@semcore/date-picker 2.8.1 → 2.8.4
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 +18 -0
- package/lib/cjs/DatePicker.js +1 -1
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangePicker.js.map +1 -1
- package/lib/cjs/MonthPicker.js.map +1 -1
- package/lib/cjs/MonthRangePicker.js.map +1 -1
- package/lib/cjs/components/ButtonTrigger.js +3 -9
- package/lib/cjs/components/ButtonTrigger.js.map +1 -1
- package/lib/cjs/components/Calendar.js +5 -5
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +1 -2
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +2 -4
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +15 -20
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/index.d.ts +355 -0
- package/lib/cjs/index.js +5 -39
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/shortDateRangeFormat.js +1 -0
- package/lib/cjs/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/es6/DatePicker.js +1 -1
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangePicker.js.map +1 -1
- package/lib/es6/MonthPicker.js.map +1 -1
- package/lib/es6/MonthRangePicker.js.map +1 -1
- package/lib/es6/components/ButtonTrigger.js +3 -9
- package/lib/es6/components/ButtonTrigger.js.map +1 -1
- package/lib/es6/components/Calendar.js +5 -5
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +1 -2
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +2 -4
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +15 -20
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/index.d.ts +355 -0
- package/lib/es6/index.js +0 -3
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/utils/shortDateRangeFormat.js +1 -0
- package/lib/es6/utils/shortDateRangeFormat.js.map +1 -1
- package/package.json +5 -2
- package/src/{DatePicker.js → DatePicker.jsx} +0 -0
- package/src/{DateRangePicker.js → DateRangePicker.jsx} +0 -0
- package/src/{MonthPicker.js → MonthPicker.jsx} +0 -0
- package/src/{MonthRangePicker.js → MonthRangePicker.jsx} +0 -0
- package/src/components/{ButtonTrigger.js → ButtonTrigger.jsx} +2 -3
- package/src/components/{Calendar.js → Calendar.jsx} +0 -0
- package/src/components/{PickerAbstract.js → PickerAbstract.jsx} +0 -1
- package/src/components/{RangePickerAbstract.js → RangePickerAbstract.jsx} +2 -8
- package/src/components/{index.js → index.jsx} +2 -8
- package/src/index.js +0 -3
- package/src/utils/shortDateRangeFormat.js +1 -0
|
@@ -53,8 +53,6 @@ var _ButtonTrigger = _interopRequireDefault(require("./ButtonTrigger"));
|
|
|
53
53
|
|
|
54
54
|
var _excluded = ["value", "onClick", "onMouseEnter", "onMouseLeave"];
|
|
55
55
|
|
|
56
|
-
var _this = void 0;
|
|
57
|
-
|
|
58
56
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
59
57
|
|
|
60
58
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
@@ -64,15 +62,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
64
62
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
65
63
|
|
|
66
64
|
function Trigger() {
|
|
67
|
-
var _ref =
|
|
68
|
-
|
|
65
|
+
var _ref = arguments[0];
|
|
69
66
|
return /*#__PURE__*/_react["default"].createElement(_dropdown["default"].Trigger, (0, _core.assignProps)({
|
|
70
67
|
"tag": _ButtonTrigger["default"]
|
|
71
68
|
}, _ref));
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
function Popper(props) {
|
|
75
|
-
var _ref2 =
|
|
72
|
+
var _ref2 = arguments[0],
|
|
76
73
|
_ref8;
|
|
77
74
|
|
|
78
75
|
var SPopper = _dropdown["default"].Popper;
|
|
@@ -83,7 +80,7 @@ function Popper(props) {
|
|
|
83
80
|
}
|
|
84
81
|
|
|
85
82
|
function Header(props) {
|
|
86
|
-
var _ref3 =
|
|
83
|
+
var _ref3 = arguments[0],
|
|
87
84
|
_ref9;
|
|
88
85
|
|
|
89
86
|
var SHeader = _flexBox.Box;
|
|
@@ -91,7 +88,7 @@ function Header(props) {
|
|
|
91
88
|
}
|
|
92
89
|
|
|
93
90
|
var Title = function Title(_ref12) {
|
|
94
|
-
var _ref4 =
|
|
91
|
+
var _ref4 = arguments[0],
|
|
95
92
|
_ref10;
|
|
96
93
|
|
|
97
94
|
var Children = _ref12.Children,
|
|
@@ -103,8 +100,7 @@ var Title = function Title(_ref12) {
|
|
|
103
100
|
exports.Title = Title;
|
|
104
101
|
|
|
105
102
|
function Prev() {
|
|
106
|
-
var _ref5 =
|
|
107
|
-
|
|
103
|
+
var _ref5 = arguments[0];
|
|
108
104
|
return /*#__PURE__*/_react["default"].createElement(_button["default"], (0, _core.assignProps)({
|
|
109
105
|
"use": "tertiary",
|
|
110
106
|
"theme": "muted",
|
|
@@ -119,8 +115,7 @@ Prev.defaultProps = {
|
|
|
119
115
|
};
|
|
120
116
|
|
|
121
117
|
function Next() {
|
|
122
|
-
var _ref6 =
|
|
123
|
-
|
|
118
|
+
var _ref6 = arguments[0];
|
|
124
119
|
return /*#__PURE__*/_react["default"].createElement(_button["default"], (0, _core.assignProps)({
|
|
125
120
|
"use": "tertiary",
|
|
126
121
|
"theme": "muted",
|
|
@@ -137,12 +132,12 @@ var stylesBtn = (
|
|
|
137
132
|
/*__reshadow_css_start__*/
|
|
138
133
|
_core.sstyled.insert(
|
|
139
134
|
/*__inner_css_start__*/
|
|
140
|
-
".
|
|
135
|
+
".___SInner_1td0i_gg_{justify-content:flex-start}"
|
|
141
136
|
/*__inner_css_end__*/
|
|
142
137
|
, "rfgf9b_gg_")
|
|
143
138
|
/*__reshadow_css_end__*/
|
|
144
139
|
, {
|
|
145
|
-
"__SInner": "
|
|
140
|
+
"__SInner": "___SInner_1td0i_gg_"
|
|
146
141
|
});
|
|
147
142
|
|
|
148
143
|
var Period = /*#__PURE__*/function (_Component) {
|
|
@@ -151,7 +146,7 @@ var Period = /*#__PURE__*/function (_Component) {
|
|
|
151
146
|
var _super = _createSuper(Period);
|
|
152
147
|
|
|
153
148
|
function Period() {
|
|
154
|
-
var
|
|
149
|
+
var _this;
|
|
155
150
|
|
|
156
151
|
(0, _classCallCheck2["default"])(this, Period);
|
|
157
152
|
|
|
@@ -159,8 +154,8 @@ var Period = /*#__PURE__*/function (_Component) {
|
|
|
159
154
|
args[_key] = arguments[_key];
|
|
160
155
|
}
|
|
161
156
|
|
|
162
|
-
|
|
163
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(
|
|
157
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
158
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getActiveControl", function () {
|
|
164
159
|
var period = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
165
160
|
var value = arguments.length > 1 ? arguments[1] : undefined;
|
|
166
161
|
|
|
@@ -177,15 +172,15 @@ var Period = /*#__PURE__*/function (_Component) {
|
|
|
177
172
|
|
|
178
173
|
return compareMonth(period[0], value);
|
|
179
174
|
});
|
|
180
|
-
return
|
|
175
|
+
return _this;
|
|
181
176
|
}
|
|
182
177
|
|
|
183
178
|
(0, _createClass2["default"])(Period, [{
|
|
184
179
|
key: "render",
|
|
185
180
|
value: function render() {
|
|
186
|
-
var _ref7 = this
|
|
181
|
+
var _ref7 = this.asProps,
|
|
187
182
|
_ref11,
|
|
188
|
-
|
|
183
|
+
_this2 = this;
|
|
189
184
|
|
|
190
185
|
var SPeriod = _flexBox.Box;
|
|
191
186
|
var _this$asProps = this.asProps,
|
|
@@ -206,7 +201,7 @@ var Period = /*#__PURE__*/function (_Component) {
|
|
|
206
201
|
theme: "muted",
|
|
207
202
|
styles: stylesBtn,
|
|
208
203
|
key: i,
|
|
209
|
-
active:
|
|
204
|
+
active: _this2.getActiveControl(period, value),
|
|
210
205
|
onClick: (0, _assignProps8.callAllEventHandlers)(onClick, function () {
|
|
211
206
|
return onChange(period);
|
|
212
207
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/index.
|
|
1
|
+
{"version":3,"sources":["../../../src/components/index.jsx"],"names":["Trigger","Dropdown","ButtonTrigger","Popper","props","SPopper","styles","Header","SHeader","Box","Title","Children","STitle","Prev","Button","defaultProps","children","Next","stylesBtn","sstyled","Period","period","value","compareMonth","monthOne","monthTwo","isSame","Array","isArray","length","SPeriod","asProps","onChange","periods","onHighlightedChange","onDisplayedPeriodChange","map","i","onClick","onMouseEnter","onMouseLeave","other","getActiveControl","toDate","Date","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AAFA;;AAC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A,uBAA/D;AAGA,sBAAO,mBAAQ7B,MAAR,CAAP,eACE,gCAAC,OAAD,8EACG2B,OAAO,CAACG,GAAR,CAAY,kBAAmEC,CAAnE;AAAA,YAAUhB,MAAV,UAAGC,KAAH;AAAA,YAAkBgB,OAAlB,UAAkBA,OAAlB;AAAA,YAA2BC,YAA3B,UAA2BA,YAA3B;AAAA,YAAyCC,YAAzC,UAAyCA,YAAzC;AAAA,YAA0DC,KAA1D;AAAA,4BACX,gCAAC,kBAAD;AACE,UAAA,GAAG,EAAC,UADN;AAEE,UAAA,KAAK,EAAC,OAFR;AAGE,UAAA,MAAM,EAAEvB,SAHV;AAIE,UAAA,GAAG,EAAEmB,CAJP;AAKE,UAAA,MAAM,EAAE,MAAI,CAACK,gBAAL,CAAsBrB,MAAtB,EAA8BC,KAA9B,CALV;AAME,UAAA,OAAO,EAAE,wCAAqBgB,OAArB,EAA8B;AAAA,mBAAMN,QAAQ,CAACX,MAAD,CAAd;AAAA,WAA9B,CANX;AAOE,UAAA,YAAY,EAAE,wCAAqBkB,YAArB,EAAmC,YAAM;AACrDL,YAAAA,mBAAmB,CAACb,MAAD,CAAnB;AACAc,YAAAA,uBAAuB,CAAC,uBAAMd,MAAM,CAAC,CAAD,CAAZ,EAAiBsB,MAAjB,EAAD,CAAvB;AACD,WAHa,CAPhB;AAWE,UAAA,YAAY,EAAE,wCAAqBH,YAArB,EAAmC,YAAM;AACrDN,YAAAA,mBAAmB,CAAC,EAAD,CAAnB;AACAC,YAAAA,uBAAuB,CAACb,KAAK,CAAC,CAAD,CAAL,GAAW,uBAAMA,KAAK,CAAC,CAAD,CAAX,EAAgBqB,MAAhB,EAAX,GAAsC,IAAIC,IAAJ,EAAvC,CAAvB;AACD,WAHa;AAXhB,WAeMH,KAfN,EADW;AAAA,OAAZ,CADH,CADF;AAuBD;;;EA3CyBI,e","sourcesContent":["import React from 'react';\nimport dayjs from 'dayjs';\nimport { Component, Root, sstyled } from '@semcore/core';\nimport Dropdown from '@semcore/dropdown';\nimport { Box } from '@semcore/flex-box';\nimport Button from '@semcore/button';\nimport ChevronLeft from '@semcore/icon/ChevronLeft/m';\nimport ChevronRight from '@semcore/icon/ChevronRight/m';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\nimport ButtonTrigger from './ButtonTrigger';\n\nexport function Trigger() {\n return <Root render={Dropdown.Trigger} tag={ButtonTrigger} />;\n}\n\nexport function Popper(props) {\n const SPopper = Root;\n return sstyled(props.styles)(\n <SPopper render={Dropdown.Popper} role=\"region\" aria-label=\"calendar-container\" />,\n );\n}\n\nexport function Header(props) {\n const SHeader = Root;\n return sstyled(props.styles)(<SHeader render={Box} />);\n}\n\nexport const Title = ({ Children, styles }) => {\n const STitle = Root;\n return sstyled(styles)(\n <STitle render={Box}>\n <Children />\n </STitle>,\n );\n};\n\nexport function Prev() {\n return (\n <Root\n render={Button}\n use=\"tertiary\"\n theme=\"muted\"\n size=\"l\"\n tabIndex={-1}\n aria-label=\"Prev period\"\n />\n );\n}\n\nPrev.defaultProps = {\n children: <ChevronLeft />,\n};\n\nexport function Next() {\n return (\n <Root\n render={Button}\n use=\"tertiary\"\n theme=\"muted\"\n size=\"l\"\n tabIndex={-1}\n aria-label=\"Next period\"\n />\n );\n}\n\nNext.defaultProps = {\n children: <ChevronRight />,\n};\n\nconst stylesBtn = sstyled.css`\n SInner {\n justify-content: flex-start;\n }\n`;\n\nexport class Period extends Component {\n getActiveControl = (period = [], value) => {\n function compareMonth(monthOne, monthTwo) {\n return dayjs(monthOne).isSame(dayjs(monthTwo), 'date');\n }\n\n if (!period || !value) return false;\n if (Array.isArray(value) && period.length !== value.length) return false;\n if (Array.isArray(value)) {\n return compareMonth(period[0], value[0]) && compareMonth(period[1], value[1]);\n }\n\n return compareMonth(period[0], value);\n };\n\n render() {\n const SPeriod = Root;\n const { styles, value, onChange, periods, onHighlightedChange, onDisplayedPeriodChange } =\n this.asProps;\n\n return sstyled(styles)(\n <SPeriod render={Box}>\n {periods.map(({ value: period, onClick, onMouseEnter, onMouseLeave, ...other }, i) => (\n <Button\n use=\"tertiary\"\n theme=\"muted\"\n styles={stylesBtn}\n key={i}\n active={this.getActiveControl(period, value)}\n onClick={callAllEventHandlers(onClick, () => onChange(period))}\n onMouseEnter={callAllEventHandlers(onMouseEnter, () => {\n onHighlightedChange(period);\n onDisplayedPeriodChange(dayjs(period[0]).toDate());\n })}\n onMouseLeave={callAllEventHandlers(onMouseLeave, () => {\n onHighlightedChange([]);\n onDisplayedPeriodChange(value[0] ? dayjs(value[0]).toDate() : new Date());\n })}\n {...other}\n />\n ))}\n </SPeriod>,\n );\n }\n}\n"],"file":"index.js"}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import React, { ComponentProps } from 'react';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { Box, IBoxProps } from '@semcore/flex-box';
|
|
4
|
+
import Button from '@semcore/button';
|
|
5
|
+
import { CProps, Merge, PropGetterFn, ReturnEl } from '@semcore/core';
|
|
6
|
+
import Dropdown, { IDropdownProps } from '@semcore/dropdown';
|
|
7
|
+
import { IWithI18nEnhanceProps } from '@semcore/utils/lib/enhances/i18nEnhance';
|
|
8
|
+
import BaseTrigger from '@semcore/base-trigger';
|
|
9
|
+
|
|
10
|
+
export type DateConstructorParams = string | number | Date;
|
|
11
|
+
|
|
12
|
+
export interface ICalendarProps extends IBoxProps {
|
|
13
|
+
/**
|
|
14
|
+
* Locale for displaying the days of a week and months, to be transferred to `Intl`
|
|
15
|
+
* @default en
|
|
16
|
+
* */
|
|
17
|
+
locale?: NavigatorLanguage['language'];
|
|
18
|
+
/**
|
|
19
|
+
* Array of dates blocked for selection
|
|
20
|
+
* Accepts the date, the range of dates or `falsICalendarPropse` for specifying infinity ([Date | false, Date | false]), crontab( 6,7)
|
|
21
|
+
* */
|
|
22
|
+
disabled?: (Date | (Date | false)[] | string)[];
|
|
23
|
+
/**
|
|
24
|
+
* @ignore
|
|
25
|
+
* */
|
|
26
|
+
highlighted?: DateConstructorParams[];
|
|
27
|
+
/**
|
|
28
|
+
* @ignore
|
|
29
|
+
* */
|
|
30
|
+
onHighlightedChange?: (date: Date[]) => void;
|
|
31
|
+
/**
|
|
32
|
+
* The selected date, accepts everything which is accepted by `new Date()`
|
|
33
|
+
* */
|
|
34
|
+
value?: DateConstructorParams[];
|
|
35
|
+
/**
|
|
36
|
+
* To be activated upon selecting the date
|
|
37
|
+
* */
|
|
38
|
+
onChange?: (date: Date[]) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Date for showing the necessary month
|
|
41
|
+
* @default new Date()
|
|
42
|
+
* */
|
|
43
|
+
displayedPeriod?: Date;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ICalendarDaysContext {
|
|
47
|
+
days: ICalendarUnitProps[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ICalendarMonthsContext {
|
|
51
|
+
months: ICalendarUnitProps[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ICalendarUnitProps extends IBoxProps {
|
|
55
|
+
selected?: boolean;
|
|
56
|
+
outdated?: boolean;
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
today?: boolean;
|
|
59
|
+
startSelected?: boolean;
|
|
60
|
+
endSelected?: boolean;
|
|
61
|
+
highlighted?: boolean;
|
|
62
|
+
startHighlighted?: boolean;
|
|
63
|
+
endHighlighted?: boolean;
|
|
64
|
+
children?: React.ReactNode;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ICalendarContext {
|
|
68
|
+
getUnitProps: PropGetterFn;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare const Calendar: (<T>(
|
|
72
|
+
props: CProps<ICalendarProps & T, ICalendarContext, IAbstractDatePickerHandlers>,
|
|
73
|
+
) => ReturnEl) & {
|
|
74
|
+
Unit: <T>(props: ICalendarUnitProps & T) => ReturnEl;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export interface IDatePickerProps extends IDropdownProps, IWithI18nEnhanceProps {
|
|
78
|
+
/**
|
|
79
|
+
* The selected date, accepts everything which is accepted by `new Date()`
|
|
80
|
+
* */
|
|
81
|
+
value?: DateConstructorParams;
|
|
82
|
+
/**
|
|
83
|
+
* To be activated upon selecting the date
|
|
84
|
+
* */
|
|
85
|
+
onChange?: (date: Date) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Array of dates blocked for selection
|
|
88
|
+
* */
|
|
89
|
+
disabled?: (Date | (Date | false)[] | string)[];
|
|
90
|
+
/**
|
|
91
|
+
* Date for showing the necessary month
|
|
92
|
+
* @default new Date()
|
|
93
|
+
* */
|
|
94
|
+
displayedPeriod?: DateConstructorParams;
|
|
95
|
+
/**
|
|
96
|
+
* To be activated upon changing the current shown month
|
|
97
|
+
* */
|
|
98
|
+
onDisplayedPeriodChange?: (date: Date) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Component size
|
|
101
|
+
* @default m
|
|
102
|
+
*/
|
|
103
|
+
size?: 'm' | 'l' | 'xl';
|
|
104
|
+
/**
|
|
105
|
+
* The selected date, accepts everything which is accepted by `new Date()`
|
|
106
|
+
* */
|
|
107
|
+
highlighted?: DateConstructorParams[];
|
|
108
|
+
/**
|
|
109
|
+
* Default value selected date, accepts everything which is accepted by `new Date()`
|
|
110
|
+
* */
|
|
111
|
+
defaultValue?: DateConstructorParams;
|
|
112
|
+
/**
|
|
113
|
+
* Default value date for showing the necessary month
|
|
114
|
+
* */
|
|
115
|
+
defaultDisplayedPeriod?: DateConstructorParams;
|
|
116
|
+
/**
|
|
117
|
+
* Default value selected date, accepts everything which is accepted by `new Date()`
|
|
118
|
+
* */
|
|
119
|
+
defaultHighlighted?: DateConstructorParams[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface IDateRangePickerProps extends IDropdownProps, IWithI18nEnhanceProps {
|
|
123
|
+
/**
|
|
124
|
+
* The selected date, accepts everything which is accepted by `new Date()`
|
|
125
|
+
* */
|
|
126
|
+
value?: DateConstructorParams[];
|
|
127
|
+
/**
|
|
128
|
+
* Default value selected date, accepts everything which is accepted by `new Date()`
|
|
129
|
+
* */
|
|
130
|
+
defaultValue?: DateConstructorParams[];
|
|
131
|
+
/**
|
|
132
|
+
* Default value date for showing the necessary month
|
|
133
|
+
* */
|
|
134
|
+
defaultDisplayedPeriod?: DateConstructorParams;
|
|
135
|
+
/**
|
|
136
|
+
* Default value selected date, accepts everything which is accepted by `new Date()`
|
|
137
|
+
* */
|
|
138
|
+
defaultHighlighted?: DateConstructorParams[];
|
|
139
|
+
/**
|
|
140
|
+
* To be activated upon selecting the date
|
|
141
|
+
* */
|
|
142
|
+
onChange?: (date: Date[]) => void;
|
|
143
|
+
/**
|
|
144
|
+
* Array of dates blocked for selection
|
|
145
|
+
* */
|
|
146
|
+
disabled?: (Date | (Date | false)[] | string)[];
|
|
147
|
+
/**
|
|
148
|
+
* Date for showing the necessary month
|
|
149
|
+
* @default new Date()
|
|
150
|
+
* */
|
|
151
|
+
displayedPeriod?: DateConstructorParams;
|
|
152
|
+
/**
|
|
153
|
+
* To be activated upon changing the current shown month
|
|
154
|
+
* */
|
|
155
|
+
onDisplayedPeriodChange?: (date: Date) => void;
|
|
156
|
+
/**
|
|
157
|
+
* Component size
|
|
158
|
+
* @default m
|
|
159
|
+
*/
|
|
160
|
+
size?: 'm' | 'l' | 'xl';
|
|
161
|
+
/**
|
|
162
|
+
* The selected date, accepts everything which is accepted by `new Date()`
|
|
163
|
+
* */
|
|
164
|
+
highlighted?: DateConstructorParams[];
|
|
165
|
+
/**
|
|
166
|
+
* Remove the 'Reset' button
|
|
167
|
+
* */
|
|
168
|
+
unclearable?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* To be activated upon selecting the date
|
|
171
|
+
* */
|
|
172
|
+
onHighlightedChange?: (date: Date[]) => void;
|
|
173
|
+
/**
|
|
174
|
+
* Array of periods
|
|
175
|
+
* [{value: [new Date(), new Date()], children: "Today"}]
|
|
176
|
+
* @default Past 2 days / Past week / Past 2 week / Past month / Past 2 month
|
|
177
|
+
* */
|
|
178
|
+
periods?: (ComponentProps<typeof Button> & { value: Date[] })[];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface IDateRangePickerPeriodProps extends IBoxProps {
|
|
182
|
+
/**
|
|
183
|
+
* Current selected period
|
|
184
|
+
* */
|
|
185
|
+
value?: DateConstructorParams[];
|
|
186
|
+
/**
|
|
187
|
+
* To be activated by clicking the button for switching the selected period.
|
|
188
|
+
* */
|
|
189
|
+
onChange?: (date: Date[]) => void;
|
|
190
|
+
/**
|
|
191
|
+
* To be activated by hovering a cursor over the button for changing the current displayed month.
|
|
192
|
+
* */
|
|
193
|
+
onDisplayedPeriodChange?: (date: Date) => void;
|
|
194
|
+
/**
|
|
195
|
+
* To be activated by hovering a cursor over the button for selecting the dates.
|
|
196
|
+
* */
|
|
197
|
+
onHighlightedChange?: (date: Date[]) => void;
|
|
198
|
+
/**
|
|
199
|
+
* Array of periods
|
|
200
|
+
* [{value: [new Date(), new Date()], children: "Today"}]
|
|
201
|
+
* @default Past 2 days / Past week / Past 2 week / Past month / Past 2 month
|
|
202
|
+
* */
|
|
203
|
+
periods?: (ComponentProps<typeof Button> & { value: Date[] })[];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface IDatePickerContext {
|
|
207
|
+
getTriggerProps: PropGetterFn;
|
|
208
|
+
getPopperProps: PropGetterFn;
|
|
209
|
+
getHeaderProps: PropGetterFn;
|
|
210
|
+
getTitleProps: PropGetterFn;
|
|
211
|
+
getNextProps: PropGetterFn;
|
|
212
|
+
getPrevProps: PropGetterFn;
|
|
213
|
+
getCalendarProps: PropGetterFn;
|
|
214
|
+
getTodayProps: PropGetterFn;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface IAbstractDatePickerHandlers {
|
|
218
|
+
displayedPeriod: (value: DateConstructorParams) => void;
|
|
219
|
+
visible: (index: boolean) => void;
|
|
220
|
+
highlighted: (list: DateConstructorParams[]) => void;
|
|
221
|
+
value: (index: DateConstructorParams) => void;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface IDatePickerHandlers {
|
|
225
|
+
visible: (index: boolean) => void;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare const DatePicker: ((
|
|
229
|
+
props: CProps<IDatePickerProps, IDatePickerContext & ICalendarDaysContext, IDatePickerHandlers>,
|
|
230
|
+
) => ReturnEl) & {
|
|
231
|
+
Trigger: (<T>(
|
|
232
|
+
props: Merge<ComponentProps<typeof Dropdown.Trigger>, ComponentProps<typeof BaseTrigger>> & T,
|
|
233
|
+
) => ReturnEl) & {
|
|
234
|
+
Addon: typeof BaseTrigger.Addon;
|
|
235
|
+
Text: typeof BaseTrigger.Text;
|
|
236
|
+
};
|
|
237
|
+
Popper: typeof Dropdown.Popper;
|
|
238
|
+
Header: typeof Box;
|
|
239
|
+
Title: <T>(props: CProps<IDatePickerProps & IBoxProps & T, IDatePickerContext>) => ReturnEl;
|
|
240
|
+
Prev: typeof Button;
|
|
241
|
+
Next: typeof Button;
|
|
242
|
+
Calendar: typeof Calendar;
|
|
243
|
+
Today: typeof Box;
|
|
244
|
+
add: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
245
|
+
subtract: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export interface IDateRangePickerContext {
|
|
249
|
+
getTriggerProps: PropGetterFn;
|
|
250
|
+
getPopperProps: PropGetterFn;
|
|
251
|
+
getHeaderProps: PropGetterFn;
|
|
252
|
+
getTitleProps: PropGetterFn;
|
|
253
|
+
getNextProps: PropGetterFn;
|
|
254
|
+
getPrevProps: PropGetterFn;
|
|
255
|
+
getCalendarProps: PropGetterFn;
|
|
256
|
+
getPeriodProps: PropGetterFn;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
declare const DateRangePicker: ((
|
|
260
|
+
props: CProps<
|
|
261
|
+
IDateRangePickerProps,
|
|
262
|
+
IDateRangePickerContext & ICalendarDaysContext,
|
|
263
|
+
IDatePickerHandlers
|
|
264
|
+
>,
|
|
265
|
+
) => ReturnEl) & {
|
|
266
|
+
Trigger: (<T>(
|
|
267
|
+
props: Merge<ComponentProps<typeof Dropdown.Trigger>, ComponentProps<typeof BaseTrigger>> & T,
|
|
268
|
+
) => ReturnEl) & {
|
|
269
|
+
Addon: typeof BaseTrigger.Addon;
|
|
270
|
+
Text: typeof BaseTrigger.Text;
|
|
271
|
+
};
|
|
272
|
+
Popper: <T>(props: ComponentProps<typeof Dropdown.Popper> & T) => ReturnEl;
|
|
273
|
+
Header: typeof Box;
|
|
274
|
+
Title: <T>(
|
|
275
|
+
props: CProps<IDateRangePickerProps & IBoxProps & T, IDateRangePickerContext>,
|
|
276
|
+
) => ReturnEl;
|
|
277
|
+
Prev: typeof Button;
|
|
278
|
+
Next: typeof Button;
|
|
279
|
+
Calendar: typeof Calendar;
|
|
280
|
+
Period: <T>(props: IDateRangePickerPeriodProps & T) => ReturnEl;
|
|
281
|
+
add: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
282
|
+
subtract: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export interface IMonthPickerContext {
|
|
286
|
+
getTriggerProps: PropGetterFn;
|
|
287
|
+
getPopperProps: PropGetterFn;
|
|
288
|
+
getHeaderProps: PropGetterFn;
|
|
289
|
+
getTitleProps: PropGetterFn;
|
|
290
|
+
getNextProps: PropGetterFn;
|
|
291
|
+
getPrevProps: PropGetterFn;
|
|
292
|
+
getCalendarProps: PropGetterFn;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
declare const MonthPicker: ((
|
|
296
|
+
props: CProps<
|
|
297
|
+
IDatePickerProps,
|
|
298
|
+
IMonthPickerContext & ICalendarMonthsContext,
|
|
299
|
+
IDatePickerHandlers
|
|
300
|
+
>,
|
|
301
|
+
) => ReturnEl) & {
|
|
302
|
+
Trigger: (<T>(
|
|
303
|
+
props: Merge<ComponentProps<typeof Dropdown.Trigger>, ComponentProps<typeof BaseTrigger>> & T,
|
|
304
|
+
) => ReturnEl) & {
|
|
305
|
+
Addon: typeof BaseTrigger.Addon;
|
|
306
|
+
Text: typeof BaseTrigger.Text;
|
|
307
|
+
};
|
|
308
|
+
Popper: typeof Dropdown.Popper;
|
|
309
|
+
Header: typeof Box;
|
|
310
|
+
Title: <T>(props: CProps<IDatePickerProps & IBoxProps & T, IMonthPickerContext>) => ReturnEl;
|
|
311
|
+
Prev: typeof Button;
|
|
312
|
+
Next: typeof Button;
|
|
313
|
+
Calendar: typeof Calendar;
|
|
314
|
+
add: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
315
|
+
subtract: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export interface IMonthRangePickerContext {
|
|
319
|
+
getTriggerProps: PropGetterFn;
|
|
320
|
+
getPopperProps: PropGetterFn;
|
|
321
|
+
getHeaderProps: PropGetterFn;
|
|
322
|
+
getTitleProps: PropGetterFn;
|
|
323
|
+
getNextProps: PropGetterFn;
|
|
324
|
+
getPrevProps: PropGetterFn;
|
|
325
|
+
getCalendarProps: PropGetterFn;
|
|
326
|
+
getPeriodProps: PropGetterFn;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
declare const MonthRangePicker: ((
|
|
330
|
+
props: CProps<
|
|
331
|
+
IDateRangePickerProps,
|
|
332
|
+
IMonthRangePickerContext & ICalendarMonthsContext,
|
|
333
|
+
IDatePickerHandlers
|
|
334
|
+
>,
|
|
335
|
+
) => ReturnEl) & {
|
|
336
|
+
Trigger: (<T>(
|
|
337
|
+
props: Merge<ComponentProps<typeof Dropdown.Trigger>, ComponentProps<typeof BaseTrigger>> & T,
|
|
338
|
+
) => ReturnEl) & {
|
|
339
|
+
Addon: typeof BaseTrigger.Addon;
|
|
340
|
+
Text: typeof BaseTrigger.Text;
|
|
341
|
+
};
|
|
342
|
+
Popper: typeof Dropdown.Popper;
|
|
343
|
+
Header: typeof Box;
|
|
344
|
+
Title: <T>(
|
|
345
|
+
props: CProps<IDateRangePickerProps & IBoxProps & T, IMonthRangePickerContext>,
|
|
346
|
+
) => ReturnEl;
|
|
347
|
+
Prev: typeof Button;
|
|
348
|
+
Next: typeof Button;
|
|
349
|
+
Calendar: typeof Calendar;
|
|
350
|
+
Period: <T>(props: IDateRangePickerPeriodProps & T) => ReturnEl;
|
|
351
|
+
add: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
352
|
+
subtract: (date: number | Date, amount: number, unit: dayjs.OpUnitType) => Date;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export { DatePicker, DateRangePicker, MonthPicker, MonthRangePicker };
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -50,47 +52,11 @@ Object.keys(_DatePicker).forEach(function (key) {
|
|
|
50
52
|
});
|
|
51
53
|
});
|
|
52
54
|
|
|
53
|
-
var _DateRangePicker =
|
|
54
|
-
|
|
55
|
-
Object.keys(_DateRangePicker).forEach(function (key) {
|
|
56
|
-
if (key === "default" || key === "__esModule") return;
|
|
57
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
58
|
-
if (key in exports && exports[key] === _DateRangePicker[key]) return;
|
|
59
|
-
Object.defineProperty(exports, key, {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
get: function get() {
|
|
62
|
-
return _DateRangePicker[key];
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
var _MonthPicker = _interopRequireWildcard(require("./MonthPicker"));
|
|
68
|
-
|
|
69
|
-
Object.keys(_MonthPicker).forEach(function (key) {
|
|
70
|
-
if (key === "default" || key === "__esModule") return;
|
|
71
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
72
|
-
if (key in exports && exports[key] === _MonthPicker[key]) return;
|
|
73
|
-
Object.defineProperty(exports, key, {
|
|
74
|
-
enumerable: true,
|
|
75
|
-
get: function get() {
|
|
76
|
-
return _MonthPicker[key];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
55
|
+
var _DateRangePicker = _interopRequireDefault(require("./DateRangePicker"));
|
|
80
56
|
|
|
81
|
-
var
|
|
57
|
+
var _MonthPicker = _interopRequireDefault(require("./MonthPicker"));
|
|
82
58
|
|
|
83
|
-
|
|
84
|
-
if (key === "default" || key === "__esModule") return;
|
|
85
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
86
|
-
if (key in exports && exports[key] === _MonthRangePicker[key]) return;
|
|
87
|
-
Object.defineProperty(exports, key, {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function get() {
|
|
90
|
-
return _MonthRangePicker[key];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
59
|
+
var _MonthRangePicker = _interopRequireDefault(require("./MonthRangePicker"));
|
|
94
60
|
|
|
95
61
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
96
62
|
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AAEA;;AAEA","sourcesContent":["export { default as DatePicker } from './DatePicker';\nexport * from './DatePicker';\n\nexport { default as DateRangePicker } from './DateRangePicker';\n\nexport { default as MonthPicker } from './MonthPicker';\n\nexport { default as MonthRangePicker } from './MonthRangePicker';\n"],"file":"index.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/shortDateRangeFormat.js"],"names":["getDayJSLocale","locale","includes","shortDateRangeFormat","dates","options","Intl","DateTimeFormat","format","normalizeDates","map","date","toDate","monthsYears","month","year","length","isSimilarDay","isSimilarMonth","isSimilarYear","day","getDate","getFullYear","newOptions"],"mappings":";;;;;;;;;;;AAAA;;;;;AAEA,SAASA,cAAT,CAAwBC,MAAxB,EAAgC;AAC9B,MAAIA,MAAM,CAACC,QAAP,CAAgB,IAAhB,KAAyBD,MAAM,CAACC,QAAP,CAAgB,IAAhB,CAA7B,EAAoD;AAClD,WAAO,IAAP;AACD;;AACD,SAAO,IAAP;AACD;;AAEc,SAASC,oBAAT,CAA8BC,KAA9B,QAAuE;AAAA,yBAAhCH,MAAgC;AAAA,MAAhCA,MAAgC,4BAAvB,OAAuB;AAAA,MAAXI,OAAW;;AACpF,6BAAmB,IAAIC,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCI,OAAhC,CAAnB;AAAA,MAAQG,MAAR,wBAAQA,MAAR;;AACA,MAAMC,cAAc,GAAGL,KAAK,CAACM,GAAN,CAAU,UAACC,IAAD;AAAA,WAAU,uBAAMA,IAAN,EAAYC,MAAZ,EAAV;AAAA,GAAV,CAAvB;AACA,MAAMC,WAAW,GAAGT,KAAK,CAACM,GAAN,CAAU,UAACC,IAAD;AAAA,WAAU,CACtC,uBAAMA,IAAN,EAAYA,IAAZ,EADsC,EAEtC,uBAAMA,IAAN,EAAYG,KA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kBa,WAAlB,EAJN;AAKD;;AACD,uBAAU,IAAIhB,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACRC,cAAc,CAAC,CAAD,CADN,CAAV,gBAEO,IAAIH,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACLC,cAAc,CAAC,CAAD,CADT,CAFP,cAIKA,cAAc,CAAC,CAAD,CAAd,CAAkBa,WAAlB,EAJL;AAKD;;AAED,qBAAUd,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAAhB,gBAAyCD,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAA/C;AACD;;AAED,SAAOD,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAAb;AACD","sourcesContent":["import dayjs from 'dayjs';\n\nfunction getDayJSLocale(locale) {\n if (locale.includes('en') || locale.includes('ja')) {\n return 'en';\n }\n return 'ru';\n}\n\nexport default function shortDateRangeFormat(dates, { locale = 'en-US', ...options }) {\n const { format } = new Intl.DateTimeFormat(locale, options);\n const normalizeDates = dates.map((date) => dayjs(date).toDate());\n const monthsYears = dates.map((date) => [\n dayjs(date).date(),\n dayjs(date).month(),\n dayjs(date).year(),\n ]);\n\n if (monthsYears.length > 1) {\n const isSimilarDay = monthsYears[0][0] === monthsYears[1][0];\n const isSimilarMonth = monthsYears[0][1] === monthsYears[1][1];\n const isSimilarYear = monthsYears[0][2] === monthsYears[1][2];\n\n if (isSimilarMonth && isSimilarYear && !options.day) {\n return format(normalizeDates[0]);\n }\n if (isSimilarMonth && isSimilarYear) {\n if (getDayJSLocale(locale) === 'en') {\n if (isSimilarDay) {\n return `${new Intl.DateTimeFormat(locale, { month: options.month }).format(\n normalizeDates[0],\n )} ${normalizeDates[0].getDate()}, ${normalizeDates[0].getFullYear()}`;\n }\n return `${new Intl.DateTimeFormat(locale, { month: options.month }).format(\n normalizeDates[0],\n )} ${normalizeDates[0].getDate()} - ${normalizeDates[1].getDate()}, ${normalizeDates[0].getFullYear()}`;\n }\n if (isSimilarDay) {\n return `${normalizeDates[0].getDate()} ${new Intl.DateTimeFormat(locale, {\n month: options.month,\n }).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;\n }\n return `${normalizeDates[0].getDate()} - ${normalizeDates[1].getDate()} ${new Intl.DateTimeFormat(\n locale,\n { month: options.month },\n ).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;\n }\n\n if (isSimilarYear) {\n const { year, ...newOptions } = options;\n if (getDayJSLocale(locale) === 'en') {\n return `${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[0],\n )} - ${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[1],\n )}, ${normalizeDates[0].getFullYear()}`;\n }\n return `${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[0],\n )} - ${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[1],\n )} ${normalizeDates[0].getFullYear()}`;\n }\n\n return `${format(normalizeDates[0])} - ${format(normalizeDates[1])}`;\n }\n\n return format(normalizeDates[0]);\n}\n"],"file":"shortDateRangeFormat.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/shortDateRangeFormat.js"],"names":["getDayJSLocale","locale","includes","shortDateRangeFormat","dates","options","Intl","DateTimeFormat","format","normalizeDates","map","date","toDate","monthsYears","month","year","length","isSimilarDay","isSimilarMonth","isSimilarYear","day","getDate","getFullYear","newOptions"],"mappings":";;;;;;;;;;;AAAA;;;;;AAEA,SAASA,cAAT,CAAwBC,MAAxB,EAAgC;AAC9B,MAAIA,MAAM,CAACC,QAAP,CAAgB,IAAhB,KAAyBD,MAAM,CAACC,QAAP,CAAgB,IAAhB,CAA7B,EAAoD;AAClD,WAAO,IAAP;AACD;;AACD,SAAO,IAAP;AACD;;AAEc,SAASC,oBAAT,CAA8BC,KAA9B,QAAuE;AAAA,yBAAhCH,MAAgC;AAAA,MAAhCA,MAAgC,4BAAvB,OA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UAAQJ,IAAR,GAAgCV,OAAhC,CAAQU,IAAR;AAAA,UAAiBQ,UAAjB,6CAAgClB,OAAhC;;AACA,UAAIL,cAAc,CAACC,MAAD,CAAd,KAA2B,IAA/B,EAAqC;AACnC,yBAAU,IAAIK,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACRC,cAAc,CAAC,CAAD,CADN,CAAV,gBAEO,IAAIH,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACLC,cAAc,CAAC,CAAD,CADT,CAFP,eAIMA,cAAc,CAAC,CAAD,CAAd,CAAkBa,WAAlB,EAJN;AAKD;;AACD,uBAAU,IAAIhB,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACRC,cAAc,CAAC,CAAD,CADN,CAAV,gBAEO,IAAIH,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACLC,cAAc,CAAC,CAAD,CADT,CAFP,cAIKA,cAAc,CAAC,CAAD,CAAd,CAAkBa,WAAlB,EAJL;AAKD;;AAED,qBAAUd,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAAhB,gBAAyCD,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAA/C;AACD;;AAED,SAAOD,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAAb;AACD","sourcesContent":["import dayjs from 'dayjs';\n\nfunction getDayJSLocale(locale) {\n if (locale.includes('en') || locale.includes('ja')) {\n return 'en';\n }\n return 'ru';\n}\n\nexport default function shortDateRangeFormat(dates, { locale = 'en-US', ...options }) {\n const { format } = new Intl.DateTimeFormat(locale, options);\n const normalizeDates = dates.map((date) => dayjs(date).toDate());\n const monthsYears = dates.map((date) => [\n dayjs(date).date(),\n dayjs(date).month(),\n dayjs(date).year(),\n ]);\n\n if (monthsYears.length > 1) {\n const isSimilarDay = monthsYears[0][0] === monthsYears[1][0];\n const isSimilarMonth = monthsYears[0][1] === monthsYears[1][1];\n const isSimilarYear = monthsYears[0][2] === monthsYears[1][2];\n\n if (isSimilarMonth && isSimilarYear && !options.day) {\n return format(normalizeDates[0]);\n }\n if (isSimilarMonth && isSimilarYear) {\n if (getDayJSLocale(locale) === 'en') {\n if (isSimilarDay) {\n return `${new Intl.DateTimeFormat(locale, { month: options.month }).format(\n normalizeDates[0],\n )} ${normalizeDates[0].getDate()}, ${normalizeDates[0].getFullYear()}`;\n }\n return `${new Intl.DateTimeFormat(locale, { month: options.month }).format(\n normalizeDates[0],\n )} ${normalizeDates[0].getDate()} - ${normalizeDates[1].getDate()}, ${normalizeDates[0].getFullYear()}`;\n }\n if (isSimilarDay) {\n return `${normalizeDates[0].getDate()} ${new Intl.DateTimeFormat(locale, {\n month: options.month,\n }).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;\n }\n return `${normalizeDates[0].getDate()} - ${normalizeDates[1].getDate()} ${new Intl.DateTimeFormat(\n locale,\n { month: options.month },\n ).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;\n }\n\n if (isSimilarYear) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { year, ...newOptions } = options;\n if (getDayJSLocale(locale) === 'en') {\n return `${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[0],\n )} - ${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[1],\n )}, ${normalizeDates[0].getFullYear()}`;\n }\n return `${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[0],\n )} - ${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[1],\n )} ${normalizeDates[0].getFullYear()}`;\n }\n\n return `${format(normalizeDates[0])} - ${format(normalizeDates[1])}`;\n }\n\n return format(normalizeDates[0]);\n}\n"],"file":"shortDateRangeFormat.js"}
|
package/lib/es6/DatePicker.js
CHANGED