@nutui/nutui-react 0.1.0-beta.1 → 0.1.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/README.md +50 -135
- package/dist/esm/ActionSheet/style/index.js +1 -0
- package/dist/esm/Address/style/index.js +1 -0
- package/dist/esm/AnimatingNumbers/style/index.js +1 -0
- package/dist/esm/Avatar/style/index.js +1 -0
- package/dist/esm/BackTop/style/index.js +1 -0
- package/dist/esm/BackTop.js +1 -3
- package/dist/esm/Badge/style/index.js +1 -0
- package/dist/esm/Barrage/style/index.js +1 -0
- package/dist/esm/Button/style/index.js +1 -0
- package/dist/esm/Button.js +110 -4
- package/dist/esm/Calendar/style/index.js +1 -0
- package/dist/esm/Calendar.js +86 -0
- package/dist/esm/CalendarItem/style/index.js +1 -0
- package/dist/esm/CalendarItem.js +554 -0
- package/dist/esm/Cell/style/index.js +1 -0
- package/dist/esm/Cell.js +1 -1
- package/dist/esm/CellGroup/style/index.js +1 -0
- package/dist/esm/CellGroup.js +33 -0
- package/dist/esm/Checkbox/style/index.js +1 -0
- package/dist/esm/Checkbox.js +1 -1
- package/dist/esm/CheckboxGroup/style/index.js +1 -0
- package/dist/esm/CircleProgress/style/index.js +1 -0
- package/dist/esm/Col/style/index.js +1 -0
- package/dist/esm/Col.js +60 -0
- package/dist/esm/Collapse/style/index.js +1 -0
- package/dist/esm/CollapseItem/style/index.js +1 -0
- package/dist/esm/CollapseItem.js +142 -0
- package/dist/esm/Dialog/style/index.js +1 -0
- package/dist/esm/Dialog.js +327 -0
- package/dist/esm/Divider/style/index.js +1 -0
- package/dist/esm/Drag/style/index.js +1 -0
- package/dist/esm/Drag.js +83 -140
- package/dist/esm/Elevator/style/index.js +1 -0
- package/dist/esm/Elevator.js +3 -6
- package/dist/esm/FixedNav/style/index.js +1 -0
- package/dist/esm/FixedNav.js +2 -2
- package/dist/esm/Icon/style/index.js +1 -0
- package/dist/esm/Icon.js +70 -4
- package/dist/esm/Infiniteloading/style/index.js +1 -0
- package/dist/esm/Input/style/index.js +1 -0
- package/dist/esm/Input.js +1 -1
- package/dist/esm/InputNumber/style/index.js +1 -0
- package/dist/esm/Layout/style/index.js +1 -0
- package/dist/esm/NavBar/style/index.js +1 -0
- package/dist/esm/NavBar.js +1 -1
- package/dist/esm/NoticeBar/style/index.js +1 -0
- package/dist/esm/NoticeBar.js +1 -1
- package/dist/esm/Notify/style/index.js +1 -0
- package/dist/esm/Overlay/style/index.js +1 -0
- package/dist/esm/Pagination/style/index.js +1 -0
- package/dist/esm/Picker/style/index.js +1 -0
- package/dist/esm/Picker.js +397 -0
- package/dist/esm/Popover/style/index.js +1 -0
- package/dist/esm/Popover.js +299 -0
- package/dist/esm/Popup/style/index.js +1 -0
- package/dist/esm/Popup.js +0 -3
- package/dist/esm/Price/style/index.js +1 -0
- package/dist/esm/Radio/style/index.js +1 -0
- package/dist/esm/Radio.js +2 -3
- package/dist/esm/RadioGroup/style/index.js +1 -0
- package/dist/esm/Range/style/index.js +1 -0
- package/dist/esm/Range.js +1 -4
- package/dist/esm/Rate/style/index.js +1 -0
- package/dist/esm/Rate.js +1 -1
- package/dist/esm/Row/style/index.js +1 -0
- package/dist/esm/Row.js +48 -0
- package/dist/esm/ShortPassword/style/index.js +1 -0
- package/dist/esm/ShortPassword.js +203 -0
- package/dist/esm/Signature/style/index.js +1 -0
- package/dist/esm/Signature.js +1 -2
- package/dist/esm/Step/style/index.js +1 -0
- package/dist/esm/Steps/style/index.js +1 -0
- package/dist/esm/Swiper/style/index.js +1 -0
- package/dist/esm/Swiper.js +517 -0
- package/dist/esm/SwiperItem/style/index.js +1 -0
- package/dist/esm/SwiperItem.js +64 -0
- package/dist/esm/Switch/style/index.js +1 -0
- package/dist/esm/Switch.js +85 -0
- package/dist/esm/Tabbar/style/index.js +1 -0
- package/dist/esm/Tabbar.js +1 -4
- package/dist/esm/TabbarItem/style/index.js +1 -0
- package/dist/esm/TabbarItem.js +1 -1
- package/dist/esm/Tag/style/index.js +1 -0
- package/dist/esm/TextArea/style/index.js +1 -0
- package/dist/esm/Toast/style/index.js +1 -0
- package/dist/esm/Toast.js +294 -7
- package/dist/esm/Uploader/style/index.js +1 -0
- package/dist/esm/UserContext-b4181162.js +3 -0
- package/dist/esm/UserContext-be8097d2.js +3 -0
- package/dist/esm/date-649fe493.js +112 -0
- package/dist/esm/nutui-react.es.js +28 -15
- package/dist/esm/types/src/packages/calendar/calendar.d.ts +14 -0
- package/dist/esm/types/src/packages/calendar/index.d.ts +2 -0
- package/dist/esm/types/src/packages/calendaritem/calendaritem.d.ts +17 -0
- package/dist/esm/types/src/packages/calendaritem/index.d.ts +2 -0
- package/dist/esm/types/src/packages/dialog/Confirm.d.ts +7 -0
- package/dist/esm/types/src/packages/dialog/Content.d.ts +10 -0
- package/dist/esm/types/src/packages/dialog/DialogWrap.d.ts +11 -0
- package/dist/esm/types/src/packages/dialog/DialogWrapper.d.ts +8 -0
- package/dist/esm/types/src/packages/dialog/Mask.d.ts +3 -0
- package/dist/esm/types/src/packages/dialog/config.d.ts +46 -0
- package/dist/esm/types/src/packages/dialog/dialog.d.ts +2 -0
- package/dist/esm/types/src/packages/dialog/index.d.ts +2 -0
- package/dist/esm/types/src/packages/drag/drag.d.ts +1 -1
- package/dist/esm/types/src/packages/nutui.react.build.d.ts +29 -16
- package/dist/esm/types/src/packages/nutui.react.d.ts +29 -16
- package/dist/esm/types/src/packages/picker/index.d.ts +2 -0
- package/dist/esm/types/src/packages/picker/picker.d.ts +19 -0
- package/dist/esm/types/src/packages/picker/pickerSlot.d.ts +10 -0
- package/dist/esm/types/src/packages/popover/Trigger.d.ts +21 -0
- package/dist/esm/types/src/packages/popover/index.d.ts +2 -0
- package/dist/esm/types/src/packages/popover/popover.d.ts +13 -0
- package/dist/esm/types/src/packages/row/UserContext.d.ts +1 -0
- package/dist/esm/types/src/packages/shortpassword/index.d.ts +2 -0
- package/dist/esm/types/src/packages/shortpassword/shortpassword.d.ts +21 -0
- package/dist/esm/types/src/packages/steps/UserContext.d.ts +1 -0
- package/dist/esm/types/src/packages/swiper/UserContext.d.ts +2 -0
- package/dist/esm/types/src/packages/swiper/index.d.ts +2 -0
- package/dist/esm/types/src/packages/swiper/swiper.d.ts +26 -0
- package/dist/esm/types/src/packages/swiperitem/index.d.ts +2 -0
- package/dist/esm/types/src/packages/swiperitem/swiperitem.d.ts +7 -0
- package/dist/nutui.react.es.js +10683 -4344
- package/dist/nutui.react.umd.js +26 -17
- package/dist/packages/actionsheet/actionsheet.scss +1 -0
- package/dist/packages/address/address.scss +3 -0
- package/dist/packages/animatingnumbers/animatingnumbers.scss +1 -1
- package/dist/packages/backtop/backtop.scss +1 -0
- package/dist/packages/button/button.scss +1 -1
- package/dist/packages/calendar/calendar.scss +200 -0
- package/dist/packages/calendaritem/calendaritem.scss +191 -0
- package/dist/packages/cell/cell.scss +2 -0
- package/dist/packages/checkbox/checkbox.scss +1 -1
- package/dist/packages/collapse/collapse.scss +1 -1
- package/dist/packages/collapseitem/collapseitem.scss +2 -0
- package/dist/packages/dialog/dialog.scss +129 -0
- package/dist/packages/drag/drag.scss +2 -1
- package/dist/packages/fixednav/fixednav.scss +5 -0
- package/dist/packages/icon/icon.scss +1 -1
- package/dist/packages/infiniteloading/infiniteloading.scss +1 -0
- package/dist/packages/input/input.scss +1 -0
- package/dist/packages/inputnumber/inputnumber.scss +1 -0
- package/dist/packages/navbar/navbar.scss +2 -0
- package/dist/packages/noticebar/noticebar.scss +2 -0
- package/dist/packages/picker/picker.scss +104 -0
- package/dist/packages/popover/popover.scss +142 -0
- package/dist/packages/popup/popup.scss +2 -0
- package/dist/packages/radio/radio.scss +2 -0
- package/dist/packages/range/range.scss +1 -0
- package/dist/packages/rate/rate.scss +2 -0
- package/dist/packages/shortpassword/shortpassword.scss +115 -0
- package/dist/packages/signature/signature.scss +1 -0
- package/dist/packages/step/step.scss +1 -0
- package/dist/packages/swiper/swiper.scss +45 -0
- package/dist/packages/swiperitem/swiperitem.scss +3 -0
- package/dist/packages/tabbaritem/{tabbarItem.scss → tabbaritem.scss} +2 -0
- package/dist/packages/tag/tag.scss +1 -0
- package/dist/packages/toast/toast.scss +2 -0
- package/dist/packages/uploader/uploader.scss +2 -0
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/themes/default.scss +26 -16
- package/dist/styles/variables.scss +25 -0
- package/package.json +16 -5
- package/dist/esm/button-345fb015.js +0 -110
- package/dist/esm/icon-63c0d58f.js +0 -70
- package/dist/esm/toast-420b65b7.js +0 -294
|
@@ -0,0 +1,554 @@
|
|
|
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 { c as cn } from './bem-893ad28d.js';
|
|
11
|
+
import classNames from 'classnames';
|
|
12
|
+
import { U as Utils } from './date-649fe493.js';
|
|
13
|
+
import '@bem-react/classname';
|
|
14
|
+
|
|
15
|
+
function requestAniFrame() {
|
|
16
|
+
if (typeof window !== 'undefined') {
|
|
17
|
+
return window.requestAnimationFrame || function (callback) {
|
|
18
|
+
window.setTimeout(callback, 1000 / 60);
|
|
19
|
+
};
|
|
20
|
+
} else {
|
|
21
|
+
return function (callback) {
|
|
22
|
+
setTimeout(callback, 1000 / 60);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var requestAniFrame$1 = requestAniFrame();
|
|
28
|
+
var defaultProps = {
|
|
29
|
+
type: 'one',
|
|
30
|
+
isAutoBackFill: false,
|
|
31
|
+
poppable: true,
|
|
32
|
+
visible: false,
|
|
33
|
+
title: '日历选择',
|
|
34
|
+
defaultValue: '',
|
|
35
|
+
startDate: Utils.getDay(0),
|
|
36
|
+
endDate: Utils.getDay(365),
|
|
37
|
+
onChoose: function onChoose(data) {},
|
|
38
|
+
onUpdate: function onUpdate() {},
|
|
39
|
+
onClose: function onClose() {}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var CalendarItem = function CalendarItem(props) {
|
|
43
|
+
var _classNames, _classNames2;
|
|
44
|
+
|
|
45
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
46
|
+
children = _defaultProps$props.children,
|
|
47
|
+
type = _defaultProps$props.type,
|
|
48
|
+
isAutoBackFill = _defaultProps$props.isAutoBackFill,
|
|
49
|
+
poppable = _defaultProps$props.poppable,
|
|
50
|
+
visible = _defaultProps$props.visible,
|
|
51
|
+
title = _defaultProps$props.title,
|
|
52
|
+
defaultValue = _defaultProps$props.defaultValue,
|
|
53
|
+
startDate = _defaultProps$props.startDate,
|
|
54
|
+
endDate = _defaultProps$props.endDate,
|
|
55
|
+
onChoose = _defaultProps$props.onChoose,
|
|
56
|
+
onUpdate = _defaultProps$props.onUpdate,
|
|
57
|
+
onClose = _defaultProps$props.onClose;
|
|
58
|
+
|
|
59
|
+
var weeks = ['日', '一', '二', '三', '四', '五', '六'];
|
|
60
|
+
|
|
61
|
+
var _useState = useState(''),
|
|
62
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
63
|
+
yearMonthTitle = _useState2[0],
|
|
64
|
+
setYearMonthTitle = _useState2[1];
|
|
65
|
+
|
|
66
|
+
var _useState3 = useState(false),
|
|
67
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
68
|
+
unLoadPrev = _useState4[0],
|
|
69
|
+
setUnLoadPrev = _useState4[1];
|
|
70
|
+
|
|
71
|
+
var _useState5 = useState([]),
|
|
72
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
73
|
+
monthsData = _useState6[0],
|
|
74
|
+
setMonthsData = _useState6[1];
|
|
75
|
+
|
|
76
|
+
var _useState7 = useState({
|
|
77
|
+
currDate: '',
|
|
78
|
+
touchParams: {
|
|
79
|
+
startY: 0,
|
|
80
|
+
endY: 0,
|
|
81
|
+
startTime: 0,
|
|
82
|
+
endTime: 0,
|
|
83
|
+
lastY: 0,
|
|
84
|
+
lastTime: 0
|
|
85
|
+
},
|
|
86
|
+
transformY: 0,
|
|
87
|
+
translateY: 0,
|
|
88
|
+
scrollDistance: 0,
|
|
89
|
+
defaultData: [],
|
|
90
|
+
chooseData: [],
|
|
91
|
+
monthsData: [],
|
|
92
|
+
dayPrefix: 'calendar-month-day',
|
|
93
|
+
startData: '',
|
|
94
|
+
endData: '',
|
|
95
|
+
isRange: type === 'range',
|
|
96
|
+
timer: 0
|
|
97
|
+
}),
|
|
98
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
99
|
+
state = _useState8[0],
|
|
100
|
+
setState = _useState8[1];
|
|
101
|
+
|
|
102
|
+
var weeksPanel = useRef(null);
|
|
103
|
+
var months = useRef(null);
|
|
104
|
+
var monthsPanel = useRef(null);
|
|
105
|
+
var b = cn('calendar');
|
|
106
|
+
var classes = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b(''), "-tile"), !poppable), _defineProperty(_classNames, "".concat(b(''), "-nofooter"), !!isAutoBackFill), _classNames), b(''));
|
|
107
|
+
var headerClasses = classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b(''), "-header"), true), _defineProperty(_classNames2, "".concat(b(''), "-header-tile"), !poppable), _classNames2));
|
|
108
|
+
var monthitemclasses = classNames(_defineProperty({
|
|
109
|
+
'calendar-month-item': true
|
|
110
|
+
}, "".concat(type === 'range' ? 'month-item-range' : ''), true));
|
|
111
|
+
|
|
112
|
+
var splitDate = function splitDate(date) {
|
|
113
|
+
return date.split('-');
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
var isStart = function isStart(currDate) {
|
|
117
|
+
return Utils.isEqual(state.currDate[0], currDate);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var isEnd = function isEnd(currDate) {
|
|
121
|
+
return Utils.isEqual(state.currDate[1], currDate);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
var getCurrDate = function getCurrDate(day, month, isRange) {
|
|
125
|
+
return isRange ? month.curData[3] + '-' + month.curData[4] + '-' + Utils.getNumTwoBit(+day.day) : month.curData[0] + '-' + month.curData[1] + '-' + Utils.getNumTwoBit(+day.day);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
var getClass = function getClass(day, month, isRange) {
|
|
129
|
+
var currDate = getCurrDate(day, month, isRange);
|
|
130
|
+
|
|
131
|
+
if (day.type === 'curr') {
|
|
132
|
+
if (!state.isRange && Utils.isEqual(state.currDate, currDate) || state.isRange && (isStart(currDate) || isEnd(currDate))) {
|
|
133
|
+
return "".concat(state.dayPrefix, "-active");
|
|
134
|
+
} else if (startDate && Utils.compareDate(currDate, startDate) || endDate && Utils.compareDate(endDate, currDate)) {
|
|
135
|
+
return "".concat(state.dayPrefix, "-disabled");
|
|
136
|
+
} else 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])) {
|
|
137
|
+
return "".concat(state.dayPrefix, "-choose");
|
|
138
|
+
} else {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
return "".concat(state.dayPrefix, "-disabled");
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
var isActive = function isActive(day, month) {
|
|
147
|
+
return state.isRange && day.type == 'curr' && getClass(day, month) == 'calendar-month-day-active';
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
var isCurrDay = function isCurrDay(month, day) {
|
|
151
|
+
var date = "".concat(month.curData[0], "-").concat(month.curData[1], "-").concat(day);
|
|
152
|
+
return Utils.isEqual(date, Utils.date2Str(new Date()));
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
var confirm = function confirm() {
|
|
156
|
+
if (state.isRange && state.chooseData.length == 2 || !state.isRange) {
|
|
157
|
+
onChoose && onChoose(state.chooseData);
|
|
158
|
+
|
|
159
|
+
if (poppable) {
|
|
160
|
+
onUpdate && onUpdate();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
var chooseDay = function chooseDay(day, month, isFirst, isRange) {
|
|
166
|
+
if (getClass(day, month, isRange) != "".concat(state.dayPrefix, "-disabled")) {
|
|
167
|
+
var days = _toConsumableArray(month.curData);
|
|
168
|
+
|
|
169
|
+
days = isRange ? days.splice(3) : days.splice(0, 3);
|
|
170
|
+
days[2] = typeof day.day === 'number' ? Utils.getNumTwoBit(day.day) : day.day;
|
|
171
|
+
days[3] = "".concat(days[0], "-").concat(days[1], "-").concat(days[2]);
|
|
172
|
+
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
173
|
+
|
|
174
|
+
if (!state.isRange) {
|
|
175
|
+
state.currDate = days[3];
|
|
176
|
+
state.chooseData = _toConsumableArray(days);
|
|
177
|
+
} else {
|
|
178
|
+
if (Object.values(state.currDate).length === 2) {
|
|
179
|
+
state.currDate = [days[3]];
|
|
180
|
+
} else {
|
|
181
|
+
if (Utils.compareDate(state.currDate[0], days[3])) {
|
|
182
|
+
Array.isArray(state.currDate) && state.currDate.push(days[3]);
|
|
183
|
+
} else {
|
|
184
|
+
Array.isArray(state.currDate) && state.currDate.unshift(days[3]);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (state.chooseData.length == 2 || !state.chooseData.length) {
|
|
189
|
+
state.chooseData = _toConsumableArray(days);
|
|
190
|
+
} else {
|
|
191
|
+
if (Utils.compareDate(state.chooseData[3], days[3])) {
|
|
192
|
+
state.chooseData = [_toConsumableArray(state.chooseData), _toConsumableArray(days)];
|
|
193
|
+
} else {
|
|
194
|
+
state.chooseData = [_toConsumableArray(days), _toConsumableArray(state.chooseData)];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (isAutoBackFill && !isFirst) {
|
|
200
|
+
confirm();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
setMonthsData(state.monthsData.slice());
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
var isStartTip = function isStartTip(day, month) {
|
|
208
|
+
if (isActive(day, month)) {
|
|
209
|
+
return isStart(getCurrDate(day, month));
|
|
210
|
+
} else {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}; // 是否有结束提示
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
var isEndTip = function isEndTip(day, month) {
|
|
217
|
+
return isActive(day, month);
|
|
218
|
+
}; // 获取当前月数据
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
var getCurrData = function getCurrData(type) {
|
|
222
|
+
var monthData = type == 'prev' ? state.monthsData[0] : state.monthsData[state.monthsData.length - 1];
|
|
223
|
+
var year = parseInt(monthData.curData[0]);
|
|
224
|
+
var month = parseInt(monthData.curData[1].toString().replace(/^0/, ''));
|
|
225
|
+
|
|
226
|
+
switch (type) {
|
|
227
|
+
case 'prev':
|
|
228
|
+
month == 1 && (year -= 1);
|
|
229
|
+
month = month == 1 ? 12 : --month;
|
|
230
|
+
break;
|
|
231
|
+
|
|
232
|
+
case 'next':
|
|
233
|
+
month == 12 && (year += 1);
|
|
234
|
+
month = month == 12 ? 1 : ++month;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return [year, Utils.getNumTwoBit(month), Utils.getMonthDays(String(year), String(month))];
|
|
239
|
+
}; // 获取日期状态
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
var getDaysStatus = function getDaysStatus(days, type) {
|
|
243
|
+
// 修复:当某个月的1号是周日时,月份下方会空出来一行
|
|
244
|
+
if (type == 'prev' && days >= 7) {
|
|
245
|
+
days -= 7;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return Array.from(Array(days), function (v, k) {
|
|
249
|
+
return {
|
|
250
|
+
day: k + 1,
|
|
251
|
+
type: type
|
|
252
|
+
};
|
|
253
|
+
});
|
|
254
|
+
}; // 获取月数据
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
var getMonth = function getMonth(curData, type) {
|
|
258
|
+
var preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
|
|
259
|
+
var currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
|
|
260
|
+
var title = {
|
|
261
|
+
year: curData[0],
|
|
262
|
+
month: curData[1]
|
|
263
|
+
};
|
|
264
|
+
var monthInfo = {
|
|
265
|
+
curData: curData,
|
|
266
|
+
title: "".concat(title.year, "\u5E74").concat(title.month, "\u6708"),
|
|
267
|
+
monthData: [].concat(_toConsumableArray(getDaysStatus(preMonthDays, 'prev')), _toConsumableArray(getDaysStatus(currMonthDays, 'curr')))
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
if (type == 'next') {
|
|
271
|
+
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]))) {
|
|
272
|
+
state.monthsData.push(monthInfo);
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
if (!state.startData || !Utils.compareDate("".concat(curData[0], "-").concat(curData[1], "-").concat(curData[2]), "".concat(state.startData[0], "-").concat(state.startData[1], "-01"))) {
|
|
276
|
+
state.monthsData.unshift(monthInfo);
|
|
277
|
+
} else {
|
|
278
|
+
setUnLoadPrev(true);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
setMonthsData(state.monthsData);
|
|
283
|
+
}; // 监听月份滚动,改变月份标题
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
var loadScroll = function loadScroll() {
|
|
287
|
+
if (!props.poppable) {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
requestAniFrame$1(function () {
|
|
292
|
+
if (weeksPanel !== null && weeksPanel !== void 0 && weeksPanel.current && monthsPanel !== null && monthsPanel !== void 0 && monthsPanel.current) {
|
|
293
|
+
var top = weeksPanel === null || weeksPanel === void 0 ? void 0 : weeksPanel.current.getBoundingClientRect().bottom;
|
|
294
|
+
var monthsDoms = monthsPanel.current.getElementsByClassName('calendar-month');
|
|
295
|
+
|
|
296
|
+
for (var i = 0; i < monthsDoms.length; i++) {
|
|
297
|
+
if (monthsDoms[i].getBoundingClientRect().top <= top && monthsDoms[i].getBoundingClientRect().bottom >= top) {
|
|
298
|
+
setYearMonthTitle(state.monthsData[i].title);
|
|
299
|
+
} else if (state.scrollDistance === 0) {
|
|
300
|
+
setYearMonthTitle(state.monthsData[0].title);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}; // 设置月份滚动距离和速度
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
var setTransform = function setTransform() {
|
|
309
|
+
var translateY = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
310
|
+
var type = arguments.length > 1 ? arguments[1] : undefined;
|
|
311
|
+
var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
312
|
+
|
|
313
|
+
if (monthsPanel !== null && monthsPanel !== void 0 && monthsPanel.current) {
|
|
314
|
+
if (type === 'end') {
|
|
315
|
+
monthsPanel.current.style.webkitTransition = "transform ".concat(time, "ms cubic-bezier(0.19, 1, 0.22, 1)");
|
|
316
|
+
clearTimeout(state.timer);
|
|
317
|
+
state.timer = setTimeout(function () {
|
|
318
|
+
loadScroll();
|
|
319
|
+
}, time);
|
|
320
|
+
} else {
|
|
321
|
+
monthsPanel.current.style.webkitTransition = '';
|
|
322
|
+
loadScroll();
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
monthsPanel.current.style.webkitTransform = "translateY(".concat(translateY, "px)");
|
|
326
|
+
state.scrollDistance = translateY;
|
|
327
|
+
}
|
|
328
|
+
}; // 计算滚动方向和距离
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
var setMove = function setMove(move, type, time) {
|
|
332
|
+
var _months$current, _monthsPanel$current;
|
|
333
|
+
|
|
334
|
+
var updateMove = move + state.transformY;
|
|
335
|
+
var h = ((_months$current = months.current) === null || _months$current === void 0 ? void 0 : _months$current.offsetHeight) || 0;
|
|
336
|
+
var offsetHeight = ((_monthsPanel$current = monthsPanel.current) === null || _monthsPanel$current === void 0 ? void 0 : _monthsPanel$current.offsetHeight) || 0;
|
|
337
|
+
|
|
338
|
+
if (type === 'end') {
|
|
339
|
+
// 限定滚动距离
|
|
340
|
+
if (updateMove > 0) {
|
|
341
|
+
updateMove = 0;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (updateMove < 0 && updateMove < -offsetHeight + h) {
|
|
345
|
+
updateMove = -offsetHeight + h;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (offsetHeight <= h && state.monthsData.length == 1) {
|
|
349
|
+
updateMove = 0;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
setTransform(updateMove, type, time);
|
|
353
|
+
} else {
|
|
354
|
+
if (updateMove > 0 && updateMove > 100) {
|
|
355
|
+
updateMove = 100;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (updateMove < -offsetHeight + h - 100 && state.monthsData.length > 1) {
|
|
359
|
+
updateMove = -offsetHeight + h - 100;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (updateMove < 0 && updateMove < -100 && state.monthsData.length == 1) {
|
|
363
|
+
updateMove = -100;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
setTransform(updateMove);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
var onTouchStart = function onTouchStart(event) {
|
|
371
|
+
event.stopPropagation();
|
|
372
|
+
var changedTouches = event.changedTouches[0];
|
|
373
|
+
state.touchParams.startY = changedTouches.pageY;
|
|
374
|
+
state.touchParams.startTime = event.timeStamp || Date.now();
|
|
375
|
+
state.transformY = state.scrollDistance;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
var onTouchMove = function onTouchMove(event) {
|
|
379
|
+
event.stopPropagation();
|
|
380
|
+
var changedTouches = event.changedTouches[0];
|
|
381
|
+
state.touchParams.lastY = changedTouches.pageY;
|
|
382
|
+
state.touchParams.lastTime = event.timeStamp || Date.now();
|
|
383
|
+
var move = state.touchParams.lastY - state.touchParams.startY;
|
|
384
|
+
|
|
385
|
+
if (Math.abs(move) < 5) {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
setMove(move);
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
var onTouchEnd = function onTouchEnd(event) {
|
|
393
|
+
var _months$current2, _monthsPanel$current2;
|
|
394
|
+
|
|
395
|
+
event.stopPropagation();
|
|
396
|
+
var changedTouches = event.changedTouches[0];
|
|
397
|
+
state.touchParams.lastY = changedTouches.pageY;
|
|
398
|
+
state.touchParams.lastTime = event.timeStamp || Date.now();
|
|
399
|
+
var move = state.touchParams.lastY - state.touchParams.startY;
|
|
400
|
+
|
|
401
|
+
if (Math.abs(move) < 5) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
var updateMove = move + state.transformY;
|
|
406
|
+
var h = ((_months$current2 = months.current) === null || _months$current2 === void 0 ? void 0 : _months$current2.offsetHeight) || 0;
|
|
407
|
+
var offsetHeight = ((_monthsPanel$current2 = monthsPanel.current) === null || _monthsPanel$current2 === void 0 ? void 0 : _monthsPanel$current2.offsetHeight) || 0;
|
|
408
|
+
|
|
409
|
+
if (updateMove > 0) {
|
|
410
|
+
getMonth(getCurrData('prev'), 'prev');
|
|
411
|
+
} else if (updateMove < 0 && updateMove < -offsetHeight + (Math.abs(move) > h ? Math.abs(move) : h) * 5) {
|
|
412
|
+
getMonth(getCurrData('next'), 'next');
|
|
413
|
+
|
|
414
|
+
if (Math.abs(move) >= 300) {
|
|
415
|
+
getMonth(getCurrData('next'), 'next');
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
var moveTime = state.touchParams.lastTime - state.touchParams.startTime;
|
|
420
|
+
|
|
421
|
+
if (moveTime <= 300) {
|
|
422
|
+
move = move * 2;
|
|
423
|
+
moveTime = moveTime + 1000;
|
|
424
|
+
setMove(move, 'end', moveTime);
|
|
425
|
+
} else {
|
|
426
|
+
setMove(move, 'end');
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
var initData = function initData() {
|
|
431
|
+
//初始化开始结束数据
|
|
432
|
+
state.startData = startDate ? splitDate(startDate) : '';
|
|
433
|
+
state.endData = endDate ? splitDate(endDate) : ''; //初始化当前日期
|
|
434
|
+
|
|
435
|
+
if (!defaultValue) {
|
|
436
|
+
state.currDate = state.isRange ? [Utils.date2Str(new Date()), Utils.getDay(1)] : Utils.date2Str(new Date());
|
|
437
|
+
} else {
|
|
438
|
+
state.currDate = state.isRange ? _toConsumableArray(defaultValue) : defaultValue;
|
|
439
|
+
} //日期转化为数组
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
if (state.isRange && Array.isArray(state.currDate)) {
|
|
443
|
+
if (startDate && Utils.compareDate(state.currDate[0], startDate)) {
|
|
444
|
+
state.currDate.splice(0, 1, startDate);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (endDate && Utils.compareDate(endDate, state.currDate[1])) {
|
|
448
|
+
state.currDate.splice(1, 1, endDate);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
state.defaultData = [].concat(_toConsumableArray(splitDate(state.currDate[0])), _toConsumableArray(splitDate(state.currDate[1])));
|
|
452
|
+
} else {
|
|
453
|
+
if (startDate && Utils.compareDate(state.currDate, startDate)) {
|
|
454
|
+
state.currDate = startDate;
|
|
455
|
+
} else if (endDate && !Utils.compareDate(state.currDate, endDate)) {
|
|
456
|
+
state.currDate = endDate;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
state.defaultData = _toConsumableArray(splitDate(state.currDate));
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
getMonth(state.defaultData, 'next');
|
|
463
|
+
setYearMonthTitle(state.monthsData[0].title);
|
|
464
|
+
var i = 1;
|
|
465
|
+
|
|
466
|
+
do {
|
|
467
|
+
getMonth(getCurrData('next'), 'next');
|
|
468
|
+
} while (i++ < 4);
|
|
469
|
+
|
|
470
|
+
if (state.isRange) {
|
|
471
|
+
chooseDay({
|
|
472
|
+
day: state.defaultData[2],
|
|
473
|
+
type: 'curr'
|
|
474
|
+
}, state.monthsData[0], true);
|
|
475
|
+
chooseDay({
|
|
476
|
+
day: state.defaultData[5],
|
|
477
|
+
type: 'curr'
|
|
478
|
+
}, state.monthsData[0], true, true);
|
|
479
|
+
} else {
|
|
480
|
+
chooseDay({
|
|
481
|
+
day: state.defaultData[2],
|
|
482
|
+
type: 'curr'
|
|
483
|
+
}, state.monthsData[0], true);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
useEffect(function () {
|
|
488
|
+
initData();
|
|
489
|
+
}, []);
|
|
490
|
+
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
491
|
+
className: classes
|
|
492
|
+
}, React__default.createElement("div", {
|
|
493
|
+
className: headerClasses
|
|
494
|
+
}, poppable ? React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
495
|
+
className: "calendar-title"
|
|
496
|
+
}, title), React__default.createElement("div", {
|
|
497
|
+
className: "calendar-curr-month"
|
|
498
|
+
}, yearMonthTitle)) : '', React__default.createElement("div", {
|
|
499
|
+
className: "calendar-weeks",
|
|
500
|
+
ref: weeksPanel
|
|
501
|
+
}, weeks.map(function (item) {
|
|
502
|
+
return React__default.createElement("div", {
|
|
503
|
+
className: "calendar-week-item",
|
|
504
|
+
key: item
|
|
505
|
+
}, item);
|
|
506
|
+
}))), React__default.createElement("div", {
|
|
507
|
+
className: "nut-calendar-content",
|
|
508
|
+
onTouchStart: onTouchStart,
|
|
509
|
+
onTouchMove: onTouchMove,
|
|
510
|
+
onTouchEnd: onTouchEnd,
|
|
511
|
+
ref: months
|
|
512
|
+
}, React__default.createElement("div", {
|
|
513
|
+
className: "calendar-months-panel",
|
|
514
|
+
ref: monthsPanel
|
|
515
|
+
}, React__default.createElement("div", {
|
|
516
|
+
className: "calendar-loading-tip"
|
|
517
|
+
}, !unLoadPrev ? '加载上一个月' : '没有更早月份'), monthsData.map(function (month, key) {
|
|
518
|
+
return React__default.createElement("div", {
|
|
519
|
+
className: "calendar-month",
|
|
520
|
+
key: key
|
|
521
|
+
}, React__default.createElement("div", {
|
|
522
|
+
className: "calendar-month-title"
|
|
523
|
+
}, month.title), React__default.createElement("div", {
|
|
524
|
+
className: "calendar-month-con"
|
|
525
|
+
}, React__default.createElement("div", {
|
|
526
|
+
className: monthitemclasses
|
|
527
|
+
}, month.monthData && month.monthData.map(function (day, index) {
|
|
528
|
+
return React__default.createElement("div", {
|
|
529
|
+
className: ['calendar-month-day', getClass(day, month)].join(' '),
|
|
530
|
+
key: index,
|
|
531
|
+
onClick: function onClick() {
|
|
532
|
+
chooseDay(day, month);
|
|
533
|
+
}
|
|
534
|
+
}, React__default.createElement("div", {
|
|
535
|
+
className: "calendar-day"
|
|
536
|
+
}, day.type === 'curr' ? day.day : ''), isCurrDay(month, day.day) ? React__default.createElement("div", {
|
|
537
|
+
className: "calendar-curr-tips"
|
|
538
|
+
}, "\u4ECA\u5929") : '', isStartTip(day, month) ? React__default.createElement("div", {
|
|
539
|
+
className: "calendar-day-tip"
|
|
540
|
+
}, "\u5F00\u59CB") : isEndTip(day, month) ? React__default.createElement("div", {
|
|
541
|
+
className: "calendar-day-tip"
|
|
542
|
+
}, "\u7ED3\u675F") : '');
|
|
543
|
+
}))));
|
|
544
|
+
}))), poppable && !isAutoBackFill ? React__default.createElement("div", {
|
|
545
|
+
className: "nut-calendar-footer"
|
|
546
|
+
}, React__default.createElement("div", {
|
|
547
|
+
className: "calendar-confirm-btn",
|
|
548
|
+
onClick: confirm
|
|
549
|
+
}, "\u786E\u5B9A")) : ''));
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
CalendarItem.defaultProps = defaultProps;
|
|
553
|
+
CalendarItem.displayName = 'NutCalendarItem';
|
|
554
|
+
export { CalendarItem as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../packages/cell/cell.scss'
|
package/dist/esm/Cell.js
CHANGED
|
@@ -9,7 +9,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
9
9
|
import React__default from 'react';
|
|
10
10
|
import { useHistory } from 'react-router-dom';
|
|
11
11
|
import { c as cn } from './bem-893ad28d.js';
|
|
12
|
-
import
|
|
12
|
+
import Icon from './Icon.js';
|
|
13
13
|
import '@bem-react/classname';
|
|
14
14
|
var defaultProps = {
|
|
15
15
|
title: '',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../packages/cellgroup/cellgroup.scss'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
import React__default from 'react';
|
|
8
|
+
import { c as cn } from './bem-893ad28d.js';
|
|
9
|
+
import '@bem-react/classname';
|
|
10
|
+
var defaultProps = {
|
|
11
|
+
title: '',
|
|
12
|
+
classPrefix: 'nutui-cell-group'
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
var CellGroup = function CellGroup(props) {
|
|
16
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
17
|
+
children = _defaultProps$props.children,
|
|
18
|
+
classPrefix = _defaultProps$props.classPrefix,
|
|
19
|
+
title = _defaultProps$props.title;
|
|
20
|
+
|
|
21
|
+
var b = cn('cell-group');
|
|
22
|
+
return React__default.createElement("div", {
|
|
23
|
+
className: b(null, [classPrefix])
|
|
24
|
+
}, title ? React__default.createElement("div", {
|
|
25
|
+
className: b('title')
|
|
26
|
+
}, title) : null, React__default.createElement("div", {
|
|
27
|
+
className: b('wrap')
|
|
28
|
+
}, children));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
CellGroup.defaultProps = defaultProps;
|
|
32
|
+
CellGroup.displayName = 'NutCellGroup';
|
|
33
|
+
export { CellGroup as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../packages/checkbox/checkbox.scss'
|
package/dist/esm/Checkbox.js
CHANGED
|
@@ -8,7 +8,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
8
8
|
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; }
|
|
9
9
|
|
|
10
10
|
import React__default, { useState, useEffect } from 'react';
|
|
11
|
-
import
|
|
11
|
+
import Icon from './Icon.js';
|
|
12
12
|
import CheckboxGroup from './CheckboxGroup.js';
|
|
13
13
|
import { c as cn } from './bem-893ad28d.js';
|
|
14
14
|
import '@bem-react/classname';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../packages/checkboxgroup/checkboxgroup.scss'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../packages/circleprogress/circleprogress.scss'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../packages/col/col.scss'
|
package/dist/esm/Col.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
|
|
4
|
+
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; }
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
8
|
+
import React__default, { useState, useContext, useEffect } from 'react';
|
|
9
|
+
import { D as DataContext } from './UserContext-be8097d2.js';
|
|
10
|
+
var defaultProps = {
|
|
11
|
+
span: '24',
|
|
12
|
+
offset: '0',
|
|
13
|
+
gutter: '0'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
var Col = function Col(props) {
|
|
17
|
+
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
18
|
+
span = _defaultProps$props.span,
|
|
19
|
+
offset = _defaultProps$props.offset,
|
|
20
|
+
children = _defaultProps$props.children;
|
|
21
|
+
|
|
22
|
+
var _useState = useState(''),
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
colName = _useState2[0],
|
|
25
|
+
setColName = _useState2[1];
|
|
26
|
+
|
|
27
|
+
var _useState3 = useState({}),
|
|
28
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
|
+
colStyle = _useState4[0],
|
|
30
|
+
setColStyle = _useState4[1];
|
|
31
|
+
|
|
32
|
+
var gutter = useContext(DataContext).gutter;
|
|
33
|
+
|
|
34
|
+
var classs = function classs() {
|
|
35
|
+
//定义col的class类
|
|
36
|
+
var prefixCls = 'nut-col';
|
|
37
|
+
return "".concat(prefixCls, " ").concat(prefixCls, "-").concat(span, " ").concat(gutter ? "".concat(prefixCls, "-gutter") : '', " ").concat(prefixCls, "-").concat(offset);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var getStyle = function getStyle() {
|
|
41
|
+
//定义col的style类
|
|
42
|
+
var style = {};
|
|
43
|
+
style.paddingLeft = "".concat(gutter / 2, "px");
|
|
44
|
+
style.paddingRight = "".concat(gutter / 2, "px");
|
|
45
|
+
return style;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
setColName(classs);
|
|
50
|
+
setColStyle(getStyle);
|
|
51
|
+
}, [span, offset, gutter]);
|
|
52
|
+
return React__default.createElement("div", {
|
|
53
|
+
className: "".concat(colName),
|
|
54
|
+
style: _objectSpread({}, colStyle)
|
|
55
|
+
}, children);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Col.defaultProps = defaultProps;
|
|
59
|
+
Col.displayName = 'NutCol';
|
|
60
|
+
export { Col as default };
|