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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/ActionSheet/ActionSheet.d.ts +25 -0
  2. package/dist/ActionSheet/ActionSheet.js +77 -0
  3. package/dist/ActionSheet/index.d.ts +1 -1
  4. package/dist/ActionSheet/index.js +1 -1
  5. package/dist/ActionSheet/style.scss +52 -0
  6. package/dist/Button/button.d.ts +2 -1
  7. package/dist/Button/button.js +1 -1
  8. package/dist/Button/style.scss +41 -39
  9. package/dist/Calendar/calendar-grid.d.ts +10 -9
  10. package/dist/Calendar/calendar-grid.js +41 -64
  11. package/dist/Calendar/calendar-header.d.ts +3 -2
  12. package/dist/Calendar/calendar-header.js +6 -6
  13. package/dist/Calendar/calendar-range.d.ts +4 -3
  14. package/dist/Calendar/calendar-range.js +12 -11
  15. package/dist/Calendar/calendar.d.ts +5 -4
  16. package/dist/Calendar/calendar.js +23 -14
  17. package/dist/Calendar/style.scss +4 -4
  18. package/dist/Calendar/touchable-calendar-grid.d.ts +6 -5
  19. package/dist/Calendar/touchable-calendar-grid.js +58 -50
  20. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.d.ts +3 -2
  21. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.js +14 -28
  22. package/dist/CalendarDatetimePicker/DateTimeSwitch.d.ts +3 -2
  23. package/dist/CalendarDatetimePicker/DateTimeSwitch.js +4 -3
  24. package/dist/CalendarDatetimePicker/demo/base.js +1 -1
  25. package/dist/CalendarDatetimePicker/style.scss +9 -9
  26. package/dist/CalendarDatetimePicker/types.d.ts +1 -1
  27. package/dist/CalendarDatetimePicker/types.js +1 -1
  28. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.d.ts +11 -0
  29. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.js +61 -0
  30. package/dist/{Mask → CalendarDatetimePickerCell}/demo/base.js +9 -15
  31. package/dist/CalendarDatetimePickerCell/index.d.ts +3 -0
  32. package/dist/CalendarDatetimePickerCell/index.js +2 -0
  33. package/dist/CalendarDatetimePickerCell/style.scss +10 -0
  34. package/dist/CalendarDatetimePickerCell/types.d.ts +1 -0
  35. package/dist/CalendarDatetimePickerCell/types.js +1 -0
  36. package/dist/CalendarPicker/calendar-picker.js +2 -2
  37. package/dist/CalendarPicker/calendar-range-picker.d.ts +4 -4
  38. package/dist/CalendarPicker/calendar-range-picker.js +11 -9
  39. package/dist/CalendarPicker/demo/base.js +6 -6
  40. package/dist/CalendarPicker/index.d.ts +2 -2
  41. package/dist/CalendarPicker/index.js +3 -3
  42. package/dist/CalendarPicker/style.scss +5 -5
  43. package/dist/CalendarPicker/types.d.ts +8 -7
  44. package/dist/CalendarPickerCell/CalendarPickerCell.d.ts +11 -0
  45. package/dist/CalendarPickerCell/CalendarPickerCell.js +54 -0
  46. package/dist/CalendarPickerCell/CalendarRangePickerCell.d.ts +11 -0
  47. package/dist/CalendarPickerCell/CalendarRangePickerCell.js +56 -0
  48. package/dist/CalendarPickerCell/demo/base.d.ts +3 -0
  49. package/dist/CalendarPickerCell/demo/base.js +31 -0
  50. package/dist/CalendarPickerCell/index.d.ts +8 -0
  51. package/dist/CalendarPickerCell/index.js +5 -0
  52. package/dist/CascaderPicker/cascader-picker.d.ts +27 -0
  53. package/dist/CascaderPicker/cascader-picker.js +90 -0
  54. package/dist/CascaderPicker/demo/base.js +1 -4
  55. package/dist/CascaderPicker/index.d.ts +1 -1
  56. package/dist/CascaderPicker/index.js +1 -1
  57. package/dist/CascaderPicker/style.scss +45 -0
  58. package/dist/CascaderPickerCell/CascaderPickerCell.d.ts +21 -0
  59. package/dist/CascaderPickerCell/CascaderPickerCell.js +70 -0
  60. package/dist/CascaderPickerCell/demo/base.js +71 -0
  61. package/dist/CascaderPickerCell/index.d.ts +3 -0
  62. package/dist/CascaderPickerCell/index.js +2 -0
  63. package/dist/CascaderPickerCell/style.scss +24 -0
  64. package/dist/Cell/demo/base.js +41 -2
  65. package/dist/Checkbox/demo/base.js +9 -4
  66. package/dist/Checkbox/demo/disabled.js +2 -1
  67. package/dist/DemoBlock/index.d.ts +6 -0
  68. package/dist/DemoBlock/index.js +9 -2
  69. package/dist/FetchPicker/FetchPicker.d.ts +113 -0
  70. package/dist/FetchPicker/FetchPicker.js +319 -0
  71. package/dist/FetchPicker/index.d.ts +4 -0
  72. package/dist/FetchPicker/index.js +3 -0
  73. package/dist/FetchPicker/styles.scss +118 -0
  74. package/dist/FloatButton/FloatButton.d.ts +21 -0
  75. package/dist/FloatButton/FloatButton.js +66 -0
  76. package/dist/FloatButton/FloatButtonGroup.d.ts +21 -0
  77. package/dist/FloatButton/FloatButtonGroup.js +120 -0
  78. package/dist/FloatButton/context.d.ts +13 -0
  79. package/dist/FloatButton/context.js +2 -0
  80. package/dist/FloatButton/demo/base.d.ts +3 -0
  81. package/dist/FloatButton/demo/base.js +10 -0
  82. package/dist/FloatButton/demo/group.d.ts +3 -0
  83. package/dist/FloatButton/demo/group.js +20 -0
  84. package/dist/FloatButton/demo/square.d.ts +3 -0
  85. package/dist/FloatButton/demo/square.js +12 -0
  86. package/dist/FloatButton/index.d.ts +10 -0
  87. package/dist/FloatButton/index.js +5 -0
  88. package/dist/FloatButton/style.scss +123 -0
  89. package/dist/Form/FormItem/form-item-content.d.ts +17 -0
  90. package/dist/Form/FormItem/form-item-content.js +39 -0
  91. package/dist/Form/FormItem/form-item-label.d.ts +13 -0
  92. package/dist/Form/FormItem/form-item-label.js +29 -0
  93. package/dist/Form/FormItem/form-item.d.ts +51 -0
  94. package/dist/Form/FormItem/form-item.js +74 -0
  95. package/dist/Form/FormItem/index.d.ts +5 -0
  96. package/dist/Form/FormItem/index.js +3 -0
  97. package/dist/Form/demo/input.js +7 -3
  98. package/dist/Form/demo/vertical.d.ts +3 -0
  99. package/dist/Form/demo/vertical.js +45 -0
  100. package/dist/Form/index.d.ts +9 -2
  101. package/dist/Form/index.js +5 -1
  102. package/dist/Form/style.scss +106 -0
  103. package/dist/FormCell/index.d.ts +3 -0
  104. package/dist/FormCell/index.js +2 -0
  105. package/dist/ImagesPreview/ImagesPreview.js +2 -2
  106. package/dist/ImagesWall/CameraModal.js +2 -2
  107. package/dist/ImagesWall/style.scss +4 -4
  108. package/dist/Input/base-input.d.ts +13 -0
  109. package/dist/Input/base-input.js +41 -0
  110. package/dist/Input/demo/base.js +113 -11
  111. package/dist/Input/index.d.ts +14 -2
  112. package/dist/Input/index.js +11 -1
  113. package/dist/Input/index.scss +240 -0
  114. package/dist/Input/input-affix-wrapper.d.ts +13 -0
  115. package/dist/Input/input-affix-wrapper.js +37 -0
  116. package/dist/Input/input-opt.d.ts +16 -0
  117. package/dist/Input/input-opt.js +87 -0
  118. package/dist/Input/input-password.d.ts +7 -0
  119. package/dist/Input/input-password.js +48 -0
  120. package/dist/Input/input.d.ts +20 -0
  121. package/dist/Input/input.js +66 -0
  122. package/dist/Input/textarea.d.ts +15 -0
  123. package/dist/Input/textarea.js +51 -0
  124. package/dist/Input/types.d.ts +3 -0
  125. package/dist/Input/types.js +2 -0
  126. package/dist/Loading/DotLoading.d.ts +1 -0
  127. package/dist/Loading/DotLoading.js +1 -0
  128. package/dist/Loading/SpinLoading.d.ts +1 -0
  129. package/dist/Loading/SpinLoading.js +1 -0
  130. package/dist/Loading/demo/base.d.ts +3 -0
  131. package/dist/{SpinLoading → Loading}/demo/base.js +8 -2
  132. package/dist/Loading/demo/dot-loading.d.ts +3 -0
  133. package/dist/Loading/demo/dot-loading.js +25 -0
  134. package/dist/Loading/index.d.ts +5 -0
  135. package/dist/Loading/index.js +3 -0
  136. package/dist/Overlay/Overlay.d.ts +16 -0
  137. package/dist/Overlay/Overlay.js +117 -0
  138. package/dist/Overlay/demo/base.d.ts +3 -0
  139. package/dist/Overlay/demo/base.js +27 -0
  140. package/dist/Overlay/index.d.ts +4 -0
  141. package/dist/Overlay/index.js +3 -0
  142. package/dist/Overlay/style.scss +20 -0
  143. package/dist/Picker/index.d.ts +1 -1
  144. package/dist/Picker/index.js +1 -1
  145. package/dist/Picker/picker.d.ts +20 -0
  146. package/dist/Picker/picker.js +94 -0
  147. package/dist/Picker/style.scss +44 -0
  148. package/dist/PickerView/index.d.ts +2 -1
  149. package/dist/PickerView/index.js +1 -1
  150. package/dist/PickerView/picker-view-column-item.d.ts +7 -0
  151. package/dist/PickerView/picker-view-column-item.js +11 -0
  152. package/dist/PickerView/picker-view-column.d.ts +10 -0
  153. package/dist/PickerView/picker-view-column.js +117 -0
  154. package/dist/PickerView/picker-view.d.ts +12 -0
  155. package/dist/PickerView/picker-view.js +60 -0
  156. package/dist/PickerView/style.scss +72 -0
  157. package/dist/PickerView/types.d.ts +4 -0
  158. package/dist/PickerView/types.js +1 -0
  159. package/dist/Popup/demo/base.js +107 -25
  160. package/dist/Popup/index.d.ts +2 -1
  161. package/dist/Popup/index.js +2 -1
  162. package/dist/Popup/popup.d.ts +31 -0
  163. package/dist/Popup/popup.js +87 -0
  164. package/dist/Popup/style.scss +129 -0
  165. package/dist/Progress/index.d.ts +1 -1
  166. package/dist/Progress/index.js +1 -1
  167. package/dist/Radio/demo/base.js +2 -2
  168. package/dist/ScrollView/index.d.ts +2 -1
  169. package/dist/ScrollView/index.js +1 -1
  170. package/dist/ScrollView/scroll-view.d.ts +4 -0
  171. package/dist/ScrollView/scroll-view.js +55 -0
  172. package/dist/ScrollView/style.scss +19 -0
  173. package/dist/ScrollView/types.d.ts +26 -0
  174. package/dist/ScrollView/types.js +1 -0
  175. package/dist/Segmented/demo/base.d.ts +3 -0
  176. package/dist/Segmented/demo/base.js +33 -0
  177. package/dist/Segmented/index.d.ts +3 -0
  178. package/dist/Segmented/index.js +2 -0
  179. package/dist/SideBar/index.d.ts +1 -1
  180. package/dist/SideBar/style.scss +6 -6
  181. package/dist/Skeleton/demo/base.d.ts +3 -0
  182. package/dist/Skeleton/demo/base.js +8 -0
  183. package/dist/Skeleton/index.d.ts +3 -0
  184. package/dist/Skeleton/index.js +2 -0
  185. package/dist/Stepper/demo/base.d.ts +3 -0
  186. package/dist/Stepper/demo/base.js +23 -0
  187. package/dist/Stepper/index.d.ts +3 -0
  188. package/dist/Stepper/index.js +2 -0
  189. package/dist/Swiper/style.scss +1 -1
  190. package/dist/Toast/toast-modal.js +4 -4
  191. package/dist/VerificationCodeInput/demo/base.js +2 -2
  192. package/dist/VerificationCodeInput/index.d.ts +2 -2
  193. package/dist/VerificationCodeInput/index.js +1 -1
  194. package/dist/VerificationCodeInput/style.scss +20 -0
  195. package/dist/VerificationCodeInput/verification-code-input.d.ts +24 -0
  196. package/dist/VerificationCodeInput/verification-code-input.js +99 -0
  197. package/dist/index.d.ts +33 -19
  198. package/dist/index.js +9 -2
  199. package/dist/types.d.ts +0 -8
  200. package/dist/types.js +0 -1
  201. package/dist/utils/dayjs.d.ts +4 -0
  202. package/dist/utils/dayjs.js +42 -0
  203. package/dist/utils/use-isomorphic-update-layout-effect.d.ts +1 -1
  204. package/package.json +11 -16
  205. package/dist/Mask/index.d.ts +0 -3
  206. package/dist/Mask/index.js +0 -2
  207. package/dist/Progress/Progress.d.ts +0 -37
  208. package/dist/Progress/Progress.js +0 -52
  209. package/dist/Progress/ProgressCircle.d.ts +0 -17
  210. package/dist/Progress/ProgressCircle.js +0 -148
  211. package/dist/Progress/ProgressLine.d.ts +0 -15
  212. package/dist/Progress/ProgressLine.js +0 -87
  213. package/dist/Progress/style.scss +0 -33
  214. package/dist/Progress/types.d.ts +0 -4
  215. package/dist/Progress/types.js +0 -2
  216. package/dist/SpinLoading/index.d.ts +0 -3
  217. package/dist/SpinLoading/index.js +0 -2
  218. /package/dist/{Mask → CalendarDatetimePickerCell}/demo/base.d.ts +0 -0
  219. /package/dist/{SpinLoading → CascaderPickerCell}/demo/base.d.ts +0 -0
@@ -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,4 +1,4 @@
1
- @use "../style/variable" as *;
1
+ @use "../style/variable" as variable;
2
2
 
3
3
  $calendarCls: 'triones-antm-calendar';
4
4
 
@@ -14,7 +14,7 @@ $calendarCls: 'triones-antm-calendar';
14
14
  display: flex;
15
15
  justify-content: center;
16
16
  align-items: center;
17
- border-radius: $trionesBorderRadius;
17
+ border-radius: variable.$trionesBorderRadius;
18
18
  cursor: default;
19
19
  flex-direction: column;
20
20
 
@@ -39,13 +39,13 @@ $calendarCls: 'triones-antm-calendar';
39
39
  }
40
40
 
41
41
  &-selected {
42
- background-color: $trionesColorPrimary;
42
+ background-color: variable.$trionesColorPrimary;
43
43
  color: white;
44
44
  }
45
45
 
46
46
  &-selected-range {
47
47
  border-radius: 0;
48
- background-color: $trionesColorPrimaryBg;
48
+ background-color: variable.$trionesColorPrimaryBg;
49
49
  color: black;
50
50
  }
51
51
  }
@@ -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
  /**
@@ -16,13 +16,15 @@ import React, { memo, useEffect, useRef, useState } from 'react';
16
16
  import { CalendarGrid } from "../Calendar";
17
17
  import { RandomUtils } from "../utils/random-utils";
18
18
  import classNames from "classnames";
19
+ import dayjs from "dayjs";
20
+ var monthLines = 6;
19
21
  /**
20
22
  * 可以手势滑动的日历组件
21
23
  */
22
24
  export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
23
25
  var _wrapperRef$current3;
24
- var _ref$mouth = _ref.mouth,
25
- mouth = _ref$mouth === void 0 ? new Date() : _ref$mouth,
26
+ var _ref$month = _ref.month,
27
+ month = _ref$month === void 0 ? dayjs() : _ref$month,
26
28
  value = _ref.value,
27
29
  defaultValue = _ref.defaultValue,
28
30
  onChange = _ref.onChange,
@@ -30,10 +32,10 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
30
32
  range = _ref.range;
31
33
  var wrapperRef = useRef();
32
34
  var wrapperUniqueRef = React.useRef(RandomUtils.random());
33
- var _useState = useState(mouth),
35
+ var _useState = useState(dayjs(month)),
34
36
  _useState2 = _slicedToArray(_useState, 2),
35
- currentMouth = _useState2[0],
36
- setCurrentMouth = _useState2[1];
37
+ currentMonth = _useState2[0],
38
+ setCurrentMonth = _useState2[1];
37
39
  var waiting = false;
38
40
  var _useState3 = useState(200),
39
41
  _useState4 = _slicedToArray(_useState3, 2),
@@ -57,8 +59,8 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
57
59
  setTranslateY = _useState8[1];
58
60
  var _useState9 = useState([]),
59
61
  _useState10 = _slicedToArray(_useState9, 2),
60
- mouths = _useState10[0],
61
- setMouths = _useState10[1];
62
+ months = _useState10[0],
63
+ setMonths = _useState10[1];
62
64
 
63
65
  /**
64
66
  * 计算出每个格子的大小
@@ -105,34 +107,40 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
105
107
  * 计算出该月的行数
106
108
  * @param mouth
107
109
  */
108
- var mouthLines = function mouthLines(mouth) {
109
- var firstDate = new Date(mouth.getFullYear(), mouth.getMonth(), 1);
110
- var lastDate = new Date(mouth.getFullYear(), mouth.getMonth() + 1, 0);
111
- var beforeDays = firstDate.getDay();
112
- var afterDays = 6 - lastDate.getDay();
113
- var countDays = beforeDays + lastDate.getDate() + afterDays;
114
- return Math.ceil(countDays / 7);
115
- };
110
+ // const mouthLines = (mouth: Date) => {
111
+ // const firstDate = new Date(mouth.getFullYear(), mouth.getMonth(), 1);
112
+ // const lastDate = new Date(mouth.getFullYear(), mouth.getMonth() + 1, 0);
113
+ // const beforeDays = firstDate.getDay();
114
+ // const afterDays = 6 - lastDate.getDay();
115
+ // const countDays = beforeDays + lastDate.getDate() + afterDays;
116
+ // return Math.ceil(countDays / 7);
117
+ // };
118
+
116
119
  var handleInsertMouth = /*#__PURE__*/function () {
117
120
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
118
- var firstMouth, insertMouth, newMouths, insertMouthLines, insertMouthHeight;
121
+ var firstMouth, insertMouth, newMouths, insertMouthHeight;
119
122
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
120
123
  while (1) switch (_context3.prev = _context3.next) {
121
124
  case 0:
122
- firstMouth = mouths[0];
123
- insertMouth = new Date(firstMouth.getFullYear(), firstMouth.getMonth() - 1, 1);
124
- newMouths = [insertMouth].concat(_toConsumableArray(mouths));
125
- setMouths(newMouths);
126
- insertMouthLines = mouthLines(insertMouth);
127
- _context3.t0 = insertMouthLines;
128
- _context3.next = 8;
125
+ // if (waiting){
126
+ // return
127
+ // }
128
+ // debugger
129
+ // waiting = true
130
+ firstMouth = months[0];
131
+ insertMouth = dayjs(new Date(firstMouth.year(), firstMouth.month() - 1, 1));
132
+ newMouths = [insertMouth].concat(_toConsumableArray(months));
133
+ setMonths(newMouths);
134
+ // const insertMouthLines = mouthLines(insertMouth);
135
+ _context3.t0 = monthLines;
136
+ _context3.next = 7;
129
137
  return cellSize();
130
- case 8:
138
+ case 7:
131
139
  _context3.t1 = _context3.sent;
132
140
  insertMouthHeight = _context3.t0 * _context3.t1;
133
141
  setTranslateY(translateY - insertMouthHeight);
134
142
  // waiting = false
135
- case 11:
143
+ case 10:
136
144
  case "end":
137
145
  return _context3.stop();
138
146
  }
@@ -147,29 +155,29 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
147
155
  // return
148
156
  // }
149
157
  // waiting = true
150
- var lastMouth = mouths[mouths.length - 1];
151
- var appendMouth = new Date(lastMouth.getFullYear(), lastMouth.getMonth() + 1, 1);
152
- var newMouths = [].concat(_toConsumableArray(mouths), [appendMouth]);
153
- setMouths(newMouths);
158
+ var lastMouth = months[months.length - 1];
159
+ var appendMouth = lastMouth.add(1, 'month');
160
+ var newMouths = [].concat(_toConsumableArray(months), [appendMouth]);
161
+ setMonths(newMouths);
154
162
  // waiting = false
155
163
  };
156
164
  useEffect(function () {
157
- 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)];
165
+ var initMonths = [currentMonth.clone().subtract(1, 'month'), currentMonth.clone(), currentMonth.clone().add(1, 'month')];
158
166
  Promise.all([]).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
159
167
  var firstMouthHeight;
160
168
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
161
169
  while (1) switch (_context4.prev = _context4.next) {
162
170
  case 0:
163
- setMouths(initMouths);
171
+ setMonths(initMonths);
164
172
  _context4.t0 = setMouthHeight;
165
- _context4.t1 = mouthLines(currentMouth);
173
+ _context4.t1 = monthLines;
166
174
  _context4.next = 5;
167
175
  return cellSize();
168
176
  case 5:
169
177
  _context4.t2 = _context4.sent;
170
178
  _context4.t3 = _context4.t1 * _context4.t2;
171
179
  (0, _context4.t0)(_context4.t3);
172
- _context4.t4 = mouthLines(initMouths[0]);
180
+ _context4.t4 = monthLines;
173
181
  _context4.next = 11;
174
182
  return cellSize();
175
183
  case 11:
@@ -182,15 +190,15 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
182
190
  }
183
191
  }, _callee4);
184
192
  })));
185
- }, [currentMouth]);
193
+ }, [currentMonth]);
186
194
  useEffect(function () {
187
- if (mouth !== undefined) {
188
- var newMouth = new Date(mouth.getFullYear(), mouth.getMonth(), 1);
189
- if (currentMouth === null || !(currentMouth.getFullYear() === newMouth.getFullYear() && currentMouth.getMonth() === newMouth.getMonth())) {
190
- setCurrentMouth(newMouth);
195
+ if (month !== undefined) {
196
+ var newMouth = dayjs(new Date(month.year(), month.month(), 1));
197
+ if (currentMonth === null || !(currentMonth !== null && currentMonth !== void 0 && currentMonth.isSame(newMouth, 'month'))) {
198
+ setCurrentMonth(newMouth);
191
199
  }
192
200
  }
193
- }, [mouth]);
201
+ }, [month]);
194
202
  useEffect(function () {
195
203
  if (value !== undefined) {}
196
204
  }, [value]);
@@ -307,18 +315,18 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
307
315
  }
308
316
  return _context6.abrupt("return");
309
317
  case 3:
310
- console.log(mouths);
318
+ console.log(months);
311
319
  //region 判断当前月份是否在视窗内
312
320
  _mouthHeightSum = 0;
313
321
  i = 0;
314
322
  case 6:
315
- if (!(i < mouths.length)) {
323
+ if (!(i < months.length)) {
316
324
  _context6.next = 40;
317
325
  break;
318
326
  }
319
327
  console.log('mouthHeight', mouthHeight);
320
- console.log('mouths[i]', mouths[i], i);
321
- _context6.t0 = mouthLines(mouths[i]);
328
+ console.log('mouths[i]', months[i], i);
329
+ _context6.t0 = monthLines;
322
330
  _context6.next = 12;
323
331
  return cellSize();
324
332
  case 12:
@@ -341,8 +349,8 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
341
349
  _context6.next = 27;
342
350
  break;
343
351
  }
344
- console.log('displayMouth', mouths[i]);
345
- displayMouth = mouths[i];
352
+ console.log('displayMouth', months[i]);
353
+ displayMouth = months[i];
346
354
  return _context6.abrupt("break", 40);
347
355
  case 27:
348
356
  _bottomLineY = 0 - _mouthHeightSum; //该月份区域底部,对于顶点的偏移量
@@ -359,8 +367,8 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
359
367
  _context6.next = 37;
360
368
  break;
361
369
  }
362
- console.log('displayMouth', mouths[i]);
363
- displayMouth = mouths[i];
370
+ console.log('displayMouth', months[i]);
371
+ displayMouth = months[i];
364
372
  return _context6.abrupt("break", 40);
365
373
  case 37:
366
374
  i++;
@@ -369,7 +377,7 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
369
377
  case 40:
370
378
  //endregion
371
379
  if (displayMouth) {
372
- setCurrentMouth(displayMouth);
380
+ setCurrentMonth(displayMouth);
373
381
  onMouthChange === null || onMouthChange === void 0 || onMouthChange(displayMouth);
374
382
  }
375
383
  case 41:
@@ -382,10 +390,10 @@ export var TouchableCalendarGrid = /*#__PURE__*/memo(function (_ref) {
382
390
  return _ref7.apply(this, arguments);
383
391
  };
384
392
  }())
385
- }, mouths.map(function (mouth, index) {
393
+ }, months.map(function (mouth, index) {
386
394
  return /*#__PURE__*/React.createElement(CalendarGrid, {
387
395
  key: index,
388
- mouth: mouth,
396
+ month: mouth,
389
397
  value: value,
390
398
  defaultValue: defaultValue,
391
399
  onChange: onChange,
@@ -1,10 +1,11 @@
1
1
  import { FC } from 'react';
2
2
  import './style.scss';
3
+ import dayjs from "dayjs";
3
4
  export type CalendarDatetimePickerProps = {
4
5
  open?: boolean;
5
6
  afterOpenChange?: (open: boolean) => void;
6
- value?: Date;
7
- onOk?: (value?: Date) => void;
7
+ value?: dayjs.Dayjs | Date;
8
+ onOk?: (value?: dayjs.Dayjs) => void;
8
9
  onClose?: () => void;
9
10
  };
10
11
  export declare const CalendarDatetimePicker: FC<CalendarDatetimePickerProps>;
@@ -18,25 +18,21 @@ import { DatetimeUtils } from "../utils/datetime-utils";
18
18
  import { DateTimeSwitch } from "./DateTimeSwitch";
19
19
  import "./style.scss";
20
20
  import { cls, Mode } from "./types";
21
+ import dayjs from "dayjs";
21
22
  export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
22
23
  var _bodyRef$current;
23
24
  var open = _ref.open,
24
25
  afterOpenChange = _ref.afterOpenChange,
25
- _ref$value = _ref.value,
26
- value = _ref$value === void 0 ? new Date() : _ref$value,
26
+ value = _ref.value,
27
27
  onOk = _ref.onOk,
28
28
  onClose = _ref.onClose;
29
29
  var _ConfigProvider$useCo = ConfigProvider.useConfig(),
30
30
  locale = _ConfigProvider$useCo.locale;
31
- var _React$useState = React.useState(open || false),
32
- _React$useState2 = _slicedToArray(_React$useState, 2),
33
- innerOpen = _React$useState2[0],
34
- setInnerOpen = _React$useState2[1];
35
31
  var _useState = useState(Mode.date),
36
32
  _useState2 = _slicedToArray(_useState, 2),
37
33
  mode = _useState2[0],
38
34
  setMode = _useState2[1];
39
- var valueRef = useRef(value || new Date());
35
+ var valueRef = useRef(dayjs(value));
40
36
  var bodyRef = useRef(null);
41
37
  var datetimeSwitchRef = useRef();
42
38
  var _useState3 = useState(300),
@@ -44,7 +40,6 @@ export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
44
40
  bodyHeight = _useState4[0],
45
41
  setBodyHeight = _useState4[1];
46
42
  var handleClose = function handleClose() {
47
- setInnerOpen(false);
48
43
  onClose === null || onClose === void 0 || onClose();
49
44
  };
50
45
  var handleOk = function handleOk() {
@@ -68,19 +63,11 @@ export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
68
63
  };
69
64
  }();
70
65
  useEffect(function () {
71
- afterOpenChange === null || afterOpenChange === void 0 || afterOpenChange(innerOpen);
72
- if (!innerOpen) {
73
- onClose === null || onClose === void 0 || onClose();
66
+ if (open) {
67
+ afterOpenChange === null || afterOpenChange === void 0 || afterOpenChange(true);
68
+ } else {
69
+ afterOpenChange === null || afterOpenChange === void 0 || afterOpenChange(false);
74
70
  }
75
- }, [innerOpen]);
76
- useEffect(function () {
77
- if (open === undefined) {
78
- return;
79
- }
80
- if (open === innerOpen) {
81
- return;
82
- }
83
- setInnerOpen(open);
84
71
  }, [open]);
85
72
  useEffect(function () {
86
73
  if (datetimeSwitchRef.current) {
@@ -91,11 +78,11 @@ export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
91
78
  return /*#__PURE__*/React.createElement(React.Fragment, null, mode === Mode.date && /*#__PURE__*/React.createElement("div", {
92
79
  style: {}
93
80
  }, /*#__PURE__*/React.createElement(Calendar, {
94
- mouth: value,
81
+ month: value,
95
82
  value: value,
96
83
  onChange: function onChange(date) {
97
84
  var _datetimeSwitchRef$cu;
98
- valueRef.current = new Date(date.getFullYear(), date.getMonth(), date.getDate(), valueRef.current.getHours(), valueRef.current.getMinutes());
85
+ valueRef.current = dayjs(new Date(date.year(), date.month(), date.date(), valueRef.current.hour(), valueRef.current.minute()));
99
86
  (_datetimeSwitchRef$cu = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu === void 0 || _datetimeSwitchRef$cu.setDatetime(valueRef.current);
100
87
  }
101
88
  })), mode === Mode.time && /*#__PURE__*/React.createElement("div", {
@@ -115,19 +102,18 @@ export var CalendarDatetimePicker = function CalendarDatetimePicker(_ref) {
115
102
  };
116
103
  })],
117
104
  labelInValue: false,
118
- value: ["".concat(valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.getHours()), "".concat(valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.getMinutes())],
105
+ value: ["".concat(valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.hour()), "".concat(valueRef === null || valueRef === void 0 ? void 0 : valueRef.current.minute())],
119
106
  onChange: function onChange(v) {
120
107
  var _datetimeSwitchRef$cu2;
121
- valueRef.current = new Date(valueRef.current.getFullYear(), valueRef.current.getMonth(), valueRef.current.getDate(), v[0], v[1]);
108
+ valueRef.current = dayjs(new Date(valueRef.current.year(), valueRef.current.month(), valueRef.current.date(), v[0], v[1]));
122
109
  (_datetimeSwitchRef$cu2 = datetimeSwitchRef.current) === null || _datetimeSwitchRef$cu2 === void 0 || _datetimeSwitchRef$cu2.setDatetime(valueRef.current);
123
110
  }
124
111
  })));
125
112
  };
126
113
  return /*#__PURE__*/React.createElement(Popup, {
127
- open: innerOpen,
128
- onClose: function onClose() {
129
- setInnerOpen(false);
130
- }
114
+ open: open,
115
+ onClose: onClose,
116
+ round: true
131
117
  }, /*#__PURE__*/React.createElement("div", {
132
118
  className: classNames(cls)
133
119
  }, /*#__PURE__*/React.createElement("div", {
@@ -1,14 +1,15 @@
1
1
  import React from 'react';
2
2
  import './style.scss';
3
3
  import { Mode } from './types';
4
+ import dayjs from "dayjs";
4
5
  export interface DateTimeSwitchHandle {
5
- setDatetime: (datetime: Date) => void;
6
+ setDatetime: (datetime: dayjs.Dayjs) => void;
6
7
  }
7
8
  type DateTimeSwitchProps = {
8
9
  onDateTabTap?: () => void;
9
10
  onTimeTabTap?: () => void;
10
11
  mode?: Mode;
11
- value?: Date;
12
+ value?: dayjs.Dayjs;
12
13
  };
13
14
  export declare const DateTimeSwitch: React.ForwardRefExoticComponent<DateTimeSwitchProps & React.RefAttributes<DateTimeSwitchHandle>>;
14
15
  export {};
@@ -13,12 +13,13 @@ import React, { forwardRef, useImperativeHandle, useState } from 'react';
13
13
  import { DatetimeUtils } from "../utils/datetime-utils";
14
14
  import "./style.scss";
15
15
  import { cls, Mode } from "./types";
16
+ import dayjs from "dayjs";
16
17
  export var DateTimeSwitch = /*#__PURE__*/forwardRef(function (_ref, ref) {
17
18
  var onDateTabTap = _ref.onDateTabTap,
18
19
  onTimeTabTap = _ref.onTimeTabTap,
19
20
  mode = _ref.mode,
20
21
  value = _ref.value;
21
- var _useState = useState(value),
22
+ var _useState = useState(dayjs(value)),
22
23
  _useState2 = _slicedToArray(_useState, 2),
23
24
  datetime = _useState2[0],
24
25
  setDatetime = _useState2[1];
@@ -32,8 +33,8 @@ export var DateTimeSwitch = /*#__PURE__*/forwardRef(function (_ref, ref) {
32
33
  }, /*#__PURE__*/React.createElement("div", {
33
34
  className: classNames("".concat(cls, "-header-display-date"), _defineProperty({}, "".concat(cls, "-header-display-active"), mode === Mode.date)),
34
35
  onClick: onDateTabTap
35
- }, datetime ? "".concat(datetime.getFullYear(), "-").concat(DatetimeUtils.twoDigits(datetime.getMonth() + 1), "-").concat(DatetimeUtils.twoDigits(datetime.getDate())) : ''), /*#__PURE__*/React.createElement("div", {
36
+ }, datetime ? "".concat(datetime.year(), "-").concat(DatetimeUtils.twoDigits(datetime.month() + 1), "-").concat(DatetimeUtils.twoDigits(datetime.date())) : ''), /*#__PURE__*/React.createElement("div", {
36
37
  className: classNames("".concat(cls, "-header-display-time"), _defineProperty({}, "".concat(cls, "-header-display-active"), mode === Mode.time)),
37
38
  onClick: onTimeTabTap
38
- }, datetime ? "".concat(datetime.getHours(), ":").concat(datetime.getMinutes()) : ''));
39
+ }, datetime ? "".concat(datetime.hour(), ":").concat(datetime.minute()) : ''));
39
40
  });
@@ -29,7 +29,7 @@ export default (function () {
29
29
  getContainer: function getContainer() {
30
30
  return toastContainer.current;
31
31
  },
32
- content: "".concat(date.getFullYear(), "-").concat(date.getMonth() + 1, "-").concat(date.getDate(), " ").concat(date.getHours(), ":").concat(date.getMinutes())
32
+ content: "".concat(date.year(), "-").concat(date.month() + 1, "-").concat(date.date(), " ").concat(date.hour(), ":").concat(date.minute())
33
33
  });
34
34
  }
35
35
  }), /*#__PURE__*/React.createElement(Button, {
@@ -1,15 +1,15 @@
1
- @use "../style/variable" as *;
1
+ @use "../style/variable" as variable;
2
2
 
3
- $calendarDatetimePickerCls: 'triones-antm-calendar-datetime-picker';
3
+ $calendarDatetimePopupCls: 'triones-antm-calendar-datetime-popup';
4
4
 
5
- .#{$calendarDatetimePickerCls} {
6
- border-top-left-radius: $trionesBorderRadius;
7
- border-top-right-radius: $trionesBorderRadius;
5
+ .#{$calendarDatetimePopupCls} {
6
+ border-top-left-radius: variable.$trionesBorderRadius;
7
+ border-top-right-radius: variable.$trionesBorderRadius;
8
8
 
9
9
  &-header {
10
10
  display: flex;
11
11
  justify-content: space-between;
12
- border-bottom: 1Px solid $trionesBorderColor;
12
+ border-bottom: 1Px solid variable.$trionesBorderColor;
13
13
 
14
14
 
15
15
  &-display {
@@ -31,9 +31,9 @@ $calendarDatetimePickerCls: 'triones-antm-calendar-datetime-picker';
31
31
  }
32
32
 
33
33
  &-active {
34
- color: $trionesColorText;
34
+ color: variable.$trionesColorText;
35
35
  font-weight: bold;
36
- background-color: $trionesColorBgTextActive;
36
+ background-color: variable.$trionesColorBgTextActive;
37
37
  }
38
38
  }
39
39
 
@@ -44,7 +44,7 @@ $calendarDatetimePickerCls: 'triones-antm-calendar-datetime-picker';
44
44
  }
45
45
 
46
46
  &-ok {
47
- color: $trionesColorPrimary;
47
+ color: variable.$trionesColorPrimary;
48
48
  }
49
49
  }
50
50
  }
@@ -1,4 +1,4 @@
1
- export declare const cls = "triones-antm-calendar-datetime-picker";
1
+ export declare const cls = "triones-antm-calendar-datetime-popup";
2
2
  export declare enum Mode {
3
3
  date = 0,
4
4
  time = 1