first commit
This commit is contained in:
62
node_modules/vant/es/floating-bubble/FloatingBubble.d.ts
generated
vendored
Normal file
62
node_modules/vant/es/floating-bubble/FloatingBubble.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
import { PropType, TeleportProps, type ExtractPropTypes } from 'vue';
|
||||
import { FloatingBubbleAxis, FloatingBubbleMagnetic, FloatingBubbleOffset, FloatingBubbleGap } from './types';
|
||||
export declare const floatingBubbleProps: {
|
||||
gap: {
|
||||
type: PropType<FloatingBubbleGap>;
|
||||
default: number;
|
||||
};
|
||||
icon: StringConstructor;
|
||||
axis: {
|
||||
type: PropType<FloatingBubbleAxis>;
|
||||
default: FloatingBubbleAxis;
|
||||
};
|
||||
magnetic: PropType<FloatingBubbleMagnetic>;
|
||||
offset: PropType<FloatingBubbleOffset>;
|
||||
teleport: {
|
||||
type: PropType<TeleportProps["to"]>;
|
||||
default: string;
|
||||
};
|
||||
};
|
||||
export type FloatingBubbleProps = ExtractPropTypes<typeof floatingBubbleProps>;
|
||||
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
||||
gap: {
|
||||
type: PropType<FloatingBubbleGap>;
|
||||
default: number;
|
||||
};
|
||||
icon: StringConstructor;
|
||||
axis: {
|
||||
type: PropType<FloatingBubbleAxis>;
|
||||
default: FloatingBubbleAxis;
|
||||
};
|
||||
magnetic: PropType<FloatingBubbleMagnetic>;
|
||||
offset: PropType<FloatingBubbleOffset>;
|
||||
teleport: {
|
||||
type: PropType<TeleportProps["to"]>;
|
||||
default: string;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "update:offset" | "offsetChange")[], "click" | "update:offset" | "offsetChange", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
||||
gap: {
|
||||
type: PropType<FloatingBubbleGap>;
|
||||
default: number;
|
||||
};
|
||||
icon: StringConstructor;
|
||||
axis: {
|
||||
type: PropType<FloatingBubbleAxis>;
|
||||
default: FloatingBubbleAxis;
|
||||
};
|
||||
magnetic: PropType<FloatingBubbleMagnetic>;
|
||||
offset: PropType<FloatingBubbleOffset>;
|
||||
teleport: {
|
||||
type: PropType<TeleportProps["to"]>;
|
||||
default: string;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onClick?: ((...args: any[]) => any) | undefined;
|
||||
"onUpdate:offset"?: ((...args: any[]) => any) | undefined;
|
||||
onOffsetChange?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
teleport: string | import("vue").RendererElement | null | undefined;
|
||||
gap: FloatingBubbleGap;
|
||||
axis: FloatingBubbleAxis;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
173
node_modules/vant/es/floating-bubble/FloatingBubble.mjs
generated
vendored
Normal file
173
node_modules/vant/es/floating-bubble/FloatingBubble.mjs
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
import { Teleport, computed, defineComponent, nextTick, onMounted, ref, watch, onActivated, onDeactivated, createVNode as _createVNode, vShow as _vShow, mergeProps as _mergeProps, withDirectives as _withDirectives } from "vue";
|
||||
import { pick, addUnit, closest, createNamespace, isObject, makeStringProp, windowWidth, windowHeight } from "../utils/index.mjs";
|
||||
import { useRect, useEventListener } from "@vant/use";
|
||||
import { useTouch } from "../composables/use-touch.mjs";
|
||||
import Icon from "../icon/index.mjs";
|
||||
const floatingBubbleProps = {
|
||||
gap: {
|
||||
type: [Number, Object],
|
||||
default: 24
|
||||
},
|
||||
icon: String,
|
||||
axis: makeStringProp("y"),
|
||||
magnetic: String,
|
||||
offset: Object,
|
||||
teleport: {
|
||||
type: [String, Object],
|
||||
default: "body"
|
||||
}
|
||||
};
|
||||
const [name, bem] = createNamespace("floating-bubble");
|
||||
var stdin_default = defineComponent({
|
||||
name,
|
||||
inheritAttrs: false,
|
||||
props: floatingBubbleProps,
|
||||
emits: ["click", "update:offset", "offsetChange"],
|
||||
setup(props, {
|
||||
slots,
|
||||
emit,
|
||||
attrs
|
||||
}) {
|
||||
const rootRef = ref();
|
||||
const state = ref({
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0
|
||||
});
|
||||
const gapX = computed(() => isObject(props.gap) ? props.gap.x : props.gap);
|
||||
const gapY = computed(() => isObject(props.gap) ? props.gap.y : props.gap);
|
||||
const boundary = computed(() => ({
|
||||
top: gapY.value,
|
||||
right: windowWidth.value - state.value.width - gapX.value,
|
||||
bottom: windowHeight.value - state.value.height - gapY.value,
|
||||
left: gapX.value
|
||||
}));
|
||||
const dragging = ref(false);
|
||||
let initialized = false;
|
||||
const rootStyle = computed(() => {
|
||||
const style = {};
|
||||
const x = addUnit(state.value.x);
|
||||
const y = addUnit(state.value.y);
|
||||
style.transform = `translate3d(${x}, ${y}, 0)`;
|
||||
if (dragging.value || !initialized) {
|
||||
style.transition = "none";
|
||||
}
|
||||
return style;
|
||||
});
|
||||
const updateState = () => {
|
||||
if (!show.value) return;
|
||||
const {
|
||||
width,
|
||||
height
|
||||
} = useRect(rootRef.value);
|
||||
const {
|
||||
offset
|
||||
} = props;
|
||||
state.value = {
|
||||
x: offset ? offset.x : windowWidth.value - width - gapX.value,
|
||||
y: offset ? offset.y : windowHeight.value - height - gapY.value,
|
||||
width,
|
||||
height
|
||||
};
|
||||
};
|
||||
const touch = useTouch();
|
||||
let prevX = 0;
|
||||
let prevY = 0;
|
||||
const onTouchStart = (e) => {
|
||||
touch.start(e);
|
||||
dragging.value = true;
|
||||
prevX = state.value.x;
|
||||
prevY = state.value.y;
|
||||
};
|
||||
const onTouchMove = (e) => {
|
||||
e.preventDefault();
|
||||
touch.move(e);
|
||||
if (props.axis === "lock") return;
|
||||
if (!touch.isTap.value) {
|
||||
if (props.axis === "x" || props.axis === "xy") {
|
||||
let nextX = prevX + touch.deltaX.value;
|
||||
if (nextX < boundary.value.left) nextX = boundary.value.left;
|
||||
if (nextX > boundary.value.right) nextX = boundary.value.right;
|
||||
state.value.x = nextX;
|
||||
}
|
||||
if (props.axis === "y" || props.axis === "xy") {
|
||||
let nextY = prevY + touch.deltaY.value;
|
||||
if (nextY < boundary.value.top) nextY = boundary.value.top;
|
||||
if (nextY > boundary.value.bottom) nextY = boundary.value.bottom;
|
||||
state.value.y = nextY;
|
||||
}
|
||||
const offset = pick(state.value, ["x", "y"]);
|
||||
emit("update:offset", offset);
|
||||
}
|
||||
};
|
||||
useEventListener("touchmove", onTouchMove, {
|
||||
target: rootRef
|
||||
});
|
||||
const onTouchEnd = () => {
|
||||
dragging.value = false;
|
||||
nextTick(() => {
|
||||
if (props.magnetic === "x") {
|
||||
const nextX = closest([boundary.value.left, boundary.value.right], state.value.x);
|
||||
state.value.x = nextX;
|
||||
}
|
||||
if (props.magnetic === "y") {
|
||||
const nextY = closest([boundary.value.top, boundary.value.bottom], state.value.y);
|
||||
state.value.y = nextY;
|
||||
}
|
||||
if (!touch.isTap.value) {
|
||||
const offset = pick(state.value, ["x", "y"]);
|
||||
emit("update:offset", offset);
|
||||
if (prevX !== offset.x || prevY !== offset.y) {
|
||||
emit("offsetChange", offset);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const onClick = (e) => {
|
||||
if (touch.isTap.value) emit("click", e);
|
||||
else e.stopPropagation();
|
||||
};
|
||||
onMounted(() => {
|
||||
updateState();
|
||||
nextTick(() => {
|
||||
initialized = true;
|
||||
});
|
||||
});
|
||||
watch([windowWidth, windowHeight, gapX, gapY, () => props.offset], updateState, {
|
||||
deep: true
|
||||
});
|
||||
const show = ref(true);
|
||||
onActivated(() => {
|
||||
show.value = true;
|
||||
});
|
||||
onDeactivated(() => {
|
||||
if (props.teleport) {
|
||||
show.value = false;
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
const Content = _withDirectives(_createVNode("div", _mergeProps({
|
||||
"class": bem(),
|
||||
"ref": rootRef,
|
||||
"onTouchstartPassive": onTouchStart,
|
||||
"onTouchend": onTouchEnd,
|
||||
"onTouchcancel": onTouchEnd,
|
||||
"onClickCapture": onClick,
|
||||
"style": rootStyle.value
|
||||
}, attrs), [slots.default ? slots.default() : _createVNode(Icon, {
|
||||
"name": props.icon,
|
||||
"class": bem("icon")
|
||||
}, null)]), [[_vShow, show.value]]);
|
||||
return props.teleport ? _createVNode(Teleport, {
|
||||
"to": props.teleport
|
||||
}, {
|
||||
default: () => [Content]
|
||||
}) : Content;
|
||||
};
|
||||
}
|
||||
});
|
||||
export {
|
||||
stdin_default as default,
|
||||
floatingBubbleProps
|
||||
};
|
||||
1
node_modules/vant/es/floating-bubble/index.css
generated
vendored
Normal file
1
node_modules/vant/es/floating-bubble/index.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
:root,:host{--van-floating-bubble-size: 48px;--van-floating-bubble-initial-gap: 24px;--van-floating-bubble-icon-size: 28px;--van-floating-bubble-background: var(--van-primary-color);--van-floating-bubble-color: var(--van-background-2);--van-floating-bubble-z-index: 999;--van-floating-bubble-border-radius: var(--van-radius-max)}.van-floating-bubble{position:fixed;left:0;top:0;right:var(--van-floating-bubble-initial-gap);bottom:var(--van-floating-bubble-initial-gap);width:var(--van-floating-bubble-size);height:var(--van-floating-bubble-size);box-sizing:border-box;display:flex;justify-content:center;align-items:center;overflow:hidden;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;background:var(--van-floating-bubble-background);color:var(--van-floating-bubble-color);border-radius:var(--van-floating-bubble-border-radius);z-index:var(--van-floating-bubble-z-index);transition:transform var(--van-duration-base)}.van-floating-bubble:active{opacity:.8}.van-floating-bubble__icon{font-size:var(--van-floating-bubble-icon-size)}
|
||||
50
node_modules/vant/es/floating-bubble/index.d.ts
generated
vendored
Normal file
50
node_modules/vant/es/floating-bubble/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
export declare const FloatingBubble: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
gap: {
|
||||
type: import("vue").PropType<import("./types").FloatingBubbleGap>;
|
||||
default: number;
|
||||
};
|
||||
icon: StringConstructor;
|
||||
axis: {
|
||||
type: import("vue").PropType<import("./types").FloatingBubbleAxis>;
|
||||
default: import("./types").FloatingBubbleAxis;
|
||||
};
|
||||
magnetic: import("vue").PropType<import("./types").FloatingBubbleMagnetic>;
|
||||
offset: import("vue").PropType<import("./types").FloatingBubbleOffset>;
|
||||
teleport: {
|
||||
type: import("vue").PropType<import("vue").TeleportProps["to"]>;
|
||||
default: string;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "update:offset" | "offsetChange")[], "click" | "update:offset" | "offsetChange", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
gap: {
|
||||
type: import("vue").PropType<import("./types").FloatingBubbleGap>;
|
||||
default: number;
|
||||
};
|
||||
icon: StringConstructor;
|
||||
axis: {
|
||||
type: import("vue").PropType<import("./types").FloatingBubbleAxis>;
|
||||
default: import("./types").FloatingBubbleAxis;
|
||||
};
|
||||
magnetic: import("vue").PropType<import("./types").FloatingBubbleMagnetic>;
|
||||
offset: import("vue").PropType<import("./types").FloatingBubbleOffset>;
|
||||
teleport: {
|
||||
type: import("vue").PropType<import("vue").TeleportProps["to"]>;
|
||||
default: string;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onClick?: ((...args: any[]) => any) | undefined;
|
||||
"onUpdate:offset"?: ((...args: any[]) => any) | undefined;
|
||||
onOffsetChange?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
teleport: string | import("vue").RendererElement | null | undefined;
|
||||
gap: import("./types").FloatingBubbleGap;
|
||||
axis: import("./types").FloatingBubbleAxis;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
||||
export default FloatingBubble;
|
||||
export { floatingBubbleProps } from './FloatingBubble';
|
||||
export type { FloatingBubbleProps } from './FloatingBubble';
|
||||
export type { FloatingBubbleThemeVars, FloatingBubbleAxis, FloatingBubbleMagnetic, FloatingBubbleOffset, } from './types';
|
||||
declare module 'vue' {
|
||||
interface GlobalComponents {
|
||||
VanFloatingBubble: typeof FloatingBubble;
|
||||
}
|
||||
}
|
||||
10
node_modules/vant/es/floating-bubble/index.mjs
generated
vendored
Normal file
10
node_modules/vant/es/floating-bubble/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { withInstall } from "../utils/index.mjs";
|
||||
import _FloatingBubble from "./FloatingBubble.mjs";
|
||||
const FloatingBubble = withInstall(_FloatingBubble);
|
||||
var stdin_default = FloatingBubble;
|
||||
import { floatingBubbleProps } from "./FloatingBubble.mjs";
|
||||
export {
|
||||
FloatingBubble,
|
||||
stdin_default as default,
|
||||
floatingBubbleProps
|
||||
};
|
||||
1
node_modules/vant/es/floating-bubble/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/es/floating-bubble/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
4
node_modules/vant/es/floating-bubble/style/index.mjs
generated
vendored
Normal file
4
node_modules/vant/es/floating-bubble/style/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import "../../style/base.css";
|
||||
import "../../badge/index.css";
|
||||
import "../../icon/index.css";
|
||||
import "../index.css";
|
||||
24
node_modules/vant/es/floating-bubble/types.d.ts
generated
vendored
Normal file
24
node_modules/vant/es/floating-bubble/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
export type FloatingBubbleThemeVars = {
|
||||
floatingBubbleSize?: string;
|
||||
floatingBubbleInitialGap?: string;
|
||||
floatingBubbleIconSize?: string;
|
||||
floatingBubbleBackground?: string;
|
||||
floatingBubbleColor?: string;
|
||||
floatingBubbleZIndex?: number | string;
|
||||
};
|
||||
export type FloatingBubbleAxis = 'x' | 'y' | 'xy' | 'lock';
|
||||
export type FloatingBubbleMagnetic = 'x' | 'y';
|
||||
export type FloatingBubbleOffset = {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
export type FloatingBubbleGap = number | {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
export type FloatingBubbleBoundary = {
|
||||
top: number;
|
||||
right: number;
|
||||
bottom: number;
|
||||
left: number;
|
||||
};
|
||||
0
node_modules/vant/es/floating-bubble/types.mjs
generated
vendored
Normal file
0
node_modules/vant/es/floating-bubble/types.mjs
generated
vendored
Normal file
Reference in New Issue
Block a user