@trionesdev/antd-taro-react 0.0.2-beta.2 → 0.0.2-beta.21

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.
Files changed (175) hide show
  1. package/dist/ActionSheet/ActionSheet.d.ts +25 -0
  2. package/dist/ActionSheet/ActionSheet.js +77 -0
  3. package/dist/ActionSheet/index.d.ts +1 -1
  4. package/dist/ActionSheet/index.js +1 -1
  5. package/dist/ActionSheet/style.scss +52 -0
  6. package/dist/Button/button.d.ts +2 -1
  7. package/dist/Button/button.js +2 -3
  8. package/dist/Button/style.scss +65 -50
  9. package/dist/Calendar/calendar-grid.d.ts +10 -9
  10. package/dist/Calendar/calendar-grid.js +37 -62
  11. package/dist/Calendar/calendar-header.d.ts +3 -2
  12. package/dist/Calendar/calendar-header.js +9 -6
  13. package/dist/Calendar/calendar-range.d.ts +4 -3
  14. package/dist/Calendar/calendar-range.js +22 -18
  15. package/dist/Calendar/calendar.d.ts +5 -4
  16. package/dist/Calendar/calendar.js +30 -17
  17. package/dist/Calendar/style.scss +8 -5
  18. package/dist/Calendar/touchable-calendar-grid.d.ts +6 -5
  19. package/dist/Calendar/touchable-calendar-grid.js +87 -86
  20. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.d.ts +3 -2
  21. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.js +40 -57
  22. package/dist/CalendarDatetimePicker/DateTimeSwitch.d.ts +3 -2
  23. package/dist/CalendarDatetimePicker/DateTimeSwitch.js +2 -2
  24. package/dist/CalendarDatetimePicker/style.scss +11 -3
  25. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.d.ts +9 -0
  26. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.js +60 -0
  27. package/dist/CalendarDatetimePickerCell/index.d.ts +3 -0
  28. package/dist/CalendarDatetimePickerCell/index.js +2 -0
  29. package/dist/CalendarPicker/{calendar-picker.js → CalendarPicker.js} +10 -6
  30. package/dist/CalendarPicker/{calendar-range-picker.js → CalendarRangePicker.js} +8 -6
  31. package/dist/CalendarPicker/index.d.ts +3 -4
  32. package/dist/CalendarPicker/index.js +2 -2
  33. package/dist/CalendarPicker/style.scss +7 -6
  34. package/dist/CalendarPicker/types.d.ts +8 -6
  35. package/dist/CalendarPicker/types.js +1 -1
  36. package/dist/CalendarPickerCell/CalendarPickerCell.d.ts +11 -0
  37. package/dist/CalendarPickerCell/CalendarPickerCell.js +54 -0
  38. package/dist/CalendarPickerCell/CalendarRangePickerCell.d.ts +11 -0
  39. package/dist/CalendarPickerCell/CalendarRangePickerCell.js +56 -0
  40. package/dist/CalendarPickerCell/index.d.ts +8 -0
  41. package/dist/CalendarPickerCell/index.js +5 -0
  42. package/dist/CascaderPicker/cascader-picker.d.ts +27 -0
  43. package/dist/CascaderPicker/cascader-picker.js +90 -0
  44. package/dist/CascaderPicker/index.d.ts +1 -1
  45. package/dist/CascaderPicker/index.js +1 -1
  46. package/dist/CascaderPicker/style.scss +45 -0
  47. package/dist/CascaderPickerCell/CascaderPickerCell.d.ts +20 -0
  48. package/dist/CascaderPickerCell/CascaderPickerCell.js +70 -0
  49. package/dist/CascaderPickerCell/index.d.ts +3 -0
  50. package/dist/CascaderPickerCell/index.js +2 -0
  51. package/dist/DatePicker/DatePicker.d.ts +18 -0
  52. package/dist/DatePicker/DatePicker.js +310 -0
  53. package/dist/DatePicker/index.d.ts +4 -0
  54. package/dist/DatePicker/index.js +3 -0
  55. package/dist/DatePicker/style.scss +41 -0
  56. package/dist/DatePicker/types.d.ts +1 -0
  57. package/dist/DatePicker/types.js +1 -0
  58. package/dist/DatePickerCell/DatePickerCell.d.ts +16 -0
  59. package/dist/DatePickerCell/DatePickerCell.js +78 -0
  60. package/dist/DatePickerCell/index.d.ts +3 -0
  61. package/dist/DatePickerCell/index.js +2 -0
  62. package/dist/FetchPicker/FetchPicker.d.ts +78 -0
  63. package/dist/FetchPicker/FetchPicker.js +310 -0
  64. package/dist/FetchPicker/index.d.ts +4 -0
  65. package/dist/FetchPicker/index.js +3 -0
  66. package/dist/FetchPicker/styles.scss +130 -0
  67. package/dist/FloatButton/FloatButton.d.ts +19 -0
  68. package/dist/FloatButton/FloatButton.js +60 -0
  69. package/dist/FloatButton/FloatButtonGroup.d.ts +21 -0
  70. package/dist/FloatButton/FloatButtonGroup.js +141 -0
  71. package/dist/FloatButton/context.d.ts +10 -0
  72. package/dist/FloatButton/context.js +2 -0
  73. package/dist/FloatButton/index.d.ts +10 -0
  74. package/dist/FloatButton/index.js +5 -0
  75. package/dist/FloatButton/style.scss +126 -0
  76. package/dist/Form/FormItem/form-item-content.d.ts +17 -0
  77. package/dist/Form/FormItem/form-item-content.js +39 -0
  78. package/dist/Form/FormItem/form-item-label.d.ts +13 -0
  79. package/dist/Form/FormItem/form-item-label.js +29 -0
  80. package/dist/Form/FormItem/form-item.d.ts +23 -0
  81. package/dist/Form/FormItem/form-item.js +77 -0
  82. package/dist/Form/FormItem/index.d.ts +5 -0
  83. package/dist/Form/FormItem/index.js +3 -0
  84. package/dist/Form/index.d.ts +9 -2
  85. package/dist/Form/index.js +5 -1
  86. package/dist/Form/style.scss +100 -0
  87. package/dist/FormCell/index.d.ts +3 -0
  88. package/dist/FormCell/index.js +2 -0
  89. package/dist/ImagesPreview/ImagesPreview.js +4 -3
  90. package/dist/ImagesWall/ImagesWall.js +1 -1
  91. package/dist/Input/index.d.ts +17 -2
  92. package/dist/Input/index.js +13 -1
  93. package/dist/Input/index.scss +282 -0
  94. package/dist/Input/input-affix-wrapper.d.ts +13 -0
  95. package/dist/Input/input-affix-wrapper.js +37 -0
  96. package/dist/Input/input-digit.d.ts +7 -0
  97. package/dist/Input/input-digit.js +53 -0
  98. package/dist/Input/input-number.d.ts +7 -0
  99. package/dist/Input/input-number.js +50 -0
  100. package/dist/Input/input-opt.d.ts +16 -0
  101. package/dist/Input/input-opt.js +87 -0
  102. package/dist/Input/input-password.d.ts +8 -0
  103. package/dist/Input/input-password.js +49 -0
  104. package/dist/Input/input.d.ts +3 -0
  105. package/dist/Input/input.js +7 -0
  106. package/dist/Input/taro-input.d.ts +8 -0
  107. package/dist/Input/taro-input.js +70 -0
  108. package/dist/Input/textarea.d.ts +15 -0
  109. package/dist/Input/textarea.js +52 -0
  110. package/dist/Input/types.d.ts +20 -0
  111. package/dist/Input/types.js +2 -0
  112. package/dist/Loading/index.d.ts +4 -0
  113. package/dist/Loading/index.js +3 -0
  114. package/dist/Overlay/Overlay.d.ts +17 -0
  115. package/dist/Overlay/Overlay.js +100 -0
  116. package/dist/Overlay/index.d.ts +4 -0
  117. package/dist/Overlay/index.js +3 -0
  118. package/dist/Overlay/style.scss +20 -0
  119. package/dist/Picker/Picker.d.ts +27 -0
  120. package/dist/Picker/Picker.js +100 -0
  121. package/dist/Picker/index.d.ts +1 -1
  122. package/dist/Picker/index.js +1 -1
  123. package/dist/Picker/style.scss +41 -0
  124. package/dist/PickerView/PickerView.d.ts +4 -0
  125. package/dist/PickerView/PickerView.js +71 -0
  126. package/dist/PickerView/index.d.ts +2 -2
  127. package/dist/PickerView/index.js +1 -1
  128. package/dist/PickerView/style.scss +13 -0
  129. package/dist/PickerView/types.d.ts +15 -0
  130. package/dist/PickerView/types.js +1 -0
  131. package/dist/Popup/Popup.d.ts +48 -0
  132. package/dist/Popup/Popup.js +135 -0
  133. package/dist/Popup/index.d.ts +2 -1
  134. package/dist/Popup/index.js +2 -1
  135. package/dist/Popup/style.scss +126 -0
  136. package/dist/Progress/index.d.ts +1 -1
  137. package/dist/Progress/index.js +1 -1
  138. package/dist/Segmented/index.d.ts +3 -0
  139. package/dist/Segmented/index.js +2 -0
  140. package/dist/SideBar/side-bar.js +3 -2
  141. package/dist/SideBar/style.scss +6 -6
  142. package/dist/Stepper/index.d.ts +3 -0
  143. package/dist/Stepper/index.js +2 -0
  144. package/dist/Toast/Toast.d.ts +18 -0
  145. package/dist/Toast/Toast.js +112 -0
  146. package/dist/Toast/index.d.ts +1 -1
  147. package/dist/Toast/index.js +1 -1
  148. package/dist/Toast/style.scss +63 -0
  149. package/dist/VerificationCodeInput/index.d.ts +2 -2
  150. package/dist/VerificationCodeInput/index.js +1 -1
  151. package/dist/VerificationCodeInput/style.scss +20 -0
  152. package/dist/VerificationCodeInput/verification-code-input.d.ts +24 -0
  153. package/dist/VerificationCodeInput/verification-code-input.js +99 -0
  154. package/dist/index.d.ts +28 -7
  155. package/dist/index.js +12 -2
  156. package/dist/style/variable.scss +33 -0
  157. package/dist/types.d.ts +0 -1
  158. package/dist/utils/dayjs.d.ts +4 -0
  159. package/dist/utils/dayjs.js +42 -0
  160. package/package.json +25 -30
  161. package/dist/Mask/index.d.ts +0 -3
  162. package/dist/Mask/index.js +0 -2
  163. package/dist/Progress/Progress.d.ts +0 -38
  164. package/dist/Progress/Progress.js +0 -53
  165. package/dist/Progress/ProgressCircle.d.ts +0 -16
  166. package/dist/Progress/ProgressCircle.js +0 -147
  167. package/dist/Progress/ProgressLine.d.ts +0 -15
  168. package/dist/Progress/ProgressLine.js +0 -87
  169. package/dist/Progress/style.scss +0 -33
  170. package/dist/Progress/types.d.ts +0 -4
  171. package/dist/Progress/types.js +0 -2
  172. package/dist/SpinLoading/index.d.ts +0 -3
  173. package/dist/SpinLoading/index.js +0 -2
  174. /package/dist/CalendarPicker/{calendar-picker.d.ts → CalendarPicker.d.ts} +0 -0
  175. /package/dist/CalendarPicker/{calendar-range-picker.d.ts → CalendarRangePicker.d.ts} +0 -0
@@ -15,30 +15,32 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  import React, { memo, useEffect, useRef, useState } from 'react';
16
16
  import Taro from '@tarojs/taro';
17
17
  import { CalendarGrid } from "../Calendar";
18
- import { useTaro } from "../hooks/useTaro";
18
+ import { useTaro } from "../hooks";
19
19
  import { RandomUtils } from "../utils/random-utils";
20
20
  import classNames from "classnames";
21
+ import dayjs from "dayjs";
22
+ var monthLines = 6;
23
+
21
24
  /**
22
25
  * 可以手势滑动的日历组件
23
26
  */
24
27
  export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
25
28
  var _wrapperRef$current3;
26
- var _ref$mouth = _ref.mouth,
27
- mouth = _ref$mouth === void 0 ? new Date() : _ref$mouth,
29
+ var month = _ref.month,
28
30
  value = _ref.value,
29
31
  defaultValue = _ref.defaultValue,
30
32
  onChange = _ref.onChange,
31
- onMouthChange = _ref.onMouthChange,
33
+ onMonthChange = _ref.onMonthChange,
32
34
  range = _ref.range;
33
35
  var _useTaro = useTaro(),
34
36
  isTaroEnv = _useTaro.isTaroEnv,
35
37
  isTaroWeApp = _useTaro.isTaroWeApp;
36
38
  var wrapperRef = useRef();
37
39
  var wrapperUniqueRef = React.useRef(RandomUtils.random());
38
- var _useState = useState(mouth),
40
+ var _useState = useState(dayjs(month)),
39
41
  _useState2 = _slicedToArray(_useState, 2),
40
- currentMouth = _useState2[0],
41
- setCurrentMouth = _useState2[1];
42
+ currentMonth = _useState2[0],
43
+ setCurrentMonth = _useState2[1];
42
44
  var waiting = false;
43
45
  var _useState3 = useState(200),
44
46
  _useState4 = _slicedToArray(_useState3, 2),
@@ -62,8 +64,8 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
62
64
  setTranslateY = _useState8[1];
63
65
  var _useState9 = useState([]),
64
66
  _useState10 = _slicedToArray(_useState9, 2),
65
- mouths = _useState10[0],
66
- setMouths = _useState10[1];
67
+ months = _useState10[0],
68
+ setMonths = _useState10[1];
67
69
 
68
70
  /**
69
71
  * 计算出每个格子的大小
@@ -139,16 +141,16 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
139
141
  * @param mouth
140
142
  */
141
143
  var mouthLines = function mouthLines(mouth) {
142
- var firstDate = new Date(mouth.getFullYear(), mouth.getMonth(), 1);
143
- var lastDate = new Date(mouth.getFullYear(), mouth.getMonth() + 1, 0);
144
- var beforeDays = firstDate.getDay();
145
- var afterDays = 6 - lastDate.getDay();
146
- var countDays = beforeDays + lastDate.getDate() + afterDays;
144
+ var firstDate = dayjs(new Date(mouth.year(), mouth.month(), 1));
145
+ var lastDate = dayjs(new Date(mouth.year(), mouth.month() + 1, 0));
146
+ var beforeDays = firstDate.day();
147
+ var afterDays = 6 - lastDate.day();
148
+ var countDays = beforeDays + lastDate.date() + afterDays;
147
149
  return Math.ceil(countDays / 7);
148
150
  };
149
151
  var handleInsertMouth = /*#__PURE__*/function () {
150
152
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
151
- var firstMouth, insertMouth, newMouths, insertMouthLines, insertMouthHeight;
153
+ var firstMouth, insertMouth, newMouths, insertMouthHeight;
152
154
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
153
155
  while (1) switch (_context3.prev = _context3.next) {
154
156
  case 0:
@@ -157,20 +159,20 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
157
159
  // }
158
160
  // debugger
159
161
  // waiting = true
160
- firstMouth = mouths[0];
161
- insertMouth = new Date(firstMouth.getFullYear(), firstMouth.getMonth() - 1, 1);
162
- newMouths = [insertMouth].concat(_toConsumableArray(mouths));
163
- setMouths(newMouths);
164
- insertMouthLines = mouthLines(insertMouth);
165
- _context3.t0 = insertMouthLines;
166
- _context3.next = 8;
162
+ firstMouth = months[0];
163
+ insertMouth = dayjs(new Date(firstMouth.year(), firstMouth.month() - 1, 1));
164
+ newMouths = [insertMouth].concat(_toConsumableArray(months));
165
+ setMonths(newMouths);
166
+ // const insertMouthLines = mouthLines(insertMouth);
167
+ _context3.t0 = monthLines;
168
+ _context3.next = 7;
167
169
  return cellSize();
168
- case 8:
170
+ case 7:
169
171
  _context3.t1 = _context3.sent;
170
172
  insertMouthHeight = _context3.t0 * _context3.t1;
171
173
  setTranslateY(translateY - insertMouthHeight);
172
174
  // waiting = false
173
- case 11:
175
+ case 10:
174
176
  case "end":
175
177
  return _context3.stop();
176
178
  }
@@ -185,29 +187,29 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
185
187
  // return
186
188
  // }
187
189
  // waiting = true
188
- var lastMouth = mouths[mouths.length - 1];
189
- var appendMouth = new Date(lastMouth.getFullYear(), lastMouth.getMonth() + 1, 1);
190
- var newMouths = [].concat(_toConsumableArray(mouths), [appendMouth]);
191
- setMouths(newMouths);
190
+ var lastMouth = months[months.length - 1];
191
+ var appendMouth = lastMouth.add(1, 'month');
192
+ var newMouths = [].concat(_toConsumableArray(months), [appendMouth]);
193
+ setMonths(newMouths);
192
194
  // waiting = false
193
195
  };
194
196
  useEffect(function () {
195
- var initMouths = [new Date(currentMouth.getFullYear(), currentMouth.getMonth() - 1, 1), new Date(currentMouth.getFullYear(), currentMouth.getMonth(), 1), new Date(currentMouth.getFullYear(), currentMouth.getMonth() + 1, 1)];
197
+ var initMonths = [currentMonth.clone().subtract(1, 'month'), currentMonth.clone(), currentMonth.clone().add(1, 'month')];
196
198
  Promise.all([]).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
197
199
  var firstMouthHeight;
198
200
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
199
201
  while (1) switch (_context4.prev = _context4.next) {
200
202
  case 0:
201
- setMouths(initMouths);
203
+ setMonths(initMonths);
202
204
  _context4.t0 = setMouthHeight;
203
- _context4.t1 = mouthLines(currentMouth);
205
+ _context4.t1 = monthLines;
204
206
  _context4.next = 5;
205
207
  return cellSize();
206
208
  case 5:
207
209
  _context4.t2 = _context4.sent;
208
210
  _context4.t3 = _context4.t1 * _context4.t2;
209
211
  (0, _context4.t0)(_context4.t3);
210
- _context4.t4 = mouthLines(initMouths[0]);
212
+ _context4.t4 = monthLines;
211
213
  _context4.next = 11;
212
214
  return cellSize();
213
215
  case 11:
@@ -220,15 +222,15 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
220
222
  }
221
223
  }, _callee4);
222
224
  })));
223
- }, [currentMouth]);
225
+ }, [currentMonth]);
224
226
  useEffect(function () {
225
- if (mouth !== undefined) {
226
- var newMouth = new Date(mouth.getFullYear(), mouth.getMonth(), 1);
227
- if (currentMouth === null || !(currentMouth.getFullYear() === newMouth.getFullYear() && currentMouth.getMonth() === newMouth.getMonth())) {
228
- setCurrentMouth(newMouth);
227
+ if (month !== undefined) {
228
+ var newMouth = dayjs(new Date(month.year(), month.month(), 1));
229
+ if (currentMonth === null || !(currentMonth !== null && currentMonth !== void 0 && currentMonth.isSame(newMouth, 'month'))) {
230
+ setCurrentMonth(newMouth);
229
231
  }
230
232
  }
231
- }, [mouth]);
233
+ }, [month]);
232
234
  useEffect(function () {
233
235
  if (value !== undefined) {}
234
236
  }, [value]);
@@ -265,7 +267,7 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
265
267
  event.preventDefault();
266
268
  event.stopPropagation();
267
269
  if (!touching) {
268
- _context5.next = 33;
270
+ _context5.next = 30;
269
271
  break;
270
272
  }
271
273
  movePoint = {
@@ -291,38 +293,36 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
291
293
  }
292
294
  return _context5.abrupt("return");
293
295
  case 14:
294
- console.log('move', movePoint.clientY - touchPoint.clientY);
296
+ // console.log('move', movePoint.clientY - touchPoint.clientY);
295
297
  newTranslateY = translateY + (movePoint.clientY - touchPoint.clientY);
296
298
  setTranslateY(newTranslateY);
297
299
  setTouchPoint(movePoint);
298
300
  // console.log(newTranslateY,minTranslateY())
299
301
  if (!(newTranslateY > -10)) {
300
- _context5.next = 24;
302
+ _context5.next = 22;
301
303
  break;
302
304
  }
303
- //当向下滑动,顶部距离视窗顶部距离小于10,则插入上一个月份
304
- console.log('insert');
305
- _context5.next = 22;
305
+ _context5.next = 20;
306
306
  return handleInsertMouth();
307
- case 22:
308
- _context5.next = 33;
307
+ case 20:
308
+ _context5.next = 30;
309
309
  break;
310
- case 24:
310
+ case 22:
311
311
  _context5.t4 = newTranslateY;
312
- _context5.next = 27;
312
+ _context5.next = 25;
313
313
  return minTranslateY();
314
- case 27:
314
+ case 25:
315
315
  _context5.t5 = _context5.sent;
316
316
  _context5.t6 = 0 - _context5.t5;
317
317
  _context5.t7 = _context5.t6 + 10;
318
318
  if (!(_context5.t4 < _context5.t7)) {
319
- _context5.next = 33;
319
+ _context5.next = 30;
320
320
  break;
321
321
  }
322
322
  //当向下滑动,底部距离视窗底部距离小于10,则追加下一个月份
323
- console.log('append');
323
+ // console.log('append');
324
324
  handleAppendMouth();
325
- case 33:
325
+ case 30:
326
326
  case "end":
327
327
  return _context5.stop();
328
328
  }
@@ -345,72 +345,73 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
345
345
  }
346
346
  return _context6.abrupt("return");
347
347
  case 3:
348
- console.log(mouths);
348
+ console.log(months);
349
349
  //region 判断当前月份是否在视窗内
350
350
  _mouthHeightSum = 0;
351
351
  i = 0;
352
352
  case 6:
353
- if (!(i < mouths.length)) {
354
- _context6.next = 40;
353
+ if (!(i < months.length)) {
354
+ _context6.next = 28;
355
355
  break;
356
356
  }
357
- console.log('mouthHeight', mouthHeight);
358
- console.log('mouths[i]', mouths[i], i);
359
- _context6.t0 = mouthLines(mouths[i]);
360
- _context6.next = 12;
357
+ _context6.t0 = monthLines;
358
+ _context6.next = 10;
361
359
  return cellSize();
362
- case 12:
360
+ case 10:
363
361
  _context6.t1 = _context6.sent;
364
362
  _mouthHeight = _context6.t0 * _context6.t1;
365
363
  _mouthHeightSum += _mouthHeight;
366
- console.log('_mouthHeightSum', _mouthHeightSum);
367
- console.log('translateY', translateY);
364
+ // console.log('_mouthHeightSum', _mouthHeightSum);
365
+ // console.log('translateY', translateY);
368
366
  _topLineY = 0 - (_mouthHeightSum - _mouthHeight); //该月份区域顶部,对于顶点的偏移量
369
- console.log('_topLineY', _topLineY);
367
+ // console.log('_topLineY', _topLineY);
370
368
  if (!(_topLineY <= translateY && _topLineY >= translateY - mouthHeight)) {
371
- _context6.next = 27;
369
+ _context6.next = 19;
372
370
  break;
373
371
  }
374
372
  //该月份区域的顶部在视窗内
375
- console.log('top_in');
373
+ // console.log('top_in');
376
374
  _windowDisplayHeight = _mouthHeightSum - (0 - translateY); //该月份区域底部距离视窗顶部的距离
377
- console.log('_windowDisplayHeight——top', _windowDisplayHeight);
375
+ // console.log('_windowDisplayHeight——top', _windowDisplayHeight);
378
376
  if (!(_windowDisplayHeight >= mouthHeight / 2)) {
379
- _context6.next = 27;
377
+ _context6.next = 19;
380
378
  break;
381
379
  }
382
- console.log('displayMouth', mouths[i]);
383
- displayMouth = mouths[i];
384
- return _context6.abrupt("break", 40);
385
- case 27:
380
+ // console.log('displayMouth', mouths[i]);
381
+ displayMouth = months[i];
382
+ return _context6.abrupt("break", 28);
383
+ case 19:
386
384
  _bottomLineY = 0 - _mouthHeightSum; //该月份区域底部,对于顶点的偏移量
387
- console.log('_bottomLineY', _bottomLineY);
385
+ // console.log('_bottomLineY', _bottomLineY);
388
386
  if (!(_bottomLineY <= translateY && _bottomLineY >= translateY - mouthHeight)) {
389
- _context6.next = 37;
387
+ _context6.next = 25;
390
388
  break;
391
389
  }
392
390
  //该月份区域的底部在视窗内
393
- console.log('bottom_in');
391
+ // console.log('bottom_in');
394
392
  _windowDisplayHeight2 = _mouthHeightSum - (0 - translateY); //该月份区域底部距离视窗顶部的距离
395
- console.log('_windowDisplayHeight-bottom', _windowDisplayHeight2);
393
+ // console.log(
394
+ // '_windowDisplayHeight-bottom',
395
+ // _windowDisplayHeight,
396
+ // );
396
397
  if (!(_windowDisplayHeight2 >= mouthHeight / 2)) {
397
- _context6.next = 37;
398
+ _context6.next = 25;
398
399
  break;
399
400
  }
400
- console.log('displayMouth', mouths[i]);
401
- displayMouth = mouths[i];
402
- return _context6.abrupt("break", 40);
403
- case 37:
401
+ // console.log('displayMouth', mouths[i]);
402
+ displayMouth = months[i];
403
+ return _context6.abrupt("break", 28);
404
+ case 25:
404
405
  i++;
405
406
  _context6.next = 6;
406
407
  break;
407
- case 40:
408
+ case 28:
408
409
  //endregion
409
410
  if (displayMouth) {
410
- setCurrentMouth(displayMouth);
411
- onMouthChange === null || onMouthChange === void 0 || onMouthChange(displayMouth);
411
+ setCurrentMonth(displayMouth);
412
+ onMonthChange === null || onMonthChange === void 0 || onMonthChange(displayMouth);
412
413
  }
413
- case 41:
414
+ case 29:
414
415
  case "end":
415
416
  return _context6.stop();
416
417
  }
@@ -420,10 +421,10 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
420
421
  return _ref7.apply(this, arguments);
421
422
  };
422
423
  }())
423
- }, mouths.map(function (mouth, index) {
424
+ }, months.map(function (mouth, index) {
424
425
  return /*#__PURE__*/React.createElement(CalendarGrid, {
425
426
  key: index,
426
- mouth: mouth,
427
+ month: mouth,
427
428
  value: value,
428
429
  defaultValue: defaultValue,
429
430
  onChange: onChange,
@@ -1,10 +1,11 @@
1
1
  import { FC } from 'react';
2
2
  import './style.scss';
3
+ import dayjs from "dayjs";
3
4
  export type CalendarDatetimePickerProps = {
4
5
  open?: boolean;
5
6
  afterOpenChange?: (open: boolean) => void;
6
- value?: Date;
7
- onOk?: (value?: Date) => void;
7
+ value?: dayjs.Dayjs | Date;
8
+ onOk?: (value?: dayjs.Dayjs) => void;
8
9
  onClose?: () => void;
9
10
  };
10
11
  export declare const CalendarDatetimePicker: FC<CalendarDatetimePickerProps>;
@@ -8,41 +8,34 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
- import { CustomWrapper } from '@tarojs/components';
11
+ import { CustomWrapper, PickerView, PickerViewColumn, View } from '@tarojs/components';
12
12
  import Taro from '@tarojs/taro';
13
13
  import classNames from 'classnames';
14
14
  import React, { useEffect, useRef, useState } from 'react';
15
15
  import Calendar from "../Calendar";
16
16
  import ConfigProvider from "../ConfigProvider";
17
- import { useTaro } from "../hooks/useTaro";
18
- import PickerView from "../PickerView";
17
+ import { useTaro } from "../hooks";
19
18
  import Popup from "../Popup";
20
- import { DatetimeUtils } from "../utils/datetime-utils";
21
19
  import { DateTimeSwitch } from "./DateTimeSwitch";
22
20
  import "./style.scss";
23
21
  import { cls, Mode } from "./types";
22
+ import { DatetimeUtils } from "../utils/datetime-utils";
23
+ import dayjs from "dayjs";
24
24
  export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
25
- var _bodyRef$current;
26
25
  var open = _ref.open,
27
- afterOpenChange = _ref.afterOpenChange,
28
- _ref$value = _ref.value,
29
- value = _ref$value === void 0 ? new Date() : _ref$value,
26
+ _afterOpenChange = _ref.afterOpenChange,
27
+ value = _ref.value,
30
28
  onOk = _ref.onOk,
31
29
  _onClose = _ref.onClose;
32
30
  var _ConfigProvider$useCo = ConfigProvider.useConfig(),
33
31
  locale = _ConfigProvider$useCo.locale;
34
32
  var _useTaro = useTaro(),
35
- isTaroEnv = _useTaro.isTaroEnv,
36
33
  isTaroWeApp = _useTaro.isTaroWeApp;
37
- var _React$useState = React.useState(open || false),
38
- _React$useState2 = _slicedToArray(_React$useState, 2),
39
- innerOpen = _React$useState2[0],
40
- setInnerOpen = _React$useState2[1];
41
34
  var _useState = useState(Mode.date),
42
35
  _useState2 = _slicedToArray(_useState, 2),
43
36
  mode = _useState2[0],
44
37
  setMode = _useState2[1];
45
- var valueRef = useRef(value || new Date());
38
+ var valueRef = useRef(dayjs(value));
46
39
  var bodyRef = useRef(null);
47
40
  var datetimeSwitchRef = useRef();
48
41
  var _useState3 = useState(300),
@@ -50,7 +43,6 @@ export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
50
43
  bodyHeight = _useState4[0],
51
44
  setBodyHeight = _useState4[1];
52
45
  var handleClose = function handleClose() {
53
- setInnerOpen(false);
54
46
  _onClose === null || _onClose === void 0 || _onClose();
55
47
  };
56
48
  var handleOk = function handleOk() {
@@ -62,7 +54,7 @@ export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
62
54
  return _regeneratorRuntime().wrap(function _callee$(_context) {
63
55
  while (1) switch (_context.prev = _context.next) {
64
56
  case 0:
65
- if (!(isTaroEnv && isTaroWeApp)) {
57
+ if (!isTaroWeApp) {
66
58
  _context.next = 2;
67
59
  break;
68
60
  }
@@ -87,21 +79,6 @@ export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
87
79
  return _ref2.apply(this, arguments);
88
80
  };
89
81
  }();
90
- useEffect(function () {
91
- afterOpenChange === null || afterOpenChange === void 0 || afterOpenChange(innerOpen);
92
- if (!innerOpen) {
93
- _onClose === null || _onClose === void 0 || _onClose();
94
- }
95
- }, [innerOpen]);
96
- useEffect(function () {
97
- if (open === undefined) {
98
- return;
99
- }
100
- if (open === innerOpen) {
101
- return;
102
- }
103
- setInnerOpen(open);
104
- }, [open]);
105
82
  useEffect(function () {
106
83
  if (datetimeSwitchRef.current) {
107
84
  datetimeSwitchRef.current.setDatetime(valueRef.current);
@@ -111,11 +88,11 @@ export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
111
88
  return /*#__PURE__*/React.createElement(React.Fragment, null, mode === Mode.date && /*#__PURE__*/React.createElement("div", {
112
89
  style: {}
113
90
  }, /*#__PURE__*/React.createElement(Calendar, {
114
- mouth: value,
91
+ month: value,
115
92
  value: value,
116
93
  onChange: function onChange(date) {
117
94
  var _datetimeSwitchRef$cu;
118
- valueRef.current = new Date(date.getFullYear(), date.getMonth(), date.getDate(), valueRef.current.getHours(), valueRef.current.getMinutes());
95
+ valueRef.current = dayjs(new Date(date.year(), date.month(), date.date(), valueRef.current.hour(), valueRef.current.minute()));
119
96
  (_datetimeSwitchRef$cu = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu === void 0 || _datetimeSwitchRef$cu.setDatetime(valueRef.current);
120
97
  }
121
98
  })), mode === Mode.time && /*#__PURE__*/React.createElement("div", {
@@ -123,30 +100,40 @@ export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
123
100
  height: bodyHeight
124
101
  }
125
102
  }, /*#__PURE__*/React.createElement(PickerView, {
126
- columns: [Array(24).fill(0).map(function (_, i) {
127
- return {
128
- label: "".concat(DatetimeUtils.twoDigits(i)),
129
- value: "".concat(i)
130
- };
131
- }), Array(60).fill(0).map(function (_, i) {
132
- return {
133
- label: "".concat(DatetimeUtils.twoDigits(i)),
134
- value: "".concat(i)
135
- };
136
- })],
137
- labelInValue: false,
138
- value: ["".concat(valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.getHours()), "".concat(valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.getMinutes())],
139
- onChange: function onChange(v) {
103
+ className: "time-picker",
104
+ indicatorStyle: "height: 32Px;",
105
+ style: {
106
+ height: bodyHeight
107
+ },
108
+ value: [valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.hour(), valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.minute()],
109
+ onChange: function onChange(e) {
140
110
  var _datetimeSwitchRef$cu2;
141
- valueRef.current = new Date(valueRef.current.getFullYear(), valueRef.current.getMonth(), valueRef.current.getDate(), v[0], v[1]);
111
+ var v = e.detail.value;
112
+ valueRef.current = dayjs(new Date(valueRef.current.year(), valueRef.current.month(), valueRef.current.date(), v[0], v[1]));
142
113
  (_datetimeSwitchRef$cu2 = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu2 === void 0 || _datetimeSwitchRef$cu2.setDatetime(valueRef.current);
143
114
  }
144
- })));
115
+ }, /*#__PURE__*/React.createElement(PickerViewColumn, null, Array(24).fill(0).map(function (_, i) {
116
+ return /*#__PURE__*/React.createElement(View, {
117
+ key: "hour-".concat(i),
118
+ className: "time-item"
119
+ }, DatetimeUtils.twoDigits(i));
120
+ })), /*#__PURE__*/React.createElement(PickerViewColumn, null, Array(60).fill(0).map(function (_, i) {
121
+ return /*#__PURE__*/React.createElement(View, {
122
+ key: "minute-".concat(i),
123
+ className: "time-item"
124
+ }, DatetimeUtils.twoDigits(i));
125
+ })))));
145
126
  };
146
127
  return /*#__PURE__*/React.createElement(Popup, {
147
- open: innerOpen,
128
+ open: open,
129
+ round: true,
130
+ afterOpenChange: function afterOpenChange(o) {
131
+ if (!o) {
132
+ setMode(Mode.date);
133
+ }
134
+ _afterOpenChange === null || _afterOpenChange === void 0 || _afterOpenChange(o);
135
+ },
148
136
  onClose: function onClose() {
149
- setInnerOpen(false);
150
137
  _onClose === null || _onClose === void 0 || _onClose();
151
138
  }
152
139
  }, /*#__PURE__*/React.createElement("div", {
@@ -169,13 +156,9 @@ export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
169
156
  }), /*#__PURE__*/React.createElement("a", {
170
157
  className: classNames("".concat(cls, "-header-button"), "".concat(cls, "-header-button-ok")),
171
158
  onClick: handleOk
172
- }, locale.common.confirm)), isTaroEnv ? /*#__PURE__*/React.createElement(CustomWrapper, {
159
+ }, locale.common.confirm)), /*#__PURE__*/React.createElement(CustomWrapper, {
173
160
  ref: bodyRef
174
161
  }, /*#__PURE__*/React.createElement("div", {
175
162
  className: "".concat(cls, "-body")
176
- }, bodyRender())) : /*#__PURE__*/React.createElement("div", {
177
- className: "".concat(cls, "-body"),
178
- ref: bodyRef,
179
- id: (_bodyRef$current = bodyRef.current) === null || _bodyRef$current === void 0 ? void 0 : _bodyRef$current.uid
180
- }, bodyRender())));
163
+ }, bodyRender()))));
181
164
  };
@@ -1,14 +1,15 @@
1
1
  import React from 'react';
2
2
  import './style.scss';
3
3
  import { Mode } from './types';
4
+ import dayjs from "dayjs";
4
5
  export interface DateTimeSwitchHandle {
5
- setDatetime: (datetime: Date) => void;
6
+ setDatetime: (datetime: dayjs.Dayjs) => void;
6
7
  }
7
8
  type DateTimeSwitchProps = {
8
9
  onDateTabTap?: () => void;
9
10
  onTimeTabTap?: () => void;
10
11
  mode?: Mode;
11
- value?: Date;
12
+ value?: dayjs.Dayjs;
12
13
  };
13
14
  export declare const DateTimeSwitch: React.ForwardRefExoticComponent<DateTimeSwitchProps & React.RefAttributes<DateTimeSwitchHandle>>;
14
15
  export {};
@@ -32,8 +32,8 @@ export var DateTimeSwitch = /*#__PURE__*/forwardRef(function (_ref, ref) {
32
32
  }, /*#__PURE__*/React.createElement("div", {
33
33
  className: classNames("".concat(cls, "-header-display-date"), _defineProperty({}, "".concat(cls, "-header-display-active"), mode === Mode.date)),
34
34
  onClick: onDateTabTap
35
- }, datetime ? "".concat(datetime.getFullYear(), "-").concat(DatetimeUtils.twoDigits(datetime.getMonth() + 1), "-").concat(DatetimeUtils.twoDigits(datetime.getDate())) : ''), /*#__PURE__*/React.createElement("div", {
35
+ }, datetime ? "".concat(datetime.year(), "-").concat(DatetimeUtils.twoDigits(datetime.month() + 1), "-").concat(DatetimeUtils.twoDigits(datetime.date())) : ''), /*#__PURE__*/React.createElement("div", {
36
36
  className: classNames("".concat(cls, "-header-display-time"), _defineProperty({}, "".concat(cls, "-header-display-active"), mode === Mode.time)),
37
37
  onClick: onTimeTabTap
38
- }, datetime ? "".concat(DatetimeUtils.twoDigits(datetime.getHours()), ":").concat(DatetimeUtils.twoDigits(datetime.getMinutes())) : ''));
38
+ }, datetime ? "".concat(DatetimeUtils.twoDigits(datetime.hour()), ":").concat(DatetimeUtils.twoDigits(datetime.minute())) : ''));
39
39
  });
@@ -40,15 +40,23 @@ $calendarDatetimePickerCls: 'triones-antm-calendar-datetime-picker';
40
40
  &-button {
41
41
  padding: 12Px 16Px;
42
42
 
43
- &-cancel {
44
- }
43
+ &-cancel {}
45
44
 
46
45
  &-ok {
47
46
  color: variable.$trionesColorPrimary;
48
47
  }
49
48
  }
50
49
  }
51
- &-body {
52
50
 
51
+ &-body {
52
+ .time-picker {
53
+ .time-item {
54
+ flex-shrink: 0;
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: center;
58
+ height: 32Px;
59
+ }
60
+ }
53
61
  }
54
62
  }
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import dayjs from "dayjs";
3
+ import { FormCellProps } from "../FormCell";
4
+ export type CalendarDatetimePickerCellProps = Omit<FormCellProps, 'value'> & {
5
+ value?: dayjs.Dayjs | Date;
6
+ format?: string;
7
+ onChange?: (value?: dayjs.Dayjs) => void;
8
+ };
9
+ export declare const CalendarDatetimePickerCell: FC<CalendarDatetimePickerCellProps>;