@nutui/nutui-react-taro 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/Address.js +4 -4
- package/dist/esm/Audio/style/index.js +4 -0
- package/dist/esm/Audio.js +18 -0
- package/dist/esm/AvatarGroup.js +4 -4
- package/dist/esm/Calendar/style/index.js +1 -2
- package/dist/esm/Calendar.js +6 -5
- package/dist/esm/CalendarItem.js +5 -5
- package/dist/esm/Cascader/style/index.js +2 -0
- package/dist/esm/Cascader.js +14 -0
- package/dist/esm/ConfigProvider.js +3 -3
- package/dist/esm/CountDown.js +4 -4
- package/dist/esm/DatePicker.js +4 -4
- package/dist/esm/Dialog.js +4 -4
- package/dist/esm/Empty.js +4 -4
- package/dist/esm/FixedNav.js +4 -4
- package/dist/esm/Grid/style/index.js +2 -0
- package/dist/esm/Grid.js +7 -0
- package/dist/esm/GridItem/style/index.js +2 -0
- package/dist/esm/GridItem.js +8 -0
- package/dist/esm/ImagePreview/style/index.js +2 -0
- package/dist/esm/ImagePreview.js +15 -0
- package/dist/esm/Infiniteloading.js +4 -4
- package/dist/esm/Input.js +4 -4
- package/dist/esm/Menu/style/index.js +3 -0
- package/dist/esm/Menu.js +7 -0
- package/dist/esm/MenuItem/style/index.js +3 -0
- package/dist/esm/MenuItem.js +11 -0
- package/dist/esm/NoticeBar.js +3 -2
- package/dist/esm/{Notification-dccc7625.js → Notification-422905bd.js} +2 -1
- package/dist/esm/Notify.js +3 -2
- package/dist/esm/NumberKeyboard.js +4 -4
- package/dist/esm/Pagination.js +4 -4
- package/dist/esm/Picker.js +4 -4
- package/dist/esm/Popover.js +3 -2
- package/dist/esm/Range.js +7 -5
- package/dist/esm/SearchBar.js +4 -4
- package/dist/esm/ShortPassword.js +4 -4
- package/dist/esm/SideNavBar.js +4 -4
- package/dist/esm/Signature.js +4 -4
- package/dist/esm/Swipe/style/index.js +2 -0
- package/dist/esm/Swipe.js +7 -0
- package/dist/esm/Swiper.js +3 -2
- package/dist/esm/Table.js +4 -4
- package/dist/esm/TextArea.js +4 -4
- package/dist/esm/TimeDetail.js +4 -4
- package/dist/esm/TimePannel.js +4 -4
- package/dist/esm/TimeSelect.js +4 -4
- package/dist/esm/Toast.js +4 -3
- package/dist/esm/Uploader.js +4 -4
- package/dist/esm/VirtualList.js +4 -4
- package/dist/esm/{address.taro-a1092e30.js → address.taro-4765a826.js} +17 -6
- package/dist/esm/audio.taro-cd6cc93b.js +292 -0
- package/dist/esm/{avatargroup-65173caa.js → avatargroup-1ca79066.js} +1 -1
- package/dist/esm/calendar.taro-1abb1925.js +89 -0
- package/dist/esm/{calendaritem.taro-fe84d94b.js → calendaritem.taro-3c06a809.js} +130 -5
- package/dist/esm/cascader.taro-31dbc60e.js +786 -0
- package/dist/esm/{configprovider-18657611.js → configprovider-9c393a29.js} +1 -1
- package/dist/esm/{configprovider.taro-98343012.js → configprovider.taro-1ff7f150.js} +2 -2
- package/dist/esm/{countdown.taro-cd6a1bd4.js → countdown.taro-b00d0d46.js} +1 -1
- package/dist/esm/{datepicker.taro-c1249537.js → datepicker.taro-e385849d.js} +1 -1
- package/dist/esm/{dialog.taro-5b850861.js → dialog.taro-c80b7b5f.js} +12 -18
- package/dist/esm/{empty.taro-6f86eda5.js → empty.taro-20b8adac.js} +1 -1
- package/dist/esm/{fixednav.taro-ca94fd6a.js → fixednav.taro-75e35339.js} +1 -1
- package/dist/esm/grid.taro-7fb43d02.js +90 -0
- package/dist/esm/griditem.taro-8020b409.js +98 -0
- package/dist/esm/imagepreview.taro-a0ddd8a2.js +813 -0
- package/dist/esm/{infiniteloading.taro-d2c0ca14.js → infiniteloading.taro-0a86819e.js} +1 -1
- package/dist/esm/{input.taro-2e31ebbb.js → input.taro-1d23861d.js} +1 -1
- package/dist/esm/menu.taro-03e3b011.js +153 -0
- package/dist/esm/menuitem.taro-56bf3205.js +195 -0
- package/dist/esm/{noticebar.taro-ae593896.js → noticebar.taro-1890c693.js} +3 -2
- package/dist/esm/{notify.taro-95b5f97e.js → notify.taro-22b8f4cd.js} +2 -1
- package/dist/esm/{numberkeyboard.taro-71b2e0eb.js → numberkeyboard.taro-5d685c76.js} +1 -1
- package/dist/esm/nutui-react.es.js +45 -36
- package/dist/esm/{pagination.taro-abc4a71e.js → pagination.taro-10449c4a.js} +1 -1
- package/dist/esm/{picker.taro-0eb8bfa3.js → picker.taro-216cc3cb.js} +1 -1
- package/dist/esm/{popover.taro-4c102df6.js → popover.taro-9b3da0fa.js} +17 -71
- package/dist/esm/{range.taro-034fcf7a.js → range.taro-fe08c5f4.js} +118 -110
- package/dist/esm/render-4a3856cb.js +32 -0
- package/dist/esm/{searchbar.taro-4c6091cb.js → searchbar.taro-450d2f88.js} +1 -1
- package/dist/esm/{shortpassword.taro-ce46b9cd.js → shortpassword.taro-08a05360.js} +23 -18
- package/dist/esm/{sidenavbar.taro-36f1e118.js → sidenavbar.taro-dd471476.js} +1 -1
- package/dist/esm/{signature.taro-45aedfa9.js → signature.taro-7cb77bab.js} +1 -1
- package/dist/esm/swipe.taro-dfb9a049.js +264 -0
- package/dist/esm/{swiper.taro-59bf2777.js → swiper.taro-7a2ef124.js} +2 -1
- package/dist/esm/{table.taro-49009dfc.js → table.taro-305e0317.js} +1 -1
- package/dist/esm/{textarea.taro-0c40e966.js → textarea.taro-700b04c2.js} +1 -1
- package/dist/esm/{timedetail.taro-0e31b4a5.js → timedetail.taro-7cc00243.js} +1 -1
- package/dist/esm/{timepannel.taro-2d54b3db.js → timepannel.taro-e24537e4.js} +1 -1
- package/dist/esm/{timeselect.taro-c35d3490.js → timeselect.taro-210fd548.js} +1 -1
- package/dist/esm/{toast.taro-48539c09.js → toast.taro-bb181833.js} +1 -1
- package/dist/esm/{uploader.taro-ece83a00.js → uploader.taro-f7528535.js} +1 -1
- package/dist/esm/useClientRect-8b7cc406.js +74 -0
- package/dist/esm/{virtuallist.taro-2ff1a5ad.js → virtuallist.taro-ce9619f9.js} +1 -1
- package/dist/esm/{zh-CN-f5124686.js → zh-CN-91090ae2.js} +16 -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 +5595 -4062
- package/dist/nutui.react.umd.js +20243 -30
- 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/audio.taro.d.ts +18 -0
- package/dist/types/audio/index.taro.d.ts +2 -0
- package/dist/types/cascader/cascader.taro.d.ts +25 -0
- package/dist/types/cascader/cascaderItem.taro.d.ts +25 -0
- package/dist/types/cascader/index.taro.d.ts +2 -0
- package/dist/types/checkbox/checkbox.taro.d.ts +2 -2
- package/dist/types/checkboxgroup/checkboxgroup.taro.d.ts +2 -2
- package/dist/types/dialog/dialog.taro.d.ts +2 -1
- package/dist/types/grid/grid.taro.d.ts +16 -0
- package/dist/types/grid/index.taro.d.ts +2 -0
- package/dist/types/griditem/griditem.taro.d.ts +20 -0
- package/dist/types/griditem/index.taro.d.ts +2 -0
- package/dist/types/icon/icon.taro.d.ts +1 -2
- package/dist/types/imagepreview/imagepreview.taro.d.ts +26 -0
- package/dist/types/imagepreview/index.taro.d.ts +2 -0
- package/dist/types/menu/index.taro.d.ts +2 -0
- package/dist/types/menu/menu.taro.d.ts +12 -0
- package/dist/types/menuitem/index.taro.d.ts +2 -0
- package/dist/types/menuitem/menuitem.taro.d.ts +23 -0
- package/dist/types/notify/notify.taro.d.ts +13 -0
- package/dist/types/nutui.react.d.ts +95 -1
- package/dist/types/picker/picker.taro.d.ts +2 -2
- 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.taro.d.ts +14 -2
- package/dist/types/sidenavbaritem/sidenavbaritem.taro.d.ts +10 -2
- package/dist/types/subsidenavbar/subsidenavbar.taro.d.ts +13 -3
- package/dist/types/swipe/index.taro.d.ts +2 -0
- package/dist/types/swipe/swipe.taro.d.ts +41 -0
- package/dist/types/table/table.taro.d.ts +2 -1
- package/dist/types/toast/toast.taro.d.ts +18 -0
- package/dist/types/virtuallist/virtuallist.taro.d.ts +2 -1
- package/package.json +4 -4
- package/dist/esm/calendar.taro-4b2103c1.js +0 -621
- package/dist/esm/raf-3fbb5f92.js +0 -126
|
@@ -1,621 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
|
-
import React__default, { useState, useRef, useEffect } from 'react';
|
|
10
|
-
import { P as Popup } from './popup-67173ec6.js';
|
|
11
|
-
import classNames from 'classnames';
|
|
12
|
-
import { c as cn } from './bem-893ad28d.js';
|
|
13
|
-
import { U as Utils, r as requestAniFrame } from './raf-3fbb5f92.js';
|
|
14
|
-
import { u as useConfig } from './configprovider-18657611.js';
|
|
15
|
-
var defaultProps$1 = {
|
|
16
|
-
type: 'one',
|
|
17
|
-
isAutoBackFill: false,
|
|
18
|
-
poppable: true,
|
|
19
|
-
visible: false,
|
|
20
|
-
title: '日历选择',
|
|
21
|
-
defaultValue: '',
|
|
22
|
-
startDate: Utils.getDay(0),
|
|
23
|
-
endDate: Utils.getDay(365),
|
|
24
|
-
onChoose: function onChoose(data) {},
|
|
25
|
-
onUpdate: function onUpdate() {},
|
|
26
|
-
onClose: function onClose() {}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var CalendarItem = function CalendarItem(props) {
|
|
30
|
-
var _classNames, _classNames2;
|
|
31
|
-
|
|
32
|
-
var _useConfig = useConfig(),
|
|
33
|
-
locale = _useConfig.locale;
|
|
34
|
-
|
|
35
|
-
var _defaultProps$1$props = _objectSpread(_objectSpread({}, defaultProps$1), props),
|
|
36
|
-
type = _defaultProps$1$props.type,
|
|
37
|
-
isAutoBackFill = _defaultProps$1$props.isAutoBackFill,
|
|
38
|
-
poppable = _defaultProps$1$props.poppable,
|
|
39
|
-
title = _defaultProps$1$props.title,
|
|
40
|
-
defaultValue = _defaultProps$1$props.defaultValue,
|
|
41
|
-
startDate = _defaultProps$1$props.startDate,
|
|
42
|
-
endDate = _defaultProps$1$props.endDate,
|
|
43
|
-
onChoose = _defaultProps$1$props.onChoose,
|
|
44
|
-
onUpdate = _defaultProps$1$props.onUpdate,
|
|
45
|
-
onClose = _defaultProps$1$props.onClose;
|
|
46
|
-
|
|
47
|
-
var weeks = locale.calendaritem.weekdays;
|
|
48
|
-
|
|
49
|
-
var _useState = useState(''),
|
|
50
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
51
|
-
yearMonthTitle = _useState2[0],
|
|
52
|
-
setYearMonthTitle = _useState2[1];
|
|
53
|
-
|
|
54
|
-
var _useState3 = useState(false),
|
|
55
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
-
unLoadPrev = _useState4[0],
|
|
57
|
-
setUnLoadPrev = _useState4[1];
|
|
58
|
-
|
|
59
|
-
var _useState5 = useState([]),
|
|
60
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
61
|
-
monthsData = _useState6[0],
|
|
62
|
-
setMonthsData = _useState6[1];
|
|
63
|
-
|
|
64
|
-
var _useState7 = useState({
|
|
65
|
-
currDate: '',
|
|
66
|
-
touchParams: {
|
|
67
|
-
startY: 0,
|
|
68
|
-
endY: 0,
|
|
69
|
-
startTime: 0,
|
|
70
|
-
endTime: 0,
|
|
71
|
-
lastY: 0,
|
|
72
|
-
lastTime: 0
|
|
73
|
-
},
|
|
74
|
-
transformY: 0,
|
|
75
|
-
translateY: 0,
|
|
76
|
-
scrollDistance: 0,
|
|
77
|
-
defaultData: [],
|
|
78
|
-
chooseData: [],
|
|
79
|
-
monthsData: [],
|
|
80
|
-
dayPrefix: 'calendar-month-day',
|
|
81
|
-
startData: '',
|
|
82
|
-
endData: '',
|
|
83
|
-
isRange: type === 'range',
|
|
84
|
-
timer: 0
|
|
85
|
-
}),
|
|
86
|
-
_useState8 = _slicedToArray(_useState7, 1),
|
|
87
|
-
state = _useState8[0];
|
|
88
|
-
|
|
89
|
-
var weeksPanel = useRef(null);
|
|
90
|
-
var months = useRef(null);
|
|
91
|
-
var monthsPanel = useRef(null);
|
|
92
|
-
var b = cn('calendar');
|
|
93
|
-
var classes = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b(''), "-tile"), !poppable), _defineProperty(_classNames, "".concat(b(''), "-nofooter"), !!isAutoBackFill), _classNames), b(''));
|
|
94
|
-
var headerClasses = classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b(''), "-header"), true), _defineProperty(_classNames2, "".concat(b(''), "-header-tile"), !poppable), _classNames2));
|
|
95
|
-
var monthitemclasses = classNames(_defineProperty({
|
|
96
|
-
'calendar-month-item': true
|
|
97
|
-
}, "".concat(type === 'range' ? 'month-item-range' : ''), true));
|
|
98
|
-
|
|
99
|
-
var splitDate = function splitDate(date) {
|
|
100
|
-
return date.split('-');
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
var isStart = function isStart(currDate) {
|
|
104
|
-
return Utils.isEqual(state.currDate[0], currDate);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
var isEnd = function isEnd(currDate) {
|
|
108
|
-
return Utils.isEqual(state.currDate[1], currDate);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
var getCurrDate = function getCurrDate(day, month, isRange) {
|
|
112
|
-
return isRange ? "".concat(month.curData[3], "-").concat(month.curData[4], "-").concat(Utils.getNumTwoBit(+day.day)) : "".concat(month.curData[0], "-").concat(month.curData[1], "-").concat(Utils.getNumTwoBit(+day.day));
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
var getClass = function getClass(day, month, isRange) {
|
|
116
|
-
var currDate = getCurrDate(day, month, isRange);
|
|
117
|
-
|
|
118
|
-
if (day.type === 'curr') {
|
|
119
|
-
if (!state.isRange && Utils.isEqual(state.currDate, currDate) || state.isRange && (isStart(currDate) || isEnd(currDate))) {
|
|
120
|
-
return "".concat(state.dayPrefix, "-active");
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (startDate && Utils.compareDate(currDate, startDate) || endDate && Utils.compareDate(endDate, currDate)) {
|
|
124
|
-
return "".concat(state.dayPrefix, "-disabled");
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (state.isRange && Array.isArray(state.currDate) && Object.values(state.currDate).length === 2 && Utils.compareDate(state.currDate[0], currDate) && Utils.compareDate(currDate, state.currDate[1])) {
|
|
128
|
-
return "".concat(state.dayPrefix, "-choose");
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return "".concat(state.dayPrefix, "-disabled");
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
var isActive = function isActive(day, month) {
|
|
138
|
-
return state.isRange && day.type === 'curr' && getClass(day, month) === 'calendar-month-day-active';
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
var isCurrDay = function isCurrDay(month, day) {
|
|
142
|
-
var date = "".concat(month.curData[0], "-").concat(month.curData[1], "-").concat(day);
|
|
143
|
-
return Utils.isEqual(date, Utils.date2Str(new Date()));
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
var confirm = function confirm() {
|
|
147
|
-
if (state.isRange && state.chooseData.length === 2 || !state.isRange) {
|
|
148
|
-
onChoose && onChoose(state.chooseData);
|
|
149
|
-
|
|
150
|
-
if (poppable) {
|
|
151
|
-
onUpdate && onUpdate();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
var chooseDay = function chooseDay(day, month, isFirst, isRange) {
|
|
157
|
-
if (getClass(day, month, isRange) !== "".concat(state.dayPrefix, "-disabled")) {
|
|
158
|
-
var days = _toConsumableArray(month.curData);
|
|
159
|
-
|
|
160
|
-
days = isRange ? days.splice(3) : days.splice(0, 3);
|
|
161
|
-
days[2] = typeof day.day === 'number' ? Utils.getNumTwoBit(day.day) : day.day;
|
|
162
|
-
days[3] = "".concat(days[0], "-").concat(days[1], "-").concat(days[2]);
|
|
163
|
-
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
164
|
-
|
|
165
|
-
if (!state.isRange) {
|
|
166
|
-
state.currDate = days[3];
|
|
167
|
-
state.chooseData = _toConsumableArray(days);
|
|
168
|
-
} else {
|
|
169
|
-
if (Object.values(state.currDate).length === 2) {
|
|
170
|
-
state.currDate = [days[3]];
|
|
171
|
-
} else if (Utils.compareDate(state.currDate[0], days[3])) {
|
|
172
|
-
Array.isArray(state.currDate) && state.currDate.push(days[3]);
|
|
173
|
-
} else {
|
|
174
|
-
Array.isArray(state.currDate) && state.currDate.unshift(days[3]);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (state.chooseData.length === 2 || !state.chooseData.length) {
|
|
178
|
-
state.chooseData = _toConsumableArray(days);
|
|
179
|
-
} else if (Utils.compareDate(state.chooseData[3], days[3])) {
|
|
180
|
-
state.chooseData = [_toConsumableArray(state.chooseData), _toConsumableArray(days)];
|
|
181
|
-
} else {
|
|
182
|
-
state.chooseData = [_toConsumableArray(days), _toConsumableArray(state.chooseData)];
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (isAutoBackFill && !isFirst) {
|
|
187
|
-
confirm();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
setMonthsData(state.monthsData.slice());
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
var isStartTip = function isStartTip(day, month) {
|
|
195
|
-
if (isActive(day, month)) {
|
|
196
|
-
return isStart(getCurrDate(day, month));
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return false;
|
|
200
|
-
}; // 是否有结束提示
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var isEndTip = function isEndTip(day, month) {
|
|
204
|
-
if (isStartTip(day, month)) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return isActive(day, month);
|
|
209
|
-
}; // 获取当前月数据
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
var getCurrData = function getCurrData(type) {
|
|
213
|
-
var monthData = type === 'prev' ? state.monthsData[0] : state.monthsData[state.monthsData.length - 1];
|
|
214
|
-
var year = parseInt(monthData.curData[0]);
|
|
215
|
-
var month = parseInt(monthData.curData[1].toString().replace(/^0/, ''));
|
|
216
|
-
|
|
217
|
-
switch (type) {
|
|
218
|
-
case 'prev':
|
|
219
|
-
month === 1 && (year -= 1);
|
|
220
|
-
month = month === 1 ? 12 : --month;
|
|
221
|
-
break;
|
|
222
|
-
|
|
223
|
-
case 'next':
|
|
224
|
-
month === 12 && (year += 1);
|
|
225
|
-
month = month === 12 ? 1 : ++month;
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return [year, Utils.getNumTwoBit(month), Utils.getMonthDays(String(year), String(month))];
|
|
230
|
-
}; // 获取日期状态
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
var getDaysStatus = function getDaysStatus(days, type) {
|
|
234
|
-
// 修复:当某个月的1号是周日时,月份下方会空出来一行
|
|
235
|
-
if (type === 'prev' && days >= 7) {
|
|
236
|
-
days -= 7;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return Array.from(Array(days), function (v, k) {
|
|
240
|
-
return {
|
|
241
|
-
day: k + 1,
|
|
242
|
-
type: type
|
|
243
|
-
};
|
|
244
|
-
});
|
|
245
|
-
}; // 获取月数据
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
var getMonth = function getMonth(curData, type) {
|
|
249
|
-
var preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
|
|
250
|
-
var currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
|
|
251
|
-
var title = {
|
|
252
|
-
year: curData[0],
|
|
253
|
-
month: curData[1]
|
|
254
|
-
};
|
|
255
|
-
var monthInfo = {
|
|
256
|
-
curData: curData,
|
|
257
|
-
title: locale.calendaritem.monthTitle(title.year, title.month),
|
|
258
|
-
monthData: [].concat(_toConsumableArray(getDaysStatus(preMonthDays, 'prev')), _toConsumableArray(getDaysStatus(currMonthDays, 'curr')))
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
if (type === 'next') {
|
|
262
|
-
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]))) {
|
|
263
|
-
state.monthsData.push(monthInfo);
|
|
264
|
-
}
|
|
265
|
-
} else if (!state.startData || !Utils.compareDate("".concat(curData[0], "-").concat(curData[1], "-").concat(curData[2]), "".concat(state.startData[0], "-").concat(state.startData[1], "-01"))) {
|
|
266
|
-
state.monthsData.unshift(monthInfo);
|
|
267
|
-
} else {
|
|
268
|
-
setUnLoadPrev(true);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
setMonthsData(state.monthsData);
|
|
272
|
-
}; // 监听月份滚动,改变月份标题
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
var loadScroll = function loadScroll() {
|
|
276
|
-
if (!props.poppable) {
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
requestAniFrame(function () {
|
|
281
|
-
if (weeksPanel !== null && weeksPanel !== void 0 && weeksPanel.current && monthsPanel !== null && monthsPanel !== void 0 && monthsPanel.current) {
|
|
282
|
-
var top = weeksPanel === null || weeksPanel === void 0 ? void 0 : weeksPanel.current.getBoundingClientRect().bottom;
|
|
283
|
-
var monthsDoms = monthsPanel.current.getElementsByClassName('calendar-month');
|
|
284
|
-
|
|
285
|
-
for (var i = 0; i < monthsDoms.length; i++) {
|
|
286
|
-
if (monthsDoms[i].getBoundingClientRect().top <= top && monthsDoms[i].getBoundingClientRect().bottom >= top) {
|
|
287
|
-
setYearMonthTitle(state.monthsData[i].title);
|
|
288
|
-
} else if (state.scrollDistance === 0) {
|
|
289
|
-
setYearMonthTitle(state.monthsData[0].title);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
}; // 设置月份滚动距离和速度
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
var setTransform = function setTransform() {
|
|
298
|
-
var translateY = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
299
|
-
var type = arguments.length > 1 ? arguments[1] : undefined;
|
|
300
|
-
var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
301
|
-
|
|
302
|
-
if (monthsPanel !== null && monthsPanel !== void 0 && monthsPanel.current) {
|
|
303
|
-
if (type === 'end') {
|
|
304
|
-
monthsPanel.current.style.webkitTransition = "transform ".concat(time, "ms cubic-bezier(0.19, 1, 0.22, 1)");
|
|
305
|
-
clearTimeout(state.timer);
|
|
306
|
-
state.timer = setTimeout(function () {
|
|
307
|
-
loadScroll();
|
|
308
|
-
}, time);
|
|
309
|
-
} else {
|
|
310
|
-
monthsPanel.current.style.webkitTransition = '';
|
|
311
|
-
loadScroll();
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
monthsPanel.current.style.webkitTransform = "translateY(".concat(translateY, "px)");
|
|
315
|
-
state.scrollDistance = translateY;
|
|
316
|
-
}
|
|
317
|
-
}; // 计算滚动方向和距离
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
var setMove = function setMove(move, type, time) {
|
|
321
|
-
var _months$current, _monthsPanel$current;
|
|
322
|
-
|
|
323
|
-
var updateMove = move + state.transformY;
|
|
324
|
-
var h = ((_months$current = months.current) === null || _months$current === void 0 ? void 0 : _months$current.offsetHeight) || 0;
|
|
325
|
-
var offsetHeight = ((_monthsPanel$current = monthsPanel.current) === null || _monthsPanel$current === void 0 ? void 0 : _monthsPanel$current.offsetHeight) || 0;
|
|
326
|
-
|
|
327
|
-
if (type === 'end') {
|
|
328
|
-
// 限定滚动距离
|
|
329
|
-
if (updateMove > 0) {
|
|
330
|
-
updateMove = 0;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (updateMove < 0 && updateMove < -offsetHeight + h) {
|
|
334
|
-
updateMove = -offsetHeight + h;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
if (offsetHeight <= h && state.monthsData.length === 1) {
|
|
338
|
-
updateMove = 0;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
setTransform(updateMove, type, time);
|
|
342
|
-
} else {
|
|
343
|
-
if (updateMove > 0 && updateMove > 100) {
|
|
344
|
-
updateMove = 100;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (updateMove < -offsetHeight + h - 100 && state.monthsData.length > 1) {
|
|
348
|
-
updateMove = -offsetHeight + h - 100;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
if (updateMove < 0 && updateMove < -100 && state.monthsData.length === 1) {
|
|
352
|
-
updateMove = -100;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
setTransform(updateMove);
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
var onTouchStart = function onTouchStart(event) {
|
|
360
|
-
event.stopPropagation();
|
|
361
|
-
var changedTouches = event.changedTouches[0];
|
|
362
|
-
state.touchParams.startY = changedTouches.pageY;
|
|
363
|
-
state.touchParams.startTime = event.timeStamp || Date.now();
|
|
364
|
-
state.transformY = state.scrollDistance;
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
var onTouchMove = function onTouchMove(event) {
|
|
368
|
-
event.stopPropagation();
|
|
369
|
-
var changedTouches = event.changedTouches[0];
|
|
370
|
-
state.touchParams.lastY = changedTouches.pageY;
|
|
371
|
-
state.touchParams.lastTime = event.timeStamp || Date.now();
|
|
372
|
-
var move = state.touchParams.lastY - state.touchParams.startY;
|
|
373
|
-
|
|
374
|
-
if (Math.abs(move) < 5) {
|
|
375
|
-
return false;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
setMove(move);
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
var onTouchEnd = function onTouchEnd(event) {
|
|
382
|
-
var _months$current2, _monthsPanel$current2;
|
|
383
|
-
|
|
384
|
-
event.stopPropagation();
|
|
385
|
-
var changedTouches = event.changedTouches[0];
|
|
386
|
-
state.touchParams.lastY = changedTouches.pageY;
|
|
387
|
-
state.touchParams.lastTime = event.timeStamp || Date.now();
|
|
388
|
-
var move = state.touchParams.lastY - state.touchParams.startY;
|
|
389
|
-
|
|
390
|
-
if (Math.abs(move) < 5) {
|
|
391
|
-
return false;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
var updateMove = move + state.transformY;
|
|
395
|
-
var h = ((_months$current2 = months.current) === null || _months$current2 === void 0 ? void 0 : _months$current2.offsetHeight) || 0;
|
|
396
|
-
var offsetHeight = ((_monthsPanel$current2 = monthsPanel.current) === null || _monthsPanel$current2 === void 0 ? void 0 : _monthsPanel$current2.offsetHeight) || 0;
|
|
397
|
-
|
|
398
|
-
if (updateMove > 0) {
|
|
399
|
-
getMonth(getCurrData('prev'), 'prev');
|
|
400
|
-
} else if (updateMove < 0 && updateMove < -offsetHeight + (Math.abs(move) > h ? Math.abs(move) : h) * 5) {
|
|
401
|
-
getMonth(getCurrData('next'), 'next');
|
|
402
|
-
|
|
403
|
-
if (Math.abs(move) >= 300) {
|
|
404
|
-
getMonth(getCurrData('next'), 'next');
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
var moveTime = state.touchParams.lastTime - state.touchParams.startTime;
|
|
409
|
-
|
|
410
|
-
if (moveTime <= 300) {
|
|
411
|
-
move *= 2;
|
|
412
|
-
moveTime += 1000;
|
|
413
|
-
setMove(move, 'end', moveTime);
|
|
414
|
-
} else {
|
|
415
|
-
setMove(move, 'end');
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
var initData = function initData() {
|
|
420
|
-
// 初始化开始结束数据
|
|
421
|
-
state.startData = startDate ? splitDate(startDate) : '';
|
|
422
|
-
state.endData = endDate ? splitDate(endDate) : ''; // 初始化当前日期
|
|
423
|
-
|
|
424
|
-
if (!defaultValue) {
|
|
425
|
-
state.currDate = state.isRange ? [Utils.date2Str(new Date()), Utils.getDay(1)] : Utils.date2Str(new Date());
|
|
426
|
-
} else {
|
|
427
|
-
state.currDate = state.isRange ? _toConsumableArray(defaultValue) : defaultValue;
|
|
428
|
-
} // 日期转化为数组
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
if (state.isRange && Array.isArray(state.currDate)) {
|
|
432
|
-
if (startDate && Utils.compareDate(state.currDate[0], startDate)) {
|
|
433
|
-
state.currDate.splice(0, 1, startDate);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
if (endDate && Utils.compareDate(endDate, state.currDate[1])) {
|
|
437
|
-
state.currDate.splice(1, 1, endDate);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
state.defaultData = [].concat(_toConsumableArray(splitDate(state.currDate[0])), _toConsumableArray(splitDate(state.currDate[1])));
|
|
441
|
-
} else {
|
|
442
|
-
if (startDate && Utils.compareDate(state.currDate, startDate)) {
|
|
443
|
-
state.currDate = startDate;
|
|
444
|
-
} else if (endDate && !Utils.compareDate(state.currDate, endDate)) {
|
|
445
|
-
state.currDate = endDate;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
state.defaultData = _toConsumableArray(splitDate(state.currDate));
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
getMonth(state.defaultData, 'next');
|
|
452
|
-
setYearMonthTitle(state.monthsData[0].title);
|
|
453
|
-
var i = 1;
|
|
454
|
-
|
|
455
|
-
do {
|
|
456
|
-
getMonth(getCurrData('next'), 'next');
|
|
457
|
-
} while (i++ < 4);
|
|
458
|
-
|
|
459
|
-
if (state.isRange) {
|
|
460
|
-
chooseDay({
|
|
461
|
-
day: state.defaultData[2],
|
|
462
|
-
type: 'curr'
|
|
463
|
-
}, state.monthsData[0], true);
|
|
464
|
-
chooseDay({
|
|
465
|
-
day: state.defaultData[5],
|
|
466
|
-
type: 'curr'
|
|
467
|
-
}, state.monthsData[0], true, true);
|
|
468
|
-
} else {
|
|
469
|
-
chooseDay({
|
|
470
|
-
day: state.defaultData[2],
|
|
471
|
-
type: 'curr'
|
|
472
|
-
}, state.monthsData[0], true);
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
useEffect(function () {
|
|
477
|
-
initData();
|
|
478
|
-
}, []);
|
|
479
|
-
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
480
|
-
className: classes
|
|
481
|
-
}, React__default.createElement("div", {
|
|
482
|
-
className: headerClasses
|
|
483
|
-
}, poppable ? React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
484
|
-
className: "calendar-title"
|
|
485
|
-
}, locale.calendaritem.title), React__default.createElement("div", {
|
|
486
|
-
className: "calendar-curr-month"
|
|
487
|
-
}, yearMonthTitle)) : '', React__default.createElement("div", {
|
|
488
|
-
className: "calendar-weeks",
|
|
489
|
-
ref: weeksPanel
|
|
490
|
-
}, weeks.map(function (item) {
|
|
491
|
-
return React__default.createElement("div", {
|
|
492
|
-
className: "calendar-week-item",
|
|
493
|
-
key: item
|
|
494
|
-
}, item);
|
|
495
|
-
}))), React__default.createElement("div", {
|
|
496
|
-
className: "nut-calendar-content",
|
|
497
|
-
onTouchStart: onTouchStart,
|
|
498
|
-
onTouchMove: onTouchMove,
|
|
499
|
-
onTouchEnd: onTouchEnd,
|
|
500
|
-
ref: months
|
|
501
|
-
}, React__default.createElement("div", {
|
|
502
|
-
className: "calendar-months-panel",
|
|
503
|
-
ref: monthsPanel
|
|
504
|
-
}, React__default.createElement("div", {
|
|
505
|
-
className: "calendar-loading-tip"
|
|
506
|
-
}, !unLoadPrev ? locale.calendaritem.loadPreviousMonth : locale.calendaritem.noEarlierMonth), monthsData.map(function (month, key) {
|
|
507
|
-
return React__default.createElement("div", {
|
|
508
|
-
className: "calendar-month",
|
|
509
|
-
key: key
|
|
510
|
-
}, React__default.createElement("div", {
|
|
511
|
-
className: "calendar-month-title"
|
|
512
|
-
}, month.title), React__default.createElement("div", {
|
|
513
|
-
className: "calendar-month-con"
|
|
514
|
-
}, React__default.createElement("div", {
|
|
515
|
-
className: monthitemclasses
|
|
516
|
-
}, month.monthData && month.monthData.map(function (day, index) {
|
|
517
|
-
return React__default.createElement("div", {
|
|
518
|
-
className: ['calendar-month-day', getClass(day, month)].join(' '),
|
|
519
|
-
key: index,
|
|
520
|
-
onClick: function onClick() {
|
|
521
|
-
chooseDay(day, month);
|
|
522
|
-
}
|
|
523
|
-
}, React__default.createElement("div", {
|
|
524
|
-
className: "calendar-day"
|
|
525
|
-
}, day.type === 'curr' ? day.day : ''), isCurrDay(month, day.day) ? React__default.createElement("div", {
|
|
526
|
-
className: "calendar-curr-tips"
|
|
527
|
-
}, locale.calendaritem.today) : '', isStartTip(day, month) ? React__default.createElement("div", {
|
|
528
|
-
className: "calendar-day-tip"
|
|
529
|
-
}, locale.calendaritem.start) : '', isEndTip(day, month) ? React__default.createElement("div", {
|
|
530
|
-
className: "calendar-day-tip"
|
|
531
|
-
}, locale.calendaritem.end) : '');
|
|
532
|
-
}))));
|
|
533
|
-
}))), poppable && !isAutoBackFill ? React__default.createElement("div", {
|
|
534
|
-
className: "nut-calendar-footer"
|
|
535
|
-
}, React__default.createElement("div", {
|
|
536
|
-
className: "calendar-confirm-btn",
|
|
537
|
-
onClick: confirm
|
|
538
|
-
}, locale.confirm)) : ''));
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
CalendarItem.defaultProps = defaultProps$1;
|
|
542
|
-
CalendarItem.displayName = 'NutCalendarItem';
|
|
543
|
-
var defaultProps = {
|
|
544
|
-
type: 'one',
|
|
545
|
-
isAutoBackFill: false,
|
|
546
|
-
poppable: true,
|
|
547
|
-
visible: false,
|
|
548
|
-
title: '日历选择',
|
|
549
|
-
defaultValue: '',
|
|
550
|
-
startDate: Utils.getDay(0),
|
|
551
|
-
endDate: Utils.getDay(365),
|
|
552
|
-
onClose: function onClose() {},
|
|
553
|
-
onChoose: function onChoose(param) {}
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
var Calendar = function Calendar(props) {
|
|
557
|
-
var _useConfig2 = useConfig(),
|
|
558
|
-
locale = _useConfig2.locale;
|
|
559
|
-
|
|
560
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
561
|
-
children = _defaultProps$props.children,
|
|
562
|
-
poppable = _defaultProps$props.poppable,
|
|
563
|
-
visible = _defaultProps$props.visible,
|
|
564
|
-
type = _defaultProps$props.type,
|
|
565
|
-
isAutoBackFill = _defaultProps$props.isAutoBackFill,
|
|
566
|
-
title = _defaultProps$props.title,
|
|
567
|
-
defaultValue = _defaultProps$props.defaultValue,
|
|
568
|
-
startDate = _defaultProps$props.startDate,
|
|
569
|
-
endDate = _defaultProps$props.endDate,
|
|
570
|
-
onClose = _defaultProps$props.onClose,
|
|
571
|
-
onChoose = _defaultProps$props.onChoose;
|
|
572
|
-
|
|
573
|
-
var close = function close() {
|
|
574
|
-
onClose && onClose();
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
var update = function update() {};
|
|
578
|
-
|
|
579
|
-
var choose = function choose(param) {
|
|
580
|
-
close();
|
|
581
|
-
onChoose && onChoose(param);
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
var closePopup = function closePopup() {
|
|
585
|
-
close();
|
|
586
|
-
};
|
|
587
|
-
|
|
588
|
-
return React__default.createElement(React__default.Fragment, null, poppable ? React__default.createElement(Popup, {
|
|
589
|
-
visible: visible,
|
|
590
|
-
position: "bottom",
|
|
591
|
-
round: true,
|
|
592
|
-
closeable: true,
|
|
593
|
-
onClickOverlay: closePopup,
|
|
594
|
-
onClickCloseIcon: closePopup
|
|
595
|
-
}, React__default.createElement(CalendarItem, {
|
|
596
|
-
type: type,
|
|
597
|
-
isAutoBackFill: isAutoBackFill,
|
|
598
|
-
poppable: poppable,
|
|
599
|
-
title: locale.calendaritem.title || title,
|
|
600
|
-
defaultValue: defaultValue,
|
|
601
|
-
startDate: startDate,
|
|
602
|
-
endDate: endDate,
|
|
603
|
-
onUpdate: update,
|
|
604
|
-
onClose: close,
|
|
605
|
-
onChoose: choose
|
|
606
|
-
})) : React__default.createElement(CalendarItem, {
|
|
607
|
-
type: type,
|
|
608
|
-
isAutoBackFill: isAutoBackFill,
|
|
609
|
-
poppable: poppable,
|
|
610
|
-
title: locale.calendaritem.title,
|
|
611
|
-
defaultValue: defaultValue,
|
|
612
|
-
startDate: startDate,
|
|
613
|
-
endDate: endDate,
|
|
614
|
-
onClose: close,
|
|
615
|
-
onChoose: choose
|
|
616
|
-
}));
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
Calendar.defaultProps = defaultProps;
|
|
620
|
-
Calendar.displayName = 'NutCalendar';
|
|
621
|
-
export { Calendar as C };
|