@v-c/image 1.0.9 → 1.0.11
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/dist/Image.js +21 -15
- package/dist/Preview/CloseBtn.d.ts +3 -0
- package/dist/Preview/CloseBtn.js +19 -7
- package/dist/Preview/Footer.js +26 -48
- package/dist/Preview/PrevNext.js +9 -12
- package/dist/Preview/index.d.ts +3 -1
- package/dist/Preview/index.js +48 -29
- package/dist/PreviewGroup.js +7 -5
- package/dist/common.js +3 -1
- package/dist/context.js +2 -0
- package/dist/getFixScaleEleTransPosition.js +14 -0
- package/dist/hooks/useImageTransform.js +16 -4
- package/dist/hooks/useMouseEvent.js +5 -2
- package/dist/hooks/usePreviewItems.js +5 -0
- package/dist/hooks/useRegisterImage.js +2 -0
- package/dist/hooks/useStatus.js +2 -0
- package/dist/hooks/useTouchEvent.js +6 -2
- package/dist/index.js +7 -6
- package/dist/previewConfig.js +6 -2
- package/dist/util.js +2 -0
- package/package.json +1 -1
- package/dist/util/dist/Dom/canUseDom.js +0 -4
- package/dist/util/dist/Dom/findDOMNode.js +0 -20
- package/dist/util/dist/Dom/focus.js +0 -129
- package/dist/util/dist/Dom/isVisible.js +0 -16
- package/dist/util/dist/KeyCode.js +0 -81
- package/dist/util/dist/hooks/useId.js +0 -12
- package/dist/util/dist/hooks/useMergedState.js +0 -24
- package/dist/util/dist/isEqual.js +0 -27
- package/dist/util/dist/omit.js +0 -8
- package/dist/util/dist/pickAttrs.js +0 -39
- package/dist/util/dist/props-util/index.js +0 -32
- package/dist/util/dist/raf.js +0 -36
- package/dist/util/dist/type.js +0 -2
- package/dist/util/dist/utils/transition.js +0 -21
- package/dist/util/dist/warning.js +0 -37
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getClientSize } from "../util.js";
|
|
2
|
-
import { isEqual_default } from "../util/dist/isEqual.js";
|
|
3
|
-
import { raf_default } from "../util/dist/raf.js";
|
|
4
2
|
import { ref, shallowRef } from "vue";
|
|
3
|
+
import isEqual from "@v-c/util/dist/isEqual";
|
|
4
|
+
import raf from "@v-c/util/dist/raf";
|
|
5
|
+
//#region src/hooks/useImageTransform.ts
|
|
5
6
|
var initialTransform = {
|
|
6
7
|
x: 0,
|
|
7
8
|
y: 0,
|
|
@@ -17,15 +18,16 @@ function useImageTransform(imgRef, minScale, maxScale, onTransform) {
|
|
|
17
18
|
const resetTransform = (action) => {
|
|
18
19
|
const oldTransform = transform.value;
|
|
19
20
|
transform.value = initialTransform;
|
|
20
|
-
if (!
|
|
21
|
+
if (!isEqual(initialTransform, oldTransform)) onTransform?.({
|
|
21
22
|
transform: initialTransform,
|
|
22
23
|
action
|
|
23
24
|
});
|
|
24
25
|
};
|
|
26
|
+
/** Direct update transform */
|
|
25
27
|
const updateTransform = (newTransform, action) => {
|
|
26
28
|
if (frame.value === null) {
|
|
27
29
|
queue.value = [];
|
|
28
|
-
frame.value =
|
|
30
|
+
frame.value = raf(() => {
|
|
29
31
|
let memoState = transform.value;
|
|
30
32
|
queue.value.forEach((queueState) => {
|
|
31
33
|
memoState = {
|
|
@@ -46,6 +48,7 @@ function useImageTransform(imgRef, minScale, maxScale, onTransform) {
|
|
|
46
48
|
...newTransform
|
|
47
49
|
});
|
|
48
50
|
};
|
|
51
|
+
/** Scale according to the position of centerX and centerY */
|
|
49
52
|
const dispatchZoomChange = (ratio, action, centerX, centerY, isTouch) => {
|
|
50
53
|
if (!imgRef.value) return;
|
|
51
54
|
const { width, height, offsetWidth, offsetHeight, offsetLeft, offsetTop } = imgRef.value;
|
|
@@ -61,15 +64,23 @@ function useImageTransform(imgRef, minScale, maxScale, onTransform) {
|
|
|
61
64
|
newScale = isTouch ? newScale : _minScale;
|
|
62
65
|
newRatio = newScale / _transform.scale;
|
|
63
66
|
}
|
|
67
|
+
/** Default center point scaling */
|
|
64
68
|
const mergedCenterX = centerX ?? innerWidth / 2;
|
|
65
69
|
const mergedCenterY = centerY ?? innerHeight / 2;
|
|
66
70
|
const diffRatio = newRatio - 1;
|
|
71
|
+
/** Deviation calculated from image size */
|
|
67
72
|
const diffImgX = diffRatio * width * .5;
|
|
68
73
|
const diffImgY = diffRatio * height * .5;
|
|
74
|
+
/** The difference between the click position and the edge of the document */
|
|
69
75
|
const diffOffsetLeft = diffRatio * (mergedCenterX - _transform.x - offsetLeft);
|
|
70
76
|
const diffOffsetTop = diffRatio * (mergedCenterY - _transform.y - offsetTop);
|
|
77
|
+
/** Final positioning */
|
|
71
78
|
let newX = _transform.x - (diffOffsetLeft - diffImgX);
|
|
72
79
|
let newY = _transform.y - (diffOffsetTop - diffImgY);
|
|
80
|
+
/**
|
|
81
|
+
* When zooming the image
|
|
82
|
+
* When the image size is smaller than the width and height of the window, the position is initialized
|
|
83
|
+
*/
|
|
73
84
|
if (ratio < 1 && newScale === 1) {
|
|
74
85
|
const mergedWidth = offsetWidth * newScale;
|
|
75
86
|
const mergedHeight = offsetHeight * newScale;
|
|
@@ -92,4 +103,5 @@ function useImageTransform(imgRef, minScale, maxScale, onTransform) {
|
|
|
92
103
|
dispatchZoomChange
|
|
93
104
|
};
|
|
94
105
|
}
|
|
106
|
+
//#endregion
|
|
95
107
|
export { useImageTransform as default };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { canUseDom } from "../util/dist/Dom/canUseDom.js";
|
|
2
1
|
import getFixScaleEleTransPosition from "../getFixScaleEleTransPosition.js";
|
|
3
|
-
import
|
|
2
|
+
import "../previewConfig.js";
|
|
4
3
|
import { shallowRef, watch } from "vue";
|
|
5
4
|
import { warning } from "@v-c/util";
|
|
5
|
+
import canUseDom from "@v-c/util/dist/Dom/canUseDom";
|
|
6
|
+
//#region src/hooks/useMouseEvent.ts
|
|
6
7
|
function useMouseEvent(imgRef, movable, open, scaleStep, transform, updateTransform, dispatchZoomChange) {
|
|
7
8
|
const isMoving = shallowRef(false);
|
|
8
9
|
const startPositionInfo = shallowRef({
|
|
@@ -34,6 +35,7 @@ function useMouseEvent(imgRef, movable, open, scaleStep, transform, updateTransf
|
|
|
34
35
|
if (open.value && isMoving.value) {
|
|
35
36
|
const { x, y, scale, rotate } = transform.value;
|
|
36
37
|
isMoving.value = false;
|
|
38
|
+
/** No need to restore the position when the picture is not moved, So as not to interfere with the click */
|
|
37
39
|
const { transformX, transformY } = startPositionInfo.value;
|
|
38
40
|
if (!(x !== transformX && y !== transformY)) return;
|
|
39
41
|
if (!imgRef.value) return;
|
|
@@ -88,4 +90,5 @@ function useMouseEvent(imgRef, movable, open, scaleStep, transform, updateTransf
|
|
|
88
90
|
onWheel
|
|
89
91
|
};
|
|
90
92
|
}
|
|
93
|
+
//#endregion
|
|
91
94
|
export { useMouseEvent as default };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { COMMON_PROPS } from "../common.js";
|
|
2
2
|
import { computed, shallowRef, watchEffect } from "vue";
|
|
3
|
+
//#region src/hooks/usePreviewItems.ts
|
|
4
|
+
/**
|
|
5
|
+
* Merge props provided `items` or context collected images
|
|
6
|
+
*/
|
|
3
7
|
function usePreviewItems(items) {
|
|
4
8
|
const images = shallowRef({});
|
|
5
9
|
const registerImage = (id, data) => {
|
|
@@ -41,4 +45,5 @@ function usePreviewItems(items) {
|
|
|
41
45
|
computed(() => !!items?.value)
|
|
42
46
|
];
|
|
43
47
|
}
|
|
48
|
+
//#endregion
|
|
44
49
|
export { usePreviewItems as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { usePreviewGroupContext } from "../context.js";
|
|
2
2
|
import { onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
|
|
3
|
+
//#region src/hooks/useRegisterImage.ts
|
|
3
4
|
var uid = 0;
|
|
4
5
|
function useRegisterImage(canPreview, data) {
|
|
5
6
|
uid += 1;
|
|
@@ -21,4 +22,5 @@ function useRegisterImage(canPreview, data) {
|
|
|
21
22
|
});
|
|
22
23
|
return id.value;
|
|
23
24
|
}
|
|
25
|
+
//#endregion
|
|
24
26
|
export { useRegisterImage as default };
|
package/dist/hooks/useStatus.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isImageValid } from "../util.js";
|
|
2
2
|
import { computed, shallowRef, watch, watchEffect } from "vue";
|
|
3
|
+
//#region src/hooks/useStatus.ts
|
|
3
4
|
function useStatus(options) {
|
|
4
5
|
const { src, isCustomPlaceholder, fallback } = options;
|
|
5
6
|
const status = shallowRef(isCustomPlaceholder?.value ? "loading" : "normal");
|
|
@@ -42,4 +43,5 @@ function useStatus(options) {
|
|
|
42
43
|
status
|
|
43
44
|
];
|
|
44
45
|
}
|
|
46
|
+
//#endregion
|
|
45
47
|
export { useStatus as default };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { canUseDom } from "../util/dist/Dom/canUseDom.js";
|
|
2
1
|
import getFixScaleEleTransPosition from "../getFixScaleEleTransPosition.js";
|
|
3
2
|
import { shallowRef, watchEffect } from "vue";
|
|
3
|
+
import canUseDom from "@v-c/util/dist/Dom/canUseDom";
|
|
4
|
+
//#region src/hooks/useTouchEvent.ts
|
|
4
5
|
function getDistance(a, b) {
|
|
5
6
|
const x = a.x - b.x;
|
|
6
7
|
const y = a.y - b.y;
|
|
@@ -89,7 +90,9 @@ function useTouchEvent(imgRef, movable, open, minScale, transform, updateTransfo
|
|
|
89
90
|
if (isTouching.value) isTouching.value = false;
|
|
90
91
|
updateTouchPointInfo({ eventType: "none" });
|
|
91
92
|
const { rotate, scale } = transform.value;
|
|
92
|
-
if (minScale.value > scale)
|
|
93
|
+
if (minScale.value > scale)
|
|
94
|
+
/** When the scaling ratio is less than the minimum scaling ratio, reset the scaling ratio */
|
|
95
|
+
return updateTransform({
|
|
93
96
|
x: 0,
|
|
94
97
|
y: 0,
|
|
95
98
|
scale: minScale.value
|
|
@@ -118,4 +121,5 @@ function useTouchEvent(imgRef, movable, open, minScale, transform, updateTransfo
|
|
|
118
121
|
onTouchEnd
|
|
119
122
|
};
|
|
120
123
|
}
|
|
124
|
+
//#endregion
|
|
121
125
|
export { useTouchEvent as default };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
ExportImage
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import Image from "./Image.js";
|
|
2
|
+
import PreviewGroup from "./PreviewGroup.js";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
var ExportImage = Image;
|
|
5
|
+
ExportImage.PreviewGroup = PreviewGroup;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { PreviewGroup, ExportImage as default };
|
package/dist/previewConfig.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/previewConfig.ts
|
|
2
|
+
/** Scale the ratio base */
|
|
3
|
+
var BASE_SCALE_RATIO = 1;
|
|
4
|
+
/** The maximum zoom ratio when the mouse zooms in, adjustable */
|
|
5
|
+
var WHEEL_MAX_SCALE_RATIO = 1;
|
|
6
|
+
//#endregion
|
|
3
7
|
export { BASE_SCALE_RATIO, WHEEL_MAX_SCALE_RATIO };
|
package/dist/util.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/util.ts
|
|
1
2
|
function isImageValid(src) {
|
|
2
3
|
return new Promise((resolve) => {
|
|
3
4
|
if (!src) {
|
|
@@ -26,4 +27,5 @@ function getClientSize() {
|
|
|
26
27
|
height: window.innerHeight || document.documentElement.clientHeight
|
|
27
28
|
};
|
|
28
29
|
}
|
|
30
|
+
//#endregion
|
|
29
31
|
export { getClientSize, isImageValid };
|
package/package.json
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { canUseDom } from "./canUseDom.js";
|
|
2
|
-
import { unref } from "vue";
|
|
3
|
-
function isDOM(node) {
|
|
4
|
-
return node instanceof HTMLElement || node instanceof SVGElement;
|
|
5
|
-
}
|
|
6
|
-
function getDOM(elementRef) {
|
|
7
|
-
const unrefElementRef = unref(elementRef);
|
|
8
|
-
if (!canUseDom()) return unrefElementRef;
|
|
9
|
-
const dom = findDOMNode(unrefElementRef) || (unrefElementRef && typeof unrefElementRef === "object" ? findDOMNode(unrefElementRef.nativeElement) : null);
|
|
10
|
-
if (dom && (dom.nodeType === 3 || dom.nodeType === 8) && dom.nextElementSibling) return dom.nextElementSibling;
|
|
11
|
-
return dom;
|
|
12
|
-
}
|
|
13
|
-
function findDOMNode(_node) {
|
|
14
|
-
const node = unref(_node);
|
|
15
|
-
if (!canUseDom()) return node;
|
|
16
|
-
if (isDOM(node)) return node;
|
|
17
|
-
else if (node && "$el" in node) return node.$el;
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
export { getDOM };
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { useId_default } from "../hooks/useId.js";
|
|
2
|
-
import { getDOM } from "./findDOMNode.js";
|
|
3
|
-
import { isVisible_default } from "./isVisible.js";
|
|
4
|
-
import { watch } from "vue";
|
|
5
|
-
function focusable(node, includePositive = false) {
|
|
6
|
-
if (isVisible_default(node)) {
|
|
7
|
-
const nodeName = node.nodeName.toLowerCase();
|
|
8
|
-
const isFocusableElement = [
|
|
9
|
-
"input",
|
|
10
|
-
"select",
|
|
11
|
-
"textarea",
|
|
12
|
-
"button"
|
|
13
|
-
].includes(nodeName) || node.isContentEditable || nodeName === "a" && !!node.getAttribute("href");
|
|
14
|
-
const tabIndexAttr = node.getAttribute("tabindex");
|
|
15
|
-
const tabIndexNum = Number(tabIndexAttr);
|
|
16
|
-
let tabIndex = null;
|
|
17
|
-
if (tabIndexAttr && !Number.isNaN(tabIndexNum)) tabIndex = tabIndexNum;
|
|
18
|
-
else if (isFocusableElement && tabIndex === null) tabIndex = 0;
|
|
19
|
-
if (isFocusableElement && node.disabled) tabIndex = null;
|
|
20
|
-
return tabIndex !== null && (tabIndex >= 0 || includePositive && tabIndex < 0);
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
function getFocusNodeList(node, includePositive = false) {
|
|
25
|
-
const res = [...node.querySelectorAll("*")].filter((child) => {
|
|
26
|
-
return focusable(child, includePositive);
|
|
27
|
-
});
|
|
28
|
-
if (focusable(node, includePositive)) res.unshift(node);
|
|
29
|
-
return res;
|
|
30
|
-
}
|
|
31
|
-
var lastFocusElement = null;
|
|
32
|
-
var focusElements = [];
|
|
33
|
-
var idToElementMap = /* @__PURE__ */ new Map();
|
|
34
|
-
var ignoredElementMap = /* @__PURE__ */ new Map();
|
|
35
|
-
var allowedElementMap = /* @__PURE__ */ new Map();
|
|
36
|
-
function getLastElement() {
|
|
37
|
-
return focusElements[focusElements.length - 1];
|
|
38
|
-
}
|
|
39
|
-
function getLastLockId() {
|
|
40
|
-
const lastElement = getLastElement();
|
|
41
|
-
if (!lastElement) return void 0;
|
|
42
|
-
for (const [id, ele] of idToElementMap.entries()) if (ele === lastElement) return id;
|
|
43
|
-
}
|
|
44
|
-
function isIgnoredElement(element) {
|
|
45
|
-
const lockId = getLastLockId();
|
|
46
|
-
if (!lockId || !element) return false;
|
|
47
|
-
const ignoredEle = ignoredElementMap.get(lockId);
|
|
48
|
-
return !!ignoredEle && (ignoredEle === element || ignoredEle.contains(element));
|
|
49
|
-
}
|
|
50
|
-
function isAllowedElement(element) {
|
|
51
|
-
const lockId = getLastLockId();
|
|
52
|
-
if (!lockId || !element) return false;
|
|
53
|
-
const allowedElements = allowedElementMap.get(lockId);
|
|
54
|
-
if (!allowedElements?.size) return false;
|
|
55
|
-
for (const allowedElement of allowedElements) if (allowedElement === element || allowedElement.contains(element)) return true;
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
function hasFocus(element) {
|
|
59
|
-
const { activeElement } = document;
|
|
60
|
-
return element === activeElement || element.contains(activeElement);
|
|
61
|
-
}
|
|
62
|
-
function syncFocus() {
|
|
63
|
-
const lastElement = getLastElement();
|
|
64
|
-
const { activeElement } = document;
|
|
65
|
-
if (isIgnoredElement(activeElement) || isAllowedElement(activeElement)) return;
|
|
66
|
-
if (lastElement && !hasFocus(lastElement)) {
|
|
67
|
-
const focusableList = getFocusNodeList(lastElement);
|
|
68
|
-
(focusableList.includes(lastFocusElement) ? lastFocusElement : focusableList[0])?.focus({ preventScroll: true });
|
|
69
|
-
} else lastFocusElement = activeElement;
|
|
70
|
-
}
|
|
71
|
-
function onWindowKeyDown(e) {
|
|
72
|
-
if (e.key === "Tab") {
|
|
73
|
-
const { activeElement } = document;
|
|
74
|
-
const focusableList = getFocusNodeList(getLastElement());
|
|
75
|
-
const last = focusableList[focusableList.length - 1];
|
|
76
|
-
if (e.shiftKey && activeElement === focusableList[0]) lastFocusElement = last;
|
|
77
|
-
else if (!e.shiftKey && activeElement === last) lastFocusElement = focusableList[0];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function lockFocus(element, id) {
|
|
81
|
-
if (element) {
|
|
82
|
-
idToElementMap.set(id, element);
|
|
83
|
-
focusElements = focusElements.filter((ele) => ele !== element);
|
|
84
|
-
focusElements.push(element);
|
|
85
|
-
window.addEventListener("focusin", syncFocus);
|
|
86
|
-
window.addEventListener("keydown", onWindowKeyDown, true);
|
|
87
|
-
syncFocus();
|
|
88
|
-
}
|
|
89
|
-
return () => {
|
|
90
|
-
lastFocusElement = null;
|
|
91
|
-
focusElements = focusElements.filter((ele) => ele !== element);
|
|
92
|
-
idToElementMap.delete(id);
|
|
93
|
-
ignoredElementMap.delete(id);
|
|
94
|
-
allowedElementMap.delete(id);
|
|
95
|
-
if (focusElements.length === 0) {
|
|
96
|
-
window.removeEventListener("focusin", syncFocus);
|
|
97
|
-
window.removeEventListener("keydown", onWindowKeyDown, true);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function useLockFocus(lock, getElement) {
|
|
102
|
-
const id = useId_default();
|
|
103
|
-
watch([lock, () => getElement()], ([nextLock, element], _o, onCleanup) => {
|
|
104
|
-
element = getDOM(element);
|
|
105
|
-
if (nextLock && element) onCleanup(lockFocus(element, id));
|
|
106
|
-
}, {
|
|
107
|
-
flush: "post",
|
|
108
|
-
immediate: true
|
|
109
|
-
});
|
|
110
|
-
const ignoreElement = (ele) => {
|
|
111
|
-
if (ele) ignoredElementMap.set(id, ele);
|
|
112
|
-
};
|
|
113
|
-
const registerAllowedElement = (ele) => {
|
|
114
|
-
if (!ele) return () => {};
|
|
115
|
-
let allowedElements = allowedElementMap.get(id);
|
|
116
|
-
if (!allowedElements) {
|
|
117
|
-
allowedElements = /* @__PURE__ */ new Set();
|
|
118
|
-
allowedElementMap.set(id, allowedElements);
|
|
119
|
-
}
|
|
120
|
-
allowedElements.add(ele);
|
|
121
|
-
return () => {
|
|
122
|
-
const nextAllowedElements = allowedElementMap.get(id);
|
|
123
|
-
nextAllowedElements?.delete(ele);
|
|
124
|
-
if (!nextAllowedElements?.size) allowedElementMap.delete(id);
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
return [ignoreElement, registerAllowedElement];
|
|
128
|
-
}
|
|
129
|
-
export { useLockFocus };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var isVisible_default = (element) => {
|
|
2
|
-
if (!element) return false;
|
|
3
|
-
if (element instanceof Element) {
|
|
4
|
-
if (element.offsetParent) return true;
|
|
5
|
-
if (element.getBBox) {
|
|
6
|
-
const { width, height } = element.getBBox();
|
|
7
|
-
if (width || height) return true;
|
|
8
|
-
}
|
|
9
|
-
if (element.getBoundingClientRect) {
|
|
10
|
-
const { width, height } = element.getBoundingClientRect();
|
|
11
|
-
if (width || height) return true;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
};
|
|
16
|
-
export { isVisible_default };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
var KeyCodeStr = {
|
|
2
|
-
Enter: "Enter",
|
|
3
|
-
Backspace: "Backspace",
|
|
4
|
-
Tab: "Tab",
|
|
5
|
-
Space: " ",
|
|
6
|
-
Escape: "Escape",
|
|
7
|
-
Shift: "Shift",
|
|
8
|
-
Control: "Control",
|
|
9
|
-
Alt: "Alt",
|
|
10
|
-
Meta: "Meta",
|
|
11
|
-
ArrowLeft: "ArrowLeft",
|
|
12
|
-
ArrowUp: "ArrowUp",
|
|
13
|
-
ArrowRight: "ArrowRight",
|
|
14
|
-
ArrowDown: "ArrowDown",
|
|
15
|
-
Home: "Home",
|
|
16
|
-
End: "End",
|
|
17
|
-
PageUp: "PageUp",
|
|
18
|
-
PageDown: "PageDown",
|
|
19
|
-
Insert: "Insert",
|
|
20
|
-
Delete: "Delete",
|
|
21
|
-
F1: "F1",
|
|
22
|
-
F2: "F2",
|
|
23
|
-
F3: "F3",
|
|
24
|
-
F4: "F4",
|
|
25
|
-
F5: "F5",
|
|
26
|
-
F6: "F6",
|
|
27
|
-
F7: "F7",
|
|
28
|
-
F8: "F8",
|
|
29
|
-
F9: "F9",
|
|
30
|
-
F10: "F10",
|
|
31
|
-
F11: "F11",
|
|
32
|
-
F12: "F12",
|
|
33
|
-
Digit0: "0",
|
|
34
|
-
Digit1: "1",
|
|
35
|
-
Digit2: "2",
|
|
36
|
-
Digit3: "3",
|
|
37
|
-
Digit4: "4",
|
|
38
|
-
Digit5: "5",
|
|
39
|
-
Digit6: "6",
|
|
40
|
-
Digit7: "7",
|
|
41
|
-
Digit8: "8",
|
|
42
|
-
Digit9: "9",
|
|
43
|
-
KeyA: "a",
|
|
44
|
-
KeyB: "b",
|
|
45
|
-
KeyC: "c",
|
|
46
|
-
KeyD: "d",
|
|
47
|
-
KeyE: "e",
|
|
48
|
-
KeyF: "f",
|
|
49
|
-
KeyG: "g",
|
|
50
|
-
KeyH: "h",
|
|
51
|
-
KeyI: "i",
|
|
52
|
-
KeyJ: "j",
|
|
53
|
-
KeyK: "k",
|
|
54
|
-
KeyL: "l",
|
|
55
|
-
KeyM: "m",
|
|
56
|
-
KeyN: "n",
|
|
57
|
-
KeyO: "o",
|
|
58
|
-
KeyP: "p",
|
|
59
|
-
KeyQ: "q",
|
|
60
|
-
KeyR: "r",
|
|
61
|
-
KeyS: "s",
|
|
62
|
-
KeyT: "t",
|
|
63
|
-
KeyU: "u",
|
|
64
|
-
KeyV: "v",
|
|
65
|
-
KeyW: "w",
|
|
66
|
-
KeyX: "x",
|
|
67
|
-
KeyY: "y",
|
|
68
|
-
KeyZ: "z",
|
|
69
|
-
Semicolon: ";",
|
|
70
|
-
Equal: "=",
|
|
71
|
-
Comma: ",",
|
|
72
|
-
Minus: "-",
|
|
73
|
-
Period: ".",
|
|
74
|
-
Slash: "/",
|
|
75
|
-
Backquote: "`",
|
|
76
|
-
BracketLeft: "[",
|
|
77
|
-
Backslash: "\\",
|
|
78
|
-
BracketRight: "]",
|
|
79
|
-
Quote: "'"
|
|
80
|
-
};
|
|
81
|
-
export { KeyCodeStr };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useId } from "vue";
|
|
2
|
-
function getUseId() {
|
|
3
|
-
return useId;
|
|
4
|
-
}
|
|
5
|
-
var useOriginalId = getUseId();
|
|
6
|
-
function useId_default(id) {
|
|
7
|
-
const vueId = useOriginalId();
|
|
8
|
-
if (id) return id;
|
|
9
|
-
if (process.env.NODE_ENV === "test") return "test-id";
|
|
10
|
-
return vueId;
|
|
11
|
-
}
|
|
12
|
-
export { useId_default };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ref, toRaw, unref, watch, watchEffect } from "vue";
|
|
2
|
-
function useMergedState(defaultStateValue, option) {
|
|
3
|
-
const { defaultValue, value = ref() } = option || {};
|
|
4
|
-
let initValue = typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue;
|
|
5
|
-
if (value.value !== void 0) initValue = unref(value);
|
|
6
|
-
if (defaultValue !== void 0) initValue = typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
7
|
-
const innerValue = ref(initValue);
|
|
8
|
-
const mergedValue = ref(initValue);
|
|
9
|
-
watchEffect(() => {
|
|
10
|
-
let val = value.value !== void 0 ? value.value : innerValue.value;
|
|
11
|
-
if (option?.postState) val = option.postState(val);
|
|
12
|
-
mergedValue.value = val;
|
|
13
|
-
});
|
|
14
|
-
function triggerChange(newValue) {
|
|
15
|
-
const preVal = mergedValue.value;
|
|
16
|
-
innerValue.value = newValue;
|
|
17
|
-
if (toRaw(mergedValue.value) !== newValue && option?.onChange) option.onChange(newValue, preVal);
|
|
18
|
-
}
|
|
19
|
-
watch(value, () => {
|
|
20
|
-
innerValue.value = value.value;
|
|
21
|
-
});
|
|
22
|
-
return [mergedValue, triggerChange];
|
|
23
|
-
}
|
|
24
|
-
export { useMergedState };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { warning_default } from "./warning.js";
|
|
2
|
-
function isEqual(obj1, obj2, shallow = false) {
|
|
3
|
-
const refSet = /* @__PURE__ */ new Set();
|
|
4
|
-
function deepEqual(a, b, level = 1) {
|
|
5
|
-
const circular = refSet.has(a);
|
|
6
|
-
warning_default(!circular, "Warning: There may be circular references");
|
|
7
|
-
if (circular) return false;
|
|
8
|
-
if (a === b) return true;
|
|
9
|
-
if (shallow && level > 1) return false;
|
|
10
|
-
refSet.add(a);
|
|
11
|
-
const newLevel = level + 1;
|
|
12
|
-
if (Array.isArray(a)) {
|
|
13
|
-
if (!Array.isArray(b) || a.length !== b.length) return false;
|
|
14
|
-
for (let i = 0; i < a.length; i++) if (!deepEqual(a[i], b[i], newLevel)) return false;
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
18
|
-
const keys = Object.keys(a);
|
|
19
|
-
if (keys.length !== Object.keys(b).length) return false;
|
|
20
|
-
return keys.every((key) => deepEqual(a[key], b[key], newLevel));
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
return deepEqual(obj1, obj2);
|
|
25
|
-
}
|
|
26
|
-
var isEqual_default = isEqual;
|
|
27
|
-
export { isEqual_default };
|
package/dist/util/dist/omit.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var propList = `accept acceptCharset accessKey action allowFullScreen allowTransparency
|
|
2
|
-
alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge
|
|
3
|
-
charSet checked classID className colSpan cols content contentEditable contextMenu
|
|
4
|
-
controls coords crossOrigin data dateTime default defer dir disabled download draggable
|
|
5
|
-
encType form formAction formEncType formMethod formNoValidate formTarget frameBorder
|
|
6
|
-
headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode integrity
|
|
7
|
-
is keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media
|
|
8
|
-
mediaGroup method min minLength multiple muted name noValidate nonce open
|
|
9
|
-
optimum pattern placeholder poster preload radioGroup readOnly rel required
|
|
10
|
-
reversed role rowSpan rows sandbox scope scoped scrolling seamless selected
|
|
11
|
-
shape size sizes span spellCheck src srcDoc srcLang srcSet start step style
|
|
12
|
-
summary tabIndex target title type useMap value width wmode wrap onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown
|
|
13
|
-
onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick
|
|
14
|
-
onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown
|
|
15
|
-
onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel
|
|
16
|
-
onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough
|
|
17
|
-
onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata
|
|
18
|
-
onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`.split(/\s+/);
|
|
19
|
-
var ariaPrefix = "aria-";
|
|
20
|
-
var dataPrefix = "data-";
|
|
21
|
-
function match(key, prefix) {
|
|
22
|
-
return key.indexOf(prefix) === 0;
|
|
23
|
-
}
|
|
24
|
-
function pickAttrs(props, ariaOnly = false) {
|
|
25
|
-
let mergedConfig;
|
|
26
|
-
if (ariaOnly === false) mergedConfig = {
|
|
27
|
-
aria: true,
|
|
28
|
-
data: true,
|
|
29
|
-
attr: true
|
|
30
|
-
};
|
|
31
|
-
else if (ariaOnly === true) mergedConfig = { aria: true };
|
|
32
|
-
else mergedConfig = { ...ariaOnly };
|
|
33
|
-
const attrs = {};
|
|
34
|
-
Object.keys(props).forEach((key) => {
|
|
35
|
-
if (mergedConfig.aria && (key === "role" || match(key, ariaPrefix)) || mergedConfig.data && match(key, dataPrefix) || mergedConfig.attr && propList.includes(key)) attrs[key] = props[key];
|
|
36
|
-
});
|
|
37
|
-
return attrs;
|
|
38
|
-
}
|
|
39
|
-
export { pickAttrs };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { omit } from "../omit.js";
|
|
2
|
-
import { Fragment, toRef } from "vue";
|
|
3
|
-
var defaultOptions = {
|
|
4
|
-
class: true,
|
|
5
|
-
style: true
|
|
6
|
-
};
|
|
7
|
-
function pureAttrs(attrs, options = defaultOptions) {
|
|
8
|
-
const enableClass = options.class ?? defaultOptions.class;
|
|
9
|
-
const enableStyle = options.style ?? defaultOptions.style;
|
|
10
|
-
const newAttrs = { ...attrs };
|
|
11
|
-
if (enableClass) delete newAttrs.class;
|
|
12
|
-
if (enableStyle) delete newAttrs.style;
|
|
13
|
-
if (options.omits && options.omits.length > 0) return omit(newAttrs, options.omits);
|
|
14
|
-
return newAttrs;
|
|
15
|
-
}
|
|
16
|
-
function getAttrStyleAndClass(attrs, options) {
|
|
17
|
-
return {
|
|
18
|
-
className: attrs.class,
|
|
19
|
-
style: attrs.style,
|
|
20
|
-
restAttrs: pureAttrs(attrs, options)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function getStylePxValue(value) {
|
|
24
|
-
if (typeof value === "number") return `${value}px`;
|
|
25
|
-
else if (typeof value === "string") {
|
|
26
|
-
const trimed = value.trim();
|
|
27
|
-
if (Number.isNaN(Number(trimed))) return trimed;
|
|
28
|
-
else return `${Number(trimed)}px`;
|
|
29
|
-
}
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
export { getAttrStyleAndClass, getStylePxValue };
|
package/dist/util/dist/raf.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
var raf = (callback) => +setTimeout(callback, 16);
|
|
2
|
-
var caf = (num) => clearTimeout(num);
|
|
3
|
-
if (typeof window !== "undefined" && "requestAnimationFrame" in window) {
|
|
4
|
-
raf = (callback) => window.requestAnimationFrame(callback);
|
|
5
|
-
caf = (handle) => window.cancelAnimationFrame(handle);
|
|
6
|
-
}
|
|
7
|
-
var rafUUID = 0;
|
|
8
|
-
var rafIds = /* @__PURE__ */ new Map();
|
|
9
|
-
function cleanup(id) {
|
|
10
|
-
rafIds.delete(id);
|
|
11
|
-
}
|
|
12
|
-
function wrapperRaf(callback, times = 1) {
|
|
13
|
-
rafUUID += 1;
|
|
14
|
-
const id = rafUUID;
|
|
15
|
-
function callRef(leftTimes) {
|
|
16
|
-
if (leftTimes === 0) {
|
|
17
|
-
cleanup(id);
|
|
18
|
-
callback();
|
|
19
|
-
} else {
|
|
20
|
-
const realId = raf(() => {
|
|
21
|
-
callRef(leftTimes - 1);
|
|
22
|
-
});
|
|
23
|
-
rafIds.set(id, realId);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
callRef(times);
|
|
27
|
-
return id;
|
|
28
|
-
}
|
|
29
|
-
wrapperRaf.cancel = (id) => {
|
|
30
|
-
const realId = rafIds.get(id);
|
|
31
|
-
cleanup(id);
|
|
32
|
-
return caf(realId);
|
|
33
|
-
};
|
|
34
|
-
if (process.env.NODE_ENV !== "production") wrapperRaf.ids = () => rafIds;
|
|
35
|
-
var raf_default = wrapperRaf;
|
|
36
|
-
export { raf_default };
|
package/dist/util/dist/type.js
DELETED