@v-c/util 1.0.4 → 1.0.5
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/hooks/useMemo.cjs
CHANGED
|
@@ -5,7 +5,10 @@ Object.defineProperties(exports, {
|
|
|
5
5
|
let vue = require("vue");
|
|
6
6
|
function useMemo(getValue, condition, shouldUpdate) {
|
|
7
7
|
const cacheRef = (0, vue.ref)(getValue());
|
|
8
|
-
(0, vue.watch)(condition
|
|
8
|
+
(0, vue.watch)(condition.map((item) => {
|
|
9
|
+
if (typeof item === "function" || (0, vue.isRef)(item) || (0, vue.isReactive)(item)) return item;
|
|
10
|
+
return () => item;
|
|
11
|
+
}), (next, pre) => {
|
|
9
12
|
if (shouldUpdate) {
|
|
10
13
|
if (shouldUpdate(next, pre)) cacheRef.value = getValue();
|
|
11
14
|
} else cacheRef.value = getValue();
|
package/dist/hooks/useMemo.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { ref, watch } from "vue";
|
|
1
|
+
import { isReactive, isRef, ref, watch } from "vue";
|
|
2
2
|
function useMemo(getValue, condition, shouldUpdate) {
|
|
3
3
|
const cacheRef = ref(getValue());
|
|
4
|
-
watch(condition
|
|
4
|
+
watch(condition.map((item) => {
|
|
5
|
+
if (typeof item === "function" || isRef(item) || isReactive(item)) return item;
|
|
6
|
+
return () => item;
|
|
7
|
+
}), (next, pre) => {
|
|
5
8
|
if (shouldUpdate) {
|
|
6
9
|
if (shouldUpdate(next, pre)) cacheRef.value = getValue();
|
|
7
10
|
} else cacheRef.value = getValue();
|
|
@@ -6,6 +6,7 @@ function isEmptyElement(c) {
|
|
|
6
6
|
return c && (c.type === vue.Comment || c.type === vue.Fragment && c.children.length === 0 || c.type === vue.Text && c.children.trim() === "");
|
|
7
7
|
}
|
|
8
8
|
function filterEmpty(children = []) {
|
|
9
|
+
if (!Array.isArray(children)) children = [children];
|
|
9
10
|
const res = [];
|
|
10
11
|
children.forEach((child) => {
|
|
11
12
|
if (Array.isArray(child)) res.push(...child);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref, VNode, VNodeNormalizedChildren } from 'vue';
|
|
2
2
|
export declare function isEmptyElement(c: any): boolean;
|
|
3
|
-
export declare function filterEmpty(children?: any
|
|
3
|
+
export declare function filterEmpty(children?: any): any[];
|
|
4
4
|
export declare const skipFlattenKey: unique symbol;
|
|
5
5
|
declare function flattenChildren(children?: VNode | VNodeNormalizedChildren, isFilterEmpty?: boolean): any[];
|
|
6
6
|
export { flattenChildren };
|
package/dist/props-util/index.js
CHANGED
|
@@ -5,6 +5,7 @@ function isEmptyElement(c) {
|
|
|
5
5
|
return c && (c.type === Comment || c.type === Fragment && c.children.length === 0 || c.type === Text && c.children.trim() === "");
|
|
6
6
|
}
|
|
7
7
|
function filterEmpty(children = []) {
|
|
8
|
+
if (!Array.isArray(children)) children = [children];
|
|
8
9
|
const res = [];
|
|
9
10
|
children.forEach((child) => {
|
|
10
11
|
if (Array.isArray(child)) res.push(...child);
|
package/dist/vnode.cjs
CHANGED
|
@@ -49,6 +49,10 @@ function resolveToElement(node) {
|
|
|
49
49
|
if (require_findDOMNode.isDOM(node)) return node;
|
|
50
50
|
const exposed = node;
|
|
51
51
|
if (require_findDOMNode.isDOM(exposed?.$el)) return exposed.$el;
|
|
52
|
+
else if (exposed.$el) {
|
|
53
|
+
const dom = exposed.$el;
|
|
54
|
+
if (dom && (dom.nodeType === 3 || dom.nodeType === 8) && dom.nextElementSibling) return dom.nextElementSibling;
|
|
55
|
+
}
|
|
52
56
|
const nativeEl = exposed?.nativeElement;
|
|
53
57
|
if (require_findDOMNode.isDOM(nativeEl?.value)) return nativeEl.value;
|
|
54
58
|
if (require_findDOMNode.isDOM(nativeEl)) return nativeEl;
|
package/dist/vnode.js
CHANGED
|
@@ -48,6 +48,10 @@ function resolveToElement(node) {
|
|
|
48
48
|
if (isDOM(node)) return node;
|
|
49
49
|
const exposed = node;
|
|
50
50
|
if (isDOM(exposed?.$el)) return exposed.$el;
|
|
51
|
+
else if (exposed.$el) {
|
|
52
|
+
const dom = exposed.$el;
|
|
53
|
+
if (dom && (dom.nodeType === 3 || dom.nodeType === 8) && dom.nextElementSibling) return dom.nextElementSibling;
|
|
54
|
+
}
|
|
51
55
|
const nativeEl = exposed?.nativeElement;
|
|
52
56
|
if (isDOM(nativeEl?.value)) return nativeEl.value;
|
|
53
57
|
if (isDOM(nativeEl)) return nativeEl;
|