@v-c/util 0.0.5 → 0.0.6
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/props-util/index.cjs +1 -1
- package/dist/props-util/index.d.ts +1 -2
- package/dist/props-util/index.js +18 -20
- package/package.json +1 -1
- package/dist/props-util/initDefaultProps.cjs +0 -1
- package/dist/props-util/initDefaultProps.d.ts +0 -8
- package/dist/props-util/initDefaultProps.js +0 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue"),y=require("../isValid.cjs");function a(t){return t&&(t.type===u.Comment||t.type===u.Fragment&&t.children.length===0||t.type===u.Text&&t.children.trim()==="")}function o(t=[]){const r=[];return t.forEach(n=>{Array.isArray(n)?r.push(...n):n?.type===u.Fragment?r.push(...o(n.children)):r.push(n)}),r.filter(n=>!a(n))}const p=Symbol("skipFlatten");function f(t,r=!0){const n=Array.isArray(t)?t:[t],s=[];return n.forEach(e=>{Array.isArray(e)?s.push(...f(e,r)):y.default(e)?s.push(e):e&&typeof e=="object"&&e.type===u.Fragment?e.key===p?s.push(e):s.push(...f(e.children,r)):e&&u.isVNode(e)&&(r&&!a(e)?s.push(e):r||s.push(e))}),r?o(s):s}exports.filterEmpty=o;exports.flattenChildren=f;exports.isEmptyElement=a;exports.skipFlattenKey=p;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { VNode, VNodeNormalizedChildren } from 'vue';
|
|
2
|
-
import { default as initDefaultProps } from './initDefaultProps';
|
|
3
2
|
export declare function isEmptyElement(c: any): boolean;
|
|
4
3
|
export declare function filterEmpty(children?: any[]): any[];
|
|
5
4
|
export declare const skipFlattenKey: unique symbol;
|
|
6
5
|
declare function flattenChildren(children?: VNode | VNodeNormalizedChildren, isFilterEmpty?: boolean): any[];
|
|
7
|
-
export { flattenChildren
|
|
6
|
+
export { flattenChildren };
|
package/dist/props-util/index.js
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import { Comment as a, Fragment as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return t && (t.type === a || t.type === p && t.children.length === 0 || t.type === y && t.children.trim() === "");
|
|
1
|
+
import { Comment as a, Fragment as f, Text as y, isVNode as m } from "vue";
|
|
2
|
+
import A from "../isValid.js";
|
|
3
|
+
function p(r) {
|
|
4
|
+
return r && (r.type === a || r.type === f && r.children.length === 0 || r.type === y && r.children.trim() === "");
|
|
6
5
|
}
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
return
|
|
10
|
-
Array.isArray(
|
|
11
|
-
}),
|
|
6
|
+
function u(r = []) {
|
|
7
|
+
const t = [];
|
|
8
|
+
return r.forEach((s) => {
|
|
9
|
+
Array.isArray(s) ? t.push(...s) : s?.type === f ? t.push(...u(s.children)) : t.push(s);
|
|
10
|
+
}), t.filter((s) => !p(s));
|
|
12
11
|
}
|
|
13
|
-
const
|
|
14
|
-
function o(
|
|
15
|
-
const
|
|
16
|
-
return
|
|
17
|
-
Array.isArray(e) ? n.push(...o(e,
|
|
18
|
-
}),
|
|
12
|
+
const i = Symbol("skipFlatten");
|
|
13
|
+
function o(r, t = !0) {
|
|
14
|
+
const s = Array.isArray(r) ? r : [r], n = [];
|
|
15
|
+
return s.forEach((e) => {
|
|
16
|
+
Array.isArray(e) ? n.push(...o(e, t)) : A(e) ? n.push(e) : e && typeof e == "object" && e.type === f ? e.key === i ? n.push(e) : n.push(...o(e.children, t)) : e && m(e) && (t && !p(e) ? n.push(e) : t || n.push(e));
|
|
17
|
+
}), t ? u(n) : n;
|
|
19
18
|
}
|
|
20
19
|
export {
|
|
21
|
-
|
|
20
|
+
u as filterEmpty,
|
|
22
21
|
o as flattenChildren,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
A as skipFlattenKey
|
|
22
|
+
p as isEmptyElement,
|
|
23
|
+
i as skipFlattenKey
|
|
26
24
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function i(f,o){const r={...f};return Object.keys(o).forEach(t=>{const e=r[t];if(e)e.type||e.default?e.default=o[t]:e.def?e.def(o[t]):r[t]={type:e,default:o[t]};else throw new Error(`not have ${t} prop`)}),r}exports.default=i;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PropType } from 'vue';
|
|
2
|
-
import { VueTypeDef, VueTypeValidableDef } from 'vue-types';
|
|
3
|
-
declare function initDefaultProps<T>(types: T, defaultProps: {
|
|
4
|
-
[K in keyof T]?: T[K] extends VueTypeValidableDef<infer U> ? U : T[K] extends VueTypeDef<infer U> ? U : T[K] extends {
|
|
5
|
-
type: PropType<infer U>;
|
|
6
|
-
} ? U : any;
|
|
7
|
-
}): T;
|
|
8
|
-
export default initDefaultProps;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
function n(r, f) {
|
|
2
|
-
const o = { ...r };
|
|
3
|
-
return Object.keys(f).forEach((t) => {
|
|
4
|
-
const e = o[t];
|
|
5
|
-
if (e)
|
|
6
|
-
e.type || e.default ? e.default = f[t] : e.def ? e.def(f[t]) : o[t] = { type: e, default: f[t] };
|
|
7
|
-
else
|
|
8
|
-
throw new Error(`not have ${t} prop`);
|
|
9
|
-
}), o;
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
n as default
|
|
13
|
-
};
|