@veltra/utils 1.2.23 → 1.2.25
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/helper/vue.d.ts +3 -1
- package/dist/helper/vue.js +5 -1
- package/dist/helper/vue.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/helper/vue.ts +5 -0
package/dist/helper/vue.d.ts
CHANGED
|
@@ -38,7 +38,9 @@ declare function isTemplate(node: unknown): node is VNode;
|
|
|
38
38
|
* @returns
|
|
39
39
|
*/
|
|
40
40
|
declare function extractNormalVNodes(nodes: VNodeArrayChildren, results?: VNode[]): VNode[];
|
|
41
|
+
/** 字段名:空串 / null / undefined 时回退默认值 */
|
|
42
|
+
declare function fieldKey(key: string | null | undefined, fallback: string): string;
|
|
41
43
|
declare function shallowComputed<T>(getter: () => T): ShallowRef<T>;
|
|
42
44
|
//#endregion
|
|
43
|
-
export { extractNormalVNodes, isComment, isFragment, isTemplate, isTextNode, shallowComputed };
|
|
45
|
+
export { extractNormalVNodes, fieldKey, isComment, isFragment, isTemplate, isTextNode, shallowComputed };
|
|
44
46
|
//# sourceMappingURL=vue.d.ts.map
|
package/dist/helper/vue.js
CHANGED
|
@@ -49,6 +49,10 @@ function extractNormalVNodes(nodes, results = []) {
|
|
|
49
49
|
});
|
|
50
50
|
return results;
|
|
51
51
|
}
|
|
52
|
+
/** 字段名:空串 / null / undefined 时回退默认值 */
|
|
53
|
+
function fieldKey(key, fallback) {
|
|
54
|
+
return key ? key : fallback;
|
|
55
|
+
}
|
|
52
56
|
function shallowComputed(getter) {
|
|
53
57
|
const result = shallowRef(getter());
|
|
54
58
|
watch(getter, (value) => {
|
|
@@ -57,6 +61,6 @@ function shallowComputed(getter) {
|
|
|
57
61
|
return result;
|
|
58
62
|
}
|
|
59
63
|
//#endregion
|
|
60
|
-
export { extractNormalVNodes, isComment, isFragment, isTemplate, isTextNode, shallowComputed };
|
|
64
|
+
export { extractNormalVNodes, fieldKey, isComment, isFragment, isTemplate, isTextNode, shallowComputed };
|
|
61
65
|
|
|
62
66
|
//# sourceMappingURL=vue.js.map
|
package/dist/helper/vue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.js","names":[],"sources":["../../src/helper/vue.ts"],"sourcesContent":["import {\n Text,\n Fragment,\n Comment,\n type VNode,\n isVNode,\n createTextVNode,\n type VNodeArrayChildren,\n shallowRef,\n watch,\n type ShallowRef\n} from 'vue'\n\ninterface TextVNode extends VNode {\n children: string\n}\n\n/**\n * 是否为文本\n * @param node\n * @returns\n */\nexport function isTextNode(node: VNode): node is TextVNode {\n return node.type === Text\n}\n\n/**\n * 是否为片段\n * @param node\n * @returns\n */\nexport function isFragment(node: any): node is VNode {\n return node && node.type === Fragment\n}\n\ninterface CommentVNode extends VNode {\n children: string\n}\n\n/**\n * 是否为注释\n * @param node\n * @returns\n */\nexport function isComment(node: VNode): node is CommentVNode {\n return node.type === Comment\n}\n\n/**\n * 是否为模板\n * @param node\n * @returns\n */\nexport function isTemplate(node: unknown): node is VNode {\n return isVNode(node) && node.type === 'template'\n}\n\n/**\n * 提取常规虚拟节点(移除type为fragment、template的节点)\n * @param nodes VNodeArrayChildren\n * @param results 虚拟节点\n * @returns\n */\nexport function extractNormalVNodes(nodes: VNodeArrayChildren, results: VNode[] = []): VNode[] {\n nodes.forEach((node) => {\n if (!isVNode(node)) {\n if (typeof node === 'string' || typeof node === 'number') {\n results.push(createTextVNode(String(node)))\n }\n return\n }\n if ((isFragment(node) || isTemplate(node)) && Array.isArray(node.children)) {\n extractNormalVNodes(node.children, results)\n } else {\n results.push(node)\n }\n })\n return results\n}\n\nexport function shallowComputed<T>(getter: () => T): ShallowRef<T> {\n const result = shallowRef<T>(getter())\n watch(getter, (value) => {\n result.value = value\n })\n\n return result\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,WAAW,MAAgC;CACzD,OAAO,KAAK,SAAS;AACvB;;;;;;AAOA,SAAgB,WAAW,MAA0B;CACnD,OAAO,QAAQ,KAAK,SAAS;AAC/B;;;;;;AAWA,SAAgB,UAAU,MAAmC;CAC3D,OAAO,KAAK,SAAS;AACvB;;;;;;AAOA,SAAgB,WAAW,MAA8B;CACvD,OAAO,QAAQ,IAAI,KAAK,KAAK,SAAS;AACxC;;;;;;;AAQA,SAAgB,oBAAoB,OAA2B,UAAmB,CAAC,GAAY;CAC7F,MAAM,SAAS,SAAS;EACtB,IAAI,CAAC,QAAQ,IAAI,GAAG;GAClB,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAC9C,QAAQ,KAAK,gBAAgB,OAAO,IAAI,CAAC,CAAC;GAE5C;EACF;EACA,KAAK,WAAW,IAAI,KAAK,WAAW,IAAI,MAAM,MAAM,QAAQ,KAAK,QAAQ,GACvE,oBAAoB,KAAK,UAAU,OAAO;OAE1C,QAAQ,KAAK,IAAI;CAErB,CAAC;CACD,OAAO;AACT;AAEA,SAAgB,gBAAmB,QAAgC;CACjE,MAAM,SAAS,WAAc,OAAO,CAAC;CACrC,MAAM,SAAS,UAAU;EACvB,OAAO,QAAQ;CACjB,CAAC;CAED,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"vue.js","names":[],"sources":["../../src/helper/vue.ts"],"sourcesContent":["import {\n Text,\n Fragment,\n Comment,\n type VNode,\n isVNode,\n createTextVNode,\n type VNodeArrayChildren,\n shallowRef,\n watch,\n type ShallowRef\n} from 'vue'\n\ninterface TextVNode extends VNode {\n children: string\n}\n\n/**\n * 是否为文本\n * @param node\n * @returns\n */\nexport function isTextNode(node: VNode): node is TextVNode {\n return node.type === Text\n}\n\n/**\n * 是否为片段\n * @param node\n * @returns\n */\nexport function isFragment(node: any): node is VNode {\n return node && node.type === Fragment\n}\n\ninterface CommentVNode extends VNode {\n children: string\n}\n\n/**\n * 是否为注释\n * @param node\n * @returns\n */\nexport function isComment(node: VNode): node is CommentVNode {\n return node.type === Comment\n}\n\n/**\n * 是否为模板\n * @param node\n * @returns\n */\nexport function isTemplate(node: unknown): node is VNode {\n return isVNode(node) && node.type === 'template'\n}\n\n/**\n * 提取常规虚拟节点(移除type为fragment、template的节点)\n * @param nodes VNodeArrayChildren\n * @param results 虚拟节点\n * @returns\n */\nexport function extractNormalVNodes(nodes: VNodeArrayChildren, results: VNode[] = []): VNode[] {\n nodes.forEach((node) => {\n if (!isVNode(node)) {\n if (typeof node === 'string' || typeof node === 'number') {\n results.push(createTextVNode(String(node)))\n }\n return\n }\n if ((isFragment(node) || isTemplate(node)) && Array.isArray(node.children)) {\n extractNormalVNodes(node.children, results)\n } else {\n results.push(node)\n }\n })\n return results\n}\n\n/** 字段名:空串 / null / undefined 时回退默认值 */\nexport function fieldKey(key: string | null | undefined, fallback: string): string {\n return key ? key : fallback\n}\n\nexport function shallowComputed<T>(getter: () => T): ShallowRef<T> {\n const result = shallowRef<T>(getter())\n watch(getter, (value) => {\n result.value = value\n })\n\n return result\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,WAAW,MAAgC;CACzD,OAAO,KAAK,SAAS;AACvB;;;;;;AAOA,SAAgB,WAAW,MAA0B;CACnD,OAAO,QAAQ,KAAK,SAAS;AAC/B;;;;;;AAWA,SAAgB,UAAU,MAAmC;CAC3D,OAAO,KAAK,SAAS;AACvB;;;;;;AAOA,SAAgB,WAAW,MAA8B;CACvD,OAAO,QAAQ,IAAI,KAAK,KAAK,SAAS;AACxC;;;;;;;AAQA,SAAgB,oBAAoB,OAA2B,UAAmB,CAAC,GAAY;CAC7F,MAAM,SAAS,SAAS;EACtB,IAAI,CAAC,QAAQ,IAAI,GAAG;GAClB,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAC9C,QAAQ,KAAK,gBAAgB,OAAO,IAAI,CAAC,CAAC;GAE5C;EACF;EACA,KAAK,WAAW,IAAI,KAAK,WAAW,IAAI,MAAM,MAAM,QAAQ,KAAK,QAAQ,GACvE,oBAAoB,KAAK,UAAU,OAAO;OAE1C,QAAQ,KAAK,IAAI;CAErB,CAAC;CACD,OAAO;AACT;;AAGA,SAAgB,SAAS,KAAgC,UAA0B;CACjF,OAAO,MAAM,MAAM;AACrB;AAEA,SAAgB,gBAAmB,QAAgC;CACjE,MAAM,SAAS,WAAc,OAAO,CAAC;CACrC,MAAM,SAAS,UAAU;EACvB,OAAO,QAAQ;CACjB,CAAC;CAED,OAAO;AACT"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ import { createIncrease } from "./helper/create-increase.js";
|
|
|
10
10
|
import { createToggle } from "./helper/create-toggle.js";
|
|
11
11
|
import { AnimeConfig, Tween, TweenConfig } from "./helper/tween.js";
|
|
12
12
|
import { nextFrame } from "./helper/frame.js";
|
|
13
|
-
import { extractNormalVNodes, isComment, isFragment, isTemplate, isTextNode, shallowComputed } from "./helper/vue.js";
|
|
13
|
+
import { extractNormalVNodes, fieldKey, isComment, isFragment, isTemplate, isTextNode, shallowComputed } from "./helper/vue.js";
|
|
14
14
|
import { middleProxy } from "./reactive/proxy.js";
|
|
15
15
|
import { DeconstructValue, DefineEvent, Index, Null, RenderReturn, Undef } from "./types/helper.js";
|
|
16
16
|
import { BreakpointName, ColorType, ComponentProps, ComponentSize, FormComponentProps, PresetRule, PropsWithServerQuery, ValidateRule } from "./types/component-common.js";
|
|
17
17
|
import { FormContextModel, FormContextProps, FormFieldItem, injectFormContext, provideFormContext } from "./types/form-context.js";
|
|
18
|
-
export { AnimeConfig, BEM, BEMFactory, BreakpointName, CLS_PREFIX, ColorType, ComponentProps, ComponentSize, DeconstructValue, DefineEvent, ExpandTransition, ExpandTransitionOptions, FORM_EMPTY_CONTENT, FormComponentProps, FormContextModel, FormContextProps, FormFieldItem, Index, NAME_SPACE, Null, PresetRule, PropsWithServerQuery, RenderReturn, Tween, TweenConfig, Undef, ValidateRule, addClass, bem, createIncrease, createToggle, extractNormalVNodes, getHighlightChunks, getNearestScrollParent, getScrollParents, injectFormContext, isComment, isFragment, isTemplate, isTextNode, makeBEM, middleProxy, nextFrame, provideFormContext, removeClass, removeStyles, scrollIntoContainerView, setStyles, shallowComputed, withUnit, zIndex };
|
|
18
|
+
export { AnimeConfig, BEM, BEMFactory, BreakpointName, CLS_PREFIX, ColorType, ComponentProps, ComponentSize, DeconstructValue, DefineEvent, ExpandTransition, ExpandTransitionOptions, FORM_EMPTY_CONTENT, FormComponentProps, FormContextModel, FormContextProps, FormFieldItem, Index, NAME_SPACE, Null, PresetRule, PropsWithServerQuery, RenderReturn, Tween, TweenConfig, Undef, ValidateRule, addClass, bem, createIncrease, createToggle, extractNormalVNodes, fieldKey, getHighlightChunks, getNearestScrollParent, getScrollParents, injectFormContext, isComment, isFragment, isTemplate, isTextNode, makeBEM, middleProxy, nextFrame, provideFormContext, removeClass, removeStyles, scrollIntoContainerView, setStyles, shallowComputed, withUnit, zIndex };
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { zIndex } from "./dom/z-index.js";
|
|
|
10
10
|
import { createToggle } from "./helper/create-toggle.js";
|
|
11
11
|
import { Tween } from "./helper/tween.js";
|
|
12
12
|
import { nextFrame } from "./helper/frame.js";
|
|
13
|
-
import { extractNormalVNodes, isComment, isFragment, isTemplate, isTextNode, shallowComputed } from "./helper/vue.js";
|
|
13
|
+
import { extractNormalVNodes, fieldKey, isComment, isFragment, isTemplate, isTextNode, shallowComputed } from "./helper/vue.js";
|
|
14
14
|
import { middleProxy } from "./reactive/proxy.js";
|
|
15
15
|
import { injectFormContext, provideFormContext } from "./types/form-context.js";
|
|
16
|
-
export { CLS_PREFIX, ExpandTransition, FORM_EMPTY_CONTENT, NAME_SPACE, Tween, addClass, bem, createIncrease, createToggle, extractNormalVNodes, getHighlightChunks, getNearestScrollParent, getScrollParents, injectFormContext, isComment, isFragment, isTemplate, isTextNode, makeBEM, middleProxy, nextFrame, provideFormContext, removeClass, removeStyles, scrollIntoContainerView, setStyles, shallowComputed, withUnit, zIndex };
|
|
16
|
+
export { CLS_PREFIX, ExpandTransition, FORM_EMPTY_CONTENT, NAME_SPACE, Tween, addClass, bem, createIncrease, createToggle, extractNormalVNodes, fieldKey, getHighlightChunks, getNearestScrollParent, getScrollParents, injectFormContext, isComment, isFragment, isTemplate, isTextNode, makeBEM, middleProxy, nextFrame, provideFormContext, removeClass, removeStyles, scrollIntoContainerView, setStyles, shallowComputed, withUnit, zIndex };
|
package/package.json
CHANGED
package/src/helper/vue.ts
CHANGED
|
@@ -78,6 +78,11 @@ export function extractNormalVNodes(nodes: VNodeArrayChildren, results: VNode[]
|
|
|
78
78
|
return results
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/** 字段名:空串 / null / undefined 时回退默认值 */
|
|
82
|
+
export function fieldKey(key: string | null | undefined, fallback: string): string {
|
|
83
|
+
return key ? key : fallback
|
|
84
|
+
}
|
|
85
|
+
|
|
81
86
|
export function shallowComputed<T>(getter: () => T): ShallowRef<T> {
|
|
82
87
|
const result = shallowRef<T>(getter())
|
|
83
88
|
watch(getter, (value) => {
|