@trionesdev/antd-mobile-react 0.0.2-beta.12 → 0.0.2-beta.14

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 (100) hide show
  1. package/dist/Calendar/calendar-grid.d.ts +10 -9
  2. package/dist/Calendar/calendar-grid.js +41 -64
  3. package/dist/Calendar/calendar-header.d.ts +3 -2
  4. package/dist/Calendar/calendar-header.js +6 -6
  5. package/dist/Calendar/calendar-range.d.ts +4 -3
  6. package/dist/Calendar/calendar-range.js +12 -11
  7. package/dist/Calendar/calendar.d.ts +5 -4
  8. package/dist/Calendar/calendar.js +23 -15
  9. package/dist/Calendar/touchable-calendar-grid.d.ts +6 -5
  10. package/dist/Calendar/touchable-calendar-grid.js +58 -50
  11. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.d.ts +8 -6
  12. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.js +123 -42
  13. package/dist/{CalendarDatetimePopup → CalendarDatetimePicker}/DateTimeSwitch.d.ts +3 -2
  14. package/dist/{CalendarDatetimePopup → CalendarDatetimePicker}/DateTimeSwitch.js +4 -3
  15. package/dist/CalendarDatetimePicker/demo/base.js +21 -5
  16. package/dist/CalendarDatetimePicker/index.d.ts +2 -2
  17. package/dist/CalendarDatetimePicker/style.scss +50 -6
  18. package/dist/CalendarDatetimePicker/types.d.ts +5 -1
  19. package/dist/CalendarDatetimePicker/types.js +6 -1
  20. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.d.ts +10 -0
  21. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.js +60 -0
  22. package/dist/{CalendarDatetimePopup → CalendarDatetimePickerCell}/demo/base.js +5 -22
  23. package/dist/CalendarDatetimePickerCell/index.d.ts +3 -0
  24. package/dist/CalendarDatetimePickerCell/index.js +2 -0
  25. package/dist/CalendarDatetimePickerCell/style.scss +10 -0
  26. package/dist/CalendarDatetimePickerCell/types.d.ts +1 -0
  27. package/dist/CalendarDatetimePickerCell/types.js +1 -0
  28. package/dist/CalendarPicker/calendar-picker.d.ts +4 -0
  29. package/dist/{CalendarPopup/calendar-popup.js → CalendarPicker/calendar-picker.js} +4 -4
  30. package/dist/CalendarPicker/calendar-range-picker.d.ts +4 -0
  31. package/dist/{CalendarPopup/calendar-range-popup.js → CalendarPicker/calendar-range-picker.js} +7 -6
  32. package/dist/{CalendarPopup → CalendarPicker}/demo/base.js +3 -3
  33. package/dist/CalendarPicker/index.d.ts +9 -0
  34. package/dist/CalendarPicker/index.js +5 -0
  35. package/dist/{CalendarPopup → CalendarPicker}/style.scss +2 -2
  36. package/dist/{CalendarPopup → CalendarPicker}/types.d.ts +9 -8
  37. package/dist/CalendarPickerCell/CalendarPickerCell.d.ts +11 -0
  38. package/dist/CalendarPickerCell/CalendarPickerCell.js +54 -0
  39. package/dist/CalendarPickerCell/CalendarRangePickerCell.d.ts +11 -0
  40. package/dist/CalendarPickerCell/CalendarRangePickerCell.js +56 -0
  41. package/dist/CalendarPickerCell/demo/base.d.ts +3 -0
  42. package/dist/CalendarPickerCell/demo/base.js +33 -0
  43. package/dist/CalendarPickerCell/index.d.ts +8 -0
  44. package/dist/CalendarPickerCell/index.js +5 -0
  45. package/dist/{CascaderPopup/cascader-popup.d.ts → CascaderPicker/cascader-picker.d.ts} +2 -2
  46. package/dist/{CascaderPopup/cascader-popup.js → CascaderPicker/cascader-picker.js} +8 -8
  47. package/dist/CascaderPicker/demo/base.js +16 -7
  48. package/dist/CascaderPicker/index.d.ts +1 -1
  49. package/dist/CascaderPicker/index.js +1 -1
  50. package/dist/CascaderPicker/style.scss +33 -12
  51. package/dist/{CascaderPicker/CascaderPicker.d.ts → CascaderPickerCell/CascaderPickerCell.d.ts} +4 -8
  52. package/dist/{CascaderPicker/CascaderPicker.js → CascaderPickerCell/CascaderPickerCell.js} +7 -15
  53. package/dist/{CascaderPopup → CascaderPickerCell}/demo/base.js +6 -16
  54. package/dist/CascaderPickerCell/index.d.ts +3 -0
  55. package/dist/CascaderPickerCell/index.js +2 -0
  56. package/dist/CascaderPickerCell/style.scss +24 -0
  57. package/dist/FloatButton/FloatButton.d.ts +21 -0
  58. package/dist/FloatButton/FloatButton.js +66 -0
  59. package/dist/FloatButton/FloatButtonGroup.d.ts +21 -0
  60. package/dist/FloatButton/FloatButtonGroup.js +120 -0
  61. package/dist/FloatButton/context.d.ts +13 -0
  62. package/dist/FloatButton/context.js +2 -0
  63. package/dist/FloatButton/demo/base.d.ts +3 -0
  64. package/dist/FloatButton/demo/base.js +10 -0
  65. package/dist/FloatButton/demo/group.d.ts +3 -0
  66. package/dist/FloatButton/demo/group.js +20 -0
  67. package/dist/FloatButton/demo/square.d.ts +3 -0
  68. package/dist/FloatButton/demo/square.js +12 -0
  69. package/dist/FloatButton/index.d.ts +10 -0
  70. package/dist/FloatButton/index.js +5 -0
  71. package/dist/FloatButton/style.scss +123 -0
  72. package/dist/Picker/picker.d.ts +1 -0
  73. package/dist/Picker/picker.js +3 -6
  74. package/dist/Segmented/demo/base.d.ts +3 -0
  75. package/dist/Segmented/demo/base.js +33 -0
  76. package/dist/Segmented/index.d.ts +3 -0
  77. package/dist/Segmented/index.js +2 -0
  78. package/dist/index.d.ts +14 -6
  79. package/dist/index.js +7 -3
  80. package/dist/utils/dayjs.d.ts +4 -0
  81. package/dist/utils/dayjs.js +42 -0
  82. package/package.json +4 -4
  83. package/dist/CalendarDatetimePopup/CalendarDatetimePopup.d.ts +0 -10
  84. package/dist/CalendarDatetimePopup/CalendarDatetimePopup.js +0 -142
  85. package/dist/CalendarDatetimePopup/index.d.ts +0 -3
  86. package/dist/CalendarDatetimePopup/index.js +0 -2
  87. package/dist/CalendarDatetimePopup/style.scss +0 -54
  88. package/dist/CalendarDatetimePopup/types.d.ts +0 -5
  89. package/dist/CalendarDatetimePopup/types.js +0 -6
  90. package/dist/CalendarPopup/calendar-popup.d.ts +0 -4
  91. package/dist/CalendarPopup/calendar-range-popup.d.ts +0 -4
  92. package/dist/CalendarPopup/index.d.ts +0 -9
  93. package/dist/CalendarPopup/index.js +0 -5
  94. package/dist/CascaderPopup/index.d.ts +0 -3
  95. package/dist/CascaderPopup/index.js +0 -2
  96. package/dist/CascaderPopup/style.scss +0 -45
  97. /package/dist/{CalendarDatetimePopup → CalendarDatetimePickerCell}/demo/base.d.ts +0 -0
  98. /package/dist/{CalendarPopup → CalendarPicker}/demo/base.d.ts +0 -0
  99. /package/dist/{CalendarPopup → CalendarPicker}/types.js +0 -0
  100. /package/dist/{CascaderPopup → CascaderPickerCell}/demo/base.d.ts +0 -0
@@ -1,27 +1,28 @@
1
1
  import { FC } from 'react';
2
2
  import './style.scss';
3
+ import dayjs from "dayjs";
3
4
  export type CalendarGridProps = {
4
- mouth?: Date;
5
+ month?: dayjs.Dayjs;
5
6
  /**
6
7
  * @description 值,如果是区间模式,则 0,1 索引的值有效,0是开始时间,1是结束时间
7
8
  */
8
- value?: Date[];
9
+ value?: (dayjs.Dayjs | Date)[];
9
10
  /**
10
11
  * @description 默认值,如果是区间模式,则 0,1 索引的值有效,0是开始时间,1是结束时间
11
12
  */
12
- defaultValue?: Date[];
13
- onChange?: (value: Date[]) => void;
13
+ defaultValue?: (dayjs.Dayjs | Date)[];
14
+ onChange?: (value: dayjs.Dayjs[]) => void;
14
15
  /**
15
16
  * @description 是否为范围选择
16
17
  */
17
18
  range?: boolean;
18
- onSelect?: (date: Date) => void;
19
+ onSelect?: (date: dayjs.Dayjs) => void;
19
20
  };
20
21
  export type CalendarCellProps = {
21
- mouth?: Date;
22
- date?: Date;
23
- value?: Date[];
22
+ month?: dayjs.Dayjs;
23
+ date?: dayjs.Dayjs;
24
+ value?: dayjs.Dayjs[];
24
25
  range?: boolean;
25
- onSelect?: (date: Date) => void;
26
+ onSelect?: (date: dayjs.Dayjs) => void;
26
27
  };
27
28
  export declare const CalendarGrid: FC<CalendarGridProps>;
@@ -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,39 +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 { cloneDeep } from "lodash-es";
13
+ import dayjs from "dayjs";
14
+ import { isSame } from "../utils/dayjs";
14
15
  var calendarCls = 'triones-antm-calendar';
15
16
  export var Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
16
- var _ref$mouth = _ref.mouth,
17
- mouth = _ref$mouth === void 0 ? new Date() : _ref$mouth,
17
+ var _ref$month = _ref.month,
18
+ month = _ref$month === void 0 ? dayjs() : _ref$month,
18
19
  value = _ref.value,
19
20
  _onChange = _ref.onChange,
20
- _onMouthChange = _ref.onMouthChange,
21
+ onMonthChange = _ref.onMonthChange,
21
22
  _ref$slideable = _ref.slideable,
22
23
  slideable = _ref$slideable === void 0 ? false : _ref$slideable;
23
- var _useState = useState(mouth),
24
+ var _useState = useState(dayjs(month)),
24
25
  _useState2 = _slicedToArray(_useState, 2),
25
- currentMouth = _useState2[0],
26
- 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
+ };
27
35
  return /*#__PURE__*/React.createElement("div", {
28
36
  ref: ref,
29
37
  className: classNames("".concat(calendarCls))
30
38
  }, /*#__PURE__*/React.createElement(CalendarHeader, {
31
- mouth: currentMouth,
32
- onChange: setCurrentMouth
39
+ month: currentMonth,
40
+ onChange: handleMonthChange
33
41
  }), slideable ? /*#__PURE__*/React.createElement(TouchableCalendarGrid, {
34
- mouth: currentMouth,
35
- value: value ? [value] : [],
42
+ month: currentMonth,
43
+ value: value ? [dayjs(value)] : [],
36
44
  onMouthChange: function onMouthChange(newMouth) {
37
- setCurrentMouth(newMouth);
38
- _onMouthChange === null || _onMouthChange === void 0 || _onMouthChange(newMouth);
45
+ setCurrentMonth(newMouth);
46
+ onMonthChange === null || onMonthChange === void 0 || onMonthChange(newMouth);
39
47
  },
40
48
  onChange: function onChange(value) {
41
49
  _onChange === null || _onChange === void 0 || _onChange(value === null || value === void 0 ? void 0 : value[0]);
42
50
  }
43
51
  }) : /*#__PURE__*/React.createElement(CalendarGrid, {
44
- mouth: currentMouth,
45
- value: value ? [cloneDeep(value)] : [],
52
+ month: currentMonth,
53
+ value: value ? [dayjs(value)] : [],
46
54
  onChange: function onChange(value) {
47
55
  _onChange === null || _onChange === void 0 || _onChange(value === null || value === void 0 ? void 0 : value[0]);
48
56
  }
@@ -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
  /**