@chayns-components/date 5.0.0-beta.1000
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/LICENSE +21 -0
- package/README.md +34 -0
- package/lib/cjs/components/calendar/Calendar.js +314 -0
- package/lib/cjs/components/calendar/Calendar.js.map +1 -0
- package/lib/cjs/components/calendar/Calendar.styles.js +34 -0
- package/lib/cjs/components/calendar/Calendar.styles.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js +158 -0
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.styles.js +23 -0
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.styles.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/Month.js +65 -0
- package/lib/cjs/components/calendar/month-wrapper/month/Month.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/Month.styles.js +26 -0
- package/lib/cjs/components/calendar/month-wrapper/month/Month.styles.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +129 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js +16 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +63 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js +114 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js +17 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js +18 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +42 -0
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.js +16 -0
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js +15 -0
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js.map +1 -0
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js +17 -0
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js.map +1 -0
- package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js +86 -0
- package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -0
- package/lib/cjs/components/date-info/DateInfo.js +35 -0
- package/lib/cjs/components/date-info/DateInfo.js.map +1 -0
- package/lib/cjs/components/opening-times/OpeningTimes.js +246 -0
- package/lib/cjs/components/opening-times/OpeningTimes.js.map +1 -0
- package/lib/cjs/components/opening-times/OpeningTimes.styles.js +28 -0
- package/lib/cjs/components/opening-times/OpeningTimes.styles.js.map +1 -0
- package/lib/cjs/components/opening-times/hint-text/HintText.js +19 -0
- package/lib/cjs/components/opening-times/hint-text/HintText.js.map +1 -0
- package/lib/cjs/components/opening-times/hint-text/HintText.styles.js +24 -0
- package/lib/cjs/components/opening-times/hint-text/HintText.styles.js.map +1 -0
- package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.js +153 -0
- package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -0
- package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.styles.js +24 -0
- package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -0
- package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.js +106 -0
- package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -0
- package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +41 -0
- package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -0
- package/lib/cjs/hooks/useDateInfo.js +63 -0
- package/lib/cjs/hooks/useDateInfo.js.map +1 -0
- package/lib/cjs/index.js +177 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/types/calendar.js +28 -0
- package/lib/cjs/types/calendar.js.map +1 -0
- package/lib/cjs/types/dateinfo.js +2 -0
- package/lib/cjs/types/dateinfo.js.map +1 -0
- package/lib/cjs/types/openingTimes.js +18 -0
- package/lib/cjs/types/openingTimes.js.map +1 -0
- package/lib/cjs/utils/calendar.js +73 -0
- package/lib/cjs/utils/calendar.js.map +1 -0
- package/lib/cjs/utils/date.js +114 -0
- package/lib/cjs/utils/date.js.map +1 -0
- package/lib/cjs/utils/dateInfo.js +126 -0
- package/lib/cjs/utils/dateInfo.js.map +1 -0
- package/lib/esm/components/calendar/Calendar.js +306 -0
- package/lib/esm/components/calendar/Calendar.js.map +1 -0
- package/lib/esm/components/calendar/Calendar.styles.js +33 -0
- package/lib/esm/components/calendar/Calendar.styles.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js +150 -0
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.styles.js +22 -0
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.styles.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/Month.js +61 -0
- package/lib/esm/components/calendar/month-wrapper/month/Month.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js +22 -0
- package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +121 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js +9 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +54 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js +123 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js +13 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js +14 -0
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +34 -0
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.js +9 -0
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js +11 -0
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js.map +1 -0
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js +13 -0
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js.map +1 -0
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js +79 -0
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -0
- package/lib/esm/components/date-info/DateInfo.js +28 -0
- package/lib/esm/components/date-info/DateInfo.js.map +1 -0
- package/lib/esm/components/opening-times/OpeningTimes.js +240 -0
- package/lib/esm/components/opening-times/OpeningTimes.js.map +1 -0
- package/lib/esm/components/opening-times/OpeningTimes.styles.js +24 -0
- package/lib/esm/components/opening-times/OpeningTimes.styles.js.map +1 -0
- package/lib/esm/components/opening-times/hint-text/HintText.js +12 -0
- package/lib/esm/components/opening-times/hint-text/HintText.js.map +1 -0
- package/lib/esm/components/opening-times/hint-text/HintText.styles.js +23 -0
- package/lib/esm/components/opening-times/hint-text/HintText.styles.js.map +1 -0
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.js +149 -0
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -0
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js +22 -0
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -0
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.js +99 -0
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -0
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +40 -0
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -0
- package/lib/esm/hooks/useDateInfo.js +57 -0
- package/lib/esm/hooks/useDateInfo.js.map +1 -0
- package/lib/esm/index.js +15 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/types/calendar.js +22 -0
- package/lib/esm/types/calendar.js.map +1 -0
- package/lib/esm/types/dateinfo.js +2 -0
- package/lib/esm/types/dateinfo.js.map +1 -0
- package/lib/esm/types/openingTimes.js +12 -0
- package/lib/esm/types/openingTimes.js.map +1 -0
- package/lib/esm/utils/calendar.js +63 -0
- package/lib/esm/utils/calendar.js.map +1 -0
- package/lib/esm/utils/date.js +89 -0
- package/lib/esm/utils/date.js.map +1 -0
- package/lib/esm/utils/dateInfo.js +120 -0
- package/lib/esm/utils/dateInfo.js.map +1 -0
- package/lib/types/components/calendar/Calendar.d.ts +97 -0
- package/lib/types/components/calendar/Calendar.styles.d.ts +8 -0
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.d.ts +26 -0
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.styles.d.ts +274 -0
- package/lib/types/components/calendar/month-wrapper/month/Month.d.ts +26 -0
- package/lib/types/components/calendar/month-wrapper/month/Month.styles.d.ts +8 -0
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.d.ts +20 -0
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.d.ts +1 -0
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/Day.d.ts +19 -0
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.d.ts +20 -0
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.d.ts +6 -0
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.d.ts +7 -0
- package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.d.ts +7 -0
- package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.d.ts +1 -0
- package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.d.ts +6 -0
- package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.d.ts +3 -0
- package/lib/types/components/calendar/month-year-pickers/MonthYearPickers.d.ts +19 -0
- package/lib/types/components/date-info/DateInfo.d.ts +5 -0
- package/lib/types/components/opening-times/OpeningTimes.d.ts +51 -0
- package/lib/types/components/opening-times/OpeningTimes.styles.d.ts +11 -0
- package/lib/types/components/opening-times/hint-text/HintText.d.ts +6 -0
- package/lib/types/components/opening-times/hint-text/HintText.styles.d.ts +3 -0
- package/lib/types/components/opening-times/opening-inputs/OpeningInputs.d.ts +46 -0
- package/lib/types/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +272 -0
- package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.d.ts +15 -0
- package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +273 -0
- package/lib/types/hooks/useDateInfo.d.ts +2 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/types/calendar.d.ts +55 -0
- package/lib/types/types/dateinfo.d.ts +34 -0
- package/lib/types/types/openingTimes.d.ts +33 -0
- package/lib/types/utils/calendar.d.ts +18 -0
- package/lib/types/utils/date.d.ts +27 -0
- package/lib/types/utils/dateInfo.d.ts +14 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Tobit Laboratories AG
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>
|
|
3
|
+
<img src="https://raw.githubusercontent.com/TobitSoftware/chayns-components/master/assets/logo.png" width="600px" alt="chayns-components" />
|
|
4
|
+
</h1>
|
|
5
|
+
<p>A set of beautiful React components for developing your own applications with chayns.</p>
|
|
6
|
+
<div>
|
|
7
|
+
<img src="https://img.shields.io/npm/dm/@chayns-components/typewriter.svg?style=for-the-badge" alt="" />
|
|
8
|
+
<img src="https://img.shields.io/npm/v/@chayns-components/typewriter?style=for-the-badge" alt="" />
|
|
9
|
+
<img src="https://img.shields.io/github/license/TobitSoftware/chayns-components?style=for-the-badge" alt="" />
|
|
10
|
+
<img src="https://img.shields.io/github/contributors/TobitSoftware/chayns-components?style=for-the-badge" alt="" />
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
First you need to install the color picker part of the chayns-components.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# NPM
|
|
22
|
+
npm install @chayns-components/date
|
|
23
|
+
|
|
24
|
+
# Yarn
|
|
25
|
+
yarn add @chayns-components/date
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
> **Information:** Since the components have now been implemented with the styled-components
|
|
29
|
+
> library, the styles are delivered directly with the components. There is no need to load an extra
|
|
30
|
+
> stylesheet anymore.
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
For detailed usage visit the [storybook](https://components.chayns.site/storybook).
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _core = require("@chayns-components/core");
|
|
8
|
+
var _chaynsApi = require("chayns-api");
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _calendar = require("../../types/calendar");
|
|
11
|
+
var _calendar2 = require("../../utils/calendar");
|
|
12
|
+
var _date = require("../../utils/date");
|
|
13
|
+
var _Calendar = require("./Calendar.styles");
|
|
14
|
+
var _MonthWrapper = _interopRequireDefault(require("./month-wrapper/MonthWrapper"));
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
const DEFAULT_MAX_DATE = (0, _date.addYears)(new Date(), 1);
|
|
19
|
+
const DEFAULT_MIN_DATE = (0, _date.subYears)(new Date(), 1);
|
|
20
|
+
const Calendar = ({
|
|
21
|
+
locale = _chaynsApi.Language.German,
|
|
22
|
+
maxDate = DEFAULT_MAX_DATE,
|
|
23
|
+
minDate = DEFAULT_MIN_DATE,
|
|
24
|
+
highlightedDates,
|
|
25
|
+
onChange,
|
|
26
|
+
customThumbColors,
|
|
27
|
+
selectedDate,
|
|
28
|
+
selectedDates,
|
|
29
|
+
selectedDateInterval,
|
|
30
|
+
categories,
|
|
31
|
+
isDisabled,
|
|
32
|
+
type = _calendar.CalendarType.Single,
|
|
33
|
+
shouldShowHighlightsInMonthOverlay = true,
|
|
34
|
+
disabledDates = [],
|
|
35
|
+
showMonthYearPickers: showMonthYearPickersProp,
|
|
36
|
+
onShownDatesChange = () => {}
|
|
37
|
+
}) => {
|
|
38
|
+
const [currentDate, setCurrentDate] = (0, _react.useState)();
|
|
39
|
+
const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = (0, _react.useState)(true);
|
|
40
|
+
const [internalSelectedDate, setInternalSelectedDate] = (0, _react.useState)(() => type === _calendar.CalendarType.Multiple ? [] : undefined);
|
|
41
|
+
const [direction, setDirection] = (0, _react.useState)();
|
|
42
|
+
const [width, setWidth] = (0, _react.useState)(0);
|
|
43
|
+
const showMonthYearPickers = (0, _react.useMemo)(() => {
|
|
44
|
+
const hasMultipleMonths = (0, _date.differenceInCalendarMonths)(maxDate, minDate) > 0;
|
|
45
|
+
const hasMultipleYears = (0, _calendar2.getYearsBetween)(minDate, maxDate).length > 1;
|
|
46
|
+
return !!(showMonthYearPickersProp && (hasMultipleMonths || hasMultipleYears));
|
|
47
|
+
}, [minDate, maxDate, showMonthYearPickersProp]);
|
|
48
|
+
const calendarRef = (0, _react.useRef)(null);
|
|
49
|
+
(0, _react.useEffect)(() => {
|
|
50
|
+
if (currentDate) {
|
|
51
|
+
const start = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
|
|
52
|
+
if (shouldRenderTwoMonths) {
|
|
53
|
+
const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 2, 0);
|
|
54
|
+
onShownDatesChange({
|
|
55
|
+
start,
|
|
56
|
+
end
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
|
|
60
|
+
onShownDatesChange({
|
|
61
|
+
start,
|
|
62
|
+
end
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
|
+
}, [currentDate, shouldRenderTwoMonths]);
|
|
68
|
+
(0, _react.useEffect)(() => {
|
|
69
|
+
const bounds = {
|
|
70
|
+
start: minDate,
|
|
71
|
+
end: maxDate
|
|
72
|
+
};
|
|
73
|
+
if (type === _calendar.CalendarType.Single) {
|
|
74
|
+
if (selectedDate) {
|
|
75
|
+
const isDisabledDate = disabledDates.some(disabledDate => (0, _date.isSameDay)(selectedDate, disabledDate));
|
|
76
|
+
const isDateInBounds = (0, _date.isWithinInterval)(selectedDate, bounds);
|
|
77
|
+
if (!isDisabledDate && isDateInBounds) {
|
|
78
|
+
setInternalSelectedDate(selectedDate);
|
|
79
|
+
} else {
|
|
80
|
+
console.warn('[@chayns-components/date] Warning: Failed to set selectedDate, because it is disabled or out of bounds.', '\nselectedDate:', selectedDate, ...(isDisabledDate ? ['\nselectedDate is disabled'] : []), ...(isDateInBounds ? [] : ['\nselectedDate is outside of bounds:', {
|
|
81
|
+
minDate,
|
|
82
|
+
maxDate
|
|
83
|
+
}]));
|
|
84
|
+
setInternalSelectedDate(() => undefined);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
setInternalSelectedDate(() => undefined);
|
|
88
|
+
}
|
|
89
|
+
} else if (type === _calendar.CalendarType.Multiple) {
|
|
90
|
+
if (selectedDates) {
|
|
91
|
+
const disabledSelectedDates = [];
|
|
92
|
+
const datesOutsideOfBounds = [];
|
|
93
|
+
const filteredDates = selectedDates.filter(date => {
|
|
94
|
+
if (disabledDates.some(disabledDate => (0, _date.isSameDay)(date, disabledDate))) {
|
|
95
|
+
disabledSelectedDates.push(date);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (!(0, _date.isWithinInterval)(date, bounds)) {
|
|
99
|
+
datesOutsideOfBounds.push(date);
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
});
|
|
104
|
+
if (disabledSelectedDates.length > 0 || datesOutsideOfBounds.length > 0) {
|
|
105
|
+
console.warn('[@chayns-components/date] Warning: Failed to set all selectedDates, because some are disabled or out of bounds.', ...(disabledSelectedDates.length > 0 ? ['\nselectedDates that are disabled:', disabledSelectedDates] : []), ...(datesOutsideOfBounds.length > 0 ? ['\nselectedDates that are outside of bounds:', datesOutsideOfBounds, 'bounds:', {
|
|
106
|
+
minDate,
|
|
107
|
+
maxDate
|
|
108
|
+
}] : []));
|
|
109
|
+
}
|
|
110
|
+
setInternalSelectedDate(filteredDates);
|
|
111
|
+
} else {
|
|
112
|
+
setInternalSelectedDate([]);
|
|
113
|
+
}
|
|
114
|
+
} else if (type === _calendar.CalendarType.Interval) {
|
|
115
|
+
if (selectedDateInterval) {
|
|
116
|
+
const intervalIncludesDisabledDate = selectedDateInterval.end && disabledDates.some(disabledDate => (0, _date.isWithinInterval)(disabledDate, {
|
|
117
|
+
start: selectedDateInterval.start,
|
|
118
|
+
end: selectedDateInterval.end
|
|
119
|
+
}));
|
|
120
|
+
const intervalIsInBounds = (0, _date.isWithinInterval)(selectedDateInterval.start, bounds) && (!selectedDateInterval.end || (0, _date.isWithinInterval)(selectedDateInterval.end, bounds));
|
|
121
|
+
if (!intervalIncludesDisabledDate && intervalIsInBounds) {
|
|
122
|
+
setInternalSelectedDate(selectedDateInterval);
|
|
123
|
+
} else {
|
|
124
|
+
console.warn('[@chayns-components/date] Warning: Failed to set selectedDateInterval, because it includes disabled dates or dates that are out of bounds.', '\nselectedDateInterval:', selectedDateInterval, ...(intervalIncludesDisabledDate ? ['\ndisabled dates:', disabledDates] : []), ...(intervalIsInBounds ? [] : ['\nbounds:', {
|
|
125
|
+
minDate,
|
|
126
|
+
maxDate
|
|
127
|
+
}]));
|
|
128
|
+
setInternalSelectedDate(() => undefined);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, [type, selectedDate, selectedDates, selectedDateInterval, disabledDates, minDate, maxDate]);
|
|
133
|
+
(0, _react.useEffect)(() => {
|
|
134
|
+
if (calendarRef.current) {
|
|
135
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
136
|
+
if (entries && entries[0]) {
|
|
137
|
+
const observedWidth = entries[0].contentRect.width;
|
|
138
|
+
setWidth(observedWidth - 30);
|
|
139
|
+
if (observedWidth < 430) {
|
|
140
|
+
setShouldRenderTwoMonths(false);
|
|
141
|
+
} else {
|
|
142
|
+
setShouldRenderTwoMonths(true);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
resizeObserver.observe(calendarRef.current);
|
|
147
|
+
return () => {
|
|
148
|
+
resizeObserver.disconnect();
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return () => {};
|
|
152
|
+
}, []);
|
|
153
|
+
(0, _react.useEffect)(() => {
|
|
154
|
+
setCurrentDate(prevDate => (0, _calendar2.isDateInRange)({
|
|
155
|
+
minDate,
|
|
156
|
+
maxDate,
|
|
157
|
+
currentDate: prevDate || new Date()
|
|
158
|
+
}));
|
|
159
|
+
}, [maxDate, minDate]);
|
|
160
|
+
const handleLeftArrowClick = (0, _react.useCallback)(() => {
|
|
161
|
+
if (direction) return;
|
|
162
|
+
setDirection('left');
|
|
163
|
+
setCurrentDate(prevDate => {
|
|
164
|
+
if (!prevDate) {
|
|
165
|
+
return prevDate;
|
|
166
|
+
}
|
|
167
|
+
const newDate = (0, _calendar2.getNewDate)(-1, prevDate);
|
|
168
|
+
return (0, _calendar2.isDateInRange)({
|
|
169
|
+
minDate,
|
|
170
|
+
maxDate,
|
|
171
|
+
currentDate: newDate
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}, [maxDate, minDate, direction]);
|
|
175
|
+
const handleRightArrowClick = (0, _react.useCallback)(() => {
|
|
176
|
+
if (direction) return;
|
|
177
|
+
setDirection('right');
|
|
178
|
+
setCurrentDate(prevDate => {
|
|
179
|
+
if (!prevDate) {
|
|
180
|
+
return prevDate;
|
|
181
|
+
}
|
|
182
|
+
const newDate = (0, _calendar2.getNewDate)(1, prevDate);
|
|
183
|
+
return (0, _calendar2.isDateInRange)({
|
|
184
|
+
minDate,
|
|
185
|
+
maxDate,
|
|
186
|
+
currentDate: newDate
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}, [maxDate, minDate, direction]);
|
|
190
|
+
const handleSelect = (0, _react.useCallback)(date => {
|
|
191
|
+
setInternalSelectedDate(prevDate => {
|
|
192
|
+
let onChangePayload = null;
|
|
193
|
+
let newInternalSelectedDate;
|
|
194
|
+
if (type === _calendar.CalendarType.Single) {
|
|
195
|
+
onChangePayload = date;
|
|
196
|
+
newInternalSelectedDate = date;
|
|
197
|
+
} else if (type === _calendar.CalendarType.Multiple) {
|
|
198
|
+
const prevSelectedDates = prevDate;
|
|
199
|
+
// Selects or unselects date , depending on if it is already selected.
|
|
200
|
+
if (prevSelectedDates.some(d => (0, _date.isSameDay)(d, date))) {
|
|
201
|
+
newInternalSelectedDate = prevSelectedDates.filter(d => !(0, _date.isSameDay)(d, date));
|
|
202
|
+
} else {
|
|
203
|
+
newInternalSelectedDate = [...prevSelectedDates, date];
|
|
204
|
+
}
|
|
205
|
+
onChangePayload = newInternalSelectedDate;
|
|
206
|
+
} else if (type === _calendar.CalendarType.Interval) {
|
|
207
|
+
const prevSelectedDateInterval = prevDate;
|
|
208
|
+
const updateInterval = (start, end) => {
|
|
209
|
+
const newInterval = {
|
|
210
|
+
start,
|
|
211
|
+
end
|
|
212
|
+
};
|
|
213
|
+
onChangePayload = newInterval;
|
|
214
|
+
newInternalSelectedDate = newInterval;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// Sets first selection as interval start.
|
|
218
|
+
if (!prevSelectedDateInterval) {
|
|
219
|
+
updateInterval(date);
|
|
220
|
+
} else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {
|
|
221
|
+
// Sets second selection as interval start, if it is earlier than the previous interval start.
|
|
222
|
+
// Else sets it as interval end.
|
|
223
|
+
if (date < prevSelectedDateInterval.start) {
|
|
224
|
+
updateInterval(date);
|
|
225
|
+
} else {
|
|
226
|
+
updateInterval(prevSelectedDateInterval.start, date);
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
// Resets interval if a third date is selected.
|
|
230
|
+
updateInterval(date);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (typeof onChange === 'function' && onChangePayload) {
|
|
234
|
+
onChange(onChangePayload);
|
|
235
|
+
}
|
|
236
|
+
return newInternalSelectedDate;
|
|
237
|
+
});
|
|
238
|
+
}, [type, onChange]);
|
|
239
|
+
const handleAnimationFinished = () => {
|
|
240
|
+
setDirection(() => undefined);
|
|
241
|
+
};
|
|
242
|
+
const ShouldShowLeftArrow = (0, _react.useMemo)(() => {
|
|
243
|
+
if (!currentDate) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
return !(0, _date.isSameMonth)(currentDate, minDate);
|
|
247
|
+
}, [currentDate, minDate]);
|
|
248
|
+
const ShouldShowRightArrow = (0, _react.useMemo)(() => {
|
|
249
|
+
if (!currentDate) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
return !(0, _date.isSameMonth)(currentDate, maxDate);
|
|
253
|
+
}, [currentDate, maxDate]);
|
|
254
|
+
return /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendar, {
|
|
255
|
+
ref: calendarRef,
|
|
256
|
+
$isDisabled: isDisabled
|
|
257
|
+
}, ShouldShowLeftArrow ? /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapper, {
|
|
258
|
+
onClick: handleLeftArrowClick
|
|
259
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
260
|
+
// TODO Use styled-components instead of inline styles
|
|
261
|
+
style: {
|
|
262
|
+
display: 'flex',
|
|
263
|
+
flexDirection: 'row',
|
|
264
|
+
flexWrap: 'nowrap',
|
|
265
|
+
height: 'fit-content'
|
|
266
|
+
}
|
|
267
|
+
}, showMonthYearPickers && /*#__PURE__*/_react.default.createElement(_Calendar.StyledPseudoMonthYearPicker, null, /*#__PURE__*/_react.default.createElement(_core.ComboBox, {
|
|
268
|
+
lists: [{
|
|
269
|
+
list: []
|
|
270
|
+
}],
|
|
271
|
+
placeholder: ""
|
|
272
|
+
})), /*#__PURE__*/_react.default.createElement(_core.Icon, {
|
|
273
|
+
icons: ['fa fa-angle-left']
|
|
274
|
+
}))) : /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapperPseudo, null), currentDate && /*#__PURE__*/_react.default.createElement(_MonthWrapper.default, {
|
|
275
|
+
shouldRenderTwo: shouldRenderTwoMonths,
|
|
276
|
+
currentDate: currentDate,
|
|
277
|
+
width: width,
|
|
278
|
+
locale: locale,
|
|
279
|
+
direction: direction,
|
|
280
|
+
customThumbColors: customThumbColors,
|
|
281
|
+
onSelect: handleSelect,
|
|
282
|
+
selectedDate: internalSelectedDate,
|
|
283
|
+
highlightedDates: highlightedDates,
|
|
284
|
+
categories: categories,
|
|
285
|
+
onAnimationFinished: handleAnimationFinished,
|
|
286
|
+
minDate: minDate,
|
|
287
|
+
maxDate: maxDate,
|
|
288
|
+
type: type,
|
|
289
|
+
disabledDates: disabledDates,
|
|
290
|
+
setCurrentDate: setCurrentDate,
|
|
291
|
+
shouldShowHighlightsInMonthOverlay: shouldShowHighlightsInMonthOverlay,
|
|
292
|
+
showMonthYearPickers: showMonthYearPickers
|
|
293
|
+
}), ShouldShowRightArrow ? /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapper, {
|
|
294
|
+
onClick: handleRightArrowClick
|
|
295
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
296
|
+
// TODO Use styled-components instead of inline styles
|
|
297
|
+
style: {
|
|
298
|
+
display: 'flex',
|
|
299
|
+
flexDirection: 'row',
|
|
300
|
+
flexWrap: 'nowrap',
|
|
301
|
+
height: 'fit-content'
|
|
302
|
+
}
|
|
303
|
+
}, showMonthYearPickers && /*#__PURE__*/_react.default.createElement(_Calendar.StyledPseudoMonthYearPicker, null, /*#__PURE__*/_react.default.createElement(_core.ComboBox, {
|
|
304
|
+
lists: [{
|
|
305
|
+
list: []
|
|
306
|
+
}],
|
|
307
|
+
placeholder: ""
|
|
308
|
+
})), /*#__PURE__*/_react.default.createElement(_core.Icon, {
|
|
309
|
+
icons: ['fa fa-angle-right']
|
|
310
|
+
}))) : /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapperPseudo, null));
|
|
311
|
+
};
|
|
312
|
+
Calendar.displayName = 'Calendar';
|
|
313
|
+
var _default = exports.default = Calendar;
|
|
314
|
+
//# sourceMappingURL=Calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calendar.js","names":["_core","require","_chaynsApi","_react","_interopRequireWildcard","_calendar","_calendar2","_date","_Calendar","_MonthWrapper","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DEFAULT_MAX_DATE","addYears","Date","DEFAULT_MIN_DATE","subYears","Calendar","locale","Language","German","maxDate","minDate","highlightedDates","onChange","customThumbColors","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","CalendarType","Single","shouldShowHighlightsInMonthOverlay","disabledDates","showMonthYearPickers","showMonthYearPickersProp","onShownDatesChange","currentDate","setCurrentDate","useState","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","useMemo","hasMultipleMonths","differenceInCalendarMonths","hasMultipleYears","getYearsBetween","length","calendarRef","useRef","useEffect","start","getFullYear","getMonth","end","bounds","isDisabledDate","some","disabledDate","isSameDay","isDateInBounds","isWithinInterval","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","prevDate","isDateInRange","handleLeftArrowClick","useCallback","newDate","getNewDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","isSameMonth","ShouldShowRightArrow","createElement","StyledCalendar","ref","$isDisabled","StyledCalendarIconWrapper","onClick","style","display","flexDirection","flexWrap","height","StyledPseudoMonthYearPicker","ComboBox","lists","list","placeholder","Icon","icons","StyledCalendarIconWrapperPseudo","shouldRenderTwo","onSelect","onAnimationFinished","displayName","_default","exports"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport { Language } from 'chayns-api';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n CalendarType,\n Categories,\n CustomThumbColors,\n DateInterval,\n HighlightedDates,\n} from '../../types/calendar';\nimport { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';\nimport {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears,\n} from '../../utils/date';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n StyledPseudoMonthYearPicker,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * Custom colors for the thumb.\n */\n customThumbColors?: CustomThumbColors;\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Language;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n /**\n * Whether the highlighted dates should be displayed for the greyed month overlay days.\n */\n shouldShowHighlightsInMonthOverlay?: boolean;\n /**\n * Shows the month and year pickers, if there are multiple months/years to select from.\n */\n showMonthYearPickers?: boolean;\n /**\n * Function to be executed when the selected date, dates or date interval change.\n * @param date\n */\n onChange?: (date: Date | Date[] | DateInterval) => void;\n /**\n * Function to be executed when the shown dates change. Returns the start of the displayed month and the end of the last displayed month (since depending on the available widths, there are one or two months displayed).\n @param { start: Date, end: Date }\n */\n onShownDatesChange?: (dates: { start: Date; end: Date }) => void;\n}\n\ninterface SingleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type?: CalendarType.Single;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n selectedDates?: never;\n selectedDateInterval?: never;\n}\n\ninterface MultipleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Multiple;\n /**\n * An array of dates that should be preselected.\n */\n selectedDates?: Date[];\n selectedDate?: never;\n selectedDateInterval?: never;\n}\n\ninterface IntervalSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Interval;\n /**\n * An interval that should be preselected.\n */\n selectedDateInterval?: DateInterval;\n selectedDates?: never;\n selectedDate?: never;\n}\n\nexport type CalendarProps = BaseProps &\n (SingleSelectionProps | MultipleSelectionProps | IntervalSelectionProps);\n\nconst DEFAULT_MAX_DATE = addYears(new Date(), 1);\nconst DEFAULT_MIN_DATE = subYears(new Date(), 1);\n\nconst Calendar: FC<CalendarProps> = ({\n locale = Language.German,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,\n customThumbColors,\n selectedDate,\n selectedDates,\n selectedDateInterval,\n categories,\n isDisabled,\n type = CalendarType.Single,\n shouldShowHighlightsInMonthOverlay = true,\n disabledDates = [],\n showMonthYearPickers: showMonthYearPickersProp,\n onShownDatesChange = () => {},\n}) => {\n const [currentDate, setCurrentDate] = useState<Date>();\n const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);\n const [internalSelectedDate, setInternalSelectedDate] = useState<\n Date | Date[] | DateInterval | undefined\n >(() => (type === CalendarType.Multiple ? [] : undefined));\n const [direction, setDirection] = useState<'left' | 'right' | undefined>();\n const [width, setWidth] = useState(0);\n\n const showMonthYearPickers = useMemo(() => {\n const hasMultipleMonths = differenceInCalendarMonths(maxDate, minDate) > 0;\n const hasMultipleYears = getYearsBetween(minDate, maxDate).length > 1;\n\n return !!(showMonthYearPickersProp && (hasMultipleMonths || hasMultipleYears));\n }, [minDate, maxDate, showMonthYearPickersProp]);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (currentDate) {\n const start = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);\n\n if (shouldRenderTwoMonths) {\n const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 2, 0);\n onShownDatesChange({\n start,\n end,\n });\n } else {\n const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);\n onShownDatesChange({\n start,\n end,\n });\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [currentDate, shouldRenderTwoMonths]);\n\n useEffect(() => {\n const bounds = {\n start: minDate,\n end: maxDate,\n };\n if (type === CalendarType.Single) {\n if (selectedDate) {\n const isDisabledDate = disabledDates.some((disabledDate) =>\n isSameDay(selectedDate, disabledDate),\n );\n const isDateInBounds = isWithinInterval(selectedDate, bounds);\n\n if (!isDisabledDate && isDateInBounds) {\n setInternalSelectedDate(selectedDate);\n } else {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set selectedDate, because it is disabled or out of bounds.',\n '\\nselectedDate:',\n selectedDate,\n ...(isDisabledDate ? ['\\nselectedDate is disabled'] : []),\n ...(isDateInBounds\n ? []\n : ['\\nselectedDate is outside of bounds:', { minDate, maxDate }]),\n );\n setInternalSelectedDate(() => undefined);\n }\n } else {\n setInternalSelectedDate(() => undefined);\n }\n } else if (type === CalendarType.Multiple) {\n if (selectedDates) {\n const disabledSelectedDates: Date[] = [];\n const datesOutsideOfBounds: Date[] = [];\n\n const filteredDates = selectedDates.filter((date) => {\n if (disabledDates.some((disabledDate) => isSameDay(date, disabledDate))) {\n disabledSelectedDates.push(date);\n return false;\n }\n\n if (!isWithinInterval(date, bounds)) {\n datesOutsideOfBounds.push(date);\n return false;\n }\n\n return true;\n });\n\n if (disabledSelectedDates.length > 0 || datesOutsideOfBounds.length > 0) {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set all selectedDates, because some are disabled or out of bounds.',\n ...(disabledSelectedDates.length > 0\n ? ['\\nselectedDates that are disabled:', disabledSelectedDates]\n : []),\n ...(datesOutsideOfBounds.length > 0\n ? [\n '\\nselectedDates that are outside of bounds:',\n datesOutsideOfBounds,\n 'bounds:',\n { minDate, maxDate },\n ]\n : []),\n );\n }\n\n setInternalSelectedDate(filteredDates);\n } else {\n setInternalSelectedDate([]);\n }\n } else if (type === CalendarType.Interval) {\n if (selectedDateInterval) {\n const intervalIncludesDisabledDate =\n selectedDateInterval.end &&\n disabledDates.some((disabledDate) =>\n isWithinInterval(disabledDate, {\n start: selectedDateInterval.start,\n end: selectedDateInterval.end as Date,\n }),\n );\n\n const intervalIsInBounds =\n isWithinInterval(selectedDateInterval.start, bounds) &&\n (!selectedDateInterval.end ||\n isWithinInterval(selectedDateInterval.end, bounds));\n\n if (!intervalIncludesDisabledDate && intervalIsInBounds) {\n setInternalSelectedDate(selectedDateInterval);\n } else {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set selectedDateInterval, because it includes disabled dates or dates that are out of bounds.',\n '\\nselectedDateInterval:',\n selectedDateInterval,\n ...(intervalIncludesDisabledDate\n ? ['\\ndisabled dates:', disabledDates]\n : []),\n ...(intervalIsInBounds ? [] : ['\\nbounds:', { minDate, maxDate }]),\n );\n setInternalSelectedDate(() => undefined);\n }\n }\n }\n }, [type, selectedDate, selectedDates, selectedDateInterval, disabledDates, minDate, maxDate]);\n\n useEffect(() => {\n if (calendarRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedWidth = entries[0].contentRect.width;\n\n setWidth(observedWidth - 30);\n\n if (observedWidth < 430) {\n setShouldRenderTwoMonths(false);\n } else {\n setShouldRenderTwoMonths(true);\n }\n }\n });\n\n resizeObserver.observe(calendarRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, []);\n\n useEffect(() => {\n setCurrentDate((prevDate) =>\n isDateInRange({ minDate, maxDate, currentDate: prevDate || new Date() }),\n );\n }, [maxDate, minDate]);\n\n const handleLeftArrowClick = useCallback(() => {\n if (direction) return;\n\n setDirection('left');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(-1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate, direction]);\n\n const handleRightArrowClick = useCallback(() => {\n if (direction) return;\n\n setDirection('right');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate, direction]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate((prevDate) => {\n let onChangePayload: Date | Date[] | DateInterval | null = null;\n let newInternalSelectedDate: Date | Date[] | DateInterval | undefined;\n\n if (type === CalendarType.Single) {\n onChangePayload = date;\n newInternalSelectedDate = date;\n } else if (type === CalendarType.Multiple) {\n const prevSelectedDates = prevDate as Date[];\n // Selects or unselects date , depending on if it is already selected.\n if (prevSelectedDates.some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = prevSelectedDates.filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevSelectedDates, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n const prevSelectedDateInterval = prevDate as DateInterval;\n\n const updateInterval = (start: Date, end?: Date): void => {\n const newInterval = { start, end };\n onChangePayload = newInterval;\n newInternalSelectedDate = newInterval;\n };\n\n // Sets first selection as interval start.\n if (!prevSelectedDateInterval) {\n updateInterval(date);\n } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {\n // Sets second selection as interval start, if it is earlier than the previous interval start.\n // Else sets it as interval end.\n if (date < prevSelectedDateInterval.start) {\n updateInterval(date);\n } else {\n updateInterval(prevSelectedDateInterval.start, date);\n }\n } else {\n // Resets interval if a third date is selected.\n updateInterval(date);\n }\n }\n\n if (typeof onChange === 'function' && onChangePayload) {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(() => undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n customThumbColors={customThumbColors}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n showMonthYearPickers={showMonthYearPickers}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAOA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAQA,IAAAO,SAAA,GAAAP,OAAA;AAMA,IAAAQ,aAAA,GAAAC,sBAAA,CAAAT,OAAA;AAAwD,SAAAS,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAK,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MAAA,CAAAU,OAAA,CAAAoH,aAAA,CAACjI,KAAA,CAAAiJ,IAAI;IAACC,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACpC,CACkB,CAAC,gBAE5B/I,MAAA,CAAAU,OAAA,CAAAoH,aAAA,CAACzH,SAAA,CAAA2I,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAED/G,QAAQ,CAACmH,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA5I,OAAA,GAEnBuB,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledPseudoMonthYearPicker = exports.StyledCalendarIconWrapperPseudo = exports.StyledCalendarIconWrapper = exports.StyledCalendar = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const StyledCalendar = exports.StyledCalendar = _styledComponents.default.div`
|
|
10
|
+
display: flex;
|
|
11
|
+
width: 100%;
|
|
12
|
+
opacity: ${({
|
|
13
|
+
$isDisabled
|
|
14
|
+
}) => $isDisabled ? 0.5 : 1};
|
|
15
|
+
pointer-events: ${({
|
|
16
|
+
$isDisabled
|
|
17
|
+
}) => $isDisabled ? 'none' : undefined};
|
|
18
|
+
user-select: none;
|
|
19
|
+
`;
|
|
20
|
+
const StyledCalendarIconWrapper = exports.StyledCalendarIconWrapper = _styledComponents.default.div`
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
z-index: 2;
|
|
23
|
+
`;
|
|
24
|
+
const StyledCalendarIconWrapperPseudo = exports.StyledCalendarIconWrapperPseudo = _styledComponents.default.div`
|
|
25
|
+
width: 15px;
|
|
26
|
+
`;
|
|
27
|
+
const StyledPseudoMonthYearPicker = exports.StyledPseudoMonthYearPicker = _styledComponents.default.div`
|
|
28
|
+
height: fit-content;
|
|
29
|
+
width: 0;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
user-select: none;
|
|
33
|
+
`;
|
|
34
|
+
//# sourceMappingURL=Calendar.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calendar.styles.js","names":["_styledComponents","_interopRequireDefault","require","e","__esModule","default","StyledCalendar","exports","styled","div","$isDisabled","undefined","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo","StyledPseudoMonthYearPicker"],"sources":["../../../../src/components/calendar/Calendar.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\ntype StyledCalendarProps = { $isDisabled?: boolean };\n\nexport const StyledCalendar = styled.div<StyledCalendarProps>`\n display: flex;\n width: 100%;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n pointer-events: ${({ $isDisabled }) => ($isDisabled ? 'none' : undefined)};\n user-select: none;\n`;\n\nexport const StyledCalendarIconWrapper = styled.div`\n cursor: pointer;\n z-index: 2;\n`;\n\nexport const StyledCalendarIconWrapperPseudo = styled.div`\n width: 15px;\n`;\n\nexport const StyledPseudoMonthYearPicker = styled.div`\n height: fit-content;\n width: 0;\n overflow: hidden;\n pointer-events: none;\n user-select: none;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIhC,MAAMG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGE,yBAAM,CAACC,GAAwB;AAC7D;AACA;AACA,eAAe,CAAC;EAAEC;AAAY,CAAC,KAAMA,WAAW,GAAG,GAAG,GAAG,CAAE;AAC3D,sBAAsB,CAAC;EAAEA;AAAY,CAAC,KAAMA,WAAW,GAAG,MAAM,GAAGC,SAAU;AAC7E;AACA,CAAC;AAEM,MAAMC,yBAAyB,GAAAL,OAAA,CAAAK,yBAAA,GAAGJ,yBAAM,CAACC,GAAG;AACnD;AACA;AACA,CAAC;AAEM,MAAMI,+BAA+B,GAAAN,OAAA,CAAAM,+BAAA,GAAGL,yBAAM,CAACC,GAAG;AACzD;AACA,CAAC;AAEM,MAAMK,2BAA2B,GAAAP,OAAA,CAAAO,2BAAA,GAAGN,yBAAM,CAACC,GAAG;AACrD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _calendar = require("../../../utils/calendar");
|
|
9
|
+
var _Month = _interopRequireDefault(require("./month/Month"));
|
|
10
|
+
var _MonthWrapper = require("./MonthWrapper.styles");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
const MonthWrapper = ({
|
|
15
|
+
locale,
|
|
16
|
+
currentDate,
|
|
17
|
+
highlightedDates,
|
|
18
|
+
selectedDate,
|
|
19
|
+
onSelect,
|
|
20
|
+
categories,
|
|
21
|
+
direction,
|
|
22
|
+
onAnimationFinished,
|
|
23
|
+
shouldRenderTwo,
|
|
24
|
+
width,
|
|
25
|
+
customThumbColors,
|
|
26
|
+
isDisabled,
|
|
27
|
+
minDate,
|
|
28
|
+
maxDate,
|
|
29
|
+
shouldShowHighlightsInMonthOverlay,
|
|
30
|
+
type,
|
|
31
|
+
disabledDates,
|
|
32
|
+
setCurrentDate,
|
|
33
|
+
showMonthYearPickers
|
|
34
|
+
}) => {
|
|
35
|
+
const [content, setContent] = (0, _react.useState)();
|
|
36
|
+
const [hoveringDay, setHoveringDay] = (0, _react.useState)(null);
|
|
37
|
+
const monthHeight = (0, _react.useMemo)(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);
|
|
38
|
+
(0, _react.useEffect)(() => {
|
|
39
|
+
setContent(() => {
|
|
40
|
+
// Initial render of months
|
|
41
|
+
const items = [];
|
|
42
|
+
for (let i = -1; i < 3; i++) {
|
|
43
|
+
const date = (0, _calendar.getNewDate)(i, currentDate);
|
|
44
|
+
const {
|
|
45
|
+
month,
|
|
46
|
+
year
|
|
47
|
+
} = (0, _calendar.getMonthAndYear)(date);
|
|
48
|
+
items.push(/*#__PURE__*/_react.default.createElement(_Month.default, {
|
|
49
|
+
height: monthHeight,
|
|
50
|
+
key: `${month}-${year}`,
|
|
51
|
+
month: month,
|
|
52
|
+
year: year,
|
|
53
|
+
locale: locale,
|
|
54
|
+
onSelect: onSelect,
|
|
55
|
+
highlightedDates: highlightedDates,
|
|
56
|
+
shouldShowHighlightsInMonthOverlay: shouldShowHighlightsInMonthOverlay,
|
|
57
|
+
categories: categories,
|
|
58
|
+
selectedDate: selectedDate,
|
|
59
|
+
minDate: minDate,
|
|
60
|
+
maxDate: maxDate,
|
|
61
|
+
type: type,
|
|
62
|
+
customThumbColors: customThumbColors,
|
|
63
|
+
hoveringDay: hoveringDay,
|
|
64
|
+
setHoveringDay: setHoveringDay,
|
|
65
|
+
disabledDates: disabledDates,
|
|
66
|
+
setCurrentDate: setCurrentDate,
|
|
67
|
+
displayIndex: i,
|
|
68
|
+
showMonthYearPickers: showMonthYearPickers
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
return items;
|
|
72
|
+
});
|
|
73
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
|
+
}, [monthHeight]);
|
|
75
|
+
(0, _react.useEffect)(() => {
|
|
76
|
+
// Doesn't update props until animation is completed
|
|
77
|
+
if (direction) return;
|
|
78
|
+
setContent(prevState => (prevState ?? []).map((element, index) => {
|
|
79
|
+
const date = (0, _calendar.getNewDate)(index - 1, currentDate);
|
|
80
|
+
const {
|
|
81
|
+
month,
|
|
82
|
+
year
|
|
83
|
+
} = (0, _calendar.getMonthAndYear)(date);
|
|
84
|
+
return {
|
|
85
|
+
...element,
|
|
86
|
+
props: {
|
|
87
|
+
...element.props,
|
|
88
|
+
categories,
|
|
89
|
+
disabledDates,
|
|
90
|
+
displayIndex: index - 1,
|
|
91
|
+
highlightedDates,
|
|
92
|
+
hoveringDay,
|
|
93
|
+
locale,
|
|
94
|
+
onSelect,
|
|
95
|
+
shouldShowHighlightsInMonthOverlay,
|
|
96
|
+
maxDate,
|
|
97
|
+
minDate,
|
|
98
|
+
month,
|
|
99
|
+
customThumbColors,
|
|
100
|
+
selectedDate,
|
|
101
|
+
setCurrentDate,
|
|
102
|
+
setHoveringDay,
|
|
103
|
+
showMonthYearPickers,
|
|
104
|
+
type,
|
|
105
|
+
year
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}));
|
|
109
|
+
}, [customThumbColors, categories, currentDate, direction, disabledDates, highlightedDates, hoveringDay, locale, onAnimationFinished, onSelect, maxDate, minDate, selectedDate, setCurrentDate, setHoveringDay, showMonthYearPickers, type, shouldShowHighlightsInMonthOverlay]);
|
|
110
|
+
const animate = (0, _react.useMemo)(() => {
|
|
111
|
+
if (shouldRenderTwo) {
|
|
112
|
+
switch (true) {
|
|
113
|
+
case direction === 'left':
|
|
114
|
+
return {
|
|
115
|
+
x: '0%'
|
|
116
|
+
};
|
|
117
|
+
case direction === 'right':
|
|
118
|
+
return {
|
|
119
|
+
x: '-100%'
|
|
120
|
+
};
|
|
121
|
+
default:
|
|
122
|
+
return {
|
|
123
|
+
x: '-50%'
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
switch (true) {
|
|
128
|
+
case direction === 'left':
|
|
129
|
+
return {
|
|
130
|
+
x: '0%'
|
|
131
|
+
};
|
|
132
|
+
case direction === 'right':
|
|
133
|
+
return {
|
|
134
|
+
x: '-200%'
|
|
135
|
+
};
|
|
136
|
+
default:
|
|
137
|
+
return {
|
|
138
|
+
x: '-100%'
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}, [direction, shouldRenderTwo]);
|
|
143
|
+
return /*#__PURE__*/_react.default.createElement(_MonthWrapper.StyledMonthWrapper, {
|
|
144
|
+
$height: monthHeight,
|
|
145
|
+
$width: width
|
|
146
|
+
}, /*#__PURE__*/_react.default.createElement(_MonthWrapper.StyledMotionWrapper, {
|
|
147
|
+
animate: animate,
|
|
148
|
+
$isDisabled: isDisabled,
|
|
149
|
+
transition: {
|
|
150
|
+
type: 'tween',
|
|
151
|
+
duration: !direction ? 0 : 0.2
|
|
152
|
+
},
|
|
153
|
+
onAnimationComplete: onAnimationFinished
|
|
154
|
+
}, content));
|
|
155
|
+
};
|
|
156
|
+
MonthWrapper.displayName = 'MonthWrapper';
|
|
157
|
+
var _default = exports.default = MonthWrapper;
|
|
158
|
+
//# sourceMappingURL=MonthWrapper.js.map
|