@semcore/date-picker 16.2.4 → 17.0.0-prerelease.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/DatePicker.js +116 -139
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangeComparator.js +144 -149
- package/lib/cjs/DateRangeComparator.js.map +1 -1
- package/lib/cjs/DateRangePicker.js +86 -101
- package/lib/cjs/DateRangePicker.js.map +1 -1
- package/lib/cjs/MonthDateRangeComparator.js +173 -180
- package/lib/cjs/MonthDateRangeComparator.js.map +1 -1
- package/lib/cjs/MonthPicker.js +70 -87
- package/lib/cjs/MonthPicker.js.map +1 -1
- package/lib/cjs/MonthRangePicker.js +96 -111
- package/lib/cjs/MonthRangePicker.js.map +1 -1
- package/lib/cjs/components/ButtonTrigger.js +12 -11
- package/lib/cjs/components/ButtonTrigger.js.map +1 -1
- package/lib/cjs/components/Calendar.js +409 -466
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/DateRangeComparatorAbstract.js +574 -626
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +585 -677
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +254 -273
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +407 -439
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +92 -102
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/index.js +15 -15
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +17 -17
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/cjs/utils/cronTabScheduler.js +13 -22
- package/lib/cjs/utils/cronTabScheduler.js.map +1 -1
- package/lib/cjs/utils/datesIntersects.js +12 -19
- package/lib/cjs/utils/datesIntersects.js.map +1 -1
- package/lib/cjs/utils/formatDate.js +11 -9
- package/lib/cjs/utils/formatDate.js.map +1 -1
- package/lib/cjs/utils/includesDate.js +11 -16
- package/lib/cjs/utils/includesDate.js.map +1 -1
- package/lib/cjs/utils/isBetweenPlugin.js +6 -6
- package/lib/cjs/utils/isBetweenPlugin.js.map +1 -1
- package/lib/cjs/utils/shortDateRangeFormat.js +29 -33
- package/lib/cjs/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/es6/DatePicker.js +117 -141
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangeComparator.js +130 -135
- package/lib/es6/DateRangeComparator.js.map +1 -1
- package/lib/es6/DateRangePicker.js +87 -102
- package/lib/es6/DateRangePicker.js.map +1 -1
- package/lib/es6/MonthDateRangeComparator.js +159 -166
- package/lib/es6/MonthDateRangeComparator.js.map +1 -1
- package/lib/es6/MonthPicker.js +72 -89
- package/lib/es6/MonthPicker.js.map +1 -1
- package/lib/es6/MonthRangePicker.js +97 -112
- package/lib/es6/MonthRangePicker.js.map +1 -1
- package/lib/es6/components/ButtonTrigger.js +4 -3
- package/lib/es6/components/ButtonTrigger.js.map +1 -1
- package/lib/es6/components/Calendar.js +400 -457
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/DateRangeComparatorAbstract.js +552 -604
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +568 -660
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +246 -265
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +397 -429
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +74 -85
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +16 -16
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/utils/cronTabScheduler.js +13 -21
- package/lib/es6/utils/cronTabScheduler.js.map +1 -1
- package/lib/es6/utils/datesIntersects.js +10 -18
- package/lib/es6/utils/datesIntersects.js.map +1 -1
- package/lib/es6/utils/formatDate.js +6 -6
- package/lib/es6/utils/formatDate.js.map +1 -1
- package/lib/es6/utils/includesDate.js +10 -15
- package/lib/es6/utils/includesDate.js.map +1 -1
- package/lib/es6/utils/isBetweenPlugin.js +4 -4
- package/lib/es6/utils/isBetweenPlugin.js.map +1 -1
- package/lib/es6/utils/shortDateRangeFormat.js +27 -31
- package/lib/es6/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/esm/DatePicker.mjs +109 -114
- package/lib/esm/DateRangeComparator.mjs +112 -105
- package/lib/esm/DateRangePicker.mjs +76 -80
- package/lib/esm/MonthDateRangeComparator.mjs +141 -134
- package/lib/esm/MonthPicker.mjs +65 -70
- package/lib/esm/MonthRangePicker.mjs +86 -88
- package/lib/esm/components/ButtonTrigger.mjs +4 -3
- package/lib/esm/components/Calendar.mjs +397 -423
- package/lib/esm/components/DateRangeComparatorAbstract.mjs +559 -516
- package/lib/esm/components/InputTrigger.mjs +550 -557
- package/lib/esm/components/PickerAbstract.mjs +249 -244
- package/lib/esm/components/RangePickerAbstract.mjs +400 -384
- package/lib/esm/components/index.mjs +73 -69
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
- package/lib/esm/utils/cronTabScheduler.mjs +13 -18
- package/lib/esm/utils/datesIntersects.mjs +10 -14
- package/lib/esm/utils/formatDate.mjs +6 -6
- package/lib/esm/utils/includesDate.mjs +10 -13
- package/lib/esm/utils/isBetweenPlugin.mjs +4 -4
- package/lib/esm/utils/shortDateRangeFormat.mjs +27 -27
- package/lib/types/index.d.ts +2 -44
- package/package.json +16 -17
|
@@ -1,144 +1,124 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
-
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
10
3
|
import { createComponent, sstyled, assignProps, Component } from "@semcore/core";
|
|
11
|
-
import
|
|
4
|
+
import { Box, ScreenReaderOnly } from "@semcore/base-components";
|
|
12
5
|
import fire from "@semcore/core/lib/utils/fire";
|
|
13
|
-
import { Box, ScreenReaderOnly } from "@semcore/flex-box";
|
|
14
6
|
import dayjs from "dayjs";
|
|
15
7
|
import React from "react";
|
|
16
|
-
import {
|
|
8
|
+
import { formatMMYY, formatDDMMYY } from "../utils/formatDate.mjs";
|
|
17
9
|
import { includesDate } from "../utils/includesDate.mjs";
|
|
18
10
|
import isBetween from "../utils/isBetweenPlugin.mjs";
|
|
19
|
-
var _excluded = ["date"];
|
|
20
11
|
/*!__reshadow-styles__:"../style/calendar.shadow.css"*/
|
|
21
|
-
|
|
12
|
+
const style = (
|
|
22
13
|
/*__reshadow_css_start__*/
|
|
23
14
|
(sstyled.insert(
|
|
24
15
|
/*__inner_css_start__*/
|
|
25
|
-
'.
|
|
16
|
+
'.___SCalendar_bx7k3_gg_{display:flex;flex-direction:column;border-radius:var(--intergalactic-surface-rounded, 6px)}.___SCalendar_bx7k3_gg_ .___SCalendarUnit_bx7k3_gg_:focus-visible{outline:0}.___SGridDays_bx7k3_gg_{display:grid;grid-template-columns:repeat(7,minmax(32px,auto));grid-template-rows:repeat(auto-fit,minmax(32px,auto))}.___SGridMonths_bx7k3_gg_{display:grid;grid-row-gap:var(--intergalactic-spacing-2x, 8px);grid-template-columns:repeat(3,minmax(60px,auto));grid-template-rows:repeat(4,minmax(32px,auto))}.___SWeekDays_bx7k3_gg_{display:grid;grid-template-columns:repeat(7,minmax(32px,auto))}.___SCalendarUnit_bx7k3_gg_,.___SWeekDay_bx7k3_gg_{align-items:center;display:flex;font-size:var(--intergalactic-fs-200, 14px);justify-content:center;min-height:32px;min-width:32px}.___SWeekDay_bx7k3_gg_{color:var(--intergalactic-text-secondary, #6c6e79);font-weight:var(--intergalactic-regular, 400);overflow:hidden}.___SCalendarUnit_bx7k3_gg_{font-family:inherit;font-weight:400;line-height:normal;-webkit-text-decoration:none;text-decoration:none;text-align:center;vertical-align:middle;border:1px solid transparent;color:var(--intergalactic-text-primary, #191b23);box-shadow:none;overflow:visible;-webkit-user-select:none;-moz-user-select:none;user-select:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent;background-color:var(--intergalactic-date-picker-cell, #ffffff);border-radius:var(--intergalactic-control-rounded, 6px);box-sizing:border-box;cursor:pointer;position:relative;transition:border-radius .15s .15s;outline:0;margin:4px 0 0}@media (hover:hover){.___SCalendarUnit_bx7k3_gg_:hover{color:var(--intergalactic-text-primary, #191b23);background-color:var(--intergalactic-date-picker-cell-hover, #e0e1e9)}}.___SCalendarUnit_bx7k3_gg_.__today_bx7k3_gg_:before{content:"";position:absolute;display:block;top:1px;left:1px;border-radius:var(--intergalactic-control-rounded, 6px);width:calc(100% - 2px);height:calc(100% - 2px);box-sizing:border-box;border:1px solid var(--intergalactic-date-picker-cell-current, #8a8e9b)}.___SCalendarUnit_bx7k3_gg_.___SCalendarUnit_bx7k3_gg_.__today_bx7k3_gg_.__endSelected_bx7k3_gg_:before,.___SCalendarUnit_bx7k3_gg_.___SCalendarUnit_bx7k3_gg_.__today_bx7k3_gg_.__startSelected_bx7k3_gg_:before{border-color:var(--intergalactic-border-secondary, #e0e1e9)}.___SCalendarUnit_bx7k3_gg_.__highlighted_bx7k3_gg_,.___SCalendarUnit_bx7k3_gg_.__selected_bx7k3_gg_{background-color:var(--intergalactic-date-picker-cell-range, #c4e5fe);border-radius:0;transition:border-radius 0s 0s;color:var(--intergalactic-text-primary, #191b23)}@media (hover:hover){.___SCalendarUnit_bx7k3_gg_.__selected_bx7k3_gg_:hover{background-color:var(--intergalactic-date-picker-cell-range-hover, #8ecdff)}}@media (hover:hover){.___SCalendarUnit_bx7k3_gg_.__highlighted_bx7k3_gg_:hover{background-color:var(--intergalactic-date-picker-cell-range-hover, #8ecdff)}}.___SCalendarUnit_bx7k3_gg_.__startSelected_bx7k3_gg_{color:var(--intergalactic-text-primary-invert, #ffffff);background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff)}.___SCalendarUnit_bx7k3_gg_.__startSelected_bx7k3_gg_:not(.__highlighted_bx7k3_gg_){border-bottom-left-radius:var(--intergalactic-control-rounded, 6px);border-bottom-right-radius:0;border-top-left-radius:var(--intergalactic-control-rounded, 6px);border-top-right-radius:0}@media (hover:hover){.___SCalendarUnit_bx7k3_gg_.__startSelected_bx7k3_gg_:hover{color:var(--intergalactic-text-primary-invert, #ffffff);background-color:var(--intergalactic-date-picker-cell-active-hover, #008ff8)}}.___SCalendarUnit_bx7k3_gg_.__endSelected_bx7k3_gg_{background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff);color:var(--intergalactic-text-primary-invert, #ffffff)}.___SCalendarUnit_bx7k3_gg_.__endSelected_bx7k3_gg_:not(.__highlighted_bx7k3_gg_){border-bottom-left-radius:0;border-bottom-right-radius:var(--intergalactic-control-rounded, 6px);border-top-left-radius:0;border-top-right-radius:var(--intergalactic-control-rounded, 6px)}@media (hover:hover){.___SCalendarUnit_bx7k3_gg_.__endSelected_bx7k3_gg_:hover{color:var(--intergalactic-text-primary-invert, #ffffff);background-color:var(--intergalactic-date-picker-cell-active-hover, #008ff8)}}.___SCalendarUnit_bx7k3_gg_.__startHighlighted_bx7k3_gg_:not(.__selected_bx7k3_gg_){border-bottom-left-radius:var(--intergalactic-control-rounded, 6px);border-bottom-right-radius:0;border-top-left-radius:var(--intergalactic-control-rounded, 6px);border-top-right-radius:0}.___SCalendarUnit_bx7k3_gg_.__endHighlighted_bx7k3_gg_:not(.__selected_bx7k3_gg_){border-bottom-left-radius:0;border-bottom-right-radius:var(--intergalactic-control-rounded, 6px);border-top-left-radius:0;border-top-right-radius:var(--intergalactic-control-rounded, 6px)}.___SCalendarUnit_bx7k3_gg_.__startHighlighted_bx7k3_gg_.___SCalendarUnit_bx7k3_gg_.__endHighlighted_bx7k3_gg_,.___SCalendarUnit_bx7k3_gg_.__startSelected_bx7k3_gg_.___SCalendarUnit_bx7k3_gg_.__endSelected_bx7k3_gg_{border-bottom-left-radius:var(--intergalactic-control-rounded, 6px);border-bottom-right-radius:var(--intergalactic-control-rounded, 6px);border-top-left-radius:var(--intergalactic-control-rounded, 6px);border-top-right-radius:var(--intergalactic-control-rounded, 6px)}.___SCalendarUnit_bx7k3_gg_.__compareHighlighted_bx7k3_gg_{border-top:2px dashed var(--intergalactic-date-picker-cell-comparison-active, #8649e1);border-bottom:2px dashed var(--intergalactic-date-picker-cell-comparison-active, #8649e1);border-radius:0;transition:none}.___SCalendarUnit_bx7k3_gg_.__compareEndHighlighted_bx7k3_gg_,.___SCalendarUnit_bx7k3_gg_.__compareStartHighlighted_bx7k3_gg_{border-left:2px dashed var(--intergalactic-date-picker-cell-comparison-active, #8649e1);border-right:2px dashed var(--intergalactic-date-picker-cell-comparison-active, #8649e1)}.___SCalendarUnit_bx7k3_gg_.__compareEnd_bx7k3_gg_,.___SCalendarUnit_bx7k3_gg_.__compareStart_bx7k3_gg_{border-radius:0;background-color:var(--intergalactic-date-picker-cell-comparison-active, #8649e1);color:var(--intergalactic-text-primary-invert, #ffffff)}@media (hover:hover){.___SCalendarUnit_bx7k3_gg_.__compareEnd_bx7k3_gg_:hover,.___SCalendarUnit_bx7k3_gg_.__compareStart_bx7k3_gg_:hover{color:var(--intergalactic-text-primary-invert, #ffffff);background-color:var(--intergalactic-date-picker-cell-comparison-active-hover, #5925ab)}}.___SCalendarUnit_bx7k3_gg_.__compareStartHighlighted_bx7k3_gg_{border-top-left-radius:var(--intergalactic-control-rounded, 6px);border-bottom-left-radius:var(--intergalactic-control-rounded, 6px)}.___SCalendarUnit_bx7k3_gg_.__compareEndHighlighted_bx7k3_gg_{border-top-right-radius:var(--intergalactic-control-rounded, 6px);border-bottom-right-radius:var(--intergalactic-control-rounded, 6px)}.___SCalendarUnit_bx7k3_gg_.__compareStart_bx7k3_gg_:not(.__compareHighlighted_bx7k3_gg_){border-top-left-radius:var(--intergalactic-control-rounded, 6px);border-bottom-left-radius:var(--intergalactic-control-rounded, 6px)}.___SCalendarUnit_bx7k3_gg_.__compareEnd_bx7k3_gg_:not(.__compareHighlighted_bx7k3_gg_){border-top-right-radius:var(--intergalactic-control-rounded, 6px);border-bottom-right-radius:var(--intergalactic-control-rounded, 6px)}.___SCalendarUnit_bx7k3_gg_.__outdated_bx7k3_gg_{opacity:.2}.___SCalendarUnit_bx7k3_gg_.__disabled_bx7k3_gg_{opacity:.4;cursor:default;pointer-events:none}.___SCalendar_bx7k3_gg_:focus .___SCalendarUnit_bx7k3_gg_.__highlighted_bx7k3_gg_{z-index:1}.___SCalendar_bx7k3_gg_:focus:not(.___SCalendar_bx7k3_gg_:focus:has(.___SCalendarUnit_bx7k3_gg_.__highlighted_bx7k3_gg_)){border-radius:var(--intergalactic-surface-rounded, 6px)}@media (prefers-reduced-motion){.___SCalendarUnit_bx7k3_gg_,.___SCalendarUnit_bx7k3_gg_.__highlighted_bx7k3_gg_,.___SCalendarUnit_bx7k3_gg_.__selected_bx7k3_gg_{transition:none}}',
|
|
26
17
|
/*__inner_css_end__*/
|
|
27
|
-
"
|
|
18
|
+
"bx7k3_gg_"
|
|
28
19
|
), /*__reshadow_css_end__*/
|
|
29
20
|
{
|
|
30
|
-
"__SGridDays": "
|
|
31
|
-
"__SGridMonths": "
|
|
32
|
-
"__SWeekDays": "
|
|
33
|
-
"__SWeekDay": "
|
|
34
|
-
"__SCalendarUnit": "
|
|
35
|
-
"_startHighlighted": "
|
|
36
|
-
"_selected": "
|
|
37
|
-
"_endHighlighted": "
|
|
38
|
-
"_startSelected": "
|
|
39
|
-
"_endSelected": "
|
|
40
|
-
"_compareHighlighted": "
|
|
41
|
-
"_compareStartHighlighted": "
|
|
42
|
-
"_compareEndHighlighted": "
|
|
43
|
-
"_compareStart": "
|
|
44
|
-
"_compareEnd": "
|
|
45
|
-
"_outdated": "
|
|
46
|
-
"_disabled": "
|
|
47
|
-
"_highlighted": "
|
|
48
|
-
"__SCalendar": "
|
|
49
|
-
"_today": "
|
|
21
|
+
"__SGridDays": "___SGridDays_bx7k3_gg_",
|
|
22
|
+
"__SGridMonths": "___SGridMonths_bx7k3_gg_",
|
|
23
|
+
"__SWeekDays": "___SWeekDays_bx7k3_gg_",
|
|
24
|
+
"__SWeekDay": "___SWeekDay_bx7k3_gg_",
|
|
25
|
+
"__SCalendarUnit": "___SCalendarUnit_bx7k3_gg_",
|
|
26
|
+
"_startHighlighted": "__startHighlighted_bx7k3_gg_",
|
|
27
|
+
"_selected": "__selected_bx7k3_gg_",
|
|
28
|
+
"_endHighlighted": "__endHighlighted_bx7k3_gg_",
|
|
29
|
+
"_startSelected": "__startSelected_bx7k3_gg_",
|
|
30
|
+
"_endSelected": "__endSelected_bx7k3_gg_",
|
|
31
|
+
"_compareHighlighted": "__compareHighlighted_bx7k3_gg_",
|
|
32
|
+
"_compareStartHighlighted": "__compareStartHighlighted_bx7k3_gg_",
|
|
33
|
+
"_compareEndHighlighted": "__compareEndHighlighted_bx7k3_gg_",
|
|
34
|
+
"_compareStart": "__compareStart_bx7k3_gg_",
|
|
35
|
+
"_compareEnd": "__compareEnd_bx7k3_gg_",
|
|
36
|
+
"_outdated": "__outdated_bx7k3_gg_",
|
|
37
|
+
"_disabled": "__disabled_bx7k3_gg_",
|
|
38
|
+
"_highlighted": "__highlighted_bx7k3_gg_",
|
|
39
|
+
"__SCalendar": "___SCalendar_bx7k3_gg_",
|
|
40
|
+
"_today": "__today_bx7k3_gg_"
|
|
50
41
|
})
|
|
51
42
|
);
|
|
52
43
|
dayjs.extend(isBetween);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}, function(_v, k) {
|
|
57
|
-
return cb(k);
|
|
58
|
-
});
|
|
59
|
-
};
|
|
44
|
+
const range = (N, cb) => Array.from({
|
|
45
|
+
length: N
|
|
46
|
+
}, (_v, k) => cb(k));
|
|
60
47
|
function getDayJSLocaleParams(locale) {
|
|
61
48
|
if (locale.includes("en") || locale.includes("ja")) {
|
|
62
|
-
return
|
|
63
|
-
weekStart: 0
|
|
64
|
-
|
|
49
|
+
return {
|
|
50
|
+
weekStart: 0,
|
|
51
|
+
...dayjs.Ls[locale]
|
|
52
|
+
};
|
|
65
53
|
}
|
|
66
|
-
return
|
|
67
|
-
weekStart: 1
|
|
68
|
-
|
|
54
|
+
return {
|
|
55
|
+
weekStart: 1,
|
|
56
|
+
...dayjs.Ls[locale]
|
|
57
|
+
};
|
|
69
58
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}).format(date.valueOf());
|
|
85
|
-
var _long = new Intl.DateTimeFormat(locale, {
|
|
86
|
-
weekday: "long"
|
|
87
|
-
}).format(date.valueOf());
|
|
88
|
-
date = date.add(1, "day");
|
|
89
|
-
return {
|
|
90
|
-
"children": _short,
|
|
91
|
-
"aria-label": _long
|
|
92
|
-
};
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}, {
|
|
96
|
-
key: "setContext",
|
|
97
|
-
value: function setContext() {
|
|
59
|
+
class CalendarWeekDaysRoot extends Component {
|
|
60
|
+
getDaysByWeek() {
|
|
61
|
+
const {
|
|
62
|
+
locale
|
|
63
|
+
} = this.asProps;
|
|
64
|
+
let date = dayjs().locale(locale, getDayJSLocaleParams(locale)).startOf("week");
|
|
65
|
+
return range(7, () => {
|
|
66
|
+
const short = new Intl.DateTimeFormat(locale, {
|
|
67
|
+
weekday: "short"
|
|
68
|
+
}).format(date.valueOf());
|
|
69
|
+
const long = new Intl.DateTimeFormat(locale, {
|
|
70
|
+
weekday: "long"
|
|
71
|
+
}).format(date.valueOf());
|
|
72
|
+
date = date.add(1, "day");
|
|
98
73
|
return {
|
|
99
|
-
|
|
74
|
+
"children": short,
|
|
75
|
+
"aria-label": long
|
|
100
76
|
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
setContext() {
|
|
80
|
+
return {
|
|
81
|
+
days: this.getDaysByWeek()
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
var _ref = this.asProps, _ref6;
|
|
86
|
+
const SWeekDays = Box;
|
|
87
|
+
const {
|
|
88
|
+
Children,
|
|
89
|
+
styles
|
|
90
|
+
} = this.asProps;
|
|
91
|
+
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SWeekDays, _ref6.cn("SWeekDays", {
|
|
92
|
+
...assignProps({}, _ref)
|
|
93
|
+
}), /* @__PURE__ */ React.createElement(Children, _ref6.cn("Children", {})));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
112
96
|
_defineProperty(CalendarWeekDaysRoot, "displayName", "CalendarWeekDays");
|
|
113
97
|
_defineProperty(CalendarWeekDaysRoot, "style", style);
|
|
114
98
|
_defineProperty(CalendarWeekDaysRoot, "defaultProps", {
|
|
115
99
|
locale: "en",
|
|
116
|
-
children:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}, data));
|
|
122
|
-
});
|
|
123
|
-
}
|
|
100
|
+
children: ({
|
|
101
|
+
days
|
|
102
|
+
}) => days.map((data, i) => /* @__PURE__ */ React.createElement(CalendarWeekDays.Unit, _extends({
|
|
103
|
+
key: i
|
|
104
|
+
}, data)))
|
|
124
105
|
});
|
|
125
|
-
function CalendarWeekUnit(
|
|
106
|
+
function CalendarWeekUnit({
|
|
107
|
+
styles
|
|
108
|
+
}) {
|
|
126
109
|
var _ref2 = arguments[0], _ref7;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
110
|
+
const SWeekDay = Box;
|
|
111
|
+
return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(SWeekDay, _ref7.cn("SWeekDay", {
|
|
112
|
+
...assignProps({
|
|
113
|
+
"role": "columnheader"
|
|
114
|
+
}, _ref2)
|
|
115
|
+
}));
|
|
132
116
|
}
|
|
133
117
|
function resolveHighlighting(date, unit, highlighted) {
|
|
134
|
-
|
|
135
|
-
|
|
118
|
+
let highlighted0 = highlighted[0] ? dayjs(highlighted[0]) : null;
|
|
119
|
+
let highlighted1 = highlighted[1] ? dayjs(highlighted[1]) : highlighted0;
|
|
136
120
|
if (highlighted0 && highlighted1) {
|
|
137
|
-
if (highlighted0 > highlighted1)
|
|
138
|
-
var _ref10 = [highlighted0, highlighted1];
|
|
139
|
-
highlighted1 = _ref10[0];
|
|
140
|
-
highlighted0 = _ref10[1];
|
|
141
|
-
}
|
|
121
|
+
if (highlighted0 > highlighted1) [highlighted1, highlighted0] = [highlighted0, highlighted1];
|
|
142
122
|
return {
|
|
143
123
|
highlighted: date.isBetween(highlighted0, highlighted1, unit, "[]"),
|
|
144
124
|
startHighlighted: highlighted0 && date.isSame(highlighted0, "date"),
|
|
@@ -152,363 +132,357 @@ function resolveHighlighting(date, unit, highlighted) {
|
|
|
152
132
|
};
|
|
153
133
|
}
|
|
154
134
|
function resolveSelecting(date, unit, value) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
135
|
+
let value0 = value[0] ? dayjs(value[0]) : null;
|
|
136
|
+
let value1 = value[1] ? dayjs(value[1]) : null;
|
|
137
|
+
let selected;
|
|
158
138
|
if (value0 && value1) {
|
|
159
|
-
if (value0 > value1)
|
|
160
|
-
var _ref11 = [value0, value1];
|
|
161
|
-
value1 = _ref11[0];
|
|
162
|
-
value0 = _ref11[1];
|
|
163
|
-
}
|
|
139
|
+
if (value0 > value1) [value1, value0] = [value0, value1];
|
|
164
140
|
selected = date.isBetween(value0, value1, unit, "()");
|
|
165
141
|
}
|
|
166
|
-
|
|
167
|
-
|
|
142
|
+
const startSelected = value0 && date.isSame(value0, unit);
|
|
143
|
+
const endSelected = value1 && date.isSame(value1, unit);
|
|
168
144
|
return {
|
|
169
145
|
selected,
|
|
170
146
|
startSelected,
|
|
171
147
|
endSelected
|
|
172
148
|
};
|
|
173
149
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
_defineProperty(_this, "handleMouseLeave", function() {
|
|
184
|
-
var highlighted = _this.asProps.highlighted;
|
|
185
|
-
fire(_this, "onHighlightedChange", highlighted.length ? [highlighted[0]] : []);
|
|
150
|
+
class CalendarAbstract extends Component {
|
|
151
|
+
constructor(...args) {
|
|
152
|
+
super(...args);
|
|
153
|
+
_defineProperty(this, "today", new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)));
|
|
154
|
+
_defineProperty(this, "handleMouseLeave", () => {
|
|
155
|
+
const {
|
|
156
|
+
highlighted
|
|
157
|
+
} = this.asProps;
|
|
158
|
+
fire(this, "onHighlightedChange", highlighted.length ? [highlighted[0]] : []);
|
|
186
159
|
});
|
|
187
|
-
_defineProperty(
|
|
188
|
-
return _this;
|
|
160
|
+
_defineProperty(this, "formatter", formatDDMMYY);
|
|
189
161
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
162
|
+
createUnit({
|
|
163
|
+
date,
|
|
164
|
+
...other
|
|
165
|
+
}, unit) {
|
|
166
|
+
const self = this;
|
|
167
|
+
const {
|
|
168
|
+
disabled: _disabled,
|
|
169
|
+
value,
|
|
170
|
+
compare,
|
|
171
|
+
highlighted,
|
|
172
|
+
compareHighlighted,
|
|
173
|
+
locale
|
|
174
|
+
} = this.asProps;
|
|
175
|
+
const highlighting = resolveHighlighting(date, unit, highlighted ?? []);
|
|
176
|
+
const comparedHighlighting = resolveHighlighting(date, unit, compareHighlighted ?? []);
|
|
177
|
+
const selecting = resolveSelecting(date, unit, value ?? []);
|
|
178
|
+
const comparing = resolveSelecting(date, unit, compare ?? []);
|
|
179
|
+
const disabled = _disabled.some(includesDate(date, unit));
|
|
180
|
+
return {
|
|
181
|
+
"date": formatDDMMYY(date, locale),
|
|
182
|
+
"dateKey": this.formatter(date, locale),
|
|
183
|
+
"children": "",
|
|
184
|
+
"role": "gridcell",
|
|
185
|
+
"startSelected": selecting.startSelected,
|
|
186
|
+
"endSelected": selecting.endSelected,
|
|
187
|
+
"selected": selecting.selected,
|
|
188
|
+
"highlighted": highlighting.highlighted,
|
|
189
|
+
"startHighlighted": highlighting.startHighlighted,
|
|
190
|
+
"endHighlighted": highlighting.endHighlighted,
|
|
191
|
+
"compareHighlighted": comparedHighlighting.highlighted || comparing.selected,
|
|
192
|
+
"compareStartHighlighted": comparedHighlighting.startHighlighted,
|
|
193
|
+
"compareEndHighlighted": comparedHighlighting.endHighlighted,
|
|
194
|
+
"compareStart": comparing.startSelected,
|
|
195
|
+
"compareEnd": comparing.endSelected,
|
|
196
|
+
"aria-selected": selecting.selected,
|
|
197
|
+
"aria-disabled": disabled,
|
|
198
|
+
"aria-current": highlighting.highlighted ? "date" : void 0,
|
|
199
|
+
disabled,
|
|
200
|
+
"today": date.isSame(self.today, unit),
|
|
201
|
+
"onClick": () => {
|
|
202
|
+
const {
|
|
203
|
+
range: range2,
|
|
204
|
+
highlighted: _highlighted
|
|
205
|
+
} = this.asProps;
|
|
206
|
+
let highlighted2 = [date.valueOf()];
|
|
207
|
+
if (_highlighted.length === 1) {
|
|
208
|
+
highlighted2 = [_highlighted[0], date.valueOf()];
|
|
209
|
+
} else if (_highlighted.length >= 2) {
|
|
210
|
+
highlighted2 = [];
|
|
211
|
+
}
|
|
212
|
+
if (range2 === "compare") {
|
|
213
|
+
fire(this, "onCompareHighlightedChange", highlighted2);
|
|
214
|
+
} else {
|
|
215
|
+
fire(this, "onHighlightedChange", highlighted2);
|
|
216
|
+
}
|
|
217
|
+
fire(this, "onChange", date.toDate());
|
|
218
|
+
},
|
|
219
|
+
"onMouseEnter": () => {
|
|
220
|
+
const {
|
|
221
|
+
range: range2,
|
|
222
|
+
highlighted: _highlighted
|
|
223
|
+
} = this.asProps;
|
|
224
|
+
const value2 = range2 === "compare" ? this.asProps.compare : this.asProps.value;
|
|
225
|
+
if (_highlighted[0] || (value2 ?? []).length === 1) {
|
|
226
|
+
const startDate = _highlighted[0] || (value2 ?? [])[0];
|
|
227
|
+
const highlighted2 = [startDate.valueOf(), date.valueOf()];
|
|
228
|
+
if (range2 === "compare") {
|
|
229
|
+
fire(this, "onCompareHighlightedChange", highlighted2);
|
|
234
230
|
} else {
|
|
235
|
-
fire(
|
|
236
|
-
}
|
|
237
|
-
fire(_this2, "onChange", date.toDate());
|
|
238
|
-
},
|
|
239
|
-
"onMouseEnter": function onMouseEnter() {
|
|
240
|
-
var _this2$asProps2 = _this2.asProps, range3 = _this2$asProps2.range, _highlighted = _this2$asProps2.highlighted;
|
|
241
|
-
var value2 = range3 === "compare" ? _this2.asProps.compare : _this2.asProps.value;
|
|
242
|
-
if (_highlighted[0] || (value2 !== null && value2 !== void 0 ? value2 : []).length === 1) {
|
|
243
|
-
var startDate = _highlighted[0] || (value2 !== null && value2 !== void 0 ? value2 : [])[0];
|
|
244
|
-
var _highlighted2 = [startDate.valueOf(), date.valueOf()];
|
|
245
|
-
if (range3 === "compare") {
|
|
246
|
-
fire(_this2, "onCompareHighlightedChange", _highlighted2);
|
|
247
|
-
} else {
|
|
248
|
-
fire(_this2, "onHighlightedChange", _highlighted2);
|
|
249
|
-
}
|
|
231
|
+
fire(this, "onHighlightedChange", highlighted2);
|
|
250
232
|
}
|
|
251
233
|
}
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}, {
|
|
270
|
-
key: "getRootProps",
|
|
271
|
-
value: function getRootProps() {
|
|
272
|
-
return {
|
|
273
|
-
role: "grid",
|
|
274
|
-
tabIndex: 0
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
}, {
|
|
278
|
-
key: "describeValue",
|
|
279
|
-
value: function describeValue() {
|
|
280
|
-
var _this3 = this;
|
|
281
|
-
var _this$asProps3 = this.asProps, locale = _this$asProps3.locale, getI18nText = _this$asProps3.getI18nText, actionsDescribing = _this$asProps3.actionsDescribing;
|
|
282
|
-
var value = this.asProps.value || [];
|
|
283
|
-
var compare = this.asProps.compare || [];
|
|
284
|
-
if (!actionsDescribing) return null;
|
|
285
|
-
var t = function t2(key, date) {
|
|
286
|
-
return getI18nText(key, date ? {
|
|
287
|
-
date: _this3.formatter(date, locale)
|
|
288
|
-
} : void 0);
|
|
289
|
-
};
|
|
290
|
-
var description = "";
|
|
291
|
-
if (value.length === 1 || compare.length === 1) {
|
|
292
|
-
description += t("selectingStarted") + ". ";
|
|
293
|
-
} else if (value.length === 2 || compare.length === 2) {
|
|
294
|
-
description += t("selectingFinished") + ". ";
|
|
234
|
+
},
|
|
235
|
+
...other
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
getUnitProps({
|
|
239
|
+
dateKey
|
|
240
|
+
}, index) {
|
|
241
|
+
const inRow = 7;
|
|
242
|
+
const {
|
|
243
|
+
unitRefs
|
|
244
|
+
} = this.asProps;
|
|
245
|
+
return {
|
|
246
|
+
"aria-colindex": index % inRow + 1,
|
|
247
|
+
"aria-rowindex": Math.floor(index / inRow) + 1,
|
|
248
|
+
"ref": (node) => {
|
|
249
|
+
if (!dateKey) return;
|
|
250
|
+
unitRefs[dateKey] = node;
|
|
295
251
|
}
|
|
296
|
-
|
|
297
|
-
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
getRootProps() {
|
|
255
|
+
return {
|
|
256
|
+
role: "grid",
|
|
257
|
+
tabIndex: 0
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
describeValue() {
|
|
261
|
+
const {
|
|
262
|
+
locale,
|
|
263
|
+
getI18nText,
|
|
264
|
+
actionsDescribing
|
|
265
|
+
} = this.asProps;
|
|
266
|
+
const value = this.asProps.value || [];
|
|
267
|
+
const compare = this.asProps.compare || [];
|
|
268
|
+
if (!actionsDescribing) return null;
|
|
269
|
+
const t = (key, date) => getI18nText(key, date ? {
|
|
270
|
+
date: this.formatter(date, locale)
|
|
271
|
+
} : void 0);
|
|
272
|
+
let description = "";
|
|
273
|
+
if (value.length === 1 || compare.length === 1) {
|
|
274
|
+
description += t("selectingStarted") + ". ";
|
|
275
|
+
} else if (value.length === 2 || compare.length === 2) {
|
|
276
|
+
description += t("selectingFinished") + ". ";
|
|
277
|
+
}
|
|
278
|
+
if (actionsDescribing === "range") {
|
|
279
|
+
if (value[0] || value[1]) description += t("dateRange") + " ";
|
|
280
|
+
if (value[0]) description += t("fromDate", value[0]) + ", ";
|
|
281
|
+
if (value[1]) description += t("toDate", value[1]) + ". ";
|
|
282
|
+
} else if (actionsDescribing === "range-compare") {
|
|
283
|
+
if (compare.length === 1) {
|
|
284
|
+
description += t("dateRange2") + " ";
|
|
285
|
+
if (compare[0]) description += t("fromDate", value[0]) + ", ";
|
|
286
|
+
if (compare[1]) description += t("toDate", value[1]) + ". ";
|
|
287
|
+
} else {
|
|
288
|
+
if (value[0] || value[1]) description += t("dateRange1") + " ";
|
|
298
289
|
if (value[0]) description += t("fromDate", value[0]) + ", ";
|
|
299
290
|
if (value[1]) description += t("toDate", value[1]) + ". ";
|
|
300
|
-
|
|
301
|
-
if (compare.length === 1) {
|
|
291
|
+
if (compare.length > 0) {
|
|
302
292
|
description += t("dateRange2") + " ";
|
|
303
|
-
if (compare[0]) description += t("fromDate",
|
|
304
|
-
if (compare[1]) description += t("toDate",
|
|
305
|
-
} else {
|
|
306
|
-
if (value[0] || value[1]) description += t("dateRange1") + " ";
|
|
307
|
-
if (value[0]) description += t("fromDate", value[0]) + ", ";
|
|
308
|
-
if (value[1]) description += t("toDate", value[1]) + ". ";
|
|
309
|
-
if (compare.length > 0) {
|
|
310
|
-
description += t("dateRange2") + " ";
|
|
311
|
-
if (compare[0]) description += t("fromDate", compare[0]) + ", ";
|
|
312
|
-
if (compare[1]) description += t("toDate", compare[1]) + ". ";
|
|
313
|
-
}
|
|
293
|
+
if (compare[0]) description += t("fromDate", compare[0]) + ", ";
|
|
294
|
+
if (compare[1]) description += t("toDate", compare[1]) + ". ";
|
|
314
295
|
}
|
|
315
296
|
}
|
|
316
|
-
return description;
|
|
317
297
|
}
|
|
318
|
-
|
|
319
|
-
}
|
|
298
|
+
return description;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
320
301
|
_defineProperty(CalendarAbstract, "style", style);
|
|
321
|
-
function CalendarUnit(
|
|
302
|
+
function CalendarUnit({
|
|
303
|
+
styles,
|
|
304
|
+
date,
|
|
305
|
+
long,
|
|
306
|
+
outdated,
|
|
307
|
+
disabled,
|
|
308
|
+
highlighted
|
|
309
|
+
}) {
|
|
322
310
|
var _ref3 = arguments[0], _ref8;
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
311
|
+
const SCalendarUnit = Box;
|
|
312
|
+
return _ref8 = sstyled(styles), /* @__PURE__ */ React.createElement(SCalendarUnit, _ref8.cn("SCalendarUnit", {
|
|
313
|
+
...assignProps({
|
|
314
|
+
"use:disabled": disabled || outdated || !date,
|
|
315
|
+
"aria-hidden": !date,
|
|
316
|
+
"aria-label": long || date,
|
|
317
|
+
"use:tabIndex": highlighted ? 0 : -1
|
|
318
|
+
}, _ref3)
|
|
319
|
+
}));
|
|
331
320
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
})
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
date
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
prevMonthDays = prevMonthDays.map(function() {
|
|
379
|
-
return {
|
|
380
|
-
disabled: true,
|
|
381
|
-
children: ""
|
|
382
|
-
};
|
|
383
|
-
});
|
|
384
|
-
nextMonthDays = [];
|
|
385
|
-
}
|
|
386
|
-
return [].concat(_toConsumableArray(prevMonthDays), _toConsumableArray(monthDays), _toConsumableArray(nextMonthDays));
|
|
387
|
-
}
|
|
388
|
-
}, {
|
|
389
|
-
key: "setContext",
|
|
390
|
-
value: function setContext() {
|
|
391
|
-
return {
|
|
392
|
-
days: this.getDaysByMonth()
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
}, {
|
|
396
|
-
key: "render",
|
|
397
|
-
value: function render() {
|
|
398
|
-
var _ref4 = this.asProps, _ref9;
|
|
399
|
-
var SCalendar = Box;
|
|
400
|
-
var SGridDays = "div";
|
|
401
|
-
var _this$asProps5 = this.asProps, Children = _this$asProps5.Children, styles = _this$asProps5.styles, locale = _this$asProps5.locale;
|
|
402
|
-
var description = this.describeValue();
|
|
403
|
-
return _ref9 = sstyled(styles), /* @__PURE__ */ React.createElement(SCalendar, _ref9.cn("SCalendar", _objectSpread({}, assignProps(_objectSpread({}, this.getRootProps()), _ref4))), /* @__PURE__ */ React.createElement(CalendarWeekDays, _ref9.cn("CalendarWeekDays", {
|
|
404
|
-
"locale": locale,
|
|
405
|
-
"role": "row"
|
|
406
|
-
})), /* @__PURE__ */ React.createElement(SGridDays, _ref9.cn("SGridDays", {
|
|
407
|
-
"onMouseLeave": this.handleMouseLeave,
|
|
408
|
-
"role": "row"
|
|
409
|
-
}), /* @__PURE__ */ React.createElement(Children, _ref9.cn("Children", {}))), /* @__PURE__ */ React.createElement(ScreenReaderOnly, _ref9.cn("ScreenReaderOnly", {
|
|
410
|
-
"role": "row"
|
|
411
|
-
}), /* @__PURE__ */ React.createElement("span", _ref9.cn("span", {
|
|
412
|
-
"aria-live": "polite",
|
|
413
|
-
"role": "gridcell"
|
|
414
|
-
}), description)));
|
|
321
|
+
class CalendarDaysRoot extends CalendarAbstract {
|
|
322
|
+
getDaysByMonth() {
|
|
323
|
+
const {
|
|
324
|
+
displayedPeriod,
|
|
325
|
+
renderOutdated,
|
|
326
|
+
locale
|
|
327
|
+
} = this.asProps;
|
|
328
|
+
let date = dayjs(displayedPeriod).startOf("month");
|
|
329
|
+
let prevDate = date.subtract(1, "month");
|
|
330
|
+
let nextDate = date.add(1, "month");
|
|
331
|
+
const dateStartOfWeek = date.locale(locale, getDayJSLocaleParams(locale)).startOf("week").get("d") ? (date.get("d") || 7) - 1 : date.get("d");
|
|
332
|
+
let prevMonthDays = dateStartOfWeek ? range(prevDate.daysInMonth(), (i) => {
|
|
333
|
+
const day = this.createUnit({
|
|
334
|
+
date: prevDate,
|
|
335
|
+
outdated: true,
|
|
336
|
+
i
|
|
337
|
+
}, "date");
|
|
338
|
+
day.children = String(prevDate.get("date"));
|
|
339
|
+
prevDate = prevDate.add(1, "day");
|
|
340
|
+
return day;
|
|
341
|
+
}).slice(-dateStartOfWeek) : [];
|
|
342
|
+
const monthDays = range(date.daysInMonth(), (i) => {
|
|
343
|
+
const day = this.createUnit({
|
|
344
|
+
date,
|
|
345
|
+
i
|
|
346
|
+
}, "date");
|
|
347
|
+
day.children = String(date.get("date"));
|
|
348
|
+
date = date.add(1, "day");
|
|
349
|
+
return day;
|
|
350
|
+
});
|
|
351
|
+
let nextMonthDays = range(42 - prevMonthDays.length - monthDays.length, (i) => {
|
|
352
|
+
const day = this.createUnit({
|
|
353
|
+
date: nextDate,
|
|
354
|
+
outdated: true,
|
|
355
|
+
i
|
|
356
|
+
}, "date");
|
|
357
|
+
day.children = String(nextDate.get("date"));
|
|
358
|
+
nextDate = nextDate.add(1, "day");
|
|
359
|
+
return day;
|
|
360
|
+
});
|
|
361
|
+
if (!renderOutdated) {
|
|
362
|
+
prevMonthDays = prevMonthDays.map(() => ({
|
|
363
|
+
disabled: true,
|
|
364
|
+
children: ""
|
|
365
|
+
}));
|
|
366
|
+
nextMonthDays = [];
|
|
415
367
|
}
|
|
416
|
-
|
|
417
|
-
}
|
|
368
|
+
return [...prevMonthDays, ...monthDays, ...nextMonthDays];
|
|
369
|
+
}
|
|
370
|
+
setContext() {
|
|
371
|
+
return {
|
|
372
|
+
days: this.getDaysByMonth()
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
render() {
|
|
376
|
+
var _ref4 = this.asProps, _ref9;
|
|
377
|
+
const SCalendar = Box;
|
|
378
|
+
const SGridDays = "div";
|
|
379
|
+
const {
|
|
380
|
+
Children,
|
|
381
|
+
styles,
|
|
382
|
+
locale
|
|
383
|
+
} = this.asProps;
|
|
384
|
+
const description = this.describeValue();
|
|
385
|
+
return _ref9 = sstyled(styles), /* @__PURE__ */ React.createElement(SCalendar, _ref9.cn("SCalendar", {
|
|
386
|
+
...assignProps({
|
|
387
|
+
...this.getRootProps()
|
|
388
|
+
}, _ref4)
|
|
389
|
+
}), /* @__PURE__ */ React.createElement(CalendarWeekDays, _ref9.cn("CalendarWeekDays", {
|
|
390
|
+
"locale": locale,
|
|
391
|
+
"role": "row"
|
|
392
|
+
})), /* @__PURE__ */ React.createElement(SGridDays, _ref9.cn("SGridDays", {
|
|
393
|
+
"onMouseLeave": this.handleMouseLeave,
|
|
394
|
+
"role": "row"
|
|
395
|
+
}), /* @__PURE__ */ React.createElement(Children, _ref9.cn("Children", {}))), /* @__PURE__ */ React.createElement(ScreenReaderOnly, _ref9.cn("ScreenReaderOnly", {
|
|
396
|
+
"role": "row"
|
|
397
|
+
}), /* @__PURE__ */ React.createElement("span", _ref9.cn("span", {
|
|
398
|
+
"aria-live": "polite",
|
|
399
|
+
"role": "gridcell"
|
|
400
|
+
}), description)));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
418
403
|
_defineProperty(CalendarDaysRoot, "displayName", "CalendarDays");
|
|
419
404
|
_defineProperty(CalendarDaysRoot, "defaultProps", {
|
|
420
405
|
displayedPeriod: new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)),
|
|
421
406
|
disabled: [],
|
|
422
407
|
value: [],
|
|
423
408
|
locale: "en",
|
|
424
|
-
children:
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
409
|
+
children: ({
|
|
410
|
+
days
|
|
411
|
+
}) => days.map((data, i) => /* @__PURE__ */ React.createElement(CalendarDays.Unit, _extends({
|
|
412
|
+
key: i
|
|
413
|
+
}, data)))
|
|
414
|
+
});
|
|
415
|
+
class CalendarMonthsRoot extends CalendarAbstract {
|
|
416
|
+
constructor(...args) {
|
|
417
|
+
super(...args);
|
|
418
|
+
_defineProperty(this, "formatter", formatMMYY);
|
|
419
|
+
}
|
|
420
|
+
getMonthsByYear() {
|
|
421
|
+
const {
|
|
422
|
+
displayedPeriod,
|
|
423
|
+
locale
|
|
424
|
+
} = this.asProps;
|
|
425
|
+
let date = dayjs(displayedPeriod).startOf("year");
|
|
426
|
+
return range(12, () => {
|
|
427
|
+
const month = this.createUnit({
|
|
428
|
+
date
|
|
429
|
+
}, "month");
|
|
430
|
+
month.children = new Intl.DateTimeFormat(locale, {
|
|
431
|
+
month: "short"
|
|
432
|
+
}).format(date.valueOf());
|
|
433
|
+
month.long = new Intl.DateTimeFormat(locale, {
|
|
434
|
+
month: "long",
|
|
435
|
+
year: "numeric"
|
|
436
|
+
}).format(date.valueOf());
|
|
437
|
+
date = date.add(1, "month");
|
|
438
|
+
return month;
|
|
430
439
|
});
|
|
431
440
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
_classCallCheck(this, CalendarMonthsRoot2);
|
|
437
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
438
|
-
args[_key2] = arguments[_key2];
|
|
439
|
-
}
|
|
440
|
-
_this5 = _callSuper(this, CalendarMonthsRoot2, [].concat(args));
|
|
441
|
-
_defineProperty(_this5, "formatter", formatMMYY);
|
|
442
|
-
return _this5;
|
|
441
|
+
setContext() {
|
|
442
|
+
return {
|
|
443
|
+
months: this.getMonthsByYear()
|
|
444
|
+
};
|
|
443
445
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
value: function setContext() {
|
|
469
|
-
return {
|
|
470
|
-
months: this.getMonthsByYear()
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
}, {
|
|
474
|
-
key: "render",
|
|
475
|
-
value: function render() {
|
|
476
|
-
var _ref5 = this.asProps, _ref0;
|
|
477
|
-
var SCalendar = Box;
|
|
478
|
-
var SGridMonths = "div";
|
|
479
|
-
var _this$asProps7 = this.asProps, Children = _this$asProps7.Children, styles = _this$asProps7.styles;
|
|
480
|
-
var description = this.describeValue();
|
|
481
|
-
return _ref0 = sstyled(styles), /* @__PURE__ */ React.createElement(SCalendar, _ref0.cn("SCalendar", _objectSpread({}, assignProps(_objectSpread({}, this.getRootProps()), _ref5))), /* @__PURE__ */ React.createElement(SGridMonths, _ref0.cn("SGridMonths", {
|
|
482
|
-
"onMouseLeave": this.handleMouseLeave,
|
|
483
|
-
"role": "row"
|
|
484
|
-
}), /* @__PURE__ */ React.createElement(Children, _ref0.cn("Children", {}))), /* @__PURE__ */ React.createElement(ScreenReaderOnly, _ref0.cn("ScreenReaderOnly", {
|
|
485
|
-
"role": "row"
|
|
486
|
-
}), /* @__PURE__ */ React.createElement("span", _ref0.cn("span", {
|
|
487
|
-
"aria-live": "polite",
|
|
488
|
-
"role": "gridcell"
|
|
489
|
-
}), description)));
|
|
490
|
-
}
|
|
491
|
-
}]);
|
|
492
|
-
})(CalendarAbstract);
|
|
446
|
+
render() {
|
|
447
|
+
var _ref5 = this.asProps, _ref0;
|
|
448
|
+
const SCalendar = Box;
|
|
449
|
+
const SGridMonths = "div";
|
|
450
|
+
const {
|
|
451
|
+
Children,
|
|
452
|
+
styles
|
|
453
|
+
} = this.asProps;
|
|
454
|
+
const description = this.describeValue();
|
|
455
|
+
return _ref0 = sstyled(styles), /* @__PURE__ */ React.createElement(SCalendar, _ref0.cn("SCalendar", {
|
|
456
|
+
...assignProps({
|
|
457
|
+
...this.getRootProps()
|
|
458
|
+
}, _ref5)
|
|
459
|
+
}), /* @__PURE__ */ React.createElement(SGridMonths, _ref0.cn("SGridMonths", {
|
|
460
|
+
"onMouseLeave": this.handleMouseLeave,
|
|
461
|
+
"role": "row"
|
|
462
|
+
}), /* @__PURE__ */ React.createElement(Children, _ref0.cn("Children", {}))), /* @__PURE__ */ React.createElement(ScreenReaderOnly, _ref0.cn("ScreenReaderOnly", {
|
|
463
|
+
"role": "row"
|
|
464
|
+
}), /* @__PURE__ */ React.createElement("span", _ref0.cn("span", {
|
|
465
|
+
"aria-live": "polite",
|
|
466
|
+
"role": "gridcell"
|
|
467
|
+
}), description)));
|
|
468
|
+
}
|
|
469
|
+
}
|
|
493
470
|
_defineProperty(CalendarMonthsRoot, "displayName", "CalendarMonths");
|
|
494
471
|
_defineProperty(CalendarMonthsRoot, "defaultProps", {
|
|
495
472
|
locale: "en",
|
|
496
|
-
children:
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}, data));
|
|
502
|
-
});
|
|
503
|
-
}
|
|
473
|
+
children: ({
|
|
474
|
+
months
|
|
475
|
+
}) => months.map((data, i) => /* @__PURE__ */ React.createElement(CalendarMonths.Unit, _extends({
|
|
476
|
+
key: i
|
|
477
|
+
}, data)))
|
|
504
478
|
});
|
|
505
|
-
|
|
479
|
+
const CalendarWeekDays = createComponent(CalendarWeekDaysRoot, {
|
|
506
480
|
Unit: CalendarWeekUnit
|
|
507
481
|
});
|
|
508
|
-
|
|
482
|
+
const CalendarDays = createComponent(CalendarDaysRoot, {
|
|
509
483
|
Unit: CalendarUnit
|
|
510
484
|
});
|
|
511
|
-
|
|
485
|
+
const CalendarMonths = createComponent(CalendarMonthsRoot, {
|
|
512
486
|
Unit: CalendarUnit
|
|
513
487
|
});
|
|
514
488
|
export {
|