@chaoswise/ui 2.6.9 → 2.7.0

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.
@@ -143,7 +143,7 @@ import { ConfigConsumer } from '../config-provider';
143
143
  import warning from '../_util/warning';
144
144
  function getAction(actions) {
145
145
  var actionList = actions.map(function (action, index) {
146
- return /*#__PURE__*/(
146
+ return (/*#__PURE__*/
147
147
  // eslint-disable-next-line react/no-array-index-key
148
148
  React.createElement("li", {
149
149
  style: {
@@ -182,7 +182,7 @@ var Checkbox = /*#__PURE__*/function (_React$Component) {
182
182
  }
183
183
  var classString = classNames(className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-wrapper"), true), _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-checked"), checkboxProps.checked), _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-disabled"), checkboxProps.disabled), _classNames));
184
184
  var checkboxClass = classNames(_defineProperty({}, "".concat(prefixCls, "-indeterminate"), indeterminate));
185
- return /*#__PURE__*/(
185
+ return (/*#__PURE__*/
186
186
  // eslint-disable-next-line jsx-a11y/label-has-associated-control
187
187
  React.createElement("label", {
188
188
  className: classString,
@@ -189,7 +189,7 @@ var Item = /*#__PURE__*/function (_React$Component) {
189
189
  className: "".concat(prefixCls, "-item-action"),
190
190
  key: "actions"
191
191
  }, actions.map(function (action, i) {
192
- return /*#__PURE__*/(
192
+ return (/*#__PURE__*/
193
193
  // eslint-disable-next-line react/no-array-index-key
194
194
  React.createElement("li", {
195
195
  key: "".concat(prefixCls, "-item-action-").concat(i)
@@ -176,7 +176,7 @@ var Radio = /*#__PURE__*/function (_React$Component) {
176
176
  radioProps.disabled = props.disabled || radioGroup.disabled;
177
177
  }
178
178
  var wrapperClassString = classNames(className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-wrapper"), true), _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-checked"), radioProps.checked), _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-disabled"), radioProps.disabled), _classNames));
179
- return /*#__PURE__*/(
179
+ return (/*#__PURE__*/
180
180
  // eslint-disable-next-line jsx-a11y/label-has-associated-control
181
181
  React.createElement("label", {
182
182
  className: wrapperClassString,
@@ -156,7 +156,7 @@ var Paragraph = /*#__PURE__*/function (_React$Component) {
156
156
  style = _this$props2.style,
157
157
  rows = _this$props2.rows;
158
158
  var rowList = _toConsumableArray(Array(rows)).map(function (_, index) {
159
- return /*#__PURE__*/(
159
+ return (/*#__PURE__*/
160
160
  // eslint-disable-next-line react/no-array-index-key
161
161
  React.createElement("li", {
162
162
  key: index,
@@ -22,7 +22,7 @@ import { ConfigContext } from '../config-provider';
22
22
  import SizeContext from '../config-provider/SizeContext';
23
23
  function getAction(actions) {
24
24
  var actionList = actions.map(function (action, index) {
25
- return /*#__PURE__*/(
25
+ return (/*#__PURE__*/
26
26
  // eslint-disable-next-line react/no-array-index-key
27
27
  React.createElement("li", {
28
28
  style: {
@@ -71,7 +71,7 @@ var InternalCheckbox = function InternalCheckbox(_a, ref) {
71
71
  }
72
72
  var classString = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-wrapper"), true), _defineProperty(_classNames, "".concat(prefixCls, "-rtl"), direction === 'rtl'), _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-checked"), checkboxProps.checked), _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-disabled"), checkboxProps.disabled), _classNames), className);
73
73
  var checkboxClass = classNames(_defineProperty({}, "".concat(prefixCls, "-indeterminate"), indeterminate));
74
- return /*#__PURE__*/(
74
+ return (/*#__PURE__*/
75
75
  // eslint-disable-next-line jsx-a11y/label-has-associated-control
76
76
  React.createElement("label", {
77
77
  className: classString,
@@ -35,7 +35,7 @@ var Collapse = function Collapse(props) {
35
35
  var icon = expandIcon ? expandIcon(panelProps) : /*#__PURE__*/React.createElement(RightOutlined, {
36
36
  rotate: panelProps.isActive ? 90 : undefined
37
37
  });
38
- return /*#__PURE__*/(
38
+ return (/*#__PURE__*/
39
39
  // Create additional div here to make arrow align to center of first line
40
40
  React.createElement("div", null, cloneElement(icon, function () {
41
41
  return {
@@ -73,7 +73,7 @@ var Item = function Item(_a) {
73
73
  className: "".concat(prefixCls, "-item-action"),
74
74
  key: "actions"
75
75
  }, actions.map(function (action, i) {
76
- return /*#__PURE__*/(
76
+ return (/*#__PURE__*/
77
77
  // eslint-disable-next-line react/no-array-index-key
78
78
  React.createElement("li", {
79
79
  key: "".concat(prefixCls, "-item-action-").concat(i)
@@ -47,7 +47,7 @@ var InternalRadio = function InternalRadio(props, ref) {
47
47
  radioProps.disabled = props.disabled || context.disabled;
48
48
  }
49
49
  var wrapperClassString = classNames("".concat(prefixCls, "-wrapper"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-checked"), radioProps.checked), _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-disabled"), radioProps.disabled), _defineProperty(_classNames, "".concat(prefixCls, "-wrapper-rtl"), direction === 'rtl'), _classNames), className);
50
- return /*#__PURE__*/(
50
+ return (/*#__PURE__*/
51
51
  // eslint-disable-next-line jsx-a11y/label-has-associated-control
52
52
  React.createElement("label", {
53
53
  className: wrapperClassString,
@@ -20,7 +20,7 @@ var Paragraph = function Paragraph(props) {
20
20
  style = props.style,
21
21
  rows = props.rows;
22
22
  var rowList = _toConsumableArray(Array(rows)).map(function (_, index) {
23
- return /*#__PURE__*/(
23
+ return (/*#__PURE__*/
24
24
  // eslint-disable-next-line react/no-array-index-key
25
25
  React.createElement("li", {
26
26
  key: index,
@@ -2,8 +2,11 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  import _Drawer from "@chaoswise/ui/lib/Drawer";
3
3
  import "@chaoswise/ui/lib/Badge/index.less";
4
4
  import _Badge from "@chaoswise/ui/lib/Badge";
5
+ import "@chaoswise/ui/lib/Modal/index.less";
6
+ import _Modal from "@chaoswise/ui/lib/Modal";
5
7
  import "@chaoswise/ui/lib/CustomNotification/index.less";
6
8
  import _CustomNotification from "@chaoswise/ui/lib/CustomNotification";
9
+ import _useLocale2 from "@chaoswise/ui/lib/useLocale";
7
10
  import _useConfigContext2 from "@chaoswise/ui/lib/useConfigContext";
8
11
  var _excluded = ["count"],
9
12
  _excluded2 = ["onClickStrongMessageItem"];
@@ -32,6 +35,9 @@ import MessageContent from "./MessageContent";
32
35
  import classnames from "classnames";
33
36
  import PropTypes from "prop-types";
34
37
  import io from "socket.io-client";
38
+ import audioMp3 from "./audioMp3.wav";
39
+ import langConfig from "./locale";
40
+ import { formatMessage } from "../utils";
35
41
  import "./index.less";
36
42
  function Message(props) {
37
43
  var _props$hideOnSinglePa = props.hideOnSinglePage,
@@ -62,10 +68,15 @@ function Message(props) {
62
68
  _props$onSocketChange = props.onSocketChange,
63
69
  onSocketChange = _props$onSocketChange === void 0 ? function () {} : _props$onSocketChange,
64
70
  _props$renderMessageD = props.renderMessageDateFormat,
65
- renderMessageDateFormat = _props$renderMessageD === void 0 ? function () {} : _props$renderMessageD;
71
+ renderMessageDateFormat = _props$renderMessageD === void 0 ? function () {} : _props$renderMessageD,
72
+ customAudioSrc = props.customAudioSrc,
73
+ _props$enableVoicePro = props.enableVoicePrompt,
74
+ enableVoicePrompt = _props$enableVoicePro === void 0 ? false : _props$enableVoicePro;
66
75
  var _useConfigContext = _useConfigContext2(),
67
76
  getPrefixCls = _useConfigContext.getPrefixCls;
68
77
  var prefixCls = getPrefixCls();
78
+ var _useLocale = _useLocale2(langConfig),
79
+ localeObj = _useLocale.langObj;
69
80
  var messageImg = imgOption.messageImg,
70
81
  _imgOption$badgeOptio = imgOption.badgeOption,
71
82
  badgeOption = _imgOption$badgeOptio === void 0 ? {} : _imgOption$badgeOptio;
@@ -114,6 +125,7 @@ function Message(props) {
114
125
  clientType: "BROWSER",
115
126
  status: 0
116
127
  });
128
+ var audioRef = useRef(null);
117
129
  useEffect(function () {
118
130
  getMessageQuerySettings();
119
131
  connectSocket();
@@ -121,6 +133,10 @@ function Message(props) {
121
133
  if (socketConnectInfo.current) {
122
134
  socketConnectInfo.current.disconnect && socketConnectInfo.current.disconnect();
123
135
  }
136
+ var audio = audioRef.current;
137
+ if (audio) {
138
+ audio.pause();
139
+ }
124
140
  };
125
141
  }, []);
126
142
  useEffect(function () {
@@ -162,6 +178,27 @@ function Message(props) {
162
178
  var onClickBell = function onClickBell() {
163
179
  setVisible(true);
164
180
  };
181
+ // 播放音频
182
+ var playAudio = function playAudio() {
183
+ var audio = audioRef.current;
184
+ if (audio) {
185
+ audio.currentTime = 0; // 重置播放时间
186
+ audio.play()["catch"](function (err) {
187
+ if ((err === null || err === void 0 ? void 0 : err.name) === "NotAllowedError") {
188
+ _Modal.warning({
189
+ title: formatMessage(localeObj["playAutomatically"]),
190
+ prefixCls: "".concat(prefixCls, "-modal"),
191
+ okButtonProps: {
192
+ prefixCls: "".concat(prefixCls, "-btn")
193
+ },
194
+ okText: formatMessage(localeObj["ok"]),
195
+ mask: true,
196
+ maskClosable: true
197
+ });
198
+ }
199
+ });
200
+ }
201
+ };
165
202
  var openNotification = /*#__PURE__*/function () {
166
203
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(time, id) {
167
204
  var params, resRequestApi, res, data, _ref2, userMessageId, title, summary;
@@ -179,7 +216,8 @@ function Message(props) {
179
216
  res = _context.sent;
180
217
  if (res && res.status == "success") {
181
218
  data = res.data;
182
- _ref2 = data || {}, userMessageId = _ref2.userMessageId, title = _ref2.title, summary = _ref2.summary;
219
+ _ref2 = data || {}, userMessageId = _ref2.userMessageId, title = _ref2.title, summary = _ref2.summary; // 消息语音提示
220
+ playAudio();
183
221
  _CustomNotification.open(_objectSpread({
184
222
  message: title,
185
223
  description: summary,
@@ -370,7 +408,11 @@ function Message(props) {
370
408
  closable: closable,
371
409
  conditionsRef: conditionsRef,
372
410
  renderMessageDateFormat: renderMessageDateFormat
373
- })));
411
+ })), enableVoicePrompt && /*#__PURE__*/React.createElement("audio", {
412
+ ref: audioRef,
413
+ preload: "auto",
414
+ src: customAudioSrc || audioMp3
415
+ }));
374
416
  }
375
417
  Message.defaultProps = {
376
418
  pageSize: 30,
@@ -2,5 +2,7 @@ export default {
2
2
  "markAllRead": "Mark all read",
3
3
  "no_new_messages": "No new messages",
4
4
  "more": "More",
5
- "totalItems": "{total} total"
5
+ "totalItems": "{total} total",
6
+ "ok": "OK",
7
+ "playAutomatically": "Message alerts can be played automatically only when interactive behavior is required"
6
8
  };
@@ -2,5 +2,7 @@ export default {
2
2
  "markAllRead": "全部已读",
3
3
  "no_new_messages": "暂无新消息",
4
4
  "more": "更多",
5
- "totalItems": "共{total}条"
5
+ "totalItems": "共{total}条",
6
+ "ok": "确定",
7
+ "playAutomatically": "消息提醒需要有交互行为才可以自动播放"
6
8
  };
@@ -2,5 +2,7 @@ export default {
2
2
  "markAllRead": "全部已讀",
3
3
  "no_new_messages": "暫無新消息",
4
4
  "more": "更多",
5
- "totalItems": "共{total}條"
5
+ "totalItems": "共{total}條",
6
+ "ok": "確定",
7
+ "playAutomatically": "消息提醒需要有交互行爲纔可以自動播放"
6
8
  };
@@ -37,7 +37,8 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
37
37
  isHasDate = props.isHasDate,
38
38
  enableAutoRefresh = props.enableAutoRefresh,
39
39
  isClickAutoRefresh = props.isClickAutoRefresh,
40
- timeSpanOption = props.timeSpanOption;
40
+ timeSpanOption = props.timeSpanOption,
41
+ findDataSourceValue = props.findDataSourceValue;
41
42
  var _refreshOption$onAuto = refreshOption.onAutoRefreshChange,
42
43
  onAutoRefreshChange = _refreshOption$onAuto === void 0 ? function () {} : _refreshOption$onAuto,
43
44
  _refreshOption$onClic = refreshOption.onClickRefresh,
@@ -49,30 +50,39 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
49
50
  _refreshOption$showAu = refreshOption.showAutoRefresh,
50
51
  showAutoRefresh = _refreshOption$showAu === void 0 ? true : _refreshOption$showAu,
51
52
  _refreshOption$showRe = refreshOption.showRefresh,
52
- showRefresh = _refreshOption$showRe === void 0 ? true : _refreshOption$showRe;
53
+ showRefresh = _refreshOption$showRe === void 0 ? true : _refreshOption$showRe,
54
+ _refreshOption$isSpec = refreshOption.isSpecialRelativeTime,
55
+ isSpecialRelativeTime = _refreshOption$isSpec === void 0 ? false : _refreshOption$isSpec;
53
56
  var _timeSpanOption$timeS = timeSpanOption.timeSpanBoundary,
54
57
  timeSpanBoundary = _timeSpanOption$timeS === void 0 ? 94608000 : _timeSpanOption$timeS;
55
58
  var _useLocale = _useLocale2(langConfig),
56
59
  localeObj = _useLocale.langObj;
57
60
  // 手动刷新
58
61
  var onRefresh = function onRefresh() {
59
- var values = recordDateValue.value;
62
+ var values = recordDateValue.value,
63
+ type = recordDateValue.type;
60
64
  var _judgeType = judgeType(recordDateValue),
61
65
  _judgeType2 = _slicedToArray(_judgeType, 2),
62
66
  isRule = _judgeType2[0],
63
67
  captureUnit = _judgeType2[1];
64
68
  var returnValue = _objectSpread({}, recordDateValue);
65
- values = funcValueChangeArrayValue(values);
69
+ if (findDataSourceValue || values) {
70
+ values = funcValueChangeArrayValue(findDataSourceValue || values);
71
+ returnValue = _objectSpread(_objectSpread({}, returnValue), {}, {
72
+ value: values
73
+ });
74
+ }
66
75
  if (enableAutoRefresh) {
67
- if (values) {
68
- returnValue = _objectSpread(_objectSpread({}, returnValue), {}, {
69
- value: computedRecentlyValue(values)
70
- });
71
- }
72
- if (isRule && !values) {
73
- returnValue = _objectSpread(_objectSpread({}, recordDateValue), {}, {
74
- value: getChangeUnitDate(captureUnit[0], captureUnit[1])
75
- });
76
+ if (type !== "relative" || !isSpecialRelativeTime) {
77
+ if (values) {
78
+ returnValue = _objectSpread(_objectSpread({}, returnValue), {}, {
79
+ value: computedRecentlyValue(values)
80
+ });
81
+ } else if (isRule) {
82
+ returnValue = _objectSpread(_objectSpread({}, returnValue), {}, {
83
+ value: getChangeUnitDate(captureUnit[0], captureUnit[1])
84
+ });
85
+ }
76
86
  }
77
87
  }
78
88
  onClickRefresh(returnValue);
@@ -89,34 +99,36 @@ var Refresh = /*#__PURE__*/forwardRef(function (props, ref) {
89
99
  _judgeType4 = _slicedToArray(_judgeType3, 2),
90
100
  isRule = _judgeType4[0],
91
101
  captureUnit = _judgeType4[1];
92
- values = funcValueChangeArrayValue(values);
93
102
  var finalRecordDateValue = {
94
103
  isRecently: false
95
104
  };
96
- if (!enableAutoRefresh) {
105
+ if (findDataSourceValue || values) {
106
+ values = funcValueChangeArrayValue(findDataSourceValue || values);
107
+ finalRecordDateValue = _objectSpread(_objectSpread({}, finalRecordDateValue), {}, {
108
+ value: values
109
+ });
110
+ }
111
+ if (rest.type === "relative" && isSpecialRelativeTime) {
112
+ // 如果type是relative,则需要把type和title回传回去,受控value接收时type和title也必须回传回来
113
+ finalRecordDateValue = _objectSpread(_objectSpread({}, finalRecordDateValue), {}, {
114
+ type: rest.type,
115
+ title: rest.title
116
+ });
117
+ } else {
97
118
  if (values) {
98
119
  values = computedRecentlyValue(values);
99
- finalRecordDateValue = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, finalRecordDateValue), rest), getTimeSpanFromValue(values, timeSpanBoundary)), {}, {
100
- isRecently: true
101
- });
102
- }
103
- if (isRule && !values) {
120
+ } else if (isRule) {
104
121
  values = getChangeUnitDate(captureUnit[0], captureUnit[1]);
105
- finalRecordDateValue = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, finalRecordDateValue), rest), getTimeSpanFromValue(values, timeSpanBoundary)), {}, {
106
- isRecently: true
107
- });
108
122
  }
123
+ }
124
+ if (!enableAutoRefresh) {
125
+ finalRecordDateValue = _objectSpread(_objectSpread(_objectSpread({}, finalRecordDateValue), rest), {}, {
126
+ isRecently: true
127
+ }, getTimeSpanFromValue(values, timeSpanBoundary));
109
128
  } else {
110
- if (values) {
111
- finalRecordDateValue = _objectSpread(_objectSpread({}, finalRecordDateValue), {}, {
112
- value: computedRecentlyValue(values)
113
- });
114
- }
115
- if (isRule && !values) {
116
- finalRecordDateValue = _objectSpread(_objectSpread({}, finalRecordDateValue), {}, {
117
- value: getChangeUnitDate(captureUnit[0], captureUnit[1])
118
- });
119
- }
129
+ finalRecordDateValue = _objectSpread(_objectSpread({}, finalRecordDateValue), {}, {
130
+ value: values
131
+ });
120
132
  }
121
133
  onChange(finalRecordDateValue);
122
134
  if (!value) {
@@ -27,6 +27,12 @@ var TimeSpan = function TimeSpan(props) {
27
27
  showBackwardBtn = _timeSpanOption$showB === void 0 ? true : _timeSpanOption$showB,
28
28
  _timeSpanOption$showE = timeSpanOption.showEnlargeBtn,
29
29
  showEnlargeBtn = _timeSpanOption$showE === void 0 ? true : _timeSpanOption$showE,
30
+ _timeSpanOption$isDis = timeSpanOption.isDisabledForwardBtn,
31
+ isDisabledForwardBtn = _timeSpanOption$isDis === void 0 ? false : _timeSpanOption$isDis,
32
+ _timeSpanOption$isDis2 = timeSpanOption.isDisabledBackwardBtn,
33
+ isDisabledBackwardBtn = _timeSpanOption$isDis2 === void 0 ? false : _timeSpanOption$isDis2,
34
+ _timeSpanOption$isDis3 = timeSpanOption.isDisabledEnlargeBtn,
35
+ disabledEnlargeBtn = _timeSpanOption$isDis3 === void 0 ? false : _timeSpanOption$isDis3,
30
36
  _timeSpanOption$toolt = timeSpanOption.tooltipTitleCustom,
31
37
  tooltipTitleCustom = _timeSpanOption$toolt === void 0 ? {} : _timeSpanOption$toolt,
32
38
  forwardIcon = timeSpanOption.forwardIcon,
@@ -67,7 +73,8 @@ var TimeSpan = function TimeSpan(props) {
67
73
  icon: forwardIcon ? forwardIcon : "caret-left",
68
74
  onClick: function onClick() {
69
75
  onChangeTimeSpan("left");
70
- }
76
+ },
77
+ disabled: isDisabledForwardBtn
71
78
  })), /*#__PURE__*/React.createElement(_Tooltip, {
72
79
  title: backTitle
73
80
  }, showBackwardBtn && /*#__PURE__*/React.createElement(_Button, {
@@ -75,7 +82,7 @@ var TimeSpan = function TimeSpan(props) {
75
82
  onClick: function onClick() {
76
83
  onChangeTimeSpan("right");
77
84
  },
78
- disabled: isRightDisabled
85
+ disabled: isDisabledBackwardBtn || isRightDisabled
79
86
  })), showEnlargeBtn && /*#__PURE__*/React.createElement(_Tooltip, {
80
87
  title: expandTitle
81
88
  }, /*#__PURE__*/React.createElement(_Button, {
@@ -83,7 +90,7 @@ var TimeSpan = function TimeSpan(props) {
83
90
  onClick: function onClick() {
84
91
  onChangeTimeSpan("even");
85
92
  },
86
- disabled: isDisabledEnlargeBtn
93
+ disabled: disabledEnlargeBtn || isDisabledEnlargeBtn
87
94
  })));
88
95
  };
89
96
  export default TimeSpan;