@nutui/nutui-react 1.5.1-beta.0 → 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -35
- package/dist/esm/ActionSheet.js +62 -54
- package/dist/esm/Address/style/index.js +0 -1
- package/dist/esm/Address.js +235 -330
- package/dist/esm/Animate.js +43 -32
- package/dist/esm/AnimatingNumbers.js +88 -49
- package/dist/esm/Audio/style/index.js +0 -1
- package/dist/esm/Audio.js +104 -114
- package/dist/esm/Avatar.js +65 -78
- package/dist/esm/AvatarContext.js +5 -0
- package/dist/esm/AvatarGroup.js +46 -27
- package/dist/esm/BackTop/style/index.js +1 -1
- package/dist/esm/BackTop.js +74 -76
- package/dist/esm/Badge.js +57 -54
- package/dist/esm/Barrage.js +45 -32
- package/dist/esm/Button/style/index.js +1 -1
- package/dist/esm/Button.js +66 -87
- package/dist/esm/Calendar.js +80 -79
- package/dist/esm/CalendarItem.js +199 -231
- package/dist/esm/Card.js +44 -37
- package/dist/esm/Cascader.js +430 -433
- package/dist/esm/Cell/style/index.js +1 -1
- package/dist/esm/Cell.js +57 -87
- package/dist/esm/CellGroup.js +7 -5
- package/dist/esm/Checkbox/style/index.js +0 -1
- package/dist/esm/Checkbox.js +11 -8
- package/dist/esm/CheckboxGroup.js +78 -71
- package/dist/esm/CircleProgress.js +50 -40
- package/dist/esm/Col.js +46 -41
- package/dist/esm/Collapse.js +44 -44
- package/dist/esm/CollapseItem/style/index.js +1 -1
- package/dist/esm/CollapseItem.js +64 -104
- package/dist/esm/ConfigProvider.js +400 -101
- package/dist/esm/CountDown.js +90 -95
- package/dist/esm/DatePicker.js +104 -123
- package/dist/esm/Dialog.js +98 -104
- package/dist/esm/Divider.js +36 -27
- package/dist/esm/Drag.js +55 -59
- package/dist/esm/Elevator.js +77 -88
- package/dist/esm/Ellipsis.js +80 -79
- package/dist/esm/Empty.js +50 -44
- package/dist/esm/FixedNav/style/index.js +0 -1
- package/dist/esm/FixedNav.js +57 -65
- package/dist/esm/Form.js +1154 -123
- package/dist/esm/FormItem.js +7 -5
- package/dist/esm/Grid/style/index.js +1 -1
- package/dist/esm/Grid.js +51 -55
- package/dist/esm/GridItem.js +7 -124
- package/dist/esm/Icon.js +83 -5
- package/dist/esm/Image.js +123 -122
- package/dist/esm/ImagePreview.js +75 -93
- package/dist/esm/Indicator.js +41 -36
- package/dist/esm/Infiniteloading/style/index.js +1 -1
- package/dist/esm/Infiniteloading.js +77 -93
- package/dist/esm/Input/style/index.js +1 -1
- package/dist/esm/Input.js +120 -172
- package/dist/esm/InputNumber/style/index.js +1 -1
- package/dist/esm/InputNumber.js +133 -167
- package/dist/esm/Layout.js +27 -6
- package/dist/esm/Menu.js +84 -86
- package/dist/esm/MenuItem/style/index.js +0 -1
- package/dist/esm/MenuItem.js +76 -86
- package/dist/esm/NavBar/style/index.js +1 -1
- package/dist/esm/NavBar.js +59 -63
- package/dist/esm/NoticeBar/style/index.js +1 -1
- package/dist/esm/NoticeBar.js +173 -290
- package/dist/esm/Notify.js +112 -78
- package/dist/esm/NumberKeyboard.js +110 -109
- package/dist/esm/Overlay.js +7 -6
- package/dist/esm/Pagination.js +94 -135
- package/dist/esm/Picker.js +149 -201
- package/dist/esm/Popover/style/index.js +0 -1
- package/dist/esm/Popover.js +121 -116
- package/dist/esm/Popup/style/index.js +0 -1
- package/dist/esm/Popup.js +109 -119
- package/dist/esm/Price.js +51 -39
- package/dist/esm/Progress/style/index.js +1 -1
- package/dist/esm/Progress.js +59 -64
- package/dist/esm/PullToRefresh.js +173 -149
- package/dist/esm/Radio/style/index.js +0 -1
- package/dist/esm/Radio.js +8 -6
- package/dist/esm/RadioGroup.js +64 -84
- package/dist/esm/Range.js +93 -122
- package/dist/esm/Rate/style/index.js +1 -1
- package/dist/esm/Rate.js +77 -95
- package/dist/esm/Row.js +46 -35
- package/dist/esm/SearchBar/style/index.js +1 -1
- package/dist/esm/SearchBar.js +110 -120
- package/dist/esm/ShortPassword/style/index.js +0 -1
- package/dist/esm/ShortPassword.js +120 -116
- package/dist/esm/SideNavBar.js +39 -27
- package/dist/esm/SideNavBarItem.js +31 -14
- package/dist/esm/Signature.js +65 -61
- package/dist/esm/Skeleton.js +48 -40
- package/dist/esm/Step/style/index.js +1 -1
- package/dist/esm/Step.js +49 -49
- package/dist/esm/Steps.js +37 -23
- package/dist/esm/Sticky.js +111 -120
- package/dist/esm/SubSideNavBar.js +50 -38
- package/dist/esm/Swipe.js +75 -63
- package/dist/esm/Swiper.js +171 -206
- package/dist/esm/SwiperItem.js +39 -22
- package/dist/esm/Switch.js +46 -37
- package/dist/esm/TabPane.js +8 -6
- package/dist/esm/Tabbar.js +47 -39
- package/dist/esm/TabbarItem/style/index.js +1 -1
- package/dist/esm/TabbarItem.js +50 -52
- package/dist/esm/Table/style/index.js +1 -1
- package/dist/esm/Table.js +70 -70
- package/dist/esm/Tabs/style/index.js +1 -2
- package/dist/esm/Tabs.js +11 -9
- package/dist/esm/Tag/style/index.js +1 -1
- package/dist/esm/Tag.js +69 -70
- package/dist/esm/TextArea.js +70 -64
- package/dist/esm/TimeDetail.js +47 -38
- package/dist/esm/TimePannel.js +35 -19
- package/dist/esm/TimeSelect.js +60 -68
- package/dist/esm/Toast/style/index.js +1 -1
- package/dist/esm/Toast.js +126 -98
- package/dist/esm/TrendArrow/style/index.js +1 -1
- package/dist/esm/TrendArrow.js +59 -55
- package/dist/esm/Uploader/style/index.js +0 -1
- package/dist/esm/Uploader.js +180 -229
- package/dist/esm/UserContext.js +5 -0
- package/dist/esm/UserContext2.js +5 -0
- package/dist/esm/UserContext3.js +5 -0
- package/dist/esm/Video.js +49 -39
- package/dist/esm/VirtualList.js +111 -146
- package/dist/esm/WaterMark.js +57 -60
- package/dist/esm/bem.js +10 -0
- package/dist/esm/cellgroup2.js +49 -0
- package/dist/esm/checkbox2.js +145 -0
- package/dist/esm/{date-c7aad4c0.js → date.js} +13 -11
- package/dist/esm/{formitem-8a73a5fb.js → formitem2.js} +83 -50
- package/dist/esm/get-scroll-parent.js +26 -0
- package/dist/esm/griditem2.js +96 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/nutui-react.es.js +188 -94
- package/dist/esm/offsetContext.js +19 -0
- package/dist/esm/overlay2.js +98 -0
- package/dist/esm/px-check.js +6 -0
- package/dist/esm/radio2.js +129 -0
- package/dist/esm/render.js +95 -0
- package/dist/esm/tabpane2.js +44 -0
- package/dist/esm/tabs2.js +175 -0
- package/dist/esm/typings.js +7 -0
- package/dist/esm/use-client-rect.js +32 -0
- package/dist/esm/use-props-value.js +18 -0
- package/dist/esm/use-touch.js +74 -0
- package/dist/locales/base.d.ts +2 -2
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +3 -3
- package/dist/locales/id-ID.js +3 -3
- package/dist/locales/zh-CN.js +3 -3
- package/dist/locales/zh-TW.js +3 -3
- package/dist/locales/zh-UG.js +3 -3
- package/dist/nutui.react.mjs +8327 -4829
- package/dist/nutui.react.umd.js +8328 -4830
- package/dist/packages/actionsheet/actionsheet.scss +10 -2
- package/dist/packages/backtop/backtop.scss +0 -8
- package/dist/packages/badge/badge.scss +3 -4
- package/dist/packages/button/button.scss +80 -93
- package/dist/packages/cell/cell.scss +18 -90
- package/dist/packages/cellgroup/cellgroup.scss +26 -20
- package/dist/packages/collapseitem/collapseitem.scss +0 -1
- package/dist/packages/dialog/dialog.scss +1 -1
- package/dist/packages/divider/divider.scss +3 -17
- package/dist/packages/grid/grid.scss +1 -0
- package/dist/packages/griditem/griditem.scss +2 -17
- package/dist/packages/icon/icon.scss +0 -132
- package/dist/packages/image/image.scss +0 -12
- package/dist/packages/indicator/indicator.scss +21 -39
- package/dist/packages/infiniteloading/infiniteloading.scss +4 -12
- package/dist/packages/input/input.scss +4 -0
- package/dist/packages/inputnumber/inputnumber.scss +10 -26
- package/dist/packages/menuitem/menuitem.scss +2 -0
- package/dist/packages/navbar/navbar.scss +4 -5
- package/dist/packages/overlay/overlay.scss +0 -19
- package/dist/packages/picker/picker.scss +97 -103
- package/dist/packages/progress/progress.scss +0 -1
- package/dist/packages/radio/radio.scss +8 -0
- package/dist/packages/rate/rate.scss +29 -6
- package/dist/packages/searchbar/searchbar.scss +0 -1
- package/dist/packages/shortpassword/shortpassword.scss +4 -1
- package/dist/packages/step/step.scss +0 -1
- package/dist/packages/sticky/sticky.scss +1 -1
- package/dist/packages/swiper/swiper.scss +8 -0
- package/dist/packages/tabbaritem/tabbaritem.scss +0 -1
- package/dist/packages/table/table.scss +0 -1
- package/dist/packages/tag/tag.scss +9 -2
- package/dist/packages/timedetail/timedetail.scss +9 -3
- package/dist/packages/timeselect/timeselect.scss +1 -1
- package/dist/packages/toast/toast.scss +0 -1
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/font-jmapp/config.json +175 -0
- package/dist/styles/font-jmapp/demo.css +539 -0
- package/dist/styles/font-jmapp/demo_index.html +1821 -0
- package/dist/styles/font-jmapp/iconfont.css +299 -0
- package/dist/styles/font-jmapp/iconfont.eot +0 -0
- package/dist/styles/font-jmapp/iconfont.js +68 -0
- package/dist/styles/font-jmapp/iconfont.json +506 -0
- package/dist/styles/font-jmapp/iconfont.svg +356 -0
- package/dist/styles/font-jmapp/iconfont.ttf +0 -0
- package/dist/styles/font-jmapp/iconfont.woff +0 -0
- package/dist/styles/font-jmapp/iconfont.woff2 +0 -0
- package/dist/styles/theme-default.scss +1 -0
- package/dist/styles/theme-jmapp.scss +41 -0
- package/dist/styles/themes/default.scss +0 -1
- package/dist/styles/variables-jmapp.scss +2601 -0
- package/dist/styles/variables.scss +49 -73
- package/dist/types/index.d.ts +147 -240
- package/package.json +23 -154
- package/dist/esm/AvatarContext-15733596.js +0 -3
- package/dist/esm/Icon/style/index.js +0 -4
- package/dist/esm/UserContext-101ad4a4.js +0 -3
- package/dist/esm/UserContext-2629d479.js +0 -3
- package/dist/esm/UserContext-b33bcf21.js +0 -3
- package/dist/esm/bem-3b438e61.js +0 -8
- package/dist/esm/cellgroup-fcc72767.js +0 -34
- package/dist/esm/checkbox-44e13cd0.js +0 -137
- package/dist/esm/get-scroll-parent-5f85dee8.js +0 -24
- package/dist/esm/grid.context-2ee27d95.js +0 -6
- package/dist/esm/icon-4ef1581c.js +0 -70
- package/dist/esm/index-030b7245.js +0 -11
- package/dist/esm/offsetContext-3ab00d40.js +0 -16
- package/dist/esm/overlay-de6c79d5.js +0 -83
- package/dist/esm/radio-9f141e6b.js +0 -118
- package/dist/esm/render-bbebb760.js +0 -79
- package/dist/esm/tabpane-01075e6c.js +0 -29
- package/dist/esm/tabs-e1b4e4b1.js +0 -181
- package/dist/esm/typings-f27b58f4.js +0 -8
- package/dist/esm/useClientRect-56bb675b.js +0 -39
- package/dist/esm/useTouch-cf73a407.js +0 -99
package/dist/esm/CalendarItem.js
CHANGED
|
@@ -1,203 +1,191 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
function ownKeys(object, enumerableOnly) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
function ownKeys(object, enumerableOnly) {
|
|
5
|
+
var keys = Object.keys(object);
|
|
6
|
+
if (Object.getOwnPropertySymbols) {
|
|
7
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
8
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
9
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
10
|
+
})), keys.push.apply(keys, symbols);
|
|
11
|
+
}
|
|
12
|
+
return keys;
|
|
13
|
+
}
|
|
14
|
+
function _objectSpread(target) {
|
|
15
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
16
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
17
|
+
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
18
|
+
_defineProperty(target, key, source[key]);
|
|
19
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
20
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return target;
|
|
24
|
+
}
|
|
25
|
+
import React__default, { useState, useRef, useEffect } from "react";
|
|
26
|
+
import classNames from "classnames";
|
|
27
|
+
import { c as cn } from "./bem.js";
|
|
28
|
+
import { U as Utils } from "./date.js";
|
|
29
|
+
import { useConfig } from "./ConfigProvider.js";
|
|
30
|
+
import "@bem-react/classname";
|
|
12
31
|
function requestAniFrame() {
|
|
13
|
-
if (typeof window !==
|
|
14
|
-
return window.requestAnimationFrame || function
|
|
15
|
-
window.setTimeout(callback,
|
|
32
|
+
if (typeof window !== "undefined") {
|
|
33
|
+
return window.requestAnimationFrame || function(callback) {
|
|
34
|
+
window.setTimeout(callback, 1e3 / 60);
|
|
16
35
|
};
|
|
17
36
|
}
|
|
18
|
-
return function
|
|
19
|
-
setTimeout(callback,
|
|
37
|
+
return function(callback) {
|
|
38
|
+
setTimeout(callback, 1e3 / 60);
|
|
20
39
|
};
|
|
21
40
|
}
|
|
22
41
|
var requestAniFrame$1 = requestAniFrame();
|
|
23
42
|
var defaultProps = {
|
|
24
|
-
type:
|
|
43
|
+
type: "one",
|
|
25
44
|
isAutoBackFill: false,
|
|
26
45
|
poppable: true,
|
|
27
46
|
visible: false,
|
|
28
|
-
title:
|
|
29
|
-
defaultValue:
|
|
47
|
+
title: "日历选择",
|
|
48
|
+
defaultValue: "",
|
|
30
49
|
startDate: Utils.getDay(0),
|
|
31
50
|
endDate: Utils.getDay(365),
|
|
32
51
|
showToday: true,
|
|
33
|
-
startText:
|
|
34
|
-
endText:
|
|
35
|
-
confirmText:
|
|
52
|
+
startText: "开始",
|
|
53
|
+
endText: "结束",
|
|
54
|
+
confirmText: "确认",
|
|
36
55
|
showTitle: true,
|
|
37
56
|
showSubTitle: true,
|
|
38
57
|
toDateAnimation: true,
|
|
39
|
-
onBtn:
|
|
40
|
-
onDay:
|
|
41
|
-
onTopInfo:
|
|
42
|
-
onBottomInfo:
|
|
43
|
-
onChoose: function onChoose(data) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
58
|
+
onBtn: void 0,
|
|
59
|
+
onDay: void 0,
|
|
60
|
+
onTopInfo: void 0,
|
|
61
|
+
onBottomInfo: void 0,
|
|
62
|
+
onChoose: function onChoose(data) {
|
|
63
|
+
},
|
|
64
|
+
onUpdate: function onUpdate() {
|
|
65
|
+
},
|
|
66
|
+
onSelected: function onSelected(data) {
|
|
67
|
+
},
|
|
68
|
+
onYearMonthChange: function onYearMonthChange(data) {
|
|
69
|
+
}
|
|
47
70
|
};
|
|
48
|
-
var CalendarItem = React__default.forwardRef(function
|
|
71
|
+
var CalendarItem = React__default.forwardRef(function(props, ref) {
|
|
49
72
|
var _classNames, _classNames2;
|
|
50
|
-
var _useConfig = useConfig(),
|
|
51
|
-
|
|
52
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
53
|
-
type = _defaultProps$props.type,
|
|
54
|
-
isAutoBackFill = _defaultProps$props.isAutoBackFill,
|
|
55
|
-
poppable = _defaultProps$props.poppable,
|
|
56
|
-
title = _defaultProps$props.title,
|
|
57
|
-
defaultValue = _defaultProps$props.defaultValue,
|
|
58
|
-
showToday = _defaultProps$props.showToday,
|
|
59
|
-
startText = _defaultProps$props.startText,
|
|
60
|
-
endText = _defaultProps$props.endText,
|
|
61
|
-
confirmText = _defaultProps$props.confirmText,
|
|
62
|
-
showTitle = _defaultProps$props.showTitle,
|
|
63
|
-
showSubTitle = _defaultProps$props.showSubTitle,
|
|
64
|
-
toDateAnimation = _defaultProps$props.toDateAnimation,
|
|
65
|
-
onBtn = _defaultProps$props.onBtn,
|
|
66
|
-
onDay = _defaultProps$props.onDay,
|
|
67
|
-
onTopInfo = _defaultProps$props.onTopInfo,
|
|
68
|
-
onBottomInfo = _defaultProps$props.onBottomInfo,
|
|
69
|
-
onChoose = _defaultProps$props.onChoose,
|
|
70
|
-
onUpdate = _defaultProps$props.onUpdate,
|
|
71
|
-
onSelected = _defaultProps$props.onSelected,
|
|
72
|
-
onYearMonthChange = _defaultProps$props.onYearMonthChange;
|
|
73
|
+
var _useConfig = useConfig(), locale = _useConfig.locale;
|
|
74
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), type = _defaultProps$props.type, isAutoBackFill = _defaultProps$props.isAutoBackFill, poppable = _defaultProps$props.poppable, title = _defaultProps$props.title, defaultValue = _defaultProps$props.defaultValue, showToday = _defaultProps$props.showToday, startText = _defaultProps$props.startText, endText = _defaultProps$props.endText, confirmText = _defaultProps$props.confirmText, showTitle = _defaultProps$props.showTitle, showSubTitle = _defaultProps$props.showSubTitle, toDateAnimation = _defaultProps$props.toDateAnimation, onBtn = _defaultProps$props.onBtn, onDay = _defaultProps$props.onDay, onTopInfo = _defaultProps$props.onTopInfo, onBottomInfo = _defaultProps$props.onBottomInfo, onChoose2 = _defaultProps$props.onChoose, onUpdate2 = _defaultProps$props.onUpdate, onSelected2 = _defaultProps$props.onSelected, onYearMonthChange2 = _defaultProps$props.onYearMonthChange;
|
|
73
75
|
var weeks = locale.calendaritem.weekdays;
|
|
74
|
-
var _useState = useState(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var _useState3 = useState([]),
|
|
79
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
80
|
-
monthsData = _useState4[0],
|
|
81
|
-
setMonthsData = _useState4[1];
|
|
82
|
-
var _useState5 = useState(0),
|
|
83
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
84
|
-
translateY = _useState6[0],
|
|
85
|
-
setTranslateY = _useState6[1];
|
|
86
|
-
var _useState7 = useState([]),
|
|
87
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
88
|
-
monthDefaultRange = _useState8[0],
|
|
89
|
-
setMonthDefaultRange = _useState8[1];
|
|
76
|
+
var _useState = useState(""), _useState2 = _slicedToArray(_useState, 2), yearMonthTitle = _useState2[0], setYearMonthTitle = _useState2[1];
|
|
77
|
+
var _useState3 = useState([]), _useState4 = _slicedToArray(_useState3, 2), monthsData = _useState4[0], setMonthsData = _useState4[1];
|
|
78
|
+
var _useState5 = useState(0), _useState6 = _slicedToArray(_useState5, 2), translateY = _useState6[0], setTranslateY = _useState6[1];
|
|
79
|
+
var _useState7 = useState([]), _useState8 = _slicedToArray(_useState7, 2), monthDefaultRange = _useState8[0], setMonthDefaultRange = _useState8[1];
|
|
90
80
|
var _useState9 = useState({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
_useState10 = _slicedToArray(_useState9, 1),
|
|
118
|
-
state = _useState10[0];
|
|
81
|
+
currDate: "",
|
|
82
|
+
propStartDate: "",
|
|
83
|
+
propEndDate: "",
|
|
84
|
+
unLoadPrev: false,
|
|
85
|
+
touchParams: {
|
|
86
|
+
startY: 0,
|
|
87
|
+
endY: 0,
|
|
88
|
+
startTime: 0,
|
|
89
|
+
endTime: 0,
|
|
90
|
+
lastY: 0,
|
|
91
|
+
lastTime: 0
|
|
92
|
+
},
|
|
93
|
+
transformY: 0,
|
|
94
|
+
scrollDistance: 0,
|
|
95
|
+
defaultData: [],
|
|
96
|
+
chooseData: [],
|
|
97
|
+
monthsData: [],
|
|
98
|
+
dayPrefix: "calendar-month-day",
|
|
99
|
+
startData: "",
|
|
100
|
+
endData: "",
|
|
101
|
+
isRange: props.type === "range",
|
|
102
|
+
timer: 0,
|
|
103
|
+
currentIndex: 0,
|
|
104
|
+
avgHeight: 0,
|
|
105
|
+
monthsNum: 0
|
|
106
|
+
}), _useState10 = _slicedToArray(_useState9, 1), state = _useState10[0];
|
|
119
107
|
var weeksPanel = useRef(null);
|
|
120
108
|
var months = useRef(null);
|
|
121
109
|
var monthsPanel = useRef(null);
|
|
122
110
|
var viewArea = useRef(null);
|
|
123
111
|
var viewHeight = 0;
|
|
124
|
-
var b = cn(
|
|
125
|
-
var classes = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b(
|
|
126
|
-
var headerClasses = classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b(
|
|
112
|
+
var b = cn("calendar");
|
|
113
|
+
var classes = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b(""), "-tile"), !poppable), _defineProperty(_classNames, "".concat(b(""), "-nofooter"), !!isAutoBackFill), _classNames), b(""));
|
|
114
|
+
var headerClasses = classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b(""), "-header"), true), _defineProperty(_classNames2, "".concat(b(""), "-header-tile"), !poppable), _classNames2));
|
|
127
115
|
var monthitemclasses = classNames(_defineProperty({
|
|
128
|
-
|
|
129
|
-
}, "".concat(type ===
|
|
130
|
-
var splitDate = function
|
|
131
|
-
return date.split(
|
|
116
|
+
"calendar-month-item": true
|
|
117
|
+
}, "".concat(type === "range" ? "month-item-range" : ""), true));
|
|
118
|
+
var splitDate = function splitDate2(date) {
|
|
119
|
+
return date.split("-");
|
|
132
120
|
};
|
|
133
|
-
var isStart = function
|
|
121
|
+
var isStart = function isStart2(currDate) {
|
|
134
122
|
return Utils.isEqual(state.currDate[0], currDate);
|
|
135
123
|
};
|
|
136
|
-
var isEnd = function
|
|
124
|
+
var isEnd = function isEnd2(currDate) {
|
|
137
125
|
return Utils.isEqual(state.currDate[1], currDate);
|
|
138
126
|
};
|
|
139
|
-
var isMultiple = function
|
|
127
|
+
var isMultiple = function isMultiple2(currDate) {
|
|
140
128
|
if (state.currDate.length > 0) {
|
|
141
|
-
return state.currDate.some(function
|
|
129
|
+
return state.currDate.some(function(item) {
|
|
142
130
|
return Utils.isEqual(item, currDate);
|
|
143
131
|
});
|
|
144
132
|
}
|
|
145
133
|
return false;
|
|
146
134
|
};
|
|
147
|
-
var getCurrDate = function
|
|
135
|
+
var getCurrDate = function getCurrDate2(day, month) {
|
|
148
136
|
return "".concat(month.curData[0], "-").concat(month.curData[1], "-").concat(Utils.getNumTwoBit(+day.day));
|
|
149
137
|
};
|
|
150
|
-
var getClass = function
|
|
138
|
+
var getClass = function getClass2(day, month) {
|
|
151
139
|
var currDate = getCurrDate(day, month);
|
|
152
|
-
if (day.type ===
|
|
153
|
-
if (Utils.isEqual(state.currDate, currDate) || type ===
|
|
140
|
+
if (day.type === "curr") {
|
|
141
|
+
if (Utils.isEqual(state.currDate, currDate) || type === "range" && (isStart(currDate) || isEnd(currDate)) || type === "multiple" && isMultiple(currDate)) {
|
|
154
142
|
return "".concat(state.dayPrefix, "-active");
|
|
155
143
|
}
|
|
156
144
|
if (state.propStartDate && Utils.compareDate(currDate, state.propStartDate) || state.propEndDate && Utils.compareDate(state.propEndDate, currDate)) {
|
|
157
145
|
return "".concat(state.dayPrefix, "-disabled");
|
|
158
146
|
}
|
|
159
|
-
if (type ===
|
|
147
|
+
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])) {
|
|
160
148
|
return "".concat(state.dayPrefix, "-choose");
|
|
161
149
|
}
|
|
162
150
|
return null;
|
|
163
151
|
}
|
|
164
152
|
return "".concat(state.dayPrefix, "-disabled");
|
|
165
153
|
};
|
|
166
|
-
var isActive = function
|
|
167
|
-
return state.isRange && day.type ===
|
|
154
|
+
var isActive = function isActive2(day, month) {
|
|
155
|
+
return state.isRange && day.type === "curr" && getClass(day, month) === "calendar-month-day-active";
|
|
168
156
|
};
|
|
169
|
-
var isCurrDay = function
|
|
157
|
+
var isCurrDay = function isCurrDay2(month, day) {
|
|
170
158
|
var date = "".concat(month.curData[0], "-").concat(month.curData[1], "-").concat(day);
|
|
171
|
-
return Utils.isEqual(date, Utils.date2Str(new Date()));
|
|
159
|
+
return Utils.isEqual(date, Utils.date2Str(/* @__PURE__ */ new Date()));
|
|
172
160
|
};
|
|
173
|
-
var confirm = function
|
|
174
|
-
var
|
|
175
|
-
if (
|
|
161
|
+
var confirm = function confirm2() {
|
|
162
|
+
var type2 = props.type;
|
|
163
|
+
if (type2 === "range" && state.chooseData.length === 2 || type2 !== "range") {
|
|
176
164
|
var chooseData = state.chooseData.slice(0);
|
|
177
|
-
|
|
165
|
+
onChoose2 && onChoose2(chooseData);
|
|
178
166
|
if (poppable) {
|
|
179
|
-
|
|
167
|
+
onUpdate2 && onUpdate2();
|
|
180
168
|
}
|
|
181
169
|
}
|
|
182
170
|
};
|
|
183
|
-
var chooseDay = function
|
|
171
|
+
var chooseDay = function chooseDay2(day, month, isFirst) {
|
|
184
172
|
if (getClass(day, month) !== "".concat(state.dayPrefix, "-disabled")) {
|
|
185
|
-
var
|
|
173
|
+
var type2 = props.type;
|
|
186
174
|
var days = _toConsumableArray(month.curData);
|
|
187
|
-
days[2] = typeof day.day ===
|
|
175
|
+
days[2] = typeof day.day === "number" ? Utils.getNumTwoBit(day.day) : day.day;
|
|
188
176
|
days[3] = "".concat(days[0], "-").concat(days[1], "-").concat(days[2]);
|
|
189
177
|
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
190
|
-
if (
|
|
178
|
+
if (type2 === "multiple") {
|
|
191
179
|
if (state.currDate.length > 0) {
|
|
192
|
-
var hasIndex =
|
|
193
|
-
state.currDate.forEach(function
|
|
180
|
+
var hasIndex = "";
|
|
181
|
+
state.currDate.forEach(function(item, index) {
|
|
194
182
|
if (item === days[3]) {
|
|
195
183
|
hasIndex = index;
|
|
196
184
|
}
|
|
197
185
|
});
|
|
198
186
|
if (isFirst) {
|
|
199
187
|
state.chooseData.push(_toConsumableArray(days));
|
|
200
|
-
} else if (hasIndex !==
|
|
188
|
+
} else if (hasIndex !== "") {
|
|
201
189
|
state.currDate.splice(hasIndex, 1);
|
|
202
190
|
state.chooseData.splice(hasIndex, 1);
|
|
203
191
|
} else {
|
|
@@ -208,7 +196,7 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
208
196
|
state.currDate = [days[3]];
|
|
209
197
|
state.chooseData = [_toConsumableArray(days)];
|
|
210
198
|
}
|
|
211
|
-
} else if (
|
|
199
|
+
} else if (type2 === "range") {
|
|
212
200
|
var curDataLength = Object.values(state.currDate).length;
|
|
213
201
|
if (curDataLength === 2 || curDataLength === 0) {
|
|
214
202
|
state.currDate = [days[3]];
|
|
@@ -229,8 +217,7 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
229
217
|
state.chooseData = _toConsumableArray(days);
|
|
230
218
|
}
|
|
231
219
|
if (!isFirst) {
|
|
232
|
-
|
|
233
|
-
onSelected && onSelected(state.chooseData);
|
|
220
|
+
onSelected2 && onSelected2(state.chooseData);
|
|
234
221
|
if (isAutoBackFill || !poppable) {
|
|
235
222
|
confirm();
|
|
236
223
|
}
|
|
@@ -238,77 +225,67 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
238
225
|
setMonthsData(state.monthsData.slice());
|
|
239
226
|
}
|
|
240
227
|
};
|
|
241
|
-
var isStartTip = function
|
|
228
|
+
var isStartTip = function isStartTip2(day, month) {
|
|
242
229
|
return isActive(day, month) && isStart(getCurrDate(day, month));
|
|
243
230
|
};
|
|
244
|
-
|
|
245
|
-
var isEndTip = function isEndTip(day, month) {
|
|
231
|
+
var isEndTip = function isEndTip2(day, month) {
|
|
246
232
|
if (state.currDate.length >= 2 && isEnd(getCurrDate(day, month))) {
|
|
247
233
|
return isActive(day, month);
|
|
248
234
|
}
|
|
249
235
|
return false;
|
|
250
236
|
};
|
|
251
|
-
|
|
252
|
-
var rangeTip = function rangeTip() {
|
|
237
|
+
var rangeTip = function rangeTip2() {
|
|
253
238
|
if (state.currDate.length >= 2) {
|
|
254
239
|
return Utils.isEqual(state.currDate[0], state.currDate[1]);
|
|
255
240
|
}
|
|
256
241
|
return false;
|
|
257
242
|
};
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
var monthData = type === 'prev' ? state.monthsData[0] : state.monthsData[state.monthsData.length - 1];
|
|
243
|
+
var getCurrData = function getCurrData2(type2) {
|
|
244
|
+
var monthData = type2 === "prev" ? state.monthsData[0] : state.monthsData[state.monthsData.length - 1];
|
|
261
245
|
var year = parseInt(monthData.curData[0]);
|
|
262
|
-
var month = parseInt(monthData.curData[1].toString().replace(/^0/,
|
|
263
|
-
switch (
|
|
264
|
-
case
|
|
246
|
+
var month = parseInt(monthData.curData[1].toString().replace(/^0/, ""));
|
|
247
|
+
switch (type2) {
|
|
248
|
+
case "prev":
|
|
265
249
|
month === 1 && (year -= 1);
|
|
266
250
|
month = month === 1 ? 12 : --month;
|
|
267
251
|
break;
|
|
268
|
-
case
|
|
252
|
+
case "next":
|
|
269
253
|
month === 12 && (year += 1);
|
|
270
254
|
month = month === 12 ? 1 : ++month;
|
|
271
255
|
break;
|
|
272
256
|
}
|
|
273
257
|
return [year, Utils.getNumTwoBit(month), Utils.getMonthDays(String(year), String(month))];
|
|
274
258
|
};
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
var year = dateInfo.year,
|
|
279
|
-
month = dateInfo.month;
|
|
280
|
-
if (type === 'prev' && days >= 7) {
|
|
259
|
+
var getDaysStatus = function getDaysStatus2(days, type2, dateInfo) {
|
|
260
|
+
var year = dateInfo.year, month = dateInfo.month;
|
|
261
|
+
if (type2 === "prev" && days >= 7) {
|
|
281
262
|
days -= 7;
|
|
282
263
|
}
|
|
283
|
-
return Array.from(Array(days), function
|
|
264
|
+
return Array.from(Array(days), function(v, k) {
|
|
284
265
|
return {
|
|
285
266
|
day: k + 1,
|
|
286
|
-
type:
|
|
287
|
-
year
|
|
288
|
-
month
|
|
267
|
+
type: type2,
|
|
268
|
+
year,
|
|
269
|
+
month
|
|
289
270
|
};
|
|
290
271
|
});
|
|
291
272
|
};
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
var year = dateInfo.year,
|
|
296
|
-
month = dateInfo.month;
|
|
297
|
-
if (type === 'prev' && days >= 7) {
|
|
273
|
+
var getPreDaysStatus = function getPreDaysStatus2(days, type2, dateInfo, preCurrMonthDays) {
|
|
274
|
+
var year = dateInfo.year, month = dateInfo.month;
|
|
275
|
+
if (type2 === "prev" && days >= 7) {
|
|
298
276
|
days -= 7;
|
|
299
277
|
}
|
|
300
|
-
var
|
|
278
|
+
var months2 = Array.from(Array(preCurrMonthDays), function(v, k) {
|
|
301
279
|
return {
|
|
302
280
|
day: k + 1,
|
|
303
|
-
type:
|
|
304
|
-
year
|
|
305
|
-
month
|
|
281
|
+
type: type2,
|
|
282
|
+
year,
|
|
283
|
+
month
|
|
306
284
|
};
|
|
307
285
|
});
|
|
308
|
-
return
|
|
286
|
+
return months2.slice(preCurrMonthDays - days);
|
|
309
287
|
};
|
|
310
|
-
|
|
311
|
-
var getMonth = function getMonth(curData, type) {
|
|
288
|
+
var getMonth = function getMonth2(curData, type2) {
|
|
312
289
|
var preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
|
|
313
290
|
var preMonth = +curData[1] - 1;
|
|
314
291
|
var preYear = curData[0];
|
|
@@ -318,17 +295,17 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
318
295
|
}
|
|
319
296
|
var currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
|
|
320
297
|
var preCurrMonthDays = Utils.getMonthDays("".concat(preYear), "".concat(preMonth));
|
|
321
|
-
var
|
|
298
|
+
var title2 = {
|
|
322
299
|
year: curData[0],
|
|
323
300
|
month: curData[1]
|
|
324
301
|
};
|
|
325
302
|
var monthInfo = {
|
|
326
|
-
curData
|
|
327
|
-
title: locale.calendaritem.monthTitle(
|
|
328
|
-
monthData: [].concat(_toConsumableArray(getPreDaysStatus(preMonthDays,
|
|
303
|
+
curData,
|
|
304
|
+
title: locale.calendaritem.monthTitle(title2.year, title2.month),
|
|
305
|
+
monthData: [].concat(_toConsumableArray(getPreDaysStatus(preMonthDays, "prev", {
|
|
329
306
|
month: preMonth,
|
|
330
307
|
year: preYear
|
|
331
|
-
}, preCurrMonthDays)), _toConsumableArray(getDaysStatus(currMonthDays,
|
|
308
|
+
}, preCurrMonthDays)), _toConsumableArray(getDaysStatus(currMonthDays, "curr", title2)))
|
|
332
309
|
};
|
|
333
310
|
monthInfo.cssHeight = 39 + (monthInfo.monthData.length > 35 ? 384 : 320);
|
|
334
311
|
var cssScrollHeight = 0;
|
|
@@ -336,7 +313,7 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
336
313
|
cssScrollHeight = state.monthsData[state.monthsData.length - 1].cssScrollHeight + state.monthsData[state.monthsData.length - 1].cssHeight;
|
|
337
314
|
}
|
|
338
315
|
monthInfo.cssScrollHeight = cssScrollHeight;
|
|
339
|
-
if (
|
|
316
|
+
if (type2 === "next") {
|
|
340
317
|
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]))) {
|
|
341
318
|
state.monthsData.push(monthInfo);
|
|
342
319
|
}
|
|
@@ -345,16 +322,15 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
345
322
|
}
|
|
346
323
|
setMonthsData(state.monthsData);
|
|
347
324
|
};
|
|
348
|
-
var setReachedYearMonthInfo = function
|
|
325
|
+
var setReachedYearMonthInfo = function setReachedYearMonthInfo2() {
|
|
349
326
|
var currentMonthsData = state.monthsData[state.currentIndex];
|
|
350
|
-
var _currentMonthsData$cu = _slicedToArray(currentMonthsData.curData, 2),
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
onYearMonthChange && onYearMonthChange([year, month, "".concat(year, "-").concat(month)]);
|
|
327
|
+
var _currentMonthsData$cu = _slicedToArray(currentMonthsData.curData, 2), year = _currentMonthsData$cu[0], month = _currentMonthsData$cu[1];
|
|
328
|
+
if (currentMonthsData.title === yearMonthTitle)
|
|
329
|
+
return;
|
|
330
|
+
onYearMonthChange2 && onYearMonthChange2([year, month, "".concat(year, "-").concat(month)]);
|
|
355
331
|
setYearMonthTitle(currentMonthsData.title);
|
|
356
332
|
};
|
|
357
|
-
var setDefaultRange = function
|
|
333
|
+
var setDefaultRange = function setDefaultRange2(monthsNum, current) {
|
|
358
334
|
var start = 0;
|
|
359
335
|
var end = 0;
|
|
360
336
|
if (monthsNum >= 3) {
|
|
@@ -375,7 +351,7 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
375
351
|
setMonthDefaultRange([start, end]);
|
|
376
352
|
setTranslateY(state.monthsData[start].cssScrollHeight);
|
|
377
353
|
};
|
|
378
|
-
var monthsViewScroll = function
|
|
354
|
+
var monthsViewScroll = function monthsViewScroll2(e) {
|
|
379
355
|
if (state.monthsData.length <= 1) {
|
|
380
356
|
return;
|
|
381
357
|
}
|
|
@@ -411,19 +387,16 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
411
387
|
}
|
|
412
388
|
setReachedYearMonthInfo();
|
|
413
389
|
};
|
|
414
|
-
var initData = function
|
|
415
|
-
// 初始化开始结束数据
|
|
390
|
+
var initData = function initData2() {
|
|
416
391
|
var propStartDate = props.startDate ? props.startDate : Utils.getDay(0);
|
|
417
392
|
var propEndDate = props.endDate ? props.endDate : Utils.getDay(365);
|
|
418
393
|
state.propStartDate = propStartDate;
|
|
419
394
|
state.propEndDate = propEndDate;
|
|
420
395
|
state.startData = splitDate(propStartDate);
|
|
421
396
|
state.endData = splitDate(propEndDate);
|
|
422
|
-
// 根据是否存在默认时间,初始化当前日期
|
|
423
397
|
if (defaultValue || Array.isArray(defaultValue) && defaultValue.length > 0) {
|
|
424
|
-
state.currDate = props.type !==
|
|
398
|
+
state.currDate = props.type !== "one" ? _toConsumableArray(props.defaultValue) : props.defaultValue;
|
|
425
399
|
}
|
|
426
|
-
// 判断时间范围内存在多少个月
|
|
427
400
|
var startDate = {
|
|
428
401
|
year: Number(state.startData[0]),
|
|
429
402
|
month: Number(state.startData[1])
|
|
@@ -439,15 +412,13 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
439
412
|
if (monthsNum <= 0) {
|
|
440
413
|
monthsNum = 1;
|
|
441
414
|
}
|
|
442
|
-
|
|
443
|
-
getMonth(state.startData, 'next');
|
|
415
|
+
getMonth(state.startData, "next");
|
|
444
416
|
var i = 1;
|
|
445
417
|
do {
|
|
446
|
-
getMonth(getCurrData(
|
|
418
|
+
getMonth(getCurrData("next"), "next");
|
|
447
419
|
} while (i++ < monthsNum);
|
|
448
420
|
state.monthsNum = monthsNum;
|
|
449
|
-
|
|
450
|
-
if (type === 'range' && Array.isArray(state.currDate)) {
|
|
421
|
+
if (type === "range" && Array.isArray(state.currDate)) {
|
|
451
422
|
if (state.currDate.length > 0) {
|
|
452
423
|
if (propStartDate && Utils.compareDate(state.currDate[0], propStartDate)) {
|
|
453
424
|
state.currDate.splice(0, 1, propStartDate);
|
|
@@ -457,11 +428,11 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
457
428
|
}
|
|
458
429
|
state.defaultData = [].concat(_toConsumableArray(splitDate(state.currDate[0])), _toConsumableArray(splitDate(state.currDate[1])));
|
|
459
430
|
}
|
|
460
|
-
} else if (props.type ===
|
|
431
|
+
} else if (props.type === "multiple" && Array.isArray(state.currDate)) {
|
|
461
432
|
if (state.currDate.length > 0) {
|
|
462
433
|
var defaultArr = [];
|
|
463
434
|
var obj = {};
|
|
464
|
-
state.currDate.forEach(function
|
|
435
|
+
state.currDate.forEach(function(item) {
|
|
465
436
|
if (propStartDate && !Utils.compareDate(item, propStartDate) && propEndDate && !Utils.compareDate(propEndDate, item)) {
|
|
466
437
|
if (!Object.hasOwnProperty.call(obj, item)) {
|
|
467
438
|
defaultArr.push(item);
|
|
@@ -480,25 +451,23 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
480
451
|
}
|
|
481
452
|
state.defaultData = _toConsumableArray(splitDate(state.currDate));
|
|
482
453
|
}
|
|
483
|
-
// 设置默认可见区域
|
|
484
454
|
var current = 0;
|
|
485
455
|
var lastCurrent = 0;
|
|
486
456
|
if (state.defaultData.length > 0) {
|
|
487
|
-
state.monthsData.forEach(function
|
|
457
|
+
state.monthsData.forEach(function(item, index) {
|
|
488
458
|
if (item.title === locale.calendaritem.monthTitle(state.defaultData[0], state.defaultData[1])) {
|
|
489
459
|
current = index;
|
|
490
460
|
}
|
|
491
|
-
if (props.type ===
|
|
461
|
+
if (props.type === "range") {
|
|
492
462
|
if (item.title === locale.calendaritem.monthTitle(state.defaultData[3], state.defaultData[4])) {
|
|
493
463
|
lastCurrent = index;
|
|
494
464
|
}
|
|
495
465
|
}
|
|
496
466
|
});
|
|
497
467
|
} else {
|
|
498
|
-
|
|
499
|
-
var
|
|
500
|
-
var
|
|
501
|
-
var currentYearMonthIndex = state.monthsData.findIndex(function (item) {
|
|
468
|
+
var currentYear = /* @__PURE__ */ (/* @__PURE__ */ new Date()).getFullYear();
|
|
469
|
+
var currentMonth = /* @__PURE__ */ (/* @__PURE__ */ new Date()).getMonth() + 1;
|
|
470
|
+
var currentYearMonthIndex = state.monthsData.findIndex(function(item) {
|
|
502
471
|
return +item.curData[0] === currentYear && +item.curData[1] === currentMonth;
|
|
503
472
|
});
|
|
504
473
|
if (currentYearMonthIndex > -1) {
|
|
@@ -509,41 +478,39 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
509
478
|
state.currentIndex = current;
|
|
510
479
|
setReachedYearMonthInfo();
|
|
511
480
|
if (state.defaultData.length > 0) {
|
|
512
|
-
|
|
513
|
-
if (type === 'range') {
|
|
481
|
+
if (type === "range") {
|
|
514
482
|
chooseDay({
|
|
515
483
|
day: state.defaultData[2],
|
|
516
|
-
type:
|
|
484
|
+
type: "curr"
|
|
517
485
|
}, state.monthsData[state.currentIndex], true);
|
|
518
486
|
chooseDay({
|
|
519
487
|
day: state.defaultData[5],
|
|
520
|
-
type:
|
|
488
|
+
type: "curr"
|
|
521
489
|
}, state.monthsData[lastCurrent], true);
|
|
522
|
-
} else if (type ===
|
|
523
|
-
_toConsumableArray(state.currDate).forEach(function
|
|
490
|
+
} else if (type === "multiple") {
|
|
491
|
+
_toConsumableArray(state.currDate).forEach(function(item) {
|
|
524
492
|
var dateArr = splitDate(item);
|
|
525
|
-
var
|
|
526
|
-
state.monthsData.forEach(function
|
|
527
|
-
if (
|
|
528
|
-
|
|
493
|
+
var current2 = state.currentIndex;
|
|
494
|
+
state.monthsData.forEach(function(item2, index) {
|
|
495
|
+
if (item2.title === locale.calendaritem.monthTitle(dateArr[0], dateArr[1])) {
|
|
496
|
+
current2 = index;
|
|
529
497
|
}
|
|
530
498
|
});
|
|
531
499
|
chooseDay({
|
|
532
500
|
day: dateArr[2],
|
|
533
|
-
type:
|
|
534
|
-
}, state.monthsData[
|
|
501
|
+
type: "curr"
|
|
502
|
+
}, state.monthsData[current2], true);
|
|
535
503
|
});
|
|
536
504
|
} else {
|
|
537
505
|
chooseDay({
|
|
538
506
|
day: state.defaultData[2],
|
|
539
|
-
type:
|
|
507
|
+
type: "curr"
|
|
540
508
|
}, state.monthsData[state.currentIndex], true);
|
|
541
509
|
}
|
|
542
510
|
}
|
|
543
511
|
var lastItem = state.monthsData[state.monthsData.length - 1];
|
|
544
512
|
var containerHeight = lastItem.cssHeight + lastItem.cssScrollHeight;
|
|
545
|
-
requestAniFrame$1(function
|
|
546
|
-
// 初始化 日历位置
|
|
513
|
+
requestAniFrame$1(function() {
|
|
547
514
|
if (months && monthsPanel && viewArea) {
|
|
548
515
|
viewHeight = months.current.clientHeight;
|
|
549
516
|
monthsPanel.current.style.height = "".concat(containerHeight, "px");
|
|
@@ -552,26 +519,25 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
552
519
|
});
|
|
553
520
|
state.avgHeight = Math.floor(containerHeight / (monthsNum + 1));
|
|
554
521
|
};
|
|
555
|
-
var resetRender = function
|
|
522
|
+
var resetRender = function resetRender2() {
|
|
556
523
|
state.chooseData.splice(0);
|
|
557
524
|
state.monthsData.splice(0);
|
|
558
525
|
initData();
|
|
559
526
|
};
|
|
560
|
-
|
|
561
|
-
var scrollToDate = function scrollToDate(date) {
|
|
527
|
+
var scrollToDate = function scrollToDate2(date) {
|
|
562
528
|
if (Utils.compareDate(date, state.propStartDate)) {
|
|
563
529
|
date = state.propStartDate;
|
|
564
530
|
} else if (!Utils.compareDate(date, state.propEndDate)) {
|
|
565
531
|
date = state.propEndDate;
|
|
566
532
|
}
|
|
567
533
|
var dateArr = splitDate(date);
|
|
568
|
-
state.monthsData.forEach(function
|
|
534
|
+
state.monthsData.forEach(function(item, index) {
|
|
569
535
|
if (item.title === locale.calendaritem.monthTitle(dateArr[0], dateArr[1])) {
|
|
570
536
|
if (months.current) {
|
|
571
537
|
var distance = state.monthsData[index].cssScrollHeight - months.current.scrollTop;
|
|
572
538
|
if (toDateAnimation) {
|
|
573
539
|
var flag = 0;
|
|
574
|
-
var interval = setInterval(function
|
|
540
|
+
var interval = setInterval(function() {
|
|
575
541
|
flag++;
|
|
576
542
|
if (months.current) {
|
|
577
543
|
var offset = distance / 10;
|
|
@@ -591,15 +557,15 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
591
557
|
}
|
|
592
558
|
});
|
|
593
559
|
};
|
|
594
|
-
useEffect(function
|
|
560
|
+
useEffect(function() {
|
|
595
561
|
initData();
|
|
596
562
|
}, []);
|
|
597
|
-
useEffect(function
|
|
563
|
+
useEffect(function() {
|
|
598
564
|
poppable && resetRender();
|
|
599
565
|
}, [defaultValue]);
|
|
600
|
-
React__default.useImperativeHandle(ref, function
|
|
566
|
+
React__default.useImperativeHandle(ref, function() {
|
|
601
567
|
return {
|
|
602
|
-
scrollToDate
|
|
568
|
+
scrollToDate
|
|
603
569
|
};
|
|
604
570
|
});
|
|
605
571
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
@@ -615,7 +581,7 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
615
581
|
}, yearMonthTitle), React__default.createElement("div", {
|
|
616
582
|
className: "calendar-weeks",
|
|
617
583
|
ref: weeksPanel
|
|
618
|
-
}, weeks.map(function
|
|
584
|
+
}, weeks.map(function(item) {
|
|
619
585
|
return React__default.createElement("div", {
|
|
620
586
|
className: "calendar-week-item",
|
|
621
587
|
key: item
|
|
@@ -633,19 +599,19 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
633
599
|
style: {
|
|
634
600
|
transform: "translateY(".concat(translateY, "px)")
|
|
635
601
|
}
|
|
636
|
-
}, state.monthsData.slice(monthDefaultRange[0], monthDefaultRange[1]).map(function
|
|
602
|
+
}, state.monthsData.slice(monthDefaultRange[0], monthDefaultRange[1]).map(function(month, key) {
|
|
637
603
|
return React__default.createElement("div", {
|
|
638
604
|
className: "calendar-month",
|
|
639
|
-
key
|
|
605
|
+
key
|
|
640
606
|
}, React__default.createElement("div", {
|
|
641
607
|
className: "calendar-month-title"
|
|
642
608
|
}, month.title), React__default.createElement("div", {
|
|
643
609
|
className: "calendar-month-con"
|
|
644
610
|
}, React__default.createElement("div", {
|
|
645
611
|
className: monthitemclasses
|
|
646
|
-
}, month.monthData.map(function
|
|
612
|
+
}, month.monthData.map(function(day, i) {
|
|
647
613
|
return React__default.createElement("div", {
|
|
648
|
-
className: [
|
|
614
|
+
className: ["calendar-month-day", getClass(day, month)].join(" "),
|
|
649
615
|
onClick: function onClick() {
|
|
650
616
|
chooseDay(day, month);
|
|
651
617
|
},
|
|
@@ -659,7 +625,7 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
659
625
|
}, onBottomInfo(day)), !onBottomInfo && showToday && isCurrDay(month, day.day) && React__default.createElement("div", {
|
|
660
626
|
className: "calendar-curr-tip-curr"
|
|
661
627
|
}, locale.calendaritem.today), isStartTip(day, month) && React__default.createElement("div", {
|
|
662
|
-
className: "calendar-day-tip ".concat(rangeTip() ?
|
|
628
|
+
className: "calendar-day-tip ".concat(rangeTip() ? "calendar-curr-tips-top" : "")
|
|
663
629
|
}, startText || locale.calendaritem.start), isEndTip(day, month) && React__default.createElement("div", {
|
|
664
630
|
className: "calendar-day-tip"
|
|
665
631
|
}, endText || locale.calendaritem.end));
|
|
@@ -669,8 +635,10 @@ var CalendarItem = React__default.forwardRef(function (props, ref) {
|
|
|
669
635
|
}, React__default.createElement("div", {
|
|
670
636
|
className: "calendar-confirm-btn",
|
|
671
637
|
onClick: confirm
|
|
672
|
-
}, confirmText || locale.confirm)) :
|
|
638
|
+
}, confirmText || locale.confirm)) : ""));
|
|
673
639
|
});
|
|
674
640
|
CalendarItem.defaultProps = defaultProps;
|
|
675
|
-
CalendarItem.displayName =
|
|
676
|
-
export {
|
|
641
|
+
CalendarItem.displayName = "NutCalendarItem";
|
|
642
|
+
export {
|
|
643
|
+
CalendarItem as default
|
|
644
|
+
};
|