@clayui/tabs 3.156.0 → 3.158.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/README.md +4 -4
- package/lib/Content.d.ts +2 -2
- package/lib/Item.d.ts +2 -2
- package/lib/List.d.ts +2 -2
- package/lib/TabPane.d.ts +2 -2
- package/lib/cjs/Content.js +64 -39
- package/lib/cjs/Item.js +68 -36
- package/lib/cjs/List.js +90 -74
- package/lib/cjs/TabPane.js +77 -46
- package/lib/cjs/index.js +80 -60
- package/lib/esm/Content.js +36 -36
- package/lib/esm/Item.js +40 -33
- package/lib/esm/List.js +58 -65
- package/lib/esm/TabPane.js +49 -43
- package/lib/esm/index.js +43 -48
- package/lib/index.d.ts +2 -2
- package/package.json +31 -32
package/lib/cjs/index.js
CHANGED
|
@@ -1,48 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty
|
|
4
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var src_exports = {};
|
|
30
|
+
__export(src_exports, {
|
|
31
|
+
default: () => src_default
|
|
5
32
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
modern = false,
|
|
29
|
-
onActiveChange,
|
|
30
|
-
...otherProps
|
|
31
|
-
} = _ref;
|
|
32
|
-
const [active, setActive, isUncontrolled] = (0, _shared.useControlledState)({
|
|
33
|
-
defaultName: 'defaultActive',
|
|
33
|
+
module.exports = __toCommonJS(src_exports);
|
|
34
|
+
var import_shared = require("@clayui/shared");
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_Content = __toESM(require("./Content"));
|
|
37
|
+
var import_Item = __toESM(require("./Item"));
|
|
38
|
+
var import_List = require("./List");
|
|
39
|
+
var import_TabPane = __toESM(require("./TabPane"));
|
|
40
|
+
function Tabs({
|
|
41
|
+
activation = "manual",
|
|
42
|
+
active: externalActive,
|
|
43
|
+
children,
|
|
44
|
+
className,
|
|
45
|
+
defaultActive = 0,
|
|
46
|
+
displayType,
|
|
47
|
+
fade = false,
|
|
48
|
+
justified,
|
|
49
|
+
modern = false,
|
|
50
|
+
onActiveChange,
|
|
51
|
+
...otherProps
|
|
52
|
+
}) {
|
|
53
|
+
const [active, setActive, isUncontrolled] = (0, import_shared.useControlledState)({
|
|
54
|
+
defaultName: "defaultActive",
|
|
34
55
|
defaultValue: defaultActive,
|
|
35
|
-
handleName:
|
|
36
|
-
name:
|
|
56
|
+
handleName: "onActiveChange",
|
|
57
|
+
name: "active",
|
|
37
58
|
onChange: onActiveChange,
|
|
38
59
|
value: externalActive
|
|
39
60
|
});
|
|
40
|
-
const [left, right] =
|
|
41
|
-
const tabsId = (0,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (left?.type?.displayName === 'ClayTabsList') {
|
|
45
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.cloneElement(left, {
|
|
61
|
+
const [left, right] = import_react.default.Children.toArray(children);
|
|
62
|
+
const tabsId = (0, import_shared.useId)();
|
|
63
|
+
if (left?.type?.displayName === "ClayTabsList") {
|
|
64
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, import_react.default.cloneElement(left, {
|
|
46
65
|
activation,
|
|
47
66
|
active,
|
|
48
67
|
displayType,
|
|
@@ -51,30 +70,31 @@ function Tabs(_ref) {
|
|
|
51
70
|
onActiveChange: setActive,
|
|
52
71
|
shouldUseActive: isUncontrolled,
|
|
53
72
|
tabsId
|
|
54
|
-
}),
|
|
73
|
+
}), import_react.default.isValidElement(right) && import_react.default.cloneElement(right, {
|
|
55
74
|
active,
|
|
56
75
|
fade,
|
|
57
76
|
tabsId
|
|
58
77
|
}));
|
|
59
78
|
}
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
80
|
+
import_List.List,
|
|
81
|
+
{
|
|
82
|
+
...otherProps,
|
|
83
|
+
activation,
|
|
84
|
+
active,
|
|
85
|
+
className,
|
|
86
|
+
displayType,
|
|
87
|
+
justified,
|
|
88
|
+
modern,
|
|
89
|
+
onActiveChange: setActive
|
|
90
|
+
},
|
|
91
|
+
children
|
|
92
|
+
);
|
|
69
93
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
Tabs.
|
|
75
|
-
Tabs.
|
|
76
|
-
|
|
77
|
-
Tabs.List = _List.List;
|
|
78
|
-
Tabs.TabPane = _TabPane.default;
|
|
79
|
-
Tabs.TabPanel = _TabPane.default;
|
|
80
|
-
var _default = exports.default = Tabs;
|
|
94
|
+
Tabs.Content = import_Content.default;
|
|
95
|
+
Tabs.Panels = import_Content.default;
|
|
96
|
+
Tabs.Item = import_Item.default;
|
|
97
|
+
Tabs.List = import_List.List;
|
|
98
|
+
Tabs.TabPane = import_TabPane.default;
|
|
99
|
+
Tabs.TabPanel = import_TabPane.default;
|
|
100
|
+
var src_default = Tabs;
|
package/lib/esm/Content.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
key: index
|
|
34
|
-
});
|
|
35
|
-
}));
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import React from "react";
|
|
3
|
+
const Content = React.forwardRef(function Content2({
|
|
4
|
+
active,
|
|
5
|
+
activeIndex = 0,
|
|
6
|
+
children,
|
|
7
|
+
className,
|
|
8
|
+
fade = false,
|
|
9
|
+
tabsId,
|
|
10
|
+
...otherProps
|
|
11
|
+
}, ref) {
|
|
12
|
+
return /* @__PURE__ */ React.createElement(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
className: classNames("tab-content", className),
|
|
16
|
+
...otherProps,
|
|
17
|
+
ref
|
|
18
|
+
},
|
|
19
|
+
React.Children.map(children, (child, index) => {
|
|
20
|
+
if (!React.isValidElement(child)) {
|
|
21
|
+
return child;
|
|
22
|
+
}
|
|
23
|
+
return React.cloneElement(child, {
|
|
24
|
+
...child.props,
|
|
25
|
+
"active": typeof active === "number" ? active === index : activeIndex === index,
|
|
26
|
+
"aria-labelledby": tabsId ? `${tabsId}-tab-${index}` : child.props["aria-labelledby"],
|
|
27
|
+
fade,
|
|
28
|
+
"id": tabsId ? `${tabsId}-tabpanel-${index}` : child.props.id,
|
|
29
|
+
"key": index
|
|
30
|
+
});
|
|
31
|
+
})
|
|
32
|
+
);
|
|
36
33
|
});
|
|
37
|
-
|
|
34
|
+
var Content_default = Content;
|
|
35
|
+
export {
|
|
36
|
+
Content_default as default
|
|
37
|
+
};
|
package/lib/esm/Item.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { LinkOrButton } from '@clayui/shared';
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
import React from 'react';
|
|
10
|
-
const Item = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
11
|
-
let {
|
|
1
|
+
import { LinkOrButton } from "@clayui/shared";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import React from "react";
|
|
4
|
+
const Item = React.forwardRef(
|
|
5
|
+
({
|
|
12
6
|
active = false,
|
|
13
7
|
children,
|
|
14
8
|
className,
|
|
@@ -17,25 +11,38 @@ const Item = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
17
11
|
innerProps = {},
|
|
18
12
|
onClick,
|
|
19
13
|
...otherProps
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
14
|
+
}, ref) => /* @__PURE__ */ React.createElement(
|
|
15
|
+
"li",
|
|
16
|
+
{
|
|
17
|
+
...otherProps,
|
|
18
|
+
className: classNames("nav-item", className),
|
|
19
|
+
role: "none"
|
|
20
|
+
},
|
|
21
|
+
/* @__PURE__ */ React.createElement(
|
|
22
|
+
LinkOrButton,
|
|
23
|
+
{
|
|
24
|
+
...innerProps,
|
|
25
|
+
"aria-selected": active,
|
|
26
|
+
buttonDisplayType: "unstyled",
|
|
27
|
+
buttonType: "button",
|
|
28
|
+
className: classNames("nav-link", {
|
|
29
|
+
active,
|
|
30
|
+
disabled
|
|
31
|
+
}),
|
|
32
|
+
"data-testid": "tabItem",
|
|
33
|
+
disabled,
|
|
34
|
+
href,
|
|
35
|
+
onClick,
|
|
36
|
+
ref,
|
|
37
|
+
role: "tab",
|
|
38
|
+
tabIndex: !active ? -1 : 0
|
|
39
|
+
},
|
|
40
|
+
children
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
Item.displayName = "ClayTabsItem";
|
|
45
|
+
var Item_default = Item;
|
|
46
|
+
export {
|
|
47
|
+
Item_default as default
|
|
48
|
+
};
|
package/lib/esm/List.js
CHANGED
|
@@ -1,84 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
justified,
|
|
18
|
-
modern: __,
|
|
19
|
-
onActiveChange,
|
|
20
|
-
shouldUseActive = false,
|
|
21
|
-
tabsId,
|
|
22
|
-
...otherProps
|
|
23
|
-
} = _ref;
|
|
1
|
+
import { useNavigation } from "@clayui/shared";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import React, { useEffect, useImperativeHandle, useRef } from "react";
|
|
4
|
+
const List = React.forwardRef(function List2({
|
|
5
|
+
activation,
|
|
6
|
+
active,
|
|
7
|
+
children,
|
|
8
|
+
className,
|
|
9
|
+
displayType = null,
|
|
10
|
+
justified,
|
|
11
|
+
modern: __,
|
|
12
|
+
onActiveChange,
|
|
13
|
+
shouldUseActive = false,
|
|
14
|
+
tabsId,
|
|
15
|
+
...otherProps
|
|
16
|
+
}, ref) {
|
|
24
17
|
const tabsRef = useRef(null);
|
|
25
|
-
const {
|
|
26
|
-
navigationProps
|
|
27
|
-
} = useNavigation({
|
|
18
|
+
const { navigationProps } = useNavigation({
|
|
28
19
|
activation,
|
|
29
20
|
containerRef: tabsRef,
|
|
30
|
-
orientation:
|
|
21
|
+
orientation: "horizontal"
|
|
31
22
|
});
|
|
32
23
|
useImperativeHandle(ref, () => tabsRef.current, [tabsRef]);
|
|
33
24
|
useEffect(() => {
|
|
34
|
-
// Internal API to maintain compatibility with the old Tabs pattern and to
|
|
35
|
-
// only update the initial state when the component is in
|
|
36
|
-
// uncontrolled mode.
|
|
37
25
|
if (!shouldUseActive) {
|
|
38
26
|
return;
|
|
39
27
|
}
|
|
40
28
|
const childrenArray = React.Children.toArray(children);
|
|
41
|
-
|
|
42
|
-
// The `active` API in the new pattern has uncontrolled behavior, working
|
|
43
|
-
// just like defaultActive as in the prop declared in the root component.
|
|
44
29
|
for (let index = 0; index < childrenArray.length; index++) {
|
|
45
30
|
const child = childrenArray[index];
|
|
46
|
-
if (
|
|
31
|
+
if (React.isValidElement(child) && child.props.active) {
|
|
47
32
|
onActiveChange(index);
|
|
48
33
|
break;
|
|
49
34
|
}
|
|
50
35
|
}
|
|
51
36
|
}, []);
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
...(child.props.innerProps ?? {})
|
|
70
|
-
},
|
|
71
|
-
onClick: event => {
|
|
72
|
-
const {
|
|
73
|
-
onClick
|
|
74
|
-
} = child.props;
|
|
75
|
-
if (onClick) {
|
|
76
|
-
onClick(event);
|
|
77
|
-
} else {
|
|
78
|
-
onActiveChange(index);
|
|
79
|
-
}
|
|
37
|
+
return /* @__PURE__ */ React.createElement(
|
|
38
|
+
"ul",
|
|
39
|
+
{
|
|
40
|
+
...otherProps,
|
|
41
|
+
...navigationProps,
|
|
42
|
+
className: classNames(
|
|
43
|
+
"nav nav-tabs",
|
|
44
|
+
{ "nav-justified": justified },
|
|
45
|
+
{ [`nav-tabs-${displayType}`]: displayType === "light" },
|
|
46
|
+
className
|
|
47
|
+
),
|
|
48
|
+
ref: tabsRef,
|
|
49
|
+
role: "tablist"
|
|
50
|
+
},
|
|
51
|
+
React.Children.map(children, (child, index) => {
|
|
52
|
+
if (!React.isValidElement(child)) {
|
|
53
|
+
return child;
|
|
80
54
|
}
|
|
81
|
-
|
|
82
|
-
|
|
55
|
+
return React.cloneElement(child, {
|
|
56
|
+
active: !shouldUseActive && child.props.active !== void 0 ? child.props.active : active === index,
|
|
57
|
+
innerProps: {
|
|
58
|
+
"aria-controls": tabsId && `${tabsId}-tabpanel-${index}`,
|
|
59
|
+
"id": tabsId && `${tabsId}-tab-${index}`,
|
|
60
|
+
...child.props.innerProps ?? {}
|
|
61
|
+
},
|
|
62
|
+
onClick: (event) => {
|
|
63
|
+
const { onClick } = child.props;
|
|
64
|
+
if (onClick) {
|
|
65
|
+
onClick(event);
|
|
66
|
+
} else {
|
|
67
|
+
onActiveChange(index);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
})
|
|
72
|
+
);
|
|
83
73
|
});
|
|
84
|
-
List.displayName =
|
|
74
|
+
List.displayName = "ClayTabsList";
|
|
75
|
+
export {
|
|
76
|
+
List
|
|
77
|
+
};
|
package/lib/esm/TabPane.js
CHANGED
|
@@ -1,52 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import classNames from 'classnames';
|
|
8
|
-
import React from 'react';
|
|
9
|
-
const delay = function (fn) {
|
|
10
|
-
let val = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 150;
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import React from "react";
|
|
3
|
+
function delay(fn, val = 150) {
|
|
11
4
|
return setTimeout(() => {
|
|
12
5
|
fn();
|
|
13
6
|
}, val);
|
|
14
|
-
}
|
|
15
|
-
const TabPane =
|
|
16
|
-
|
|
7
|
+
}
|
|
8
|
+
const TabPane = React.forwardRef(
|
|
9
|
+
function TabPane2({
|
|
17
10
|
active = false,
|
|
18
11
|
children,
|
|
19
12
|
className,
|
|
20
13
|
fade,
|
|
21
14
|
tabIndex = 0,
|
|
22
15
|
...otherProps
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
16
|
+
}, ref) {
|
|
17
|
+
const [internalActive, setInternalActive] = React.useState(active);
|
|
18
|
+
const [internalShow, setInternalShow] = React.useState(active);
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
let delayFn = () => {
|
|
21
|
+
setInternalActive(true);
|
|
22
|
+
delay(() => setInternalShow(true), 50);
|
|
23
|
+
};
|
|
24
|
+
if (!active) {
|
|
25
|
+
setInternalShow(false);
|
|
26
|
+
delayFn = () => setInternalActive(false);
|
|
27
|
+
}
|
|
28
|
+
const timer = delay(delayFn);
|
|
29
|
+
return () => {
|
|
30
|
+
clearTimeout(timer);
|
|
31
|
+
setInternalShow(false);
|
|
32
|
+
};
|
|
33
|
+
}, [active]);
|
|
34
|
+
return /* @__PURE__ */ React.createElement(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
...otherProps,
|
|
38
|
+
className: classNames(
|
|
39
|
+
"tab-pane",
|
|
40
|
+
{
|
|
41
|
+
active: internalActive,
|
|
42
|
+
fade,
|
|
43
|
+
show: internalShow
|
|
44
|
+
},
|
|
45
|
+
className
|
|
46
|
+
),
|
|
47
|
+
ref,
|
|
48
|
+
role: "tabpanel",
|
|
49
|
+
tabIndex
|
|
50
|
+
},
|
|
51
|
+
children
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
var TabPane_default = TabPane;
|
|
56
|
+
export {
|
|
57
|
+
TabPane_default as default
|
|
58
|
+
};
|