@trionesdev/antd-taro-react 0.0.2-beta.1 → 0.0.2-beta.11

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 (303) 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 -2
  4. package/dist/ActionSheet/index.js +1 -1
  5. package/dist/ActionSheet/style.scss +52 -0
  6. package/dist/Alert/index.d.ts +0 -1
  7. package/dist/Avatar/index.d.ts +0 -1
  8. package/dist/Badge/index.d.ts +0 -1
  9. package/dist/Button/button.d.ts +2 -2
  10. package/dist/Button/index.d.ts +0 -1
  11. package/dist/Button/style.scss +235 -231
  12. package/dist/Calendar/calendar-grid.d.ts +10 -10
  13. package/dist/Calendar/calendar-grid.js +37 -62
  14. package/dist/Calendar/calendar-header.d.ts +3 -3
  15. package/dist/Calendar/calendar-header.js +9 -6
  16. package/dist/Calendar/calendar-range.d.ts +4 -4
  17. package/dist/Calendar/calendar-range.js +22 -18
  18. package/dist/Calendar/calendar.d.ts +5 -5
  19. package/dist/Calendar/calendar.js +33 -17
  20. package/dist/Calendar/index.d.ts +0 -1
  21. package/dist/Calendar/style.scss +88 -85
  22. package/dist/Calendar/touchable-calendar-grid.d.ts +6 -6
  23. package/dist/Calendar/touchable-calendar-grid.js +82 -81
  24. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.d.ts +6 -6
  25. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.js +43 -156
  26. package/dist/CalendarDatetimePicker/index.d.ts +0 -1
  27. package/dist/CalendarDatetimePicker/style.scss +24 -54
  28. package/dist/CalendarDatetimePicker/types.d.ts +0 -5
  29. package/dist/CalendarDatetimePicker/types.js +1 -6
  30. package/dist/CalendarDatetimePopup/CalendarDatetimePopup.d.ts +11 -0
  31. package/dist/CalendarDatetimePopup/CalendarDatetimePopup.js +164 -0
  32. package/dist/{CalendarDatetimePicker → CalendarDatetimePopup}/DateTimeSwitch.d.ts +3 -3
  33. package/dist/{CalendarDatetimePicker → CalendarDatetimePopup}/DateTimeSwitch.js +2 -2
  34. package/dist/CalendarDatetimePopup/index.d.ts +3 -0
  35. package/dist/CalendarDatetimePopup/index.js +2 -0
  36. package/dist/CalendarDatetimePopup/style.scss +62 -0
  37. package/dist/CalendarDatetimePopup/types.d.ts +5 -0
  38. package/dist/CalendarDatetimePopup/types.js +6 -0
  39. package/dist/CalendarPopup/CalendarPopup.d.ts +4 -0
  40. package/dist/{CalendarPicker/calendar-picker.js → CalendarPopup/CalendarPopup.js} +9 -6
  41. package/dist/CalendarPopup/CalendarRangePopup.d.ts +4 -0
  42. package/dist/{CalendarPicker/calendar-range-picker.js → CalendarPopup/CalendarRangePopup.js} +7 -6
  43. package/dist/CalendarPopup/index.d.ts +8 -0
  44. package/dist/CalendarPopup/index.js +5 -0
  45. package/dist/CalendarPopup/style.scss +32 -0
  46. package/dist/CalendarPopup/types.d.ts +23 -0
  47. package/dist/CalendarPopup/types.js +1 -0
  48. package/dist/Card/index.d.ts +0 -1
  49. package/dist/CascaderPicker/CascaderPicker.d.ts +25 -0
  50. package/dist/CascaderPicker/CascaderPicker.js +78 -0
  51. package/dist/CascaderPicker/index.d.ts +1 -2
  52. package/dist/CascaderPicker/index.js +1 -1
  53. package/dist/CascaderPicker/style.scss +24 -0
  54. package/dist/CascaderPopup/cascader-popup.d.ts +27 -0
  55. package/dist/CascaderPopup/cascader-popup.js +90 -0
  56. package/dist/CascaderPopup/index.d.ts +3 -0
  57. package/dist/CascaderPopup/index.js +2 -0
  58. package/dist/CascaderPopup/style.scss +45 -0
  59. package/dist/CascaderView/index.d.ts +0 -1
  60. package/dist/Cell/index.d.ts +0 -1
  61. package/dist/Checkbox/index.d.ts +0 -1
  62. package/dist/ConfigProvider/index.d.ts +0 -1
  63. package/dist/DatePicker/DatePicker.d.ts +15 -0
  64. package/dist/DatePicker/DatePicker.js +85 -0
  65. package/dist/DatePicker/DatePickerPopup.d.ts +18 -0
  66. package/dist/DatePicker/DatePickerPopup.js +329 -0
  67. package/dist/DatePicker/index.d.ts +3 -0
  68. package/dist/DatePicker/index.js +3 -0
  69. package/dist/DatePicker/style.scss +64 -0
  70. package/dist/DatePicker/types.d.ts +1 -0
  71. package/dist/Descriptions/index.d.ts +0 -1
  72. package/dist/Divider/index.d.ts +0 -1
  73. package/dist/Ellipsis/index.d.ts +0 -1
  74. package/dist/Empty/index.d.ts +0 -1
  75. package/dist/ErrorBlock/index.d.ts +0 -1
  76. package/dist/Footer/index.d.ts +0 -1
  77. package/dist/Form/FormItem/form-item-input.d.ts +15 -0
  78. package/dist/Form/FormItem/form-item-input.js +39 -0
  79. package/dist/Form/FormItem/form-item-label.d.ts +13 -0
  80. package/dist/Form/FormItem/form-item-label.js +35 -0
  81. package/dist/Form/FormItem/form-item.d.ts +22 -0
  82. package/dist/Form/FormItem/form-item.js +73 -0
  83. package/dist/Form/FormItem/index.d.ts +5 -0
  84. package/dist/Form/FormItem/index.js +3 -0
  85. package/dist/Form/index.d.ts +8 -2
  86. package/dist/Form/index.js +5 -1
  87. package/dist/Form/style.scss +78 -0
  88. package/dist/Grid/index.d.ts +0 -1
  89. package/dist/Icon/check-icon.d.ts +0 -1
  90. package/dist/Image/image.d.ts +0 -1
  91. package/dist/Image/index.d.ts +0 -1
  92. package/dist/ImagesPreview/ImagesPreview.d.ts +0 -1
  93. package/dist/ImagesPreview/ImagesPreview.js +4 -3
  94. package/dist/ImagesPreview/index.d.ts +0 -1
  95. package/dist/ImagesPreview/style.scss +34 -34
  96. package/dist/ImagesWall/ImagesWall.d.ts +0 -1
  97. package/dist/ImagesWall/ImagesWall.js +1 -1
  98. package/dist/ImagesWall/index.d.ts +0 -1
  99. package/dist/ImagesWall/style.scss +70 -70
  100. package/dist/Input/index.d.ts +17 -3
  101. package/dist/Input/index.js +13 -1
  102. package/dist/Input/index.scss +267 -0
  103. package/dist/Input/input-affix-wrapper.d.ts +13 -0
  104. package/dist/Input/input-affix-wrapper.js +37 -0
  105. package/dist/Input/input-digit.d.ts +7 -0
  106. package/dist/Input/input-digit.js +53 -0
  107. package/dist/Input/input-number.d.ts +7 -0
  108. package/dist/Input/input-number.js +50 -0
  109. package/dist/Input/input-opt.d.ts +16 -0
  110. package/dist/Input/input-opt.js +87 -0
  111. package/dist/Input/input-password.d.ts +8 -0
  112. package/dist/Input/input-password.js +49 -0
  113. package/dist/Input/input.d.ts +3 -0
  114. package/dist/Input/input.js +7 -0
  115. package/dist/Input/taro-input.d.ts +8 -0
  116. package/dist/Input/taro-input.js +54 -0
  117. package/dist/Input/textarea.d.ts +15 -0
  118. package/dist/Input/textarea.js +52 -0
  119. package/dist/Input/types.d.ts +19 -0
  120. package/dist/Input/types.js +2 -0
  121. package/dist/InputNumber/index.d.ts +0 -1
  122. package/dist/NavBar/index.d.ts +0 -1
  123. package/dist/NoticeBar/index.d.ts +0 -1
  124. package/dist/Overlay/Overlay.d.ts +17 -0
  125. package/dist/Overlay/Overlay.js +100 -0
  126. package/dist/Overlay/index.d.ts +4 -0
  127. package/dist/Overlay/index.js +3 -0
  128. package/dist/Overlay/style.scss +20 -0
  129. package/dist/PageIndicator/index.d.ts +0 -1
  130. package/dist/Picker/Picker.d.ts +19 -0
  131. package/dist/Picker/Picker.js +75 -0
  132. package/dist/Picker/index.d.ts +1 -2
  133. package/dist/Picker/index.js +1 -1
  134. package/dist/Picker/style.scss +41 -0
  135. package/dist/PickerView/PickerView.d.ts +4 -0
  136. package/dist/PickerView/PickerView.js +71 -0
  137. package/dist/PickerView/index.d.ts +2 -3
  138. package/dist/PickerView/index.js +1 -1
  139. package/dist/PickerView/style.scss +13 -0
  140. package/dist/PickerView/types.d.ts +15 -0
  141. package/dist/PickerView/types.js +1 -0
  142. package/dist/Popup/Popup.d.ts +48 -0
  143. package/dist/Popup/Popup.js +135 -0
  144. package/dist/Popup/index.d.ts +2 -2
  145. package/dist/Popup/index.js +2 -1
  146. package/dist/Popup/style.scss +124 -0
  147. package/dist/Progress/index.d.ts +1 -2
  148. package/dist/Progress/index.js +1 -1
  149. package/dist/Radio/index.d.ts +0 -1
  150. package/dist/Rate/index.d.ts +0 -1
  151. package/dist/Result/index.d.ts +0 -1
  152. package/dist/SafeArea/index.d.ts +0 -1
  153. package/dist/Scaffold/index.d.ts +0 -1
  154. package/dist/ScrollView/index.d.ts +0 -1
  155. package/dist/SideBar/SideBarContext.d.ts +0 -1
  156. package/dist/SideBar/index.d.ts +0 -1
  157. package/dist/SideBar/side-bar.d.ts +0 -1
  158. package/dist/SideBar/side-bar.js +9 -8
  159. package/dist/SideBar/style.scss +85 -85
  160. package/dist/SideBar/types.d.ts +0 -1
  161. package/dist/Space/index.d.ts +0 -1
  162. package/dist/SpinLoading/index.d.ts +0 -1
  163. package/dist/Steps/index.d.ts +0 -1
  164. package/dist/Swiper/index.d.ts +0 -1
  165. package/dist/Swiper/swiper.d.ts +0 -1
  166. package/dist/Switch/index.d.ts +0 -1
  167. package/dist/TabBar/index.d.ts +0 -1
  168. package/dist/Tabs/index.d.ts +0 -1
  169. package/dist/Tag/index.d.ts +0 -1
  170. package/dist/Toast/Toast.d.ts +18 -0
  171. package/dist/Toast/Toast.js +112 -0
  172. package/dist/Toast/index.d.ts +1 -2
  173. package/dist/Toast/index.js +1 -1
  174. package/dist/Toast/style.scss +63 -0
  175. package/dist/VerificationCodeInput/index.d.ts +2 -3
  176. package/dist/VerificationCodeInput/index.js +1 -1
  177. package/dist/VerificationCodeInput/style.scss +20 -0
  178. package/dist/VerificationCodeInput/verification-code-input.d.ts +24 -0
  179. package/dist/VerificationCodeInput/verification-code-input.js +99 -0
  180. package/dist/WaterMark/index.d.ts +0 -1
  181. package/dist/hooks/index.d.ts +0 -1
  182. package/dist/hooks/useTaro.d.ts +0 -1
  183. package/dist/index.d.ts +10 -6
  184. package/dist/index.js +5 -2
  185. package/dist/locales/base.d.ts +0 -1
  186. package/dist/locales/en-US.d.ts +0 -1
  187. package/dist/locales/zh-CN.d.ts +0 -1
  188. package/dist/style/variable.scss +20 -1
  189. package/dist/types.d.ts +0 -2
  190. package/dist/utils/datetime-utils.d.ts +0 -1
  191. package/dist/utils/dayjs.d.ts +3 -0
  192. package/dist/utils/dayjs.js +29 -0
  193. package/dist/utils/merge-locale.d.ts +0 -1
  194. package/dist/utils/native-props.d.ts +0 -1
  195. package/dist/utils/random-utils.d.ts +0 -1
  196. package/package.json +25 -26
  197. package/readme.md +23 -23
  198. package/dist/ActionSheet/index.d.ts.map +0 -1
  199. package/dist/Alert/index.d.ts.map +0 -1
  200. package/dist/Avatar/index.d.ts.map +0 -1
  201. package/dist/Badge/index.d.ts.map +0 -1
  202. package/dist/Button/button.d.ts.map +0 -1
  203. package/dist/Button/index.d.ts.map +0 -1
  204. package/dist/Calendar/calendar-grid.d.ts.map +0 -1
  205. package/dist/Calendar/calendar-header.d.ts.map +0 -1
  206. package/dist/Calendar/calendar-range.d.ts.map +0 -1
  207. package/dist/Calendar/calendar.d.ts.map +0 -1
  208. package/dist/Calendar/index.d.ts.map +0 -1
  209. package/dist/Calendar/touchable-calendar-grid.d.ts.map +0 -1
  210. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.d.ts.map +0 -1
  211. package/dist/CalendarDatetimePicker/DateTimeSwitch.d.ts.map +0 -1
  212. package/dist/CalendarDatetimePicker/index.d.ts.map +0 -1
  213. package/dist/CalendarDatetimePicker/types.d.ts.map +0 -1
  214. package/dist/CalendarPicker/calendar-picker.d.ts +0 -5
  215. package/dist/CalendarPicker/calendar-picker.d.ts.map +0 -1
  216. package/dist/CalendarPicker/calendar-range-picker.d.ts +0 -5
  217. package/dist/CalendarPicker/calendar-range-picker.d.ts.map +0 -1
  218. package/dist/CalendarPicker/index.d.ts +0 -10
  219. package/dist/CalendarPicker/index.d.ts.map +0 -1
  220. package/dist/CalendarPicker/index.js +0 -5
  221. package/dist/CalendarPicker/style.scss +0 -31
  222. package/dist/CalendarPicker/types.d.ts +0 -22
  223. package/dist/CalendarPicker/types.d.ts.map +0 -1
  224. package/dist/Card/index.d.ts.map +0 -1
  225. package/dist/CascaderPicker/index.d.ts.map +0 -1
  226. package/dist/CascaderView/index.d.ts.map +0 -1
  227. package/dist/Cell/index.d.ts.map +0 -1
  228. package/dist/Checkbox/index.d.ts.map +0 -1
  229. package/dist/ConfigProvider/index.d.ts.map +0 -1
  230. package/dist/Descriptions/index.d.ts.map +0 -1
  231. package/dist/Divider/index.d.ts.map +0 -1
  232. package/dist/Ellipsis/index.d.ts.map +0 -1
  233. package/dist/Empty/index.d.ts.map +0 -1
  234. package/dist/ErrorBlock/index.d.ts.map +0 -1
  235. package/dist/Footer/index.d.ts.map +0 -1
  236. package/dist/Form/index.d.ts.map +0 -1
  237. package/dist/Grid/index.d.ts.map +0 -1
  238. package/dist/Icon/check-icon.d.ts.map +0 -1
  239. package/dist/Image/image.d.ts.map +0 -1
  240. package/dist/Image/index.d.ts.map +0 -1
  241. package/dist/ImagesPreview/ImagesPreview.d.ts.map +0 -1
  242. package/dist/ImagesPreview/index.d.ts.map +0 -1
  243. package/dist/ImagesWall/ImagesWall.d.ts.map +0 -1
  244. package/dist/ImagesWall/index.d.ts.map +0 -1
  245. package/dist/Input/index.d.ts.map +0 -1
  246. package/dist/InputNumber/index.d.ts.map +0 -1
  247. package/dist/Mask/index.d.ts +0 -4
  248. package/dist/Mask/index.d.ts.map +0 -1
  249. package/dist/Mask/index.js +0 -2
  250. package/dist/NavBar/index.d.ts.map +0 -1
  251. package/dist/NoticeBar/index.d.ts.map +0 -1
  252. package/dist/PageIndicator/index.d.ts.map +0 -1
  253. package/dist/Picker/index.d.ts.map +0 -1
  254. package/dist/PickerView/index.d.ts.map +0 -1
  255. package/dist/Popup/index.d.ts.map +0 -1
  256. package/dist/Progress/Progress.d.ts +0 -39
  257. package/dist/Progress/Progress.d.ts.map +0 -1
  258. package/dist/Progress/Progress.js +0 -53
  259. package/dist/Progress/ProgressCircle.d.ts +0 -17
  260. package/dist/Progress/ProgressCircle.d.ts.map +0 -1
  261. package/dist/Progress/ProgressCircle.js +0 -147
  262. package/dist/Progress/ProgressLine.d.ts +0 -16
  263. package/dist/Progress/ProgressLine.d.ts.map +0 -1
  264. package/dist/Progress/ProgressLine.js +0 -87
  265. package/dist/Progress/index.d.ts.map +0 -1
  266. package/dist/Progress/style.scss +0 -33
  267. package/dist/Progress/types.d.ts +0 -5
  268. package/dist/Progress/types.d.ts.map +0 -1
  269. package/dist/Progress/types.js +0 -2
  270. package/dist/Radio/index.d.ts.map +0 -1
  271. package/dist/Rate/index.d.ts.map +0 -1
  272. package/dist/Result/index.d.ts.map +0 -1
  273. package/dist/SafeArea/index.d.ts.map +0 -1
  274. package/dist/Scaffold/index.d.ts.map +0 -1
  275. package/dist/ScrollView/index.d.ts.map +0 -1
  276. package/dist/SideBar/SideBarContext.d.ts.map +0 -1
  277. package/dist/SideBar/index.d.ts.map +0 -1
  278. package/dist/SideBar/side-bar.d.ts.map +0 -1
  279. package/dist/SideBar/types.d.ts.map +0 -1
  280. package/dist/Space/index.d.ts.map +0 -1
  281. package/dist/SpinLoading/index.d.ts.map +0 -1
  282. package/dist/Steps/index.d.ts.map +0 -1
  283. package/dist/Swiper/index.d.ts.map +0 -1
  284. package/dist/Swiper/swiper.d.ts.map +0 -1
  285. package/dist/Switch/index.d.ts.map +0 -1
  286. package/dist/TabBar/index.d.ts.map +0 -1
  287. package/dist/Tabs/index.d.ts.map +0 -1
  288. package/dist/Tag/index.d.ts.map +0 -1
  289. package/dist/Toast/index.d.ts.map +0 -1
  290. package/dist/VerificationCodeInput/index.d.ts.map +0 -1
  291. package/dist/WaterMark/index.d.ts.map +0 -1
  292. package/dist/hooks/index.d.ts.map +0 -1
  293. package/dist/hooks/useTaro.d.ts.map +0 -1
  294. package/dist/index.d.ts.map +0 -1
  295. package/dist/locales/base.d.ts.map +0 -1
  296. package/dist/locales/en-US.d.ts.map +0 -1
  297. package/dist/locales/zh-CN.d.ts.map +0 -1
  298. package/dist/types.d.ts.map +0 -1
  299. package/dist/utils/datetime-utils.d.ts.map +0 -1
  300. package/dist/utils/merge-locale.d.ts.map +0 -1
  301. package/dist/utils/native-props.d.ts.map +0 -1
  302. package/dist/utils/random-utils.d.ts.map +0 -1
  303. /package/dist/{CalendarPicker → DatePicker}/types.js +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
- /**
22
- * 可以手势滑动的日历组件
21
+ import dayjs from "dayjs";
22
+ var monthLines = 6;
23
+
24
+ /**
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(month || dayjs()),
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),
@@ -65,8 +67,8 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
65
67
  mouths = _useState10[0],
66
68
  setMouths = _useState10[1];
67
69
 
68
- /**
69
- * 计算出每个格子的大小
70
+ /**
71
+ * 计算出每个格子的大小
70
72
  */
71
73
  var cellSize = /*#__PURE__*/function () {
72
74
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -99,8 +101,8 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
99
101
  return _ref2.apply(this, arguments);
100
102
  };
101
103
  }();
102
- /**
103
- * 计算出最大的translateY,默认为wrapperRef.current?.clientHeight
104
+ /**
105
+ * 计算出最大的translateY,默认为wrapperRef.current?.clientHeight
104
106
  */
105
107
  var minTranslateY = /*#__PURE__*/function () {
106
108
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
@@ -134,21 +136,21 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
134
136
  };
135
137
  }();
136
138
 
137
- /**
138
- * 计算出该月的行数
139
- * @param mouth
139
+ /**
140
+ * 计算出该月的行数
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:
@@ -158,19 +160,19 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
158
160
  // debugger
159
161
  // waiting = true
160
162
  firstMouth = mouths[0];
161
- insertMouth = new Date(firstMouth.getFullYear(), firstMouth.getMonth() - 1, 1);
163
+ insertMouth = dayjs(new Date(firstMouth.year(), firstMouth.month() - 1, 1));
162
164
  newMouths = [insertMouth].concat(_toConsumableArray(mouths));
163
165
  setMouths(newMouths);
164
- insertMouthLines = mouthLines(insertMouth);
165
- _context3.t0 = insertMouthLines;
166
- _context3.next = 8;
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
  }
@@ -186,13 +188,13 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
186
188
  // }
187
189
  // waiting = true
188
190
  var lastMouth = mouths[mouths.length - 1];
189
- var appendMouth = new Date(lastMouth.getFullYear(), lastMouth.getMonth() + 1, 1);
191
+ var appendMouth = lastMouth.add(1, 'month');
190
192
  var newMouths = [].concat(_toConsumableArray(mouths), [appendMouth]);
191
193
  setMouths(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 initMouths = [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) {
@@ -200,14 +202,14 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
200
202
  case 0:
201
203
  setMouths(initMouths);
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
  }
@@ -351,66 +351,67 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
351
351
  i = 0;
352
352
  case 6:
353
353
  if (!(i < mouths.length)) {
354
- _context6.next = 40;
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]);
380
+ // console.log('displayMouth', mouths[i]);
383
381
  displayMouth = mouths[i];
384
- return _context6.abrupt("break", 40);
385
- case 27:
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
+ // console.log('displayMouth', mouths[i]);
401
402
  displayMouth = mouths[i];
402
- return _context6.abrupt("break", 40);
403
- case 37:
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
  }
@@ -423,7 +424,7 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
423
424
  }, mouths.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,11 +1,11 @@
1
1
  import { FC } from 'react';
2
2
  import './style.scss';
3
+ import dayjs from "dayjs";
3
4
  export type CalendarDatetimePickerProps = {
4
- open?: boolean;
5
- afterOpenChange?: (open: boolean) => void;
6
- value?: Date;
7
- onOk?: (value?: Date) => void;
8
- onClose?: () => void;
5
+ placeholder?: string;
6
+ value?: dayjs.Dayjs | Date;
7
+ format?: string;
8
+ onChange?: (value?: dayjs.Dayjs) => void;
9
+ align?: 'left' | 'right' | 'center';
9
10
  };
10
11
  export declare const CalendarDatetimePicker: FC<CalendarDatetimePickerProps>;
11
- //# sourceMappingURL=CalendarDatetimePicker.d.ts.map
@@ -1,181 +1,68 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
5
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
6
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
7
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
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';
12
- import Taro from '@tarojs/taro';
13
11
  import classNames from 'classnames';
14
- import React, { useEffect, useRef, useState } from 'react';
15
- import Calendar from "../Calendar";
16
- import ConfigProvider from "../ConfigProvider";
17
- import { useTaro } from "../hooks/useTaro";
18
- import PickerView from "../PickerView";
19
- import Popup from "../Popup";
20
- import { DatetimeUtils } from "../utils/datetime-utils";
21
- import { DateTimeSwitch } from "./DateTimeSwitch";
12
+ import React, { useEffect, useState } from 'react';
22
13
  import "./style.scss";
23
- import { cls, Mode } from "./types";
14
+ import { cls } from "./types";
15
+ import CalendarDatetimePopup from "../CalendarDatetimePopup";
16
+ import dayjs from "dayjs";
17
+ import { isSame } from "../utils/dayjs";
24
18
  export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
25
- var _bodyRef$current;
26
- var open = _ref.open,
27
- afterOpenChange = _ref.afterOpenChange,
28
- _ref$value = _ref.value,
29
- value = _ref$value === void 0 ? new Date() : _ref$value,
30
- onOk = _ref.onOk,
31
- _onClose = _ref.onClose;
32
- var _ConfigProvider$useCo = ConfigProvider.useConfig(),
33
- locale = _ConfigProvider$useCo.locale;
34
- var _useTaro = useTaro(),
35
- isTaroEnv = _useTaro.isTaroEnv,
36
- isTaroWeApp = _useTaro.isTaroWeApp;
37
- var _React$useState = React.useState(open || false),
19
+ var _ref$placeholder = _ref.placeholder,
20
+ placeholder = _ref$placeholder === void 0 ? '请选择' : _ref$placeholder,
21
+ value = _ref.value,
22
+ _ref$format = _ref.format,
23
+ format = _ref$format === void 0 ? 'YYYY-MM-DD HH:mm' : _ref$format,
24
+ onChange = _ref.onChange,
25
+ _ref$align = _ref.align,
26
+ align = _ref$align === void 0 ? 'left' : _ref$align;
27
+ var _React$useState = React.useState(false),
38
28
  _React$useState2 = _slicedToArray(_React$useState, 2),
39
29
  innerOpen = _React$useState2[0],
40
30
  setInnerOpen = _React$useState2[1];
41
- var _useState = useState(Mode.date),
31
+ var _useState = useState(value ? dayjs(value) : undefined),
42
32
  _useState2 = _slicedToArray(_useState, 2),
43
- mode = _useState2[0],
44
- setMode = _useState2[1];
45
- var valueRef = useRef(value || new Date());
46
- var bodyRef = useRef(null);
47
- var datetimeSwitchRef = useRef();
48
- var _useState3 = useState(300),
49
- _useState4 = _slicedToArray(_useState3, 2),
50
- bodyHeight = _useState4[0],
51
- setBodyHeight = _useState4[1];
52
- var handleClose = function handleClose() {
53
- setInnerOpen(false);
54
- _onClose === null || _onClose === void 0 || _onClose();
55
- };
56
- var handleOk = function handleOk() {
57
- onOk === null || onOk === void 0 || onOk(valueRef.current);
58
- handleClose();
59
- };
60
- var handleComputeBodyHeight = /*#__PURE__*/function () {
61
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
62
- return _regeneratorRuntime().wrap(function _callee$(_context) {
63
- while (1) switch (_context.prev = _context.next) {
64
- case 0:
65
- if (!(isTaroEnv && isTaroWeApp)) {
66
- _context.next = 2;
67
- break;
68
- }
69
- return _context.abrupt("return", new Promise(function (resolve) {
70
- Taro.createSelectorQuery().in(bodyRef.current.ctx).select(".".concat(cls, "-body")).boundingClientRect()
71
- // .fields({ node: true, size: true })
72
- .exec(function (res) {
73
- var _res$;
74
- console.log(res);
75
- resolve(res === null || res === void 0 || (_res$ = res[0]) === null || _res$ === void 0 ? void 0 : _res$.height);
76
- });
77
- }));
78
- case 2:
79
- return _context.abrupt("return", Promise.resolve(bodyRef.current.offsetHeight));
80
- case 3:
81
- case "end":
82
- return _context.stop();
83
- }
84
- }, _callee);
85
- }));
86
- return function handleComputeBodyHeight() {
87
- return _ref2.apply(this, arguments);
88
- };
89
- }();
90
- useEffect(function () {
91
- afterOpenChange === null || afterOpenChange === void 0 || afterOpenChange(innerOpen);
92
- if (!innerOpen) {
93
- _onClose === null || _onClose === void 0 || _onClose();
33
+ internalValue = _useState2[0],
34
+ setInternalValue = _useState2[1];
35
+ var handleValueRender = function handleValueRender() {
36
+ if (internalValue) {
37
+ return internalValue.format(format);
94
38
  }
95
- }, [innerOpen]);
39
+ return null;
40
+ };
96
41
  useEffect(function () {
97
- if (open === undefined) {
42
+ if (value === undefined) {
98
43
  return;
99
44
  }
100
- if (open === innerOpen) {
101
- return;
45
+ if (!isSame(value, internalValue)) {
46
+ setInternalValue(dayjs(value));
102
47
  }
103
- setInnerOpen(open);
104
- }, [open]);
105
- useEffect(function () {
106
- if (datetimeSwitchRef.current) {
107
- datetimeSwitchRef.current.setDatetime(valueRef.current);
108
- }
109
- }, []);
110
- var bodyRender = function bodyRender() {
111
- return /*#__PURE__*/React.createElement(React.Fragment, null, mode === Mode.date && /*#__PURE__*/React.createElement("div", {
112
- style: {}
113
- }, /*#__PURE__*/React.createElement(Calendar, {
114
- mouth: value,
115
- value: value,
116
- onChange: function onChange(date) {
117
- var _datetimeSwitchRef$cu;
118
- valueRef.current = new Date(date.getFullYear(), date.getMonth(), date.getDate(), valueRef.current.getHours(), valueRef.current.getMinutes());
119
- (_datetimeSwitchRef$cu = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu === void 0 || _datetimeSwitchRef$cu.setDatetime(valueRef.current);
120
- }
121
- })), mode === Mode.time && /*#__PURE__*/React.createElement("div", {
122
- style: {
123
- height: bodyHeight
124
- }
125
- }, /*#__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) {
140
- var _datetimeSwitchRef$cu2;
141
- valueRef.current = new Date(valueRef.current.getFullYear(), valueRef.current.getMonth(), valueRef.current.getDate(), v[0], v[1]);
142
- (_datetimeSwitchRef$cu2 = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu2 === void 0 || _datetimeSwitchRef$cu2.setDatetime(valueRef.current);
143
- }
144
- })));
145
- };
146
- return /*#__PURE__*/React.createElement(Popup, {
48
+ }, [value]);
49
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CalendarDatetimePopup, {
147
50
  open: innerOpen,
51
+ value: internalValue || dayjs(),
148
52
  onClose: function onClose() {
149
53
  setInnerOpen(false);
150
- _onClose === null || _onClose === void 0 || _onClose();
151
- }
152
- }, /*#__PURE__*/React.createElement("div", {
153
- className: classNames(cls)
154
- }, /*#__PURE__*/React.createElement("div", {
155
- className: "".concat(cls, "-header")
156
- }, /*#__PURE__*/React.createElement(DateTimeSwitch, {
157
- ref: datetimeSwitchRef,
158
- mode: mode,
159
- value: valueRef.current,
160
- onDateTabTap: function onDateTabTap() {
161
- return setMode(Mode.date);
162
54
  },
163
- onTimeTabTap: function onTimeTabTap() {
164
- handleComputeBodyHeight().then(function (height) {
165
- setBodyHeight(height);
166
- setMode(Mode.time);
167
- });
55
+ onOk: function onOk(date) {
56
+ setInternalValue(date);
57
+ setInnerOpen(false);
58
+ onChange === null || onChange === void 0 || onChange(date);
59
+ }
60
+ }), /*#__PURE__*/React.createElement("div", {
61
+ className: classNames(cls, _defineProperty({}, "".concat(cls, "-").concat(align), true)),
62
+ onClick: function onClick() {
63
+ setInnerOpen(true);
168
64
  }
169
- }), /*#__PURE__*/React.createElement("a", {
170
- className: classNames("".concat(cls, "-header-button"), "".concat(cls, "-header-button-ok")),
171
- onClick: handleOk
172
- }, locale.common.confirm)), isTaroEnv ? /*#__PURE__*/React.createElement(CustomWrapper, {
173
- ref: bodyRef
174
- }, /*#__PURE__*/React.createElement("div", {
175
- 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())));
65
+ }, !internalValue ? /*#__PURE__*/React.createElement("div", {
66
+ className: "".concat(cls, "-placeholder")
67
+ }, placeholder) : /*#__PURE__*/React.createElement("div", null, handleValueRender())));
181
68
  };
@@ -1,4 +1,3 @@
1
1
  import { CalendarDatetimePicker, CalendarDatetimePickerProps } from "./CalendarDatetimePicker";
2
2
  export type { CalendarDatetimePickerProps };
3
3
  export default CalendarDatetimePicker;
4
- //# sourceMappingURL=index.d.ts.map