@v-c/image 1.0.2 → 1.0.4
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
CHANGED
|
@@ -74,7 +74,7 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
|
|
|
74
74
|
const { width, height } = props;
|
|
75
75
|
const { className, style: attrStyle, restAttrs } = getAttrStyleAndClass(attrs);
|
|
76
76
|
const coverPlacement = typeof cover.value === "object" && cover.value && cover.value.placement ? cover.value.placement || "center" : "center";
|
|
77
|
-
const coverNode = typeof cover.value === "object" && cover.value && cover.value.coverNode ? cover.value.coverNode : cover.value;
|
|
77
|
+
const coverNode = slots.cover?.() || (typeof cover.value === "object" && cover.value && cover.value.coverNode ? cover.value.coverNode : cover.value);
|
|
78
78
|
const imgStyle = [
|
|
79
79
|
height ? { height: getStylePxValue(height) } : null,
|
|
80
80
|
props.styles?.image,
|
|
@@ -6,6 +6,7 @@ import { canUseDom } from "../../util/dist/Dom/canUseDom.js";
|
|
|
6
6
|
import { useDom } from "./useDom.js";
|
|
7
7
|
import { useEscKeyDown } from "./useEscKeyDown.js";
|
|
8
8
|
import { useScrollLocker } from "./useScrollLocker.js";
|
|
9
|
+
import { getDOM } from "../../util/dist/Dom/findDOMNode.js";
|
|
9
10
|
import { Teleport, computed, createVNode, defineComponent, isVNode, mergeDefaults, onMounted, shallowRef, watch } from "vue";
|
|
10
11
|
function _isSlot(s) {
|
|
11
12
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
@@ -14,8 +15,8 @@ function getPortalContainer(getContainer) {
|
|
|
14
15
|
if (getContainer === false) return false;
|
|
15
16
|
if (!canUseDom() || !getContainer) return null;
|
|
16
17
|
if (typeof getContainer === "string") return document.querySelector(getContainer);
|
|
17
|
-
if (typeof getContainer === "function") return getContainer();
|
|
18
|
-
return getContainer;
|
|
18
|
+
if (typeof getContainer === "function") return getDOM(getContainer());
|
|
19
|
+
return typeof getContainer === "object" ? getDOM(getContainer) : getContainer;
|
|
19
20
|
}
|
|
20
21
|
var Portal_default = /* @__PURE__ */ defineComponent((props, { slots, expose }) => {
|
|
21
22
|
const shouldRender = shallowRef(props.open);
|
|
@@ -0,0 +1,20 @@
|
|
|
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,53 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { removeCSS, updateCSS } from "./Dom/dynamicCSS.js";
|
|
2
|
+
function measureScrollbarSize(ele) {
|
|
3
|
+
const randomId = `vc-scrollbar-measure-${Math.random().toString(36).substring(7)}`;
|
|
4
|
+
const measureEle = document.createElement("div");
|
|
5
|
+
measureEle.id = randomId;
|
|
6
|
+
const measureStyle = measureEle.style;
|
|
7
|
+
measureStyle.position = "absolute";
|
|
8
|
+
measureStyle.left = "0";
|
|
9
|
+
measureStyle.top = "0";
|
|
10
|
+
measureStyle.width = "100px";
|
|
11
|
+
measureStyle.height = "100px";
|
|
12
|
+
measureStyle.overflow = "scroll";
|
|
13
|
+
let fallbackWidth;
|
|
14
|
+
let fallbackHeight;
|
|
15
|
+
if (ele) {
|
|
16
|
+
const targetStyle = getComputedStyle(ele);
|
|
17
|
+
measureStyle.scrollbarColor = targetStyle.scrollbarColor;
|
|
18
|
+
measureStyle.scrollbarWidth = targetStyle.scrollbarWidth;
|
|
19
|
+
const webkitScrollbarStyle = getComputedStyle(ele, "::-webkit-scrollbar");
|
|
20
|
+
const width = parseInt(webkitScrollbarStyle.width, 10);
|
|
21
|
+
const height = parseInt(webkitScrollbarStyle.height, 10);
|
|
22
|
+
try {
|
|
23
|
+
updateCSS(`
|
|
24
|
+
#${randomId}::-webkit-scrollbar {
|
|
25
|
+
${width ? `width: ${webkitScrollbarStyle.width};` : ""}
|
|
26
|
+
${height ? `height: ${webkitScrollbarStyle.height};` : ""}
|
|
27
|
+
}`, randomId);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.error(e);
|
|
30
|
+
fallbackWidth = width;
|
|
31
|
+
fallbackHeight = height;
|
|
32
|
+
}
|
|
26
33
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return
|
|
34
|
+
document.body.appendChild(measureEle);
|
|
35
|
+
const scrollWidth = ele && fallbackWidth && !Number.isNaN(fallbackWidth) ? fallbackWidth : measureEle.offsetWidth - measureEle.clientWidth;
|
|
36
|
+
const scrollHeight = ele && fallbackHeight && !Number.isNaN(fallbackHeight) ? fallbackHeight : measureEle.offsetHeight - measureEle.clientHeight;
|
|
37
|
+
document.body.removeChild(measureEle);
|
|
38
|
+
removeCSS(randomId);
|
|
39
|
+
return {
|
|
40
|
+
width: scrollWidth,
|
|
41
|
+
height: scrollHeight
|
|
42
|
+
};
|
|
33
43
|
}
|
|
34
44
|
function getTargetScrollBarSize(target) {
|
|
35
45
|
if (typeof document === "undefined" || !target || !(target instanceof Element)) return {
|
|
36
46
|
width: 0,
|
|
37
47
|
height: 0
|
|
38
48
|
};
|
|
39
|
-
|
|
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 {}
|
|
48
|
-
return {
|
|
49
|
-
width: ensureSize(width),
|
|
50
|
-
height: ensureSize(height)
|
|
51
|
-
};
|
|
49
|
+
return measureScrollbarSize(target);
|
|
52
50
|
}
|
|
53
51
|
export { getTargetScrollBarSize };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { nextTick, shallowRef, watch } from "vue";
|
package/dist/util/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { raf_default } from "./raf.js";
|
|
|
2
2
|
import { omit } from "./omit.js";
|
|
3
3
|
import "./RenderComponent.js";
|
|
4
4
|
import { classNames, clsx } from "./classnames.js";
|
|
5
|
+
import "./hooks/useControlledState.js";
|
|
5
6
|
import "./hooks/useId.js";
|
|
6
7
|
import { useMergedState } from "./hooks/useMergedState.js";
|
|
7
8
|
import { warning_default } from "./warning.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/image",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
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/
|
|
36
|
-
"@v-c/
|
|
35
|
+
"@v-c/portal": "^1.0.7",
|
|
36
|
+
"@v-c/util": "^1.0.17"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@ant-design/icons-vue": "^7.0.1"
|