@chaoswise/ui 2.3.1 → 2.3.3

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.
@@ -4,7 +4,7 @@ import _ErrorBoundary from "@chaoswise/ui/lib/ErrorBoundary";
4
4
  import "@chaoswise/ui/lib/Header/index.less";
5
5
  import _Header from "@chaoswise/ui/lib/Header";
6
6
  import _Layout from "@chaoswise/ui/lib/Antd/Layout";
7
- var _excluded = ["logo", "headerTitle", "headerExtra", "showHome", "onClickHome", "showTopNavigation", "topNavigation", "topNavigationClassName", "topNavigationTrigger", "onClickTopNavigation", "siderMenu", "children", "siderWidth", "siderCollapsedWidth", "collapsed", "onCollapse", "showHead", "showBreadcrumb", "showBack", "onClickBack", "backNavigationTitle", "backIcon", "showSider", "breadcrumbOptions", "menuOptions", "contentClassName", "currentPath", "className", "version", "versionTooltip", "customContent", "allProductsTitle", "logoText", "localeSwitcherOption", "messageOption", "documentOption", "userSetingOption", "logoSize", "renderSetting", "showMessage", "homeIcon", "contentOption", "ErrorBoundary", "onPassWidth"];
7
+ var _excluded = ["logo", "headerTitle", "headerExtra", "showHome", "onClickHome", "showTopNavigation", "topNavigation", "topNavigationClassName", "topNavigationTrigger", "onClickTopNavigation", "siderMenu", "children", "siderWidth", "siderCollapsedWidth", "collapsed", "onCollapse", "showHead", "showBreadcrumb", "showBack", "onClickBack", "backNavigationTitle", "backIcon", "showSider", "breadcrumbOptions", "menuOptions", "contentClassName", "currentPath", "className", "version", "versionTooltip", "customContent", "allProductsTitle", "logoText", "localeSwitcherOption", "messageOption", "documentOption", "userSetingOption", "logoSize", "renderSetting", "showMessage", "homeIcon", "contentOption", "ErrorBoundary", "onPassWidth", "topNavigationOption"];
8
8
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
9
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
10
  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."); }
@@ -93,6 +93,8 @@ var BasicLayout = function BasicLayout(_ref) {
93
93
  ErrorBoundary = _ref$ErrorBoundary === void 0 ? true : _ref$ErrorBoundary,
94
94
  _ref$onPassWidth = _ref.onPassWidth,
95
95
  onPassWidth = _ref$onPassWidth === void 0 ? function () {} : _ref$onPassWidth,
96
+ _ref$topNavigationOpt = _ref.topNavigationOption,
97
+ topNavigationOption = _ref$topNavigationOpt === void 0 ? {} : _ref$topNavigationOpt,
96
98
  rest = _objectWithoutProperties(_ref, _excluded);
97
99
  var _useConfigContext = useConfigContext(),
98
100
  getPrefixCls = _useConfigContext.getPrefixCls;
@@ -271,7 +273,8 @@ var BasicLayout = function BasicLayout(_ref) {
271
273
  documentOption: documentOption,
272
274
  userSetingOption: userSetingOption,
273
275
  showMessage: showMessage,
274
- homeIcon: homeIcon
276
+ homeIcon: homeIcon,
277
+ topNavigationOption: topNavigationOption
275
278
  })), specialContent && /*#__PURE__*/React.createElement("div", {
276
279
  className: classnames(specialContentClassName)
277
280
  }, specialContent), /*#__PURE__*/React.createElement(_Layout, {
@@ -497,7 +500,17 @@ BasicLayout.propTypes = {
497
500
  /**
498
501
  * 左侧菜单展开宽度值
499
502
  */
500
- onPassWidth: PropTypes.func
503
+ onPassWidth: PropTypes.func,
504
+ /**
505
+ * 顶部导航配置(主要针对unfold类型):{
506
+ * topNavigationType: PropTypes.oneOf(["fold", "unfold"]), // 默认为fold,fold会将所有产品折叠收纳,unfold会将所有产品平铺
507
+ * activeKey: PropTypes.string, // 受控的活跃的key
508
+ * unfoldMaxCount: PropTypes.number // 默认值为4,topNavigationType为unfold类型时,超过unfoldMaxCount数目将会展示到更多中
509
+ * moreOverlayClassName: PropTypes.string // 更多浮层类名
510
+ * topNavigationWrapperClassName: PropTypes.string // 导航外壳容器类名
511
+ * }
512
+ */
513
+ topNavigationOption: PropTypes.object
501
514
  };
502
515
  BasicLayout.Footer = Footer;
503
516
  export default BasicLayout;
@@ -14,7 +14,6 @@ import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
14
14
  import React from "react";
15
15
  import classnames from "classnames";
16
16
  import { getLocale } from "../../locale";
17
- import _ from "lodash";
18
17
  import "./index.less";
19
18
  var MoreTimeList = function MoreTimeList(props) {
20
19
  var regroupDataSource = props.regroupDataSource,
@@ -32,7 +32,6 @@ import MoreSvg from "../assets/more";
32
32
  import MoreTimeList from "./MoreTimeList";
33
33
  import MoreHistoryList from "./MoreHistoryList";
34
34
  import { judgeType, funcValueChangeArrayValue, getCorrectValue, getHistoryInfo } from "../utils";
35
- import _ from "lodash";
36
35
  import "./index.less";
37
36
  var DropdownMenu = function DropdownMenu(props) {
38
37
  var dataSource = props.dataSource,
@@ -47,9 +46,7 @@ var DropdownMenu = function DropdownMenu(props) {
47
46
  setIsFocus = props.setIsFocus,
48
47
  historyList = props.historyList,
49
48
  setHistoryList = props.setHistoryList,
50
- format = props.format,
51
- setIsAutoRefresh = props.setIsAutoRefresh,
52
- refreshOption = props.refreshOption;
49
+ format = props.format;
53
50
  var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
54
51
  _ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
55
52
  locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
@@ -64,8 +61,6 @@ var DropdownMenu = function DropdownMenu(props) {
64
61
  showDefaultHistoryCount = _menuOption$showDefau2 === void 0 ? 5 : _menuOption$showDefau2,
65
62
  _menuOption$moreHisto = menuOption.moreHistoryDropdownPosition,
66
63
  moreHistoryDropdownPosition = _menuOption$moreHisto === void 0 ? "left" : _menuOption$moreHisto;
67
- var _refreshOption$onAuto = refreshOption.onAutoRefreshChange,
68
- onAutoRefreshChange = _refreshOption$onAuto === void 0 ? function () {} : _refreshOption$onAuto;
69
64
  // 点击Menu.Item中切换选项列表
70
65
  var onClickItem = function onClickItem(item) {
71
66
  var timeDomain = recordDateValue.timeDomain,
@@ -81,17 +76,6 @@ var DropdownMenu = function DropdownMenu(props) {
81
76
  value: funcValueChangeArrayValue(values)
82
77
  });
83
78
  returnValue = getCorrectValue(returnValue, item.key);
84
- var _judgeType = judgeType(returnValue),
85
- _judgeType2 = _slicedToArray(_judgeType, 1),
86
- isRule = _judgeType2[0];
87
- if (!isRule && !returnValue.value) {
88
- setIsAutoRefresh(function (pre) {
89
- if (!pre) {
90
- onAutoRefreshChange(true);
91
- }
92
- return true;
93
- });
94
- }
95
79
  onChange(returnValue);
96
80
  var _getHistoryInfo = getHistoryInfo(returnValue, historyList, locale, format),
97
81
  _getHistoryInfo2 = _slicedToArray(_getHistoryInfo, 2),
@@ -123,17 +107,6 @@ var DropdownMenu = function DropdownMenu(props) {
123
107
  value: funcValueChangeArrayValue(values)
124
108
  });
125
109
  returnValue = getCorrectValue(returnValue, timeDomain);
126
- var _judgeType3 = judgeType(returnValue),
127
- _judgeType4 = _slicedToArray(_judgeType3, 1),
128
- isRule = _judgeType4[0];
129
- if (!isRule && !returnValue.value) {
130
- setIsAutoRefresh(function (pre) {
131
- if (!pre) {
132
- onAutoRefreshChange(true);
133
- }
134
- return true;
135
- });
136
- }
137
110
  onChange(returnValue);
138
111
  if (!_value) {
139
112
  setRecordDateValue(returnValue);
@@ -158,9 +131,9 @@ var DropdownMenu = function DropdownMenu(props) {
158
131
  className: classnames("cw-dropdown-menu-wrapper")
159
132
  }, dataSource === null || dataSource === void 0 ? void 0 : dataSource.slice(0, showDefaultCount).map(function (item) {
160
133
  var values = item.value;
161
- var _judgeType5 = judgeType(item),
162
- _judgeType6 = _slicedToArray(_judgeType5, 1),
163
- isRule = _judgeType6[0];
134
+ var _judgeType = judgeType(item),
135
+ _judgeType2 = _slicedToArray(_judgeType, 1),
136
+ isRule = _judgeType2[0];
164
137
  var isHasDate = true;
165
138
  if (!isRule && !values) {
166
139
  isHasDate = false;
@@ -12,6 +12,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
12
12
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
13
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
14
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
16
+ 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."); }
17
+ 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); }
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
+ 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
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
21
  /*
16
22
  * @Author: andrew.qiao andrew.qiao@cloudwise.com
17
23
  * @Date: 2022-09-05 09:23:24
@@ -25,7 +31,7 @@ import classnames from "classnames";
25
31
  import Refresh1Svg from "../assets/Refresh1";
26
32
  import Refresh2Svg from "../assets/Refresh2";
27
33
  import Refresh3Svg from "../assets/Refresh3";
28
- import { getUnit, getChangeUnitDate, funcValueChangeArrayValue, getTimeSpanFromValue, computedRecentlyValue } from "../utils";
34
+ import { getChangeUnitDate, funcValueChangeArrayValue, getTimeSpanFromValue, computedRecentlyValue, judgeType } from "../utils";
29
35
  import { getLocale } from "../locale";
30
36
  import "./index.less";
31
37
  var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
@@ -33,11 +39,12 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
33
39
  setRecordDateValue = props.setRecordDateValue,
34
40
  onChange = props.onChange,
35
41
  value = props.value,
36
- isAutoRefresh = props.isAutoRefresh,
37
42
  setIsAutoRefresh = props.setIsAutoRefresh,
38
43
  refreshOption = props.refreshOption,
39
44
  isHasDate = props.isHasDate,
40
- setBackTooltipVisible = props.setBackTooltipVisible;
45
+ setBackTooltipVisible = props.setBackTooltipVisible,
46
+ enableAutoRefresh = props.enableAutoRefresh,
47
+ isClickAutoRefresh = props.isClickAutoRefresh;
41
48
  var _refreshOption$onAuto = refreshOption.onAutoRefreshChange,
42
49
  onAutoRefreshChange = _refreshOption$onAuto === void 0 ? function () {} : _refreshOption$onAuto,
43
50
  _refreshOption$onClic = refreshOption.onClickRefresh,
@@ -56,14 +63,14 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
56
63
  var localeObj = getLocale(locale);
57
64
  // 手动刷新
58
65
  var onRefresh = function onRefresh() {
59
- var values = recordDateValue.value,
60
- key = recordDateValue.key;
61
- var _getUnit = getUnit(key),
62
- isRule = _getUnit.isRule,
63
- captureUnit = _getUnit.captureUnit;
66
+ var values = recordDateValue.value;
67
+ var _judgeType = judgeType(recordDateValue),
68
+ _judgeType2 = _slicedToArray(_judgeType, 2),
69
+ isRule = _judgeType2[0],
70
+ captureUnit = _judgeType2[1];
64
71
  var returnValue = _objectSpread({}, recordDateValue);
65
72
  values = funcValueChangeArrayValue(values);
66
- if (isAutoRefresh) {
73
+ if (enableAutoRefresh) {
67
74
  if (values) {
68
75
  returnValue = _objectSpread(_objectSpread({}, returnValue), {}, {
69
76
  value: computedRecentlyValue(values)
@@ -80,25 +87,33 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
80
87
  // 自动刷新
81
88
  var onAutoRefresh = function onAutoRefresh() {
82
89
  setBackTooltipVisible(false);
83
- onClickAutoRefresh(!isAutoRefresh);
90
+ onClickAutoRefresh(!enableAutoRefresh);
91
+ isClickAutoRefresh.current = true;
84
92
  if (isHasDate) {
85
93
  var values = recordDateValue.value,
86
94
  key = recordDateValue.key,
87
95
  rest = _objectWithoutProperties(recordDateValue, _excluded);
88
- var _getUnit2 = getUnit(key),
89
- isRule = _getUnit2.isRule,
90
- captureUnit = _getUnit2.captureUnit;
96
+ var _judgeType3 = judgeType(recordDateValue),
97
+ _judgeType4 = _slicedToArray(_judgeType3, 2),
98
+ isRule = _judgeType4[0],
99
+ captureUnit = _judgeType4[1];
91
100
  values = funcValueChangeArrayValue(values);
92
101
  var finalRecordDateValue = {
93
102
  isRecently: false
94
103
  };
95
- if (!isAutoRefresh) {
104
+ if (!enableAutoRefresh) {
96
105
  if (values) {
97
106
  values = computedRecentlyValue(values);
98
107
  finalRecordDateValue = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, finalRecordDateValue), rest), getTimeSpanFromValue(values)), {}, {
99
108
  isRecently: true
100
109
  });
101
110
  }
111
+ if (isRule) {
112
+ values = getChangeUnitDate(captureUnit[0], captureUnit[1]);
113
+ finalRecordDateValue = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, finalRecordDateValue), rest), getTimeSpanFromValue(values)), {}, {
114
+ isRecently: true
115
+ });
116
+ }
102
117
  } else {
103
118
  if (values) {
104
119
  finalRecordDateValue = _objectSpread(_objectSpread({}, finalRecordDateValue), {}, {
@@ -116,11 +131,11 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
116
131
  setRecordDateValue(finalRecordDateValue);
117
132
  }
118
133
  } else {
119
- onChange(recordDateValue);
134
+ onAutoRefreshChange(!enableAutoRefresh);
120
135
  setIsAutoRefresh(function (pre) {
121
- onAutoRefreshChange(!pre);
122
136
  return !pre;
123
137
  });
138
+ onChange(recordDateValue);
124
139
  if (!value) {
125
140
  setRecordDateValue(recordDateValue);
126
141
  }
@@ -138,16 +153,16 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
138
153
  title: localeObj["refresh"]
139
154
  }, /*#__PURE__*/React.createElement(_Button, {
140
155
  onClick: onRefresh,
141
- disabled: isDisabledRefresh
156
+ disabled: isDisabledRefresh || !enableAutoRefresh
142
157
  }, /*#__PURE__*/React.createElement(Refresh1Svg, null))), showAutoRefresh && /*#__PURE__*/React.createElement(_Tooltip, {
143
158
  title: localeObj["autoRefresh"]
144
159
  }, /*#__PURE__*/React.createElement(_Button, {
145
160
  onClick: onAutoRefresh,
146
161
  disabled: isDisabledAutoRefresh,
147
162
  className: classnames({
148
- "cw-range-picker-auto-refresh-wrapper": isAutoRefresh
163
+ "cw-range-picker-auto-refresh-wrapper": enableAutoRefresh
149
164
  })
150
- }, isAutoRefresh ? /*#__PURE__*/React.createElement(Refresh3Svg, {
165
+ }, enableAutoRefresh ? /*#__PURE__*/React.createElement(Refresh3Svg, {
151
166
  className: "cw-range-picker-auto-refresh"
152
167
  }) : /*#__PURE__*/React.createElement(Refresh2Svg, null))));
153
168
  });
@@ -24,21 +24,17 @@ var TimeSpan = function TimeSpan(props) {
24
24
  isHasDate = props.isHasDate,
25
25
  onRecover = props.onRecover,
26
26
  timeSpanOption = props.timeSpanOption,
27
- isAutoRefresh = props.isAutoRefresh,
28
- setIsAutoRefresh = props.setIsAutoRefresh,
29
- refreshOption = props.refreshOption,
30
27
  forwardTooltipVisible = props.forwardTooltipVisible,
31
28
  setForwardTooltipVisible = props.setForwardTooltipVisible,
32
29
  backTooltipVisible = props.backTooltipVisible,
33
30
  setBackTooltipVisible = props.setBackTooltipVisible,
34
31
  expandTooltipVisible = props.expandTooltipVisible,
35
- setExpandTooltipVisible = props.setExpandTooltipVisible;
32
+ setExpandTooltipVisible = props.setExpandTooltipVisible,
33
+ isRightDisabled = props.isRightDisabled;
36
34
  var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
37
35
  _ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
38
36
  locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
39
37
  var localeObj = getLocale(locale);
40
- var _refreshOption$onAuto = refreshOption.onAutoRefreshChange,
41
- onAutoRefreshChange = _refreshOption$onAuto === void 0 ? function () {} : _refreshOption$onAuto;
42
38
  var _timeSpanOption$showF = timeSpanOption.showForwardBtn,
43
39
  showForwardBtn = _timeSpanOption$showF === void 0 ? true : _timeSpanOption$showF,
44
40
  _timeSpanOption$showB = timeSpanOption.showBackwardBtn,
@@ -46,7 +42,10 @@ var TimeSpan = function TimeSpan(props) {
46
42
  _timeSpanOption$showE = timeSpanOption.showEnlargeBtn,
47
43
  showEnlargeBtn = _timeSpanOption$showE === void 0 ? true : _timeSpanOption$showE,
48
44
  _timeSpanOption$toolt = timeSpanOption.tooltipTitleCustom,
49
- tooltipTitleCustom = _timeSpanOption$toolt === void 0 ? {} : _timeSpanOption$toolt;
45
+ tooltipTitleCustom = _timeSpanOption$toolt === void 0 ? {} : _timeSpanOption$toolt,
46
+ forwardIcon = timeSpanOption.forwardIcon,
47
+ backIcon = timeSpanOption.backIcon,
48
+ expandIcon = timeSpanOption.expandIcon;
50
49
  var _tooltipTitleCustom$f = tooltipTitleCustom.forwardTitle,
51
50
  forwardTitle = _tooltipTitleCustom$f === void 0 ? localeObj["forwardSmooth"] : _tooltipTitleCustom$f,
52
51
  _tooltipTitleCustom$b = tooltipTitleCustom.backTitle,
@@ -77,7 +76,7 @@ var TimeSpan = function TimeSpan(props) {
77
76
  },
78
77
  visible: forwardTooltipVisible
79
78
  }, showForwardBtn && /*#__PURE__*/React.createElement(_Button, {
80
- icon: "caret-left",
79
+ icon: forwardIcon ? forwardIcon : "caret-left",
81
80
  onClick: function onClick() {
82
81
  onChangeTimeSpan("left");
83
82
  },
@@ -87,16 +86,16 @@ var TimeSpan = function TimeSpan(props) {
87
86
  }
88
87
  })), /*#__PURE__*/React.createElement(_Tooltip, {
89
88
  title: backTitle,
90
- visible: isAutoRefresh ? false : backTooltipVisible,
89
+ visible: isRightDisabled ? false : backTooltipVisible,
91
90
  onVisibleChange: function onVisibleChange(visible) {
92
91
  setBackTooltipVisible(visible);
93
92
  }
94
93
  }, showBackwardBtn && /*#__PURE__*/React.createElement(_Button, {
95
- icon: "caret-right",
94
+ icon: backIcon ? backIcon : "caret-right",
96
95
  onClick: function onClick() {
97
96
  onChangeTimeSpan("right");
98
97
  },
99
- disabled: isAutoRefresh
98
+ disabled: isRightDisabled
100
99
  })), showEnlargeBtn && /*#__PURE__*/React.createElement(_Tooltip, {
101
100
  title: expandTitle,
102
101
  onVisibleChange: function onVisibleChange(visible) {
@@ -104,7 +103,7 @@ var TimeSpan = function TimeSpan(props) {
104
103
  },
105
104
  visible: expandTooltipVisible
106
105
  }, /*#__PURE__*/React.createElement(_Button, {
107
- icon: "zoom-out",
106
+ icon: expandIcon ? expandIcon : "zoom-out",
108
107
  onClick: function onClick() {
109
108
  onChangeTimeSpan("even");
110
109
  },