@semcore/date-picker 3.0.10 → 3.0.13
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.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.map +1 -1
- package/lib/cjs/components/Calendar.js +17 -17
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +7 -7
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +7 -7
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +3 -3
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/cronTabScheduler.js.map +1 -1
- package/lib/cjs/utils/formatDate.js.map +1 -1
- package/lib/cjs/utils/includesDate.js.map +1 -1
- package/lib/cjs/utils/shortDateRangeFormat.js.map +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.map +1 -1
- package/lib/es6/components/Calendar.js +17 -17
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +7 -7
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +7 -7
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +3 -3
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/utils/cronTabScheduler.js.map +1 -1
- package/lib/es6/utils/formatDate.js.map +1 -1
- package/lib/es6/utils/includesDate.js.map +1 -1
- package/lib/es6/utils/shortDateRangeFormat.js.map +1 -1
- package/package.json +1 -1
- package/src/DatePicker.jsx +0 -113
- package/src/DateRangePicker.jsx +0 -91
- package/src/MonthPicker.jsx +0 -71
- package/src/MonthRangePicker.jsx +0 -108
- package/src/components/ButtonTrigger.jsx +0 -23
- package/src/components/Calendar.jsx +0 -284
- package/src/components/PickerAbstract.jsx +0 -199
- package/src/components/RangePickerAbstract.jsx +0 -340
- package/src/components/index.jsx +0 -121
- package/src/index.d.ts +0 -355
- package/src/index.js +0 -8
- package/src/style/calendar.shadow.css +0 -190
- package/src/style/date-picker.shadow.css +0 -49
- package/src/translations/de.json +0 -13
- package/src/translations/en.json +0 -13
- package/src/translations/es.json +0 -13
- package/src/translations/fr.json +0 -13
- package/src/translations/it.json +0 -13
- package/src/translations/ja.json +0 -13
- package/src/translations/ko.json +0 -13
- package/src/translations/pt.json +0 -13
- package/src/translations/ru.json +0 -13
- package/src/translations/vi.json +0 -13
- package/src/translations/zh.json +0 -13
- package/src/utils/cronTabScheduler.js +0 -99
- package/src/utils/formatDate.js +0 -8
- package/src/utils/includesDate.js +0 -13
- package/src/utils/shortDateRangeFormat.js +0 -70
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import dayjs from 'dayjs';
|
|
3
|
-
import { Component, Root, CORE_INSTANCE, sstyled } from '@semcore/core';
|
|
4
|
-
import Button from '@semcore/button';
|
|
5
|
-
import { Box, Flex } from '@semcore/flex-box';
|
|
6
|
-
import Divider from '@semcore/divider';
|
|
7
|
-
import Dropdown from '@semcore/dropdown';
|
|
8
|
-
import i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';
|
|
9
|
-
import de from '../translations/de.json';
|
|
10
|
-
import en from '../translations/en.json';
|
|
11
|
-
import es from '../translations/es.json';
|
|
12
|
-
import fr from '../translations/fr.json';
|
|
13
|
-
import it from '../translations/it.json';
|
|
14
|
-
import ja from '../translations/ja.json';
|
|
15
|
-
import pt from '../translations/pt.json';
|
|
16
|
-
import ru from '../translations/ru.json';
|
|
17
|
-
import zh from '../translations/zh.json';
|
|
18
|
-
import ko from '../translations/ko.json';
|
|
19
|
-
import vi from '../translations/vi.json';
|
|
20
|
-
|
|
21
|
-
import style from '../style/date-picker.shadow.css';
|
|
22
|
-
|
|
23
|
-
const i18n = { de, en, es, fr, it, ja, ru, zh, pt, ko, vi };
|
|
24
|
-
|
|
25
|
-
const INTERACTION_TAGS = ['INPUT'];
|
|
26
|
-
|
|
27
|
-
const defaultDisplayedPeriod = new Date(new Date().setHours(0, 0, 0, 0));
|
|
28
|
-
|
|
29
|
-
function getEndDate(value) {
|
|
30
|
-
if (!Array.isArray(value)) return null;
|
|
31
|
-
const [startDate, endDate = startDate] = value;
|
|
32
|
-
return endDate;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
class RangePickerAbstract extends Component {
|
|
36
|
-
static displayName = 'DatePicker';
|
|
37
|
-
static style = style;
|
|
38
|
-
static defaultProps({ value, defaultValue }) {
|
|
39
|
-
return {
|
|
40
|
-
i18n,
|
|
41
|
-
locale: 'en',
|
|
42
|
-
defaultDisplayedPeriod:
|
|
43
|
-
getEndDate(value) || getEndDate(defaultValue) || defaultDisplayedPeriod,
|
|
44
|
-
defaultValue: [],
|
|
45
|
-
defaultHighlighted: [],
|
|
46
|
-
defaultVisible: false,
|
|
47
|
-
disabled: [],
|
|
48
|
-
size: 'm',
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
static enhance = [i18nEnhance()];
|
|
52
|
-
|
|
53
|
-
static add = (date, amount, unit) => {
|
|
54
|
-
return dayjs(date).add(amount, unit).toDate();
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
static subtract = (date, amount, unit) => {
|
|
58
|
-
return dayjs(date).subtract(amount, unit).toDate();
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
navigateStep;
|
|
62
|
-
keyDiff;
|
|
63
|
-
keyStep;
|
|
64
|
-
|
|
65
|
-
state = {
|
|
66
|
-
dirtyValue: [],
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
uncontrolledProps() {
|
|
70
|
-
return {
|
|
71
|
-
displayedPeriod: null,
|
|
72
|
-
visible: [
|
|
73
|
-
null,
|
|
74
|
-
(visible) => {
|
|
75
|
-
if (!visible) {
|
|
76
|
-
this.handlers.highlighted([]);
|
|
77
|
-
this.setState({ dirtyValue: [] });
|
|
78
|
-
this.handlers.displayedPeriod(
|
|
79
|
-
getEndDate(this.asProps.value) || this.props.defaultDisplayedPeriod,
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
highlighted: null,
|
|
85
|
-
value: [
|
|
86
|
-
null,
|
|
87
|
-
(value) => {
|
|
88
|
-
// TODO: работает только из-за new Date() !== new Date()
|
|
89
|
-
this.handlers.visible(false);
|
|
90
|
-
this.handlers.displayedPeriod(getEndDate(value));
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
navigateView = (direction) => {
|
|
97
|
-
const { displayedPeriod } = this.asProps;
|
|
98
|
-
const action = direction >= 1 ? 'add' : 'subtract';
|
|
99
|
-
const date = dayjs(displayedPeriod)[action](1, this.navigateStep).toDate();
|
|
100
|
-
this.handlers.displayedPeriod(date);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
bindHandlerNavigateClick = (direction) => () => this.navigateView(direction);
|
|
104
|
-
|
|
105
|
-
handlerKeyDown = (e) => {
|
|
106
|
-
if (e.target !== e.currentTarget) return;
|
|
107
|
-
const { displayedPeriod, highlighted } = this.asProps;
|
|
108
|
-
const { dirtyValue } = this.state;
|
|
109
|
-
const day = this.keyDiff[e.keyCode];
|
|
110
|
-
|
|
111
|
-
const setNextDisplayedPeriod = (next_highlighted) => {
|
|
112
|
-
const [, right_period] = next_highlighted;
|
|
113
|
-
|
|
114
|
-
if (right_period) {
|
|
115
|
-
const month_right_period = right_period.getMonth();
|
|
116
|
-
const month_displayed_Period = displayedPeriod.getMonth();
|
|
117
|
-
if (month_right_period - month_displayed_Period > 1) {
|
|
118
|
-
return RangePickerAbstract.subtract(right_period, 1, 'month');
|
|
119
|
-
} else if (month_right_period - month_displayed_Period < 0) {
|
|
120
|
-
return right_period;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return displayedPeriod;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
if (e.keyCode === 32 && highlighted.length) {
|
|
127
|
-
this.handlerChange(highlighted[1] || highlighted[0]);
|
|
128
|
-
e.preventDefault();
|
|
129
|
-
}
|
|
130
|
-
if (day) {
|
|
131
|
-
if (INTERACTION_TAGS.includes(e.target.tagName)) return;
|
|
132
|
-
if (highlighted.length) {
|
|
133
|
-
let next_highlighted;
|
|
134
|
-
if (dirtyValue.length === 1) {
|
|
135
|
-
next_highlighted = [
|
|
136
|
-
dirtyValue[0],
|
|
137
|
-
dayjs(highlighted[1] || highlighted[0])
|
|
138
|
-
.add(day, this.keyStep)
|
|
139
|
-
.toDate(),
|
|
140
|
-
];
|
|
141
|
-
} else {
|
|
142
|
-
next_highlighted = [dayjs(highlighted[0]).add(day, this.keyStep).toDate()];
|
|
143
|
-
}
|
|
144
|
-
this.handlers.highlighted(next_highlighted);
|
|
145
|
-
this.handlers.displayedPeriod(setNextDisplayedPeriod(next_highlighted));
|
|
146
|
-
} else {
|
|
147
|
-
this.handlers.highlighted([displayedPeriod]);
|
|
148
|
-
}
|
|
149
|
-
e.preventDefault();
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
handlerApply = (value) => {
|
|
154
|
-
const [startDate, endDate = startDate] = value;
|
|
155
|
-
this.handlerChange([]);
|
|
156
|
-
this.handlers.value([startDate, endDate]);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
handlerChange = (date) => {
|
|
160
|
-
let { dirtyValue } = this.state;
|
|
161
|
-
let highlighted = [];
|
|
162
|
-
if (Array.isArray(date)) {
|
|
163
|
-
dirtyValue = date;
|
|
164
|
-
} else if (!dirtyValue.length) {
|
|
165
|
-
dirtyValue = [date];
|
|
166
|
-
highlighted = [date];
|
|
167
|
-
} else if (dirtyValue.length >= 2) {
|
|
168
|
-
dirtyValue = [date];
|
|
169
|
-
highlighted = [date];
|
|
170
|
-
} else if (dirtyValue[0] > date) {
|
|
171
|
-
dirtyValue = [date, dirtyValue[0]];
|
|
172
|
-
} else {
|
|
173
|
-
dirtyValue = [dirtyValue[0], date];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
this.setState({ dirtyValue }, () => {
|
|
177
|
-
this.handlers.highlighted(highlighted);
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
getDefaultPeriods() {
|
|
182
|
-
return [];
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
getTriggerProps() {
|
|
186
|
-
const { value, size } = this.asProps;
|
|
187
|
-
return {
|
|
188
|
-
size,
|
|
189
|
-
empty: !value[0] && !value[1],
|
|
190
|
-
onKeyDown: this.handlerKeyDown,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
getPopperProps() {
|
|
195
|
-
const Picker = this[CORE_INSTANCE];
|
|
196
|
-
const { value, periods = this.getDefaultPeriods(), unclearable, getI18nText } = this.asProps;
|
|
197
|
-
const { dirtyValue } = this.state;
|
|
198
|
-
|
|
199
|
-
const buttons = (
|
|
200
|
-
<>
|
|
201
|
-
<Button
|
|
202
|
-
use="primary"
|
|
203
|
-
children={getI18nText('apply')}
|
|
204
|
-
onClick={() => this.handlerApply(dirtyValue.length ? dirtyValue : value)}
|
|
205
|
-
/>
|
|
206
|
-
{!unclearable && (
|
|
207
|
-
<Button
|
|
208
|
-
ml={2}
|
|
209
|
-
use="tertiary"
|
|
210
|
-
theme="muted"
|
|
211
|
-
children={getI18nText('reset')}
|
|
212
|
-
onClick={() => this.handlerApply([])}
|
|
213
|
-
/>
|
|
214
|
-
)}
|
|
215
|
-
</>
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
return {
|
|
219
|
-
tabIndex: 0,
|
|
220
|
-
onKeyDown: this.handlerKeyDown,
|
|
221
|
-
children: (
|
|
222
|
-
<>
|
|
223
|
-
<Flex>
|
|
224
|
-
<Box mr={2}>
|
|
225
|
-
<Picker.Header>
|
|
226
|
-
<Picker.Prev />
|
|
227
|
-
<Picker.Title />
|
|
228
|
-
</Picker.Header>
|
|
229
|
-
<Picker.Calendar />
|
|
230
|
-
</Box>
|
|
231
|
-
<Box ml={2}>
|
|
232
|
-
<Picker.Header>
|
|
233
|
-
<Picker.Title />
|
|
234
|
-
<Picker.Next />
|
|
235
|
-
</Picker.Header>
|
|
236
|
-
<Picker.Calendar />
|
|
237
|
-
</Box>
|
|
238
|
-
{Boolean(periods.length) && (
|
|
239
|
-
<>
|
|
240
|
-
<Divider m="-16px 16px" orientation="vertical" h="auto" />
|
|
241
|
-
<Flex direction="column">
|
|
242
|
-
<Picker.Period />
|
|
243
|
-
<Flex mt="auto">{buttons}</Flex>
|
|
244
|
-
</Flex>
|
|
245
|
-
</>
|
|
246
|
-
)}
|
|
247
|
-
</Flex>
|
|
248
|
-
{!Boolean(periods.length) && <Flex mt={4}>{buttons}</Flex>}
|
|
249
|
-
</>
|
|
250
|
-
),
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
getHeaderProps() {
|
|
255
|
-
const Picker = this[CORE_INSTANCE];
|
|
256
|
-
return {
|
|
257
|
-
children: (
|
|
258
|
-
<>
|
|
259
|
-
<Picker.Prev />
|
|
260
|
-
<Picker.Title />
|
|
261
|
-
<Picker.Next />
|
|
262
|
-
</>
|
|
263
|
-
),
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
getTitleProps(props, index) {
|
|
268
|
-
const { locale, displayedPeriod } = this.asProps;
|
|
269
|
-
return {
|
|
270
|
-
children: new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(
|
|
271
|
-
dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
272
|
-
),
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
getNextProps() {
|
|
277
|
-
return {
|
|
278
|
-
onClick: this.bindHandlerNavigateClick(1),
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
getPrevProps() {
|
|
283
|
-
return {
|
|
284
|
-
onClick: this.bindHandlerNavigateClick(-1),
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
getCalendarProps(props, index) {
|
|
289
|
-
const {
|
|
290
|
-
locale,
|
|
291
|
-
displayedPeriod,
|
|
292
|
-
disabled,
|
|
293
|
-
value,
|
|
294
|
-
highlighted,
|
|
295
|
-
onHighlightedChange,
|
|
296
|
-
} = this.asProps;
|
|
297
|
-
const { dirtyValue } = this.state;
|
|
298
|
-
|
|
299
|
-
return {
|
|
300
|
-
locale,
|
|
301
|
-
displayedPeriod: dayjs(displayedPeriod)
|
|
302
|
-
.add(index, this.navigateStep)
|
|
303
|
-
.startOf(this.navigateStep)
|
|
304
|
-
.toDate(),
|
|
305
|
-
disabled,
|
|
306
|
-
highlighted,
|
|
307
|
-
onHighlightedChange,
|
|
308
|
-
value: dirtyValue.length ? dirtyValue : value,
|
|
309
|
-
onChange: this.handlerChange,
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
getPeriodProps() {
|
|
314
|
-
const {
|
|
315
|
-
periods = this.getDefaultPeriods(),
|
|
316
|
-
value,
|
|
317
|
-
onHighlightedChange,
|
|
318
|
-
onDisplayedPeriodChange,
|
|
319
|
-
} = this.asProps;
|
|
320
|
-
const { dirtyValue } = this.state;
|
|
321
|
-
return {
|
|
322
|
-
periods,
|
|
323
|
-
value: dirtyValue.length ? dirtyValue : value,
|
|
324
|
-
onChange: this.handlerApply,
|
|
325
|
-
onHighlightedChange,
|
|
326
|
-
onDisplayedPeriodChange,
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
render() {
|
|
331
|
-
const { Children, styles } = this.asProps;
|
|
332
|
-
return sstyled(styles)(
|
|
333
|
-
<Root render={Dropdown}>
|
|
334
|
-
<Children />
|
|
335
|
-
</Root>,
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export default RangePickerAbstract;
|
package/src/components/index.jsx
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import dayjs from 'dayjs';
|
|
3
|
-
import { Component, Root, sstyled } from '@semcore/core';
|
|
4
|
-
import Dropdown from '@semcore/dropdown';
|
|
5
|
-
import { Box } from '@semcore/flex-box';
|
|
6
|
-
import Button from '@semcore/button';
|
|
7
|
-
import ChevronLeft from '@semcore/icon/ChevronLeft/m';
|
|
8
|
-
import ChevronRight from '@semcore/icon/ChevronRight/m';
|
|
9
|
-
import { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
|
10
|
-
import ButtonTrigger from './ButtonTrigger';
|
|
11
|
-
|
|
12
|
-
export function Trigger() {
|
|
13
|
-
return <Root render={Dropdown.Trigger} tag={ButtonTrigger} />;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function Popper(props) {
|
|
17
|
-
const SPopper = Root;
|
|
18
|
-
return sstyled(props.styles)(
|
|
19
|
-
<SPopper render={Dropdown.Popper} role="region" aria-label="calendar-container" />,
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function Header(props) {
|
|
24
|
-
const SHeader = Root;
|
|
25
|
-
return sstyled(props.styles)(<SHeader render={Box} />);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const Title = ({ Children, styles }) => {
|
|
29
|
-
const STitle = Root;
|
|
30
|
-
return sstyled(styles)(
|
|
31
|
-
<STitle render={Box}>
|
|
32
|
-
<Children />
|
|
33
|
-
</STitle>,
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export function Prev() {
|
|
38
|
-
return (
|
|
39
|
-
<Root
|
|
40
|
-
render={Button}
|
|
41
|
-
use="tertiary"
|
|
42
|
-
theme="muted"
|
|
43
|
-
size="l"
|
|
44
|
-
tabIndex={-1}
|
|
45
|
-
aria-label="Prev period"
|
|
46
|
-
/>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
Prev.defaultProps = {
|
|
51
|
-
children: <ChevronLeft />,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export function Next() {
|
|
55
|
-
return (
|
|
56
|
-
<Root
|
|
57
|
-
render={Button}
|
|
58
|
-
use="tertiary"
|
|
59
|
-
theme="muted"
|
|
60
|
-
size="l"
|
|
61
|
-
tabIndex={-1}
|
|
62
|
-
aria-label="Next period"
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
Next.defaultProps = {
|
|
68
|
-
children: <ChevronRight />,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const stylesBtn = sstyled.css`
|
|
72
|
-
SInner {
|
|
73
|
-
justify-content: flex-start;
|
|
74
|
-
}
|
|
75
|
-
`;
|
|
76
|
-
|
|
77
|
-
export class Period extends Component {
|
|
78
|
-
getActiveControl = (period = [], value) => {
|
|
79
|
-
function compareMonth(monthOne, monthTwo) {
|
|
80
|
-
return dayjs(monthOne).isSame(dayjs(monthTwo), 'date');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!period || !value) return false;
|
|
84
|
-
if (Array.isArray(value) && period.length !== value.length) return false;
|
|
85
|
-
if (Array.isArray(value)) {
|
|
86
|
-
return compareMonth(period[0], value[0]) && compareMonth(period[1], value[1]);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return compareMonth(period[0], value);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
render() {
|
|
93
|
-
const SPeriod = Root;
|
|
94
|
-
const { styles, value, onChange, periods, onHighlightedChange, onDisplayedPeriodChange } =
|
|
95
|
-
this.asProps;
|
|
96
|
-
|
|
97
|
-
return sstyled(styles)(
|
|
98
|
-
<SPeriod render={Box}>
|
|
99
|
-
{periods.map(({ value: period, onClick, onMouseEnter, onMouseLeave, ...other }, i) => (
|
|
100
|
-
<Button
|
|
101
|
-
use="tertiary"
|
|
102
|
-
theme="muted"
|
|
103
|
-
styles={stylesBtn}
|
|
104
|
-
key={i}
|
|
105
|
-
active={this.getActiveControl(period, value)}
|
|
106
|
-
onClick={callAllEventHandlers(onClick, () => onChange(period))}
|
|
107
|
-
onMouseEnter={callAllEventHandlers(onMouseEnter, () => {
|
|
108
|
-
onHighlightedChange(period);
|
|
109
|
-
onDisplayedPeriodChange(dayjs(period[0]).toDate());
|
|
110
|
-
})}
|
|
111
|
-
onMouseLeave={callAllEventHandlers(onMouseLeave, () => {
|
|
112
|
-
onHighlightedChange([]);
|
|
113
|
-
onDisplayedPeriodChange(value[0] ? dayjs(value[0]).toDate() : new Date());
|
|
114
|
-
})}
|
|
115
|
-
{...other}
|
|
116
|
-
/>
|
|
117
|
-
))}
|
|
118
|
-
</SPeriod>,
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
}
|