@trionesdev/antd-mobile-react 0.0.2-beta.2 → 0.0.2-beta.20

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 (262) hide show
  1. package/LICENSE +21 -21
  2. package/dist/ActionSheet/ActionSheet.d.ts +25 -0
  3. package/dist/ActionSheet/ActionSheet.js +77 -0
  4. package/dist/ActionSheet/index.d.ts +1 -1
  5. package/dist/ActionSheet/index.js +1 -1
  6. package/dist/ActionSheet/style.scss +52 -0
  7. package/dist/Avatar/demo/base.js +2 -2
  8. package/dist/Avatar/demo/style.scss +6 -6
  9. package/dist/Badge/demo/base.js +2 -2
  10. package/dist/Badge/demo/base.scss +6 -6
  11. package/dist/Button/button.d.ts +2 -1
  12. package/dist/Button/button.js +1 -1
  13. package/dist/Button/demo/base.js +2 -2
  14. package/dist/Button/style.scss +234 -232
  15. package/dist/Calendar/calendar-grid.d.ts +10 -9
  16. package/dist/Calendar/calendar-grid.js +41 -64
  17. package/dist/Calendar/calendar-header.d.ts +3 -2
  18. package/dist/Calendar/calendar-header.js +6 -6
  19. package/dist/Calendar/calendar-range.d.ts +4 -3
  20. package/dist/Calendar/calendar-range.js +12 -11
  21. package/dist/Calendar/calendar.d.ts +5 -4
  22. package/dist/Calendar/calendar.js +23 -14
  23. package/dist/Calendar/style.scss +85 -85
  24. package/dist/Calendar/touchable-calendar-grid.d.ts +6 -5
  25. package/dist/Calendar/touchable-calendar-grid.js +67 -59
  26. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.d.ts +3 -2
  27. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.js +14 -28
  28. package/dist/CalendarDatetimePicker/DateTimeSwitch.d.ts +3 -2
  29. package/dist/CalendarDatetimePicker/DateTimeSwitch.js +4 -3
  30. package/dist/CalendarDatetimePicker/demo/base.js +1 -1
  31. package/dist/CalendarDatetimePicker/style.scss +54 -54
  32. package/dist/CalendarDatetimePicker/types.d.ts +1 -1
  33. package/dist/CalendarDatetimePicker/types.js +1 -1
  34. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.d.ts +11 -0
  35. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.js +61 -0
  36. package/dist/{Mask → CalendarDatetimePickerCell}/demo/base.js +9 -15
  37. package/dist/CalendarDatetimePickerCell/index.d.ts +3 -0
  38. package/dist/CalendarDatetimePickerCell/index.js +2 -0
  39. package/dist/CalendarDatetimePickerCell/style.scss +10 -0
  40. package/dist/CalendarDatetimePickerCell/types.d.ts +1 -0
  41. package/dist/CalendarDatetimePickerCell/types.js +1 -0
  42. package/dist/CalendarPicker/calendar-picker.js +2 -2
  43. package/dist/CalendarPicker/calendar-range-picker.d.ts +4 -4
  44. package/dist/CalendarPicker/calendar-range-picker.js +11 -9
  45. package/dist/CalendarPicker/demo/base.js +6 -6
  46. package/dist/CalendarPicker/index.d.ts +2 -2
  47. package/dist/CalendarPicker/index.js +3 -3
  48. package/dist/CalendarPicker/style.scss +31 -31
  49. package/dist/CalendarPicker/types.d.ts +8 -7
  50. package/dist/CalendarPickerCell/CalendarPickerCell.d.ts +11 -0
  51. package/dist/CalendarPickerCell/CalendarPickerCell.js +54 -0
  52. package/dist/CalendarPickerCell/CalendarRangePickerCell.d.ts +11 -0
  53. package/dist/CalendarPickerCell/CalendarRangePickerCell.js +56 -0
  54. package/dist/CalendarPickerCell/demo/base.d.ts +3 -0
  55. package/dist/CalendarPickerCell/demo/base.js +31 -0
  56. package/dist/CalendarPickerCell/index.d.ts +8 -0
  57. package/dist/CalendarPickerCell/index.js +5 -0
  58. package/dist/Card/demo/base.js +2 -2
  59. package/dist/Card/demo/base.scss +18 -18
  60. package/dist/CascaderPicker/cascader-picker.d.ts +27 -0
  61. package/dist/CascaderPicker/cascader-picker.js +90 -0
  62. package/dist/CascaderPicker/demo/base.js +1 -4
  63. package/dist/CascaderPicker/index.d.ts +1 -1
  64. package/dist/CascaderPicker/index.js +1 -1
  65. package/dist/CascaderPicker/style.scss +45 -0
  66. package/dist/CascaderPickerCell/CascaderPickerCell.d.ts +21 -0
  67. package/dist/CascaderPickerCell/CascaderPickerCell.js +70 -0
  68. package/dist/CascaderPickerCell/demo/base.js +71 -0
  69. package/dist/CascaderPickerCell/index.d.ts +3 -0
  70. package/dist/CascaderPickerCell/index.js +2 -0
  71. package/dist/CascaderPickerCell/style.scss +24 -0
  72. package/dist/Cell/demo/base.js +41 -2
  73. package/dist/Checkbox/demo/base.js +11 -6
  74. package/dist/Checkbox/demo/disabled.js +2 -1
  75. package/dist/ConfigProvider/demo/base.js +2 -2
  76. package/dist/DemoBlock/index.d.ts +6 -0
  77. package/dist/DemoBlock/index.js +9 -2
  78. package/dist/DemoBlock/index.scss +20 -20
  79. package/dist/DemoDescription/index.scss +3 -3
  80. package/dist/Divider/demo/base.js +2 -2
  81. package/dist/Ellipsis/demo/base.js +2 -2
  82. package/dist/Empty/demo/base.js +2 -2
  83. package/dist/ErrorBlock/demo/base.js +2 -2
  84. package/dist/FetchPicker/FetchPicker.d.ts +113 -0
  85. package/dist/FetchPicker/FetchPicker.js +319 -0
  86. package/dist/FetchPicker/index.d.ts +4 -0
  87. package/dist/FetchPicker/index.js +3 -0
  88. package/dist/FetchPicker/styles.scss +118 -0
  89. package/dist/FloatButton/FloatButton.d.ts +21 -0
  90. package/dist/FloatButton/FloatButton.js +66 -0
  91. package/dist/FloatButton/FloatButtonGroup.d.ts +21 -0
  92. package/dist/FloatButton/FloatButtonGroup.js +120 -0
  93. package/dist/FloatButton/context.d.ts +13 -0
  94. package/dist/FloatButton/context.js +2 -0
  95. package/dist/FloatButton/demo/base.d.ts +3 -0
  96. package/dist/FloatButton/demo/base.js +10 -0
  97. package/dist/FloatButton/demo/group.d.ts +3 -0
  98. package/dist/FloatButton/demo/group.js +20 -0
  99. package/dist/FloatButton/demo/square.d.ts +3 -0
  100. package/dist/FloatButton/demo/square.js +12 -0
  101. package/dist/FloatButton/index.d.ts +10 -0
  102. package/dist/FloatButton/index.js +5 -0
  103. package/dist/FloatButton/style.scss +123 -0
  104. package/dist/Footer/demo/base.js +2 -2
  105. package/dist/Form/FormItem/form-item-content.d.ts +17 -0
  106. package/dist/Form/FormItem/form-item-content.js +39 -0
  107. package/dist/Form/FormItem/form-item-label.d.ts +13 -0
  108. package/dist/Form/FormItem/form-item-label.js +29 -0
  109. package/dist/Form/FormItem/form-item.d.ts +51 -0
  110. package/dist/Form/FormItem/form-item.js +74 -0
  111. package/dist/Form/FormItem/index.d.ts +5 -0
  112. package/dist/Form/FormItem/index.js +3 -0
  113. package/dist/Form/demo/input.js +7 -3
  114. package/dist/Form/demo/vertical.d.ts +3 -0
  115. package/dist/Form/demo/vertical.js +45 -0
  116. package/dist/Form/index.d.ts +9 -2
  117. package/dist/Form/index.js +5 -1
  118. package/dist/Form/style.scss +106 -0
  119. package/dist/FormCell/index.d.ts +3 -0
  120. package/dist/FormCell/index.js +2 -0
  121. package/dist/Grid/demo/base.js +2 -2
  122. package/dist/Grid/demo/base.scss +7 -7
  123. package/dist/Icon/demo/base.js +2 -2
  124. package/dist/Image/demo/base.js +2 -2
  125. package/dist/Image/demo/base.scss +4 -4
  126. package/dist/Image/style.scss +30 -30
  127. package/dist/ImagesPreview/ImagesPreview.js +2 -2
  128. package/dist/ImagesPreview/style.scss +34 -34
  129. package/dist/ImagesWall/CameraModal.js +2 -2
  130. package/dist/ImagesWall/style.scss +70 -70
  131. package/dist/Input/base-input.d.ts +13 -0
  132. package/dist/Input/base-input.js +41 -0
  133. package/dist/Input/demo/base.js +115 -13
  134. package/dist/Input/index.d.ts +14 -2
  135. package/dist/Input/index.js +11 -1
  136. package/dist/Input/index.scss +240 -0
  137. package/dist/Input/input-affix-wrapper.d.ts +13 -0
  138. package/dist/Input/input-affix-wrapper.js +37 -0
  139. package/dist/Input/input-opt.d.ts +16 -0
  140. package/dist/Input/input-opt.js +87 -0
  141. package/dist/Input/input-password.d.ts +7 -0
  142. package/dist/Input/input-password.js +48 -0
  143. package/dist/Input/input.d.ts +20 -0
  144. package/dist/Input/input.js +66 -0
  145. package/dist/Input/textarea.d.ts +15 -0
  146. package/dist/Input/textarea.js +51 -0
  147. package/dist/Input/types.d.ts +3 -0
  148. package/dist/Input/types.js +2 -0
  149. package/dist/Loading/DotLoading.d.ts +1 -0
  150. package/dist/Loading/DotLoading.js +1 -0
  151. package/dist/Loading/SpinLoading.d.ts +1 -0
  152. package/dist/Loading/SpinLoading.js +1 -0
  153. package/dist/Loading/demo/base.d.ts +3 -0
  154. package/dist/{SpinLoading → Loading}/demo/base.js +8 -2
  155. package/dist/Loading/demo/dot-loading.d.ts +3 -0
  156. package/dist/Loading/demo/dot-loading.js +25 -0
  157. package/dist/Loading/index.d.ts +5 -0
  158. package/dist/Loading/index.js +3 -0
  159. package/dist/NavBar/demo/base.scss +5 -5
  160. package/dist/NoticeBar/demo/base.js +2 -2
  161. package/dist/Overlay/Overlay.d.ts +16 -0
  162. package/dist/Overlay/Overlay.js +117 -0
  163. package/dist/Overlay/demo/base.d.ts +3 -0
  164. package/dist/Overlay/demo/base.js +27 -0
  165. package/dist/Overlay/index.d.ts +4 -0
  166. package/dist/Overlay/index.js +3 -0
  167. package/dist/Overlay/style.scss +20 -0
  168. package/dist/PageIndicator/demo/base.js +2 -2
  169. package/dist/Picker/index.d.ts +1 -1
  170. package/dist/Picker/index.js +1 -1
  171. package/dist/Picker/picker.d.ts +20 -0
  172. package/dist/Picker/picker.js +94 -0
  173. package/dist/Picker/style.scss +44 -0
  174. package/dist/PickerView/index.d.ts +2 -1
  175. package/dist/PickerView/index.js +1 -1
  176. package/dist/PickerView/picker-view-column-item.d.ts +7 -0
  177. package/dist/PickerView/picker-view-column-item.js +11 -0
  178. package/dist/PickerView/picker-view-column.d.ts +10 -0
  179. package/dist/PickerView/picker-view-column.js +117 -0
  180. package/dist/PickerView/picker-view.d.ts +12 -0
  181. package/dist/PickerView/picker-view.js +60 -0
  182. package/dist/PickerView/style.scss +72 -0
  183. package/dist/PickerView/types.d.ts +4 -0
  184. package/dist/PickerView/types.js +1 -0
  185. package/dist/Popup/demo/base.js +109 -27
  186. package/dist/Popup/index.d.ts +2 -1
  187. package/dist/Popup/index.js +2 -1
  188. package/dist/Popup/popup.d.ts +31 -0
  189. package/dist/Popup/popup.js +87 -0
  190. package/dist/Popup/style.scss +129 -0
  191. package/dist/Progress/index.d.ts +1 -1
  192. package/dist/Progress/index.js +1 -1
  193. package/dist/Radio/demo/base.js +2 -2
  194. package/dist/Radio/demo/base.scss +4 -4
  195. package/dist/Result/demo/base.js +2 -2
  196. package/dist/SafeArea/demo/base.scss +18 -18
  197. package/dist/ScrollView/index.d.ts +2 -1
  198. package/dist/ScrollView/index.js +1 -1
  199. package/dist/ScrollView/scroll-view.d.ts +4 -0
  200. package/dist/ScrollView/scroll-view.js +55 -0
  201. package/dist/ScrollView/style.scss +19 -0
  202. package/dist/ScrollView/types.d.ts +26 -0
  203. package/dist/ScrollView/types.js +1 -0
  204. package/dist/Segmented/demo/base.d.ts +3 -0
  205. package/dist/Segmented/demo/base.js +33 -0
  206. package/dist/Segmented/index.d.ts +3 -0
  207. package/dist/Segmented/index.js +2 -0
  208. package/dist/SideBar/index.d.ts +1 -1
  209. package/dist/SideBar/side-bar.js +6 -6
  210. package/dist/SideBar/style.scss +85 -85
  211. package/dist/Skeleton/demo/base.d.ts +3 -0
  212. package/dist/Skeleton/demo/base.js +8 -0
  213. package/dist/Skeleton/index.d.ts +3 -0
  214. package/dist/Skeleton/index.js +2 -0
  215. package/dist/Space/demo/base.js +2 -2
  216. package/dist/Stepper/demo/base.d.ts +3 -0
  217. package/dist/Stepper/demo/base.js +23 -0
  218. package/dist/Stepper/index.d.ts +3 -0
  219. package/dist/Stepper/index.js +2 -0
  220. package/dist/Swiper/style.scss +54 -54
  221. package/dist/Switch/demo/base.js +2 -2
  222. package/dist/TabBar/demo/base.js +2 -2
  223. package/dist/Tag/demo/base.js +2 -2
  224. package/dist/Tag/demo/style.scss +8 -8
  225. package/dist/Toast/style.scss +63 -63
  226. package/dist/Toast/toast-modal.js +4 -4
  227. package/dist/VerificationCodeInput/demo/base.js +2 -2
  228. package/dist/VerificationCodeInput/index.d.ts +2 -2
  229. package/dist/VerificationCodeInput/index.js +1 -1
  230. package/dist/VerificationCodeInput/style.scss +20 -0
  231. package/dist/VerificationCodeInput/verification-code-input.d.ts +24 -0
  232. package/dist/VerificationCodeInput/verification-code-input.js +99 -0
  233. package/dist/WaterMark/demo/demo1.js +2 -2
  234. package/dist/WaterMark/demo/demo1.scss +6 -6
  235. package/dist/WaterMark/demo/demo2.js +2 -2
  236. package/dist/index.d.ts +33 -19
  237. package/dist/index.js +9 -2
  238. package/dist/style/variable.scss +1 -1
  239. package/dist/types.d.ts +0 -8
  240. package/dist/types.js +0 -1
  241. package/dist/utils/dayjs.d.ts +4 -0
  242. package/dist/utils/dayjs.js +42 -0
  243. package/dist/utils/type.js +36 -36
  244. package/dist/utils/use-isomorphic-update-layout-effect.d.ts +1 -1
  245. package/dist/utils/with-default-props.js +4 -4
  246. package/package.json +11 -16
  247. package/readme.md +43 -43
  248. package/dist/Mask/index.d.ts +0 -3
  249. package/dist/Mask/index.js +0 -2
  250. package/dist/Progress/Progress.d.ts +0 -37
  251. package/dist/Progress/Progress.js +0 -52
  252. package/dist/Progress/ProgressCircle.d.ts +0 -17
  253. package/dist/Progress/ProgressCircle.js +0 -148
  254. package/dist/Progress/ProgressLine.d.ts +0 -15
  255. package/dist/Progress/ProgressLine.js +0 -87
  256. package/dist/Progress/style.scss +0 -33
  257. package/dist/Progress/types.d.ts +0 -4
  258. package/dist/Progress/types.js +0 -2
  259. package/dist/SpinLoading/index.d.ts +0 -3
  260. package/dist/SpinLoading/index.js +0 -2
  261. /package/dist/{Mask → CalendarDatetimePickerCell}/demo/base.d.ts +0 -0
  262. /package/dist/{SpinLoading → CascaderPickerCell}/demo/base.d.ts +0 -0
@@ -1,8 +1,4 @@
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
3
  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."); }
8
4
  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); }
@@ -16,41 +12,32 @@ import classNames from 'classnames';
16
12
  import { isEmpty } from 'lodash-es';
17
13
  import React, { forwardRef, memo, useEffect, useMemo, useState } from 'react';
18
14
  import "./style.scss";
15
+ import dayjs from "dayjs";
16
+ import { isSame, toDayjsArray } from "../utils/dayjs";
19
17
  var calendarCls = 'triones-antm-calendar';
20
18
  var CalendarCell = /*#__PURE__*/memo(function (_ref) {
21
- var _ref$mouth = _ref.mouth,
22
- mouth = _ref$mouth === void 0 ? new Date() : _ref$mouth,
19
+ var _ref$month = _ref.month,
20
+ month = _ref$month === void 0 ? dayjs() : _ref$month,
23
21
  _ref$date = _ref.date,
24
- date = _ref$date === void 0 ? new Date() : _ref$date,
22
+ date = _ref$date === void 0 ? dayjs() : _ref$date,
25
23
  value = _ref.value,
26
24
  range = _ref.range,
27
25
  onSelect = _ref.onSelect;
28
26
  var disabled = useMemo(function () {
29
- return date.getMonth() !== mouth.getMonth();
30
- }, [date, mouth]);
27
+ return !isSame(date, month, 'month');
28
+ }, [date, month]);
31
29
  var selected = useMemo(function () {
32
30
  if (disabled || isEmpty(value)) {
33
31
  return false;
34
32
  }
35
- if (value !== null && value !== void 0 && value[0]) {
36
- var _value$;
37
- value === null || value === void 0 || (_value$ = value[0]) === null || _value$ === void 0 || _value$.setHours(0, 0, 0, 0);
38
- }
39
- if (value !== null && value !== void 0 && value[1]) {
40
- var _value$2;
41
- value === null || value === void 0 || (_value$2 = value[1]) === null || _value$2 === void 0 || _value$2.setHours(0, 0, 0, 0);
42
- }
43
- date.setHours(0, 0, 0, 0);
44
33
  if (range) {
45
34
  var startDate = value === null || value === void 0 ? void 0 : value[0];
46
35
  var endDate = value === null || value === void 0 ? void 0 : value[1];
47
- console.log('value', value);
48
- return date.getTime() === (startDate === null || startDate === void 0 ? void 0 : startDate.getTime()) || date.getTime() === (endDate === null || endDate === void 0 ? void 0 : endDate.getTime());
36
+ return isSame(date, startDate, 'date') || isSame(date, endDate, 'date');
49
37
  } else {
50
- var _value$3;
51
- return date.getTime() === (value === null || value === void 0 || (_value$3 = value[0]) === null || _value$3 === void 0 ? void 0 : _value$3.getTime());
38
+ return isSame(date, value === null || value === void 0 ? void 0 : value[0], 'date');
52
39
  }
53
- }, [mouth, date, value]);
40
+ }, [month, date, value]);
54
41
  var selectedRange = useMemo(function () {
55
42
  if (disabled || !range) {
56
43
  return false;
@@ -60,11 +47,8 @@ var CalendarCell = /*#__PURE__*/memo(function (_ref) {
60
47
  if (!startDate || !endDate) {
61
48
  return false;
62
49
  }
63
- date.setHours(0, 0, 0, 0);
64
- startDate.setHours(0, 0, 0, 0);
65
- endDate.setHours(0, 0, 0, 0);
66
- return date.getTime() > startDate.getTime() && date.getTime() < endDate.getTime();
67
- }, [mouth, date, value]);
50
+ return dayjs(date).isAfter(startDate, 'date') && dayjs(date).isBefore(endDate, 'date');
51
+ }, [month, date, value]);
68
52
  return /*#__PURE__*/React.createElement("div", {
69
53
  className: classNames("".concat(calendarCls, "-cell"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(calendarCls, "-cell-disabled"), disabled), "".concat(calendarCls, "-cell-selected"), selected), "".concat(calendarCls, "-cell-selected-range"), selectedRange))
70
54
  // style={{ width: size, height: size }}
@@ -74,33 +58,32 @@ var CalendarCell = /*#__PURE__*/memo(function (_ref) {
74
58
  }
75
59
  }, /*#__PURE__*/React.createElement("div", {
76
60
  className: classNames("".concat(calendarCls, "-cell-date"))
77
- }, date.getDate()), date.getDate() === 1 && /*#__PURE__*/React.createElement("div", {
61
+ }, date.date()), date.date() === 1 && /*#__PURE__*/React.createElement("div", {
78
62
  className: classNames("".concat(calendarCls, "-cell-mouth"))
79
- }, "".concat(date.getMonth() + 1, "\u6708")));
63
+ }, "".concat(date.month() + 1, "\u6708")));
80
64
  });
81
65
  export var CalendarGrid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref2, ref) {
82
- var _ref3;
83
- var _ref2$mouth = _ref2.mouth,
84
- mouth = _ref2$mouth === void 0 ? new Date() : _ref2$mouth,
66
+ var _ref3, _toDayjsArray;
67
+ var _ref2$month = _ref2.month,
68
+ month = _ref2$month === void 0 ? dayjs() : _ref2$month,
85
69
  value = _ref2.value,
86
70
  defaultValue = _ref2.defaultValue,
87
71
  _ref2$range = _ref2.range,
88
72
  range = _ref2$range === void 0 ? false : _ref2$range,
89
73
  onChange = _ref2.onChange,
90
74
  onSelect = _ref2.onSelect;
91
- var _useState = useState((_ref3 = value !== null && value !== void 0 ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : []),
75
+ var _useState = useState((_ref3 = (_toDayjsArray = toDayjsArray(value)) !== null && _toDayjsArray !== void 0 ? _toDayjsArray : toDayjsArray(defaultValue)) !== null && _ref3 !== void 0 ? _ref3 : []),
92
76
  _useState2 = _slicedToArray(_useState, 2),
93
77
  innerValue = _useState2[0],
94
78
  setInnerValue = _useState2[1];
95
79
  var handleSelect = function handleSelect(date) {
96
- date.setHours(0, 0, 0, 0);
97
80
  var _value = innerValue;
98
81
  if (range) {
99
82
  if (!_value[0]) {
100
83
  _value = [date];
101
84
  } else if (!_value[1]) {
102
85
  var startDate = _value[0];
103
- if (date.getTime() < startDate.getTime()) {
86
+ if (dayjs(date).isBefore(startDate, 'date')) {
104
87
  _value = [date, startDate];
105
88
  } else {
106
89
  _value = [startDate, date];
@@ -116,35 +99,29 @@ export var CalendarGrid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_
116
99
  onChange === null || onChange === void 0 || onChange(_value);
117
100
  };
118
101
  var cells = useMemo(function () {
119
- var firstDate = new Date(mouth.getFullYear(), mouth.getMonth(), 1);
120
- var lastDate = new Date(mouth.getFullYear(), mouth.getMonth() + 1, 0);
121
- var beforeDays = Array.from({
122
- length: firstDate.getDay()
123
- }).map(function (_, index) {
124
- var date = new Date(firstDate);
125
- date.setDate(firstDate.getDate() - (firstDate.getDay() - index));
126
- return date;
127
- });
128
- var afterDays = Array.from({
129
- length: 6 - lastDate.getDay()
130
- }).map(function (_, index) {
131
- var date = new Date(lastDate);
132
- date.setDate(lastDate.getDate() + index + 1);
133
- return date;
102
+ var firstDate = dayjs(month).startOf('month');
103
+
104
+ // 固定生成42天的日期网格(6行7列)
105
+ var startDate = firstDate.subtract(firstDate.day(), 'day');
106
+ var cells = Array.from({
107
+ length: 42
108
+ }, function (_, index) {
109
+ return startDate.add(index, 'day');
134
110
  });
135
- var mouthDays = Array.from({
136
- length: lastDate.getDate()
137
- }).map(function (_, index) {
138
- var date = new Date(firstDate);
139
- date.setDate(date.getDate() + index);
140
- return date;
141
- });
142
- return [].concat(_toConsumableArray(beforeDays), _toConsumableArray(mouthDays), _toConsumableArray(afterDays));
143
- }, [mouth]);
111
+ return cells;
112
+ }, [month]);
144
113
  useEffect(function () {
145
114
  if (value !== undefined) {
146
- if (value !== innerValue) {
147
- setInnerValue(value);
115
+ if (range) {
116
+ if (!isSame(value[0], innerValue[0], 'day') || !isSame(value[1], innerValue[1], 'day')) {
117
+ var _toDayjsArray2;
118
+ setInnerValue((_toDayjsArray2 = toDayjsArray(value)) !== null && _toDayjsArray2 !== void 0 ? _toDayjsArray2 : []);
119
+ }
120
+ } else {
121
+ if (!isSame(value[0], innerValue[0], 'day')) {
122
+ var _toDayjsArray3;
123
+ setInnerValue((_toDayjsArray3 = toDayjsArray(value)) !== null && _toDayjsArray3 !== void 0 ? _toDayjsArray3 : []);
124
+ }
148
125
  }
149
126
  }
150
127
  }, [value]);
@@ -154,9 +131,9 @@ export var CalendarGrid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_
154
131
  }, cells.map(function (item, index) {
155
132
  return /*#__PURE__*/React.createElement(CalendarCell, {
156
133
  key: index,
157
- mouth: mouth,
134
+ month: month,
158
135
  date: item,
159
- value: innerValue,
136
+ value: toDayjsArray(innerValue),
160
137
  range: range,
161
138
  onSelect: handleSelect
162
139
  });
@@ -1,7 +1,8 @@
1
1
  import { FC } from "react";
2
+ import dayjs from "dayjs";
2
3
  type CalendarHeaderProps = {
3
- mouth: Date;
4
- onChange: (mouth: Date) => void;
4
+ month: dayjs.Dayjs;
5
+ onChange: (mouth: dayjs.Dayjs) => void;
5
6
  };
6
7
  export declare const CalendarHeader: FC<CalendarHeaderProps>;
7
8
  export {};
@@ -3,7 +3,7 @@ import classNames from "classnames";
3
3
  import ConfigProvider from "../ConfigProvider";
4
4
  var calendarCls = 'triones-antm-calendar';
5
5
  export var CalendarHeader = function CalendarHeader(_ref) {
6
- var mouth = _ref.mouth,
6
+ var month = _ref.month,
7
7
  onChange = _ref.onChange;
8
8
  var _ConfigProvider$useCo = ConfigProvider.useConfig(),
9
9
  locale = _ConfigProvider$useCo.locale;
@@ -12,24 +12,24 @@ export var CalendarHeader = function CalendarHeader(_ref) {
12
12
  }, /*#__PURE__*/React.createElement("div", {
13
13
  className: classNames("".concat(calendarCls, "-header-button")),
14
14
  onClick: function onClick() {
15
- onChange(new Date(mouth.getFullYear() - 1, mouth.getMonth(), 1));
15
+ onChange(month.subtract(1, 'year'));
16
16
  }
17
17
  }, "<<"), /*#__PURE__*/React.createElement("div", {
18
18
  className: classNames("".concat(calendarCls, "-header-button")),
19
19
  onClick: function onClick() {
20
- onChange(new Date(mouth.getFullYear(), mouth.getMonth() - 1, 1));
20
+ onChange(month.subtract(1, 'month'));
21
21
  }
22
22
  }, "<"), /*#__PURE__*/React.createElement("div", {
23
23
  className: classNames("".concat(calendarCls, "-header-title"))
24
- }, "".concat(mouth.getFullYear(), "\u5E74").concat(mouth.getMonth() + 1, "\u6708")), /*#__PURE__*/React.createElement("div", {
24
+ }, "".concat(month.year(), "\u5E74").concat(month.month() + 1, "\u6708")), /*#__PURE__*/React.createElement("div", {
25
25
  className: classNames("".concat(calendarCls, "-header-button")),
26
26
  onClick: function onClick() {
27
- onChange(new Date(mouth.getFullYear(), mouth.getMonth() + 1, 1));
27
+ onChange(month.add(1, 'month'));
28
28
  }
29
29
  }, ">"), /*#__PURE__*/React.createElement("div", {
30
30
  className: classNames("".concat(calendarCls, "-header-button")),
31
31
  onClick: function onClick() {
32
- onChange(new Date(mouth.getFullYear() + 1, mouth.getMonth(), 1));
32
+ onChange(month.add(1, 'year'));
33
33
  }
34
34
  }, ">>")), /*#__PURE__*/React.createElement("div", {
35
35
  className: classNames("".concat(calendarCls, "-week"))
@@ -1,9 +1,10 @@
1
1
  import { FC } from 'react';
2
2
  import './style.scss';
3
+ import dayjs from "dayjs";
3
4
  type CalendarProps = {
4
- mouth?: Date;
5
- value?: Date[];
6
- onChange?: (date: Date[]) => void;
5
+ month?: dayjs.Dayjs | Date;
6
+ value?: (dayjs.Dayjs | Date)[];
7
+ onChange?: (date: dayjs.Dayjs[]) => void;
7
8
  slideable?: boolean;
8
9
  };
9
10
  export declare const CalendarRange: FC<CalendarProps>;
@@ -5,40 +5,41 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
5
5
  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; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import classNames from 'classnames';
8
- import { isEqual } from 'lodash-es';
9
8
  import React, { memo, useEffect, useRef, useState } from 'react';
10
9
  import { CalendarGrid } from "./calendar-grid";
11
10
  import { CalendarHeader } from "./calendar-header";
12
11
  import "./style.scss";
13
12
  import { TouchableCalendarGrid } from "./touchable-calendar-grid";
13
+ import dayjs from "dayjs";
14
+ import { isSameArray, toDayjsArray } from "../utils/dayjs";
14
15
  var calendarCls = 'triones-antm-calendar';
15
16
  export var CalendarRange = /*#__PURE__*/memo(function (_ref) {
16
- var _ref2, _ref3;
17
- var _ref$mouth = _ref.mouth,
18
- mouth = _ref$mouth === void 0 ? new Date() : _ref$mouth,
17
+ var _ref2, _toDayjsArray, _ref3;
18
+ var _ref$month = _ref.month,
19
+ month = _ref$month === void 0 ? dayjs() : _ref$month,
19
20
  value = _ref.value,
20
21
  _onChange = _ref.onChange,
21
22
  slideable = _ref.slideable;
22
- var _useState = useState(mouth),
23
+ var _useState = useState(dayjs(month)),
23
24
  _useState2 = _slicedToArray(_useState, 2),
24
25
  currentMouth = _useState2[0],
25
26
  setCurrentMouth = _useState2[1];
26
27
  var valueRef = useRef();
27
28
  useEffect(function () {
28
29
  if (value !== undefined) {
29
- if (!isEqual(value, valueRef.current)) {
30
- valueRef.current = value;
30
+ if (!isSameArray(value, valueRef.current, 'day')) {
31
+ valueRef.current = toDayjsArray(value);
31
32
  }
32
33
  }
33
34
  }, [value]);
34
35
  return /*#__PURE__*/React.createElement("div", {
35
36
  className: classNames("".concat(calendarCls))
36
37
  }, /*#__PURE__*/React.createElement(CalendarHeader, {
37
- mouth: currentMouth,
38
+ month: currentMouth,
38
39
  onChange: setCurrentMouth
39
40
  }), slideable ? /*#__PURE__*/React.createElement(TouchableCalendarGrid, {
40
- mouth: currentMouth,
41
- value: (_ref2 = value !== null && value !== void 0 ? value : valueRef.current) !== null && _ref2 !== void 0 ? _ref2 : [],
41
+ month: currentMouth,
42
+ value: (_ref2 = (_toDayjsArray = toDayjsArray(value)) !== null && _toDayjsArray !== void 0 ? _toDayjsArray : valueRef.current) !== null && _ref2 !== void 0 ? _ref2 : [],
42
43
  onMouthChange: setCurrentMouth,
43
44
  onChange: function onChange(value) {
44
45
  valueRef.current = value;
@@ -46,7 +47,7 @@ export var CalendarRange = /*#__PURE__*/memo(function (_ref) {
46
47
  },
47
48
  range: true
48
49
  }) : /*#__PURE__*/React.createElement(CalendarGrid, {
49
- mouth: currentMouth,
50
+ month: currentMouth,
50
51
  value: (_ref3 = value !== null && value !== void 0 ? value : valueRef.current) !== null && _ref3 !== void 0 ? _ref3 : [],
51
52
  onChange: function onChange(value) {
52
53
  valueRef.current = value;
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import './style.scss';
3
+ import dayjs from "dayjs";
3
4
  export type CalendarProps = {
4
- mouth?: Date;
5
- value?: Date;
6
- onChange?: (date: Date) => void;
7
- onMouthChange?: (mouth: Date) => void;
5
+ month?: dayjs.Dayjs | Date;
6
+ value?: dayjs.Dayjs | Date;
7
+ onChange?: (date: dayjs.Dayjs) => void;
8
+ onMonthChange?: (mouth: dayjs.Dayjs) => void;
8
9
  slideable?: boolean;
9
10
  };
10
11
  export declare const Calendar: React.MemoExoticComponent<React.ForwardRefExoticComponent<CalendarProps & React.RefAttributes<HTMLDivElement>>>;
@@ -10,38 +10,47 @@ import { CalendarHeader } from "./calendar-header";
10
10
  import "./style.scss";
11
11
  import { TouchableCalendarGrid } from "./touchable-calendar-grid";
12
12
  import { CalendarGrid } from "./calendar-grid";
13
+ import dayjs from "dayjs";
14
+ import { isSame } from "../utils/dayjs";
13
15
  var calendarCls = 'triones-antm-calendar';
14
16
  export var Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
15
- var _ref$mouth = _ref.mouth,
16
- mouth = _ref$mouth === void 0 ? new Date() : _ref$mouth,
17
+ var _ref$month = _ref.month,
18
+ month = _ref$month === void 0 ? dayjs() : _ref$month,
17
19
  value = _ref.value,
18
20
  _onChange = _ref.onChange,
19
- _onMouthChange = _ref.onMouthChange,
21
+ onMonthChange = _ref.onMonthChange,
20
22
  _ref$slideable = _ref.slideable,
21
23
  slideable = _ref$slideable === void 0 ? false : _ref$slideable;
22
- var _useState = useState(mouth),
24
+ var _useState = useState(dayjs(month)),
23
25
  _useState2 = _slicedToArray(_useState, 2),
24
- currentMouth = _useState2[0],
25
- setCurrentMouth = _useState2[1];
26
+ currentMonth = _useState2[0],
27
+ setCurrentMonth = _useState2[1];
28
+ var handleMonthChange = function handleMonthChange(newMonth) {
29
+ if (isSame(currentMonth, newMonth, 'month')) {
30
+ return;
31
+ }
32
+ setCurrentMonth(newMonth);
33
+ onMonthChange === null || onMonthChange === void 0 || onMonthChange(newMonth);
34
+ };
26
35
  return /*#__PURE__*/React.createElement("div", {
27
36
  ref: ref,
28
37
  className: classNames("".concat(calendarCls))
29
38
  }, /*#__PURE__*/React.createElement(CalendarHeader, {
30
- mouth: currentMouth,
31
- onChange: setCurrentMouth
39
+ month: currentMonth,
40
+ onChange: handleMonthChange
32
41
  }), slideable ? /*#__PURE__*/React.createElement(TouchableCalendarGrid, {
33
- mouth: currentMouth,
34
- value: value ? [value] : [],
42
+ month: currentMonth,
43
+ value: value ? [dayjs(value)] : [],
35
44
  onMouthChange: function onMouthChange(newMouth) {
36
- setCurrentMouth(newMouth);
37
- _onMouthChange === null || _onMouthChange === void 0 || _onMouthChange(newMouth);
45
+ setCurrentMonth(newMouth);
46
+ onMonthChange === null || onMonthChange === void 0 || onMonthChange(newMouth);
38
47
  },
39
48
  onChange: function onChange(value) {
40
49
  _onChange === null || _onChange === void 0 || _onChange(value === null || value === void 0 ? void 0 : value[0]);
41
50
  }
42
51
  }) : /*#__PURE__*/React.createElement(CalendarGrid, {
43
- mouth: currentMouth,
44
- value: value ? [value] : [],
52
+ month: currentMonth,
53
+ value: value ? [dayjs(value)] : [],
45
54
  onChange: function onChange(value) {
46
55
  _onChange === null || _onChange === void 0 || _onChange(value === null || value === void 0 ? void 0 : value[0]);
47
56
  }
@@ -1,85 +1,85 @@
1
- @use "../style/variable" as *;
2
-
3
- $calendarCls: 'triones-antm-calendar';
4
-
5
- .#{$calendarCls}-grid {
6
- //display: flex;
7
- //flex-wrap: wrap;
8
- display: grid;
9
- grid-template-columns: repeat(7, 1fr);
10
- }
11
-
12
- .#{$calendarCls}-cell {
13
- aspect-ratio: 1;
14
- display: flex;
15
- justify-content: center;
16
- align-items: center;
17
- border-radius: $trionesBorderRadius;
18
- cursor: default;
19
- flex-direction: column;
20
-
21
- &-date {
22
- display: flex;
23
- width: 100%;
24
- justify-content: center;
25
- align-items: center;
26
- }
27
-
28
- &-mouth {
29
- display: flex;
30
- width: 100%;
31
- justify-content: center;
32
- align-items: center;
33
- font-size: 8Px;
34
- }
35
-
36
- &.#{$calendarCls}-cell {
37
- &-disabled {
38
- color: #999999;
39
- }
40
-
41
- &-selected {
42
- background-color: $trionesColorPrimary;
43
- color: white;
44
- }
45
-
46
- &-selected-range {
47
- border-radius: 0;
48
- background-color: $trionesColorPrimaryBg;
49
- color: black;
50
- }
51
- }
52
- }
53
-
54
- .#{$calendarCls} {
55
- &-header {
56
- display: flex;
57
- justify-content: space-between;
58
- align-items: center;
59
-
60
- &-title {
61
- font-size: 16Px;
62
- padding: 8Px;
63
- text-align: center;
64
- }
65
-
66
- &-button {
67
- padding-left: 12Px;
68
- padding-right: 12Px;
69
- cursor: pointer;
70
- }
71
- }
72
-
73
- &-week {
74
- display: grid;
75
- grid-template-columns: repeat(7, 1fr);
76
-
77
- &-cell {
78
- display: flex;
79
- justify-content: center;
80
- align-items: center;
81
- padding-top: 8Px;
82
- padding-bottom: 8Px;
83
- }
84
- }
85
- }
1
+ @use "../style/variable" as variable;
2
+
3
+ $calendarCls: 'triones-antm-calendar';
4
+
5
+ .#{$calendarCls}-grid {
6
+ //display: flex;
7
+ //flex-wrap: wrap;
8
+ display: grid;
9
+ grid-template-columns: repeat(7, 1fr);
10
+ }
11
+
12
+ .#{$calendarCls}-cell {
13
+ aspect-ratio: 1;
14
+ display: flex;
15
+ justify-content: center;
16
+ align-items: center;
17
+ border-radius: variable.$trionesBorderRadius;
18
+ cursor: default;
19
+ flex-direction: column;
20
+
21
+ &-date {
22
+ display: flex;
23
+ width: 100%;
24
+ justify-content: center;
25
+ align-items: center;
26
+ }
27
+
28
+ &-mouth {
29
+ display: flex;
30
+ width: 100%;
31
+ justify-content: center;
32
+ align-items: center;
33
+ font-size: 8Px;
34
+ }
35
+
36
+ &.#{$calendarCls}-cell {
37
+ &-disabled {
38
+ color: #999999;
39
+ }
40
+
41
+ &-selected {
42
+ background-color: variable.$trionesColorPrimary;
43
+ color: white;
44
+ }
45
+
46
+ &-selected-range {
47
+ border-radius: 0;
48
+ background-color: variable.$trionesColorPrimaryBg;
49
+ color: black;
50
+ }
51
+ }
52
+ }
53
+
54
+ .#{$calendarCls} {
55
+ &-header {
56
+ display: flex;
57
+ justify-content: space-between;
58
+ align-items: center;
59
+
60
+ &-title {
61
+ font-size: 16Px;
62
+ padding: 8Px;
63
+ text-align: center;
64
+ }
65
+
66
+ &-button {
67
+ padding-left: 12Px;
68
+ padding-right: 12Px;
69
+ cursor: pointer;
70
+ }
71
+ }
72
+
73
+ &-week {
74
+ display: grid;
75
+ grid-template-columns: repeat(7, 1fr);
76
+
77
+ &-cell {
78
+ display: flex;
79
+ justify-content: center;
80
+ align-items: center;
81
+ padding-top: 8Px;
82
+ padding-bottom: 8Px;
83
+ }
84
+ }
85
+ }
@@ -1,10 +1,11 @@
1
1
  import { FC } from 'react';
2
+ import dayjs from "dayjs";
2
3
  type CalendarPickerViewProps = {
3
- mouth?: Date;
4
- value?: Date[];
5
- defaultValue?: Date[];
6
- onChange?: (value: Date[]) => void;
7
- onMouthChange?: (mouth: Date) => void;
4
+ month?: dayjs.Dayjs;
5
+ value?: dayjs.Dayjs[];
6
+ defaultValue?: dayjs.Dayjs[];
7
+ onChange?: (value: dayjs.Dayjs[]) => void;
8
+ onMouthChange?: (mouth: dayjs.Dayjs) => void;
8
9
  range?: boolean;
9
10
  };
10
11
  /**