@nutui/nutui-react-taro 1.3.2-beta.0 → 1.3.2-beta.1

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.
@@ -1,13 +1,16 @@
1
- import { D as DatePicker } from './datepicker.taro-440e6da6.js';
2
- export { D as default } from './datepicker.taro-440e6da6.js';
1
+ import { D as DatePicker } from './datepicker.taro-318e9561.js';
2
+ export { D as default } from './datepicker.taro-318e9561.js';
3
3
  import 'react';
4
- import './useRefs-032cf186.js';
4
+ import './picker.taro-62ce13e0.js';
5
+ import './popup.taro-8363fbae.js';
5
6
  import 'react-dom';
6
7
  import 'react-transition-group';
7
8
  import 'classnames';
9
+ import './overlay.taro-be45fed5.js';
8
10
  import './bem-893ad28d.js';
9
11
  import '@bem-react/classname';
10
- import './icon-8dc4de10.js';
12
+ import './icon.taro-1d0d4fb7.js';
11
13
  import './useTouch-a2ea68c6.js';
12
- import './configprovider-3e87d67a.js';
14
+ import './useClientRect-8b7cc406.js';
15
+ import './configprovider.taro-6c7b3056.js';
13
16
  import './zh-CN-14165629.js';
@@ -1,13 +1,14 @@
1
- import { P as Picker } from './picker.taro-6b663b69.js';
2
- export { P as default } from './picker.taro-6b663b69.js';
1
+ import { P as Picker } from './picker.taro-62ce13e0.js';
2
+ export { P as default } from './picker.taro-62ce13e0.js';
3
3
  import 'react';
4
- import './useRefs-032cf186.js';
4
+ import './popup.taro-8363fbae.js';
5
5
  import 'react-dom';
6
6
  import 'react-transition-group';
7
7
  import 'classnames';
8
+ import './overlay.taro-be45fed5.js';
8
9
  import './bem-893ad28d.js';
9
10
  import '@bem-react/classname';
10
- import './icon-8dc4de10.js';
11
+ import './icon.taro-1d0d4fb7.js';
11
12
  import './useTouch-a2ea68c6.js';
12
13
  import './useClientRect-8b7cc406.js';
13
14
  import './configprovider.taro-6c7b3056.js';
@@ -0,0 +1,364 @@
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
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
+ var _excluded = ["minDate", "maxDate", "type", "isShowChinese", "minuteStep", "modelValue", "visible", "title", "formatter", "onCloseDatePicker", "onConfirmDatePicker", "filter", "threeDimensional", "className", "style"];
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
11
+ import React__default, { useState, useRef, useEffect } from 'react';
12
+ import { P as Picker } from './picker.taro-62ce13e0.js';
13
+ var currentYear = new Date().getFullYear();
14
+ var defaultProps = {
15
+ modelValue: null,
16
+ visible: false,
17
+ title: '',
18
+ type: 'date',
19
+ isShowChinese: false,
20
+ threeDimensional: true,
21
+ minuteStep: 1,
22
+ minDate: new Date(currentYear - 10, 0, 1),
23
+ maxDate: new Date(currentYear + 10, 11, 31)
24
+ };
25
+
26
+ var DatePicker = function DatePicker(props) {
27
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
28
+ minDate = _defaultProps$props.minDate,
29
+ maxDate = _defaultProps$props.maxDate,
30
+ type = _defaultProps$props.type,
31
+ isShowChinese = _defaultProps$props.isShowChinese,
32
+ minuteStep = _defaultProps$props.minuteStep,
33
+ modelValue = _defaultProps$props.modelValue,
34
+ visible = _defaultProps$props.visible,
35
+ title = _defaultProps$props.title,
36
+ formatter = _defaultProps$props.formatter,
37
+ onCloseDatePicker = _defaultProps$props.onCloseDatePicker,
38
+ onConfirmDatePicker = _defaultProps$props.onConfirmDatePicker,
39
+ filter = _defaultProps$props.filter,
40
+ threeDimensional = _defaultProps$props.threeDimensional,
41
+ className = _defaultProps$props.className,
42
+ style = _defaultProps$props.style,
43
+ rest = _objectWithoutProperties(_defaultProps$props, _excluded);
44
+
45
+ var _useState = useState(false),
46
+ _useState2 = _slicedToArray(_useState, 2),
47
+ show = _useState2[0],
48
+ setShow = _useState2[1];
49
+
50
+ var _useState3 = useState(modelValue),
51
+ _useState4 = _slicedToArray(_useState3, 2),
52
+ currentDate = _useState4[0],
53
+ setCurrentDate = _useState4[1];
54
+
55
+ var _useState5 = useState([]),
56
+ _useState6 = _slicedToArray(_useState5, 2),
57
+ defaultValue = _useState6[0],
58
+ setDefaultValue = _useState6[1];
59
+
60
+ var _useState7 = useState([]),
61
+ _useState8 = _slicedToArray(_useState7, 2),
62
+ listData = _useState8[0],
63
+ setListData = _useState8[1];
64
+
65
+ var pickerRef = useRef(null);
66
+
67
+ var isDate = function isDate(val) {
68
+ return Object.prototype.toString.call(val) === '[object Date]' && !Number.isNaN(val.getTime());
69
+ };
70
+
71
+ var zhCNType = {
72
+ day: '日',
73
+ year: '年',
74
+ month: '月',
75
+ hour: '时',
76
+ minute: '分',
77
+ seconds: '秒'
78
+ };
79
+
80
+ var formatValue = function formatValue(value) {
81
+ var cvalue = value;
82
+
83
+ if (!cvalue || cvalue && !isDate(cvalue)) {
84
+ cvalue = minDate;
85
+ }
86
+
87
+ var timestmp = Math.max(cvalue.getTime(), minDate.getTime());
88
+ timestmp = Math.min(timestmp, maxDate.getTime());
89
+ return new Date(timestmp);
90
+ };
91
+
92
+ function getMonthEndDay(year, month) {
93
+ return new Date(year, month, 0).getDate();
94
+ }
95
+
96
+ var getBoundary = function getBoundary(type, value) {
97
+ var _ref;
98
+
99
+ var boundary = type === 'min' ? minDate : maxDate;
100
+ var year = boundary.getFullYear();
101
+ var month = 1;
102
+ var date = 1;
103
+ var hour = 0;
104
+ var minute = 0;
105
+
106
+ if (type === 'max') {
107
+ month = 12;
108
+ date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
109
+ hour = 23;
110
+ minute = 59;
111
+ }
112
+
113
+ var seconds = minute;
114
+
115
+ if (value.getFullYear() === year) {
116
+ month = boundary.getMonth() + 1;
117
+
118
+ if (value.getMonth() + 1 === month) {
119
+ date = boundary.getDate();
120
+
121
+ if (value.getDate() === date) {
122
+ hour = boundary.getHours();
123
+
124
+ if (value.getHours() === hour) {
125
+ minute = boundary.getMinutes();
126
+ }
127
+ }
128
+ }
129
+ }
130
+
131
+ return _ref = {}, _defineProperty(_ref, "".concat(type, "Year"), year), _defineProperty(_ref, "".concat(type, "Month"), month), _defineProperty(_ref, "".concat(type, "Date"), date), _defineProperty(_ref, "".concat(type, "Hour"), hour), _defineProperty(_ref, "".concat(type, "Minute"), minute), _defineProperty(_ref, "".concat(type, "Seconds"), seconds), _ref;
132
+ };
133
+
134
+ var ranges = function ranges(date) {
135
+ var curDate = date || currentDate;
136
+ console.log(11, currentDate);
137
+ if (!curDate) return [];
138
+
139
+ var _getBoundary = getBoundary('max', curDate),
140
+ maxYear = _getBoundary.maxYear,
141
+ maxDate = _getBoundary.maxDate,
142
+ maxMonth = _getBoundary.maxMonth,
143
+ maxHour = _getBoundary.maxHour,
144
+ maxMinute = _getBoundary.maxMinute,
145
+ maxSeconds = _getBoundary.maxSeconds;
146
+
147
+ var _getBoundary2 = getBoundary('min', curDate),
148
+ minYear = _getBoundary2.minYear,
149
+ minDate = _getBoundary2.minDate,
150
+ minMonth = _getBoundary2.minMonth,
151
+ minHour = _getBoundary2.minHour,
152
+ minMinute = _getBoundary2.minMinute,
153
+ minSeconds = _getBoundary2.minSeconds;
154
+
155
+ var result = [{
156
+ type: 'year',
157
+ range: [minYear, maxYear]
158
+ }, {
159
+ type: 'month',
160
+ range: [minMonth, maxMonth]
161
+ }, {
162
+ type: 'day',
163
+ range: [minDate, maxDate]
164
+ }, {
165
+ type: 'hour',
166
+ range: [minHour, maxHour]
167
+ }, {
168
+ type: 'minute',
169
+ range: [minMinute, maxMinute]
170
+ }, {
171
+ type: 'seconds',
172
+ range: [minSeconds, maxSeconds]
173
+ }];
174
+
175
+ switch (type.toLocaleLowerCase()) {
176
+ case 'date':
177
+ result = result.slice(0, 3);
178
+ break;
179
+
180
+ case 'datetime':
181
+ result = result.slice(0, 5);
182
+ break;
183
+
184
+ case 'time':
185
+ result = result.slice(3, 6);
186
+ break;
187
+
188
+ case 'year-month':
189
+ result = result.slice(0, 2);
190
+ break;
191
+
192
+ case 'month-day':
193
+ result = result.slice(1, 3);
194
+ break;
195
+
196
+ case 'datehour':
197
+ result = result.slice(0, 4);
198
+ break;
199
+ }
200
+
201
+ return result;
202
+ };
203
+
204
+ var updateChooseValueCustmer = function updateChooseValueCustmer(index, selectedValue, cacheValueData) {
205
+ if (['date', 'datetime', 'datehour', 'month-day', 'year-month'].includes(type.toLocaleLowerCase())) {
206
+ var _date;
207
+
208
+ var formatDate = [];
209
+ selectedValue.forEach(function (item) {
210
+ formatDate.push(item);
211
+ });
212
+
213
+ if (type.toLocaleLowerCase() === 'month-day' && formatDate.length < 3) {
214
+ formatDate.unshift(new Date(modelValue || minDate || maxDate).getFullYear());
215
+ }
216
+
217
+ if (type.toLocaleLowerCase() === 'year-month' && formatDate.length < 3) {
218
+ formatDate.push(new Date(modelValue || minDate || maxDate).getDate());
219
+ }
220
+
221
+ var year = Number(formatDate[0]);
222
+ var month = Number(formatDate[1]) - 1;
223
+ var day = Math.min(Number(formatDate[2]), getMonthEndDay(Number(formatDate[0]), Number(formatDate[1])));
224
+ var date = null;
225
+
226
+ if (type.toLocaleLowerCase() === 'date' || type.toLocaleLowerCase() === 'month-day' || type.toLocaleLowerCase() === 'year-month') {
227
+ date = new Date(year, month, day);
228
+ } else if (type.toLocaleLowerCase() === 'datetime') {
229
+ date = new Date(year, month, day, Number(formatDate[3]), Number(formatDate[4]));
230
+ } else if (type.toLocaleLowerCase() === 'datehour') {
231
+ date = new Date(year, month, day, Number(formatDate[3]));
232
+ }
233
+
234
+ var isEqual = (currentDate === null || currentDate === void 0 ? void 0 : currentDate.getTime()) === ((_date = date) === null || _date === void 0 ? void 0 : _date.getTime());
235
+ date && isDate(date) && !isEqual && setCurrentDate(formatValue(date));
236
+ }
237
+
238
+ props.onChangeDatePicker && props.onChangeDatePicker(index, selectedValue, cacheValueData);
239
+ };
240
+
241
+ var padZero = function padZero(num) {
242
+ var targetLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
243
+ var str = "".concat(num);
244
+
245
+ while (str.length < targetLength) {
246
+ str = "0".concat(str);
247
+ }
248
+
249
+ return str;
250
+ };
251
+
252
+ var formatterOption = function formatterOption(type, value) {
253
+ var fOption = null;
254
+
255
+ if (formatter) {
256
+ fOption = formatter(type, {
257
+ text: padZero(value, 2),
258
+ value: padZero(value, 2)
259
+ });
260
+ } else {
261
+ var padMin = padZero(value, 2);
262
+ var fatter = isShowChinese ? zhCNType[type] : '';
263
+ fOption = {
264
+ text: padMin + fatter,
265
+ value: padMin
266
+ };
267
+ }
268
+
269
+ return fOption;
270
+ };
271
+
272
+ var generateValue = function generateValue(min, max, val, type, columnIndex) {
273
+ var cmin = min;
274
+ var arr = [];
275
+ var index = 0;
276
+
277
+ while (cmin <= max) {
278
+ arr.push(formatterOption(type, cmin));
279
+
280
+ if (type === 'minute') {
281
+ cmin += minuteStep;
282
+ } else {
283
+ cmin++;
284
+ }
285
+
286
+ if (cmin <= val) {
287
+ index++;
288
+ }
289
+ }
290
+
291
+ defaultValue[columnIndex] = arr[index].value;
292
+ setDefaultValue(_toConsumableArray(defaultValue));
293
+
294
+ if (props.filter && props.filter(type, arr)) {
295
+ return props.filter(type, arr);
296
+ }
297
+
298
+ return arr;
299
+ };
300
+
301
+ var getDateIndex = function getDateIndex(type) {
302
+ if (!currentDate) return 0;
303
+ var d = 0;
304
+
305
+ if (type === 'year') {
306
+ d = currentDate.getFullYear();
307
+ } else if (type === 'month') {
308
+ d = currentDate.getMonth() + 1;
309
+ } else if (type === 'day') {
310
+ d = currentDate.getDate();
311
+ } else if (type === 'hour') {
312
+ d = currentDate.getHours();
313
+ } else if (type === 'minute') {
314
+ d = currentDate.getMinutes();
315
+ } else if (type === 'seconds') {
316
+ d = currentDate.getSeconds();
317
+ }
318
+
319
+ return d;
320
+ };
321
+
322
+ var columns = function columns(date) {
323
+ var val = ranges(date).map(function (res, columnIndex) {
324
+ return generateValue(res.range[0], res.range[1], getDateIndex(res.type), res.type, columnIndex);
325
+ });
326
+ return val || [];
327
+ };
328
+
329
+ useEffect(function () {
330
+ setCurrentDate(formatValue(modelValue)); // initDefault()
331
+ }, []);
332
+ useEffect(function () {
333
+ setCurrentDate(formatValue(modelValue));
334
+ }, [modelValue]);
335
+ useEffect(function () {
336
+ setShow(visible);
337
+ }, [visible]);
338
+ useEffect(function () {
339
+ if (currentDate) {
340
+ setListData(columns());
341
+ }
342
+ }, [currentDate]);
343
+ return React__default.createElement("div", _objectSpread({
344
+ className: "nut-datepicker ".concat(className || ''),
345
+ style: style
346
+ }, rest), listData.length > 0 && React__default.createElement(Picker, {
347
+ isVisible: show,
348
+ listData: listData,
349
+ onClose: onCloseDatePicker,
350
+ defaultValueData: defaultValue,
351
+ onConfirm: function onConfirm(values, options) {
352
+ return onConfirmDatePicker && onConfirmDatePicker(values, options);
353
+ },
354
+ onChange: function onChange(index, value, list) {
355
+ return updateChooseValueCustmer(index, value, list);
356
+ },
357
+ threeDimensional: threeDimensional,
358
+ ref: pickerRef
359
+ }));
360
+ };
361
+
362
+ DatePicker.defaultProps = defaultProps;
363
+ DatePicker.displayName = 'NutDatePicker';
364
+ export { DatePicker as D };
@@ -29,14 +29,14 @@ export { R as Range } from './range.taro-ef3b30f0.js';
29
29
  export { C as Calendar } from './calendar.taro-1fc76ba0.js';
30
30
  export { C as Checkbox } from './checkbox.taro-9d05ae76.js';
31
31
  export { C as CheckboxGroup } from './checkboxgroup.taro-3d380042.js';
32
- export { D as DatePicker } from './datepicker.taro-440e6da6.js';
32
+ export { D as DatePicker } from './datepicker.taro-318e9561.js';
33
33
  export { I as InputNumber } from './inputnumber.taro-102203f3.js';
34
34
  export { I as Input } from './input.taro-505632ac.js';
35
35
  export { R as Radio } from './radio.taro-1c63512f.js';
36
36
  export { R as RadioGroup } from './radiogroup.taro-b5dad516.js';
37
37
  export { R as Rate } from './rate.taro-bb2e6c87.js';
38
38
  export { C as CalendarItem } from './calendaritem.taro-11333579.js';
39
- export { P as Picker } from './picker.taro-6b663b69.js';
39
+ export { P as Picker } from './picker.taro-62ce13e0.js';
40
40
  export { S as ShortPassword } from './shortpassword.taro-2db97cc8.js';
41
41
  export { T as TextArea } from './textarea.taro-388d1f90.js';
42
42
  export { U as Uploader } from './uploader.taro-b232b2d3.js';
@@ -99,10 +99,9 @@ import '@react-spring/web';
99
99
  import './offsetContext-0e3d04b3.js';
100
100
  import './useTouch-a2ea68c6.js';
101
101
  import './useClientRect-8b7cc406.js';
102
- import './useRefs-032cf186.js';
103
102
  import './icon-8dc4de10.js';
104
- import './configprovider-3e87d67a.js';
105
103
  import './render-4a3856cb.js';
106
104
  import './UserContext-68f62e66.js';
107
105
  import './UserContext-b4181162.js';
108
106
  import './AvatarContext-7153ad2b.js';
107
+ import './configprovider-3e87d67a.js';
@@ -11,7 +11,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
11
11
 
12
12
  import _regeneratorRuntime from "@babel/runtime/regenerator";
13
13
  import React__default, { useState, useRef, useEffect, useImperativeHandle } from 'react';
14
- import { u as useRefs, P as Popup } from './useRefs-032cf186.js';
14
+ import { P as Popup } from './popup.taro-8363fbae.js';
15
15
  import { u as useTouch } from './useTouch-a2ea68c6.js';
16
16
  import { g as getRectByTaro } from './useClientRect-8b7cc406.js';
17
17
  import { u as useConfig } from './configprovider.taro-6c7b3056.js';
@@ -340,6 +340,19 @@ var InternalPickerSlot = function InternalPickerSlot(props, ref) {
340
340
 
341
341
  var PickerSlot = React__default.forwardRef(InternalPickerSlot);
342
342
 
343
+ function useRefs() {
344
+ var refs = React__default.useRef([]);
345
+ var setRefs = React__default.useCallback(function (index) {
346
+ return function (el) {
347
+ if (el) refs.current[index] = el;
348
+ };
349
+ }, []);
350
+ var reset = React__default.useCallback(function () {
351
+ refs.current = [];
352
+ }, []);
353
+ return [refs.current, setRefs, reset];
354
+ }
355
+
343
356
  var InternalPicker = function InternalPicker(props, ref) {
344
357
  var _useConfig = useConfig(),
345
358
  locale = _useConfig.locale;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.3.2-beta.0 Wed Sep 07 2022 10:39:38 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v1.3.2-beta.1 Wed Sep 07 2022 14:20:00 GMT+0800 (China Standard Time)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.3.2-beta.0 Wed Sep 07 2022 10:39:38 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v1.3.2-beta.1 Wed Sep 07 2022 14:20:00 GMT+0800 (China Standard Time)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.3.2-beta.0 Wed Sep 07 2022 10:39:38 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v1.3.2-beta.1 Wed Sep 07 2022 14:20:00 GMT+0800 (China Standard Time)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.3.2-beta.0 Wed Sep 07 2022 10:39:38 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v1.3.2-beta.1 Wed Sep 07 2022 14:20:00 GMT+0800 (China Standard Time)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v1.3.2-beta.0 Wed Sep 07 2022 10:39:38 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v1.3.2-beta.1 Wed Sep 07 2022 14:20:00 GMT+0800 (China Standard Time)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */