@v-c/image 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.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Image.cjs +228 -0
  3. package/dist/Image.d.ts +46 -0
  4. package/dist/Image.js +226 -0
  5. package/dist/Preview/CloseBtn.cjs +41 -0
  6. package/dist/Preview/CloseBtn.d.ts +8 -0
  7. package/dist/Preview/CloseBtn.js +39 -0
  8. package/dist/Preview/Footer.cjs +231 -0
  9. package/dist/Preview/Footer.d.ts +24 -0
  10. package/dist/Preview/Footer.js +229 -0
  11. package/dist/Preview/PrevNext.cjs +56 -0
  12. package/dist/Preview/PrevNext.d.ts +10 -0
  13. package/dist/Preview/PrevNext.js +54 -0
  14. package/dist/Preview/index.cjs +399 -0
  15. package/dist/Preview/index.d.ts +101 -0
  16. package/dist/Preview/index.js +397 -0
  17. package/dist/PreviewGroup.cjs +135 -0
  18. package/dist/PreviewGroup.d.ts +34 -0
  19. package/dist/PreviewGroup.js +133 -0
  20. package/dist/common.cjs +12 -0
  21. package/dist/common.d.ts +2 -0
  22. package/dist/common.js +12 -0
  23. package/dist/context.cjs +10 -0
  24. package/dist/context.d.ts +7 -0
  25. package/dist/context.js +9 -0
  26. package/dist/getFixScaleEleTransPosition.cjs +25 -0
  27. package/dist/getFixScaleEleTransPosition.d.ts +16 -0
  28. package/dist/getFixScaleEleTransPosition.js +24 -0
  29. package/dist/hooks/useImageTransform.cjs +96 -0
  30. package/dist/hooks/useImageTransform.d.ts +21 -0
  31. package/dist/hooks/useImageTransform.js +95 -0
  32. package/dist/hooks/useMouseEvent.cjs +93 -0
  33. package/dist/hooks/useMouseEvent.d.ts +9 -0
  34. package/dist/hooks/useMouseEvent.js +92 -0
  35. package/dist/hooks/usePreviewItems.cjs +45 -0
  36. package/dist/hooks/usePreviewItems.d.ts +10 -0
  37. package/dist/hooks/usePreviewItems.js +44 -0
  38. package/dist/hooks/useRegisterImage.cjs +25 -0
  39. package/dist/hooks/useRegisterImage.d.ts +3 -0
  40. package/dist/hooks/useRegisterImage.js +24 -0
  41. package/dist/hooks/useStatus.cjs +46 -0
  42. package/dist/hooks/useStatus.d.ts +13 -0
  43. package/dist/hooks/useStatus.js +45 -0
  44. package/dist/hooks/useTouchEvent.cjs +120 -0
  45. package/dist/hooks/useTouchEvent.d.ts +8 -0
  46. package/dist/hooks/useTouchEvent.js +119 -0
  47. package/dist/index.cjs +8 -0
  48. package/dist/index.d.ts +11 -0
  49. package/dist/index.js +6 -0
  50. package/dist/interface.cjs +0 -0
  51. package/dist/interface.d.ts +13 -0
  52. package/dist/interface.js +0 -0
  53. package/dist/portal/dist/Context.cjs +12 -0
  54. package/dist/portal/dist/Context.js +11 -0
  55. package/dist/portal/dist/Portal.cjs +91 -0
  56. package/dist/portal/dist/Portal.js +91 -0
  57. package/dist/portal/dist/index.cjs +3 -0
  58. package/dist/portal/dist/index.js +3 -0
  59. package/dist/portal/dist/useDom.cjs +47 -0
  60. package/dist/portal/dist/useDom.js +47 -0
  61. package/dist/portal/dist/useScrollLocker.cjs +26 -0
  62. package/dist/portal/dist/useScrollLocker.js +26 -0
  63. package/dist/portal/dist/util.cjs +4 -0
  64. package/dist/portal/dist/util.js +4 -0
  65. package/dist/previewConfig.cjs +4 -0
  66. package/dist/previewConfig.d.ts +4 -0
  67. package/dist/previewConfig.js +3 -0
  68. package/dist/util/dist/Dom/canUseDom.cjs +4 -0
  69. package/dist/util/dist/Dom/canUseDom.js +4 -0
  70. package/dist/util/dist/Dom/contains.cjs +11 -0
  71. package/dist/util/dist/Dom/contains.js +11 -0
  72. package/dist/util/dist/Dom/dynamicCSS.cjs +78 -0
  73. package/dist/util/dist/Dom/dynamicCSS.js +77 -0
  74. package/dist/util/dist/KeyCode.cjs +81 -0
  75. package/dist/util/dist/KeyCode.js +81 -0
  76. package/dist/util/dist/RenderComponent.cjs +29 -0
  77. package/dist/util/dist/RenderComponent.js +29 -0
  78. package/dist/util/dist/classnames.cjs +36 -0
  79. package/dist/util/dist/classnames.js +35 -0
  80. package/dist/util/dist/getScrollBarSize.cjs +45 -0
  81. package/dist/util/dist/getScrollBarSize.js +45 -0
  82. package/dist/util/dist/hooks/useMergedState.cjs +24 -0
  83. package/dist/util/dist/hooks/useMergedState.js +24 -0
  84. package/dist/util/dist/index.cjs +3 -0
  85. package/dist/util/dist/index.js +3 -0
  86. package/dist/util/dist/isEqual.cjs +27 -0
  87. package/dist/util/dist/isEqual.js +27 -0
  88. package/dist/util/dist/omit.cjs +8 -0
  89. package/dist/util/dist/omit.js +8 -0
  90. package/dist/util/dist/pickAttrs.cjs +39 -0
  91. package/dist/util/dist/pickAttrs.js +39 -0
  92. package/dist/util/dist/props-util/index.cjs +47 -0
  93. package/dist/util/dist/props-util/index.js +44 -0
  94. package/dist/util/dist/raf.cjs +36 -0
  95. package/dist/util/dist/raf.js +36 -0
  96. package/dist/util/dist/type.cjs +2 -0
  97. package/dist/util/dist/type.js +2 -0
  98. package/dist/util/dist/utils/transition.cjs +21 -0
  99. package/dist/util/dist/utils/transition.js +21 -0
  100. package/dist/util/dist/warning.cjs +37 -0
  101. package/dist/util/dist/warning.js +37 -0
  102. package/dist/util.cjs +26 -0
  103. package/dist/util.d.ts +5 -0
  104. package/dist/util.js +25 -0
  105. package/package.json +48 -0
@@ -0,0 +1,24 @@
1
+ import { usePreviewGroupContext } from "../context.js";
2
+ import { onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
3
+ var uid = 0;
4
+ function useRegisterImage(canPreview, data) {
5
+ uid += 1;
6
+ const id = shallowRef(String(uid));
7
+ const groupContext = usePreviewGroupContext();
8
+ const registerData = () => ({
9
+ data: data.value,
10
+ canPreview: canPreview.value
11
+ });
12
+ let unRegister;
13
+ onMounted(() => {
14
+ if (groupContext) unRegister = groupContext.register(id.value, registerData());
15
+ });
16
+ watch([canPreview, data], () => {
17
+ if (groupContext) groupContext.register(id.value, registerData());
18
+ }, { deep: true });
19
+ onBeforeUnmount(() => {
20
+ unRegister?.();
21
+ });
22
+ return id.value;
23
+ }
24
+ export { useRegisterImage as default };
@@ -0,0 +1,46 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ const require_util = require("../util.cjs");
3
+ let vue = require("vue");
4
+ function useStatus(options) {
5
+ const { src, isCustomPlaceholder, fallback } = options;
6
+ const status = (0, vue.shallowRef)(isCustomPlaceholder?.value ? "loading" : "normal");
7
+ const isLoaded = (0, vue.shallowRef)(false);
8
+ const isError = (0, vue.computed)(() => status.value === "error");
9
+ (0, vue.watchEffect)((onCleanup) => {
10
+ let isCurrentSrc = true;
11
+ require_util.isImageValid(src.value || "").then((isValid) => {
12
+ if (!isValid && isCurrentSrc) status.value = "error";
13
+ });
14
+ onCleanup(() => {
15
+ isCurrentSrc = false;
16
+ });
17
+ });
18
+ (0, vue.watch)(() => src.value, () => {
19
+ isLoaded.value = false;
20
+ if (isCustomPlaceholder?.value && !isLoaded.value) status.value = "loading";
21
+ else if (isError.value) status.value = "normal";
22
+ }, { immediate: true });
23
+ const onLoad = () => {
24
+ isLoaded.value = true;
25
+ status.value = "normal";
26
+ };
27
+ const getImgRef = (img) => {
28
+ isLoaded.value = false;
29
+ if (status.value === "loading" && img?.complete && (img.naturalWidth || img.naturalHeight)) {
30
+ isLoaded.value = true;
31
+ onLoad();
32
+ }
33
+ };
34
+ return [
35
+ getImgRef,
36
+ (0, vue.computed)(() => {
37
+ if (isError.value && fallback?.value) return { src: fallback.value };
38
+ return {
39
+ onLoad,
40
+ src: src.value
41
+ };
42
+ }),
43
+ status
44
+ ];
45
+ }
46
+ exports.default = useStatus;
@@ -0,0 +1,13 @@
1
+ import { Ref } from 'vue';
2
+ export type ImageStatus = 'normal' | 'error' | 'loading';
3
+ export default function useStatus(options: {
4
+ src: Ref<string | undefined>;
5
+ isCustomPlaceholder?: Ref<boolean>;
6
+ fallback?: Ref<string | undefined>;
7
+ }): readonly [(img?: HTMLImageElement | null) => void, import('vue').ComputedRef<{
8
+ src: string;
9
+ onLoad?: undefined;
10
+ } | {
11
+ onLoad: () => void;
12
+ src: string | undefined;
13
+ }>, import('vue').ShallowRef<ImageStatus, ImageStatus>];
@@ -0,0 +1,45 @@
1
+ import { isImageValid } from "../util.js";
2
+ import { computed, shallowRef, watch, watchEffect } from "vue";
3
+ function useStatus(options) {
4
+ const { src, isCustomPlaceholder, fallback } = options;
5
+ const status = shallowRef(isCustomPlaceholder?.value ? "loading" : "normal");
6
+ const isLoaded = shallowRef(false);
7
+ const isError = computed(() => status.value === "error");
8
+ watchEffect((onCleanup) => {
9
+ let isCurrentSrc = true;
10
+ isImageValid(src.value || "").then((isValid) => {
11
+ if (!isValid && isCurrentSrc) status.value = "error";
12
+ });
13
+ onCleanup(() => {
14
+ isCurrentSrc = false;
15
+ });
16
+ });
17
+ watch(() => src.value, () => {
18
+ isLoaded.value = false;
19
+ if (isCustomPlaceholder?.value && !isLoaded.value) status.value = "loading";
20
+ else if (isError.value) status.value = "normal";
21
+ }, { immediate: true });
22
+ const onLoad = () => {
23
+ isLoaded.value = true;
24
+ status.value = "normal";
25
+ };
26
+ const getImgRef = (img) => {
27
+ isLoaded.value = false;
28
+ if (status.value === "loading" && img?.complete && (img.naturalWidth || img.naturalHeight)) {
29
+ isLoaded.value = true;
30
+ onLoad();
31
+ }
32
+ };
33
+ return [
34
+ getImgRef,
35
+ computed(() => {
36
+ if (isError.value && fallback?.value) return { src: fallback.value };
37
+ return {
38
+ onLoad,
39
+ src: src.value
40
+ };
41
+ }),
42
+ status
43
+ ];
44
+ }
45
+ export { useStatus as default };
@@ -0,0 +1,120 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ const require_getFixScaleEleTransPosition = require("../getFixScaleEleTransPosition.cjs");
3
+ let vue = require("vue");
4
+ function getDistance(a, b) {
5
+ const x = a.x - b.x;
6
+ const y = a.y - b.y;
7
+ return Math.hypot(x, y);
8
+ }
9
+ function getCenter(oldPoint1, oldPoint2, newPoint1, newPoint2) {
10
+ const distance1 = getDistance(oldPoint1, newPoint1);
11
+ const distance2 = getDistance(oldPoint2, newPoint2);
12
+ if (distance1 === 0 && distance2 === 0) return [oldPoint1.x, oldPoint1.y];
13
+ const ratio = distance1 / (distance1 + distance2);
14
+ return [oldPoint1.x + ratio * (oldPoint2.x - oldPoint1.x), oldPoint1.y + ratio * (oldPoint2.y - oldPoint1.y)];
15
+ }
16
+ function useTouchEvent(imgRef, movable, open, minScale, transform, updateTransform, dispatchZoomChange) {
17
+ const isTouching = (0, vue.shallowRef)(false);
18
+ const touchPointInfo = (0, vue.shallowRef)({
19
+ point1: {
20
+ x: 0,
21
+ y: 0
22
+ },
23
+ point2: {
24
+ x: 0,
25
+ y: 0
26
+ },
27
+ eventType: "none"
28
+ });
29
+ const updateTouchPointInfo = (values) => {
30
+ touchPointInfo.value = {
31
+ ...touchPointInfo.value,
32
+ ...values
33
+ };
34
+ };
35
+ const onTouchStart = (event) => {
36
+ if (!movable.value) return;
37
+ event.stopPropagation();
38
+ isTouching.value = true;
39
+ const { touches = [] } = event;
40
+ const { x, y } = transform.value;
41
+ if (touches.length > 1) updateTouchPointInfo({
42
+ point1: {
43
+ x: touches[0].clientX,
44
+ y: touches[0].clientY
45
+ },
46
+ point2: {
47
+ x: touches[1].clientX,
48
+ y: touches[1].clientY
49
+ },
50
+ eventType: "touchZoom"
51
+ });
52
+ else updateTouchPointInfo({
53
+ point1: {
54
+ x: touches[0].clientX - x,
55
+ y: touches[0].clientY - y
56
+ },
57
+ eventType: "move"
58
+ });
59
+ };
60
+ const onTouchMove = (event) => {
61
+ const { touches = [] } = event;
62
+ const { point1, point2, eventType } = touchPointInfo.value;
63
+ if (touches.length > 1 && eventType === "touchZoom") {
64
+ const newPoint1 = {
65
+ x: touches[0].clientX,
66
+ y: touches[0].clientY
67
+ };
68
+ const newPoint2 = {
69
+ x: touches[1].clientX,
70
+ y: touches[1].clientY
71
+ };
72
+ const [centerX, centerY] = getCenter(point1, point2, newPoint1, newPoint2);
73
+ dispatchZoomChange(getDistance(newPoint1, newPoint2) / getDistance(point1, point2), "touchZoom", centerX, centerY, true);
74
+ updateTouchPointInfo({
75
+ point1: newPoint1,
76
+ point2: newPoint2,
77
+ eventType: "touchZoom"
78
+ });
79
+ } else if (eventType === "move") {
80
+ updateTransform({
81
+ x: touches[0].clientX - point1.x,
82
+ y: touches[0].clientY - point1.y
83
+ }, "move");
84
+ updateTouchPointInfo({ eventType: "move" });
85
+ }
86
+ };
87
+ const onTouchEnd = () => {
88
+ if (!open.value || !imgRef.value) return;
89
+ if (isTouching.value) isTouching.value = false;
90
+ updateTouchPointInfo({ eventType: "none" });
91
+ const { rotate, scale } = transform.value;
92
+ if (minScale.value > scale) return updateTransform({
93
+ x: 0,
94
+ y: 0,
95
+ scale: minScale.value
96
+ }, "touchZoom");
97
+ const width = imgRef.value.offsetWidth * scale;
98
+ const height = imgRef.value.offsetHeight * scale;
99
+ const { left, top } = imgRef.value.getBoundingClientRect() ?? {};
100
+ const isRotate = rotate % 180 !== 0;
101
+ const fixState = require_getFixScaleEleTransPosition.default(isRotate ? height : width, isRotate ? width : height, left, top);
102
+ if (fixState) updateTransform({ ...fixState }, "dragRebound");
103
+ };
104
+ (0, vue.watchEffect)((onCleanup) => {
105
+ const preventDefault = (e) => {
106
+ e.preventDefault();
107
+ };
108
+ if (open.value && movable.value) window.addEventListener("touchmove", preventDefault, { passive: false });
109
+ onCleanup(() => {
110
+ window.removeEventListener("touchmove", preventDefault);
111
+ });
112
+ });
113
+ return {
114
+ isTouching,
115
+ onTouchStart,
116
+ onTouchMove,
117
+ onTouchEnd
118
+ };
119
+ }
120
+ exports.default = useTouchEvent;
@@ -0,0 +1,8 @@
1
+ import { Ref } from 'vue';
2
+ import { DispatchZoomChangeFunc, TransformType, UpdateTransformFunc } from './useImageTransform.ts';
3
+ export default function useTouchEvent(imgRef: Ref<HTMLImageElement>, movable: Ref<boolean>, open: Ref<boolean>, minScale: Ref<number>, transform: Ref<TransformType>, updateTransform: UpdateTransformFunc, dispatchZoomChange: DispatchZoomChangeFunc): {
4
+ isTouching: import('vue').ShallowRef<boolean, boolean>;
5
+ onTouchStart: (event: TouchEvent) => void;
6
+ onTouchMove: (event: TouchEvent) => void;
7
+ onTouchEnd: () => void;
8
+ };
@@ -0,0 +1,119 @@
1
+ import getFixScaleEleTransPosition from "../getFixScaleEleTransPosition.js";
2
+ import { shallowRef, watchEffect } from "vue";
3
+ function getDistance(a, b) {
4
+ const x = a.x - b.x;
5
+ const y = a.y - b.y;
6
+ return Math.hypot(x, y);
7
+ }
8
+ function getCenter(oldPoint1, oldPoint2, newPoint1, newPoint2) {
9
+ const distance1 = getDistance(oldPoint1, newPoint1);
10
+ const distance2 = getDistance(oldPoint2, newPoint2);
11
+ if (distance1 === 0 && distance2 === 0) return [oldPoint1.x, oldPoint1.y];
12
+ const ratio = distance1 / (distance1 + distance2);
13
+ return [oldPoint1.x + ratio * (oldPoint2.x - oldPoint1.x), oldPoint1.y + ratio * (oldPoint2.y - oldPoint1.y)];
14
+ }
15
+ function useTouchEvent(imgRef, movable, open, minScale, transform, updateTransform, dispatchZoomChange) {
16
+ const isTouching = shallowRef(false);
17
+ const touchPointInfo = shallowRef({
18
+ point1: {
19
+ x: 0,
20
+ y: 0
21
+ },
22
+ point2: {
23
+ x: 0,
24
+ y: 0
25
+ },
26
+ eventType: "none"
27
+ });
28
+ const updateTouchPointInfo = (values) => {
29
+ touchPointInfo.value = {
30
+ ...touchPointInfo.value,
31
+ ...values
32
+ };
33
+ };
34
+ const onTouchStart = (event) => {
35
+ if (!movable.value) return;
36
+ event.stopPropagation();
37
+ isTouching.value = true;
38
+ const { touches = [] } = event;
39
+ const { x, y } = transform.value;
40
+ if (touches.length > 1) updateTouchPointInfo({
41
+ point1: {
42
+ x: touches[0].clientX,
43
+ y: touches[0].clientY
44
+ },
45
+ point2: {
46
+ x: touches[1].clientX,
47
+ y: touches[1].clientY
48
+ },
49
+ eventType: "touchZoom"
50
+ });
51
+ else updateTouchPointInfo({
52
+ point1: {
53
+ x: touches[0].clientX - x,
54
+ y: touches[0].clientY - y
55
+ },
56
+ eventType: "move"
57
+ });
58
+ };
59
+ const onTouchMove = (event) => {
60
+ const { touches = [] } = event;
61
+ const { point1, point2, eventType } = touchPointInfo.value;
62
+ if (touches.length > 1 && eventType === "touchZoom") {
63
+ const newPoint1 = {
64
+ x: touches[0].clientX,
65
+ y: touches[0].clientY
66
+ };
67
+ const newPoint2 = {
68
+ x: touches[1].clientX,
69
+ y: touches[1].clientY
70
+ };
71
+ const [centerX, centerY] = getCenter(point1, point2, newPoint1, newPoint2);
72
+ dispatchZoomChange(getDistance(newPoint1, newPoint2) / getDistance(point1, point2), "touchZoom", centerX, centerY, true);
73
+ updateTouchPointInfo({
74
+ point1: newPoint1,
75
+ point2: newPoint2,
76
+ eventType: "touchZoom"
77
+ });
78
+ } else if (eventType === "move") {
79
+ updateTransform({
80
+ x: touches[0].clientX - point1.x,
81
+ y: touches[0].clientY - point1.y
82
+ }, "move");
83
+ updateTouchPointInfo({ eventType: "move" });
84
+ }
85
+ };
86
+ const onTouchEnd = () => {
87
+ if (!open.value || !imgRef.value) return;
88
+ if (isTouching.value) isTouching.value = false;
89
+ updateTouchPointInfo({ eventType: "none" });
90
+ const { rotate, scale } = transform.value;
91
+ if (minScale.value > scale) return updateTransform({
92
+ x: 0,
93
+ y: 0,
94
+ scale: minScale.value
95
+ }, "touchZoom");
96
+ const width = imgRef.value.offsetWidth * scale;
97
+ const height = imgRef.value.offsetHeight * scale;
98
+ const { left, top } = imgRef.value.getBoundingClientRect() ?? {};
99
+ const isRotate = rotate % 180 !== 0;
100
+ const fixState = getFixScaleEleTransPosition(isRotate ? height : width, isRotate ? width : height, left, top);
101
+ if (fixState) updateTransform({ ...fixState }, "dragRebound");
102
+ };
103
+ watchEffect((onCleanup) => {
104
+ const preventDefault = (e) => {
105
+ e.preventDefault();
106
+ };
107
+ if (open.value && movable.value) window.addEventListener("touchmove", preventDefault, { passive: false });
108
+ onCleanup(() => {
109
+ window.removeEventListener("touchmove", preventDefault);
110
+ });
111
+ });
112
+ return {
113
+ isTouching,
114
+ onTouchStart,
115
+ onTouchMove,
116
+ onTouchEnd
117
+ };
118
+ }
119
+ export { useTouchEvent as default };
package/dist/index.cjs ADDED
@@ -0,0 +1,8 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ const require_Image = require("./Image.cjs");
3
+ const require_PreviewGroup = require("./PreviewGroup.cjs");
4
+ var ExportImage = require_Image.default;
5
+ ExportImage.PreviewGroup = require_PreviewGroup.default;
6
+ var src_default = ExportImage;
7
+ exports.PreviewGroup = require_PreviewGroup.default;
8
+ exports.default = src_default;
@@ -0,0 +1,11 @@
1
+ import { ImageProps, default as Image } from './Image';
2
+ import { default as PreviewGroup } from './PreviewGroup';
3
+ export * from './Image';
4
+ export type { PreviewGroupProps } from './PreviewGroup';
5
+ export { PreviewGroup };
6
+ export type { ImageProps };
7
+ type ImageType = typeof Image & {
8
+ PreviewGroup: typeof PreviewGroup;
9
+ };
10
+ declare const ExportImage: ImageType;
11
+ export default ExportImage;
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import Image_default from "./Image.js";
2
+ import PreviewGroup_default from "./PreviewGroup.js";
3
+ var ExportImage = Image_default;
4
+ ExportImage.PreviewGroup = PreviewGroup_default;
5
+ var src_default = ExportImage;
6
+ export { PreviewGroup_default as PreviewGroup, src_default as default };
File without changes
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Used for PreviewGroup passed image data
3
+ */
4
+ export type ImageElementProps = Pick<HTMLImageElement, 'src' | 'crossOrigin' | 'decoding' | 'draggable' | 'loading' | 'referrerPolicy' | 'sizes' | 'srcset' | 'useMap' | 'alt'>;
5
+ export interface PreviewImageElementProps {
6
+ data: ImageElementProps;
7
+ canPreview: boolean;
8
+ }
9
+ export type InternalItem = PreviewImageElementProps & {
10
+ id?: string;
11
+ };
12
+ export type RegisterImage = (id: string, data: PreviewImageElementProps) => VoidFunction;
13
+ export type OnGroupPreview = (id: string, imageSrc: string, mouseX: number, mouseY: number) => void;
File without changes
@@ -0,0 +1,12 @@
1
+ let vue = require("vue");
2
+ var QueueContextKey = Symbol("QueueContextKey");
3
+ function useContextProvider(appendFunc) {
4
+ const queueCreate = appendFunc;
5
+ (0, vue.provide)(QueueContextKey, queueCreate);
6
+ return queueCreate;
7
+ }
8
+ function useContextState() {
9
+ return (0, vue.inject)(QueueContextKey, void 0);
10
+ }
11
+ exports.useContextProvider = useContextProvider;
12
+ exports.useContextState = useContextState;
@@ -0,0 +1,11 @@
1
+ import { inject, provide } from "vue";
2
+ var QueueContextKey = Symbol("QueueContextKey");
3
+ function useContextProvider(appendFunc) {
4
+ const queueCreate = appendFunc;
5
+ provide(QueueContextKey, queueCreate);
6
+ return queueCreate;
7
+ }
8
+ function useContextState() {
9
+ return inject(QueueContextKey, void 0);
10
+ }
11
+ export { useContextProvider, useContextState };
@@ -0,0 +1,91 @@
1
+ const require_index = require("../../util/dist/props-util/index.cjs");
2
+ const require_warning = require("../../util/dist/warning.cjs");
3
+ require("../../util/dist/index.cjs");
4
+ const require_Context = require("./Context.cjs");
5
+ const require_canUseDom = require("../../util/dist/Dom/canUseDom.cjs");
6
+ const require_useDom = require("./useDom.cjs");
7
+ const require_useScrollLocker = require("./useScrollLocker.cjs");
8
+ let vue = require("vue");
9
+ function _isSlot(s) {
10
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
11
+ }
12
+ function getPortalContainer(getContainer) {
13
+ if (getContainer === false) return false;
14
+ if (!require_canUseDom.canUseDom() || !getContainer) return null;
15
+ if (typeof getContainer === "string") return document.querySelector(getContainer);
16
+ if (typeof getContainer === "function") return getContainer();
17
+ return getContainer;
18
+ }
19
+ var Portal_default = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, expose }) => {
20
+ const shouldRender = (0, vue.shallowRef)(props.open);
21
+ const mergedRender = (0, vue.computed)(() => shouldRender.value || props.open);
22
+ if (process.env.NODE_ENV !== "production") require_warning.warning_default(require_canUseDom.canUseDom() || !open, `Portal only work in client side. Please call 'useEffect' to show Portal instead default render in SSR.`);
23
+ (0, vue.watch)([() => props.open, () => props.autoDestroy], () => {
24
+ if (props.autoDestroy || props.open) shouldRender.value = props.open;
25
+ });
26
+ const innerContainer = (0, vue.shallowRef)(getPortalContainer(props.getContainer));
27
+ (0, vue.onMounted)(() => {
28
+ innerContainer.value = getPortalContainer(props.getContainer) ?? null;
29
+ });
30
+ (0, vue.watch)(() => props.getContainer, () => {
31
+ innerContainer.value = getPortalContainer(props.getContainer) ?? null;
32
+ });
33
+ const [defaultContainer, queueCreate] = require_useDom.useDom((0, vue.computed)(() => !!(mergedRender.value && !innerContainer.value)), props.debug);
34
+ require_Context.useContextProvider(queueCreate);
35
+ const mergedContainer = (0, vue.computed)(() => innerContainer.value ?? defaultContainer);
36
+ require_useScrollLocker.useScrollLocker((0, vue.computed)(() => !!(props.autoLock && props.open && require_canUseDom.canUseDom() && (mergedContainer.value === defaultContainer || mergedContainer.value === document.body))));
37
+ const elementEl = (0, vue.shallowRef)();
38
+ const setRef = (el) => {
39
+ elementEl.value = el;
40
+ };
41
+ expose({ elementEl });
42
+ return () => {
43
+ if (!mergedRender.value || !require_canUseDom.canUseDom() || innerContainer.value === void 0) return null;
44
+ const renderInline = mergedContainer.value === false;
45
+ const reffedChildren = require_index.filterEmpty(slots.default?.() ?? []);
46
+ if (renderInline) return reffedChildren;
47
+ else {
48
+ const child = reffedChildren.length === 1 ? (0, vue.isVNode)(reffedChildren[0]) ? (0, vue.createVNode)(reffedChildren[0], { ref: setRef }) : reffedChildren[0] : reffedChildren;
49
+ return (0, vue.createVNode)(vue.Teleport, { "to": mergedContainer.value }, _isSlot(child) ? child : { default: () => [child] });
50
+ }
51
+ };
52
+ }, {
53
+ props: /* @__PURE__ */ (0, vue.mergeDefaults)({
54
+ getContainer: {
55
+ type: [
56
+ String,
57
+ Function,
58
+ Boolean
59
+ ],
60
+ required: false,
61
+ skipCheck: true,
62
+ default: void 0
63
+ },
64
+ open: {
65
+ type: Boolean,
66
+ required: false,
67
+ default: void 0
68
+ },
69
+ autoDestroy: {
70
+ type: Boolean,
71
+ required: false,
72
+ default: void 0
73
+ },
74
+ autoLock: {
75
+ type: Boolean,
76
+ required: false,
77
+ default: void 0
78
+ },
79
+ debug: {
80
+ type: String,
81
+ required: false,
82
+ default: void 0
83
+ }
84
+ }, {
85
+ autoDestroy: true,
86
+ getContainer: void 0
87
+ }),
88
+ name: "Portal",
89
+ inheritAttrs: false
90
+ });
91
+ exports.Portal_default = Portal_default;
@@ -0,0 +1,91 @@
1
+ import { filterEmpty } from "../../util/dist/props-util/index.js";
2
+ import { warning_default } from "../../util/dist/warning.js";
3
+ import "../../util/dist/index.js";
4
+ import { useContextProvider } from "./Context.js";
5
+ import { canUseDom } from "../../util/dist/Dom/canUseDom.js";
6
+ import { useDom } from "./useDom.js";
7
+ import { useScrollLocker } from "./useScrollLocker.js";
8
+ import { Teleport, computed, createVNode, defineComponent, isVNode, mergeDefaults, onMounted, shallowRef, watch } from "vue";
9
+ function _isSlot(s) {
10
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
11
+ }
12
+ function getPortalContainer(getContainer) {
13
+ if (getContainer === false) return false;
14
+ if (!canUseDom() || !getContainer) return null;
15
+ if (typeof getContainer === "string") return document.querySelector(getContainer);
16
+ if (typeof getContainer === "function") return getContainer();
17
+ return getContainer;
18
+ }
19
+ var Portal_default = /* @__PURE__ */ defineComponent((props, { slots, expose }) => {
20
+ const shouldRender = shallowRef(props.open);
21
+ const mergedRender = computed(() => shouldRender.value || props.open);
22
+ if (process.env.NODE_ENV !== "production") warning_default(canUseDom() || !open, `Portal only work in client side. Please call 'useEffect' to show Portal instead default render in SSR.`);
23
+ watch([() => props.open, () => props.autoDestroy], () => {
24
+ if (props.autoDestroy || props.open) shouldRender.value = props.open;
25
+ });
26
+ const innerContainer = shallowRef(getPortalContainer(props.getContainer));
27
+ onMounted(() => {
28
+ innerContainer.value = getPortalContainer(props.getContainer) ?? null;
29
+ });
30
+ watch(() => props.getContainer, () => {
31
+ innerContainer.value = getPortalContainer(props.getContainer) ?? null;
32
+ });
33
+ const [defaultContainer, queueCreate] = useDom(computed(() => !!(mergedRender.value && !innerContainer.value)), props.debug);
34
+ useContextProvider(queueCreate);
35
+ const mergedContainer = computed(() => innerContainer.value ?? defaultContainer);
36
+ useScrollLocker(computed(() => !!(props.autoLock && props.open && canUseDom() && (mergedContainer.value === defaultContainer || mergedContainer.value === document.body))));
37
+ const elementEl = shallowRef();
38
+ const setRef = (el) => {
39
+ elementEl.value = el;
40
+ };
41
+ expose({ elementEl });
42
+ return () => {
43
+ if (!mergedRender.value || !canUseDom() || innerContainer.value === void 0) return null;
44
+ const renderInline = mergedContainer.value === false;
45
+ const reffedChildren = filterEmpty(slots.default?.() ?? []);
46
+ if (renderInline) return reffedChildren;
47
+ else {
48
+ const child = reffedChildren.length === 1 ? isVNode(reffedChildren[0]) ? createVNode(reffedChildren[0], { ref: setRef }) : reffedChildren[0] : reffedChildren;
49
+ return createVNode(Teleport, { "to": mergedContainer.value }, _isSlot(child) ? child : { default: () => [child] });
50
+ }
51
+ };
52
+ }, {
53
+ props: /* @__PURE__ */ mergeDefaults({
54
+ getContainer: {
55
+ type: [
56
+ String,
57
+ Function,
58
+ Boolean
59
+ ],
60
+ required: false,
61
+ skipCheck: true,
62
+ default: void 0
63
+ },
64
+ open: {
65
+ type: Boolean,
66
+ required: false,
67
+ default: void 0
68
+ },
69
+ autoDestroy: {
70
+ type: Boolean,
71
+ required: false,
72
+ default: void 0
73
+ },
74
+ autoLock: {
75
+ type: Boolean,
76
+ required: false,
77
+ default: void 0
78
+ },
79
+ debug: {
80
+ type: String,
81
+ required: false,
82
+ default: void 0
83
+ }
84
+ }, {
85
+ autoDestroy: true,
86
+ getContainer: void 0
87
+ }),
88
+ name: "Portal",
89
+ inheritAttrs: false
90
+ });
91
+ export { Portal_default };
@@ -0,0 +1,3 @@
1
+ const require_Portal = require("./Portal.cjs");
2
+ var src_default = require_Portal.Portal_default;
3
+ exports.src_default = src_default;
@@ -0,0 +1,3 @@
1
+ import { Portal_default } from "./Portal.js";
2
+ var src_default = Portal_default;
3
+ export { src_default };