@semcore/date-picker 2.8.3 → 3.0.0
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 +19 -0
- package/lib/cjs/DatePicker.js +2 -1
- package/lib/cjs/DatePicker.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 +22 -22
- package/lib/cjs/components/PickerAbstract.js +8 -9
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +9 -11
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +13 -18
- 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/style/calendar.shadow.css +44 -44
- package/lib/cjs/style/date-picker.shadow.css +4 -2
- package/lib/cjs/utils/shortDateRangeFormat.js +1 -0
- package/lib/cjs/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/es6/DatePicker.js +2 -1
- package/lib/es6/DatePicker.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 +22 -22
- package/lib/es6/components/PickerAbstract.js +8 -9
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +9 -11
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +13 -18
- 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/style/calendar.shadow.css +44 -44
- package/lib/es6/style/date-picker.shadow.css +4 -2
- package/lib/es6/utils/shortDateRangeFormat.js +1 -0
- package/lib/es6/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/types/index.d.ts +1 -1
- package/package.json +7 -4
- package/src/DatePicker.jsx +1 -1
- package/src/components/ButtonTrigger.jsx +2 -3
- package/src/components/PickerAbstract.jsx +0 -1
- package/src/components/RangePickerAbstract.jsx +10 -10
- package/src/index.d.ts +1 -1
- package/src/index.js +0 -3
- package/src/style/calendar.shadow.css +44 -44
- package/src/style/date-picker.shadow.css +4 -2
- package/src/utils/shortDateRangeFormat.js +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/index.jsx"],"names":["React","dayjs","Component","Root","sstyled","Dropdown","Box","Button","ChevronLeft","ChevronRight","callAllEventHandlers","ButtonTrigger","Trigger","Popper","props","SPopper","styles","Header","SHeader","Title","Children","STitle","Prev","defaultProps","children","Next","stylesBtn","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"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/index.jsx"],"names":["React","dayjs","Component","Root","sstyled","Dropdown","Box","Button","ChevronLeft","ChevronRight","callAllEventHandlers","ButtonTrigger","Trigger","Popper","props","SPopper","styles","Header","SHeader","Title","Children","STitle","Prev","defaultProps","children","Next","stylesBtn","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAASC,SAAT,EAAoBC,IAApB,EAA0BC,OAA1B,QAAyC,eAAzC;AACA,OAAOC,QAAP,MAAqB,mBAArB;AACA,SAASC,GAAT,QAAoB,mBAApB;AACA,OAAOC,MAA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uB,CAACb,KAAK,CAAC,CAAD,CAAL,GAAW5B,KAAK,CAAC4B,KAAK,CAAC,CAAD,CAAN,CAAL,CAAgBqB,MAAhB,EAAX,GAAsC,IAAIC,IAAJ,EAAvC,CAAvB;AACD,WAHiC;AAXpC,WAeMH,KAfN,EADW;AAAA,OAAZ,CADH,CADF;AAuBD;AA3CH;;AAAA;AAAA,EAA4B9C,SAA5B","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';
|
|
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/es6/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export { default as DatePicker } from './DatePicker';
|
|
2
2
|
export * from './DatePicker';
|
|
3
3
|
export { default as DateRangePicker } from './DateRangePicker';
|
|
4
|
-
export * from './DateRangePicker';
|
|
5
4
|
export { default as MonthPicker } from './MonthPicker';
|
|
6
|
-
export * from './MonthPicker';
|
|
7
5
|
export { default as MonthRangePicker } from './MonthRangePicker';
|
|
8
|
-
export * from './MonthRangePicker';
|
|
9
6
|
//# sourceMappingURL=index.js.map
|
package/lib/es6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.js"],"names":["default","DatePicker","DateRangePicker","MonthPicker","MonthRangePicker"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAApB,QAAsC,cAAtC;AACA,cAAc,cAAd;AAEA,SAASD,OAAO,IAAIE,eAApB,QAA2C,mBAA3C;
|
|
1
|
+
{"version":3,"sources":["../../src/index.js"],"names":["default","DatePicker","DateRangePicker","MonthPicker","MonthRangePicker"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAApB,QAAsC,cAAtC;AACA,cAAc,cAAd;AAEA,SAASD,OAAO,IAAIE,eAApB,QAA2C,mBAA3C;AAEA,SAASF,OAAO,IAAIG,WAApB,QAAuC,eAAvC;AAEA,SAASH,OAAO,IAAII,gBAApB,QAA4C,oBAA5C","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"}
|
|
@@ -29,8 +29,8 @@ SWeekDay {
|
|
|
29
29
|
display: flex;
|
|
30
30
|
align-items: center;
|
|
31
31
|
justify-content: center;
|
|
32
|
-
color: var(--
|
|
33
|
-
font-size: var(--fs-
|
|
32
|
+
color: var(--gray-500);
|
|
33
|
+
font-size: var(--fs-200);
|
|
34
34
|
font-weight: 400;
|
|
35
35
|
overflow: hidden;
|
|
36
36
|
}
|
|
@@ -43,7 +43,7 @@ SCalendarUnit {
|
|
|
43
43
|
text-align: center;
|
|
44
44
|
vertical-align: middle;
|
|
45
45
|
border: 1px solid transparent;
|
|
46
|
-
color: var(--
|
|
46
|
+
color: var(--gray-800);
|
|
47
47
|
outline: 0;
|
|
48
48
|
box-shadow: none;
|
|
49
49
|
overflow: visible;
|
|
@@ -53,11 +53,11 @@ SCalendarUnit {
|
|
|
53
53
|
background: transparent;
|
|
54
54
|
|
|
55
55
|
align-items: center;
|
|
56
|
-
border-radius:
|
|
56
|
+
border-radius: var(--rounded-m);
|
|
57
57
|
box-sizing: border-box;
|
|
58
58
|
cursor: pointer;
|
|
59
59
|
display: flex;
|
|
60
|
-
font-size:
|
|
60
|
+
font-size: var(--fs-200);
|
|
61
61
|
justify-content: center;
|
|
62
62
|
min-height: 32px;
|
|
63
63
|
min-width: 32px;
|
|
@@ -66,12 +66,12 @@ SCalendarUnit {
|
|
|
66
66
|
outline: none;
|
|
67
67
|
|
|
68
68
|
&:hover {
|
|
69
|
-
color: var(--
|
|
70
|
-
background:
|
|
69
|
+
color: var(--gray-800);
|
|
70
|
+
background: var(--gray-100);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
&:focus-visible {
|
|
74
|
-
box-shadow: var(--
|
|
74
|
+
box-shadow: var(--keyboard-focus);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -80,13 +80,13 @@ SCalendarUnit[today] {
|
|
|
80
80
|
content: '';
|
|
81
81
|
position: absolute;
|
|
82
82
|
display: block;
|
|
83
|
-
top:
|
|
84
|
-
left:
|
|
85
|
-
border-radius:
|
|
86
|
-
width: calc(100% -
|
|
87
|
-
height: calc(100% -
|
|
83
|
+
top: 1px;
|
|
84
|
+
left: 1px;
|
|
85
|
+
border-radius: var(--rounded-m);
|
|
86
|
+
width: calc(100% - 2px);
|
|
87
|
+
height: calc(100% - 2px);
|
|
88
88
|
box-sizing: border-box;
|
|
89
|
-
border: 1px solid
|
|
89
|
+
border: 1px solid var(--gray-200);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -98,79 +98,83 @@ SCalendarUnit[today]SCalendarUnit[endSelected] {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
SCalendarUnit[selected] {
|
|
101
|
-
background:
|
|
101
|
+
background: var(--blue-100);
|
|
102
102
|
border-radius: 0;
|
|
103
|
-
color: var(--
|
|
103
|
+
color: var(--gray-800);
|
|
104
104
|
|
|
105
105
|
&:hover {
|
|
106
|
-
background:
|
|
106
|
+
background: var(--blue-400);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
SCalendarUnit[highlighted] {
|
|
111
|
-
background: color-mod(var(--
|
|
111
|
+
background: color-mod(var(--blue-400) alpha(20%));
|
|
112
112
|
border-radius: 0;
|
|
113
|
-
color: var(--
|
|
113
|
+
color: var(--gray-800);
|
|
114
114
|
|
|
115
115
|
&:hover {
|
|
116
|
-
background: color-mod(var(--
|
|
116
|
+
background: color-mod(var(--blue-400) alpha(30%));
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
SCalendarUnit[startSelected] {
|
|
121
|
-
|
|
122
|
-
border-bottom-left-radius: 4px;
|
|
121
|
+
border-bottom-left-radius: var(--rounded-m);
|
|
123
122
|
border-bottom-right-radius: 0;
|
|
124
|
-
border-top-left-radius:
|
|
123
|
+
border-top-left-radius: var(--rounded-m);
|
|
125
124
|
border-top-right-radius: 0;
|
|
126
125
|
color: white;
|
|
126
|
+
background: var(--blue-300);
|
|
127
127
|
|
|
128
128
|
&:hover {
|
|
129
129
|
color: white;
|
|
130
|
-
background:
|
|
130
|
+
background: var(--blue-400);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
SCalendarUnit[endSelected] {
|
|
135
|
-
background: var(--
|
|
135
|
+
background: var(--blue-300);
|
|
136
136
|
border-bottom-left-radius: 0;
|
|
137
|
-
border-bottom-right-radius:
|
|
137
|
+
border-bottom-right-radius: var(--rounded-m);
|
|
138
138
|
border-top-left-radius: 0;
|
|
139
|
-
border-top-right-radius:
|
|
139
|
+
border-top-right-radius: var(--rounded-m);
|
|
140
140
|
color: white;
|
|
141
141
|
|
|
142
142
|
&:hover {
|
|
143
143
|
color: white;
|
|
144
|
-
background:
|
|
144
|
+
background: var(--blue-400);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
SCalendarUnit[startHighlighted] {
|
|
149
|
-
border-bottom-left-radius:
|
|
149
|
+
border-bottom-left-radius: var(--rounded-m);
|
|
150
150
|
border-bottom-right-radius: 0;
|
|
151
|
-
border-top-left-radius:
|
|
151
|
+
border-top-left-radius: var(--rounded-m);
|
|
152
152
|
border-top-right-radius: 0;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
SCalendarUnit[endHighlighted] {
|
|
156
156
|
border-bottom-left-radius: 0;
|
|
157
|
-
border-bottom-right-radius:
|
|
157
|
+
border-bottom-right-radius: var(--rounded-m);
|
|
158
158
|
border-top-left-radius: 0;
|
|
159
|
-
border-top-right-radius:
|
|
159
|
+
border-top-right-radius: var(--rounded-m);
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
SCalendarUnit[startHighlighted]SCalendarUnit[endHighlighted] {
|
|
163
|
-
border-bottom-left-radius:
|
|
164
|
-
border-bottom-right-radius:
|
|
165
|
-
border-top-left-radius:
|
|
166
|
-
border-top-right-radius:
|
|
163
|
+
border-bottom-left-radius: var(--rounded-m);
|
|
164
|
+
border-bottom-right-radius: var(--rounded-m);
|
|
165
|
+
border-top-left-radius: var(--rounded-m);
|
|
166
|
+
border-top-right-radius: var(--rounded-m);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
SCalendarUnit[startSelected]SCalendarUnit[endSelected] {
|
|
170
|
-
border-bottom-left-radius:
|
|
171
|
-
border-bottom-right-radius:
|
|
172
|
-
border-top-left-radius:
|
|
173
|
-
border-top-right-radius:
|
|
170
|
+
border-bottom-left-radius: var(--rounded-m);
|
|
171
|
+
border-bottom-right-radius: var(--rounded-m);
|
|
172
|
+
border-top-left-radius: var(--rounded-m);
|
|
173
|
+
border-top-right-radius: var(--rounded-m);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
SCalendarUnit[outdated] {
|
|
177
|
+
opacity: 0.2;
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
SCalendarUnit[disabled] {
|
|
@@ -179,10 +183,6 @@ SCalendarUnit[disabled] {
|
|
|
179
183
|
pointer-events: none;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
SCalendarUnit[outdated] {
|
|
183
|
-
opacity: 0.2;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
186
|
@media (prefers-reduced-motion) {
|
|
187
187
|
SCalendarUnit {
|
|
188
188
|
transition: none;
|
|
@@ -17,16 +17,18 @@ SPopper {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
&:focus {
|
|
20
|
-
box-shadow: var(--
|
|
20
|
+
box-shadow: var(--keyboard-focus);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
SHeader {
|
|
25
25
|
display: flex;
|
|
26
|
+
align-items: center;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
STitle {
|
|
29
|
-
font-size: var(--fs-
|
|
30
|
+
font-size: var(--fs-200);
|
|
31
|
+
color: var(--gray-800);
|
|
30
32
|
height: 32px;
|
|
31
33
|
width: 100%;
|
|
32
34
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/shortDateRangeFormat.js"],"names":["dayjs","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,OAAOA,KAAP,MAAkB,OAAlB;;AAEA,SAASC,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;;AAED,eAAe,SAASC,oBAAT,CAA8BC,KAA9B,QAAuE;AAAA,yBAAhCH,MAAgC;AAAA,MAAhCA,MAAgC,4BAAvB,OAAuB;AAAA,MAAXI,OAAW;;AACpF,6BA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;AACjB,UAAQJ,IAAR,GAAgCV,OAAhC,CAAQU,IAAR;AAAA,UAAiBQ,UAAjB,4BAAgClB,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 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":["dayjs","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,OAAOA,KAAP,MAAkB,OAAlB;;AAEA,SAASC,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;;AAED,eAAe,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,WAAUZ,KAAK,CAACY,IAAD,CAAL,CAAYC,MAAZ,EAAV;AAAA,GAAV,CAAvB;AACA,MAAMC,WAAW,GAAGT,KAAK,CAACM,GAAN,CAAU,UAACC,IAAD;AAAA,WAAU,CACtCZ,KAAK,CAACY,IAAD,CAAL,CAAYA,IAAZ,EADsC,EAEtCZ,KAAK,CAACY,IAAD,CAAL,CAAYG,KAAZ,EAFsC,EAGtCf,KAAK,CAACY,IAAD,CAAL,CAAYI,IAAZ,EAHsC,CAAV;AAAA,GAAV,CAApB;;AAMA,MAAIF,WAAW,CAACG,MAAZ,GAAqB,CAAzB,EAA4B;AAC1B,QAAMC,YAAY,GAAGJ,WAAW,CAAC,CAAD,CAAX,CAAe,CAAf,MAAsBA,WAAW,CAAC,CAAD,CAAX,CAAe,CAAf,CAA3C;AACA,QAAMK,cAAc,GAAGL,WAAW,CAAC,CAAD,CAAX,CAAe,CAAf,MAAsBA,WAA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KD;;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/types/index.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ export interface IDatePickerProps extends IDropdownProps, IWithI18nEnhanceProps
|
|
|
100
100
|
* Component size
|
|
101
101
|
* @default m
|
|
102
102
|
*/
|
|
103
|
-
size?: 'm' | 'l'
|
|
103
|
+
size?: 'm' | 'l';
|
|
104
104
|
/**
|
|
105
105
|
* The selected date, accepts everything which is accepted by `new Date()`
|
|
106
106
|
* */
|