Skip to content

Commit ec4a90b

Browse files
committed
ExpandableCalendar + WeekCalendar/presenter - change require to import for commons.UpdateSources
1 parent 188056a commit ec4a90b

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/expandableCalendar/WeekCalendar/presenter.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import {DateData} from '../../types';
88
import {WeekCalendarProps} from './index';
99
import constants from '../../commons/constants';
1010
import {generateDay} from '../../dateutils';
11+
import {UpdateSources} from '../commons';
1112

12-
const commons = require('../commons');
13-
const updateSources = commons.UpdateSources;
1413
// must be a positive number
1514
const NUMBER_OF_PAGES = 2;
1615

@@ -26,7 +25,7 @@ class Presenter {
2625

2726
// Events
2827
onDayPress = (context: any, value: DateData) => {
29-
context.setDate?.(value.dateString, updateSources.DAY_PRESS);
28+
context.setDate?.(value.dateString, UpdateSources.DAY_PRESS);
3029
};
3130

3231
onScroll = ({context, updateState, x, page, items, width}: any) => {
@@ -39,7 +38,7 @@ class Presenter {
3938
const newPage = this._getNewPage(x, width);
4039

4140
if (this._shouldUpdateState(page, newPage)) {
42-
context.setDate?.(items[newPage], updateSources.WEEK_SCROLL);
41+
context.setDate?.(items[newPage], UpdateSources.WEEK_SCROLL);
4342
const data = this._getItemsForPage(newPage, items);
4443
updateState(data, newPage);
4544
}
@@ -64,7 +63,7 @@ class Presenter {
6463
shouldComponentUpdate = (context: any, prevContext: any) => {
6564
const {date, updateSource, numberOfDays} = context;
6665
return (
67-
(date !== prevContext.date && updateSource !== updateSources.WEEK_SCROLL) ||
66+
(date !== prevContext.date && updateSource !== UpdateSources.WEEK_SCROLL) ||
6867
numberOfDays !== prevContext.numberOfDays
6968
);
7069
};

src/expandableCalendar/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ import CalendarList, {CalendarListProps} from '../calendar-list';
3131
import Week from './week';
3232
import WeekCalendar from './WeekCalendar';
3333
import Context from './Context';
34-
3534
import constants from '../commons/constants';
36-
const commons = require('./commons');
37-
const updateSources = commons.UpdateSources;
35+
import {UpdateSources} from './commons';
36+
3837
enum Positions {
3938
CLOSED = 'closed',
4039
OPEN = 'open'
@@ -299,7 +298,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
299298

300299
}
301300

302-
setDate?.(toMarkingFormat(d), updateSources.PAGE_SCROLL);
301+
setDate?.(toMarkingFormat(d), UpdateSources.PAGE_SCROLL);
303302
}
304303
}, [horizontal, isOpen, firstDay, numberOfDays, setDate, date]);
305304

@@ -421,7 +420,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
421420

422421
const _onDayPress = useCallback((value: DateData) => {
423422
if (numberOfDaysCondition) {
424-
setDate?.(value.dateString, updateSources.DAY_PRESS);
423+
setDate?.(value.dateString, UpdateSources.DAY_PRESS);
425424
}
426425
if (closeOnDayPress) {
427426
closeCalendar();

0 commit comments

Comments
 (0)