assui 3.1.62 → 3.1.63

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.
@@ -54,11 +54,7 @@ import getDefaultRadioList from './defaultRadioList';
54
54
  import LabelRangePicker from '../label-range-picker';
55
55
  import LocaleContext from '../config-provider/context';
56
56
  import formatMessage from '../messages';
57
- import { formatMaxScope } from './utils';
58
- /** 1整天的毫秒数 */
59
- var ONE_DAY_MILLISECOND = 1000 * 60 * 60 * 24;
60
- /** 1分钟的毫秒数 */
61
- var ONE_MINUTE_MILLISECOND = 1000 * 60;
57
+ import { formatMaxScope, getDateDiffScope, ONE_DAY_MILLISECOND, getTimeDiffOfShowTime } from './utils';
62
58
  var RangePicker = DatePicker.RangePicker;
63
59
  var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
64
60
  var customizeTimeList = props.customizeTimeList,
@@ -152,7 +148,6 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
152
148
  };
153
149
  var onDateChange = function onDateChange(nextValue) {
154
150
  var _a, _b;
155
- console.log('nextValue', nextValue);
156
151
  var _c = __read(nextValue || [], 2),
157
152
  start = _c[0],
158
153
  end = _c[1];
@@ -164,7 +159,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
164
159
  if (!maxScope) {
165
160
  return setDate([nextStartDate, nextEndDate]);
166
161
  }
167
- var timeDiffOfShowTime = maxScope * ONE_DAY_MILLISECOND - ONE_MINUTE_MILLISECOND;
162
+ var timeDiffOfShowTime = getTimeDiffOfShowTime(maxScope);
168
163
  var _d = __read(date || [], 1),
169
164
  startDate = _d[0];
170
165
  // 1. start和end都存在时
@@ -184,10 +179,12 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
184
179
  }
185
180
  // 2. 仅end存在时,自动填入start
186
181
  } else if (!nextStartDate && nextEndDate) {
187
- nextStartDate = showTime ? nextEndDate.clone().subtract(timeDiffOfShowTime, 'milliseconds').startOf('minute') : nextEndDate.clone().subtract(maxScope - 1, 'day').startOf('day');
182
+ var scope = getDateDiffScope(date, maxScope);
183
+ nextStartDate = showTime ? nextEndDate.clone().subtract(getTimeDiffOfShowTime(scope), 'milliseconds').startOf('minute') : nextEndDate.clone().subtract(scope - 1, 'day').startOf('day');
188
184
  // 3. 仅start存在时,自动填入end
189
185
  } else if (nextStartDate && !nextEndDate) {
190
- nextEndDate = showTime ? nextStartDate.clone().add(timeDiffOfShowTime, 'milliseconds').endOf('minute') : nextStartDate.clone().add(maxScope - 1, 'day').endOf('day');
186
+ var scope = getDateDiffScope(date, maxScope);
187
+ nextEndDate = showTime ? nextStartDate.clone().add(getTimeDiffOfShowTime(scope), 'milliseconds').endOf('minute') : nextStartDate.clone().add(scope - 1, 'day').endOf('day');
191
188
  }
192
189
  if (nextStartDate && nextEndDate) {
193
190
  return setDate([nextStartDate, nextEndDate]);
@@ -1,3 +1,11 @@
1
1
  import type { RangeValue } from 'rc-picker/lib/interface';
2
2
  import type { Moment } from 'moment';
3
+ /** 1整天的毫秒数 */
4
+ export declare const ONE_DAY_MILLISECOND: number;
5
+ /** 1分钟的毫秒数 */
6
+ export declare const ONE_MINUTE_MILLISECOND: number;
3
7
  export declare const formatMaxScope: (dateStampTuple: RangeValue<Moment>, maxScope: number) => (Moment | null)[];
8
+ /** 开始时间和结束时间相差的天数 */
9
+ export declare const getDateDiffScope: (date: [Moment, Moment], maxScope: number) => number;
10
+ /** showTime下的所需的时间撮 */
11
+ export declare const getTimeDiffOfShowTime: (scope: number) => number;
@@ -23,6 +23,10 @@ var __read = this && this.__read || function (o, n) {
23
23
  return ar;
24
24
  };
25
25
  import dateUtils from "aa-utils/es/dateUtils";
26
+ /** 1整天的毫秒数 */
27
+ export var ONE_DAY_MILLISECOND = 1000 * 60 * 60 * 24;
28
+ /** 1分钟的毫秒数 */
29
+ export var ONE_MINUTE_MILLISECOND = 1000 * 60;
26
30
  export var formatMaxScope = function formatMaxScope(dateStampTuple, maxScope) {
27
31
  var _a, _b;
28
32
  var now = dateUtils.getToday().endOf('day');
@@ -45,4 +49,14 @@ export var formatMaxScope = function formatMaxScope(dateStampTuple, maxScope) {
45
49
  endStamp = endStamp !== null && endStamp !== void 0 ? endStamp : startStamp.clone().add(maxScope - 1, 'day').endOf('day');
46
50
  }
47
51
  return [startStamp, endStamp];
52
+ };
53
+ /** 开始时间和结束时间相差的天数 */
54
+ export var getDateDiffScope = function getDateDiffScope(date, maxScope) {
55
+ var momentDiffDay = (date[1].diff(date[0]) + 1) / ONE_DAY_MILLISECOND;
56
+ var finalScope = momentDiffDay < maxScope ? momentDiffDay : maxScope;
57
+ return finalScope;
58
+ };
59
+ /** showTime下的所需的时间撮 */
60
+ export var getTimeDiffOfShowTime = function getTimeDiffOfShowTime(scope) {
61
+ return scope * ONE_DAY_MILLISECOND - ONE_MINUTE_MILLISECOND;
48
62
  };
@@ -98,10 +98,6 @@ var label_range_picker_1 = __importDefault(require("../label-range-picker"));
98
98
  var context_1 = __importDefault(require("../config-provider/context"));
99
99
  var messages_1 = __importDefault(require("../messages"));
100
100
  var utils_1 = require("./utils");
101
- /** 1整天的毫秒数 */
102
- var ONE_DAY_MILLISECOND = 1000 * 60 * 60 * 24;
103
- /** 1分钟的毫秒数 */
104
- var ONE_MINUTE_MILLISECOND = 1000 * 60;
105
101
  var RangePicker = date_picker_1["default"].RangePicker;
106
102
  var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
107
103
  var customizeTimeList = props.customizeTimeList,
@@ -195,7 +191,6 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
195
191
  };
196
192
  var onDateChange = function onDateChange(nextValue) {
197
193
  var _a, _b;
198
- console.log('nextValue', nextValue);
199
194
  var _c = __read(nextValue || [], 2),
200
195
  start = _c[0],
201
196
  end = _c[1];
@@ -207,13 +202,13 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
207
202
  if (!maxScope) {
208
203
  return setDate([nextStartDate, nextEndDate]);
209
204
  }
210
- var timeDiffOfShowTime = maxScope * ONE_DAY_MILLISECOND - ONE_MINUTE_MILLISECOND;
205
+ var timeDiffOfShowTime = (0, utils_1.getTimeDiffOfShowTime)(maxScope);
211
206
  var _d = __read(date || [], 1),
212
207
  startDate = _d[0];
213
208
  // 1. start和end都存在时
214
209
  if (nextStartDate && nextEndDate) {
215
210
  var isChangeStartData = !(startDate === null || startDate === void 0 ? void 0 : startDate.clone().isSame(nextStartDate));
216
- var momentDiffDay = nextEndDate.diff(nextStartDate) / ONE_DAY_MILLISECOND;
211
+ var momentDiffDay = nextEndDate.diff(nextStartDate) / utils_1.ONE_DAY_MILLISECOND;
217
212
  // 更改start
218
213
  if (isChangeStartData) {
219
214
  // 时间差大于maxScope,则将end调整到期望范围
@@ -227,10 +222,12 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
227
222
  }
228
223
  // 2. 仅end存在时,自动填入start
229
224
  } else if (!nextStartDate && nextEndDate) {
230
- nextStartDate = showTime ? nextEndDate.clone().subtract(timeDiffOfShowTime, 'milliseconds').startOf('minute') : nextEndDate.clone().subtract(maxScope - 1, 'day').startOf('day');
225
+ var scope = (0, utils_1.getDateDiffScope)(date, maxScope);
226
+ nextStartDate = showTime ? nextEndDate.clone().subtract((0, utils_1.getTimeDiffOfShowTime)(scope), 'milliseconds').startOf('minute') : nextEndDate.clone().subtract(scope - 1, 'day').startOf('day');
231
227
  // 3. 仅start存在时,自动填入end
232
228
  } else if (nextStartDate && !nextEndDate) {
233
- nextEndDate = showTime ? nextStartDate.clone().add(timeDiffOfShowTime, 'milliseconds').endOf('minute') : nextStartDate.clone().add(maxScope - 1, 'day').endOf('day');
229
+ var scope = (0, utils_1.getDateDiffScope)(date, maxScope);
230
+ nextEndDate = showTime ? nextStartDate.clone().add((0, utils_1.getTimeDiffOfShowTime)(scope), 'milliseconds').endOf('minute') : nextStartDate.clone().add(scope - 1, 'day').endOf('day');
234
231
  }
235
232
  if (nextStartDate && nextEndDate) {
236
233
  return setDate([nextStartDate, nextEndDate]);
@@ -250,7 +247,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
250
247
  var _a = __read(item.value, 2),
251
248
  startTime = _a[0],
252
249
  entTime = _a[1];
253
- var space = entTime.diff(startTime) / ONE_DAY_MILLISECOND;
250
+ var space = entTime.diff(startTime) / utils_1.ONE_DAY_MILLISECOND;
254
251
  return space <= maxScope;
255
252
  }) : dataSource;
256
253
  var panelRender = function panelRender(panel) {
@@ -1,3 +1,11 @@
1
1
  import type { RangeValue } from 'rc-picker/lib/interface';
2
2
  import type { Moment } from 'moment';
3
+ /** 1整天的毫秒数 */
4
+ export declare const ONE_DAY_MILLISECOND: number;
5
+ /** 1分钟的毫秒数 */
6
+ export declare const ONE_MINUTE_MILLISECOND: number;
3
7
  export declare const formatMaxScope: (dateStampTuple: RangeValue<Moment>, maxScope: number) => (Moment | null)[];
8
+ /** 开始时间和结束时间相差的天数 */
9
+ export declare const getDateDiffScope: (date: [Moment, Moment], maxScope: number) => number;
10
+ /** showTime下的所需的时间撮 */
11
+ export declare const getTimeDiffOfShowTime: (scope: number) => number;
@@ -32,8 +32,12 @@ var __importDefault = this && this.__importDefault || function (mod) {
32
32
  Object.defineProperty(exports, "__esModule", {
33
33
  value: true
34
34
  });
35
- exports.formatMaxScope = void 0;
35
+ exports.getTimeDiffOfShowTime = exports.getDateDiffScope = exports.formatMaxScope = exports.ONE_MINUTE_MILLISECOND = exports.ONE_DAY_MILLISECOND = void 0;
36
36
  var dateUtils_1 = __importDefault(require("aa-utils/lib/dateUtils"));
37
+ /** 1整天的毫秒数 */
38
+ exports.ONE_DAY_MILLISECOND = 1000 * 60 * 60 * 24;
39
+ /** 1分钟的毫秒数 */
40
+ exports.ONE_MINUTE_MILLISECOND = 1000 * 60;
37
41
  var formatMaxScope = function formatMaxScope(dateStampTuple, maxScope) {
38
42
  var _a, _b;
39
43
  var now = dateUtils_1["default"].getToday().endOf('day');
@@ -57,4 +61,16 @@ var formatMaxScope = function formatMaxScope(dateStampTuple, maxScope) {
57
61
  }
58
62
  return [startStamp, endStamp];
59
63
  };
60
- exports.formatMaxScope = formatMaxScope;
64
+ exports.formatMaxScope = formatMaxScope;
65
+ /** 开始时间和结束时间相差的天数 */
66
+ var getDateDiffScope = function getDateDiffScope(date, maxScope) {
67
+ var momentDiffDay = (date[1].diff(date[0]) + 1) / exports.ONE_DAY_MILLISECOND;
68
+ var finalScope = momentDiffDay < maxScope ? momentDiffDay : maxScope;
69
+ return finalScope;
70
+ };
71
+ exports.getDateDiffScope = getDateDiffScope;
72
+ /** showTime下的所需的时间撮 */
73
+ var getTimeDiffOfShowTime = function getTimeDiffOfShowTime(scope) {
74
+ return scope * exports.ONE_DAY_MILLISECOND - exports.ONE_MINUTE_MILLISECOND;
75
+ };
76
+ exports.getTimeDiffOfShowTime = getTimeDiffOfShowTime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assui",
3
- "version": "3.1.62",
3
+ "version": "3.1.63",
4
4
  "description": "react ui library",
5
5
  "author": "jason <usochen@gmail.com>",
6
6
  "main": "./lib/index.js",
@@ -80,5 +80,5 @@
80
80
  "node": ">=10.0.0"
81
81
  },
82
82
  "license": "MIT",
83
- "gitHead": "56e7a89245c64bb2f5d960cd4272e5a1cc778f4d"
83
+ "gitHead": "e653440a169dc9da1624ccd5562bf102512b8c3c"
84
84
  }