first commit
This commit is contained in:
64
node_modules/vant/es/index-bar/IndexBar.d.ts
generated
vendored
Normal file
64
node_modules/vant/es/index-bar/IndexBar.d.ts
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
import { type PropType, type InjectionKey, type TeleportProps, type ExtractPropTypes } from 'vue';
|
||||
import { type Numeric } from '../utils';
|
||||
import { IndexBarProvide } from './types';
|
||||
declare function genAlphabet(): string[];
|
||||
export declare const indexBarProps: {
|
||||
sticky: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
zIndex: (NumberConstructor | StringConstructor)[];
|
||||
teleport: PropType<TeleportProps["to"]>;
|
||||
highlightColor: StringConstructor;
|
||||
stickyOffsetTop: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
indexList: {
|
||||
type: PropType<Numeric[]>;
|
||||
default: typeof genAlphabet;
|
||||
};
|
||||
};
|
||||
export type IndexBarProps = ExtractPropTypes<typeof indexBarProps>;
|
||||
export declare const INDEX_BAR_KEY: InjectionKey<IndexBarProvide>;
|
||||
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
||||
sticky: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
zIndex: (NumberConstructor | StringConstructor)[];
|
||||
teleport: PropType<TeleportProps["to"]>;
|
||||
highlightColor: StringConstructor;
|
||||
stickyOffsetTop: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
indexList: {
|
||||
type: PropType<Numeric[]>;
|
||||
default: typeof genAlphabet;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "change")[], "select" | "change", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
||||
sticky: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
zIndex: (NumberConstructor | StringConstructor)[];
|
||||
teleport: PropType<TeleportProps["to"]>;
|
||||
highlightColor: StringConstructor;
|
||||
stickyOffsetTop: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
indexList: {
|
||||
type: PropType<Numeric[]>;
|
||||
default: typeof genAlphabet;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
onSelect?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
sticky: boolean;
|
||||
stickyOffsetTop: number;
|
||||
indexList: Numeric[];
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
234
node_modules/vant/es/index-bar/IndexBar.mjs
generated
vendored
Normal file
234
node_modules/vant/es/index-bar/IndexBar.mjs
generated
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
import { ref, watch, computed, nextTick, Teleport, onMounted, defineComponent, createVNode as _createVNode } from "vue";
|
||||
import { isDef, isHidden, truthProp, numericProp, getScrollTop, preventDefault, makeNumberProp, createNamespace, getRootScrollTop, setRootScrollTop } from "../utils/index.mjs";
|
||||
import { useRect, useChildren, useScrollParent, useEventListener } from "@vant/use";
|
||||
import { useTouch } from "../composables/use-touch.mjs";
|
||||
import { useExpose } from "../composables/use-expose.mjs";
|
||||
function genAlphabet() {
|
||||
const charCodeOfA = "A".charCodeAt(0);
|
||||
const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
|
||||
return indexList;
|
||||
}
|
||||
const [name, bem] = createNamespace("index-bar");
|
||||
const indexBarProps = {
|
||||
sticky: truthProp,
|
||||
zIndex: numericProp,
|
||||
teleport: [String, Object],
|
||||
highlightColor: String,
|
||||
stickyOffsetTop: makeNumberProp(0),
|
||||
indexList: {
|
||||
type: Array,
|
||||
default: genAlphabet
|
||||
}
|
||||
};
|
||||
const INDEX_BAR_KEY = Symbol(name);
|
||||
var stdin_default = defineComponent({
|
||||
name,
|
||||
props: indexBarProps,
|
||||
emits: ["select", "change"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const root = ref();
|
||||
const sidebar = ref();
|
||||
const activeAnchor = ref("");
|
||||
const touch = useTouch();
|
||||
const scrollParent = useScrollParent(root);
|
||||
const {
|
||||
children,
|
||||
linkChildren
|
||||
} = useChildren(INDEX_BAR_KEY);
|
||||
let selectActiveIndex;
|
||||
linkChildren({
|
||||
props
|
||||
});
|
||||
const sidebarStyle = computed(() => {
|
||||
if (isDef(props.zIndex)) {
|
||||
return {
|
||||
zIndex: +props.zIndex + 1
|
||||
};
|
||||
}
|
||||
});
|
||||
const highlightStyle = computed(() => {
|
||||
if (props.highlightColor) {
|
||||
return {
|
||||
color: props.highlightColor
|
||||
};
|
||||
}
|
||||
});
|
||||
const getActiveAnchor = (scrollTop, rects) => {
|
||||
for (let i = children.length - 1; i >= 0; i--) {
|
||||
const prevHeight = i > 0 ? rects[i - 1].height : 0;
|
||||
const reachTop = props.sticky ? prevHeight + props.stickyOffsetTop : 0;
|
||||
if (scrollTop + reachTop >= rects[i].top) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
|
||||
const onScroll = () => {
|
||||
if (isHidden(root)) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
sticky,
|
||||
indexList
|
||||
} = props;
|
||||
const scrollTop = getScrollTop(scrollParent.value);
|
||||
const scrollParentRect = useRect(scrollParent);
|
||||
const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
|
||||
let active = -1;
|
||||
if (selectActiveIndex) {
|
||||
const match = getMatchAnchor(selectActiveIndex);
|
||||
if (match) {
|
||||
const rect = match.getRect(scrollParent.value, scrollParentRect);
|
||||
if (props.sticky && props.stickyOffsetTop) {
|
||||
active = getActiveAnchor(rect.top - props.stickyOffsetTop, rects);
|
||||
} else {
|
||||
active = getActiveAnchor(rect.top, rects);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
active = getActiveAnchor(scrollTop, rects);
|
||||
}
|
||||
activeAnchor.value = indexList[active];
|
||||
if (sticky) {
|
||||
children.forEach((item, index) => {
|
||||
const {
|
||||
state,
|
||||
$el
|
||||
} = item;
|
||||
if (index === active || index === active - 1) {
|
||||
const rect = $el.getBoundingClientRect();
|
||||
state.left = rect.left;
|
||||
state.width = rect.width;
|
||||
} else {
|
||||
state.left = null;
|
||||
state.width = null;
|
||||
}
|
||||
if (index === active) {
|
||||
state.active = true;
|
||||
state.top = Math.max(props.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
|
||||
} else if (index === active - 1 && selectActiveIndex === "") {
|
||||
const activeItemTop = rects[active].top - scrollTop;
|
||||
state.active = activeItemTop > 0;
|
||||
state.top = activeItemTop + scrollParentRect.top - rects[index].height;
|
||||
} else {
|
||||
state.active = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
selectActiveIndex = "";
|
||||
};
|
||||
const init = () => {
|
||||
nextTick(onScroll);
|
||||
};
|
||||
useEventListener("scroll", onScroll, {
|
||||
target: scrollParent,
|
||||
passive: true
|
||||
});
|
||||
onMounted(init);
|
||||
watch(() => props.indexList, init);
|
||||
watch(activeAnchor, (value) => {
|
||||
if (value) {
|
||||
emit("change", value);
|
||||
}
|
||||
});
|
||||
const renderIndexes = () => props.indexList.map((index) => {
|
||||
const active = index === activeAnchor.value;
|
||||
return _createVNode("span", {
|
||||
"class": bem("index", {
|
||||
active
|
||||
}),
|
||||
"style": active ? highlightStyle.value : void 0,
|
||||
"data-index": index
|
||||
}, [index]);
|
||||
});
|
||||
const scrollTo = (index) => {
|
||||
selectActiveIndex = String(index);
|
||||
const match = getMatchAnchor(selectActiveIndex);
|
||||
if (match) {
|
||||
const scrollTop = getScrollTop(scrollParent.value);
|
||||
const scrollParentRect = useRect(scrollParent);
|
||||
const {
|
||||
offsetHeight
|
||||
} = document.documentElement;
|
||||
match.$el.scrollIntoView();
|
||||
if (scrollTop === offsetHeight - scrollParentRect.height) {
|
||||
onScroll();
|
||||
return;
|
||||
}
|
||||
if (props.sticky && props.stickyOffsetTop) {
|
||||
if (getRootScrollTop() === offsetHeight - scrollParentRect.height) {
|
||||
setRootScrollTop(getRootScrollTop());
|
||||
} else {
|
||||
setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
|
||||
}
|
||||
}
|
||||
emit("select", match.index);
|
||||
}
|
||||
};
|
||||
const scrollToElement = (element) => {
|
||||
const {
|
||||
index
|
||||
} = element.dataset;
|
||||
if (index) {
|
||||
scrollTo(index);
|
||||
}
|
||||
};
|
||||
const onClickSidebar = (event) => {
|
||||
scrollToElement(event.target);
|
||||
};
|
||||
let touchActiveIndex;
|
||||
const onTouchMove = (event) => {
|
||||
touch.move(event);
|
||||
if (touch.isVertical()) {
|
||||
preventDefault(event);
|
||||
const {
|
||||
clientX,
|
||||
clientY
|
||||
} = event.touches[0];
|
||||
const target = document.elementFromPoint(clientX, clientY);
|
||||
if (target) {
|
||||
const {
|
||||
index
|
||||
} = target.dataset;
|
||||
if (index && touchActiveIndex !== index) {
|
||||
touchActiveIndex = index;
|
||||
scrollToElement(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const renderSidebar = () => _createVNode("div", {
|
||||
"ref": sidebar,
|
||||
"class": bem("sidebar"),
|
||||
"style": sidebarStyle.value,
|
||||
"onClick": onClickSidebar,
|
||||
"onTouchstartPassive": touch.start
|
||||
}, [renderIndexes()]);
|
||||
useExpose({
|
||||
scrollTo
|
||||
});
|
||||
useEventListener("touchmove", onTouchMove, {
|
||||
target: sidebar
|
||||
});
|
||||
return () => {
|
||||
var _a;
|
||||
return _createVNode("div", {
|
||||
"ref": root,
|
||||
"class": bem()
|
||||
}, [props.teleport ? _createVNode(Teleport, {
|
||||
"to": props.teleport
|
||||
}, {
|
||||
default: () => [renderSidebar()]
|
||||
}) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
||||
};
|
||||
}
|
||||
});
|
||||
export {
|
||||
INDEX_BAR_KEY,
|
||||
stdin_default as default,
|
||||
indexBarProps
|
||||
};
|
||||
1
node_modules/vant/es/index-bar/index.css
generated
vendored
Normal file
1
node_modules/vant/es/index-bar/index.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
:root,:host{--van-index-bar-sidebar-z-index: 2;--van-index-bar-index-font-size: var(--van-font-size-xs);--van-index-bar-index-line-height: var(--van-line-height-xs);--van-index-bar-index-active-color: var(--van-primary-color)}.van-index-bar__sidebar{position:fixed;top:50%;right:0;z-index:var(--van-index-bar-sidebar-z-index);display:flex;flex-direction:column;text-align:center;transform:translateY(-50%);cursor:pointer;-webkit-user-select:none;user-select:none}.van-index-bar__index{padding:0 var(--van-padding-xs) 0 var(--van-padding-md);font-weight:var(--van-font-bold);font-size:var(--van-index-bar-index-font-size);line-height:var(--van-index-bar-index-line-height)}.van-index-bar__index--active{color:var(--van-index-bar-index-active-color);font-weight:700}
|
||||
50
node_modules/vant/es/index-bar/index.d.ts
generated
vendored
Normal file
50
node_modules/vant/es/index-bar/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import { IndexBarProps } from './IndexBar';
|
||||
export declare const IndexBar: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
sticky: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
zIndex: (NumberConstructor | StringConstructor)[];
|
||||
teleport: import("vue").PropType<import("vue").TeleportProps["to"]>;
|
||||
highlightColor: StringConstructor;
|
||||
stickyOffsetTop: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
indexList: {
|
||||
type: import("vue").PropType<import("../utils").Numeric[]>;
|
||||
default: () => string[];
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "change")[], "select" | "change", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
sticky: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
zIndex: (NumberConstructor | StringConstructor)[];
|
||||
teleport: import("vue").PropType<import("vue").TeleportProps["to"]>;
|
||||
highlightColor: StringConstructor;
|
||||
stickyOffsetTop: {
|
||||
type: NumberConstructor;
|
||||
default: number;
|
||||
};
|
||||
indexList: {
|
||||
type: import("vue").PropType<import("../utils").Numeric[]>;
|
||||
default: () => string[];
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
onSelect?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
sticky: boolean;
|
||||
stickyOffsetTop: number;
|
||||
indexList: import("../utils").Numeric[];
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
||||
export default IndexBar;
|
||||
export { indexBarProps } from './IndexBar';
|
||||
export type { IndexBarProps };
|
||||
export type { IndexBarInstance, IndexBarThemeVars } from './types';
|
||||
declare module 'vue' {
|
||||
interface GlobalComponents {
|
||||
VanIndexBar: typeof IndexBar;
|
||||
}
|
||||
}
|
||||
10
node_modules/vant/es/index-bar/index.mjs
generated
vendored
Normal file
10
node_modules/vant/es/index-bar/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { withInstall } from "../utils/index.mjs";
|
||||
import _IndexBar from "./IndexBar.mjs";
|
||||
const IndexBar = withInstall(_IndexBar);
|
||||
var stdin_default = IndexBar;
|
||||
import { indexBarProps } from "./IndexBar.mjs";
|
||||
export {
|
||||
IndexBar,
|
||||
stdin_default as default,
|
||||
indexBarProps
|
||||
};
|
||||
1
node_modules/vant/es/index-bar/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/es/index-bar/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
2
node_modules/vant/es/index-bar/style/index.mjs
generated
vendored
Normal file
2
node_modules/vant/es/index-bar/style/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import "../../style/base.css";
|
||||
import "../index.css";
|
||||
16
node_modules/vant/es/index-bar/types.d.ts
generated
vendored
Normal file
16
node_modules/vant/es/index-bar/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { ComponentPublicInstance } from 'vue';
|
||||
import type { Numeric } from '../utils';
|
||||
import type { IndexBarProps } from './IndexBar';
|
||||
export type IndexBarProvide = {
|
||||
props: IndexBarProps;
|
||||
};
|
||||
export type IndexBarExpose = {
|
||||
scrollTo: (index: Numeric) => void;
|
||||
};
|
||||
export type IndexBarInstance = ComponentPublicInstance<IndexBarProps, IndexBarExpose>;
|
||||
export type IndexBarThemeVars = {
|
||||
indexBarSidebarZIndex?: number | string;
|
||||
indexBarIndexFontSize?: string;
|
||||
indexBarIndexLineHeight?: number | string;
|
||||
indexBarIndexActiveColor?: string;
|
||||
};
|
||||
0
node_modules/vant/es/index-bar/types.mjs
generated
vendored
Normal file
0
node_modules/vant/es/index-bar/types.mjs
generated
vendored
Normal file
Reference in New Issue
Block a user