@oceanbase/design 0.2.19 → 0.2.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.
- package/dist/design.min.js +1 -1
- package/es/card/index.d.ts +1 -1
- package/es/card/index.js +2 -35
- package/es/config-provider/index.d.ts +3 -1
- package/es/config-provider/index.js +7 -1
- package/es/tabs/index.d.ts +1 -1
- package/es/tabs/index.js +3 -47
- package/lib/card/index.d.ts +1 -1
- package/lib/card/index.js +1 -36
- package/lib/config-provider/index.d.ts +3 -1
- package/lib/config-provider/index.js +15 -1
- package/lib/tabs/index.d.ts +1 -1
- package/lib/tabs/index.js +0 -32
- package/package.json +4 -4
- package/es/tabs/hooks/useInkBar.d.ts +0 -12
- package/es/tabs/hooks/useInkBar.js +0 -41
- package/lib/tabs/hooks/useInkBar.d.ts +0 -12
- package/lib/tabs/hooks/useInkBar.js +0 -62
package/es/card/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface CardProps extends AntCardProps {
|
|
|
10
10
|
tabList?: CardTabListType[];
|
|
11
11
|
}
|
|
12
12
|
declare const Card: {
|
|
13
|
-
({ children, divided, tabList,
|
|
13
|
+
({ children, divided, tabList, prefixCls: customizePrefixCls, className, ...restProps }: CardProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
14
14
|
Grid: React.FC<import("antd/es/card").CardGridProps>;
|
|
15
15
|
Meta: React.FC<import("antd/es/card").CardMetaProps>;
|
|
16
16
|
displayName: string;
|
package/es/card/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
var _excluded = ["children", "divided", "tabList", "
|
|
3
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
-
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."); }
|
|
5
|
-
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); }
|
|
6
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
8
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2
|
+
var _excluded = ["children", "divided", "tabList", "prefixCls", "className"];
|
|
9
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
5
|
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; }
|
|
@@ -16,24 +10,18 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
16
10
|
import { isNullValue } from '@oceanbase/util';
|
|
17
11
|
import { Card as AntCard, Space, Tag } from 'antd';
|
|
18
12
|
import classNames from 'classnames';
|
|
19
|
-
import React, { useContext
|
|
13
|
+
import React, { useContext } from 'react';
|
|
20
14
|
import ConfigProvider from "../config-provider";
|
|
21
|
-
import useInkBar from "../tabs/hooks/useInkBar";
|
|
22
15
|
import useStyle from "./style";
|
|
23
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
18
|
export * from 'antd/es/card/Card';
|
|
26
19
|
export * from 'antd/es/card';
|
|
27
20
|
var Card = function Card(_ref) {
|
|
28
|
-
var _newTabList$;
|
|
29
21
|
var children = _ref.children,
|
|
30
22
|
_ref$divided = _ref.divided,
|
|
31
23
|
divided = _ref$divided === void 0 ? true : _ref$divided,
|
|
32
24
|
tabList = _ref.tabList,
|
|
33
|
-
activeTabKey = _ref.activeTabKey,
|
|
34
|
-
defaultActiveTabKey = _ref.defaultActiveTabKey,
|
|
35
|
-
_onTabChange = _ref.onTabChange,
|
|
36
|
-
tabProps = _ref.tabProps,
|
|
37
25
|
customizePrefixCls = _ref.prefixCls,
|
|
38
26
|
className = _ref.className,
|
|
39
27
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -44,7 +32,6 @@ var Card = function Card(_ref) {
|
|
|
44
32
|
var _useStyle = useStyle(prefixCls, tabsPrefixCls),
|
|
45
33
|
wrapSSR = _useStyle.wrapSSR;
|
|
46
34
|
var cardCls = classNames(_defineProperty({}, "".concat(prefixCls, "-no-divider"), !divided), className);
|
|
47
|
-
var ref = useRef();
|
|
48
35
|
var newTabList = tabList === null || tabList === void 0 ? void 0 : tabList.map(function (item) {
|
|
49
36
|
if (!isNullValue(item.tag)) {
|
|
50
37
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -60,28 +47,8 @@ var Card = function Card(_ref) {
|
|
|
60
47
|
}
|
|
61
48
|
return item;
|
|
62
49
|
});
|
|
63
|
-
var _useState = useState(activeTabKey || defaultActiveTabKey || (newTabList === null || newTabList === void 0 ? void 0 : (_newTabList$ = newTabList[0]) === null || _newTabList$ === void 0 ? void 0 : _newTabList$.key)),
|
|
64
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
65
|
-
activeKey = _useState2[0],
|
|
66
|
-
setActiveKey = _useState2[1];
|
|
67
|
-
useInkBar({
|
|
68
|
-
prefixCls: tabsPrefixCls,
|
|
69
|
-
activeKey: activeKey,
|
|
70
|
-
size: tabProps === null || tabProps === void 0 ? void 0 : tabProps.size,
|
|
71
|
-
type: tabProps === null || tabProps === void 0 ? void 0 : tabProps.type,
|
|
72
|
-
tabPosition: tabProps === null || tabProps === void 0 ? void 0 : tabProps.tabPosition,
|
|
73
|
-
containerRef: ref
|
|
74
|
-
});
|
|
75
50
|
return wrapSSR( /*#__PURE__*/_jsx(AntCard, _objectSpread(_objectSpread({
|
|
76
|
-
ref: ref,
|
|
77
51
|
tabList: newTabList,
|
|
78
|
-
defaultActiveTabKey: defaultActiveTabKey,
|
|
79
|
-
activeTabKey: activeTabKey,
|
|
80
|
-
onTabChange: function onTabChange(key) {
|
|
81
|
-
setActiveKey(key);
|
|
82
|
-
_onTabChange === null || _onTabChange === void 0 ? void 0 : _onTabChange(key);
|
|
83
|
-
},
|
|
84
|
-
tabProps: tabProps,
|
|
85
52
|
prefixCls: customizePrefixCls,
|
|
86
53
|
className: cardCls
|
|
87
54
|
}, restProps), {}, {
|
|
@@ -15,6 +15,8 @@ export type SpinConfig = ComponentStyleConfig & {
|
|
|
15
15
|
indicator?: SpinIndicator;
|
|
16
16
|
};
|
|
17
17
|
export interface ConfigConsumerProps extends AntConfigConsumerProps {
|
|
18
|
+
theme?: ThemeConfig;
|
|
19
|
+
navigate?: NavigateFunction;
|
|
18
20
|
spin?: SpinConfig;
|
|
19
21
|
}
|
|
20
22
|
export interface ConfigProviderProps extends AntConfigProviderProps {
|
|
@@ -26,7 +28,7 @@ export interface ExtendedConfigConsumerProps {
|
|
|
26
28
|
navigate?: NavigateFunction;
|
|
27
29
|
}
|
|
28
30
|
declare const ConfigProvider: {
|
|
29
|
-
({ children, theme, navigate, spin, ...restProps }: ConfigProviderProps): import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
|
|
31
|
+
({ children, theme, navigate, spin, tabs, ...restProps }: ConfigProviderProps): import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
|
|
30
32
|
ConfigContext: React.Context<ConfigConsumerProps>;
|
|
31
33
|
ExtendedConfigContext: React.Context<ExtendedConfigConsumerProps>;
|
|
32
34
|
config: ({ prefixCls, iconPrefixCls, theme, }: Pick<AntConfigProviderProps, "prefixCls" | "iconPrefixCls"> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
var _excluded = ["children", "theme", "navigate", "spin"];
|
|
2
|
+
var _excluded = ["children", "theme", "navigate", "spin", "tabs"];
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
5
|
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; }
|
|
@@ -30,12 +30,18 @@ var ConfigProvider = function ConfigProvider(_ref) {
|
|
|
30
30
|
theme = _ref.theme,
|
|
31
31
|
navigate = _ref.navigate,
|
|
32
32
|
spin = _ref.spin,
|
|
33
|
+
tabs = _ref.tabs,
|
|
33
34
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
34
35
|
// inherit from parent ConfigProvider
|
|
35
36
|
var parentContext = React.useContext(AntConfigProvider.ConfigContext);
|
|
36
37
|
var parentExtendedContext = React.useContext(ExtendedConfigContext);
|
|
37
38
|
return /*#__PURE__*/_jsx(AntConfigProvider, _objectSpread(_objectSpread({
|
|
38
39
|
spin: merge(parentContext.spin, spin),
|
|
40
|
+
tabs: merge({
|
|
41
|
+
indicatorSize: function indicatorSize(origin) {
|
|
42
|
+
return origin >= 24 ? origin - 16 : origin;
|
|
43
|
+
}
|
|
44
|
+
}, parentContext.tabs, tabs),
|
|
39
45
|
theme: merge({
|
|
40
46
|
// Only set seed token for dark theme
|
|
41
47
|
// Because defaultThemeToken is designed for light theme
|
package/es/tabs/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface TabsProps extends AntTabsProps {
|
|
|
11
11
|
}
|
|
12
12
|
export type TabsPosition = AntTabsPosition;
|
|
13
13
|
declare const Tabs: {
|
|
14
|
-
({ children, items,
|
|
14
|
+
({ children, items, type, tabPosition, prefixCls: customizePrefixCls, className, ...restProps }: TabsProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
15
15
|
TabPane: React.FC<import("./TabPane").TabPaneProps>;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
package/es/tabs/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
var _excluded = ["children", "items", "
|
|
3
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
-
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."); }
|
|
5
|
-
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); }
|
|
6
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
8
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2
|
+
var _excluded = ["children", "items", "type", "tabPosition", "prefixCls", "className"];
|
|
9
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
5
|
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; }
|
|
@@ -15,25 +9,18 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
15
9
|
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; }
|
|
16
10
|
import { isNullValue } from '@oceanbase/util';
|
|
17
11
|
import { Space, Tabs as AntTabs, Tag } from 'antd';
|
|
18
|
-
import React, {
|
|
12
|
+
import React, { useContext } from 'react';
|
|
19
13
|
import classNames from 'classnames';
|
|
20
14
|
import ConfigProvider from "../config-provider";
|
|
21
|
-
import useInkBar from "./hooks/useInkBar";
|
|
22
15
|
import useLegacyItems from "./hooks/useLegacyItems";
|
|
23
16
|
import useStyle from "./style";
|
|
24
|
-
import { useUpdateEffect } from 'ahooks';
|
|
25
17
|
import TabPane from "./TabPane";
|
|
26
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
20
|
export * from 'antd/es/tabs';
|
|
29
21
|
var Tabs = function Tabs(_ref) {
|
|
30
|
-
var _newItems, _newItems$;
|
|
31
22
|
var children = _ref.children,
|
|
32
23
|
items = _ref.items,
|
|
33
|
-
defaultActiveKey = _ref.defaultActiveKey,
|
|
34
|
-
activeKeyProp = _ref.activeKey,
|
|
35
|
-
_onChange = _ref.onChange,
|
|
36
|
-
size = _ref.size,
|
|
37
24
|
type = _ref.type,
|
|
38
25
|
tabPosition = _ref.tabPosition,
|
|
39
26
|
customizePrefixCls = _ref.prefixCls,
|
|
@@ -45,7 +32,6 @@ var Tabs = function Tabs(_ref) {
|
|
|
45
32
|
var _useStyle = useStyle(prefixCls),
|
|
46
33
|
wrapSSR = _useStyle.wrapSSR;
|
|
47
34
|
var tabsCls = classNames(className);
|
|
48
|
-
var ref = useRef();
|
|
49
35
|
var isHorizontal = !tabPosition || tabPosition === 'top' || tabPosition === 'bottom';
|
|
50
36
|
var newItems = items === null || items === void 0 ? void 0 : items.map(function (item) {
|
|
51
37
|
if (!isNullValue(item.tag)) {
|
|
@@ -63,38 +49,8 @@ var Tabs = function Tabs(_ref) {
|
|
|
63
49
|
return item;
|
|
64
50
|
});
|
|
65
51
|
newItems = useLegacyItems(newItems, children, prefixCls);
|
|
66
|
-
|
|
67
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
68
|
-
activeKey = _useState2[0],
|
|
69
|
-
setActiveKey = _useState2[1];
|
|
70
|
-
|
|
71
|
-
// 防止第一次顶掉默认值
|
|
72
|
-
useUpdateEffect(function () {
|
|
73
|
-
// 外部触发的 activeKey 更改,需要同步内部状态变化
|
|
74
|
-
if (activeKeyProp) {
|
|
75
|
-
setActiveKey(activeKeyProp);
|
|
76
|
-
}
|
|
77
|
-
}, [activeKeyProp]);
|
|
78
|
-
useInkBar({
|
|
79
|
-
prefixCls: prefixCls,
|
|
80
|
-
activeKey: activeKey,
|
|
81
|
-
size: size,
|
|
82
|
-
type: type,
|
|
83
|
-
tabPosition: tabPosition,
|
|
84
|
-
containerRef: ref
|
|
85
|
-
});
|
|
86
|
-
return wrapSSR( /*#__PURE__*/_jsx(AntTabs
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
, _objectSpread({
|
|
89
|
-
ref: ref,
|
|
52
|
+
return wrapSSR( /*#__PURE__*/_jsx(AntTabs, _objectSpread({
|
|
90
53
|
items: newItems,
|
|
91
|
-
defaultActiveKey: defaultActiveKey,
|
|
92
|
-
activeKey: activeKey,
|
|
93
|
-
onChange: function onChange(key) {
|
|
94
|
-
setActiveKey(key);
|
|
95
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(key);
|
|
96
|
-
},
|
|
97
|
-
size: size,
|
|
98
54
|
type: type,
|
|
99
55
|
tabPosition: tabPosition,
|
|
100
56
|
tabBarGutter: !type || type === 'line' ? isHorizontal ? 24 : 0 : undefined,
|
package/lib/card/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface CardProps extends AntCardProps {
|
|
|
10
10
|
tabList?: CardTabListType[];
|
|
11
11
|
}
|
|
12
12
|
declare const Card: {
|
|
13
|
-
({ children, divided, tabList,
|
|
13
|
+
({ children, divided, tabList, prefixCls: customizePrefixCls, className, ...restProps }: CardProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
14
14
|
Grid: React.FC<import("antd/es/card").CardGridProps>;
|
|
15
15
|
Meta: React.FC<import("antd/es/card").CardMetaProps>;
|
|
16
16
|
displayName: string;
|
package/lib/card/index.js
CHANGED
|
@@ -38,7 +38,6 @@ var import_antd = require("antd");
|
|
|
38
38
|
var import_classnames = __toESM(require("classnames"));
|
|
39
39
|
var import_react = __toESM(require("react"));
|
|
40
40
|
var import_config_provider = __toESM(require("../config-provider"));
|
|
41
|
-
var import_useInkBar = __toESM(require("../tabs/hooks/useInkBar"));
|
|
42
41
|
var import_style = __toESM(require("./style"));
|
|
43
42
|
__reExport(card_exports, require("antd/es/card/Card"), module.exports);
|
|
44
43
|
__reExport(card_exports, require("antd/es/card"), module.exports);
|
|
@@ -46,15 +45,10 @@ var Card = ({
|
|
|
46
45
|
children,
|
|
47
46
|
divided = true,
|
|
48
47
|
tabList,
|
|
49
|
-
activeTabKey,
|
|
50
|
-
defaultActiveTabKey,
|
|
51
|
-
onTabChange,
|
|
52
|
-
tabProps,
|
|
53
48
|
prefixCls: customizePrefixCls,
|
|
54
49
|
className,
|
|
55
50
|
...restProps
|
|
56
51
|
}) => {
|
|
57
|
-
var _a;
|
|
58
52
|
const { getPrefixCls } = (0, import_react.useContext)(import_config_provider.default.ConfigContext);
|
|
59
53
|
const prefixCls = getPrefixCls("card", customizePrefixCls);
|
|
60
54
|
const tabsPrefixCls = getPrefixCls("tabs", customizePrefixCls);
|
|
@@ -65,7 +59,6 @@ var Card = ({
|
|
|
65
59
|
},
|
|
66
60
|
className
|
|
67
61
|
);
|
|
68
|
-
const ref = (0, import_react.useRef)();
|
|
69
62
|
const newTabList = tabList == null ? void 0 : tabList.map((item) => {
|
|
70
63
|
if (!(0, import_util.isNullValue)(item.tag)) {
|
|
71
64
|
return {
|
|
@@ -75,36 +68,8 @@ var Card = ({
|
|
|
75
68
|
}
|
|
76
69
|
return item;
|
|
77
70
|
});
|
|
78
|
-
const [activeKey, setActiveKey] = (0, import_react.useState)(
|
|
79
|
-
activeTabKey || defaultActiveTabKey || ((_a = newTabList == null ? void 0 : newTabList[0]) == null ? void 0 : _a.key)
|
|
80
|
-
);
|
|
81
|
-
(0, import_useInkBar.default)({
|
|
82
|
-
prefixCls: tabsPrefixCls,
|
|
83
|
-
activeKey,
|
|
84
|
-
size: tabProps == null ? void 0 : tabProps.size,
|
|
85
|
-
type: tabProps == null ? void 0 : tabProps.type,
|
|
86
|
-
tabPosition: tabProps == null ? void 0 : tabProps.tabPosition,
|
|
87
|
-
containerRef: ref
|
|
88
|
-
});
|
|
89
71
|
return wrapSSR(
|
|
90
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
91
|
-
import_antd.Card,
|
|
92
|
-
{
|
|
93
|
-
ref,
|
|
94
|
-
tabList: newTabList,
|
|
95
|
-
defaultActiveTabKey,
|
|
96
|
-
activeTabKey,
|
|
97
|
-
onTabChange: (key) => {
|
|
98
|
-
setActiveKey(key);
|
|
99
|
-
onTabChange == null ? void 0 : onTabChange(key);
|
|
100
|
-
},
|
|
101
|
-
tabProps,
|
|
102
|
-
prefixCls: customizePrefixCls,
|
|
103
|
-
className: cardCls,
|
|
104
|
-
...restProps
|
|
105
|
-
},
|
|
106
|
-
children
|
|
107
|
-
)
|
|
72
|
+
/* @__PURE__ */ import_react.default.createElement(import_antd.Card, { tabList: newTabList, prefixCls: customizePrefixCls, className: cardCls, ...restProps }, children)
|
|
108
73
|
);
|
|
109
74
|
};
|
|
110
75
|
Card.Grid = import_antd.Card.Grid;
|
|
@@ -15,6 +15,8 @@ export type SpinConfig = ComponentStyleConfig & {
|
|
|
15
15
|
indicator?: SpinIndicator;
|
|
16
16
|
};
|
|
17
17
|
export interface ConfigConsumerProps extends AntConfigConsumerProps {
|
|
18
|
+
theme?: ThemeConfig;
|
|
19
|
+
navigate?: NavigateFunction;
|
|
18
20
|
spin?: SpinConfig;
|
|
19
21
|
}
|
|
20
22
|
export interface ConfigProviderProps extends AntConfigProviderProps {
|
|
@@ -26,7 +28,7 @@ export interface ExtendedConfigConsumerProps {
|
|
|
26
28
|
navigate?: NavigateFunction;
|
|
27
29
|
}
|
|
28
30
|
declare const ConfigProvider: {
|
|
29
|
-
({ children, theme, navigate, spin, ...restProps }: ConfigProviderProps): import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
|
|
31
|
+
({ children, theme, navigate, spin, tabs, ...restProps }: ConfigProviderProps): import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
|
|
30
32
|
ConfigContext: React.Context<ConfigConsumerProps>;
|
|
31
33
|
ExtendedConfigContext: React.Context<ExtendedConfigConsumerProps>;
|
|
32
34
|
config: ({ prefixCls, iconPrefixCls, theme, }: Pick<AntConfigProviderProps, "prefixCls" | "iconPrefixCls"> & {
|
|
@@ -48,13 +48,27 @@ var ExtendedConfigContext = import_react.default.createContext({
|
|
|
48
48
|
navigate: void 0
|
|
49
49
|
});
|
|
50
50
|
var { defaultSeed, components } = import_theme.default;
|
|
51
|
-
var ConfigProvider = ({
|
|
51
|
+
var ConfigProvider = ({
|
|
52
|
+
children,
|
|
53
|
+
theme,
|
|
54
|
+
navigate,
|
|
55
|
+
spin,
|
|
56
|
+
tabs,
|
|
57
|
+
...restProps
|
|
58
|
+
}) => {
|
|
52
59
|
const parentContext = import_react.default.useContext(import_antd.ConfigProvider.ConfigContext);
|
|
53
60
|
const parentExtendedContext = import_react.default.useContext(ExtendedConfigContext);
|
|
54
61
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
55
62
|
import_antd.ConfigProvider,
|
|
56
63
|
{
|
|
57
64
|
spin: (0, import_lodash.merge)(parentContext.spin, spin),
|
|
65
|
+
tabs: (0, import_lodash.merge)(
|
|
66
|
+
{
|
|
67
|
+
indicatorSize: (origin) => origin >= 24 ? origin - 16 : origin
|
|
68
|
+
},
|
|
69
|
+
parentContext.tabs,
|
|
70
|
+
tabs
|
|
71
|
+
),
|
|
58
72
|
theme: (0, import_lodash.merge)(
|
|
59
73
|
{
|
|
60
74
|
// Only set seed token for dark theme
|
package/lib/tabs/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface TabsProps extends AntTabsProps {
|
|
|
11
11
|
}
|
|
12
12
|
export type TabsPosition = AntTabsPosition;
|
|
13
13
|
declare const Tabs: {
|
|
14
|
-
({ children, items,
|
|
14
|
+
({ children, items, type, tabPosition, prefixCls: customizePrefixCls, className, ...restProps }: TabsProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
15
15
|
TabPane: React.FC<import("./TabPane").TabPaneProps>;
|
|
16
16
|
displayName: string;
|
|
17
17
|
};
|
package/lib/tabs/index.js
CHANGED
|
@@ -38,31 +38,23 @@ var import_antd = require("antd");
|
|
|
38
38
|
var import_react = __toESM(require("react"));
|
|
39
39
|
var import_classnames = __toESM(require("classnames"));
|
|
40
40
|
var import_config_provider = __toESM(require("../config-provider"));
|
|
41
|
-
var import_useInkBar = __toESM(require("./hooks/useInkBar"));
|
|
42
41
|
var import_useLegacyItems = __toESM(require("./hooks/useLegacyItems"));
|
|
43
42
|
var import_style = __toESM(require("./style"));
|
|
44
|
-
var import_ahooks = require("ahooks");
|
|
45
43
|
var import_TabPane = __toESM(require("./TabPane"));
|
|
46
44
|
__reExport(tabs_exports, require("antd/es/tabs"), module.exports);
|
|
47
45
|
var Tabs = ({
|
|
48
46
|
children,
|
|
49
47
|
items,
|
|
50
|
-
defaultActiveKey,
|
|
51
|
-
activeKey: activeKeyProp,
|
|
52
|
-
onChange,
|
|
53
|
-
size,
|
|
54
48
|
type,
|
|
55
49
|
tabPosition,
|
|
56
50
|
prefixCls: customizePrefixCls,
|
|
57
51
|
className,
|
|
58
52
|
...restProps
|
|
59
53
|
}) => {
|
|
60
|
-
var _a;
|
|
61
54
|
const { getPrefixCls } = (0, import_react.useContext)(import_config_provider.default.ConfigContext);
|
|
62
55
|
const prefixCls = getPrefixCls("tabs", customizePrefixCls);
|
|
63
56
|
const { wrapSSR } = (0, import_style.default)(prefixCls);
|
|
64
57
|
const tabsCls = (0, import_classnames.default)(className);
|
|
65
|
-
const ref = (0, import_react.useRef)();
|
|
66
58
|
const isHorizontal = !tabPosition || tabPosition === "top" || tabPosition === "bottom";
|
|
67
59
|
let newItems = items == null ? void 0 : items.map((item) => {
|
|
68
60
|
if (!(0, import_util.isNullValue)(item.tag)) {
|
|
@@ -74,35 +66,11 @@ var Tabs = ({
|
|
|
74
66
|
return item;
|
|
75
67
|
});
|
|
76
68
|
newItems = (0, import_useLegacyItems.default)(newItems, children, prefixCls);
|
|
77
|
-
const [activeKey, setActiveKey] = (0, import_react.useState)(
|
|
78
|
-
activeKeyProp || defaultActiveKey || ((_a = newItems == null ? void 0 : newItems[0]) == null ? void 0 : _a.key)
|
|
79
|
-
);
|
|
80
|
-
(0, import_ahooks.useUpdateEffect)(() => {
|
|
81
|
-
if (activeKeyProp) {
|
|
82
|
-
setActiveKey(activeKeyProp);
|
|
83
|
-
}
|
|
84
|
-
}, [activeKeyProp]);
|
|
85
|
-
(0, import_useInkBar.default)({
|
|
86
|
-
prefixCls,
|
|
87
|
-
activeKey,
|
|
88
|
-
size,
|
|
89
|
-
type,
|
|
90
|
-
tabPosition,
|
|
91
|
-
containerRef: ref
|
|
92
|
-
});
|
|
93
69
|
return wrapSSR(
|
|
94
70
|
/* @__PURE__ */ import_react.default.createElement(
|
|
95
71
|
import_antd.Tabs,
|
|
96
72
|
{
|
|
97
|
-
ref,
|
|
98
73
|
items: newItems,
|
|
99
|
-
defaultActiveKey,
|
|
100
|
-
activeKey,
|
|
101
|
-
onChange: (key) => {
|
|
102
|
-
setActiveKey(key);
|
|
103
|
-
onChange == null ? void 0 : onChange(key);
|
|
104
|
-
},
|
|
105
|
-
size,
|
|
106
74
|
type,
|
|
107
75
|
tabPosition,
|
|
108
76
|
tabBarGutter: !type || type === "line" ? isHorizontal ? 24 : 0 : void 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oceanbase/design",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"description": "The Design System of OceanBase",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"oceanbase",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ant-design/cssinjs": "^1.17.0",
|
|
39
39
|
"@oceanbase/icons": "^0.2.7",
|
|
40
|
-
"@oceanbase/util": "^0.2.
|
|
40
|
+
"@oceanbase/util": "^0.2.9",
|
|
41
41
|
"ahooks": "^2.10.14",
|
|
42
42
|
"antd": "^5.9.0",
|
|
43
43
|
"classnames": "^2.3.2",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"react-sticky-mouse-tooltip": "^0.0.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@babel/cli": "^7.
|
|
51
|
+
"@babel/cli": "^7.23.0",
|
|
52
52
|
"@babel/preset-env": "^7.22.20",
|
|
53
53
|
"antd-token-previewer": "^1.1.0"
|
|
54
54
|
},
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"react": ">=16.9.0",
|
|
57
57
|
"react-dom": ">=16.9.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "38becd333620011d0d084df62b1131135a396abb"
|
|
60
60
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
2
|
-
import type { TabsPosition, TabsType } from 'antd/es/tabs';
|
|
3
|
-
import type { MutableRefObject } from 'react';
|
|
4
|
-
declare const _default: ({ prefixCls, activeKey, size, type, tabPosition, containerRef, }: {
|
|
5
|
-
prefixCls: string;
|
|
6
|
-
activeKey: string;
|
|
7
|
-
size: SizeType;
|
|
8
|
-
type: TabsType;
|
|
9
|
-
tabPosition: TabsPosition;
|
|
10
|
-
containerRef: MutableRefObject<HTMLDivElement>;
|
|
11
|
-
}) => void;
|
|
12
|
-
export default _default;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
export default (function (_ref) {
|
|
3
|
-
var prefixCls = _ref.prefixCls,
|
|
4
|
-
activeKey = _ref.activeKey,
|
|
5
|
-
size = _ref.size,
|
|
6
|
-
type = _ref.type,
|
|
7
|
-
tabPosition = _ref.tabPosition,
|
|
8
|
-
containerRef = _ref.containerRef;
|
|
9
|
-
var isHorizontal = !tabPosition || tabPosition === 'top' || tabPosition === 'bottom';
|
|
10
|
-
var isVertical = tabPosition === 'left' || tabPosition === 'right';
|
|
11
|
-
useEffect(function () {
|
|
12
|
-
var _containerNode$getEle;
|
|
13
|
-
// Tabs 容器节点
|
|
14
|
-
var containerNode = containerRef.current;
|
|
15
|
-
// inkbar 节点
|
|
16
|
-
var inkBarNode = containerNode === null || containerNode === void 0 ? void 0 : (_containerNode$getEle = containerNode.getElementsByClassName("".concat(prefixCls, "-ink-bar"))) === null || _containerNode$getEle === void 0 ? void 0 : _containerNode$getEle[0];
|
|
17
|
-
// 当前选中的 Tab 节点
|
|
18
|
-
var activeTabNode = containerNode === null || containerNode === void 0 ? void 0 : containerNode.querySelector("[data-node-key=\"".concat(activeKey, "\"]"));
|
|
19
|
-
// 当前选中的 Tab 下的 btn 节点
|
|
20
|
-
var activeTabBtnNode = containerNode === null || containerNode === void 0 ? void 0 : containerNode.querySelector("[data-node-key=\"".concat(activeKey, "\"]>.").concat(prefixCls, "-tab-btn"));
|
|
21
|
-
|
|
22
|
-
// 水平布局下 inkbar 的偏移量
|
|
23
|
-
var horizontalOffset = 8;
|
|
24
|
-
setTimeout(function () {
|
|
25
|
-
if ((!type || type === 'line') && inkBarNode) {
|
|
26
|
-
// 水平布局,如果 inkbar 宽度 >= 24,则两侧各减去 8px,并保持水平居中
|
|
27
|
-
if (isHorizontal && (activeTabNode === null || activeTabNode === void 0 ? void 0 : activeTabNode.offsetWidth) >= 24) {
|
|
28
|
-
inkBarNode.style.width = "".concat((activeTabNode === null || activeTabNode === void 0 ? void 0 : activeTabNode.offsetWidth) - horizontalOffset * 2, "px");
|
|
29
|
-
inkBarNode.style.marginLeft = "".concat(horizontalOffset, "px");
|
|
30
|
-
inkBarNode.style.marginTop = '0px';
|
|
31
|
-
}
|
|
32
|
-
// 垂直布局,inkbar 高度始终与 Tab btn 相同,并保持垂直居中
|
|
33
|
-
if (isVertical) {
|
|
34
|
-
inkBarNode.style.height = "".concat(activeTabBtnNode === null || activeTabBtnNode === void 0 ? void 0 : activeTabBtnNode.offsetHeight, "px");
|
|
35
|
-
inkBarNode.style.marginTop = "".concat(((activeTabNode === null || activeTabNode === void 0 ? void 0 : activeTabNode.offsetHeight) - (activeTabBtnNode === null || activeTabBtnNode === void 0 ? void 0 : activeTabBtnNode.offsetHeight)) / 2, "px");
|
|
36
|
-
inkBarNode.style.marginLeft = '0px';
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}, 100);
|
|
40
|
-
}, [prefixCls, activeKey, size, type, isHorizontal, isVertical, containerRef]);
|
|
41
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
2
|
-
import type { TabsPosition, TabsType } from 'antd/es/tabs';
|
|
3
|
-
import type { MutableRefObject } from 'react';
|
|
4
|
-
declare const _default: ({ prefixCls, activeKey, size, type, tabPosition, containerRef, }: {
|
|
5
|
-
prefixCls: string;
|
|
6
|
-
activeKey: string;
|
|
7
|
-
size: SizeType;
|
|
8
|
-
type: TabsType;
|
|
9
|
-
tabPosition: TabsPosition;
|
|
10
|
-
containerRef: MutableRefObject<HTMLDivElement>;
|
|
11
|
-
}) => void;
|
|
12
|
-
export default _default;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/tabs/hooks/useInkBar.ts
|
|
20
|
-
var useInkBar_exports = {};
|
|
21
|
-
__export(useInkBar_exports, {
|
|
22
|
-
default: () => useInkBar_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(useInkBar_exports);
|
|
25
|
-
var import_react = require("react");
|
|
26
|
-
var useInkBar_default = ({
|
|
27
|
-
prefixCls,
|
|
28
|
-
activeKey,
|
|
29
|
-
size,
|
|
30
|
-
type,
|
|
31
|
-
tabPosition,
|
|
32
|
-
containerRef
|
|
33
|
-
}) => {
|
|
34
|
-
const isHorizontal = !tabPosition || tabPosition === "top" || tabPosition === "bottom";
|
|
35
|
-
const isVertical = tabPosition === "left" || tabPosition === "right";
|
|
36
|
-
(0, import_react.useEffect)(() => {
|
|
37
|
-
var _a;
|
|
38
|
-
const containerNode = containerRef.current;
|
|
39
|
-
const inkBarNode = (_a = containerNode == null ? void 0 : containerNode.getElementsByClassName(
|
|
40
|
-
`${prefixCls}-ink-bar`
|
|
41
|
-
)) == null ? void 0 : _a[0];
|
|
42
|
-
const activeTabNode = containerNode == null ? void 0 : containerNode.querySelector(`[data-node-key="${activeKey}"]`);
|
|
43
|
-
const activeTabBtnNode = containerNode == null ? void 0 : containerNode.querySelector(
|
|
44
|
-
`[data-node-key="${activeKey}"]>.${prefixCls}-tab-btn`
|
|
45
|
-
);
|
|
46
|
-
const horizontalOffset = 8;
|
|
47
|
-
setTimeout(() => {
|
|
48
|
-
if ((!type || type === "line") && inkBarNode) {
|
|
49
|
-
if (isHorizontal && (activeTabNode == null ? void 0 : activeTabNode.offsetWidth) >= 24) {
|
|
50
|
-
inkBarNode.style.width = `${(activeTabNode == null ? void 0 : activeTabNode.offsetWidth) - horizontalOffset * 2}px`;
|
|
51
|
-
inkBarNode.style.marginLeft = `${horizontalOffset}px`;
|
|
52
|
-
inkBarNode.style.marginTop = "0px";
|
|
53
|
-
}
|
|
54
|
-
if (isVertical) {
|
|
55
|
-
inkBarNode.style.height = `${activeTabBtnNode == null ? void 0 : activeTabBtnNode.offsetHeight}px`;
|
|
56
|
-
inkBarNode.style.marginTop = `${((activeTabNode == null ? void 0 : activeTabNode.offsetHeight) - (activeTabBtnNode == null ? void 0 : activeTabBtnNode.offsetHeight)) / 2}px`;
|
|
57
|
-
inkBarNode.style.marginLeft = "0px";
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}, 100);
|
|
61
|
-
}, [prefixCls, activeKey, size, type, isHorizontal, isVertical, containerRef]);
|
|
62
|
-
};
|