@transferwise/components 0.0.0-experimental-0301818 → 0.0.0-experimental-f4a328f
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/build/Calendar/Calendar.js +16 -94
- package/build/Calendar/Calendar.js.map +1 -1
- package/build/Calendar/Calendar.messages.js +0 -12
- package/build/Calendar/Calendar.messages.js.map +1 -1
- package/build/Calendar/Calendar.messages.mjs +0 -12
- package/build/Calendar/Calendar.messages.mjs.map +1 -1
- package/build/Calendar/Calendar.mjs +17 -95
- package/build/Calendar/Calendar.mjs.map +1 -1
- package/build/Calendar/DateHeader/DateHeader.js +1 -5
- package/build/Calendar/DateHeader/DateHeader.js.map +1 -1
- package/build/Calendar/DateHeader/DateHeader.mjs +1 -5
- package/build/Calendar/DateHeader/DateHeader.mjs.map +1 -1
- package/build/Calendar/DayCalendar/DayCalendar.js +0 -14
- package/build/Calendar/DayCalendar/DayCalendar.js.map +1 -1
- package/build/Calendar/DayCalendar/DayCalendar.mjs +0 -14
- package/build/Calendar/DayCalendar/DayCalendar.mjs.map +1 -1
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.js +19 -53
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.js.map +1 -1
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs +19 -53
- package/build/Calendar/DayCalendar/Table/DayCalendarTable.mjs.map +1 -1
- package/build/Calendar/MonthCalendar/MonthCalendar.js +0 -6
- package/build/Calendar/MonthCalendar/MonthCalendar.js.map +1 -1
- package/build/Calendar/MonthCalendar/MonthCalendar.mjs +0 -6
- package/build/Calendar/MonthCalendar/MonthCalendar.mjs.map +1 -1
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.js +3 -8
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.js.map +1 -1
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.mjs +3 -8
- package/build/Calendar/MonthCalendar/Table/MonthCalendarTable.mjs.map +1 -1
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.js +3 -8
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.js.map +1 -1
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.mjs +3 -8
- package/build/Calendar/YearCalendar/Table/YearCalendarTable.mjs.map +1 -1
- package/build/Calendar/YearCalendar/YearCalendar.js +0 -7
- package/build/Calendar/YearCalendar/YearCalendar.js.map +1 -1
- package/build/Calendar/YearCalendar/YearCalendar.mjs +0 -7
- package/build/Calendar/YearCalendar/YearCalendar.mjs.map +1 -1
- package/build/Calendar/{TableLink → tableLink}/TableLink.js +11 -26
- package/build/Calendar/tableLink/TableLink.js.map +1 -0
- package/build/Calendar/{TableLink → tableLink}/TableLink.mjs +11 -26
- package/build/Calendar/tableLink/TableLink.mjs.map +1 -0
- package/build/DateLookup/DateLookup.js +9 -20
- package/build/DateLookup/DateLookup.js.map +1 -1
- package/build/DateLookup/DateLookup.mjs +9 -20
- package/build/DateLookup/DateLookup.mjs.map +1 -1
- package/build/Markup/Markup.js +137 -0
- package/build/Markup/Markup.js.map +1 -0
- package/build/Markup/Markup.mjs +132 -0
- package/build/Markup/Markup.mjs.map +1 -0
- package/build/Markup/constants.js +36 -0
- package/build/Markup/constants.js.map +1 -0
- package/build/Markup/constants.mjs +29 -0
- package/build/Markup/constants.mjs.map +1 -0
- package/build/Markup/utils/parseMarkup.js +236 -0
- package/build/Markup/utils/parseMarkup.js.map +1 -0
- package/build/Markup/utils/parseMarkup.mjs +231 -0
- package/build/Markup/utils/parseMarkup.mjs.map +1 -0
- package/build/Markup/utils/sanitise.js +114 -0
- package/build/Markup/utils/sanitise.js.map +1 -0
- package/build/Markup/utils/sanitise.mjs +111 -0
- package/build/Markup/utils/sanitise.mjs.map +1 -0
- package/build/i18n/en.json +0 -4
- package/build/i18n/en.json.js +0 -4
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +0 -4
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/index.mjs +2 -1
- package/build/index.mjs.map +1 -1
- package/build/main.css +78 -123
- package/build/styles/Calendar/Calendar.css +37 -112
- package/build/styles/Markup/Markup.css +28 -0
- package/build/styles/Markup/_stories/Vulnerability/Vulnerability.css +69 -0
- package/build/styles/main.css +78 -123
- package/build/types/Body/Body.d.ts +2 -2
- package/build/types/Calendar/Calendar.d.ts +3 -16
- package/build/types/Calendar/Calendar.d.ts.map +1 -1
- package/build/types/Calendar/Calendar.messages.d.ts +0 -20
- package/build/types/Calendar/Calendar.messages.d.ts.map +1 -1
- package/build/types/Calendar/DateHeader/DateHeader.d.ts +0 -2
- package/build/types/Calendar/DateHeader/DateHeader.d.ts.map +1 -1
- package/build/types/Calendar/DayCalendar/DayCalendar.d.ts +1 -5
- package/build/types/Calendar/DayCalendar/DayCalendar.d.ts.map +1 -1
- package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts +0 -4
- package/build/types/Calendar/DayCalendar/Table/DayCalendarTable.d.ts.map +1 -1
- package/build/types/Calendar/MonthCalendar/MonthCalendar.d.ts +0 -1
- package/build/types/Calendar/MonthCalendar/MonthCalendar.d.ts.map +1 -1
- package/build/types/Calendar/MonthCalendar/Table/MonthCalendarTable.d.ts +1 -2
- package/build/types/Calendar/MonthCalendar/Table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/Calendar/YearCalendar/Table/YearCalendarTable.d.ts +1 -2
- package/build/types/Calendar/YearCalendar/Table/YearCalendarTable.d.ts.map +1 -1
- package/build/types/Calendar/YearCalendar/YearCalendar.d.ts +0 -1
- package/build/types/Calendar/YearCalendar/YearCalendar.d.ts.map +1 -1
- package/build/types/Calendar/index.d.ts +0 -1
- package/build/types/Calendar/index.d.ts.map +1 -1
- package/build/types/Calendar/{TableLink → tableLink}/TableLink.d.ts +1 -3
- package/build/types/Calendar/tableLink/TableLink.d.ts.map +1 -0
- package/build/types/Calendar/tableLink/index.d.ts.map +1 -0
- package/build/types/DateLookup/DateLookup.d.ts +5 -24
- package/build/types/DateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/DateLookup/index.d.ts +0 -1
- package/build/types/DateLookup/index.d.ts.map +1 -1
- package/build/types/IconButton/IconButton.d.ts +1 -1
- package/build/types/Markup/Markup.d.ts +18 -0
- package/build/types/Markup/Markup.d.ts.map +1 -0
- package/build/types/Markup/Markup.types.d.ts +77 -0
- package/build/types/Markup/Markup.types.d.ts.map +1 -0
- package/build/types/Markup/_stories/Vulnerability/Vulnerability.d.ts +12 -0
- package/build/types/Markup/_stories/Vulnerability/Vulnerability.d.ts.map +1 -0
- package/build/types/Markup/constants.d.ts +20 -0
- package/build/types/Markup/constants.d.ts.map +1 -0
- package/build/types/Markup/index.d.ts +3 -0
- package/build/types/Markup/index.d.ts.map +1 -0
- package/build/types/Markup/utils/parseMarkup.d.ts +8 -0
- package/build/types/Markup/utils/parseMarkup.d.ts.map +1 -0
- package/build/types/Markup/utils/sanitise.d.ts +4 -0
- package/build/types/Markup/utils/sanitise.d.ts.map +1 -0
- package/build/types/Title/Title.d.ts +2 -2
- package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
- package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
- package/build/types/index.d.ts +4 -3
- package/build/types/index.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +0 -8
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Calendar/Calendar.css +37 -112
- package/src/Calendar/Calendar.less +35 -5
- package/src/Calendar/Calendar.messages.ts +0 -21
- package/src/Calendar/Calendar.test.tsx +27 -288
- package/src/Calendar/Calendar.tsx +18 -130
- package/src/Calendar/DateHeader/DateHeader.tsx +0 -6
- package/src/Calendar/DayCalendar/DayCalendar.tsx +1 -33
- package/src/Calendar/DayCalendar/Table/DayCalendarTable.tsx +27 -62
- package/src/Calendar/MonthCalendar/MonthCalendar.tsx +0 -8
- package/src/Calendar/MonthCalendar/Table/MonthCalendarTable.tsx +3 -15
- package/src/Calendar/YearCalendar/Table/YearCalendarTable.tsx +3 -15
- package/src/Calendar/YearCalendar/YearCalendar.tsx +0 -9
- package/src/Calendar/_stories/Calendar.story.tsx +4 -138
- package/src/Calendar/index.ts +0 -7
- package/src/Calendar/{TableLink → tableLink}/TableLink.tsx +14 -29
- package/src/DateLookup/DateLookup.test.tsx +37 -34
- package/src/DateLookup/DateLookup.tsx +13 -37
- package/src/DateLookup/_stories/DateLookup.story.tsx +2 -124
- package/src/DateLookup/index.ts +0 -6
- package/src/Markup/Markup.css +28 -0
- package/src/Markup/Markup.injection.test.tsx +163 -0
- package/src/Markup/Markup.less +29 -0
- package/src/Markup/Markup.test.tsx +463 -0
- package/src/Markup/Markup.tsx +169 -0
- package/src/Markup/Markup.types.ts +62 -0
- package/src/Markup/_stories/Markup.docs.mdx +75 -0
- package/src/Markup/_stories/Markup.security.docs.mdx +343 -0
- package/src/Markup/_stories/Markup.story.tsx +266 -0
- package/src/Markup/_stories/Vulnerability/Vulnerability.css +69 -0
- package/src/Markup/_stories/Vulnerability/Vulnerability.tsx +30 -0
- package/src/Markup/constants.ts +41 -0
- package/src/Markup/index.ts +2 -0
- package/src/Markup/utils/parseMarkup.test.ts +706 -0
- package/src/Markup/utils/parseMarkup.ts +234 -0
- package/src/Markup/utils/sanitise.test.ts +497 -0
- package/src/Markup/utils/sanitise.ts +133 -0
- package/src/i18n/en.json +0 -4
- package/src/index.ts +4 -3
- package/src/main.css +78 -123
- package/src/main.less +1 -0
- package/build/Calendar/TableLink/TableLink.js.map +0 -1
- package/build/Calendar/TableLink/TableLink.mjs.map +0 -1
- package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js +0 -33
- package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js.map +0 -1
- package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs +0 -31
- package/build/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs.map +0 -1
- package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.js +0 -40
- package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.js.map +0 -1
- package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.mjs +0 -38
- package/build/Calendar/_helpers/isDateDisabled/isDateDisabled.mjs.map +0 -1
- package/build/styles/Calendar/TableLink/TableLink.css +0 -115
- package/build/types/Calendar/Calendar.types.d.ts +0 -32
- package/build/types/Calendar/Calendar.types.d.ts.map +0 -1
- package/build/types/Calendar/TableLink/TableLink.d.ts.map +0 -1
- package/build/types/Calendar/TableLink/index.d.ts.map +0 -1
- package/build/types/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.d.ts +0 -3
- package/build/types/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.d.ts.map +0 -1
- package/build/types/Calendar/_helpers/index.d.ts +0 -3
- package/build/types/Calendar/_helpers/index.d.ts.map +0 -1
- package/build/types/Calendar/_helpers/isDateDisabled/isDateDisabled.d.ts +0 -3
- package/build/types/Calendar/_helpers/isDateDisabled/isDateDisabled.d.ts.map +0 -1
- package/src/Calendar/Calendar.disabledDates.test.tsx +0 -518
- package/src/Calendar/Calendar.types.ts +0 -35
- package/src/Calendar/TableLink/TableLink.css +0 -115
- package/src/Calendar/TableLink/TableLink.less +0 -68
- package/src/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.test.ts +0 -98
- package/src/Calendar/_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.ts +0 -45
- package/src/Calendar/_helpers/index.ts +0 -2
- package/src/Calendar/_helpers/isDateDisabled/isDateDisabled.test.ts +0 -169
- package/src/Calendar/_helpers/isDateDisabled/isDateDisabled.ts +0 -59
- package/src/Calendar/_stories/Calendar.accessibility.docs.mdx +0 -118
- package/src/Calendar/_stories/Calendar.test.story.tsx +0 -74
- package/src/DateLookup/DateLookup.disabledDates.test.tsx +0 -293
- package/src/DateLookup/_stories/DateLookup.accessibility.docs.mdx +0 -108
- /package/build/types/Calendar/{TableLink → tableLink}/index.d.ts +0 -0
- /package/src/Calendar/{TableLink → tableLink}/index.ts +0 -0
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var reactIntl = require('react-intl');
|
|
7
|
-
var formatting = require('@transferwise/formatting');
|
|
8
6
|
require('../common/theme.js');
|
|
9
7
|
require('../common/direction.js');
|
|
10
8
|
require('@transferwise/neptune-tokens');
|
|
@@ -24,19 +22,17 @@ require('../common/PropsValues/variant.js');
|
|
|
24
22
|
require('../common/PropsValues/scroll.js');
|
|
25
23
|
require('../common/PropsValues/markdownNodeType.js');
|
|
26
24
|
require('../common/fileType.js');
|
|
25
|
+
require('@transferwise/formatting');
|
|
27
26
|
require('@transferwise/icons');
|
|
28
27
|
require('clsx');
|
|
28
|
+
require('react-intl');
|
|
29
29
|
require('../common/CloseButton/CloseButton.messages.js');
|
|
30
30
|
var jsxRuntime = require('react/jsx-runtime');
|
|
31
31
|
var moveToWithinRange = require('../common/DateUtils/moveToWithinRange/moveToWithinRange.js');
|
|
32
32
|
var isWithinRange = require('../common/DateUtils/isWithinRange/isWithinRange.js');
|
|
33
33
|
var getDateView = require('../common/DateUtils/getDateView/getDateView.js');
|
|
34
|
-
var isDateDisabled = require('./_helpers/isDateDisabled/isDateDisabled.js');
|
|
35
|
-
var hasDisabledDatesInMonth = require('./_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.js');
|
|
36
|
-
var InlinePrompt = require('../Prompt/InlinePrompt/InlinePrompt.js');
|
|
37
34
|
var DayCalendar = require('./DayCalendar/DayCalendar.js');
|
|
38
35
|
var GetStartOfDay = require('./GetStartOfDay/GetStartOfDay.js');
|
|
39
|
-
var Calendar_messages = require('./Calendar.messages.js');
|
|
40
36
|
var MonthCalendar = require('./MonthCalendar/MonthCalendar.js');
|
|
41
37
|
var YearCalendar = require('./YearCalendar/YearCalendar.js');
|
|
42
38
|
|
|
@@ -46,38 +42,17 @@ const Calendar = ({
|
|
|
46
42
|
max: maxProp = null,
|
|
47
43
|
monthFormat: monthFormat$1 = monthFormat.MonthFormat.LONG,
|
|
48
44
|
placeholder,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
onChange
|
|
45
|
+
onChange,
|
|
46
|
+
onSelect
|
|
52
47
|
}) => {
|
|
53
|
-
const intl = reactIntl.useIntl();
|
|
54
48
|
const selectedDate = GetStartOfDay.getStartOfDay(value);
|
|
55
49
|
const min = GetStartOfDay.getStartOfDay(minProp);
|
|
56
50
|
const max = GetStartOfDay.getStartOfDay(maxProp);
|
|
57
|
-
const disabledReasonId = React.useId();
|
|
58
|
-
const disabledRulesRef = React.useRef(disabledRules);
|
|
59
|
-
React.useEffect(() => {
|
|
60
|
-
disabledRulesRef.current = disabledRules;
|
|
61
|
-
});
|
|
62
|
-
const [focusedDate, setFocusedDate] = React.useState(selectedDate);
|
|
63
|
-
React.useEffect(() => {
|
|
64
|
-
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
65
|
-
setFocusedDate(selectedDate);
|
|
66
|
-
}, [selectedDate?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
67
|
-
const checkIsEnabled = date => {
|
|
68
|
-
if (!date) return true;
|
|
69
|
-
return isWithinRange.isWithinRange(date, min, max) && !isDateDisabled.isDateDisabled(date, disabledRulesRef.current);
|
|
70
|
-
};
|
|
71
|
-
const focusedDateDisabled = focusedDate ? !isWithinRange.isWithinRange(focusedDate, min, max) || isDateDisabled.isDateDisabled(focusedDate, disabledRules) : false;
|
|
72
51
|
React.useEffect(() => {
|
|
73
52
|
if (selectedDate && !isWithinRange.isWithinRange(selectedDate, min, max)) {
|
|
74
|
-
|
|
75
|
-
setFocusedDate(clamped); // eslint-disable-line react-hooks/set-state-in-effect
|
|
76
|
-
onDateFocus?.(clamped, {
|
|
77
|
-
isEnabled: checkIsEnabled(clamped)
|
|
78
|
-
});
|
|
53
|
+
onChange(moveToWithinRange.moveToWithinRange(selectedDate, min, max));
|
|
79
54
|
}
|
|
80
|
-
}, [selectedDate?.getTime(), min?.getTime(), max?.getTime(),
|
|
55
|
+
}, [selectedDate?.getTime(), min?.getTime(), max?.getTime(), onChange]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
81
56
|
const dateView = getDateView.returnDateView(selectedDate, min, max);
|
|
82
57
|
const [viewMonth, setViewMonth] = React.useState(dateView.getMonth());
|
|
83
58
|
const [viewYear, setViewYear] = React.useState(dateView.getFullYear());
|
|
@@ -88,13 +63,6 @@ const Calendar = ({
|
|
|
88
63
|
setViewMonth(view.getMonth());
|
|
89
64
|
setViewYear(view.getFullYear());
|
|
90
65
|
}, [selectedDate?.getTime(), min?.getTime(), max?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
91
|
-
React.useEffect(() => {
|
|
92
|
-
if (focusedDate) {
|
|
93
|
-
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
94
|
-
setViewMonth(focusedDate.getMonth());
|
|
95
|
-
setViewYear(focusedDate.getFullYear());
|
|
96
|
-
}
|
|
97
|
-
}, [focusedDate?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
98
66
|
const handleViewDateUpdate = React.useCallback(
|
|
99
67
|
// eslint-disable-next-line react-hooks/preserve-manual-memoization
|
|
100
68
|
({
|
|
@@ -108,31 +76,24 @@ const Calendar = ({
|
|
|
108
76
|
const switchToMonths = React.useCallback(() => setMode('month'), []);
|
|
109
77
|
const switchToYears = React.useCallback(() => setMode('year'), []);
|
|
110
78
|
const handleSelectedDateUpdate = React.useCallback(date => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
isEnabled
|
|
115
|
-
});
|
|
116
|
-
if (isEnabled && onChange) {
|
|
79
|
+
if (onSelect) {
|
|
80
|
+
onSelect(date);
|
|
81
|
+
} else {
|
|
117
82
|
onChange(date);
|
|
118
83
|
}
|
|
119
|
-
}, [
|
|
84
|
+
}, [onChange, onSelect]);
|
|
120
85
|
const adjustDate = React.useCallback((daysToAdd, monthsToAdd, yearsToAdd) => {
|
|
121
|
-
const base = focusedDate ?? selectedDate;
|
|
122
86
|
let date;
|
|
123
|
-
if (
|
|
124
|
-
date = new Date(mode === 'year' ?
|
|
87
|
+
if (selectedDate) {
|
|
88
|
+
date = new Date(mode === 'year' ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(), mode === 'month' ? selectedDate.getMonth() + monthsToAdd : selectedDate.getMonth(), mode === 'day' ? selectedDate.getDate() + daysToAdd : selectedDate.getDate());
|
|
125
89
|
} else {
|
|
126
90
|
date = GetStartOfDay.getStartOfDay(new Date());
|
|
127
91
|
}
|
|
128
92
|
date &&= moveToWithinRange.moveToWithinRange(date, min, max);
|
|
129
|
-
if (date?.getTime() !==
|
|
130
|
-
|
|
131
|
-
onDateFocus?.(date, {
|
|
132
|
-
isEnabled: checkIsEnabled(date)
|
|
133
|
-
});
|
|
93
|
+
if (date?.getTime() !== selectedDate?.getTime()) {
|
|
94
|
+
onChange(date);
|
|
134
95
|
}
|
|
135
|
-
}, [
|
|
96
|
+
}, [selectedDate, min, max, mode, onChange]);
|
|
136
97
|
const handleKeyDown = React.useCallback(event => {
|
|
137
98
|
switch (event.key) {
|
|
138
99
|
case 'ArrowLeft':
|
|
@@ -151,36 +112,8 @@ const Calendar = ({
|
|
|
151
112
|
adjustDate(7, 4, 4);
|
|
152
113
|
event.preventDefault();
|
|
153
114
|
break;
|
|
154
|
-
case 'Enter':
|
|
155
|
-
case ' ':
|
|
156
|
-
if (mode === 'day' && focusedDate && event.target.hasAttribute('data-calendar-cell')) {
|
|
157
|
-
handleSelectedDateUpdate(focusedDate);
|
|
158
|
-
event.preventDefault();
|
|
159
|
-
}
|
|
160
|
-
break;
|
|
161
115
|
}
|
|
162
|
-
}, [adjustDate
|
|
163
|
-
const focusedDateOutOfRange = focusedDate ? !isWithinRange.isWithinRange(focusedDate, min, max) : false;
|
|
164
|
-
const formatDateForPrompt = date => formatting.formatDate(date, intl.locale, {
|
|
165
|
-
day: 'numeric',
|
|
166
|
-
month: 'long',
|
|
167
|
-
year: 'numeric'
|
|
168
|
-
});
|
|
169
|
-
const outOfRangePromptText = min && max ? intl.formatMessage(Calendar_messages.default.outOfRangeBetween, {
|
|
170
|
-
min: formatDateForPrompt(min),
|
|
171
|
-
max: formatDateForPrompt(max)
|
|
172
|
-
}) : min ? intl.formatMessage(Calendar_messages.default.outOfRangeAfter, {
|
|
173
|
-
min: formatDateForPrompt(min)
|
|
174
|
-
}) : max ? intl.formatMessage(Calendar_messages.default.outOfRangeBefore, {
|
|
175
|
-
max: formatDateForPrompt(max)
|
|
176
|
-
}) : '';
|
|
177
|
-
const hasOutOfRangeDates = mode === 'day' && !!(min || max);
|
|
178
|
-
const showRulesPrompt = mode === 'day' && !!disabledRules && hasDisabledDatesInMonth.hasDisabledDatesInMonth(viewMonth, viewYear, disabledRules, min, max);
|
|
179
|
-
const showOutOfRangePrompt = mode === 'day' && focusedDateOutOfRange;
|
|
180
|
-
const showPrompt = hasOutOfRangeDates || showRulesPrompt;
|
|
181
|
-
const promptText = showOutOfRangePrompt ? outOfRangePromptText : disabledRules?.reason ?? outOfRangePromptText;
|
|
182
|
-
const promptSentiment = showOutOfRangePrompt || focusedDateDisabled ? 'negative' : 'neutral';
|
|
183
|
-
const promptClassName = showOutOfRangePrompt || showRulesPrompt && !showOutOfRangePrompt ? 'm-t-1' : 'sr-only';
|
|
116
|
+
}, [adjustDate]);
|
|
184
117
|
return (
|
|
185
118
|
/*#__PURE__*/
|
|
186
119
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
@@ -188,20 +121,16 @@ const Calendar = ({
|
|
|
188
121
|
onKeyDown: handleKeyDown,
|
|
189
122
|
children: [mode === 'day' && /*#__PURE__*/jsxRuntime.jsx(DayCalendar.default, {
|
|
190
123
|
selectedDate: selectedDate,
|
|
191
|
-
focusedDate: focusedDate,
|
|
192
124
|
min: min,
|
|
193
125
|
max: max,
|
|
194
126
|
viewMonth: viewMonth,
|
|
195
127
|
viewYear: viewYear,
|
|
196
128
|
monthFormat: monthFormat$1,
|
|
197
|
-
disabledRules: disabledRules,
|
|
198
|
-
disabledReasonId: showPrompt ? disabledReasonId : undefined,
|
|
199
129
|
onSelect: handleSelectedDateUpdate,
|
|
200
130
|
onLabelClick: switchToYears,
|
|
201
131
|
onViewDateUpdate: handleViewDateUpdate
|
|
202
132
|
}), mode === 'month' && /*#__PURE__*/jsxRuntime.jsx(MonthCalendar.default, {
|
|
203
133
|
selectedDate: selectedDate,
|
|
204
|
-
focusedDate: focusedDate,
|
|
205
134
|
min: min,
|
|
206
135
|
max: max,
|
|
207
136
|
viewYear: viewYear,
|
|
@@ -213,7 +142,6 @@ const Calendar = ({
|
|
|
213
142
|
onViewDateUpdate: handleViewDateUpdate
|
|
214
143
|
}), mode === 'year' && /*#__PURE__*/jsxRuntime.jsx(YearCalendar.default, {
|
|
215
144
|
selectedDate: selectedDate,
|
|
216
|
-
focusedDate: focusedDate,
|
|
217
145
|
min: min,
|
|
218
146
|
max: max,
|
|
219
147
|
viewYear: viewYear,
|
|
@@ -222,12 +150,6 @@ const Calendar = ({
|
|
|
222
150
|
}),
|
|
223
151
|
onSelect: switchToMonths,
|
|
224
152
|
onViewDateUpdate: handleViewDateUpdate
|
|
225
|
-
}), showPrompt && /*#__PURE__*/jsxRuntime.jsx(InlinePrompt.InlinePrompt, {
|
|
226
|
-
sentiment: promptSentiment,
|
|
227
|
-
width: "full",
|
|
228
|
-
id: disabledReasonId,
|
|
229
|
-
className: promptClassName,
|
|
230
|
-
children: promptText
|
|
231
153
|
})]
|
|
232
154
|
})
|
|
233
155
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","sources":["../../src/Calendar/Calendar.tsx"],"sourcesContent":["import { useState, useCallback, useEffect, useId, useRef, KeyboardEvent } from 'react';\nimport { useIntl } from 'react-intl';\nimport { formatDate } from '@transferwise/formatting';\n\nimport { MonthFormat } from '../common';\nimport { isWithinRange, moveToWithinRange, returnDateView } from '../common/DateUtils';\nimport { isDateDisabled, hasDisabledDatesInMonth } from './_helpers';\nimport { InlinePrompt } from '../Prompt/InlinePrompt';\nimport type { DateChangeMeta, DisabledRules } from './Calendar.types';\nimport DayCalendar from './DayCalendar';\nimport { getStartOfDay } from './GetStartOfDay';\nimport messages from './Calendar.messages';\nimport MonthCalendar from './MonthCalendar';\nimport YearCalendar from './YearCalendar';\n\nexport interface CalendarProps {\n /** The currently selected date, or `null` for no selection. */\n value: Date | null;\n /** Earliest selectable date (inclusive). Dates before this are interactive but not selectable, and show a boundary prompt. */\n min?: Date | null;\n /** Latest selectable date (inclusive). Dates after this are interactive but not selectable, and show a boundary prompt. */\n max?: Date | null;\n /** Month name format in the header. Defaults to `'long'` (e.g. \"January\"). */\n monthFormat?: `${MonthFormat}`;\n /** Placeholder text shown in the month/year cells when no date is selected. */\n placeholder?: string;\n /** Rules for disabling specific weekdays, individual dates, or date ranges. The required `reason` is shown in an inline prompt and linked to disabled cells via `aria-describedby` for screen reader accessibility. */\n disabledRules?: DisabledRules;\n /** Called whenever the focused date changes — including disabled and out-of-range dates. `meta.isEnabled` is `false` when the date is not selectable. */\n onDateFocus?: (date: Date | null, meta: DateChangeMeta) => void;\n /** Called when a date is confirmed (click or Enter). Only fires for enabled dates. */\n onChange?: (date: Date | null) => void;\n}\n\n/**\n * Inline calendar for selecting a single date. Powers [DateLookup](?path=/docs/forms-datelookup--docs).\n */\nconst Calendar = ({\n value,\n min: minProp = null,\n max: maxProp = null,\n monthFormat = MonthFormat.LONG,\n placeholder,\n disabledRules,\n onDateFocus,\n onChange,\n}: CalendarProps) => {\n const intl = useIntl();\n const selectedDate = getStartOfDay(value);\n const min = getStartOfDay(minProp);\n const max = getStartOfDay(maxProp);\n const disabledReasonId = useId();\n const disabledRulesRef = useRef(disabledRules);\n useEffect(() => {\n disabledRulesRef.current = disabledRules;\n });\n\n const [focusedDate, setFocusedDate] = useState<Date | null>(selectedDate);\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setFocusedDate(selectedDate);\n }, [selectedDate?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const checkIsEnabled = (date: Date | null) => {\n if (!date) return true;\n return isWithinRange(date, min, max) && !isDateDisabled(date, disabledRulesRef.current);\n };\n\n const focusedDateDisabled = focusedDate\n ? !isWithinRange(focusedDate, min, max) || isDateDisabled(focusedDate, disabledRules)\n : false;\n\n useEffect(() => {\n if (selectedDate && !isWithinRange(selectedDate, min, max)) {\n const clamped = moveToWithinRange(selectedDate, min, max);\n setFocusedDate(clamped); // eslint-disable-line react-hooks/set-state-in-effect\n onDateFocus?.(clamped, { isEnabled: checkIsEnabled(clamped) });\n }\n }, [selectedDate?.getTime(), min?.getTime(), max?.getTime(), onDateFocus]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const dateView = returnDateView(selectedDate, min, max);\n const [viewMonth, setViewMonth] = useState(dateView.getMonth());\n const [viewYear, setViewYear] = useState(dateView.getFullYear());\n const [mode, setMode] = useState<'day' | 'month' | 'year'>('day');\n\n useEffect(() => {\n const view = returnDateView(selectedDate, min, max);\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setViewMonth(view.getMonth());\n\n setViewYear(view.getFullYear());\n }, [selectedDate?.getTime(), min?.getTime(), max?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n if (focusedDate) {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setViewMonth(focusedDate.getMonth());\n setViewYear(focusedDate.getFullYear());\n }\n }, [focusedDate?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleViewDateUpdate = useCallback(\n // eslint-disable-next-line react-hooks/preserve-manual-memoization\n ({ month, year }: { month?: number; year?: number }) => {\n if (month !== undefined) setViewMonth(month);\n if (year !== undefined) setViewYear(year);\n },\n [],\n );\n\n const switchToDays = useCallback(() => setMode('day'), []);\n const switchToMonths = useCallback(() => setMode('month'), []);\n const switchToYears = useCallback(() => setMode('year'), []);\n\n const handleSelectedDateUpdate = useCallback(\n (date: Date) => {\n const isEnabled = checkIsEnabled(date);\n setFocusedDate(date);\n onDateFocus?.(date, { isEnabled });\n if (isEnabled && onChange) {\n onChange(date);\n }\n },\n [onDateFocus, onChange], // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n const adjustDate = useCallback(\n (daysToAdd: number, monthsToAdd: number, yearsToAdd: number) => {\n const base = focusedDate ?? selectedDate;\n let date: Date | null;\n if (base) {\n date = new Date(\n mode === 'year' ? base.getFullYear() + yearsToAdd : base.getFullYear(),\n mode === 'month' ? base.getMonth() + monthsToAdd : base.getMonth(),\n mode === 'day' ? base.getDate() + daysToAdd : base.getDate(),\n );\n } else {\n date = getStartOfDay(new Date());\n }\n date &&= moveToWithinRange(date, min, max);\n if (date?.getTime() !== focusedDate?.getTime()) {\n setFocusedDate(date);\n onDateFocus?.(date, { isEnabled: checkIsEnabled(date) });\n }\n },\n [focusedDate, selectedDate, min, max, mode, onDateFocus], // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n switch (event.key) {\n case 'ArrowLeft':\n adjustDate(-1, -1, -1);\n event.preventDefault();\n break;\n case 'ArrowUp':\n adjustDate(-7, -4, -4);\n event.preventDefault();\n break;\n case 'ArrowRight':\n adjustDate(1, 1, 1);\n event.preventDefault();\n break;\n case 'ArrowDown':\n adjustDate(7, 4, 4);\n event.preventDefault();\n break;\n case 'Enter':\n case ' ':\n if (\n mode === 'day' &&\n focusedDate &&\n (event.target as HTMLElement).hasAttribute('data-calendar-cell')\n ) {\n handleSelectedDateUpdate(focusedDate);\n event.preventDefault();\n }\n break;\n default:\n break;\n }\n },\n [adjustDate, focusedDate, mode, handleSelectedDateUpdate],\n );\n\n const focusedDateOutOfRange = focusedDate ? !isWithinRange(focusedDate, min, max) : false;\n\n const formatDateForPrompt = (date: Date) =>\n formatDate(date, intl.locale, { day: 'numeric', month: 'long', year: 'numeric' });\n\n const outOfRangePromptText =\n min && max\n ? intl.formatMessage(messages.outOfRangeBetween, {\n min: formatDateForPrompt(min),\n max: formatDateForPrompt(max),\n })\n : min\n ? intl.formatMessage(messages.outOfRangeAfter, { min: formatDateForPrompt(min) })\n : max\n ? intl.formatMessage(messages.outOfRangeBefore, { max: formatDateForPrompt(max) })\n : '';\n\n const hasOutOfRangeDates = mode === 'day' && !!(min || max);\n const showRulesPrompt =\n mode === 'day' &&\n !!disabledRules &&\n hasDisabledDatesInMonth(viewMonth, viewYear, disabledRules, min, max);\n const showOutOfRangePrompt = mode === 'day' && focusedDateOutOfRange;\n const showPrompt = hasOutOfRangeDates || showRulesPrompt;\n\n const promptText = showOutOfRangePrompt\n ? outOfRangePromptText\n : (disabledRules?.reason ?? outOfRangePromptText);\n const promptSentiment = showOutOfRangePrompt || focusedDateDisabled ? 'negative' : 'neutral';\n const promptClassName =\n showOutOfRangePrompt || (showRulesPrompt && !showOutOfRangePrompt) ? 'm-t-1' : 'sr-only';\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div onKeyDown={handleKeyDown}>\n {mode === 'day' && (\n <DayCalendar\n selectedDate={selectedDate}\n focusedDate={focusedDate}\n min={min}\n max={max}\n viewMonth={viewMonth}\n viewYear={viewYear}\n monthFormat={monthFormat}\n disabledRules={disabledRules}\n disabledReasonId={showPrompt ? disabledReasonId : undefined}\n onSelect={handleSelectedDateUpdate}\n onLabelClick={switchToYears}\n onViewDateUpdate={handleViewDateUpdate}\n />\n )}\n {mode === 'month' && (\n <MonthCalendar\n selectedDate={selectedDate}\n focusedDate={focusedDate}\n min={min}\n max={max}\n viewYear={viewYear}\n {...(placeholder != null && { placeholder })}\n onSelect={switchToDays}\n onLabelClick={switchToYears}\n onViewDateUpdate={handleViewDateUpdate}\n />\n )}\n {mode === 'year' && (\n <YearCalendar\n selectedDate={selectedDate}\n focusedDate={focusedDate}\n min={min}\n max={max}\n viewYear={viewYear}\n {...(placeholder != null && { placeholder })}\n onSelect={switchToMonths}\n onViewDateUpdate={handleViewDateUpdate}\n />\n )}\n {showPrompt && (\n <InlinePrompt\n sentiment={promptSentiment}\n width=\"full\"\n id={disabledReasonId}\n className={promptClassName}\n >\n {promptText}\n </InlinePrompt>\n )}\n </div>\n );\n};\n\nexport default Calendar;\n"],"names":["Calendar","value","min","minProp","max","maxProp","monthFormat","MonthFormat","LONG","placeholder","disabledRules","onDateFocus","onChange","intl","useIntl","selectedDate","getStartOfDay","disabledReasonId","useId","disabledRulesRef","useRef","useEffect","current","focusedDate","setFocusedDate","useState","getTime","checkIsEnabled","date","isWithinRange","isDateDisabled","focusedDateDisabled","clamped","moveToWithinRange","isEnabled","dateView","returnDateView","viewMonth","setViewMonth","getMonth","viewYear","setViewYear","getFullYear","mode","setMode","view","handleViewDateUpdate","useCallback","month","year","undefined","switchToDays","switchToMonths","switchToYears","handleSelectedDateUpdate","adjustDate","daysToAdd","monthsToAdd","yearsToAdd","base","Date","getDate","handleKeyDown","event","key","preventDefault","target","hasAttribute","focusedDateOutOfRange","formatDateForPrompt","formatDate","locale","day","outOfRangePromptText","formatMessage","messages","outOfRangeBetween","outOfRangeAfter","outOfRangeBefore","hasOutOfRangeDates","showRulesPrompt","hasDisabledDatesInMonth","showOutOfRangePrompt","showPrompt","promptText","reason","promptSentiment","promptClassName","_jsxs","onKeyDown","children","_jsx","DayCalendar","onSelect","onLabelClick","onViewDateUpdate","MonthCalendar","YearCalendar","InlinePrompt","sentiment","width","id","className"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAMA,QAAQ,GAAGA,CAAC;EAChBC,KAAK;EACLC,GAAG,EAAEC,OAAO,GAAG,IAAI;EACnBC,GAAG,EAAEC,OAAO,GAAG,IAAI;eACnBC,aAAW,GAA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gBAAiB;AACrBqF,QAAAA,SAAS,EAAEf,eAAgB;AAAAG,QAAAA,QAAA,EAE1BN;AAAU,OACC,CACf;KACE;AAAC;AAEV;;;;"}
|
|
1
|
+
{"version":3,"file":"Calendar.js","sources":["../../src/Calendar/Calendar.tsx"],"sourcesContent":["import { useState, useCallback, useEffect, KeyboardEvent } from 'react';\n\nimport { MonthFormat } from '../common';\nimport { isWithinRange, moveToWithinRange, returnDateView } from '../common/DateUtils';\nimport DayCalendar from './DayCalendar';\nimport { getStartOfDay } from './GetStartOfDay';\nimport MonthCalendar from './MonthCalendar';\nimport YearCalendar from './YearCalendar';\n\nexport interface CalendarProps {\n value: Date | null;\n min?: Date | null;\n max?: Date | null;\n monthFormat?: `${MonthFormat}`;\n placeholder?: string;\n onChange: (date: Date | null) => void;\n onSelect?: (date: Date) => void;\n}\n\nconst Calendar = ({\n value,\n min: minProp = null,\n max: maxProp = null,\n monthFormat = MonthFormat.LONG,\n placeholder,\n onChange,\n onSelect,\n}: CalendarProps) => {\n const selectedDate = getStartOfDay(value);\n const min = getStartOfDay(minProp);\n const max = getStartOfDay(maxProp);\n\n useEffect(() => {\n if (selectedDate && !isWithinRange(selectedDate, min, max)) {\n onChange(moveToWithinRange(selectedDate, min, max));\n }\n }, [selectedDate?.getTime(), min?.getTime(), max?.getTime(), onChange]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const dateView = returnDateView(selectedDate, min, max);\n const [viewMonth, setViewMonth] = useState(dateView.getMonth());\n const [viewYear, setViewYear] = useState(dateView.getFullYear());\n const [mode, setMode] = useState<'day' | 'month' | 'year'>('day');\n\n useEffect(() => {\n const view = returnDateView(selectedDate, min, max);\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setViewMonth(view.getMonth());\n\n setViewYear(view.getFullYear());\n }, [selectedDate?.getTime(), min?.getTime(), max?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleViewDateUpdate = useCallback(\n // eslint-disable-next-line react-hooks/preserve-manual-memoization\n ({ month, year }: { month?: number; year?: number }) => {\n if (month !== undefined) setViewMonth(month);\n if (year !== undefined) setViewYear(year);\n },\n [],\n );\n\n const switchToDays = useCallback(() => setMode('day'), []);\n const switchToMonths = useCallback(() => setMode('month'), []);\n const switchToYears = useCallback(() => setMode('year'), []);\n\n const handleSelectedDateUpdate = useCallback(\n (date: Date) => {\n if (onSelect) {\n onSelect(date);\n } else {\n onChange(date);\n }\n },\n [onChange, onSelect],\n );\n\n const adjustDate = useCallback(\n (daysToAdd: number, monthsToAdd: number, yearsToAdd: number) => {\n let date: Date | null;\n if (selectedDate) {\n date = new Date(\n mode === 'year' ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(),\n mode === 'month' ? selectedDate.getMonth() + monthsToAdd : selectedDate.getMonth(),\n mode === 'day' ? selectedDate.getDate() + daysToAdd : selectedDate.getDate(),\n );\n } else {\n date = getStartOfDay(new Date());\n }\n date &&= moveToWithinRange(date, min, max);\n if (date?.getTime() !== selectedDate?.getTime()) {\n onChange(date);\n }\n },\n [selectedDate, min, max, mode, onChange],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n switch (event.key) {\n case 'ArrowLeft':\n adjustDate(-1, -1, -1);\n event.preventDefault();\n break;\n case 'ArrowUp':\n adjustDate(-7, -4, -4);\n event.preventDefault();\n break;\n case 'ArrowRight':\n adjustDate(1, 1, 1);\n event.preventDefault();\n break;\n case 'ArrowDown':\n adjustDate(7, 4, 4);\n event.preventDefault();\n break;\n default:\n break;\n }\n },\n [adjustDate],\n );\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div onKeyDown={handleKeyDown}>\n {mode === 'day' && (\n <DayCalendar\n selectedDate={selectedDate}\n min={min}\n max={max}\n viewMonth={viewMonth}\n viewYear={viewYear}\n monthFormat={monthFormat}\n onSelect={handleSelectedDateUpdate}\n onLabelClick={switchToYears}\n onViewDateUpdate={handleViewDateUpdate}\n />\n )}\n {mode === 'month' && (\n <MonthCalendar\n selectedDate={selectedDate}\n min={min}\n max={max}\n viewYear={viewYear}\n {...(placeholder != null && { placeholder })}\n onSelect={switchToDays}\n onLabelClick={switchToYears}\n onViewDateUpdate={handleViewDateUpdate}\n />\n )}\n {mode === 'year' && (\n <YearCalendar\n selectedDate={selectedDate}\n min={min}\n max={max}\n viewYear={viewYear}\n {...(placeholder != null && { placeholder })}\n onSelect={switchToMonths}\n onViewDateUpdate={handleViewDateUpdate}\n />\n )}\n </div>\n );\n};\n\nexport default Calendar;\n"],"names":["Calendar","value","min","minProp","max","maxProp","monthFormat","MonthFormat","LONG","placeholder","onChange","onSelect","selectedDate","getStartOfDay","useEffect","isWithinRange","moveToWithinRange","getTime","dateView","returnDateView","viewMonth","setViewMonth","useState","getMonth","viewYear","setViewYear","getFullYear","mode","setMode","view","handleViewDateUpdate","useCallback","month","year","undefined","switchToDays","switchToMonths","switchToYears","handleSelectedDateUpdate","date","adjustDate","daysToAdd","monthsToAdd","yearsToAdd","Date","getDate","handleKeyDown","event","key","preventDefault","_jsxs","onKeyDown","children","_jsx","DayCalendar","onLabelClick","onViewDateUpdate","MonthCalendar","YearCalendar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,QAAQ,GAAGA,CAAC;EAChBC,KAAK;EACLC,GAAG,EAAEC,OAAO,GAAG,IAAI;EACnBC,GAAG,EAAEC,OAAO,GAAG,IAAI;eACnBC,aAAW,GAAGC,uBAAW,CAACC,IAAI;EAC9BC,WAAW;EACXC,QAAQ;AACRC,EAAAA;AAAQ,CACM,KAAI;AAClB,EAAA,MAAMC,YAAY,GAAGC,2BAAa,CAACZ,KAAK,CAAC;AACzC,EAAA,MAAMC,GAAG,GAAGW,2BAAa,CAACV,OAAO,CAAC;AAClC,EAAA,MAAMC,GAAG,GAAGS,2BAAa,CAACR,OAAO,CAAC;AAElCS,EAAAA,eAAS,CAAC,MAAK;IACb,IAAIF,YAAY,IAAI,CAACG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ACrBI,QAAAA,QAAQ,EAAEA,QAAS;AACnBlB,QAAAA,WAAW,EAAEA,aAAY;AACzBK,QAAAA,QAAQ,EAAE2B,wBAAyB;AACnCiB,QAAAA,YAAY,EAAElB,aAAc;AAC5BmB,QAAAA,gBAAgB,EAAE1B;OAAqB,CAE1C,EACAH,IAAI,KAAK,OAAO,iBACf0B,cAAA,CAACI,qBAAa,EAAA;AACZ7C,QAAAA,YAAY,EAAEA,YAAa;AAC3BV,QAAAA,GAAG,EAAEA,GAAI;AACTE,QAAAA,GAAG,EAAEA,GAAI;AACToB,QAAAA,QAAQ,EAAEA,QAAS;QAAA,IACdf,WAAW,IAAI,IAAI,IAAI;AAAEA,UAAAA;SAAa,CAAA;AAC3CE,QAAAA,QAAQ,EAAEwB,YAAa;AACvBoB,QAAAA,YAAY,EAAElB,aAAc;AAC5BmB,QAAAA,gBAAgB,EAAE1B;OAAqB,CAE1C,EACAH,IAAI,KAAK,MAAM,iBACd0B,cAAA,CAACK,oBAAY,EAAA;AACX9C,QAAAA,YAAY,EAAEA,YAAa;AAC3BV,QAAAA,GAAG,EAAEA,GAAI;AACTE,QAAAA,GAAG,EAAEA,GAAI;AACToB,QAAAA,QAAQ,EAAEA,QAAS;QAAA,IACdf,WAAW,IAAI,IAAI,IAAI;AAAEA,UAAAA;SAAa,CAAA;AAC3CE,QAAAA,QAAQ,EAAEyB,cAAe;AACzBoB,QAAAA,gBAAgB,EAAE1B;AAAqB,OAAA,CAE1C;KACE;AAAC;AAEV;;;;"}
|
|
@@ -26,20 +26,8 @@ var messages = reactIntl.defineMessages({
|
|
|
26
26
|
selected: {
|
|
27
27
|
id: "neptune.DateLookup.selected"
|
|
28
28
|
},
|
|
29
|
-
notAvailable: {
|
|
30
|
-
id: "neptune.DateLookup.notAvailable"
|
|
31
|
-
},
|
|
32
29
|
goTo20YearView: {
|
|
33
30
|
id: "neptune.DateLookup.goTo20YearView"
|
|
34
|
-
},
|
|
35
|
-
outOfRangeBetween: {
|
|
36
|
-
id: "neptune.DateLookup.outOfRangeBetween"
|
|
37
|
-
},
|
|
38
|
-
outOfRangeAfter: {
|
|
39
|
-
id: "neptune.DateLookup.outOfRangeAfter"
|
|
40
|
-
},
|
|
41
|
-
outOfRangeBefore: {
|
|
42
|
-
id: "neptune.DateLookup.outOfRangeBefore"
|
|
43
31
|
}
|
|
44
32
|
});
|
|
45
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.messages.js","sources":["../../src/Calendar/Calendar.messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n next: {\n id: 'neptune.DateLookup.next',\n defaultMessage: 'next',\n description: 'Description of next button',\n },\n previous: {\n id: 'neptune.DateLookup.previous',\n defaultMessage: 'previous',\n description: 'Description of previous button',\n },\n day: {\n id: 'neptune.DateLookup.day',\n defaultMessage: 'day',\n description: 'Description of next/previous/selected day button',\n },\n month: {\n id: 'neptune.DateLookup.month',\n defaultMessage: 'month',\n description: 'Description of next/previous/selected month button',\n },\n year: {\n id: 'neptune.DateLookup.year',\n defaultMessage: 'year',\n description: 'Description of next/previous/selected year button',\n },\n twentyYears: {\n id: 'neptune.DateLookup.twentyYears',\n defaultMessage: '20 years',\n description: 'Description of next/previous 20 years button',\n },\n selected: {\n id: 'neptune.DateLookup.selected',\n defaultMessage: 'selected',\n description: 'Description of the selected day/month/year',\n },\n
|
|
1
|
+
{"version":3,"file":"Calendar.messages.js","sources":["../../src/Calendar/Calendar.messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n next: {\n id: 'neptune.DateLookup.next',\n defaultMessage: 'next',\n description: 'Description of next button',\n },\n previous: {\n id: 'neptune.DateLookup.previous',\n defaultMessage: 'previous',\n description: 'Description of previous button',\n },\n day: {\n id: 'neptune.DateLookup.day',\n defaultMessage: 'day',\n description: 'Description of next/previous/selected day button',\n },\n month: {\n id: 'neptune.DateLookup.month',\n defaultMessage: 'month',\n description: 'Description of next/previous/selected month button',\n },\n year: {\n id: 'neptune.DateLookup.year',\n defaultMessage: 'year',\n description: 'Description of next/previous/selected year button',\n },\n twentyYears: {\n id: 'neptune.DateLookup.twentyYears',\n defaultMessage: '20 years',\n description: 'Description of next/previous 20 years button',\n },\n selected: {\n id: 'neptune.DateLookup.selected',\n defaultMessage: 'selected',\n description: 'Description of the selected day/month/year',\n },\n goTo20YearView: {\n id: 'neptune.DateLookup.goTo20YearView',\n defaultMessage: 'Go to 20 year view',\n description: 'Description of the button to go to 20 year view',\n },\n});\n"],"names":["defineMessages","next","id","previous","day","month","year","twentyYears","selected","goTo20YearView"],"mappings":";;;;;;AAEA,eAAeA,wBAAc,CAAC;AAC5BC,EAAAA,IAAI,EAAE;IACJC,EAAE,EAAA;GAGH;AACDC,EAAAA,QAAQ,EAAE;IACRD,EAAE,EAAA;GAGH;AACDE,EAAAA,GAAG,EAAE;IACHF,EAAE,EAAA;GAGH;AACDG,EAAAA,KAAK,EAAE;IACLH,EAAE,EAAA;GAGH;AACDI,EAAAA,IAAI,EAAE;IACJJ,EAAE,EAAA;GAGH;AACDK,EAAAA,WAAW,EAAE;IACXL,EAAE,EAAA;GAGH;AACDM,EAAAA,QAAQ,EAAE;IACRN,EAAE,EAAA;GAGH;AACDO,EAAAA,cAAc,EAAE;IACdP,EAAE,EAAA;AAGH;AACF,CAAA,CAAC;;;;"}
|
|
@@ -22,20 +22,8 @@ var messages = defineMessages({
|
|
|
22
22
|
selected: {
|
|
23
23
|
id: "neptune.DateLookup.selected"
|
|
24
24
|
},
|
|
25
|
-
notAvailable: {
|
|
26
|
-
id: "neptune.DateLookup.notAvailable"
|
|
27
|
-
},
|
|
28
25
|
goTo20YearView: {
|
|
29
26
|
id: "neptune.DateLookup.goTo20YearView"
|
|
30
|
-
},
|
|
31
|
-
outOfRangeBetween: {
|
|
32
|
-
id: "neptune.DateLookup.outOfRangeBetween"
|
|
33
|
-
},
|
|
34
|
-
outOfRangeAfter: {
|
|
35
|
-
id: "neptune.DateLookup.outOfRangeAfter"
|
|
36
|
-
},
|
|
37
|
-
outOfRangeBefore: {
|
|
38
|
-
id: "neptune.DateLookup.outOfRangeBefore"
|
|
39
27
|
}
|
|
40
28
|
});
|
|
41
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.messages.mjs","sources":["../../src/Calendar/Calendar.messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n next: {\n id: 'neptune.DateLookup.next',\n defaultMessage: 'next',\n description: 'Description of next button',\n },\n previous: {\n id: 'neptune.DateLookup.previous',\n defaultMessage: 'previous',\n description: 'Description of previous button',\n },\n day: {\n id: 'neptune.DateLookup.day',\n defaultMessage: 'day',\n description: 'Description of next/previous/selected day button',\n },\n month: {\n id: 'neptune.DateLookup.month',\n defaultMessage: 'month',\n description: 'Description of next/previous/selected month button',\n },\n year: {\n id: 'neptune.DateLookup.year',\n defaultMessage: 'year',\n description: 'Description of next/previous/selected year button',\n },\n twentyYears: {\n id: 'neptune.DateLookup.twentyYears',\n defaultMessage: '20 years',\n description: 'Description of next/previous 20 years button',\n },\n selected: {\n id: 'neptune.DateLookup.selected',\n defaultMessage: 'selected',\n description: 'Description of the selected day/month/year',\n },\n
|
|
1
|
+
{"version":3,"file":"Calendar.messages.mjs","sources":["../../src/Calendar/Calendar.messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n next: {\n id: 'neptune.DateLookup.next',\n defaultMessage: 'next',\n description: 'Description of next button',\n },\n previous: {\n id: 'neptune.DateLookup.previous',\n defaultMessage: 'previous',\n description: 'Description of previous button',\n },\n day: {\n id: 'neptune.DateLookup.day',\n defaultMessage: 'day',\n description: 'Description of next/previous/selected day button',\n },\n month: {\n id: 'neptune.DateLookup.month',\n defaultMessage: 'month',\n description: 'Description of next/previous/selected month button',\n },\n year: {\n id: 'neptune.DateLookup.year',\n defaultMessage: 'year',\n description: 'Description of next/previous/selected year button',\n },\n twentyYears: {\n id: 'neptune.DateLookup.twentyYears',\n defaultMessage: '20 years',\n description: 'Description of next/previous 20 years button',\n },\n selected: {\n id: 'neptune.DateLookup.selected',\n defaultMessage: 'selected',\n description: 'Description of the selected day/month/year',\n },\n goTo20YearView: {\n id: 'neptune.DateLookup.goTo20YearView',\n defaultMessage: 'Go to 20 year view',\n description: 'Description of the button to go to 20 year view',\n },\n});\n"],"names":["defineMessages","next","id","previous","day","month","year","twentyYears","selected","goTo20YearView"],"mappings":";;AAEA,eAAeA,cAAc,CAAC;AAC5BC,EAAAA,IAAI,EAAE;IACJC,EAAE,EAAA;GAGH;AACDC,EAAAA,QAAQ,EAAE;IACRD,EAAE,EAAA;GAGH;AACDE,EAAAA,GAAG,EAAE;IACHF,EAAE,EAAA;GAGH;AACDG,EAAAA,KAAK,EAAE;IACLH,EAAE,EAAA;GAGH;AACDI,EAAAA,IAAI,EAAE;IACJJ,EAAE,EAAA;GAGH;AACDK,EAAAA,WAAW,EAAE;IACXL,EAAE,EAAA;GAGH;AACDM,EAAAA,QAAQ,EAAE;IACRN,EAAE,EAAA;GAGH;AACDO,EAAAA,cAAc,EAAE;IACdP,EAAE,EAAA;AAGH;AACF,CAAA,CAAC;;;;"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useIntl } from 'react-intl';
|
|
3
|
-
import { formatDate } from '@transferwise/formatting';
|
|
1
|
+
import { useEffect, useState, useCallback } from 'react';
|
|
4
2
|
import '../common/theme.mjs';
|
|
5
3
|
import '../common/direction.mjs';
|
|
6
4
|
import '@transferwise/neptune-tokens';
|
|
@@ -20,19 +18,17 @@ import '../common/PropsValues/variant.mjs';
|
|
|
20
18
|
import '../common/PropsValues/scroll.mjs';
|
|
21
19
|
import '../common/PropsValues/markdownNodeType.mjs';
|
|
22
20
|
import '../common/fileType.mjs';
|
|
21
|
+
import '@transferwise/formatting';
|
|
23
22
|
import '@transferwise/icons';
|
|
24
23
|
import 'clsx';
|
|
24
|
+
import 'react-intl';
|
|
25
25
|
import '../common/CloseButton/CloseButton.messages.mjs';
|
|
26
26
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
27
27
|
import { moveToWithinRange } from '../common/DateUtils/moveToWithinRange/moveToWithinRange.mjs';
|
|
28
28
|
import { isWithinRange } from '../common/DateUtils/isWithinRange/isWithinRange.mjs';
|
|
29
29
|
import { returnDateView } from '../common/DateUtils/getDateView/getDateView.mjs';
|
|
30
|
-
import { isDateDisabled } from './_helpers/isDateDisabled/isDateDisabled.mjs';
|
|
31
|
-
import { hasDisabledDatesInMonth } from './_helpers/hasDisabledDatesInMonth/hasDisabledDatesInMonth.mjs';
|
|
32
|
-
import { InlinePrompt } from '../Prompt/InlinePrompt/InlinePrompt.mjs';
|
|
33
30
|
import DayCalendar from './DayCalendar/DayCalendar.mjs';
|
|
34
31
|
import { getStartOfDay } from './GetStartOfDay/GetStartOfDay.mjs';
|
|
35
|
-
import messages from './Calendar.messages.mjs';
|
|
36
32
|
import MonthCalendar from './MonthCalendar/MonthCalendar.mjs';
|
|
37
33
|
import YearCalendar from './YearCalendar/YearCalendar.mjs';
|
|
38
34
|
|
|
@@ -42,38 +38,17 @@ const Calendar = ({
|
|
|
42
38
|
max: maxProp = null,
|
|
43
39
|
monthFormat = MonthFormat.LONG,
|
|
44
40
|
placeholder,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
onChange
|
|
41
|
+
onChange,
|
|
42
|
+
onSelect
|
|
48
43
|
}) => {
|
|
49
|
-
const intl = useIntl();
|
|
50
44
|
const selectedDate = getStartOfDay(value);
|
|
51
45
|
const min = getStartOfDay(minProp);
|
|
52
46
|
const max = getStartOfDay(maxProp);
|
|
53
|
-
const disabledReasonId = useId();
|
|
54
|
-
const disabledRulesRef = useRef(disabledRules);
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
disabledRulesRef.current = disabledRules;
|
|
57
|
-
});
|
|
58
|
-
const [focusedDate, setFocusedDate] = useState(selectedDate);
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
61
|
-
setFocusedDate(selectedDate);
|
|
62
|
-
}, [selectedDate?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
63
|
-
const checkIsEnabled = date => {
|
|
64
|
-
if (!date) return true;
|
|
65
|
-
return isWithinRange(date, min, max) && !isDateDisabled(date, disabledRulesRef.current);
|
|
66
|
-
};
|
|
67
|
-
const focusedDateDisabled = focusedDate ? !isWithinRange(focusedDate, min, max) || isDateDisabled(focusedDate, disabledRules) : false;
|
|
68
47
|
useEffect(() => {
|
|
69
48
|
if (selectedDate && !isWithinRange(selectedDate, min, max)) {
|
|
70
|
-
|
|
71
|
-
setFocusedDate(clamped); // eslint-disable-line react-hooks/set-state-in-effect
|
|
72
|
-
onDateFocus?.(clamped, {
|
|
73
|
-
isEnabled: checkIsEnabled(clamped)
|
|
74
|
-
});
|
|
49
|
+
onChange(moveToWithinRange(selectedDate, min, max));
|
|
75
50
|
}
|
|
76
|
-
}, [selectedDate?.getTime(), min?.getTime(), max?.getTime(),
|
|
51
|
+
}, [selectedDate?.getTime(), min?.getTime(), max?.getTime(), onChange]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
77
52
|
const dateView = returnDateView(selectedDate, min, max);
|
|
78
53
|
const [viewMonth, setViewMonth] = useState(dateView.getMonth());
|
|
79
54
|
const [viewYear, setViewYear] = useState(dateView.getFullYear());
|
|
@@ -84,13 +59,6 @@ const Calendar = ({
|
|
|
84
59
|
setViewMonth(view.getMonth());
|
|
85
60
|
setViewYear(view.getFullYear());
|
|
86
61
|
}, [selectedDate?.getTime(), min?.getTime(), max?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
if (focusedDate) {
|
|
89
|
-
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
90
|
-
setViewMonth(focusedDate.getMonth());
|
|
91
|
-
setViewYear(focusedDate.getFullYear());
|
|
92
|
-
}
|
|
93
|
-
}, [focusedDate?.getTime()]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
94
62
|
const handleViewDateUpdate = useCallback(
|
|
95
63
|
// eslint-disable-next-line react-hooks/preserve-manual-memoization
|
|
96
64
|
({
|
|
@@ -104,31 +72,24 @@ const Calendar = ({
|
|
|
104
72
|
const switchToMonths = useCallback(() => setMode('month'), []);
|
|
105
73
|
const switchToYears = useCallback(() => setMode('year'), []);
|
|
106
74
|
const handleSelectedDateUpdate = useCallback(date => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
isEnabled
|
|
111
|
-
});
|
|
112
|
-
if (isEnabled && onChange) {
|
|
75
|
+
if (onSelect) {
|
|
76
|
+
onSelect(date);
|
|
77
|
+
} else {
|
|
113
78
|
onChange(date);
|
|
114
79
|
}
|
|
115
|
-
}, [
|
|
80
|
+
}, [onChange, onSelect]);
|
|
116
81
|
const adjustDate = useCallback((daysToAdd, monthsToAdd, yearsToAdd) => {
|
|
117
|
-
const base = focusedDate ?? selectedDate;
|
|
118
82
|
let date;
|
|
119
|
-
if (
|
|
120
|
-
date = new Date(mode === 'year' ?
|
|
83
|
+
if (selectedDate) {
|
|
84
|
+
date = new Date(mode === 'year' ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(), mode === 'month' ? selectedDate.getMonth() + monthsToAdd : selectedDate.getMonth(), mode === 'day' ? selectedDate.getDate() + daysToAdd : selectedDate.getDate());
|
|
121
85
|
} else {
|
|
122
86
|
date = getStartOfDay(new Date());
|
|
123
87
|
}
|
|
124
88
|
date &&= moveToWithinRange(date, min, max);
|
|
125
|
-
if (date?.getTime() !==
|
|
126
|
-
|
|
127
|
-
onDateFocus?.(date, {
|
|
128
|
-
isEnabled: checkIsEnabled(date)
|
|
129
|
-
});
|
|
89
|
+
if (date?.getTime() !== selectedDate?.getTime()) {
|
|
90
|
+
onChange(date);
|
|
130
91
|
}
|
|
131
|
-
}, [
|
|
92
|
+
}, [selectedDate, min, max, mode, onChange]);
|
|
132
93
|
const handleKeyDown = useCallback(event => {
|
|
133
94
|
switch (event.key) {
|
|
134
95
|
case 'ArrowLeft':
|
|
@@ -147,36 +108,8 @@ const Calendar = ({
|
|
|
147
108
|
adjustDate(7, 4, 4);
|
|
148
109
|
event.preventDefault();
|
|
149
110
|
break;
|
|
150
|
-
case 'Enter':
|
|
151
|
-
case ' ':
|
|
152
|
-
if (mode === 'day' && focusedDate && event.target.hasAttribute('data-calendar-cell')) {
|
|
153
|
-
handleSelectedDateUpdate(focusedDate);
|
|
154
|
-
event.preventDefault();
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
111
|
}
|
|
158
|
-
}, [adjustDate
|
|
159
|
-
const focusedDateOutOfRange = focusedDate ? !isWithinRange(focusedDate, min, max) : false;
|
|
160
|
-
const formatDateForPrompt = date => formatDate(date, intl.locale, {
|
|
161
|
-
day: 'numeric',
|
|
162
|
-
month: 'long',
|
|
163
|
-
year: 'numeric'
|
|
164
|
-
});
|
|
165
|
-
const outOfRangePromptText = min && max ? intl.formatMessage(messages.outOfRangeBetween, {
|
|
166
|
-
min: formatDateForPrompt(min),
|
|
167
|
-
max: formatDateForPrompt(max)
|
|
168
|
-
}) : min ? intl.formatMessage(messages.outOfRangeAfter, {
|
|
169
|
-
min: formatDateForPrompt(min)
|
|
170
|
-
}) : max ? intl.formatMessage(messages.outOfRangeBefore, {
|
|
171
|
-
max: formatDateForPrompt(max)
|
|
172
|
-
}) : '';
|
|
173
|
-
const hasOutOfRangeDates = mode === 'day' && !!(min || max);
|
|
174
|
-
const showRulesPrompt = mode === 'day' && !!disabledRules && hasDisabledDatesInMonth(viewMonth, viewYear, disabledRules, min, max);
|
|
175
|
-
const showOutOfRangePrompt = mode === 'day' && focusedDateOutOfRange;
|
|
176
|
-
const showPrompt = hasOutOfRangeDates || showRulesPrompt;
|
|
177
|
-
const promptText = showOutOfRangePrompt ? outOfRangePromptText : disabledRules?.reason ?? outOfRangePromptText;
|
|
178
|
-
const promptSentiment = showOutOfRangePrompt || focusedDateDisabled ? 'negative' : 'neutral';
|
|
179
|
-
const promptClassName = showOutOfRangePrompt || showRulesPrompt && !showOutOfRangePrompt ? 'm-t-1' : 'sr-only';
|
|
112
|
+
}, [adjustDate]);
|
|
180
113
|
return (
|
|
181
114
|
/*#__PURE__*/
|
|
182
115
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
@@ -184,20 +117,16 @@ const Calendar = ({
|
|
|
184
117
|
onKeyDown: handleKeyDown,
|
|
185
118
|
children: [mode === 'day' && /*#__PURE__*/jsx(DayCalendar, {
|
|
186
119
|
selectedDate: selectedDate,
|
|
187
|
-
focusedDate: focusedDate,
|
|
188
120
|
min: min,
|
|
189
121
|
max: max,
|
|
190
122
|
viewMonth: viewMonth,
|
|
191
123
|
viewYear: viewYear,
|
|
192
124
|
monthFormat: monthFormat,
|
|
193
|
-
disabledRules: disabledRules,
|
|
194
|
-
disabledReasonId: showPrompt ? disabledReasonId : undefined,
|
|
195
125
|
onSelect: handleSelectedDateUpdate,
|
|
196
126
|
onLabelClick: switchToYears,
|
|
197
127
|
onViewDateUpdate: handleViewDateUpdate
|
|
198
128
|
}), mode === 'month' && /*#__PURE__*/jsx(MonthCalendar, {
|
|
199
129
|
selectedDate: selectedDate,
|
|
200
|
-
focusedDate: focusedDate,
|
|
201
130
|
min: min,
|
|
202
131
|
max: max,
|
|
203
132
|
viewYear: viewYear,
|
|
@@ -209,7 +138,6 @@ const Calendar = ({
|
|
|
209
138
|
onViewDateUpdate: handleViewDateUpdate
|
|
210
139
|
}), mode === 'year' && /*#__PURE__*/jsx(YearCalendar, {
|
|
211
140
|
selectedDate: selectedDate,
|
|
212
|
-
focusedDate: focusedDate,
|
|
213
141
|
min: min,
|
|
214
142
|
max: max,
|
|
215
143
|
viewYear: viewYear,
|
|
@@ -218,12 +146,6 @@ const Calendar = ({
|
|
|
218
146
|
}),
|
|
219
147
|
onSelect: switchToMonths,
|
|
220
148
|
onViewDateUpdate: handleViewDateUpdate
|
|
221
|
-
}), showPrompt && /*#__PURE__*/jsx(InlinePrompt, {
|
|
222
|
-
sentiment: promptSentiment,
|
|
223
|
-
width: "full",
|
|
224
|
-
id: disabledReasonId,
|
|
225
|
-
className: promptClassName,
|
|
226
|
-
children: promptText
|
|
227
149
|
})]
|
|
228
150
|
})
|
|
229
151
|
);
|