@oceanbase/ui 0.4.19 → 0.4.21

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 (136) hide show
  1. package/dist/ui.min.css +1 -1
  2. package/dist/ui.min.js +1 -1
  3. package/es/Action/Group.js +121 -15
  4. package/es/Action/style/index.js +8 -4
  5. package/es/BasicLayout/locale/ja-JP.d.ts +13 -0
  6. package/es/BasicLayout/locale/ja-JP.js +12 -0
  7. package/es/BatchOperationBar/locale/ja-JP.d.ts +7 -0
  8. package/es/BatchOperationBar/locale/ja-JP.js +6 -0
  9. package/es/Boundary/locale/ja-JP.d.ts +11 -0
  10. package/es/Boundary/locale/ja-JP.js +10 -0
  11. package/es/DateRanger/Ranger.d.ts +4 -0
  12. package/es/DateRanger/Ranger.js +158 -14
  13. package/es/DateRanger/constant/index.js +1 -1
  14. package/es/DateRanger/index.less +23 -0
  15. package/es/DateRanger/locale/ja-JP.d.ts +56 -0
  16. package/es/DateRanger/locale/ja-JP.js +20 -0
  17. package/es/Dialog/locale/ja-JP.d.ts +5 -0
  18. package/es/Dialog/locale/ja-JP.js +4 -0
  19. package/es/DocDialog/locale/ja-JP.d.ts +2 -0
  20. package/es/DocDialog/locale/ja-JP.js +1 -0
  21. package/es/FullscreenBox/locale/ja-JP.d.ts +2 -0
  22. package/es/FullscreenBox/locale/ja-JP.js +1 -0
  23. package/es/GraphToolbar/locale/ja-JP.d.ts +9 -0
  24. package/es/GraphToolbar/locale/ja-JP.js +8 -0
  25. package/es/Highlight/locale/ja-JP.d.ts +4 -0
  26. package/es/Highlight/locale/ja-JP.js +3 -0
  27. package/es/Login/locale/ja-JP.d.ts +28 -0
  28. package/es/Login/locale/ja-JP.js +27 -0
  29. package/es/PageContainer/locale/ja-JP.d.ts +4 -0
  30. package/es/PageContainer/locale/ja-JP.js +3 -0
  31. package/es/Password/locale/ja-JP.d.ts +13 -0
  32. package/es/Password/locale/ja-JP.js +12 -0
  33. package/es/ProTable/index.js +4 -1
  34. package/es/Ranger/locale/ja-JP.d.ts +28 -0
  35. package/es/Ranger/locale/ja-JP.js +29 -0
  36. package/es/SideTip/locale/ja-JP.d.ts +2 -0
  37. package/es/SideTip/locale/ja-JP.js +1 -0
  38. package/es/TaskGraph/locale/ja-JP.d.ts +13 -0
  39. package/es/TaskGraph/locale/ja-JP.js +12 -0
  40. package/es/Welcome/locale/ja-JP.d.ts +5 -0
  41. package/es/Welcome/locale/ja-JP.js +4 -0
  42. package/es/locale/ja-JP.d.ts +3 -0
  43. package/es/locale/ja-JP.js +42 -0
  44. package/lib/Action/Group.js +122 -46
  45. package/lib/Action/Item.js +14 -9
  46. package/lib/Action/style/index.js +16 -1
  47. package/lib/BackgroundTaskManager/RefreshMan.js +3 -12
  48. package/lib/BackgroundTaskManager/index.js +3 -12
  49. package/lib/BasicLayout/Header.js +120 -62
  50. package/lib/BasicLayout/index.js +166 -143
  51. package/lib/BasicLayout/locale/ja-JP.d.ts +13 -0
  52. package/lib/BasicLayout/locale/ja-JP.js +36 -0
  53. package/lib/BatchOperationBar/index.js +59 -44
  54. package/lib/BatchOperationBar/locale/ja-JP.d.ts +7 -0
  55. package/lib/BatchOperationBar/locale/ja-JP.js +30 -0
  56. package/lib/Boundary/Components/Code.js +11 -5
  57. package/lib/Boundary/Components/Exception.js +33 -23
  58. package/lib/Boundary/Components/Function.js +11 -5
  59. package/lib/Boundary/locale/ja-JP.d.ts +11 -0
  60. package/lib/Boundary/locale/ja-JP.js +34 -0
  61. package/lib/ContentWithIcon/index.js +30 -22
  62. package/lib/ContentWithQuestion/index.js +8 -3
  63. package/lib/DateRanger/PickerPanel.js +235 -217
  64. package/lib/DateRanger/Ranger.d.ts +4 -0
  65. package/lib/DateRanger/Ranger.js +396 -227
  66. package/lib/DateRanger/constant/index.js +1 -1
  67. package/lib/DateRanger/index.less +23 -0
  68. package/lib/DateRanger/locale/ja-JP.d.ts +56 -0
  69. package/lib/DateRanger/locale/ja-JP.js +49 -0
  70. package/lib/Dialog/Anchor.js +8 -5
  71. package/lib/Dialog/EventProxy.js +3 -12
  72. package/lib/Dialog/index.js +132 -108
  73. package/lib/Dialog/locale/ja-JP.d.ts +5 -0
  74. package/lib/Dialog/locale/ja-JP.js +28 -0
  75. package/lib/DocDialog/index.js +3 -2
  76. package/lib/DocDialog/locale/ja-JP.d.ts +2 -0
  77. package/lib/DocDialog/locale/ja-JP.js +25 -0
  78. package/lib/FooterToolbar/index.js +3 -2
  79. package/lib/FullscreenBox/index.js +16 -7
  80. package/lib/FullscreenBox/locale/ja-JP.d.ts +2 -0
  81. package/lib/FullscreenBox/locale/ja-JP.js +25 -0
  82. package/lib/GraphToolbar/index.js +70 -58
  83. package/lib/GraphToolbar/locale/ja-JP.d.ts +9 -0
  84. package/lib/GraphToolbar/locale/ja-JP.js +32 -0
  85. package/lib/Highlight/DiffView/DiffCells.js +17 -10
  86. package/lib/Highlight/DiffView/index.js +35 -31
  87. package/lib/Highlight/HighlightCell.js +13 -10
  88. package/lib/Highlight/JsonView.js +15 -14
  89. package/lib/Highlight/index.js +50 -45
  90. package/lib/Highlight/locale/ja-JP.d.ts +4 -0
  91. package/lib/Highlight/locale/ja-JP.js +27 -0
  92. package/lib/IconFont/index.js +2 -12
  93. package/lib/LightFilter/index.js +3 -2
  94. package/lib/LocaleDropdown/index.js +13 -20
  95. package/lib/Login/ActivateForm.js +53 -60
  96. package/lib/Login/LoginForm.js +118 -109
  97. package/lib/Login/RegisterForm.js +79 -86
  98. package/lib/Login/index.js +92 -64
  99. package/lib/Login/locale/ja-JP.d.ts +28 -0
  100. package/lib/Login/locale/ja-JP.js +51 -0
  101. package/lib/NavMenu/index.js +9 -8
  102. package/lib/PageContainer/ItemRender.js +5 -5
  103. package/lib/PageContainer/index.js +8 -4
  104. package/lib/PageContainer/locale/ja-JP.d.ts +4 -0
  105. package/lib/PageContainer/locale/ja-JP.js +27 -0
  106. package/lib/PageLoading/index.js +6 -16
  107. package/lib/Password/Content.js +38 -42
  108. package/lib/Password/index.js +83 -68
  109. package/lib/Password/locale/ja-JP.d.ts +13 -0
  110. package/lib/Password/locale/ja-JP.js +36 -0
  111. package/lib/ProCard/index.js +4 -3
  112. package/lib/ProTable/index.js +10 -5
  113. package/lib/Ranger/QuickPicker.js +24 -15
  114. package/lib/Ranger/Ranger.js +37 -34
  115. package/lib/Ranger/locale/ja-JP.d.ts +28 -0
  116. package/lib/Ranger/locale/ja-JP.js +53 -0
  117. package/lib/SideTip/Dragger.js +5 -4
  118. package/lib/SideTip/IconLoading.js +25 -25
  119. package/lib/SideTip/index.js +19 -10
  120. package/lib/SideTip/locale/ja-JP.d.ts +2 -0
  121. package/lib/SideTip/locale/ja-JP.js +25 -0
  122. package/lib/TagSelect/Group.js +9 -5
  123. package/lib/TagSelect/Item.js +22 -18
  124. package/lib/TaskGraph/Graph.js +29 -24
  125. package/lib/TaskGraph/index.js +56 -50
  126. package/lib/TaskGraph/locale/ja-JP.d.ts +13 -0
  127. package/lib/TaskGraph/locale/ja-JP.js +36 -0
  128. package/lib/TreeSearch/index.js +30 -35
  129. package/lib/Welcome/index.js +64 -37
  130. package/lib/Welcome/locale/ja-JP.d.ts +5 -0
  131. package/lib/Welcome/locale/ja-JP.js +28 -0
  132. package/lib/Welcome/step.js +11 -4
  133. package/lib/locale/LocaleWrapper.js +15 -14
  134. package/lib/locale/ja-JP.d.ts +3 -0
  135. package/lib/locale/ja-JP.js +71 -0
  136. package/package.json +5 -5
@@ -10,8 +10,8 @@ import { EllipsisOutlined, LoadingOutlined } from '@oceanbase/icons';
10
10
  import { isBoolean, max, omit } from 'lodash';
11
11
  import useStyle from "./style";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
14
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
15
  var getOrder = function getOrder(_ref) {
16
16
  var type = _ref.type,
17
17
  fixed = _ref.fixed;
@@ -29,6 +29,97 @@ var getOrder = function getOrder(_ref) {
29
29
  }
30
30
  return order;
31
31
  };
32
+
33
+ /**
34
+ * 递归查找 Action 组件(可能被 Popconfirm/Tooltip 等组件包裹)
35
+ * 返回实际的 Action 组件和其 props
36
+ */
37
+ var findActionComponent = function findActionComponent(element) {
38
+ var _element$type, _element$type2, _element$props;
39
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
40
+ if (! /*#__PURE__*/React.isValidElement(element)) {
41
+ return null;
42
+ }
43
+
44
+ // 检查是否是 Action.Button 或 Action.Link
45
+ // @ts-ignore
46
+ if (((_element$type = element.type) === null || _element$type === void 0 ? void 0 : _element$type.__DISPLAY_NAME) === 'button' || ((_element$type2 = element.type) === null || _element$type2 === void 0 ? void 0 : _element$type2.__DISPLAY_NAME) === 'link') {
47
+ return {
48
+ action: element,
49
+ wrapper: null
50
+ };
51
+ }
52
+
53
+ // 如果深度太深,避免无限递归
54
+ if (depth > 10) {
55
+ return null;
56
+ }
57
+
58
+ // 如果有 children,递归查找
59
+ var elementChildren = (_element$props = element.props) === null || _element$props === void 0 ? void 0 : _element$props.children;
60
+ if (elementChildren) {
61
+ var child = React.Children.only(elementChildren);
62
+ if ( /*#__PURE__*/React.isValidElement(child)) {
63
+ var result = findActionComponent(child, depth + 1);
64
+ if (result) {
65
+ // 如果找到了 Action 组件,当前元素就是 wrapper
66
+ return {
67
+ action: result.action,
68
+ wrapper: element
69
+ };
70
+ }
71
+ }
72
+ }
73
+ return null;
74
+ };
75
+
76
+ /**
77
+ * 渲染菜单项内容,保持嵌套的 Popconfirm/Tooltip 结构
78
+ */
79
+ var renderMenuItemContent = function renderMenuItemContent(action, actionProps, enableLoading) {
80
+ var loading = actionProps.loading,
81
+ children = actionProps.children,
82
+ tooltip = actionProps.tooltip;
83
+ var result = findActionComponent(action);
84
+ if (!result) {
85
+ // 如果没有找到嵌套结构,使用默认渲染
86
+ var _content = /*#__PURE__*/_jsxs(_Fragment, {
87
+ children: [loading && enableLoading && /*#__PURE__*/_jsx(LoadingOutlined, {}), " ", children || action]
88
+ });
89
+ // 如果有 tooltip,用 Tooltip 包裹
90
+ return tooltip ? /*#__PURE__*/_jsx(Tooltip, {
91
+ title: tooltip,
92
+ children: _content
93
+ }) : _content;
94
+ }
95
+ var actualAction = result.action,
96
+ wrapper = result.wrapper;
97
+
98
+ // 创建新的 action 元素,保留所有 props 并添加 loading 状态
99
+ var newAction = /*#__PURE__*/React.cloneElement(actualAction, _objectSpread(_objectSpread(_objectSpread({}, actualAction.props), actionProps), {}, {
100
+ children: /*#__PURE__*/_jsxs(_Fragment, {
101
+ children: [loading && enableLoading && /*#__PURE__*/_jsx(LoadingOutlined, {}), " ", children || actualAction.props.children]
102
+ })
103
+ }));
104
+
105
+ // 如果 action 被包裹,需要重新构建包裹结构
106
+ if (wrapper) {
107
+ var wrapperProps = wrapper.props;
108
+ // 保持原有的 wrapper 结构,只更新 children
109
+ return /*#__PURE__*/React.cloneElement(wrapper, _objectSpread(_objectSpread({}, wrapperProps), {}, {
110
+ children: newAction
111
+ }));
112
+ }
113
+
114
+ // 如果没有包裹,直接渲染,如果有 tooltip 则用 Tooltip 包裹
115
+ var content = /*#__PURE__*/_jsxs(_Fragment, {
116
+ children: [loading && enableLoading && /*#__PURE__*/_jsx(LoadingOutlined, {}), " ", children || actualAction.props.children]
117
+ });
118
+ return tooltip ? /*#__PURE__*/_jsx(Tooltip, {
119
+ title: tooltip,
120
+ children: content
121
+ }) : content;
122
+ };
32
123
  export default (function (_ref2) {
33
124
  var customizePrefixCls = _ref2.prefixCls,
34
125
  _ref2$size = _ref2.size,
@@ -121,25 +212,40 @@ export default (function (_ref2) {
121
212
  children: ellipsisActions.map(function (action, index) {
122
213
  var _ref3;
123
214
  var actionKey = action.key;
124
- var disabled = false;
125
- if (isBoolean(action.props.disabled)) disabled = action.props.disabled;else if (shouldDisabled) disabled = shouldDisabled(action.key);
215
+ // 查找实际的 Action 组件以获取 props
216
+ var actionResult = findActionComponent(action);
217
+ var actualAction = (actionResult === null || actionResult === void 0 ? void 0 : actionResult.action) || action;
218
+ var actionProps = actualAction.props;
219
+
126
220
  // 当用户传入loading 或者 传入 disabled 的情况都要禁用按钮
127
- var actionDisabled = action.props.loading || (isBoolean(action.props.disabled) ? action.props.disabled : getDefaultDisabled(action.key));
221
+ var actionDisabled = actionProps.loading || (isBoolean(actionProps.disabled) ? actionProps.disabled : getDefaultDisabled(action.key));
222
+
223
+ // 提取需要传递给 Menu.Item 的 props(排除 danger,单独处理)
224
+ var menuItemProps = omit(actionProps, ['disabled', 'loading', 'tooltip', 'visible', 'fixed', 'enableLoading', 'onClick', 'children', 'danger']);
225
+
226
+ // 处理 onClick:如果 action 被 Popconfirm 包裹,Menu.Item 的 onClick 不应该直接触发 action 的 onClick
227
+ // 而是让 Popconfirm 来处理。如果没有 Popconfirm,则正常触发。
228
+ var handleMenuItemClick = function handleMenuItemClick(info) {
229
+ var _actionProps$onClick;
230
+ // 如果 action 被包裹(可能是 Popconfirm 或其他组件),不直接触发 onClick
231
+ // 让包裹组件来处理交互
232
+ if (actionResult !== null && actionResult !== void 0 && actionResult.wrapper) {
233
+ // 包裹组件会处理点击,这里不需要做任何事
234
+ // 注意:Menu.Item 的点击会关闭下拉菜单,但 Popconfirm 应该能够正常显示
235
+ return;
236
+ }
237
+ // 如果没有包裹,正常触发 onClick
238
+ (_actionProps$onClick = actionProps.onClick) === null || _actionProps$onClick === void 0 || _actionProps$onClick.call(actionProps, info.domEvent);
239
+ };
128
240
  return /*#__PURE__*/_jsxs(_Fragment, {
129
241
  children: [/*#__PURE__*/_jsx(Menu.Item, _objectSpread(_objectSpread({
130
242
  // @ts-ignore
131
- onClick: function onClick(_ref4) {
132
- var _action$props$onClick, _action$props;
133
- var domEvent = _ref4.domEvent;
134
- (_action$props$onClick = (_action$props = action.props).onClick) === null || _action$props$onClick === void 0 || _action$props$onClick.call(_action$props, domEvent);
135
- }
136
- }, omit(action.props, ['disabled'])), {}, {
243
+ onClick: handleMenuItemClick,
137
244
  disabled: actionDisabled,
138
- children: /*#__PURE__*/_jsxs(Tooltip, {
139
- title: action.props.tooltip,
140
- children: [action.props.loading && /*#__PURE__*/_jsx(LoadingOutlined, {}), ' ', action.props.children || action]
141
- })
142
- }), (_ref3 = actionKey) !== null && _ref3 !== void 0 ? _ref3 : index.toString()), action.props.divider && /*#__PURE__*/_jsx(Menu.Divider, {})]
245
+ danger: !!actionProps.danger
246
+ }, menuItemProps), {}, {
247
+ children: renderMenuItemContent(action, actionProps, enableLoading)
248
+ }), (_ref3 = actionKey) !== null && _ref3 !== void 0 ? _ref3 : index.toString()), actionProps.divider && /*#__PURE__*/_jsx(Menu.Divider, {})]
143
249
  });
144
250
  })
145
251
  }),
@@ -10,9 +10,7 @@ export var genActionStyle = function genActionStyle(token) {
10
10
  var paddingHorizontal = token.paddingSM;
11
11
  var padding = "".concat(paddingVertical, "px ").concat(paddingHorizontal, "px");
12
12
  var margin = "-".concat(paddingVertical, "px -").concat(paddingHorizontal, "px");
13
- return _defineProperty({}, "".concat(componentCls, "-more-menu"), _defineProperty({
14
- background: 'red'
15
- }, "".concat(antCls, "-dropdown-menu-item"), _defineProperty(_defineProperty({}, "".concat(antCls, "-typography"), _defineProperty({
13
+ return _defineProperty({}, "".concat(componentCls, "-more-menu"), _defineProperty({}, "".concat(antCls, "-dropdown-menu-item"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(antCls, "-typography"), _defineProperty({
16
14
  display: 'block',
17
15
  margin: margin,
18
16
  padding: "".concat(padding, " !important")
@@ -33,7 +31,13 @@ export var genActionStyle = function genActionStyle(token) {
33
31
  background: 'transparent'
34
32
  })), "".concat(antCls, "-wave"), {
35
33
  display: 'none'
36
- }))));
34
+ })), "&".concat(antCls, "-dropdown-menu-item-danger"), _defineProperty(_defineProperty({}, "".concat(antCls, "-typography"), _defineProperty({}, "&:not(".concat(antCls, "-typography-disabled)"), {
35
+ color: 'unset'
36
+ })), "".concat(antCls, "-btn"), _defineProperty({}, "&:not(:disabled):not(".concat(antCls, "-btn-disabled)"), _defineProperty({
37
+ color: 'unset'
38
+ }, "&:hover", {
39
+ color: 'unset'
40
+ }))))));
37
41
  };
38
42
  export default (function (prefixCls) {
39
43
  var useStyle = genComponentStyleHook('Action', function (token) {
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ help: string;
3
+ welcome: string;
4
+ versionNotice: string;
5
+ viewDocs: string;
6
+ downloadDocs: string;
7
+ about: string;
8
+ version: string;
9
+ releaseTime: string;
10
+ company: string;
11
+ right: string;
12
+ };
13
+ export default _default;
@@ -0,0 +1,12 @@
1
+ export default {
2
+ help: 'ヘルプ',
3
+ welcome: 'ウェルカムページ',
4
+ versionNotice: 'バージョン通知',
5
+ viewDocs: 'ユーザーマニュアルを表示',
6
+ downloadDocs: 'ユーザーマニュアルをダウンロード',
7
+ about: 'について',
8
+ version: 'バージョン',
9
+ releaseTime: 'リリース日',
10
+ company: '北京奥星贝斯科技有限公司',
11
+ right: '著作権所有'
12
+ };
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ cancelText: string;
3
+ openText: string;
4
+ hiddenText: string;
5
+ alertText: string;
6
+ };
7
+ export default _default;
@@ -0,0 +1,6 @@
1
+ export default {
2
+ cancelText: '選択解除',
3
+ openText: '選択済みを展開',
4
+ hiddenText: '選択済みを折りたたむ',
5
+ alertText: '${} 件を選択しました'
6
+ };
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ goHome: string;
3
+ noPermission: string;
4
+ noPage: string;
5
+ normal: string;
6
+ test: string;
7
+ collapse: string;
8
+ incompatible: string;
9
+ proposal: string;
10
+ };
11
+ export default _default;
@@ -0,0 +1,10 @@
1
+ export default {
2
+ goHome: 'ホームに戻る',
3
+ noPermission: 'このページへのアクセス権限がありません',
4
+ noPage: 'このページが見つかりません',
5
+ normal: '正常動作',
6
+ test: 'クリックしてクラッシュ効果をテスト',
7
+ collapse: 'ページがクラッシュしました~',
8
+ incompatible: 'ブラウザバージョンが互換性がありません',
9
+ proposal: 'ブラウザバージョンが低すぎます。セキュリティリスクを避けるため、Chrome ブラウザのバージョン 80 以上を使用することをお勧めします'
10
+ };
@@ -8,6 +8,7 @@ import type { Rule } from './PickerPanel';
8
8
  import './index.less';
9
9
  export type RangeName = 'customize' | string;
10
10
  export type RangeValue = [Moment, Moment] | [Dayjs, Dayjs] | [] | null;
11
+ export type RangeValueFormat = [string, string] | [] | null;
11
12
  export type RangeDateValue = {
12
13
  name: RangeName;
13
14
  range: RangeValue;
@@ -20,6 +21,9 @@ export interface DateRangerProps extends Omit<RangePickerProps, 'mode' | 'picker
20
21
  hasSync?: boolean;
21
22
  hasForward?: boolean;
22
23
  hasZoomOut?: boolean;
24
+ history?: boolean | {
25
+ capacity: number;
26
+ };
23
27
  hasTagInPicker?: boolean;
24
28
  tip?: string;
25
29
  rules?: Rule[];
@@ -1,5 +1,4 @@
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 _excluded = ["selects", "value", "defaultValue", "defaultQuickValue", "hasRewind", "hasPlay", "hasSync", "hasForward", "hasZoomOut", "hasTagInPicker", "pastOnly", "simpleMode", "hideYear", "hideSecond", "autoCalcRange", "onChange", "disabledDate", "locale", "size", "stickRangeName", "tooltipProps", "isMoment", "rules", "tip", "autoAdjustOverflow", "overlayClassName", "overlayStyle", "getPopupContainer"];
1
+ var _excluded = ["selects", "value", "defaultValue", "defaultQuickValue", "hasRewind", "hasPlay", "hasSync", "hasForward", "hasZoomOut", "hasTagInPicker", "pastOnly", "simpleMode", "hideYear", "hideSecond", "autoCalcRange", "history", "onChange", "disabledDate", "locale", "size", "stickRangeName", "tooltipProps", "isMoment", "rules", "tip", "autoAdjustOverflow", "overlayClassName", "overlayStyle", "getPopupContainer"];
3
2
  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; }
4
3
  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; }
5
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -9,6 +8,7 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
9
8
  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."); }
10
9
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
10
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
+ 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); }
12
12
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
13
  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."); }
14
14
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -17,11 +17,11 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
19
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
- import React, { useEffect, useState, useImperativeHandle, useRef } from 'react';
21
- import { Button, DatePicker, Divider, Dropdown, Radio, Space, Tooltip, theme } from '@oceanbase/design';
22
- import { LeftOutlined, RightOutlined, ZoomOutOutlined, SyncOutlined } from '@oceanbase/icons';
20
+ import React, { useEffect, useRef, useState, useImperativeHandle, useMemo } from 'react';
21
+ import { Button, DatePicker, Divider, Dropdown, Flex, Menu, Radio, Space, Tooltip, message, theme } from '@oceanbase/design';
22
+ import { LeftOutlined, RightOutlined, ZoomOutOutlined, SyncOutlined, ArrowLeftOutlined, CopyOutlined, DeleteOutlined } from '@oceanbase/icons';
23
23
  import dayjs from 'dayjs';
24
- import { findIndex, isNil, noop, omit } from 'lodash';
24
+ import { findIndex, isEqual as _isEqual, isNil, noop, omit } from 'lodash';
25
25
  import moment from 'moment';
26
26
  import classNames from 'classnames';
27
27
  import LocaleWrapper from "../locale/LocaleWrapper";
@@ -31,8 +31,10 @@ import InternalPickerPanel from "./PickerPanel";
31
31
  import zhCN from "./locale/zh-CN";
32
32
  import "./index.less";
33
33
  import { useClickAway } from 'ahooks';
34
+ import { useLocalStorageState } from '@oceanbase/util';
34
35
  import { jsx as _jsx } from "react/jsx-runtime";
35
36
  import { jsxs as _jsxs } from "react/jsx-runtime";
37
+ var DefaultMaxHistoryCapacity = 20;
36
38
  var prefix = getPrefix('date-ranger');
37
39
  var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
38
40
  var _selects$;
@@ -63,6 +65,8 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
63
65
  hideSecond = _props$hideSecond === void 0 ? false : _props$hideSecond,
64
66
  _props$autoCalcRange = props.autoCalcRange,
65
67
  autoCalcRange = _props$autoCalcRange === void 0 ? false : _props$autoCalcRange,
68
+ _props$history = props.history,
69
+ historyProp = _props$history === void 0 ? false : _props$history,
66
70
  _props$onChange = props.onChange,
67
71
  onChange = _props$onChange === void 0 ? noop : _props$onChange,
68
72
  disabledDate = props.disabledDate,
@@ -116,15 +120,59 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
116
120
  _useState10 = _slicedToArray(_useState9, 2),
117
121
  backRadioFocused = _useState10[0],
118
122
  setBackRadioFocused = _useState10[1];
123
+ var _useState11 = useState(false),
124
+ _useState12 = _slicedToArray(_useState11, 2),
125
+ historyMenuVisible = _useState12[0],
126
+ setHistoryMenuVisible = _useState12[1];
119
127
  var rangeRef = useRef(null);
120
128
  var popRef = useRef(null);
121
129
  var labelRef = useRef(null);
122
130
 
123
131
  // 没有 selects 时,回退到普通 RangePicker, 当前时间选项为自定义时,应该显示 RangePicker
124
- var _useState11 = useState(rangeName !== CUSTOMIZE),
125
- _useState12 = _slicedToArray(_useState11, 2),
126
- isPlay = _useState12[0],
127
- setIsPlay = _useState12[1];
132
+ var _useState13 = useState(rangeName !== CUSTOMIZE),
133
+ _useState14 = _slicedToArray(_useState13, 2),
134
+ isPlay = _useState14[0],
135
+ setIsPlay = _useState14[1];
136
+ var history = useMemo(function () {
137
+ if (historyProp) {
138
+ return {
139
+ capacity: _typeof(historyProp) === 'object' ? historyProp.capacity : DefaultMaxHistoryCapacity
140
+ };
141
+ }
142
+ return false;
143
+ }, [historyProp]);
144
+ var _useLocalStorageState = useLocalStorageState('ob-design-date-ranger-local-storage-range-history-state', {
145
+ defaultValue: [],
146
+ listenStorageChange: true
147
+ }),
148
+ _useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 2),
149
+ rangeHistory = _useLocalStorageState2[0],
150
+ setRangeHistory = _useLocalStorageState2[1];
151
+ var updateRangeHistory = function updateRangeHistory(range) {
152
+ if (!range) {
153
+ return;
154
+ }
155
+ if (range.length < 2 || !history) {
156
+ return;
157
+ }
158
+ var formattedValue = [range[0].format(YEAR_DATE_TIME_SECOND_FORMAT_CN), range[1].format(YEAR_DATE_TIME_SECOND_FORMAT_CN)];
159
+ if (rangeHistory.find(function (item) {
160
+ return _isEqual(item, formattedValue);
161
+ })) {
162
+ return;
163
+ }
164
+ var updatedValue = [formattedValue].concat(_toConsumableArray(rangeHistory));
165
+ if (updatedValue.length > history.capacity) {
166
+ updatedValue.splice(0, history.capacity);
167
+ }
168
+ setRangeHistory(updatedValue);
169
+ };
170
+ var delRangeHistory = function delRangeHistory(range) {
171
+ var updatedValue = rangeHistory.filter(function (item) {
172
+ return !_isEqual(item, range);
173
+ });
174
+ setRangeHistory(updatedValue);
175
+ };
128
176
  var compare = function compare(m1, m2) {
129
177
  if (Array.isArray(m1) && !Array.isArray(m2)) return false;
130
178
  if (Array.isArray(m2) && !Array.isArray(m1)) return false;
@@ -159,6 +207,7 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
159
207
  var rangeChange = function rangeChange(range) {
160
208
  setInnerValue(range);
161
209
  onChange(range);
210
+ updateRangeHistory(range);
162
211
  };
163
212
  var datePickerChange = function datePickerChange(range) {
164
213
  rangeChange(range);
@@ -221,6 +270,9 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
221
270
  }
222
271
  return isEN ? "Nearly ".concat(differenceSeconds, " seconds") : "\u8FD1 ".concat(differenceSeconds, " \u79D2");
223
272
  };
273
+ var getHistoryTitle = function getHistoryTitle() {
274
+ return isEN ? 'History records' : '历史记录';
275
+ };
224
276
  var setNow = function setNow() {
225
277
  var selected = selects.find(function (item) {
226
278
  return item.name === rangeName;
@@ -284,7 +336,99 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
284
336
  ref: popRef,
285
337
  className: classNames("".concat(prefix, "-dropdown-picker"), overlayClassName),
286
338
  style: overlayStyle,
287
- children: [originNode, /*#__PURE__*/_jsx(Divider, {
339
+ children: [/*#__PURE__*/_jsxs(Flex, {
340
+ vertical: true,
341
+ justify: "space-between",
342
+ children: [!historyMenuVisible && /*#__PURE__*/_jsx("div", {
343
+ className: "options",
344
+ children: originNode
345
+ }), history && historyMenuVisible && /*#__PURE__*/_jsxs("div", {
346
+ className: "history",
347
+ children: [/*#__PURE__*/_jsxs(Button, {
348
+ type: "link",
349
+ style: {
350
+ paddingLeft: 8,
351
+ color: token.colorTextBase
352
+ },
353
+ onClick: function onClick(e) {
354
+ setHistoryMenuVisible(false);
355
+ e.stopPropagation();
356
+ },
357
+ children: [/*#__PURE__*/_jsx(ArrowLeftOutlined, {
358
+ color: token.colorTextLabel
359
+ }), getHistoryTitle()]
360
+ }), /*#__PURE__*/_jsx(Menu, {
361
+ onClick: function onClick(_ref4) {
362
+ var rangeString = _ref4.key;
363
+ var vList = rangeString.split(',').map(function (v) {
364
+ return v.trim();
365
+ });
366
+ rangeChange(vList.map(function (v) {
367
+ return isMoment ? moment(v) : dayjs(v);
368
+ }));
369
+ handleNameChange(CUSTOMIZE);
370
+ },
371
+ style: {
372
+ maxHeight: 480,
373
+ overflowY: 'auto'
374
+ },
375
+ items: rangeHistory.map(function (range) {
376
+ return {
377
+ key: String(range),
378
+ label: /*#__PURE__*/_jsxs(Flex, {
379
+ className: "".concat(prefix, "-history-menu-item"),
380
+ vertical: true,
381
+ children: [/*#__PURE__*/_jsxs("span", {
382
+ children: [(isMoment ? moment(range[0]) : dayjs(range[0])).format(YEAR_DATE_TIME_SECOND_FORMAT_CN), "~"]
383
+ }), /*#__PURE__*/_jsx("span", {
384
+ children: (isMoment ? moment(range[1]) : dayjs(range[1])).format(YEAR_DATE_TIME_SECOND_FORMAT_CN)
385
+ }), /*#__PURE__*/_jsxs(Space, {
386
+ className: "".concat(prefix, "-menu-text-btn-wrapper"),
387
+ children: [/*#__PURE__*/_jsx(Button, {
388
+ className: "".concat(prefix, "-menu-text-btn"),
389
+ type: "text",
390
+ color: "default",
391
+ variant: "filled",
392
+ size: "small",
393
+ onClick: function onClick(e) {
394
+ e.stopPropagation();
395
+ var vList = range.map(function (v) {
396
+ return v;
397
+ });
398
+ var text = "".concat(vList.join('~'));
399
+ navigator.clipboard.writeText(text);
400
+ message.success(text);
401
+ },
402
+ children: /*#__PURE__*/_jsx(CopyOutlined, {})
403
+ }), /*#__PURE__*/_jsx(Button, {
404
+ className: "".concat(prefix, "-menu-text-btn"),
405
+ type: "text",
406
+ color: "default",
407
+ variant: "filled",
408
+ size: "small",
409
+ onClick: function onClick(e) {
410
+ e.stopPropagation();
411
+ delRangeHistory(range);
412
+ },
413
+ children: /*#__PURE__*/_jsx(DeleteOutlined, {})
414
+ })]
415
+ })]
416
+ }, String(range))
417
+ };
418
+ })
419
+ })]
420
+ }), history && !historyMenuVisible && /*#__PURE__*/_jsxs(Button, {
421
+ type: "link",
422
+ style: {
423
+ width: 'max-content'
424
+ },
425
+ onClick: function onClick(e) {
426
+ setHistoryMenuVisible(true);
427
+ e.stopPropagation();
428
+ },
429
+ children: [getHistoryTitle(), /*#__PURE__*/_jsx(RightOutlined, {})]
430
+ })]
431
+ }), /*#__PURE__*/_jsx(Divider, {
288
432
  type: "vertical",
289
433
  style: {
290
434
  height: 'auto',
@@ -317,9 +461,9 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
317
461
  menu: {
318
462
  selectable: true,
319
463
  defaultSelectedKeys: [rangeName],
320
- onClick: function onClick(_ref4) {
321
- var key = _ref4.key,
322
- domEvent = _ref4.domEvent;
464
+ onClick: function onClick(_ref5) {
465
+ var key = _ref5.key,
466
+ domEvent = _ref5.domEvent;
323
467
  var selected = selects.find(function (_item) {
324
468
  return _item.name === key;
325
469
  });
@@ -192,7 +192,7 @@ export var THIS_WEEK = {
192
192
  export var LAST_WEEK = {
193
193
  label: '上周',
194
194
  enLabel: 'Last week',
195
- rangeLabel: 'last week',
195
+ rangeLabel: '1w',
196
196
  name: 'LAST_WEEK',
197
197
  range: function range() {
198
198
  var current = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : moment();
@@ -155,3 +155,26 @@
155
155
  }
156
156
  }
157
157
  }
158
+
159
+ .@{prefix}-history-menu-item {
160
+ .@{prefix}-menu-text-btn-wrapper {
161
+ justify-content: space-between;
162
+ height: 0;
163
+ transition: height 0.2s;
164
+ overflow: hidden;
165
+ }
166
+ &:hover {
167
+ .@{prefix}-menu-text-btn-wrapper {
168
+ height: 22px;
169
+ }
170
+ }
171
+ }
172
+
173
+ .@{prefix}-menu-text-btn {
174
+ width: 72px;
175
+
176
+ background-color: @colorFillSecondary !important;
177
+ &:hover {
178
+ background-color: @colorFill !important;
179
+ }
180
+ }
@@ -0,0 +1,56 @@
1
+ declare const _default: {
2
+ locale: string;
3
+ dateFormat?: string;
4
+ dateTimeFormat?: string;
5
+ fieldDateTimeFormat?: string;
6
+ fieldDateFormat?: string;
7
+ fieldTimeFormat?: string;
8
+ fieldMonthFormat?: string;
9
+ fieldYearFormat?: string;
10
+ fieldWeekFormat?: string;
11
+ fieldQuarterFormat?: string;
12
+ monthBeforeYear?: boolean;
13
+ yearFormat?: string;
14
+ monthFormat?: string;
15
+ cellYearFormat?: string;
16
+ cellQuarterFormat?: string;
17
+ dayFormat?: string;
18
+ cellDateFormat?: string;
19
+ cellMeridiemFormat?: string;
20
+ today: string;
21
+ now: string;
22
+ backToToday: string;
23
+ ok: string;
24
+ timeSelect: string;
25
+ dateSelect: string;
26
+ weekSelect?: string;
27
+ clear: string;
28
+ week: string;
29
+ month: string;
30
+ year: string;
31
+ previousMonth: string;
32
+ nextMonth: string;
33
+ monthSelect: string;
34
+ yearSelect: string;
35
+ decadeSelect: string;
36
+ previousYear: string;
37
+ nextYear: string;
38
+ previousDecade: string;
39
+ nextDecade: string;
40
+ previousCentury: string;
41
+ nextCentury: string;
42
+ shortWeekDays?: string[];
43
+ shortMonths?: string[];
44
+ customize: string;
45
+ customTime: string;
46
+ startDate: string;
47
+ startTime: string;
48
+ endDate: string;
49
+ endTime: string;
50
+ cancel: string;
51
+ confirm: string;
52
+ current: string;
53
+ jumpBack: string;
54
+ jumpForward: string;
55
+ };
56
+ export default _default;
@@ -0,0 +1,20 @@
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
+ 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
+ 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
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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 ja_JP from 'rc-picker/es/locale/ja_JP';
8
+ export default _objectSpread({
9
+ customize: 'カスタム',
10
+ customTime: 'カスタム時間',
11
+ startDate: '開始日',
12
+ startTime: '開始時刻',
13
+ endDate: '終了日',
14
+ endTime: '終了時刻',
15
+ cancel: 'キャンセル',
16
+ confirm: '確定',
17
+ current: '現在',
18
+ jumpBack: '前の時間間隔にジャンプ',
19
+ jumpForward: '次の時間間隔にジャンプ'
20
+ }, ja_JP);
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ helpDocument: string;
3
+ openHelpCenter: string;
4
+ };
5
+ export default _default;
@@ -0,0 +1,4 @@
1
+ export default {
2
+ helpDocument: 'ヘルプドキュメント',
3
+ openHelpCenter: 'ドキュメントセンターを開く'
4
+ };