@stenajs-webui/calendar 14.1.1 → 15.0.0-alpha.10
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/dist/components/calendar/CalendarMonth.d.ts +3 -3
- package/dist/components/calendar/CalendarWeek.d.ts +3 -3
- package/dist/components/calendar/DisabledDayWrapper.d.ts +7 -0
- package/dist/components/calendar-types/date-range-calendar/DateRangeCalendar.d.ts +4 -11
- package/dist/components/calendar-types/date-range-calendar/DateRangeCalendar.stories.d.ts +2 -0
- package/dist/components/calendar-types/date-range-calendar/hooks/UseDateRangeSelection.d.ts +1 -1
- package/dist/components/calendar-types/date-range-exclusion-calendar/DateRangeExclusionCalendar.d.ts +2 -3
- package/dist/components/calendar-types/date-range-exclusion-calendar/UseDateRangeExclusionSelection.d.ts +1 -1
- package/dist/components/input-types/date-input/DateInput.d.ts +2 -1
- package/dist/components/input-types/date-input/DateInput.stories.d.ts +2 -0
- package/dist/components/input-types/date-range-dual-text-input/DateRangeDualTextInput.d.ts +8 -4
- package/dist/components/input-types/date-range-dual-text-input/DateRangeDualTextInput.stories.d.ts +5 -2
- package/dist/components/input-types/date-range-input/DateRangeInput.d.ts +7 -8
- package/dist/components/input-types/date-range-input/DateRangeInput.stories.d.ts +2 -1
- package/dist/components/input-types/date-range-input/hooks/UseDateRangeInput.d.ts +3 -2
- package/dist/components/input-types/date-text-input/DateTextInput.d.ts +2 -1
- package/dist/components/input-types/date-time-input/DateTimeInput.d.ts +2 -1
- package/dist/components/input-types/date-time-input/DateTimeInput.stories.d.ts +1 -0
- package/dist/config/DefaultMaxDate.d.ts +1 -0
- package/dist/features/date-range/hooks/UseDateRangeOnClickDayHandler.d.ts +2 -5
- package/dist/features/dual-text-input/DualTextInput.d.ts +4 -0
- package/dist/features/month-switcher/CalendarWithMonthSwitcher.d.ts +2 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.es.js +341 -321
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +367 -324
- package/dist/index.js.map +1 -1
- package/dist/types/CalendarTypes.d.ts +21 -1
- package/dist/types/DateRange.d.ts +16 -0
- package/dist/util/calendar/StateModifier.d.ts +1 -0
- package/dist/util/date/DateMinMaxValidator.d.ts +1 -0
- package/dist/util/date/__tests__/DateMinMaxValidator.test.d.ts +1 -0
- package/dist/util/date-range/DateRangeTransformer.d.ts +3 -0
- package/dist/util/date-range/DateRangeValidator.d.ts +4 -0
- package/dist/util/date-range/__tests__/DateRangeValidator.test.d.ts +1 -0
- package/package.json +8 -9
- package/dist/components/calendar-types/date-range-calendar/util/IntervalSwitcher.d.ts +0 -4
- package/dist/util/calendar/CalendarIntervalValidator.d.ts +0 -11
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useMemo, useCallback, useState, useEffect, useRef } from 'react';
|
|
2
3
|
import { FlatButton, PrimaryButton, Icon, stenaArrowRight } from '@stenajs-webui/elements';
|
|
3
4
|
import { Box, Text, Clickable, Row, Space, Spacing, Indent, Column, SeparatorLine, parseIntElseUndefined, useBoolean, useDelayedFalse } from '@stenajs-webui/core';
|
|
4
|
-
import { isAfter, eachDayOfInterval, isSameDay, endOfMonth, startOfMonth, min, addDays, max, subDays, format, getISOWeek, getDate, startOfISOWeek, addWeeks, getMonth, getYear, getISODay, addHours, addMonths, addYears, subMonths, subYears,
|
|
5
|
+
import { isAfter, eachDayOfInterval, isSameDay, endOfMonth, startOfMonth, min, addDays, max, subDays, format, getISOWeek, getDate, startOfISOWeek, addWeeks, getMonth, getYear, getISODay, addHours, isBefore, parse, addMonths, addYears, subMonths, subYears, isValid } from 'date-fns';
|
|
5
6
|
import { last, chunk, range, debounce } from 'lodash';
|
|
6
7
|
import styled from '@emotion/styled';
|
|
7
8
|
import { faAngleLeft } from '@fortawesome/free-solid-svg-icons/faAngleLeft';
|
|
@@ -10,14 +11,14 @@ import { faAngleDoubleLeft } from '@fortawesome/free-solid-svg-icons/faAngleDoub
|
|
|
10
11
|
import { faAngleDoubleRight } from '@fortawesome/free-solid-svg-icons/faAngleDoubleRight';
|
|
11
12
|
import { faCaretLeft } from '@fortawesome/free-solid-svg-icons/faCaretLeft';
|
|
12
13
|
import { faCaretRight } from '@fortawesome/free-solid-svg-icons/faCaretRight';
|
|
13
|
-
import { faCalendarAlt } from '@fortawesome/free-
|
|
14
|
+
import { faCalendarAlt } from '@fortawesome/free-regular-svg-icons/faCalendarAlt';
|
|
14
15
|
import { TextInput, TextInputBox } from '@stenajs-webui/forms';
|
|
15
16
|
import { useTippyInstance, Popover } from '@stenajs-webui/tooltip';
|
|
17
|
+
import { faCalendarAlt as faCalendarAlt$1 } from '@fortawesome/free-solid-svg-icons/faCalendarAlt';
|
|
16
18
|
import { cssColor } from '@stenajs-webui/theme';
|
|
17
19
|
import { faLongArrowAltRight } from '@fortawesome/free-solid-svg-icons/faLongArrowAltRight';
|
|
18
20
|
import { faClock } from '@fortawesome/free-solid-svg-icons/faClock';
|
|
19
21
|
import { faClock as faClock$1 } from '@fortawesome/free-regular-svg-icons/faClock';
|
|
20
|
-
import { faCalendarAlt as faCalendarAlt$1 } from '@fortawesome/free-regular-svg-icons/faCalendarAlt';
|
|
21
22
|
import { faAngleDown } from '@fortawesome/free-solid-svg-icons/faAngleDown';
|
|
22
23
|
|
|
23
24
|
/*! *****************************************************************************
|
|
@@ -58,12 +59,14 @@ function __rest(s, e) {
|
|
|
58
59
|
return t;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
function __spreadArray(to, from, pack) {
|
|
63
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
64
|
+
if (ar || !(i in from)) {
|
|
65
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
66
|
+
ar[i] = from[i];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
var DateFormats = {
|
|
@@ -75,7 +78,7 @@ var DateFormats = {
|
|
|
75
78
|
weekDayName: "EEEE",
|
|
76
79
|
weekDayNameShort: "EEE",
|
|
77
80
|
dateAndMonth: "d MMM",
|
|
78
|
-
monthAndDate: "MMM do",
|
|
81
|
+
monthAndDate: "MMM do", // Jan 2nd
|
|
79
82
|
};
|
|
80
83
|
|
|
81
84
|
var buildDayStateForDateRange = function (statePerMonth, start, end) {
|
|
@@ -147,11 +150,13 @@ var addDayStateHighlights = function (calendarState, date, highlights) {
|
|
|
147
150
|
calendarState[monthString] &&
|
|
148
151
|
calendarState[monthString][weekNumber] &&
|
|
149
152
|
calendarState[monthString][weekNumber][dayInMonth];
|
|
150
|
-
var newHighlights = dayState && dayState.highlights
|
|
151
|
-
? __spreadArrays(dayState.highlights, highlights) : highlights;
|
|
152
153
|
return __assign(__assign({}, calendarState), (_a = {}, _a[monthString] = __assign(__assign({}, (calendarState && calendarState[monthString])), (_b = {}, _b[weekNumber] = __assign(__assign({}, (calendarState &&
|
|
153
154
|
calendarState[monthString] &&
|
|
154
|
-
calendarState[monthString][weekNumber])), (_c = {}, _c[dayInMonth] =
|
|
155
|
+
calendarState[monthString][weekNumber])), (_c = {}, _c[dayInMonth] = addDayStateHighlightsOnSingleDay(dayState, highlights), _c)), _b)), _a));
|
|
156
|
+
};
|
|
157
|
+
var addDayStateHighlightsOnSingleDay = function (dayState, highlights) {
|
|
158
|
+
var _a;
|
|
159
|
+
return __assign(__assign({}, dayState), { highlights: __spreadArray(__spreadArray([], ((_a = dayState === null || dayState === void 0 ? void 0 : dayState.highlights) !== null && _a !== void 0 ? _a : []), true), highlights, true) });
|
|
155
160
|
};
|
|
156
161
|
var addWeekStateHighlights = function (calendarState, week, highlights) {
|
|
157
162
|
var _a, _b;
|
|
@@ -165,7 +170,7 @@ var addWeekStateHighlights = function (calendarState, week, highlights) {
|
|
|
165
170
|
});
|
|
166
171
|
var weekState = state && state[monthString] ? state[monthString][weekNumber] : undefined;
|
|
167
172
|
var newHighlights = weekState && weekState.highlights
|
|
168
|
-
?
|
|
173
|
+
? __spreadArray(__spreadArray([], weekState.highlights, true), highlights, true) : highlights;
|
|
169
174
|
var newWeekState = __assign(__assign({}, weekState), { highlights: newHighlights });
|
|
170
175
|
return __assign(__assign({}, state), (_a = {}, _a[monthString] = __assign(__assign({}, (calendarState && calendarState[monthString])), (_b = {}, _b[weekNumber] = newWeekState, _b)), _a));
|
|
171
176
|
};
|
|
@@ -399,42 +404,62 @@ var defaultCalendarTheme = {
|
|
|
399
404
|
};
|
|
400
405
|
var extranetCalendarTheme = __assign(__assign({}, defaultCalendarTheme), { width: "37px", height: "37px" });
|
|
401
406
|
|
|
407
|
+
var isDateInMinMaxRange = function (date, min, max) {
|
|
408
|
+
if (min && isBefore(date, min)) {
|
|
409
|
+
return isSameDay(date, min);
|
|
410
|
+
}
|
|
411
|
+
if (max && isAfter(date, max)) {
|
|
412
|
+
return isSameDay(date, max);
|
|
413
|
+
}
|
|
414
|
+
return true;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
var DisabledDayWrapper = function DisabledDayWrapper(_a) {
|
|
418
|
+
var DayComponent = _a.dayComponent, minDate = _a.minDate, maxDate = _a.maxDate, dayState = _a.dayState, day = _a.day, props = __rest(_a, ["dayComponent", "minDate", "maxDate", "dayState", "day"]);
|
|
419
|
+
var activeDayState = useMemo(function () {
|
|
420
|
+
return !isDateInMinMaxRange(day.date, minDate, maxDate)
|
|
421
|
+
? addDayStateHighlightsOnSingleDay(dayState, ["disabled"])
|
|
422
|
+
: dayState;
|
|
423
|
+
}, [day.date, dayState, maxDate, minDate]);
|
|
424
|
+
return React.createElement(DayComponent, __assign({ day: day }, props, { dayState: activeDayState }));
|
|
425
|
+
};
|
|
426
|
+
|
|
402
427
|
var WeekNumberCell = function (_a) {
|
|
403
428
|
var onClickWeek = _a.onClickWeek, theme = _a.theme, week = _a.week, background = _a.background, backgroundColor = _a.backgroundColor, prefix = _a.prefix;
|
|
404
|
-
var content = (createElement(Box, { width: theme.width, height: theme.height, justifyContent: "center", alignItems: "center" },
|
|
405
|
-
background && createElement(Box, { position: "absolute" }, background),
|
|
406
|
-
createElement(Box, { position: "absolute" },
|
|
407
|
-
createElement(Text, { color: onClickWeek
|
|
429
|
+
var content = (React.createElement(Box, { width: theme.width, height: theme.height, justifyContent: "center", alignItems: "center" },
|
|
430
|
+
background && React.createElement(Box, { position: "absolute" }, background),
|
|
431
|
+
React.createElement(Box, { position: "absolute" },
|
|
432
|
+
React.createElement(Text, { color: onClickWeek
|
|
408
433
|
? theme.WeekNumber.clickableTextColor
|
|
409
434
|
: theme.WeekNumber.textColor },
|
|
410
435
|
prefix,
|
|
411
436
|
week.weekNumber))));
|
|
412
|
-
return (createElement(Box, { background: backgroundColor || theme.WeekNumber.backgroundColor, position: "relative" }, onClickWeek ? (createElement(Clickable, { borderRadius: "var(--swui-calendar-day-border-radius)", onClick: function (ev) { return onClickWeek(week, ev); }, disableFocusHighlight: !onClickWeek }, content)) : (content)));
|
|
437
|
+
return (React.createElement(Box, { background: backgroundColor || theme.WeekNumber.backgroundColor, position: "relative" }, onClickWeek ? (React.createElement(Clickable, { borderRadius: "var(--swui-calendar-day-border-radius)", onClick: function (ev) { return onClickWeek(week, ev); }, disableFocusHighlight: !onClickWeek }, content)) : (content)));
|
|
413
438
|
};
|
|
414
439
|
|
|
415
440
|
function CalendarWeek(_a) {
|
|
416
|
-
var week = _a.week, month = _a.month,
|
|
417
|
-
return (createElement("tr", { key: week.weekNumber },
|
|
418
|
-
theme.WeekNumber.show && (createElement("td", null, renderWeekNumber ? (renderWeekNumber(week, theme, onClickWeek)) : (createElement(WeekNumberCell, { week: week, onClickWeek: onClickWeek, theme: theme })))),
|
|
419
|
-
week.days.map(function (day) { return (createElement(
|
|
441
|
+
var week = _a.week, month = _a.month, dayComponent = _a.dayComponent, statePerWeekDay = _a.statePerWeekDay, userDataPerWeekDay = _a.userDataPerWeekDay, minDate = _a.minDate, maxDate = _a.maxDate, onClickWeek = _a.onClickWeek, onClickDay = _a.onClickDay, theme = _a.theme, renderWeekNumber = _a.renderWeekNumber, extraDayContent = _a.extraDayContent, defaultHighlights = _a.defaultHighlights;
|
|
442
|
+
return (React.createElement("tr", { key: week.weekNumber },
|
|
443
|
+
theme.WeekNumber.show && (React.createElement("td", null, renderWeekNumber ? (renderWeekNumber(week, theme, onClickWeek)) : (React.createElement(WeekNumberCell, { week: week, onClickWeek: onClickWeek, theme: theme })))),
|
|
444
|
+
week.days.map(function (day) { return (React.createElement(DisabledDayWrapper, { dayComponent: dayComponent, key: day.dateString, day: day, week: week, month: month, dayState: statePerWeekDay && statePerWeekDay[day.dayOfMonth], userData: userDataPerWeekDay && userDataPerWeekDay[day.dayOfMonth], onClickDay: onClickDay, theme: theme, extraDayContent: extraDayContent, defaultHighlights: defaultHighlights, minDate: minDate, maxDate: maxDate })); })));
|
|
420
445
|
}
|
|
421
446
|
|
|
422
447
|
var WeekDayCell = function (_a) {
|
|
423
448
|
var onClickWeekDay = _a.onClickWeekDay, day = _a.day, theme = _a.theme;
|
|
424
|
-
var content = (createElement(Box, { width: theme.width, height: theme.height, justifyContent: "center", alignItems: "center" },
|
|
425
|
-
createElement(Text, { size: "small", color: onClickWeekDay
|
|
449
|
+
var content = (React.createElement(Box, { width: theme.width, height: theme.height, justifyContent: "center", alignItems: "center" },
|
|
450
|
+
React.createElement(Text, { size: "small", color: onClickWeekDay
|
|
426
451
|
? theme.WeekDay.clickableTextColor
|
|
427
452
|
: theme.WeekDay.textColor }, day.name)));
|
|
428
453
|
if (onClickWeekDay) {
|
|
429
|
-
return (createElement(Clickable, { borderRadius: "var(--swui-calendar-day-border-radius)", onClick: function (ev) { return onClickWeekDay(day.dayOfWeek, ev); }, disableFocusHighlight: !onClickWeekDay }, content));
|
|
454
|
+
return (React.createElement(Clickable, { borderRadius: "var(--swui-calendar-day-border-radius)", onClick: function (ev) { return onClickWeekDay(day.dayOfWeek, ev); }, disableFocusHighlight: !onClickWeekDay }, content));
|
|
430
455
|
}
|
|
431
456
|
return content;
|
|
432
457
|
};
|
|
433
458
|
|
|
434
|
-
var CalendarDay = function (_a) {
|
|
459
|
+
var CalendarDay = function CalendarDay(_a) {
|
|
435
460
|
var day = _a.day, week = _a.week, month = _a.month, dayState = _a.dayState, userData = _a.userData, onClickDay = _a.onClickDay, theme = _a.theme, ExtraDayContent = _a.extraDayContent, defaultHighlights = _a.defaultHighlights;
|
|
436
|
-
var content = (createElement(Box, { width: "100%", height: "100%", justifyContent: "center", alignItems: "center" },
|
|
437
|
-
createElement(Text, __assign({}, (theme.CalendarDay.textProps &&
|
|
461
|
+
var content = (React.createElement(Box, { width: "100%", height: "100%", justifyContent: "center", alignItems: "center" },
|
|
462
|
+
React.createElement(Text, __assign({}, (theme.CalendarDay.textProps &&
|
|
438
463
|
theme.CalendarDay.textProps(defaultHighlights, dayState, day, week, month, userData))), day.dayOfMonth)));
|
|
439
464
|
var WrapperTd = styled.td(__assign({}, (theme.CalendarDay.tdStyle &&
|
|
440
465
|
theme.CalendarDay.tdStyle(defaultHighlights, dayState, day, week, month, userData))));
|
|
@@ -442,36 +467,36 @@ var CalendarDay = function (_a) {
|
|
|
442
467
|
theme.CalendarDay.innerWrapperStyle(defaultHighlights, dayState, day, week, month, userData))), { width: "100%", height: "100%" }));
|
|
443
468
|
var CellWrapperDiv = styled.div(__assign(__assign({}, (theme.CalendarDay.cellWrapperStyle &&
|
|
444
469
|
theme.CalendarDay.cellWrapperStyle(defaultHighlights, dayState, day, week, month, userData))), { width: "100%", height: "100%", position: "relative" }));
|
|
445
|
-
return (createElement(WrapperTd, null,
|
|
446
|
-
createElement(InnerWrapperDiv, null,
|
|
447
|
-
createElement(CellWrapperDiv, null, day.month === month.monthInYear && (createElement(Fragment, null,
|
|
448
|
-
ExtraDayContent && (createElement(ExtraDayContent, { week: week, month: month, day: day, dayState: dayState, theme: theme, userData: userData })),
|
|
449
|
-
onClickDay && isClickable(defaultHighlights, dayState) ? (createElement(Clickable, { onClick: function (ev) { return onClickDay(day, userData, ev); }, style: { width: "100%", height: "100%" }, borderRadius: "var(--swui-calendar-day-border-radius)" }, content)) : (createElement(Fragment, null, content))))))));
|
|
470
|
+
return (React.createElement(WrapperTd, null,
|
|
471
|
+
React.createElement(InnerWrapperDiv, null,
|
|
472
|
+
React.createElement(CellWrapperDiv, null, day.month === month.monthInYear && (React.createElement(React.Fragment, null,
|
|
473
|
+
ExtraDayContent && (React.createElement(ExtraDayContent, { week: week, month: month, day: day, dayState: dayState, theme: theme, userData: userData })),
|
|
474
|
+
onClickDay && isClickable(defaultHighlights, dayState) ? (React.createElement(Clickable, { onClick: function (ev) { return onClickDay(day, userData, ev); }, style: { width: "100%", height: "100%" }, borderRadius: "var(--swui-calendar-day-border-radius)" }, content)) : (React.createElement(React.Fragment, null, content))))))));
|
|
450
475
|
};
|
|
451
476
|
var isClickable = function (defaultHighlights, dayState) {
|
|
452
477
|
return !!dayHighlightSelect(dayState, defaultHighlights, ["enabled", "disabled"], [true, false], true);
|
|
453
478
|
};
|
|
454
479
|
|
|
455
480
|
function CalendarMonth(_a) {
|
|
456
|
-
var month = _a.month, _b = _a.dayComponent, dayComponent = _b === void 0 ? CalendarDay : _b, statePerWeek = _a.statePerWeek, userDataPerWeek = _a.userDataPerWeek, onClickDay = _a.onClickDay, onClickWeek = _a.onClickWeek, onClickWeekDay = _a.onClickWeekDay, onClickMonth = _a.onClickMonth, onClickYear = _a.onClickYear, renderWeekNumber = _a.renderWeekNumber, renderWeekDay = _a.renderWeekDay, headerLeftContent = _a.headerLeftContent, headerRightContent = _a.headerRightContent, _c = _a.theme, theme = _c === void 0 ? defaultCalendarTheme : _c, extraDayContent = _a.extraDayContent, defaultHighlights = _a.defaultHighlights;
|
|
481
|
+
var month = _a.month, _b = _a.dayComponent, dayComponent = _b === void 0 ? CalendarDay : _b, statePerWeek = _a.statePerWeek, userDataPerWeek = _a.userDataPerWeek, minDate = _a.minDate, maxDate = _a.maxDate, onClickDay = _a.onClickDay, onClickWeek = _a.onClickWeek, onClickWeekDay = _a.onClickWeekDay, onClickMonth = _a.onClickMonth, onClickYear = _a.onClickYear, renderWeekNumber = _a.renderWeekNumber, renderWeekDay = _a.renderWeekDay, headerLeftContent = _a.headerLeftContent, headerRightContent = _a.headerRightContent, _c = _a.theme, theme = _c === void 0 ? defaultCalendarTheme : _c, extraDayContent = _a.extraDayContent, defaultHighlights = _a.defaultHighlights;
|
|
457
482
|
var showWeekNumber = theme.WeekNumber.show;
|
|
458
|
-
return (createElement(Fragment, null,
|
|
459
|
-
createElement(Box, { alignItems: "stretch" },
|
|
460
|
-
createElement(Row, { justifyContent: "space-between", alignItems: "center", height: "32px" },
|
|
461
|
-
createElement(Box, { alignItems: "center" }, headerLeftContent),
|
|
462
|
-
createElement(Row, { alignItems: "center" },
|
|
463
|
-
createElement(Row, { width: "104px", justifyContent: "center" }, onClickMonth ? (createElement(FlatButton, { onClick: function () { return onClickMonth(month); }, label: month.name })) : (createElement(Text, null, month.name))),
|
|
464
|
-
createElement(Space, null),
|
|
465
|
-
createElement(Row, { width: "64px", justifyContent: "center" }, onClickYear ? (createElement(FlatButton, { onClick: function () { return onClickYear(month.year); }, label: String(month.year) })) : (createElement(Text, null, month.year)))),
|
|
466
|
-
createElement(Box, { alignItems: "center" }, headerRightContent)),
|
|
467
|
-
createElement("table", null,
|
|
468
|
-
createElement("tbody", null,
|
|
469
|
-
createElement("tr", null,
|
|
470
|
-
showWeekNumber && (createElement("td", null,
|
|
471
|
-
createElement(Box, { width: theme.width, height: theme.height, justifyContent: "center", alignItems: "center" },
|
|
472
|
-
createElement(Text, { size: "small", color: theme.CalendarMonth.headerTextColor }, "W")))),
|
|
473
|
-
month.weeks[0].days.map(function (day) { return (createElement("td", { key: day.name }, renderWeekDay ? (renderWeekDay(day.name, theme, onClickWeekDay)) : (createElement(WeekDayCell, { day: day, onClickWeekDay: onClickWeekDay, theme: theme })))); })),
|
|
474
|
-
month.weeks.map(function (week) { return (createElement(CalendarWeek, { key: week.weekNumber, month: month, week: week, dayComponent: dayComponent, statePerWeekDay: statePerWeek && statePerWeek[week.weekNumber], userDataPerWeekDay: userDataPerWeek && userDataPerWeek[week.weekNumber], onClickDay: onClickDay, onClickWeek: onClickWeek, theme: theme, renderWeekNumber: renderWeekNumber, extraDayContent: extraDayContent, defaultHighlights: defaultHighlights })); }))))));
|
|
483
|
+
return (React.createElement(React.Fragment, null,
|
|
484
|
+
React.createElement(Box, { alignItems: "stretch" },
|
|
485
|
+
React.createElement(Row, { justifyContent: "space-between", alignItems: "center", height: "32px" },
|
|
486
|
+
React.createElement(Box, { alignItems: "center" }, headerLeftContent),
|
|
487
|
+
React.createElement(Row, { alignItems: "center" },
|
|
488
|
+
React.createElement(Row, { width: "104px", justifyContent: "center" }, onClickMonth ? (React.createElement(FlatButton, { onClick: function () { return onClickMonth(month); }, label: month.name })) : (React.createElement(Text, null, month.name))),
|
|
489
|
+
React.createElement(Space, null),
|
|
490
|
+
React.createElement(Row, { width: "64px", justifyContent: "center" }, onClickYear ? (React.createElement(FlatButton, { onClick: function () { return onClickYear(month.year); }, label: String(month.year) })) : (React.createElement(Text, null, month.year)))),
|
|
491
|
+
React.createElement(Box, { alignItems: "center" }, headerRightContent)),
|
|
492
|
+
React.createElement("table", null,
|
|
493
|
+
React.createElement("tbody", null,
|
|
494
|
+
React.createElement("tr", null,
|
|
495
|
+
showWeekNumber && (React.createElement("td", null,
|
|
496
|
+
React.createElement(Box, { width: theme.width, height: theme.height, justifyContent: "center", alignItems: "center" },
|
|
497
|
+
React.createElement(Text, { size: "small", color: theme.CalendarMonth.headerTextColor }, "W")))),
|
|
498
|
+
month.weeks[0].days.map(function (day) { return (React.createElement("td", { key: day.name }, renderWeekDay ? (renderWeekDay(day.name, theme, onClickWeekDay)) : (React.createElement(WeekDayCell, { day: day, onClickWeekDay: onClickWeekDay, theme: theme })))); })),
|
|
499
|
+
month.weeks.map(function (week) { return (React.createElement(CalendarWeek, { key: week.weekNumber, month: month, week: week, dayComponent: dayComponent, statePerWeekDay: statePerWeek && statePerWeek[week.weekNumber], userDataPerWeekDay: userDataPerWeek && userDataPerWeek[week.weekNumber], onClickDay: onClickDay, onClickWeek: onClickWeek, theme: theme, renderWeekNumber: renderWeekNumber, extraDayContent: extraDayContent, defaultHighlights: defaultHighlights, minDate: minDate, maxDate: maxDate })); }))))));
|
|
475
500
|
}
|
|
476
501
|
|
|
477
502
|
function styleInject(css, ref) {
|
|
@@ -501,23 +526,25 @@ function styleInject(css, ref) {
|
|
|
501
526
|
}
|
|
502
527
|
}
|
|
503
528
|
|
|
504
|
-
var css_248z = ".Calendar-module_calendar__Ztvgm {\n --swui-calendar-day-width: 40px;\n --swui-calendar-day-height: 38px;\n --swui-calendar-day-border-radius: 4px;\n\n /* Week number */\n\n --swui-calendar-week-number-bg-color: transparent;\n --swui-calendar-week-number-text-color: var(--lhds-color-ui-500);\n --swui-calendar-week-number-clickable-text-color: var(--lhds-color-ui-500);\n\n /* Week day */\n\n --swui-calendar-week-day-text-color: var(--lhds-color-ui-500);\n --swui-calendar-week-day-clickable-text-color: var(--lhds-color-ui-500);\n\n /* Wrapper */\n\n --swui-calendar-wrapper-selected-border: var(--swui-primary-action-color);\n --swui-calendar-wrapper-selected-background: var(--swui-primary-action-color);\n --swui-calendar-wrapper-range-border: var(--lhds-color-blue-100);\n --swui-calendar-wrapper-range-background: var(--lhds-color-blue-100);\n --swui-calendar-wrapper-today-border: var(--lhds-color-ui-200);\n --swui-calendar-wrapper-today-background: var(--lhds-color-ui-200);\n\n /* Text */\n\n --swui-calendar-text-selected-color: #fff;\n --swui-calendar-text-disabled-color: var(--swui-text-disabled-color);\n --swui-calendar-text-in-other-month-color: var(--swui-text-disabled-color);\n}\n\n .Calendar-module_calendar__Ztvgm table {\n border-spacing: 0 4px;\n }\n\n .Calendar-module_calendar__Ztvgm span {\n line-height: 100%;\n }\n\n .Calendar-module_calendar__Ztvgm tr td:last-child {\n border-top-right-radius: var(--swui-calendar-day-border-radius);\n border-bottom-right-radius: var(--swui-calendar-day-border-radius);\n }\n\n .Calendar-module_calendar__Ztvgm tr td:nth-child(2) {\n border-top-left-radius: var(--swui-calendar-day-border-radius);\n border-bottom-left-radius: var(--swui-calendar-day-border-radius);\n }\n\n .Calendar-module_calendar__Ztvgm td {\n padding: 0;\n width: var(--swui-calendar-day-width);\n height: var(--swui-calendar-day-height);\n }\n";
|
|
505
|
-
var styles = {"calendar":"Calendar-module_calendar__Ztvgm"};
|
|
506
|
-
styleInject(css_248z);
|
|
529
|
+
var css_248z$1 = ".Calendar-module_calendar__Ztvgm {\n --swui-calendar-day-width: 40px;\n --swui-calendar-day-height: 38px;\n --swui-calendar-day-border-radius: 4px;\n\n /* Week number */\n\n --swui-calendar-week-number-bg-color: transparent;\n --swui-calendar-week-number-text-color: var(--lhds-color-ui-500);\n --swui-calendar-week-number-clickable-text-color: var(--lhds-color-ui-500);\n\n /* Week day */\n\n --swui-calendar-week-day-text-color: var(--lhds-color-ui-500);\n --swui-calendar-week-day-clickable-text-color: var(--lhds-color-ui-500);\n\n /* Wrapper */\n\n --swui-calendar-wrapper-selected-border: var(--swui-primary-action-color);\n --swui-calendar-wrapper-selected-background: var(--swui-primary-action-color);\n --swui-calendar-wrapper-range-border: var(--lhds-color-blue-100);\n --swui-calendar-wrapper-range-background: var(--lhds-color-blue-100);\n --swui-calendar-wrapper-today-border: var(--lhds-color-ui-200);\n --swui-calendar-wrapper-today-background: var(--lhds-color-ui-200);\n\n /* Text */\n\n --swui-calendar-text-selected-color: #fff;\n --swui-calendar-text-disabled-color: var(--swui-text-disabled-color);\n --swui-calendar-text-in-other-month-color: var(--swui-text-disabled-color);\n}\n\n .Calendar-module_calendar__Ztvgm table {\n border-spacing: 0 4px;\n }\n\n .Calendar-module_calendar__Ztvgm span {\n line-height: 100%;\n }\n\n .Calendar-module_calendar__Ztvgm tr td:last-child {\n border-top-right-radius: var(--swui-calendar-day-border-radius);\n border-bottom-right-radius: var(--swui-calendar-day-border-radius);\n }\n\n .Calendar-module_calendar__Ztvgm tr td:nth-child(2) {\n border-top-left-radius: var(--swui-calendar-day-border-radius);\n border-bottom-left-radius: var(--swui-calendar-day-border-radius);\n }\n\n .Calendar-module_calendar__Ztvgm td {\n padding: 0;\n width: var(--swui-calendar-day-width);\n height: var(--swui-calendar-day-height);\n }\n";
|
|
530
|
+
var styles$1 = {"calendar":"Calendar-module_calendar__Ztvgm"};
|
|
531
|
+
styleInject(css_248z$1);
|
|
507
532
|
|
|
508
533
|
function CalendarPanel(_a) {
|
|
509
|
-
var monthRows = _a.monthRows, _b = _a.dayComponent, dayComponent = _b === void 0 ? CalendarDay : _b, userDataPerMonth = _a.userDataPerMonth, statePerMonth = _a.statePerMonth, onClickDay = _a.onClickDay, onClickWeekDay = _a.onClickWeekDay, onClickWeek = _a.onClickWeek, onClickMonth = _a.onClickMonth, onClickYear = _a.onClickYear, renderWeekDay = _a.renderWeekDay, renderWeekNumber = _a.renderWeekNumber, headerLeftContent = _a.headerLeftContent, headerRightContent = _a.headerRightContent, extraDayContent = _a.extraDayContent, defaultHighlights = _a.defaultHighlights, _c = _a.theme, theme = _c === void 0 ? defaultCalendarTheme : _c;
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
534
|
+
var monthRows = _a.monthRows, _b = _a.dayComponent, dayComponent = _b === void 0 ? CalendarDay : _b, userDataPerMonth = _a.userDataPerMonth, statePerMonth = _a.statePerMonth, minDate = _a.minDate, maxDate = _a.maxDate, onClickDay = _a.onClickDay, onClickWeekDay = _a.onClickWeekDay, onClickWeek = _a.onClickWeek, onClickMonth = _a.onClickMonth, onClickYear = _a.onClickYear, renderWeekDay = _a.renderWeekDay, renderWeekNumber = _a.renderWeekNumber, headerLeftContent = _a.headerLeftContent, headerRightContent = _a.headerRightContent, extraDayContent = _a.extraDayContent, defaultHighlights = _a.defaultHighlights, _c = _a.theme, theme = _c === void 0 ? defaultCalendarTheme : _c;
|
|
535
|
+
var minDateObj = useMemo(function () { return (minDate ? parse(minDate, "yyyy-MM-dd", new Date()) : undefined); }, [minDate]);
|
|
536
|
+
var maxDateObj = useMemo(function () { return (maxDate ? parse(maxDate, "yyyy-MM-dd", new Date()) : undefined); }, [maxDate]);
|
|
537
|
+
return (React.createElement("div", { className: styles$1.calendar }, monthRows.map(function (monthRow, rowIndex) { return (React.createElement(Spacing, { key: rowIndex },
|
|
538
|
+
React.createElement(Row, null, monthRow.map(function (month, index) { return (React.createElement(React.Fragment, { key: month.name },
|
|
539
|
+
index > 0 && React.createElement(Space, null),
|
|
540
|
+
React.createElement(CalendarMonth, { month: month, dayComponent: dayComponent, userDataPerWeek: userDataPerMonth && userDataPerMonth[month.monthString], statePerWeek: statePerMonth && statePerMonth[month.monthString], onClickDay: onClickDay, onClickWeekDay: onClickWeekDay, onClickWeek: onClickWeek, onClickMonth: onClickMonth, onClickYear: onClickYear, theme: theme, renderWeekNumber: renderWeekNumber, renderWeekDay: renderWeekDay, headerLeftContent: headerLeftContent, headerRightContent: headerRightContent, extraDayContent: extraDayContent, defaultHighlights: defaultHighlights, minDate: minDateObj, maxDate: maxDateObj }))); })))); })));
|
|
514
541
|
}
|
|
515
542
|
function Calendar(props) {
|
|
516
543
|
var initialDate = getInitialDate(props.year, props.month, props.date);
|
|
517
544
|
var _a = calculateOverflowingMonth(initialDate.year, initialDate.month), year = _a.year, month = _a.month;
|
|
518
545
|
var monthRows = getMonthRows(year, month, props.numMonths, props.monthsPerRow);
|
|
519
546
|
var statePerMonth = useHighlightToday(props.highlightToday, props.statePerMonth);
|
|
520
|
-
return (createElement(CalendarPanel, __assign({ year: year, month: month, monthRows: monthRows }, props, { statePerMonth: statePerMonth })));
|
|
547
|
+
return (React.createElement(CalendarPanel, __assign({ year: year, month: month, monthRows: monthRows }, props, { statePerMonth: statePerMonth })));
|
|
521
548
|
}
|
|
522
549
|
var getInitialDate = function (year, month, date) {
|
|
523
550
|
if (month && year) {
|
|
@@ -577,18 +604,18 @@ var useSelectedMonthStepperLogic = function (dateInFocus, setDateInFocus, months
|
|
|
577
604
|
|
|
578
605
|
var WithMonthSwitcherBelow = function (_a) {
|
|
579
606
|
var children = _a.children, prevMonth = _a.prevMonth, nextMonth = _a.nextMonth, prevYear = _a.prevYear, nextYear = _a.nextYear;
|
|
580
|
-
return (createElement("div", null,
|
|
607
|
+
return (React.createElement("div", null,
|
|
581
608
|
children,
|
|
582
|
-
createElement(Indent, null,
|
|
583
|
-
createElement(Row, null,
|
|
584
|
-
createElement(FlatButton, { onClick: prevYear, leftIcon: faAngleDoubleLeft }),
|
|
585
|
-
createElement(Space, null),
|
|
586
|
-
createElement(FlatButton, { onClick: prevMonth, leftIcon: faAngleLeft }),
|
|
587
|
-
createElement(Indent, { num: 2 }),
|
|
588
|
-
createElement(FlatButton, { onClick: nextMonth, leftIcon: faAngleRight }),
|
|
589
|
-
createElement(Space, null),
|
|
590
|
-
createElement(FlatButton, { onClick: nextYear, leftIcon: faAngleDoubleRight }))),
|
|
591
|
-
createElement(Space, null)));
|
|
609
|
+
React.createElement(Indent, null,
|
|
610
|
+
React.createElement(Row, null,
|
|
611
|
+
React.createElement(FlatButton, { onClick: prevYear, leftIcon: faAngleDoubleLeft }),
|
|
612
|
+
React.createElement(Space, null),
|
|
613
|
+
React.createElement(FlatButton, { onClick: prevMonth, leftIcon: faAngleLeft }),
|
|
614
|
+
React.createElement(Indent, { num: 2 }),
|
|
615
|
+
React.createElement(FlatButton, { onClick: nextMonth, leftIcon: faAngleRight }),
|
|
616
|
+
React.createElement(Space, null),
|
|
617
|
+
React.createElement(FlatButton, { onClick: nextYear, leftIcon: faAngleDoubleRight }))),
|
|
618
|
+
React.createElement(Space, null)));
|
|
592
619
|
};
|
|
593
620
|
|
|
594
621
|
var MonthPickerCell = function (_a) {
|
|
@@ -598,7 +625,7 @@ var MonthPickerCell = function (_a) {
|
|
|
598
625
|
now.setMonth(month);
|
|
599
626
|
return format(now, "MMM");
|
|
600
627
|
}, [month]);
|
|
601
|
-
return (createElement(Row, { width: "64px", justifyContent: "center", spacing: 0.5, indent: 0.5 }, value === month ? (createElement(PrimaryButton, { label: label, onClick: function () { return onValueChange && onValueChange(month); } })) : (createElement(FlatButton, { label: label, onClick: function () { return onValueChange && onValueChange(month); } }))));
|
|
628
|
+
return (React.createElement(Row, { width: "64px", justifyContent: "center", spacing: 0.5, indent: 0.5 }, value === month ? (React.createElement(PrimaryButton, { label: label, onClick: function () { return onValueChange && onValueChange(month); } })) : (React.createElement(FlatButton, { label: label, onClick: function () { return onValueChange && onValueChange(month); } }))));
|
|
602
629
|
};
|
|
603
630
|
|
|
604
631
|
var monthMatrix = [
|
|
@@ -609,7 +636,7 @@ var monthMatrix = [
|
|
|
609
636
|
];
|
|
610
637
|
var MonthPicker = function (_a) {
|
|
611
638
|
var value = _a.value, onValueChange = _a.onValueChange;
|
|
612
|
-
return (createElement(Column, null, monthMatrix.map(function (monthRow) { return (createElement(Row, { key: monthRow[0] }, monthRow.map(function (month) { return (createElement(MonthPickerCell, { key: month, month: month, onValueChange: onValueChange, value: value })); }))); })));
|
|
639
|
+
return (React.createElement(Column, null, monthMatrix.map(function (monthRow) { return (React.createElement(Row, { key: monthRow[0] }, monthRow.map(function (month) { return (React.createElement(MonthPickerCell, { key: month, month: month, onValueChange: onValueChange, value: value })); }))); })));
|
|
613
640
|
};
|
|
614
641
|
|
|
615
642
|
var createStandardDateRangePresets = function (now) { return [
|
|
@@ -639,21 +666,21 @@ var PresetPicker = function (_a) {
|
|
|
639
666
|
var _c = useState(0), pageIndex = _c[0], setPageIndex = _c[1];
|
|
640
667
|
var pages = useMemo(function () { return createStandardDateRangePresets(new Date()); }, []);
|
|
641
668
|
var currentPage = (_b = pages[pageIndex]) !== null && _b !== void 0 ? _b : pages[0];
|
|
642
|
-
return (createElement(Column, null,
|
|
643
|
-
createElement(Row, { justifyContent: "space-between", alignItems: "center", width: "200px" },
|
|
644
|
-
createElement(FlatButton, { size: "small", leftIcon: faAngleLeft, disabled: pageIndex === 0, onClick: function () { return setPageIndex(pageIndex - 1); } }),
|
|
645
|
-
createElement(Text, null, currentPage.label),
|
|
646
|
-
createElement(FlatButton, { size: "small", leftIcon: faAngleRight, disabled: pageIndex === pages.length - 1, onClick: function () { return setPageIndex(pageIndex + 1); } })),
|
|
647
|
-
createElement(Space, null),
|
|
648
|
-
createElement(Column, { alignItems: "center" }, currentPage.presets.map(function (preset) { return (createElement(Fragment, { key: preset.label },
|
|
649
|
-
createElement(PrimaryButton, { label: preset.label, onClick: function () { return onClickPreset(preset); } }),
|
|
650
|
-
createElement(Space, null))); }))));
|
|
669
|
+
return (React.createElement(Column, null,
|
|
670
|
+
React.createElement(Row, { justifyContent: "space-between", alignItems: "center", width: "200px" },
|
|
671
|
+
React.createElement(FlatButton, { size: "small", leftIcon: faAngleLeft, disabled: pageIndex === 0, onClick: function () { return setPageIndex(pageIndex - 1); } }),
|
|
672
|
+
React.createElement(Text, null, currentPage.label),
|
|
673
|
+
React.createElement(FlatButton, { size: "small", leftIcon: faAngleRight, disabled: pageIndex === pages.length - 1, onClick: function () { return setPageIndex(pageIndex + 1); } })),
|
|
674
|
+
React.createElement(Space, null),
|
|
675
|
+
React.createElement(Column, { alignItems: "center" }, currentPage.presets.map(function (preset) { return (React.createElement(React.Fragment, { key: preset.label },
|
|
676
|
+
React.createElement(PrimaryButton, { label: preset.label, onClick: function () { return onClickPreset(preset); } }),
|
|
677
|
+
React.createElement(Space, null))); }))));
|
|
651
678
|
};
|
|
652
679
|
|
|
653
680
|
var YearPickerCell = function (_a) {
|
|
654
681
|
var value = _a.value, onValueChange = _a.onValueChange, year = _a.year;
|
|
655
682
|
var label = String(year);
|
|
656
|
-
return (createElement(Row, { width: "64px", justifyContent: "center", spacing: 0.5, indent: 0.5 }, value === year ? (createElement(PrimaryButton, { label: label, onClick: function () { return onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(year); } })) : (createElement(FlatButton, { label: label, onClick: function () { return onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(year); } }))));
|
|
683
|
+
return (React.createElement(Row, { width: "64px", justifyContent: "center", spacing: 0.5, indent: 0.5 }, value === year ? (React.createElement(PrimaryButton, { label: label, onClick: function () { return onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(year); } })) : (React.createElement(FlatButton, { label: label, onClick: function () { return onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(year); } }))));
|
|
657
684
|
};
|
|
658
685
|
|
|
659
686
|
var YearPicker = function (_a) {
|
|
@@ -671,12 +698,12 @@ var YearPicker = function (_a) {
|
|
|
671
698
|
useEffect(function () {
|
|
672
699
|
setLastYear(function (prev) { return calculateLastYearInFocus(value, prev); });
|
|
673
700
|
}, [value]);
|
|
674
|
-
return (createElement(Row, null,
|
|
675
|
-
createElement(Column, { justifyContent: "center" },
|
|
676
|
-
createElement(FlatButton, { leftIcon: faCaretLeft, onClick: function () { return setLastYear(lastYear - 3); } })),
|
|
677
|
-
createElement(Column, null, yearRows.map(function (yearRow) { return (createElement(Row, { key: yearRow[0] }, yearRow.map(function (year) { return (createElement(YearPickerCell, { key: year, year: year, onValueChange: onValueChange, value: value })); }))); })),
|
|
678
|
-
createElement(Column, { justifyContent: "center" },
|
|
679
|
-
createElement(FlatButton, { leftIcon: faCaretRight, onClick: function () { return setLastYear(lastYear + 3); } }))));
|
|
701
|
+
return (React.createElement(Row, null,
|
|
702
|
+
React.createElement(Column, { justifyContent: "center" },
|
|
703
|
+
React.createElement(FlatButton, { leftIcon: faCaretLeft, onClick: function () { return setLastYear(lastYear - 3); } })),
|
|
704
|
+
React.createElement(Column, null, yearRows.map(function (yearRow) { return (React.createElement(Row, { key: yearRow[0] }, yearRow.map(function (year) { return (React.createElement(YearPickerCell, { key: year, year: year, onValueChange: onValueChange, value: value })); }))); })),
|
|
705
|
+
React.createElement(Column, { justifyContent: "center" },
|
|
706
|
+
React.createElement(FlatButton, { leftIcon: faCaretRight, onClick: function () { return setLastYear(lastYear + 3); } }))));
|
|
680
707
|
};
|
|
681
708
|
var calculateLastYearInFocus = function (value, lastYear) {
|
|
682
709
|
if (value == null) {
|
|
@@ -724,42 +751,42 @@ var CalendarWithMonthYearPickers = function CalendarWithMonthYearPickers(_a) {
|
|
|
724
751
|
}, [setCurrentPanel]);
|
|
725
752
|
switch (currentPanel) {
|
|
726
753
|
case "calendar":
|
|
727
|
-
return (createElement(Fragment, null,
|
|
728
|
-
createElement(Calendar, __assign({}, props, { date: dateInFocus, onClickYear: onClickYear, onClickMonth: onClickMonth }))));
|
|
754
|
+
return (React.createElement(React.Fragment, null,
|
|
755
|
+
React.createElement(Calendar, __assign({}, props, { date: dateInFocus, onClickYear: onClickYear, onClickMonth: onClickMonth }))));
|
|
729
756
|
case "month":
|
|
730
|
-
return (createElement(MonthPicker, { value: dateInFocus.getMonth(), onValueChange: onChangeSelectedMonth }));
|
|
757
|
+
return (React.createElement(MonthPicker, { value: dateInFocus.getMonth(), onValueChange: onChangeSelectedMonth }));
|
|
731
758
|
case "year":
|
|
732
|
-
return (createElement(YearPicker, { value: dateInFocus.getFullYear(), onValueChange: onChangeSelectedYear }));
|
|
759
|
+
return (React.createElement(YearPicker, { value: dateInFocus.getFullYear(), onValueChange: onChangeSelectedYear }));
|
|
733
760
|
case "presets":
|
|
734
|
-
return createElement(PresetPicker, { onClickPreset: function () { } });
|
|
761
|
+
return React.createElement(PresetPicker, { onClickPreset: function () { } });
|
|
735
762
|
default:
|
|
736
|
-
return (createElement(Box, null,
|
|
737
|
-
createElement(PrimaryButton, { label: "Show calendar", onClick: function () { return setCurrentPanel("calendar"); } })));
|
|
763
|
+
return (React.createElement(Box, null,
|
|
764
|
+
React.createElement(PrimaryButton, { label: "Show calendar", onClick: function () { return setCurrentPanel("calendar"); } })));
|
|
738
765
|
}
|
|
739
766
|
};
|
|
740
767
|
|
|
741
768
|
var noop = function () { };
|
|
742
769
|
function CalendarWithMonthSwitcher(_a) {
|
|
743
|
-
var monthSwitcherPlacement = _a.monthSwitcherPlacement, _b = _a.theme, theme = _b === void 0 ? defaultCalendarTheme : _b, dateInFocus = _a.dateInFocus, setDateInFocus = _a.setDateInFocus, currentPanel = _a.currentPanel, setCurrentPanel = _a.setCurrentPanel, _c = _a.onSelectPreset, onSelectPreset = _c === void 0 ? noop : _c, calendarProps = __rest(_a, ["monthSwitcherPlacement", "theme", "dateInFocus", "setDateInFocus", "currentPanel", "setCurrentPanel", "onSelectPreset"]);
|
|
744
|
-
var
|
|
770
|
+
var monthSwitcherPlacement = _a.monthSwitcherPlacement, _b = _a.theme, theme = _b === void 0 ? defaultCalendarTheme : _b, dateInFocus = _a.dateInFocus, setDateInFocus = _a.setDateInFocus, currentPanel = _a.currentPanel, setCurrentPanel = _a.setCurrentPanel, _c = _a.onSelectPreset, onSelectPreset = _c === void 0 ? noop : _c, _d = _a.hideYearPagination, hideYearPagination = _d === void 0 ? false : _d, calendarProps = __rest(_a, ["monthSwitcherPlacement", "theme", "dateInFocus", "setDateInFocus", "currentPanel", "setCurrentPanel", "onSelectPreset", "hideYearPagination"]);
|
|
771
|
+
var _e = useSelectedMonthStepperLogic(dateInFocus, setDateInFocus, calendarProps.monthsPerRow, calendarProps.numMonths), nextMonth = _e.nextMonth, prevMonth = _e.prevMonth, nextYear = _e.nextYear, prevYear = _e.prevYear;
|
|
745
772
|
var placement = fallbackIfNoPlacement(monthSwitcherPlacement, calendarProps.numMonths);
|
|
746
773
|
switch (placement) {
|
|
747
774
|
case "below": {
|
|
748
|
-
return (createElement(WithMonthSwitcherBelow, { theme: theme, nextMonth: nextMonth, prevMonth: prevMonth, nextYear: nextYear, prevYear: prevYear },
|
|
749
|
-
createElement(Calendar, __assign({}, calendarProps, { theme: theme, date: dateInFocus }))));
|
|
775
|
+
return (React.createElement(WithMonthSwitcherBelow, { theme: theme, nextMonth: nextMonth, prevMonth: prevMonth, nextYear: nextYear, prevYear: prevYear },
|
|
776
|
+
React.createElement(Calendar, __assign({}, calendarProps, { theme: theme, date: dateInFocus }))));
|
|
750
777
|
}
|
|
751
778
|
case "header": {
|
|
752
|
-
return (createElement(Column, null,
|
|
753
|
-
createElement(CalendarWithMonthYearPickers, __assign({}, calendarProps, { theme: theme, dateInFocus: dateInFocus, setDateInFocus: setDateInFocus, currentPanel: currentPanel, setCurrentPanel: setCurrentPanel, onSelectPreset: onSelectPreset, headerLeftContent: createElement(Row, { alignItems: "center" },
|
|
754
|
-
createElement(FlatButton, { size: "small", onClick: prevYear, leftIcon: faAngleDoubleLeft }),
|
|
755
|
-
createElement(Space, null),
|
|
756
|
-
createElement(FlatButton, { size: "small", onClick: prevMonth, leftIcon: faAngleLeft })), headerRightContent: createElement(Row, { alignItems: "center" },
|
|
757
|
-
createElement(FlatButton, { size: "small", onClick: nextMonth, leftIcon: faAngleRight }),
|
|
758
|
-
createElement(Space, null),
|
|
759
|
-
createElement(FlatButton, { size: "small", onClick: nextYear, leftIcon: faAngleDoubleRight })) }))));
|
|
779
|
+
return (React.createElement(Column, null,
|
|
780
|
+
React.createElement(CalendarWithMonthYearPickers, __assign({}, calendarProps, { theme: theme, dateInFocus: dateInFocus, setDateInFocus: setDateInFocus, currentPanel: currentPanel, setCurrentPanel: setCurrentPanel, onSelectPreset: onSelectPreset, headerLeftContent: React.createElement(Row, { alignItems: "center" },
|
|
781
|
+
!hideYearPagination && (React.createElement(FlatButton, { size: "small", onClick: prevYear, leftIcon: faAngleDoubleLeft })),
|
|
782
|
+
React.createElement(Space, null),
|
|
783
|
+
React.createElement(FlatButton, { size: "small", onClick: prevMonth, leftIcon: faAngleLeft })), headerRightContent: React.createElement(Row, { alignItems: "center" },
|
|
784
|
+
React.createElement(FlatButton, { size: "small", onClick: nextMonth, leftIcon: faAngleRight }),
|
|
785
|
+
React.createElement(Space, null),
|
|
786
|
+
!hideYearPagination && (React.createElement(FlatButton, { size: "small", onClick: nextYear, leftIcon: faAngleDoubleRight }))) }))));
|
|
760
787
|
}
|
|
761
788
|
default: {
|
|
762
|
-
return (createElement(Calendar, __assign({}, calendarProps, { theme: theme, date: dateInFocus })));
|
|
789
|
+
return (React.createElement(Calendar, __assign({}, calendarProps, { theme: theme, date: dateInFocus })));
|
|
763
790
|
}
|
|
764
791
|
}
|
|
765
792
|
}
|
|
@@ -767,97 +794,65 @@ var fallbackIfNoPlacement = function (monthSwitcherPlacement, numMonths) {
|
|
|
767
794
|
return monthSwitcherPlacement || (numMonths || 1) > 1 ? "below" : "header";
|
|
768
795
|
};
|
|
769
796
|
|
|
770
|
-
var
|
|
771
|
-
startDate:
|
|
772
|
-
|
|
797
|
+
var dateRangeToStrings = function (dateRange) { return ({
|
|
798
|
+
startDate: dateRange.startDate
|
|
799
|
+
? format(dateRange.startDate, "yyyy-MM-dd")
|
|
800
|
+
: undefined,
|
|
801
|
+
endDate: dateRange.endDate
|
|
802
|
+
? format(dateRange.endDate, "yyyy-MM-dd")
|
|
803
|
+
: undefined,
|
|
773
804
|
}); };
|
|
774
|
-
var
|
|
805
|
+
var stringsToDateRange = function (_a) {
|
|
806
|
+
var startDate = _a.startDate, endDate = _a.endDate;
|
|
775
807
|
var now = new Date();
|
|
776
808
|
return {
|
|
777
|
-
startDate: (
|
|
778
|
-
|
|
779
|
-
undefined,
|
|
780
|
-
endDate: (interval.endDate &&
|
|
781
|
-
parse(interval.endDate, DateFormats.fullDate, now)) ||
|
|
782
|
-
undefined,
|
|
809
|
+
startDate: startDate ? parse(startDate, "yyyy-MM-dd", now) : undefined,
|
|
810
|
+
endDate: endDate ? parse(endDate, "yyyy-MM-dd", now) : undefined,
|
|
783
811
|
};
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
var isDateRangeInvalid = function (_a) {
|
|
815
|
+
var startDate = _a.startDate, endDate = _a.endDate;
|
|
816
|
+
return Boolean(startDate &&
|
|
817
|
+
endDate &&
|
|
818
|
+
!isSameDay(startDate, endDate) &&
|
|
819
|
+
isAfter(startDate, endDate));
|
|
784
820
|
};
|
|
785
|
-
var
|
|
786
|
-
if (
|
|
787
|
-
interval.endDate &&
|
|
788
|
-
isAfter(interval.startDate, interval.endDate)) {
|
|
821
|
+
var toggleDatesIfEndIsEarlierThanStart = function (dateRange) {
|
|
822
|
+
if (isDateRangeInvalid(dateRange)) {
|
|
789
823
|
return {
|
|
790
|
-
startDate:
|
|
791
|
-
endDate:
|
|
824
|
+
startDate: dateRange.endDate,
|
|
825
|
+
endDate: dateRange.startDate,
|
|
792
826
|
};
|
|
793
827
|
}
|
|
794
|
-
return
|
|
828
|
+
return dateRange;
|
|
829
|
+
};
|
|
830
|
+
var toggleDateStringsIfEndIsEarlierThanStart = function (dateRange) {
|
|
831
|
+
if (dateRange.startDate && dateRange.endDate) {
|
|
832
|
+
return dateRangeToStrings(toggleDatesIfEndIsEarlierThanStart(stringsToDateRange(dateRange)));
|
|
833
|
+
}
|
|
834
|
+
return dateRange;
|
|
795
835
|
};
|
|
796
836
|
|
|
797
|
-
var useDateRangeOnClickDayHandler = function (
|
|
837
|
+
var useDateRangeOnClickDayHandler = function (value, onValueChange, focusedInput, setFocusedInput) {
|
|
798
838
|
return useCallback(function (day) {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
else {
|
|
808
|
-
setStartDate(day.date);
|
|
809
|
-
setFocusedInput("endDate");
|
|
810
|
-
if (onChange) {
|
|
811
|
-
onChange(ensureStartIsFirst({
|
|
812
|
-
startDate: day.date,
|
|
813
|
-
endDate: endDate,
|
|
814
|
-
}));
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
else if (focusedInput === "endDate") {
|
|
819
|
-
if (startDate && isAfter(startDate, day.date)) {
|
|
820
|
-
setStartDate(day.date);
|
|
821
|
-
setEndDate(startDate);
|
|
822
|
-
if (onChange) {
|
|
823
|
-
onChange({ startDate: day.date, endDate: startDate });
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
else {
|
|
827
|
-
setEndDate(day.date);
|
|
828
|
-
setFocusedInput("startDate");
|
|
829
|
-
if (onChange) {
|
|
830
|
-
onChange(ensureStartIsFirst({
|
|
831
|
-
startDate: startDate,
|
|
832
|
-
endDate: day.date,
|
|
833
|
-
}));
|
|
834
|
-
}
|
|
835
|
-
}
|
|
839
|
+
var dateRange = {
|
|
840
|
+
startDate: focusedInput === "startDate" ? day.date : value === null || value === void 0 ? void 0 : value.startDate,
|
|
841
|
+
endDate: focusedInput === "endDate" ? day.date : value === null || value === void 0 ? void 0 : value.endDate,
|
|
842
|
+
};
|
|
843
|
+
if (!isDateRangeInvalid(dateRange)) {
|
|
844
|
+
setFocusedInput(focusedInput === "startDate" ? "endDate" : "startDate");
|
|
836
845
|
}
|
|
846
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(toggleDatesIfEndIsEarlierThanStart(dateRange));
|
|
837
847
|
}, [
|
|
838
848
|
focusedInput,
|
|
839
|
-
|
|
840
|
-
startDate,
|
|
841
|
-
setStartDate,
|
|
842
|
-
setEndDate,
|
|
843
|
-
onChange,
|
|
849
|
+
onValueChange,
|
|
844
850
|
setFocusedInput,
|
|
851
|
+
value === null || value === void 0 ? void 0 : value.endDate,
|
|
852
|
+
value === null || value === void 0 ? void 0 : value.startDate,
|
|
845
853
|
]);
|
|
846
854
|
};
|
|
847
855
|
|
|
848
|
-
var toggleDatesIfEndIsEarlierThanStart = function (startDate, endDate) {
|
|
849
|
-
if (startDate && endDate && isAfter(startDate, endDate)) {
|
|
850
|
-
return {
|
|
851
|
-
startDate: endDate,
|
|
852
|
-
endDate: startDate,
|
|
853
|
-
};
|
|
854
|
-
}
|
|
855
|
-
return {
|
|
856
|
-
startDate: startDate,
|
|
857
|
-
endDate: endDate,
|
|
858
|
-
};
|
|
859
|
-
};
|
|
860
|
-
|
|
861
856
|
var useInternalPanelState = function (onChangePanel) {
|
|
862
857
|
var _a = useState("calendar"), currentPanel = _a[0], _setCurrentPanel = _a[1];
|
|
863
858
|
var setCurrentPanel = useCallback(function (currentPanel) {
|
|
@@ -871,14 +866,13 @@ var useInternalPanelState = function (onChangePanel) {
|
|
|
871
866
|
};
|
|
872
867
|
|
|
873
868
|
var useDateRangeSelection = function (_a) {
|
|
874
|
-
var focusedInput = _a.focusedInput,
|
|
869
|
+
var focusedInput = _a.focusedInput, value = _a.value, onValueChange = _a.onValueChange, setFocusedInput = _a.setFocusedInput, statePerMonth = _a.statePerMonth, onChangePanel = _a.onChangePanel;
|
|
875
870
|
var _b = useInternalPanelState(onChangePanel), currentPanel = _b.currentPanel, setCurrentPanel = _b.setCurrentPanel;
|
|
876
871
|
var _c = useState(function () { return new Date(); }), dateInFocus = _c[0], setDateInFocus = _c[1];
|
|
877
|
-
var onClickDay = useDateRangeOnClickDayHandler(
|
|
878
|
-
var dates = useMemo(function () { return toggleDatesIfEndIsEarlierThanStart(startDate, endDate); }, [startDate, endDate]);
|
|
872
|
+
var onClickDay = useDateRangeOnClickDayHandler(value, onValueChange, focusedInput, setFocusedInput);
|
|
879
873
|
var statePerMonthWithSelection = useMemo(function () {
|
|
880
|
-
return buildDayStateForDateRange(statePerMonth,
|
|
881
|
-
}, [statePerMonth,
|
|
874
|
+
return buildDayStateForDateRange(statePerMonth, value === null || value === void 0 ? void 0 : value.startDate, value === null || value === void 0 ? void 0 : value.endDate);
|
|
875
|
+
}, [statePerMonth, value === null || value === void 0 ? void 0 : value.endDate, value === null || value === void 0 ? void 0 : value.startDate]);
|
|
882
876
|
return {
|
|
883
877
|
onClickDay: onClickDay,
|
|
884
878
|
statePerMonth: statePerMonthWithSelection,
|
|
@@ -891,7 +885,7 @@ var useDateRangeSelection = function (_a) {
|
|
|
891
885
|
|
|
892
886
|
function DateRangeCalendar(props) {
|
|
893
887
|
var dateRangeSelectionProps = useDateRangeSelection(props);
|
|
894
|
-
return (createElement(CalendarWithMonthSwitcher, __assign({}, props, dateRangeSelectionProps)));
|
|
888
|
+
return (React.createElement(CalendarWithMonthSwitcher, __assign({}, props, dateRangeSelectionProps)));
|
|
895
889
|
}
|
|
896
890
|
|
|
897
891
|
var useDateRangeCalendarState = function () {
|
|
@@ -938,7 +932,7 @@ var useSingleDateSelection = function (_a) {
|
|
|
938
932
|
|
|
939
933
|
function SingleDateCalendar(props) {
|
|
940
934
|
var singleDateSelectionProps = useSingleDateSelection(props);
|
|
941
|
-
return (createElement(CalendarWithMonthSwitcher, __assign({}, props, singleDateSelectionProps)));
|
|
935
|
+
return (React.createElement(CalendarWithMonthSwitcher, __assign({}, props, singleDateSelectionProps)));
|
|
942
936
|
}
|
|
943
937
|
|
|
944
938
|
var useMultiDateSelection = function (_a) {
|
|
@@ -954,7 +948,7 @@ var useMultiDateSelection = function (_a) {
|
|
|
954
948
|
onChange(value.filter(function (v) { return !isSameDay(v, day.date); }));
|
|
955
949
|
}
|
|
956
950
|
else {
|
|
957
|
-
onChange(
|
|
951
|
+
onChange(__spreadArray(__spreadArray([], (value || []), true), [day.date], false));
|
|
958
952
|
}
|
|
959
953
|
}, [onChange, value]);
|
|
960
954
|
var statePerMonthWithSelectedDate = useMemo(function () {
|
|
@@ -975,7 +969,7 @@ var useMultiDateSelection = function (_a) {
|
|
|
975
969
|
|
|
976
970
|
function MultiDateCalendar(props) {
|
|
977
971
|
var selectionProps = useMultiDateSelection(props);
|
|
978
|
-
return createElement(CalendarWithMonthSwitcher, __assign({}, props, selectionProps));
|
|
972
|
+
return React.createElement(CalendarWithMonthSwitcher, __assign({}, props, selectionProps));
|
|
979
973
|
}
|
|
980
974
|
|
|
981
975
|
var useSingleWeekSelection = function (_a) {
|
|
@@ -1040,7 +1034,7 @@ var getWeekDataFromWeekString = function (week) {
|
|
|
1040
1034
|
|
|
1041
1035
|
function SingleWeekCalendar(props) {
|
|
1042
1036
|
var singleWeekSelectionProps = useSingleWeekSelection(props);
|
|
1043
|
-
return (createElement(CalendarWithMonthSwitcher, __assign({}, props, singleWeekSelectionProps)));
|
|
1037
|
+
return (React.createElement(CalendarWithMonthSwitcher, __assign({}, props, singleWeekSelectionProps)));
|
|
1044
1038
|
}
|
|
1045
1039
|
|
|
1046
1040
|
var removeDateIfExist = function (list, date) {
|
|
@@ -1051,46 +1045,46 @@ var listContainsDate = function (list, date) {
|
|
|
1051
1045
|
};
|
|
1052
1046
|
|
|
1053
1047
|
var useDateRangeExclusionSelection = function (_a) {
|
|
1054
|
-
var
|
|
1055
|
-
var _b = useState(),
|
|
1056
|
-
var _c = useState(),
|
|
1057
|
-
var _d =
|
|
1058
|
-
var _e =
|
|
1059
|
-
var _f = useState(function () { var _a; return (_a = (focusedInput && (value === null || value === void 0 ? void 0 : value[focusedInput]))) !== null && _a !== void 0 ? _a : new Date(); }), dateInFocus = _f[0], setDateInFocus = _f[1];
|
|
1048
|
+
var value = _a.value, onValueChange = _a.onValueChange, statePerMonth = _a.statePerMonth, onChangePanel = _a.onChangePanel;
|
|
1049
|
+
var _b = useState(), dateRange = _b[0], setDateRange = _b[1];
|
|
1050
|
+
var _c = useState("startDate"), focusedInput = _c[0], setFocusedInput = _c[1];
|
|
1051
|
+
var _d = useInternalPanelState(onChangePanel), currentPanel = _d.currentPanel, setCurrentPanel = _d.setCurrentPanel;
|
|
1052
|
+
var _e = useState(function () { var _a; return (_a = (focusedInput && (value === null || value === void 0 ? void 0 : value[focusedInput]))) !== null && _a !== void 0 ? _a : new Date(); }), dateInFocus = _e[0], setDateInFocus = _e[1];
|
|
1060
1053
|
var onChangeHandler = useCallback(function (value) {
|
|
1054
|
+
setDateRange(value);
|
|
1061
1055
|
var startDate = value.startDate, endDate = value.endDate;
|
|
1062
|
-
if (
|
|
1056
|
+
if (onValueChange) {
|
|
1063
1057
|
if (startDate && endDate) {
|
|
1064
1058
|
var dates = eachDayOfInterval({ start: startDate, end: endDate });
|
|
1065
|
-
|
|
1059
|
+
onValueChange(dates);
|
|
1066
1060
|
}
|
|
1067
1061
|
else if (startDate) {
|
|
1068
|
-
|
|
1062
|
+
onValueChange([startDate]);
|
|
1069
1063
|
}
|
|
1070
1064
|
else if (endDate) {
|
|
1071
|
-
|
|
1065
|
+
onValueChange([endDate]);
|
|
1072
1066
|
}
|
|
1073
1067
|
}
|
|
1074
|
-
}, [
|
|
1075
|
-
var onClickDayRange = useDateRangeOnClickDayHandler(
|
|
1068
|
+
}, [onValueChange]);
|
|
1069
|
+
var onClickDayRange = useDateRangeOnClickDayHandler(dateRange, onChangeHandler, focusedInput, setFocusedInput);
|
|
1076
1070
|
var onClickDay = useCallback(function (day, userData, ev) {
|
|
1077
|
-
if (
|
|
1071
|
+
if (onValueChange) {
|
|
1078
1072
|
if (ev.ctrlKey || ev.metaKey) {
|
|
1079
1073
|
if (!value) {
|
|
1080
|
-
|
|
1074
|
+
onValueChange([day.date]);
|
|
1081
1075
|
}
|
|
1082
1076
|
else if (listContainsDate(value, day.date)) {
|
|
1083
|
-
|
|
1077
|
+
onValueChange(removeDateIfExist(value, day.date));
|
|
1084
1078
|
}
|
|
1085
1079
|
else {
|
|
1086
|
-
|
|
1080
|
+
onValueChange(__spreadArray(__spreadArray([], value, true), [day.date], false));
|
|
1087
1081
|
}
|
|
1088
1082
|
}
|
|
1089
1083
|
else {
|
|
1090
1084
|
onClickDayRange(day, userData, ev);
|
|
1091
1085
|
}
|
|
1092
1086
|
}
|
|
1093
|
-
}, [
|
|
1087
|
+
}, [onValueChange, onClickDayRange, value]);
|
|
1094
1088
|
var statePerMonthWithSelectedDate = useMemo(function () {
|
|
1095
1089
|
return addHighlighting(statePerMonth, value);
|
|
1096
1090
|
}, [statePerMonth, value]);
|
|
@@ -1114,7 +1108,7 @@ var addHighlighting = function (statePerMonth, dateList) {
|
|
|
1114
1108
|
|
|
1115
1109
|
function DateRangeExclusionCalendar(props) {
|
|
1116
1110
|
var selectionProps = useDateRangeExclusionSelection(props);
|
|
1117
|
-
return createElement(CalendarWithMonthSwitcher, __assign({}, props, selectionProps));
|
|
1111
|
+
return React.createElement(CalendarWithMonthSwitcher, __assign({}, props, selectionProps));
|
|
1118
1112
|
}
|
|
1119
1113
|
|
|
1120
1114
|
var defaultPopoverPlacement = "bottom";
|
|
@@ -1157,16 +1151,18 @@ var useDateInput = function (onChange, onClose, openOnMount) {
|
|
|
1157
1151
|
};
|
|
1158
1152
|
};
|
|
1159
1153
|
|
|
1154
|
+
var defaultMaxDate = "2999-12-31";
|
|
1155
|
+
|
|
1160
1156
|
var DateInput = function (_a) {
|
|
1161
|
-
var _b = _a.displayFormat, displayFormat = _b === void 0 ? DateFormats.fullDate : _b, _c = _a.placeholder, placeholder = _c === void 0 ? "Enter date" : _c, value = _a.value, _d = _a.zIndex, zIndex = _d === void 0 ? 100 : _d, _e = _a.calendarTheme, calendarTheme = _e === void 0 ? defaultCalendarTheme : _e, calendarProps = _a.calendarProps, openOnMount = _a.openOnMount, onClose = _a.onClose, onChange = _a.onChange, portalTarget = _a.portalTarget, variant = _a.variant, width = _a.width;
|
|
1162
|
-
var
|
|
1163
|
-
var
|
|
1164
|
-
return (createElement(Box, { width: width },
|
|
1165
|
-
createElement(Popover, { arrow: false, lazy: true, visible: showingCalendar, onClickOutside: hideCalendar, placement: defaultPopoverPlacement, zIndex: zIndex, appendTo: portalTarget !== null && portalTarget !== void 0 ? portalTarget : "parent", tippyRef: tippyRef, content: createElement(SingleDateCalendar, __assign({}, calendarProps, { onChange: onSelectDate, value: value, theme: calendarTheme, onChangePanel: onChangePanel })) },
|
|
1166
|
-
createElement(TextInput, {
|
|
1157
|
+
var _b = _a.displayFormat, displayFormat = _b === void 0 ? DateFormats.fullDate : _b, _c = _a.placeholder, placeholder = _c === void 0 ? "Enter date" : _c, value = _a.value, _d = _a.zIndex, zIndex = _d === void 0 ? 100 : _d, _e = _a.calendarTheme, calendarTheme = _e === void 0 ? defaultCalendarTheme : _e, calendarProps = _a.calendarProps, openOnMount = _a.openOnMount, onClose = _a.onClose, onChange = _a.onChange, portalTarget = _a.portalTarget, variant = _a.variant, width = _a.width, minDate = _a.minDate, _f = _a.maxDate, maxDate = _f === void 0 ? defaultMaxDate : _f;
|
|
1158
|
+
var _g = useDateInput(onChange, onClose, openOnMount), hideCalendar = _g.hideCalendar, showingCalendar = _g.showingCalendar, onSelectDate = _g.onSelectDate, showCalendar = _g.showCalendar;
|
|
1159
|
+
var _h = useCalendarPopoverUpdater(), tippyRef = _h.tippyRef, onChangePanel = _h.onChangePanel;
|
|
1160
|
+
return (React.createElement(Box, { width: width },
|
|
1161
|
+
React.createElement(Popover, { arrow: false, lazy: true, visible: showingCalendar, onClickOutside: hideCalendar, placement: defaultPopoverPlacement, zIndex: zIndex, appendTo: portalTarget !== null && portalTarget !== void 0 ? portalTarget : "parent", tippyRef: tippyRef, content: React.createElement(SingleDateCalendar, __assign({}, calendarProps, { onChange: onSelectDate, value: value, theme: calendarTheme, onChangePanel: onChangePanel, minDate: minDate, maxDate: maxDate })) },
|
|
1162
|
+
React.createElement(TextInput, { type: "date", iconRight: faCalendarAlt, onFocus: showCalendar, onClickRight: showCalendar, value: value ? format(value, displayFormat) : "", placeholder: placeholder, size: 9, autoFocus: openOnMount, variant: variant, min: minDate, max: maxDate }))));
|
|
1167
1163
|
};
|
|
1168
1164
|
|
|
1169
|
-
var useDateRangeInput = function (value,
|
|
1165
|
+
var useDateRangeInput = function (value, onValueChange) {
|
|
1170
1166
|
var startDateInputRef = useRef(null);
|
|
1171
1167
|
var endDateInputRef = useRef(null);
|
|
1172
1168
|
var _a = useState(false), showingCalendar = _a[0], setShowingCalendar = _a[1];
|
|
@@ -1186,11 +1182,11 @@ var useDateRangeInput = function (value, onChange) {
|
|
|
1186
1182
|
}, [setShowingCalendar]);
|
|
1187
1183
|
var onClickDay = useCallback(function (day) {
|
|
1188
1184
|
if (focusedInput === "startDate") {
|
|
1189
|
-
|
|
1185
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange({
|
|
1190
1186
|
startDate: day.date,
|
|
1191
|
-
endDate: value.endDate,
|
|
1187
|
+
endDate: value === null || value === void 0 ? void 0 : value.endDate,
|
|
1192
1188
|
});
|
|
1193
|
-
if (!value.endDate) {
|
|
1189
|
+
if (!(value === null || value === void 0 ? void 0 : value.endDate)) {
|
|
1194
1190
|
setFocusedInput("endDate");
|
|
1195
1191
|
endDateInputRef.current && endDateInputRef.current.focus();
|
|
1196
1192
|
}
|
|
@@ -1199,11 +1195,11 @@ var useDateRangeInput = function (value, onChange) {
|
|
|
1199
1195
|
}
|
|
1200
1196
|
}
|
|
1201
1197
|
else if (focusedInput === "endDate") {
|
|
1202
|
-
|
|
1203
|
-
startDate: value.startDate,
|
|
1198
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange({
|
|
1199
|
+
startDate: value === null || value === void 0 ? void 0 : value.startDate,
|
|
1204
1200
|
endDate: day.date,
|
|
1205
1201
|
});
|
|
1206
|
-
if (!value.startDate) {
|
|
1202
|
+
if (!(value === null || value === void 0 ? void 0 : value.startDate)) {
|
|
1207
1203
|
setFocusedInput("startDate");
|
|
1208
1204
|
startDateInputRef.current && startDateInputRef.current.focus();
|
|
1209
1205
|
}
|
|
@@ -1211,12 +1207,12 @@ var useDateRangeInput = function (value, onChange) {
|
|
|
1211
1207
|
setTimeout(hideCalendar, 150);
|
|
1212
1208
|
}
|
|
1213
1209
|
}
|
|
1214
|
-
}, [focusedInput,
|
|
1210
|
+
}, [focusedInput, onValueChange, setFocusedInput, hideCalendar, value]);
|
|
1215
1211
|
var startDateIsAfterEnd = useMemo(function () {
|
|
1216
|
-
return value.startDate &&
|
|
1217
|
-
value.endDate &&
|
|
1212
|
+
return (value === null || value === void 0 ? void 0 : value.startDate) &&
|
|
1213
|
+
(value === null || value === void 0 ? void 0 : value.endDate) &&
|
|
1218
1214
|
isAfter(value.startDate, value.endDate);
|
|
1219
|
-
}, [value.startDate, value.endDate]);
|
|
1215
|
+
}, [value === null || value === void 0 ? void 0 : value.startDate, value === null || value === void 0 ? void 0 : value.endDate]);
|
|
1220
1216
|
return {
|
|
1221
1217
|
showingCalendar: showingCalendar,
|
|
1222
1218
|
hideCalendar: hideCalendar,
|
|
@@ -1235,24 +1231,26 @@ var useDateRangeInput = function (value, onChange) {
|
|
|
1235
1231
|
* @deprecated Please use DateRangeDualTextInput instead.
|
|
1236
1232
|
*/
|
|
1237
1233
|
var DateRangeInput = function (_a) {
|
|
1238
|
-
var _b = _a.displayFormat, displayFormat = _b === void 0 ? DateFormats.fullDate : _b, _c = _a.placeholderStartDate, placeholderStartDate = _c === void 0 ? "Start date" : _c, _d = _a.placeholderEndDate, placeholderEndDate = _d === void 0 ? "End date" : _d, portalTarget = _a.portalTarget, value = _a.value,
|
|
1239
|
-
var
|
|
1240
|
-
var
|
|
1241
|
-
var
|
|
1242
|
-
var statePerMonth = useMemo(function () {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
createElement(
|
|
1248
|
-
createElement(Space, null),
|
|
1249
|
-
createElement(
|
|
1234
|
+
var _b = _a.displayFormat, displayFormat = _b === void 0 ? DateFormats.fullDate : _b, _c = _a.placeholderStartDate, placeholderStartDate = _c === void 0 ? "Start date" : _c, _d = _a.placeholderEndDate, placeholderEndDate = _d === void 0 ? "End date" : _d, portalTarget = _a.portalTarget, value = _a.value, onValueChange = _a.onValueChange, _e = _a.zIndex, zIndex = _e === void 0 ? 100 : _e, width = _a.width, _f = _a.calendarTheme, calendarTheme = _f === void 0 ? defaultCalendarTheme : _f, calendarProps = _a.calendarProps, minDate = _a.minDate, _g = _a.maxDate, maxDate = _g === void 0 ? defaultMaxDate : _g;
|
|
1235
|
+
var _h = useState(function () { var _a; return (_a = (focusedInput && (value === null || value === void 0 ? void 0 : value[focusedInput]))) !== null && _a !== void 0 ? _a : new Date(); }), dateInFocus = _h[0], setDateInFocus = _h[1];
|
|
1236
|
+
var _j = useState("calendar"), currentPanel = _j[0], setCurrentPanel = _j[1];
|
|
1237
|
+
var _k = useDateRangeInput(value, onValueChange), hideCalendar = _k.hideCalendar, showCalendarEndDate = _k.showCalendarEndDate, showCalendarStartDate = _k.showCalendarStartDate, showingCalendar = _k.showingCalendar, focusedInput = _k.focusedInput, startDateInputRef = _k.startDateInputRef, endDateInputRef = _k.endDateInputRef, onClickDay = _k.onClickDay, startDateIsAfterEnd = _k.startDateIsAfterEnd;
|
|
1238
|
+
var statePerMonth = useMemo(function () {
|
|
1239
|
+
return buildDayStateForDateRange(undefined, value === null || value === void 0 ? void 0 : value.startDate, value === null || value === void 0 ? void 0 : value.endDate);
|
|
1240
|
+
}, [value]);
|
|
1241
|
+
return (React.createElement(Popover, { arrow: false, lazy: true, visible: showingCalendar, zIndex: zIndex, placement: defaultPopoverPlacement, appendTo: portalTarget !== null && portalTarget !== void 0 ? portalTarget : "parent", onClickOutside: hideCalendar, content: React.createElement(CalendarWithMonthSwitcher, __assign({}, calendarProps, { dateInFocus: dateInFocus, setDateInFocus: setDateInFocus, statePerMonth: statePerMonth, theme: calendarTheme, onClickDay: onClickDay, currentPanel: currentPanel, setCurrentPanel: setCurrentPanel, minDate: minDate, maxDate: maxDate })) },
|
|
1242
|
+
React.createElement(Row, { alignItems: "center" },
|
|
1243
|
+
React.createElement(TextInput, { iconLeft: faCalendarAlt$1, onFocus: showCalendarStartDate, value: (value === null || value === void 0 ? void 0 : value.startDate) ? format(value.startDate, displayFormat) : "", placeholder: placeholderStartDate, width: width, inputRef: startDateInputRef, size: 9, variant: startDateIsAfterEnd ? "error" : undefined }),
|
|
1244
|
+
React.createElement(Space, null),
|
|
1245
|
+
React.createElement(Icon, { icon: faLongArrowAltRight, color: cssColor("--lhds-color-ui-500"), size: 14 }),
|
|
1246
|
+
React.createElement(Space, null),
|
|
1247
|
+
React.createElement(TextInput, { iconLeft: faCalendarAlt$1, onFocus: showCalendarEndDate, value: (value === null || value === void 0 ? void 0 : value.endDate) ? format(value.endDate, displayFormat) : "", placeholder: placeholderEndDate, width: width, inputRef: endDateInputRef, size: 9, variant: startDateIsAfterEnd ? "error" : undefined }))));
|
|
1250
1248
|
};
|
|
1251
1249
|
|
|
1252
1250
|
var DateTextInput = function (_a) {
|
|
1253
|
-
var calendarProps = _a.calendarProps, _b = _a.closeOnCalendarSelectDate, closeOnCalendarSelectDate = _b === void 0 ? true : _b, _c = _a.dateFormat, dateFormat = _c === void 0 ? DateFormats.fullDate : _c
|
|
1254
|
-
var
|
|
1255
|
-
var
|
|
1251
|
+
var calendarProps = _a.calendarProps, _b = _a.closeOnCalendarSelectDate, closeOnCalendarSelectDate = _b === void 0 ? true : _b, _c = _a.dateFormat, dateFormat = _c === void 0 ? DateFormats.fullDate : _c; _a.disableCalender; var onValueChange = _a.onValueChange, _e = _a.placeholder, placeholder = _e === void 0 ? "yyyy-mm-dd" : _e, portalTarget = _a.portalTarget, value = _a.value, _f = _a.width, width = _f === void 0 ? "130px" : _f, _g = _a.zIndex, zIndex = _g === void 0 ? 100 : _g, _h = _a.calendarTheme, calendarTheme = _h === void 0 ? defaultCalendarTheme : _h, _j = _a.hideCalenderIcon, hideCalenderIcon = _j === void 0 ? false : _j, minDate = _a.minDate, _k = _a.maxDate, maxDate = _k === void 0 ? defaultMaxDate : _k, props = __rest(_a, ["calendarProps", "closeOnCalendarSelectDate", "dateFormat", "disableCalender", "onValueChange", "placeholder", "portalTarget", "value", "width", "zIndex", "calendarTheme", "hideCalenderIcon", "minDate", "maxDate"]);
|
|
1252
|
+
var _l = useState(false), open = _l[0], setOpen = _l[1];
|
|
1253
|
+
var _m = useCalendarPopoverUpdater(), tippyRef = _m.tippyRef, onChangePanel = _m.onChangePanel;
|
|
1256
1254
|
var toggleCalendar = useCallback(function () {
|
|
1257
1255
|
setOpen(!open);
|
|
1258
1256
|
}, [setOpen, open]);
|
|
@@ -1276,12 +1274,12 @@ var DateTextInput = function (_a) {
|
|
|
1276
1274
|
var dateIsValid = !!value && isValid(parse(value, dateFormat, new Date()));
|
|
1277
1275
|
var userInputCorrectLength = !!value && value.length >= dateFormat.length;
|
|
1278
1276
|
var invalid = (userInputCorrectLength && !dateIsValid) || inValidInput;
|
|
1279
|
-
return (createElement(Box, { width: width },
|
|
1280
|
-
createElement(Popover, { arrow: false, lazy: true, visible: open, zIndex: zIndex, appendTo: portalTarget !== null && portalTarget !== void 0 ? portalTarget : "parent", placement: defaultPopoverPlacement, onClickOutside: hideCalendar, tippyRef: tippyRef, content: createElement(SingleDateCalendar, __assign({}, calendarProps, { onChange: onCalendarSelectDate, onChangePanel: onChangePanel, value: value && dateIsValid
|
|
1277
|
+
return (React.createElement(Box, { width: width },
|
|
1278
|
+
React.createElement(Popover, { arrow: false, lazy: true, visible: open, zIndex: zIndex, appendTo: portalTarget !== null && portalTarget !== void 0 ? portalTarget : "parent", placement: defaultPopoverPlacement, onClickOutside: hideCalendar, tippyRef: tippyRef, content: React.createElement(SingleDateCalendar, __assign({}, calendarProps, { onChange: onCalendarSelectDate, onChangePanel: onChangePanel, value: value && dateIsValid
|
|
1281
1279
|
? parse(value, dateFormat, new Date())
|
|
1282
|
-
: undefined, theme: calendarTheme })) },
|
|
1283
|
-
createElement(TextInput, __assign({}, props, { variant: invalid ? "error" : "standard", disableContentPaddingRight: true, contentRight: !hideCalenderIcon ? (createElement(Row, { alignItems: "center", indent: 0.5 },
|
|
1284
|
-
createElement(FlatButton, { size: "small", leftIcon: faCalendarAlt, onClick: toggleCalendar }))) : undefined, onValueChange: onValueChangeHandler, placeholder: placeholder, value: value || "", size: 10 })))));
|
|
1280
|
+
: undefined, minDate: minDate, maxDate: maxDate, theme: calendarTheme })) },
|
|
1281
|
+
React.createElement(TextInput, __assign({}, props, { variant: invalid ? "error" : "standard", disableContentPaddingRight: true, contentRight: !hideCalenderIcon ? (React.createElement(Row, { alignItems: "center", indent: 0.5 },
|
|
1282
|
+
React.createElement(FlatButton, { size: "small", leftIcon: faCalendarAlt$1, onClick: toggleCalendar }))) : undefined, onValueChange: onValueChangeHandler, placeholder: placeholder, value: value || "", min: minDate, max: maxDate, size: 10 })))));
|
|
1285
1283
|
};
|
|
1286
1284
|
|
|
1287
1285
|
var formatHours = function (hours) {
|
|
@@ -1415,11 +1413,11 @@ var TimeTextInput = function (_a) {
|
|
|
1415
1413
|
onValueChange(time);
|
|
1416
1414
|
}
|
|
1417
1415
|
}, [onValueChange, setValid]);
|
|
1418
|
-
return (createElement(TextInput, __assign({}, props, { type: "time", variant: !valid ? "error" : variant, iconLeft: useIcon ? faClock : undefined, value: value, placeholder: showPlaceholder ? timeFormat : undefined, onChange: onChangeHandler, onBlur: onBlur, width: width })));
|
|
1416
|
+
return (React.createElement(TextInput, __assign({}, props, { type: "time", variant: !valid ? "error" : variant, iconLeft: useIcon ? faClock : undefined, value: value, placeholder: showPlaceholder ? timeFormat : undefined, onChange: onChangeHandler, onBlur: onBlur, width: width })));
|
|
1419
1417
|
};
|
|
1420
1418
|
|
|
1421
1419
|
var DualTextInput = function (_a) {
|
|
1422
|
-
var autoFocusLeft = _a.autoFocusLeft, autoFocusRight = _a.autoFocusRight, onEsc = _a.onEsc, onEnter = _a.onEnter, onValueChangeLeft = _a.onValueChangeLeft, onValueChangeRight = _a.onValueChangeRight, separatorIcon = _a.separatorIcon, placeholderLeft = _a.placeholderLeft, placeholderRight = _a.placeholderRight, typeLeft = _a.typeLeft, typeRight = _a.typeRight, onChangeLeft = _a.onChangeLeft, onChangeRight = _a.onChangeRight, valueLeft = _a.valueLeft, valueRight = _a.valueRight, onClickLeft = _a.onClickLeft, onClickRight = _a.onClickRight, onClickCalendar = _a.onClickCalendar, onClickArrowDown = _a.onClickArrowDown, onBlurLeft = _a.onBlurLeft, onBlurRight = _a.onBlurRight, onFocusLeft = _a.onFocusLeft, onFocusRight = _a.onFocusRight, inputRefLeft = _a.inputRefLeft, inputRefRight = _a.inputRefRight, variant = _a.variant, variantLeft = _a.variantLeft, variantRight = _a.variantRight, onBlur = _a.onBlur, showPresets = _a.showPresets, widthLeft = _a.widthLeft, widthRight = _a.widthRight;
|
|
1420
|
+
var autoFocusLeft = _a.autoFocusLeft, autoFocusRight = _a.autoFocusRight, onEsc = _a.onEsc, onEnter = _a.onEnter, onValueChangeLeft = _a.onValueChangeLeft, onValueChangeRight = _a.onValueChangeRight, separatorIcon = _a.separatorIcon, placeholderLeft = _a.placeholderLeft, placeholderRight = _a.placeholderRight, typeLeft = _a.typeLeft, typeRight = _a.typeRight, onChangeLeft = _a.onChangeLeft, onChangeRight = _a.onChangeRight, valueLeft = _a.valueLeft, valueRight = _a.valueRight, minLeft = _a.minLeft, maxLeft = _a.maxLeft, minRight = _a.minRight, maxRight = _a.maxRight, onClickLeft = _a.onClickLeft, onClickRight = _a.onClickRight, onClickCalendar = _a.onClickCalendar, onClickArrowDown = _a.onClickArrowDown, onBlurLeft = _a.onBlurLeft, onBlurRight = _a.onBlurRight, onFocusLeft = _a.onFocusLeft, onFocusRight = _a.onFocusRight, inputRefLeft = _a.inputRefLeft, inputRefRight = _a.inputRefRight, variant = _a.variant, variantLeft = _a.variantLeft, variantRight = _a.variantRight, onBlur = _a.onBlur, showPresets = _a.showPresets, widthLeft = _a.widthLeft, widthRight = _a.widthRight;
|
|
1423
1421
|
var focusCounter = useRef(0);
|
|
1424
1422
|
var tryTriggerOnBlur = useMemo(function () {
|
|
1425
1423
|
return debounce(function (focusCounter) {
|
|
@@ -1456,21 +1454,21 @@ var DualTextInput = function (_a) {
|
|
|
1456
1454
|
onBlurRight(ev);
|
|
1457
1455
|
}
|
|
1458
1456
|
}, [onBlurRight, focusCounter, tryTriggerOnBlur]);
|
|
1459
|
-
return (createElement(Box, null,
|
|
1460
|
-
createElement(TextInputBox, { disableContentPaddingRight: true, variant: variant, contentRight: createElement(Row, { alignItems: "center" },
|
|
1461
|
-
createElement(Indent, { num: 0.5 },
|
|
1462
|
-
createElement(FlatButton, { leftIcon: faCalendarAlt
|
|
1463
|
-
showPresets ? (createElement(Fragment, null,
|
|
1464
|
-
createElement(Row, { height: "22px" },
|
|
1465
|
-
createElement(SeparatorLine, { vertical: true })),
|
|
1466
|
-
createElement(Indent, { num: 0.5 },
|
|
1467
|
-
createElement(FlatButton, { leftIcon: faAngleDown, onClick: onClickArrowDown, size: "small" })))) : null) },
|
|
1468
|
-
createElement(Box, { width: widthLeft },
|
|
1469
|
-
createElement(TextInput, { onEsc: onEsc, onEnter: onEnter, onClick: onClickLeft, hideBorder: true, placeholder: placeholderLeft, value: valueLeft, onValueChange: onValueChangeLeft, onChange: onChangeLeft, onBlur: blurLeftHandler, onFocus: focusLeftHandler, inputRef: inputRefLeft, variant: variantLeft, type: typeLeft, autoFocus: autoFocusLeft })),
|
|
1470
|
-
createElement(Row, { indent: 0.5, alignItems: "center", justifyContent: "center" },
|
|
1471
|
-
createElement(Icon, { icon: separatorIcon, size: 12, color: cssColor("--lhds-color-ui-500") })),
|
|
1472
|
-
createElement(Box, { width: widthRight },
|
|
1473
|
-
createElement(TextInput, { onEsc: onEsc, onEnter: onEnter, onClick: onClickRight, hideBorder: true, placeholder: placeholderRight, value: valueRight, onValueChange: onValueChangeRight, onChange: onChangeRight, onBlur: blurRightHandler, onFocus: focusRightHandler, inputRef: inputRefRight, variant: variantRight, type: typeRight, autoFocus: autoFocusRight })))));
|
|
1457
|
+
return (React.createElement(Box, null,
|
|
1458
|
+
React.createElement(TextInputBox, { disableContentPaddingRight: true, variant: variant, contentRight: React.createElement(Row, { alignItems: "center" },
|
|
1459
|
+
React.createElement(Indent, { num: 0.5 },
|
|
1460
|
+
React.createElement(FlatButton, { leftIcon: faCalendarAlt, onClick: onClickCalendar, size: "small" })),
|
|
1461
|
+
showPresets ? (React.createElement(React.Fragment, null,
|
|
1462
|
+
React.createElement(Row, { height: "22px" },
|
|
1463
|
+
React.createElement(SeparatorLine, { vertical: true })),
|
|
1464
|
+
React.createElement(Indent, { num: 0.5 },
|
|
1465
|
+
React.createElement(FlatButton, { leftIcon: faAngleDown, onClick: onClickArrowDown, size: "small" })))) : null) },
|
|
1466
|
+
React.createElement(Box, { width: widthLeft },
|
|
1467
|
+
React.createElement(TextInput, { onEsc: onEsc, onEnter: onEnter, onClick: onClickLeft, hideBorder: true, placeholder: placeholderLeft, value: valueLeft, onValueChange: onValueChangeLeft, onChange: onChangeLeft, onBlur: blurLeftHandler, onFocus: focusLeftHandler, inputRef: inputRefLeft, variant: variantLeft, type: typeLeft, autoFocus: autoFocusLeft, min: minLeft, max: maxLeft })),
|
|
1468
|
+
React.createElement(Row, { indent: 0.5, alignItems: "center", justifyContent: "center" },
|
|
1469
|
+
React.createElement(Icon, { icon: separatorIcon, size: 12, color: cssColor("--lhds-color-ui-500") })),
|
|
1470
|
+
React.createElement(Box, { width: widthRight },
|
|
1471
|
+
React.createElement(TextInput, { onEsc: onEsc, onEnter: onEnter, onClick: onClickRight, hideBorder: true, placeholder: placeholderRight, value: valueRight, onValueChange: onValueChangeRight, onChange: onChangeRight, onBlur: blurRightHandler, onFocus: focusRightHandler, inputRef: inputRefRight, variant: variantRight, type: typeRight, autoFocus: autoFocusRight, min: minRight, max: maxRight })))));
|
|
1474
1472
|
};
|
|
1475
1473
|
|
|
1476
1474
|
var transformTimeStringToNumber = function (time) {
|
|
@@ -1532,9 +1530,9 @@ var transformTimeInDateToTimeString = function (date) {
|
|
|
1532
1530
|
return formatHours(String(date.getHours())) + ":" + formatMinutes(String(date.getMinutes()));
|
|
1533
1531
|
};
|
|
1534
1532
|
|
|
1535
|
-
var css_248z
|
|
1536
|
-
var styles
|
|
1537
|
-
styleInject(css_248z
|
|
1533
|
+
var css_248z = ".TimePicker-module_timePicker__1ElGu {\n overflow: hidden;\n width: 180px;\n}\n\n.TimePicker-module_timePickerColumn__2vfuE {\n overflow-y: hidden;\n -webkit-flex: 1;\n flex: 1;\n}\n\n.TimePicker-module_timePickerColumn__2vfuE:hover {\n overflow-y: scroll;\n }\n";
|
|
1534
|
+
var styles = {"timePicker":"TimePicker-module_timePicker__1ElGu","timePickerColumn":"TimePicker-module_timePickerColumn__2vfuE"};
|
|
1535
|
+
styleInject(css_248z);
|
|
1538
1536
|
|
|
1539
1537
|
var TimePickerCell = function (_a) {
|
|
1540
1538
|
var onClick = _a.onClick, item = _a.item, selected = _a.selected, columnRef = _a.columnRef, canScrollRef = _a.canScrollRef;
|
|
@@ -1549,13 +1547,13 @@ var TimePickerCell = function (_a) {
|
|
|
1549
1547
|
canScrollRef.current = false;
|
|
1550
1548
|
}
|
|
1551
1549
|
}, [columnRef, item, selected, canScrollRef]);
|
|
1552
|
-
return (createElement(Row, { width: "64px", justifyContent: "center", spacing: 0.5, indent: 0.5, ref: ref }, selected ? (createElement(PrimaryButton, { label: String(item), onClick: function () { return onClick && onClick(item); } })) : (createElement(FlatButton, { label: String(item), onClick: function () { return onClick && onClick(item); } }))));
|
|
1550
|
+
return (React.createElement(Row, { width: "64px", justifyContent: "center", spacing: 0.5, indent: 0.5, ref: ref }, selected ? (React.createElement(PrimaryButton, { label: String(item), onClick: function () { return onClick && onClick(item); } })) : (React.createElement(FlatButton, { label: String(item), onClick: function () { return onClick && onClick(item); } }))));
|
|
1553
1551
|
};
|
|
1554
1552
|
|
|
1555
1553
|
var TimePickerColumn = function (_a) {
|
|
1556
1554
|
var onClick = _a.onClick, items = _a.items, selectedItem = _a.selectedItem, canScrollRef = _a.canScrollRef;
|
|
1557
1555
|
var columnRef = useRef(null);
|
|
1558
|
-
return (createElement(Column, { className: styles
|
|
1556
|
+
return (React.createElement(Column, { className: styles.timePickerColumn, ref: columnRef }, items.map(function (item) { return (React.createElement(TimePickerCell, { key: item, item: item, onClick: onClick, selected: item === selectedItem, columnRef: columnRef, canScrollRef: canScrollRef })); })));
|
|
1559
1557
|
};
|
|
1560
1558
|
|
|
1561
1559
|
var hours = range(0, 24);
|
|
@@ -1580,13 +1578,13 @@ var TimePicker = function (_a) {
|
|
|
1580
1578
|
setMinute(m);
|
|
1581
1579
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(formatHours(String(hour !== null && hour !== void 0 ? hour : 0)) + ":" + formatMinutes(String(m !== null && m !== void 0 ? m : 0)));
|
|
1582
1580
|
}, [hour, onValueChange]);
|
|
1583
|
-
return (createElement(Row, { className: styles
|
|
1584
|
-
createElement(TimePickerColumn, { items: hours, onClick: onClickHour, selectedItem: hour, canScrollRef: canScrollRef }),
|
|
1585
|
-
createElement(Indent, null),
|
|
1586
|
-
createElement(TimePickerColumn, { items: minutes, onClick: onClickMinutes, selectedItem: minute, canScrollRef: canScrollRef })));
|
|
1581
|
+
return (React.createElement(Row, { className: styles.timePicker },
|
|
1582
|
+
React.createElement(TimePickerColumn, { items: hours, onClick: onClickHour, selectedItem: hour, canScrollRef: canScrollRef }),
|
|
1583
|
+
React.createElement(Indent, null),
|
|
1584
|
+
React.createElement(TimePickerColumn, { items: minutes, onClick: onClickMinutes, selectedItem: minute, canScrollRef: canScrollRef })));
|
|
1587
1585
|
};
|
|
1588
1586
|
|
|
1589
|
-
var useDateRangeEffects = function (date, setDateInFocus, dateInputRef) {
|
|
1587
|
+
var useDateRangeEffects$1 = function (date, setDateInFocus, dateInputRef) {
|
|
1590
1588
|
useEffect(function moveFocusedDateWhenDateChanges() {
|
|
1591
1589
|
if (date) {
|
|
1592
1590
|
setDateInFocus(date);
|
|
@@ -1604,7 +1602,7 @@ var useDateRangeEffects = function (date, setDateInFocus, dateInputRef) {
|
|
|
1604
1602
|
}, [date, dateInputRef]);
|
|
1605
1603
|
};
|
|
1606
1604
|
|
|
1607
|
-
var useDateRangeHandlers = function (date, onValueChange, _a, dateInputRef) {
|
|
1605
|
+
var useDateRangeHandlers$1 = function (date, onValueChange, _a, dateInputRef) {
|
|
1608
1606
|
var setDateInFocus = _a.setDateInFocus, showCalendarInternal = _a.showCalendarInternal, hideCalendarInternal = _a.hideCalendarInternal, setFirstFocusedInput = _a.setFirstFocusedInput, setCurrentPanel = _a.setCurrentPanel, localTime = _a.localTime, setLocalTime = _a.setLocalTime, localDate = _a.localDate, setLocalDate = _a.setLocalDate;
|
|
1609
1607
|
var onChangeDate = useCallback(function (incomingDate) {
|
|
1610
1608
|
if (!incomingDate) {
|
|
@@ -1692,7 +1690,7 @@ var useDateRangeHandlers = function (date, onValueChange, _a, dateInputRef) {
|
|
|
1692
1690
|
};
|
|
1693
1691
|
};
|
|
1694
1692
|
|
|
1695
|
-
var useInputStates = function (date) {
|
|
1693
|
+
var useInputStates$1 = function (date) {
|
|
1696
1694
|
var _a = useState(undefined), localDate = _a[0], setLocalDate = _a[1];
|
|
1697
1695
|
var _b = useState(undefined), localTime = _b[0], setLocalTime = _b[1];
|
|
1698
1696
|
var _c = useBoolean(false), isCalendarVisible = _c[0], showCalendarInternal = _c[1], hideCalendarInternal = _c[2];
|
|
@@ -1720,7 +1718,7 @@ var useInputStates = function (date) {
|
|
|
1720
1718
|
};
|
|
1721
1719
|
};
|
|
1722
1720
|
|
|
1723
|
-
var useUserInputHandlers = function (onChangeDate, dateInputRef, showCalendar, hideCalendar, _a) {
|
|
1721
|
+
var useUserInputHandlers$1 = function (onChangeDate, dateInputRef, showCalendar, hideCalendar, _a) {
|
|
1724
1722
|
var isCalendarVisible = _a.isCalendarVisible, setCurrentPanel = _a.setCurrentPanel, showTimePicker = _a.showTimePicker, hideTimePicker = _a.hideTimePicker;
|
|
1725
1723
|
var onFocusLeft = useCallback(function () {
|
|
1726
1724
|
if (!isCalendarVisible) {
|
|
@@ -1775,14 +1773,14 @@ var useUserInputHandlers = function (onChangeDate, dateInputRef, showCalendar, h
|
|
|
1775
1773
|
};
|
|
1776
1774
|
|
|
1777
1775
|
var DateTimeInput = function (_a) {
|
|
1778
|
-
var value = _a.value, onValueChange = _a.onValueChange, onEnter = _a.onEnter, onEsc = _a.onEsc, onBlur = _a.onBlur, autoFocus = _a.autoFocus;
|
|
1776
|
+
var value = _a.value, onValueChange = _a.onValueChange, onEnter = _a.onEnter, onEsc = _a.onEsc, onBlur = _a.onBlur, autoFocus = _a.autoFocus, minDate = _a.minDate, _b = _a.maxDate, maxDate = _b === void 0 ? defaultMaxDate : _b;
|
|
1779
1777
|
var dateInputRef = useRef(null);
|
|
1780
1778
|
var timeInputRef = useRef(null);
|
|
1781
|
-
var states = useInputStates(value);
|
|
1779
|
+
var states = useInputStates$1(value);
|
|
1782
1780
|
var setCurrentPanel = states.setCurrentPanel, currentPanel = states.currentPanel, isCalendarVisible = states.isCalendarVisible, dateInFocus = states.dateInFocus, setDateInFocus = states.setDateInFocus, isTimePickerVisible = states.isTimePickerVisible, hideTimePicker = states.hideTimePicker, localTime = states.localTime, localDate = states.localDate;
|
|
1783
|
-
var
|
|
1784
|
-
var
|
|
1785
|
-
useDateRangeEffects(value, setDateInFocus, dateInputRef);
|
|
1781
|
+
var _c = useDateRangeHandlers$1(value, onValueChange, states, dateInputRef), showCalendar = _c.showCalendar, hideCalendar = _c.hideCalendar, inputLeftChangeHandler = _c.inputLeftChangeHandler, inputRightChangeHandler = _c.inputRightChangeHandler, onChangeTime = _c.onChangeTime, onChangeDate = _c.onChangeDate;
|
|
1782
|
+
var _d = useUserInputHandlers$1(onChangeDate, dateInputRef, showCalendar, hideCalendar, states), onKeyDownHandler = _d.onKeyDownHandler, onFocusRight = _d.onFocusRight, onFocusLeft = _d.onFocusLeft, onClickDay = _d.onClickDay, onClickCalendarButton = _d.onClickCalendarButton, onClickArrowButton = _d.onClickArrowButton;
|
|
1783
|
+
useDateRangeEffects$1(value, setDateInFocus, dateInputRef);
|
|
1786
1784
|
var statePerMonth = useMemo(function () {
|
|
1787
1785
|
var dateToHighlight = value || localDate;
|
|
1788
1786
|
if (!dateToHighlight) {
|
|
@@ -1800,17 +1798,17 @@ var DateTimeInput = function (_a) {
|
|
|
1800
1798
|
var timeValue = useMemo(function () { return (value ? transformTimeInDateToTimeString(value) : localTime); }, [value, localTime]);
|
|
1801
1799
|
var delayedIsCalendarVisible = useDelayedFalse(isCalendarVisible, 300);
|
|
1802
1800
|
var delayedIsTimePickerVisible = useDelayedFalse(isTimePickerVisible, 300);
|
|
1803
|
-
return (createElement(Box, { onKeyDown: onKeyDownHandler },
|
|
1804
|
-
createElement(Popover, { arrow: false, lazy: true, placement: defaultPopoverPlacement, visible: isCalendarVisible || isTimePickerVisible, onClickOutside: hideAll, content: (delayedIsCalendarVisible || delayedIsTimePickerVisible) && (createElement(Column, null, delayedIsCalendarVisible ? (createElement(CalendarWithMonthSwitcher, { statePerMonth: statePerMonth, onClickDay: onClickDay, dateInFocus: dateInFocus, setDateInFocus: setDateInFocus, currentPanel: currentPanel, setCurrentPanel: setCurrentPanel })) : delayedIsTimePickerVisible ? (createElement(Column, null,
|
|
1805
|
-
createElement(Column, { overflow: "hidden", height: "250px" },
|
|
1806
|
-
createElement(TimePicker, { value: timeValue !== null && timeValue !== void 0 ? timeValue : "", onValueChange: onChangeTime })),
|
|
1807
|
-
createElement(Space, null),
|
|
1808
|
-
createElement(Row, { justifyContent: "flex-end" },
|
|
1809
|
-
createElement(PrimaryButton, { label: "Done", onClick: hideTimePicker })))) : null)) },
|
|
1810
|
-
createElement(DualTextInput, { autoFocusLeft: autoFocus, onEsc: onEsc, onEnter: onEnter, onBlur: onBlur, separatorIcon: faClock$1, typeLeft: "date", typeRight: "time", placeholderLeft: "yyyy-mm-dd", placeholderRight: "hh:mm", onChangeLeft: inputLeftChangeHandler, onChangeRight: inputRightChangeHandler, onClickArrowDown: onClickArrowButton, onClickCalendar: onClickCalendarButton, onFocusLeft: onFocusLeft, onFocusRight: onFocusRight, onClickLeft: onFocusLeft, onClickRight: onFocusRight, inputRefLeft: dateInputRef, inputRefRight: timeInputRef, valueRight: timeValue !== null && timeValue !== void 0 ? timeValue : "", widthLeft: "104px", widthRight: "64px" }))));
|
|
1801
|
+
return (React.createElement(Box, { onKeyDown: onKeyDownHandler },
|
|
1802
|
+
React.createElement(Popover, { arrow: false, lazy: true, placement: defaultPopoverPlacement, visible: isCalendarVisible || isTimePickerVisible, onClickOutside: hideAll, content: (delayedIsCalendarVisible || delayedIsTimePickerVisible) && (React.createElement(Column, null, delayedIsCalendarVisible ? (React.createElement(CalendarWithMonthSwitcher, { statePerMonth: statePerMonth, onClickDay: onClickDay, dateInFocus: dateInFocus, setDateInFocus: setDateInFocus, currentPanel: currentPanel, setCurrentPanel: setCurrentPanel, minDate: minDate, maxDate: maxDate })) : delayedIsTimePickerVisible ? (React.createElement(Column, null,
|
|
1803
|
+
React.createElement(Column, { overflow: "hidden", height: "250px" },
|
|
1804
|
+
React.createElement(TimePicker, { value: timeValue !== null && timeValue !== void 0 ? timeValue : "", onValueChange: onChangeTime })),
|
|
1805
|
+
React.createElement(Space, null),
|
|
1806
|
+
React.createElement(Row, { justifyContent: "flex-end" },
|
|
1807
|
+
React.createElement(PrimaryButton, { label: "Done", onClick: hideTimePicker })))) : null)) },
|
|
1808
|
+
React.createElement(DualTextInput, { autoFocusLeft: autoFocus, onEsc: onEsc, onEnter: onEnter, onBlur: onBlur, separatorIcon: faClock$1, typeLeft: "date", typeRight: "time", placeholderLeft: "yyyy-mm-dd", placeholderRight: "hh:mm", onChangeLeft: inputLeftChangeHandler, onChangeRight: inputRightChangeHandler, onClickArrowDown: onClickArrowButton, onClickCalendar: onClickCalendarButton, onFocusLeft: onFocusLeft, onFocusRight: onFocusRight, onClickLeft: onFocusLeft, onClickRight: onFocusRight, inputRefLeft: dateInputRef, inputRefRight: timeInputRef, valueRight: timeValue !== null && timeValue !== void 0 ? timeValue : "", widthLeft: "104px", widthRight: "64px", minLeft: minDate, maxLeft: maxDate }))));
|
|
1811
1809
|
};
|
|
1812
1810
|
|
|
1813
|
-
var useDateRangeEffects
|
|
1811
|
+
var useDateRangeEffects = function (startDate, endDate, setDateInFocus, startDateInputRef, endDateInputRef) {
|
|
1814
1812
|
useEffect(function moveFocusedDateWhenStartDateChanges() {
|
|
1815
1813
|
if (startDate) {
|
|
1816
1814
|
setDateInFocus(startDate);
|
|
@@ -1843,7 +1841,7 @@ var useDateRangeEffects$1 = function (startDate, endDate, setDateInFocus, startD
|
|
|
1843
1841
|
}, [endDate, endDateInputRef]);
|
|
1844
1842
|
};
|
|
1845
1843
|
|
|
1846
|
-
var useDateRangeHandlers
|
|
1844
|
+
var useDateRangeHandlers = function (startDate, endDate, onValueChange, _a) {
|
|
1847
1845
|
var setDateInFocus = _a.setDateInFocus, showCalendarInternal = _a.showCalendarInternal, hideCalendarInternal = _a.hideCalendarInternal, setFirstFocusedInput = _a.setFirstFocusedInput, setCurrentPanel = _a.setCurrentPanel;
|
|
1848
1846
|
var inputLeftChangeHandler = useCallback(function (ev) {
|
|
1849
1847
|
var _a;
|
|
@@ -1896,7 +1894,7 @@ var useDateRangeHandlers$1 = function (startDate, endDate, onValueChange, _a) {
|
|
|
1896
1894
|
};
|
|
1897
1895
|
};
|
|
1898
1896
|
|
|
1899
|
-
var useInputStates
|
|
1897
|
+
var useInputStates = function (startDate, endDate) {
|
|
1900
1898
|
var _a = useBoolean(false), isCalendarVisible = _a[0], showCalendarInternal = _a[1], hideCalendarInternal = _a[2];
|
|
1901
1899
|
var _b = useState(undefined), firstFocusedInput = _b[0], setFirstFocusedInput = _b[1];
|
|
1902
1900
|
var _c = useState("startDate"), focusedInput = _c[0], setFocusedInput = _c[1];
|
|
@@ -1924,7 +1922,7 @@ var useInputStates$1 = function (startDate, endDate) {
|
|
|
1924
1922
|
};
|
|
1925
1923
|
};
|
|
1926
1924
|
|
|
1927
|
-
var useUserInputHandlers
|
|
1925
|
+
var useUserInputHandlers = function (startDate, endDate, onValueChange, startDateInputRef, endDateInputRef, showCalendar, hideCalendar, _a) {
|
|
1928
1926
|
var firstFocusedInput = _a.firstFocusedInput, setFirstFocusedInput = _a.setFirstFocusedInput, isCalendarVisible = _a.isCalendarVisible, setFocusedInput = _a.setFocusedInput, focusedInput = _a.focusedInput, setCurrentPanel = _a.setCurrentPanel;
|
|
1929
1927
|
var onFocusLeft = useCallback(function () {
|
|
1930
1928
|
if (firstFocusedInput == null) {
|
|
@@ -1957,30 +1955,52 @@ var useUserInputHandlers$1 = function (startDate, endDate, onValueChange, startD
|
|
|
1957
1955
|
firstFocusedInput,
|
|
1958
1956
|
]);
|
|
1959
1957
|
var onClickDay = useCallback(function (day) {
|
|
1960
|
-
var _a, _b;
|
|
1958
|
+
var _a, _b, _c, _d;
|
|
1961
1959
|
if (focusedInput === "startDate") {
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1960
|
+
if (endDate != null && isAfter(day.date, endDate)) {
|
|
1961
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange({
|
|
1962
|
+
startDate: day.date,
|
|
1963
|
+
endDate: undefined,
|
|
1964
|
+
});
|
|
1967
1965
|
setFocusedInput("endDate");
|
|
1968
1966
|
(_a = endDateInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1969
1967
|
}
|
|
1970
1968
|
else {
|
|
1971
|
-
|
|
1969
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange({
|
|
1970
|
+
startDate: day.date,
|
|
1971
|
+
endDate: endDate,
|
|
1972
|
+
});
|
|
1973
|
+
if (firstFocusedInput === "startDate") {
|
|
1974
|
+
setFocusedInput("endDate");
|
|
1975
|
+
(_b = endDateInputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
1976
|
+
}
|
|
1977
|
+
else {
|
|
1978
|
+
setTimeout(hideCalendar, 50);
|
|
1979
|
+
}
|
|
1972
1980
|
}
|
|
1973
1981
|
}
|
|
1974
1982
|
else if (focusedInput === "endDate") {
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1983
|
+
if (!startDate) {
|
|
1984
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange({
|
|
1985
|
+
startDate: startDate,
|
|
1986
|
+
endDate: day.date,
|
|
1987
|
+
});
|
|
1980
1988
|
setFocusedInput("startDate");
|
|
1981
|
-
(
|
|
1989
|
+
(_c = startDateInputRef.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
1990
|
+
}
|
|
1991
|
+
else if (isAfter(startDate, day.date)) {
|
|
1992
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange({
|
|
1993
|
+
startDate: day.date,
|
|
1994
|
+
endDate: undefined,
|
|
1995
|
+
});
|
|
1996
|
+
setFocusedInput("endDate");
|
|
1997
|
+
(_d = endDateInputRef.current) === null || _d === void 0 ? void 0 : _d.focus();
|
|
1982
1998
|
}
|
|
1983
1999
|
else {
|
|
2000
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange({
|
|
2001
|
+
startDate: startDate,
|
|
2002
|
+
endDate: day.date,
|
|
2003
|
+
});
|
|
1984
2004
|
setTimeout(hideCalendar, 50);
|
|
1985
2005
|
}
|
|
1986
2006
|
}
|
|
@@ -2036,24 +2056,24 @@ var useUserInputHandlers$1 = function (startDate, endDate, onValueChange, startD
|
|
|
2036
2056
|
};
|
|
2037
2057
|
|
|
2038
2058
|
var DateRangeDualTextInput = function (_a) {
|
|
2039
|
-
var value = _a.value, onValueChange = _a.onValueChange, autoFocus = _a.autoFocus, onBlur = _a.onBlur, onEnter = _a.onEnter, onEsc = _a.onEsc;
|
|
2040
|
-
var
|
|
2059
|
+
var value = _a.value, onValueChange = _a.onValueChange, autoFocus = _a.autoFocus, onBlur = _a.onBlur, onEnter = _a.onEnter, onEsc = _a.onEsc, minDate = _a.minDate, _b = _a.maxDate, maxDate = _b === void 0 ? defaultMaxDate : _b, calendarProps = _a.calendarProps, _c = _a.widthLeft, widthLeft = _c === void 0 ? 128 : _c, _d = _a.widthRight, widthRight = _d === void 0 ? 128 : _d;
|
|
2060
|
+
var _e = value || {}, startDate = _e.startDate, endDate = _e.endDate;
|
|
2041
2061
|
var startDateInputRef = useRef(null);
|
|
2042
2062
|
var endDateInputRef = useRef(null);
|
|
2043
|
-
var states = useInputStates
|
|
2063
|
+
var states = useInputStates(startDate, endDate);
|
|
2044
2064
|
var dateInFocus = states.dateInFocus, setDateInFocus = states.setDateInFocus, isCalendarVisible = states.isCalendarVisible, currentPanel = states.currentPanel, setCurrentPanel = states.setCurrentPanel;
|
|
2045
|
-
var
|
|
2046
|
-
var
|
|
2047
|
-
useDateRangeEffects
|
|
2065
|
+
var _f = useDateRangeHandlers(startDate, endDate, onValueChange, states), showCalendar = _f.showCalendar, hideCalendar = _f.hideCalendar, inputLeftChangeHandler = _f.inputLeftChangeHandler, inputRightChangeHandler = _f.inputRightChangeHandler;
|
|
2066
|
+
var _g = useUserInputHandlers(startDate, endDate, onValueChange, startDateInputRef, endDateInputRef, showCalendar, hideCalendar, states), onKeyDownHandler = _g.onKeyDownHandler, onFocusRight = _g.onFocusRight, onFocusLeft = _g.onFocusLeft, onClickDay = _g.onClickDay, onClickCalendarButton = _g.onClickCalendarButton, onClickArrowButton = _g.onClickArrowButton;
|
|
2067
|
+
useDateRangeEffects(startDate, endDate, setDateInFocus, startDateInputRef, endDateInputRef);
|
|
2048
2068
|
var startDateIsAfterEnd = useMemo(function () { return startDate && endDate && isAfter(startDate, endDate); }, [startDate, endDate]);
|
|
2049
2069
|
var statePerMonth = useMemo(function () {
|
|
2050
|
-
return buildDayStateForSingleMonth(
|
|
2051
|
-
}, [startDate, endDate, dateInFocus]);
|
|
2070
|
+
return buildDayStateForSingleMonth(calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.statePerMonth, startDate, endDate, dateInFocus);
|
|
2071
|
+
}, [calendarProps === null || calendarProps === void 0 ? void 0 : calendarProps.statePerMonth, startDate, endDate, dateInFocus]);
|
|
2052
2072
|
var delayedIsCalendarVisible = useDelayedFalse(isCalendarVisible, 300);
|
|
2053
|
-
return (createElement(Box, { onKeyDown: onKeyDownHandler },
|
|
2054
|
-
createElement(Popover, { arrow: false, lazy: true, placement: defaultPopoverPlacement, onClickOutside: hideCalendar, visible: isCalendarVisible, content: delayedIsCalendarVisible && (createElement(CalendarWithMonthSwitcher, {
|
|
2055
|
-
createElement(DualTextInput, { autoFocusLeft: autoFocus, onEsc: onEsc, onEnter: onEnter, onBlur: onBlur, separatorIcon: stenaArrowRight, typeLeft: "date", typeRight: "date", placeholderLeft: "Start date", placeholderRight: "End date", onChangeLeft: inputLeftChangeHandler, onChangeRight: inputRightChangeHandler, onClickArrowDown: onClickArrowButton, onClickCalendar: onClickCalendarButton, onFocusLeft: onFocusLeft, onFocusRight: onFocusRight, onClickLeft: onFocusLeft, onClickRight: onFocusRight, inputRefLeft: startDateInputRef, inputRefRight: endDateInputRef, variant: startDateIsAfterEnd ? "error" : undefined, widthLeft:
|
|
2073
|
+
return (React.createElement(Box, { onKeyDown: onKeyDownHandler },
|
|
2074
|
+
React.createElement(Popover, { arrow: false, lazy: true, placement: defaultPopoverPlacement, onClickOutside: hideCalendar, visible: isCalendarVisible, content: delayedIsCalendarVisible && (React.createElement(CalendarWithMonthSwitcher, __assign({ onClickDay: onClickDay, dateInFocus: dateInFocus, setDateInFocus: setDateInFocus, currentPanel: currentPanel, setCurrentPanel: setCurrentPanel, minDate: minDate, maxDate: maxDate }, calendarProps, { statePerMonth: statePerMonth }))) },
|
|
2075
|
+
React.createElement(DualTextInput, { autoFocusLeft: autoFocus, onEsc: onEsc, onEnter: onEnter, onBlur: onBlur, separatorIcon: stenaArrowRight, typeLeft: "date", typeRight: "date", placeholderLeft: "Start date", placeholderRight: "End date", onChangeLeft: inputLeftChangeHandler, onChangeRight: inputRightChangeHandler, onClickArrowDown: onClickArrowButton, onClickCalendar: onClickCalendarButton, onFocusLeft: onFocusLeft, onFocusRight: onFocusRight, onClickLeft: onFocusLeft, onClickRight: onFocusRight, inputRefLeft: startDateInputRef, inputRefRight: endDateInputRef, variant: startDateIsAfterEnd ? "error" : undefined, widthLeft: widthLeft, widthRight: widthRight, minLeft: minDate, maxLeft: maxDate, minRight: minDate, maxRight: maxDate }))));
|
|
2056
2076
|
};
|
|
2057
2077
|
|
|
2058
|
-
export { Calendar, CalendarDay, DateInput, DateRangeCalendar, DateRangeDualTextInput, DateRangeExclusionCalendar, DateRangeInput, DateTextInput, DateTimeInput, Month, MonthPicker, MultiDateCalendar, PresetPicker, SingleDateCalendar, SingleWeekCalendar, TimeTextInput, WeekDay, WeekDayCell, WeekNumberCell, YearPicker, addDayStateHighlights, addWeekRangeHighlights, addWeekStateHighlights, buildDayStateForDateRange, buildDayStateForRange, buildDayStateForSingleMonth, calculateOverflowingMonth, createDay, dayHasHighlight, dayHighlightSelect, defaultCalendarTheme, defaultTextPropsProvider, defaultWrapperStyleProvider,
|
|
2078
|
+
export { Calendar, CalendarDay, DateInput, DateRangeCalendar, DateRangeDualTextInput, DateRangeExclusionCalendar, DateRangeInput, DateTextInput, DateTimeInput, Month, MonthPicker, MultiDateCalendar, PresetPicker, SingleDateCalendar, SingleWeekCalendar, TimeTextInput, WeekDay, WeekDayCell, WeekNumberCell, YearPicker, addDayStateHighlights, addDayStateHighlightsOnSingleDay, addWeekRangeHighlights, addWeekStateHighlights, buildDayStateForDateRange, buildDayStateForRange, buildDayStateForSingleMonth, calculateOverflowingMonth, createDay, dateRangeToStrings, dayHasHighlight, dayHighlightSelect, defaultCalendarTheme, defaultTextPropsProvider, defaultWrapperStyleProvider, extranetCalendarTheme, getDaysForWeekForDate, getMonthInYear, getMonthsInYear, getStartDateOfISOWeek, getWeekForDate, getWeeksForMonth, isDateRangeInvalid, setDayStateValue, setDayStateValueFunction, stringsToDateRange, toggleDateStringsIfEndIsEarlierThanStart, toggleDatesIfEndIsEarlierThanStart, useDateRangeCalendarState, useDateRangeExclusionSelection, useDateRangeSelection, useMultiDateSelection, useSingleDateSelection, useSingleWeekSelection };
|
|
2059
2079
|
//# sourceMappingURL=index.es.js.map
|