first commit
This commit is contained in:
64
node_modules/vant/lib/index-bar/IndexBar.d.ts
generated
vendored
Normal file
64
node_modules/vant/lib/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;
|
||||
253
node_modules/vant/lib/index-bar/IndexBar.js
generated
vendored
Normal file
253
node_modules/vant/lib/index-bar/IndexBar.js
generated
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name2 in all)
|
||||
__defProp(target, name2, { get: all[name2], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
INDEX_BAR_KEY: () => INDEX_BAR_KEY,
|
||||
default: () => stdin_default,
|
||||
indexBarProps: () => indexBarProps
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_vue = require("vue");
|
||||
var import_utils = require("../utils");
|
||||
var import_use = require("@vant/use");
|
||||
var import_use_touch = require("../composables/use-touch");
|
||||
var import_use_expose = require("../composables/use-expose");
|
||||
function genAlphabet() {
|
||||
const charCodeOfA = "A".charCodeAt(0);
|
||||
const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
|
||||
return indexList;
|
||||
}
|
||||
const [name, bem] = (0, import_utils.createNamespace)("index-bar");
|
||||
const indexBarProps = {
|
||||
sticky: import_utils.truthProp,
|
||||
zIndex: import_utils.numericProp,
|
||||
teleport: [String, Object],
|
||||
highlightColor: String,
|
||||
stickyOffsetTop: (0, import_utils.makeNumberProp)(0),
|
||||
indexList: {
|
||||
type: Array,
|
||||
default: genAlphabet
|
||||
}
|
||||
};
|
||||
const INDEX_BAR_KEY = Symbol(name);
|
||||
var stdin_default = (0, import_vue.defineComponent)({
|
||||
name,
|
||||
props: indexBarProps,
|
||||
emits: ["select", "change"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const root = (0, import_vue.ref)();
|
||||
const sidebar = (0, import_vue.ref)();
|
||||
const activeAnchor = (0, import_vue.ref)("");
|
||||
const touch = (0, import_use_touch.useTouch)();
|
||||
const scrollParent = (0, import_use.useScrollParent)(root);
|
||||
const {
|
||||
children,
|
||||
linkChildren
|
||||
} = (0, import_use.useChildren)(INDEX_BAR_KEY);
|
||||
let selectActiveIndex;
|
||||
linkChildren({
|
||||
props
|
||||
});
|
||||
const sidebarStyle = (0, import_vue.computed)(() => {
|
||||
if ((0, import_utils.isDef)(props.zIndex)) {
|
||||
return {
|
||||
zIndex: +props.zIndex + 1
|
||||
};
|
||||
}
|
||||
});
|
||||
const highlightStyle = (0, import_vue.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 ((0, import_utils.isHidden)(root)) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
sticky,
|
||||
indexList
|
||||
} = props;
|
||||
const scrollTop = (0, import_utils.getScrollTop)(scrollParent.value);
|
||||
const scrollParentRect = (0, import_use.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 = () => {
|
||||
(0, import_vue.nextTick)(onScroll);
|
||||
};
|
||||
(0, import_use.useEventListener)("scroll", onScroll, {
|
||||
target: scrollParent,
|
||||
passive: true
|
||||
});
|
||||
(0, import_vue.onMounted)(init);
|
||||
(0, import_vue.watch)(() => props.indexList, init);
|
||||
(0, import_vue.watch)(activeAnchor, (value) => {
|
||||
if (value) {
|
||||
emit("change", value);
|
||||
}
|
||||
});
|
||||
const renderIndexes = () => props.indexList.map((index) => {
|
||||
const active = index === activeAnchor.value;
|
||||
return (0, import_vue.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 = (0, import_utils.getScrollTop)(scrollParent.value);
|
||||
const scrollParentRect = (0, import_use.useRect)(scrollParent);
|
||||
const {
|
||||
offsetHeight
|
||||
} = document.documentElement;
|
||||
match.$el.scrollIntoView();
|
||||
if (scrollTop === offsetHeight - scrollParentRect.height) {
|
||||
onScroll();
|
||||
return;
|
||||
}
|
||||
if (props.sticky && props.stickyOffsetTop) {
|
||||
if ((0, import_utils.getRootScrollTop)() === offsetHeight - scrollParentRect.height) {
|
||||
(0, import_utils.setRootScrollTop)((0, import_utils.getRootScrollTop)());
|
||||
} else {
|
||||
(0, import_utils.setRootScrollTop)((0, import_utils.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()) {
|
||||
(0, import_utils.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 = () => (0, import_vue.createVNode)("div", {
|
||||
"ref": sidebar,
|
||||
"class": bem("sidebar"),
|
||||
"style": sidebarStyle.value,
|
||||
"onClick": onClickSidebar,
|
||||
"onTouchstartPassive": touch.start
|
||||
}, [renderIndexes()]);
|
||||
(0, import_use_expose.useExpose)({
|
||||
scrollTo
|
||||
});
|
||||
(0, import_use.useEventListener)("touchmove", onTouchMove, {
|
||||
target: sidebar
|
||||
});
|
||||
return () => {
|
||||
var _a;
|
||||
return (0, import_vue.createVNode)("div", {
|
||||
"ref": root,
|
||||
"class": bem()
|
||||
}, [props.teleport ? (0, import_vue.createVNode)(import_vue.Teleport, {
|
||||
"to": props.teleport
|
||||
}, {
|
||||
default: () => [renderSidebar()]
|
||||
}) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
||||
};
|
||||
}
|
||||
});
|
||||
1
node_modules/vant/lib/index-bar/index.css
generated
vendored
Normal file
1
node_modules/vant/lib/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/lib/index-bar/index.d.ts
generated
vendored
Normal file
50
node_modules/vant/lib/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;
|
||||
}
|
||||
}
|
||||
39
node_modules/vant/lib/index-bar/index.js
generated
vendored
Normal file
39
node_modules/vant/lib/index-bar/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
IndexBar: () => IndexBar,
|
||||
default: () => stdin_default,
|
||||
indexBarProps: () => import_IndexBar2.indexBarProps
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_utils = require("../utils");
|
||||
var import_IndexBar = __toESM(require("./IndexBar"));
|
||||
var import_IndexBar2 = require("./IndexBar");
|
||||
const IndexBar = (0, import_utils.withInstall)(import_IndexBar.default);
|
||||
var stdin_default = IndexBar;
|
||||
1
node_modules/vant/lib/index-bar/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/lib/index-bar/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
2
node_modules/vant/lib/index-bar/style/index.js
generated
vendored
Normal file
2
node_modules/vant/lib/index-bar/style/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
require("../../style/base.css");
|
||||
require("../index.css");
|
||||
16
node_modules/vant/lib/index-bar/types.d.ts
generated
vendored
Normal file
16
node_modules/vant/lib/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;
|
||||
};
|
||||
15
node_modules/vant/lib/index-bar/types.js
generated
vendored
Normal file
15
node_modules/vant/lib/index-bar/types.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
Reference in New Issue
Block a user