@v-c/tour 0.0.1
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/Mask.cjs +162 -0
- package/dist/Mask.d.ts +21 -0
- package/dist/Mask.js +159 -0
- package/dist/Placeholder.cjs +58 -0
- package/dist/Placeholder.d.ts +8 -0
- package/dist/Placeholder.js +54 -0
- package/dist/Tour.cjs +324 -0
- package/dist/Tour.d.ts +4 -0
- package/dist/Tour.js +321 -0
- package/dist/TourStep/DefaultPanel.cjs +175 -0
- package/dist/TourStep/DefaultPanel.d.ts +8 -0
- package/dist/TourStep/DefaultPanel.js +171 -0
- package/dist/TourStep/index.cjs +128 -0
- package/dist/TourStep/index.d.ts +5 -0
- package/dist/TourStep/index.js +125 -0
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/hooks/useClosable.cjs +23 -0
- package/dist/hooks/useClosable.d.ts +5 -0
- package/dist/hooks/useClosable.js +22 -0
- package/dist/hooks/useTarget.cjs +74 -0
- package/dist/hooks/useTarget.d.ts +20 -0
- package/dist/hooks/useTarget.js +72 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/interface.cjs +0 -0
- package/dist/interface.d.ts +81 -0
- package/dist/interface.js +0 -0
- package/dist/placements.cjs +65 -0
- package/dist/placements.d.ts +4 -0
- package/dist/placements.js +64 -0
- package/dist/util.cjs +11 -0
- package/dist/util.d.ts +3 -0
- package/dist/util.js +10 -0
- package/package.json +42 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
|
+
const require_util = require("../util.cjs");
|
|
4
|
+
let vue = require("vue");
|
|
5
|
+
function isValidNumber(val) {
|
|
6
|
+
return typeof val === "number" && !Number.isNaN(val);
|
|
7
|
+
}
|
|
8
|
+
function useTarget(target, open, gap, scrollIntoViewOptions, inlineMode, placeholderRef) {
|
|
9
|
+
const targetElement = (0, vue.shallowRef)(null);
|
|
10
|
+
const syncTargetElement = () => {
|
|
11
|
+
targetElement.value = (typeof target.value === "function" ? target.value() : target.value) || null;
|
|
12
|
+
};
|
|
13
|
+
(0, vue.watch)(target, () => {
|
|
14
|
+
syncTargetElement();
|
|
15
|
+
}, {
|
|
16
|
+
immediate: true,
|
|
17
|
+
flush: "post"
|
|
18
|
+
});
|
|
19
|
+
const posInfo = (0, vue.shallowRef)(null);
|
|
20
|
+
const updatePos = () => {
|
|
21
|
+
if (targetElement.value) {
|
|
22
|
+
if (!inlineMode?.value && !require_util.isInViewPort(targetElement.value) && open.value) targetElement.value?.scrollIntoView(scrollIntoViewOptions.value);
|
|
23
|
+
const { left, top, width, height } = targetElement.value.getBoundingClientRect();
|
|
24
|
+
const nextPosInfo = {
|
|
25
|
+
left,
|
|
26
|
+
top,
|
|
27
|
+
width,
|
|
28
|
+
height,
|
|
29
|
+
radius: 0
|
|
30
|
+
};
|
|
31
|
+
if (inlineMode?.value) {
|
|
32
|
+
const parentRect = placeholderRef?.value?.parentElement?.getBoundingClientRect?.();
|
|
33
|
+
if (parentRect) {
|
|
34
|
+
nextPosInfo.left -= parentRect.left;
|
|
35
|
+
nextPosInfo.top -= parentRect.top;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const origin = posInfo.value;
|
|
39
|
+
if (JSON.stringify(origin) !== JSON.stringify(nextPosInfo)) posInfo.value = nextPosInfo;
|
|
40
|
+
} else posInfo.value = null;
|
|
41
|
+
};
|
|
42
|
+
(0, vue.onMounted)(() => {
|
|
43
|
+
syncTargetElement();
|
|
44
|
+
updatePos();
|
|
45
|
+
});
|
|
46
|
+
const getGapOffset = (index) => (Array.isArray(gap?.value?.offset) ? gap?.value?.offset[index] : gap?.value?.offset) ?? 6;
|
|
47
|
+
(0, vue.watch)([targetElement, open], async (_n, _o, onCleanup) => {
|
|
48
|
+
await (0, vue.nextTick)();
|
|
49
|
+
updatePos();
|
|
50
|
+
window.addEventListener("resize", updatePos);
|
|
51
|
+
window.addEventListener("scroll", updatePos);
|
|
52
|
+
onCleanup(() => {
|
|
53
|
+
window.removeEventListener("resize", updatePos);
|
|
54
|
+
window.removeEventListener("scroll", updatePos);
|
|
55
|
+
});
|
|
56
|
+
}, {
|
|
57
|
+
immediate: true,
|
|
58
|
+
flush: "post"
|
|
59
|
+
});
|
|
60
|
+
return [(0, vue.computed)(() => {
|
|
61
|
+
if (!posInfo.value) return posInfo.value;
|
|
62
|
+
const gapOffsetX = getGapOffset(0);
|
|
63
|
+
const gapOffsetY = getGapOffset(1);
|
|
64
|
+
const gapRadius = isValidNumber(gap?.value?.radius) ? gap?.value?.radius : 2;
|
|
65
|
+
return {
|
|
66
|
+
left: posInfo.value.left - gapOffsetX,
|
|
67
|
+
top: posInfo.value.top - gapOffsetY,
|
|
68
|
+
width: posInfo.value.width + gapOffsetX * 2,
|
|
69
|
+
height: posInfo.value.height + gapOffsetY * 2,
|
|
70
|
+
radius: gapRadius
|
|
71
|
+
};
|
|
72
|
+
}), targetElement];
|
|
73
|
+
}
|
|
74
|
+
exports.default = useTarget;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { TourStepInfo } from '../interface.ts';
|
|
3
|
+
export interface Gap {
|
|
4
|
+
offset?: number | [number, number];
|
|
5
|
+
radius?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface PosInfo {
|
|
8
|
+
left: number;
|
|
9
|
+
top: number;
|
|
10
|
+
height: number;
|
|
11
|
+
width: number;
|
|
12
|
+
radius: number;
|
|
13
|
+
}
|
|
14
|
+
export default function useTarget(target: Ref<TourStepInfo['target']>, open: Ref<boolean>, gap?: Ref<Gap | undefined>, scrollIntoViewOptions?: Ref<boolean | ScrollIntoViewOptions>, inlineMode?: Ref<boolean>, placeholderRef?: Ref<HTMLDivElement | null>): readonly [import('vue').ComputedRef<{
|
|
15
|
+
left: number;
|
|
16
|
+
top: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
radius: number | undefined;
|
|
20
|
+
} | null>, import('vue').ShallowRef<HTMLElement | null, HTMLElement | null>];
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { isInViewPort } from "../util.js";
|
|
2
|
+
import { computed, nextTick, onMounted, shallowRef, watch } from "vue";
|
|
3
|
+
function isValidNumber(val) {
|
|
4
|
+
return typeof val === "number" && !Number.isNaN(val);
|
|
5
|
+
}
|
|
6
|
+
function useTarget(target, open, gap, scrollIntoViewOptions, inlineMode, placeholderRef) {
|
|
7
|
+
const targetElement = shallowRef(null);
|
|
8
|
+
const syncTargetElement = () => {
|
|
9
|
+
targetElement.value = (typeof target.value === "function" ? target.value() : target.value) || null;
|
|
10
|
+
};
|
|
11
|
+
watch(target, () => {
|
|
12
|
+
syncTargetElement();
|
|
13
|
+
}, {
|
|
14
|
+
immediate: true,
|
|
15
|
+
flush: "post"
|
|
16
|
+
});
|
|
17
|
+
const posInfo = shallowRef(null);
|
|
18
|
+
const updatePos = () => {
|
|
19
|
+
if (targetElement.value) {
|
|
20
|
+
if (!inlineMode?.value && !isInViewPort(targetElement.value) && open.value) targetElement.value?.scrollIntoView(scrollIntoViewOptions.value);
|
|
21
|
+
const { left, top, width, height } = targetElement.value.getBoundingClientRect();
|
|
22
|
+
const nextPosInfo = {
|
|
23
|
+
left,
|
|
24
|
+
top,
|
|
25
|
+
width,
|
|
26
|
+
height,
|
|
27
|
+
radius: 0
|
|
28
|
+
};
|
|
29
|
+
if (inlineMode?.value) {
|
|
30
|
+
const parentRect = placeholderRef?.value?.parentElement?.getBoundingClientRect?.();
|
|
31
|
+
if (parentRect) {
|
|
32
|
+
nextPosInfo.left -= parentRect.left;
|
|
33
|
+
nextPosInfo.top -= parentRect.top;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const origin = posInfo.value;
|
|
37
|
+
if (JSON.stringify(origin) !== JSON.stringify(nextPosInfo)) posInfo.value = nextPosInfo;
|
|
38
|
+
} else posInfo.value = null;
|
|
39
|
+
};
|
|
40
|
+
onMounted(() => {
|
|
41
|
+
syncTargetElement();
|
|
42
|
+
updatePos();
|
|
43
|
+
});
|
|
44
|
+
const getGapOffset = (index) => (Array.isArray(gap?.value?.offset) ? gap?.value?.offset[index] : gap?.value?.offset) ?? 6;
|
|
45
|
+
watch([targetElement, open], async (_n, _o, onCleanup) => {
|
|
46
|
+
await nextTick();
|
|
47
|
+
updatePos();
|
|
48
|
+
window.addEventListener("resize", updatePos);
|
|
49
|
+
window.addEventListener("scroll", updatePos);
|
|
50
|
+
onCleanup(() => {
|
|
51
|
+
window.removeEventListener("resize", updatePos);
|
|
52
|
+
window.removeEventListener("scroll", updatePos);
|
|
53
|
+
});
|
|
54
|
+
}, {
|
|
55
|
+
immediate: true,
|
|
56
|
+
flush: "post"
|
|
57
|
+
});
|
|
58
|
+
return [computed(() => {
|
|
59
|
+
if (!posInfo.value) return posInfo.value;
|
|
60
|
+
const gapOffsetX = getGapOffset(0);
|
|
61
|
+
const gapOffsetY = getGapOffset(1);
|
|
62
|
+
const gapRadius = isValidNumber(gap?.value?.radius) ? gap?.value?.radius : 2;
|
|
63
|
+
return {
|
|
64
|
+
left: posInfo.value.left - gapOffsetX,
|
|
65
|
+
top: posInfo.value.top - gapOffsetY,
|
|
66
|
+
width: posInfo.value.width + gapOffsetX * 2,
|
|
67
|
+
height: posInfo.value.height + gapOffsetY * 2,
|
|
68
|
+
radius: gapRadius
|
|
69
|
+
};
|
|
70
|
+
}), targetElement];
|
|
71
|
+
}
|
|
72
|
+
export { useTarget as default };
|
package/dist/index.cjs
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { TriggerProps } from '@v-c/trigger';
|
|
2
|
+
import { VueNode } from '@v-c/util/dist/type';
|
|
3
|
+
import { AriaAttributes, CSSProperties, Ref } from 'vue';
|
|
4
|
+
import { Gap } from './hooks/useTarget.ts';
|
|
5
|
+
import { PlacementType } from './placements';
|
|
6
|
+
import { DefaultPanelProps } from './TourStep/DefaultPanel.tsx';
|
|
7
|
+
export type SemanticName = 'section' | 'footer' | 'actions' | 'header' | 'title' | 'description' | 'mask';
|
|
8
|
+
export type HTMLAriaDataAttributes = AriaAttributes & {
|
|
9
|
+
[key: `data-${string}`]: unknown;
|
|
10
|
+
role?: string;
|
|
11
|
+
};
|
|
12
|
+
export interface TourStepInfo {
|
|
13
|
+
arrow?: boolean | {
|
|
14
|
+
pointAtCenter: boolean;
|
|
15
|
+
};
|
|
16
|
+
target?: Ref<HTMLElement | null | undefined> | HTMLElement | null | (() => HTMLElement | null | undefined);
|
|
17
|
+
title: VueNode;
|
|
18
|
+
description?: VueNode;
|
|
19
|
+
placement?: PlacementType;
|
|
20
|
+
className?: string;
|
|
21
|
+
style?: CSSProperties;
|
|
22
|
+
mask?: boolean | {
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
color?: string;
|
|
25
|
+
};
|
|
26
|
+
scrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
|
|
27
|
+
closeIcon?: VueNode;
|
|
28
|
+
closable?: boolean | ({
|
|
29
|
+
closeIcon?: VueNode;
|
|
30
|
+
} & HTMLAriaDataAttributes);
|
|
31
|
+
}
|
|
32
|
+
export interface TourStepProps extends TourStepInfo {
|
|
33
|
+
prefixCls?: string;
|
|
34
|
+
total?: number;
|
|
35
|
+
current?: number;
|
|
36
|
+
onClose?: () => void;
|
|
37
|
+
onFinish?: () => void;
|
|
38
|
+
renderPanel?: (step: DefaultPanelProps, current: number) => VueNode;
|
|
39
|
+
onPrev?: () => void;
|
|
40
|
+
onNext?: () => void;
|
|
41
|
+
classNames?: Partial<Record<SemanticName, string>>;
|
|
42
|
+
styles?: Partial<Record<SemanticName, CSSProperties>>;
|
|
43
|
+
}
|
|
44
|
+
export interface TourProps extends Pick<TriggerProps, 'onPopupAlign'> {
|
|
45
|
+
classNames?: Partial<Record<SemanticName, string>>;
|
|
46
|
+
styles?: Partial<Record<SemanticName, CSSProperties>>;
|
|
47
|
+
className?: string;
|
|
48
|
+
style?: CSSProperties;
|
|
49
|
+
steps?: TourStepInfo[];
|
|
50
|
+
open?: boolean;
|
|
51
|
+
defaultOpen?: boolean;
|
|
52
|
+
defaultCurrent?: number;
|
|
53
|
+
current?: number;
|
|
54
|
+
onChange?: (current: number) => void;
|
|
55
|
+
onClose?: (current: number) => void;
|
|
56
|
+
onFinish?: () => void;
|
|
57
|
+
closeIcon?: TourStepProps['closeIcon'];
|
|
58
|
+
closable?: TourStepProps['closable'];
|
|
59
|
+
mask?: boolean | {
|
|
60
|
+
style?: CSSProperties;
|
|
61
|
+
color?: string;
|
|
62
|
+
};
|
|
63
|
+
arrow?: boolean | {
|
|
64
|
+
pointAtCenter: boolean;
|
|
65
|
+
};
|
|
66
|
+
rootClassName?: string;
|
|
67
|
+
placement?: PlacementType;
|
|
68
|
+
prefixCls?: string;
|
|
69
|
+
renderPanel?: (props: DefaultPanelProps, current: number) => VueNode;
|
|
70
|
+
gap?: Gap;
|
|
71
|
+
animated?: boolean | {
|
|
72
|
+
placeholder: boolean;
|
|
73
|
+
};
|
|
74
|
+
scrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
|
|
75
|
+
zIndex?: number;
|
|
76
|
+
getPopupContainer?: TriggerProps['getPopupContainer'] | false;
|
|
77
|
+
builtinPlacements?: TriggerProps['builtinPlacements'] | ((config?: {
|
|
78
|
+
arrowPointAtCenter?: boolean;
|
|
79
|
+
}) => TriggerProps['builtinPlacements']);
|
|
80
|
+
disabledInteraction?: boolean;
|
|
81
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var targetOffset = [0, 0];
|
|
2
|
+
var basePlacements = {
|
|
3
|
+
left: {
|
|
4
|
+
points: ["cr", "cl"],
|
|
5
|
+
offset: [-8, 0]
|
|
6
|
+
},
|
|
7
|
+
right: {
|
|
8
|
+
points: ["cl", "cr"],
|
|
9
|
+
offset: [8, 0]
|
|
10
|
+
},
|
|
11
|
+
top: {
|
|
12
|
+
points: ["bc", "tc"],
|
|
13
|
+
offset: [0, -8]
|
|
14
|
+
},
|
|
15
|
+
bottom: {
|
|
16
|
+
points: ["tc", "bc"],
|
|
17
|
+
offset: [0, 8]
|
|
18
|
+
},
|
|
19
|
+
topLeft: {
|
|
20
|
+
points: ["bl", "tl"],
|
|
21
|
+
offset: [0, -8]
|
|
22
|
+
},
|
|
23
|
+
leftTop: {
|
|
24
|
+
points: ["tr", "tl"],
|
|
25
|
+
offset: [-8, 0]
|
|
26
|
+
},
|
|
27
|
+
topRight: {
|
|
28
|
+
points: ["br", "tr"],
|
|
29
|
+
offset: [0, -8]
|
|
30
|
+
},
|
|
31
|
+
rightTop: {
|
|
32
|
+
points: ["tl", "tr"],
|
|
33
|
+
offset: [8, 0]
|
|
34
|
+
},
|
|
35
|
+
bottomRight: {
|
|
36
|
+
points: ["tr", "br"],
|
|
37
|
+
offset: [0, 8]
|
|
38
|
+
},
|
|
39
|
+
rightBottom: {
|
|
40
|
+
points: ["bl", "br"],
|
|
41
|
+
offset: [8, 0]
|
|
42
|
+
},
|
|
43
|
+
bottomLeft: {
|
|
44
|
+
points: ["tl", "bl"],
|
|
45
|
+
offset: [0, 8]
|
|
46
|
+
},
|
|
47
|
+
leftBottom: {
|
|
48
|
+
points: ["br", "bl"],
|
|
49
|
+
offset: [-8, 0]
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function getPlacements(arrowPointAtCenter = false) {
|
|
53
|
+
const placements$1 = {};
|
|
54
|
+
Object.keys(basePlacements).forEach((key) => {
|
|
55
|
+
placements$1[key] = {
|
|
56
|
+
...basePlacements[key],
|
|
57
|
+
autoArrow: arrowPointAtCenter,
|
|
58
|
+
targetOffset
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
return placements$1;
|
|
62
|
+
}
|
|
63
|
+
const placements = getPlacements();
|
|
64
|
+
exports.getPlacements = getPlacements;
|
|
65
|
+
exports.placements = placements;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BuildInPlacements } from '@v-c/trigger';
|
|
2
|
+
export type PlacementType = 'left' | 'leftTop' | 'leftBottom' | 'right' | 'rightTop' | 'rightBottom' | 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight' | 'center';
|
|
3
|
+
export declare function getPlacements(arrowPointAtCenter?: boolean): BuildInPlacements;
|
|
4
|
+
export declare const placements: BuildInPlacements;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var targetOffset = [0, 0];
|
|
2
|
+
var basePlacements = {
|
|
3
|
+
left: {
|
|
4
|
+
points: ["cr", "cl"],
|
|
5
|
+
offset: [-8, 0]
|
|
6
|
+
},
|
|
7
|
+
right: {
|
|
8
|
+
points: ["cl", "cr"],
|
|
9
|
+
offset: [8, 0]
|
|
10
|
+
},
|
|
11
|
+
top: {
|
|
12
|
+
points: ["bc", "tc"],
|
|
13
|
+
offset: [0, -8]
|
|
14
|
+
},
|
|
15
|
+
bottom: {
|
|
16
|
+
points: ["tc", "bc"],
|
|
17
|
+
offset: [0, 8]
|
|
18
|
+
},
|
|
19
|
+
topLeft: {
|
|
20
|
+
points: ["bl", "tl"],
|
|
21
|
+
offset: [0, -8]
|
|
22
|
+
},
|
|
23
|
+
leftTop: {
|
|
24
|
+
points: ["tr", "tl"],
|
|
25
|
+
offset: [-8, 0]
|
|
26
|
+
},
|
|
27
|
+
topRight: {
|
|
28
|
+
points: ["br", "tr"],
|
|
29
|
+
offset: [0, -8]
|
|
30
|
+
},
|
|
31
|
+
rightTop: {
|
|
32
|
+
points: ["tl", "tr"],
|
|
33
|
+
offset: [8, 0]
|
|
34
|
+
},
|
|
35
|
+
bottomRight: {
|
|
36
|
+
points: ["tr", "br"],
|
|
37
|
+
offset: [0, 8]
|
|
38
|
+
},
|
|
39
|
+
rightBottom: {
|
|
40
|
+
points: ["bl", "br"],
|
|
41
|
+
offset: [8, 0]
|
|
42
|
+
},
|
|
43
|
+
bottomLeft: {
|
|
44
|
+
points: ["tl", "bl"],
|
|
45
|
+
offset: [0, 8]
|
|
46
|
+
},
|
|
47
|
+
leftBottom: {
|
|
48
|
+
points: ["br", "bl"],
|
|
49
|
+
offset: [-8, 0]
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function getPlacements(arrowPointAtCenter = false) {
|
|
53
|
+
const placements$1 = {};
|
|
54
|
+
Object.keys(basePlacements).forEach((key) => {
|
|
55
|
+
placements$1[key] = {
|
|
56
|
+
...basePlacements[key],
|
|
57
|
+
autoArrow: arrowPointAtCenter,
|
|
58
|
+
targetOffset
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
return placements$1;
|
|
62
|
+
}
|
|
63
|
+
const placements = getPlacements();
|
|
64
|
+
export { getPlacements, placements };
|
package/dist/util.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function isInViewPort(element) {
|
|
2
|
+
const viewWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
3
|
+
const viewHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
4
|
+
const { top, right, bottom, left } = element.getBoundingClientRect();
|
|
5
|
+
return top >= 0 && left >= 0 && right <= viewWidth && bottom <= viewHeight;
|
|
6
|
+
}
|
|
7
|
+
function getPlacement(targetElement, placement, stepPlacement) {
|
|
8
|
+
return stepPlacement ?? placement ?? (targetElement === null ? "center" : "bottom");
|
|
9
|
+
}
|
|
10
|
+
exports.getPlacement = getPlacement;
|
|
11
|
+
exports.isInViewPort = isInViewPort;
|
package/dist/util.d.ts
ADDED
package/dist/util.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function isInViewPort(element) {
|
|
2
|
+
const viewWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
3
|
+
const viewHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
4
|
+
const { top, right, bottom, left } = element.getBoundingClientRect();
|
|
5
|
+
return top >= 0 && left >= 0 && right <= viewWidth && bottom <= viewHeight;
|
|
6
|
+
}
|
|
7
|
+
function getPlacement(targetElement, placement, stepPlacement) {
|
|
8
|
+
return stepPlacement ?? placement ?? (targetElement === null ? "center" : "bottom");
|
|
9
|
+
}
|
|
10
|
+
export { getPlacement, isInViewPort };
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@v-c/tour",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"description": "tour",
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"tour"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"require": "./dist/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./dist/*": "./dist/*",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"package.json"
|
|
27
|
+
],
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"vue": "^3.0.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@v-c/trigger": "0.0.14",
|
|
33
|
+
"@v-c/util": "0.0.13",
|
|
34
|
+
"@v-c/portal": "0.0.5"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build",
|
|
38
|
+
"test": "vitest",
|
|
39
|
+
"prepublish": "pnpm build",
|
|
40
|
+
"bump": "bumpp --release patch"
|
|
41
|
+
}
|
|
42
|
+
}
|