@oceanbase/ui 1.0.0-alpha.13 → 1.0.0-alpha.14
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.
- package/dist/ui.min.js +1 -1
- package/es/Action/Group.js +54 -46
- package/es/FooterToolbar/style/index.js +2 -5
- package/es/Highlight/index.d.ts +1 -1
- package/es/PageContainer/index.js +11 -2
- package/es/PageContainer/style/index.js +10 -8
- package/lib/Action/Group.js +54 -48
- package/lib/FooterToolbar/style/index.js +2 -5
- package/lib/Highlight/index.d.ts +1 -1
- package/lib/PageContainer/index.js +11 -2
- package/lib/PageContainer/style/index.js +19 -6
- package/package.json +3 -3
package/es/Action/Group.js
CHANGED
|
@@ -31,23 +31,29 @@ var getOrder = function getOrder(_ref) {
|
|
|
31
31
|
return order;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* 判断是否是 Action 组件(Action.Button 或 Action.Link)
|
|
36
|
+
*/
|
|
37
|
+
var isActionComponent = function isActionComponent(element) {
|
|
38
|
+
var _element$type, _element$type2;
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
return ((_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';
|
|
41
|
+
};
|
|
42
|
+
|
|
34
43
|
/**
|
|
35
44
|
* 递归查找 Action 组件(可能被 Popconfirm/Tooltip 等组件包裹)
|
|
36
|
-
* 返回实际的 Action
|
|
45
|
+
* 返回实际的 Action 组件和是否被包裹
|
|
37
46
|
*/
|
|
38
47
|
var findActionComponent = function findActionComponent(element) {
|
|
39
|
-
var _element$
|
|
48
|
+
var _element$props;
|
|
40
49
|
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
41
50
|
if (! /*#__PURE__*/React.isValidElement(element)) {
|
|
42
51
|
return null;
|
|
43
52
|
}
|
|
44
|
-
|
|
45
|
-
// 检查是否是 Action.Button 或 Action.Link
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
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') {
|
|
53
|
+
if (isActionComponent(element)) {
|
|
48
54
|
return {
|
|
49
55
|
action: element,
|
|
50
|
-
|
|
56
|
+
hasWrapper: false
|
|
51
57
|
};
|
|
52
58
|
}
|
|
53
59
|
|
|
@@ -63,10 +69,9 @@ var findActionComponent = function findActionComponent(element) {
|
|
|
63
69
|
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
64
70
|
var result = findActionComponent(child, depth + 1);
|
|
65
71
|
if (result) {
|
|
66
|
-
// 如果找到了 Action 组件,当前元素就是 wrapper
|
|
67
72
|
return {
|
|
68
73
|
action: result.action,
|
|
69
|
-
|
|
74
|
+
hasWrapper: true
|
|
70
75
|
};
|
|
71
76
|
}
|
|
72
77
|
}
|
|
@@ -74,6 +79,24 @@ var findActionComponent = function findActionComponent(element) {
|
|
|
74
79
|
return null;
|
|
75
80
|
};
|
|
76
81
|
|
|
82
|
+
/**
|
|
83
|
+
* 递归克隆元素树,将 newProps 应用到最内层的 Action 组件
|
|
84
|
+
*/
|
|
85
|
+
var cloneWithActionProps = function cloneWithActionProps(element, newProps) {
|
|
86
|
+
var _element$props2;
|
|
87
|
+
if (isActionComponent(element)) {
|
|
88
|
+
return /*#__PURE__*/React.cloneElement(element, _objectSpread(_objectSpread({}, newProps), element.props));
|
|
89
|
+
}
|
|
90
|
+
var elementChildren = (_element$props2 = element.props) === null || _element$props2 === void 0 ? void 0 : _element$props2.children;
|
|
91
|
+
if ( /*#__PURE__*/React.isValidElement(elementChildren)) {
|
|
92
|
+
return /*#__PURE__*/React.cloneElement(element, _objectSpread(_objectSpread({}, element.props), {}, {
|
|
93
|
+
key: newProps.key,
|
|
94
|
+
children: cloneWithActionProps(elementChildren, newProps)
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
return element;
|
|
98
|
+
};
|
|
99
|
+
|
|
77
100
|
/**
|
|
78
101
|
* 渲染菜单项内容,保持嵌套的 Popconfirm/Tooltip 结构
|
|
79
102
|
*/
|
|
@@ -82,40 +105,19 @@ var renderMenuItemContent = function renderMenuItemContent(action, actionProps,
|
|
|
82
105
|
children = actionProps.children,
|
|
83
106
|
tooltip = actionProps.tooltip;
|
|
84
107
|
var result = findActionComponent(action);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
90
|
-
// 如果有 tooltip,用 Tooltip 包裹
|
|
91
|
-
return tooltip ? /*#__PURE__*/_jsx(Tooltip, {
|
|
92
|
-
title: tooltip,
|
|
93
|
-
children: _content
|
|
94
|
-
}) : _content;
|
|
95
|
-
}
|
|
96
|
-
var actualAction = result.action,
|
|
97
|
-
wrapper = result.wrapper;
|
|
98
|
-
|
|
99
|
-
// 创建新的 action 元素,保留所有 props 并添加 loading 状态
|
|
100
|
-
var newAction = /*#__PURE__*/React.cloneElement(actualAction, _objectSpread(_objectSpread(_objectSpread({}, actualAction.props), actionProps), {}, {
|
|
101
|
-
children: /*#__PURE__*/_jsxs(_Fragment, {
|
|
102
|
-
children: [loading && enableLoading && /*#__PURE__*/_jsx(LoadingOutlined, {}), " ", children || actualAction.props.children]
|
|
103
|
-
})
|
|
104
|
-
}));
|
|
108
|
+
var actualAction = (result === null || result === void 0 ? void 0 : result.action) || action;
|
|
109
|
+
var content = /*#__PURE__*/_jsxs(_Fragment, {
|
|
110
|
+
children: [loading && enableLoading && /*#__PURE__*/_jsx(LoadingOutlined, {}), " ", children || actualAction.props.children]
|
|
111
|
+
});
|
|
105
112
|
|
|
106
|
-
//
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return /*#__PURE__*/React.cloneElement(wrapper, _objectSpread(_objectSpread({}, wrapperProps), {}, {
|
|
111
|
-
children: newAction
|
|
113
|
+
// 如果有 wrapper,需要重新构建包裹结构
|
|
114
|
+
if (result !== null && result !== void 0 && result.hasWrapper) {
|
|
115
|
+
return cloneWithActionProps(action, _objectSpread(_objectSpread({}, actionProps), {}, {
|
|
116
|
+
children: content
|
|
112
117
|
}));
|
|
113
118
|
}
|
|
114
119
|
|
|
115
|
-
//
|
|
116
|
-
var content = /*#__PURE__*/_jsxs(_Fragment, {
|
|
117
|
-
children: [loading && enableLoading && /*#__PURE__*/_jsx(LoadingOutlined, {}), " ", children || actualAction.props.children]
|
|
118
|
-
});
|
|
120
|
+
// 没有包裹时,如果有 tooltip 则用 Tooltip 包裹
|
|
119
121
|
return tooltip ? /*#__PURE__*/_jsx(Tooltip, {
|
|
120
122
|
title: tooltip,
|
|
121
123
|
children: content
|
|
@@ -198,14 +200,20 @@ export default (function (_ref2) {
|
|
|
198
200
|
return wrapSSR( /*#__PURE__*/_jsxs(Space, {
|
|
199
201
|
size: ellipsisType === 'button' ? 8 : 16,
|
|
200
202
|
children: [mainActions.map(function (action) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
// 查找实际的 Action 组件(可能被 Popconfirm/Tooltip 等包裹)
|
|
204
|
+
var actionResult = findActionComponent(action);
|
|
205
|
+
var actualAction = (actionResult === null || actionResult === void 0 ? void 0 : actionResult.action) || action;
|
|
206
|
+
var actualActionProps = actualAction.props;
|
|
207
|
+
var newProps = {
|
|
205
208
|
key: action.key,
|
|
209
|
+
// size should be covered by action props
|
|
210
|
+
size: buttonSize,
|
|
206
211
|
enableLoading: enableLoading,
|
|
207
|
-
disabled: isBoolean(
|
|
208
|
-
}
|
|
212
|
+
disabled: isBoolean(actualActionProps.disabled) ? actualActionProps.disabled : getDefaultDisabled(action.key)
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// 统一使用 cloneWithActionProps,无论是否有包裹都能正确处理
|
|
216
|
+
return cloneWithActionProps(action, newProps);
|
|
209
217
|
}), ellipsisActions.length > 0 && /*#__PURE__*/_jsx(Dropdown, {
|
|
210
218
|
placement: dropDownPlacement,
|
|
211
219
|
overlay: /*#__PURE__*/_jsx(Menu, {
|
|
@@ -230,7 +238,7 @@ export default (function (_ref2) {
|
|
|
230
238
|
var _actionProps$onClick;
|
|
231
239
|
// 如果 action 被包裹(可能是 Popconfirm 或其他组件),不直接触发 onClick
|
|
232
240
|
// 让包裹组件来处理交互
|
|
233
|
-
if (actionResult !== null && actionResult !== void 0 && actionResult.
|
|
241
|
+
if (actionResult !== null && actionResult !== void 0 && actionResult.hasWrapper) {
|
|
234
242
|
// 包裹组件会处理点击,这里不需要做任何事
|
|
235
243
|
// 注意:Menu.Item 的点击会关闭下拉菜单,但 Popconfirm 应该能够正常显示
|
|
236
244
|
return;
|
|
@@ -5,10 +5,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
5
5
|
import { genComponentStyleHook } from "../../_util/genComponentStyleHook";
|
|
6
6
|
export var genFooterToolbarStyle = function genFooterToolbarStyle(token) {
|
|
7
7
|
var componentCls = token.componentCls,
|
|
8
|
-
colorBgBase = token.colorBgBase
|
|
9
|
-
borderRadius = token.borderRadius,
|
|
10
|
-
boxShadowSecondary = token.boxShadowSecondary,
|
|
11
|
-
controlHeightLG = token.controlHeightLG;
|
|
8
|
+
colorBgBase = token.colorBgBase;
|
|
12
9
|
return _defineProperty({}, "div".concat(componentCls), {
|
|
13
10
|
flexDirection: 'row-reverse',
|
|
14
11
|
lineHeight: 'initial',
|
|
@@ -19,7 +16,7 @@ export var genFooterToolbarStyle = function genFooterToolbarStyle(token) {
|
|
|
19
16
|
paddingInline: token.paddingXL,
|
|
20
17
|
width: '100%',
|
|
21
18
|
backgroundColor: colorBgBase,
|
|
22
|
-
boxShadow:
|
|
19
|
+
boxShadow: '0px -1px 2px 0px #1320391A',
|
|
23
20
|
borderBlockStart: 'none'
|
|
24
21
|
});
|
|
25
22
|
};
|
package/es/Highlight/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const THEME_DARK = "dark";
|
|
|
28
28
|
export declare const THEME_LIGHT = "light";
|
|
29
29
|
declare const ThemeTypes: ["dark", "light"];
|
|
30
30
|
export type ThemeType = (typeof ThemeTypes)[number];
|
|
31
|
-
declare const supportedLanguages: ("
|
|
31
|
+
declare const supportedLanguages: ("ruby" | "css" | "json" | "jsx" | "tsx" | "javascript" | "typescript" | "groovy" | "java" | "python" | "bash" | "cpp" | "http" | "markdown" | "nginx" | "sql" | "xml" | "dockerfile" | "go" | "yaml" | "solidity")[];
|
|
32
32
|
export type LanguageType = (typeof supportedLanguages)[number] | 'html';
|
|
33
33
|
export interface HighlightProps extends LocaleWrapperProps {
|
|
34
34
|
/**
|
|
@@ -15,10 +15,11 @@ import classNames from 'classnames';
|
|
|
15
15
|
import { isObject } from 'lodash';
|
|
16
16
|
import React, { useContext } from 'react';
|
|
17
17
|
import { Button, ConfigProvider, Divider, Space, Tooltip, theme } from '@oceanbase/design';
|
|
18
|
+
import { useSize } from 'ahooks';
|
|
18
19
|
import LocaleWrapper from "../locale/LocaleWrapper";
|
|
20
|
+
import zhCN from "./locale/zh-CN";
|
|
19
21
|
import ItemRender from "./ItemRender";
|
|
20
22
|
import PageLoading from "../PageLoading";
|
|
21
|
-
import zhCN from "./locale/zh-CN";
|
|
22
23
|
import useStyle from "./style";
|
|
23
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
25
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -53,6 +54,7 @@ var DocumentIcon = function DocumentIcon(_ref) {
|
|
|
53
54
|
});
|
|
54
55
|
};
|
|
55
56
|
var PageContainer = function PageContainer(_ref2) {
|
|
57
|
+
var _window, _restProps$style;
|
|
56
58
|
var customizePrefixCls = _ref2.prefixCls,
|
|
57
59
|
className = _ref2.className,
|
|
58
60
|
titleProp = _ref2.title,
|
|
@@ -78,6 +80,13 @@ var PageContainer = function PageContainer(_ref2) {
|
|
|
78
80
|
wrapSSR = _useStyle.wrapSSR;
|
|
79
81
|
var _theme$useToken = theme.useToken(),
|
|
80
82
|
token = _theme$useToken.token;
|
|
83
|
+
|
|
84
|
+
// TODO: PageContainer should support ref to get the width of the container
|
|
85
|
+
var size = useSize((_window = window) === null || _window === void 0 || (_window = _window.document) === null || _window === void 0 ? void 0 : _window.querySelector(".".concat(prefixCls)));
|
|
86
|
+
var width = size === null || size === void 0 ? void 0 : size.width;
|
|
87
|
+
var maxWidthValue = (_restProps$style = restProps.style) === null || _restProps$style === void 0 ? void 0 : _restProps$style.maxWidth;
|
|
88
|
+
var maxWidth = typeof maxWidthValue === 'number' ? maxWidthValue : maxWidthValue !== null && maxWidthValue !== void 0 && maxWidthValue.includes('px') ? parseInt(maxWidthValue) : undefined;
|
|
89
|
+
var isOverflow = width && width >= maxWidth;
|
|
81
90
|
var _ref3 = header || {},
|
|
82
91
|
reload = _ref3.reload,
|
|
83
92
|
_ref3$title = _ref3.title,
|
|
@@ -147,7 +156,7 @@ var PageContainer = function PageContainer(_ref2) {
|
|
|
147
156
|
var noHasHeader = ['title', 'subTitle', 'onBack', 'breadcrumb', 'extra', 'tags', 'avatar'].every(function (item) {
|
|
148
157
|
return !(newHeader !== null && newHeader !== void 0 && newHeader[item]);
|
|
149
158
|
}) && !content && !extraContent && !tabList && !tabBarExtraContent;
|
|
150
|
-
var pageContainerCls = classNames(_defineProperty({}, "".concat(prefixCls, "-no-page-header"), noHasHeader), className);
|
|
159
|
+
var pageContainerCls = classNames(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-no-page-header"), noHasHeader), "".concat(prefixCls, "-max-width"), isOverflow), className);
|
|
151
160
|
return wrapSSR( /*#__PURE__*/_jsx(AntPageContainer, _objectSpread({
|
|
152
161
|
prefixCls: customizePrefixCls,
|
|
153
162
|
className: pageContainerCls,
|
|
@@ -15,7 +15,7 @@ export var genPageContainerStyle = function genPageContainerStyle(token) {
|
|
|
15
15
|
fontSizeHeading2 = token.fontSizeHeading2,
|
|
16
16
|
padding = token.padding,
|
|
17
17
|
paddingLG = token.paddingLG;
|
|
18
|
-
return _objectSpread(_defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls), _defineProperty(_defineProperty(_defineProperty({
|
|
18
|
+
return _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(componentCls), _defineProperty(_defineProperty(_defineProperty({
|
|
19
19
|
minHeight: '100vh',
|
|
20
20
|
backgroundColor: colorBgLayout
|
|
21
21
|
}, "".concat(proComponentsCls, "-grid-content"), {
|
|
@@ -64,9 +64,7 @@ export var genPageContainerStyle = function genPageContainerStyle(token) {
|
|
|
64
64
|
}), _defineProperty(_$concat$concat, "".concat(antCls, "-page-header-footer"), _defineProperty({
|
|
65
65
|
marginBlockStart: 0
|
|
66
66
|
}, "".concat(antCls, "-tabs-top > ").concat(antCls, "-tabs-nav::before"), {
|
|
67
|
-
borderBottom: "1px solid ".concat(token.colorBorderSecondary)
|
|
68
|
-
left: -token.paddingXL,
|
|
69
|
-
right: -token.paddingXL
|
|
67
|
+
borderBottom: "1px solid ".concat(token.colorBorderSecondary)
|
|
70
68
|
})))), "".concat(componentCls, "-children-container"), _defineProperty(_defineProperty({
|
|
71
69
|
paddingInline: token.paddingXL,
|
|
72
70
|
paddingBlockStart: 0,
|
|
@@ -75,14 +73,18 @@ export var genPageContainerStyle = function genPageContainerStyle(token) {
|
|
|
75
73
|
// equal to page header paddingBlockEnd
|
|
76
74
|
marginTop: -padding
|
|
77
75
|
}), "& > ".concat(antCls, "-tabs-top > ").concat(antCls, "-tabs-nav::before"), {
|
|
78
|
-
borderBottom: "1px solid ".concat(token.colorBorderSecondary)
|
|
79
|
-
left: -token.paddingXL,
|
|
80
|
-
right: -token.paddingXL
|
|
76
|
+
borderBottom: "1px solid ".concat(token.colorBorderSecondary)
|
|
81
77
|
}))), "".concat(componentCls, "-no-page-header"), _defineProperty({}, "".concat(componentCls, "-children-container"), {
|
|
82
78
|
paddingBlockStart: paddingLG
|
|
83
79
|
})), "".concat(componentCls, "-with-footer "), {
|
|
84
80
|
paddingBottom: 64
|
|
85
|
-
}),
|
|
81
|
+
}), "".concat(componentCls, ":not(").concat(componentCls, "-max-width)"), _defineProperty(_defineProperty({}, "".concat(componentCls, "-warp-page-header,").concat(componentCls, "-wrap-page-header"), _defineProperty({}, "".concat(antCls, "-page-header-footer"), _defineProperty({}, "".concat(antCls, "-tabs-top > ").concat(antCls, "-tabs-nav::before"), {
|
|
82
|
+
left: -token.paddingXL,
|
|
83
|
+
right: -token.paddingXL
|
|
84
|
+
}))), "".concat(componentCls, "-children-container"), _defineProperty({}, "& > ".concat(antCls, "-tabs-top > ").concat(antCls, "-tabs-nav::before"), {
|
|
85
|
+
left: -token.paddingXL,
|
|
86
|
+
right: -token.paddingXL
|
|
87
|
+
}))), genFooterToolbarStyle(_objectSpread(_objectSpread({}, token), {}, {
|
|
86
88
|
componentCls: "".concat(proComponentsCls, "-footer-bar")
|
|
87
89
|
})));
|
|
88
90
|
};
|
package/lib/Action/Group.js
CHANGED
|
@@ -32,21 +32,26 @@ const getOrder = ({
|
|
|
32
32
|
return order;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* 判断是否是 Action 组件(Action.Button 或 Action.Link)
|
|
37
|
+
*/
|
|
38
|
+
const isActionComponent = element => {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
return element.type?.__DISPLAY_NAME === 'button' || element.type?.__DISPLAY_NAME === 'link';
|
|
41
|
+
};
|
|
42
|
+
|
|
35
43
|
/**
|
|
36
44
|
* 递归查找 Action 组件(可能被 Popconfirm/Tooltip 等组件包裹)
|
|
37
|
-
* 返回实际的 Action
|
|
45
|
+
* 返回实际的 Action 组件和是否被包裹
|
|
38
46
|
*/
|
|
39
47
|
const findActionComponent = (element, depth = 0) => {
|
|
40
48
|
if (! /*#__PURE__*/_react.default.isValidElement(element)) {
|
|
41
49
|
return null;
|
|
42
50
|
}
|
|
43
|
-
|
|
44
|
-
// 检查是否是 Action.Button 或 Action.Link
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
if (element.type?.__DISPLAY_NAME === 'button' || element.type?.__DISPLAY_NAME === 'link') {
|
|
51
|
+
if (isActionComponent(element)) {
|
|
47
52
|
return {
|
|
48
53
|
action: element,
|
|
49
|
-
|
|
54
|
+
hasWrapper: false
|
|
50
55
|
};
|
|
51
56
|
}
|
|
52
57
|
|
|
@@ -62,10 +67,9 @@ const findActionComponent = (element, depth = 0) => {
|
|
|
62
67
|
if ( /*#__PURE__*/_react.default.isValidElement(child)) {
|
|
63
68
|
const result = findActionComponent(child, depth + 1);
|
|
64
69
|
if (result) {
|
|
65
|
-
// 如果找到了 Action 组件,当前元素就是 wrapper
|
|
66
70
|
return {
|
|
67
71
|
action: result.action,
|
|
68
|
-
|
|
72
|
+
hasWrapper: true
|
|
69
73
|
};
|
|
70
74
|
}
|
|
71
75
|
}
|
|
@@ -73,6 +77,27 @@ const findActionComponent = (element, depth = 0) => {
|
|
|
73
77
|
return null;
|
|
74
78
|
};
|
|
75
79
|
|
|
80
|
+
/**
|
|
81
|
+
* 递归克隆元素树,将 newProps 应用到最内层的 Action 组件
|
|
82
|
+
*/
|
|
83
|
+
const cloneWithActionProps = (element, newProps) => {
|
|
84
|
+
if (isActionComponent(element)) {
|
|
85
|
+
return /*#__PURE__*/_react.default.cloneElement(element, {
|
|
86
|
+
...newProps,
|
|
87
|
+
...element.props
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const elementChildren = element.props?.children;
|
|
91
|
+
if ( /*#__PURE__*/_react.default.isValidElement(elementChildren)) {
|
|
92
|
+
return /*#__PURE__*/_react.default.cloneElement(element, {
|
|
93
|
+
...element.props,
|
|
94
|
+
key: newProps.key,
|
|
95
|
+
children: cloneWithActionProps(elementChildren, newProps)
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return element;
|
|
99
|
+
};
|
|
100
|
+
|
|
76
101
|
/**
|
|
77
102
|
* 渲染菜单项内容,保持嵌套的 Popconfirm/Tooltip 结构
|
|
78
103
|
*/
|
|
@@ -83,45 +108,20 @@ const renderMenuItemContent = (action, actionProps, enableLoading) => {
|
|
|
83
108
|
tooltip
|
|
84
109
|
} = actionProps;
|
|
85
110
|
const result = findActionComponent(action);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
children: [loading && enableLoading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LoadingOutlined, {}), " ", children || action]
|
|
90
|
-
});
|
|
91
|
-
// 如果有 tooltip,用 Tooltip 包裹
|
|
92
|
-
return tooltip ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Tooltip, {
|
|
93
|
-
title: tooltip,
|
|
94
|
-
children: content
|
|
95
|
-
}) : content;
|
|
96
|
-
}
|
|
97
|
-
const {
|
|
98
|
-
action: actualAction,
|
|
99
|
-
wrapper
|
|
100
|
-
} = result;
|
|
101
|
-
|
|
102
|
-
// 创建新的 action 元素,保留所有 props 并添加 loading 状态
|
|
103
|
-
const newAction = /*#__PURE__*/_react.default.cloneElement(actualAction, {
|
|
104
|
-
...actualAction.props,
|
|
105
|
-
...actionProps,
|
|
106
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
107
|
-
children: [loading && enableLoading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LoadingOutlined, {}), " ", children || actualAction.props.children]
|
|
108
|
-
})
|
|
111
|
+
const actualAction = result?.action || action;
|
|
112
|
+
const content = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
113
|
+
children: [loading && enableLoading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LoadingOutlined, {}), " ", children || actualAction.props.children]
|
|
109
114
|
});
|
|
110
115
|
|
|
111
|
-
//
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
...wrapperProps,
|
|
117
|
-
children: newAction
|
|
116
|
+
// 如果有 wrapper,需要重新构建包裹结构
|
|
117
|
+
if (result?.hasWrapper) {
|
|
118
|
+
return cloneWithActionProps(action, {
|
|
119
|
+
...actionProps,
|
|
120
|
+
children: content
|
|
118
121
|
});
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
//
|
|
122
|
-
const content = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
123
|
-
children: [loading && enableLoading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LoadingOutlined, {}), " ", children || actualAction.props.children]
|
|
124
|
-
});
|
|
124
|
+
// 没有包裹时,如果有 tooltip 则用 Tooltip 包裹
|
|
125
125
|
return tooltip ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Tooltip, {
|
|
126
126
|
title: tooltip,
|
|
127
127
|
children: content
|
|
@@ -197,14 +197,20 @@ var _default = ({
|
|
|
197
197
|
return wrapSSR( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Space, {
|
|
198
198
|
size: ellipsisType === 'button' ? 8 : 16,
|
|
199
199
|
children: [mainActions.map(action => {
|
|
200
|
-
|
|
200
|
+
// 查找实际的 Action 组件(可能被 Popconfirm/Tooltip 等包裹)
|
|
201
|
+
const actionResult = findActionComponent(action);
|
|
202
|
+
const actualAction = actionResult?.action || action;
|
|
203
|
+
const actualActionProps = actualAction.props;
|
|
204
|
+
const newProps = {
|
|
205
|
+
key: action.key,
|
|
201
206
|
// size should be covered by action props
|
|
202
207
|
size: buttonSize,
|
|
203
|
-
...action.props,
|
|
204
|
-
key: action.key,
|
|
205
208
|
enableLoading: enableLoading,
|
|
206
|
-
disabled: (0, _lodash.isBoolean)(
|
|
207
|
-
}
|
|
209
|
+
disabled: (0, _lodash.isBoolean)(actualActionProps.disabled) ? actualActionProps.disabled : getDefaultDisabled(action.key)
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// 统一使用 cloneWithActionProps,无论是否有包裹都能正确处理
|
|
213
|
+
return cloneWithActionProps(action, newProps);
|
|
208
214
|
}), ellipsisActions.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Dropdown, {
|
|
209
215
|
placement: dropDownPlacement,
|
|
210
216
|
overlay: /*#__PURE__*/(0, _jsxRuntime.jsx)(_design.Menu, {
|
|
@@ -227,7 +233,7 @@ var _default = ({
|
|
|
227
233
|
const handleMenuItemClick = info => {
|
|
228
234
|
// 如果 action 被包裹(可能是 Popconfirm 或其他组件),不直接触发 onClick
|
|
229
235
|
// 让包裹组件来处理交互
|
|
230
|
-
if (actionResult?.
|
|
236
|
+
if (actionResult?.hasWrapper) {
|
|
231
237
|
// 包裹组件会处理点击,这里不需要做任何事
|
|
232
238
|
// 注意:Menu.Item 的点击会关闭下拉菜单,但 Popconfirm 应该能够正常显示
|
|
233
239
|
return;
|
|
@@ -8,10 +8,7 @@ var _genComponentStyleHook = require("../../_util/genComponentStyleHook");
|
|
|
8
8
|
const genFooterToolbarStyle = token => {
|
|
9
9
|
const {
|
|
10
10
|
componentCls,
|
|
11
|
-
colorBgBase
|
|
12
|
-
borderRadius,
|
|
13
|
-
boxShadowSecondary,
|
|
14
|
-
controlHeightLG
|
|
11
|
+
colorBgBase
|
|
15
12
|
} = token;
|
|
16
13
|
return {
|
|
17
14
|
[`div${componentCls}`]: {
|
|
@@ -24,7 +21,7 @@ const genFooterToolbarStyle = token => {
|
|
|
24
21
|
paddingInline: token.paddingXL,
|
|
25
22
|
width: '100%',
|
|
26
23
|
backgroundColor: colorBgBase,
|
|
27
|
-
boxShadow:
|
|
24
|
+
boxShadow: '0px -1px 2px 0px #1320391A',
|
|
28
25
|
borderBlockStart: 'none'
|
|
29
26
|
}
|
|
30
27
|
};
|
package/lib/Highlight/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const THEME_DARK = "dark";
|
|
|
28
28
|
export declare const THEME_LIGHT = "light";
|
|
29
29
|
declare const ThemeTypes: ["dark", "light"];
|
|
30
30
|
export type ThemeType = (typeof ThemeTypes)[number];
|
|
31
|
-
declare const supportedLanguages: ("
|
|
31
|
+
declare const supportedLanguages: ("ruby" | "css" | "json" | "jsx" | "tsx" | "javascript" | "typescript" | "groovy" | "java" | "python" | "bash" | "cpp" | "http" | "markdown" | "nginx" | "sql" | "xml" | "dockerfile" | "go" | "yaml" | "solidity")[];
|
|
32
32
|
export type LanguageType = (typeof supportedLanguages)[number] | 'html';
|
|
33
33
|
export interface HighlightProps extends LocaleWrapperProps {
|
|
34
34
|
/**
|
|
@@ -11,10 +11,11 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
11
11
|
var _lodash = require("lodash");
|
|
12
12
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _design = require("@oceanbase/design");
|
|
14
|
+
var _ahooks = require("ahooks");
|
|
14
15
|
var _LocaleWrapper = _interopRequireDefault(require("../locale/LocaleWrapper"));
|
|
16
|
+
var _zhCN = _interopRequireDefault(require("./locale/zh-CN"));
|
|
15
17
|
var _ItemRender = _interopRequireDefault(require("./ItemRender"));
|
|
16
18
|
var _PageLoading = _interopRequireDefault(require("../PageLoading"));
|
|
17
|
-
var _zhCN = _interopRequireDefault(require("./locale/zh-CN"));
|
|
18
19
|
var _style = _interopRequireDefault(require("./style"));
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
21
|
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); }
|
|
@@ -83,6 +84,13 @@ const PageContainer = ({
|
|
|
83
84
|
const {
|
|
84
85
|
token
|
|
85
86
|
} = _design.theme.useToken();
|
|
87
|
+
|
|
88
|
+
// TODO: PageContainer should support ref to get the width of the container
|
|
89
|
+
const size = (0, _ahooks.useSize)(window?.document?.querySelector(`.${prefixCls}`));
|
|
90
|
+
const width = size?.width;
|
|
91
|
+
const maxWidthValue = restProps.style?.maxWidth;
|
|
92
|
+
const maxWidth = typeof maxWidthValue === 'number' ? maxWidthValue : maxWidthValue?.includes('px') ? parseInt(maxWidthValue) : undefined;
|
|
93
|
+
const isOverflow = width && width >= maxWidth;
|
|
86
94
|
const {
|
|
87
95
|
reload,
|
|
88
96
|
title = titleProp,
|
|
@@ -147,7 +155,8 @@ const PageContainer = ({
|
|
|
147
155
|
};
|
|
148
156
|
const noHasHeader = ['title', 'subTitle', 'onBack', 'breadcrumb', 'extra', 'tags', 'avatar'].every(item => !newHeader?.[item]) && !content && !extraContent && !tabList && !tabBarExtraContent;
|
|
149
157
|
const pageContainerCls = (0, _classnames.default)({
|
|
150
|
-
[`${prefixCls}-no-page-header`]: noHasHeader
|
|
158
|
+
[`${prefixCls}-no-page-header`]: noHasHeader,
|
|
159
|
+
[`${prefixCls}-max-width`]: isOverflow
|
|
151
160
|
}, className);
|
|
152
161
|
return wrapSSR( /*#__PURE__*/(0, _jsxRuntime.jsx)(_proComponents.PageContainer, {
|
|
153
162
|
prefixCls: customizePrefixCls,
|
|
@@ -78,9 +78,7 @@ const genPageContainerStyle = token => {
|
|
|
78
78
|
[`${antCls}-page-header-footer`]: {
|
|
79
79
|
marginBlockStart: 0,
|
|
80
80
|
[`${antCls}-tabs-top > ${antCls}-tabs-nav::before`]: {
|
|
81
|
-
borderBottom: `1px solid ${token.colorBorderSecondary}
|
|
82
|
-
left: -token.paddingXL,
|
|
83
|
-
right: -token.paddingXL
|
|
81
|
+
borderBottom: `1px solid ${token.colorBorderSecondary}`
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
84
|
},
|
|
@@ -94,9 +92,7 @@ const genPageContainerStyle = token => {
|
|
|
94
92
|
marginTop: -padding
|
|
95
93
|
},
|
|
96
94
|
[`& > ${antCls}-tabs-top > ${antCls}-tabs-nav::before`]: {
|
|
97
|
-
borderBottom: `1px solid ${token.colorBorderSecondary}
|
|
98
|
-
left: -token.paddingXL,
|
|
99
|
-
right: -token.paddingXL
|
|
95
|
+
borderBottom: `1px solid ${token.colorBorderSecondary}`
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
98
|
},
|
|
@@ -108,6 +104,23 @@ const genPageContainerStyle = token => {
|
|
|
108
104
|
[`${componentCls}-with-footer `]: {
|
|
109
105
|
paddingBottom: 64
|
|
110
106
|
},
|
|
107
|
+
// tabs pull through when the width is not overflow
|
|
108
|
+
[`${componentCls}:not(${componentCls}-max-width)`]: {
|
|
109
|
+
[`${componentCls}-warp-page-header,${componentCls}-wrap-page-header`]: {
|
|
110
|
+
[`${antCls}-page-header-footer`]: {
|
|
111
|
+
[`${antCls}-tabs-top > ${antCls}-tabs-nav::before`]: {
|
|
112
|
+
left: -token.paddingXL,
|
|
113
|
+
right: -token.paddingXL
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
[`${componentCls}-children-container`]: {
|
|
118
|
+
[`& > ${antCls}-tabs-top > ${antCls}-tabs-nav::before`]: {
|
|
119
|
+
left: -token.paddingXL,
|
|
120
|
+
right: -token.paddingXL
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
111
124
|
...(0, _style.genFooterToolbarStyle)({
|
|
112
125
|
...token,
|
|
113
126
|
componentCls: `${proComponentsCls}-footer-bar`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oceanbase/ui",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.14",
|
|
4
4
|
"description": "The UI library based on OceanBase Design",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"oceanbase",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@ant-design/cssinjs": "^1.24.0",
|
|
39
39
|
"@ant-design/pro-components": "^2.8.10",
|
|
40
40
|
"@inline-svg-unique-id/react": "^1.2.3",
|
|
41
|
-
"@oceanbase/design": "^1.0.0-alpha.
|
|
41
|
+
"@oceanbase/design": "^1.0.0-alpha.14",
|
|
42
42
|
"@oceanbase/icons": "^1.0.0-alpha.0",
|
|
43
43
|
"@oceanbase/util": "^1.0.0-alpha.2",
|
|
44
44
|
"ahooks": "^2.10.14",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"react": ">=16.9.0",
|
|
68
68
|
"react-dom": ">=16.9.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "ba396251e1eb9fa2be8cfc758d1c857720ac8e72"
|
|
71
71
|
}
|