@nutui/nutui-react-taro 1.4.4 → 1.4.5

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 (219) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/esm/Address.js +5 -5
  3. package/dist/esm/Audio.js +5 -5
  4. package/dist/esm/AvatarContext-7153ad2b.js +3 -1
  5. package/dist/esm/AvatarGroup.js +4 -4
  6. package/dist/esm/Calendar.js +5 -5
  7. package/dist/esm/CalendarItem.js +4 -4
  8. package/dist/esm/Card.js +4 -3
  9. package/dist/esm/Cell.js +2 -2
  10. package/dist/esm/ConfigProvider.js +3 -3
  11. package/dist/esm/CountDown.js +4 -4
  12. package/dist/esm/DatePicker.js +5 -5
  13. package/dist/esm/Dialog.js +4 -4
  14. package/dist/esm/Ellipsis.js +4 -4
  15. package/dist/esm/Empty.js +4 -4
  16. package/dist/esm/FixedNav.js +4 -4
  17. package/dist/esm/Form.js +4 -4
  18. package/dist/esm/FormItem.js +3 -3
  19. package/dist/esm/Grid.js +4 -4
  20. package/dist/esm/GridItem.js +4 -4
  21. package/dist/esm/Image.js +4 -4
  22. package/dist/esm/Infiniteloading.js +4 -4
  23. package/dist/esm/Input.js +4 -4
  24. package/dist/esm/MenuItem.js +4 -4
  25. package/dist/esm/NoticeBar.js +2 -2
  26. package/dist/esm/NumberKeyboard.js +4 -4
  27. package/dist/esm/Pagination.js +4 -4
  28. package/dist/esm/Picker.js +4 -4
  29. package/dist/esm/PullToRefresh.js +4 -4
  30. package/dist/esm/Range.js +4 -4
  31. package/dist/esm/SearchBar.js +4 -4
  32. package/dist/esm/ShortPassword.js +4 -4
  33. package/dist/esm/SideNavBar.js +4 -4
  34. package/dist/esm/Signature.js +4 -4
  35. package/dist/esm/Sticky.js +4 -4
  36. package/dist/esm/Table.js +4 -4
  37. package/dist/esm/Tag.js +3 -2
  38. package/dist/esm/TextArea.js +4 -4
  39. package/dist/esm/TimeDetail.js +4 -4
  40. package/dist/esm/TimePannel.js +4 -4
  41. package/dist/esm/TimeSelect.js +6 -6
  42. package/dist/esm/Uploader.js +4 -4
  43. package/dist/esm/UserContext-68f62e66.js +3 -1
  44. package/dist/esm/UserContext-b4181162.js +3 -1
  45. package/dist/esm/UserContext-be8097d2.js +3 -1
  46. package/dist/esm/VirtualList.js +6 -4
  47. package/dist/esm/WaterMark.js +4 -4
  48. package/dist/esm/actionsheet.taro-a58d3d12.js +45 -83
  49. package/dist/esm/address.taro-79cc7c96.js +461 -0
  50. package/dist/esm/animate.taro-b0e83dd5.js +32 -46
  51. package/dist/esm/animatingnumbers.taro-6f40a2e9.js +93 -134
  52. package/dist/esm/audio.taro-4fadc583.js +161 -0
  53. package/dist/esm/avatar.taro-85ced995.js +93 -119
  54. package/dist/esm/avatargroup-1d900174.js +34 -0
  55. package/dist/esm/backtop.taro-99107c30.js +39 -62
  56. package/dist/esm/badge.taro-fe9171ec.js +40 -58
  57. package/dist/esm/barrage.taro-0e157b5e.js +61 -91
  58. package/dist/esm/bem-893ad28d.js +3 -6
  59. package/dist/esm/button.taro-4ce133b9.js +87 -98
  60. package/dist/esm/calendar.taro-4ed72058.js +38 -0
  61. package/dist/esm/calendaritem.taro-1ebe428d.js +571 -0
  62. package/dist/esm/card.taro-39055e82.js +32 -0
  63. package/dist/esm/cascader.taro-d8cb1c3e.js +397 -636
  64. package/dist/esm/cell.taro-9a04a92e.js +64 -0
  65. package/dist/esm/cellgroup.taro-e094471c.js +18 -27
  66. package/dist/esm/checkbox.taro-0bda9796.js +160 -232
  67. package/dist/esm/circleprogress.taro-47db537c.js +99 -120
  68. package/dist/esm/col.taro-b61c7cba.js +33 -50
  69. package/dist/esm/collapse.taro-af58206c.js +73 -86
  70. package/dist/esm/collapseitem-ce1849d2.js +75 -139
  71. package/dist/esm/configprovider-5eea4f5d.js +19 -0
  72. package/dist/esm/configprovider.taro-26882dd2.js +42 -0
  73. package/dist/esm/countdown.taro-9e40de9c.js +225 -0
  74. package/dist/esm/datepicker.taro-7220e495.js +270 -0
  75. package/dist/esm/dialog.taro-1c03960e.js +123 -0
  76. package/dist/esm/divider.taro-5236fe6a.js +27 -27
  77. package/dist/esm/drag.taro-82b6b27a.js +99 -138
  78. package/dist/esm/elevator.taro-d7d65470.js +185 -259
  79. package/dist/esm/ellipsis.taro-49b6db0c.js +232 -0
  80. package/dist/esm/empty.taro-7bd813f9.js +62 -0
  81. package/dist/esm/fixednav.taro-5ad15202.js +53 -0
  82. package/dist/esm/form.taro-71d32671.js +179 -0
  83. package/dist/esm/formitem.taro-3089489b.js +89 -0
  84. package/dist/esm/grid.taro-e6decfce.js +58 -0
  85. package/dist/esm/grid.taro.context-39636af9.js +4 -2
  86. package/dist/esm/griditem.taro-4cade72e.js +90 -0
  87. package/dist/esm/icon-8dc4de10.js +43 -51
  88. package/dist/esm/icon.taro-1d0d4fb7.js +43 -51
  89. package/dist/esm/image.taro-e6dc5867.js +64 -0
  90. package/dist/esm/imagepreview.taro-3400ea03.js +158 -205
  91. package/dist/esm/index.taro-a36f96fb.js +149 -210
  92. package/dist/esm/indicator.taro-183ea169.js +29 -43
  93. package/dist/esm/infiniteloading.taro-6c2a2e95.js +142 -0
  94. package/dist/esm/input.taro-fd566407.js +243 -0
  95. package/dist/esm/inputnumber.taro-dc39b853.js +129 -177
  96. package/dist/esm/layout.taro-358f014f.js +6 -9
  97. package/dist/esm/menu.taro-4abed328.js +89 -132
  98. package/dist/esm/menuitem.taro-6e8b27c3.js +130 -0
  99. package/dist/esm/navbar.taro-c931c078.js +69 -105
  100. package/dist/esm/noticebar.taro-69ea7673.js +450 -0
  101. package/dist/esm/notify.taro-308e5892.js +66 -97
  102. package/dist/esm/numberkeyboard.taro-194519e4.js +158 -0
  103. package/dist/esm/nutui-react.es.js +44 -44
  104. package/dist/esm/offsetContext-bfb02c25.js +3 -1
  105. package/dist/esm/overlay.taro-98367bc1.js +59 -74
  106. package/dist/esm/pagination.taro-bb490de9.js +124 -0
  107. package/dist/esm/picker.taro-2a8ded7c.js +420 -0
  108. package/dist/esm/popover.taro-46d813e8.js +132 -222
  109. package/dist/esm/popup.taro-cb777e09.js +125 -178
  110. package/dist/esm/price.taro-8801462e.js +75 -86
  111. package/dist/esm/progress.taro-623bc807.js +84 -118
  112. package/dist/esm/pulltorefresh.taro-cab7b51c.js +221 -0
  113. package/dist/esm/range.taro-5d6ff217.js +332 -0
  114. package/dist/esm/rate.taro-10197384.js +64 -111
  115. package/dist/esm/row.taro-37a895de.js +38 -42
  116. package/dist/esm/searchbar.taro-839dd622.js +148 -0
  117. package/dist/esm/shortpassword.taro-182d46f7.js +111 -0
  118. package/dist/esm/sidenavbar.taro-006cf38b.js +35 -0
  119. package/dist/esm/sidenavbaritem.taro-fee11d26.js +9 -22
  120. package/dist/esm/signature.taro-33632585.js +143 -0
  121. package/dist/esm/skeleton.taro-853ce460.js +51 -88
  122. package/dist/esm/step.taro-1c94e067.js +49 -78
  123. package/dist/esm/steps.taro-acf205a0.js +21 -30
  124. package/dist/esm/sticky.taro-d0553f48.js +13 -0
  125. package/dist/esm/subsidenavbar.taro-f46b4c73.js +58 -75
  126. package/dist/esm/swipe.taro-83bc248f.js +164 -254
  127. package/dist/esm/swiper.taro-852f6615.js +424 -505
  128. package/dist/esm/swiperitem-86a3578a.js +20 -28
  129. package/dist/esm/switch.taro-bae2dca0.js +43 -64
  130. package/dist/esm/tabbar.taro-86cece39.js +47 -57
  131. package/dist/esm/tabbaritem.taro-8dfb8055.js +51 -79
  132. package/dist/esm/table.taro-cb4dd2c3.js +92 -0
  133. package/dist/esm/tabpane.taro-91cd6cf4.js +17 -22
  134. package/dist/esm/tabs.taro-e71875fa.js +121 -165
  135. package/dist/esm/tag.taro-00fe554d.js +89 -0
  136. package/dist/esm/textarea.taro-42600f8c.js +74 -0
  137. package/dist/esm/timedetail.taro-c5f564fd.js +44 -0
  138. package/dist/esm/timepannel.taro-29f9dd86.js +22 -0
  139. package/dist/esm/timeselect.taro-3ecce65d.js +133 -0
  140. package/dist/esm/toast.taro-0804b6b4.js +99 -137
  141. package/dist/esm/trendarrow.taro-5a7153e4.js +63 -90
  142. package/dist/esm/types/src/packages/cell/cell.taro.d.ts +0 -1
  143. package/dist/esm/types/src/packages/noticebar/noticebar.d.ts +5 -4
  144. package/dist/esm/types/src/packages/noticebar/noticebar.taro.d.ts +5 -4
  145. package/dist/esm/types/src/packages/uploader/uploader.d.ts +1 -1
  146. package/dist/esm/types/src/packages/virtuallist/virtuallist.taro.d.ts +13 -2
  147. package/dist/esm/typings-1c5f2628.js +7 -6
  148. package/dist/esm/uploader.taro-f80d76d9.js +392 -0
  149. package/dist/esm/useClientRect-bf69d7b3.js +5 -25
  150. package/dist/esm/useTouch-a2ea68c6.js +63 -93
  151. package/dist/esm/video-8a3518c5.js +59 -83
  152. package/dist/esm/virtuallist.taro-e3345ced.js +215 -0
  153. package/dist/esm/watermark.taro-cd9db98a.js +114 -0
  154. package/dist/esm/zh-CN-dfc384d0.js +128 -133
  155. package/dist/locales/base.js +1 -1
  156. package/dist/locales/en-US.js +1 -1
  157. package/dist/locales/id-ID.js +1 -1
  158. package/dist/locales/zh-CN.js +1 -1
  159. package/dist/locales/zh-TW.js +1 -1
  160. package/dist/locales/zh-UG.js +1 -1
  161. package/dist/nutui.react.es.js +634 -5664
  162. package/dist/nutui.react.umd.js +634 -5664
  163. package/dist/packages/noticebar/noticebar.scss +17 -0
  164. package/dist/packages/radio/radio.scss +3 -1
  165. package/dist/packages/row/row.scss +2 -0
  166. package/dist/packages/searchbar/searchbar.scss +1 -1
  167. package/dist/packages/tag/tag.scss +13 -5
  168. package/dist/packages/virtuallist/virtuallist.scss +24 -0
  169. package/dist/style.css +1 -1
  170. package/dist/style.es.js +1 -1
  171. package/dist/styles/temp.scss +2340 -0
  172. package/dist/styles/theme-dark.scss +7 -0
  173. package/dist/styles/theme-default.scss +11 -0
  174. package/dist/styles/variables.scss +1945 -710
  175. package/dist/types/index.d.ts +16 -23
  176. package/package.json +9 -4
  177. package/dist/esm/address.taro-1e2aea24.js +0 -615
  178. package/dist/esm/audio.taro-fddcdfc0.js +0 -228
  179. package/dist/esm/avatargroup-f7f600ff.js +0 -42
  180. package/dist/esm/calendar.taro-72974415.js +0 -83
  181. package/dist/esm/calendaritem.taro-84e889eb.js +0 -580
  182. package/dist/esm/card.taro-a530dfb3.js +0 -61
  183. package/dist/esm/cell.taro-cf50c4f2.js +0 -109
  184. package/dist/esm/configprovider-c7d60e20.js +0 -18
  185. package/dist/esm/configprovider.taro-8bdb3a28.js +0 -50
  186. package/dist/esm/countdown.taro-d7dc8681.js +0 -246
  187. package/dist/esm/datepicker.taro-7199f521.js +0 -304
  188. package/dist/esm/dialog.taro-f54cfbf0.js +0 -187
  189. package/dist/esm/ellipsis.taro-c0de6ff4.js +0 -309
  190. package/dist/esm/empty.taro-dbc66496.js +0 -81
  191. package/dist/esm/fixednav.taro-9e759320.js +0 -97
  192. package/dist/esm/form.taro-880014b1.js +0 -181
  193. package/dist/esm/formitem.taro-3695f4a7.js +0 -136
  194. package/dist/esm/grid.taro-c2cc12d6.js +0 -81
  195. package/dist/esm/griditem.taro-892153cd.js +0 -122
  196. package/dist/esm/image.taro-c30973d5.js +0 -105
  197. package/dist/esm/infiniteloading.taro-b5ddf3cc.js +0 -188
  198. package/dist/esm/input.taro-104130c1.js +0 -361
  199. package/dist/esm/menuitem.taro-216e9f7d.js +0 -193
  200. package/dist/esm/noticebar.taro-94002898.js +0 -368
  201. package/dist/esm/numberkeyboard.taro-5e8f0ddf.js +0 -245
  202. package/dist/esm/pagination.taro-9925ffab.js +0 -169
  203. package/dist/esm/picker.taro-3b5cc054.js +0 -540
  204. package/dist/esm/pulltorefresh.taro-f26a20dd.js +0 -302
  205. package/dist/esm/range.taro-c41e9b90.js +0 -469
  206. package/dist/esm/searchbar.taro-01ed4ea4.js +0 -236
  207. package/dist/esm/shortpassword.taro-3a3bf412.js +0 -190
  208. package/dist/esm/sidenavbar.taro-06026f31.js +0 -66
  209. package/dist/esm/signature.taro-17648cac.js +0 -192
  210. package/dist/esm/sticky.taro-36013e97.js +0 -16
  211. package/dist/esm/table.taro-adda6622.js +0 -139
  212. package/dist/esm/tag.taro-bd900990.js +0 -104
  213. package/dist/esm/textarea.taro-83d5fe73.js +0 -102
  214. package/dist/esm/timedetail.taro-105f5380.js +0 -68
  215. package/dist/esm/timepannel.taro-c66c63dd.js +0 -30
  216. package/dist/esm/timeselect.taro-fc7ec6ee.js +0 -172
  217. package/dist/esm/uploader.taro-a1edf38f.js +0 -529
  218. package/dist/esm/virtuallist.taro-4add61c3.js +0 -315
  219. package/dist/esm/watermark.taro-323d1cf3.js +0 -132
@@ -1,580 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
- import _regeneratorRuntime from "@babel/runtime/regenerator";
6
- 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; }
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
- import React__default, { useState, useRef, useEffect } from 'react';
9
- import classNames from 'classnames';
10
- import { c as cn } from './bem-893ad28d.js';
11
- import { u as useConfig } from './configprovider.taro-8bdb3a28.js';
12
- import { g as getRectByTaro } from './useClientRect-bf69d7b3.js';
13
- var Utils = {
14
- /**
15
- * 是否为闫年
16
- * @return {Boolse} true|false
17
- */
18
- isLeapYear: function isLeapYear(y) {
19
- return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;
20
- },
21
- /**
22
- * 返回星期数
23
- * @return {String}
24
- */
25
- getWhatDay: function getWhatDay(year, month, day) {
26
- var date = new Date("".concat(year, "/").concat(month, "/").concat(day));
27
- var index = date.getDay();
28
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
29
- return dayNames[index];
30
- },
31
- /**
32
- * 返回星期数
33
- * @return {Number}
34
- */
35
- getMonthPreDay: function getMonthPreDay(year, month) {
36
- var date = new Date("".concat(year, "/").concat(month, "/01"));
37
- var day = date.getDay();
38
- if (day == 0) {
39
- day = 7;
40
- }
41
- return day;
42
- },
43
- /**
44
- * 返回月份天数
45
- * @return {Number}
46
- */
47
- getMonthDays: function getMonthDays(year, month) {
48
- if (/^0/.test(month)) {
49
- month = month.split('')[1];
50
- }
51
- return [0, 31, this.isLeapYear(Number(year)) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
52
- },
53
- /**
54
- * 补齐数字位数
55
- * @return {string}
56
- */
57
- getNumTwoBit: function getNumTwoBit(n) {
58
- n = Number(n);
59
- return (n > 9 ? '' : '0') + n;
60
- },
61
- /**
62
- * 日期对象转成字符串
63
- * @return {string}
64
- */
65
- date2Str: function date2Str(date, split) {
66
- split = split || '-';
67
- var y = date.getFullYear();
68
- var m = this.getNumTwoBit(date.getMonth() + 1);
69
- var d = this.getNumTwoBit(date.getDate());
70
- return [y, m, d].join(split);
71
- },
72
- /**
73
- * 返回日期格式字符串
74
- * @param {Number} 0返回今天的日期、1返回明天的日期,2返回后天得日期,依次类推
75
- * @return {string} '2014-12-31'
76
- */
77
- getDay: function getDay(i) {
78
- i = i || 0;
79
- var date = new Date();
80
- var diff = i * (1000 * 60 * 60 * 24);
81
- date = new Date(date.getTime() + diff);
82
- return this.date2Str(date);
83
- },
84
- /**
85
- * 时间比较
86
- * @return {Boolean}
87
- */
88
- compareDate: function compareDate(date1, date2) {
89
- var startTime = new Date(date1.replace('-', '/').replace('-', '/'));
90
- var endTime = new Date(date2.replace('-', '/').replace('-', '/'));
91
- if (startTime >= endTime) {
92
- return false;
93
- }
94
- return true;
95
- },
96
- /**
97
- * 时间是否相等
98
- * @return {Boolean}
99
- */
100
- isEqual: function isEqual(date1, date2) {
101
- var startTime = new Date(date1).getTime();
102
- var endTime = new Date(date2).getTime();
103
- if (startTime == endTime) {
104
- return true;
105
- }
106
- return false;
107
- }
108
- };
109
- function requestAniFrame() {
110
- if (typeof window !== 'undefined') {
111
- return window.requestAnimationFrame || function (callback) {
112
- window.setTimeout(callback, 1000 / 60);
113
- };
114
- }
115
- return function (callback) {
116
- setTimeout(callback, 1000 / 60);
117
- };
118
- }
119
- var requestAniFrame$1 = requestAniFrame();
120
- var defaultProps = {
121
- type: 'one',
122
- isAutoBackFill: false,
123
- poppable: true,
124
- visible: false,
125
- title: '日历选择',
126
- defaultValue: '',
127
- startDate: Utils.getDay(0),
128
- endDate: Utils.getDay(365),
129
- onChoose: function onChoose(data) {},
130
- onUpdate: function onUpdate() {},
131
- onClose: function onClose() {}
132
- };
133
- var CalendarItem = function CalendarItem(props) {
134
- var _classNames, _classNames2;
135
- var _useConfig = useConfig(),
136
- locale = _useConfig.locale;
137
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
138
- type = _defaultProps$props.type,
139
- isAutoBackFill = _defaultProps$props.isAutoBackFill,
140
- poppable = _defaultProps$props.poppable,
141
- title = _defaultProps$props.title,
142
- defaultValue = _defaultProps$props.defaultValue,
143
- startDate = _defaultProps$props.startDate,
144
- endDate = _defaultProps$props.endDate,
145
- onChoose = _defaultProps$props.onChoose,
146
- onUpdate = _defaultProps$props.onUpdate,
147
- onClose = _defaultProps$props.onClose;
148
- var weeks = locale.calendaritem.weekdays;
149
- var _useState = useState(''),
150
- _useState2 = _slicedToArray(_useState, 2),
151
- yearMonthTitle = _useState2[0],
152
- setYearMonthTitle = _useState2[1];
153
- var _useState3 = useState(false),
154
- _useState4 = _slicedToArray(_useState3, 2),
155
- unLoadPrev = _useState4[0],
156
- setUnLoadPrev = _useState4[1];
157
- var _useState5 = useState([]),
158
- _useState6 = _slicedToArray(_useState5, 2),
159
- monthsData = _useState6[0],
160
- setMonthsData = _useState6[1];
161
- var _useState7 = useState({
162
- currDate: '',
163
- touchParams: {
164
- startY: 0,
165
- endY: 0,
166
- startTime: 0,
167
- endTime: 0,
168
- lastY: 0,
169
- lastTime: 0
170
- },
171
- transformY: 0,
172
- translateY: 0,
173
- scrollDistance: 0,
174
- defaultData: [],
175
- chooseData: [],
176
- monthsData: [],
177
- dayPrefix: 'calendar-month-day',
178
- startData: '',
179
- endData: '',
180
- isRange: type === 'range',
181
- timer: 0
182
- }),
183
- _useState8 = _slicedToArray(_useState7, 1),
184
- state = _useState8[0];
185
- var weeksPanel = useRef(null);
186
- var months = useRef(null);
187
- var monthsPanel = useRef(null);
188
- var b = cn('calendar');
189
- var classes = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b(''), "-tile"), !poppable), _defineProperty(_classNames, "".concat(b(''), "-nofooter"), !!isAutoBackFill), _classNames), b(''));
190
- var headerClasses = classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b(''), "-header"), true), _defineProperty(_classNames2, "".concat(b(''), "-header-tile"), !poppable), _classNames2));
191
- var monthitemclasses = classNames(_defineProperty({
192
- 'calendar-month-item': true
193
- }, "".concat(type === 'range' ? 'month-item-range' : ''), true));
194
- var splitDate = function splitDate(date) {
195
- return date.split('-');
196
- };
197
- var isStart = function isStart(currDate) {
198
- return Utils.isEqual(state.currDate[0], currDate);
199
- };
200
- var isEnd = function isEnd(currDate) {
201
- return Utils.isEqual(state.currDate[1], currDate);
202
- };
203
- var getCurrDate = function getCurrDate(day, month, isRange) {
204
- return isRange ? "".concat(month.curData[3], "-").concat(month.curData[4], "-").concat(Utils.getNumTwoBit(+day.day)) : "".concat(month.curData[0], "-").concat(month.curData[1], "-").concat(Utils.getNumTwoBit(+day.day));
205
- };
206
- var getClass = function getClass(day, month, isRange) {
207
- var currDate = getCurrDate(day, month, isRange);
208
- if (day.type === 'curr') {
209
- if (!state.isRange && Utils.isEqual(state.currDate, currDate) || state.isRange && (isStart(currDate) || isEnd(currDate))) {
210
- return "".concat(state.dayPrefix, "-active");
211
- }
212
- if (startDate && Utils.compareDate(currDate, startDate) || endDate && Utils.compareDate(endDate, currDate)) {
213
- return "".concat(state.dayPrefix, "-disabled");
214
- }
215
- if (state.isRange && Array.isArray(state.currDate) && Object.values(state.currDate).length === 2 && Utils.compareDate(state.currDate[0], currDate) && Utils.compareDate(currDate, state.currDate[1])) {
216
- return "".concat(state.dayPrefix, "-choose");
217
- }
218
- return null;
219
- }
220
- return "".concat(state.dayPrefix, "-disabled");
221
- };
222
- var isActive = function isActive(day, month) {
223
- return state.isRange && day.type === 'curr' && getClass(day, month) === 'calendar-month-day-active';
224
- };
225
- var isCurrDay = function isCurrDay(month, day) {
226
- var date = "".concat(month.curData[0], "-").concat(month.curData[1], "-").concat(day);
227
- return Utils.isEqual(date, Utils.date2Str(new Date()));
228
- };
229
- var confirm = function confirm() {
230
- if (state.isRange && state.chooseData.length === 2 || !state.isRange) {
231
- onChoose && onChoose(state.chooseData);
232
- if (poppable) {
233
- onUpdate && onUpdate();
234
- }
235
- }
236
- };
237
- var chooseDay = function chooseDay(day, month, isFirst, isRange) {
238
- if (getClass(day, month, isRange) !== "".concat(state.dayPrefix, "-disabled")) {
239
- var days = _toConsumableArray(month.curData);
240
- days = isRange ? days.splice(3) : days.splice(0, 3);
241
- days[2] = typeof day.day === 'number' ? Utils.getNumTwoBit(day.day) : day.day;
242
- days[3] = "".concat(days[0], "-").concat(days[1], "-").concat(days[2]);
243
- days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
244
- if (!state.isRange) {
245
- state.currDate = days[3];
246
- state.chooseData = _toConsumableArray(days);
247
- } else {
248
- if (Object.values(state.currDate).length === 2) {
249
- state.currDate = [days[3]];
250
- } else if (Utils.compareDate(state.currDate[0], days[3])) {
251
- Array.isArray(state.currDate) && state.currDate.push(days[3]);
252
- } else {
253
- Array.isArray(state.currDate) && state.currDate.unshift(days[3]);
254
- }
255
- if (state.chooseData.length === 2 || !state.chooseData.length) {
256
- state.chooseData = _toConsumableArray(days);
257
- } else if (Utils.compareDate(state.chooseData[3], days[3])) {
258
- state.chooseData = [_toConsumableArray(state.chooseData), _toConsumableArray(days)];
259
- } else {
260
- state.chooseData = [_toConsumableArray(days), _toConsumableArray(state.chooseData)];
261
- }
262
- }
263
- if (isAutoBackFill && !isFirst) {
264
- confirm();
265
- }
266
- setMonthsData(state.monthsData.slice());
267
- }
268
- };
269
- var isStartTip = function isStartTip(day, month) {
270
- if (isActive(day, month)) {
271
- return isStart(getCurrDate(day, month));
272
- }
273
- return false;
274
- };
275
- // 是否有结束提示
276
- var isEndTip = function isEndTip(day, month) {
277
- if (isStartTip(day, month)) {
278
- return false;
279
- }
280
- return isActive(day, month);
281
- };
282
- // 获取当前月数据
283
- var getCurrData = function getCurrData(type) {
284
- var monthData = type === 'prev' ? state.monthsData[0] : state.monthsData[state.monthsData.length - 1];
285
- var year = parseInt(monthData.curData[0]);
286
- var month = parseInt(monthData.curData[1].toString().replace(/^0/, ''));
287
- switch (type) {
288
- case 'prev':
289
- month === 1 && (year -= 1);
290
- month = month === 1 ? 12 : --month;
291
- break;
292
- case 'next':
293
- month === 12 && (year += 1);
294
- month = month === 12 ? 1 : ++month;
295
- break;
296
- }
297
- return [year, Utils.getNumTwoBit(month), Utils.getMonthDays(String(year), String(month))];
298
- };
299
- // 获取日期状态
300
- var getDaysStatus = function getDaysStatus(days, type) {
301
- // 修复:当某个月的1号是周日时,月份下方会空出来一行
302
- if (type === 'prev' && days >= 7) {
303
- days -= 7;
304
- }
305
- return Array.from(Array(days), function (v, k) {
306
- return {
307
- day: k + 1,
308
- type: type
309
- };
310
- });
311
- };
312
- // 获取月数据
313
- var getMonth = function getMonth(curData, type) {
314
- var preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
315
- var currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
316
- var title = {
317
- year: curData[0],
318
- month: curData[1]
319
- };
320
- var monthInfo = {
321
- curData: curData,
322
- title: locale.calendaritem.monthTitle(title.year, title.month),
323
- monthData: [].concat(_toConsumableArray(getDaysStatus(preMonthDays, 'prev')), _toConsumableArray(getDaysStatus(currMonthDays, 'curr')))
324
- };
325
- if (type === 'next') {
326
- if (!state.endData || !Utils.compareDate("".concat(state.endData[0], "-").concat(state.endData[1], "-").concat(Utils.getMonthDays(state.endData[0], state.endData[1])), "".concat(curData[0], "-").concat(curData[1], "-").concat(curData[2]))) {
327
- state.monthsData.push(monthInfo);
328
- }
329
- } else if (!state.startData || !Utils.compareDate("".concat(curData[0], "-").concat(curData[1], "-").concat(curData[2]), "".concat(state.startData[0], "-").concat(state.startData[1], "-01"))) {
330
- state.monthsData.unshift(monthInfo);
331
- } else {
332
- setUnLoadPrev(true);
333
- }
334
- setMonthsData(state.monthsData);
335
- };
336
- // 监听月份滚动,改变月份标题
337
- var loadScroll = function loadScroll() {
338
- if (!props.poppable) {
339
- return false;
340
- }
341
- requestAniFrame$1( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
342
- var weeksPanelRes, monthsDoms, i;
343
- return _regeneratorRuntime.wrap(function _callee$(_context) {
344
- while (1) {
345
- switch (_context.prev = _context.next) {
346
- case 0:
347
- if (!(weeksPanel !== null && weeksPanel !== void 0 && weeksPanel.current && monthsPanel !== null && monthsPanel !== void 0 && monthsPanel.current)) {
348
- _context.next = 7;
349
- break;
350
- }
351
- _context.next = 3;
352
- return getRectByTaro(weeksPanel === null || weeksPanel === void 0 ? void 0 : weeksPanel.current);
353
- case 3:
354
- weeksPanelRes = _context.sent;
355
- weeksPanelRes === null || weeksPanelRes === void 0 ? void 0 : weeksPanelRes.bottom;
356
- monthsDoms = monthsPanel.current.getElementsByClassName('calendar-month');
357
- for (i = 0; i < monthsDoms.length; i++) {}
358
- case 7:
359
- case "end":
360
- return _context.stop();
361
- }
362
- }
363
- }, _callee);
364
- })));
365
- };
366
- // 设置月份滚动距离和速度
367
- var setTransform = function setTransform() {
368
- var translateY = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
369
- var type = arguments.length > 1 ? arguments[1] : undefined;
370
- var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
371
- if (monthsPanel !== null && monthsPanel !== void 0 && monthsPanel.current) {
372
- if (type === 'end') {
373
- monthsPanel.current.style.webkitTransition = "transform ".concat(time, "ms cubic-bezier(0.19, 1, 0.22, 1)");
374
- clearTimeout(state.timer);
375
- state.timer = window.setTimeout(function () {
376
- loadScroll();
377
- }, time);
378
- } else {
379
- monthsPanel.current.style.webkitTransition = '';
380
- loadScroll();
381
- }
382
- monthsPanel.current.style.webkitTransform = "translateY(".concat(translateY, "px)");
383
- state.scrollDistance = translateY;
384
- }
385
- };
386
- // 计算滚动方向和距离
387
- var setMove = function setMove(move, type, time) {
388
- var _months$current, _monthsPanel$current;
389
- var updateMove = move + state.transformY;
390
- var h = ((_months$current = months.current) === null || _months$current === void 0 ? void 0 : _months$current.offsetHeight) || 0;
391
- var offsetHeight = ((_monthsPanel$current = monthsPanel.current) === null || _monthsPanel$current === void 0 ? void 0 : _monthsPanel$current.offsetHeight) || 0;
392
- if (type === 'end') {
393
- // 限定滚动距离
394
- if (updateMove > 0) {
395
- updateMove = 0;
396
- }
397
- if (updateMove < 0 && updateMove < -offsetHeight + h) {
398
- updateMove = -offsetHeight + h;
399
- }
400
- if (offsetHeight <= h && state.monthsData.length === 1) {
401
- updateMove = 0;
402
- }
403
- setTransform(updateMove, type, time);
404
- } else {
405
- if (updateMove > 0 && updateMove > 100) {
406
- updateMove = 100;
407
- }
408
- if (updateMove < -offsetHeight + h - 100 && state.monthsData.length > 1) {
409
- updateMove = -offsetHeight + h - 100;
410
- }
411
- if (updateMove < 0 && updateMove < -100 && state.monthsData.length === 1) {
412
- updateMove = -100;
413
- }
414
- setTransform(updateMove);
415
- }
416
- };
417
- var onTouchStart = function onTouchStart(event) {
418
- event.stopPropagation();
419
- var changedTouches = event.changedTouches[0];
420
- state.touchParams.startY = changedTouches.pageY;
421
- state.touchParams.startTime = event.timeStamp || Date.now();
422
- state.transformY = state.scrollDistance;
423
- };
424
- var onTouchMove = function onTouchMove(event) {
425
- event.stopPropagation();
426
- var changedTouches = event.changedTouches[0];
427
- state.touchParams.lastY = changedTouches.pageY;
428
- state.touchParams.lastTime = event.timeStamp || Date.now();
429
- var move = state.touchParams.lastY - state.touchParams.startY;
430
- if (Math.abs(move) < 5) {
431
- return false;
432
- }
433
- setMove(move);
434
- };
435
- var onTouchEnd = function onTouchEnd(event) {
436
- var _months$current2, _monthsPanel$current2;
437
- event.stopPropagation();
438
- var changedTouches = event.changedTouches[0];
439
- state.touchParams.lastY = changedTouches.pageY;
440
- state.touchParams.lastTime = event.timeStamp || Date.now();
441
- var move = state.touchParams.lastY - state.touchParams.startY;
442
- if (Math.abs(move) < 5) {
443
- return false;
444
- }
445
- var updateMove = move + state.transformY;
446
- var h = ((_months$current2 = months.current) === null || _months$current2 === void 0 ? void 0 : _months$current2.offsetHeight) || 0;
447
- var offsetHeight = ((_monthsPanel$current2 = monthsPanel.current) === null || _monthsPanel$current2 === void 0 ? void 0 : _monthsPanel$current2.offsetHeight) || 0;
448
- if (updateMove > 0) {
449
- getMonth(getCurrData('prev'), 'prev');
450
- } else if (updateMove < 0 && updateMove < -offsetHeight + (Math.abs(move) > h ? Math.abs(move) : h) * 5) {
451
- getMonth(getCurrData('next'), 'next');
452
- if (Math.abs(move) >= 300) {
453
- getMonth(getCurrData('next'), 'next');
454
- }
455
- }
456
- var moveTime = state.touchParams.lastTime - state.touchParams.startTime;
457
- if (moveTime <= 300) {
458
- move *= 2;
459
- moveTime += 1000;
460
- setMove(move, 'end', moveTime);
461
- } else {
462
- setMove(move, 'end');
463
- }
464
- };
465
- var initData = function initData() {
466
- // 初始化开始结束数据
467
- state.startData = startDate ? splitDate(startDate) : '';
468
- state.endData = endDate ? splitDate(endDate) : '';
469
- // 初始化当前日期
470
- if (!defaultValue) {
471
- state.currDate = state.isRange ? [Utils.date2Str(new Date()), Utils.getDay(1)] : Utils.date2Str(new Date());
472
- } else {
473
- state.currDate = state.isRange ? _toConsumableArray(defaultValue) : defaultValue;
474
- }
475
- // 日期转化为数组
476
- if (state.isRange && Array.isArray(state.currDate)) {
477
- if (startDate && Utils.compareDate(state.currDate[0], startDate)) {
478
- state.currDate.splice(0, 1, startDate);
479
- }
480
- if (endDate && Utils.compareDate(endDate, state.currDate[1])) {
481
- state.currDate.splice(1, 1, endDate);
482
- }
483
- state.defaultData = [].concat(_toConsumableArray(splitDate(state.currDate[0])), _toConsumableArray(splitDate(state.currDate[1])));
484
- } else {
485
- if (startDate && Utils.compareDate(state.currDate, startDate)) {
486
- state.currDate = startDate;
487
- } else if (endDate && !Utils.compareDate(state.currDate, endDate)) {
488
- state.currDate = endDate;
489
- }
490
- state.defaultData = _toConsumableArray(splitDate(state.currDate));
491
- }
492
- getMonth(state.defaultData, 'next');
493
- setYearMonthTitle(state.monthsData[0].title);
494
- var i = 1;
495
- do {
496
- getMonth(getCurrData('next'), 'next');
497
- } while (i++ < 4);
498
- if (state.isRange) {
499
- chooseDay({
500
- day: state.defaultData[2],
501
- type: 'curr'
502
- }, state.monthsData[0], true);
503
- chooseDay({
504
- day: state.defaultData[5],
505
- type: 'curr'
506
- }, state.monthsData[0], true, true);
507
- } else {
508
- chooseDay({
509
- day: state.defaultData[2],
510
- type: 'curr'
511
- }, state.monthsData[0], true);
512
- }
513
- };
514
- useEffect(function () {
515
- initData();
516
- }, []);
517
- return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
518
- className: classes
519
- }, React__default.createElement("div", {
520
- className: headerClasses
521
- }, poppable ? React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
522
- className: "calendar-title"
523
- }, locale.calendaritem.title), React__default.createElement("div", {
524
- className: "calendar-curr-month"
525
- }, yearMonthTitle)) : '', React__default.createElement("div", {
526
- className: "calendar-weeks",
527
- ref: weeksPanel
528
- }, weeks.map(function (item) {
529
- return React__default.createElement("div", {
530
- className: "calendar-week-item",
531
- key: item
532
- }, item);
533
- }))), React__default.createElement("div", {
534
- className: "nut-calendar-content",
535
- onTouchStart: onTouchStart,
536
- onTouchMove: onTouchMove,
537
- onTouchEnd: onTouchEnd,
538
- ref: months
539
- }, React__default.createElement("div", {
540
- className: "calendar-months-panel",
541
- ref: monthsPanel
542
- }, React__default.createElement("div", {
543
- className: "calendar-loading-tip"
544
- }, !unLoadPrev ? locale.calendaritem.loadPreviousMonth : locale.calendaritem.noEarlierMonth), monthsData.map(function (month, key) {
545
- return React__default.createElement("div", {
546
- className: "calendar-month",
547
- key: key
548
- }, React__default.createElement("div", {
549
- className: "calendar-month-title"
550
- }, month.title), React__default.createElement("div", {
551
- className: "calendar-month-con"
552
- }, React__default.createElement("div", {
553
- className: monthitemclasses
554
- }, month.monthData && month.monthData.map(function (day, index) {
555
- return React__default.createElement("div", {
556
- className: ['calendar-month-day', getClass(day, month)].join(' '),
557
- key: index,
558
- onClick: function onClick() {
559
- chooseDay(day, month);
560
- }
561
- }, React__default.createElement("div", {
562
- className: "calendar-day"
563
- }, day.type === 'curr' ? day.day : ''), isCurrDay(month, day.day) ? React__default.createElement("div", {
564
- className: "calendar-curr-tip-curr"
565
- }, locale.calendaritem.today) : '', isStartTip(day, month) ? React__default.createElement("div", {
566
- className: "calendar-day-tip"
567
- }, locale.calendaritem.start) : '', isEndTip(day, month) ? React__default.createElement("div", {
568
- className: "calendar-day-tip"
569
- }, locale.calendaritem.end) : '');
570
- }))));
571
- }))), poppable && !isAutoBackFill ? React__default.createElement("div", {
572
- className: "nut-calendar-footer"
573
- }, React__default.createElement("div", {
574
- className: "calendar-confirm-btn",
575
- onClick: confirm
576
- }, locale.confirm)) : ''));
577
- };
578
- CalendarItem.defaultProps = defaultProps;
579
- CalendarItem.displayName = 'NutCalendarItem';
580
- export { CalendarItem as C, Utils as U };
@@ -1,61 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["className", "style", "imgUrl", "title", "price", "vipPrice", "shopDesc", "delivery", "shopName", "shopTagTpl", "originTpl", "prolistTpl", "footerTpl"];
4
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
- import React__default from 'react';
7
- import { P as Price } from './price.taro-8801462e.js';
8
- import { T as Tag } from './tag.taro-bd900990.js';
9
- import { c as cn } from './bem-893ad28d.js';
10
- var defaultProps = {};
11
- var Card = function Card(props) {
12
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
13
- className = _defaultProps$props.className,
14
- style = _defaultProps$props.style,
15
- imgUrl = _defaultProps$props.imgUrl,
16
- title = _defaultProps$props.title,
17
- price = _defaultProps$props.price,
18
- vipPrice = _defaultProps$props.vipPrice,
19
- shopDesc = _defaultProps$props.shopDesc,
20
- delivery = _defaultProps$props.delivery,
21
- shopName = _defaultProps$props.shopName,
22
- shopTagTpl = _defaultProps$props.shopTagTpl,
23
- originTpl = _defaultProps$props.originTpl,
24
- prolistTpl = _defaultProps$props.prolistTpl,
25
- footerTpl = _defaultProps$props.footerTpl,
26
- rest = _objectWithoutProperties(_defaultProps$props, _excluded);
27
- var b = cn('card');
28
- return React__default.createElement("div", _objectSpread({
29
- className: "".concat(b(), " ").concat(className),
30
- style: style
31
- }, rest), React__default.createElement("div", {
32
- className: b('left')
33
- }, React__default.createElement("img", {
34
- src: imgUrl,
35
- alt: ""
36
- })), React__default.createElement("div", {
37
- className: b('right')
38
- }, React__default.createElement("div", {
39
- className: b('right__title')
40
- }, title), prolistTpl, React__default.createElement("div", {
41
- className: b('right__price')
42
- }, React__default.createElement(Price, {
43
- price: price
44
- }), originTpl || React__default.createElement(Price, {
45
- className: b('right__price__origin'),
46
- price: vipPrice
47
- })), React__default.createElement("div", {
48
- className: b('right__other')
49
- }, shopTagTpl || React__default.createElement(React__default.Fragment, null, React__default.createElement(Tag, {
50
- type: "danger"
51
- }, shopDesc), React__default.createElement(Tag, {
52
- plain: true
53
- }, delivery))), React__default.createElement("div", {
54
- className: b('right__shop')
55
- }, React__default.createElement("div", {
56
- className: b('right__shop__name')
57
- }, shopName), footerTpl)));
58
- };
59
- Card.defaultProps = defaultProps;
60
- Card.displayName = 'NutCard';
61
- export { Card as C };