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/types.js.flow
CHANGED
|
@@ -9,7 +9,7 @@ LICENSE file in the root directory of this source tree.
|
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import type {OverrideT} from '../helpers/overrides.js';
|
|
11
11
|
import type {SizeT} from '../input/types.js';
|
|
12
|
-
import {ORIENTATION, STATE_CHANGE_TYPE} from './constants.js';
|
|
12
|
+
import {ORIENTATION, STATE_CHANGE_TYPE, DENSITY} from './constants.js';
|
|
13
13
|
import type {DateIOAdapter} from './utils/types.js';
|
|
14
14
|
import type {
|
|
15
15
|
TimePickerPropsT as TimePickerPropsTBase,
|
|
@@ -23,6 +23,8 @@ type LocaleT = any; // see https://github.com/date-fns/date-fns/blob/master/src/
|
|
|
23
23
|
|
|
24
24
|
type onChangeT<T> = ({date: ?T | Array<T>}) => mixed;
|
|
25
25
|
|
|
26
|
+
export type DensityT = $Keys<typeof DENSITY>;
|
|
27
|
+
|
|
26
28
|
export type DatepickerOverridesT = {
|
|
27
29
|
Root?: OverrideT,
|
|
28
30
|
/** Override for reused Select component. QuickSelect is **not a styled element** but a react component that can be replaced */
|
|
@@ -57,12 +59,16 @@ export type DatepickerOverridesT = {
|
|
|
57
59
|
InputWrapper?: OverrideT,
|
|
58
60
|
/** Override for reused Popover component. Popover is **not a styled element** but a react component that can be replaced */
|
|
59
61
|
Popover?: OverrideT,
|
|
62
|
+
StartDate?: OverrideT,
|
|
63
|
+
EndDate?: OverrideT,
|
|
64
|
+
InputLabel?: OverrideT,
|
|
60
65
|
};
|
|
61
66
|
|
|
62
67
|
export type DayPropsT<T = Date> = {
|
|
63
68
|
disabled: boolean,
|
|
64
69
|
date: T,
|
|
65
70
|
dateLabel: ?(day: T) => React.Node,
|
|
71
|
+
density: DensityT,
|
|
66
72
|
filterDate: ?(day: T) => boolean,
|
|
67
73
|
highlightedDate: ?T,
|
|
68
74
|
includeDates: ?Array<T>,
|
|
@@ -93,6 +99,7 @@ export type DayStateT = {
|
|
|
93
99
|
export type WeekPropsT<T = Date> = {
|
|
94
100
|
date: T,
|
|
95
101
|
dateLabel: ?(date: T) => React.Node,
|
|
102
|
+
density: DensityT,
|
|
96
103
|
excludeDates: ?Array<T>,
|
|
97
104
|
filterDate: ?(day: T) => boolean,
|
|
98
105
|
// highlighted while keyboard navigating or hovered
|
|
@@ -132,6 +139,8 @@ export type CalendarInternalState<T = Date> = {
|
|
|
132
139
|
export type CalendarPropsT<T = Date> = {
|
|
133
140
|
/** Defines if the calendar is set to be focused on an initial render. */
|
|
134
141
|
autoFocusCalendar?: boolean,
|
|
142
|
+
/** Determines the density of the calendar */
|
|
143
|
+
density?: DensityT,
|
|
135
144
|
/** A list of dates to disable. */
|
|
136
145
|
excludeDates?: ?Array<T>,
|
|
137
146
|
/** Display select for quickly choosing date ranges. `range` must be true as well. */
|
|
@@ -219,13 +228,20 @@ export type DatepickerPropsT<T = Date> = CalendarPropsT<T> & {
|
|
|
219
228
|
mountNode?: HTMLElement,
|
|
220
229
|
/** Called when calendar is closed */
|
|
221
230
|
onClose?: () => mixed,
|
|
231
|
+
/** Called when calendar is opened */
|
|
232
|
+
onOpen?: () => mixed,
|
|
222
233
|
mask?: string | null,
|
|
234
|
+
/** Determines if startDate and endDate should be separated into two input fields. Ignored if `range` is not true. */
|
|
235
|
+
separateRangeInputs?: boolean,
|
|
236
|
+
startDateLabel?: string,
|
|
237
|
+
endDateLabel?: string,
|
|
223
238
|
};
|
|
224
239
|
|
|
225
240
|
export type SharedStylePropsT = {
|
|
226
241
|
// eslint-disable-next-line flowtype/no-weak-types
|
|
227
242
|
$date: any,
|
|
228
243
|
$disabled: ?boolean,
|
|
244
|
+
$density: DensityT,
|
|
229
245
|
$endDate: ?boolean,
|
|
230
246
|
$endOfMonth: ?boolean,
|
|
231
247
|
$isHighlighted: ?boolean,
|
package/datepicker/week.js
CHANGED
|
@@ -92,6 +92,7 @@ var Week = /*#__PURE__*/function (_React$Component) {
|
|
|
92
92
|
adapter: _this.props.adapter,
|
|
93
93
|
date: day,
|
|
94
94
|
dateLabel: _this.props.dateLabel,
|
|
95
|
+
density: _this.props.density,
|
|
95
96
|
disabled: _this.dateHelpers.isDayDisabled(day, _this.props),
|
|
96
97
|
excludeDates: _this.props.excludeDates,
|
|
97
98
|
filterDate: _this.props.filterDate,
|
package/datepicker/week.js.flow
CHANGED
|
@@ -52,6 +52,7 @@ export default class Week<T = Date> extends React.Component<WeekPropsT<T>> {
|
|
|
52
52
|
adapter={this.props.adapter}
|
|
53
53
|
date={day}
|
|
54
54
|
dateLabel={this.props.dateLabel}
|
|
55
|
+
density={this.props.density}
|
|
55
56
|
disabled={this.dateHelpers.isDayDisabled(day, this.props)}
|
|
56
57
|
excludeDates={this.props.excludeDates}
|
|
57
58
|
filterDate={this.props.filterDate}
|
package/dnd-list/list.js
CHANGED
|
@@ -220,8 +220,7 @@ var StatelessList = /*#__PURE__*/function (_React$Component) {
|
|
|
220
220
|
display: 'flex'
|
|
221
221
|
})
|
|
222
222
|
}), /*#__PURE__*/React.createElement(DragHandle, _extends({}, sharedProps, dragHandleProps), /*#__PURE__*/React.createElement(_grab.default, {
|
|
223
|
-
size: 24
|
|
224
|
-
color: "#CCC"
|
|
223
|
+
size: 24
|
|
225
224
|
})), /*#__PURE__*/React.createElement(Label, _extends({}, sharedProps, labelProps), value), removable && /*#__PURE__*/React.createElement(CloseHandle, _extends({}, sharedProps, {
|
|
226
225
|
onClick: function onClick(evt) {
|
|
227
226
|
evt.preventDefault();
|
package/dnd-list/list.js.flow
CHANGED
|
@@ -136,7 +136,7 @@ class StatelessList extends React.Component<
|
|
|
136
136
|
style={{...props.style, display: 'flex'}}
|
|
137
137
|
>
|
|
138
138
|
<DragHandle {...sharedProps} {...dragHandleProps}>
|
|
139
|
-
<Grab size={24}
|
|
139
|
+
<Grab size={24} />
|
|
140
140
|
</DragHandle>
|
|
141
141
|
<Label {...sharedProps} {...labelProps}>
|
|
142
142
|
{value}
|
|
@@ -94,7 +94,7 @@ var DragHandle = (0, _index.styled)('div', function (_ref4) {
|
|
|
94
94
|
|
|
95
95
|
var $theme = _ref4.$theme;
|
|
96
96
|
var marginDir = $theme.direction === 'rtl' ? 'marginLeft' : 'marginRight';
|
|
97
|
-
return _ref5 = {}, _defineProperty(_ref5, marginDir, $theme.sizing.scale600), _defineProperty(_ref5, "width", $theme.sizing.scale800), _defineProperty(_ref5, "display", 'flex'), _defineProperty(_ref5, "alignItems", 'center'), _ref5;
|
|
97
|
+
return _ref5 = {}, _defineProperty(_ref5, marginDir, $theme.sizing.scale600), _defineProperty(_ref5, "width", $theme.sizing.scale800), _defineProperty(_ref5, "color", '#CCC'), _defineProperty(_ref5, "display", 'flex'), _defineProperty(_ref5, "alignItems", 'center'), _ref5;
|
|
98
98
|
});
|
|
99
99
|
exports.DragHandle = DragHandle;
|
|
100
100
|
DragHandle.displayName = "DragHandle";
|
package/es/combobox/combobox.js
CHANGED
|
@@ -235,7 +235,11 @@ function Combobox(props) {
|
|
|
235
235
|
return /*#__PURE__*/React.createElement(Root // eslint-disable-next-line flowtype/no-weak-types
|
|
236
236
|
, _extends({
|
|
237
237
|
ref: rootRef
|
|
238
|
-
}, rootProps), /*#__PURE__*/React.createElement(OverriddenPopover,
|
|
238
|
+
}, rootProps), /*#__PURE__*/React.createElement(OverriddenPopover // React-focus-lock used in Popover used to skip non-tabbable elements (`tabIndex=-1`) elements for focus, we had ListBox with tabIndex to disable focus on
|
|
239
|
+
// the ListBox, but we can just disable autoFocus (as ListBox / ListItem should not be focusable) (and input is also not autoFocused).
|
|
240
|
+
// Select Component does the same thing
|
|
241
|
+
, _extends({
|
|
242
|
+
autoFocus: false,
|
|
239
243
|
isOpen: isOpen,
|
|
240
244
|
overrides: popoverOverrides,
|
|
241
245
|
placement: PLACEMENT.bottomLeft,
|
|
@@ -29,6 +29,7 @@ import { COLUMNS, DATETIME_OPERATIONS } from './constants.js';
|
|
|
29
29
|
import FilterShell from './filter-shell.js';
|
|
30
30
|
import { LocaleContext } from '../locale/index.js';
|
|
31
31
|
const DATE_FORMAT = 'MM-dd-yyyy';
|
|
32
|
+
const MASK = '99-99-9999 - 99-99-9999';
|
|
32
33
|
const TIME_FORMAT = 'HH:mm ss:SS';
|
|
33
34
|
const FORMAT_STRING = `${DATE_FORMAT} ${TIME_FORMAT}`;
|
|
34
35
|
|
|
@@ -326,6 +327,7 @@ function DatetimeFilter(props) {
|
|
|
326
327
|
}
|
|
327
328
|
},
|
|
328
329
|
formatString: DATE_FORMAT,
|
|
330
|
+
mask: MASK,
|
|
329
331
|
placeholder: "MM-DD-YYYY - MM-DD-YYYY",
|
|
330
332
|
minDate: datesSorted[0],
|
|
331
333
|
maxDate: datesSorted[datesSorted.length - 1],
|
|
@@ -20,7 +20,7 @@ import { Popover } from '../popover/index.js';
|
|
|
20
20
|
import { LocaleContext } from '../locale/index.js';
|
|
21
21
|
import { ThemeContext } from '../styles/theme-provider.js';
|
|
22
22
|
import { StyledCalendarHeader, StyledPrevButton, StyledNextButton, StyledMonthHeader, StyledWeekdayHeader, StyledMonthYearSelectButton, StyledMonthYearSelectIconContainer } from './styled-components.js';
|
|
23
|
-
import { ORIENTATION, WEEKDAYS } from './constants.js';
|
|
23
|
+
import { ORIENTATION, WEEKDAYS, DENSITY } from './constants.js';
|
|
24
24
|
import { getOverrides, mergeOverrides } from '../helpers/overrides.js';
|
|
25
25
|
import { isFocusVisible, forkFocus, forkBlur } from '../utils/focusVisible.js';
|
|
26
26
|
|
|
@@ -205,7 +205,8 @@ export default class CalendarHeader extends React.Component {
|
|
|
205
205
|
}) => {
|
|
206
206
|
const date = this.getDateProp();
|
|
207
207
|
const {
|
|
208
|
-
overrides = {}
|
|
208
|
+
overrides = {},
|
|
209
|
+
density
|
|
209
210
|
} = this.props;
|
|
210
211
|
const allPrevDaysDisabled = this.dateHelpers.monthDisabledBefore(date, this.props);
|
|
211
212
|
let isDisabled = false;
|
|
@@ -245,7 +246,7 @@ export default class CalendarHeader extends React.Component {
|
|
|
245
246
|
$disabled: isDisabled,
|
|
246
247
|
$order: this.props.order
|
|
247
248
|
}, prevButtonProps), isHidden ? null : /*#__PURE__*/React.createElement(PrevButtonIcon, _extends({
|
|
248
|
-
size:
|
|
249
|
+
size: density === DENSITY.high ? 24 : 36,
|
|
249
250
|
overrides: {
|
|
250
251
|
Svg: {
|
|
251
252
|
style: navBtnStyle
|
|
@@ -260,7 +261,8 @@ export default class CalendarHeader extends React.Component {
|
|
|
260
261
|
}) => {
|
|
261
262
|
const date = this.getDateProp();
|
|
262
263
|
const {
|
|
263
|
-
overrides = {}
|
|
264
|
+
overrides = {},
|
|
265
|
+
density
|
|
264
266
|
} = this.props;
|
|
265
267
|
const allNextDaysDisabled = this.dateHelpers.monthDisabledAfter(date, this.props);
|
|
266
268
|
let isDisabled = false;
|
|
@@ -304,7 +306,7 @@ export default class CalendarHeader extends React.Component {
|
|
|
304
306
|
$isFocusVisible: this.state.isFocusVisible,
|
|
305
307
|
$order: this.props.order
|
|
306
308
|
}, nextButtonProps), isHidden ? null : /*#__PURE__*/React.createElement(NextButtonIcon, _extends({
|
|
307
|
-
size:
|
|
309
|
+
size: density === DENSITY.high ? 24 : 36,
|
|
308
310
|
overrides: {
|
|
309
311
|
Svg: {
|
|
310
312
|
style: navBtnStyle
|
|
@@ -329,7 +331,8 @@ export default class CalendarHeader extends React.Component {
|
|
|
329
331
|
const year = this.dateHelpers.getYear(date);
|
|
330
332
|
const {
|
|
331
333
|
locale,
|
|
332
|
-
overrides = {}
|
|
334
|
+
overrides = {},
|
|
335
|
+
density
|
|
333
336
|
} = this.props;
|
|
334
337
|
const [MonthYearSelectButton, monthYearSelectButtonProps] = getOverrides(overrides.MonthYearSelectButton, StyledMonthYearSelectButton);
|
|
335
338
|
const [MonthYearSelectIconContainer, monthYearSelectIconContainerProps] = getOverrides(overrides.MonthYearSelectIconContainer, StyledMonthYearSelectIconContainer);
|
|
@@ -394,6 +397,7 @@ export default class CalendarHeader extends React.Component {
|
|
|
394
397
|
"aria-live": "polite",
|
|
395
398
|
type: "button",
|
|
396
399
|
$isFocusVisible: this.state.isFocusVisible,
|
|
400
|
+
$density: density,
|
|
397
401
|
onKeyUp: event => {
|
|
398
402
|
if (this.canArrowsOpenDropdown(event)) {
|
|
399
403
|
this.setState({
|
|
@@ -421,7 +425,8 @@ export default class CalendarHeader extends React.Component {
|
|
|
421
425
|
role: 'presentation'
|
|
422
426
|
}
|
|
423
427
|
}
|
|
424
|
-
}
|
|
428
|
+
},
|
|
429
|
+
size: density === DENSITY.high ? 16 : 24
|
|
425
430
|
})))), /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
|
|
426
431
|
placement: "bottom",
|
|
427
432
|
focusLock: true,
|
|
@@ -465,6 +470,7 @@ export default class CalendarHeader extends React.Component {
|
|
|
465
470
|
"aria-live": "polite",
|
|
466
471
|
type: "button",
|
|
467
472
|
$isFocusVisible: this.state.isFocusVisible,
|
|
473
|
+
$density: density,
|
|
468
474
|
onKeyUp: event => {
|
|
469
475
|
if (this.canArrowsOpenDropdown(event)) {
|
|
470
476
|
this.setState({
|
|
@@ -492,7 +498,8 @@ export default class CalendarHeader extends React.Component {
|
|
|
492
498
|
role: 'presentation'
|
|
493
499
|
}
|
|
494
500
|
}
|
|
495
|
-
}
|
|
501
|
+
},
|
|
502
|
+
size: density === DENSITY.high ? 16 : 24
|
|
496
503
|
})))));
|
|
497
504
|
});
|
|
498
505
|
|
|
@@ -523,13 +530,15 @@ export default class CalendarHeader extends React.Component {
|
|
|
523
530
|
|
|
524
531
|
render() {
|
|
525
532
|
const {
|
|
526
|
-
overrides = {}
|
|
533
|
+
overrides = {},
|
|
534
|
+
density
|
|
527
535
|
} = this.props;
|
|
528
536
|
const [CalendarHeader, calendarHeaderProps] = getOverrides(overrides.CalendarHeader, StyledCalendarHeader);
|
|
529
537
|
const [MonthHeader, monthHeaderProps] = getOverrides(overrides.MonthHeader, StyledMonthHeader);
|
|
530
538
|
const [WeekdayHeader, weekdayHeaderProps] = getOverrides(overrides.WeekdayHeader, StyledWeekdayHeader);
|
|
531
539
|
const startOfWeek = this.dateHelpers.getStartOfWeek(this.getDateProp(), this.props.locale);
|
|
532
540
|
return /*#__PURE__*/React.createElement(ThemeContext.Consumer, null, theme => /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, locale => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CalendarHeader, _extends({}, calendarHeaderProps, {
|
|
541
|
+
$density: this.props.density,
|
|
533
542
|
onFocus: forkFocus(calendarHeaderProps, this.handleFocus),
|
|
534
543
|
onBlur: forkBlur(calendarHeaderProps, this.handleBlur)
|
|
535
544
|
}), this.renderPreviousMonthButton({
|
|
@@ -545,7 +554,9 @@ export default class CalendarHeader extends React.Component {
|
|
|
545
554
|
return /*#__PURE__*/React.createElement(WeekdayHeader, _extends({
|
|
546
555
|
key: offset,
|
|
547
556
|
alt: this.dateHelpers.getWeekdayInLocale(day, this.props.locale)
|
|
548
|
-
}, weekdayHeaderProps
|
|
557
|
+
}, weekdayHeaderProps, {
|
|
558
|
+
$density: density
|
|
559
|
+
}), this.dateHelpers.getWeekdayMinInLocale(day, this.props.locale));
|
|
549
560
|
})))));
|
|
550
561
|
}
|
|
551
562
|
|
|
@@ -19,7 +19,7 @@ import { StyledCalendarContainer, StyledMonthContainer, StyledRoot, StyledSelect
|
|
|
19
19
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
20
20
|
import DateHelpers from './utils/date-helpers.js';
|
|
21
21
|
import { getOverrides, mergeOverrides } from '../helpers/overrides.js';
|
|
22
|
-
import { ORIENTATION } from './constants.js';
|
|
22
|
+
import { DENSITY, ORIENTATION } from './constants.js';
|
|
23
23
|
export default class Calendar extends React.Component {
|
|
24
24
|
constructor(props) {
|
|
25
25
|
super(props);
|
|
@@ -329,10 +329,13 @@ export default class Calendar extends React.Component {
|
|
|
329
329
|
"aria-roledescription": translations.ariaRoleDescCalMonth,
|
|
330
330
|
"aria-multiselectable": this.props.range || null,
|
|
331
331
|
onKeyDown: this.onKeyDown
|
|
332
|
-
}, calendarContainerProps
|
|
332
|
+
}, calendarContainerProps, {
|
|
333
|
+
$density: this.props.density
|
|
334
|
+
}), /*#__PURE__*/React.createElement(Month, {
|
|
333
335
|
adapter: this.props.adapter,
|
|
334
336
|
date: monthDate,
|
|
335
337
|
dateLabel: this.props.dateLabel,
|
|
338
|
+
density: this.props.density,
|
|
336
339
|
excludeDates: this.props.excludeDates,
|
|
337
340
|
filterDate: this.props.filterDate,
|
|
338
341
|
highlightedDate: this.state.highlightedDate,
|
|
@@ -571,6 +574,7 @@ export default class Calendar extends React.Component {
|
|
|
571
574
|
const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
|
|
572
575
|
const [startDate, endDate] = [].concat(this.props.value);
|
|
573
576
|
return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, locale => /*#__PURE__*/React.createElement(Root, _extends({
|
|
577
|
+
$density: this.props.density,
|
|
574
578
|
"data-baseweb": "calendar",
|
|
575
579
|
role: "application",
|
|
576
580
|
"aria-roledescription": "datepicker",
|
|
@@ -593,6 +597,7 @@ export default class Calendar extends React.Component {
|
|
|
593
597
|
_defineProperty(Calendar, "defaultProps", {
|
|
594
598
|
autoFocusCalendar: false,
|
|
595
599
|
dateLabel: null,
|
|
600
|
+
density: DENSITY.default,
|
|
596
601
|
excludeDates: null,
|
|
597
602
|
filterDate: null,
|
|
598
603
|
highlightedDate: null,
|
|
@@ -21,4 +21,8 @@ export const STATE_CHANGE_TYPE = Object.freeze({
|
|
|
21
21
|
mouseLeave: 'mouseLeave'
|
|
22
22
|
});
|
|
23
23
|
export const WEEKDAYS = [0, 1, 2, 3, 4, 5, 6];
|
|
24
|
-
export const DEFAULT_MONTHS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
24
|
+
export const DEFAULT_MONTHS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
25
|
+
export const DENSITY = {
|
|
26
|
+
high: 'high',
|
|
27
|
+
default: 'default'
|
|
28
|
+
};
|
|
@@ -15,10 +15,27 @@ import Calendar from './calendar.js';
|
|
|
15
15
|
import { getOverrides } from '../helpers/overrides.js';
|
|
16
16
|
import getInterpolatedString from '../helpers/i18n-interpolation.js';
|
|
17
17
|
import { LocaleContext } from '../locale/index.js';
|
|
18
|
-
import { StyledInputWrapper } from './styled-components.js';
|
|
18
|
+
import { StyledInputWrapper, StyledInputLabel, StyledStartDate, StyledEndDate } from './styled-components.js';
|
|
19
19
|
import DateHelpers from './utils/date-helpers.js';
|
|
20
20
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
21
21
|
export const DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
|
|
22
|
+
const INPUT_DELIMITER = ' – ';
|
|
23
|
+
|
|
24
|
+
const combineSeparatedInputs = (newInputValue, prevCombinedInputValue = '', separatedInput) => {
|
|
25
|
+
let inputValue = newInputValue;
|
|
26
|
+
const [prevStartDate = '', prevEndDate = ''] = prevCombinedInputValue.split(INPUT_DELIMITER);
|
|
27
|
+
|
|
28
|
+
if (separatedInput === 'startDate' && prevEndDate) {
|
|
29
|
+
inputValue = `${inputValue} – ${prevEndDate}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (separatedInput === 'endDate') {
|
|
33
|
+
inputValue = `${prevStartDate} – ${inputValue}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return inputValue;
|
|
37
|
+
};
|
|
38
|
+
|
|
22
39
|
export default class Datepicker extends React.Component {
|
|
23
40
|
constructor(props) {
|
|
24
41
|
super(props);
|
|
@@ -134,7 +151,7 @@ export default class Datepicker extends React.Component {
|
|
|
134
151
|
isOpen: true,
|
|
135
152
|
isPseudoFocused: true,
|
|
136
153
|
calendarFocused: false
|
|
137
|
-
});
|
|
154
|
+
}, this.props.onOpen);
|
|
138
155
|
});
|
|
139
156
|
|
|
140
157
|
_defineProperty(this, "close", () => {
|
|
@@ -164,10 +181,11 @@ export default class Datepicker extends React.Component {
|
|
|
164
181
|
const {
|
|
165
182
|
formatString,
|
|
166
183
|
mask,
|
|
167
|
-
range
|
|
184
|
+
range,
|
|
185
|
+
separateRangeInputs
|
|
168
186
|
} = this.props;
|
|
169
187
|
|
|
170
|
-
if (mask === null) {
|
|
188
|
+
if (mask === null || mask === undefined && formatString !== DEFAULT_DATE_FORMAT) {
|
|
171
189
|
return null;
|
|
172
190
|
}
|
|
173
191
|
|
|
@@ -175,26 +193,17 @@ export default class Datepicker extends React.Component {
|
|
|
175
193
|
return this.normalizeDashes(mask);
|
|
176
194
|
}
|
|
177
195
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (formatString) {
|
|
181
|
-
if (range) {
|
|
182
|
-
return `${normalizedFormatString} – ${normalizedFormatString}`.replace(/[a-z]/gi, '9');
|
|
183
|
-
} else {
|
|
184
|
-
return normalizedFormatString.replace(/[a-z]/gi, '9');
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (range) {
|
|
196
|
+
if (range && !separateRangeInputs) {
|
|
189
197
|
return '9999/99/99 – 9999/99/99';
|
|
190
198
|
}
|
|
191
199
|
|
|
192
200
|
return '9999/99/99';
|
|
193
201
|
});
|
|
194
202
|
|
|
195
|
-
_defineProperty(this, "handleInputChange", event => {
|
|
196
|
-
const inputValue = event.currentTarget.value;
|
|
203
|
+
_defineProperty(this, "handleInputChange", (event, separatedInput) => {
|
|
204
|
+
const inputValue = this.props.range && this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, this.state.inputValue, separatedInput) : event.currentTarget.value;
|
|
197
205
|
const mask = this.getMask();
|
|
206
|
+
const formatString = this.normalizeDashes(this.props.formatString);
|
|
198
207
|
|
|
199
208
|
if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
|
|
200
209
|
if (this.props.onChange) {
|
|
@@ -213,7 +222,6 @@ export default class Datepicker extends React.Component {
|
|
|
213
222
|
this.setState({
|
|
214
223
|
inputValue
|
|
215
224
|
});
|
|
216
|
-
const formatString = this.normalizeDashes(this.props.formatString);
|
|
217
225
|
|
|
218
226
|
const parseDateString = dateString => {
|
|
219
227
|
if (formatString === DEFAULT_DATE_FORMAT) {
|
|
@@ -224,7 +232,7 @@ export default class Datepicker extends React.Component {
|
|
|
224
232
|
};
|
|
225
233
|
|
|
226
234
|
if (this.props.range && typeof this.props.displayValueAtRangeIndex !== 'number') {
|
|
227
|
-
const [left, right] = this.normalizeDashes(inputValue).split(
|
|
235
|
+
const [left, right] = this.normalizeDashes(inputValue).split(INPUT_DELIMITER);
|
|
228
236
|
let startDate = this.dateHelpers.date(left);
|
|
229
237
|
let endDate = this.dateHelpers.date(right);
|
|
230
238
|
|
|
@@ -372,7 +380,7 @@ export default class Datepicker extends React.Component {
|
|
|
372
380
|
} else if (Array.isArray(date) && !date[0] && !date[1]) {
|
|
373
381
|
return '';
|
|
374
382
|
} else if (Array.isArray(date)) {
|
|
375
|
-
return date.map(day => format(day)).join(
|
|
383
|
+
return date.map(day => format(day)).join(INPUT_DELIMITER);
|
|
376
384
|
} else {
|
|
377
385
|
return format(date);
|
|
378
386
|
}
|
|
@@ -386,16 +394,53 @@ export default class Datepicker extends React.Component {
|
|
|
386
394
|
}
|
|
387
395
|
}
|
|
388
396
|
|
|
389
|
-
|
|
397
|
+
renderInputComponent(locale, separatedInput) {
|
|
390
398
|
const {
|
|
391
399
|
overrides = {}
|
|
392
400
|
} = this.props;
|
|
393
401
|
const [InputComponent, inputProps] = getOverrides(overrides.Input, MaskedInput);
|
|
402
|
+
const 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';
|
|
403
|
+
const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(INPUT_DELIMITER);
|
|
404
|
+
const value = separatedInput === 'startDate' ? startDate : separatedInput === 'endDate' ? endDate : this.state.inputValue;
|
|
405
|
+
|
|
406
|
+
const onChange = event => this.handleInputChange(event, separatedInput);
|
|
407
|
+
|
|
408
|
+
return /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
409
|
+
"aria-disabled": this.props.disabled,
|
|
410
|
+
"aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
|
|
411
|
+
error: this.props.error,
|
|
412
|
+
positive: this.props.positive,
|
|
413
|
+
"aria-describedby": this.props['aria-describedby'],
|
|
414
|
+
"aria-labelledby": this.props['aria-labelledby'],
|
|
415
|
+
"aria-required": this.props.required || null,
|
|
416
|
+
disabled: this.props.disabled,
|
|
417
|
+
size: this.props.size,
|
|
418
|
+
value: value,
|
|
419
|
+
onFocus: this.open,
|
|
420
|
+
onBlur: this.handleInputBlur,
|
|
421
|
+
onKeyDown: this.handleKeyDown,
|
|
422
|
+
onChange: onChange,
|
|
423
|
+
placeholder: placeholder,
|
|
424
|
+
mask: this.getMask(),
|
|
425
|
+
required: this.props.required,
|
|
426
|
+
clearable: this.props.clearable
|
|
427
|
+
}, inputProps));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
render() {
|
|
431
|
+
const {
|
|
432
|
+
overrides = {},
|
|
433
|
+
startDateLabel = 'Start Date',
|
|
434
|
+
endDateLabel = 'End Date'
|
|
435
|
+
} = this.props;
|
|
394
436
|
const [PopoverComponent, popoverProps] = getOverrides(overrides.Popover, Popover);
|
|
395
437
|
const [InputWrapper, inputWrapperProps] = getOverrides(overrides.InputWrapper, StyledInputWrapper);
|
|
396
|
-
const
|
|
438
|
+
const [StartDate, startDateProps] = getOverrides(overrides.StartDate, StyledStartDate);
|
|
439
|
+
const [EndDate, endDateProps] = getOverrides(overrides.EndDate, StyledEndDate);
|
|
440
|
+
const [InputLabel, inputLabelProps] = getOverrides(overrides.InputLabel, StyledInputLabel);
|
|
397
441
|
return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, locale => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PopoverComponent, _extends({
|
|
398
442
|
focusLock: false,
|
|
443
|
+
autoFocus: false,
|
|
399
444
|
mountNode: this.props.mountNode,
|
|
400
445
|
placement: PLACEMENT.bottom,
|
|
401
446
|
isOpen: this.state.isOpen,
|
|
@@ -409,26 +454,9 @@ export default class Datepicker extends React.Component {
|
|
|
409
454
|
}, this.props, {
|
|
410
455
|
onChange: this.onChange
|
|
411
456
|
}))
|
|
412
|
-
}, popoverProps), /*#__PURE__*/React.createElement(InputWrapper,
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
error: this.props.error,
|
|
416
|
-
positive: this.props.positive,
|
|
417
|
-
"aria-describedby": this.props['aria-describedby'],
|
|
418
|
-
"aria-labelledby": this.props['aria-labelledby'],
|
|
419
|
-
"aria-required": this.props.required || null,
|
|
420
|
-
disabled: this.props.disabled,
|
|
421
|
-
size: this.props.size,
|
|
422
|
-
value: this.state.inputValue,
|
|
423
|
-
onFocus: this.open,
|
|
424
|
-
onBlur: this.handleInputBlur,
|
|
425
|
-
onKeyDown: this.handleKeyDown,
|
|
426
|
-
onChange: this.handleInputChange,
|
|
427
|
-
placeholder: placeholder,
|
|
428
|
-
mask: this.getMask(),
|
|
429
|
-
required: this.props.required,
|
|
430
|
-
clearable: this.props.clearable
|
|
431
|
-
}, inputProps)))), /*#__PURE__*/React.createElement("p", {
|
|
457
|
+
}, popoverProps), /*#__PURE__*/React.createElement(InputWrapper, _extends({}, inputWrapperProps, {
|
|
458
|
+
$separateRangeInputs: this.props.range && this.props.separateRangeInputs
|
|
459
|
+
}), this.props.range && this.props.separateRangeInputs ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StartDate, startDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, startDateLabel), this.renderInputComponent(locale, 'startDate')), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), this.renderInputComponent(locale, 'endDate'))) : /*#__PURE__*/React.createElement(React.Fragment, null, this.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
|
|
432
460
|
id: this.props['aria-describedby'],
|
|
433
461
|
style: {
|
|
434
462
|
position: 'fixed',
|
package/es/datepicker/day.js
CHANGED
|
@@ -280,6 +280,7 @@ export default class Day extends React.Component {
|
|
|
280
280
|
const $outsideMonthWithinRange = !!(Array.isArray(value) && range && $outsideMonth && !this.props.peekNextMonth && this.isOutsideOfMonthButWithinRange());
|
|
281
281
|
return {
|
|
282
282
|
$date: date,
|
|
283
|
+
$density: this.props.density,
|
|
283
284
|
$disabled: this.props.disabled,
|
|
284
285
|
$endDate: Array.isArray(value) && this.props.range && $selected && this.dateHelpers.isSameDay(date, value[1]) || false,
|
|
285
286
|
$hasDateLabel: !!this.props.dateLabel,
|
package/es/datepicker/month.js
CHANGED
|
@@ -12,8 +12,10 @@ import { StyledMonth } from './styled-components.js';
|
|
|
12
12
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
13
13
|
import DateHelpers from './utils/date-helpers.js';
|
|
14
14
|
import { getOverrides } from '../helpers/overrides.js';
|
|
15
|
+
import { DENSITY } from './constants.js';
|
|
15
16
|
const defaultProps = {
|
|
16
17
|
dateLabel: null,
|
|
18
|
+
density: DENSITY.high,
|
|
17
19
|
excludeDates: null,
|
|
18
20
|
filterDate: null,
|
|
19
21
|
highlightDates: null,
|
|
@@ -60,6 +62,7 @@ export default class CalendarMonth extends React.Component {
|
|
|
60
62
|
adapter: this.props.adapter,
|
|
61
63
|
date: currentWeekStart,
|
|
62
64
|
dateLabel: this.props.dateLabel,
|
|
65
|
+
density: this.props.density,
|
|
63
66
|
excludeDates: this.props.excludeDates,
|
|
64
67
|
filterDate: this.props.filterDate,
|
|
65
68
|
highlightedDate: this.props.highlightedDate,
|