@nutui/nutui-react 1.3.0 → 1.3.1-beta.2
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/dist/esm/Audio/style/index.js +4 -0
- package/dist/esm/Audio.js +293 -0
- package/dist/esm/Calendar/style/index.js +1 -2
- package/dist/esm/Calendar.js +80 -33
- package/dist/esm/CalendarItem.js +429 -231
- package/dist/esm/Cascader/style/index.js +2 -0
- package/dist/esm/Cascader.js +788 -0
- package/dist/esm/ConfigProvider.js +16 -0
- package/dist/esm/DatePicker.js +37 -6
- package/dist/esm/Dialog.js +9 -16
- package/dist/esm/Elevator.js +16 -5
- package/dist/esm/Grid/style/index.js +2 -0
- package/dist/esm/Grid.js +91 -0
- package/dist/esm/GridItem/style/index.js +2 -0
- package/dist/esm/GridItem.js +99 -0
- package/dist/esm/ImagePreview/style/index.js +2 -0
- package/dist/esm/ImagePreview.js +257 -0
- package/dist/esm/Menu/style/index.js +3 -0
- package/dist/esm/Menu.js +153 -0
- package/dist/esm/MenuItem/style/index.js +3 -0
- package/dist/esm/MenuItem.js +197 -0
- package/dist/esm/NoticeBar.js +3 -2
- package/dist/esm/Notify.js +2 -1
- package/dist/esm/Popover.js +4 -11
- package/dist/esm/Range.js +2 -45
- package/dist/esm/Swipe/style/index.js +2 -0
- package/dist/esm/Swipe.js +265 -0
- package/dist/esm/Swiper.js +2 -1
- package/dist/esm/TabPane.js +5 -33
- package/dist/esm/Tabs.js +6 -196
- package/dist/esm/TextArea.js +45 -4
- package/dist/esm/Toast.js +2 -1
- package/dist/esm/nutui-react.es.js +8 -0
- package/dist/esm/render-4a3856cb.js +32 -0
- package/dist/esm/tabpane-c957ab14.js +33 -0
- package/dist/esm/tabs-a48583e9.js +196 -0
- package/dist/esm/useClientRect-839d18c5.js +44 -0
- package/dist/locales/base.d.ts +16 -0
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +17 -1
- package/dist/locales/id-ID.js +17 -1
- package/dist/locales/zh-CN.js +17 -1
- package/dist/locales/zh-TW.js +17 -1
- package/dist/nutui.react.es.js +2338 -530
- package/dist/nutui.react.umd.js +2345 -529
- package/dist/packages/audio/audio.scss +80 -0
- package/dist/packages/calendar/calendar.scss +57 -36
- package/dist/packages/calendaritem/calendaritem.scss +0 -191
- package/dist/packages/cascader/cascader.scss +69 -0
- package/dist/packages/grid/grid.scss +10 -0
- package/dist/packages/griditem/griditem.scss +103 -0
- package/dist/packages/imagepreview/imagepreview.scss +51 -0
- package/dist/packages/menu/menu.scss +72 -0
- package/dist/packages/menuitem/menuitem.scss +90 -0
- package/dist/packages/popup/popup.scss +1 -1
- package/dist/packages/searchbar/searchbar.scss +1 -0
- package/dist/packages/shortpassword/shortpassword.scss +6 -1
- package/dist/packages/swipe/swipe.scss +33 -0
- package/dist/packages/textarea/textarea.scss +16 -1
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/font/iconfont.js +20 -18
- package/dist/styles/themes/default.scss +8 -0
- package/dist/styles/variables.scss +59 -8
- package/dist/types/audio/__test__/audio.spec.d.ts +1 -0
- package/dist/types/audio/audio.d.ts +18 -0
- package/dist/types/audio/audio.taro.d.ts +18 -0
- package/dist/types/audio/demo.d.ts +4 -0
- package/dist/types/audio/index.d.ts +2 -0
- package/dist/types/audio/index.taro.d.ts +2 -0
- package/dist/types/backtop/__test__/backtop.spec.d.ts +1 -0
- package/dist/types/calendar/__tests__/calendar.spec.d.ts +1 -0
- package/dist/types/calendar/calendar.d.ts +22 -2
- package/dist/types/calendar/demo.d.ts +1 -0
- package/dist/types/calendaritem/calendaritem.d.ts +21 -3
- package/dist/types/cascader/__tests__/cascader.spec.d.ts +1 -0
- package/dist/types/cascader/cascader.d.ts +25 -0
- package/dist/types/cascader/cascader.taro.d.ts +25 -0
- package/dist/types/cascader/cascaderItem.d.ts +25 -0
- package/dist/types/cascader/cascaderItem.taro.d.ts +25 -0
- package/dist/types/cascader/demo.d.ts +3 -0
- package/dist/types/cascader/helper.d.ts +4 -0
- package/dist/types/cascader/index.d.ts +2 -0
- package/dist/types/cascader/index.taro.d.ts +2 -0
- package/dist/types/cascader/tree.d.ts +12 -0
- package/dist/types/cascader/types.d.ts +28 -0
- package/dist/types/checkbox/checkbox.d.ts +2 -2
- package/dist/types/checkbox/checkbox.taro.d.ts +2 -2
- package/dist/types/checkboxgroup/checkboxgroup.d.ts +2 -2
- package/dist/types/checkboxgroup/checkboxgroup.taro.d.ts +2 -2
- package/dist/types/dialog/__test__/dialog.spec.d.ts +1 -0
- package/dist/types/dialog/config.d.ts +3 -3
- package/dist/types/dialog/dialog.d.ts +2 -1
- package/dist/types/dialog/dialog.taro.d.ts +2 -1
- package/dist/types/fixednav/fixednav.d.ts +2 -2
- package/dist/types/grid/__test__/grid.spec.d.ts +1 -0
- package/dist/types/grid/demo.d.ts +3 -0
- package/dist/types/grid/grid.d.ts +16 -0
- package/dist/types/grid/grid.taro.d.ts +16 -0
- package/dist/types/grid/index.d.ts +2 -0
- package/dist/types/grid/index.taro.d.ts +2 -0
- package/dist/types/griditem/griditem.d.ts +20 -0
- package/dist/types/griditem/griditem.taro.d.ts +20 -0
- package/dist/types/griditem/index.d.ts +2 -0
- package/dist/types/griditem/index.taro.d.ts +2 -0
- package/dist/types/icon/icon.d.ts +1 -2
- package/dist/types/icon/icon.taro.d.ts +1 -2
- package/dist/types/imagepreview/__test__/imagepreview.spec.d.ts +1 -0
- package/dist/types/imagepreview/demo.d.ts +3 -0
- package/dist/types/imagepreview/imagepreview.d.ts +26 -0
- package/dist/types/imagepreview/imagepreview.taro.d.ts +26 -0
- package/dist/types/imagepreview/index.d.ts +2 -0
- package/dist/types/imagepreview/index.taro.d.ts +2 -0
- package/dist/types/input/__test__/input.spec.d.ts +1 -0
- package/dist/types/menu/__test__/menu.spec.d.ts +1 -0
- package/dist/types/menu/demo.d.ts +4 -0
- package/dist/types/menu/index.d.ts +2 -0
- package/dist/types/menu/index.taro.d.ts +2 -0
- package/dist/types/menu/menu.d.ts +12 -0
- package/dist/types/menu/menu.taro.d.ts +12 -0
- package/dist/types/menuitem/index.d.ts +2 -0
- package/dist/types/menuitem/index.taro.d.ts +2 -0
- package/dist/types/menuitem/menuitem.d.ts +23 -0
- package/dist/types/menuitem/menuitem.taro.d.ts +23 -0
- package/dist/types/notify/__test__/notify.spec.d.ts +1 -0
- package/dist/types/notify/notify.d.ts +13 -0
- package/dist/types/notify/notify.taro.d.ts +13 -0
- package/dist/types/nutui.react.d.ts +95 -1
- package/dist/types/picker/doc.en.d.ts +142 -0
- package/dist/types/picker/picker.d.ts +2 -2
- package/dist/types/picker/picker.taro.d.ts +2 -2
- package/dist/types/popup/popup.d.ts +1 -1
- package/dist/types/popup/popup.taro.d.ts +1 -1
- package/dist/types/shortpassword/shortpassword.taro.d.ts +3 -3
- package/dist/types/sidenavbar/sidenavbar.d.ts +14 -2
- package/dist/types/sidenavbar/sidenavbar.taro.d.ts +14 -2
- package/dist/types/sidenavbaritem/sidenavbaritem.d.ts +10 -2
- package/dist/types/sidenavbaritem/sidenavbaritem.taro.d.ts +10 -2
- package/dist/types/subsidenavbar/subsidenavbar.d.ts +13 -3
- package/dist/types/subsidenavbar/subsidenavbar.taro.d.ts +13 -3
- package/dist/types/swipe/__tests__/swipe.spec.d.ts +1 -0
- package/dist/types/swipe/demo.d.ts +3 -0
- package/dist/types/swipe/index.d.ts +2 -0
- package/dist/types/swipe/index.taro.d.ts +2 -0
- package/dist/types/swipe/swipe.d.ts +41 -0
- package/dist/types/swipe/swipe.taro.d.ts +41 -0
- package/dist/types/swiper/swiper.d.ts +1 -2
- package/dist/types/swiperitem/swiperitem.d.ts +1 -2
- package/dist/types/table/table.d.ts +2 -1
- package/dist/types/table/table.taro.d.ts +2 -1
- package/dist/types/table/types.d.ts +1 -1
- package/dist/types/textarea/__test__/textarea.spec.d.ts +1 -0
- package/dist/types/toast/toast.d.ts +21 -0
- package/dist/types/toast/toast.taro.d.ts +18 -0
- package/dist/types/virtuallist/type.d.ts +1 -1
- package/dist/types/virtuallist/virtuallist.d.ts +2 -1
- package/dist/types/virtuallist/virtuallist.taro.d.ts +2 -1
- package/package.json +4 -4
package/dist/esm/CalendarItem.js
CHANGED
|
@@ -35,12 +35,22 @@ var defaultProps = {
|
|
|
35
35
|
defaultValue: '',
|
|
36
36
|
startDate: Utils.getDay(0),
|
|
37
37
|
endDate: Utils.getDay(365),
|
|
38
|
+
showToday: true,
|
|
39
|
+
startText: '开始',
|
|
40
|
+
endText: '结束',
|
|
41
|
+
confirmText: '确认',
|
|
42
|
+
showTitle: true,
|
|
43
|
+
showSubTitle: true,
|
|
44
|
+
toDateAnimation: true,
|
|
45
|
+
onBtn: undefined,
|
|
46
|
+
onDay: undefined,
|
|
47
|
+
onTopInfo: undefined,
|
|
48
|
+
onBottomInfo: undefined,
|
|
38
49
|
onChoose: function onChoose(data) {},
|
|
39
50
|
onUpdate: function onUpdate() {},
|
|
40
|
-
|
|
51
|
+
onSelected: function onSelected(data) {}
|
|
41
52
|
};
|
|
42
|
-
|
|
43
|
-
var CalendarItem = function CalendarItem(props) {
|
|
53
|
+
var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
44
54
|
var _classNames, _classNames2;
|
|
45
55
|
|
|
46
56
|
var _useConfig = useConfig(),
|
|
@@ -52,11 +62,20 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
52
62
|
poppable = _defaultProps$props.poppable,
|
|
53
63
|
title = _defaultProps$props.title,
|
|
54
64
|
defaultValue = _defaultProps$props.defaultValue,
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
showToday = _defaultProps$props.showToday,
|
|
66
|
+
startText = _defaultProps$props.startText,
|
|
67
|
+
endText = _defaultProps$props.endText,
|
|
68
|
+
confirmText = _defaultProps$props.confirmText,
|
|
69
|
+
showTitle = _defaultProps$props.showTitle,
|
|
70
|
+
showSubTitle = _defaultProps$props.showSubTitle,
|
|
71
|
+
toDateAnimation = _defaultProps$props.toDateAnimation,
|
|
72
|
+
onBtn = _defaultProps$props.onBtn,
|
|
73
|
+
onDay = _defaultProps$props.onDay,
|
|
74
|
+
onTopInfo = _defaultProps$props.onTopInfo,
|
|
75
|
+
onBottomInfo = _defaultProps$props.onBottomInfo,
|
|
57
76
|
onChoose = _defaultProps$props.onChoose,
|
|
58
77
|
onUpdate = _defaultProps$props.onUpdate,
|
|
59
|
-
|
|
78
|
+
onSelected = _defaultProps$props.onSelected;
|
|
60
79
|
|
|
61
80
|
var weeks = locale.calendaritem.weekdays;
|
|
62
81
|
|
|
@@ -65,18 +84,26 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
65
84
|
yearMonthTitle = _useState2[0],
|
|
66
85
|
setYearMonthTitle = _useState2[1];
|
|
67
86
|
|
|
68
|
-
var _useState3 = useState(
|
|
87
|
+
var _useState3 = useState([]),
|
|
69
88
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
monthsData = _useState4[0],
|
|
90
|
+
setMonthsData = _useState4[1];
|
|
72
91
|
|
|
73
|
-
var _useState5 = useState(
|
|
92
|
+
var _useState5 = useState(0),
|
|
74
93
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
75
|
-
|
|
76
|
-
|
|
94
|
+
translateY = _useState6[0],
|
|
95
|
+
setTranslateY = _useState6[1];
|
|
96
|
+
|
|
97
|
+
var _useState7 = useState([]),
|
|
98
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
99
|
+
monthDefaultRange = _useState8[0],
|
|
100
|
+
setMonthDefaultRange = _useState8[1];
|
|
77
101
|
|
|
78
|
-
var
|
|
102
|
+
var _useState9 = useState({
|
|
79
103
|
currDate: '',
|
|
104
|
+
propStartDate: '',
|
|
105
|
+
propEndDate: '',
|
|
106
|
+
unLoadPrev: false,
|
|
80
107
|
touchParams: {
|
|
81
108
|
startY: 0,
|
|
82
109
|
endY: 0,
|
|
@@ -86,7 +113,6 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
86
113
|
lastTime: 0
|
|
87
114
|
},
|
|
88
115
|
transformY: 0,
|
|
89
|
-
translateY: 0,
|
|
90
116
|
scrollDistance: 0,
|
|
91
117
|
defaultData: [],
|
|
92
118
|
chooseData: [],
|
|
@@ -94,15 +120,20 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
94
120
|
dayPrefix: 'calendar-month-day',
|
|
95
121
|
startData: '',
|
|
96
122
|
endData: '',
|
|
97
|
-
isRange: type === 'range',
|
|
98
|
-
timer: 0
|
|
123
|
+
isRange: props.type === 'range',
|
|
124
|
+
timer: 0,
|
|
125
|
+
currentIndex: 0,
|
|
126
|
+
avgHeight: 0,
|
|
127
|
+
monthsNum: 0
|
|
99
128
|
}),
|
|
100
|
-
|
|
101
|
-
state =
|
|
129
|
+
_useState10 = _slicedToArray(_useState9, 1),
|
|
130
|
+
state = _useState10[0];
|
|
102
131
|
|
|
103
132
|
var weeksPanel = useRef(null);
|
|
104
133
|
var months = useRef(null);
|
|
105
134
|
var monthsPanel = useRef(null);
|
|
135
|
+
var viewArea = useRef(null);
|
|
136
|
+
var viewHeight = 0;
|
|
106
137
|
var b = cn('calendar');
|
|
107
138
|
var classes = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b(''), "-tile"), !poppable), _defineProperty(_classNames, "".concat(b(''), "-nofooter"), !!isAutoBackFill), _classNames), b(''));
|
|
108
139
|
var headerClasses = classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b(''), "-header"), true), _defineProperty(_classNames2, "".concat(b(''), "-header-tile"), !poppable), _classNames2));
|
|
@@ -122,23 +153,33 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
122
153
|
return Utils.isEqual(state.currDate[1], currDate);
|
|
123
154
|
};
|
|
124
155
|
|
|
125
|
-
var
|
|
126
|
-
|
|
156
|
+
var isMultiple = function isMultiple(currDate) {
|
|
157
|
+
if (state.currDate.length > 0) {
|
|
158
|
+
return state.currDate.some(function (item) {
|
|
159
|
+
return Utils.isEqual(item, currDate);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return false;
|
|
127
164
|
};
|
|
128
165
|
|
|
129
|
-
var
|
|
130
|
-
|
|
166
|
+
var getCurrDate = function getCurrDate(day, month) {
|
|
167
|
+
return "".concat(month.curData[0], "-").concat(month.curData[1], "-").concat(Utils.getNumTwoBit(+day.day));
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
var getClass = function getClass(day, month) {
|
|
171
|
+
var currDate = getCurrDate(day, month);
|
|
131
172
|
|
|
132
173
|
if (day.type === 'curr') {
|
|
133
|
-
if (
|
|
174
|
+
if (Utils.isEqual(state.currDate, currDate) || type === 'range' && (isStart(currDate) || isEnd(currDate)) || type === 'multiple' && isMultiple(currDate)) {
|
|
134
175
|
return "".concat(state.dayPrefix, "-active");
|
|
135
176
|
}
|
|
136
177
|
|
|
137
|
-
if (
|
|
178
|
+
if (state.propStartDate && Utils.compareDate(currDate, state.propStartDate) || state.propEndDate && Utils.compareDate(state.propEndDate, currDate)) {
|
|
138
179
|
return "".concat(state.dayPrefix, "-disabled");
|
|
139
180
|
}
|
|
140
181
|
|
|
141
|
-
if (
|
|
182
|
+
if (type === 'range' && Array.isArray(state.currDate) && Object.values(state.currDate).length === 2 && Utils.compareDate(state.currDate[0], currDate) && Utils.compareDate(currDate, state.currDate[1])) {
|
|
142
183
|
return "".concat(state.dayPrefix, "-choose");
|
|
143
184
|
}
|
|
144
185
|
|
|
@@ -158,8 +199,11 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
158
199
|
};
|
|
159
200
|
|
|
160
201
|
var confirm = function confirm() {
|
|
161
|
-
|
|
162
|
-
|
|
202
|
+
var type = props.type;
|
|
203
|
+
|
|
204
|
+
if (type === 'range' && state.chooseData.length === 2 || type !== 'range') {
|
|
205
|
+
var chooseData = state.chooseData.slice(0);
|
|
206
|
+
onChoose && onChoose(chooseData);
|
|
163
207
|
|
|
164
208
|
if (poppable) {
|
|
165
209
|
onUpdate && onUpdate();
|
|
@@ -167,20 +211,42 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
167
211
|
}
|
|
168
212
|
};
|
|
169
213
|
|
|
170
|
-
var chooseDay = function chooseDay(day, month, isFirst
|
|
171
|
-
if (getClass(day, month
|
|
214
|
+
var chooseDay = function chooseDay(day, month, isFirst) {
|
|
215
|
+
if (getClass(day, month) !== "".concat(state.dayPrefix, "-disabled")) {
|
|
216
|
+
var _type = props.type;
|
|
217
|
+
|
|
172
218
|
var days = _toConsumableArray(month.curData);
|
|
173
219
|
|
|
174
|
-
days = isRange ? days.splice(3) : days.splice(0, 3);
|
|
175
220
|
days[2] = typeof day.day === 'number' ? Utils.getNumTwoBit(day.day) : day.day;
|
|
176
221
|
days[3] = "".concat(days[0], "-").concat(days[1], "-").concat(days[2]);
|
|
177
222
|
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
178
223
|
|
|
179
|
-
if (
|
|
180
|
-
state.currDate
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
224
|
+
if (_type === 'multiple') {
|
|
225
|
+
if (state.currDate.length > 0) {
|
|
226
|
+
var hasIndex = '';
|
|
227
|
+
state.currDate.forEach(function (item, index) {
|
|
228
|
+
if (item === days[3]) {
|
|
229
|
+
hasIndex = index;
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
if (isFirst) {
|
|
234
|
+
state.chooseData.push(_toConsumableArray(days));
|
|
235
|
+
} else if (hasIndex !== '') {
|
|
236
|
+
state.currDate.splice(hasIndex, 1);
|
|
237
|
+
state.chooseData.splice(hasIndex, 1);
|
|
238
|
+
} else {
|
|
239
|
+
state.currDate.push(days[3]);
|
|
240
|
+
state.chooseData.push(_toConsumableArray(days));
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
state.currDate = [days[3]];
|
|
244
|
+
state.chooseData = [_toConsumableArray(days)];
|
|
245
|
+
}
|
|
246
|
+
} else if (_type === 'range') {
|
|
247
|
+
var curDataLength = Object.values(state.currDate).length;
|
|
248
|
+
|
|
249
|
+
if (curDataLength === 2 || curDataLength === 0) {
|
|
184
250
|
state.currDate = [days[3]];
|
|
185
251
|
} else if (Utils.compareDate(state.currDate[0], days[3])) {
|
|
186
252
|
Array.isArray(state.currDate) && state.currDate.push(days[3]);
|
|
@@ -189,16 +255,24 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
189
255
|
}
|
|
190
256
|
|
|
191
257
|
if (state.chooseData.length === 2 || !state.chooseData.length) {
|
|
192
|
-
state.chooseData = _toConsumableArray(days);
|
|
193
|
-
} else if (Utils.compareDate(state.chooseData[3], days[3])) {
|
|
194
|
-
state.chooseData = [_toConsumableArray(state.chooseData), _toConsumableArray(days)];
|
|
258
|
+
state.chooseData = [_toConsumableArray(days)];
|
|
259
|
+
} else if (Utils.compareDate(state.chooseData[0][3], days[3])) {
|
|
260
|
+
state.chooseData = [].concat(_toConsumableArray(state.chooseData), [_toConsumableArray(days)]);
|
|
195
261
|
} else {
|
|
196
|
-
state.chooseData = [_toConsumableArray(days)
|
|
262
|
+
state.chooseData = [_toConsumableArray(days)].concat(_toConsumableArray(state.chooseData));
|
|
197
263
|
}
|
|
264
|
+
} else {
|
|
265
|
+
state.currDate = days[3];
|
|
266
|
+
state.chooseData = _toConsumableArray(days);
|
|
198
267
|
}
|
|
199
268
|
|
|
200
|
-
if (
|
|
201
|
-
|
|
269
|
+
if (!isFirst) {
|
|
270
|
+
// 点击日期 触发
|
|
271
|
+
onSelected && onSelected(state.chooseData);
|
|
272
|
+
|
|
273
|
+
if (isAutoBackFill || !poppable) {
|
|
274
|
+
confirm();
|
|
275
|
+
}
|
|
202
276
|
}
|
|
203
277
|
|
|
204
278
|
setMonthsData(state.monthsData.slice());
|
|
@@ -206,20 +280,25 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
206
280
|
};
|
|
207
281
|
|
|
208
282
|
var isStartTip = function isStartTip(day, month) {
|
|
209
|
-
|
|
210
|
-
|
|
283
|
+
return isActive(day, month) && isStart(getCurrDate(day, month));
|
|
284
|
+
}; // 是否有结束提示
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
var isEndTip = function isEndTip(day, month) {
|
|
288
|
+
if (state.currDate.length >= 2 && isEnd(getCurrDate(day, month))) {
|
|
289
|
+
return isActive(day, month);
|
|
211
290
|
}
|
|
212
291
|
|
|
213
292
|
return false;
|
|
214
|
-
}; //
|
|
293
|
+
}; // 开始结束时间是否相等
|
|
215
294
|
|
|
216
295
|
|
|
217
|
-
var
|
|
218
|
-
if (
|
|
219
|
-
return
|
|
296
|
+
var rangeTip = function rangeTip() {
|
|
297
|
+
if (state.currDate.length >= 2) {
|
|
298
|
+
return Utils.isEqual(state.currDate[0], state.currDate[1]);
|
|
220
299
|
}
|
|
221
300
|
|
|
222
|
-
return
|
|
301
|
+
return false;
|
|
223
302
|
}; // 获取当前月数据
|
|
224
303
|
|
|
225
304
|
|
|
@@ -244,8 +323,11 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
244
323
|
}; // 获取日期状态
|
|
245
324
|
|
|
246
325
|
|
|
247
|
-
var getDaysStatus = function getDaysStatus(days, type) {
|
|
326
|
+
var getDaysStatus = function getDaysStatus(days, type, dateInfo) {
|
|
248
327
|
// 修复:当某个月的1号是周日时,月份下方会空出来一行
|
|
328
|
+
var year = dateInfo.year,
|
|
329
|
+
month = dateInfo.month;
|
|
330
|
+
|
|
249
331
|
if (type === 'prev' && days >= 7) {
|
|
250
332
|
days -= 7;
|
|
251
333
|
}
|
|
@@ -253,15 +335,47 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
253
335
|
return Array.from(Array(days), function (v, k) {
|
|
254
336
|
return {
|
|
255
337
|
day: k + 1,
|
|
256
|
-
type: type
|
|
338
|
+
type: type,
|
|
339
|
+
year: year,
|
|
340
|
+
month: month
|
|
257
341
|
};
|
|
258
342
|
});
|
|
343
|
+
}; // 获取上一个月的最后一周天数,填充当月空白
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
var getPreDaysStatus = function getPreDaysStatus(days, type, dateInfo, preCurrMonthDays) {
|
|
347
|
+
// 修复:当某个月的1号是周日时,月份下方会空出来一行
|
|
348
|
+
var year = dateInfo.year,
|
|
349
|
+
month = dateInfo.month;
|
|
350
|
+
|
|
351
|
+
if (type === 'prev' && days >= 7) {
|
|
352
|
+
days -= 7;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
var months = Array.from(Array(preCurrMonthDays), function (v, k) {
|
|
356
|
+
return {
|
|
357
|
+
day: k + 1,
|
|
358
|
+
type: type,
|
|
359
|
+
year: year,
|
|
360
|
+
month: month
|
|
361
|
+
};
|
|
362
|
+
});
|
|
363
|
+
return months.slice(preCurrMonthDays - days);
|
|
259
364
|
}; // 获取月数据
|
|
260
365
|
|
|
261
366
|
|
|
262
367
|
var getMonth = function getMonth(curData, type) {
|
|
263
368
|
var preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
|
|
369
|
+
var preMonth = +curData[1] - 1;
|
|
370
|
+
var preYear = curData[0];
|
|
371
|
+
|
|
372
|
+
if (preMonth <= 0) {
|
|
373
|
+
preMonth = 12;
|
|
374
|
+
preYear += 1;
|
|
375
|
+
}
|
|
376
|
+
|
|
264
377
|
var currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
|
|
378
|
+
var preCurrMonthDays = Utils.getMonthDays("".concat(preYear), "".concat(preMonth));
|
|
265
379
|
var title = {
|
|
266
380
|
year: curData[0],
|
|
267
381
|
month: curData[1]
|
|
@@ -269,8 +383,19 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
269
383
|
var monthInfo = {
|
|
270
384
|
curData: curData,
|
|
271
385
|
title: locale.calendaritem.monthTitle(title.year, title.month),
|
|
272
|
-
monthData: [].concat(_toConsumableArray(
|
|
386
|
+
monthData: [].concat(_toConsumableArray(getPreDaysStatus(preMonthDays, 'prev', {
|
|
387
|
+
month: preMonth,
|
|
388
|
+
year: preYear
|
|
389
|
+
}, preCurrMonthDays)), _toConsumableArray(getDaysStatus(currMonthDays, 'curr', title)))
|
|
273
390
|
};
|
|
391
|
+
monthInfo.cssHeight = 39 + (monthInfo.monthData.length > 35 ? 384 : 320);
|
|
392
|
+
var cssScrollHeight = 0;
|
|
393
|
+
|
|
394
|
+
if (state.monthsData.length > 0) {
|
|
395
|
+
cssScrollHeight = state.monthsData[state.monthsData.length - 1].cssScrollHeight + state.monthsData[state.monthsData.length - 1].cssHeight;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
monthInfo.cssScrollHeight = cssScrollHeight;
|
|
274
399
|
|
|
275
400
|
if (type === 'next') {
|
|
276
401
|
if (!state.endData || !Utils.compareDate("".concat(state.endData[0], "-").concat(state.endData[1], "-").concat(Utils.getMonthDays(state.endData[0], state.endData[1])), "".concat(curData[0], "-").concat(curData[1], "-").concat(curData[2]))) {
|
|
@@ -278,227 +403,295 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
278
403
|
}
|
|
279
404
|
} else if (!state.startData || !Utils.compareDate("".concat(curData[0], "-").concat(curData[1], "-").concat(curData[2]), "".concat(state.startData[0], "-").concat(state.startData[1], "-01"))) {
|
|
280
405
|
state.monthsData.unshift(monthInfo);
|
|
281
|
-
} else {
|
|
282
|
-
setUnLoadPrev(true);
|
|
283
406
|
}
|
|
284
407
|
|
|
285
408
|
setMonthsData(state.monthsData);
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
var loadScroll = function loadScroll() {
|
|
290
|
-
if (!props.poppable) {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
requestAniFrame$1(function () {
|
|
295
|
-
if (weeksPanel !== null && weeksPanel !== void 0 && weeksPanel.current && monthsPanel !== null && monthsPanel !== void 0 && monthsPanel.current) {
|
|
296
|
-
var top = weeksPanel === null || weeksPanel === void 0 ? void 0 : weeksPanel.current.getBoundingClientRect().bottom;
|
|
297
|
-
var monthsDoms = monthsPanel.current.getElementsByClassName('calendar-month');
|
|
298
|
-
|
|
299
|
-
for (var i = 0; i < monthsDoms.length; i++) {
|
|
300
|
-
if (monthsDoms[i].getBoundingClientRect().top <= top && monthsDoms[i].getBoundingClientRect().bottom >= top) {
|
|
301
|
-
setYearMonthTitle(state.monthsData[i].title);
|
|
302
|
-
} else if (state.scrollDistance === 0) {
|
|
303
|
-
setYearMonthTitle(state.monthsData[0].title);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
}; // 设置月份滚动距离和速度
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
var setTransform = function setTransform() {
|
|
312
|
-
var translateY = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
313
|
-
var type = arguments.length > 1 ? arguments[1] : undefined;
|
|
314
|
-
var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
409
|
+
};
|
|
315
410
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
411
|
+
var setDefaultRange = function setDefaultRange(monthsNum, current) {
|
|
412
|
+
var start = 0;
|
|
413
|
+
var end = 0;
|
|
414
|
+
|
|
415
|
+
if (monthsNum >= 3) {
|
|
416
|
+
if (current > 0 && current < monthsNum) {
|
|
417
|
+
start = current - 1;
|
|
418
|
+
end = current + 3;
|
|
419
|
+
} else if (current === 0) {
|
|
420
|
+
start = current;
|
|
421
|
+
end = current + 4;
|
|
422
|
+
} else if (current === monthsNum) {
|
|
423
|
+
start = current - 2;
|
|
424
|
+
end = current + 2;
|
|
326
425
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
426
|
+
} else {
|
|
427
|
+
start = 0;
|
|
428
|
+
end = monthsNum + 2;
|
|
330
429
|
}
|
|
331
|
-
}; // 计算滚动方向和距离
|
|
332
430
|
|
|
431
|
+
setMonthDefaultRange([start, end]);
|
|
432
|
+
setTranslateY(state.monthsData[start].cssScrollHeight);
|
|
433
|
+
};
|
|
333
434
|
|
|
334
|
-
var
|
|
335
|
-
|
|
435
|
+
var mothsViewScroll = function mothsViewScroll(e) {
|
|
436
|
+
if (state.monthsData.length <= 1) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
336
439
|
|
|
337
|
-
var
|
|
338
|
-
var
|
|
339
|
-
var
|
|
440
|
+
var target = e.target;
|
|
441
|
+
var currentScrollTop = target.scrollTop;
|
|
442
|
+
var current = Math.floor(currentScrollTop / state.avgHeight);
|
|
340
443
|
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
updateMove = 0;
|
|
444
|
+
if (current === 0) {
|
|
445
|
+
if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
|
|
446
|
+
current += 1;
|
|
345
447
|
}
|
|
346
|
-
|
|
347
|
-
if (
|
|
348
|
-
|
|
448
|
+
} else if (current > 0 && current < state.monthsNum - 1) {
|
|
449
|
+
if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
|
|
450
|
+
current += 1;
|
|
349
451
|
}
|
|
350
452
|
|
|
351
|
-
if (
|
|
352
|
-
|
|
453
|
+
if (currentScrollTop < state.monthsData[current].cssScrollHeight) {
|
|
454
|
+
current -= 1;
|
|
353
455
|
}
|
|
354
|
-
|
|
355
|
-
setTransform(updateMove, type, time);
|
|
356
456
|
} else {
|
|
357
|
-
|
|
358
|
-
|
|
457
|
+
var viewPosition = Math.round(currentScrollTop + viewHeight);
|
|
458
|
+
|
|
459
|
+
if (viewPosition < state.monthsData[current].cssScrollHeight + state.monthsData[current].cssHeight && currentScrollTop > state.monthsData[current - 1].cssScrollHeight) {
|
|
460
|
+
current -= 1;
|
|
359
461
|
}
|
|
360
462
|
|
|
361
|
-
if (
|
|
362
|
-
|
|
463
|
+
if (current + 1 <= state.monthsNum && viewPosition >= state.monthsData[current + 1].cssScrollHeight + state.monthsData[current + 1].cssHeight) {
|
|
464
|
+
current += 1;
|
|
363
465
|
}
|
|
364
466
|
|
|
365
|
-
if (
|
|
366
|
-
|
|
467
|
+
if (current >= 1 && currentScrollTop < state.monthsData[current - 1].cssScrollHeight) {
|
|
468
|
+
current -= 1;
|
|
367
469
|
}
|
|
470
|
+
}
|
|
368
471
|
|
|
369
|
-
|
|
472
|
+
if (state.currentIndex !== current) {
|
|
473
|
+
state.currentIndex = current;
|
|
474
|
+
setDefaultRange(state.monthsNum, current);
|
|
370
475
|
}
|
|
371
|
-
};
|
|
372
476
|
|
|
373
|
-
|
|
374
|
-
event.stopPropagation();
|
|
375
|
-
var changedTouches = event.changedTouches[0];
|
|
376
|
-
state.touchParams.startY = changedTouches.pageY;
|
|
377
|
-
state.touchParams.startTime = event.timeStamp || Date.now();
|
|
378
|
-
state.transformY = state.scrollDistance;
|
|
477
|
+
setYearMonthTitle(state.monthsData[current].title);
|
|
379
478
|
};
|
|
380
479
|
|
|
381
|
-
var
|
|
382
|
-
|
|
383
|
-
var
|
|
384
|
-
|
|
385
|
-
state.
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
480
|
+
var initData = function initData() {
|
|
481
|
+
// 初始化开始结束数据
|
|
482
|
+
var propStartDate = props.startDate ? props.startDate : Utils.getDay(0);
|
|
483
|
+
var propEndDate = props.endDate ? props.endDate : Utils.getDay(365);
|
|
484
|
+
state.propStartDate = propStartDate;
|
|
485
|
+
state.propEndDate = propEndDate;
|
|
486
|
+
state.startData = splitDate(propStartDate);
|
|
487
|
+
state.endData = splitDate(propEndDate); // 根据是否存在默认时间,初始化当前日期
|
|
391
488
|
|
|
392
|
-
|
|
393
|
-
|
|
489
|
+
if (defaultValue || Array.isArray(defaultValue) && defaultValue.length > 0) {
|
|
490
|
+
state.currDate = props.type !== 'one' ? _toConsumableArray(props.defaultValue) : props.defaultValue;
|
|
491
|
+
} // 判断时间范围内存在多少个月
|
|
394
492
|
|
|
395
|
-
var onTouchEnd = function onTouchEnd(event) {
|
|
396
|
-
var _months$current2, _monthsPanel$current2;
|
|
397
493
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
var
|
|
494
|
+
var startDate = {
|
|
495
|
+
year: Number(state.startData[0]),
|
|
496
|
+
month: Number(state.startData[1])
|
|
497
|
+
};
|
|
498
|
+
var endDate = {
|
|
499
|
+
year: Number(state.endData[0]),
|
|
500
|
+
month: Number(state.endData[1])
|
|
501
|
+
};
|
|
502
|
+
var monthsNum = endDate.month - startDate.month;
|
|
403
503
|
|
|
404
|
-
if (
|
|
405
|
-
|
|
504
|
+
if (endDate.year - startDate.year > 0) {
|
|
505
|
+
monthsNum += 12 * (endDate.year - startDate.year);
|
|
406
506
|
}
|
|
407
507
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
508
|
+
if (monthsNum <= 0) {
|
|
509
|
+
monthsNum = 1;
|
|
510
|
+
} // 设置月份数据
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
getMonth(state.startData, 'next');
|
|
514
|
+
var i = 1;
|
|
411
515
|
|
|
412
|
-
|
|
413
|
-
getMonth(getCurrData('prev'), 'prev');
|
|
414
|
-
} else if (updateMove < 0 && updateMove < -offsetHeight + (Math.abs(move) > h ? Math.abs(move) : h) * 5) {
|
|
516
|
+
do {
|
|
415
517
|
getMonth(getCurrData('next'), 'next');
|
|
518
|
+
} while (i++ < monthsNum);
|
|
416
519
|
|
|
417
|
-
|
|
418
|
-
getMonth(getCurrData('next'), 'next');
|
|
419
|
-
}
|
|
420
|
-
}
|
|
520
|
+
state.monthsNum = monthsNum; // 日期转化为数组,限制初始日期。判断时间范围
|
|
421
521
|
|
|
422
|
-
|
|
522
|
+
if (type === 'range' && Array.isArray(state.currDate)) {
|
|
523
|
+
if (state.currDate.length > 0) {
|
|
524
|
+
if (propStartDate && Utils.compareDate(state.currDate[0], propStartDate)) {
|
|
525
|
+
state.currDate.splice(0, 1, propStartDate);
|
|
526
|
+
}
|
|
423
527
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
setMove(move, 'end', moveTime);
|
|
428
|
-
} else {
|
|
429
|
-
setMove(move, 'end');
|
|
430
|
-
}
|
|
431
|
-
};
|
|
528
|
+
if (propEndDate && Utils.compareDate(propEndDate, state.currDate[1])) {
|
|
529
|
+
state.currDate.splice(1, 1, propEndDate);
|
|
530
|
+
}
|
|
432
531
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
532
|
+
state.defaultData = [].concat(_toConsumableArray(splitDate(state.currDate[0])), _toConsumableArray(splitDate(state.currDate[1])));
|
|
533
|
+
}
|
|
534
|
+
} else if (props.type === 'multiple' && Array.isArray(state.currDate)) {
|
|
535
|
+
if (state.currDate.length > 0) {
|
|
536
|
+
var defaultArr = [];
|
|
537
|
+
var obj = {};
|
|
538
|
+
state.currDate.forEach(function (item) {
|
|
539
|
+
if (propStartDate && !Utils.compareDate(item, propStartDate) && propEndDate && !Utils.compareDate(propEndDate, item)) {
|
|
540
|
+
if (!Object.hasOwnProperty.call(obj, item)) {
|
|
541
|
+
defaultArr.push(item);
|
|
542
|
+
obj[item] = item;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
state.currDate = [].concat(defaultArr);
|
|
547
|
+
state.defaultData = _toConsumableArray(splitDate(defaultArr[0]));
|
|
548
|
+
}
|
|
549
|
+
} else if (state.currDate) {
|
|
550
|
+
if (propStartDate && Utils.compareDate(state.currDate, propStartDate)) {
|
|
551
|
+
state.currDate = propStartDate;
|
|
552
|
+
} else if (propEndDate && !Utils.compareDate(state.currDate, propEndDate)) {
|
|
553
|
+
state.currDate = propEndDate;
|
|
554
|
+
}
|
|
437
555
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
} else {
|
|
441
|
-
state.currDate = state.isRange ? _toConsumableArray(defaultValue) : defaultValue;
|
|
442
|
-
} // 日期转化为数组
|
|
556
|
+
state.defaultData = _toConsumableArray(splitDate(state.currDate));
|
|
557
|
+
} // 设置默认可见区域
|
|
443
558
|
|
|
444
559
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
560
|
+
var current = 0;
|
|
561
|
+
var lastCurrent = 0;
|
|
562
|
+
|
|
563
|
+
if (state.defaultData.length > 0) {
|
|
564
|
+
state.monthsData.forEach(function (item, index) {
|
|
565
|
+
if (item.title === locale.calendaritem.monthTitle(state.defaultData[0], state.defaultData[1])) {
|
|
566
|
+
current = index;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (props.type === 'range') {
|
|
570
|
+
if (item.title === locale.calendaritem.monthTitle(state.defaultData[3], state.defaultData[4])) {
|
|
571
|
+
lastCurrent = index;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}
|
|
449
576
|
|
|
450
|
-
|
|
451
|
-
|
|
577
|
+
setDefaultRange(monthsNum, current);
|
|
578
|
+
state.currentIndex = current;
|
|
579
|
+
setYearMonthTitle(state.monthsData[state.currentIndex].title);
|
|
580
|
+
|
|
581
|
+
if (state.defaultData.length > 0) {
|
|
582
|
+
// 设置当前选中日期
|
|
583
|
+
if (type === 'range') {
|
|
584
|
+
chooseDay({
|
|
585
|
+
day: state.defaultData[2],
|
|
586
|
+
type: 'curr'
|
|
587
|
+
}, state.monthsData[state.currentIndex], true);
|
|
588
|
+
chooseDay({
|
|
589
|
+
day: state.defaultData[5],
|
|
590
|
+
type: 'curr'
|
|
591
|
+
}, state.monthsData[lastCurrent], true);
|
|
592
|
+
} else if (type === 'multiple') {
|
|
593
|
+
_toConsumableArray(state.currDate).forEach(function (item) {
|
|
594
|
+
var dateArr = splitDate(item);
|
|
595
|
+
var current = state.currentIndex;
|
|
596
|
+
state.monthsData.forEach(function (item, index) {
|
|
597
|
+
if (item.title === locale.calendaritem.monthTitle(dateArr[0], dateArr[1])) {
|
|
598
|
+
current = index;
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
chooseDay({
|
|
602
|
+
day: dateArr[2],
|
|
603
|
+
type: 'curr'
|
|
604
|
+
}, state.monthsData[current], true);
|
|
605
|
+
});
|
|
606
|
+
} else {
|
|
607
|
+
chooseDay({
|
|
608
|
+
day: state.defaultData[2],
|
|
609
|
+
type: 'curr'
|
|
610
|
+
}, state.monthsData[state.currentIndex], true);
|
|
452
611
|
}
|
|
612
|
+
}
|
|
453
613
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
614
|
+
var lastItem = state.monthsData[state.monthsData.length - 1];
|
|
615
|
+
var containerHeight = lastItem.cssHeight + lastItem.cssScrollHeight;
|
|
616
|
+
requestAniFrame$1(function () {
|
|
617
|
+
// 初始化 日历位置
|
|
618
|
+
if (months && monthsPanel && viewArea) {
|
|
619
|
+
viewHeight = months.current.clientHeight;
|
|
620
|
+
monthsPanel.current.style.height = "".concat(containerHeight, "px");
|
|
621
|
+
months.current.scrollTop = state.monthsData[state.currentIndex].cssScrollHeight;
|
|
460
622
|
}
|
|
623
|
+
});
|
|
624
|
+
state.avgHeight = Math.floor(containerHeight / (monthsNum + 1));
|
|
625
|
+
};
|
|
461
626
|
|
|
462
|
-
|
|
463
|
-
|
|
627
|
+
var resetRender = function resetRender() {
|
|
628
|
+
state.chooseData.splice(0);
|
|
629
|
+
state.monthsData.splice(0);
|
|
630
|
+
initData();
|
|
631
|
+
}; // 暴露出的API
|
|
464
632
|
|
|
465
|
-
getMonth(state.defaultData, 'next');
|
|
466
|
-
setYearMonthTitle(state.monthsData[0].title);
|
|
467
|
-
var i = 1;
|
|
468
633
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
chooseDay({
|
|
475
|
-
day: state.defaultData[2],
|
|
476
|
-
type: 'curr'
|
|
477
|
-
}, state.monthsData[0], true);
|
|
478
|
-
chooseDay({
|
|
479
|
-
day: state.defaultData[5],
|
|
480
|
-
type: 'curr'
|
|
481
|
-
}, state.monthsData[0], true, true);
|
|
482
|
-
} else {
|
|
483
|
-
chooseDay({
|
|
484
|
-
day: state.defaultData[2],
|
|
485
|
-
type: 'curr'
|
|
486
|
-
}, state.monthsData[0], true);
|
|
634
|
+
var scrollToDate = function scrollToDate(date) {
|
|
635
|
+
if (Utils.compareDate(date, state.propStartDate)) {
|
|
636
|
+
date = state.propStartDate;
|
|
637
|
+
} else if (!Utils.compareDate(date, state.propEndDate)) {
|
|
638
|
+
date = state.propEndDate;
|
|
487
639
|
}
|
|
640
|
+
|
|
641
|
+
var dateArr = splitDate(date);
|
|
642
|
+
state.monthsData.forEach(function (item, index) {
|
|
643
|
+
if (item.title === locale.calendaritem.monthTitle(dateArr[0], dateArr[1])) {
|
|
644
|
+
if (months.current) {
|
|
645
|
+
var distance = state.monthsData[index].cssScrollHeight - months.current.scrollTop;
|
|
646
|
+
|
|
647
|
+
if (toDateAnimation) {
|
|
648
|
+
var flag = 0;
|
|
649
|
+
var interval = setInterval(function () {
|
|
650
|
+
flag++;
|
|
651
|
+
|
|
652
|
+
if (months.current) {
|
|
653
|
+
var offset = distance / 10;
|
|
654
|
+
months.current.scrollTop += offset;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
if (flag >= 10) {
|
|
658
|
+
clearInterval(interval);
|
|
659
|
+
|
|
660
|
+
if (months.current) {
|
|
661
|
+
months.current.scrollTop = state.monthsData[index].cssScrollHeight;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}, 40);
|
|
665
|
+
} else {
|
|
666
|
+
months.current.scrollTop = state.monthsData[index].cssScrollHeight;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
});
|
|
488
671
|
};
|
|
489
672
|
|
|
490
673
|
useEffect(function () {
|
|
491
674
|
initData();
|
|
492
675
|
}, []);
|
|
676
|
+
useEffect(function () {
|
|
677
|
+
poppable && resetRender();
|
|
678
|
+
}, [defaultValue]);
|
|
679
|
+
React__default.useImperativeHandle(ref, function () {
|
|
680
|
+
return {
|
|
681
|
+
scrollToDate: scrollToDate
|
|
682
|
+
};
|
|
683
|
+
});
|
|
493
684
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
494
685
|
className: classes
|
|
495
686
|
}, React__default.createElement("div", {
|
|
496
687
|
className: headerClasses
|
|
497
|
-
},
|
|
688
|
+
}, showTitle && React__default.createElement("div", {
|
|
498
689
|
className: "calendar-title"
|
|
499
|
-
}, locale.calendaritem.title), React__default.createElement("div", {
|
|
690
|
+
}, title || locale.calendaritem.title), onBtn && React__default.createElement("div", {
|
|
691
|
+
className: "calendar-top-slot"
|
|
692
|
+
}, onBtn()), showSubTitle && React__default.createElement("div", {
|
|
500
693
|
className: "calendar-curr-month"
|
|
501
|
-
}, yearMonthTitle)
|
|
694
|
+
}, yearMonthTitle), React__default.createElement("div", {
|
|
502
695
|
className: "calendar-weeks",
|
|
503
696
|
ref: weeksPanel
|
|
504
697
|
}, weeks.map(function (item) {
|
|
@@ -508,16 +701,18 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
508
701
|
}, item);
|
|
509
702
|
}))), React__default.createElement("div", {
|
|
510
703
|
className: "nut-calendar-content",
|
|
511
|
-
|
|
512
|
-
onTouchMove: onTouchMove,
|
|
513
|
-
onTouchEnd: onTouchEnd,
|
|
704
|
+
onScroll: mothsViewScroll,
|
|
514
705
|
ref: months
|
|
515
706
|
}, React__default.createElement("div", {
|
|
516
707
|
className: "calendar-months-panel",
|
|
517
708
|
ref: monthsPanel
|
|
518
709
|
}, React__default.createElement("div", {
|
|
519
|
-
className: "
|
|
520
|
-
|
|
710
|
+
className: "viewArea",
|
|
711
|
+
ref: viewArea,
|
|
712
|
+
style: {
|
|
713
|
+
transform: "translateY(".concat(translateY, "px)")
|
|
714
|
+
}
|
|
715
|
+
}, state.monthsData.slice(monthDefaultRange[0], monthDefaultRange[1]).map(function (month, key) {
|
|
521
716
|
return React__default.createElement("div", {
|
|
522
717
|
className: "calendar-month",
|
|
523
718
|
key: key
|
|
@@ -527,31 +722,34 @@ var CalendarItem = function CalendarItem(props) {
|
|
|
527
722
|
className: "calendar-month-con"
|
|
528
723
|
}, React__default.createElement("div", {
|
|
529
724
|
className: monthitemclasses
|
|
530
|
-
}, month.monthData
|
|
725
|
+
}, month.monthData.map(function (day, i) {
|
|
531
726
|
return React__default.createElement("div", {
|
|
532
727
|
className: ['calendar-month-day', getClass(day, month)].join(' '),
|
|
533
|
-
key: index,
|
|
534
728
|
onClick: function onClick() {
|
|
535
729
|
chooseDay(day, month);
|
|
536
|
-
}
|
|
730
|
+
},
|
|
731
|
+
key: i
|
|
537
732
|
}, React__default.createElement("div", {
|
|
538
733
|
className: "calendar-day"
|
|
539
|
-
},
|
|
540
|
-
className: "calendar-curr-tips"
|
|
541
|
-
},
|
|
542
|
-
className: "calendar-
|
|
543
|
-
},
|
|
734
|
+
}, onDay ? onDay(day) : day.day), onTopInfo && React__default.createElement("div", {
|
|
735
|
+
className: "calendar-curr-tips calendar-curr-tips-top"
|
|
736
|
+
}, onTopInfo(day)), onBottomInfo && React__default.createElement("div", {
|
|
737
|
+
className: "calendar-curr-tips calendar-curr-tips-bottom"
|
|
738
|
+
}, onBottomInfo(day)), !onBottomInfo && showToday && isCurrDay(month, day.day) && React__default.createElement("div", {
|
|
739
|
+
className: "calendar-curr-tip-curr"
|
|
740
|
+
}, locale.calendaritem.today), isStartTip(day, month) && React__default.createElement("div", {
|
|
741
|
+
className: "calendar-day-tip ".concat(rangeTip() ? 'calendar-curr-tips-top' : '')
|
|
742
|
+
}, startText || locale.calendaritem.start), isEndTip(day, month) && React__default.createElement("div", {
|
|
544
743
|
className: "calendar-day-tip"
|
|
545
|
-
}, locale.calendaritem.end)
|
|
744
|
+
}, endText || locale.calendaritem.end));
|
|
546
745
|
}))));
|
|
547
|
-
}))), poppable && !isAutoBackFill ? React__default.createElement("div", {
|
|
746
|
+
})))), poppable && !isAutoBackFill ? React__default.createElement("div", {
|
|
548
747
|
className: "nut-calendar-footer"
|
|
549
748
|
}, React__default.createElement("div", {
|
|
550
749
|
className: "calendar-confirm-btn",
|
|
551
750
|
onClick: confirm
|
|
552
|
-
}, locale.confirm)) : ''));
|
|
553
|
-
};
|
|
554
|
-
|
|
751
|
+
}, confirmText || locale.confirm)) : ''));
|
|
752
|
+
});
|
|
555
753
|
CalendarItem.defaultProps = defaultProps;
|
|
556
754
|
CalendarItem.displayName = 'NutCalendarItem';
|
|
557
755
|
export { CalendarItem as default };
|