baseui 10.12.1 → 11.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/accordion/accordion.js +60 -13
- package/accordion/accordion.js.flow +49 -12
- package/accordion/index.d.ts +0 -3
- package/accordion/panel.js +7 -6
- package/accordion/panel.js.flow +20 -20
- package/accordion/stateless-accordion.js +2 -4
- package/accordion/stateless-accordion.js.flow +0 -2
- package/accordion/types.js.flow +0 -5
- package/button/constants.js +1 -2
- package/button/constants.js.flow +0 -1
- package/button/index.d.ts +0 -1
- package/button/styled-components.js +2 -29
- package/button/styled-components.js.flow +2 -30
- package/checkbox/checkbox.js +6 -30
- package/checkbox/checkbox.js.flow +7 -38
- package/checkbox/constants.js +2 -1
- package/checkbox/constants.js.flow +2 -1
- package/checkbox/index.d.ts +4 -6
- package/checkbox/index.js +0 -6
- package/checkbox/index.js.flow +0 -1
- package/checkbox/styled-components.js +52 -149
- package/checkbox/styled-components.js.flow +59 -165
- package/checkbox/types.js.flow +0 -5
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +1 -1
- package/data-table/column-datetime.js +1 -1
- package/data-table/column-datetime.js.flow +3 -1
- package/data-table/column.js +6 -2
- package/data-table/column.js.flow +9 -7
- package/data-table/data-table.js +10 -2
- package/data-table/data-table.js.flow +4 -1
- package/data-table/header-cell.js +3 -0
- package/data-table/header-cell.js.flow +1 -1
- package/data-table/index.d.ts +7 -8
- package/data-table/stateful-data-table.js +2 -1
- package/data-table/stateful-data-table.js.flow +1 -0
- package/data-table/types.js.flow +8 -0
- package/datepicker/calendar.js +28 -15
- package/datepicker/calendar.js.flow +31 -14
- package/datepicker/constants.js +12 -2
- package/datepicker/constants.js.flow +10 -0
- package/datepicker/datepicker.js +117 -86
- package/datepicker/datepicker.js.flow +123 -66
- package/datepicker/day.js +85 -34
- package/datepicker/day.js.flow +118 -54
- package/datepicker/locale.js.flow +0 -1
- package/datepicker/month.js +3 -1
- package/datepicker/month.js.flow +2 -0
- package/datepicker/stateful-calendar.js +6 -1
- package/datepicker/stateful-calendar.js.flow +8 -1
- package/datepicker/stateful-container.js +23 -2
- package/datepicker/stateful-container.js.flow +17 -3
- package/datepicker/stateful-datepicker.js +6 -1
- package/datepicker/stateful-datepicker.js.flow +7 -1
- package/datepicker/styled-components.js +23 -1
- package/datepicker/styled-components.js.flow +12 -2
- package/datepicker/types.js.flow +46 -43
- package/datepicker/utils/date-helpers.js +30 -0
- package/datepicker/utils/date-helpers.js.flow +12 -0
- package/datepicker/week.js +3 -1
- package/datepicker/week.js.flow +2 -0
- package/es/accordion/accordion.js +52 -12
- package/es/accordion/panel.js +7 -5
- package/es/accordion/stateless-accordion.js +2 -4
- package/es/button/constants.js +1 -2
- package/es/button/styled-components.js +2 -29
- package/es/checkbox/checkbox.js +7 -32
- package/es/checkbox/constants.js +2 -1
- package/es/checkbox/index.js +1 -1
- package/es/checkbox/styled-components.js +51 -146
- package/es/data-table/column-categorical.js +1 -1
- package/es/data-table/column-datetime.js +1 -1
- package/es/data-table/column.js +6 -2
- package/es/data-table/data-table.js +6 -2
- package/es/data-table/header-cell.js +3 -0
- package/es/data-table/stateful-data-table.js +2 -1
- package/es/datepicker/calendar.js +28 -15
- package/es/datepicker/constants.js +8 -0
- package/es/datepicker/datepicker.js +106 -79
- package/es/datepicker/day.js +77 -34
- package/es/datepicker/month.js +3 -1
- package/es/datepicker/stateful-calendar.js +6 -1
- package/es/datepicker/stateful-container.js +22 -2
- package/es/datepicker/stateful-datepicker.js +6 -1
- package/es/datepicker/styled-components.js +8 -2
- package/es/datepicker/types.js +1 -1
- package/es/datepicker/utils/date-helpers.js +16 -0
- package/es/datepicker/week.js +3 -1
- package/es/file-uploader/file-uploader.js +4 -4
- package/es/form-control/styled-components.js +0 -1
- package/es/header-navigation/styled-components.js +3 -3
- package/es/helpers/overrides.js +1 -2
- package/es/input/styled-components.js +4 -4
- package/es/layer/layer.js +4 -4
- package/es/list/list-item.js +5 -1
- package/es/list/menu-adapter.js +4 -0
- package/es/locale/index.js +0 -7
- package/es/menu/stateful-container.js +0 -1
- package/es/menu/styled-components.js +1 -1
- package/es/modal/index.js +1 -1
- package/es/modal/modal.js +19 -65
- package/es/modal/styled-components.js +12 -48
- package/es/phone-input/default-props.js +1 -1
- package/es/phone-input/index.js +0 -4
- package/es/phone-input/phone-input-lite.js +55 -31
- package/es/radio/radio.js +1 -7
- package/es/radio/radiogroup.js +3 -28
- package/es/radio/styled-components.js +4 -5
- package/es/rating/styled-components.js +3 -3
- package/es/select/index.js +1 -2
- package/es/select/select-component.js +20 -20
- package/es/select/styled-components.js +21 -17
- package/es/snackbar/snackbar-context.js +1 -1
- package/es/snackbar/styled-components.js +2 -2
- package/es/spinner/index.js +3 -9
- package/es/spinner/styled-components.js +2 -32
- package/es/table/filter.js +3 -3
- package/es/tag/styled-components.js +1 -1
- package/es/themes/dark-theme/color-component-tokens.js +0 -38
- package/es/themes/dark-theme/color-tokens.js +0 -2
- package/es/themes/dark-theme/create-dark-theme.js +0 -2
- package/es/themes/dark-theme/dark-theme.js +0 -2
- package/es/themes/light-theme/color-component-tokens.js +0 -38
- package/es/themes/light-theme/color-tokens.js +0 -2
- package/es/themes/light-theme/create-light-theme.js +0 -2
- package/es/themes/light-theme/light-theme.js +0 -2
- package/es/timepicker/timepicker.js +1 -8
- package/es/typography/index.js +1 -31
- package/esm/accordion/accordion.js +60 -13
- package/esm/accordion/panel.js +7 -6
- package/esm/accordion/stateless-accordion.js +2 -4
- package/esm/button/constants.js +1 -2
- package/esm/button/styled-components.js +2 -29
- package/esm/checkbox/checkbox.js +7 -30
- package/esm/checkbox/constants.js +2 -1
- package/esm/checkbox/index.js +1 -1
- package/esm/checkbox/styled-components.js +52 -147
- package/esm/data-table/column-categorical.js +1 -1
- package/esm/data-table/column-datetime.js +1 -1
- package/esm/data-table/column.js +6 -2
- package/esm/data-table/data-table.js +10 -2
- package/esm/data-table/header-cell.js +3 -0
- package/esm/data-table/stateful-data-table.js +2 -1
- package/esm/datepicker/calendar.js +28 -15
- package/esm/datepicker/constants.js +8 -0
- package/esm/datepicker/datepicker.js +116 -86
- package/esm/datepicker/day.js +84 -34
- package/esm/datepicker/month.js +3 -1
- package/esm/datepicker/stateful-calendar.js +6 -1
- package/esm/datepicker/stateful-container.js +23 -2
- package/esm/datepicker/stateful-datepicker.js +6 -1
- package/esm/datepicker/styled-components.js +24 -2
- package/esm/datepicker/types.js +1 -1
- package/esm/datepicker/utils/date-helpers.js +30 -0
- package/esm/datepicker/week.js +3 -1
- package/esm/file-uploader/file-uploader.js +4 -4
- package/esm/form-control/styled-components.js +0 -1
- package/esm/header-navigation/styled-components.js +3 -3
- package/esm/helpers/overrides.js +1 -2
- package/esm/input/styled-components.js +4 -4
- package/esm/layer/layer.js +4 -4
- package/esm/list/list-item.js +5 -1
- package/esm/list/menu-adapter.js +4 -0
- package/esm/locale/index.js +0 -7
- package/esm/menu/stateful-container.js +0 -1
- package/esm/menu/styled-components.js +1 -1
- package/esm/modal/index.js +1 -1
- package/esm/modal/modal.js +28 -71
- package/esm/modal/styled-components.js +6 -38
- package/esm/phone-input/default-props.js +1 -1
- package/esm/phone-input/index.js +0 -4
- package/esm/phone-input/phone-input-lite.js +60 -37
- package/esm/radio/radio.js +1 -7
- package/esm/radio/radiogroup.js +3 -28
- package/esm/radio/styled-components.js +4 -5
- package/esm/rating/styled-components.js +3 -3
- package/esm/select/index.js +1 -2
- package/esm/select/select-component.js +20 -20
- package/esm/select/styled-components.js +21 -14
- package/esm/snackbar/snackbar-context.js +1 -1
- package/esm/snackbar/styled-components.js +2 -2
- package/esm/spinner/index.js +3 -9
- package/esm/spinner/styled-components.js +2 -40
- package/esm/table/filter.js +3 -3
- package/esm/tag/styled-components.js +1 -1
- package/esm/themes/dark-theme/color-component-tokens.js +0 -38
- package/esm/themes/dark-theme/color-tokens.js +0 -2
- package/esm/themes/dark-theme/create-dark-theme.js +1 -2
- package/esm/themes/dark-theme/dark-theme.js +1 -2
- package/esm/themes/light-theme/color-component-tokens.js +0 -38
- package/esm/themes/light-theme/color-tokens.js +0 -2
- package/esm/themes/light-theme/create-light-theme.js +1 -2
- package/esm/themes/light-theme/light-theme.js +1 -2
- package/esm/timepicker/timepicker.js +1 -8
- package/esm/typography/index.js +1 -35
- package/file-uploader/file-uploader.js +3 -3
- package/file-uploader/file-uploader.js.flow +4 -4
- package/form-control/index.d.ts +9 -0
- package/form-control/styled-components.js +0 -1
- package/form-control/styled-components.js.flow +0 -1
- package/header-navigation/styled-components.js +3 -3
- package/header-navigation/styled-components.js.flow +3 -3
- package/helpers/overrides.js +1 -2
- package/helpers/overrides.js.flow +1 -1
- package/input/index.d.ts +5 -9
- package/input/styled-components.js +4 -4
- package/input/styled-components.js.flow +4 -4
- package/layer/layer.js +4 -4
- package/layer/layer.js.flow +4 -3
- package/list/list-item.js +5 -1
- package/list/list-item.js.flow +4 -0
- package/list/menu-adapter.js +4 -0
- package/list/menu-adapter.js.flow +4 -0
- package/list/types.js.flow +4 -0
- package/locale/index.js +0 -7
- package/locale/index.js.flow +0 -7
- package/locale.ts +0 -1
- package/menu/index.d.ts +1 -3
- package/menu/stateful-container.js +0 -1
- package/menu/stateful-container.js.flow +0 -1
- package/menu/styled-components.js +1 -1
- package/menu/styled-components.js.flow +1 -1
- package/modal/index.d.ts +4 -6
- package/modal/index.js +0 -6
- package/modal/index.js.flow +0 -1
- package/modal/modal.js +27 -70
- package/modal/modal.js.flow +17 -83
- package/modal/styled-components.js +7 -40
- package/modal/styled-components.js.flow +12 -44
- package/modal/types.js.flow +1 -10
- package/package.json +3 -2
- package/phone-input/default-props.js +1 -1
- package/phone-input/default-props.js.flow +1 -1
- package/phone-input/index.d.ts +0 -1
- package/phone-input/index.js +0 -36
- package/phone-input/index.js.flow +0 -4
- package/phone-input/phone-input-lite.js +63 -38
- package/phone-input/phone-input-lite.js.flow +66 -44
- package/radio/index.d.ts +4 -9
- package/radio/radio.js +1 -7
- package/radio/radio.js.flow +1 -8
- package/radio/radiogroup.js +3 -28
- package/radio/radiogroup.js.flow +2 -26
- package/radio/styled-components.js +4 -5
- package/radio/styled-components.js.flow +3 -4
- package/radio/types.js.flow +4 -15
- package/rating/styled-components.js +3 -3
- package/rating/styled-components.js.flow +3 -3
- package/select/index.d.ts +0 -2
- package/select/index.js +0 -6
- package/select/index.js.flow +0 -2
- package/select/select-component.js +23 -24
- package/select/select-component.js.flow +25 -14
- package/select/styled-components.js +23 -17
- package/select/styled-components.js.flow +17 -12
- package/snackbar/snackbar-context.js +1 -1
- package/snackbar/snackbar-context.js.flow +1 -1
- package/snackbar/styled-components.js +1 -1
- package/snackbar/styled-components.js.flow +11 -11
- package/spinner/index.d.ts +5 -18
- package/spinner/index.js +2 -68
- package/spinner/index.js.flow +2 -27
- package/spinner/styled-components.js +9 -45
- package/spinner/styled-components.js.flow +2 -34
- package/spinner/types.js.flow +1 -19
- package/styles/types.js.flow +0 -2
- package/table/filter.js +3 -3
- package/table/filter.js.flow +3 -3
- package/tag/styled-components.js +1 -1
- package/tag/styled-components.js.flow +1 -1
- package/tag/types.js.flow +1 -1
- package/theme.ts +0 -81
- package/themes/dark-theme/color-component-tokens.js +0 -38
- package/themes/dark-theme/color-component-tokens.js.flow +0 -42
- package/themes/dark-theme/color-tokens.js +0 -2
- package/themes/dark-theme/color-tokens.js.flow +0 -2
- package/themes/dark-theme/create-dark-theme.js +1 -3
- package/themes/dark-theme/create-dark-theme.js.flow +0 -2
- package/themes/dark-theme/dark-theme.js +1 -3
- package/themes/dark-theme/dark-theme.js.flow +0 -2
- package/themes/light-theme/color-component-tokens.js +0 -38
- package/themes/light-theme/color-component-tokens.js.flow +0 -43
- package/themes/light-theme/color-tokens.js +0 -2
- package/themes/light-theme/color-tokens.js.flow +0 -2
- package/themes/light-theme/create-light-theme.js +1 -3
- package/themes/light-theme/create-light-theme.js.flow +0 -2
- package/themes/light-theme/light-theme.js +1 -3
- package/themes/light-theme/light-theme.js.flow +0 -2
- package/themes/types.js.flow +0 -68
- package/timepicker/timepicker.js +1 -8
- package/timepicker/timepicker.js.flow +4 -10
- package/typography/index.d.ts +0 -23
- package/typography/index.js +2 -57
- package/typography/index.js.flow +0 -31
- package/es/spinner/spinner.js +0 -68
- package/es/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -35
- package/es/themes/light-theme/color-deprecated-semantic-tokens.js +0 -35
- package/esm/spinner/spinner.js +0 -125
- package/esm/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -38
- package/esm/themes/light-theme/color-deprecated-semantic-tokens.js +0 -38
- package/spinner/spinner.js +0 -136
- package/spinner/spinner.js.flow +0 -75
- package/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/dark-theme/color-deprecated-semantic-tokens.js.flow +0 -42
- package/themes/light-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/light-theme/color-deprecated-semantic-tokens.js.flow +0 -42
|
@@ -134,7 +134,7 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
134
134
|
return monthDelta >= 0 && monthDelta < (this.props.monthsShown || 1);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
getSingleDate(value: ?T |
|
|
137
|
+
getSingleDate(value: ?T | $ReadOnlyArray<?T>): ?T {
|
|
138
138
|
// need to check this.props.range but flow would complain
|
|
139
139
|
// at the return value in the else clause
|
|
140
140
|
if (Array.isArray(value)) {
|
|
@@ -337,23 +337,38 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
337
337
|
this.props.onDayMouseLeave && this.props.onDayMouseLeave(data);
|
|
338
338
|
};
|
|
339
339
|
|
|
340
|
-
|
|
340
|
+
/** Responsible for merging time values into date values. Note: the 'Day' component
|
|
341
|
+
* determines how the days themselves change when a new day is selected. */
|
|
342
|
+
handleDateChange: ({ +date: ?T | Array<?T> }) => void = (data) => {
|
|
341
343
|
const { onChange = (params) => {} } = this.props;
|
|
342
344
|
let updatedDate = data.date;
|
|
343
|
-
// We'll need to update the date in time values of internal state
|
|
344
|
-
const newTimeState = [...this.state.time];
|
|
345
345
|
// Apply the currently selected time values (saved in state) to the updated date
|
|
346
346
|
if (Array.isArray(data.date)) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
347
|
+
// We'll need to update the date in time values of internal state
|
|
348
|
+
const newTimeState = [...this.state.time];
|
|
349
|
+
const start = data.date[0]
|
|
350
|
+
? this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0])
|
|
351
|
+
: null;
|
|
352
|
+
const end = data.date[1]
|
|
353
|
+
? this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1])
|
|
354
|
+
: null;
|
|
355
|
+
newTimeState[0] = start;
|
|
356
|
+
if (end) {
|
|
357
|
+
updatedDate = [start, end];
|
|
358
|
+
newTimeState[1] = end;
|
|
359
|
+
} else {
|
|
360
|
+
updatedDate = [start];
|
|
361
|
+
}
|
|
362
|
+
// Update the date in time values of internal state
|
|
363
|
+
this.setState({ time: newTimeState });
|
|
351
364
|
} else if (!Array.isArray(this.props.value) && data.date) {
|
|
352
|
-
newTimeState
|
|
353
|
-
updatedDate = newTimeState
|
|
365
|
+
const newTimeState = this.dateHelpers.applyDateToTime(this.state.time[0], data.date);
|
|
366
|
+
updatedDate = newTimeState;
|
|
367
|
+
|
|
368
|
+
// Update the date in time values of internal state
|
|
369
|
+
this.setState({ time: [newTimeState] });
|
|
354
370
|
}
|
|
355
|
-
|
|
356
|
-
this.setState({ time: newTimeState });
|
|
371
|
+
|
|
357
372
|
onChange({ date: updatedDate });
|
|
358
373
|
};
|
|
359
374
|
|
|
@@ -367,12 +382,12 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
367
382
|
// with the date value set to the date with updated time
|
|
368
383
|
if (Array.isArray(this.props.value)) {
|
|
369
384
|
const dates = this.props.value.map((date, i) => {
|
|
370
|
-
if (index === i) {
|
|
385
|
+
if (date && index === i) {
|
|
371
386
|
return this.dateHelpers.applyTimeToDate(date, time);
|
|
372
387
|
}
|
|
373
388
|
return date;
|
|
374
389
|
});
|
|
375
|
-
onChange({ date: dates });
|
|
390
|
+
onChange({ date: [dates[0], dates[1]] });
|
|
376
391
|
} else {
|
|
377
392
|
const date = this.dateHelpers.applyTimeToDate(this.props.value, time);
|
|
378
393
|
onChange({ date });
|
|
@@ -452,6 +467,8 @@ export default class Calendar<T = Date> extends React.Component<
|
|
|
452
467
|
value={this.props.value}
|
|
453
468
|
peekNextMonth={this.props.peekNextMonth}
|
|
454
469
|
fixedHeight={this.props.fixedHeight}
|
|
470
|
+
hasLockedBehavior={!!this.props.hasLockedBehavior}
|
|
471
|
+
selectedInput={this.props.selectedInput}
|
|
455
472
|
/>
|
|
456
473
|
</CalendarContainer>
|
|
457
474
|
);
|
package/datepicker/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
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;
|
|
6
|
+
exports.RANGED_CALENDAR_BEHAVIOR = exports.INPUT_ROLE = 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.
|
|
@@ -40,4 +40,14 @@ var DENSITY = {
|
|
|
40
40
|
high: 'high',
|
|
41
41
|
default: 'default'
|
|
42
42
|
};
|
|
43
|
-
exports.DENSITY = DENSITY;
|
|
43
|
+
exports.DENSITY = DENSITY;
|
|
44
|
+
var INPUT_ROLE = {
|
|
45
|
+
startDate: 'startDate',
|
|
46
|
+
endDate: 'endDate'
|
|
47
|
+
};
|
|
48
|
+
exports.INPUT_ROLE = INPUT_ROLE;
|
|
49
|
+
var RANGED_CALENDAR_BEHAVIOR = {
|
|
50
|
+
default: 'default',
|
|
51
|
+
locked: 'locked'
|
|
52
|
+
};
|
|
53
|
+
exports.RANGED_CALENDAR_BEHAVIOR = RANGED_CALENDAR_BEHAVIOR;
|
|
@@ -33,6 +33,16 @@ export const DENSITY = {
|
|
|
33
33
|
default: 'default',
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
export const INPUT_ROLE = {
|
|
37
|
+
startDate: 'startDate',
|
|
38
|
+
endDate: 'endDate',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const RANGED_CALENDAR_BEHAVIOR = {
|
|
42
|
+
default: 'default',
|
|
43
|
+
locked: 'locked',
|
|
44
|
+
};
|
|
45
|
+
|
|
36
46
|
declare var __DEV__: boolean;
|
|
37
47
|
declare var __NODE__: boolean;
|
|
38
48
|
declare var __BROWSER__: boolean;
|
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; }
|
|
@@ -35,6 +37,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
35
37
|
|
|
36
38
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
37
39
|
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
+
|
|
42
|
+
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; }
|
|
43
|
+
|
|
38
44
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
39
45
|
|
|
40
46
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -43,10 +49,6 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.it
|
|
|
43
49
|
|
|
44
50
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
45
51
|
|
|
46
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
47
|
-
|
|
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
|
-
|
|
50
52
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
51
53
|
|
|
52
54
|
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); } }
|
|
@@ -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,31 +120,72 @@ 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
|
|
|
125
127
|
_defineProperty(_assertThisInitialized(_this), "dateHelpers", void 0);
|
|
126
128
|
|
|
127
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
129
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function (date) {
|
|
130
|
+
var onChange = _this.props.onChange;
|
|
131
|
+
var onRangeChange = _this.props.onRangeChange;
|
|
132
|
+
|
|
133
|
+
if (Array.isArray(date)) {
|
|
134
|
+
if (onChange && date.every(Boolean)) {
|
|
135
|
+
// flowlint-next-line unclear-type:off
|
|
136
|
+
onChange({
|
|
137
|
+
date: date
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (onRangeChange) {
|
|
142
|
+
onRangeChange({
|
|
143
|
+
date: _toConsumableArray(date)
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
if (onChange) {
|
|
148
|
+
onChange({
|
|
149
|
+
date: date
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (onRangeChange) {
|
|
154
|
+
onRangeChange({
|
|
155
|
+
date: date
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
_defineProperty(_assertThisInitialized(_this), "onCalendarSelect", function (data) {
|
|
128
162
|
var isOpen = false;
|
|
129
163
|
var isPseudoFocused = false;
|
|
130
164
|
var calendarFocused = false;
|
|
131
165
|
var nextDate = data.date;
|
|
132
166
|
|
|
133
167
|
if (Array.isArray(nextDate) && _this.props.range) {
|
|
134
|
-
if (nextDate
|
|
168
|
+
if (!nextDate[0] || !nextDate[1]) {
|
|
135
169
|
isOpen = true;
|
|
136
170
|
isPseudoFocused = true;
|
|
137
171
|
calendarFocused = null;
|
|
138
|
-
} else if (nextDate
|
|
172
|
+
} else if (nextDate[0] && nextDate[1]) {
|
|
139
173
|
var _nextDate = nextDate,
|
|
140
174
|
_nextDate2 = _slicedToArray(_nextDate, 2),
|
|
141
175
|
start = _nextDate2[0],
|
|
142
176
|
end = _nextDate2[1];
|
|
143
177
|
|
|
144
178
|
if (_this.dateHelpers.isAfter(start, end)) {
|
|
145
|
-
|
|
179
|
+
if (_this.hasLockedBehavior()) {
|
|
180
|
+
nextDate = _this.props.value;
|
|
181
|
+
isOpen = true;
|
|
182
|
+
} else {
|
|
183
|
+
nextDate = [start, start];
|
|
184
|
+
}
|
|
185
|
+
} 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]
|
|
186
|
+
nextDate, _this.props.excludeDates)) {
|
|
187
|
+
nextDate = _this.props.value;
|
|
188
|
+
isOpen = true;
|
|
146
189
|
}
|
|
147
190
|
|
|
148
191
|
if (_this.state.lastActiveElm) {
|
|
@@ -192,9 +235,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
192
235
|
inputValue: _this.formatDisplayValue(nextDate)
|
|
193
236
|
}));
|
|
194
237
|
|
|
195
|
-
_this.
|
|
196
|
-
date: nextDate
|
|
197
|
-
});
|
|
238
|
+
_this.handleChange(nextDate);
|
|
198
239
|
});
|
|
199
240
|
|
|
200
241
|
_defineProperty(_assertThisInitialized(_this), "formatDisplayValue", function (date) {
|
|
@@ -234,11 +275,12 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
234
275
|
return _this.formatDate(date, formatString);
|
|
235
276
|
});
|
|
236
277
|
|
|
237
|
-
_defineProperty(_assertThisInitialized(_this), "open", function () {
|
|
278
|
+
_defineProperty(_assertThisInitialized(_this), "open", function (inputRole) {
|
|
238
279
|
_this.setState({
|
|
239
280
|
isOpen: true,
|
|
240
281
|
isPseudoFocused: true,
|
|
241
|
-
calendarFocused: false
|
|
282
|
+
calendarFocused: false,
|
|
283
|
+
selectedInput: inputRole
|
|
242
284
|
}, _this.props.onOpen);
|
|
243
285
|
});
|
|
244
286
|
|
|
@@ -247,6 +289,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
247
289
|
|
|
248
290
|
_this.setState({
|
|
249
291
|
isOpen: false,
|
|
292
|
+
selectedInput: null,
|
|
250
293
|
isPseudoFocused: isPseudoFocused,
|
|
251
294
|
calendarFocused: false
|
|
252
295
|
}, _this.props.onClose);
|
|
@@ -282,30 +325,24 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
282
325
|
}
|
|
283
326
|
|
|
284
327
|
if (range && !separateRangeInputs) {
|
|
285
|
-
return
|
|
328
|
+
return "9999/99/99 ".concat(INPUT_DELIMITER, " 9999/99/99");
|
|
286
329
|
}
|
|
287
330
|
|
|
288
331
|
return '9999/99/99';
|
|
289
332
|
});
|
|
290
333
|
|
|
291
|
-
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event,
|
|
292
|
-
var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue,
|
|
334
|
+
_defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event, inputRole) {
|
|
335
|
+
var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue, inputRole) : event.currentTarget.value;
|
|
293
336
|
|
|
294
337
|
var mask = _this.getMask();
|
|
295
338
|
|
|
296
339
|
var formatString = _this.normalizeDashes(_this.props.formatString);
|
|
297
340
|
|
|
298
341
|
if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
|
|
299
|
-
if (_this.props.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
});
|
|
304
|
-
} else {
|
|
305
|
-
_this.props.onChange({
|
|
306
|
-
date: null
|
|
307
|
-
});
|
|
308
|
-
}
|
|
342
|
+
if (_this.props.range) {
|
|
343
|
+
_this.handleChange([]);
|
|
344
|
+
} else {
|
|
345
|
+
_this.handleChange(null);
|
|
309
346
|
}
|
|
310
347
|
}
|
|
311
348
|
|
|
@@ -322,7 +359,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
322
359
|
};
|
|
323
360
|
|
|
324
361
|
if (_this.props.range && typeof _this.props.displayValueAtRangeIndex !== 'number') {
|
|
325
|
-
var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(INPUT_DELIMITER),
|
|
362
|
+
var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(" ".concat(INPUT_DELIMITER, " ")),
|
|
326
363
|
_this$normalizeDashes2 = _slicedToArray(_this$normalizeDashes, 2),
|
|
327
364
|
left = _this$normalizeDashes2[0],
|
|
328
365
|
right = _this$normalizeDashes2[1];
|
|
@@ -336,19 +373,13 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
336
373
|
endDate = parseDateString(right);
|
|
337
374
|
}
|
|
338
375
|
|
|
339
|
-
var
|
|
340
|
-
|
|
341
|
-
if (onChange) {
|
|
342
|
-
var datesValid = _this.dateHelpers.isValid(startDate) && _this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
|
|
376
|
+
var datesValid = _this.dateHelpers.isValid(startDate) && _this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
|
|
343
377
|
|
|
344
378
|
|
|
345
|
-
|
|
379
|
+
var rangeValid = _this.dateHelpers.isAfter(endDate, startDate) || _this.dateHelpers.isEqual(startDate, endDate);
|
|
346
380
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
date: [startDate, endDate]
|
|
350
|
-
});
|
|
351
|
-
}
|
|
381
|
+
if (datesValid && rangeValid) {
|
|
382
|
+
_this.handleChange([startDate, endDate]);
|
|
352
383
|
}
|
|
353
384
|
} else {
|
|
354
385
|
var dateString = _this.normalizeDashes(inputValue);
|
|
@@ -366,11 +397,10 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
366
397
|
|
|
367
398
|
var _this$props3 = _this.props,
|
|
368
399
|
displayValueAtRangeIndex = _this$props3.displayValueAtRangeIndex,
|
|
369
|
-
_onChange = _this$props3.onChange,
|
|
370
400
|
range = _this$props3.range,
|
|
371
401
|
value = _this$props3.value;
|
|
372
402
|
|
|
373
|
-
if (date && _this.dateHelpers.isValid(date)
|
|
403
|
+
if (date && _this.dateHelpers.isValid(date)) {
|
|
374
404
|
if (range && Array.isArray(value) && typeof displayValueAtRangeIndex === 'number') {
|
|
375
405
|
var _value = _slicedToArray(value, 2),
|
|
376
406
|
_left = _value[0],
|
|
@@ -380,22 +410,16 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
380
410
|
_left = date;
|
|
381
411
|
|
|
382
412
|
if (!_right) {
|
|
383
|
-
|
|
384
|
-
date: [_left]
|
|
385
|
-
});
|
|
413
|
+
_this.handleChange([_left]);
|
|
386
414
|
} else {
|
|
387
415
|
if (_this.dateHelpers.isAfter(_right, _left) || _this.dateHelpers.isEqual(_left, _right)) {
|
|
388
|
-
|
|
389
|
-
date: [_left, _right]
|
|
390
|
-
});
|
|
416
|
+
_this.handleChange([_left, _right]);
|
|
391
417
|
} else {
|
|
392
418
|
// Is resetting back to previous value appropriate? Invalid range is not
|
|
393
419
|
// communicated to the user, but if it was not reset the text value would
|
|
394
420
|
// show one value and date value another. This seems a bit better but clearly
|
|
395
421
|
// has a downside.
|
|
396
|
-
|
|
397
|
-
date: _toConsumableArray(value)
|
|
398
|
-
});
|
|
422
|
+
_this.handleChange(_toConsumableArray(value));
|
|
399
423
|
}
|
|
400
424
|
}
|
|
401
425
|
} else if (displayValueAtRangeIndex === 1) {
|
|
@@ -403,26 +427,18 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
403
427
|
|
|
404
428
|
if (!_left) {
|
|
405
429
|
// If start value is not defined, set start/end to the same day.
|
|
406
|
-
|
|
407
|
-
date: [_right, _right]
|
|
408
|
-
});
|
|
430
|
+
_this.handleChange([_right, _right]);
|
|
409
431
|
} else {
|
|
410
432
|
if (_this.dateHelpers.isAfter(_right, _left) || _this.dateHelpers.isEqual(_left, _right)) {
|
|
411
|
-
|
|
412
|
-
date: [_left, _right]
|
|
413
|
-
});
|
|
433
|
+
_this.handleChange([_left, _right]);
|
|
414
434
|
} else {
|
|
415
435
|
// See comment above about resetting dates on invalid range
|
|
416
|
-
|
|
417
|
-
date: _toConsumableArray(value)
|
|
418
|
-
});
|
|
436
|
+
_this.handleChange(_toConsumableArray(value));
|
|
419
437
|
}
|
|
420
438
|
}
|
|
421
439
|
}
|
|
422
440
|
} else {
|
|
423
|
-
|
|
424
|
-
date: date
|
|
425
|
-
});
|
|
441
|
+
_this.handleChange(date);
|
|
426
442
|
}
|
|
427
443
|
}
|
|
428
444
|
}
|
|
@@ -454,13 +470,18 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
454
470
|
|
|
455
471
|
_defineProperty(_assertThisInitialized(_this), "normalizeDashes", function (inputValue) {
|
|
456
472
|
// replacing both hyphens and em-dashes with en-dashes
|
|
457
|
-
return inputValue.replace(/-/g,
|
|
473
|
+
return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
_defineProperty(_assertThisInitialized(_this), "hasLockedBehavior", function () {
|
|
477
|
+
return _this.props.rangedCalendarBehavior === _constants.RANGED_CALENDAR_BEHAVIOR.locked && _this.props.range && _this.props.separateRangeInputs;
|
|
458
478
|
});
|
|
459
479
|
|
|
460
480
|
_this.dateHelpers = new _dateHelpers.default(props.adapter);
|
|
461
481
|
_this.state = {
|
|
462
482
|
calendarFocused: false,
|
|
463
483
|
isOpen: false,
|
|
484
|
+
selectedInput: null,
|
|
464
485
|
isPseudoFocused: false,
|
|
465
486
|
lastActiveElm: null,
|
|
466
487
|
inputValue: _this.formatDisplayValue(props.value) || ''
|
|
@@ -469,6 +490,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
469
490
|
}
|
|
470
491
|
|
|
471
492
|
_createClass(Datepicker, [{
|
|
493
|
+
key: "getNullDatePlaceholder",
|
|
494
|
+
value: function getNullDatePlaceholder(formatString) {
|
|
495
|
+
return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
|
|
496
|
+
}
|
|
497
|
+
}, {
|
|
472
498
|
key: "formatDate",
|
|
473
499
|
value: function formatDate(date, formatString) {
|
|
474
500
|
var _this2 = this;
|
|
@@ -485,10 +511,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
485
511
|
return '';
|
|
486
512
|
} else if (Array.isArray(date) && !date[0] && !date[1]) {
|
|
487
513
|
return '';
|
|
514
|
+
} else if (Array.isArray(date) && !date[0] && date[1]) {
|
|
515
|
+
var endDate = format(date[1]);
|
|
516
|
+
var startDate = this.getNullDatePlaceholder(formatString);
|
|
517
|
+
return [startDate, endDate].join(" ".concat(INPUT_DELIMITER, " "));
|
|
488
518
|
} else if (Array.isArray(date)) {
|
|
489
519
|
return date.map(function (day) {
|
|
490
|
-
return format(day);
|
|
491
|
-
}).join(INPUT_DELIMITER);
|
|
520
|
+
return day ? format(day) : '';
|
|
521
|
+
}).join(" ".concat(INPUT_DELIMITER, " "));
|
|
492
522
|
} else {
|
|
493
523
|
return format(date);
|
|
494
524
|
}
|
|
@@ -504,7 +534,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
504
534
|
}
|
|
505
535
|
}, {
|
|
506
536
|
key: "renderInputComponent",
|
|
507
|
-
value: function renderInputComponent(locale,
|
|
537
|
+
value: function renderInputComponent(locale, inputRole) {
|
|
508
538
|
var _this3 = this;
|
|
509
539
|
|
|
510
540
|
var _this$props$overrides = this.props.overrides,
|
|
@@ -515,21 +545,16 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
515
545
|
InputComponent = _getOverrides2[0],
|
|
516
546
|
inputProps = _getOverrides2[1];
|
|
517
547
|
|
|
518
|
-
var placeholder = this.props.placeholder || this.props.placeholder === '' ? this.props.placeholder : this.props.range && !this.props.separateRangeInputs ?
|
|
548
|
+
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
549
|
|
|
520
|
-
var _split = (this.state.inputValue || '').split(INPUT_DELIMITER),
|
|
550
|
+
var _split = (this.state.inputValue || '').split(" ".concat(INPUT_DELIMITER, " ")),
|
|
521
551
|
_split2 = _slicedToArray(_split, 2),
|
|
522
552
|
_split2$ = _split2[0],
|
|
523
553
|
startDate = _split2$ === void 0 ? '' : _split2$,
|
|
524
554
|
_split2$2 = _split2[1],
|
|
525
555
|
endDate = _split2$2 === void 0 ? '' : _split2$2;
|
|
526
556
|
|
|
527
|
-
var value =
|
|
528
|
-
|
|
529
|
-
var onChange = function onChange(event) {
|
|
530
|
-
return _this3.handleInputChange(event, separatedInput);
|
|
531
|
-
};
|
|
532
|
-
|
|
557
|
+
var value = inputRole === _constants.INPUT_ROLE.startDate ? startDate : inputRole === _constants.INPUT_ROLE.endDate ? endDate : this.state.inputValue;
|
|
533
558
|
return /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
534
559
|
"aria-disabled": this.props.disabled,
|
|
535
560
|
"aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
|
|
@@ -541,10 +566,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
|
|
|
541
566
|
disabled: this.props.disabled,
|
|
542
567
|
size: this.props.size,
|
|
543
568
|
value: value,
|
|
544
|
-
onFocus:
|
|
569
|
+
onFocus: function onFocus() {
|
|
570
|
+
return _this3.open(inputRole);
|
|
571
|
+
},
|
|
545
572
|
onBlur: this.handleInputBlur,
|
|
546
573
|
onKeyDown: this.handleKeyDown,
|
|
547
|
-
onChange: onChange
|
|
574
|
+
onChange: function onChange(event) {
|
|
575
|
+
return _this3.handleInputChange(event, inputRole);
|
|
576
|
+
},
|
|
548
577
|
placeholder: placeholder,
|
|
549
578
|
mask: this.getMask(),
|
|
550
579
|
required: this.props.required,
|
|
@@ -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.
|
|
636
|
+
onChange: _this4.onCalendarSelect,
|
|
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])
|