@chaoswise/ui 3.0.20 → 3.0.22

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.
@@ -179,11 +179,13 @@ var genSelectionStyle = function genSelectionStyle(token, suffix) {
179
179
  function genSizeStyle(token, suffix) {
180
180
  var componentCls = token.componentCls;
181
181
  var suffixCls = suffix ? "".concat(componentCls, "-").concat(suffix) : '';
182
- var rawStyle = _defineProperty({}, "".concat(componentCls, "-multiple").concat(suffixCls), _defineProperty(_defineProperty({
182
+ var rawStyle = _defineProperty({}, "".concat(componentCls, "-multiple").concat(suffixCls), _defineProperty(_defineProperty(_defineProperty({
183
183
  fontSize: token.fontSize
184
184
  }, "".concat(componentCls, "-selector"), _defineProperty({}, "".concat(componentCls, "-show-search&"), {
185
185
  cursor: 'text'
186
- })), "\n &".concat(componentCls, "-show-arrow ").concat(componentCls, "-selector,\n &").concat(componentCls, "-allow-clear ").concat(componentCls, "-selector\n "), {
186
+ })), "\n &".concat(componentCls, "-show-arrow ").concat(componentCls, "-selection-placeholder\n "), {
187
+ paddingInlineEnd: token.showArrowPaddingInlineEnd
188
+ }), "\n &".concat(componentCls, "-show-arrow ").concat(componentCls, "-selector,\n &").concat(componentCls, "-allow-clear ").concat(componentCls, "-selector\n "), {
187
189
  paddingInlineEnd: token.calc(token.fontSizeIcon).add(token.controlPaddingHorizontal).equal()
188
190
  }));
189
191
  return [genSelectionStyle(token, suffix), rawStyle];
@@ -9,11 +9,11 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
9
9
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
10
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
11
11
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
12
- import React from 'react';
13
- import dayjs from '../../../utils/generate/dayjs';
14
- import classnames from 'classnames';
15
- import { readInnerMessageApi } from '../../service';
16
- import { useIntl } from '../../../locales';
12
+ import React from "react";
13
+ import dayjs from "../../utils/generate/dayjs";
14
+ import classnames from "classnames";
15
+ import { readInnerMessageApi } from "../../service";
16
+ import { useIntl } from "../../../locales";
17
17
  var TabList = function TabList(props) {
18
18
  var _props$messages = props.messages,
19
19
  messages = _props$messages === void 0 ? [] : _props$messages,
@@ -29,7 +29,7 @@ var TabList = function TabList(props) {
29
29
  code = props.code,
30
30
  onTabListAllRead = props.onTabListAllRead,
31
31
  messagePrefixCls = props.messagePrefixCls,
32
- format = props.format;
32
+ renderMessageDateFormat = props.renderMessageDateFormat;
33
33
  var intl = useIntl();
34
34
  var _readInnerMessageApi = requestOption.readInnerMessageApi;
35
35
  var onHandleMessage = function onHandleMessage(message) {
@@ -42,7 +42,7 @@ var TabList = function TabList(props) {
42
42
  };
43
43
  readInnerMessage(params);
44
44
  // 撤回消息不操作
45
- if (showMode === 'invalid') return;
45
+ if (showMode === "invalid") return;
46
46
  var _isClose = onTabListItem(message);
47
47
  if (isClose || _isClose) {
48
48
  setVisible(false);
@@ -70,7 +70,7 @@ var TabList = function TabList(props) {
70
70
  return resRequestApi(params, gatewayPrefix);
71
71
  case 3:
72
72
  res = _context.sent;
73
- if (res.status == 'success') {
73
+ if (res.status == "success") {
74
74
  _params = {};
75
75
  if (pageInfo.current > 1 && messages.length === 1) {
76
76
  _params = {
@@ -98,24 +98,24 @@ var TabList = function TabList(props) {
98
98
  var messageList = messages.map(function (message) {
99
99
  var _message$title, _message$summary;
100
100
  return /*#__PURE__*/React.createElement("div", {
101
- className: classnames("".concat(messagePrefixCls, "-content-tabs-list"), _defineProperty({}, "".concat(messagePrefixCls, "-content-tabs-list-invalid"), message.showMode === 'invalid')),
101
+ className: classnames("".concat(messagePrefixCls, "-content-tabs-list"), _defineProperty({}, "".concat(messagePrefixCls, "-content-tabs-list-invalid"), message.showMode === "invalid")),
102
102
  key: message.userMessageId
103
103
  }, /*#__PURE__*/React.createElement("div", {
104
104
  className: "".concat(messagePrefixCls, "-content-tabs-list-title"),
105
105
  onClick: function onClick() {
106
106
  return onHandleMessage(message);
107
107
  }
108
- }, message.showMode === 'top' && /*#__PURE__*/React.createElement(_Tag, {
108
+ }, message.showMode === "top" && /*#__PURE__*/React.createElement(_Tag, {
109
109
  className: "".concat(messagePrefixCls, "-content-tabs-list-title-top")
110
- }, intl.get('5cc44ee5-8da3-446b-b962-3fe7f77d4f38').d('置顶')), (_message$title = message.title) !== null && _message$title !== void 0 ? _message$title : ''), /*#__PURE__*/React.createElement("div", {
110
+ }, intl.get("5cc44ee5-8da3-446b-b962-3fe7f77d4f38").d("置顶")), (_message$title = message.title) !== null && _message$title !== void 0 ? _message$title : ""), /*#__PURE__*/React.createElement("div", {
111
111
  className: "".concat(messagePrefixCls, "-content-tabs-list-desc")
112
- }, (_message$summary = message.summary) !== null && _message$summary !== void 0 ? _message$summary : ''), /*#__PURE__*/React.createElement("div", {
112
+ }, (_message$summary = message.summary) !== null && _message$summary !== void 0 ? _message$summary : ""), /*#__PURE__*/React.createElement("div", {
113
113
  className: "".concat(messagePrefixCls, "-content-tabs-list-date")
114
- }, message.time ? dayjs(Number(message.time)).format(format) : ''));
114
+ }, message.time ? renderMessageDateFormat ? renderMessageDateFormat(Number(message.time)) : dayjs(Number(message.time)).format("YYYY-MM-DD HH:mm:ss") : ""));
115
115
  });
116
116
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Button, {
117
117
  className: "".concat(messagePrefixCls, "-content-all-read"),
118
118
  onClick: onHandleReadAllMessage
119
- }, intl.get('58bc27cb-aac5-49f8-8c9e-3b0fbb9d9c61').d('全部已读')), messageList);
119
+ }, intl.get("58bc27cb-aac5-49f8-8c9e-3b0fbb9d9c61").d("全部已读")), messageList);
120
120
  };
121
121
  export default TabList;
@@ -50,7 +50,7 @@ var MessageContent = function MessageContent(props) {
50
50
  onTabListAllRead = props.onTabListAllRead,
51
51
  conditionsRef = props.conditionsRef,
52
52
  messagePrefixCls = props.messagePrefixCls,
53
- format = props.format;
53
+ renderMessageDateFormat = props.renderMessageDateFormat;
54
54
  var intl = useIntl();
55
55
  var token = useTheme();
56
56
  var history = useHistory();
@@ -243,7 +243,7 @@ var MessageContent = function MessageContent(props) {
243
243
  code: item.code,
244
244
  onTabListAllRead: onTabListAllRead,
245
245
  messagePrefixCls: messagePrefixCls,
246
- format: format
246
+ renderMessageDateFormat: renderMessageDateFormat
247
247
  }) : /*#__PURE__*/React.createElement(_Empty, {
248
248
  description: emptyDescription
249
249
  }), /*#__PURE__*/React.createElement("div", {
@@ -59,8 +59,8 @@ function Message(props) {
59
59
  strongMessageOption = _props$strongMessageO === void 0 ? {} : _props$strongMessageO,
60
60
  _props$onSocketChange = props.onSocketChange,
61
61
  onSocketChange = _props$onSocketChange === void 0 ? function () {} : _props$onSocketChange,
62
- _props$format = props.format,
63
- format = _props$format === void 0 ? "YYYY-MM-DD HH:mm:ss" : _props$format;
62
+ _props$renderMessageD = props.renderMessageDateFormat,
63
+ renderMessageDateFormat = _props$renderMessageD === void 0 ? function () {} : _props$renderMessageD;
64
64
  var _useConfigContext = useConfigContext(),
65
65
  getPrefixCls = _useConfigContext.getPrefixCls;
66
66
  var prefixCls = getPrefixCls();
@@ -392,7 +392,7 @@ function Message(props) {
392
392
  closable: closable,
393
393
  conditionsRef: conditionsRef,
394
394
  messagePrefixCls: messagePrefixCls,
395
- format: format
395
+ renderMessageDateFormat: renderMessageDateFormat
396
396
  }))));
397
397
  }
398
398
  Message.defaultProps = {
@@ -403,8 +403,7 @@ Message.defaultProps = {
403
403
  isClose: false,
404
404
  timeout: 3000,
405
405
  socketPathPrefix: "",
406
- closable: false,
407
- format: "YYYY-MM-DD HH:mm:ss"
406
+ closable: false
408
407
  };
409
408
  Message.propTypes = {
410
409
  /**
@@ -460,8 +459,8 @@ Message.propTypes = {
460
459
  */
461
460
  strongMessageOption: PropTypes.object,
462
461
  /**
463
- * 消息内容的时间format格式
462
+ * 渲染消息时间格式,function(时间戳)=>{},
464
463
  */
465
- format: PropTypes.string
464
+ renderMessageDateFormat: PropTypes.func
466
465
  };
467
466
  export default Message;
@@ -0,0 +1,12 @@
1
+ import originalDayjs from "dayjs";
2
+ import utc from "dayjs/plugin/utc";
3
+ import timezone from "dayjs/plugin/timezone";
4
+ // 扩展 dayjs 支持时区
5
+ originalDayjs.extend(utc);
6
+ originalDayjs.extend(timezone);
7
+ // 封装 dayjs 函数,使其每次调用时自动应用当前的全局时区
8
+ var dayjs = function dayjs() {
9
+ var instance = originalDayjs.apply(void 0, arguments);
10
+ return instance.tz();
11
+ };
12
+ export default dayjs;
@@ -0,0 +1,2 @@
1
+ import moment from 'moment';
2
+ export default moment;
@@ -107,7 +107,6 @@ var DropdownMenu = function DropdownMenu(props) {
107
107
  // 点击切换为日历
108
108
  var onClickSelectCalendar = function onClickSelectCalendar(e) {
109
109
  e.nativeEvent.stopImmediatePropagation();
110
- console.log(222, "22");
111
110
  setIsCalendar(true);
112
111
  };
113
112
  // 存在历史记录点击tag回显时间
@@ -1,4 +1,5 @@
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
+ var _originalDayjs$tz;
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
5
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -10,11 +11,22 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
10
11
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
12
  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; } }
12
13
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
- import dayjs from "dayjs";
14
+ import originalDayjs from "dayjs";
14
15
  import duration from "dayjs/plugin/duration";
15
- dayjs.extend(duration);
16
+ import utc from "dayjs/plugin/utc";
17
+ import timezone from "dayjs/plugin/timezone";
18
+ originalDayjs.extend(duration);
19
+ // 扩展 dayjs 支持时区
20
+ originalDayjs.extend(utc);
21
+ originalDayjs.extend(timezone);
16
22
  var _require = require("uuid"),
17
23
  uuidv4 = _require.v4;
24
+ var timeZone = ((_originalDayjs$tz = originalDayjs.tz()) === null || _originalDayjs$tz === void 0 || (_originalDayjs$tz = _originalDayjs$tz.$x) === null || _originalDayjs$tz === void 0 ? void 0 : _originalDayjs$tz.$timezone) || originalDayjs.tz.guess();
25
+ // 封装 dayjs 函数,使其每次调用时自动应用当前的全局时区
26
+ var dayjs = function dayjs() {
27
+ var instance = originalDayjs.apply(void 0, arguments);
28
+ return instance.tz();
29
+ };
18
30
  // 枚举时间单位
19
31
  var ENUM_TimeUnit = {
20
32
  s: ["Second", "Seconds", "秒", "seconds"],
@@ -203,7 +215,7 @@ export var computeTimeSpan = function computeTimeSpan(value, timeSpanBoundary) {
203
215
  if (timeDiff >= 60) {
204
216
  timeDiff = Number(timeDiff + 1);
205
217
  }
206
- var duration = dayjs.duration(timeDiff, "s");
218
+ var duration = originalDayjs.duration(timeDiff, "s");
207
219
  var _duration$$d = duration.$d,
208
220
  years = _duration$$d.years,
209
221
  months = _duration$$d.months,
@@ -291,7 +303,7 @@ export var cloneChangeDate = function cloneChangeDate(currentDate_0, currentDate
291
303
  if (_maxTimeDiff <= 0) {
292
304
  // 当前时间已经是极限了
293
305
  // 已经是极限直接当前时间向前推进timeSpanBoundary即可
294
- cloneCurrentDate_0 = dayjs().subtract(dayjs.duration(timeSpanBoundary, "s"));
306
+ cloneCurrentDate_0 = dayjs().subtract(originalDayjs.duration(timeSpanBoundary, "s"));
295
307
  cloneCurrentDate_1 = dayjs();
296
308
  switchInitial = true;
297
309
  } else {
@@ -300,27 +312,27 @@ export var cloneChangeDate = function cloneChangeDate(currentDate_0, currentDate
300
312
  var initialTimeDiff = computeTimeDiff([clone0, clone1], "s");
301
313
  if (timeSpanBoundary > initialTimeDiff) {
302
314
  var needChangeTimeDiff = Math.ceil(timeSpanBoundary - initialTimeDiff) / 2;
303
- cloneCurrentDate_0 = clone0.subtract(dayjs.duration(needChangeTimeDiff, "s"));
304
- cloneCurrentDate_1 = clone1.add(dayjs.duration(needChangeTimeDiff, "s"));
315
+ cloneCurrentDate_0 = clone0.subtract(originalDayjs.duration(needChangeTimeDiff, "s"));
316
+ cloneCurrentDate_1 = clone1.add(originalDayjs.duration(needChangeTimeDiff, "s"));
305
317
  // 计算最大值的时间差
306
318
  var _maxTimeDiff2 = computeTimeDiff([cloneCurrentDate_1, dayjs()]);
307
319
  if (_maxTimeDiff2 <= 0) {
308
320
  // 当前时间已经是极限了
309
321
  // 已经是极限直接当前时间向前推进timeSpanBoundary即可
310
- cloneCurrentDate_0 = dayjs().subtract(dayjs.duration(timeSpanBoundary, "s"));
322
+ cloneCurrentDate_0 = dayjs().subtract(originalDayjs.duration(timeSpanBoundary, "s"));
311
323
  cloneCurrentDate_1 = dayjs();
312
324
  switchInitial = true;
313
325
  }
314
326
  } else {
315
- cloneCurrentDate_1 = clone1.add(dayjs.duration(timeSpanBoundary, "s"));
327
+ cloneCurrentDate_1 = clone1.add(originalDayjs.duration(timeSpanBoundary, "s"));
316
328
  var clone = cloneCurrentDate_1.clone();
317
- cloneCurrentDate_0 = clone.subtract(dayjs.duration(timeSpanBoundary, "s"));
329
+ cloneCurrentDate_0 = clone.subtract(originalDayjs.duration(timeSpanBoundary, "s"));
318
330
  // 计算最大值的时间差
319
331
  var _maxTimeDiff3 = computeTimeDiff([cloneCurrentDate_1, dayjs()]);
320
332
  if (_maxTimeDiff3 <= 0) {
321
333
  // 当前时间已经是极限了
322
334
  // 已经是极限直接当前时间向前推进timeSpanBoundary即可
323
- cloneCurrentDate_0 = dayjs().subtract(dayjs.duration(timeSpanBoundary, "s"));
335
+ cloneCurrentDate_0 = dayjs().subtract(originalDayjs.duration(timeSpanBoundary, "s"));
324
336
  cloneCurrentDate_1 = dayjs();
325
337
  switchInitial = true;
326
338
  }
@@ -379,7 +391,7 @@ export var getChangeDate = function getChangeDate(recordDateValue, direction) {
379
391
  value = getChangeUnitDate(captureUnit[0], ENUM_TimeUnit[captureUnit[1]][3]);
380
392
  }
381
393
  var timeDiff = value[1].diff(value[0]);
382
- var duration = dayjs.duration(timeDiff);
394
+ var duration = originalDayjs.duration(timeDiff);
383
395
  var _cloneChangeDate = cloneChangeDate(value[0], value[1], direction, growSize, duration, timeSpanBoundary),
384
396
  _value = _cloneChangeDate.value,
385
397
  switchInitial = _cloneChangeDate.switchInitial;
@@ -609,7 +621,7 @@ var parseInputDate = function parseInputDate(text) {
609
621
  var finalFormat = "";
610
622
  for (var i = 0; i < FORMATS.length; i += 1) {
611
623
  var format = FORMATS[i];
612
- var date = dayjs(text, format, true);
624
+ var date = originalDayjs(text, format, true).tz(timeZone, true); // tz参数设置为undefined:使用设置后的全局时区, true:2023-01-01 02:02:02 切换到对应时区仍然是 2023-01-01 02:02:02
613
625
  if (date.isValid()) {
614
626
  finalDate = date;
615
627
  finalFormat = format;
@@ -178,7 +178,7 @@ function CWTree(_ref) {
178
178
  className: "cw-tree-treenode-title"
179
179
  }, useTooltipText ? /*#__PURE__*/React.createElement(_TooltipText, {
180
180
  placement: tooltipPlacement ? tooltipPlacement : "bottomLeft"
181
- }, title) : title), draggable && _showExtend === key && /*#__PURE__*/React.createElement("span", {
181
+ }, title) : title), /*#__PURE__*/React.createElement("span", {
182
182
  className: "cw-tree-treenode-drag-icon"
183
183
  }, /*#__PURE__*/React.createElement(_Tooltip, {
184
184
  title: intl.get("5fe60774-0f08-450f-a9d9-998996485fec").d("拖拽移动")
@@ -23,7 +23,7 @@ var genCustomCWTreeStyle = function genCustomCWTreeStyle(token) {
23
23
  overflowY: "auto",
24
24
  ".cw-tree": _defineProperty({
25
25
  width: "100%",
26
- ".cw-tree-treenode": _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
26
+ ".cw-tree-treenode": _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
27
27
  lineHeight: "32px",
28
28
  padding: "0 16px",
29
29
  whiteSpace: "nowrap",
@@ -66,7 +66,8 @@ var genCustomCWTreeStyle = function genCustomCWTreeStyle(token) {
66
66
  ".cw-tree-treenode-drag-icon": {
67
67
  position: "absolute",
68
68
  left: "8px",
69
- transform: "translateY(1.2px)"
69
+ transform: "translateY(1.2px)",
70
+ visibility: "hidden"
70
71
  }
71
72
  },
72
73
  ".cw-tree-treenode-extend": {
@@ -109,7 +110,13 @@ var genCustomCWTreeStyle = function genCustomCWTreeStyle(token) {
109
110
  height: "32px",
110
111
  lineHeight: "32px",
111
112
  marginTop: 0
112
- })
113
+ }), "&:hover", _defineProperty({}, "".concat(treeNodePrefix, "-content-wrapper"), _defineProperty({}, "".concat(treePrefix, "-title"), {
114
+ ".cw-tree-treenode-content": {
115
+ ".cw-tree-treenode-drag-icon": {
116
+ visibility: "visible"
117
+ }
118
+ }
119
+ })))
113
120
  }, "&".concat(treePrefix, "-directory"), _defineProperty({}, "".concat(treePrefix, "-child-tree"), {
114
121
  height: "100% !important"
115
122
  }))
@@ -10,7 +10,6 @@ var prepareComponentToken = function prepareComponentToken(token) {
10
10
  headerBgLayout: token.Layout.headerBg,
11
11
  headerColorLayout: token.Layout.headerColor,
12
12
  headerHeightLayout: token.Layout.headerHeight,
13
- // headerPaddingLayout: token.Layout.headerPadding,
14
13
  divisionBgLayout: token.Layout.divisionBg,
15
14
  topNavMenuBgLayout: token.Layout.topNavMenuBg
16
15
  };
@@ -50,7 +50,6 @@ var SearchIcon = function SearchIcon(_ref) {
50
50
 
51
51
  //搜索
52
52
  var onSearch = function onSearch(e) {
53
- console.log(e);
54
53
  if (!e.target.value) {
55
54
  setIconList(iconSelectList);
56
55
  return;
@@ -1,4 +1,9 @@
1
1
  import { genStyleHooks } from "../../Antd5/theme/internal";
2
+ var prepareComponentToken = function prepareComponentToken(token) {
3
+ return {
4
+ bodyBgLayout: token.Layout.bodyBg
5
+ };
6
+ };
2
7
  var genCustomLayoutWrapperStyle = function genCustomLayoutWrapperStyle(token) {
3
8
  var prefixCls = token.antCls;
4
9
  return {
@@ -37,7 +42,7 @@ var genCustomLayoutWrapperStyle = function genCustomLayoutWrapperStyle(token) {
37
42
  }
38
43
  },
39
44
  ".cw-layout-wrapper-box-no-background": {
40
- background: token.colorBgContainer
45
+ background: token.bodyBgLayout
41
46
  },
42
47
  ".cw-layout-wrapper-box-hasfooter": {
43
48
  paddingBottom: "52px"
@@ -55,4 +60,4 @@ export default genStyleHooks("LayoutWrapper", function (token) {
55
60
  return [
56
61
  //
57
62
  genCustomLayoutWrapperStyle(token)];
58
- });
63
+ }, prepareComponentToken);
@@ -17,7 +17,7 @@ import React, { useState, useEffect, useMemo, forwardRef, useRef, useCallback, u
17
17
  var RangePicker = _DatePicker.RangePicker;
18
18
  import ExtraQuickSelect from "./components/ExtraQuickSelect";
19
19
  import ExtraTimeFooter from "./components/ExtraTimeFooter";
20
- import dayjs, { formatMomentToString, formatMomentToSplit, byTimeMomentToDateMoment, disabledAllTimeFunc } from "./utils/generate/dayjs";
20
+ import dayjs, { formatStringToDate, formatDateToString, formatDateToSplit, byTimeToDate, disabledAllTimeFunc } from "./utils/generate/dayjs";
21
21
  import classnames from "classnames";
22
22
  import useConfigContext from "../useConfigContext";
23
23
  import useStyle from "./index.style";
@@ -82,9 +82,9 @@ var _RangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
82
82
  hashId = _useStyle2[1],
83
83
  cssVarCls = _useStyle2[2];
84
84
  var _defaultTimeOption$st = defaultTimeOption.startTimeOption,
85
- startTimeOption = _defaultTimeOption$st === void 0 ? dayjs("00:00:00", timeFormat.current) : _defaultTimeOption$st,
85
+ startTimeOption = _defaultTimeOption$st === void 0 ? formatStringToDate("00:00:00", timeFormat.current) : _defaultTimeOption$st,
86
86
  _defaultTimeOption$en = defaultTimeOption.endTimeOption,
87
- endTimeOption = _defaultTimeOption$en === void 0 ? dayjs("00:00:00", timeFormat.current) : _defaultTimeOption$en;
87
+ endTimeOption = _defaultTimeOption$en === void 0 ? formatStringToDate("00:00:00", timeFormat.current) : _defaultTimeOption$en;
88
88
  //监听外部控制面板的显示隐藏状态
89
89
  useEffect(function () {
90
90
  if ("open" in props) {
@@ -175,7 +175,7 @@ var _RangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
175
175
  isBtnRef.current = false;
176
176
  if (Array.isArray(dateValue)) {
177
177
  if (dateValue[0]) {
178
- var leftDateTime = byTimeMomentToDateMoment(newStartTime, dateValue[0]);
178
+ var leftDateTime = byTimeToDate(newStartTime, dateValue[0]);
179
179
  var rightDateTime = dateValue[1];
180
180
  if (dayjs(leftDateTime).isAfter(dateValue[1])) {
181
181
  rightDateTime = leftDateTime;
@@ -193,7 +193,7 @@ var _RangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
193
193
  isBtnRef.current = false;
194
194
  if (Array.isArray(dateValue)) {
195
195
  if (dateValue[1]) {
196
- var rightDateTime = byTimeMomentToDateMoment(newEndTime, dateValue[1]);
196
+ var rightDateTime = byTimeToDate(newEndTime, dateValue[1]);
197
197
  setDateValue([dateValue[0], rightDateTime]);
198
198
  recordBeforeDateRef.current = [dateValue[0], rightDateTime];
199
199
  }
@@ -227,8 +227,8 @@ var _RangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
227
227
  }
228
228
  if (startDateTime && endDateTime) {
229
229
  var _dateVal = [dayjs(startDateTime), dayjs(endDateTime)];
230
- var startDateTimeString = formatMomentToString(startDateTime, formatRef.current);
231
- var endDateTimeString = formatMomentToString(endDateTime, formatRef.current);
230
+ var startDateTimeString = formatDateToString(startDateTime, formatRef.current);
231
+ var endDateTimeString = formatDateToString(endDateTime, formatRef.current);
232
232
  setStartTimeParams(dayjs(startDateTime));
233
233
  setEndTimeParams(dayjs(endDateTime));
234
234
  _onCalendarChange(_dateVal, [startDateTimeString, endDateTimeString], {
@@ -277,12 +277,12 @@ var _RangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
277
277
  isBtnRef.current = false;
278
278
  var calendarDateTruth = calendarDate.filter(Boolean);
279
279
  if (calendarDateTruth.length == 1) {
280
- var CalendarDateStr = formatMomentToSplit(calendarDateTruth[0], formatRef.current)[0];
280
+ var CalendarDateStr = formatDateToSplit(calendarDateTruth[0], formatRef.current)[0];
281
281
  var dateTimeValue = calendarDateTruth[0];
282
282
  if (info.range == "start") {
283
283
  if (startTimeParams) {
284
- var TimeStr = formatMomentToString(startTimeParams, timeFormat.current);
285
- var StartDateTime = dayjs(CalendarDateStr + " " + TimeStr, formatRef.current);
284
+ var TimeStr = formatDateToString(startTimeParams, timeFormat.current);
285
+ var StartDateTime = formatStringToDate(CalendarDateStr + " " + TimeStr, formatRef.current);
286
286
  dateTimeValue = StartDateTime;
287
287
  _onCalendarChange([StartDateTime, null], [TimeStr, ""], info);
288
288
  }
@@ -290,8 +290,8 @@ var _RangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
290
290
  recordBeforeDateRef.current = [dateTimeValue, null];
291
291
  } else if (info.range == "end") {
292
292
  if (endTimeParams) {
293
- var _TimeStr = formatMomentToString(endTimeParams, timeFormat.current);
294
- var EndDateTime = dayjs(CalendarDateStr + " " + _TimeStr, formatRef.current);
293
+ var _TimeStr = formatDateToString(endTimeParams, timeFormat.current);
294
+ var EndDateTime = formatStringToDate(CalendarDateStr + " " + _TimeStr, formatRef.current);
295
295
  dateTimeValue = EndDateTime;
296
296
  _onCalendarChange([null, EndDateTime], [_TimeStr, ""], info);
297
297
  }
@@ -299,19 +299,19 @@ var _RangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
299
299
  recordBeforeDateRef.current = [null, dateTimeValue];
300
300
  }
301
301
  } else if (calendarDateTruth.length == 2) {
302
- var leftCalendarDateStr = formatMomentToSplit(calendarDateTruth[0], formatRef.current)[0];
303
- var rightCalendarDateStr = formatMomentToSplit(calendarDateTruth[1], formatRef.current)[0];
302
+ var leftCalendarDateStr = formatDateToSplit(calendarDateTruth[0], formatRef.current)[0];
303
+ var rightCalendarDateStr = formatDateToSplit(calendarDateTruth[1], formatRef.current)[0];
304
304
  var startDateTime = calendarDateTruth[0];
305
305
  var endDateTime = calendarDateTruth[1];
306
306
  var leftTimeStr = dateStrings[0];
307
307
  var endTimeStr = dateStrings[1];
308
308
  if (startTimeParams) {
309
- leftTimeStr = formatMomentToString(startTimeParams, timeFormat.current);
310
- startDateTime = dayjs(leftCalendarDateStr + " " + leftTimeStr, formatRef.current);
309
+ leftTimeStr = formatDateToString(startTimeParams, timeFormat.current);
310
+ startDateTime = formatStringToDate(leftCalendarDateStr + " " + leftTimeStr, formatRef.current);
311
311
  }
312
312
  if (endTimeParams) {
313
- endTimeStr = formatMomentToString(endTimeParams, timeFormat.current);
314
- endDateTime = dayjs(rightCalendarDateStr + " " + endTimeStr, formatRef.current);
313
+ endTimeStr = formatDateToString(endTimeParams, timeFormat.current);
314
+ endDateTime = formatStringToDate(rightCalendarDateStr + " " + endTimeStr, formatRef.current);
315
315
  }
316
316
  // 若开始时间晚于结束时间,结束时间同步为开始时间
317
317
  if (dayjs(startDateTime).isAfter(endDateTime)) {
@@ -335,7 +335,7 @@ var _RangePicker = /*#__PURE__*/forwardRef(function (props, ref) {
335
335
  setVisible(false);
336
336
  }
337
337
  var dateTimeValueString = dateValue.map(function (item) {
338
- return formatMomentToString(item, formatRef.current);
338
+ return formatDateToString(item, formatRef.current);
339
339
  });
340
340
  _onChange(dateValue, dateTimeValueString);
341
341
  recordQuickActiveKey.current = null;
@@ -1,3 +1,4 @@
1
+ var _originalDayjs$tz;
1
2
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
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."); }
3
4
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -5,7 +6,18 @@ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Sym
5
6
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
7
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
7
8
  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); }
8
- import dayjs from "dayjs";
9
+ import originalDayjs from "dayjs";
10
+ import utc from "dayjs/plugin/utc";
11
+ import timezone from "dayjs/plugin/timezone";
12
+ // 扩展 dayjs 支持时区
13
+ originalDayjs.extend(utc);
14
+ originalDayjs.extend(timezone);
15
+ var timeZone = ((_originalDayjs$tz = originalDayjs.tz()) === null || _originalDayjs$tz === void 0 || (_originalDayjs$tz = _originalDayjs$tz.$x) === null || _originalDayjs$tz === void 0 ? void 0 : _originalDayjs$tz.$timezone) || originalDayjs.tz.guess();
16
+ // 封装 dayjs 函数,使其每次调用时自动应用当前的全局时区
17
+ var dayjs = function dayjs() {
18
+ var instance = originalDayjs.apply(void 0, arguments);
19
+ return instance.tz();
20
+ };
9
21
  var timeFormat = "HH:mm:ss";
10
22
  var dateFormat = "YYYY-MM-DD HH:mm:ss";
11
23
  // 符合禁用规则的时间集合
@@ -17,28 +29,30 @@ export function range(start, end) {
17
29
  return result;
18
30
  }
19
31
 
20
- //格式化时间为字符串
21
- export function formatMomentToString(dateTime, format) {
32
+ // 格式化时间为字符串
33
+ export function formatDateToString(dateTime, format) {
22
34
  return dayjs(dateTime).format(format);
23
35
  }
24
36
 
25
- //格式化时间为字符串,并将其切割date time的一个数组
26
- export function formatMomentToSplit(dateTime, format) {
37
+ // 格式化时间为字符串,并将其切割date time的一个数组
38
+ export function formatDateToSplit(dateTime, format) {
27
39
  var sp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : " ";
28
- return formatMomentToString(dateTime, format).split(sp);
29
- }
30
- export function dateStringToSplit(dateTimeString) {
31
- var sp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : " ";
32
- return dateTimeString.split(sp);
40
+ return formatDateToString(dateTime, format).split(sp);
33
41
  }
42
+
34
43
  /**
35
44
  * 时间选择器变换后包装到最终显示时间上
36
45
  */
37
- export function byTimeMomentToDateMoment(currentTime, currentDate) {
38
- var DateStr = formatMomentToSplit(currentDate, dateFormat)[0];
39
- var TimeStr = formatMomentToString(currentTime, timeFormat);
46
+ export function byTimeToDate(currentTime, currentDate) {
47
+ var DateStr = formatDateToSplit(currentDate, dateFormat)[0];
48
+ var TimeStr = formatDateToString(currentTime, timeFormat);
40
49
  var leftDateTimeStr = DateStr + " " + TimeStr;
41
- return dayjs(leftDateTimeStr, dateFormat);
50
+ return formatStringToDate(leftDateTimeStr, dateFormat);
51
+ }
52
+
53
+ // 将时间字符串按照format格式化为dayjs时间。上海时区2024-1-1 12:00:00——》纽约时区2024-1-1 12:00:00
54
+ export function formatStringToDate(dateString, format) {
55
+ return originalDayjs(dateString, format).tz(timeZone, true);
42
56
  }
43
57
 
44
58
  //是否是对象
@@ -18,27 +18,29 @@ export function range(start, end) {
18
18
  }
19
19
 
20
20
  //格式化时间为字符串
21
- export function formatMomentToString(dateTime, format) {
21
+ export function formatDateToString(dateTime, format) {
22
22
  return moment(dateTime).format(format);
23
23
  }
24
24
 
25
25
  //格式化时间为字符串,并将其切割date time的一个数组
26
- export function formatMomentToSplit(dateTime, format) {
26
+ export function formatDateToSplit(dateTime, format) {
27
27
  var sp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : " ";
28
- return formatMomentToString(dateTime, format).split(sp);
29
- }
30
- export function dateStringToSplit(dateTimeString) {
31
- var sp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : " ";
32
- return dateTimeString.split(sp);
28
+ return formatDateToString(dateTime, format).split(sp);
33
29
  }
30
+
34
31
  /**
35
32
  * 时间选择器变换后包装到最终显示时间上
36
33
  */
37
- export function byTimeMomentToDateMoment(currentTime, currentDate) {
38
- var DateStr = formatMomentToSplit(currentDate, dateFormat)[0];
39
- var TimeStr = formatMomentToString(currentTime, timeFormat);
34
+ export function byTimeToDate(currentTime, currentDate) {
35
+ var DateStr = formatDateToSplit(currentDate, dateFormat)[0];
36
+ var TimeStr = formatDateToString(currentTime, timeFormat);
40
37
  var leftDateTimeStr = DateStr + " " + TimeStr;
41
- return moment(leftDateTimeStr, dateFormat);
38
+ return formatStringToDate(leftDateTimeStr, dateFormat);
39
+ }
40
+
41
+ // 将时间字符串按照format格式化为moment时间。上海时区2024-1-1 12:00:00——》纽约时区2024-1-1 12:00:00
42
+ export function formatStringToDate(dateString, format) {
43
+ return moment(dateString, format);
42
44
  }
43
45
 
44
46
  //是否是对象
@@ -46,7 +46,6 @@ function CWScrollLoad(_ref) {
46
46
  return;
47
47
  }
48
48
  fetchData(page, function (newData) {
49
- console.log(newData, "data");
50
49
  setData(data.concat(newData));
51
50
  return data.concat(newData);
52
51
  });
@@ -16,6 +16,7 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
16
16
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
17
17
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
18
18
  import React, { useMemo, useCallback } from "react";
19
+ import { DownOutlined } from "@ant-design/icons";
19
20
  import PropTypes from "prop-types";
20
21
  import classnames from "classnames";
21
22
  import useConfigContext from "../useConfigContext";
@@ -180,22 +181,12 @@ function CWMenu(_ref) {
180
181
  },
181
182
  mode: "inline",
182
183
  defaultSelectedKeys: defaultSelectedKey ? [defaultSelectedKey] : [defaultKey],
183
- inlineIndent: 12
184
- // expandIcon={item => {
185
- // return (
186
- // <span
187
- // className={
188
- // classnames({
189
- // 'cw-expand-arrow': true,
190
- // 'cw-expand-arrow-open': item.isOpen
191
- // })
192
- // }
193
- // >
194
- // <DownOutlined />
195
- // </span>
196
- // )
197
- // }}
198
- ,
184
+ inlineIndent: 12,
185
+ expandIcon: function expandIcon(item) {
186
+ return /*#__PURE__*/React.createElement("span", {
187
+ className: classnames(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-expand-arrow"), true), "".concat(prefixCls, "-expand-arrow-open"), item.isOpen))
188
+ }, /*#__PURE__*/React.createElement(DownOutlined, null));
189
+ },
199
190
  defaultOpenKeys: defaultOpenKeys,
200
191
  items: items
201
192
  }, rest))));
@@ -5,15 +5,31 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
5
5
  import { genStyleHooks } from "../Antd5/theme/internal";
6
6
  var genCustomSiderMenuStyle = function genCustomSiderMenuStyle(token) {
7
7
  var prefixCls = token.antCls,
8
- componentCls = token.componentCls;
8
+ iconCls = token.iconCls;
9
9
  var SiderMenuPrefix = "".concat(prefixCls, "-sider-menu");
10
- return _defineProperty({}, "".concat(SiderMenuPrefix, "-goup-label"), {
10
+ return _defineProperty(_defineProperty({}, "".concat(SiderMenuPrefix, "-goup-label"), {
11
11
  borderBottom: "1px solid rgb(246, 247, 248)",
12
12
  width: "calc(100% + 14px)",
13
13
  marginLeft: "-7px",
14
14
  paddingBottom: "8px",
15
15
  color: token.colorText
16
- });
16
+ }), "".concat(SiderMenuPrefix, "-expand-arrow"), _defineProperty(_defineProperty({
17
+ position: "absolute",
18
+ top: "0",
19
+ right: "8px",
20
+ height: "100%",
21
+ width: "12px",
22
+ fontSize: "12px",
23
+ lineHeight: "40px"
24
+ }, iconCls, {
25
+ minWidth: "12px !important",
26
+ fontSize: "12px !important",
27
+ transition: "transform 0.3s !important"
28
+ }), "&&-open", _defineProperty({
29
+ color: token.colorPrimary
30
+ }, iconCls, {
31
+ transform: "rotate(180deg)"
32
+ })));
17
33
  };
18
34
  // ============================== Export ==============================
19
35
  export default genStyleHooks("SiderMenu", function (token) {
@@ -6,14 +6,14 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
7
  import { getInlineCode, isModuleScriptSupported } from './utils';
8
8
  var ALL_SCRIPT_REGEX = /(<script[\s\S]*?>)[\s\S]*?<\/script>/gi;
9
- var SCRIPT_TAG_REGEX = /<(script)\s+((?!type=('|")text\/ng\x2Dtemplate\3)[\s\S])*?>[\s\S]*?<\/\1>/i;
9
+ var SCRIPT_TAG_REGEX = /<(script)\s+((?!type=('|")text\/ng-template\3)[^])*?>[^]*?<\/\1>/i;
10
10
  var SCRIPT_SRC_REGEX = /.*\ssrc=('|")?([^>'"\s]+)/;
11
11
  var SCRIPT_TYPE_REGEX = /.*\stype=('|")?([^>'"\s]+)/;
12
12
  var SCRIPT_ENTRY_REGEX = /.*\sentry\s*.*/;
13
13
  var SCRIPT_ASYNC_REGEX = /.*\sasync\s*.*/;
14
14
  var SCRIPT_NO_MODULE_REGEX = /.*\snomodule\s*.*/;
15
15
  var SCRIPT_MODULE_REGEX = /.*\stype=('|")?module('|")?\s*.*/;
16
- var LINK_TAG_REGEX = /<(link)\s+[\s\S]*?>/ig;
16
+ var LINK_TAG_REGEX = /<(link)\s+[^]*?>/ig;
17
17
  var LINK_PRELOAD_OR_PREFETCH_REGEX = /\srel=('|")?(preload|prefetch)\1/;
18
18
  var LINK_HREF_REGEX = /.*\shref=('|")?([^>'"\s]+)/;
19
19
  var LINK_AS_FONT = /.*\sas=('|")?font\1.*/;
@@ -21,9 +21,9 @@ var STYLE_TAG_REGEX = /<style[^>]*>[\s\S]*?<\/style>/gi;
21
21
  var STYLE_TYPE_REGEX = /\s+rel=('|")?stylesheet\1.*/;
22
22
  var STYLE_HREF_REGEX = /.*\shref=('|")?([^>'"\s]+)/;
23
23
  var HTML_COMMENT_REGEX = /<!--([\s\S]*?)-->/g;
24
- var LINK_IGNORE_REGEX = /<link(\s+|\s+[\s\S]+\s+)ignore(\s*|\s+[\s\S]*|=[\s\S]*)>/i;
25
- var STYLE_IGNORE_REGEX = /<style(\s+|\s+[\s\S]+\s+)ignore(\s*|\s+[\s\S]*|=[\s\S]*)>/i;
26
- var SCRIPT_IGNORE_REGEX = /<script(\s+|\s+[\s\S]+\s+)ignore(\s*|\s+[\s\S]*|=[\s\S]*)>/i;
24
+ var LINK_IGNORE_REGEX = /<link(\s+|\s+[^]+\s+)ignore(\s*|\s+[^]*|=[^]*)>/i;
25
+ var STYLE_IGNORE_REGEX = /<style(\s+|\s+[^]+\s+)ignore(\s*|\s+[^]*|=[^]*)>/i;
26
+ var SCRIPT_IGNORE_REGEX = /<script(\s+|\s+[^]+\s+)ignore(\s*|\s+[^]*|=[^]*)>/i;
27
27
  function hasProtocol(url) {
28
28
  return url.startsWith('//') || url.startsWith('http://') || url.startsWith('https://');
29
29
  }
@@ -87,7 +87,7 @@ var useMouse = function useMouse(_ref) {
87
87
  canDrag: true
88
88
  });
89
89
  var isHoverBottomWrapper = useHover(TimeRangeSliderBottomWrapperRef);
90
- var millisecondsOfTheDay = dayjs.duration(1, "days").valueOf(); // 一天的毫秒数 86400000
90
+ var millisecondsOfTheDay = 86400000; // 一天的毫秒数 86400000
91
91
  var minWidth = min / millisecondsOfTheDay * timeSliderWidth;
92
92
  var maxWidth = max / millisecondsOfTheDay * timeSliderWidth;
93
93
  useEffect(function () {
@@ -4,12 +4,23 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- import dayjs from "dayjs";
7
+ import originalDayjs from "dayjs";
8
8
  import duration from "dayjs/plugin/duration";
9
9
  import isSameOrAfter_dayjs from "dayjs/plugin/isSameOrAfter";
10
- dayjs.extend(isSameOrAfter_dayjs);
11
- dayjs.extend(duration);
10
+ import utc from "dayjs/plugin/utc";
11
+ import timezone from "dayjs/plugin/timezone";
12
12
  import { round } from "lodash-es";
13
+ originalDayjs.extend(isSameOrAfter_dayjs);
14
+ originalDayjs.extend(duration);
15
+ // 扩展 dayjs 支持时区
16
+ originalDayjs.extend(utc);
17
+ originalDayjs.extend(timezone);
18
+ // 封装 dayjs 函数,使其每次调用时自动应用当前的全局时区
19
+ var dayjs = function dayjs() {
20
+ var instance = originalDayjs.apply(void 0, arguments);
21
+ return instance.tz();
22
+ };
23
+
13
24
  // 获取所有日期 最近30天: 年月日
14
25
  // 第一天和最后一天合并成一天(上部分)
15
26
  export var getAllDates = function getAllDates(date, days) {
@@ -60,7 +71,7 @@ export var getConvertedDateData = function getConvertedDateData(dates, singleWid
60
71
  };
61
72
  // 获取传入日期的相关数据(上部分)
62
73
  var getDateInfo = function getDateInfo(date, index, left, singleWidth, lastWidth, days) {
63
- var millisecondsOfTheDay = dayjs.duration(1, "days").valueOf(); // 一天的毫秒数 86400000
74
+ var millisecondsOfTheDay = originalDayjs.duration(1, "days").valueOf(); // 一天的毫秒数 86400000
64
75
  var millisecondsOfTheDate = dayjs(date).valueOf(); // 传入日期的毫秒数
65
76
  var millisecondsOfTheDateStart = dayjs(date).startOf("day").valueOf(); // 传入日期的开始时间的毫秒数
66
77
  var millisecondsOfTheDateEnd = dayjs(date).endOf("day").valueOf(); // 传入日期的结束时间的毫秒数
@@ -84,7 +95,7 @@ var getDateInfo = function getDateInfo(date, index, left, singleWidth, lastWidth
84
95
  };
85
96
  // 根据left位置获取日期(上部分)
86
97
  export var getDateInfoByPositionInfo = function getDateInfoByPositionInfo(left, allWidth, currentMoment, days) {
87
- var millisecondsOfRecentlyMonth = dayjs.duration(days, "days").valueOf(); // 默认为30天的毫秒数 2592000000
98
+ var millisecondsOfRecentlyMonth = originalDayjs.duration(days, "days").valueOf(); // 默认为30天的毫秒数 2592000000
88
99
  var millisecondsOfRecentlyMonthStart = currentMoment.clone().subtract(days, "days").valueOf(); // 默认为最近30天的开始时间的毫秒数
89
100
  var diffTime = round(left / allWidth * millisecondsOfRecentlyMonth);
90
101
  var millisecondsOfTheDate = Number(diffTime);
@@ -97,7 +108,7 @@ export var getDateInfoByPositionInfo = function getDateInfoByPositionInfo(left,
97
108
  };
98
109
  // 根据日期获取left位置(上部分)
99
110
  export var getPositionInfoByDateInfo = function getPositionInfoByDateInfo(date, allWidth, currentMoment, days) {
100
- var millisecondsOfRecentlyMonth = dayjs.duration(days, "days").valueOf(); // 默认30天的毫秒数 2592000000
111
+ var millisecondsOfRecentlyMonth = originalDayjs.duration(days, "days").valueOf(); // 默认30天的毫秒数 2592000000
101
112
  var millisecondsOfTheDate = dayjs(date).valueOf(); // 传入日期的毫秒数
102
113
  var millisecondsOfRecentlyMonthStart = currentMoment.clone().subtract(days, "days").valueOf(); // 默认最近30天的开始时间的毫秒数
103
114
  var diffTime = millisecondsOfTheDate - millisecondsOfRecentlyMonthStart;
@@ -153,7 +164,7 @@ export var getPositionInfoByTimeDateInfo = function getPositionInfoByTimeDateInf
153
164
  width: width
154
165
  };
155
166
  }
156
- var millisecondsOfRecentlyMonth = dayjs.duration(days, "days").valueOf(); // 默认30天的毫秒数 2592000000
167
+ var millisecondsOfRecentlyMonth = originalDayjs.duration(days, "days").valueOf(); // 默认30天的毫秒数 2592000000
157
168
  var millisecondsOfTheDateStart = getValueOfDateByDate(date[0]); // 传入日期的毫秒数开始值
158
169
  var millisecondsOfTheDateEnd = getValueOfDateByDate(date[1]); // 传入日期的毫秒数结束值
159
170
  var millisecondsOfTheDateRecordTimeDataStart = getValueOfDateByDate(recordTimeDateWrapper[0]); // 容器轴开始时间点的毫秒数
@@ -173,7 +184,7 @@ export var getPositionInfoByTimeDateInfo = function getPositionInfoByTimeDateInf
173
184
  };
174
185
  // 传入left和width获取日期(下部分)
175
186
  export var getTimeDateInfoByPositionInfo = function getTimeDateInfoByPositionInfo(left, width, allWidth, currentMoment, recordTimeDateWrapper, days) {
176
- var millisecondsOfRecentlyMonth = dayjs.duration(days, "days").valueOf(); // 默认为30天的毫秒数 2592000000
187
+ var millisecondsOfRecentlyMonth = originalDayjs.duration(days, "days").valueOf(); // 默认为30天的毫秒数 2592000000
177
188
  var millisecondsOfRecentlyMonthStart = currentMoment.clone().subtract(days, "days").valueOf(); // 默认为最近30天的开始时间的毫秒数
178
189
  var millisecondsOfTheDateRecordTimeDataStart = getValueOfDateByDate(recordTimeDateWrapper[0]); // 容器轴开始时间点的毫秒数
179
190
  var diffTimeRecordTimeStart = millisecondsOfTheDateRecordTimeDataStart - millisecondsOfRecentlyMonthStart; // 容器轴开始时间点于默认最近30天开始时间的毫秒差
@@ -237,7 +248,7 @@ export var computeTimeSpan = function computeTimeSpan(value) {
237
248
  if (timeDiff >= 60) {
238
249
  timeDiff = Number(timeDiff + 1);
239
250
  }
240
- var duration = dayjs.duration(timeDiff, "s");
251
+ var duration = originalDayjs.duration(timeDiff, "s");
241
252
  var _duration$$d = duration.$d,
242
253
  years = _duration$$d.years,
243
254
  months = _duration$$d.months,
@@ -1,4 +1,5 @@
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
+ var _originalDayjs$tz;
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
5
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -10,13 +11,24 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
10
11
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
12
  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; } }
12
13
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
- import dayjs from "dayjs";
14
+ import originalDayjs from "dayjs";
14
15
  import duration from "dayjs/plugin/duration";
15
16
  import isSameOrAfter_dayjs from "dayjs/plugin/isSameOrAfter";
16
- dayjs.extend(isSameOrAfter_dayjs);
17
- dayjs.extend(duration);
17
+ import utc from "dayjs/plugin/utc";
18
+ import timezone from "dayjs/plugin/timezone";
19
+ originalDayjs.extend(isSameOrAfter_dayjs);
20
+ originalDayjs.extend(duration);
21
+ // 扩展 dayjs 支持时区
22
+ originalDayjs.extend(utc);
23
+ originalDayjs.extend(timezone);
18
24
  var _require = require("uuid"),
19
25
  uuidv4 = _require.v4;
26
+ var timeZone = ((_originalDayjs$tz = originalDayjs.tz()) === null || _originalDayjs$tz === void 0 || (_originalDayjs$tz = _originalDayjs$tz.$x) === null || _originalDayjs$tz === void 0 ? void 0 : _originalDayjs$tz.$timezone) || originalDayjs.tz.guess();
27
+ // 封装 dayjs 函数,使其每次调用时自动应用当前的全局时区
28
+ var dayjs = function dayjs() {
29
+ var instance = originalDayjs.apply(void 0, arguments);
30
+ return instance.tz();
31
+ };
20
32
  // 枚举时间单位
21
33
  var ENUM_TimeUnit = {
22
34
  s: ["Second", "Seconds", "秒", "seconds"],
@@ -26,13 +38,6 @@ var ENUM_TimeUnit = {
26
38
  mo: ["Month", "Months", "月", "mo"],
27
39
  y: ["Year", "Years", "年", "years"]
28
40
  };
29
- var EnumTimeType = {
30
- recently: "recentlyArray",
31
- relative: "relativeArray",
32
- absolute: "absoluteArray",
33
- unixTimestamp: "unixTimestampArray",
34
- other: "otherArray"
35
- };
36
41
 
37
42
  /**
38
43
  * 变换数据源格式
@@ -40,25 +45,27 @@ var EnumTimeType = {
40
45
  * @returns 重新编排组合的数据源
41
46
  */
42
47
  export var regroupDataSourceFn = function regroupDataSourceFn(dataSource) {
43
- var recentlyArray = [];
44
- var relativeArray = [];
45
- var absoluteArray = [];
46
- var unixTimestampArray = [];
47
- var otherArray = [];
48
+ var EnumTimeTypeData = {
49
+ recently: [],
50
+ relative: [],
51
+ absolute: [],
52
+ unixTimestamp: [],
53
+ other: []
54
+ };
48
55
  var regroupDataSource = [];
49
56
  dataSource.forEach(function (item) {
50
- if (EnumTimeType[item.type]) {
51
- eval(EnumTimeType[item.type]).push(item);
57
+ if (Object.keys(EnumTimeTypeData).includes(item.type)) {
58
+ EnumTimeTypeData[item.type].push(item);
52
59
  } else {
53
- eval(EnumTimeType["other"]).push(item);
60
+ EnumTimeTypeData["other"].push(item);
54
61
  }
55
62
  });
56
- Object.entries(EnumTimeType).map(function (item) {
57
- if (eval(item[1]).length) {
58
- var newObj = {};
59
- newObj.type = item[0];
60
- newObj.timeList = eval(item[1]);
61
- regroupDataSource.push(newObj);
63
+ Object.entries(EnumTimeTypeData).forEach(function (item) {
64
+ if (item[1].length) {
65
+ regroupDataSource.push({
66
+ type: item[0],
67
+ timeList: item[1]
68
+ });
62
69
  }
63
70
  });
64
71
  return regroupDataSource;
@@ -193,7 +200,7 @@ export var echoInputValue = function echoInputValue() {
193
200
  }
194
201
  };
195
202
 
196
- // 计算两个moment日期的时间差(时间戳)
203
+ // 计算两个dayjs日期的时间差(时间戳)
197
204
  export var computeTimeDiff = function computeTimeDiff(value) {
198
205
  var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ms";
199
206
  return value[1].diff(value[0], unit);
@@ -210,7 +217,7 @@ export var computeTimeSpan = function computeTimeSpan(value, timeSpanBoundary) {
210
217
  if (timeDiff >= 60) {
211
218
  timeDiff = Number(timeDiff + 1);
212
219
  }
213
- var duration = dayjs.duration(timeDiff, "s");
220
+ var duration = originalDayjs.duration(timeDiff, "s");
214
221
  var _duration$$d = duration.$d,
215
222
  years = _duration$$d.years,
216
223
  months = _duration$$d.months,
@@ -298,7 +305,7 @@ export var cloneChangeDate = function cloneChangeDate(currentDate_0, currentDate
298
305
  if (_maxTimeDiff <= 0) {
299
306
  // 当前时间已经是极限了
300
307
  // 已经是极限直接当前时间向前推进timeSpanBoundary即可
301
- cloneCurrentDate_0 = dayjs().subtract(dayjs.duration(timeSpanBoundary, "s"));
308
+ cloneCurrentDate_0 = dayjs().subtract(originalDayjs.duration(timeSpanBoundary, "s"));
302
309
  cloneCurrentDate_1 = dayjs();
303
310
  switchInitial = true;
304
311
  } else {
@@ -307,27 +314,27 @@ export var cloneChangeDate = function cloneChangeDate(currentDate_0, currentDate
307
314
  var initialTimeDiff = computeTimeDiff([clone0, clone1], "s");
308
315
  if (timeSpanBoundary > initialTimeDiff) {
309
316
  var needChangeTimeDiff = Math.ceil(timeSpanBoundary - initialTimeDiff) / 2;
310
- cloneCurrentDate_0 = clone0.subtract(dayjs.duration(needChangeTimeDiff, "s"));
311
- cloneCurrentDate_1 = clone1.add(dayjs.duration(needChangeTimeDiff, "s"));
317
+ cloneCurrentDate_0 = clone0.subtract(originalDayjs.duration(needChangeTimeDiff, "s"));
318
+ cloneCurrentDate_1 = clone1.add(originalDayjs.duration(needChangeTimeDiff, "s"));
312
319
  // 计算最大值的时间差
313
320
  var _maxTimeDiff2 = computeTimeDiff([cloneCurrentDate_1, dayjs()]);
314
321
  if (_maxTimeDiff2 <= 0) {
315
322
  // 当前时间已经是极限了
316
323
  // 已经是极限直接当前时间向前推进timeSpanBoundary即可
317
- cloneCurrentDate_0 = dayjs().subtract(dayjs.duration(timeSpanBoundary, "s"));
324
+ cloneCurrentDate_0 = dayjs().subtract(originalDayjs.duration(timeSpanBoundary, "s"));
318
325
  cloneCurrentDate_1 = dayjs();
319
326
  switchInitial = true;
320
327
  }
321
328
  } else {
322
- cloneCurrentDate_1 = clone1.add(dayjs.duration(timeSpanBoundary, "s"));
329
+ cloneCurrentDate_1 = clone1.add(originalDayjs.duration(timeSpanBoundary, "s"));
323
330
  var clone = cloneCurrentDate_1.clone();
324
- cloneCurrentDate_0 = clone.subtract(dayjs.duration(timeSpanBoundary, "s"));
331
+ cloneCurrentDate_0 = clone.subtract(originalDayjs.duration(timeSpanBoundary, "s"));
325
332
  // 计算最大值的时间差
326
333
  var _maxTimeDiff3 = computeTimeDiff([cloneCurrentDate_1, dayjs()]);
327
334
  if (_maxTimeDiff3 <= 0) {
328
335
  // 当前时间已经是极限了
329
336
  // 已经是极限直接当前时间向前推进timeSpanBoundary即可
330
- cloneCurrentDate_0 = dayjs().subtract(dayjs.duration(timeSpanBoundary, "s"));
337
+ cloneCurrentDate_0 = dayjs().subtract(originalDayjs.duration(timeSpanBoundary, "s"));
331
338
  cloneCurrentDate_1 = dayjs();
332
339
  switchInitial = true;
333
340
  }
@@ -386,7 +393,7 @@ export var getChangeDate = function getChangeDate(recordDateValue, direction) {
386
393
  value = getChangeUnitDate(captureUnit[0], ENUM_TimeUnit[captureUnit[1]][3]);
387
394
  }
388
395
  var timeDiff = value[1].diff(value[0]);
389
- var duration = dayjs.duration(timeDiff);
396
+ var duration = originalDayjs.duration(timeDiff);
390
397
  var _cloneChangeDate = cloneChangeDate(value[0], value[1], direction, growSize, duration, timeSpanBoundary),
391
398
  _value = _cloneChangeDate.value,
392
399
  switchInitial = _cloneChangeDate.switchInitial;
@@ -616,7 +623,7 @@ var parseInputDate = function parseInputDate(text) {
616
623
  var finalFormat = "";
617
624
  for (var i = 0; i < FORMATS.length; i += 1) {
618
625
  var format = FORMATS[i];
619
- var date = dayjs(text, format, true);
626
+ var date = originalDayjs(text, format, true).tz(timeZone, true); // tz参数设置为undefined:使用设置后的全局时区, true:2023-01-01 02:02:02 切换到对应时区仍然是 2023-01-01 02:02:02
620
627
  if (date.isValid()) {
621
628
  finalDate = date;
622
629
  finalFormat = format;
@@ -704,4 +704,29 @@ export function getFinalDateOption(inputStr) {
704
704
  export var isExceedMaxTimeSpan = function isExceedMaxTimeSpan(value, timeSpanBoundary) {
705
705
  return computeTimeDiff(value, "s") > timeSpanBoundary;
706
706
  };
707
+
708
+ /**
709
+ * 是否小于最小的时间跨度
710
+ */
711
+ export var isLessThanMinTimeSpan = function isLessThanMinTimeSpan(value, timeSpanBoundary) {
712
+ return computeTimeDiff(value, "s") < timeSpanBoundary;
713
+ };
714
+
715
+ // 检查一个 moment 是否在另一个 moment 之后或与之相同。
716
+ export var isSameOrAfter = function isSameOrAfter(date1, date2) {
717
+ return moment(date1).isSameOrAfter(date2);
718
+ };
719
+
720
+ /**
721
+ * 判断选择的时间是否在要求的时间时间之内,默认为最近30天
722
+ */
723
+ export var isWithinTimeSpan = function isWithinTimeSpan(value, days) {
724
+ var startDate = moment().clone().subtract(days, "days");
725
+ var endDate = moment().clone();
726
+ if (isSameOrAfter(value[0], startDate) && isSameOrAfter(endDate, value[1])) {
727
+ return true;
728
+ } else {
729
+ return false;
730
+ }
731
+ };
707
732
  export default moment;
@@ -0,0 +1,127 @@
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
+ import _Select from "@chaoswise/ui/lib/Select";
3
+ var _excluded = ["getSystemTimeZoneInfoApi", "onInitialChange", "getOptions", "renderLabel"],
4
+ _excluded2 = ["isSelected"];
5
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
6
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
7
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
8
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
9
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
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."); }
11
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
13
+ 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; } }
14
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
15
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
16
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
17
+ // TimeZoneSelect.js
18
+ import React, { useState, useEffect } from "react";
19
+ import PropTypes from "prop-types";
20
+ var Option = _Select.Option;
21
+ var TimeZoneSelect = function TimeZoneSelect(_ref) {
22
+ var getSystemTimeZoneInfoApi = _ref.getSystemTimeZoneInfoApi,
23
+ onInitialChange = _ref.onInitialChange,
24
+ getOptions = _ref.getOptions,
25
+ renderLabel = _ref.renderLabel,
26
+ rest = _objectWithoutProperties(_ref, _excluded);
27
+ var _useState = useState([]),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ timeZones = _useState2[0],
30
+ setTimeZones = _useState2[1];
31
+ var _useState3 = useState(false),
32
+ _useState4 = _slicedToArray(_useState3, 2),
33
+ loading = _useState4[0],
34
+ setLoading = _useState4[1];
35
+ useEffect(function () {
36
+ // 组件初始化时调用接口获取时区列表
37
+ var fetchTimeZones = /*#__PURE__*/function () {
38
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
39
+ var response, data, timeZoneData, _timeZoneData, initialTimeZone;
40
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
41
+ while (1) switch (_context.prev = _context.next) {
42
+ case 0:
43
+ setLoading(true);
44
+ _context.prev = 1;
45
+ _context.next = 4;
46
+ return getSystemTimeZoneInfoApi();
47
+ case 4:
48
+ response = _context.sent;
49
+ if (response.status === "success" && response.code == 100000) {
50
+ data = response.data;
51
+ timeZoneData = (data || []).map(function (item) {
52
+ return {
53
+ countryCity: item.countryCity,
54
+ countryCityCode: item.countryCityCode,
55
+ timeZone: item.timeZone,
56
+ label: "(".concat(item.timeZone, ") ").concat(item.countryCity),
57
+ isSelected: item.isSelected
58
+ };
59
+ });
60
+ _timeZoneData = timeZoneData.map(function (item) {
61
+ var isSelected = item.isSelected,
62
+ restTimeZoneData = _objectWithoutProperties(item, _excluded2);
63
+ return restTimeZoneData;
64
+ });
65
+ setTimeZones(_timeZoneData);
66
+
67
+ // 获取初始的时区值并传递给 onInitialChange
68
+ initialTimeZone = timeZoneData.find(function (item) {
69
+ return item.isSelected;
70
+ });
71
+ onInitialChange && onInitialChange(initialTimeZone ? initialTimeZone.countryCityCode : undefined);
72
+
73
+ // 提供选项数据给外部使用
74
+ if (getOptions) {
75
+ getOptions(_timeZoneData);
76
+ }
77
+ }
78
+ _context.next = 11;
79
+ break;
80
+ case 8:
81
+ _context.prev = 8;
82
+ _context.t0 = _context["catch"](1);
83
+ console.error("获取时区列表失败:", _context.t0);
84
+ case 11:
85
+ _context.prev = 11;
86
+ setLoading(false);
87
+ return _context.finish(11);
88
+ case 14:
89
+ case "end":
90
+ return _context.stop();
91
+ }
92
+ }, _callee, null, [[1, 8, 11, 14]]);
93
+ }));
94
+ return function fetchTimeZones() {
95
+ return _ref2.apply(this, arguments);
96
+ };
97
+ }();
98
+ fetchTimeZones();
99
+ }, []);
100
+ return /*#__PURE__*/React.createElement(_Select, _extends({
101
+ loading: loading,
102
+ showSearch: true,
103
+ optionFilterProp: "children",
104
+ virtual: false
105
+ }, rest), timeZones.map(function (tz) {
106
+ return /*#__PURE__*/React.createElement(Option, {
107
+ key: tz.countryCityCode,
108
+ value: tz.countryCityCode
109
+ }, renderLabel ? renderLabel(tz) : tz.label);
110
+ }));
111
+ };
112
+
113
+ // 为 props 添加类型检查
114
+ TimeZoneSelect.propTypes = {
115
+ getSystemTimeZoneInfoApi: PropTypes.func.isRequired,
116
+ // 获取时区列表的接口方法
117
+ value: PropTypes.string,
118
+ // 当前选择的时区值
119
+ onChange: PropTypes.func,
120
+ // 时区改变回调函数
121
+ onInitialChange: PropTypes.func,
122
+ // 接口初始值回调
123
+ getOptions: PropTypes.func,
124
+ // 获取选项数据
125
+ renderLabel: PropTypes.func // 自定义选项标签渲染函数,(当前选项标签)=>{}
126
+ };
127
+ export default TimeZoneSelect;
@@ -1,2 +1,7 @@
1
1
  import dayjs from "dayjs";
2
+ import utc from "dayjs/plugin/utc";
3
+ import timezone from "dayjs/plugin/timezone";
4
+ // 扩展 dayjs 支持时区
5
+ dayjs.extend(utc);
6
+ dayjs.extend(timezone);
2
7
  export default dayjs;
@@ -1,2 +1,3 @@
1
- import moment from "moment";
1
+ import moment from 'moment';
2
+ import "moment-timezone";
2
3
  export default moment;
@@ -1,3 +1,4 @@
1
+ import dayjs from './generate/dayjs';
1
2
  /**
2
3
  * 复制组件其它属性到目标组件
3
4
  */
@@ -87,4 +88,38 @@ export var formatMessage = function formatMessage(message) {
87
88
  } else {
88
89
  return "未找到对应的翻译信息";
89
90
  }
91
+ };
92
+
93
+ /**
94
+ * 根据特定时区将时间戳转换为固定时间偏移量的时间对象
95
+ * @param {*} time - 时间参数,可以是时间戳、日期字符串或 moment/dayjs 对象
96
+ * @param {*} defaultCountryCityCode - 默认时区代码,默认为本地时区(通过 moment/dayjs.tz.guess() 自动检测)
97
+ * @param {*} countryCityCode - 自定义时区代码,用于覆盖默认时区
98
+ * @returns 返回转换为指定时区的 moment/dayjs 对象 取决于webpack中useMomentWebpackPlugin配置,默认为true为moment对象,为false则为dayjs对象
99
+ */
100
+ export var setDateByTimeZone = function setDateByTimeZone(time) {
101
+ var defaultCountryCityCode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : dayjs.tz.guess();
102
+ var countryCityCode = arguments.length > 2 ? arguments[2] : undefined;
103
+ // 从 localStorage 获取时区信息
104
+ var timeZoneData = JSON.parse(localStorage.getItem('cw_timeZone'));
105
+ // 如果 localStorage 中没有找到时区信息,则使用默认时区(自动推测的本地时区)
106
+ var timezone = timeZoneData ? timeZoneData.countryCityCode : defaultCountryCityCode;
107
+ // 如果有传入的自定义时区代码,则使用自定义时区,否则使用从 localStorage 获取或推测的时区
108
+ var _timezone = countryCityCode ? countryCityCode : timezone;
109
+ // 返回转换为指定时区的 moment 对象
110
+ return dayjs.tz(time, _timezone);
111
+ };
112
+
113
+ /**
114
+ * 从localStorage获取format信息,直接获取字符串
115
+ * @param {*} format 默认的format配置
116
+ * @returns {format} 返回format信息
117
+ */
118
+ export var getFormatByLocalStorage = function getFormatByLocalStorage() {
119
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "YYYY-MM-DD HH:mm:ss";
120
+ // 从localStorage获取format信息,直接获取字符串
121
+ var formatData = localStorage.getItem('cw_timeFormat');
122
+
123
+ // 如果localStorage中存在formatData,则返回它,否则返回默认的format
124
+ return formatData ? formatData : format;
90
125
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chaoswise/ui",
3
3
  "packageName": "chaoswiseUI",
4
- "version": "3.0.20",
4
+ "version": "3.0.22",
5
5
  "description": "公共UI库",
6
6
  "keywords": [
7
7
  "ui",
@@ -27,6 +27,8 @@
27
27
  "@antv/g6": "^4.8.24",
28
28
  "@babel/runtime": "^7.18.3",
29
29
  "@chaoswise/ace": "^1.4.13",
30
+ "@chaoswise/cssinjs": "^1.0.5",
31
+ "@chaoswise/icons-svg": "^1.0.1",
30
32
  "@chaoswise/utils": "^0.0.35",
31
33
  "@ctrl/tinycolor": "^3.6.1",
32
34
  "@emotion/babel-plugin": "^11.11.0",
@@ -45,6 +47,7 @@
45
47
  "echarts": "^5.4.3",
46
48
  "echarts-for-react": "^3.0.2",
47
49
  "highlight.js": "^9.18.5",
50
+ "moment-timezone": "^0.5.46",
48
51
  "omit.js": "^2.0.2",
49
52
  "qrcode.react": "^3.1.0",
50
53
  "rc-cascader": "~3.27.0",