@v-c/image 0.0.1 → 0.0.3
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.cjs +6 -3
- package/dist/Image.js +2 -2
- package/dist/Preview/CloseBtn.cjs +4 -1
- package/dist/Preview/Footer.cjs +4 -1
- package/dist/Preview/PrevNext.cjs +4 -1
- package/dist/Preview/index.cjs +7 -4
- package/dist/Preview/index.js +3 -3
- package/dist/PreviewGroup.cjs +7 -4
- package/dist/PreviewGroup.js +3 -3
- package/dist/common.cjs +1 -0
- package/dist/context.cjs +1 -0
- package/dist/getFixScaleEleTransPosition.cjs +4 -1
- package/dist/hooks/useImageTransform.cjs +5 -2
- package/dist/hooks/useImageTransform.js +1 -1
- package/dist/hooks/useMouseEvent.cjs +4 -1
- package/dist/hooks/usePreviewItems.cjs +4 -1
- package/dist/hooks/useRegisterImage.cjs +4 -1
- package/dist/hooks/useStatus.cjs +4 -1
- package/dist/hooks/useTouchEvent.cjs +4 -1
- package/dist/index.cjs +4 -1
- package/dist/interface.cjs +1 -0
- package/dist/portal/dist/Portal.cjs +9 -0
- package/dist/portal/dist/Portal.js +9 -0
- package/dist/portal/dist/useEscKeyDown.cjs +57 -0
- package/dist/portal/dist/useEscKeyDown.js +52 -0
- package/dist/portal/dist/useScrollLocker.cjs +4 -2
- package/dist/portal/dist/useScrollLocker.js +5 -3
- package/dist/previewConfig.cjs +1 -0
- package/dist/util/dist/Dom/dynamicCSS.cjs +2 -0
- package/dist/util/dist/Dom/dynamicCSS.js +2 -0
- package/dist/util/dist/getScrollBarSize.cjs +9 -1
- package/dist/util/dist/getScrollBarSize.js +9 -1
- package/dist/util/dist/hooks/useId.cjs +5 -0
- package/dist/util/dist/hooks/useId.js +5 -0
- package/dist/util/dist/index.cjs +4 -0
- package/dist/util/dist/index.js +4 -0
- package/dist/util/dist/props-util/index.cjs +1 -1
- package/dist/util/dist/props-util/index.js +1 -0
- package/dist/util.cjs +1 -0
- package/package.json +3 -3
package/dist/Image.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_index = require("./util/dist/props-util/index.cjs");
|
|
3
6
|
const require_classnames = require("./util/dist/classnames.cjs");
|
|
4
|
-
require("./util/dist/index.cjs");
|
|
5
7
|
const require_useMergedState = require("./util/dist/hooks/useMergedState.cjs");
|
|
8
|
+
require("./util/dist/index.cjs");
|
|
6
9
|
const require_pickAttrs = require("./util/dist/pickAttrs.cjs");
|
|
7
10
|
const require_common = require("./common.cjs");
|
|
8
11
|
const require_context = require("./context.cjs");
|
|
@@ -94,7 +97,7 @@ var Image = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots }) =
|
|
|
94
97
|
actionsNode: originNode,
|
|
95
98
|
...info
|
|
96
99
|
}) : mergedPreviewConfig.value.actionsRender;
|
|
97
|
-
const { src: _previewSrc, open: _previewOpen, onOpenChange: _onPreviewOpenChange, cover: _cover, rootClassName: _previewRootCls
|
|
100
|
+
const { src: _previewSrc, open: _previewOpen, onOpenChange: _onPreviewOpenChange, cover: _cover, rootClassName: _previewRootCls, ...restPreviewProps } = mergedPreviewConfig.value;
|
|
98
101
|
return (0, vue.createVNode)(vue.Fragment, null, [(0, vue.createVNode)("div", (0, vue.mergeProps)(require_pickAttrs.pickAttrs(restAttrs, false), {
|
|
99
102
|
"class": rootCls,
|
|
100
103
|
"onClick": canPreview.value ? onPreview : onInternalClick,
|
package/dist/Image.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAttrStyleAndClass, getStylePxValue } from "./util/dist/props-util/index.js";
|
|
2
2
|
import { clsx } from "./util/dist/classnames.js";
|
|
3
|
-
import "./util/dist/index.js";
|
|
4
3
|
import { useMergedState } from "./util/dist/hooks/useMergedState.js";
|
|
4
|
+
import "./util/dist/index.js";
|
|
5
5
|
import { pickAttrs } from "./util/dist/pickAttrs.js";
|
|
6
6
|
import { COMMON_PROPS } from "./common.js";
|
|
7
7
|
import { usePreviewGroupContext } from "./context.js";
|
|
@@ -93,7 +93,7 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
|
|
|
93
93
|
actionsNode: originNode,
|
|
94
94
|
...info
|
|
95
95
|
}) : mergedPreviewConfig.value.actionsRender;
|
|
96
|
-
const { src: _previewSrc, open: _previewOpen, onOpenChange: _onPreviewOpenChange, cover: _cover, rootClassName: _previewRootCls
|
|
96
|
+
const { src: _previewSrc, open: _previewOpen, onOpenChange: _onPreviewOpenChange, cover: _cover, rootClassName: _previewRootCls, ...restPreviewProps } = mergedPreviewConfig.value;
|
|
97
97
|
return createVNode(Fragment, null, [createVNode("div", mergeProps(pickAttrs(restAttrs, false), {
|
|
98
98
|
"class": rootCls,
|
|
99
99
|
"onClick": canPreview.value ? onPreview : onInternalClick,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
let vue = require("vue");
|
|
3
6
|
var CloseBtn = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
4
7
|
return () => {
|
package/dist/Preview/Footer.cjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_classnames = require("../util/dist/classnames.cjs");
|
|
3
6
|
require("../util/dist/index.cjs");
|
|
4
7
|
let vue = require("vue");
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_classnames = require("../util/dist/classnames.cjs");
|
|
3
6
|
require("../util/dist/index.cjs");
|
|
4
7
|
let vue = require("vue");
|
package/dist/Preview/index.cjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_KeyCode = require("../util/dist/KeyCode.cjs");
|
|
2
6
|
const require_classnames = require("../util/dist/classnames.cjs");
|
|
3
7
|
require("../util/dist/index.cjs");
|
|
4
8
|
const require_context = require("../context.cjs");
|
|
5
9
|
const require_useStatus = require("../hooks/useStatus.cjs");
|
|
6
10
|
const require_index$1 = require("../portal/dist/index.cjs");
|
|
7
|
-
const require_KeyCode = require("../util/dist/KeyCode.cjs");
|
|
8
11
|
const require_transition = require("../util/dist/utils/transition.cjs");
|
|
9
12
|
const require_useImageTransform = require("../hooks/useImageTransform.cjs");
|
|
10
13
|
const require_previewConfig = require("../previewConfig.cjs");
|
|
@@ -14,7 +17,7 @@ const require_CloseBtn = require("./CloseBtn.cjs");
|
|
|
14
17
|
const require_Footer = require("./Footer.cjs");
|
|
15
18
|
const require_PrevNext = require("./PrevNext.cjs");
|
|
16
19
|
let vue = require("vue");
|
|
17
|
-
var Preview = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
20
|
+
var Preview = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots }) => {
|
|
18
21
|
const imgEl = (0, vue.shallowRef)();
|
|
19
22
|
const groupContext = require_context.usePreviewGroupContext();
|
|
20
23
|
const showLeftOrRightSwitches = (0, vue.computed)(() => !!groupContext && (props.count ?? 1) > 1);
|
|
@@ -113,7 +116,7 @@ var Preview = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
|
113
116
|
fallback: (0, vue.computed)(() => props.fallback)
|
|
114
117
|
});
|
|
115
118
|
return () => {
|
|
116
|
-
const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {} } = props;
|
|
119
|
+
const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender = slots?.actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {} } = props;
|
|
117
120
|
const bodyStyle = { ...styles.body ?? {} };
|
|
118
121
|
if (mousePosition) bodyStyle.transformOrigin = `${mousePosition.x}px ${mousePosition.y}px`;
|
|
119
122
|
const image = {
|
package/dist/Preview/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { KeyCodeStr } from "../util/dist/KeyCode.js";
|
|
1
2
|
import { clsx } from "../util/dist/classnames.js";
|
|
2
3
|
import "../util/dist/index.js";
|
|
3
4
|
import { usePreviewGroupContext } from "../context.js";
|
|
4
5
|
import useStatus from "../hooks/useStatus.js";
|
|
5
6
|
import { src_default } from "../portal/dist/index.js";
|
|
6
|
-
import { KeyCodeStr } from "../util/dist/KeyCode.js";
|
|
7
7
|
import { getTransitionProps } from "../util/dist/utils/transition.js";
|
|
8
8
|
import useImageTransform from "../hooks/useImageTransform.js";
|
|
9
9
|
import { BASE_SCALE_RATIO } from "../previewConfig.js";
|
|
@@ -13,7 +13,7 @@ import CloseBtn_default from "./CloseBtn.js";
|
|
|
13
13
|
import Footer_default from "./Footer.js";
|
|
14
14
|
import PrevNext_default from "./PrevNext.js";
|
|
15
15
|
import { Transition, computed, createVNode, defineComponent, mergeDefaults, mergeProps, nextTick, shallowRef, watch, watchEffect } from "vue";
|
|
16
|
-
var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
16
|
+
var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) => {
|
|
17
17
|
const imgEl = shallowRef();
|
|
18
18
|
const groupContext = usePreviewGroupContext();
|
|
19
19
|
const showLeftOrRightSwitches = computed(() => !!groupContext && (props.count ?? 1) > 1);
|
|
@@ -112,7 +112,7 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
112
112
|
fallback: computed(() => props.fallback)
|
|
113
113
|
});
|
|
114
114
|
return () => {
|
|
115
|
-
const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {} } = props;
|
|
115
|
+
const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender = slots?.actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {} } = props;
|
|
116
116
|
const bodyStyle = { ...styles.body ?? {} };
|
|
117
117
|
if (mousePosition) bodyStyle.transformOrigin = `${mousePosition.x}px ${mousePosition.y}px`;
|
|
118
118
|
const image = {
|
package/dist/PreviewGroup.cjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_useMergedState = require("./util/dist/hooks/useMergedState.cjs");
|
|
3
6
|
const require_context = require("./context.cjs");
|
|
4
7
|
const require_index = require("./Preview/index.cjs");
|
|
@@ -52,9 +55,9 @@ var PreviewGroup = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, emi
|
|
|
52
55
|
});
|
|
53
56
|
return () => {
|
|
54
57
|
const itemsList = mergedItems.value;
|
|
55
|
-
const { src
|
|
58
|
+
const { src, ...imgCommonProps } = itemsList[current.value]?.data || {};
|
|
56
59
|
const countRender = slots.countRender ? (currentNum, total) => slots.countRender?.(currentNum, total) : mergedPreviewConfig.value.countRender;
|
|
57
|
-
const { open: _open, current: _current, onOpenChange: _onOpenChange, onChange: _onChange
|
|
60
|
+
const { open: _open, current: _current, onOpenChange: _onOpenChange, onChange: _onChange, ...restPreviewConfig } = mergedPreviewConfig.value;
|
|
58
61
|
return (0, vue.createVNode)(vue.Fragment, null, [slots.default?.(), (0, vue.createVNode)(require_index.default, (0, vue.mergeProps)({
|
|
59
62
|
"aria-hidden": !isShowPreview.value,
|
|
60
63
|
"open": isShowPreview.value,
|
|
@@ -72,7 +75,7 @@ var PreviewGroup = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, emi
|
|
|
72
75
|
"countRender": countRender,
|
|
73
76
|
"classNames": props.classNames?.popup,
|
|
74
77
|
"styles": props.styles?.popup
|
|
75
|
-
}),
|
|
78
|
+
}), slots)]);
|
|
76
79
|
};
|
|
77
80
|
}, {
|
|
78
81
|
props: /* @__PURE__ */ (0, vue.mergeDefaults)({
|
package/dist/PreviewGroup.js
CHANGED
|
@@ -51,9 +51,9 @@ var PreviewGroup_default = /* @__PURE__ */ defineComponent((props, { slots, emit
|
|
|
51
51
|
});
|
|
52
52
|
return () => {
|
|
53
53
|
const itemsList = mergedItems.value;
|
|
54
|
-
const { src
|
|
54
|
+
const { src, ...imgCommonProps } = itemsList[current.value]?.data || {};
|
|
55
55
|
const countRender = slots.countRender ? (currentNum, total) => slots.countRender?.(currentNum, total) : mergedPreviewConfig.value.countRender;
|
|
56
|
-
const { open: _open, current: _current, onOpenChange: _onOpenChange, onChange: _onChange
|
|
56
|
+
const { open: _open, current: _current, onOpenChange: _onOpenChange, onChange: _onChange, ...restPreviewConfig } = mergedPreviewConfig.value;
|
|
57
57
|
return createVNode(Fragment, null, [slots.default?.(), createVNode(Preview_default, mergeProps({
|
|
58
58
|
"aria-hidden": !isShowPreview.value,
|
|
59
59
|
"open": isShowPreview.value,
|
|
@@ -71,7 +71,7 @@ var PreviewGroup_default = /* @__PURE__ */ defineComponent((props, { slots, emit
|
|
|
71
71
|
"countRender": countRender,
|
|
72
72
|
"classNames": props.classNames?.popup,
|
|
73
73
|
"styles": props.styles?.popup
|
|
74
|
-
}),
|
|
74
|
+
}), slots)]);
|
|
75
75
|
};
|
|
76
76
|
}, {
|
|
77
77
|
props: /* @__PURE__ */ mergeDefaults({
|
package/dist/common.cjs
CHANGED
package/dist/context.cjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_util = require("./util.cjs");
|
|
3
6
|
function fixPoint(key, start, width, clientWidth) {
|
|
4
7
|
const startAddWidth = start + width;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_raf = require("../util/dist/raf.cjs");
|
|
2
6
|
const require_util = require("../util.cjs");
|
|
3
7
|
const require_isEqual = require("../util/dist/isEqual.cjs");
|
|
4
|
-
const require_raf = require("../util/dist/raf.cjs");
|
|
5
8
|
let vue = require("vue");
|
|
6
9
|
var initialTransform = {
|
|
7
10
|
x: 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { raf_default } from "../util/dist/raf.js";
|
|
1
2
|
import { getClientSize } from "../util.js";
|
|
2
3
|
import { isEqual_default } from "../util/dist/isEqual.js";
|
|
3
|
-
import { raf_default } from "../util/dist/raf.js";
|
|
4
4
|
import { ref, shallowRef } from "vue";
|
|
5
5
|
var initialTransform = {
|
|
6
6
|
x: 0,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_warning = require("../util/dist/warning.cjs");
|
|
3
6
|
require("../util/dist/index.cjs");
|
|
4
7
|
const require_getFixScaleEleTransPosition = require("../getFixScaleEleTransPosition.cjs");
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_common = require("../common.cjs");
|
|
3
6
|
let vue = require("vue");
|
|
4
7
|
function usePreviewItems(items) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_context = require("../context.cjs");
|
|
3
6
|
let vue = require("vue");
|
|
4
7
|
var uid = 0;
|
package/dist/hooks/useStatus.cjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_util = require("../util.cjs");
|
|
3
6
|
let vue = require("vue");
|
|
4
7
|
function useStatus(options) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_getFixScaleEleTransPosition = require("../getFixScaleEleTransPosition.cjs");
|
|
3
6
|
let vue = require("vue");
|
|
4
7
|
function getDistance(a, b) {
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_Image = require("./Image.cjs");
|
|
3
6
|
const require_PreviewGroup = require("./PreviewGroup.cjs");
|
|
4
7
|
var ExportImage = require_Image.default;
|
package/dist/interface.cjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -4,6 +4,7 @@ require("../../util/dist/index.cjs");
|
|
|
4
4
|
const require_Context = require("./Context.cjs");
|
|
5
5
|
const require_canUseDom = require("../../util/dist/Dom/canUseDom.cjs");
|
|
6
6
|
const require_useDom = require("./useDom.cjs");
|
|
7
|
+
const require_useEscKeyDown = require("./useEscKeyDown.cjs");
|
|
7
8
|
const require_useScrollLocker = require("./useScrollLocker.cjs");
|
|
8
9
|
let vue = require("vue");
|
|
9
10
|
function _isSlot(s) {
|
|
@@ -34,6 +35,9 @@ var Portal_default = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, e
|
|
|
34
35
|
require_Context.useContextProvider(queueCreate);
|
|
35
36
|
const mergedContainer = (0, vue.computed)(() => innerContainer.value ?? defaultContainer);
|
|
36
37
|
require_useScrollLocker.useScrollLocker((0, vue.computed)(() => !!(props.autoLock && props.open && require_canUseDom.canUseDom() && (mergedContainer.value === defaultContainer || mergedContainer.value === document.body))));
|
|
38
|
+
require_useEscKeyDown.useEscKeyDown((0, vue.computed)(() => !!props.open), (...args) => {
|
|
39
|
+
props.onEsc?.(...args);
|
|
40
|
+
});
|
|
37
41
|
const elementEl = (0, vue.shallowRef)();
|
|
38
42
|
const setRef = (el) => {
|
|
39
43
|
elementEl.value = el;
|
|
@@ -76,6 +80,11 @@ var Portal_default = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, e
|
|
|
76
80
|
required: false,
|
|
77
81
|
default: void 0
|
|
78
82
|
},
|
|
83
|
+
onEsc: {
|
|
84
|
+
type: Function,
|
|
85
|
+
required: false,
|
|
86
|
+
default: void 0
|
|
87
|
+
},
|
|
79
88
|
debug: {
|
|
80
89
|
type: String,
|
|
81
90
|
required: false,
|
|
@@ -4,6 +4,7 @@ import "../../util/dist/index.js";
|
|
|
4
4
|
import { useContextProvider } from "./Context.js";
|
|
5
5
|
import { canUseDom } from "../../util/dist/Dom/canUseDom.js";
|
|
6
6
|
import { useDom } from "./useDom.js";
|
|
7
|
+
import { useEscKeyDown } from "./useEscKeyDown.js";
|
|
7
8
|
import { useScrollLocker } from "./useScrollLocker.js";
|
|
8
9
|
import { Teleport, computed, createVNode, defineComponent, isVNode, mergeDefaults, onMounted, shallowRef, watch } from "vue";
|
|
9
10
|
function _isSlot(s) {
|
|
@@ -34,6 +35,9 @@ var Portal_default = /* @__PURE__ */ defineComponent((props, { slots, expose })
|
|
|
34
35
|
useContextProvider(queueCreate);
|
|
35
36
|
const mergedContainer = computed(() => innerContainer.value ?? defaultContainer);
|
|
36
37
|
useScrollLocker(computed(() => !!(props.autoLock && props.open && canUseDom() && (mergedContainer.value === defaultContainer || mergedContainer.value === document.body))));
|
|
38
|
+
useEscKeyDown(computed(() => !!props.open), (...args) => {
|
|
39
|
+
props.onEsc?.(...args);
|
|
40
|
+
});
|
|
37
41
|
const elementEl = shallowRef();
|
|
38
42
|
const setRef = (el) => {
|
|
39
43
|
elementEl.value = el;
|
|
@@ -76,6 +80,11 @@ var Portal_default = /* @__PURE__ */ defineComponent((props, { slots, expose })
|
|
|
76
80
|
required: false,
|
|
77
81
|
default: void 0
|
|
78
82
|
},
|
|
83
|
+
onEsc: {
|
|
84
|
+
type: Function,
|
|
85
|
+
required: false,
|
|
86
|
+
default: void 0
|
|
87
|
+
},
|
|
79
88
|
debug: {
|
|
80
89
|
type: String,
|
|
81
90
|
required: false,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
let vue = require("vue");
|
|
2
|
+
var stack = [];
|
|
3
|
+
var IME_LOCK_DURATION = 200;
|
|
4
|
+
var lastCompositionEndTime = 0;
|
|
5
|
+
var _test = process.env.NODE_ENV === "test" ? () => ({
|
|
6
|
+
stack,
|
|
7
|
+
reset: () => {
|
|
8
|
+
lastCompositionEndTime = 0;
|
|
9
|
+
}
|
|
10
|
+
}) : null;
|
|
11
|
+
function onGlobalKeyDown(event) {
|
|
12
|
+
if (event.key === "Escape" && !event.isComposing) {
|
|
13
|
+
if (Date.now() - lastCompositionEndTime < IME_LOCK_DURATION) return;
|
|
14
|
+
const len = stack.length;
|
|
15
|
+
for (let i = len - 1; i >= 0; i -= 1) stack?.[i]?.onEsc?.({
|
|
16
|
+
top: i === len - 1,
|
|
17
|
+
event
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function onGlobalCompositionEnd() {
|
|
22
|
+
lastCompositionEndTime = Date.now();
|
|
23
|
+
}
|
|
24
|
+
function attachGlobalEventListeners() {
|
|
25
|
+
window.addEventListener("keydown", onGlobalKeyDown);
|
|
26
|
+
window.addEventListener("compositionend", onGlobalCompositionEnd);
|
|
27
|
+
}
|
|
28
|
+
function detachGlobalEventListeners() {
|
|
29
|
+
if (stack.length === 0) {
|
|
30
|
+
window.removeEventListener("keydown", onGlobalKeyDown);
|
|
31
|
+
window.removeEventListener("compositionend", onGlobalCompositionEnd);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function useEscKeyDown(open, onEsc = () => {}) {
|
|
35
|
+
const id = (0, vue.useId)();
|
|
36
|
+
const onEventEsc = onEsc;
|
|
37
|
+
const ensure = () => {
|
|
38
|
+
if (!stack.find((item) => item.id === id)) stack.push({
|
|
39
|
+
id,
|
|
40
|
+
onEsc: onEventEsc
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const clear = () => {
|
|
44
|
+
stack = stack.filter((item) => item.id !== id);
|
|
45
|
+
};
|
|
46
|
+
(0, vue.watch)(open, (_, _o, onCleanup) => {
|
|
47
|
+
if (open.value) {
|
|
48
|
+
ensure();
|
|
49
|
+
attachGlobalEventListeners();
|
|
50
|
+
onCleanup(() => {
|
|
51
|
+
clear();
|
|
52
|
+
detachGlobalEventListeners();
|
|
53
|
+
});
|
|
54
|
+
} else if (!open.value) clear();
|
|
55
|
+
}, { immediate: true });
|
|
56
|
+
}
|
|
57
|
+
exports.useEscKeyDown = useEscKeyDown;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useId, watch } from "vue";
|
|
2
|
+
var stack = [];
|
|
3
|
+
var IME_LOCK_DURATION = 200;
|
|
4
|
+
var lastCompositionEndTime = 0;
|
|
5
|
+
process.env.NODE_ENV;
|
|
6
|
+
function onGlobalKeyDown(event) {
|
|
7
|
+
if (event.key === "Escape" && !event.isComposing) {
|
|
8
|
+
if (Date.now() - lastCompositionEndTime < IME_LOCK_DURATION) return;
|
|
9
|
+
const len = stack.length;
|
|
10
|
+
for (let i = len - 1; i >= 0; i -= 1) stack?.[i]?.onEsc?.({
|
|
11
|
+
top: i === len - 1,
|
|
12
|
+
event
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function onGlobalCompositionEnd() {
|
|
17
|
+
lastCompositionEndTime = Date.now();
|
|
18
|
+
}
|
|
19
|
+
function attachGlobalEventListeners() {
|
|
20
|
+
window.addEventListener("keydown", onGlobalKeyDown);
|
|
21
|
+
window.addEventListener("compositionend", onGlobalCompositionEnd);
|
|
22
|
+
}
|
|
23
|
+
function detachGlobalEventListeners() {
|
|
24
|
+
if (stack.length === 0) {
|
|
25
|
+
window.removeEventListener("keydown", onGlobalKeyDown);
|
|
26
|
+
window.removeEventListener("compositionend", onGlobalCompositionEnd);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function useEscKeyDown(open, onEsc = () => {}) {
|
|
30
|
+
const id = useId();
|
|
31
|
+
const onEventEsc = onEsc;
|
|
32
|
+
const ensure = () => {
|
|
33
|
+
if (!stack.find((item) => item.id === id)) stack.push({
|
|
34
|
+
id,
|
|
35
|
+
onEsc: onEventEsc
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const clear = () => {
|
|
39
|
+
stack = stack.filter((item) => item.id !== id);
|
|
40
|
+
};
|
|
41
|
+
watch(open, (_, _o, onCleanup) => {
|
|
42
|
+
if (open.value) {
|
|
43
|
+
ensure();
|
|
44
|
+
attachGlobalEventListeners();
|
|
45
|
+
onCleanup(() => {
|
|
46
|
+
clear();
|
|
47
|
+
detachGlobalEventListeners();
|
|
48
|
+
});
|
|
49
|
+
} else if (!open.value) clear();
|
|
50
|
+
}, { immediate: true });
|
|
51
|
+
}
|
|
52
|
+
export { useEscKeyDown };
|
|
@@ -8,8 +8,7 @@ function useScrollLocker(lock) {
|
|
|
8
8
|
const mergedLock = (0, vue.computed)(() => (0, vue.unref)(lock));
|
|
9
9
|
uuid += 1;
|
|
10
10
|
const id = (0, vue.shallowRef)(`${UNIQUE_ID}_${uuid}`);
|
|
11
|
-
(0, vue.watch)([id, mergedLock], async () => {
|
|
12
|
-
await (0, vue.nextTick)();
|
|
11
|
+
(0, vue.watch)([id, mergedLock], async (_, _o, onCleanup) => {
|
|
13
12
|
if (mergedLock.value) {
|
|
14
13
|
const scrollbarSize = require_getScrollBarSize.getTargetScrollBarSize(document.body).width;
|
|
15
14
|
require_dynamicCSS.updateCSS(`
|
|
@@ -17,6 +16,9 @@ html body {
|
|
|
17
16
|
overflow-y: hidden;
|
|
18
17
|
${require_util.isBodyOverflowing() ? `width: calc(100% - ${scrollbarSize}px);` : ""}
|
|
19
18
|
}`, id.value);
|
|
19
|
+
onCleanup(() => {
|
|
20
|
+
require_dynamicCSS.removeCSS(id.value);
|
|
21
|
+
});
|
|
20
22
|
} else require_dynamicCSS.removeCSS(id.value);
|
|
21
23
|
}, {
|
|
22
24
|
flush: "post",
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { isBodyOverflowing } from "./util.js";
|
|
2
2
|
import { removeCSS, updateCSS } from "../../util/dist/Dom/dynamicCSS.js";
|
|
3
3
|
import { getTargetScrollBarSize } from "../../util/dist/getScrollBarSize.js";
|
|
4
|
-
import { computed,
|
|
4
|
+
import { computed, shallowRef, unref, watch } from "vue";
|
|
5
5
|
var UNIQUE_ID = `vc-util-locker-${Date.now()}`;
|
|
6
6
|
var uuid = 0;
|
|
7
7
|
function useScrollLocker(lock) {
|
|
8
8
|
const mergedLock = computed(() => unref(lock));
|
|
9
9
|
uuid += 1;
|
|
10
10
|
const id = shallowRef(`${UNIQUE_ID}_${uuid}`);
|
|
11
|
-
watch([id, mergedLock], async () => {
|
|
12
|
-
await nextTick();
|
|
11
|
+
watch([id, mergedLock], async (_, _o, onCleanup) => {
|
|
13
12
|
if (mergedLock.value) {
|
|
14
13
|
const scrollbarSize = getTargetScrollBarSize(document.body).width;
|
|
15
14
|
updateCSS(`
|
|
@@ -17,6 +16,9 @@ html body {
|
|
|
17
16
|
overflow-y: hidden;
|
|
18
17
|
${isBodyOverflowing() ? `width: calc(100% - ${scrollbarSize}px);` : ""}
|
|
19
18
|
}`, id.value);
|
|
19
|
+
onCleanup(() => {
|
|
20
|
+
removeCSS(id.value);
|
|
21
|
+
});
|
|
20
22
|
} else removeCSS(id.value);
|
|
21
23
|
}, {
|
|
22
24
|
flush: "post",
|
package/dist/previewConfig.cjs
CHANGED
|
@@ -50,6 +50,7 @@ function findExistNode(key, option = {}) {
|
|
|
50
50
|
return findStyles(getContainer(option)).find((node) => node.getAttribute(getMark(option)) === key);
|
|
51
51
|
}
|
|
52
52
|
function removeCSS(key, option = {}) {
|
|
53
|
+
if (!require_canUseDom.canUseDom()) return null;
|
|
53
54
|
const existNode = findExistNode(key, option);
|
|
54
55
|
if (existNode) getContainer(option).removeChild(existNode);
|
|
55
56
|
}
|
|
@@ -63,6 +64,7 @@ function syncRealContainer(container, option) {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
function updateCSS(css, key, option = {}) {
|
|
67
|
+
if (!require_canUseDom.canUseDom()) return null;
|
|
66
68
|
syncRealContainer(getContainer(option), option);
|
|
67
69
|
const existNode = findExistNode(key, option);
|
|
68
70
|
if (existNode) {
|
|
@@ -50,6 +50,7 @@ function findExistNode(key, option = {}) {
|
|
|
50
50
|
return findStyles(getContainer(option)).find((node) => node.getAttribute(getMark(option)) === key);
|
|
51
51
|
}
|
|
52
52
|
function removeCSS(key, option = {}) {
|
|
53
|
+
if (!canUseDom()) return null;
|
|
53
54
|
const existNode = findExistNode(key, option);
|
|
54
55
|
if (existNode) getContainer(option).removeChild(existNode);
|
|
55
56
|
}
|
|
@@ -63,6 +64,7 @@ function syncRealContainer(container, option) {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
function updateCSS(css, key, option = {}) {
|
|
67
|
+
if (!canUseDom()) return null;
|
|
66
68
|
syncRealContainer(getContainer(option), option);
|
|
67
69
|
const existNode = findExistNode(key, option);
|
|
68
70
|
if (existNode) {
|
|
@@ -36,7 +36,15 @@ function getTargetScrollBarSize(target) {
|
|
|
36
36
|
width: 0,
|
|
37
37
|
height: 0
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
if (typeof navigator !== "undefined" && /jsdom/i.test(navigator.userAgent)) return {
|
|
40
|
+
width: 0,
|
|
41
|
+
height: 0
|
|
42
|
+
};
|
|
43
|
+
let width = "0px";
|
|
44
|
+
let height = "0px";
|
|
45
|
+
try {
|
|
46
|
+
({width, height} = getComputedStyle(target, "::-webkit-scrollbar"));
|
|
47
|
+
} catch {}
|
|
40
48
|
return {
|
|
41
49
|
width: ensureSize(width),
|
|
42
50
|
height: ensureSize(height)
|
|
@@ -36,7 +36,15 @@ function getTargetScrollBarSize(target) {
|
|
|
36
36
|
width: 0,
|
|
37
37
|
height: 0
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
if (typeof navigator !== "undefined" && /jsdom/i.test(navigator.userAgent)) return {
|
|
40
|
+
width: 0,
|
|
41
|
+
height: 0
|
|
42
|
+
};
|
|
43
|
+
let width = "0px";
|
|
44
|
+
let height = "0px";
|
|
45
|
+
try {
|
|
46
|
+
({width, height} = getComputedStyle(target, "::-webkit-scrollbar"));
|
|
47
|
+
} catch {}
|
|
40
48
|
return {
|
|
41
49
|
width: ensureSize(width),
|
|
42
50
|
height: ensureSize(height)
|
package/dist/util/dist/index.cjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const require_raf = require("./raf.cjs");
|
|
2
|
+
const require_omit = require("./omit.cjs");
|
|
1
3
|
require("./RenderComponent.cjs");
|
|
2
4
|
const require_classnames = require("./classnames.cjs");
|
|
5
|
+
require("./hooks/useId.cjs");
|
|
6
|
+
const require_useMergedState = require("./hooks/useMergedState.cjs");
|
|
3
7
|
const require_warning = require("./warning.cjs");
|
package/dist/util/dist/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { raf_default } from "./raf.js";
|
|
2
|
+
import { omit } from "./omit.js";
|
|
1
3
|
import "./RenderComponent.js";
|
|
2
4
|
import { classNames, clsx } from "./classnames.js";
|
|
5
|
+
import "./hooks/useId.js";
|
|
6
|
+
import { useMergedState } from "./hooks/useMergedState.js";
|
|
3
7
|
import { warning_default } from "./warning.js";
|
|
@@ -4,6 +4,7 @@ function isEmptyElement(c) {
|
|
|
4
4
|
return c && (c.type === vue.Comment || c.type === vue.Fragment && c.children.length === 0 || c.type === vue.Text && c.children.trim() === "");
|
|
5
5
|
}
|
|
6
6
|
function filterEmpty(children = []) {
|
|
7
|
+
if (!Array.isArray(children)) children = [children];
|
|
7
8
|
const res = [];
|
|
8
9
|
children.forEach((child) => {
|
|
9
10
|
if (Array.isArray(child)) res.push(...child);
|
|
@@ -12,7 +13,6 @@ function filterEmpty(children = []) {
|
|
|
12
13
|
});
|
|
13
14
|
return res.filter((c) => !isEmptyElement(c));
|
|
14
15
|
}
|
|
15
|
-
var skipFlattenKey = Symbol("skipFlatten");
|
|
16
16
|
var defaultOptions = {
|
|
17
17
|
class: true,
|
|
18
18
|
style: true
|
|
@@ -4,6 +4,7 @@ function isEmptyElement(c) {
|
|
|
4
4
|
return c && (c.type === Comment || c.type === Fragment && c.children.length === 0 || c.type === Text && c.children.trim() === "");
|
|
5
5
|
}
|
|
6
6
|
function filterEmpty(children = []) {
|
|
7
|
+
if (!Array.isArray(children)) children = [children];
|
|
7
8
|
const res = [];
|
|
8
9
|
children.forEach((child) => {
|
|
9
10
|
if (Array.isArray(child)) res.push(...child);
|
package/dist/util.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/image",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"description": "image component",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"vue": "^3.0.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@v-c/util": "^1.0.
|
|
36
|
-
"@v-c/portal": "^1.0.
|
|
35
|
+
"@v-c/util": "^1.0.8",
|
|
36
|
+
"@v-c/portal": "^1.0.4"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@ant-design/icons-vue": "^7.0.1"
|