@oceanbase/ui 1.0.0-alpha.10 → 1.0.0-alpha.11

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.
Files changed (244) hide show
  1. package/dist/ui.min.js +1 -1
  2. package/es/Action/Group.js +1 -0
  3. package/es/Action/Item.js +1 -0
  4. package/es/Action/index.js +1 -0
  5. package/es/BackgroundTaskManager/RefreshMan.js +1 -0
  6. package/es/BackgroundTaskManager/index.js +1 -0
  7. package/es/BasicLayout/Header.js +1 -0
  8. package/es/BasicLayout/index.js +1 -0
  9. package/es/BatchOperationBar/index.js +1 -0
  10. package/es/Boundary/Components/Code.js +1 -0
  11. package/es/Boundary/Components/Exception.js +1 -0
  12. package/es/Boundary/Components/Function.js +1 -0
  13. package/es/Boundary/index.js +1 -0
  14. package/es/ContentWithIcon/index.js +1 -0
  15. package/es/ContentWithQuestion/index.js +1 -0
  16. package/es/DateRanger/PickerPanel.js +1 -0
  17. package/es/DateRanger/Ranger.js +1 -0
  18. package/es/DateRanger/index.js +1 -0
  19. package/es/Dialog/Anchor.js +1 -0
  20. package/es/Dialog/EventProxy.js +1 -0
  21. package/es/Dialog/index.js +1 -0
  22. package/es/DocDialog/index.js +1 -0
  23. package/es/FooterToolbar/index.js +1 -0
  24. package/es/FullscreenBox/index.js +1 -0
  25. package/es/Highlight/DiffView/DiffCells.js +1 -0
  26. package/es/Highlight/DiffView/index.js +1 -0
  27. package/es/Highlight/HighlightCell.js +1 -0
  28. package/es/Highlight/JsonView.js +1 -0
  29. package/es/Highlight/index.js +1 -0
  30. package/es/Highlight/useKeyDownCopyEvent.js +1 -0
  31. package/es/IconFont/index.js +1 -0
  32. package/es/LightFilter/index.js +1 -0
  33. package/es/LocaleDropdown/index.js +1 -0
  34. package/es/Login/ActivateForm.js +1 -0
  35. package/es/Login/LoginForm.js +1 -0
  36. package/es/Login/RegisterForm.js +1 -0
  37. package/es/Login/index.js +1 -0
  38. package/es/Lottie/index.js +1 -0
  39. package/es/NavMenu/index.js +1 -0
  40. package/es/PageContainer/ItemRender.js +1 -0
  41. package/es/PageContainer/index.js +1 -0
  42. package/es/PageLoading/index.js +1 -0
  43. package/es/Password/Content.js +1 -0
  44. package/es/Password/index.js +1 -0
  45. package/es/ProCard/index.js +1 -0
  46. package/es/ProTable/index.js +2 -3
  47. package/es/Ranger/QuickPicker.js +1 -0
  48. package/es/Ranger/Ranger.js +1 -0
  49. package/es/Ranger/index.js +1 -0
  50. package/es/SideTip/Dragger.js +1 -0
  51. package/es/SideTip/IconLoading.js +1 -0
  52. package/es/SideTip/index.js +1 -0
  53. package/es/TagSelect/Group.js +1 -0
  54. package/es/TagSelect/Item.js +1 -0
  55. package/es/TagSelect/index.js +1 -0
  56. package/es/TreeSearch/index.js +1 -0
  57. package/es/Welcome/index.js +1 -0
  58. package/es/Welcome/step.js +1 -0
  59. package/es/_util/index.js +1 -0
  60. package/es/constant/index.js +1 -0
  61. package/es/index.js +1 -0
  62. package/es/locale/LocaleWrapper.js +1 -0
  63. package/es/locale/index.js +1 -0
  64. package/lib/Action/Group.js +189 -162
  65. package/lib/Action/Item.js +47 -65
  66. package/lib/Action/index.js +13 -35
  67. package/lib/Action/style/index.js +25 -43
  68. package/lib/BackgroundTaskManager/RefreshMan.js +34 -50
  69. package/lib/BackgroundTaskManager/constants.js +10 -32
  70. package/lib/BackgroundTaskManager/index.js +118 -126
  71. package/lib/BasicLayout/Header.js +242 -200
  72. package/lib/BasicLayout/index.js +265 -307
  73. package/lib/BasicLayout/locale/en-US.js +16 -34
  74. package/lib/BasicLayout/locale/ja-JP.js +16 -34
  75. package/lib/BasicLayout/locale/zh-CN.js +16 -34
  76. package/lib/BasicLayout/locale/zh-TW.js +16 -34
  77. package/lib/BasicLayout/style/Header.js +41 -60
  78. package/lib/BasicLayout/style/index.js +176 -197
  79. package/lib/BatchOperationBar/index.js +109 -151
  80. package/lib/BatchOperationBar/locale/en-US.js +10 -28
  81. package/lib/BatchOperationBar/locale/ja-JP.js +10 -28
  82. package/lib/BatchOperationBar/locale/zh-CN.js +10 -28
  83. package/lib/BatchOperationBar/locale/zh-TW.js +10 -28
  84. package/lib/BatchOperationBar/style/index.js +30 -46
  85. package/lib/Boundary/Components/Code.js +57 -75
  86. package/lib/Boundary/Components/Exception.js +103 -123
  87. package/lib/Boundary/Components/Function.js +47 -62
  88. package/lib/Boundary/Components/index.js +36 -25
  89. package/lib/Boundary/IBoundary.js +4 -16
  90. package/lib/Boundary/constant.js +16 -38
  91. package/lib/Boundary/index.js +11 -24
  92. package/lib/Boundary/locale/en-US.js +14 -32
  93. package/lib/Boundary/locale/ja-JP.js +14 -32
  94. package/lib/Boundary/locale/zh-CN.js +14 -32
  95. package/lib/Boundary/locale/zh-TW.js +14 -32
  96. package/lib/Boundary/style/index.js +28 -47
  97. package/lib/Boundary/utils.js +9 -31
  98. package/lib/ContentWithIcon/index.js +101 -114
  99. package/lib/ContentWithIcon/style/index.js +17 -36
  100. package/lib/ContentWithQuestion/index.js +40 -52
  101. package/lib/ContentWithQuestion/style/index.js +16 -35
  102. package/lib/DateRanger/PickerPanel.js +343 -325
  103. package/lib/DateRanger/Ranger.js +430 -515
  104. package/lib/DateRanger/constant/index.js +188 -376
  105. package/lib/DateRanger/index.js +45 -64
  106. package/lib/DateRanger/locale/en-US.js +20 -47
  107. package/lib/DateRanger/locale/ja-JP.js +20 -47
  108. package/lib/DateRanger/locale/zh-CN.js +20 -47
  109. package/lib/DateRanger/locale/zh-TW.js +20 -47
  110. package/lib/DateRanger/style/index.js +41 -62
  111. package/lib/DateRanger/typing.js +4 -16
  112. package/lib/Dialog/Anchor.js +70 -95
  113. package/lib/Dialog/Dock.js +14 -36
  114. package/lib/Dialog/EventProxy.js +21 -39
  115. package/lib/Dialog/index.js +327 -370
  116. package/lib/Dialog/locale/en-US.js +8 -26
  117. package/lib/Dialog/locale/ja-JP.js +8 -26
  118. package/lib/Dialog/locale/zh-CN.js +8 -26
  119. package/lib/Dialog/locale/zh-TW.js +8 -26
  120. package/lib/Dialog/style/index.js +58 -76
  121. package/lib/DocDialog/index.js +51 -77
  122. package/lib/DocDialog/locale/en-US.js +5 -23
  123. package/lib/DocDialog/locale/ja-JP.js +5 -23
  124. package/lib/DocDialog/locale/zh-CN.js +5 -23
  125. package/lib/DocDialog/locale/zh-TW.js +5 -23
  126. package/lib/FooterToolbar/index.js +27 -45
  127. package/lib/FooterToolbar/style/index.js +23 -38
  128. package/lib/FullscreenBox/index.js +151 -138
  129. package/lib/FullscreenBox/locale/en-US.js +5 -23
  130. package/lib/FullscreenBox/locale/ja-JP.js +5 -23
  131. package/lib/FullscreenBox/locale/zh-CN.js +5 -23
  132. package/lib/FullscreenBox/locale/zh-TW.js +5 -23
  133. package/lib/FullscreenBox/style/index.js +23 -41
  134. package/lib/Highlight/DiffView/DiffCells.js +34 -54
  135. package/lib/Highlight/DiffView/index.js +165 -163
  136. package/lib/Highlight/HighlightCell.js +28 -47
  137. package/lib/Highlight/JsonView.js +45 -74
  138. package/lib/Highlight/index.js +200 -214
  139. package/lib/Highlight/languages/bash.js +7 -34
  140. package/lib/Highlight/languages/cpp.js +7 -34
  141. package/lib/Highlight/languages/css.js +7 -34
  142. package/lib/Highlight/languages/dockerfile.js +7 -34
  143. package/lib/Highlight/languages/go.js +7 -34
  144. package/lib/Highlight/languages/groovy.js +7 -34
  145. package/lib/Highlight/languages/http.js +7 -34
  146. package/lib/Highlight/languages/java.js +7 -34
  147. package/lib/Highlight/languages/javascript.js +7 -34
  148. package/lib/Highlight/languages/json.js +7 -34
  149. package/lib/Highlight/languages/markdown.js +7 -34
  150. package/lib/Highlight/languages/nginx.js +7 -34
  151. package/lib/Highlight/languages/python.js +7 -34
  152. package/lib/Highlight/languages/ruby.js +7 -34
  153. package/lib/Highlight/languages/solidity.js +7 -34
  154. package/lib/Highlight/languages/sql.js +7 -34
  155. package/lib/Highlight/languages/typescript.js +7 -34
  156. package/lib/Highlight/languages/xml.js +7 -34
  157. package/lib/Highlight/languages/yaml.js +7 -34
  158. package/lib/Highlight/locale/en-US.js +7 -25
  159. package/lib/Highlight/locale/ja-JP.js +7 -25
  160. package/lib/Highlight/locale/zh-CN.js +7 -25
  161. package/lib/Highlight/locale/zh-TW.js +7 -25
  162. package/lib/Highlight/style/index.js +128 -144
  163. package/lib/Highlight/useKeyDownCopyEvent.js +40 -64
  164. package/lib/IconFont/index.js +23 -28
  165. package/lib/LightFilter/index.js +29 -43
  166. package/lib/LightFilter/style/index.js +15 -33
  167. package/lib/LocaleDropdown/index.js +43 -53
  168. package/lib/Login/ActivateForm.js +93 -119
  169. package/lib/Login/LoginForm.js +149 -184
  170. package/lib/Login/RegisterForm.js +122 -163
  171. package/lib/Login/index.js +157 -163
  172. package/lib/Login/locale/en-US.js +31 -49
  173. package/lib/Login/locale/ja-JP.js +31 -49
  174. package/lib/Login/locale/zh-CN.js +31 -49
  175. package/lib/Login/locale/zh-TW.js +30 -48
  176. package/lib/Login/style/index.js +77 -98
  177. package/lib/Lottie/index.js +7 -24
  178. package/lib/NavMenu/index.js +105 -108
  179. package/lib/NavMenu/style/index.js +31 -49
  180. package/lib/PageContainer/ItemRender.js +28 -46
  181. package/lib/PageContainer/index.js +125 -140
  182. package/lib/PageContainer/locale/en-US.js +8 -26
  183. package/lib/PageContainer/locale/ja-JP.js +8 -26
  184. package/lib/PageContainer/locale/zh-CN.js +8 -26
  185. package/lib/PageContainer/locale/zh-TW.js +8 -26
  186. package/lib/PageContainer/style/index.js +19 -40
  187. package/lib/PageLoading/index.js +33 -54
  188. package/lib/Password/Content.js +92 -80
  189. package/lib/Password/index.js +125 -160
  190. package/lib/Password/locale/en-US.js +14 -32
  191. package/lib/Password/locale/ja-JP.js +16 -34
  192. package/lib/Password/locale/zh-CN.js +15 -33
  193. package/lib/Password/locale/zh-TW.js +14 -32
  194. package/lib/ProCard/index.js +77 -98
  195. package/lib/ProCard/style/index.js +21 -39
  196. package/lib/ProTable/index.js +102 -123
  197. package/lib/ProTable/style/index.js +21 -38
  198. package/lib/Ranger/QuickPicker.js +92 -94
  199. package/lib/Ranger/Ranger.js +98 -133
  200. package/lib/Ranger/constant/index.js +115 -266
  201. package/lib/Ranger/index.js +61 -69
  202. package/lib/Ranger/locale/en-US.js +31 -49
  203. package/lib/Ranger/locale/ja-JP.js +31 -49
  204. package/lib/Ranger/locale/zh-CN.js +7 -25
  205. package/lib/Ranger/locale/zh-TW.js +7 -25
  206. package/lib/Ranger/style/index.js +21 -39
  207. package/lib/Ranger/typing.js +4 -16
  208. package/lib/SideTip/Dragger.js +259 -219
  209. package/lib/SideTip/IconLoading.js +43 -74
  210. package/lib/SideTip/index.js +124 -126
  211. package/lib/SideTip/locale/en-US.js +5 -23
  212. package/lib/SideTip/locale/ja-JP.js +5 -23
  213. package/lib/SideTip/locale/zh-CN.js +5 -23
  214. package/lib/SideTip/locale/zh-TW.js +5 -23
  215. package/lib/SideTip/style/index.js +76 -92
  216. package/lib/SideTip/utils.js +40 -61
  217. package/lib/TagSelect/Group.js +64 -83
  218. package/lib/TagSelect/Item.js +68 -91
  219. package/lib/TagSelect/TagSelectContext.js +7 -25
  220. package/lib/TagSelect/index.js +12 -35
  221. package/lib/TagSelect/style/index.js +41 -64
  222. package/lib/TreeSearch/index.js +133 -127
  223. package/lib/TreeSearch/util.js +52 -70
  224. package/lib/Welcome/index.js +142 -117
  225. package/lib/Welcome/locale/en-US.js +8 -26
  226. package/lib/Welcome/locale/ja-JP.js +8 -26
  227. package/lib/Welcome/locale/zh-CN.js +8 -26
  228. package/lib/Welcome/locale/zh-TW.js +8 -26
  229. package/lib/Welcome/step/style/index.js +24 -40
  230. package/lib/Welcome/step.js +63 -59
  231. package/lib/Welcome/style/index.js +58 -70
  232. package/lib/_util/genComponentStyleHook.js +15 -43
  233. package/lib/_util/index.js +38 -43
  234. package/lib/_util/useNavigate.js +11 -26
  235. package/lib/constant/index.js +23 -49
  236. package/lib/index.js +283 -129
  237. package/lib/interface.js +4 -16
  238. package/lib/locale/LocaleWrapper.js +50 -60
  239. package/lib/locale/en-US.js +37 -64
  240. package/lib/locale/index.js +5 -16
  241. package/lib/locale/ja-JP.js +37 -64
  242. package/lib/locale/zh-CN.js +36 -63
  243. package/lib/locale/zh-TW.js +32 -59
  244. package/package.json +3 -3
@@ -1,69 +1,40 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
28
2
 
29
- // src/DateRanger/Ranger.tsx
30
- var Ranger_exports = {};
31
- __export(Ranger_exports, {
32
- default: () => Ranger_default
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
33
5
  });
34
- module.exports = __toCommonJS(Ranger_exports);
35
- var import_react = __toESM(require("react"));
36
- var import_design = require("@oceanbase/design");
37
- var import_icons = require("@oceanbase/icons");
38
- var import_dayjs = __toESM(require("dayjs"));
39
- var import_lodash = require("lodash");
40
- var import_moment = __toESM(require("moment"));
41
- var import_classnames = __toESM(require("classnames"));
42
- var import_LocaleWrapper = __toESM(require("../locale/LocaleWrapper"));
43
- var import_constant = require("./constant");
44
- var import_PickerPanel = __toESM(require("./PickerPanel"));
45
- var import_zh_CN = __toESM(require("./locale/zh-CN"));
46
- var import_style = __toESM(require("./style"));
47
- var import_ahooks = require("ahooks");
48
- var import_util = require("@oceanbase/util");
49
- var import_jsx_runtime = require("react/jsx-runtime");
50
- var DefaultMaxHistoryCapacity = 20;
51
- var Ranger = import_react.default.forwardRef((props, ref) => {
52
- var _a;
53
- const { getPrefixCls } = (0, import_react.useContext)(import_design.ConfigProvider.ConfigContext);
54
- const prefixCls = getPrefixCls("date-ranger");
55
- const { wrapSSR } = (0, import_style.default)(prefixCls);
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _design = require("@oceanbase/design");
9
+ var _icons = require("@oceanbase/icons");
10
+ var _dayjs = _interopRequireDefault(require("dayjs"));
11
+ var _lodash = require("lodash");
12
+ var _moment = _interopRequireDefault(require("moment"));
13
+ var _classnames = _interopRequireDefault(require("classnames"));
14
+ var _LocaleWrapper = _interopRequireDefault(require("../locale/LocaleWrapper"));
15
+ var _constant = require("./constant");
16
+ var _PickerPanel = _interopRequireDefault(require("./PickerPanel"));
17
+ var _zhCN = _interopRequireDefault(require("./locale/zh-CN"));
18
+ var _style = _interopRequireDefault(require("./style"));
19
+ var _ahooks = require("ahooks");
20
+ var _util = require("@oceanbase/util");
21
+ var _jsxRuntime = require("react/jsx-runtime");
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
24
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
+ "use client";
26
+ const DefaultMaxHistoryCapacity = 20;
27
+ const Ranger = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
28
+ const {
29
+ getPrefixCls
30
+ } = (0, _react.useContext)(_design.ConfigProvider.ConfigContext);
31
+ const prefixCls = getPrefixCls('date-ranger');
32
+ const {
33
+ wrapSSR
34
+ } = (0, _style.default)(prefixCls);
56
35
  const prefix = prefixCls;
57
36
  const {
58
- selects = [
59
- import_constant.NEAR_1_MINUTES,
60
- import_constant.NEAR_30_MINUTES,
61
- import_constant.NEAR_1_HOURS,
62
- import_constant.NEAR_3_HOURS,
63
- import_constant.NEAR_6_HOURS,
64
- import_constant.TODAY,
65
- import_constant.LAST_3_DAYS
66
- ],
37
+ selects = [_constant.NEAR_1_MINUTES, _constant.NEAR_30_MINUTES, _constant.NEAR_1_HOURS, _constant.NEAR_3_HOURS, _constant.NEAR_6_HOURS, _constant.TODAY, _constant.LAST_3_DAYS],
67
38
  value,
68
39
  defaultValue,
69
40
  defaultQuickValue,
@@ -79,7 +50,7 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
79
50
  hideSecond = false,
80
51
  autoCalcRange = false,
81
52
  history: historyProp = false,
82
- onChange = import_lodash.noop,
53
+ onChange = _lodash.noop,
83
54
  disabledDate,
84
55
  locale,
85
56
  size,
@@ -95,53 +66,55 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
95
66
  getPopupContainer,
96
67
  ...rest
97
68
  } = props;
98
- const { token } = import_design.theme.useToken();
99
- const isCn = locale.antLocale === "zh-cn";
100
- const isEN = locale.antLocale === "en";
101
- const isMoment = import_moment.default.isMoment(defaultValue == null ? void 0 : defaultValue[0]) || import_moment.default.isMoment(defaultValue == null ? void 0 : defaultValue[1]) || import_moment.default.isMoment(value == null ? void 0 : value[0]) || import_moment.default.isMoment(value == null ? void 0 : value[1]) || isMomentProps;
102
- const defaultRangeName = value || defaultValue ? import_constant.CUSTOMIZE : defaultQuickValue ?? ((_a = selects == null ? void 0 : selects[0]) == null ? void 0 : _a.name);
103
- const [rangeName, setRangeName] = (0, import_react.useState)(defaultRangeName);
104
- const [innerValue, setInnerValue] = (0, import_react.useState)(() => {
105
- var _a2;
106
- const initValue = value ?? defaultValue ?? ((_a2 = selects.find((item) => item.name === defaultRangeName)) == null ? void 0 : _a2.range(isMoment ? (0, import_moment.default)() : (0, import_dayjs.default)()));
69
+ const {
70
+ token
71
+ } = _design.theme.useToken();
72
+ const isCn = locale.antLocale === 'zh-cn';
73
+ const isEN = locale.antLocale === 'en';
74
+
75
+ // 是否为 moment 时间对象
76
+ const isMoment = _moment.default.isMoment(defaultValue?.[0]) || _moment.default.isMoment(defaultValue?.[1]) || _moment.default.isMoment(value?.[0]) || _moment.default.isMoment(value?.[1]) || isMomentProps;
77
+ const defaultRangeName = value || defaultValue ? _constant.CUSTOMIZE : defaultQuickValue ?? selects?.[0]?.name;
78
+ const [rangeName, setRangeName] = (0, _react.useState)(defaultRangeName);
79
+ const [innerValue, setInnerValue] = (0, _react.useState)(() => {
80
+ const initValue = value ?? defaultValue ?? selects.find(item => item.name === defaultRangeName)?.range(isMoment ? (0, _moment.default)() : (0, _dayjs.default)());
107
81
  if (onChange) {
108
82
  onChange(initValue);
109
83
  }
110
84
  return initValue;
111
85
  });
112
- const [open, setOpen] = (0, import_react.useState)(false);
113
- const [tooltipOpen, setTooltipOpen] = (0, import_react.useState)(false);
114
- const [backRadioFocused, setBackRadioFocused] = (0, import_react.useState)(false);
115
- const [historyMenuVisible, setHistoryMenuVisible] = (0, import_react.useState)(false);
116
- const rangeRef = (0, import_react.useRef)(null);
117
- const popRef = (0, import_react.useRef)(null);
118
- const labelRef = (0, import_react.useRef)(null);
119
- const [isPlay, setIsPlay] = (0, import_react.useState)(rangeName !== import_constant.CUSTOMIZE);
120
- const history = (0, import_react.useMemo)(() => {
86
+ const [open, setOpen] = (0, _react.useState)(false);
87
+ const [tooltipOpen, setTooltipOpen] = (0, _react.useState)(false);
88
+ const [backRadioFocused, setBackRadioFocused] = (0, _react.useState)(false);
89
+ const [historyMenuVisible, setHistoryMenuVisible] = (0, _react.useState)(false);
90
+ const rangeRef = (0, _react.useRef)(null);
91
+ const popRef = (0, _react.useRef)(null);
92
+ const labelRef = (0, _react.useRef)(null);
93
+
94
+ // 没有 selects 时,回退到普通 RangePicker, 当前时间选项为自定义时,应该显示 RangePicker
95
+ const [isPlay, setIsPlay] = (0, _react.useState)(rangeName !== _constant.CUSTOMIZE);
96
+ const history = (0, _react.useMemo)(() => {
121
97
  if (historyProp) {
122
98
  return {
123
- capacity: typeof historyProp === "object" ? historyProp.capacity : DefaultMaxHistoryCapacity
99
+ capacity: typeof historyProp === 'object' ? historyProp.capacity : DefaultMaxHistoryCapacity
124
100
  };
125
101
  }
126
102
  return false;
127
103
  }, [historyProp]);
128
104
  const localStorageKey = `${prefixCls}-date-ranger-history`;
129
- const [rangeHistory, setRangeHistory] = (0, import_util.useLocalStorageState)(
130
- localStorageKey,
131
- { defaultValue: [], listenStorageChange: true }
132
- );
133
- const updateRangeHistory = (range) => {
105
+ const [rangeHistory, setRangeHistory] = (0, _util.useLocalStorageState)(localStorageKey, {
106
+ defaultValue: [],
107
+ listenStorageChange: true
108
+ });
109
+ const updateRangeHistory = range => {
134
110
  if (!range) {
135
111
  return;
136
112
  }
137
113
  if (range.length < 2 || !history) {
138
114
  return;
139
115
  }
140
- const formattedValue = [
141
- range[0].format(import_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN),
142
- range[1].format(import_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN)
143
- ];
144
- if (rangeHistory.find((item) => (0, import_lodash.isEqual)(item, formattedValue))) {
116
+ const formattedValue = [range[0].format(_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN), range[1].format(_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN)];
117
+ if (rangeHistory.find(item => (0, _lodash.isEqual)(item, formattedValue))) {
145
118
  return;
146
119
  }
147
120
  const updatedValue = [formattedValue, ...rangeHistory];
@@ -150,35 +123,30 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
150
123
  }
151
124
  setRangeHistory(updatedValue);
152
125
  };
153
- const delRangeHistory = (range) => {
154
- const updatedValue = rangeHistory.filter((item) => !(0, import_lodash.isEqual)(item, range));
126
+ const delRangeHistory = range => {
127
+ const updatedValue = rangeHistory.filter(item => !(0, _lodash.isEqual)(item, range));
155
128
  setRangeHistory(updatedValue);
156
129
  };
157
130
  const compare = (m1, m2) => {
158
- if (Array.isArray(m1) && !Array.isArray(m2))
159
- return false;
160
- if (Array.isArray(m2) && !Array.isArray(m1))
161
- return false;
131
+ if (Array.isArray(m1) && !Array.isArray(m2)) return false;
132
+ if (Array.isArray(m2) && !Array.isArray(m1)) return false;
162
133
  return value[0] === innerValue[0] || value[1] === innerValue[1];
163
134
  };
164
- (0, import_ahooks.useClickAway)(() => {
135
+ (0, _ahooks.useClickAway)(() => {
165
136
  closeTooltip();
166
137
  }, [
167
- // 有range输入框时才将其ref引用加入依赖(即极简模式不加入)
168
- ...!simpleMode || !isPlay ? [rangeRef] : [],
169
- popRef,
170
- labelRef
171
- ]);
172
- (0, import_react.useEffect)(() => {
173
- if ((0, import_lodash.isNil)(value) && (0, import_lodash.isNil)(innerValue))
174
- return;
175
- if ((0, import_lodash.isNil)(value) && !(0, import_lodash.isNil)(innerValue))
176
- return;
138
+ // 有range输入框时才将其ref引用加入依赖(即极简模式不加入)
139
+ ...(!simpleMode || !isPlay ? [rangeRef] : []), popRef, labelRef]);
140
+ (0, _react.useEffect)(() => {
141
+ if ((0, _lodash.isNil)(value) && (0, _lodash.isNil)(innerValue)) return;
142
+ // FIXME: 当前存在值的时候赋空值给组件,不好处理先 workaround 绕过,后面再想一个整体的方案
143
+ if ((0, _lodash.isNil)(value) && !(0, _lodash.isNil)(innerValue)) return;
177
144
  const isEqual = compare(value, innerValue);
145
+ // 前后时间有差异时,进行赋值
178
146
  if (!isEqual) {
179
147
  setInnerValue(value);
180
148
  if (!stickRangeName) {
181
- setRangeName(import_constant.CUSTOMIZE);
149
+ setRangeName(_constant.CUSTOMIZE);
182
150
  }
183
151
  }
184
152
  }, [value, stickRangeName]);
@@ -186,35 +154,36 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
186
154
  setOpen(false);
187
155
  setTooltipOpen(false);
188
156
  };
189
- const handleNameChange = (name) => {
190
- if (name !== import_constant.CUSTOMIZE) {
157
+ const handleNameChange = name => {
158
+ if (name !== _constant.CUSTOMIZE) {
191
159
  closeTooltip();
192
160
  }
193
161
  setRangeName(name);
194
162
  };
195
- const rangeChange = (range) => {
163
+ const rangeChange = range => {
196
164
  setInnerValue(range);
197
165
  onChange(range);
198
166
  updateRangeHistory(range);
199
167
  };
200
- const datePickerChange = (range) => {
168
+ const datePickerChange = range => {
201
169
  rangeChange(range);
202
- setRangeName(import_constant.CUSTOMIZE);
170
+ setRangeName(_constant.CUSTOMIZE);
203
171
  };
204
- const disabledFuture = (current) => {
205
- const futureDay = import_moment.default.isMoment(current) ? (0, import_moment.default)().endOf("day") : (0, import_dayjs.default)().endOf("day");
172
+ const disabledFuture = current => {
173
+ const futureDay = _moment.default.isMoment(current) ? (0, _moment.default)().endOf('day') : (0, _dayjs.default)().endOf('day');
174
+ // 禁止选择未来日期
206
175
  return current && futureDay && current > futureDay;
207
176
  };
208
- const startTime = innerValue == null ? void 0 : innerValue[0];
209
- const endTime = innerValue == null ? void 0 : innerValue[1];
210
- const differenceMs = endTime == null ? void 0 : endTime.diff(startTime);
211
- const differenceSeconds = endTime == null ? void 0 : endTime.diff(startTime, "seconds");
212
- const differenceMinutes = endTime == null ? void 0 : endTime.diff(startTime, "minutes");
213
- const differenceHours = endTime == null ? void 0 : endTime.diff(startTime, "hours");
214
- const differenceDays = endTime == null ? void 0 : endTime.diff(startTime, "days");
215
- const differenceWeeks = endTime == null ? void 0 : endTime.diff(startTime, "weeks");
216
- const differenceMonths = endTime == null ? void 0 : endTime.diff(startTime, "months");
217
- const differenceYears = endTime == null ? void 0 : endTime.diff(startTime, "years");
177
+ const startTime = innerValue?.[0];
178
+ const endTime = innerValue?.[1];
179
+ const differenceMs = endTime?.diff(startTime);
180
+ const differenceSeconds = endTime?.diff(startTime, 'seconds');
181
+ const differenceMinutes = endTime?.diff(startTime, 'minutes');
182
+ const differenceHours = endTime?.diff(startTime, 'hours');
183
+ const differenceDays = endTime?.diff(startTime, 'days');
184
+ const differenceWeeks = endTime?.diff(startTime, 'weeks');
185
+ const differenceMonths = endTime?.diff(startTime, 'months');
186
+ const differenceYears = endTime?.diff(startTime, 'years');
218
187
  const getCustomizeRangeLabel = () => {
219
188
  if (!autoCalcRange) {
220
189
  return locale.customize;
@@ -258,407 +227,353 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
258
227
  return isEN ? `Nearly ${differenceSeconds} seconds` : `近 ${differenceSeconds} 秒`;
259
228
  };
260
229
  const getHistoryTitle = () => {
261
- return isEN ? "History records" : "历史记录";
230
+ return isEN ? 'History records' : '历史记录';
262
231
  };
263
232
  const setNow = () => {
264
- const selected = selects.find((item) => item.name === rangeName);
265
- if (selected == null ? void 0 : selected.range) {
266
- rangeChange(selected.range(isMoment ? (0, import_moment.default)() : (0, import_dayjs.default)()));
233
+ const selected = selects.find(item => item.name === rangeName);
234
+ if (selected?.range) {
235
+ rangeChange(selected.range(isMoment ? (0, _moment.default)() : (0, _dayjs.default)()));
267
236
  }
268
- if (rangeName === import_constant.CUSTOMIZE) {
269
- const eTime = isMoment ? (0, import_moment.default)() : (0, import_dayjs.default)();
270
- rangeChange([eTime == null ? void 0 : eTime.clone().subtract(differenceMs), eTime]);
237
+ if (rangeName === _constant.CUSTOMIZE) {
238
+ const eTime = isMoment ? (0, _moment.default)() : (0, _dayjs.default)();
239
+ rangeChange([eTime?.clone().subtract(differenceMs), eTime]);
271
240
  }
272
241
  };
273
- (0, import_react.useImperativeHandle)(ref, () => ({
242
+ (0, _react.useImperativeHandle)(ref, () => ({
274
243
  updateCurrentTime: setNow
275
244
  }));
276
- const currentRange = selects.find((_item) => _item.name === rangeName);
277
- const rangeLabel = rangeName === import_constant.CUSTOMIZE ? getCustomizeRangeLabel() : currentRange == null ? void 0 : currentRange.rangeLabel;
278
- const label = rangeName === import_constant.CUSTOMIZE ? getCustomizeLabel() : isEN ? currentRange.enLabel || currentRange.label : currentRange.label;
279
- const thisYear = (/* @__PURE__ */ new Date()).getFullYear();
280
- const isThisYear = (startTime == null ? void 0 : startTime.year()) === thisYear && (endTime == null ? void 0 : endTime.year()) === thisYear;
281
- const rangeNameIndex = (0, import_lodash.findIndex)(selects, (item) => item.name === rangeName);
282
- const nextRangeItem = rangeNameIndex === -1 ? selects.find((item) => {
283
- const [s, e] = item.range(isMoment ? (0, import_moment.default)() : (0, import_dayjs.default)());
245
+ const currentRange = selects.find(_item => _item.name === rangeName);
246
+ const rangeLabel = rangeName === _constant.CUSTOMIZE ? getCustomizeRangeLabel() : currentRange?.rangeLabel;
247
+ const label = rangeName === _constant.CUSTOMIZE ? getCustomizeLabel() : isEN ? currentRange.enLabel || currentRange.label : currentRange.label;
248
+ const thisYear = new Date().getFullYear();
249
+ const isThisYear = startTime?.year() === thisYear && endTime?.year() === thisYear;
250
+ const rangeNameIndex = (0, _lodash.findIndex)(selects, item => item.name === rangeName);
251
+ const nextRangeItem = rangeNameIndex === -1 ? selects.find(item => {
252
+ const [s, e] = item.range(isMoment ? (0, _moment.default)() : (0, _dayjs.default)());
253
+ // 自定义模式下,对比毫秒来选出比当前范围大一级的 rangeItem
284
254
  const diffMs = e.diff(s);
285
255
  return diffMs > differenceMs;
286
256
  }) : selects[rangeNameIndex + 1];
287
- return wrapSSR(
288
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
289
- import_design.Space,
290
- {
291
- className: (0, import_classnames.default)(rest.className, {
292
- [prefix]: true,
293
- [`${prefix}-show-range`]: true,
294
- [`${prefix}-back-radio-focused`]: backRadioFocused
257
+ return wrapSSR( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Space, {
258
+ className: (0, _classnames.default)(rest.className, {
259
+ [prefix]: true,
260
+ [`${prefix}-show-range`]: true,
261
+ [`${prefix}-back-radio-focused`]: backRadioFocused
262
+ }),
263
+ style: rest.style,
264
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Space, {
265
+ size: 0,
266
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
267
+ className: (0, _classnames.default)(`${prefix}-wrapper`, {
268
+ [`${prefix}-wrapper-has-jumper`]: hasRewind || hasForward
295
269
  }),
296
- style: rest.style,
297
- children: [
298
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_design.Space, { size: 0, children: [
299
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
300
- "div",
301
- {
302
- className: (0, import_classnames.default)(`${prefix}-wrapper`, {
303
- [`${prefix}-wrapper-has-jumper`]: hasRewind || hasForward
304
- }),
305
- children: [
306
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
307
- import_design.Dropdown,
308
- {
309
- trigger: ["click"],
310
- open,
311
- placement: rest.placement,
312
- autoAdjustOverflow,
313
- getPopupContainer,
314
- destroyOnHidden: true,
315
- onOpenChange: (o) => {
316
- if (o === false && tooltipOpen) {
317
- return;
318
- }
319
- setOpen(o);
320
- },
321
- popupRender: (originNode) => {
322
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
323
- "div",
324
- {
325
- ref: popRef,
326
- className: (0, import_classnames.default)(`${prefix}-dropdown-picker`, overlayClassName),
327
- style: overlayStyle,
328
- children: [
329
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_design.Flex, { vertical: true, justify: "space-between", children: [
330
- !historyMenuVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "options", children: originNode }),
331
- history && historyMenuVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "history", children: [
332
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
333
- import_design.Button,
334
- {
335
- type: "link",
336
- style: { paddingLeft: 8, color: token.colorTextBase },
337
- onClick: (e) => {
338
- setHistoryMenuVisible(false);
339
- e.stopPropagation();
340
- },
341
- children: [
342
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ArrowLeftOutlined, { color: token.colorTextLabel }),
343
- getHistoryTitle()
344
- ]
345
- }
346
- ),
347
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
348
- import_design.Menu,
349
- {
350
- onClick: ({ key: rangeString }) => {
351
- const vList = rangeString.split(",").map((v) => v.trim());
352
- rangeChange(
353
- vList.map((v) => {
354
- return isMoment ? (0, import_moment.default)(v) : (0, import_dayjs.default)(v);
355
- })
356
- );
357
- handleNameChange(import_constant.CUSTOMIZE);
358
- },
359
- style: { maxHeight: 480, overflowY: "auto" },
360
- items: rangeHistory.map((range) => {
361
- return {
362
- key: String(range),
363
- label: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
364
- import_design.Flex,
365
- {
366
- className: `${prefix}-history-menu-item`,
367
- vertical: true,
368
- children: [
369
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
370
- (isMoment ? (0, import_moment.default)(range[0]) : (0, import_dayjs.default)(range[0])).format(
371
- import_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN
372
- ),
373
- "~"
374
- ] }),
375
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: (isMoment ? (0, import_moment.default)(range[1]) : (0, import_dayjs.default)(range[1])).format(
376
- import_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN
377
- ) }),
378
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_design.Space, { className: `${prefix}-menu-text-btn-wrapper`, children: [
379
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
380
- import_design.Button,
381
- {
382
- className: `${prefix}-menu-text-btn`,
383
- type: "text",
384
- color: "default",
385
- variant: "filled",
386
- size: "small",
387
- onClick: (e) => {
388
- e.stopPropagation();
389
- const vList = range.map((v) => v);
390
- const text = `${vList.join("~")}`;
391
- navigator.clipboard.writeText(text);
392
- import_design.message.success(text);
393
- },
394
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CopyOutlined, {})
395
- }
396
- ),
397
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
398
- import_design.Button,
399
- {
400
- className: `${prefix}-menu-text-btn`,
401
- type: "text",
402
- color: "default",
403
- variant: "filled",
404
- size: "small",
405
- onClick: (e) => {
406
- e.stopPropagation();
407
- delRangeHistory(range);
408
- },
409
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.DeleteOutlined, {})
410
- }
411
- )
412
- ] })
413
- ]
414
- },
415
- String(range)
416
- )
417
- };
418
- })
419
- }
420
- )
421
- ] }),
422
- history && !historyMenuVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
423
- import_design.Button,
424
- {
425
- type: "link",
426
- style: { width: "max-content" },
427
- onClick: (e) => {
428
- setHistoryMenuVisible(true);
429
- e.stopPropagation();
430
- },
431
- children: [
432
- getHistoryTitle(),
433
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.RightOutlined, {})
434
- ]
435
- }
436
- )
437
- ] }),
438
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design.Divider, { type: "vertical", style: { height: "auto", margin: "0px 4px 0px 0px" } }),
439
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
440
- import_PickerPanel.default,
441
- {
442
- defaultValue: innerValue || [],
443
- locale,
444
- disabledDate: pastOnly ? disabledFuture : disabledDate,
445
- tip,
446
- isMoment,
447
- rules,
448
- hideSecond,
449
- onOk: (vList) => {
450
- setIsPlay(false);
451
- handleNameChange(import_constant.CUSTOMIZE);
452
- rangeChange(
453
- vList.map((v) => {
454
- return isMoment ? (0, import_moment.default)(v) : (0, import_dayjs.default)(v);
455
- })
456
- );
457
- closeTooltip();
458
- },
459
- onCancel: () => {
460
- closeTooltip();
461
- }
462
- }
463
- )
464
- ]
465
- }
466
- );
467
- },
468
- menu: {
469
- selectable: true,
470
- defaultSelectedKeys: [rangeName],
471
- onClick: ({ key, domEvent }) => {
472
- const selected = selects.find((_item) => _item.name === key);
473
- if (selected == null ? void 0 : selected.range) {
474
- handleNameChange(key);
475
- setIsPlay(true);
476
- rangeChange(selected.range(isMoment ? (0, import_moment.default)() : (0, import_dayjs.default)()));
477
- }
478
- },
479
- items: selects.filter((item) => {
480
- return !!item;
481
- }).map((item) => {
482
- return {
483
- key: item.name,
484
- label: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_design.Space, { size: 8, style: { minWidth: 100 }, children: [
485
- hasTagInPicker && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `${prefix}-label`, children: item.rangeLabel }),
486
- isEN ? item.enLabel || item.label : item.label
487
- ] })
488
- };
489
- })
490
- },
491
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
492
- import_design.Space,
493
- {
494
- ref: labelRef,
495
- size: 0,
496
- onClick: () => {
497
- setOpen(true);
498
- setTooltipOpen(true);
499
- },
500
- children: [
501
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
502
- "span",
503
- {
504
- className: `${prefix}-label`,
505
- style: {
506
- marginLeft: 8
507
- },
508
- children: rangeLabel
509
- }
510
- ),
511
- simpleMode && isPlay && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${prefix}-play`, children: label })
512
- ]
513
- }
514
- )
515
- }
516
- ),
517
- (!simpleMode || !isPlay) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
518
- "span",
519
- {
520
- ref: rangeRef,
521
- onClick: () => {
522
- setOpen(true);
523
- setTooltipOpen(true);
524
- },
525
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
526
- import_design.DatePicker.RangePicker,
527
- {
528
- className: (0, import_classnames.default)(`${prefix}-picker`),
529
- style: {
530
- // pointerEvents: 'none',
531
- border: 0
532
- },
533
- format: (v) => {
534
- if (hideYear && isThisYear) {
535
- return hideSecond ? v.format(isCn ? import_constant.DATE_TIME_FORMAT_CN : import_constant.DATE_TIME_FORMAT) : v.format(isCn ? import_constant.DATE_TIME_SECOND_FORMAT_CN : import_constant.DATE_TIME_SECOND_FORMAT);
536
- }
537
- return hideSecond ? v.format(isCn ? import_constant.YEAR_DATE_TIME_FORMAT_CN : import_constant.YEAR_DATE_TIME_FORMAT) : v.format(
538
- isCn ? import_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN : import_constant.YEAR_DATE_TIME_SECOND_FORMAT
539
- );
540
- },
541
- value: innerValue,
542
- onChange: datePickerChange,
543
- allowClear: false,
544
- size,
545
- suffixIcon: null,
546
- ...(0, import_lodash.omit)(rest, "value", "onChange", "style", "className"),
547
- open: false
548
- }
549
- )
550
- }
551
- )
552
- ]
553
- }
554
- ),
555
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
556
- import_design.Radio.Group,
557
- {
558
- value: isPlay ? "play" : "",
559
- className: `${prefix}-playback-control`,
560
- buttonStyle: "solid",
561
- children: [
562
- hasRewind && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
563
- import_design.Tooltip,
564
- {
565
- title: locale.jumpBack,
566
- getPopupContainer: (trigger) => trigger.parentNode,
567
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
568
- import_design.Radio.Button,
569
- {
570
- value: "stepBack",
571
- style: {
572
- paddingInline: 8,
573
- borderInlineStart: 0,
574
- borderTopLeftRadius: 0,
575
- borderBottomLeftRadius: 0
576
- },
577
- onMouseEnter: () => setBackRadioFocused(true),
578
- onMouseLeave: () => setBackRadioFocused(false),
579
- onClick: () => {
580
- if (isPlay) {
581
- setIsPlay(false);
582
- }
583
- if (startTime && endTime) {
584
- const newStartTime = startTime.clone().subtract(differenceMs, "milliseconds");
585
- const newEndTime = startTime == null ? void 0 : startTime.clone();
586
- rangeChange([newStartTime, newEndTime]);
587
- }
588
- },
589
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.LeftOutlined, {})
590
- }
591
- )
592
- }
593
- ),
594
- hasForward && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
595
- import_design.Tooltip,
596
- {
597
- title: locale.jumpForward,
598
- getPopupContainer: (trigger) => trigger.parentNode,
599
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
600
- import_design.Radio.Button,
601
- {
602
- value: "stepForward",
603
- style: {
604
- paddingInline: 8,
605
- borderInlineStart: 0,
606
- borderTopLeftRadius: 0,
607
- borderBottomLeftRadius: 0
608
- },
609
- onClick: () => {
610
- if (startTime && endTime) {
611
- const newStartTime = endTime.clone();
612
- const newEndTime = endTime.clone().add(differenceMs);
613
- if (newEndTime.isBefore(/* @__PURE__ */ new Date())) {
614
- rangeChange([newStartTime, newEndTime]);
615
- } else {
616
- setIsPlay(true);
617
- setNow();
618
- }
619
- }
620
- },
621
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.RightOutlined, {})
622
- }
623
- )
624
- }
625
- )
626
- ]
627
- }
628
- )
629
- ] }),
630
- hasSync && rangeName !== import_constant.CUSTOMIZE && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
631
- import_design.Button,
632
- {
633
- style: { paddingInline: 8, color: token.colorTextSecondary },
634
- onClick: () => {
635
- setNow();
636
- },
637
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.SyncOutlined, {})
270
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Dropdown, {
271
+ trigger: ['click'],
272
+ open: open,
273
+ placement: rest.placement,
274
+ autoAdjustOverflow: autoAdjustOverflow,
275
+ getPopupContainer: getPopupContainer
276
+ // 关闭后进行销毁,才可以将 Tooltip 进行同步关闭
277
+ ,
278
+ destroyOnHidden: true,
279
+ onOpenChange: o => {
280
+ if (o === false && tooltipOpen) {
281
+ return;
638
282
  }
639
- ),
640
- hasZoomOut && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
641
- import_design.Button,
642
- {
643
- disabled: !nextRangeItem,
644
- style: { color: token.colorTextSecondary },
645
- onClick: () => {
646
- setIsPlay(true);
647
- if (nextRangeItem) {
648
- setRangeName(nextRangeItem.name);
649
- rangeChange(nextRangeItem.range(isMoment ? (0, import_moment.default)() : (0, import_dayjs.default)()));
650
- return;
283
+ setOpen(o);
284
+ },
285
+ popupRender: originNode => {
286
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
287
+ ref: popRef,
288
+ className: (0, _classnames.default)(`${prefix}-dropdown-picker`, overlayClassName),
289
+ style: overlayStyle,
290
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Flex, {
291
+ vertical: true,
292
+ justify: "space-between",
293
+ children: [!historyMenuVisible && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
294
+ className: "options",
295
+ children: originNode
296
+ }), history && historyMenuVisible && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
297
+ className: "history",
298
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Button, {
299
+ type: "link",
300
+ style: {
301
+ paddingLeft: 8,
302
+ color: token.colorTextBase
303
+ },
304
+ onClick: e => {
305
+ setHistoryMenuVisible(false);
306
+ e.stopPropagation();
307
+ },
308
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ArrowLeftOutlined, {
309
+ color: token.colorTextLabel
310
+ }), getHistoryTitle()]
311
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Menu, {
312
+ onClick: ({
313
+ key: rangeString
314
+ }) => {
315
+ const vList = rangeString.split(',').map(v => v.trim());
316
+ rangeChange(vList.map(v => {
317
+ return isMoment ? (0, _moment.default)(v) : (0, _dayjs.default)(v);
318
+ }));
319
+ handleNameChange(_constant.CUSTOMIZE);
320
+ },
321
+ style: {
322
+ maxHeight: 480,
323
+ overflowY: 'auto'
324
+ },
325
+ items: rangeHistory.map(range => {
326
+ return {
327
+ key: String(range),
328
+ label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Flex, {
329
+ className: `${prefix}-history-menu-item`,
330
+ vertical: true,
331
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
332
+ children: [(isMoment ? (0, _moment.default)(range[0]) : (0, _dayjs.default)(range[0])).format(_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN), "~"]
333
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
334
+ children: (isMoment ? (0, _moment.default)(range[1]) : (0, _dayjs.default)(range[1])).format(_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN)
335
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Space, {
336
+ className: `${prefix}-menu-text-btn-wrapper`,
337
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Button, {
338
+ className: `${prefix}-menu-text-btn`,
339
+ type: "text",
340
+ color: "default",
341
+ variant: "filled",
342
+ size: "small",
343
+ onClick: e => {
344
+ e.stopPropagation();
345
+ const vList = range.map(v => v);
346
+ const text = `${vList.join('~')}`;
347
+ navigator.clipboard.writeText(text);
348
+ _design.message.success(text);
349
+ },
350
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CopyOutlined, {})
351
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Button, {
352
+ className: `${prefix}-menu-text-btn`,
353
+ type: "text",
354
+ color: "default",
355
+ variant: "filled",
356
+ size: "small",
357
+ onClick: e => {
358
+ e.stopPropagation();
359
+ delRangeHistory(range);
360
+ },
361
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.DeleteOutlined, {})
362
+ })]
363
+ })]
364
+ }, String(range))
365
+ };
366
+ })
367
+ })]
368
+ }), history && !historyMenuVisible && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Button, {
369
+ type: "link",
370
+ style: {
371
+ width: 'max-content'
372
+ },
373
+ onClick: e => {
374
+ setHistoryMenuVisible(true);
375
+ e.stopPropagation();
376
+ },
377
+ children: [getHistoryTitle(), /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.RightOutlined, {})]
378
+ })]
379
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Divider, {
380
+ type: "vertical",
381
+ style: {
382
+ height: 'auto',
383
+ margin: '0px 4px 0px 0px'
651
384
  }
385
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickerPanel.default, {
386
+ defaultValue: innerValue || []
387
+ // @ts-ignore
388
+ ,
389
+ locale: locale,
390
+ disabledDate: pastOnly ? disabledFuture : disabledDate,
391
+ tip: tip,
392
+ isMoment: isMoment,
393
+ rules: rules,
394
+ hideSecond: hideSecond,
395
+ onOk: vList => {
396
+ setIsPlay(false);
397
+ handleNameChange(_constant.CUSTOMIZE);
398
+ rangeChange(vList.map(v => {
399
+ return isMoment ? (0, _moment.default)(v) : (0, _dayjs.default)(v);
400
+ }));
401
+ closeTooltip();
402
+ },
403
+ onCancel: () => {
404
+ closeTooltip();
405
+ }
406
+ })]
407
+ });
408
+ },
409
+ menu: {
410
+ selectable: true,
411
+ defaultSelectedKeys: [rangeName],
412
+ onClick: ({
413
+ key,
414
+ domEvent
415
+ }) => {
416
+ const selected = selects.find(_item => _item.name === key);
417
+ // 存在快捷选项切换为极简模式
418
+ if (selected?.range) {
419
+ handleNameChange(key);
420
+ setIsPlay(true);
421
+ rangeChange(selected.range(isMoment ? (0, _moment.default)() : (0, _dayjs.default)()));
422
+ }
423
+ },
424
+ items: selects.filter(item => {
425
+ return !!item;
426
+ }).map(item => {
427
+ return {
428
+ key: item.name,
429
+ label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Space, {
430
+ size: 8,
431
+ style: {
432
+ minWidth: 100
433
+ },
434
+ children: [hasTagInPicker && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
435
+ className: `${prefix}-label`,
436
+ children: item.rangeLabel
437
+ }), isEN ? item.enLabel || item.label : item.label]
438
+ })
439
+ };
440
+ })
441
+ },
442
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Space, {
443
+ ref: labelRef,
444
+ size: 0,
445
+ onClick: () => {
446
+ setOpen(true);
447
+ setTooltipOpen(true);
448
+ },
449
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
450
+ className: `${prefix}-label`,
451
+ style: {
452
+ marginLeft: 8
652
453
  },
653
- icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ZoomOutOutlined, {})
454
+ children: rangeLabel
455
+ }), simpleMode && isPlay && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
456
+ className: `${prefix}-play`,
457
+ children: label
458
+ })]
459
+ })
460
+ }), (!simpleMode || !isPlay) && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
461
+ ref: rangeRef,
462
+ onClick: () => {
463
+ setOpen(true);
464
+ setTooltipOpen(true);
465
+ },
466
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.DatePicker.RangePicker, {
467
+ className: (0, _classnames.default)(`${prefix}-picker`),
468
+ style: {
469
+ // pointerEvents: 'none',
470
+ border: 0
471
+ },
472
+ format: v => {
473
+ // format 会影响布局,原先采用 v.year() === new Date().getFullYear() 进行判断,value 一共会传入三次(range0 range1 now), 会传入最新的时间导致判断异常
474
+ if (hideYear && isThisYear) {
475
+ return hideSecond ? v.format(isCn ? _constant.DATE_TIME_FORMAT_CN : _constant.DATE_TIME_FORMAT) : v.format(isCn ? _constant.DATE_TIME_SECOND_FORMAT_CN : _constant.DATE_TIME_SECOND_FORMAT);
476
+ }
477
+ return hideSecond ? v.format(isCn ? _constant.YEAR_DATE_TIME_FORMAT_CN : _constant.YEAR_DATE_TIME_FORMAT) : v.format(isCn ? _constant.YEAR_DATE_TIME_SECOND_FORMAT_CN : _constant.YEAR_DATE_TIME_SECOND_FORMAT);
654
478
  }
655
- )
656
- ]
657
- }
658
- )
659
- );
479
+ // @ts-ignore
480
+ ,
481
+ value: innerValue,
482
+ onChange: datePickerChange,
483
+ allowClear: false,
484
+ size: size,
485
+ suffixIcon: null
486
+ // 透传 props 到 antd Ranger
487
+ ,
488
+ ...(0, _lodash.omit)(rest, 'value', 'onChange', 'style', 'className'),
489
+ open: false
490
+ })
491
+ })]
492
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Radio.Group, {
493
+ value: isPlay ? 'play' : '',
494
+ className: `${prefix}-playback-control`,
495
+ buttonStyle: "solid",
496
+ children: [hasRewind && /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Tooltip, {
497
+ title: locale.jumpBack,
498
+ getPopupContainer: trigger => trigger.parentNode,
499
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Radio.Button, {
500
+ value: "stepBack",
501
+ style: {
502
+ paddingInline: 8,
503
+ borderInlineStart: 0,
504
+ borderTopLeftRadius: 0,
505
+ borderBottomLeftRadius: 0
506
+ },
507
+ onMouseEnter: () => setBackRadioFocused(true),
508
+ onMouseLeave: () => setBackRadioFocused(false),
509
+ onClick: () => {
510
+ if (isPlay) {
511
+ setIsPlay(false);
512
+ }
513
+ if (startTime && endTime) {
514
+ const newStartTime = startTime.clone().subtract(differenceMs, 'milliseconds');
515
+ const newEndTime = startTime?.clone();
516
+ rangeChange([newStartTime, newEndTime]);
517
+ }
518
+ },
519
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LeftOutlined, {})
520
+ })
521
+ }), hasForward && /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Tooltip, {
522
+ title: locale.jumpForward,
523
+ getPopupContainer: trigger => trigger.parentNode,
524
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Radio.Button, {
525
+ value: "stepForward",
526
+ style: {
527
+ paddingInline: 8,
528
+ borderInlineStart: 0,
529
+ borderTopLeftRadius: 0,
530
+ borderBottomLeftRadius: 0
531
+ }
532
+ // disabled={isPlay}
533
+ ,
534
+ onClick: () => {
535
+ if (startTime && endTime) {
536
+ const newStartTime = endTime.clone();
537
+ const newEndTime = endTime.clone().add(differenceMs);
538
+ if (newEndTime.isBefore(new Date())) {
539
+ rangeChange([newStartTime, newEndTime]);
540
+ } else {
541
+ setIsPlay(true);
542
+ setNow();
543
+ }
544
+ }
545
+ },
546
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.RightOutlined, {})
547
+ })
548
+ })]
549
+ })]
550
+ }), hasSync && rangeName !== _constant.CUSTOMIZE && /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Button, {
551
+ style: {
552
+ paddingInline: 8,
553
+ color: token.colorTextSecondary
554
+ },
555
+ onClick: () => {
556
+ setNow();
557
+ },
558
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SyncOutlined, {})
559
+ }), hasZoomOut && /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Button, {
560
+ disabled: !nextRangeItem,
561
+ style: {
562
+ color: token.colorTextSecondary
563
+ },
564
+ onClick: () => {
565
+ setIsPlay(true);
566
+ if (nextRangeItem) {
567
+ setRangeName(nextRangeItem.name);
568
+ rangeChange(nextRangeItem.range(isMoment ? (0, _moment.default)() : (0, _dayjs.default)()));
569
+ return;
570
+ }
571
+ },
572
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ZoomOutOutlined, {})
573
+ })]
574
+ }));
660
575
  });
661
- var Ranger_default = (0, import_LocaleWrapper.default)({
662
- componentName: "DateRanger",
663
- defaultLocale: import_zh_CN.default
664
- })(Ranger);
576
+ var _default = exports.default = (0, _LocaleWrapper.default)({
577
+ componentName: 'DateRanger',
578
+ defaultLocale: _zhCN.default
579
+ })(Ranger);