@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,23 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
-
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
9
3
|
import { assignProps, sstyled, Component } from "@semcore/core";
|
|
4
|
+
import { Box } from "@semcore/base-components";
|
|
10
5
|
import Button from "@semcore/button";
|
|
11
6
|
import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
|
|
12
7
|
import Dropdown from "@semcore/dropdown";
|
|
13
|
-
import { Box } from "@semcore/flex-box";
|
|
14
8
|
import ChevronLeft from "@semcore/icon/ChevronLeft/m";
|
|
15
9
|
import ChevronRight from "@semcore/icon/ChevronRight/m";
|
|
16
10
|
import dayjs from "dayjs";
|
|
17
11
|
import React from "react";
|
|
18
12
|
import ButtonTrigger from "./ButtonTrigger.mjs";
|
|
19
13
|
import InputTrigger$1 from "./InputTrigger.mjs";
|
|
20
|
-
var _excluded = ["value", "onClick", "onMouseEnter", "onMouseLeave"];
|
|
21
14
|
function Trigger() {
|
|
22
15
|
var _ref = arguments[0];
|
|
23
16
|
return /* @__PURE__ */ React.createElement(Dropdown.Trigger, assignProps({
|
|
@@ -40,53 +33,58 @@ InputTrigger.DateRangeFromInput = InputTrigger$1.DateRangeFromInput;
|
|
|
40
33
|
InputTrigger.DateRangeToInput = InputTrigger$1.DateRangeToInput;
|
|
41
34
|
function Popper(props) {
|
|
42
35
|
var _ref3 = arguments[0], _ref9;
|
|
43
|
-
|
|
44
|
-
return _ref9 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SPopper, _ref9.cn("SPopper",
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
const SPopper = Dropdown.Popper;
|
|
37
|
+
return _ref9 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SPopper, _ref9.cn("SPopper", {
|
|
38
|
+
...assignProps({
|
|
39
|
+
"role": "dialog"
|
|
40
|
+
}, _ref3)
|
|
41
|
+
}));
|
|
47
42
|
}
|
|
48
43
|
function Header(props) {
|
|
49
44
|
var _ref4 = arguments[0], _ref0;
|
|
50
|
-
|
|
51
|
-
return _ref0 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SHeader, _ref0.cn("SHeader",
|
|
45
|
+
const SHeader = Box;
|
|
46
|
+
return _ref0 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SHeader, _ref0.cn("SHeader", {
|
|
47
|
+
...assignProps({}, _ref4)
|
|
48
|
+
}));
|
|
52
49
|
}
|
|
53
|
-
function Title(
|
|
50
|
+
function Title({
|
|
51
|
+
Children,
|
|
52
|
+
styles
|
|
53
|
+
}) {
|
|
54
54
|
var _ref5 = arguments[0], _ref1;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
const STitle = Box;
|
|
56
|
+
return _ref1 = sstyled(styles), /* @__PURE__ */ React.createElement(STitle, _ref1.cn("STitle", {
|
|
57
|
+
...assignProps({
|
|
58
|
+
"aria-live": "polite"
|
|
59
|
+
}, _ref5)
|
|
60
|
+
}), /* @__PURE__ */ React.createElement(Children, _ref1.cn("Children", {})));
|
|
60
61
|
}
|
|
61
|
-
function Prev(
|
|
62
|
+
function Prev({
|
|
63
|
+
children,
|
|
64
|
+
Children
|
|
65
|
+
}) {
|
|
62
66
|
var _ref6 = arguments[0];
|
|
63
|
-
var children = _ref12.children, Children = _ref12.Children;
|
|
64
67
|
return /* @__PURE__ */ React.createElement(Button, assignProps({
|
|
65
68
|
"use": "tertiary",
|
|
66
69
|
"theme": "muted",
|
|
67
70
|
"size": "l"
|
|
68
71
|
}, _ref6), children ? /* @__PURE__ */ React.createElement(Children, null) : /* @__PURE__ */ React.createElement(Button.Addon, null, /* @__PURE__ */ React.createElement(ChevronLeft, null)));
|
|
69
72
|
}
|
|
70
|
-
function Next(
|
|
73
|
+
function Next({
|
|
74
|
+
children,
|
|
75
|
+
Children
|
|
76
|
+
}) {
|
|
71
77
|
var _ref7 = arguments[0];
|
|
72
|
-
var children = _ref13.children, Children = _ref13.Children;
|
|
73
78
|
return /* @__PURE__ */ React.createElement(Button, assignProps({
|
|
74
79
|
"use": "tertiary",
|
|
75
80
|
"theme": "muted",
|
|
76
81
|
"size": "l"
|
|
77
82
|
}, _ref7), children ? /* @__PURE__ */ React.createElement(Children, null) : /* @__PURE__ */ React.createElement(Button.Addon, null, /* @__PURE__ */ React.createElement(ChevronRight, null)));
|
|
78
83
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
84
|
-
args[_key] = arguments[_key];
|
|
85
|
-
}
|
|
86
|
-
_this = _callSuper(this, Period2, [].concat(args));
|
|
87
|
-
_defineProperty(_this, "getActiveControl", function() {
|
|
88
|
-
var period = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
89
|
-
var value = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : void 0;
|
|
84
|
+
class Period extends Component {
|
|
85
|
+
constructor(...args) {
|
|
86
|
+
super(...args);
|
|
87
|
+
_defineProperty(this, "getActiveControl", (period = [], value = void 0) => {
|
|
90
88
|
function compareMonth(monthOne, monthTwo) {
|
|
91
89
|
return dayjs(monthOne).isSame(dayjs(monthTwo), "date");
|
|
92
90
|
}
|
|
@@ -97,41 +95,47 @@ var Period = /* @__PURE__ */ (function(_Component) {
|
|
|
97
95
|
}
|
|
98
96
|
return compareMonth(period[0], value);
|
|
99
97
|
});
|
|
100
|
-
return _this;
|
|
101
98
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
})
|
|
99
|
+
render() {
|
|
100
|
+
var _ref8 = this.asProps, _ref10;
|
|
101
|
+
const SPeriod = Box;
|
|
102
|
+
const {
|
|
103
|
+
styles,
|
|
104
|
+
value,
|
|
105
|
+
onChange,
|
|
106
|
+
periods,
|
|
107
|
+
onHighlightedChange,
|
|
108
|
+
onDisplayedPeriodChange,
|
|
109
|
+
periodRef
|
|
110
|
+
} = this.asProps;
|
|
111
|
+
return _ref10 = sstyled(styles), /* @__PURE__ */ React.createElement(SPeriod, _ref10.cn("SPeriod", {
|
|
112
|
+
...assignProps({}, _ref8)
|
|
113
|
+
}), periods.map(({
|
|
114
|
+
value: period,
|
|
115
|
+
onClick,
|
|
116
|
+
onMouseEnter,
|
|
117
|
+
onMouseLeave,
|
|
118
|
+
...other
|
|
119
|
+
}, i) => /* @__PURE__ */ React.createElement(Button, _extends({
|
|
120
|
+
ref: periodRef == null ? void 0 : periodRef(i),
|
|
121
|
+
key: i,
|
|
122
|
+
use: "tertiary",
|
|
123
|
+
theme: "muted",
|
|
124
|
+
role: "option",
|
|
125
|
+
styles,
|
|
126
|
+
active: this.getActiveControl(period, value),
|
|
127
|
+
onClick: callAllEventHandlers(onClick, () => onChange(period)),
|
|
128
|
+
onMouseEnter: callAllEventHandlers(onMouseEnter, () => {
|
|
129
|
+
onHighlightedChange(period);
|
|
130
|
+
onDisplayedPeriodChange(dayjs(period[0]).toDate());
|
|
131
|
+
}),
|
|
132
|
+
onMouseLeave: callAllEventHandlers(onMouseLeave, () => {
|
|
133
|
+
onHighlightedChange([]);
|
|
134
|
+
onDisplayedPeriodChange(value[0] ? dayjs(value[0]).toDate() : /* @__PURE__ */ new Date());
|
|
135
|
+
})
|
|
136
|
+
}, other))));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
135
139
|
export {
|
|
136
140
|
Header,
|
|
137
141
|
InputTrigger,
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
function cronUnitToArray(unit) {
|
|
3
2
|
if (unit.includes("-")) {
|
|
4
|
-
|
|
3
|
+
const [start, end] = unit.split("-");
|
|
5
4
|
return Array.from({
|
|
6
5
|
length: Number.parseInt(end, 10) - Number.parseInt(start, 10) + 1
|
|
7
|
-
},
|
|
8
|
-
return Number.parseInt(start, 10) + idx;
|
|
9
|
-
});
|
|
6
|
+
}, (_, idx) => Number.parseInt(start, 10) + idx);
|
|
10
7
|
}
|
|
11
8
|
return unit.split(/[,\/]/);
|
|
12
9
|
}
|
|
13
10
|
function isValidSchedule(pattern) {
|
|
14
11
|
if (typeof pattern !== "string") return false;
|
|
15
12
|
function isValidUnit(unit, min, max) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return unitValues.every(
|
|
19
|
-
|
|
13
|
+
const unitValues = cronUnitToArray(unit);
|
|
14
|
+
const CRON_REG = /^\d+$|^\*$|^\*\/\d+$/;
|
|
15
|
+
return unitValues.every((item) => {
|
|
16
|
+
const intItem = Number.parseInt(item, 10);
|
|
20
17
|
return !(intItem < min || intItem > max || !CRON_REG.test(item));
|
|
21
18
|
});
|
|
22
19
|
}
|
|
@@ -31,12 +28,12 @@ function isValidSchedule(pattern) {
|
|
|
31
28
|
}
|
|
32
29
|
function validate(pattern2, validateFn, msg) {
|
|
33
30
|
if (validateFn(pattern2)) return true;
|
|
34
|
-
console.warn(
|
|
31
|
+
console.warn(`DatePicker disabledSchedule: ${msg} format is invalid`);
|
|
35
32
|
return false;
|
|
36
33
|
}
|
|
37
|
-
|
|
34
|
+
const patternArr = pattern.split(" ");
|
|
38
35
|
if (patternArr.length < 3) return false;
|
|
39
|
-
return patternArr.every(
|
|
36
|
+
return patternArr.every((pattern2, idx) => {
|
|
40
37
|
switch (idx) {
|
|
41
38
|
case 0:
|
|
42
39
|
return validate(pattern2, isValidMonthDay, "day of month");
|
|
@@ -50,7 +47,7 @@ function isValidSchedule(pattern) {
|
|
|
50
47
|
});
|
|
51
48
|
}
|
|
52
49
|
function isInPeriod(pattern, date) {
|
|
53
|
-
|
|
50
|
+
const patternArr = pattern.split(" ");
|
|
54
51
|
function isInPeriod2(date2, period, dateMethod) {
|
|
55
52
|
if (period === "*") return true;
|
|
56
53
|
return date2[dateMethod]() === Number.parseInt(period, 10);
|
|
@@ -66,12 +63,10 @@ function isInPeriod(pattern, date) {
|
|
|
66
63
|
return isInPeriod2(date2, period, "getDay");
|
|
67
64
|
}
|
|
68
65
|
function test(units, date2, testFn) {
|
|
69
|
-
return units.some(
|
|
70
|
-
return testFn(date2, unit);
|
|
71
|
-
});
|
|
66
|
+
return units.some((unit) => testFn(date2, unit));
|
|
72
67
|
}
|
|
73
|
-
return patternArr.every(
|
|
74
|
-
|
|
68
|
+
return patternArr.every((unit, idx) => {
|
|
69
|
+
const unitValues = cronUnitToArray(unit);
|
|
75
70
|
switch (idx) {
|
|
76
71
|
case 0:
|
|
77
72
|
return test(unitValues, date, monthDayInPeriod);
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import dayjs from "dayjs";
|
|
3
2
|
import { isValidSchedule, isInPeriod } from "./cronTabScheduler.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return dateFrom && dateTo && dayjs(disabled_day).isBetween(dayjs(dateFrom), dayjs(dateTo), unit, "[]");
|
|
16
|
-
};
|
|
3
|
+
const MAX_DATE_TIMESTAMP = 864e13;
|
|
4
|
+
const datesIntersects = ([dateFrom, dateTo], unit) => (disabled_day) => {
|
|
5
|
+
if (Array.isArray(disabled_day)) {
|
|
6
|
+
const [start, end] = disabled_day;
|
|
7
|
+
return dateFrom && dayjs(dateFrom).isBetween(start || -MAX_DATE_TIMESTAMP, end || MAX_DATE_TIMESTAMP, unit, "[]") || dateTo && dayjs(dateTo).isBetween(start || -MAX_DATE_TIMESTAMP, end || MAX_DATE_TIMESTAMP, unit, "[]") || dateFrom && dateTo && dayjs(start).isBetween(dayjs(dateFrom), dayjs(dateTo), unit, "[]") || dateFrom && dateTo && dayjs(end).isBetween(dayjs(dateFrom), dayjs(dateTo), unit, "[]");
|
|
8
|
+
}
|
|
9
|
+
if (isValidSchedule(disabled_day)) {
|
|
10
|
+
return isInPeriod(disabled_day, dateFrom) || isInPeriod(disabled_day, dateTo);
|
|
11
|
+
}
|
|
12
|
+
return dateFrom && dateTo && dayjs(disabled_day).isBetween(dayjs(dateFrom), dayjs(dateTo), unit, "[]");
|
|
17
13
|
};
|
|
18
14
|
export {
|
|
19
15
|
datesIntersects
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import dayjs from "dayjs";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const DDMMYYFormattersCache = {};
|
|
3
|
+
const formatDDMMYY = (date, locale) => {
|
|
4
4
|
if (DDMMYYFormattersCache[locale] === void 0) {
|
|
5
5
|
DDMMYYFormattersCache[locale] = new Intl.DateTimeFormat(locale, {
|
|
6
6
|
day: "numeric",
|
|
@@ -8,18 +8,18 @@ var formatDDMMYY = function formatDDMMYY2(date, locale) {
|
|
|
8
8
|
year: "numeric"
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
const formatter = DDMMYYFormattersCache[locale];
|
|
12
12
|
return formatter.format(dayjs(date).toDate());
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const MMYYYYFormattersCache = {};
|
|
15
|
+
const formatMMYY = (date, locale) => {
|
|
16
16
|
if (MMYYYYFormattersCache[locale] === void 0) {
|
|
17
17
|
MMYYYYFormattersCache[locale] = new Intl.DateTimeFormat(locale, {
|
|
18
18
|
month: "long",
|
|
19
19
|
year: "numeric"
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
const formatter = MMYYYYFormattersCache[locale];
|
|
23
23
|
return formatter.format(dayjs(date).toDate());
|
|
24
24
|
};
|
|
25
25
|
export {
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import { isValidSchedule, isInPeriod } from "./cronTabScheduler.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return date.isSame(disabled_day, "date");
|
|
14
|
-
};
|
|
2
|
+
const includesDate = (date, unit) => (disabled_day) => {
|
|
3
|
+
if (Array.isArray(disabled_day)) {
|
|
4
|
+
const MAX_DATE_TIMESTAMP = 864e13;
|
|
5
|
+
const [start, end] = disabled_day;
|
|
6
|
+
return date.isBetween(start || -MAX_DATE_TIMESTAMP, end || MAX_DATE_TIMESTAMP, unit, "[]");
|
|
7
|
+
}
|
|
8
|
+
if (isValidSchedule(disabled_day)) {
|
|
9
|
+
return isInPeriod(disabled_day, date.toDate());
|
|
10
|
+
}
|
|
11
|
+
return date.isSame(disabled_day, "date");
|
|
15
12
|
};
|
|
16
13
|
export {
|
|
17
14
|
includesDate
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const isBetween = (function(_o, c, d) {
|
|
2
2
|
c.prototype.isBetween = function(a, b, u, i) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const dA = d(a);
|
|
4
|
+
const dB = d(b);
|
|
5
5
|
i = i || "()";
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const dAi = i[0] === "(";
|
|
7
|
+
const dBi = i[1] === ")";
|
|
8
8
|
return (dAi ? this.isAfter(dA, u) : !this.isBefore(dA, u)) && (dBi ? this.isBefore(dB, u) : !this.isAfter(dB, u)) || (dAi ? this.isBefore(dA, u) : !this.isAfter(dA, u)) && (dBi ? this.isAfter(dB, u) : !this.isBefore(dB, u));
|
|
9
9
|
};
|
|
10
10
|
});
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
1
|
import dayjs from "dayjs";
|
|
3
|
-
var _excluded = ["locale"], _excluded2 = ["year"];
|
|
4
2
|
function getDayJSLocale(locale) {
|
|
5
3
|
if (locale.includes("en") || locale.includes("ja")) {
|
|
6
4
|
return "en";
|
|
7
5
|
}
|
|
8
6
|
return "ru";
|
|
9
7
|
}
|
|
10
|
-
function shortDateRangeFormat(dates,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
function shortDateRangeFormat(dates, {
|
|
9
|
+
locale = "en-US",
|
|
10
|
+
...options
|
|
11
|
+
}) {
|
|
12
|
+
const {
|
|
13
|
+
format
|
|
14
|
+
} = new Intl.DateTimeFormat(locale, options);
|
|
15
|
+
const normalizeDates = dates.map((date) => dayjs(date).toDate());
|
|
16
|
+
const monthsYears = dates.map((date) => [dayjs(date).date(), dayjs(date).month(), dayjs(date).year()]);
|
|
19
17
|
if (monthsYears.length > 1) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const isSimilarDay = monthsYears[0][0] === monthsYears[1][0];
|
|
19
|
+
const isSimilarMonth = monthsYears[0][1] === monthsYears[1][1];
|
|
20
|
+
const isSimilarYear = monthsYears[0][2] === monthsYears[1][2];
|
|
23
21
|
if (isSimilarMonth && isSimilarYear && !options.day) {
|
|
24
22
|
return format(normalizeDates[0]);
|
|
25
23
|
}
|
|
26
24
|
if (isSimilarMonth && isSimilarYear) {
|
|
27
25
|
if (getDayJSLocale(locale) === "en") {
|
|
28
26
|
if (isSimilarDay) {
|
|
29
|
-
return
|
|
27
|
+
return `${new Intl.DateTimeFormat(locale, {
|
|
30
28
|
month: options.month
|
|
31
|
-
}).format(normalizeDates[0])
|
|
29
|
+
}).format(normalizeDates[0])} ${normalizeDates[0].getDate()}, ${normalizeDates[0].getFullYear()}`;
|
|
32
30
|
}
|
|
33
|
-
return
|
|
31
|
+
return `${new Intl.DateTimeFormat(locale, {
|
|
34
32
|
month: options.month
|
|
35
|
-
}).format(normalizeDates[0])
|
|
33
|
+
}).format(normalizeDates[0])} ${normalizeDates[0].getDate()}-${normalizeDates[1].getDate()}, ${normalizeDates[0].getFullYear()}`;
|
|
36
34
|
}
|
|
37
35
|
if (isSimilarDay) {
|
|
38
|
-
return
|
|
36
|
+
return `${normalizeDates[0].getDate()} ${new Intl.DateTimeFormat(locale, {
|
|
39
37
|
month: options.month
|
|
40
|
-
}).format(normalizeDates[0])
|
|
38
|
+
}).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;
|
|
41
39
|
}
|
|
42
|
-
return
|
|
40
|
+
return `${normalizeDates[0].getDate()}-${normalizeDates[1].getDate()} ${new Intl.DateTimeFormat(locale, {
|
|
43
41
|
month: options.month
|
|
44
|
-
}).format(normalizeDates[0])
|
|
42
|
+
}).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;
|
|
45
43
|
}
|
|
46
44
|
if (isSimilarYear) {
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const {
|
|
46
|
+
year: _year,
|
|
47
|
+
...newOptions
|
|
48
|
+
} = options;
|
|
49
49
|
if (getDayJSLocale(locale) === "en") {
|
|
50
|
-
return
|
|
50
|
+
return `${new Intl.DateTimeFormat(locale, newOptions).format(normalizeDates[0])}-${new Intl.DateTimeFormat(locale, newOptions).format(normalizeDates[1])}, ${normalizeDates[0].getFullYear()}`;
|
|
51
51
|
}
|
|
52
|
-
return
|
|
52
|
+
return `${new Intl.DateTimeFormat(locale, newOptions).format(normalizeDates[0])}-${new Intl.DateTimeFormat(locale, newOptions).format(normalizeDates[1])} ${normalizeDates[0].getFullYear()}`;
|
|
53
53
|
}
|
|
54
|
-
return
|
|
54
|
+
return `${format(normalizeDates[0])}-${format(normalizeDates[1])}`;
|
|
55
55
|
}
|
|
56
56
|
return format(normalizeDates[0]);
|
|
57
57
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Flex, Box, BoxProps } from '@semcore/base-components';
|
|
2
|
+
import type Popper from '@semcore/base-components';
|
|
1
3
|
import type { BaseTriggerProps } from '@semcore/base-trigger';
|
|
2
4
|
import type BaseTrigger from '@semcore/base-trigger';
|
|
3
5
|
import type { ButtonProps } from '@semcore/button';
|
|
@@ -7,11 +9,9 @@ import type { UnknownProperties, Intergalactic, PropGetterFn } from '@semcore/co
|
|
|
7
9
|
import type { WithI18nEnhanceProps } from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
8
10
|
import type Divider from '@semcore/divider';
|
|
9
11
|
import type { DropdownProps, DropdownTriggerProps } from '@semcore/dropdown';
|
|
10
|
-
import type { Flex, Box, BoxProps } from '@semcore/flex-box';
|
|
11
12
|
import type { InputProps, InputValueProps } from '@semcore/input';
|
|
12
13
|
import type Input from '@semcore/input';
|
|
13
14
|
import type { InputMaskValueProps } from '@semcore/input-mask';
|
|
14
|
-
import type Popper from '@semcore/popper';
|
|
15
15
|
import type { TooltipProps } from '@semcore/tooltip';
|
|
16
16
|
import type dayjs from 'dayjs';
|
|
17
17
|
import type { ChangeEvent } from 'react';
|
|
@@ -25,8 +25,6 @@ export type DateConstructorParams = string | number | Date;
|
|
|
25
25
|
* */
|
|
26
26
|
export type DisabledDates = (DateConstructorParams | (DateConstructorParams | false)[] | string)[];
|
|
27
27
|
|
|
28
|
-
/** @deprecated */
|
|
29
|
-
export interface ICalendarProps extends CalendarProps, UnknownProperties {}
|
|
30
28
|
export type CalendarProps = BoxProps & {
|
|
31
29
|
/**
|
|
32
30
|
* Locale for displaying the days of a week and months, to be transferred to `Intl`
|
|
@@ -58,20 +56,14 @@ export type CalendarProps = BoxProps & {
|
|
|
58
56
|
renderOutdated?: boolean;
|
|
59
57
|
};
|
|
60
58
|
|
|
61
|
-
/** @deprecated */
|
|
62
|
-
export interface ICalendarDaysContext extends CalendarDaysContext, UnknownProperties {}
|
|
63
59
|
export type CalendarDaysContext = {
|
|
64
60
|
days: CalendarUnitProps[];
|
|
65
61
|
};
|
|
66
62
|
|
|
67
|
-
/** @deprecated */
|
|
68
|
-
export interface ICalendarMonthsContext extends CalendarMonthsContext, UnknownProperties {}
|
|
69
63
|
export type CalendarMonthsContext = {
|
|
70
64
|
months: CalendarUnitProps[];
|
|
71
65
|
};
|
|
72
66
|
|
|
73
|
-
/** @deprecated */
|
|
74
|
-
export interface ICalendarUnitProps extends CalendarUnitProps, UnknownProperties {}
|
|
75
67
|
export type CalendarUnitProps = BoxProps & {
|
|
76
68
|
/** Indicates if the calendar unit is part of a selected date range */
|
|
77
69
|
selected?: boolean;
|
|
@@ -97,8 +89,6 @@ export type CalendarUnitProps = BoxProps & {
|
|
|
97
89
|
children?: React.ReactNode;
|
|
98
90
|
};
|
|
99
91
|
|
|
100
|
-
/** @deprecated */
|
|
101
|
-
export interface ICalendarContext extends CalendarContext, UnknownProperties {}
|
|
102
92
|
export type CalendarContext = {
|
|
103
93
|
getUnitProps: PropGetterFn;
|
|
104
94
|
};
|
|
@@ -112,8 +102,6 @@ declare const Calendar: Intergalactic.Component<
|
|
|
112
102
|
Unit: Intergalactic.Component<'div', CalendarUnitProps>;
|
|
113
103
|
};
|
|
114
104
|
|
|
115
|
-
/** @deprecated */
|
|
116
|
-
export interface IDatePickerProps extends DatePickerProps, UnknownProperties {}
|
|
117
105
|
export type DatePickerProps = Intergalactic.InternalTypings.EfficientOmit<
|
|
118
106
|
DropdownProps,
|
|
119
107
|
'disabled'
|
|
@@ -167,8 +155,6 @@ WithI18nEnhanceProps & {
|
|
|
167
155
|
defaultHighlighted?: DateConstructorParams[];
|
|
168
156
|
};
|
|
169
157
|
|
|
170
|
-
/** @deprecated */
|
|
171
|
-
export interface IDateRangePickerProps extends DateRangePickerProps, UnknownProperties {}
|
|
172
158
|
export type DateRangePickerProps = Intergalactic.InternalTypings.EfficientOmit<
|
|
173
159
|
DropdownProps,
|
|
174
160
|
'disabled'
|
|
@@ -239,10 +225,6 @@ WithI18nEnhanceProps & {
|
|
|
239
225
|
periods?: (ButtonProps & { value: Date[] })[];
|
|
240
226
|
};
|
|
241
227
|
|
|
242
|
-
/** @deprecated */
|
|
243
|
-
export interface IDateRangePickerPeriodProps
|
|
244
|
-
extends DateRangePickerPeriodProps,
|
|
245
|
-
UnknownProperties {}
|
|
246
228
|
export type DateRangePickerPeriodProps = BoxProps & {
|
|
247
229
|
/**
|
|
248
230
|
* Current selected period
|
|
@@ -268,8 +250,6 @@ export type DateRangePickerPeriodProps = BoxProps & {
|
|
|
268
250
|
periods?: (ButtonProps & { value: Date[] })[];
|
|
269
251
|
};
|
|
270
252
|
|
|
271
|
-
/** @deprecated */
|
|
272
|
-
export interface IDatePickerContext extends DatePickerContext, UnknownProperties {}
|
|
273
253
|
export type DatePickerContext = {
|
|
274
254
|
getTriggerProps: PropGetterFn;
|
|
275
255
|
getPopperProps: PropGetterFn;
|
|
@@ -281,10 +261,6 @@ export type DatePickerContext = {
|
|
|
281
261
|
getTodayProps: PropGetterFn;
|
|
282
262
|
};
|
|
283
263
|
|
|
284
|
-
/** @deprecated */
|
|
285
|
-
export interface IAbstractDatePickerHandlers
|
|
286
|
-
extends AbstractDatePickerHandlers,
|
|
287
|
-
UnknownProperties {}
|
|
288
264
|
export type AbstractDatePickerHandlers = {
|
|
289
265
|
displayedPeriod: (value: DateConstructorParams) => void;
|
|
290
266
|
visible: (index: boolean) => void;
|
|
@@ -292,14 +268,10 @@ export type AbstractDatePickerHandlers = {
|
|
|
292
268
|
value: (index: DateConstructorParams) => void;
|
|
293
269
|
};
|
|
294
270
|
|
|
295
|
-
/** @deprecated */
|
|
296
|
-
export interface IDatePickerHandlers extends DatePickerHandlers, UnknownProperties {}
|
|
297
271
|
export type DatePickerHandlers = {
|
|
298
272
|
visible: (index: boolean) => void;
|
|
299
273
|
};
|
|
300
274
|
|
|
301
|
-
/** @deprecated */
|
|
302
|
-
export interface IInputTriggerProps extends InputTriggerProps, UnknownProperties {}
|
|
303
275
|
export type BaseInputTriggerProps = InputProps &
|
|
304
276
|
TooltipProps & {
|
|
305
277
|
/**
|
|
@@ -322,18 +294,10 @@ export type RangeInputTriggerProps = BaseInputTriggerProps & {
|
|
|
322
294
|
onChange?: (date: Date[], event: ChangeEvent) => void;
|
|
323
295
|
};
|
|
324
296
|
|
|
325
|
-
/** @deprecated */
|
|
326
|
-
export interface ISingleDateInputProps extends SingleDateInputProps, UnknownProperties {}
|
|
327
297
|
export type SingleDateInputProps = InputTriggerProps & {};
|
|
328
298
|
|
|
329
|
-
/** @deprecated */
|
|
330
|
-
export interface IDateRangeProps extends DateRangeProps, UnknownProperties {}
|
|
331
299
|
export type DateRangeProps = RangeInputTriggerProps & {};
|
|
332
300
|
|
|
333
|
-
/** @deprecated */
|
|
334
|
-
export interface IDatePickerMaskedInputProps
|
|
335
|
-
extends DatePickerMaskedInputProps,
|
|
336
|
-
UnknownProperties {}
|
|
337
301
|
export type DatePickerMaskedInputProps = {
|
|
338
302
|
date?: Date;
|
|
339
303
|
onDateChange?: (date: Date, event: ChangeEvent) => void;
|
|
@@ -397,8 +361,6 @@ declare const DatePicker: Intergalactic.Component<
|
|
|
397
361
|
subtract: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
398
362
|
};
|
|
399
363
|
|
|
400
|
-
/** @deprecated */
|
|
401
|
-
export interface IDateRangePickerContext extends DateRangePickerContext, UnknownProperties {}
|
|
402
364
|
export type DateRangePickerContext = {
|
|
403
365
|
getTriggerProps: PropGetterFn;
|
|
404
366
|
getPopperProps: PropGetterFn;
|
|
@@ -435,8 +397,6 @@ declare const DateRangePicker: Intergalactic.Component<
|
|
|
435
397
|
subtract: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
436
398
|
};
|
|
437
399
|
|
|
438
|
-
/** @deprecated */
|
|
439
|
-
export interface IMonthPickerContext extends MonthPickerContext, UnknownProperties {}
|
|
440
400
|
export type MonthPickerContext = {
|
|
441
401
|
getTriggerProps: PropGetterFn;
|
|
442
402
|
getPopperProps: PropGetterFn;
|
|
@@ -469,8 +429,6 @@ declare const MonthPicker: Intergalactic.Component<
|
|
|
469
429
|
subtract: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
470
430
|
};
|
|
471
431
|
|
|
472
|
-
/** @deprecated */
|
|
473
|
-
export interface IMonthRangePickerContext extends MonthRangePickerContext, UnknownProperties {}
|
|
474
432
|
export type MonthRangePickerContext = {
|
|
475
433
|
getTriggerProps: PropGetterFn;
|
|
476
434
|
getPopperProps: PropGetterFn;
|