@hi-ui/tabs 4.0.0-beta.16 → 4.0.0-beta.17

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.
@@ -15,6 +15,8 @@ Object.defineProperty(exports, '__esModule', {
15
15
  value: true
16
16
  });
17
17
 
18
+ var tslib = require('tslib');
19
+
18
20
  var React = require('react');
19
21
 
20
22
  var env = require('@hi-ui/env');
@@ -45,33 +47,34 @@ var _role = 'tabs';
45
47
 
46
48
  var _prefix = classname.getPrefixCls(_role);
47
49
 
48
- var TabList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
50
+ var TabList = /*#__PURE__*/React.forwardRef(function (_a, ref) {
49
51
  var _cx;
50
52
 
51
- var data = _ref.data,
52
- className = _ref.className,
53
- style = _ref.style,
54
- activeId = _ref.activeId,
55
- defaultActiveId = _ref.defaultActiveId,
56
- onChange = _ref.onChange,
57
- onTabClick = _ref.onTabClick,
58
- _ref$prefixCls = _ref.prefixCls,
59
- prefixCls = _ref$prefixCls === void 0 ? _prefix : _ref$prefixCls,
60
- _ref$direction = _ref.direction,
61
- direction = _ref$direction === void 0 ? 'horizontal' : _ref$direction,
62
- editable = _ref.editable,
63
- onAdd = _ref.onAdd,
64
- onDelete = _ref.onDelete,
65
- draggable = _ref.draggable,
66
- onDragStart = _ref.onDragStart,
67
- onDragOver = _ref.onDragOver,
68
- onDrop = _ref.onDrop,
69
- onDragEnd = _ref.onDragEnd,
70
- _ref$type = _ref.type,
71
- type = _ref$type === void 0 ? 'line' : _ref$type,
72
- extra = _ref.extra;
73
-
74
- var _a;
53
+ var _b;
54
+
55
+ var data = _a.data,
56
+ className = _a.className,
57
+ style = _a.style,
58
+ activeId = _a.activeId,
59
+ defaultActiveId = _a.defaultActiveId,
60
+ onChange = _a.onChange,
61
+ onTabClick = _a.onTabClick,
62
+ _a$prefixCls = _a.prefixCls,
63
+ prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls,
64
+ _a$direction = _a.direction,
65
+ direction = _a$direction === void 0 ? 'horizontal' : _a$direction,
66
+ editable = _a.editable,
67
+ onAdd = _a.onAdd,
68
+ onDelete = _a.onDelete,
69
+ draggable = _a.draggable,
70
+ onDragStart = _a.onDragStart,
71
+ onDragOver = _a.onDragOver,
72
+ onDrop = _a.onDrop,
73
+ onDragEnd = _a.onDragEnd,
74
+ _a$type = _a.type,
75
+ type = _a$type === void 0 ? 'line' : _a$type,
76
+ extra = _a.extra,
77
+ rest = tslib.__rest(_a, ["data", "className", "style", "activeId", "defaultActiveId", "onChange", "onTabClick", "prefixCls", "direction", "editable", "onAdd", "onDelete", "draggable", "onDragStart", "onDragOver", "onDrop", "onDragEnd", "type", "extra"]);
75
78
 
76
79
  var _useUncontrolledState = useUncontrolledState.useUncontrolledState(function () {
77
80
  if (typeAssertion.isUndef(defaultActiveId)) {
@@ -115,11 +118,11 @@ var TabList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
115
118
  setActiveTabId(key);
116
119
  }
117
120
  }, [activeTabId, onTabClick, setActiveTabId]);
118
- return /*#__PURE__*/React__default["default"].createElement("div", {
121
+ return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
119
122
  style: style,
120
123
  className: classname.cx(prefixCls + "__list", (_cx = {}, _cx[prefixCls + "__list--" + type] = type, _cx), className),
121
124
  ref: ref
122
- }, showScrollBtn && direction === 'horizontal' && /*#__PURE__*/React__default["default"].createElement(iconButton.IconButton, {
125
+ }, rest), showScrollBtn && direction === 'horizontal' && /*#__PURE__*/React__default["default"].createElement(iconButton.IconButton, {
123
126
  className: prefixCls + "__left-btn",
124
127
  effect: true,
125
128
  icon: /*#__PURE__*/React__default["default"].createElement(icons.LeftOutlined, null),
@@ -191,7 +194,7 @@ var TabList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
191
194
  prefixCls: prefixCls,
192
195
  direction: direction,
193
196
  tabListRef: innerRef,
194
- itemRef: (_a = itemsRef.current) === null || _a === void 0 ? void 0 : _a[activeTabId]
197
+ itemRef: (_b = itemsRef.current) === null || _b === void 0 ? void 0 : _b[activeTabId]
195
198
  }))), showScrollBtn && direction === 'horizontal' && /*#__PURE__*/React__default["default"].createElement(iconButton.IconButton, {
196
199
  effect: true,
197
200
  className: prefixCls + "__right-btn",
@@ -15,6 +15,8 @@ Object.defineProperty(exports, '__esModule', {
15
15
  value: true
16
16
  });
17
17
 
18
+ var tslib = require('tslib');
19
+
18
20
  var React = require('react');
19
21
 
20
22
  function _interopDefaultLegacy(e) {
@@ -25,15 +27,17 @@ function _interopDefaultLegacy(e) {
25
27
 
26
28
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
27
29
 
28
- var TabPane = function TabPane(_ref) {
29
- var children = _ref.children,
30
- className = _ref.className,
31
- style = _ref.style,
32
- active = _ref.active;
33
- return /*#__PURE__*/React__default["default"].createElement("div", {
30
+ var TabPane = function TabPane(_a) {
31
+ var children = _a.children,
32
+ className = _a.className,
33
+ style = _a.style,
34
+ active = _a.active,
35
+ rest = tslib.__rest(_a, ["children", "className", "style", "active"]);
36
+
37
+ return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
34
38
  style: style,
35
39
  className: className
36
- }, active ? children : null);
40
+ }, rest), active ? children : null);
37
41
  };
38
42
 
39
43
  exports.TabPane = TabPane;
@@ -7,6 +7,7 @@
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
+ import { __rest } from 'tslib';
10
11
  import React, { forwardRef, useState, useRef, useCallback } from 'react';
11
12
  import { __DEV__ } from '@hi-ui/env';
12
13
  import { TabItem } from './TabItem.js';
@@ -20,33 +21,34 @@ var _role = 'tabs';
20
21
 
21
22
  var _prefix = getPrefixCls(_role);
22
23
 
23
- var TabList = /*#__PURE__*/forwardRef(function (_ref, ref) {
24
+ var TabList = /*#__PURE__*/forwardRef(function (_a, ref) {
24
25
  var _cx;
25
26
 
26
- var data = _ref.data,
27
- className = _ref.className,
28
- style = _ref.style,
29
- activeId = _ref.activeId,
30
- defaultActiveId = _ref.defaultActiveId,
31
- onChange = _ref.onChange,
32
- onTabClick = _ref.onTabClick,
33
- _ref$prefixCls = _ref.prefixCls,
34
- prefixCls = _ref$prefixCls === void 0 ? _prefix : _ref$prefixCls,
35
- _ref$direction = _ref.direction,
36
- direction = _ref$direction === void 0 ? 'horizontal' : _ref$direction,
37
- editable = _ref.editable,
38
- onAdd = _ref.onAdd,
39
- onDelete = _ref.onDelete,
40
- draggable = _ref.draggable,
41
- onDragStart = _ref.onDragStart,
42
- onDragOver = _ref.onDragOver,
43
- onDrop = _ref.onDrop,
44
- onDragEnd = _ref.onDragEnd,
45
- _ref$type = _ref.type,
46
- type = _ref$type === void 0 ? 'line' : _ref$type,
47
- extra = _ref.extra;
48
-
49
- var _a;
27
+ var _b;
28
+
29
+ var data = _a.data,
30
+ className = _a.className,
31
+ style = _a.style,
32
+ activeId = _a.activeId,
33
+ defaultActiveId = _a.defaultActiveId,
34
+ onChange = _a.onChange,
35
+ onTabClick = _a.onTabClick,
36
+ _a$prefixCls = _a.prefixCls,
37
+ prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls,
38
+ _a$direction = _a.direction,
39
+ direction = _a$direction === void 0 ? 'horizontal' : _a$direction,
40
+ editable = _a.editable,
41
+ onAdd = _a.onAdd,
42
+ onDelete = _a.onDelete,
43
+ draggable = _a.draggable,
44
+ onDragStart = _a.onDragStart,
45
+ onDragOver = _a.onDragOver,
46
+ onDrop = _a.onDrop,
47
+ onDragEnd = _a.onDragEnd,
48
+ _a$type = _a.type,
49
+ type = _a$type === void 0 ? 'line' : _a$type,
50
+ extra = _a.extra,
51
+ rest = __rest(_a, ["data", "className", "style", "activeId", "defaultActiveId", "onChange", "onTabClick", "prefixCls", "direction", "editable", "onAdd", "onDelete", "draggable", "onDragStart", "onDragOver", "onDrop", "onDragEnd", "type", "extra"]);
50
52
 
51
53
  var _useUncontrolledState = useUncontrolledState(function () {
52
54
  if (isUndef(defaultActiveId)) {
@@ -90,11 +92,11 @@ var TabList = /*#__PURE__*/forwardRef(function (_ref, ref) {
90
92
  setActiveTabId(key);
91
93
  }
92
94
  }, [activeTabId, onTabClick, setActiveTabId]);
93
- return /*#__PURE__*/React.createElement("div", {
95
+ return /*#__PURE__*/React.createElement("div", Object.assign({
94
96
  style: style,
95
97
  className: cx(prefixCls + "__list", (_cx = {}, _cx[prefixCls + "__list--" + type] = type, _cx), className),
96
98
  ref: ref
97
- }, showScrollBtn && direction === 'horizontal' && /*#__PURE__*/React.createElement(IconButton, {
99
+ }, rest), showScrollBtn && direction === 'horizontal' && /*#__PURE__*/React.createElement(IconButton, {
98
100
  className: prefixCls + "__left-btn",
99
101
  effect: true,
100
102
  icon: /*#__PURE__*/React.createElement(LeftOutlined, null),
@@ -166,7 +168,7 @@ var TabList = /*#__PURE__*/forwardRef(function (_ref, ref) {
166
168
  prefixCls: prefixCls,
167
169
  direction: direction,
168
170
  tabListRef: innerRef,
169
- itemRef: (_a = itemsRef.current) === null || _a === void 0 ? void 0 : _a[activeTabId]
171
+ itemRef: (_b = itemsRef.current) === null || _b === void 0 ? void 0 : _b[activeTabId]
170
172
  }))), showScrollBtn && direction === 'horizontal' && /*#__PURE__*/React.createElement(IconButton, {
171
173
  effect: true,
172
174
  className: prefixCls + "__right-btn",
@@ -7,17 +7,20 @@
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
+ import { __rest } from 'tslib';
10
11
  import React from 'react';
11
12
 
12
- var TabPane = function TabPane(_ref) {
13
- var children = _ref.children,
14
- className = _ref.className,
15
- style = _ref.style,
16
- active = _ref.active;
17
- return /*#__PURE__*/React.createElement("div", {
13
+ var TabPane = function TabPane(_a) {
14
+ var children = _a.children,
15
+ className = _a.className,
16
+ style = _a.style,
17
+ active = _a.active,
18
+ rest = __rest(_a, ["children", "className", "style", "active"]);
19
+
20
+ return /*#__PURE__*/React.createElement("div", Object.assign({
18
21
  style: style,
19
22
  className: className
20
- }, active ? children : null);
23
+ }, rest), active ? children : null);
21
24
  };
22
25
 
23
26
  export { TabPane };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { TabPaneProps } from './TabPane';
3
3
  export declare const TabItem: React.ForwardRefExoticComponent<TabItemProps & React.RefAttributes<HTMLDivElement | null>>;
4
- interface TabItemProps extends TabPaneProps {
4
+ interface TabItemProps extends Omit<TabPaneProps, 'itemRef' | 'onDragEnd' | 'onDragOver' | 'onDragStart' | 'onDrop'> {
5
5
  active: boolean;
6
6
  draggable?: boolean;
7
7
  onTabClick: (key: React.ReactText, event: React.MouseEvent) => void;
@@ -1,13 +1,23 @@
1
1
  import React from 'react';
2
2
  import { TabPaneProps } from './TabPane';
3
+ import { HiBaseHTMLProps } from '@hi-ui/core';
3
4
  export declare const TabList: React.ForwardRefExoticComponent<TabListProps & React.RefAttributes<HTMLDivElement | null>>;
4
- export interface TabListProps {
5
- style?: React.CSSProperties;
6
- className?: string;
7
- prefixCls?: string;
5
+ export interface TabListProps extends Omit<HiBaseHTMLProps<'div'>, 'onDragEnd' | 'onDragOver' | 'onDragStart' | 'onDrop'> {
6
+ /**
7
+ * tabs 面板数据
8
+ */
8
9
  data: TabPaneProps[];
10
+ /**
11
+ * 是否可编辑
12
+ */
9
13
  direction?: 'horizontal' | 'vertical';
14
+ /**
15
+ * `activeId` 改变的回调
16
+ */
10
17
  onChange?: (tabId: React.ReactText) => void;
18
+ /**
19
+ * 标签点击触发回调
20
+ */
11
21
  onTabClick?: (tabId: React.ReactText, event: React.MouseEvent) => void;
12
22
  /**
13
23
  * 默认高亮id
@@ -17,8 +27,17 @@ export interface TabListProps {
17
27
  * 高亮id
18
28
  */
19
29
  activeId?: React.ReactText;
30
+ /**
31
+ * 是否可编辑
32
+ */
20
33
  editable?: boolean;
34
+ /**
35
+ * 是否可拖拽
36
+ */
21
37
  draggable?: boolean;
38
+ /**
39
+ * 布局类型
40
+ */
22
41
  type?: 'desc' | 'card' | 'button' | 'line';
23
42
  /**
24
43
  * 右侧的拓展区域
@@ -32,17 +51,29 @@ export interface TabListProps {
32
51
  * 节点删除时时触发
33
52
  */
34
53
  onDelete?: (deletedNode: TabPaneProps, index: number) => void;
54
+ /**
55
+ * 节点开始拖拽时触发
56
+ */
35
57
  onDragStart?: (e: React.DragEvent<HTMLDivElement>, { dragNode }: {
36
58
  dragNode: TabPaneProps;
37
59
  }) => void;
60
+ /**
61
+ * 节点拖拽移动时触发
62
+ */
38
63
  onDragOver?: (e: React.DragEvent<HTMLDivElement>, { targetNode }: {
39
64
  targetNode: TabPaneProps;
40
65
  }) => void;
66
+ /**
67
+ * 节点拖拽放下时触发
68
+ */
41
69
  onDrop?: (e: React.DragEvent<HTMLDivElement>, { dragNode, targetNode, direction, }: {
42
70
  dragNode: TabPaneProps;
43
71
  targetNode: TabPaneProps;
44
72
  direction: 'prev' | 'next' | null;
45
73
  }) => void;
74
+ /**
75
+ * 节点拖拽成功时触发
76
+ */
46
77
  onDragEnd?: (e: React.DragEvent<HTMLDivElement>, { dragNode }: {
47
78
  dragNode: TabPaneProps;
48
79
  }) => void;
@@ -1,12 +1,29 @@
1
1
  import React from 'react';
2
+ import { HiBaseHTMLProps } from '@hi-ui/core';
2
3
  export declare const TabPane: React.FC<TabPaneProps>;
3
- export interface TabPaneProps {
4
- style?: React.CSSProperties;
5
- className?: string;
4
+ export interface TabPaneProps extends HiBaseHTMLProps<'div'> {
5
+ /**
6
+ * 标签是否禁用
7
+ */
6
8
  disabled?: boolean;
9
+ /**
10
+ * 每个标签的唯一标识
11
+ */
7
12
  tabId: React.ReactText;
13
+ /**
14
+ * 选项卡头显示文字
15
+ */
8
16
  tabTitle: React.ReactNode;
17
+ /**
18
+ * 选项卡头描述文字,仅对 type='desc'时生效
19
+ */
9
20
  tabDesc?: React.ReactNode;
21
+ /**
22
+ * 标签是否可以关闭,仅对 type='editable'时生效
23
+ */
10
24
  closeable?: boolean;
25
+ /**
26
+ * 标签是否激活
27
+ */
11
28
  active?: boolean;
12
29
  }
@@ -1,26 +1,11 @@
1
1
  import React from 'react';
2
2
  import { TabPaneProps } from './TabPane';
3
+ import { HiBaseHTMLProps } from '@hi-ui/core';
3
4
  /**
4
5
  * TODO: What is Tabs
5
6
  */
6
7
  export declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement | null>>;
7
- export interface TabsProps {
8
- /**
9
- * 组件默认的选择器类
10
- */
11
- prefixCls?: string;
12
- /**
13
- * 组件的语义化 Role 属性
14
- */
15
- role?: string;
16
- /**
17
- * 组件的注入选择器类
18
- */
19
- className?: string;
20
- /**
21
- * 组件的注入样式
22
- */
23
- style?: React.CSSProperties;
8
+ export interface TabsProps extends Omit<HiBaseHTMLProps<'div'>, 'onDragEnd' | 'onDragOver' | 'onDragStart' | 'onDrop'> {
24
9
  /**
25
10
  * 是否可拖拽
26
11
  */
@@ -69,17 +54,29 @@ export interface TabsProps {
69
54
  * 节点删除时时触发
70
55
  */
71
56
  onDelete?: (deletedNode: TabPaneProps, index: number) => void;
57
+ /**
58
+ * 节点开始拖拽时触发
59
+ */
72
60
  onDragStart?: (e: React.DragEvent<HTMLDivElement>, { dragNode }: {
73
61
  dragNode: TabPaneProps;
74
62
  }) => void;
63
+ /**
64
+ * 节点拖拽移动时触发
65
+ */
75
66
  onDragOver?: (e: React.DragEvent<HTMLDivElement>, { targetNode }: {
76
67
  targetNode: TabPaneProps;
77
68
  }) => void;
69
+ /**
70
+ * 节点拖拽放下时触发
71
+ */
78
72
  onDrop?: (e: React.DragEvent<HTMLDivElement>, { dragNode, targetNode, direction, }: {
79
73
  dragNode: TabPaneProps;
80
74
  targetNode: TabPaneProps;
81
75
  direction: 'prev' | 'next' | null;
82
76
  }) => void;
77
+ /**
78
+ * 节点拖拽成功时触发
79
+ */
83
80
  onDragEnd?: (e: React.DragEvent<HTMLDivElement>, { dragNode }: {
84
81
  dragNode: TabPaneProps;
85
82
  }) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/tabs",
3
- "version": "4.0.0-beta.16",
3
+ "version": "4.0.0-beta.17",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HIUI <mi-hiui@xiaomi.com>",
@@ -44,6 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@hi-ui/classname": "^4.0.0-beta.0",
47
+ "@hi-ui/core": "^4.0.0-beta.8",
47
48
  "@hi-ui/core-css": "^4.0.0-beta.5",
48
49
  "@hi-ui/env": "^4.0.0-beta.0",
49
50
  "@hi-ui/icon-button": "^4.0.0-beta.9",
@@ -60,5 +61,5 @@
60
61
  "react": "^17.0.1",
61
62
  "react-dom": "^17.0.1"
62
63
  },
63
- "gitHead": "7f47840510e6dfce429eeed1591c154e321cd14f"
64
+ "gitHead": "64cc3305632f0d88f852f4a95cba7c27ff388a2d"
64
65
  }