@v-c/tabs 0.0.2
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/LICENSE +21 -0
- package/dist/TabContext.cjs +11 -0
- package/dist/TabContext.d.ts +8 -0
- package/dist/TabContext.js +9 -0
- package/dist/TabNavList/AddButton.cjs +4 -0
- package/dist/TabNavList/AddButton.js +3 -0
- package/dist/TabNavList/AddButton.vue_vue_type_script_setup_true_lang.cjs +36 -0
- package/dist/TabNavList/AddButton.vue_vue_type_script_setup_true_lang.js +35 -0
- package/dist/TabNavList/ExtraContent.cjs +4 -0
- package/dist/TabNavList/ExtraContent.js +3 -0
- package/dist/TabNavList/ExtraContent.vue_vue_type_script_setup_true_lang.cjs +51 -0
- package/dist/TabNavList/ExtraContent.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/TabNavList/OperationNode.cjs +4 -0
- package/dist/TabNavList/OperationNode.js +3 -0
- package/dist/TabNavList/OperationNode.vue_vue_type_script_setup_true_lang.cjs +210 -0
- package/dist/TabNavList/OperationNode.vue_vue_type_script_setup_true_lang.js +205 -0
- package/dist/TabNavList/TabNode.cjs +4 -0
- package/dist/TabNavList/TabNode.js +3 -0
- package/dist/TabNavList/TabNode.vue_vue_type_script_setup_true_lang.cjs +129 -0
- package/dist/TabNavList/TabNode.vue_vue_type_script_setup_true_lang.js +127 -0
- package/dist/TabNavList/Wrapper.cjs +4 -0
- package/dist/TabNavList/Wrapper.js +3 -0
- package/dist/TabNavList/Wrapper.vue_vue_type_script_setup_true_lang.cjs +54 -0
- package/dist/TabNavList/Wrapper.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/TabNavList/index.cjs +4 -0
- package/dist/TabNavList/index.js +3 -0
- package/dist/TabNavList/index.vue_vue_type_script_setup_true_lang.cjs +516 -0
- package/dist/TabNavList/index.vue_vue_type_script_setup_true_lang.js +513 -0
- package/dist/TabPanelList/TabPane.cjs +4 -0
- package/dist/TabPanelList/TabPane.js +3 -0
- package/dist/TabPanelList/TabPane.vue_vue_type_script_setup_true_lang.cjs +85 -0
- package/dist/TabPanelList/TabPane.vue_vue_type_script_setup_true_lang.js +83 -0
- package/dist/TabPanelList/index.cjs +4 -0
- package/dist/TabPanelList/index.js +3 -0
- package/dist/TabPanelList/index.vue_vue_type_script_setup_true_lang.cjs +105 -0
- package/dist/TabPanelList/index.vue_vue_type_script_setup_true_lang.js +103 -0
- package/dist/Tabs.cjs +4 -0
- package/dist/Tabs.js +3 -0
- package/dist/Tabs.vue_vue_type_script_setup_true_lang.cjs +194 -0
- package/dist/Tabs.vue_vue_type_script_setup_true_lang.js +190 -0
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/hooks/useAnimateConfig.cjs +28 -0
- package/dist/hooks/useAnimateConfig.d.ts +2 -0
- package/dist/hooks/useAnimateConfig.js +26 -0
- package/dist/hooks/useIndicator.cjs +68 -0
- package/dist/hooks/useIndicator.d.ts +11 -0
- package/dist/hooks/useIndicator.js +65 -0
- package/dist/hooks/useOffsets.cjs +39 -0
- package/dist/hooks/useOffsets.d.ts +18 -0
- package/dist/hooks/useOffsets.js +37 -0
- package/dist/hooks/useTouchMove.cjs +119 -0
- package/dist/hooks/useTouchMove.d.ts +2 -0
- package/dist/hooks/useTouchMove.js +117 -0
- package/dist/hooks/useVisibleRange.cjs +51 -0
- package/dist/hooks/useVisibleRange.d.ts +17 -0
- package/dist/hooks/useVisibleRange.js +49 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/dist/interface.cjs +0 -0
- package/dist/interface.d.ts +195 -0
- package/dist/interface.js +0 -0
- package/dist/utils.cjs +33 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.js +27 -0
- package/package.json +44 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
2
|
+
const require_TabContext = require("../TabContext.cjs");
|
|
3
|
+
const require_TabPane = require("./TabPane.cjs");
|
|
4
|
+
let vue = require("vue");
|
|
5
|
+
let __v_c_util_dist_RenderComponent = require("@v-c/util/dist/RenderComponent");
|
|
6
|
+
__v_c_util_dist_RenderComponent = require_rolldown_runtime.__toESM(__v_c_util_dist_RenderComponent);
|
|
7
|
+
let __v_c_util_dist_utils_transition = require("@v-c/util/dist/utils/transition");
|
|
8
|
+
var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
9
|
+
__name: "index",
|
|
10
|
+
props: {
|
|
11
|
+
activeKey: {},
|
|
12
|
+
id: {},
|
|
13
|
+
animated: {},
|
|
14
|
+
tabPosition: {},
|
|
15
|
+
destroyOnHidden: { type: Boolean },
|
|
16
|
+
contentStyle: {},
|
|
17
|
+
contentClassName: {}
|
|
18
|
+
},
|
|
19
|
+
setup(__props) {
|
|
20
|
+
const { id, activeKey, animated, tabPosition, destroyOnHidden, contentStyle, contentClassName } = (0, vue.toRefs)(__props);
|
|
21
|
+
const ctx = require_TabContext.useTabContext();
|
|
22
|
+
const tabs = (0, vue.computed)(() => ctx?.value.tabs || []);
|
|
23
|
+
const prefixCls = (0, vue.computed)(() => ctx?.value.prefixCls || "");
|
|
24
|
+
const tabPaneAnimated = (0, vue.computed)(() => animated.value?.tabPane === true);
|
|
25
|
+
const tabPanePrefixCls = (0, vue.computed)(() => `${prefixCls.value}-tabpane`);
|
|
26
|
+
const transitionProps = (0, vue.computed)(() => {
|
|
27
|
+
if (!tabPaneAnimated.value) return {};
|
|
28
|
+
if (animated.value?.tabPaneMotion) return animated.value.tabPaneMotion;
|
|
29
|
+
return (0, __v_c_util_dist_utils_transition.getTransitionProps)(tabPanePrefixCls.value);
|
|
30
|
+
});
|
|
31
|
+
function shouldDestroyOnHidden(item) {
|
|
32
|
+
return !!(!item.forceRender && (destroyOnHidden.value ?? item.destroyOnHidden) === true);
|
|
33
|
+
}
|
|
34
|
+
return (_ctx, _cache) => {
|
|
35
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", { class: (0, vue.normalizeClass)([`${prefixCls.value}-content-holder`]) }, [(0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)([
|
|
36
|
+
`${prefixCls.value}-content`,
|
|
37
|
+
`${prefixCls.value}-content-${(0, vue.unref)(tabPosition)}`,
|
|
38
|
+
{ [`${prefixCls.value}-content-animated`]: tabPaneAnimated.value }
|
|
39
|
+
]) }, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(tabs.value, (item) => {
|
|
40
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: item.key }, [tabPaneAnimated.value ? ((0, vue.openBlock)(), (0, vue.createBlock)(vue.Transition, (0, vue.mergeProps)({
|
|
41
|
+
key: 0,
|
|
42
|
+
ref_for: true
|
|
43
|
+
}, transitionProps.value), {
|
|
44
|
+
default: (0, vue.withCtx)(() => [(shouldDestroyOnHidden(item) ? item.key === (0, vue.unref)(activeKey) : true) ? (0, vue.withDirectives)(((0, vue.openBlock)(), (0, vue.createBlock)(require_TabPane.default, {
|
|
45
|
+
key: 0,
|
|
46
|
+
id: (0, vue.unref)(id),
|
|
47
|
+
"prefix-cls": tabPanePrefixCls.value,
|
|
48
|
+
"tab-key": item.key,
|
|
49
|
+
animated: tabPaneAnimated.value,
|
|
50
|
+
active: item.key === (0, vue.unref)(activeKey),
|
|
51
|
+
style: (0, vue.normalizeStyle)({
|
|
52
|
+
...(0, vue.unref)(contentStyle) || {},
|
|
53
|
+
...item.style || {}
|
|
54
|
+
}),
|
|
55
|
+
"class-name": [
|
|
56
|
+
(0, vue.unref)(contentClassName),
|
|
57
|
+
item.className,
|
|
58
|
+
item.key !== (0, vue.unref)(activeKey) && `${tabPanePrefixCls.value}-hidden`
|
|
59
|
+
]
|
|
60
|
+
}, {
|
|
61
|
+
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(__v_c_util_dist_RenderComponent.default), { render: item.children }, null, 8, ["render"])]),
|
|
62
|
+
_: 2
|
|
63
|
+
}, 1032, [
|
|
64
|
+
"id",
|
|
65
|
+
"prefix-cls",
|
|
66
|
+
"tab-key",
|
|
67
|
+
"animated",
|
|
68
|
+
"active",
|
|
69
|
+
"style",
|
|
70
|
+
"class-name"
|
|
71
|
+
])), [[vue.vShow, shouldDestroyOnHidden(item) ? true : item.key === (0, vue.unref)(activeKey) || item.forceRender]]) : (0, vue.createCommentVNode)("", true)]),
|
|
72
|
+
_: 2
|
|
73
|
+
}, 1040)) : (0, vue.createCommentVNode)("", true), !tabPaneAnimated.value && (shouldDestroyOnHidden(item) ? item.key === (0, vue.unref)(activeKey) : true) ? (0, vue.withDirectives)(((0, vue.openBlock)(), (0, vue.createBlock)(require_TabPane.default, {
|
|
74
|
+
key: 1,
|
|
75
|
+
id: (0, vue.unref)(id),
|
|
76
|
+
"prefix-cls": tabPanePrefixCls.value,
|
|
77
|
+
"tab-key": item.key,
|
|
78
|
+
animated: tabPaneAnimated.value,
|
|
79
|
+
active: item.key === (0, vue.unref)(activeKey),
|
|
80
|
+
style: (0, vue.normalizeStyle)({
|
|
81
|
+
...(0, vue.unref)(contentStyle) || {},
|
|
82
|
+
...item.style || {}
|
|
83
|
+
}),
|
|
84
|
+
"class-name": [
|
|
85
|
+
(0, vue.unref)(contentClassName),
|
|
86
|
+
item.className,
|
|
87
|
+
item.key !== (0, vue.unref)(activeKey) && `${tabPanePrefixCls.value}-hidden`
|
|
88
|
+
]
|
|
89
|
+
}, {
|
|
90
|
+
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(__v_c_util_dist_RenderComponent.default), { render: item.children }, null, 8, ["render"])]),
|
|
91
|
+
_: 2
|
|
92
|
+
}, 1032, [
|
|
93
|
+
"id",
|
|
94
|
+
"prefix-cls",
|
|
95
|
+
"tab-key",
|
|
96
|
+
"animated",
|
|
97
|
+
"active",
|
|
98
|
+
"style",
|
|
99
|
+
"class-name"
|
|
100
|
+
])), [[vue.vShow, shouldDestroyOnHidden(item) ? true : item.key === (0, vue.unref)(activeKey) || item.forceRender]]) : (0, vue.createCommentVNode)("", true)], 64);
|
|
101
|
+
}), 128))], 2)], 2);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
exports.default = index_vue_vue_type_script_setup_true_lang_default;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useTabContext } from "../TabContext.js";
|
|
2
|
+
import TabPane_default from "./TabPane.js";
|
|
3
|
+
import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeProps, normalizeClass, normalizeStyle, openBlock, renderList, toRefs, unref, vShow, withCtx, withDirectives } from "vue";
|
|
4
|
+
import RenderComponent from "@v-c/util/dist/RenderComponent";
|
|
5
|
+
import { getTransitionProps } from "@v-c/util/dist/utils/transition";
|
|
6
|
+
var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
7
|
+
__name: "index",
|
|
8
|
+
props: {
|
|
9
|
+
activeKey: {},
|
|
10
|
+
id: {},
|
|
11
|
+
animated: {},
|
|
12
|
+
tabPosition: {},
|
|
13
|
+
destroyOnHidden: { type: Boolean },
|
|
14
|
+
contentStyle: {},
|
|
15
|
+
contentClassName: {}
|
|
16
|
+
},
|
|
17
|
+
setup(__props) {
|
|
18
|
+
const { id, activeKey, animated, tabPosition, destroyOnHidden, contentStyle, contentClassName } = toRefs(__props);
|
|
19
|
+
const ctx = useTabContext();
|
|
20
|
+
const tabs = computed(() => ctx?.value.tabs || []);
|
|
21
|
+
const prefixCls = computed(() => ctx?.value.prefixCls || "");
|
|
22
|
+
const tabPaneAnimated = computed(() => animated.value?.tabPane === true);
|
|
23
|
+
const tabPanePrefixCls = computed(() => `${prefixCls.value}-tabpane`);
|
|
24
|
+
const transitionProps = computed(() => {
|
|
25
|
+
if (!tabPaneAnimated.value) return {};
|
|
26
|
+
if (animated.value?.tabPaneMotion) return animated.value.tabPaneMotion;
|
|
27
|
+
return getTransitionProps(tabPanePrefixCls.value);
|
|
28
|
+
});
|
|
29
|
+
function shouldDestroyOnHidden(item) {
|
|
30
|
+
return !!(!item.forceRender && (destroyOnHidden.value ?? item.destroyOnHidden) === true);
|
|
31
|
+
}
|
|
32
|
+
return (_ctx, _cache) => {
|
|
33
|
+
return openBlock(), createElementBlock("div", { class: normalizeClass([`${prefixCls.value}-content-holder`]) }, [createElementVNode("div", { class: normalizeClass([
|
|
34
|
+
`${prefixCls.value}-content`,
|
|
35
|
+
`${prefixCls.value}-content-${unref(tabPosition)}`,
|
|
36
|
+
{ [`${prefixCls.value}-content-animated`]: tabPaneAnimated.value }
|
|
37
|
+
]) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(tabs.value, (item) => {
|
|
38
|
+
return openBlock(), createElementBlock(Fragment, { key: item.key }, [tabPaneAnimated.value ? (openBlock(), createBlock(Transition, mergeProps({
|
|
39
|
+
key: 0,
|
|
40
|
+
ref_for: true
|
|
41
|
+
}, transitionProps.value), {
|
|
42
|
+
default: withCtx(() => [(shouldDestroyOnHidden(item) ? item.key === unref(activeKey) : true) ? withDirectives((openBlock(), createBlock(TabPane_default, {
|
|
43
|
+
key: 0,
|
|
44
|
+
id: unref(id),
|
|
45
|
+
"prefix-cls": tabPanePrefixCls.value,
|
|
46
|
+
"tab-key": item.key,
|
|
47
|
+
animated: tabPaneAnimated.value,
|
|
48
|
+
active: item.key === unref(activeKey),
|
|
49
|
+
style: normalizeStyle({
|
|
50
|
+
...unref(contentStyle) || {},
|
|
51
|
+
...item.style || {}
|
|
52
|
+
}),
|
|
53
|
+
"class-name": [
|
|
54
|
+
unref(contentClassName),
|
|
55
|
+
item.className,
|
|
56
|
+
item.key !== unref(activeKey) && `${tabPanePrefixCls.value}-hidden`
|
|
57
|
+
]
|
|
58
|
+
}, {
|
|
59
|
+
default: withCtx(() => [createVNode(unref(RenderComponent), { render: item.children }, null, 8, ["render"])]),
|
|
60
|
+
_: 2
|
|
61
|
+
}, 1032, [
|
|
62
|
+
"id",
|
|
63
|
+
"prefix-cls",
|
|
64
|
+
"tab-key",
|
|
65
|
+
"animated",
|
|
66
|
+
"active",
|
|
67
|
+
"style",
|
|
68
|
+
"class-name"
|
|
69
|
+
])), [[vShow, shouldDestroyOnHidden(item) ? true : item.key === unref(activeKey) || item.forceRender]]) : createCommentVNode("", true)]),
|
|
70
|
+
_: 2
|
|
71
|
+
}, 1040)) : createCommentVNode("", true), !tabPaneAnimated.value && (shouldDestroyOnHidden(item) ? item.key === unref(activeKey) : true) ? withDirectives((openBlock(), createBlock(TabPane_default, {
|
|
72
|
+
key: 1,
|
|
73
|
+
id: unref(id),
|
|
74
|
+
"prefix-cls": tabPanePrefixCls.value,
|
|
75
|
+
"tab-key": item.key,
|
|
76
|
+
animated: tabPaneAnimated.value,
|
|
77
|
+
active: item.key === unref(activeKey),
|
|
78
|
+
style: normalizeStyle({
|
|
79
|
+
...unref(contentStyle) || {},
|
|
80
|
+
...item.style || {}
|
|
81
|
+
}),
|
|
82
|
+
"class-name": [
|
|
83
|
+
unref(contentClassName),
|
|
84
|
+
item.className,
|
|
85
|
+
item.key !== unref(activeKey) && `${tabPanePrefixCls.value}-hidden`
|
|
86
|
+
]
|
|
87
|
+
}, {
|
|
88
|
+
default: withCtx(() => [createVNode(unref(RenderComponent), { render: item.children }, null, 8, ["render"])]),
|
|
89
|
+
_: 2
|
|
90
|
+
}, 1032, [
|
|
91
|
+
"id",
|
|
92
|
+
"prefix-cls",
|
|
93
|
+
"tab-key",
|
|
94
|
+
"animated",
|
|
95
|
+
"active",
|
|
96
|
+
"style",
|
|
97
|
+
"class-name"
|
|
98
|
+
])), [[vShow, shouldDestroyOnHidden(item) ? true : item.key === unref(activeKey) || item.forceRender]]) : createCommentVNode("", true)], 64);
|
|
99
|
+
}), 128))], 2)], 2);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
export { index_vue_vue_type_script_setup_true_lang_default as default };
|
package/dist/Tabs.cjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const require_Tabs_vue_vue_type_script_setup_true_lang = require("./Tabs.vue_vue_type_script_setup_true_lang.cjs");
|
|
3
|
+
var Tabs_default = require_Tabs_vue_vue_type_script_setup_true_lang.default;
|
|
4
|
+
exports.default = Tabs_default;
|
package/dist/Tabs.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
2
|
+
const require_TabContext = require("./TabContext.cjs");
|
|
3
|
+
const require_useAnimateConfig = require("./hooks/useAnimateConfig.cjs");
|
|
4
|
+
const require_utils = require("./utils.cjs");
|
|
5
|
+
const require_Wrapper = require("./TabNavList/Wrapper.cjs");
|
|
6
|
+
const require_index = require("./TabPanelList/index.cjs");
|
|
7
|
+
let vue = require("vue");
|
|
8
|
+
let __v_c_util = require("@v-c/util");
|
|
9
|
+
let __v_c_util_dist_hooks_useMergedState = require("@v-c/util/dist/hooks/useMergedState");
|
|
10
|
+
__v_c_util_dist_hooks_useMergedState = require_rolldown_runtime.__toESM(__v_c_util_dist_hooks_useMergedState);
|
|
11
|
+
let __v_c_util_dist_isMobile = require("@v-c/util/dist/isMobile");
|
|
12
|
+
__v_c_util_dist_isMobile = require_rolldown_runtime.__toESM(__v_c_util_dist_isMobile);
|
|
13
|
+
let __v_c_util_dist_omit = require("@v-c/util/dist/omit");
|
|
14
|
+
__v_c_util_dist_omit = require_rolldown_runtime.__toESM(__v_c_util_dist_omit);
|
|
15
|
+
var _hoisted_1 = ["id"];
|
|
16
|
+
var Tabs_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
17
|
+
name: "Tabs",
|
|
18
|
+
inheritAttrs: false,
|
|
19
|
+
__name: "Tabs",
|
|
20
|
+
props: {
|
|
21
|
+
prefixCls: { default: "vc-tabs" },
|
|
22
|
+
className: {},
|
|
23
|
+
style: {},
|
|
24
|
+
classNames: {},
|
|
25
|
+
styles: {},
|
|
26
|
+
id: {},
|
|
27
|
+
items: {},
|
|
28
|
+
activeKey: {},
|
|
29
|
+
defaultActiveKey: {},
|
|
30
|
+
direction: {},
|
|
31
|
+
animated: {
|
|
32
|
+
type: [Boolean, Object],
|
|
33
|
+
default: void 0
|
|
34
|
+
},
|
|
35
|
+
renderTabBar: {},
|
|
36
|
+
tabBarExtraContent: { type: [
|
|
37
|
+
Object,
|
|
38
|
+
String,
|
|
39
|
+
Number,
|
|
40
|
+
null,
|
|
41
|
+
Boolean,
|
|
42
|
+
Array
|
|
43
|
+
] },
|
|
44
|
+
tabBarGutter: {},
|
|
45
|
+
tabBarStyle: {},
|
|
46
|
+
tabPosition: { default: "top" },
|
|
47
|
+
destroyOnHidden: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: void 0
|
|
50
|
+
},
|
|
51
|
+
onChange: {},
|
|
52
|
+
onTabClick: {},
|
|
53
|
+
onTabScroll: {},
|
|
54
|
+
editable: {},
|
|
55
|
+
getPopupContainer: {},
|
|
56
|
+
locale: {},
|
|
57
|
+
more: {},
|
|
58
|
+
popupClassName: {},
|
|
59
|
+
indicator: {}
|
|
60
|
+
},
|
|
61
|
+
setup(__props) {
|
|
62
|
+
const props = __props;
|
|
63
|
+
const { id, items, direction, defaultActiveKey, tabPosition, editable, locale, tabBarGutter, more, animated, styles, prefixCls, className, activeKey, tabBarStyle, tabBarExtraContent, destroyOnHidden, renderTabBar, onChange, onTabClick, onTabScroll, getPopupContainer, popupClassName, indicator, classNames: tabsClassNames } = (0, vue.toRefs)(props);
|
|
64
|
+
const restProps = (0, vue.computed)(() => {
|
|
65
|
+
return (0, __v_c_util_dist_omit.default)(props, [
|
|
66
|
+
"id",
|
|
67
|
+
"prefixCls",
|
|
68
|
+
"className",
|
|
69
|
+
"items",
|
|
70
|
+
"direction",
|
|
71
|
+
"activeKey",
|
|
72
|
+
"defaultActiveKey",
|
|
73
|
+
"editable",
|
|
74
|
+
"animated",
|
|
75
|
+
"tabPosition",
|
|
76
|
+
"tabBarGutter",
|
|
77
|
+
"tabBarStyle",
|
|
78
|
+
"tabBarExtraContent",
|
|
79
|
+
"locale",
|
|
80
|
+
"more",
|
|
81
|
+
"destroyOnHidden",
|
|
82
|
+
"renderTabBar",
|
|
83
|
+
"onChange",
|
|
84
|
+
"onTabClick",
|
|
85
|
+
"onTabScroll",
|
|
86
|
+
"getPopupContainer",
|
|
87
|
+
"popupClassName",
|
|
88
|
+
"indicator",
|
|
89
|
+
"classNames",
|
|
90
|
+
"styles"
|
|
91
|
+
]);
|
|
92
|
+
});
|
|
93
|
+
const tabs = (0, vue.computed)(() => (items.value || []).filter((item) => item && typeof item === "object" && "key" in item));
|
|
94
|
+
const rtl = (0, vue.computed)(() => direction.value === "rtl");
|
|
95
|
+
const mergedAnimated = (0, vue.computed)(() => require_useAnimateConfig.default(animated.value));
|
|
96
|
+
const mobile = (0, vue.ref)(false);
|
|
97
|
+
(0, vue.onMounted)(() => {
|
|
98
|
+
mobile.value = (0, __v_c_util_dist_isMobile.default)();
|
|
99
|
+
});
|
|
100
|
+
const defaultKey = (0, vue.computed)(() => defaultActiveKey.value ?? tabs.value[0]?.key);
|
|
101
|
+
const [mergedActiveKey, setMergedActiveKey] = (0, __v_c_util_dist_hooks_useMergedState.default)("", {
|
|
102
|
+
defaultValue: activeKey.value ?? defaultKey.value,
|
|
103
|
+
value: activeKey
|
|
104
|
+
});
|
|
105
|
+
const activeIndex = (0, vue.ref)(tabs.value.findIndex((item) => item.key === mergedActiveKey.value));
|
|
106
|
+
(0, vue.watch)([
|
|
107
|
+
(0, vue.computed)(() => tabs.value.map((tab) => tab.key).join("_")),
|
|
108
|
+
mergedActiveKey,
|
|
109
|
+
activeIndex
|
|
110
|
+
], async () => {
|
|
111
|
+
await (0, vue.nextTick)();
|
|
112
|
+
activeIndex.value = tabs.value.findIndex((item) => item.key === mergedActiveKey.value);
|
|
113
|
+
let newActiveIndex = tabs.value.findIndex((tab) => tab.key === mergedActiveKey.value);
|
|
114
|
+
if (newActiveIndex === -1) {
|
|
115
|
+
newActiveIndex = Math.max(0, Math.min(activeIndex.value, tabs.value.length - 1));
|
|
116
|
+
setMergedActiveKey(tabs.value[newActiveIndex]?.key);
|
|
117
|
+
}
|
|
118
|
+
activeIndex.value = newActiveIndex;
|
|
119
|
+
}, { immediate: true });
|
|
120
|
+
const [mergedId, setMergedId] = (0, __v_c_util_dist_hooks_useMergedState.default)(null, { value: id.value });
|
|
121
|
+
(0, vue.onMounted)(() => {
|
|
122
|
+
const uuid = require_utils.getUUid();
|
|
123
|
+
setMergedId(`vc-tabs-${process.env.NODE_ENV === "test" ? "test" : uuid}`);
|
|
124
|
+
require_utils.setUUid(uuid + 1);
|
|
125
|
+
});
|
|
126
|
+
function onInternalTabClick(key, e) {
|
|
127
|
+
onTabClick.value?.(key, e);
|
|
128
|
+
const isActiveChanged = key !== mergedActiveKey.value;
|
|
129
|
+
setMergedActiveKey(key);
|
|
130
|
+
if (isActiveChanged) onChange.value?.(key);
|
|
131
|
+
}
|
|
132
|
+
const sharedProps = (0, vue.computed)(() => ({
|
|
133
|
+
id: mergedId.value,
|
|
134
|
+
activeKey: mergedActiveKey.value,
|
|
135
|
+
animated: mergedAnimated.value,
|
|
136
|
+
tabPosition: tabPosition.value,
|
|
137
|
+
rtl: rtl.value,
|
|
138
|
+
mobile: mobile.value
|
|
139
|
+
}));
|
|
140
|
+
const tabNavBarProps = (0, vue.computed)(() => {
|
|
141
|
+
return {
|
|
142
|
+
...sharedProps.value,
|
|
143
|
+
editable: editable.value,
|
|
144
|
+
locale: locale.value,
|
|
145
|
+
more: more.value,
|
|
146
|
+
tabBarGutter: tabBarGutter.value,
|
|
147
|
+
onTabClick: onInternalTabClick,
|
|
148
|
+
onTabScroll: onTabScroll.value,
|
|
149
|
+
extra: tabBarExtraContent.value,
|
|
150
|
+
style: tabBarStyle.value,
|
|
151
|
+
getPopupContainer: getPopupContainer.value,
|
|
152
|
+
popupClassName: (0, __v_c_util.clsx)([popupClassName.value, tabsClassNames.value?.popup]),
|
|
153
|
+
indicator: indicator.value,
|
|
154
|
+
styles: styles.value,
|
|
155
|
+
classNames: tabsClassNames.value
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
const memoizedValue = (0, vue.computed)(() => {
|
|
159
|
+
return {
|
|
160
|
+
tabs: tabs.value,
|
|
161
|
+
prefixCls: prefixCls.value
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
const tabRef = (0, vue.ref)();
|
|
165
|
+
require_TabContext.provideTabContext(memoizedValue);
|
|
166
|
+
return (_ctx, _cache) => {
|
|
167
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", (0, vue.mergeProps)({
|
|
168
|
+
id: (0, vue.unref)(id),
|
|
169
|
+
ref_key: "tabRef",
|
|
170
|
+
ref: tabRef,
|
|
171
|
+
class: [
|
|
172
|
+
(0, vue.unref)(prefixCls),
|
|
173
|
+
`${(0, vue.unref)(prefixCls)}-${(0, vue.unref)(tabPosition)}`,
|
|
174
|
+
{
|
|
175
|
+
[`${(0, vue.unref)(prefixCls)}-mobile`]: mobile.value,
|
|
176
|
+
[`${(0, vue.unref)(prefixCls)}-editable`]: (0, vue.unref)(editable),
|
|
177
|
+
[`${(0, vue.unref)(prefixCls)}-rtl`]: rtl.value
|
|
178
|
+
},
|
|
179
|
+
(0, vue.unref)(className)
|
|
180
|
+
]
|
|
181
|
+
}, restProps.value), [(0, vue.createVNode)(require_Wrapper.default, (0, vue.mergeProps)(tabNavBarProps.value, { "render-tab-bar": (0, vue.unref)(renderTabBar) }), null, 16, ["render-tab-bar"]), (0, vue.createVNode)(require_index.default, (0, vue.mergeProps)({ "destroy-on-hidden": (0, vue.unref)(destroyOnHidden) }, sharedProps.value, {
|
|
182
|
+
"content-style": (0, vue.unref)(styles)?.content,
|
|
183
|
+
"content-class-name": (0, vue.unref)(tabsClassNames)?.content,
|
|
184
|
+
animated: mergedAnimated.value
|
|
185
|
+
}), null, 16, [
|
|
186
|
+
"destroy-on-hidden",
|
|
187
|
+
"content-style",
|
|
188
|
+
"content-class-name",
|
|
189
|
+
"animated"
|
|
190
|
+
])], 16, _hoisted_1);
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
exports.default = Tabs_vue_vue_type_script_setup_true_lang_default;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { provideTabContext } from "./TabContext.js";
|
|
2
|
+
import useAnimateConfig from "./hooks/useAnimateConfig.js";
|
|
3
|
+
import { getUUid, setUUid } from "./utils.js";
|
|
4
|
+
import Wrapper_default from "./TabNavList/Wrapper.js";
|
|
5
|
+
import TabPanelList_default from "./TabPanelList/index.js";
|
|
6
|
+
import { computed, createElementBlock, createVNode, defineComponent, mergeProps, nextTick, onMounted, openBlock, ref, toRefs, unref, watch } from "vue";
|
|
7
|
+
import { clsx } from "@v-c/util";
|
|
8
|
+
import useMergedState from "@v-c/util/dist/hooks/useMergedState";
|
|
9
|
+
import isMobile from "@v-c/util/dist/isMobile";
|
|
10
|
+
import omit from "@v-c/util/dist/omit";
|
|
11
|
+
var _hoisted_1 = ["id"];
|
|
12
|
+
var Tabs_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
13
|
+
name: "Tabs",
|
|
14
|
+
inheritAttrs: false,
|
|
15
|
+
__name: "Tabs",
|
|
16
|
+
props: {
|
|
17
|
+
prefixCls: { default: "vc-tabs" },
|
|
18
|
+
className: {},
|
|
19
|
+
style: {},
|
|
20
|
+
classNames: {},
|
|
21
|
+
styles: {},
|
|
22
|
+
id: {},
|
|
23
|
+
items: {},
|
|
24
|
+
activeKey: {},
|
|
25
|
+
defaultActiveKey: {},
|
|
26
|
+
direction: {},
|
|
27
|
+
animated: {
|
|
28
|
+
type: [Boolean, Object],
|
|
29
|
+
default: void 0
|
|
30
|
+
},
|
|
31
|
+
renderTabBar: {},
|
|
32
|
+
tabBarExtraContent: { type: [
|
|
33
|
+
Object,
|
|
34
|
+
String,
|
|
35
|
+
Number,
|
|
36
|
+
null,
|
|
37
|
+
Boolean,
|
|
38
|
+
Array
|
|
39
|
+
] },
|
|
40
|
+
tabBarGutter: {},
|
|
41
|
+
tabBarStyle: {},
|
|
42
|
+
tabPosition: { default: "top" },
|
|
43
|
+
destroyOnHidden: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: void 0
|
|
46
|
+
},
|
|
47
|
+
onChange: {},
|
|
48
|
+
onTabClick: {},
|
|
49
|
+
onTabScroll: {},
|
|
50
|
+
editable: {},
|
|
51
|
+
getPopupContainer: {},
|
|
52
|
+
locale: {},
|
|
53
|
+
more: {},
|
|
54
|
+
popupClassName: {},
|
|
55
|
+
indicator: {}
|
|
56
|
+
},
|
|
57
|
+
setup(__props) {
|
|
58
|
+
const props = __props;
|
|
59
|
+
const { id, items, direction, defaultActiveKey, tabPosition, editable, locale, tabBarGutter, more, animated, styles, prefixCls, className, activeKey, tabBarStyle, tabBarExtraContent, destroyOnHidden, renderTabBar, onChange, onTabClick, onTabScroll, getPopupContainer, popupClassName, indicator, classNames: tabsClassNames } = toRefs(props);
|
|
60
|
+
const restProps = computed(() => {
|
|
61
|
+
return omit(props, [
|
|
62
|
+
"id",
|
|
63
|
+
"prefixCls",
|
|
64
|
+
"className",
|
|
65
|
+
"items",
|
|
66
|
+
"direction",
|
|
67
|
+
"activeKey",
|
|
68
|
+
"defaultActiveKey",
|
|
69
|
+
"editable",
|
|
70
|
+
"animated",
|
|
71
|
+
"tabPosition",
|
|
72
|
+
"tabBarGutter",
|
|
73
|
+
"tabBarStyle",
|
|
74
|
+
"tabBarExtraContent",
|
|
75
|
+
"locale",
|
|
76
|
+
"more",
|
|
77
|
+
"destroyOnHidden",
|
|
78
|
+
"renderTabBar",
|
|
79
|
+
"onChange",
|
|
80
|
+
"onTabClick",
|
|
81
|
+
"onTabScroll",
|
|
82
|
+
"getPopupContainer",
|
|
83
|
+
"popupClassName",
|
|
84
|
+
"indicator",
|
|
85
|
+
"classNames",
|
|
86
|
+
"styles"
|
|
87
|
+
]);
|
|
88
|
+
});
|
|
89
|
+
const tabs = computed(() => (items.value || []).filter((item) => item && typeof item === "object" && "key" in item));
|
|
90
|
+
const rtl = computed(() => direction.value === "rtl");
|
|
91
|
+
const mergedAnimated = computed(() => useAnimateConfig(animated.value));
|
|
92
|
+
const mobile = ref(false);
|
|
93
|
+
onMounted(() => {
|
|
94
|
+
mobile.value = isMobile();
|
|
95
|
+
});
|
|
96
|
+
const defaultKey = computed(() => defaultActiveKey.value ?? tabs.value[0]?.key);
|
|
97
|
+
const [mergedActiveKey, setMergedActiveKey] = useMergedState("", {
|
|
98
|
+
defaultValue: activeKey.value ?? defaultKey.value,
|
|
99
|
+
value: activeKey
|
|
100
|
+
});
|
|
101
|
+
const activeIndex = ref(tabs.value.findIndex((item) => item.key === mergedActiveKey.value));
|
|
102
|
+
watch([
|
|
103
|
+
computed(() => tabs.value.map((tab) => tab.key).join("_")),
|
|
104
|
+
mergedActiveKey,
|
|
105
|
+
activeIndex
|
|
106
|
+
], async () => {
|
|
107
|
+
await nextTick();
|
|
108
|
+
activeIndex.value = tabs.value.findIndex((item) => item.key === mergedActiveKey.value);
|
|
109
|
+
let newActiveIndex = tabs.value.findIndex((tab) => tab.key === mergedActiveKey.value);
|
|
110
|
+
if (newActiveIndex === -1) {
|
|
111
|
+
newActiveIndex = Math.max(0, Math.min(activeIndex.value, tabs.value.length - 1));
|
|
112
|
+
setMergedActiveKey(tabs.value[newActiveIndex]?.key);
|
|
113
|
+
}
|
|
114
|
+
activeIndex.value = newActiveIndex;
|
|
115
|
+
}, { immediate: true });
|
|
116
|
+
const [mergedId, setMergedId] = useMergedState(null, { value: id.value });
|
|
117
|
+
onMounted(() => {
|
|
118
|
+
const uuid = getUUid();
|
|
119
|
+
setMergedId(`vc-tabs-${process.env.NODE_ENV === "test" ? "test" : uuid}`);
|
|
120
|
+
setUUid(uuid + 1);
|
|
121
|
+
});
|
|
122
|
+
function onInternalTabClick(key, e) {
|
|
123
|
+
onTabClick.value?.(key, e);
|
|
124
|
+
const isActiveChanged = key !== mergedActiveKey.value;
|
|
125
|
+
setMergedActiveKey(key);
|
|
126
|
+
if (isActiveChanged) onChange.value?.(key);
|
|
127
|
+
}
|
|
128
|
+
const sharedProps = computed(() => ({
|
|
129
|
+
id: mergedId.value,
|
|
130
|
+
activeKey: mergedActiveKey.value,
|
|
131
|
+
animated: mergedAnimated.value,
|
|
132
|
+
tabPosition: tabPosition.value,
|
|
133
|
+
rtl: rtl.value,
|
|
134
|
+
mobile: mobile.value
|
|
135
|
+
}));
|
|
136
|
+
const tabNavBarProps = computed(() => {
|
|
137
|
+
return {
|
|
138
|
+
...sharedProps.value,
|
|
139
|
+
editable: editable.value,
|
|
140
|
+
locale: locale.value,
|
|
141
|
+
more: more.value,
|
|
142
|
+
tabBarGutter: tabBarGutter.value,
|
|
143
|
+
onTabClick: onInternalTabClick,
|
|
144
|
+
onTabScroll: onTabScroll.value,
|
|
145
|
+
extra: tabBarExtraContent.value,
|
|
146
|
+
style: tabBarStyle.value,
|
|
147
|
+
getPopupContainer: getPopupContainer.value,
|
|
148
|
+
popupClassName: clsx([popupClassName.value, tabsClassNames.value?.popup]),
|
|
149
|
+
indicator: indicator.value,
|
|
150
|
+
styles: styles.value,
|
|
151
|
+
classNames: tabsClassNames.value
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
const memoizedValue = computed(() => {
|
|
155
|
+
return {
|
|
156
|
+
tabs: tabs.value,
|
|
157
|
+
prefixCls: prefixCls.value
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
const tabRef = ref();
|
|
161
|
+
provideTabContext(memoizedValue);
|
|
162
|
+
return (_ctx, _cache) => {
|
|
163
|
+
return openBlock(), createElementBlock("div", mergeProps({
|
|
164
|
+
id: unref(id),
|
|
165
|
+
ref_key: "tabRef",
|
|
166
|
+
ref: tabRef,
|
|
167
|
+
class: [
|
|
168
|
+
unref(prefixCls),
|
|
169
|
+
`${unref(prefixCls)}-${unref(tabPosition)}`,
|
|
170
|
+
{
|
|
171
|
+
[`${unref(prefixCls)}-mobile`]: mobile.value,
|
|
172
|
+
[`${unref(prefixCls)}-editable`]: unref(editable),
|
|
173
|
+
[`${unref(prefixCls)}-rtl`]: rtl.value
|
|
174
|
+
},
|
|
175
|
+
unref(className)
|
|
176
|
+
]
|
|
177
|
+
}, restProps.value), [createVNode(Wrapper_default, mergeProps(tabNavBarProps.value, { "render-tab-bar": unref(renderTabBar) }), null, 16, ["render-tab-bar"]), createVNode(TabPanelList_default, mergeProps({ "destroy-on-hidden": unref(destroyOnHidden) }, sharedProps.value, {
|
|
178
|
+
"content-style": unref(styles)?.content,
|
|
179
|
+
"content-class-name": unref(tabsClassNames)?.content,
|
|
180
|
+
animated: mergedAnimated.value
|
|
181
|
+
}), null, 16, [
|
|
182
|
+
"destroy-on-hidden",
|
|
183
|
+
"content-style",
|
|
184
|
+
"content-class-name",
|
|
185
|
+
"animated"
|
|
186
|
+
])], 16, _hoisted_1);
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
export { Tabs_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
9
|
+
key = keys[i];
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: ((k) => from[k]).bind(null, key),
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
+
value: mod,
|
|
19
|
+
enumerable: true
|
|
20
|
+
}) : target, mod));
|
|
21
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
|
+
let __v_c_util_dist_warning = require("@v-c/util/dist/warning");
|
|
4
|
+
function useAnimateConfig(animated = {
|
|
5
|
+
inkBar: true,
|
|
6
|
+
tabPane: false
|
|
7
|
+
}) {
|
|
8
|
+
let mergedAnimated;
|
|
9
|
+
if (animated === false) mergedAnimated = {
|
|
10
|
+
inkBar: false,
|
|
11
|
+
tabPane: false
|
|
12
|
+
};
|
|
13
|
+
else if (animated === true) mergedAnimated = {
|
|
14
|
+
inkBar: true,
|
|
15
|
+
tabPane: false
|
|
16
|
+
};
|
|
17
|
+
else mergedAnimated = {
|
|
18
|
+
inkBar: true,
|
|
19
|
+
...typeof animated === "object" ? animated : {}
|
|
20
|
+
};
|
|
21
|
+
if (mergedAnimated.tabPaneMotion && mergedAnimated.tabPane === void 0) mergedAnimated.tabPane = true;
|
|
22
|
+
if (!mergedAnimated.tabPaneMotion && mergedAnimated.tabPane) {
|
|
23
|
+
if (process.env.NODE_ENV !== "production") (0, __v_c_util_dist_warning.warning)(false, "`animated.tabPane` is true but `animated.tabPaneMotion` is not provided. Motion will not work.");
|
|
24
|
+
mergedAnimated.tabPane = false;
|
|
25
|
+
}
|
|
26
|
+
return mergedAnimated;
|
|
27
|
+
}
|
|
28
|
+
exports.default = useAnimateConfig;
|