@veltra/mobile 1.1.1 → 1.1.2
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { bem } from "../../shared/bem.js";
|
|
2
2
|
import _sfc_main$1 from "./descriptions-item.js";
|
|
3
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref, useSlots } from "vue";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, isVNode, normalizeClass, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref, useSlots } from "vue";
|
|
4
4
|
// src/components/descriptions/descriptions.vue
|
|
5
5
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
6
6
|
name: "UDescriptions",
|
|
@@ -16,8 +16,15 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
16
16
|
const props = __props;
|
|
17
17
|
const cls = bem("descriptions");
|
|
18
18
|
const slots = useSlots();
|
|
19
|
+
function flattenVNodes(children) {
|
|
20
|
+
return children.flatMap((child) => {
|
|
21
|
+
if (!isVNode(child)) return [];
|
|
22
|
+
if (child.type !== Fragment) return [child];
|
|
23
|
+
return Array.isArray(child.children) ? flattenVNodes(child.children) : [];
|
|
24
|
+
});
|
|
25
|
+
}
|
|
19
26
|
const items = computed(() => {
|
|
20
|
-
return (slots.default?.() ?? []).filter((vnode) => vnode.type === _sfc_main$1).map((vnode) => ({
|
|
27
|
+
return flattenVNodes(slots.default?.() ?? []).filter((vnode) => vnode.type === _sfc_main$1).map((vnode) => ({
|
|
21
28
|
label: vnode.props?.label,
|
|
22
29
|
vnode
|
|
23
30
|
}));
|
|
@@ -37,7 +44,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
37
44
|
class: normalizeClass(unref(cls).e("list"))
|
|
38
45
|
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item, i) => {
|
|
39
46
|
return openBlock(), createElementBlock("li", {
|
|
40
|
-
key: i,
|
|
47
|
+
key: item.vnode.key ?? i,
|
|
41
48
|
class: normalizeClass(unref(cls).e("row"))
|
|
42
49
|
}, [createElementVNode("div", { class: normalizeClass(unref(cls).e("label")) }, toDisplayString(item.label), 3), createElementVNode("div", { class: normalizeClass(unref(cls).e("content")) }, [(openBlock(), createBlock(resolveDynamicComponent(item.vnode)))], 2)], 2);
|
|
43
50
|
}), 128))], 2)) : createCommentVNode("v-if", true)], 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptions.js","names":["UDescriptionsItem","_openBlock","_createElementBlock","_normalizeClass","_unref","_toDisplayString","_createCommentVNode","_Fragment","_renderList","_createElementVNode","_createBlock","_resolveDynamicComponent"],"sources":["../../../src/components/descriptions/descriptions.vue"],"sourcesContent":["<template>\n <div :class=\"classList\">\n <div v-if=\"title\" :class=\"cls.e('header')\">{{ title }}</div>\n\n <ul v-if=\"items.length\" :class=\"cls.e('list')\">\n <li v-for=\"(item, i) of items\" :key=\"i\" :class=\"cls.e('row')\">\n <div :class=\"cls.e('label')\">{{ item.label }}</div>\n <div :class=\"cls.e('content')\">\n <component :is=\"item.vnode\" />\n </div>\n </li>\n </ul>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, useSlots, type VNode } from 'vue'\n\nimport { bem } from '../../shared/bem'\nimport type { DescriptionsProps } from '../../types/descriptions'\nimport UDescriptionsItem from './descriptions-item.vue'\n\ndefineOptions({ name: 'UDescriptions' })\n\nconst props = defineProps<DescriptionsProps>()\n\nconst cls = bem('descriptions')\n\nconst slots = useSlots()\n\ninterface DescriptionItem {\n label: string | undefined\n vnode: VNode\n}\n\n// 插槽 vnode 须在渲染路径读取:插槽内容读取的响应式数据经调用链追踪,内容变化时重新计算。\n// 移动端单列形态不按 column 分组,逐项纵向堆叠(column 语义保留,不影响窄屏布局)\nconst items = computed<DescriptionItem[]>(() => {\n return (slots.default?.() ?? [])\n .filter((vnode) => vnode.type === UDescriptionsItem)\n .map((vnode) => ({ label: vnode.props?.label as string | undefined, vnode }))\n})\n\nconst classList = computed(() => [\n cls.b,\n cls.m(props.layout ?? 'horizontal'),\n cls.m(props.size ?? 'default'),\n bem.is('bordered', !!props.border)\n])\n</script>\n"],"mappings":";;;;;;;;;;;;;;;EAwBA,MAAM,QAAQ;EAEd,MAAM,MAAM,IAAI,cAAc;EAE9B,MAAM,QAAQ,SAAS;
|
|
1
|
+
{"version":3,"file":"descriptions.js","names":["UDescriptionsItem","_openBlock","_createElementBlock","_normalizeClass","_unref","_toDisplayString","_createCommentVNode","_Fragment","_renderList","_createElementVNode","_createBlock","_resolveDynamicComponent"],"sources":["../../../src/components/descriptions/descriptions.vue"],"sourcesContent":["<template>\n <div :class=\"classList\">\n <div v-if=\"title\" :class=\"cls.e('header')\">{{ title }}</div>\n\n <ul v-if=\"items.length\" :class=\"cls.e('list')\">\n <li v-for=\"(item, i) of items\" :key=\"item.vnode.key ?? i\" :class=\"cls.e('row')\">\n <div :class=\"cls.e('label')\">{{ item.label }}</div>\n <div :class=\"cls.e('content')\">\n <component :is=\"item.vnode\" />\n </div>\n </li>\n </ul>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, useSlots, Fragment, isVNode, type VNode, type VNodeChild } from 'vue'\n\nimport { bem } from '../../shared/bem'\nimport type { DescriptionsProps } from '../../types/descriptions'\nimport UDescriptionsItem from './descriptions-item.vue'\n\ndefineOptions({ name: 'UDescriptions' })\n\nconst props = defineProps<DescriptionsProps>()\n\nconst cls = bem('descriptions')\n\nconst slots = useSlots()\n\ninterface DescriptionItem {\n label: string | undefined\n vnode: VNode\n}\n\n// v-for / template 包裹产生的 Fragment 嵌在插槽顶层,递归展开后才能按组件类型过滤\nfunction flattenVNodes(children: VNodeChild[]): VNode[] {\n return children.flatMap((child) => {\n if (!isVNode(child)) return []\n if (child.type !== Fragment) return [child]\n return Array.isArray(child.children) ? flattenVNodes(child.children as VNodeChild[]) : []\n })\n}\n\n// 插槽 vnode 须在渲染路径读取:插槽内容读取的响应式数据经调用链追踪,内容变化时重新计算。\n// 移动端单列形态不按 column 分组,逐项纵向堆叠(column 语义保留,不影响窄屏布局)\nconst items = computed<DescriptionItem[]>(() => {\n return flattenVNodes(slots.default?.() ?? [])\n .filter((vnode) => vnode.type === UDescriptionsItem)\n .map((vnode) => ({ label: vnode.props?.label as string | undefined, vnode }))\n})\n\nconst classList = computed(() => [\n cls.b,\n cls.m(props.layout ?? 'horizontal'),\n cls.m(props.size ?? 'default'),\n bem.is('bordered', !!props.border)\n])\n</script>\n"],"mappings":";;;;;;;;;;;;;;;EAwBA,MAAM,QAAQ;EAEd,MAAM,MAAM,IAAI,cAAc;EAE9B,MAAM,QAAQ,SAAS;EAQvB,SAAS,cAAc,UAAiC;GACtD,OAAO,SAAS,SAAS,UAAU;IACjC,IAAI,CAAC,QAAQ,KAAK,GAAG,OAAO,CAAC;IAC7B,IAAI,MAAM,SAAS,UAAU,OAAO,CAAC,KAAK;IAC1C,OAAO,MAAM,QAAQ,MAAM,QAAQ,IAAI,cAAc,MAAM,QAAwB,IAAI,CAAC;GAC1F,CAAC;EACH;EAIA,MAAM,QAAQ,eAAkC;GAC9C,OAAO,cAAc,MAAM,UAAU,KAAK,CAAC,CAAC,CAAA,CACzC,QAAQ,UAAU,MAAM,SAASA,WAAiB,CAAA,CAClD,KAAK,WAAW;IAAE,OAAO,MAAM,OAAO;IAA6B;GAAM,EAAE;EAChF,CAAC;EAED,MAAM,YAAY,eAAe;GAC/B,IAAI;GACJ,IAAI,EAAE,MAAM,UAAU,YAAY;GAClC,IAAI,EAAE,MAAM,QAAQ,SAAS;GAC7B,IAAI,GAAG,YAAY,CAAC,CAAC,MAAM,MAAM;EACnC,CAAC;;GAxDC,OAAAC,UAAA,GAAAC,mBAWM,OAAA,EAXA,OAAKC,eAAE,UAAA,KAAS,E,IACT,QAAA,SAAXF,UAAA,GAAAC,mBAA4D,OAAA;;IAAzC,OAAKC,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,QAAA,CAAA;GAAe,GAAAC,gBAAA,QAAA,KAAK,GAAA,CAAA,K,kCAEzC,MAAA,MAAM,UAAhBJ,UAAA,GAAAC,mBAOK,MAAA;;IAPoB,OAAKC,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,MAAA,CAAA;G,KACnCH,UAAA,IAAA,GAAAC,mBAKKK,UAAA,MAAAC,WALmB,MAAA,QAAZ,MAAM,MAAC;IAAnB,OAAAP,UAAA,GAAAC,mBAKK,MAAA;KAL2B,KAAK,KAAK,MAAM,OAAO;KAAI,OAAKC,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,KAAA,CAAA;I,IACrEK,mBAAmD,OAAA,EAA7C,OAAKN,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,OAAA,CAAA,EAAc,GAAAC,gBAAA,KAAK,KAAK,GAAA,CAAA,GAC1CI,mBAEM,OAAA,EAFA,OAAKN,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,SAAA,CAAA,E,KAChBH,UAAA,GAAAS,YAA8BC,wBAAd,KAAK,KAAK,CAAA,E"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div v-if="title" :class="cls.e('header')">{{ title }}</div>
|
|
4
4
|
|
|
5
5
|
<ul v-if="items.length" :class="cls.e('list')">
|
|
6
|
-
<li v-for="(item, i) of items" :key="i" :class="cls.e('row')">
|
|
6
|
+
<li v-for="(item, i) of items" :key="item.vnode.key ?? i" :class="cls.e('row')">
|
|
7
7
|
<div :class="cls.e('label')">{{ item.label }}</div>
|
|
8
8
|
<div :class="cls.e('content')">
|
|
9
9
|
<component :is="item.vnode" />
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<script lang="ts" setup>
|
|
17
|
-
import { computed, useSlots, type VNode } from 'vue'
|
|
17
|
+
import { computed, useSlots, Fragment, isVNode, type VNode, type VNodeChild } from 'vue'
|
|
18
18
|
|
|
19
19
|
import { bem } from '../../shared/bem'
|
|
20
20
|
import type { DescriptionsProps } from '../../types/descriptions'
|
|
@@ -33,10 +33,19 @@ interface DescriptionItem {
|
|
|
33
33
|
vnode: VNode
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
// v-for / template 包裹产生的 Fragment 嵌在插槽顶层,递归展开后才能按组件类型过滤
|
|
37
|
+
function flattenVNodes(children: VNodeChild[]): VNode[] {
|
|
38
|
+
return children.flatMap((child) => {
|
|
39
|
+
if (!isVNode(child)) return []
|
|
40
|
+
if (child.type !== Fragment) return [child]
|
|
41
|
+
return Array.isArray(child.children) ? flattenVNodes(child.children as VNodeChild[]) : []
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
// 插槽 vnode 须在渲染路径读取:插槽内容读取的响应式数据经调用链追踪,内容变化时重新计算。
|
|
37
46
|
// 移动端单列形态不按 column 分组,逐项纵向堆叠(column 语义保留,不影响窄屏布局)
|
|
38
47
|
const items = computed<DescriptionItem[]>(() => {
|
|
39
|
-
return (slots.default?.() ?? [])
|
|
48
|
+
return flattenVNodes(slots.default?.() ?? [])
|
|
40
49
|
.filter((vnode) => vnode.type === UDescriptionsItem)
|
|
41
50
|
.map((vnode) => ({ label: vnode.props?.label as string | undefined, vnode }))
|
|
42
51
|
})
|