@spaced-out/ui-design-system 0.1.93-beta.1 → 0.1.94-beta.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/CHANGELOG.md +14 -0
- package/lib/components/Chip/Chip.js +2 -1
- package/lib/components/Chip/Chip.js.flow +3 -1
- package/lib/components/DateRangePicker/Calendar.js +7 -3
- package/lib/components/DateRangePicker/Calendar.js.flow +5 -3
- package/lib/components/DateRangePicker/DateRangePicker.js +23 -37
- package/lib/components/DateRangePicker/DateRangePicker.js.flow +53 -55
- package/lib/components/DateRangePicker/DateRangeWrapper.js +15 -10
- package/lib/components/DateRangePicker/DateRangeWrapper.js.flow +20 -16
- package/lib/components/DateRangePicker/Day.js +5 -7
- package/lib/components/DateRangePicker/Day.js.flow +4 -10
- package/lib/components/DateRangePicker/Day.module.css +7 -20
- package/lib/components/DateRangePicker/index.js.flow +1 -0
- package/lib/components/DateRangePicker/utils.js +87 -72
- package/lib/components/DateRangePicker/utils.js.flow +111 -103
- package/lib/components/Dropdown/Dropdown.js +6 -0
- package/lib/components/Dropdown/Dropdown.js.flow +6 -0
- package/lib/components/Dropdown/SimpleDropdown.js +2 -0
- package/lib/components/Dropdown/SimpleDropdown.js.flow +4 -1
- package/lib/components/Menu/Menu.js +48 -4
- package/lib/components/Menu/Menu.js.flow +79 -13
- package/lib/components/Menu/MenuOptionButton.js +3 -1
- package/lib/components/Menu/MenuOptionButton.js.flow +3 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.94-beta.0](https://github.com/spaced-out/ui-design-system/compare/v0.1.93...v0.1.94-beta.0) (2024-05-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* [GDS-338, GDS-349, GDS-372] virtualization in Menu Component ([#178](https://github.com/spaced-out/ui-design-system/issues/178)) ([81e5c69](https://github.com/spaced-out/ui-design-system/commit/81e5c69064e64ef7d18b3f2c02eb92e1cded8bfe))
|
|
11
|
+
|
|
12
|
+
### [0.1.93](https://github.com/spaced-out/ui-design-system/compare/v0.1.93-beta.1...v0.1.93) (2024-05-08)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* adding prop to disable hover on chip ([#200](https://github.com/spaced-out/ui-design-system/issues/200)) ([65a60dd](https://github.com/spaced-out/ui-design-system/commit/65a60dda9b9180b8be8a4145991590f2fe04d2d8))
|
|
18
|
+
|
|
5
19
|
### [0.1.93-beta.1](https://github.com/spaced-out/ui-design-system/compare/v0.1.93-beta.0...v0.1.93-beta.1) (2024-05-07)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -32,6 +32,7 @@ const Chip = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
32
32
|
iconName = '',
|
|
33
33
|
iconType = 'regular',
|
|
34
34
|
showStatusIndicator,
|
|
35
|
+
disableHoverState = false,
|
|
35
36
|
dismissable = false,
|
|
36
37
|
onDismiss = () => null,
|
|
37
38
|
onClick,
|
|
@@ -54,7 +55,7 @@ const Chip = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
54
55
|
[_ChipModule.default.dismissable]: dismissable,
|
|
55
56
|
[_ChipModule.default.withIcon]: !!iconName && size !== 'small',
|
|
56
57
|
[_ChipModule.default.disabled]: disabled,
|
|
57
|
-
[_ChipModule.default.noHoverState]: showStatusIndicator
|
|
58
|
+
[_ChipModule.default.noHoverState]: showStatusIndicator || disableHoverState
|
|
58
59
|
}, classNames?.wrapper),
|
|
59
60
|
onClick: onClick
|
|
60
61
|
}), showStatusIndicator && size !== 'small' && /*#__PURE__*/React.createElement(_StatusIndicator.StatusIndicator, {
|
|
@@ -34,6 +34,7 @@ export type BaseChipProps = {
|
|
|
34
34
|
children: React.Node,
|
|
35
35
|
disabled?: boolean,
|
|
36
36
|
showStatusIndicator?: boolean,
|
|
37
|
+
disableHoverState?: boolean,
|
|
37
38
|
onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
38
39
|
onMouseEnter?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
39
40
|
onMouseLeave?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
@@ -65,6 +66,7 @@ export const Chip: React$AbstractComponent<ChipProps, HTMLDivElement> =
|
|
|
65
66
|
iconName = '',
|
|
66
67
|
iconType = 'regular',
|
|
67
68
|
showStatusIndicator,
|
|
69
|
+
disableHoverState = false,
|
|
68
70
|
dismissable = false,
|
|
69
71
|
onDismiss = () => null,
|
|
70
72
|
onClick,
|
|
@@ -91,7 +93,7 @@ export const Chip: React$AbstractComponent<ChipProps, HTMLDivElement> =
|
|
|
91
93
|
[css.dismissable]: dismissable,
|
|
92
94
|
[css.withIcon]: !!iconName && size !== 'small',
|
|
93
95
|
[css.disabled]: disabled,
|
|
94
|
-
[css.noHoverState]: showStatusIndicator,
|
|
96
|
+
[css.noHoverState]: showStatusIndicator || disableHoverState,
|
|
95
97
|
},
|
|
96
98
|
classNames?.wrapper,
|
|
97
99
|
)}
|
|
@@ -52,16 +52,20 @@ const Calendar = _ref => {
|
|
|
52
52
|
key: week[index],
|
|
53
53
|
className: _CalendarModule.default.calendarRow
|
|
54
54
|
}, week.map(date => {
|
|
55
|
+
const isRangeValid = (0, _utils.isStartDateEndDateSame)(dateRange);
|
|
55
56
|
const isStart = (0, _utils.isStartOfRange)(dateRange, date);
|
|
56
57
|
const isEnd = (0, _utils.isEndOfRange)(dateRange, date);
|
|
57
|
-
const isRangeValid = (0, _utils.isStartDateEndDateSame)(dateRange);
|
|
58
58
|
const highlighted = (0, _utils.inDateRange)(dateRange, date) || inHoverRange(date);
|
|
59
|
+
const {
|
|
60
|
+
onDayClick,
|
|
61
|
+
onDayHover
|
|
62
|
+
} = handlers;
|
|
59
63
|
return /*#__PURE__*/React.createElement(_Day.Day, {
|
|
60
64
|
key: date,
|
|
61
65
|
date: date,
|
|
62
66
|
filled: isStart || isEnd,
|
|
63
|
-
onClick: () =>
|
|
64
|
-
onHover: () =>
|
|
67
|
+
onClick: () => onDayClick(date),
|
|
68
|
+
onHover: () => onDayHover(date),
|
|
65
69
|
outlined: (0, _momentTimezone.default)(date).isSame((0, _momentTimezone.default)(), 'd'),
|
|
66
70
|
disabled: (0, _momentTimezone.default)(date).isAfter((0, _utils.formatIsoDate)()) || !(0, _momentTimezone.default)(date).isSame((0, _momentTimezone.default)(value), 'month'),
|
|
67
71
|
endOfRange: isEnd && !isRangeValid,
|
|
@@ -82,18 +82,20 @@ export const Calendar = ({
|
|
|
82
82
|
{getDaysInMonth(value).map((week, index) => (
|
|
83
83
|
<div key={week[index]} className={css.calendarRow}>
|
|
84
84
|
{week.map((date) => {
|
|
85
|
+
const isRangeValid = isStartDateEndDateSame(dateRange);
|
|
85
86
|
const isStart = isStartOfRange(dateRange, date);
|
|
86
87
|
const isEnd = isEndOfRange(dateRange, date);
|
|
87
|
-
const isRangeValid = isStartDateEndDateSame(dateRange);
|
|
88
88
|
const highlighted =
|
|
89
89
|
inDateRange(dateRange, date) || inHoverRange(date);
|
|
90
|
+
const {onDayClick, onDayHover} = handlers;
|
|
91
|
+
|
|
90
92
|
return (
|
|
91
93
|
<Day
|
|
92
94
|
key={date}
|
|
93
95
|
date={date}
|
|
94
96
|
filled={isStart || isEnd}
|
|
95
|
-
onClick={() =>
|
|
96
|
-
onHover={() =>
|
|
97
|
+
onClick={() => onDayClick(date)}
|
|
98
|
+
onHover={() => onDayHover(date)}
|
|
97
99
|
outlined={moment(date).isSame(moment(), 'd')}
|
|
98
100
|
disabled={
|
|
99
101
|
moment(date).isAfter(formatIsoDate()) ||
|
|
@@ -21,48 +21,37 @@ const DateRangePicker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
21
21
|
onApply,
|
|
22
22
|
onCancel,
|
|
23
23
|
classNames,
|
|
24
|
-
initialDateRange
|
|
24
|
+
initialDateRange = {}
|
|
25
25
|
} = _ref;
|
|
26
26
|
const today = (0, _utils.formatIsoDate)();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if ((0, _momentTimezone.default)(initialRangeStart).isSame((0, _momentTimezone.default)(initialRangeEnd), 'M') && (0, _momentTimezone.default)(initialRangeStart).isSame((0, _momentTimezone.default)(today), 'M')) {
|
|
37
|
-
initialFirstMonth = (0, _utils.getSubtractedDate)(initialSecondMonth, 1, 'M');
|
|
38
|
-
} else {
|
|
39
|
-
initialSecondMonth = (0, _utils.getAddedDate)(initialFirstMonth, 1, 'M');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const [dateRange, setDateRange] = React.useState({
|
|
43
|
-
startDate: initialRangeStart,
|
|
44
|
-
endDate: initialRangeEnd
|
|
45
|
-
});
|
|
46
|
-
const [rangeStartMonth, setRangeStartMonth] = React.useState(initialFirstMonth);
|
|
47
|
-
const [rangeEndMonth, setRangeEndMonth] = React.useState(initialSecondMonth);
|
|
27
|
+
const currentTimezone = _momentTimezone.default.tz.guess();
|
|
28
|
+
const {
|
|
29
|
+
dateRange: initialRange,
|
|
30
|
+
monthRange
|
|
31
|
+
} = (0, _utils.getInitialDates)(initialDateRange);
|
|
32
|
+
const [dateRange, setDateRange] = React.useState(initialRange);
|
|
33
|
+
const [timeZone, setTimeZone] = React.useState(currentTimezone);
|
|
34
|
+
const [rangeStartMonth, setRangeStartMonth] = React.useState(monthRange.rangeStartMonth);
|
|
35
|
+
const [rangeEndMonth, setRangeEndMonth] = React.useState(monthRange.rangeEndMonth);
|
|
48
36
|
const [hoverDay, setHoverDay] = React.useState('');
|
|
49
|
-
const [timeZone, setTimeZone] = React.useState(_momentTimezone.default.tz.guess());
|
|
50
37
|
const {
|
|
51
38
|
startDate,
|
|
52
39
|
endDate
|
|
53
40
|
} = dateRange;
|
|
54
41
|
const setRangeStartMonthValidated = date => {
|
|
55
|
-
if ((0, _momentTimezone.default)(date).isBefore(rangeEndMonth)) {
|
|
56
|
-
setRangeStartMonth(date);
|
|
42
|
+
if ((0, _momentTimezone.default)(date).isBefore(rangeEndMonth) && (0, _momentTimezone.default)(date).isBefore(today)) {
|
|
43
|
+
setRangeStartMonth((0, _utils.getMonthStartDate)(date));
|
|
57
44
|
} else {
|
|
58
|
-
setRangeStartMonth((0, _utils.getSubtractedDate)(rangeEndMonth, 1, 'M'));
|
|
45
|
+
setRangeStartMonth((0, _utils.getMonthStartDate)((0, _utils.getSubtractedDate)(rangeEndMonth, 1, 'M')));
|
|
59
46
|
}
|
|
60
47
|
};
|
|
61
48
|
const setRangeEndMonthValidated = date => {
|
|
62
|
-
if ((0, _momentTimezone.default)(date).isAfter(rangeStartMonth)) {
|
|
63
|
-
setRangeEndMonth(date);
|
|
49
|
+
if ((0, _momentTimezone.default)(date).isAfter(rangeStartMonth) && (0, _momentTimezone.default)(date).isBefore(today)) {
|
|
50
|
+
setRangeEndMonth((0, _utils.getMonthStartDate)(date));
|
|
51
|
+
} else if ((0, _momentTimezone.default)(date).isAfter(rangeStartMonth)) {
|
|
52
|
+
setRangeEndMonth((0, _utils.getMonthStartDate)(today));
|
|
64
53
|
} else {
|
|
65
|
-
setRangeEndMonth((0, _utils.getAddedDate)(rangeStartMonth, 1, 'M'));
|
|
54
|
+
setRangeEndMonth((0, _utils.getMonthStartDate)((0, _utils.getAddedDate)(rangeStartMonth, 1, 'M')));
|
|
66
55
|
}
|
|
67
56
|
};
|
|
68
57
|
const onDayClick = day => {
|
|
@@ -73,15 +62,14 @@ const DateRangePicker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
73
62
|
});
|
|
74
63
|
} else {
|
|
75
64
|
setDateRange({
|
|
76
|
-
startDate: day
|
|
77
|
-
endDate: undefined
|
|
65
|
+
startDate: day
|
|
78
66
|
});
|
|
79
67
|
}
|
|
80
68
|
setHoverDay(day);
|
|
81
69
|
};
|
|
82
70
|
const onMonthNavigate = (marker, action) => {
|
|
83
71
|
const [firstMonth, secondMonth] = marker === _utils.MARKERS.DATE_RANGE_START ? [rangeStartMonth, rangeEndMonth] : [rangeEndMonth, rangeStartMonth];
|
|
84
|
-
const newMonth = action === _utils.NAVIGATION_ACTION.NEXT ? (0, _utils.getAddedDate)(firstMonth, 1, 'M') : (0, _utils.getSubtractedDate)(firstMonth, 1, 'M');
|
|
72
|
+
const newMonth = action === _utils.NAVIGATION_ACTION.NEXT ? (0, _utils.getMonthStartDate)((0, _utils.getAddedDate)(firstMonth, 1, 'M')) : (0, _utils.getMonthStartDate)((0, _utils.getSubtractedDate)(firstMonth, 1, 'M'));
|
|
85
73
|
const isRangeStartMonth = marker === _utils.MARKERS.DATE_RANGE_START;
|
|
86
74
|
const isBeforeCurrentMonth = (0, _momentTimezone.default)(newMonth).isBefore((0, _momentTimezone.default)());
|
|
87
75
|
const isValidMonth = isRangeStartMonth ? (0, _momentTimezone.default)(newMonth).isBefore((0, _momentTimezone.default)(secondMonth)) : (0, _momentTimezone.default)(secondMonth).isBefore((0, _momentTimezone.default)(newMonth));
|
|
@@ -89,12 +77,10 @@ const DateRangePicker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
89
77
|
isRangeStartMonth ? setRangeStartMonth(newMonth) : setRangeEndMonth(newMonth);
|
|
90
78
|
}
|
|
91
79
|
};
|
|
80
|
+
const inHoverRange = day => Boolean(startDate && !endDate && hoverDay && (0, _momentTimezone.default)(hoverDay).isAfter((0, _momentTimezone.default)(startDate)) && (0, _momentTimezone.default)(day).isBetween((0, _momentTimezone.default)(startDate), (0, _momentTimezone.default)(hoverDay), null, '[]'));
|
|
92
81
|
const onDayHover = date => {
|
|
93
|
-
|
|
94
|
-
setHoverDay(date);
|
|
95
|
-
}
|
|
82
|
+
setHoverDay(date);
|
|
96
83
|
};
|
|
97
|
-
const inHoverRange = day => Boolean(startDate && !endDate && hoverDay && (0, _momentTimezone.default)(hoverDay).isAfter((0, _momentTimezone.default)(startDate)) && (0, _momentTimezone.default)(day).isBetween((0, _momentTimezone.default)(startDate), (0, _momentTimezone.default)(hoverDay)));
|
|
98
84
|
const handlers = {
|
|
99
85
|
onDayClick,
|
|
100
86
|
onDayHover,
|
|
@@ -108,8 +94,8 @@ const DateRangePicker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
108
94
|
onCancel: onCancel,
|
|
109
95
|
timeZone: timeZone,
|
|
110
96
|
dateRange: dateRange,
|
|
111
|
-
rangeStartMonth: rangeStartMonth,
|
|
112
97
|
setTimeZone: setTimeZone,
|
|
98
|
+
rangeStartMonth: rangeStartMonth,
|
|
113
99
|
rangeEndMonth: rangeEndMonth,
|
|
114
100
|
inHoverRange: inHoverRange,
|
|
115
101
|
setRangeStartMonth: setRangeStartMonthValidated,
|
|
@@ -7,11 +7,12 @@ import moment from 'moment-timezone';
|
|
|
7
7
|
import classify from '../../utils/classify';
|
|
8
8
|
|
|
9
9
|
import {DateRangeWrapper} from './DateRangeWrapper';
|
|
10
|
+
import type {DateRange, DateRangeWithTimezone} from './utils';
|
|
10
11
|
import {
|
|
11
|
-
type DatePickerSelectedRange,
|
|
12
|
-
type DateRange,
|
|
13
12
|
formatIsoDate,
|
|
14
13
|
getAddedDate,
|
|
14
|
+
getInitialDates,
|
|
15
|
+
getMonthStartDate,
|
|
15
16
|
getSubtractedDate,
|
|
16
17
|
MARKERS,
|
|
17
18
|
NAVIGATION_ACTION,
|
|
@@ -25,7 +26,7 @@ type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
|
25
26
|
export type DateRangePickerProps = {
|
|
26
27
|
classNames?: ClassNames,
|
|
27
28
|
initialDateRange?: DateRange,
|
|
28
|
-
onApply: (datePickerSelectedRange:
|
|
29
|
+
onApply: (datePickerSelectedRange: DateRangeWithTimezone) => void,
|
|
29
30
|
onCancel: () => void,
|
|
30
31
|
};
|
|
31
32
|
|
|
@@ -34,63 +35,57 @@ export const DateRangePicker: React$AbstractComponent<
|
|
|
34
35
|
HTMLDivElement,
|
|
35
36
|
> = React.forwardRef<DateRangePickerProps, HTMLDivElement>(
|
|
36
37
|
(
|
|
37
|
-
{
|
|
38
|
+
{
|
|
39
|
+
onApply,
|
|
40
|
+
onCancel,
|
|
41
|
+
classNames,
|
|
42
|
+
initialDateRange = {},
|
|
43
|
+
}: DateRangePickerProps,
|
|
38
44
|
ref,
|
|
39
45
|
): React.Node => {
|
|
40
46
|
const today = formatIsoDate();
|
|
47
|
+
const currentTimezone = moment.tz.guess();
|
|
41
48
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
initialRangeStart = '',
|
|
45
|
-
initialRangeEnd = '';
|
|
46
|
-
|
|
47
|
-
if (initialDateRange?.startDate && initialDateRange.endDate) {
|
|
48
|
-
initialRangeStart = initialFirstMonth = formatIsoDate(
|
|
49
|
-
moment(initialDateRange.startDate),
|
|
50
|
-
);
|
|
51
|
-
initialRangeEnd = initialSecondMonth = formatIsoDate(
|
|
52
|
-
moment(initialDateRange.endDate),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
// If start and end dates are in the same current month, render them in the second calendar since next month isn't enabled yet.
|
|
56
|
-
if (
|
|
57
|
-
moment(initialRangeStart).isSame(moment(initialRangeEnd), 'M') &&
|
|
58
|
-
moment(initialRangeStart).isSame(moment(today), 'M')
|
|
59
|
-
) {
|
|
60
|
-
initialFirstMonth = getSubtractedDate(initialSecondMonth, 1, 'M');
|
|
61
|
-
} else {
|
|
62
|
-
initialSecondMonth = getAddedDate(initialFirstMonth, 1, 'M');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const [dateRange, setDateRange] = React.useState<DateRange>({
|
|
67
|
-
startDate: initialRangeStart,
|
|
68
|
-
endDate: initialRangeEnd,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const [rangeStartMonth, setRangeStartMonth] =
|
|
72
|
-
React.useState<string>(initialFirstMonth);
|
|
73
|
-
const [rangeEndMonth, setRangeEndMonth] =
|
|
74
|
-
React.useState<string>(initialSecondMonth);
|
|
49
|
+
const {dateRange: initialRange, monthRange} =
|
|
50
|
+
getInitialDates(initialDateRange);
|
|
75
51
|
|
|
52
|
+
const [dateRange, setDateRange] = React.useState<DateRange>(initialRange);
|
|
53
|
+
const [timeZone, setTimeZone] = React.useState<string>(currentTimezone);
|
|
54
|
+
const [rangeStartMonth, setRangeStartMonth] = React.useState<string>(
|
|
55
|
+
monthRange.rangeStartMonth,
|
|
56
|
+
);
|
|
57
|
+
const [rangeEndMonth, setRangeEndMonth] = React.useState<string>(
|
|
58
|
+
monthRange.rangeEndMonth,
|
|
59
|
+
);
|
|
76
60
|
const [hoverDay, setHoverDay] = React.useState<string>('');
|
|
77
|
-
const [timeZone, setTimeZone] = React.useState<string>(moment.tz.guess());
|
|
78
61
|
|
|
79
62
|
const {startDate, endDate} = dateRange;
|
|
80
63
|
|
|
81
64
|
const setRangeStartMonthValidated = (date: string) => {
|
|
82
|
-
if (
|
|
83
|
-
|
|
65
|
+
if (
|
|
66
|
+
moment(date).isBefore(rangeEndMonth) &&
|
|
67
|
+
moment(date).isBefore(today)
|
|
68
|
+
) {
|
|
69
|
+
setRangeStartMonth(getMonthStartDate(date));
|
|
84
70
|
} else {
|
|
85
|
-
setRangeStartMonth(
|
|
71
|
+
setRangeStartMonth(
|
|
72
|
+
getMonthStartDate(getSubtractedDate(rangeEndMonth, 1, 'M')),
|
|
73
|
+
);
|
|
86
74
|
}
|
|
87
75
|
};
|
|
88
76
|
|
|
89
77
|
const setRangeEndMonthValidated = (date: string) => {
|
|
90
|
-
if (
|
|
91
|
-
|
|
78
|
+
if (
|
|
79
|
+
moment(date).isAfter(rangeStartMonth) &&
|
|
80
|
+
moment(date).isBefore(today)
|
|
81
|
+
) {
|
|
82
|
+
setRangeEndMonth(getMonthStartDate(date));
|
|
83
|
+
} else if (moment(date).isAfter(rangeStartMonth)) {
|
|
84
|
+
setRangeEndMonth(getMonthStartDate(today));
|
|
92
85
|
} else {
|
|
93
|
-
setRangeEndMonth(
|
|
86
|
+
setRangeEndMonth(
|
|
87
|
+
getMonthStartDate(getAddedDate(rangeStartMonth, 1, 'M')),
|
|
88
|
+
);
|
|
94
89
|
}
|
|
95
90
|
};
|
|
96
91
|
|
|
@@ -98,7 +93,7 @@ export const DateRangePicker: React$AbstractComponent<
|
|
|
98
93
|
if (startDate && !endDate && moment(day).isSameOrAfter(startDate)) {
|
|
99
94
|
setDateRange({startDate, endDate: day});
|
|
100
95
|
} else {
|
|
101
|
-
setDateRange({startDate: day
|
|
96
|
+
setDateRange({startDate: day});
|
|
102
97
|
}
|
|
103
98
|
setHoverDay(day);
|
|
104
99
|
};
|
|
@@ -114,8 +109,8 @@ export const DateRangePicker: React$AbstractComponent<
|
|
|
114
109
|
|
|
115
110
|
const newMonth =
|
|
116
111
|
action === NAVIGATION_ACTION.NEXT
|
|
117
|
-
? getAddedDate(firstMonth, 1, 'M')
|
|
118
|
-
: getSubtractedDate(firstMonth, 1, 'M');
|
|
112
|
+
? getMonthStartDate(getAddedDate(firstMonth, 1, 'M'))
|
|
113
|
+
: getMonthStartDate(getSubtractedDate(firstMonth, 1, 'M'));
|
|
119
114
|
|
|
120
115
|
const isRangeStartMonth = marker === MARKERS.DATE_RANGE_START;
|
|
121
116
|
const isBeforeCurrentMonth = moment(newMonth).isBefore(moment());
|
|
@@ -130,21 +125,24 @@ export const DateRangePicker: React$AbstractComponent<
|
|
|
130
125
|
}
|
|
131
126
|
};
|
|
132
127
|
|
|
133
|
-
const onDayHover = (date: string) => {
|
|
134
|
-
if (startDate && !endDate && (!hoverDay || date !== hoverDay)) {
|
|
135
|
-
setHoverDay(date);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
128
|
const inHoverRange = (day: string): boolean =>
|
|
140
129
|
Boolean(
|
|
141
130
|
startDate &&
|
|
142
131
|
!endDate &&
|
|
143
132
|
hoverDay &&
|
|
144
133
|
moment(hoverDay).isAfter(moment(startDate)) &&
|
|
145
|
-
moment(day).isBetween(
|
|
134
|
+
moment(day).isBetween(
|
|
135
|
+
moment(startDate),
|
|
136
|
+
moment(hoverDay),
|
|
137
|
+
null,
|
|
138
|
+
'[]',
|
|
139
|
+
),
|
|
146
140
|
);
|
|
147
141
|
|
|
142
|
+
const onDayHover = (date: string) => {
|
|
143
|
+
setHoverDay(date);
|
|
144
|
+
};
|
|
145
|
+
|
|
148
146
|
const handlers = {
|
|
149
147
|
onDayClick,
|
|
150
148
|
onDayHover,
|
|
@@ -160,8 +158,8 @@ export const DateRangePicker: React$AbstractComponent<
|
|
|
160
158
|
onCancel={onCancel}
|
|
161
159
|
timeZone={timeZone}
|
|
162
160
|
dateRange={dateRange}
|
|
163
|
-
rangeStartMonth={rangeStartMonth}
|
|
164
161
|
setTimeZone={setTimeZone}
|
|
162
|
+
rangeStartMonth={rangeStartMonth}
|
|
165
163
|
rangeEndMonth={rangeEndMonth}
|
|
166
164
|
inHoverRange={inHoverRange}
|
|
167
165
|
setRangeStartMonth={setRangeStartMonthValidated}
|
|
@@ -23,7 +23,7 @@ const CalendarHeader = _ref => {
|
|
|
23
23
|
let {
|
|
24
24
|
date,
|
|
25
25
|
marker,
|
|
26
|
-
|
|
26
|
+
setMonth,
|
|
27
27
|
rangeStartMonth,
|
|
28
28
|
rangeEndMonth,
|
|
29
29
|
onClickNext,
|
|
@@ -34,6 +34,7 @@ const CalendarHeader = _ref => {
|
|
|
34
34
|
return /*#__PURE__*/React.createElement("div", {
|
|
35
35
|
className: _DateRangeWrapperModule.default.calendarHeader
|
|
36
36
|
}, /*#__PURE__*/React.createElement(_Icon.ClickableIcon, {
|
|
37
|
+
ariaLabel: "Select Previous Month",
|
|
37
38
|
size: "small",
|
|
38
39
|
name: "chevron-left",
|
|
39
40
|
className: (0, _classify.default)(_DateRangeWrapperModule.default.headerIcon, {
|
|
@@ -44,14 +45,14 @@ const CalendarHeader = _ref => {
|
|
|
44
45
|
}), /*#__PURE__*/React.createElement(_Dropdown.Dropdown, {
|
|
45
46
|
size: "small",
|
|
46
47
|
menu: {
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
selectedKeys: [(0, _momentTimezone.default)(date).month().toString()],
|
|
49
|
+
options: (0, _utils.getAvailableMonths)(_utils.MONTHS, rangeStartMonth, rangeEndMonth, marker)
|
|
49
50
|
},
|
|
50
51
|
onChange: event => {
|
|
51
|
-
|
|
52
|
+
setMonth((0, _utils.getMonthStartDate)((0, _momentTimezone.default)(date).set('M', event.key)));
|
|
52
53
|
},
|
|
53
54
|
dropdownInputText: _utils.MONTHS[(0, _momentTimezone.default)(date).month()].label,
|
|
54
|
-
|
|
55
|
+
scrollMenuToBottom: true
|
|
55
56
|
}), /*#__PURE__*/React.createElement(_Dropdown.Dropdown, {
|
|
56
57
|
menu: {
|
|
57
58
|
selectedKeys: [(0, _momentTimezone.default)(date).year().toString()],
|
|
@@ -59,12 +60,13 @@ const CalendarHeader = _ref => {
|
|
|
59
60
|
},
|
|
60
61
|
size: "small",
|
|
61
62
|
onChange: event => {
|
|
62
|
-
|
|
63
|
+
setMonth((0, _utils.getMonthStartDate)((0, _momentTimezone.default)(date).set('y', event.key)));
|
|
63
64
|
},
|
|
64
65
|
dropdownInputText: (0, _momentTimezone.default)(date).year(),
|
|
65
|
-
|
|
66
|
+
scrollMenuToBottom: true
|
|
66
67
|
}), /*#__PURE__*/React.createElement(_Icon.ClickableIcon, {
|
|
67
68
|
size: "small",
|
|
69
|
+
ariaLabel: "Select Next Month",
|
|
68
70
|
name: "chevron-right",
|
|
69
71
|
className: (0, _classify.default)(_DateRangeWrapperModule.default.headerIcon, {
|
|
70
72
|
[_DateRangeWrapperModule.default.disabledIcon]: nextDisabled
|
|
@@ -126,7 +128,7 @@ const DateRangeWrapper = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
126
128
|
rangeStartMonth: rangeStartMonth,
|
|
127
129
|
rangeEndMonth: rangeEndMonth,
|
|
128
130
|
date: rangeStartMonth,
|
|
129
|
-
|
|
131
|
+
setMonth: setRangeStartMonth,
|
|
130
132
|
nextDisabled: !canNavigateCloser,
|
|
131
133
|
prevDisabled: false,
|
|
132
134
|
onClickNext: () => onMonthNavigate(_utils.MARKERS.DATE_RANGE_START, _utils.NAVIGATION_ACTION.NEXT),
|
|
@@ -136,8 +138,8 @@ const DateRangeWrapper = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
136
138
|
rangeStartMonth: rangeStartMonth,
|
|
137
139
|
rangeEndMonth: rangeEndMonth,
|
|
138
140
|
date: rangeEndMonth,
|
|
139
|
-
|
|
140
|
-
nextDisabled: (0, _momentTimezone.default)((0, _utils.getAddedDate)(rangeEndMonth, 1, 'M')).
|
|
141
|
+
setMonth: setRangeEndMonth,
|
|
142
|
+
nextDisabled: (0, _momentTimezone.default)((0, _utils.getAddedDate)(rangeEndMonth, 1, 'M')).isSameOrAfter((0, _momentTimezone.default)()),
|
|
141
143
|
prevDisabled: !canNavigateCloser,
|
|
142
144
|
onClickNext: () => onMonthNavigate(_utils.MARKERS.DATE_RANGE_END, _utils.NAVIGATION_ACTION.NEXT),
|
|
143
145
|
onClickPrevious: () => onMonthNavigate(_utils.MARKERS.DATE_RANGE_END, _utils.NAVIGATION_ACTION.PREV)
|
|
@@ -161,6 +163,9 @@ const DateRangeWrapper = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
161
163
|
selectedKeys: [timeZone],
|
|
162
164
|
onChange: event => setTimeZone(event.key),
|
|
163
165
|
size: "small",
|
|
166
|
+
menuVirtualization: {
|
|
167
|
+
enable: true
|
|
168
|
+
},
|
|
164
169
|
allowSearch: true
|
|
165
170
|
})), /*#__PURE__*/React.createElement(_Card.CardActions, null, /*#__PURE__*/React.createElement(_Button.Button, {
|
|
166
171
|
type: "ghost",
|
|
@@ -19,14 +19,13 @@ import {FocusManager} from '../FocusManager';
|
|
|
19
19
|
import {ClickableIcon} from '../Icon';
|
|
20
20
|
|
|
21
21
|
import {Calendar} from './Calendar.js';
|
|
22
|
+
import type {DateRange, DateRangeWithTimezone} from './utils';
|
|
22
23
|
import {
|
|
23
|
-
type DatePickerSelectedRange,
|
|
24
|
-
type DateRange,
|
|
25
24
|
addTimeZone,
|
|
26
|
-
formatIsoDate,
|
|
27
25
|
generateAvailableYears,
|
|
28
26
|
getAddedDate,
|
|
29
27
|
getAvailableMonths,
|
|
28
|
+
getMonthStartDate,
|
|
30
29
|
getTimeZones,
|
|
31
30
|
MARKERS,
|
|
32
31
|
MONTHS,
|
|
@@ -45,7 +44,7 @@ type HeaderProps = {
|
|
|
45
44
|
onClickNext: () => void,
|
|
46
45
|
onClickPrevious: () => void,
|
|
47
46
|
marker: $Values<typeof MARKERS>,
|
|
48
|
-
|
|
47
|
+
setMonth: (date: string) => void,
|
|
49
48
|
};
|
|
50
49
|
|
|
51
50
|
type DateRangeWrapperProps = {
|
|
@@ -58,7 +57,7 @@ type DateRangeWrapperProps = {
|
|
|
58
57
|
setRangeEndMonth: (string) => void,
|
|
59
58
|
setTimeZone: (string) => void,
|
|
60
59
|
timeZone: string,
|
|
61
|
-
onApply: (datePickerSelectedRange:
|
|
60
|
+
onApply: (datePickerSelectedRange: DateRangeWithTimezone) => void,
|
|
62
61
|
onCancel: () => void,
|
|
63
62
|
inHoverRange: (day: string) => boolean,
|
|
64
63
|
handlers: {
|
|
@@ -74,7 +73,7 @@ type DateRangeWrapperProps = {
|
|
|
74
73
|
const CalendarHeader = ({
|
|
75
74
|
date,
|
|
76
75
|
marker,
|
|
77
|
-
|
|
76
|
+
setMonth,
|
|
78
77
|
rangeStartMonth,
|
|
79
78
|
rangeEndMonth,
|
|
80
79
|
onClickNext,
|
|
@@ -84,6 +83,7 @@ const CalendarHeader = ({
|
|
|
84
83
|
}: HeaderProps): React.Node => (
|
|
85
84
|
<div className={css.calendarHeader}>
|
|
86
85
|
<ClickableIcon
|
|
86
|
+
ariaLabel="Select Previous Month"
|
|
87
87
|
size="small"
|
|
88
88
|
name="chevron-left"
|
|
89
89
|
className={classify(css.headerIcon, {
|
|
@@ -95,19 +95,19 @@ const CalendarHeader = ({
|
|
|
95
95
|
<Dropdown
|
|
96
96
|
size="small"
|
|
97
97
|
menu={{
|
|
98
|
+
selectedKeys: [moment(date).month().toString()],
|
|
98
99
|
options: getAvailableMonths(
|
|
99
100
|
MONTHS,
|
|
100
101
|
rangeStartMonth,
|
|
101
102
|
rangeEndMonth,
|
|
102
103
|
marker,
|
|
103
104
|
),
|
|
104
|
-
selectedKeys: [moment(date).month().toString()],
|
|
105
105
|
}}
|
|
106
106
|
onChange={(event) => {
|
|
107
|
-
|
|
107
|
+
setMonth(getMonthStartDate(moment(date).set('M', event.key)));
|
|
108
108
|
}}
|
|
109
109
|
dropdownInputText={MONTHS[moment(date).month()].label}
|
|
110
|
-
|
|
110
|
+
scrollMenuToBottom
|
|
111
111
|
/>
|
|
112
112
|
<Dropdown
|
|
113
113
|
menu={{
|
|
@@ -121,13 +121,14 @@ const CalendarHeader = ({
|
|
|
121
121
|
}}
|
|
122
122
|
size="small"
|
|
123
123
|
onChange={(event) => {
|
|
124
|
-
|
|
124
|
+
setMonth(getMonthStartDate(moment(date).set('y', event.key)));
|
|
125
125
|
}}
|
|
126
126
|
dropdownInputText={moment(date).year()}
|
|
127
|
-
|
|
127
|
+
scrollMenuToBottom
|
|
128
128
|
/>
|
|
129
129
|
<ClickableIcon
|
|
130
130
|
size="small"
|
|
131
|
+
ariaLabel="Select Next Month"
|
|
131
132
|
name="chevron-right"
|
|
132
133
|
className={classify(css.headerIcon, {
|
|
133
134
|
[css.disabledIcon]: nextDisabled,
|
|
@@ -202,7 +203,7 @@ export const DateRangeWrapper: React$AbstractComponent<
|
|
|
202
203
|
rangeStartMonth={rangeStartMonth}
|
|
203
204
|
rangeEndMonth={rangeEndMonth}
|
|
204
205
|
date={rangeStartMonth}
|
|
205
|
-
|
|
206
|
+
setMonth={setRangeStartMonth}
|
|
206
207
|
nextDisabled={!canNavigateCloser}
|
|
207
208
|
prevDisabled={false}
|
|
208
209
|
onClickNext={() =>
|
|
@@ -223,10 +224,10 @@ export const DateRangeWrapper: React$AbstractComponent<
|
|
|
223
224
|
rangeStartMonth={rangeStartMonth}
|
|
224
225
|
rangeEndMonth={rangeEndMonth}
|
|
225
226
|
date={rangeEndMonth}
|
|
226
|
-
|
|
227
|
-
nextDisabled={moment(
|
|
228
|
-
|
|
229
|
-
)}
|
|
227
|
+
setMonth={setRangeEndMonth}
|
|
228
|
+
nextDisabled={moment(
|
|
229
|
+
getAddedDate(rangeEndMonth, 1, 'M'),
|
|
230
|
+
).isSameOrAfter(moment())}
|
|
230
231
|
prevDisabled={!canNavigateCloser}
|
|
231
232
|
onClickNext={() =>
|
|
232
233
|
onMonthNavigate(MARKERS.DATE_RANGE_END, NAVIGATION_ACTION.NEXT)
|
|
@@ -259,6 +260,9 @@ export const DateRangeWrapper: React$AbstractComponent<
|
|
|
259
260
|
selectedKeys={[timeZone]}
|
|
260
261
|
onChange={(event) => setTimeZone(event.key)}
|
|
261
262
|
size="small"
|
|
263
|
+
menuVirtualization={{
|
|
264
|
+
enable: true,
|
|
265
|
+
}}
|
|
262
266
|
allowSearch
|
|
263
267
|
/>
|
|
264
268
|
</CardTitle>
|
|
@@ -16,6 +16,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
16
16
|
|
|
17
17
|
// $FlowFixMe[untyped-import]
|
|
18
18
|
|
|
19
|
+
// $FlowFixMe[untyped-import]
|
|
20
|
+
|
|
19
21
|
const getTextColor = (disabled, filled) => {
|
|
20
22
|
if (disabled) {
|
|
21
23
|
return _Text.TEXT_COLORS.disabled;
|
|
@@ -43,9 +45,7 @@ const Day = _ref => {
|
|
|
43
45
|
tabIndex: disabled ? -1 : 0,
|
|
44
46
|
className: (0, _classify.default)(_DayModule.default.calendarItemButton, {
|
|
45
47
|
[_DayModule.default.calendarRowItemDisabled]: disabled,
|
|
46
|
-
[_DayModule.default.
|
|
47
|
-
[_DayModule.default.calendarRowItemBorderRight]: !disabled && !(0, _momentTimezone.default)(date).isSame((0, _momentTimezone.default)(hoverDay)) && (filled || highlighted) && startOfRange,
|
|
48
|
-
[_DayModule.default.calendarRowItemHighlighted]: !disabled && !filled && highlighted
|
|
48
|
+
[_DayModule.default.calendarRowItemHighlighted]: !disabled && (highlighted || startOfRange || endOfRange)
|
|
49
49
|
}),
|
|
50
50
|
onMouseOver: onHover,
|
|
51
51
|
onClick: onClick,
|
|
@@ -54,12 +54,10 @@ const Day = _ref => {
|
|
|
54
54
|
type: "ghost",
|
|
55
55
|
color: getTextColor(disabled, filled),
|
|
56
56
|
className: (0, _classify.default)(_DayModule.default.calendarRowItem, {
|
|
57
|
-
[_DayModule.default.calendarRowItemHover]: !disabled &&
|
|
57
|
+
[_DayModule.default.calendarRowItemHover]: !disabled && (0, _momentTimezone.default)(date).isSame(hoverDay),
|
|
58
58
|
[_DayModule.default.calendarRowItemFilled]: !disabled && filled,
|
|
59
59
|
[_DayModule.default.calendarRowItemOutlined]: !disabled && outlined
|
|
60
|
-
})
|
|
61
|
-
onMouseOver: onHover,
|
|
62
|
-
onClick: onClick
|
|
60
|
+
})
|
|
63
61
|
}, value));
|
|
64
62
|
};
|
|
65
63
|
exports.Day = Day;
|