@oceanbase/design 0.2.9 → 0.2.10

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.
@@ -7,7 +7,7 @@ import StaticFunction from "../static-function";
7
7
  export * from 'antd/es/config-provider';
8
8
 
9
9
  // ConfigProvider 默认内嵌 App,支持 message, notification 和 Modal 等静态方法消费 ConfigProvider 配置
10
- // ref: https://ant-design.antgroup.com/components/app-cn
10
+ // ref: https://ant.design/components/app-cn
11
11
  var ConfigProvider = function ConfigProvider(_ref) {
12
12
  var children = _ref.children,
13
13
  restProps = _objectWithoutProperties(_ref, _excluded);
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { theme } from 'antd';
2
2
 
3
3
  // 引入 antd/dist/reset.css,以重置基本样式,保证原生元素遵从 antd 规范样式
4
- // ref: https://ant-design.antgroup.com/docs/react/migration-v5-cn#%E6%8A%80%E6%9C%AF%E8%B0%83%E6%95%B4
4
+ // ref: https://ant.design/docs/react/migration-v5-cn#%E6%8A%80%E6%9C%AF%E8%B0%83%E6%95%B4
5
5
  import 'antd/dist/reset.css';
6
6
  export * from 'antd';
7
7
  export { version } from "../package.json";
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import type { TabsProps } from '..';
3
+ export default function useLegacyItems(items?: TabsProps['items'], children?: React.ReactNode, prefixCls?: string): any[];
@@ -1,6 +1,6 @@
1
- import type { TabsPosition as AntTabsPosition, TabsProps as AntTabsProps } from 'antd/es/tabs';
2
- import type { Tab as AntTab } from 'rc-tabs/es/interface';
3
1
  import React from 'react';
2
+ import type { TabsProps as AntTabsProps, TabsPosition as AntTabsPosition } from 'antd/es/tabs';
3
+ import type { Tab as AntTab } from 'rc-tabs/es/interface';
4
4
  export * from 'antd/es/tabs';
5
5
  export type { TabPaneProps } from './TabPane';
6
6
  export interface Tab extends AntTab {
package/es/tabs/index.js CHANGED
@@ -16,12 +16,13 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
16
16
  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; }
17
17
  import { isNullValue } from '@oceanbase/util';
18
18
  import { Space, Tabs as AntTabs, Tag } from 'antd';
19
+ import React, { useState, useRef, useContext } from 'react';
19
20
  import classNames from 'classnames';
20
- import React, { useContext, useRef, useState } from 'react';
21
21
  import ConfigProvider from "../config-provider";
22
22
  import useInkBar from "./hooks/useInkBar";
23
23
  import useLegacyItems from "./hooks/useLegacyItems";
24
24
  import useStyle from "./style";
25
+ import { useUpdateEffect } from 'ahooks';
25
26
  import TabPane from "./TabPane";
26
27
  export * from 'antd/es/tabs';
27
28
  var Tabs = function Tabs(_ref) {
@@ -64,6 +65,14 @@ var Tabs = function Tabs(_ref) {
64
65
  _useState2 = _slicedToArray(_useState, 2),
65
66
  activeKey = _useState2[0],
66
67
  setActiveKey = _useState2[1];
68
+
69
+ // 防止第一次顶掉默认值
70
+ useUpdateEffect(function () {
71
+ // 外部触发的 activeKey 更改,需要同步内部状态变化
72
+ if (activeKeyProp) {
73
+ setActiveKey(activeKeyProp);
74
+ }
75
+ }, [activeKeyProp]);
67
76
  useInkBar({
68
77
  prefixCls: prefixCls,
69
78
  activeKey: activeKey,
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import type { TabsProps } from '..';
3
+ export default function useLegacyItems(items?: TabsProps['items'], children?: React.ReactNode, prefixCls?: string): any[];
@@ -1,6 +1,6 @@
1
- import type { TabsPosition as AntTabsPosition, TabsProps as AntTabsProps } from 'antd/es/tabs';
2
- import type { Tab as AntTab } from 'rc-tabs/es/interface';
3
1
  import React from 'react';
2
+ import type { TabsProps as AntTabsProps, TabsPosition as AntTabsPosition } from 'antd/es/tabs';
3
+ import type { Tab as AntTab } from 'rc-tabs/es/interface';
4
4
  export * from 'antd/es/tabs';
5
5
  export type { TabPaneProps } from './TabPane';
6
6
  export interface Tab extends AntTab {
package/lib/tabs/index.js CHANGED
@@ -35,12 +35,13 @@ __export(tabs_exports, {
35
35
  module.exports = __toCommonJS(tabs_exports);
36
36
  var import_util = require("@oceanbase/util");
37
37
  var import_antd = require("antd");
38
- var import_classnames = __toESM(require("classnames"));
39
38
  var import_react = __toESM(require("react"));
39
+ var import_classnames = __toESM(require("classnames"));
40
40
  var import_config_provider = __toESM(require("../config-provider"));
41
41
  var import_useInkBar = __toESM(require("./hooks/useInkBar"));
42
42
  var import_useLegacyItems = __toESM(require("./hooks/useLegacyItems"));
43
43
  var import_style = __toESM(require("./style"));
44
+ var import_ahooks = require("ahooks");
44
45
  var import_TabPane = __toESM(require("./TabPane"));
45
46
  __reExport(tabs_exports, require("antd/es/tabs"), module.exports);
46
47
  var Tabs = ({
@@ -76,6 +77,11 @@ var Tabs = ({
76
77
  const [activeKey, setActiveKey] = (0, import_react.useState)(
77
78
  activeKeyProp || defaultActiveKey || ((_a = newItems == null ? void 0 : newItems[0]) == null ? void 0 : _a.key)
78
79
  );
80
+ (0, import_ahooks.useUpdateEffect)(() => {
81
+ if (activeKeyProp) {
82
+ setActiveKey(activeKeyProp);
83
+ }
84
+ }, [activeKeyProp]);
79
85
  (0, import_useInkBar.default)({
80
86
  prefixCls,
81
87
  activeKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oceanbase/design",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "The Design System for OceanBase",
5
5
  "keywords": [
6
6
  "OceanBase",
@@ -56,5 +56,5 @@
56
56
  "react": "^16.9.0",
57
57
  "react-dom": "^16.9.0"
58
58
  },
59
- "gitHead": "50d5e0e6ecf64b44f17c1e5de8dd5d6d5be14eab"
59
+ "gitHead": "6c0f8edb7a7871d3c87582c4293c74a58dc17072"
60
60
  }