first commit
This commit is contained in:
167
node_modules/vant/es/tabs/Tabs.d.ts
generated
vendored
Normal file
167
node_modules/vant/es/tabs/Tabs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
import { type PropType, type InjectionKey, type ExtractPropTypes } from 'vue';
|
||||
import { type Interceptor } from '../utils';
|
||||
import type { TabsProvide, TabsType } from './types';
|
||||
export declare const tabsProps: {
|
||||
type: {
|
||||
type: PropType<TabsType>;
|
||||
default: TabsType;
|
||||
};
|
||||
color: StringConstructor;
|
||||
border: BooleanConstructor;
|
||||
sticky: BooleanConstructor;
|
||||
shrink: BooleanConstructor;
|
||||
active: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
duration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
animated: BooleanConstructor;
|
||||
ellipsis: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeable: BooleanConstructor;
|
||||
scrollspy: BooleanConstructor;
|
||||
offsetTop: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
background: StringConstructor;
|
||||
lazyRender: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
showHeader: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
lineWidth: (NumberConstructor | StringConstructor)[];
|
||||
lineHeight: (NumberConstructor | StringConstructor)[];
|
||||
beforeChange: PropType<Interceptor>;
|
||||
swipeThreshold: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
titleActiveColor: StringConstructor;
|
||||
titleInactiveColor: StringConstructor;
|
||||
};
|
||||
export type TabsProps = ExtractPropTypes<typeof tabsProps>;
|
||||
export declare const TABS_KEY: InjectionKey<TabsProvide>;
|
||||
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
||||
type: {
|
||||
type: PropType<TabsType>;
|
||||
default: TabsType;
|
||||
};
|
||||
color: StringConstructor;
|
||||
border: BooleanConstructor;
|
||||
sticky: BooleanConstructor;
|
||||
shrink: BooleanConstructor;
|
||||
active: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
duration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
animated: BooleanConstructor;
|
||||
ellipsis: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeable: BooleanConstructor;
|
||||
scrollspy: BooleanConstructor;
|
||||
offsetTop: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
background: StringConstructor;
|
||||
lazyRender: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
showHeader: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
lineWidth: (NumberConstructor | StringConstructor)[];
|
||||
lineHeight: (NumberConstructor | StringConstructor)[];
|
||||
beforeChange: PropType<Interceptor>;
|
||||
swipeThreshold: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
titleActiveColor: StringConstructor;
|
||||
titleInactiveColor: StringConstructor;
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("scroll" | "change" | "rendered" | "clickTab" | "update:active")[], "scroll" | "change" | "rendered" | "clickTab" | "update:active", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
||||
type: {
|
||||
type: PropType<TabsType>;
|
||||
default: TabsType;
|
||||
};
|
||||
color: StringConstructor;
|
||||
border: BooleanConstructor;
|
||||
sticky: BooleanConstructor;
|
||||
shrink: BooleanConstructor;
|
||||
active: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
duration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
animated: BooleanConstructor;
|
||||
ellipsis: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeable: BooleanConstructor;
|
||||
scrollspy: BooleanConstructor;
|
||||
offsetTop: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
background: StringConstructor;
|
||||
lazyRender: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
showHeader: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
lineWidth: (NumberConstructor | StringConstructor)[];
|
||||
lineHeight: (NumberConstructor | StringConstructor)[];
|
||||
beforeChange: PropType<Interceptor>;
|
||||
swipeThreshold: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
titleActiveColor: StringConstructor;
|
||||
titleInactiveColor: StringConstructor;
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
onScroll?: ((...args: any[]) => any) | undefined;
|
||||
onRendered?: ((...args: any[]) => any) | undefined;
|
||||
onClickTab?: ((...args: any[]) => any) | undefined;
|
||||
"onUpdate:active"?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
type: TabsType;
|
||||
ellipsis: boolean;
|
||||
sticky: boolean;
|
||||
border: boolean;
|
||||
active: string | number;
|
||||
duration: string | number;
|
||||
lazyRender: boolean;
|
||||
offsetTop: string | number;
|
||||
animated: boolean;
|
||||
swipeable: boolean;
|
||||
shrink: boolean;
|
||||
scrollspy: boolean;
|
||||
showHeader: boolean;
|
||||
swipeThreshold: string | number;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
356
node_modules/vant/es/tabs/Tabs.mjs
generated
vendored
Normal file
356
node_modules/vant/es/tabs/Tabs.mjs
generated
vendored
Normal file
@@ -0,0 +1,356 @@
|
||||
import { ref, watch, computed, reactive, nextTick, onActivated, defineComponent, createVNode as _createVNode } from "vue";
|
||||
import { isDef, addUnit, isHidden, unitToPx, truthProp, numericProp, windowWidth, getElementTop, makeStringProp, callInterceptor, createNamespace, makeNumericProp, setRootScrollTop, BORDER_TOP_BOTTOM } from "../utils/index.mjs";
|
||||
import { scrollLeftTo, scrollTopTo } from "./utils.mjs";
|
||||
import { useRect, useChildren, useScrollParent, useEventListener, onMountedOrActivated } from "@vant/use";
|
||||
import { useId } from "../composables/use-id.mjs";
|
||||
import { route } from "../composables/use-route.mjs";
|
||||
import { useRefs } from "../composables/use-refs.mjs";
|
||||
import { useExpose } from "../composables/use-expose.mjs";
|
||||
import { onPopupReopen } from "../composables/on-popup-reopen.mjs";
|
||||
import { useVisibilityChange } from "../composables/use-visibility-change.mjs";
|
||||
import { Sticky } from "../sticky/index.mjs";
|
||||
import TabsContent from "./TabsContent.mjs";
|
||||
const [name, bem] = createNamespace("tabs");
|
||||
const tabsProps = {
|
||||
type: makeStringProp("line"),
|
||||
color: String,
|
||||
border: Boolean,
|
||||
sticky: Boolean,
|
||||
shrink: Boolean,
|
||||
active: makeNumericProp(0),
|
||||
duration: makeNumericProp(0.3),
|
||||
animated: Boolean,
|
||||
ellipsis: truthProp,
|
||||
swipeable: Boolean,
|
||||
scrollspy: Boolean,
|
||||
offsetTop: makeNumericProp(0),
|
||||
background: String,
|
||||
lazyRender: truthProp,
|
||||
showHeader: truthProp,
|
||||
lineWidth: numericProp,
|
||||
lineHeight: numericProp,
|
||||
beforeChange: Function,
|
||||
swipeThreshold: makeNumericProp(5),
|
||||
titleActiveColor: String,
|
||||
titleInactiveColor: String
|
||||
};
|
||||
const TABS_KEY = Symbol(name);
|
||||
var stdin_default = defineComponent({
|
||||
name,
|
||||
props: tabsProps,
|
||||
emits: ["change", "scroll", "rendered", "clickTab", "update:active"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
let tabHeight;
|
||||
let lockScroll;
|
||||
let stickyFixed;
|
||||
let cancelScrollLeftToRaf;
|
||||
let cancelScrollTopToRaf;
|
||||
const root = ref();
|
||||
const navRef = ref();
|
||||
const wrapRef = ref();
|
||||
const contentRef = ref();
|
||||
const id = useId();
|
||||
const scroller = useScrollParent(root);
|
||||
const [titleRefs, setTitleRefs] = useRefs();
|
||||
const {
|
||||
children,
|
||||
linkChildren
|
||||
} = useChildren(TABS_KEY);
|
||||
const state = reactive({
|
||||
inited: false,
|
||||
position: "",
|
||||
lineStyle: {},
|
||||
currentIndex: -1
|
||||
});
|
||||
const scrollable = computed(() => children.length > +props.swipeThreshold || !props.ellipsis || props.shrink);
|
||||
const navStyle = computed(() => ({
|
||||
borderColor: props.color,
|
||||
background: props.background
|
||||
}));
|
||||
const getTabName = (tab, index) => {
|
||||
var _a;
|
||||
return (_a = tab.name) != null ? _a : index;
|
||||
};
|
||||
const currentName = computed(() => {
|
||||
const activeTab = children[state.currentIndex];
|
||||
if (activeTab) {
|
||||
return getTabName(activeTab, state.currentIndex);
|
||||
}
|
||||
});
|
||||
const offsetTopPx = computed(() => unitToPx(props.offsetTop));
|
||||
const scrollOffset = computed(() => {
|
||||
if (props.sticky) {
|
||||
return offsetTopPx.value + tabHeight;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
const scrollIntoView = (immediate) => {
|
||||
const nav = navRef.value;
|
||||
const titles = titleRefs.value;
|
||||
if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
|
||||
return;
|
||||
}
|
||||
const title = titles[state.currentIndex].$el;
|
||||
const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
|
||||
if (cancelScrollLeftToRaf) cancelScrollLeftToRaf();
|
||||
cancelScrollLeftToRaf = scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
|
||||
};
|
||||
const setLine = () => {
|
||||
const shouldAnimate = state.inited;
|
||||
nextTick(() => {
|
||||
const titles = titleRefs.value;
|
||||
if (!titles || !titles[state.currentIndex] || props.type !== "line" || isHidden(root.value)) {
|
||||
return;
|
||||
}
|
||||
const title = titles[state.currentIndex].$el;
|
||||
const {
|
||||
lineWidth,
|
||||
lineHeight
|
||||
} = props;
|
||||
const left = title.offsetLeft + title.offsetWidth / 2;
|
||||
const lineStyle = {
|
||||
width: addUnit(lineWidth),
|
||||
backgroundColor: props.color,
|
||||
transform: `translateX(${left}px) translateX(-50%)`
|
||||
};
|
||||
if (shouldAnimate) {
|
||||
lineStyle.transitionDuration = `${props.duration}s`;
|
||||
}
|
||||
if (isDef(lineHeight)) {
|
||||
const height = addUnit(lineHeight);
|
||||
lineStyle.height = height;
|
||||
lineStyle.borderRadius = height;
|
||||
}
|
||||
state.lineStyle = lineStyle;
|
||||
});
|
||||
};
|
||||
const findAvailableTab = (index) => {
|
||||
const diff = index < state.currentIndex ? -1 : 1;
|
||||
while (index >= 0 && index < children.length) {
|
||||
if (!children[index].disabled) {
|
||||
return index;
|
||||
}
|
||||
index += diff;
|
||||
}
|
||||
};
|
||||
const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
|
||||
const newIndex = findAvailableTab(currentIndex);
|
||||
if (!isDef(newIndex)) {
|
||||
return;
|
||||
}
|
||||
const newTab = children[newIndex];
|
||||
const newName = getTabName(newTab, newIndex);
|
||||
const shouldEmitChange = state.currentIndex !== null;
|
||||
if (state.currentIndex !== newIndex) {
|
||||
state.currentIndex = newIndex;
|
||||
if (!skipScrollIntoView) {
|
||||
scrollIntoView();
|
||||
}
|
||||
setLine();
|
||||
}
|
||||
if (newName !== props.active) {
|
||||
emit("update:active", newName);
|
||||
if (shouldEmitChange) {
|
||||
emit("change", newName, newTab.title);
|
||||
}
|
||||
}
|
||||
if (stickyFixed && !props.scrollspy) {
|
||||
setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
|
||||
}
|
||||
};
|
||||
const setCurrentIndexByName = (name2, skipScrollIntoView) => {
|
||||
const index = children.findIndex((tab, index2) => getTabName(tab, index2) === name2);
|
||||
setCurrentIndex(index === -1 ? 0 : index, skipScrollIntoView);
|
||||
};
|
||||
const scrollToCurrentContent = (immediate = false) => {
|
||||
if (props.scrollspy) {
|
||||
const target = children[state.currentIndex].$el;
|
||||
if (target && scroller.value) {
|
||||
const to = getElementTop(target, scroller.value) - scrollOffset.value;
|
||||
lockScroll = true;
|
||||
if (cancelScrollTopToRaf) cancelScrollTopToRaf();
|
||||
cancelScrollTopToRaf = scrollTopTo(scroller.value, to, immediate ? 0 : +props.duration, () => {
|
||||
lockScroll = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
const onClickTab = (item, index, event) => {
|
||||
const {
|
||||
title,
|
||||
disabled
|
||||
} = children[index];
|
||||
const name2 = getTabName(children[index], index);
|
||||
if (!disabled) {
|
||||
callInterceptor(props.beforeChange, {
|
||||
args: [name2],
|
||||
done: () => {
|
||||
setCurrentIndex(index);
|
||||
scrollToCurrentContent();
|
||||
}
|
||||
});
|
||||
route(item);
|
||||
}
|
||||
emit("clickTab", {
|
||||
name: name2,
|
||||
title,
|
||||
event,
|
||||
disabled
|
||||
});
|
||||
};
|
||||
const onStickyScroll = (params) => {
|
||||
stickyFixed = params.isFixed;
|
||||
emit("scroll", params);
|
||||
};
|
||||
const scrollTo = (name2) => {
|
||||
nextTick(() => {
|
||||
setCurrentIndexByName(name2);
|
||||
scrollToCurrentContent(true);
|
||||
});
|
||||
};
|
||||
const getCurrentIndexOnScroll = () => {
|
||||
for (let index = 0; index < children.length; index++) {
|
||||
const {
|
||||
top
|
||||
} = useRect(children[index].$el);
|
||||
if (top > scrollOffset.value) {
|
||||
return index === 0 ? 0 : index - 1;
|
||||
}
|
||||
}
|
||||
return children.length - 1;
|
||||
};
|
||||
const onScroll = () => {
|
||||
if (props.scrollspy && !lockScroll) {
|
||||
const index = getCurrentIndexOnScroll();
|
||||
setCurrentIndex(index);
|
||||
}
|
||||
};
|
||||
const renderLine = () => {
|
||||
if (props.type === "line" && children.length) {
|
||||
return _createVNode("div", {
|
||||
"class": bem("line"),
|
||||
"style": state.lineStyle
|
||||
}, null);
|
||||
}
|
||||
};
|
||||
const renderHeader = () => {
|
||||
var _a, _b, _c;
|
||||
const {
|
||||
type,
|
||||
border,
|
||||
sticky
|
||||
} = props;
|
||||
const Header = [_createVNode("div", {
|
||||
"ref": sticky ? void 0 : wrapRef,
|
||||
"class": [bem("wrap"), {
|
||||
[BORDER_TOP_BOTTOM]: type === "line" && border
|
||||
}]
|
||||
}, [_createVNode("div", {
|
||||
"ref": navRef,
|
||||
"role": "tablist",
|
||||
"class": bem("nav", [type, {
|
||||
shrink: props.shrink,
|
||||
complete: scrollable.value
|
||||
}]),
|
||||
"style": navStyle.value,
|
||||
"aria-orientation": "horizontal"
|
||||
}, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), children.map((item) => item.renderTitle(onClickTab)), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
|
||||
if (sticky) {
|
||||
return _createVNode("div", {
|
||||
"ref": wrapRef
|
||||
}, [Header]);
|
||||
}
|
||||
return Header;
|
||||
};
|
||||
const resize = () => {
|
||||
setLine();
|
||||
nextTick(() => {
|
||||
var _a, _b;
|
||||
scrollIntoView(true);
|
||||
(_b = (_a = contentRef.value) == null ? void 0 : _a.swipeRef.value) == null ? void 0 : _b.resize();
|
||||
});
|
||||
};
|
||||
watch(() => [props.color, props.duration, props.lineWidth, props.lineHeight], setLine);
|
||||
watch(windowWidth, resize);
|
||||
watch(() => props.active, (value) => {
|
||||
if (value !== currentName.value) {
|
||||
setCurrentIndexByName(value);
|
||||
}
|
||||
});
|
||||
watch(() => children.length, () => {
|
||||
if (state.inited) {
|
||||
setCurrentIndexByName(props.active);
|
||||
setLine();
|
||||
nextTick(() => {
|
||||
scrollIntoView(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
const init = () => {
|
||||
setCurrentIndexByName(props.active, true);
|
||||
nextTick(() => {
|
||||
state.inited = true;
|
||||
if (wrapRef.value) {
|
||||
tabHeight = useRect(wrapRef.value).height;
|
||||
}
|
||||
scrollIntoView(true);
|
||||
});
|
||||
};
|
||||
const onRendered = (name2, title) => emit("rendered", name2, title);
|
||||
useExpose({
|
||||
resize,
|
||||
scrollTo
|
||||
});
|
||||
onActivated(setLine);
|
||||
onPopupReopen(setLine);
|
||||
onMountedOrActivated(init);
|
||||
useVisibilityChange(root, setLine);
|
||||
useEventListener("scroll", onScroll, {
|
||||
target: scroller,
|
||||
passive: true
|
||||
});
|
||||
linkChildren({
|
||||
id,
|
||||
props,
|
||||
setLine,
|
||||
scrollable,
|
||||
onRendered,
|
||||
currentName,
|
||||
setTitleRefs,
|
||||
scrollIntoView
|
||||
});
|
||||
return () => _createVNode("div", {
|
||||
"ref": root,
|
||||
"class": bem([props.type])
|
||||
}, [props.showHeader ? props.sticky ? _createVNode(Sticky, {
|
||||
"container": root.value,
|
||||
"offsetTop": offsetTopPx.value,
|
||||
"onScroll": onStickyScroll
|
||||
}, {
|
||||
default: () => [renderHeader()]
|
||||
}) : renderHeader() : null, _createVNode(TabsContent, {
|
||||
"ref": contentRef,
|
||||
"count": children.length,
|
||||
"inited": state.inited,
|
||||
"animated": props.animated,
|
||||
"duration": props.duration,
|
||||
"swipeable": props.swipeable,
|
||||
"lazyRender": props.lazyRender,
|
||||
"currentIndex": state.currentIndex,
|
||||
"onChange": setCurrentIndex
|
||||
}, {
|
||||
default: () => {
|
||||
var _a;
|
||||
return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
||||
}
|
||||
})]);
|
||||
}
|
||||
});
|
||||
export {
|
||||
TABS_KEY,
|
||||
stdin_default as default,
|
||||
tabsProps
|
||||
};
|
||||
43
node_modules/vant/es/tabs/TabsContent.d.ts
generated
vendored
Normal file
43
node_modules/vant/es/tabs/TabsContent.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
count: {
|
||||
type: NumberConstructor;
|
||||
required: true;
|
||||
};
|
||||
inited: BooleanConstructor;
|
||||
animated: BooleanConstructor;
|
||||
duration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
required: true;
|
||||
};
|
||||
swipeable: BooleanConstructor;
|
||||
lazyRender: BooleanConstructor;
|
||||
currentIndex: {
|
||||
type: NumberConstructor;
|
||||
required: true;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "change"[], "change", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
count: {
|
||||
type: NumberConstructor;
|
||||
required: true;
|
||||
};
|
||||
inited: BooleanConstructor;
|
||||
animated: BooleanConstructor;
|
||||
duration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
required: true;
|
||||
};
|
||||
swipeable: BooleanConstructor;
|
||||
lazyRender: BooleanConstructor;
|
||||
currentIndex: {
|
||||
type: NumberConstructor;
|
||||
required: true;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
lazyRender: boolean;
|
||||
inited: boolean;
|
||||
animated: boolean;
|
||||
swipeable: boolean;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
67
node_modules/vant/es/tabs/TabsContent.mjs
generated
vendored
Normal file
67
node_modules/vant/es/tabs/TabsContent.mjs
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import { ref, watch, onMounted, defineComponent, createVNode as _createVNode } from "vue";
|
||||
import { numericProp, makeRequiredProp, createNamespace } from "../utils/index.mjs";
|
||||
import { Swipe } from "../swipe/index.mjs";
|
||||
import { useExpose } from "../composables/use-expose.mjs";
|
||||
const [name, bem] = createNamespace("tabs");
|
||||
var stdin_default = defineComponent({
|
||||
name,
|
||||
props: {
|
||||
count: makeRequiredProp(Number),
|
||||
inited: Boolean,
|
||||
animated: Boolean,
|
||||
duration: makeRequiredProp(numericProp),
|
||||
swipeable: Boolean,
|
||||
lazyRender: Boolean,
|
||||
currentIndex: makeRequiredProp(Number)
|
||||
},
|
||||
emits: ["change"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const swipeRef = ref();
|
||||
const onChange = (index) => emit("change", index);
|
||||
const renderChildren = () => {
|
||||
var _a;
|
||||
const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
|
||||
if (props.animated || props.swipeable) {
|
||||
return _createVNode(Swipe, {
|
||||
"ref": swipeRef,
|
||||
"loop": false,
|
||||
"class": bem("track"),
|
||||
"duration": +props.duration * 1e3,
|
||||
"touchable": props.swipeable,
|
||||
"lazyRender": props.lazyRender,
|
||||
"showIndicators": false,
|
||||
"onChange": onChange
|
||||
}, {
|
||||
default: () => [Content]
|
||||
});
|
||||
}
|
||||
return Content;
|
||||
};
|
||||
const swipeToCurrentTab = (index) => {
|
||||
const swipe = swipeRef.value;
|
||||
if (swipe && swipe.state.active !== index) {
|
||||
swipe.swipeTo(index, {
|
||||
immediate: !props.inited
|
||||
});
|
||||
}
|
||||
};
|
||||
watch(() => props.currentIndex, swipeToCurrentTab);
|
||||
onMounted(() => {
|
||||
swipeToCurrentTab(props.currentIndex);
|
||||
});
|
||||
useExpose({
|
||||
swipeRef
|
||||
});
|
||||
return () => _createVNode("div", {
|
||||
"class": bem("content", {
|
||||
animated: props.animated || props.swipeable
|
||||
})
|
||||
}, [renderChildren()]);
|
||||
}
|
||||
});
|
||||
export {
|
||||
stdin_default as default
|
||||
};
|
||||
1
node_modules/vant/es/tabs/index.css
generated
vendored
Normal file
1
node_modules/vant/es/tabs/index.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
:root,:host{--van-tab-text-color: var(--van-gray-7);--van-tab-active-text-color: var(--van-text-color);--van-tab-disabled-text-color: var(--van-text-color-3);--van-tab-font-size: var(--van-font-size-md);--van-tab-line-height: var(--van-line-height-md);--van-tabs-default-color: var(--van-primary-color);--van-tabs-line-height: 44px;--van-tabs-card-height: 30px;--van-tabs-nav-background: var(--van-background-2);--van-tabs-bottom-bar-width: 40px;--van-tabs-bottom-bar-height: 3px;--van-tabs-bottom-bar-color: var(--van-primary-color)}.van-tab{position:relative;display:flex;flex:1;align-items:center;justify-content:center;box-sizing:border-box;padding:0 var(--van-padding-base);color:var(--van-tab-text-color);font-size:var(--van-tab-font-size);line-height:var(--van-tab-line-height);cursor:pointer}.van-tab--active{color:var(--van-tab-active-text-color);font-weight:var(--van-font-bold)}.van-tab--disabled{color:var(--van-tab-disabled-text-color);cursor:not-allowed}.van-tab--grow{flex:1 0 auto;padding:0 var(--van-padding-sm)}.van-tab--shrink{flex:none;padding:0 var(--van-padding-xs)}.van-tab--card{color:var(--van-tabs-default-color);border-right:var(--van-border-width) solid var(--van-tabs-default-color)}.van-tab--card:last-child{border-right:none}.van-tab--card.van-tab--active{color:var(--van-white);background-color:var(--van-tabs-default-color)}.van-tab--card.van-tab--disabled{color:var(--van-tab-disabled-text-color)}.van-tab__text--ellipsis{display:-webkit-box;overflow:hidden;-webkit-line-clamp:1;-webkit-box-orient:vertical}.van-tabs{position:relative}.van-tabs__wrap{overflow:hidden}.van-tabs__wrap--page-top{position:fixed}.van-tabs__wrap--content-bottom{top:auto;bottom:0}.van-tabs__nav{position:relative;display:flex;background:var(--van-tabs-nav-background);-webkit-user-select:none;user-select:none}.van-tabs__nav--complete{overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}.van-tabs__nav--complete::-webkit-scrollbar{display:none}.van-tabs__nav--line{box-sizing:content-box;height:100%;padding-bottom:15px}.van-tabs__nav--line.van-tabs__nav--shrink,.van-tabs__nav--line.van-tabs__nav--complete{padding-right:var(--van-padding-xs);padding-left:var(--van-padding-xs)}.van-tabs__nav--card{box-sizing:border-box;height:var(--van-tabs-card-height);margin:0 var(--van-padding-md);border:var(--van-border-width) solid var(--van-tabs-default-color);border-radius:var(--van-radius-sm)}.van-tabs__nav--card.van-tabs__nav--shrink{display:inline-flex}.van-tabs__line{position:absolute;bottom:15px;left:0;z-index:1;width:var(--van-tabs-bottom-bar-width);height:var(--van-tabs-bottom-bar-height);background:var(--van-tabs-bottom-bar-color);border-radius:var(--van-tabs-bottom-bar-height)}.van-tabs__track{position:relative;display:flex;width:100%;height:100%;will-change:left}.van-tabs__content--animated{overflow:hidden}.van-tabs--line .van-tabs__wrap{height:var(--van-tabs-line-height)}.van-tabs--card>.van-tabs__wrap{height:var(--van-tabs-card-height)}
|
||||
124
node_modules/vant/es/tabs/index.d.ts
generated
vendored
Normal file
124
node_modules/vant/es/tabs/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
import { TabsProps } from './Tabs';
|
||||
export declare const Tabs: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
type: {
|
||||
type: import("vue").PropType<import("./types").TabsType>;
|
||||
default: import("./types").TabsType;
|
||||
};
|
||||
color: StringConstructor;
|
||||
border: BooleanConstructor;
|
||||
sticky: BooleanConstructor;
|
||||
shrink: BooleanConstructor;
|
||||
active: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
duration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
animated: BooleanConstructor;
|
||||
ellipsis: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeable: BooleanConstructor;
|
||||
scrollspy: BooleanConstructor;
|
||||
offsetTop: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
background: StringConstructor;
|
||||
lazyRender: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
showHeader: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
lineWidth: (NumberConstructor | StringConstructor)[];
|
||||
lineHeight: (NumberConstructor | StringConstructor)[];
|
||||
beforeChange: import("vue").PropType<import("../utils").Interceptor>;
|
||||
swipeThreshold: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
titleActiveColor: StringConstructor;
|
||||
titleInactiveColor: StringConstructor;
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("scroll" | "change" | "rendered" | "clickTab" | "update:active")[], "scroll" | "change" | "rendered" | "clickTab" | "update:active", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
type: {
|
||||
type: import("vue").PropType<import("./types").TabsType>;
|
||||
default: import("./types").TabsType;
|
||||
};
|
||||
color: StringConstructor;
|
||||
border: BooleanConstructor;
|
||||
sticky: BooleanConstructor;
|
||||
shrink: BooleanConstructor;
|
||||
active: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
duration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
animated: BooleanConstructor;
|
||||
ellipsis: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeable: BooleanConstructor;
|
||||
scrollspy: BooleanConstructor;
|
||||
offsetTop: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
background: StringConstructor;
|
||||
lazyRender: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
showHeader: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
lineWidth: (NumberConstructor | StringConstructor)[];
|
||||
lineHeight: (NumberConstructor | StringConstructor)[];
|
||||
beforeChange: import("vue").PropType<import("../utils").Interceptor>;
|
||||
swipeThreshold: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
titleActiveColor: StringConstructor;
|
||||
titleInactiveColor: StringConstructor;
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
onScroll?: ((...args: any[]) => any) | undefined;
|
||||
onRendered?: ((...args: any[]) => any) | undefined;
|
||||
onClickTab?: ((...args: any[]) => any) | undefined;
|
||||
"onUpdate:active"?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
type: import("./types").TabsType;
|
||||
ellipsis: boolean;
|
||||
sticky: boolean;
|
||||
border: boolean;
|
||||
active: string | number;
|
||||
duration: string | number;
|
||||
lazyRender: boolean;
|
||||
offsetTop: string | number;
|
||||
animated: boolean;
|
||||
swipeable: boolean;
|
||||
shrink: boolean;
|
||||
scrollspy: boolean;
|
||||
showHeader: boolean;
|
||||
swipeThreshold: string | number;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
||||
export default Tabs;
|
||||
export { tabsProps } from './Tabs';
|
||||
export type { TabsProps };
|
||||
export type { TabsType, TabsInstance, TabsThemeVars } from './types';
|
||||
declare module 'vue' {
|
||||
interface GlobalComponents {
|
||||
VanTabs: typeof Tabs;
|
||||
}
|
||||
}
|
||||
10
node_modules/vant/es/tabs/index.mjs
generated
vendored
Normal file
10
node_modules/vant/es/tabs/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { withInstall } from "../utils/index.mjs";
|
||||
import _Tabs from "./Tabs.mjs";
|
||||
const Tabs = withInstall(_Tabs);
|
||||
var stdin_default = Tabs;
|
||||
import { tabsProps } from "./Tabs.mjs";
|
||||
export {
|
||||
Tabs,
|
||||
stdin_default as default,
|
||||
tabsProps
|
||||
};
|
||||
1
node_modules/vant/es/tabs/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/es/tabs/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
4
node_modules/vant/es/tabs/style/index.mjs
generated
vendored
Normal file
4
node_modules/vant/es/tabs/style/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import "../../style/base.css";
|
||||
import "../../sticky/index.css";
|
||||
import "../../swipe/index.css";
|
||||
import "../index.css";
|
||||
39
node_modules/vant/es/tabs/types.d.ts
generated
vendored
Normal file
39
node_modules/vant/es/tabs/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import type { ComponentPublicInstance, ComputedRef } from 'vue';
|
||||
import type { Numeric } from '../utils';
|
||||
import type { TabsProps } from './Tabs';
|
||||
export type TabsType = 'line' | 'card';
|
||||
export type TabsClickTabEventParams = {
|
||||
name: Numeric;
|
||||
title: string;
|
||||
event: MouseEvent;
|
||||
disabled: boolean;
|
||||
};
|
||||
export type TabsProvide = {
|
||||
id: string;
|
||||
props: TabsProps;
|
||||
setLine: () => void;
|
||||
scrollable: ComputedRef<boolean>;
|
||||
onRendered: (name: Numeric, title?: string) => void;
|
||||
currentName: ComputedRef<Numeric | undefined>;
|
||||
setTitleRefs: (index: number) => (el: unknown) => void;
|
||||
scrollIntoView: (immediate?: boolean) => void;
|
||||
};
|
||||
export type TabsExpose = {
|
||||
resize: () => void;
|
||||
scrollTo: (name: Numeric) => void;
|
||||
};
|
||||
export type TabsInstance = ComponentPublicInstance<TabsProps, TabsExpose>;
|
||||
export type TabsThemeVars = {
|
||||
tabTextColor?: string;
|
||||
tabActiveTextColor?: string;
|
||||
tabDisabledTextColor?: string;
|
||||
tabFontSize?: string;
|
||||
tabLineHeight?: number | string;
|
||||
tabsDefaultColor?: string;
|
||||
tabsLineHeight?: number | string;
|
||||
tabsCardHeight?: string;
|
||||
tabsNavBackground?: string;
|
||||
tabsBottomBarWidth?: string;
|
||||
tabsBottomBarHeight?: string;
|
||||
tabsBottomBarColor?: string;
|
||||
};
|
||||
0
node_modules/vant/es/tabs/types.mjs
generated
vendored
Normal file
0
node_modules/vant/es/tabs/types.mjs
generated
vendored
Normal file
3
node_modules/vant/es/tabs/utils.d.ts
generated
vendored
Normal file
3
node_modules/vant/es/tabs/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { ScrollElement } from '../utils';
|
||||
export declare function scrollLeftTo(scroller: HTMLElement, to: number, duration: number): () => void;
|
||||
export declare function scrollTopTo(scroller: ScrollElement, to: number, duration: number, callback: () => void): () => void;
|
||||
49
node_modules/vant/es/tabs/utils.mjs
generated
vendored
Normal file
49
node_modules/vant/es/tabs/utils.mjs
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import { raf, cancelRaf } from "@vant/use";
|
||||
import { getScrollTop, setScrollTop } from "../utils/index.mjs";
|
||||
function scrollLeftTo(scroller, to, duration) {
|
||||
let rafId;
|
||||
let count = 0;
|
||||
const from = scroller.scrollLeft;
|
||||
const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
|
||||
let scrollLeft = from;
|
||||
function cancel() {
|
||||
cancelRaf(rafId);
|
||||
}
|
||||
function animate() {
|
||||
scrollLeft += (to - from) / frames;
|
||||
scroller.scrollLeft = scrollLeft;
|
||||
if (++count < frames) {
|
||||
rafId = raf(animate);
|
||||
}
|
||||
}
|
||||
animate();
|
||||
return cancel;
|
||||
}
|
||||
function scrollTopTo(scroller, to, duration, callback) {
|
||||
let rafId;
|
||||
let current = getScrollTop(scroller);
|
||||
const isDown = current < to;
|
||||
const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
|
||||
const step = (to - current) / frames;
|
||||
function cancel() {
|
||||
cancelRaf(rafId);
|
||||
}
|
||||
function animate() {
|
||||
current += step;
|
||||
if (isDown && current > to || !isDown && current < to) {
|
||||
current = to;
|
||||
}
|
||||
setScrollTop(scroller, current);
|
||||
if (isDown && current < to || !isDown && current > to) {
|
||||
rafId = raf(animate);
|
||||
} else if (callback) {
|
||||
rafId = raf(callback);
|
||||
}
|
||||
}
|
||||
animate();
|
||||
return cancel;
|
||||
}
|
||||
export {
|
||||
scrollLeftTo,
|
||||
scrollTopTo
|
||||
};
|
||||
Reference in New Issue
Block a user