@chaoswise/ui 2.3.4 → 2.3.6

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.
@@ -115,13 +115,13 @@ function AbreastLayout(_ref) {
115
115
  onResizeStart: function onResizeStart() {
116
116
  var _rest$onResizeStart;
117
117
  setResizable(true);
118
- rest === null || rest === void 0 ? void 0 : (_rest$onResizeStart = rest.onResizeStart) === null || _rest$onResizeStart === void 0 ? void 0 : _rest$onResizeStart.call(rest);
118
+ rest === null || rest === void 0 || (_rest$onResizeStart = rest.onResizeStart) === null || _rest$onResizeStart === void 0 ? void 0 : _rest$onResizeStart.call(rest);
119
119
  },
120
120
  onResizeStop: function onResizeStop(e, direction, ref, d) {
121
121
  var _rest$onResizeStop;
122
122
  setLeftNavigationWidth(Number.parseInt(leftNavigationWidth) + d.width);
123
123
  setResizable(false);
124
- rest === null || rest === void 0 ? void 0 : (_rest$onResizeStop = rest.onResizeStop) === null || _rest$onResizeStop === void 0 ? void 0 : _rest$onResizeStop.call(rest);
124
+ rest === null || rest === void 0 || (_rest$onResizeStop = rest.onResizeStop) === null || _rest$onResizeStop === void 0 ? void 0 : _rest$onResizeStop.call(rest);
125
125
  },
126
126
  enable: _objectSpread({
127
127
  top: false,
@@ -26,7 +26,7 @@ import Column, { FIX_LABEL } from './Column';
26
26
  import useActive from './useActive';
27
27
  import useKeyboard from './useKeyboard';
28
28
  var RefOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
29
- var _optionColumns$, _optionColumns$$optio, _ref3, _classNames;
29
+ var _optionColumns$, _ref3, _classNames;
30
30
  var _useBaseProps = useBaseProps(),
31
31
  prefixCls = _useBaseProps.prefixCls,
32
32
  multiple = _useBaseProps.multiple,
@@ -181,7 +181,7 @@ var RefOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
181
181
  }, [activeValueCells]);
182
182
  // ========================== Render ==========================
183
183
  // >>>>> Empty
184
- var isEmpty = !((_optionColumns$ = optionColumns[0]) !== null && _optionColumns$ !== void 0 && (_optionColumns$$optio = _optionColumns$.options) !== null && _optionColumns$$optio !== void 0 && _optionColumns$$optio.length);
184
+ var isEmpty = !((_optionColumns$ = optionColumns[0]) !== null && _optionColumns$ !== void 0 && (_optionColumns$ = _optionColumns$.options) !== null && _optionColumns$ !== void 0 && _optionColumns$.length);
185
185
  var emptyList = [(_ref3 = {}, _defineProperty(_ref3, fieldNames.value, '__EMPTY__'), _defineProperty(_ref3, FIX_LABEL, notFoundContent), _defineProperty(_ref3, "disabled", true), _ref3)];
186
186
  var columnProps = _objectSpread(_objectSpread({}, props), {}, {
187
187
  multiple: !isEmpty && multiple,
@@ -32,7 +32,7 @@ export default (function (rawValues, options, fieldNames, multiple, displayRende
32
32
  }, []);
33
33
  };
34
34
  return rawValues.map(function (valueCells) {
35
- var _valueOptions, _valueOptions$option;
35
+ var _valueOptions;
36
36
  var valueOptions = toPathOptions(valueCells, options, fieldNames);
37
37
  var isBackEndQuery = false;
38
38
  if (valueOptions.length && (valueOptions[valueOptions.length - 1].index === -1 || valueOptions[valueOptions.length - 1].index === undefined)) {
@@ -78,7 +78,7 @@ export default (function (rawValues, options, fieldNames, multiple, displayRende
78
78
  value: value,
79
79
  key: value,
80
80
  valueCells: valueCells,
81
- disabled: (_valueOptions = valueOptions[valueOptions.length - 1]) === null || _valueOptions === void 0 ? void 0 : (_valueOptions$option = _valueOptions.option) === null || _valueOptions$option === void 0 ? void 0 : _valueOptions$option.disabled
81
+ disabled: (_valueOptions = valueOptions[valueOptions.length - 1]) === null || _valueOptions === void 0 || (_valueOptions = _valueOptions.option) === null || _valueOptions === void 0 ? void 0 : _valueOptions.disabled
82
82
  };
83
83
  });
84
84
  }, [rawValues, options, fieldNames, displayRender, multiple, labelInValueOption]);
@@ -58,7 +58,9 @@ function Message(props) {
58
58
  requestOption = _props$requestOption === void 0 ? {} : _props$requestOption,
59
59
  closable = props.closable,
60
60
  _props$strongMessageO = props.strongMessageOption,
61
- strongMessageOption = _props$strongMessageO === void 0 ? {} : _props$strongMessageO;
61
+ strongMessageOption = _props$strongMessageO === void 0 ? {} : _props$strongMessageO,
62
+ _props$onSocketChange = props.onSocketChange,
63
+ onSocketChange = _props$onSocketChange === void 0 ? function () {} : _props$onSocketChange;
62
64
  var _useConfigContext = _useConfigContext2(),
63
65
  getPrefixCls = _useConfigContext.getPrefixCls;
64
66
  var prefixCls = getPrefixCls();
@@ -238,25 +240,27 @@ function Message(props) {
238
240
  });
239
241
  socket.on("push", /*#__PURE__*/function () {
240
242
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data) {
241
- var _JSON$parse, _JSON$parse$count$tot, total, message, noticeMessage, userMessageId, type, _ref6, enable, mode, _ref6$time, time;
243
+ var _JSON$parse, count, message, _ref6, _ref6$total, total, noticeMessage, userMessageId, type, _ref7, enable, mode, _ref7$time, time;
242
244
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
243
245
  while (1) switch (_context3.prev = _context3.next) {
244
246
  case 0:
245
- _JSON$parse = JSON.parse(data), _JSON$parse$count$tot = _JSON$parse.count.total, total = _JSON$parse$count$tot === void 0 ? 0 : _JSON$parse$count$tot, message = _JSON$parse.message;
247
+ _JSON$parse = JSON.parse(data), count = _JSON$parse.count, message = _JSON$parse.message;
248
+ _ref6 = count || {}, _ref6$total = _ref6.total, total = _ref6$total === void 0 ? 0 : _ref6$total;
246
249
  setMessageTotal(total);
250
+ onSocketChange(JSON.parse(data));
247
251
  if (message) {
248
252
  noticeMessage = message.noticeMessage;
249
253
  if (noticeMessage) {
250
254
  userMessageId = noticeMessage.id, type = noticeMessage.type;
251
255
  if (userMessageId) {
252
- _ref6 = messageOptionRef.current[type] || {}, enable = _ref6.enable, mode = _ref6.mode, _ref6$time = _ref6.time, time = _ref6$time === void 0 ? 5 : _ref6$time;
256
+ _ref7 = messageOptionRef.current[type] || {}, enable = _ref7.enable, mode = _ref7.mode, _ref7$time = _ref7.time, time = _ref7$time === void 0 ? 5 : _ref7$time;
253
257
  if (enable) {
254
258
  openNotification(time, userMessageId);
255
259
  }
256
260
  }
257
261
  }
258
262
  }
259
- case 3:
263
+ case 5:
260
264
  case "end":
261
265
  return _context3.stop();
262
266
  }
@@ -300,7 +304,7 @@ function Message(props) {
300
304
  };
301
305
  }();
302
306
  var getMessageQuerySettings = /*#__PURE__*/function () {
303
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
307
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
304
308
  var resRequestApi, res, data;
305
309
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
306
310
  while (1) switch (_context6.prev = _context6.next) {
@@ -321,7 +325,7 @@ function Message(props) {
321
325
  }, _callee6);
322
326
  }));
323
327
  return function getMessageQuerySettings() {
324
- return _ref8.apply(this, arguments);
328
+ return _ref9.apply(this, arguments);
325
329
  };
326
330
  }();
327
331
  return /*#__PURE__*/React.createElement("div", {
@@ -46,11 +46,14 @@ var DropdownMenu = function DropdownMenu(props) {
46
46
  setIsFocus = props.setIsFocus,
47
47
  historyList = props.historyList,
48
48
  setHistoryList = props.setHistoryList,
49
- format = props.format;
49
+ format = props.format,
50
+ timeSpanOption = props.timeSpanOption;
50
51
  var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
51
52
  _ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
52
53
  locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
53
54
  var localeObj = getLocale(locale);
55
+ var _timeSpanOption$timeS = timeSpanOption.timeSpanBoundary,
56
+ timeSpanBoundary = _timeSpanOption$timeS === void 0 ? 94608000 : _timeSpanOption$timeS;
54
57
  var _menuOption$showCalen = menuOption.showCalendar,
55
58
  showCalendar = _menuOption$showCalen === void 0 ? true : _menuOption$showCalen,
56
59
  _menuOption$showHisto = menuOption.showHistoryList,
@@ -77,13 +80,13 @@ var DropdownMenu = function DropdownMenu(props) {
77
80
  });
78
81
  returnValue = getCorrectValue(returnValue, item.key);
79
82
  onChange(returnValue);
80
- var _getHistoryInfo = getHistoryInfo(returnValue, historyList, locale, format),
83
+ var _getHistoryInfo = getHistoryInfo(returnValue, historyList, locale, format, timeSpanBoundary),
81
84
  _getHistoryInfo2 = _slicedToArray(_getHistoryInfo, 2),
82
85
  isRepeat = _getHistoryInfo2[0],
83
86
  historyValue = _getHistoryInfo2[1];
84
87
  if (!isRepeat) {
85
88
  setHistoryList(function (pre) {
86
- return [].concat(_toConsumableArray(pre), [historyValue]);
89
+ return [historyValue].concat(_toConsumableArray(pre));
87
90
  });
88
91
  }
89
92
  if (!_value) {
@@ -18,14 +18,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
18
18
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
19
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
20
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
- /*
22
- * @Author: andrew.qiao andrew.qiao@cloudwise.com
23
- * @Date: 2022-09-05 09:23:24
24
- * @LastEditors: andrew.qiao andrew.qiao@cloudwise.com
25
- * @LastEditTime: 2023-03-30 18:18:34
26
- * @FilePath: /change_01/aops_web_commons/packages/ui/components/CWRangePicker1/Refresh/index.js
27
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
28
- */
29
21
  import React, { forwardRef, useImperativeHandle } from "react";
30
22
  import classnames from "classnames";
31
23
  import Refresh1Svg from "../assets/Refresh1";
@@ -42,9 +34,9 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
42
34
  setIsAutoRefresh = props.setIsAutoRefresh,
43
35
  refreshOption = props.refreshOption,
44
36
  isHasDate = props.isHasDate,
45
- setBackTooltipVisible = props.setBackTooltipVisible,
46
37
  enableAutoRefresh = props.enableAutoRefresh,
47
- isClickAutoRefresh = props.isClickAutoRefresh;
38
+ isClickAutoRefresh = props.isClickAutoRefresh,
39
+ timeSpanOption = props.timeSpanOption;
48
40
  var _refreshOption$onAuto = refreshOption.onAutoRefreshChange,
49
41
  onAutoRefreshChange = _refreshOption$onAuto === void 0 ? function () {} : _refreshOption$onAuto,
50
42
  _refreshOption$onClic = refreshOption.onClickRefresh,
@@ -57,6 +49,8 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
57
49
  showAutoRefresh = _refreshOption$showAu === void 0 ? true : _refreshOption$showAu,
58
50
  _refreshOption$showRe = refreshOption.showRefresh,
59
51
  showRefresh = _refreshOption$showRe === void 0 ? true : _refreshOption$showRe;
52
+ var _timeSpanOption$timeS = timeSpanOption.timeSpanBoundary,
53
+ timeSpanBoundary = _timeSpanOption$timeS === void 0 ? 94608000 : _timeSpanOption$timeS;
60
54
  var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
61
55
  _ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
62
56
  locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
@@ -76,7 +70,7 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
76
70
  value: computedRecentlyValue(values)
77
71
  });
78
72
  }
79
- if (isRule) {
73
+ if (isRule && !values) {
80
74
  returnValue = _objectSpread(_objectSpread({}, recordDateValue), {}, {
81
75
  value: getChangeUnitDate(captureUnit[0], captureUnit[1])
82
76
  });
@@ -86,7 +80,6 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
86
80
  };
87
81
  // 自动刷新
88
82
  var onAutoRefresh = function onAutoRefresh() {
89
- setBackTooltipVisible(false);
90
83
  onClickAutoRefresh(!enableAutoRefresh);
91
84
  isClickAutoRefresh.current = true;
92
85
  if (isHasDate) {
@@ -104,13 +97,13 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
104
97
  if (!enableAutoRefresh) {
105
98
  if (values) {
106
99
  values = computedRecentlyValue(values);
107
- finalRecordDateValue = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, finalRecordDateValue), rest), getTimeSpanFromValue(values)), {}, {
100
+ finalRecordDateValue = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, finalRecordDateValue), rest), getTimeSpanFromValue(values, timeSpanBoundary)), {}, {
108
101
  isRecently: true
109
102
  });
110
103
  }
111
- if (isRule) {
104
+ if (isRule && !values) {
112
105
  values = getChangeUnitDate(captureUnit[0], captureUnit[1]);
113
- finalRecordDateValue = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, finalRecordDateValue), rest), getTimeSpanFromValue(values)), {}, {
106
+ finalRecordDateValue = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, finalRecordDateValue), rest), getTimeSpanFromValue(values, timeSpanBoundary)), {}, {
114
107
  isRecently: true
115
108
  });
116
109
  }
@@ -120,7 +113,7 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
120
113
  value: computedRecentlyValue(values)
121
114
  });
122
115
  }
123
- if (isRule) {
116
+ if (isRule && !values) {
124
117
  finalRecordDateValue = _objectSpread(_objectSpread({}, finalRecordDateValue), {}, {
125
118
  value: getChangeUnitDate(captureUnit[0], captureUnit[1])
126
119
  });
@@ -1,8 +1,8 @@
1
1
  import "@chaoswise/ui/lib/Tooltip/index.less";
2
2
  import _Tooltip from "@chaoswise/ui/lib/Tooltip";
3
+ import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
3
4
  import "@chaoswise/ui/lib/Button/index.less";
4
5
  import _Button from "@chaoswise/ui/lib/Button";
5
- import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
6
6
  /*
7
7
  * @Author: andrew.qiao andrew.qiao@cloudwise.com
8
8
  * @Date: 2022-08-11 18:23:40
@@ -15,22 +15,17 @@ import React from "react";
15
15
  import { getChangeDate } from "../utils";
16
16
  import { getLocale } from "../locale";
17
17
  import "./index.less";
18
+ _Button.__ANT_BUTTON = true;
18
19
  var TimeSpan = function TimeSpan(props) {
19
20
  var onChange = props.onChange,
20
- growSize = props.growSize,
21
21
  recordDateValue = props.recordDateValue,
22
22
  setRecordDateValue = props.setRecordDateValue,
23
23
  _value = props.value,
24
24
  isHasDate = props.isHasDate,
25
25
  onRecover = props.onRecover,
26
26
  timeSpanOption = props.timeSpanOption,
27
- forwardTooltipVisible = props.forwardTooltipVisible,
28
- setForwardTooltipVisible = props.setForwardTooltipVisible,
29
- backTooltipVisible = props.backTooltipVisible,
30
- setBackTooltipVisible = props.setBackTooltipVisible,
31
- expandTooltipVisible = props.expandTooltipVisible,
32
- setExpandTooltipVisible = props.setExpandTooltipVisible,
33
- isRightDisabled = props.isRightDisabled;
27
+ isRightDisabled = props.isRightDisabled,
28
+ isDisabledEnlargeBtn = props.isDisabledEnlargeBtn;
34
29
  var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
35
30
  _ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
36
31
  locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
@@ -45,15 +40,19 @@ var TimeSpan = function TimeSpan(props) {
45
40
  tooltipTitleCustom = _timeSpanOption$toolt === void 0 ? {} : _timeSpanOption$toolt,
46
41
  forwardIcon = timeSpanOption.forwardIcon,
47
42
  backIcon = timeSpanOption.backIcon,
48
- expandIcon = timeSpanOption.expandIcon;
43
+ expandIcon = timeSpanOption.expandIcon,
44
+ _timeSpanOption$growS = timeSpanOption.growSize,
45
+ growSize = _timeSpanOption$growS === void 0 ? 3 : _timeSpanOption$growS,
46
+ _timeSpanOption$timeS = timeSpanOption.timeSpanBoundary,
47
+ timeSpanBoundary = _timeSpanOption$timeS === void 0 ? 94608000 : _timeSpanOption$timeS;
49
48
  var _tooltipTitleCustom$f = tooltipTitleCustom.forwardTitle,
50
49
  forwardTitle = _tooltipTitleCustom$f === void 0 ? localeObj["forwardSmooth"] : _tooltipTitleCustom$f,
51
50
  _tooltipTitleCustom$b = tooltipTitleCustom.backTitle,
52
51
  backTitle = _tooltipTitleCustom$b === void 0 ? localeObj["backSmooth"] : _tooltipTitleCustom$b,
53
52
  _tooltipTitleCustom$e = tooltipTitleCustom.expandTitle,
54
- expandTitle = _tooltipTitleCustom$e === void 0 ? localeObj["ExpandSpan"] : _tooltipTitleCustom$e;
53
+ expandTitle = _tooltipTitleCustom$e === void 0 ? localeObj["ExpandSpan"].replace('{span}', "".concat(growSize)) : _tooltipTitleCustom$e;
55
54
  var onChangeTimeSpan = function onChangeTimeSpan(direction) {
56
- var _getChangeDate = getChangeDate(recordDateValue, direction, growSize),
55
+ var _getChangeDate = getChangeDate(recordDateValue, direction, growSize, timeSpanBoundary),
57
56
  value = _getChangeDate.value,
58
57
  isInvalidDate = _getChangeDate.isInvalidDate,
59
58
  switchInitial = _getChangeDate.switchInitial;
@@ -70,26 +69,14 @@ var TimeSpan = function TimeSpan(props) {
70
69
  return isHasDate && showTimeSpan && /*#__PURE__*/React.createElement(_Button.Group, {
71
70
  className: "cw-range-picker-time-span-wrapper"
72
71
  }, /*#__PURE__*/React.createElement(_Tooltip, {
73
- title: forwardTitle,
74
- onVisibleChange: function onVisibleChange(visible) {
75
- setForwardTooltipVisible(visible);
76
- },
77
- visible: forwardTooltipVisible
72
+ title: forwardTitle
78
73
  }, showForwardBtn && /*#__PURE__*/React.createElement(_Button, {
79
74
  icon: forwardIcon ? forwardIcon : "caret-left",
80
75
  onClick: function onClick() {
81
76
  onChangeTimeSpan("left");
82
- },
83
- onMouseOver: function onMouseOver() {
84
- setForwardTooltipVisible(true);
85
- setBackTooltipVisible(false);
86
77
  }
87
78
  })), /*#__PURE__*/React.createElement(_Tooltip, {
88
- title: backTitle,
89
- visible: isRightDisabled ? false : backTooltipVisible,
90
- onVisibleChange: function onVisibleChange(visible) {
91
- setBackTooltipVisible(visible);
92
- }
79
+ title: backTitle
93
80
  }, showBackwardBtn && /*#__PURE__*/React.createElement(_Button, {
94
81
  icon: backIcon ? backIcon : "caret-right",
95
82
  onClick: function onClick() {
@@ -97,19 +84,13 @@ var TimeSpan = function TimeSpan(props) {
97
84
  },
98
85
  disabled: isRightDisabled
99
86
  })), showEnlargeBtn && /*#__PURE__*/React.createElement(_Tooltip, {
100
- title: expandTitle,
101
- onVisibleChange: function onVisibleChange(visible) {
102
- setExpandTooltipVisible(visible);
103
- },
104
- visible: expandTooltipVisible
87
+ title: expandTitle
105
88
  }, /*#__PURE__*/React.createElement(_Button, {
106
- icon: expandIcon ? expandIcon : "zoom-out",
89
+ icon: expandIcon ? expandIcon : "zoom-in",
107
90
  onClick: function onClick() {
108
91
  onChangeTimeSpan("even");
109
92
  },
110
- onMouseOver: function onMouseOver() {
111
- setExpandTooltipVisible(true);
112
- }
93
+ disabled: isDisabledEnlargeBtn
113
94
  })));
114
95
  };
115
96
  export default TimeSpan;
@@ -41,7 +41,7 @@ import Refresh from "./Refresh";
41
41
  import CalendarSvg from "./assets/Calendar";
42
42
  import LiveSvg from "./assets/live";
43
43
  import RecoverSvg from "./assets/Recover";
44
- import { regroupDataSourceFn, echoInputValue, getUnit, judgeType, getChangeUnitDate, isInvalidDate, range, funcValueChangeArrayValue, getCorrectValue, getHistoryInfo, getFinalDateOption, getTruthDateCount, isAfterDate, isSameDate } from "./utils";
44
+ import { regroupDataSourceFn, echoInputValue, getUnit, judgeType, getChangeUnitDate, isInvalidDate, range, funcValueChangeArrayValue, getCorrectValue, getHistoryInfo, getFinalDateOption, getTruthDateCount, isAfterDate, isSameDate, isExceedMaxTimeSpan, getYears, computedRecentlyValue } from "./utils";
45
45
  import _ from "lodash";
46
46
  import moment from "moment";
47
47
  import "./index.less";
@@ -55,8 +55,6 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
55
55
  _onChange = _props$onChange === void 0 ? function () {} : _props$onChange,
56
56
  _props$onInitChange = props.onInitChange,
57
57
  _onInitChange = _props$onInitChange === void 0 ? function () {} : _props$onInitChange,
58
- _props$growSize = props.growSize,
59
- growSize = _props$growSize === void 0 ? 3 : _props$growSize,
60
58
  _props$tipTooltipOpti = props.tipTooltipOption,
61
59
  tipTooltipOption = _props$tipTooltipOpti === void 0 ? {} : _props$tipTooltipOpti,
62
60
  _props$menuOption = props.menuOption,
@@ -89,6 +87,8 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
89
87
  showAutoRefresh = _refreshOption$showAu === void 0 ? true : _refreshOption$showAu,
90
88
  _refreshOption$isRece = refreshOption.isRecentlyOpenRefresh,
91
89
  isRecentlyOpenRefresh = _refreshOption$isRece === void 0 ? true : _refreshOption$isRece;
90
+ var _timeSpanOption$timeS = timeSpanOption.timeSpanBoundary,
91
+ timeSpanBoundary = _timeSpanOption$timeS === void 0 ? 94608000 : _timeSpanOption$timeS;
92
92
  var _menuOption$showCalen = menuOption.showCalendar,
93
93
  showCalendar = _menuOption$showCalen === void 0 ? true : _menuOption$showCalen,
94
94
  _menuOption$exceedSho = menuOption.exceedShowInMore,
@@ -139,19 +139,6 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
139
139
  _useState14 = _slicedToArray(_useState13, 2),
140
140
  historyList = _useState14[0],
141
141
  setHistoryList = _useState14[1];
142
- // 启用禁用状态Button切换导致Tooltip异常特殊处理
143
- var _useState15 = useState(false),
144
- _useState16 = _slicedToArray(_useState15, 2),
145
- forwardTooltipVisible = _useState16[0],
146
- setForwardTooltipVisible = _useState16[1];
147
- var _useState17 = useState(false),
148
- _useState18 = _slicedToArray(_useState17, 2),
149
- backTooltipVisible = _useState18[0],
150
- setBackTooltipVisible = _useState18[1];
151
- var _useState19 = useState(false),
152
- _useState20 = _slicedToArray(_useState19, 2),
153
- expandTooltipVisible = _useState20[0],
154
- setExpandTooltipVisible = _useState20[1];
155
142
  // 特殊时间选择器外壳容器
156
143
  var calendarRef = useRef(null);
157
144
  // 定时器计数
@@ -162,10 +149,10 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
162
149
  var inputRef = useRef(null);
163
150
  // 含有刷新组件暴露的方法
164
151
  var refreshRef = useRef(null);
165
- var _useState21 = useState([]),
166
- _useState22 = _slicedToArray(_useState21, 2),
167
- rangePickerValue = _useState22[0],
168
- setRangePickerValue = _useState22[1];
152
+ var _useState15 = useState([]),
153
+ _useState16 = _slicedToArray(_useState15, 2),
154
+ rangePickerValue = _useState16[0],
155
+ setRangePickerValue = _useState16[1];
169
156
  // 组件内部方法抛出
170
157
  useImperativeHandle(ref, function () {
171
158
  var _refreshRef$current;
@@ -223,8 +210,8 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
223
210
  }, [openAutoRefresh, isAutoRefresh]);
224
211
  // 输入框回显
225
212
  useEffect(function () {
226
- setInputValue(echoInputValue(recordDateValue, isFocus, locale, format, forceRenderTitle, enableAutoRefresh));
227
- }, [recordDateValue, isFocus, locale, format, forceRenderTitle, enableAutoRefresh]);
213
+ setInputValue(echoInputValue(recordDateValue, isFocus, locale, format, forceRenderTitle, enableAutoRefresh, timeSpanBoundary));
214
+ }, [recordDateValue, isFocus, locale, format, forceRenderTitle, enableAutoRefresh, timeSpanBoundary]);
228
215
  useEffect(function () {
229
216
  var _judgeType3 = judgeType(recordDateValue),
230
217
  _judgeType4 = _slicedToArray(_judgeType3, 1),
@@ -274,11 +261,17 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
274
261
  recordUnit = _judgeType6[2];
275
262
  if (enableAutoRefresh && isRule && showAutoRefresh) {
276
263
  timeRef.current = setInterval(function () {
264
+ var _values = [];
265
+ if (values) {
266
+ _values = computedRecentlyValue(values);
267
+ } else {
268
+ _values = getChangeUnitDate(captureUnit[0], captureUnit[1]);
269
+ }
277
270
  var newValue = _objectSpread(_objectSpread({}, recordDateValue), {}, {
278
271
  timeDomain: recordUnit,
279
272
  number: captureUnit[0],
280
273
  unit: captureUnit[1] === "mo" ? "M" : captureUnit[1],
281
- value: getChangeUnitDate(captureUnit[0], captureUnit[1]),
274
+ value: _values,
282
275
  isRecently: true
283
276
  });
284
277
  onAutoRefresh(newValue);
@@ -304,19 +297,27 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
304
297
  values = funcValueChangeArrayValue(values);
305
298
  var isHasDate = true;
306
299
  var isRightDisabled = false;
300
+ var isDisabledEnlargeBtn = false;
301
+ var years = getYears(timeSpanBoundary);
307
302
  if (isRule) {
308
303
  isRightDisabled = true;
309
- values = getChangeUnitDate(captureUnit[0], captureUnit[1]);
304
+ if (!values) {
305
+ values = getChangeUnitDate(captureUnit[0], captureUnit[1]);
306
+ }
307
+ if (captureUnit[1] === "y" && Number(captureUnit[0]) >= years) {
308
+ isDisabledEnlargeBtn = true;
309
+ }
310
310
  }
311
311
  if (!isRule && !values) {
312
312
  isHasDate = false;
313
313
  }
314
- return [isHasDate, values, isRightDisabled];
315
- }, [recordDateValue]),
316
- _useMemo2 = _slicedToArray(_useMemo, 3),
314
+ return [isHasDate, values, isRightDisabled, isDisabledEnlargeBtn];
315
+ }, [recordDateValue, timeSpanBoundary]),
316
+ _useMemo2 = _slicedToArray(_useMemo, 4),
317
317
  isHasDate = _useMemo2[0],
318
318
  _defaultValue = _useMemo2[1],
319
- isRightDisabled = _useMemo2[2];
319
+ isRightDisabled = _useMemo2[2],
320
+ isDisabledEnlargeBtn = _useMemo2[3];
320
321
  // 点击空白处日历切换
321
322
  useEffect(function () {
322
323
  document.addEventListener("click", clickBody);
@@ -437,15 +438,20 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
437
438
  var isInvalidDate_ = isInvalidDate(returnValue.value);
438
439
  if (!isInvalidDate_) {
439
440
  // message.success(localeObj["fit-the-input-format"]);
441
+ var passValue = returnValue.value;
442
+ if (isExceedMaxTimeSpan(passValue, timeSpanBoundary)) {
443
+ _message.error(localeObj["the-maximum-time-span-is-exceeded"]);
444
+ return;
445
+ }
440
446
  _onChange(returnValue);
441
447
  setIsFocus(false);
442
- var _getHistoryInfo = getHistoryInfo(returnValue, historyList, locale, format),
448
+ var _getHistoryInfo = getHistoryInfo(returnValue, historyList, locale, format, timeSpanBoundary),
443
449
  _getHistoryInfo2 = _slicedToArray(_getHistoryInfo, 2),
444
450
  isRepeat = _getHistoryInfo2[0],
445
451
  historyValue = _getHistoryInfo2[1];
446
452
  if (!isRepeat) {
447
453
  setHistoryList(function (pre) {
448
- return [].concat(_toConsumableArray(pre), [historyValue]);
454
+ return [historyValue].concat(_toConsumableArray(pre));
449
455
  });
450
456
  }
451
457
  if (!value) {
@@ -462,15 +468,20 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
462
468
  var _returnValue = getCorrectValue({
463
469
  value: _dateValue2
464
470
  });
471
+ var _passValue = _returnValue.value;
472
+ if (isExceedMaxTimeSpan(_passValue, timeSpanBoundary)) {
473
+ _message.error(localeObj["the-maximum-time-span-is-exceeded"]);
474
+ return;
475
+ }
465
476
  _onChange(_returnValue);
466
477
  setIsFocus(false);
467
- var _getHistoryInfo3 = getHistoryInfo(_returnValue, historyList, locale, format),
478
+ var _getHistoryInfo3 = getHistoryInfo(_returnValue, historyList, locale, format, timeSpanBoundary),
468
479
  _getHistoryInfo4 = _slicedToArray(_getHistoryInfo3, 2),
469
480
  _isRepeat = _getHistoryInfo4[0],
470
481
  _historyValue = _getHistoryInfo4[1];
471
482
  if (!_isRepeat) {
472
483
  setHistoryList(function (pre) {
473
- return [].concat(_toConsumableArray(pre), [_historyValue]);
484
+ return [_historyValue].concat(_toConsumableArray(pre));
474
485
  });
475
486
  }
476
487
  if (!value) {
@@ -490,7 +501,8 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
490
501
  isAutoRefresh: isAutoRefresh,
491
502
  setIsAutoRefresh: setIsAutoRefresh,
492
503
  refreshOption: refreshOption,
493
- enableAutoRefresh: enableAutoRefresh
504
+ enableAutoRefresh: enableAutoRefresh,
505
+ timeSpanOption: timeSpanOption
494
506
  };
495
507
  var dropdownMenuProps = _objectSpread(_objectSpread({}, commonProps), {}, {
496
508
  dataSource: dataSource,
@@ -505,21 +517,13 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
505
517
  });
506
518
  var timeSpanProps = _objectSpread(_objectSpread({}, commonProps), {}, {
507
519
  dataSource: dataSource,
508
- growSize: growSize,
509
520
  isHasDate: isHasDate,
510
521
  onRecover: onRecover,
511
- timeSpanOption: timeSpanOption,
512
- forwardTooltipVisible: forwardTooltipVisible,
513
- setForwardTooltipVisible: setForwardTooltipVisible,
514
- backTooltipVisible: backTooltipVisible,
515
- setBackTooltipVisible: setBackTooltipVisible,
516
- expandTooltipVisible: expandTooltipVisible,
517
- setExpandTooltipVisible: setExpandTooltipVisible,
518
- isRightDisabled: isRightDisabled
522
+ isRightDisabled: isRightDisabled,
523
+ isDisabledEnlargeBtn: isDisabledEnlargeBtn
519
524
  });
520
525
  var refreshProps = _objectSpread(_objectSpread({}, commonProps), {}, {
521
526
  isHasDate: isHasDate,
522
- setBackTooltipVisible: setBackTooltipVisible,
523
527
  isClickAutoRefresh: isClickAutoRefresh
524
528
  });
525
529
  return /*#__PURE__*/React.createElement("div", {
@@ -554,14 +558,18 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
554
558
  _message.error(localeObj["the-selected-time-does-not-meet-the-rule-limit"]);
555
559
  return;
556
560
  }
561
+ if (isExceedMaxTimeSpan(resValue, timeSpanBoundary)) {
562
+ _message.error(localeObj["the-maximum-time-span-is-exceeded"]);
563
+ return;
564
+ }
557
565
  _onChange(_values2);
558
- var _getHistoryInfo5 = getHistoryInfo(_values2, historyList, locale, format),
566
+ var _getHistoryInfo5 = getHistoryInfo(_values2, historyList, locale, format, timeSpanBoundary),
559
567
  _getHistoryInfo6 = _slicedToArray(_getHistoryInfo5, 2),
560
568
  isRepeat = _getHistoryInfo6[0],
561
569
  historyValue = _getHistoryInfo6[1];
562
570
  if (!isRepeat) {
563
571
  setHistoryList(function (pre) {
564
- return [].concat(_toConsumableArray(pre), [historyValue]);
572
+ return [historyValue].concat(_toConsumableArray(pre));
565
573
  });
566
574
  }
567
575
  if (!value) {
@@ -675,7 +683,6 @@ var CWRangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
675
683
  });
676
684
  CWRangePicker.defaultProps = {
677
685
  moreItemDropdownPosition: "left",
678
- growSize: 3,
679
686
  format: "YYYY/MM/DD HH:mm:ss",
680
687
  rangePickerFormat: "YYYY/MM/DD"
681
688
  };
@@ -704,10 +711,6 @@ CWRangePicker.propTypes = {
704
711
  * 初始时间数据进入时间返回的回调(*主要针对于最近时间)
705
712
  */
706
713
  onInitChange: PropTypes.func,
707
- /**
708
- * 时间跨度的比例,>=2,默认为3
709
- */
710
- growSize: PropTypes.number,
711
714
  /**
712
715
  * 提示信息TooltipOption
713
716
  */
@@ -10,7 +10,7 @@ export default {
10
10
  recover: "Restore default",
11
11
  forwardSmooth: "Forward smooth",
12
12
  backSmooth: "Back smooth",
13
- ExpandSpan: "Zoom Out",
13
+ ExpandSpan: "Increase the time span by {span} times",
14
14
  refresh: "Refresh",
15
15
  autoRefresh: "Auto refresh",
16
16
  s: "Second",
@@ -31,5 +31,6 @@ export default {
31
31
  "enter manually": "You can manually enter a query statement in the following format",
32
32
  "fit-the-input-format": "Fit the input format",
33
33
  "does-not-match-the-input-format": "Does not match the input format",
34
- "the-selected-time-does-not-meet-the-rule-limit": "If the selected time is the same or exceeds the current time, select another time"
34
+ "the-selected-time-does-not-meet-the-rule-limit": "If the selected time is the same or exceeds the current time, select another time",
35
+ "the-maximum-time-span-is-exceeded": "The maximum time span is exceeded, please re-enter"
35
36
  };
@@ -10,7 +10,7 @@ export default {
10
10
  recover: "恢复默认值",
11
11
  forwardSmooth: "向前平滑",
12
12
  backSmooth: "向后平滑",
13
- ExpandSpan: "缩小时间跨度",
13
+ ExpandSpan: "按{span}倍增加时间跨度",
14
14
  refresh: "刷新",
15
15
  autoRefresh: "自动刷新",
16
16
  s: "秒",
@@ -31,5 +31,6 @@ export default {
31
31
  "enter manually": "可根据以下类型,按查询语句格式手动输入",
32
32
  "fit-the-input-format": "符合输入格式",
33
33
  "does-not-match-the-input-format": "不符合输入格式,请重新输入",
34
- "the-selected-time-does-not-meet-the-rule-limit": "选择的时间二者相同或者某一时间超过当前时间,请重新选择"
34
+ "the-selected-time-does-not-meet-the-rule-limit": "选择的时间二者相同或者某一时间超过当前时间,请重新选择",
35
+ "the-maximum-time-span-is-exceeded": "超过了限制的最大时间跨度,请重新输入"
35
36
  };