@ucloud-fe/react-components 1.10.3 → 1.11.0
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/CHANGELOG.md +6 -0
- package/dist/main.min.js +7 -7
- package/lib/components/Tabs/TabBar.d.ts +2 -1
- package/lib/components/Tabs/TabBar.js +26 -11
- package/lib/components/Tabs/Tabs.d.ts +3 -1
- package/lib/components/Tabs/Tabs.js +6 -3
- package/lib/components/Tabs/index.d.ts +1 -1
- package/lib/components/Tabs/style/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { KeyboardEvent, Key } from 'react';
|
|
1
|
+
import React, { KeyboardEvent, Key, ReactNode } from 'react';
|
|
2
2
|
import { Panes, TabBarPosition } from './shared';
|
|
3
3
|
interface TabBarProps {
|
|
4
4
|
onKeyDown: (e: KeyboardEvent) => void;
|
|
@@ -8,6 +8,7 @@ interface TabBarProps {
|
|
|
8
8
|
activeKey: Key | null;
|
|
9
9
|
direction: string;
|
|
10
10
|
styleType: string;
|
|
11
|
+
extra?: ReactNode;
|
|
11
12
|
}
|
|
12
13
|
declare const _default: React.MemoExoticComponent<(props: TabBarProps) => JSX.Element>;
|
|
13
14
|
export default _default;
|
|
@@ -23,7 +23,7 @@ var _debounce2 = _interopRequireDefault(require("lodash/debounce"));
|
|
|
23
23
|
|
|
24
24
|
var _react = _interopRequireWildcard(require("react"));
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _classnames8 = _interopRequireDefault(require("classnames"));
|
|
27
27
|
|
|
28
28
|
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
|
29
29
|
|
|
@@ -33,6 +33,8 @@ var _RefContext = _interopRequireDefault(require("./RefContext"));
|
|
|
33
33
|
|
|
34
34
|
var _style2 = require("./style");
|
|
35
35
|
|
|
36
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
|
37
|
+
|
|
36
38
|
var _this = void 0;
|
|
37
39
|
|
|
38
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -76,7 +78,7 @@ var TabBarTabsNode = function TabBarTabsNode(_ref) {
|
|
|
76
78
|
if (!pane) return;
|
|
77
79
|
var key = pane.key;
|
|
78
80
|
var paneProps = pane.pane.props;
|
|
79
|
-
var className = (0,
|
|
81
|
+
var className = (0, _classnames8.default)((_classnames = {}, (0, _defineProperty2.default)(_classnames, "".concat(_style2.prefixCls, "-tab"), 1), (0, _defineProperty2.default)(_classnames, "".concat(_style2.prefixCls, "-tab-active"), activeKey === key), (0, _defineProperty2.default)(_classnames, "".concat(_style2.prefixCls, "-tab-disabled"), paneProps.disabled), _classnames));
|
|
80
82
|
var gutter = tabBarGutter && index === panes.length - 1 ? 0 : tabBarGutter;
|
|
81
83
|
var marginProperty = direction === 'rtl' ? 'marginLeft' : 'marginRight';
|
|
82
84
|
var style = (0, _defineProperty2.default)({}, (0, _utils.isVertical)(tabBarPosition) ? 'marginBottom' : marginProperty, gutter);
|
|
@@ -124,7 +126,7 @@ var TabBarRootNode = function TabBarRootNode(_ref2) {
|
|
|
124
126
|
return null;
|
|
125
127
|
}.bind(this) : _useContext2$saveRef;
|
|
126
128
|
|
|
127
|
-
var cls = (0,
|
|
129
|
+
var cls = (0, _classnames8.default)("".concat(_style2.prefixCls, "-bar"), "".concat(_style2.prefixCls, "-").concat(tabBarPosition, "-bar"), "".concat(_style2.prefixCls, "-styletype-").concat(styleType, "-bar"));
|
|
128
130
|
var topOrBottom = (0, _utils.isVertical)(tabBarPosition);
|
|
129
131
|
var tabBarExtraContentStyle = topOrBottom ? {
|
|
130
132
|
float: 'right'
|
|
@@ -267,7 +269,7 @@ var InkTabBarNode = function InkTabBarNode(_ref3) {
|
|
|
267
269
|
}.bind(this);
|
|
268
270
|
}.bind(this), [getRef, onResize]);
|
|
269
271
|
var className = "".concat(_style2.prefixCls, "-ink-bar");
|
|
270
|
-
var classes = (0,
|
|
272
|
+
var classes = (0, _classnames8.default)(className, inkBarAnimated ? "".concat(className, "-animated") : "".concat(className, "-no-animated"));
|
|
271
273
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
272
274
|
className: classes,
|
|
273
275
|
key: "inkBar",
|
|
@@ -583,7 +585,7 @@ var ScrollableTabBarNode = function ScrollableTabBarNode(_ref5) {
|
|
|
583
585
|
var prevButton = /*#__PURE__*/_react.default.createElement("span", {
|
|
584
586
|
onClick: onPrev,
|
|
585
587
|
unselectable: "on",
|
|
586
|
-
className: (0,
|
|
588
|
+
className: (0, _classnames8.default)((_classnames2 = {}, (0, _defineProperty2.default)(_classnames2, "".concat(_style2.prefixCls, "-tab-prev"), 1), (0, _defineProperty2.default)(_classnames2, "".concat(_style2.prefixCls, "-tab-btn-disabled"), !prev), (0, _defineProperty2.default)(_classnames2, "".concat(_style2.prefixCls, "-tab-arrow-show"), showNextPrev), _classnames2)),
|
|
587
589
|
onTransitionEnd: prevTransitionEnd
|
|
588
590
|
}, prevIcon || /*#__PURE__*/_react.default.createElement("span", {
|
|
589
591
|
className: "".concat(_style2.prefixCls, "-tab-prev-icon")
|
|
@@ -592,15 +594,15 @@ var ScrollableTabBarNode = function ScrollableTabBarNode(_ref5) {
|
|
|
592
594
|
var nextButton = /*#__PURE__*/_react.default.createElement("span", {
|
|
593
595
|
onClick: onNext,
|
|
594
596
|
unselectable: "on",
|
|
595
|
-
className: (0,
|
|
597
|
+
className: (0, _classnames8.default)((_classnames3 = {}, (0, _defineProperty2.default)(_classnames3, "".concat(_style2.prefixCls, "-tab-next"), 1), (0, _defineProperty2.default)(_classnames3, "".concat(_style2.prefixCls, "-tab-btn-disabled"), !next), (0, _defineProperty2.default)(_classnames3, "".concat(_style2.prefixCls, "-tab-arrow-show"), showNextPrev), _classnames3))
|
|
596
598
|
}, nextIcon || /*#__PURE__*/_react.default.createElement("span", {
|
|
597
599
|
className: "".concat(_style2.prefixCls, "-tab-next-icon")
|
|
598
600
|
}));
|
|
599
601
|
|
|
600
602
|
var navClassName = "".concat(_style2.prefixCls, "-nav");
|
|
601
|
-
var navClasses = (0,
|
|
603
|
+
var navClasses = (0, _classnames8.default)(navClassName, scrollAnimated ? "".concat(navClassName, "-animated") : "".concat(navClassName, "-no-animated"));
|
|
602
604
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
603
|
-
className: (0,
|
|
605
|
+
className: (0, _classnames8.default)((_classnames4 = {}, (0, _defineProperty2.default)(_classnames4, "".concat(_style2.prefixCls, "-nav-container"), 1), (0, _defineProperty2.default)(_classnames4, "".concat(_style2.prefixCls, "-nav-container-scrolling"), showNextPrev), _classnames4)),
|
|
604
606
|
ref: saveRef('container')
|
|
605
607
|
}, prevButton, nextButton, /*#__PURE__*/_react.default.createElement("div", {
|
|
606
608
|
className: "".concat(_style2.prefixCls, "-nav-wrap"),
|
|
@@ -624,7 +626,8 @@ ScrollableTabBarNode.propTypes = {
|
|
|
624
626
|
};
|
|
625
627
|
|
|
626
628
|
var TabBar = function TabBar(props) {
|
|
627
|
-
var _this8 = this
|
|
629
|
+
var _this8 = this,
|
|
630
|
+
_classnames7;
|
|
628
631
|
|
|
629
632
|
(0, _newArrowCheck2.default)(this, _this);
|
|
630
633
|
var refs = (0, _react.useRef)({});
|
|
@@ -648,14 +651,26 @@ var TabBar = function TabBar(props) {
|
|
|
648
651
|
getRef: getRef,
|
|
649
652
|
saveRef: saveRef
|
|
650
653
|
}
|
|
651
|
-
}, /*#__PURE__*/_react.default.createElement(TabBarRootNode, props, /*#__PURE__*/_react.default.createElement(
|
|
654
|
+
}, /*#__PURE__*/_react.default.createElement(TabBarRootNode, props, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
|
655
|
+
container: true,
|
|
656
|
+
className: (0, _classnames8.default)((0, _defineProperty2.default)({}, "".concat(_style2.prefixCls, "-srcoll-extra-warrper"), ['left', 'right'].includes(props.tabBarPosition))),
|
|
657
|
+
justifyContent: "space-between",
|
|
658
|
+
alignItems: "center"
|
|
659
|
+
}, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
|
660
|
+
flex: 1,
|
|
661
|
+
className: (0, _classnames8.default)((0, _defineProperty2.default)({}, "".concat(_style2.prefixCls, "-srcoll-box"), 1))
|
|
662
|
+
}, /*#__PURE__*/_react.default.createElement(ScrollableTabBarNode, props, /*#__PURE__*/_react.default.createElement(TabBarTabsNode, props), styleType === 'ink' ? /*#__PURE__*/_react.default.createElement(InkTabBarNode, props) : null)), /*#__PURE__*/_react.default.createElement(_Box.default, {
|
|
663
|
+
justifyContent: "flex-end",
|
|
664
|
+
className: (0, _classnames8.default)((_classnames7 = {}, (0, _defineProperty2.default)(_classnames7, "".concat(_style2.prefixCls, "-extra-wapper"), 1), (0, _defineProperty2.default)(_classnames7, "".concat(_style2.prefixCls, "-extra-show"), props.extra), _classnames7))
|
|
665
|
+
}, props.extra))));
|
|
652
666
|
}.bind(void 0);
|
|
653
667
|
|
|
654
668
|
TabBar.propTypes = {
|
|
655
669
|
onKeyDown: _propTypes.default.func.isRequired,
|
|
656
670
|
onTabClick: _propTypes.default.func.isRequired,
|
|
657
671
|
direction: _propTypes.default.string.isRequired,
|
|
658
|
-
styleType: _propTypes.default.string.isRequired
|
|
672
|
+
styleType: _propTypes.default.string.isRequired,
|
|
673
|
+
extra: _propTypes.default.node
|
|
659
674
|
};
|
|
660
675
|
|
|
661
676
|
var _default = /*#__PURE__*/(0, _react.memo)(TabBar);
|
|
@@ -22,6 +22,8 @@ export interface TabsProps {
|
|
|
22
22
|
styleType?: StyleType;
|
|
23
23
|
/** 尺寸 */
|
|
24
24
|
size?: Size;
|
|
25
|
+
/** 头部插槽 */
|
|
26
|
+
extra?: ReactNode;
|
|
25
27
|
}
|
|
26
|
-
declare const _default: React.MemoExoticComponent<({ activeKey: _activeKey, defaultActiveKey, onChange: _onChange, destroyInactiveTabPane, children, className, tabBarPosition, direction, styleType, size, ...restProps }: TabsProps) => JSX.Element>;
|
|
28
|
+
declare const _default: React.MemoExoticComponent<({ activeKey: _activeKey, defaultActiveKey, onChange: _onChange, destroyInactiveTabPane, children, className, tabBarPosition, direction, styleType, size, extra, ...restProps }: TabsProps) => JSX.Element>;
|
|
27
29
|
export default _default;
|
|
@@ -35,7 +35,7 @@ var _TabContent = _interopRequireDefault(require("./TabContent"));
|
|
|
35
35
|
|
|
36
36
|
var _style = require("./style");
|
|
37
37
|
|
|
38
|
-
var _excluded = ["activeKey", "defaultActiveKey", "onChange", "destroyInactiveTabPane", "children", "className", "tabBarPosition", "direction", "styleType", "size"];
|
|
38
|
+
var _excluded = ["activeKey", "defaultActiveKey", "onChange", "destroyInactiveTabPane", "children", "className", "tabBarPosition", "direction", "styleType", "size", "extra"];
|
|
39
39
|
|
|
40
40
|
var _this2 = void 0;
|
|
41
41
|
|
|
@@ -139,6 +139,7 @@ var Tabs = function Tabs(_ref) {
|
|
|
139
139
|
styleType = _ref$styleType === void 0 ? 'default' : _ref$styleType,
|
|
140
140
|
_ref$size = _ref.size,
|
|
141
141
|
size = _ref$size === void 0 ? 'sm' : _ref$size,
|
|
142
|
+
extra = _ref.extra,
|
|
142
143
|
restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
143
144
|
var panes = (0, _react.useMemo)(function () {
|
|
144
145
|
(0, _newArrowCheck2.default)(this, _this4);
|
|
@@ -192,7 +193,8 @@ var Tabs = function Tabs(_ref) {
|
|
|
192
193
|
}),
|
|
193
194
|
nextIcon: /*#__PURE__*/_react.default.createElement(_SvgIcon.default, {
|
|
194
195
|
type: "triangle-right"
|
|
195
|
-
})
|
|
196
|
+
}),
|
|
197
|
+
extra: extra
|
|
196
198
|
});
|
|
197
199
|
|
|
198
200
|
var tabContent = /*#__PURE__*/_react.default.createElement(_TabContent.default, {
|
|
@@ -230,7 +232,8 @@ Tabs.propTypes = {
|
|
|
230
232
|
destroyInactiveTabPane: _propTypes.default.bool,
|
|
231
233
|
children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.element), _propTypes.default.node]).isRequired,
|
|
232
234
|
className: _propTypes.default.string,
|
|
233
|
-
direction: _propTypes.default.string
|
|
235
|
+
direction: _propTypes.default.string,
|
|
236
|
+
extra: _propTypes.default.node
|
|
234
237
|
};
|
|
235
238
|
|
|
236
239
|
var _default = /*#__PURE__*/(0, _react.memo)(Tabs);
|
|
@@ -3,7 +3,7 @@ import { TabsProps } from './Tabs';
|
|
|
3
3
|
import Pane, { TabPaneProps } from './Pane';
|
|
4
4
|
import { TabBarPositions, Sizes, StyleTypes } from './shared';
|
|
5
5
|
declare const ExportTabs: import("react").NamedExoticComponent<TabsProps> & {
|
|
6
|
-
readonly type: ({ activeKey: _activeKey, defaultActiveKey, onChange: _onChange, destroyInactiveTabPane, children, className, tabBarPosition, direction, styleType, size, ...restProps }: TabsProps) => JSX.Element;
|
|
6
|
+
readonly type: ({ activeKey: _activeKey, defaultActiveKey, onChange: _onChange, destroyInactiveTabPane, children, className, tabBarPosition, direction, styleType, size, extra, ...restProps }: TabsProps) => JSX.Element;
|
|
7
7
|
} & {
|
|
8
8
|
Pane: typeof Pane;
|
|
9
9
|
/** @private 请勿使用 */
|