vft 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/index.css +1 -1
- package/es/component.mjs +9 -6
- package/es/component.mjs.map +1 -1
- package/es/components/avatar/avatar.vue2.mjs +12 -11
- package/es/components/avatar/avatar.vue2.mjs.map +1 -1
- package/es/components/avatar/index.mjs +2 -0
- package/es/components/avatar/index.mjs.map +1 -1
- package/es/components/back-top/back-top.vue2.mjs +20 -18
- package/es/components/back-top/back-top.vue2.mjs.map +1 -1
- package/es/components/back-top/index.mjs +2 -0
- package/es/components/back-top/index.mjs.map +1 -1
- package/es/components/divider/divider.vue2.mjs +4 -2
- package/es/components/divider/divider.vue2.mjs.map +1 -1
- package/es/components/divider/index.mjs +5 -3
- package/es/components/divider/index.mjs.map +1 -1
- package/es/components/empty/empty.vue2.mjs.map +1 -1
- package/es/components/empty/index.mjs +7 -5
- package/es/components/empty/index.mjs.map +1 -1
- package/es/components/exception/index.mjs +5 -3
- package/es/components/exception/index.mjs.map +1 -1
- package/es/components/icon/icon.vue2.mjs +11 -10
- package/es/components/icon/icon.vue2.mjs.map +1 -1
- package/es/components/icon/index.mjs +5 -3
- package/es/components/icon/index.mjs.map +1 -1
- package/es/components/index.d.ts +1 -0
- package/es/components/index.mjs +11 -6
- package/es/components/index.mjs.map +1 -1
- package/es/components/result/index.mjs +5 -3
- package/es/components/result/index.mjs.map +1 -1
- package/es/components/result/result.vue2.mjs +4 -2
- package/es/components/result/result.vue2.mjs.map +1 -1
- package/es/components/tabs/index.d.ts +356 -0
- package/es/components/tabs/index.mjs +15 -0
- package/es/components/tabs/index.mjs.map +1 -0
- package/es/components/tabs/style/css.d.ts +0 -0
- package/es/components/tabs/style/css.mjs +3 -0
- package/es/components/tabs/style/css.mjs.map +1 -0
- package/es/components/tabs/style/index.d.ts +0 -0
- package/es/components/tabs/style/index.mjs +3 -0
- package/es/components/tabs/style/index.mjs.map +1 -0
- package/es/components/tabs/tab-bar.vue.d.ts +51 -0
- package/es/components/tabs/tab-bar.vue.mjs +5 -0
- package/es/components/tabs/tab-bar.vue.mjs.map +1 -0
- package/es/components/tabs/tab-bar.vue2.mjs +53 -0
- package/es/components/tabs/tab-bar.vue2.mjs.map +1 -0
- package/es/components/tabs/tab-nav.vue.d.ts +121 -0
- package/es/components/tabs/tab-nav.vue.mjs +5 -0
- package/es/components/tabs/tab-nav.vue.mjs.map +1 -0
- package/es/components/tabs/tab-nav.vue2.mjs +167 -0
- package/es/components/tabs/tab-nav.vue2.mjs.map +1 -0
- package/es/components/tabs/tab-pane.vue.d.ts +45 -0
- package/es/components/tabs/tab-pane.vue.mjs +5 -0
- package/es/components/tabs/tab-pane.vue.mjs.map +1 -0
- package/es/components/tabs/tab-pane.vue2.mjs +57 -0
- package/es/components/tabs/tab-pane.vue2.mjs.map +1 -0
- package/es/components/tabs/tabs.vue.d.ts +159 -0
- package/es/components/tabs/tabs.vue.mjs +5 -0
- package/es/components/tabs/tabs.vue.mjs.map +1 -0
- package/es/components/tabs/tabs.vue2.mjs +151 -0
- package/es/components/tabs/tabs.vue2.mjs.map +1 -0
- package/es/components/tabs/types.d.ts +58 -0
- package/es/components/tabs/types.mjs +5 -0
- package/es/components/tabs/types.mjs.map +1 -0
- package/es/hooks/index.d.ts +1 -0
- package/es/hooks/index.mjs +6 -4
- package/es/hooks/index.mjs.map +1 -1
- package/es/hooks/use-ordered-children/index.d.ts +8 -0
- package/es/hooks/use-ordered-children/index.mjs +27 -0
- package/es/hooks/use-ordered-children/index.mjs.map +1 -0
- package/es/index.d.ts +1 -1
- package/es/index.mjs +42 -35
- package/es/index.mjs.map +1 -1
- package/es/package.json.mjs +1 -1
- package/es/style.css +1 -1
- package/es/theme-style/src/tabs.scss.mjs +5 -0
- package/es/theme-style/src/tabs.scss.mjs.map +1 -0
- package/es/utils/index.mjs +23 -10
- package/es/utils/index.mjs.map +1 -1
- package/es/utils/vue/index.d.ts +1 -0
- package/es/utils/vue/index.mjs +18 -5
- package/es/utils/vue/index.mjs.map +1 -1
- package/es/utils/vue/vnode.d.ts +51 -0
- package/es/utils/vue/vnode.mjs +67 -0
- package/es/utils/vue/vnode.mjs.map +1 -0
- package/lib/component.js +1 -1
- package/lib/component.js.map +1 -1
- package/lib/components/avatar/avatar.vue2.js +1 -1
- package/lib/components/avatar/avatar.vue2.js.map +1 -1
- package/lib/components/avatar/index.js +1 -1
- package/lib/components/avatar/index.js.map +1 -1
- package/lib/components/back-top/back-top.vue2.js +1 -1
- package/lib/components/back-top/back-top.vue2.js.map +1 -1
- package/lib/components/back-top/index.js +1 -1
- package/lib/components/back-top/index.js.map +1 -1
- package/lib/components/divider/divider.vue2.js +1 -1
- package/lib/components/divider/divider.vue2.js.map +1 -1
- package/lib/components/divider/index.js +1 -1
- package/lib/components/divider/index.js.map +1 -1
- package/lib/components/empty/empty.vue2.js.map +1 -1
- package/lib/components/empty/index.js +1 -1
- package/lib/components/empty/index.js.map +1 -1
- package/lib/components/exception/index.js +1 -1
- package/lib/components/exception/index.js.map +1 -1
- package/lib/components/icon/icon.vue2.js +1 -1
- package/lib/components/icon/icon.vue2.js.map +1 -1
- package/lib/components/icon/index.js +1 -1
- package/lib/components/icon/index.js.map +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -1
- package/lib/components/result/index.js +1 -1
- package/lib/components/result/index.js.map +1 -1
- package/lib/components/result/result.vue2.js +1 -1
- package/lib/components/result/result.vue2.js.map +1 -1
- package/lib/components/tabs/index.d.ts +356 -0
- package/lib/components/tabs/index.js +2 -0
- package/lib/components/tabs/index.js.map +1 -0
- package/lib/components/tabs/style/css.d.ts +0 -0
- package/lib/components/tabs/style/css.js +2 -0
- package/lib/components/tabs/style/css.js.map +1 -0
- package/lib/components/tabs/style/index.d.ts +0 -0
- package/lib/components/tabs/style/index.js +2 -0
- package/lib/components/tabs/style/index.js.map +1 -0
- package/lib/components/tabs/tab-bar.vue.d.ts +51 -0
- package/lib/components/tabs/tab-bar.vue.js +2 -0
- package/lib/components/tabs/tab-bar.vue.js.map +1 -0
- package/lib/components/tabs/tab-bar.vue2.js +2 -0
- package/lib/components/tabs/tab-bar.vue2.js.map +1 -0
- package/lib/components/tabs/tab-nav.vue.d.ts +121 -0
- package/lib/components/tabs/tab-nav.vue.js +2 -0
- package/lib/components/tabs/tab-nav.vue.js.map +1 -0
- package/lib/components/tabs/tab-nav.vue2.js +2 -0
- package/lib/components/tabs/tab-nav.vue2.js.map +1 -0
- package/lib/components/tabs/tab-pane.vue.d.ts +45 -0
- package/lib/components/tabs/tab-pane.vue.js +2 -0
- package/lib/components/tabs/tab-pane.vue.js.map +1 -0
- package/lib/components/tabs/tab-pane.vue2.js +2 -0
- package/lib/components/tabs/tab-pane.vue2.js.map +1 -0
- package/lib/components/tabs/tabs.vue.d.ts +159 -0
- package/lib/components/tabs/tabs.vue.js +2 -0
- package/lib/components/tabs/tabs.vue.js.map +1 -0
- package/lib/components/tabs/tabs.vue2.js +2 -0
- package/lib/components/tabs/tabs.vue2.js.map +1 -0
- package/lib/components/tabs/types.d.ts +58 -0
- package/lib/components/tabs/types.js +2 -0
- package/lib/components/tabs/types.js.map +1 -0
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +1 -1
- package/lib/hooks/use-ordered-children/index.d.ts +8 -0
- package/lib/hooks/use-ordered-children/index.js +2 -0
- package/lib/hooks/use-ordered-children/index.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/package.json.js +1 -1
- package/lib/theme-style/src/tabs.scss.js +2 -0
- package/lib/theme-style/src/tabs.scss.js.map +1 -0
- package/lib/utils/index.js +1 -1
- package/lib/utils/vue/index.d.ts +1 -0
- package/lib/utils/vue/index.js +1 -1
- package/lib/utils/vue/vnode.d.ts +51 -0
- package/lib/utils/vue/vnode.js +2 -0
- package/lib/utils/vue/vnode.js.map +1 -0
- package/package.json +1 -1
- package/theme-style/index.css +1 -1
- package/theme-style/src/index.scss +1 -0
- package/theme-style/src/tabs.scss +582 -0
- package/theme-style/vft-tabs.css +1 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PropType as __PropType } from 'vue';
|
|
2
|
+
declare const _sfc_main: import("vue").DefineComponent<{
|
|
3
|
+
label: {
|
|
4
|
+
type: __PropType<string | undefined>;
|
|
5
|
+
required: false;
|
|
6
|
+
};
|
|
7
|
+
name: {
|
|
8
|
+
type: __PropType<Numberish | undefined>;
|
|
9
|
+
required: false;
|
|
10
|
+
};
|
|
11
|
+
closable: {
|
|
12
|
+
type: __PropType<boolean | undefined>;
|
|
13
|
+
required: false;
|
|
14
|
+
};
|
|
15
|
+
disabled: {
|
|
16
|
+
type: __PropType<boolean | undefined>;
|
|
17
|
+
required: false;
|
|
18
|
+
};
|
|
19
|
+
lazy: {
|
|
20
|
+
type: __PropType<boolean | undefined>;
|
|
21
|
+
required: false;
|
|
22
|
+
};
|
|
23
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
24
|
+
label: {
|
|
25
|
+
type: __PropType<string | undefined>;
|
|
26
|
+
required: false;
|
|
27
|
+
};
|
|
28
|
+
name: {
|
|
29
|
+
type: __PropType<Numberish | undefined>;
|
|
30
|
+
required: false;
|
|
31
|
+
};
|
|
32
|
+
closable: {
|
|
33
|
+
type: __PropType<boolean | undefined>;
|
|
34
|
+
required: false;
|
|
35
|
+
};
|
|
36
|
+
disabled: {
|
|
37
|
+
type: __PropType<boolean | undefined>;
|
|
38
|
+
required: false;
|
|
39
|
+
};
|
|
40
|
+
lazy: {
|
|
41
|
+
type: __PropType<boolean | undefined>;
|
|
42
|
+
required: false;
|
|
43
|
+
};
|
|
44
|
+
}>>, {}>;
|
|
45
|
+
export default _sfc_main;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab-pane.vue.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),f=require("./types.js"),v=require("../../hooks/use-namespace/index.js");require("@vue/shared");require("@vft/utils");const i=require("@vueuse/core"),y=["id","aria-hidden","aria-labelledby"],d=v.useNamespace("tab-pane"),C=e.defineComponent({name:d.b()}),h=e.defineComponent({...C,props:{label:null,name:null,closable:{type:Boolean},disabled:{type:Boolean},lazy:{type:Boolean}},setup(n){const o=e.getCurrentInstance(),m=e.useSlots(),a=e.inject(f.TabsRootContextKey),r=e.ref(),p=e.computed(()=>n.closable||a.props.closable),t=i.eagerComputed(()=>a.currentName.value===(n.name??r.value)),u=e.ref(t.value),l=e.computed(()=>n.name??r.value),b=i.eagerComputed(()=>!n.lazy||u.value||t.value);e.watch(t,s=>{s&&(u.value=!0)});const c=e.reactive({uid:o.uid,slots:m,props:o.props,paneName:l,active:t,index:r,isClosable:p,attrs:o.attrs});return e.onMounted(()=>{a.registerPane(c)}),e.onUnmounted(()=>{a.unregisterPane(c.uid)}),(s,g)=>e.unref(b)?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:0,id:`pane-${e.unref(l)}`,class:e.normalizeClass(e.unref(d).b()),role:"tabpanel","aria-hidden":!e.unref(t),"aria-labelledby":`tab-${e.unref(l)}`},[e.renderSlot(s.$slots,"default")],10,y)),[[e.vShow,e.unref(t)]]):e.createCommentVNode("",!0)}});exports.default=h;
|
|
2
|
+
//# sourceMappingURL=tab-pane.vue2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab-pane.vue2.js","sources":["../../../../../packages/components/tabs/tab-pane.vue"],"sourcesContent":["<script lang=\"ts\">\nconst ns = /* hoist-static*/ useNamespace('tab-pane')\n\nimport { defineComponent as DO_defineComponent } from 'vue';\nexport default /*#__PURE__*/ DO_defineComponent({\n name: ns.b()\n});</script>\n<script lang=\"ts\" setup>\nimport { type TabsPaneContext, TabsRootContextKey } from './types';\nimport { useNamespace } from '@vft-ui/hooks';\nimport {\n computed,\n getCurrentInstance,\n inject,\n onMounted,\n onUnmounted,\n reactive,\n ref,\n useSlots,\n watch\n} from 'vue';\nimport { eagerComputed } from '@vueuse/core';\n\ninterface TabPaneProps {\n /** 选项卡标题 */\n label?: string;\n /** 与选项卡绑定值 value 对应的标识符,表示选项卡别名 */\n name?: Numberish;\n /** 标签是否可关闭 */\n closable?: boolean;\n /** 是否禁用 */\n disabled?: boolean;\n /** 标签是否延迟渲染 */\n lazy?: boolean;\n}\n\ndefineProps({\n \"label\": null,\n \"name\": null,\n \"closable\": { type: Boolean, },\n \"disabled\": { type: Boolean, },\n \"lazy\": { type: Boolean, }\n})\n\nconst vm = getCurrentInstance()!;\n\nconst slots = useSlots();\n\nconst tabsRoot = inject(TabsRootContextKey)!;\n\n\n\n;\n\nconst index = ref<string>();\n// 可关闭\nconst isClosable = computed(() => __props.closable || tabsRoot.props.closable);\n// 激活\nconst active = eagerComputed(() => {\n return tabsRoot.currentName.value === (__props.name ?? index.value);\n});\n\nconst loaded = ref(active.value);\n\nconst paneName = computed(() => __props.name ?? index.value);\n\nconst shouldBeRender = eagerComputed(() => {\n return !__props.lazy || loaded.value || active.value;\n});\n\nwatch(active, (val) => {\n if (val) loaded.value = true;\n});\n\nconst pane = reactive({\n uid: vm.uid,\n slots,\n props: vm.props as unknown as TabPaneProps,\n paneName,\n active,\n index,\n isClosable,\n attrs: vm.attrs\n});\n\n\nonMounted(() => {\n tabsRoot.registerPane(pane as TabsPaneContext);\n});\n\nonUnmounted(() => {\n tabsRoot.unregisterPane(pane.uid);\n});\n</script>\n\n<template>\n <div v-if=\"shouldBeRender\" v-show=\"active\" :id=\"`pane-${paneName}`\" :class=\"ns.b()\"\n role=\"tabpanel\" :aria-hidden=\"!active\" :aria-labelledby=\"`tab-${paneName}`\">\n <slot />\n </div>\n</template>\n"],"names":["ns","useNamespace","__default__","DO_defineComponent","vm","getCurrentInstance","slots","useSlots","tabsRoot","inject","TabsRootContextKey","index","ref","isClosable","computed","__props","active","eagerComputed","loaded","paneName","shouldBeRender","watch","val","pane","reactive","onMounted","onUnmounted"],"mappings":"iUACMA,EAAuBC,EAAAA,aAAa,UAAU,EAGpDC,EAA6BC,EAAAA,gBAAmB,CAC9C,KAAMH,EAAG,EAAE,CACb,CAAC,sIAsCD,MAAMI,EAAKC,EAAAA,qBAELC,EAAQC,EAAAA,WAERC,EAAWC,SAAOC,EAAAA,kBAAkB,EAMpCC,EAAQC,EAAAA,MAERC,EAAaC,EAAS,SAAA,IAAMC,EAAQ,UAAYP,EAAS,MAAM,QAAQ,EAEvEQ,EAASC,EAAAA,cAAc,IACpBT,EAAS,YAAY,SAAWO,EAAQ,MAAQJ,EAAM,MAC9D,EAEKO,EAASN,EAAAA,IAAII,EAAO,KAAK,EAEzBG,EAAWL,EAAAA,SAAS,IAAMC,EAAQ,MAAQJ,EAAM,KAAK,EAErDS,EAAiBH,EAAAA,cAAc,IAC5B,CAACF,EAAQ,MAAQG,EAAO,OAASF,EAAO,KAChD,EAEKK,QAAAL,EAASM,GAAQ,CACjBA,IAAKJ,EAAO,MAAQ,GAAA,CACzB,EAED,MAAMK,EAAOC,EAAAA,SAAS,CACpB,IAAKpB,EAAG,IACR,MAAAE,EACA,MAAOF,EAAG,MACV,SAAAe,EACA,OAAAH,EACA,MAAAL,EACA,WAAAE,EACA,MAAOT,EAAG,KAAA,CACX,EAGDqB,OAAAA,EAAAA,UAAU,IAAM,CACdjB,EAAS,aAAae,CAAuB,CAAA,CAC9C,EAEDG,EAAAA,YAAY,IAAM,CACPlB,EAAA,eAAee,EAAK,GAAG,CAAA,CACjC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { PropType as __PropType } from 'vue';
|
|
2
|
+
import { type IconProps } from 'vft/es/components';
|
|
3
|
+
import { type TabsPaneContext, type TabsType } from './types';
|
|
4
|
+
declare const _sfc_main: import("vue").DefineComponent<{
|
|
5
|
+
type: {
|
|
6
|
+
type: __PropType<TabsType | undefined>;
|
|
7
|
+
required: false;
|
|
8
|
+
};
|
|
9
|
+
closable: {
|
|
10
|
+
type: __PropType<boolean | undefined>;
|
|
11
|
+
required: false;
|
|
12
|
+
};
|
|
13
|
+
addable: {
|
|
14
|
+
type: __PropType<boolean | undefined>;
|
|
15
|
+
required: false;
|
|
16
|
+
};
|
|
17
|
+
modelValue: {
|
|
18
|
+
type: __PropType<Numberish>;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
editable: {
|
|
22
|
+
type: __PropType<boolean | undefined>;
|
|
23
|
+
required: false;
|
|
24
|
+
};
|
|
25
|
+
tabPosition: {
|
|
26
|
+
type: __PropType<"left" | "right" | "top" | "bottom" | undefined>;
|
|
27
|
+
required: false;
|
|
28
|
+
};
|
|
29
|
+
beforeLeave: {
|
|
30
|
+
type: __PropType<Function | undefined>;
|
|
31
|
+
required: false;
|
|
32
|
+
};
|
|
33
|
+
stretch: {
|
|
34
|
+
type: __PropType<boolean | undefined>;
|
|
35
|
+
required: false;
|
|
36
|
+
};
|
|
37
|
+
closeIconCfg: {
|
|
38
|
+
type: __PropType<IconProps | undefined>;
|
|
39
|
+
required: false;
|
|
40
|
+
};
|
|
41
|
+
addIconCfg: {
|
|
42
|
+
type: __PropType<IconProps | undefined>;
|
|
43
|
+
required: false;
|
|
44
|
+
};
|
|
45
|
+
arrowLeftIconCfg: {
|
|
46
|
+
type: __PropType<IconProps | undefined>;
|
|
47
|
+
required: false;
|
|
48
|
+
};
|
|
49
|
+
arrowRightIconCfg: {
|
|
50
|
+
type: __PropType<IconProps | undefined>;
|
|
51
|
+
required: false;
|
|
52
|
+
};
|
|
53
|
+
}, {
|
|
54
|
+
currentName: import("vue").Ref<Numberish>;
|
|
55
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
56
|
+
"update:modelValue": (name: Numberish) => boolean;
|
|
57
|
+
/** 点击 */
|
|
58
|
+
tabClick: (pane: TabsPaneContext, ev: Event) => boolean;
|
|
59
|
+
/** 右键点击 */
|
|
60
|
+
tabContextMenu: (pane: TabsPaneContext, index: number, ev: Event) => boolean;
|
|
61
|
+
tabChange: (name: Numberish) => boolean;
|
|
62
|
+
edit: (paneName: Numberish | undefined, action: 'remove' | 'add') => boolean;
|
|
63
|
+
/** 移除 */
|
|
64
|
+
tabRemove: (name: Numberish) => boolean;
|
|
65
|
+
/** 增加 */
|
|
66
|
+
tabAdd: () => true;
|
|
67
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
68
|
+
type: {
|
|
69
|
+
type: __PropType<TabsType | undefined>;
|
|
70
|
+
required: false;
|
|
71
|
+
};
|
|
72
|
+
closable: {
|
|
73
|
+
type: __PropType<boolean | undefined>;
|
|
74
|
+
required: false;
|
|
75
|
+
};
|
|
76
|
+
addable: {
|
|
77
|
+
type: __PropType<boolean | undefined>;
|
|
78
|
+
required: false;
|
|
79
|
+
};
|
|
80
|
+
modelValue: {
|
|
81
|
+
type: __PropType<Numberish>;
|
|
82
|
+
required: true;
|
|
83
|
+
};
|
|
84
|
+
editable: {
|
|
85
|
+
type: __PropType<boolean | undefined>;
|
|
86
|
+
required: false;
|
|
87
|
+
};
|
|
88
|
+
tabPosition: {
|
|
89
|
+
type: __PropType<"left" | "right" | "top" | "bottom" | undefined>;
|
|
90
|
+
required: false;
|
|
91
|
+
};
|
|
92
|
+
beforeLeave: {
|
|
93
|
+
type: __PropType<Function | undefined>;
|
|
94
|
+
required: false;
|
|
95
|
+
};
|
|
96
|
+
stretch: {
|
|
97
|
+
type: __PropType<boolean | undefined>;
|
|
98
|
+
required: false;
|
|
99
|
+
};
|
|
100
|
+
closeIconCfg: {
|
|
101
|
+
type: __PropType<IconProps | undefined>;
|
|
102
|
+
required: false;
|
|
103
|
+
};
|
|
104
|
+
addIconCfg: {
|
|
105
|
+
type: __PropType<IconProps | undefined>;
|
|
106
|
+
required: false;
|
|
107
|
+
};
|
|
108
|
+
arrowLeftIconCfg: {
|
|
109
|
+
type: __PropType<IconProps | undefined>;
|
|
110
|
+
required: false;
|
|
111
|
+
};
|
|
112
|
+
arrowRightIconCfg: {
|
|
113
|
+
type: __PropType<IconProps | undefined>;
|
|
114
|
+
required: false;
|
|
115
|
+
};
|
|
116
|
+
}>> & {
|
|
117
|
+
"onUpdate:modelValue"?: ((name: Numberish) => any) | undefined;
|
|
118
|
+
onTabClick?: ((pane: {
|
|
119
|
+
uid: number;
|
|
120
|
+
slots: Readonly<{
|
|
121
|
+
[name: string]: import("vue").Slot | undefined;
|
|
122
|
+
}>;
|
|
123
|
+
props: {
|
|
124
|
+
label: string;
|
|
125
|
+
name: Numberish;
|
|
126
|
+
closable: boolean;
|
|
127
|
+
disabled: boolean;
|
|
128
|
+
lazy: boolean;
|
|
129
|
+
};
|
|
130
|
+
paneName: string | number | undefined;
|
|
131
|
+
active: boolean;
|
|
132
|
+
index: string | undefined;
|
|
133
|
+
isClosable: boolean;
|
|
134
|
+
attrs: Record<string, any>;
|
|
135
|
+
}, ev: Event) => any) | undefined;
|
|
136
|
+
onTabContextMenu?: ((pane: {
|
|
137
|
+
uid: number;
|
|
138
|
+
slots: Readonly<{
|
|
139
|
+
[name: string]: import("vue").Slot | undefined;
|
|
140
|
+
}>;
|
|
141
|
+
props: {
|
|
142
|
+
label: string;
|
|
143
|
+
name: Numberish;
|
|
144
|
+
closable: boolean;
|
|
145
|
+
disabled: boolean;
|
|
146
|
+
lazy: boolean;
|
|
147
|
+
};
|
|
148
|
+
paneName: string | number | undefined;
|
|
149
|
+
active: boolean;
|
|
150
|
+
index: string | undefined;
|
|
151
|
+
isClosable: boolean;
|
|
152
|
+
attrs: Record<string, any>;
|
|
153
|
+
}, index: number, ev: Event) => any) | undefined;
|
|
154
|
+
onTabChange?: ((name: Numberish) => any) | undefined;
|
|
155
|
+
onEdit?: ((paneName: Numberish | undefined, action: "remove" | "add") => any) | undefined;
|
|
156
|
+
onTabRemove?: ((name: Numberish) => any) | undefined;
|
|
157
|
+
onTabAdd?: (() => any) | undefined;
|
|
158
|
+
}, {}>;
|
|
159
|
+
export default _sfc_main;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.vue.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),V=require("../../hooks/use-namespace/index.js"),q=require("../../hooks/use-ordered-children/index.js"),k=require("@vft/constants"),l=require("@vft/utils"),A=require("./tab-nav.vue2.js"),E=require("./types.js"),c=V.useNamespace("tabs"),M=n.defineComponent({name:c.b()}),z=n.defineComponent({...M,props:{type:{default:""},closable:{type:Boolean},addable:{type:Boolean,default:!1},modelValue:null,editable:{type:Boolean},tabPosition:{default:"top"},beforeLeave:{type:Function},stretch:{type:Boolean},closeIconCfg:null,addIconCfg:null,arrowLeftIconCfg:null,arrowRightIconCfg:null},emits:{[k.UPDATE_MODEL_EVENT]:t=>l.isNumberish(t),tabClick:(t,i)=>i instanceof Event,tabContextMenu:(t,i,a)=>a instanceof Event,tabChange:t=>l.isNumberish(t),edit:(t,i)=>["remove","add"].includes(i),tabRemove:t=>l.isNumberish(t),tabAdd:()=>!0},setup(t,{expose:i,emit:a}){const C=n.getCurrentInstance(),u=n.useSlots(),s=n.ref(),d=n.ref(t.modelValue??"0"),g=e=>{d.value=e,a("update:modelValue",e),a("tabChange",e)},f=async e=>{var o,r,m;if(!(d.value===e||l.isUndefined(e)))try{await((o=t.beforeLeave)==null?void 0:o.call(t,e,d.value))!==!1&&(g(e),(m=(r=s.value)==null?void 0:r.removeFocus)==null||m.call(r))}catch{}},h=(e,o,r)=>{e.props.disabled||(f(o),a("tabClick",e,r))},I=(e,o)=>{e.props.disabled||l.isUndefined(e.props.name)||(o.stopPropagation(),a("edit",e.props.name,"remove"),a("tabRemove",e.props.name))};n.watch(()=>t.modelValue,e=>f(e)),n.watch(d,async()=>{var e;await n.nextTick(),(e=s.value)==null||e.scrollToActiveTab()});const y=()=>{a("edit",void 0,"add"),a("tabAdd")},N=(e,o,r)=>{a("tabContextMenu",e,o,r)},b=n.computed(()=>{var e;return n.createVNode("div",{class:c.e("content")},[(e=u.default)==null?void 0:e.call(u)])}),{children:w,addChild:T,removeChild:p}=q.useOrderedChildren(n.getCurrentInstance(),"vri-tab-pane");n.provide(E.TabsRootContextKey,{props:C.props,currentName:d,registerPane:T,unregisterPane:p}),i({currentName:d});const R=n.computed(()=>({icon:"vi-add",color:"black",size:12,...t.addIconCfg})),x=n.computed(()=>({icon:"vi-close",size:12,...t.closeIconCfg})),L=n.computed(()=>({icon:"vi-arrow-left",size:18,...t.arrowLeftIconCfg})),P=n.computed(()=>({icon:"vi-arrow-right",size:18,...t.arrowRightIconCfg})),v=n.computed(()=>{var e;return n.createVNode("div",{class:[c.e("header"),c.is(t.tabPosition)]},[n.createVNode(A.default,{ref:s,currentName:d.value,panes:w.value,stretch:t.stretch,closeIconCfg:x.value,addIconCfg:R.value,arrowRightIconCfg:P.value,arrowLeftIconCfg:L.value,editable:t.editable,addable:t.addable,type:t.type,onTabClick:h,onTabRemove:I,onTabAdd:y,onTabContextmenu:N},null),(e=u.headerRight)==null?void 0:e.call(u)])});return()=>n.createVNode("div",{class:[c.b(),c.m(t.tabPosition),{[c.m("card")]:t.type==="card",[c.m("border-card")]:t.type==="border-card"}]},[...t.tabPosition!=="bottom"?[v.value,b.value]:[b.value,v.value]])}});exports.default=z;
|
|
2
|
+
//# sourceMappingURL=tabs.vue2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.vue2.js","sources":["../../../../../packages/components/tabs/tabs.vue"],"sourcesContent":["<script lang=\"tsx\">\nconst ns = /* hoist-static*/ useNamespace('tabs')\n\nimport { defineComponent as DO_defineComponent } from 'vue';\nexport default /*#__PURE__*/ DO_defineComponent({\n name: ns.b()\n});</script>\n<script setup lang=\"tsx\">\nimport { type IconProps } from '@vft-ui/components';\nimport { useNamespace, useOrderedChildren } from '@vft-ui/hooks';\nimport { UPDATE_MODEL_EVENT } from '@vft/constants';\nimport { isNumberish, isUndefined } from '@vft/utils';\nimport { computed, getCurrentInstance, nextTick, provide, ref, useSlots, watch } from 'vue';\nimport TabNav from './tab-nav.vue';\nimport { type TabsPaneContext, type TabsProps, TabsRootContextKey, type TabsType } from './types';\n\ninterface TabsProps {\n /** 风格类型 */\n type?: TabsType;\n /** 标签是否可关闭 */\n closable?: boolean;\n /** 标签是否可增加 */\n addable?: boolean;\n /** 绑定值,选中选项卡的 name */\n modelValue: Numberish;\n /** 标签是否同时可增加和关闭 */\n editable?: boolean;\n /** 选项卡所在位置 */\n tabPosition?: 'top' | 'right' | 'bottom' | 'left';\n /** 切换标签之前的钩子函数, 若返回 false 或者返回被 reject 的 Promise,则阻止切换 */\n beforeLeave?: Function;\n /** 是否自动撑开宽度 */\n stretch?: boolean;\n /** icon 配置 */\n closeIconCfg?: IconProps;\n addIconCfg?: IconProps;\n arrowLeftIconCfg?: IconProps;\n arrowRightIconCfg?: IconProps;\n}\n\ndefineProps({\n \"type\": { default: '' },\n \"closable\": { type: Boolean, },\n \"addable\": { type: Boolean, default: false },\n \"modelValue\": null,\n \"editable\": { type: Boolean, },\n \"tabPosition\": { default: 'top' },\n \"beforeLeave\": { type: Function, },\n \"stretch\": { type: Boolean, },\n \"closeIconCfg\": null,\n \"addIconCfg\": null,\n \"arrowLeftIconCfg\": null,\n \"arrowRightIconCfg\": null\n})\n\nconst emit = defineEmits({\n [UPDATE_MODEL_EVENT]: (name: Numberish) => isNumberish(name),\n /** 点击 */\n tabClick: (pane: TabsPaneContext, ev: Event) => ev instanceof Event,\n /** 右键点击 */\n tabContextMenu: (pane: TabsPaneContext, index: number, ev: Event) => ev instanceof Event,\n tabChange: (name: Numberish) => isNumberish(name),\n edit: (paneName: Numberish | undefined, action: 'remove' | 'add') =>\n ['remove', 'add'].includes(action),\n /** 移除 */\n tabRemove: (name: Numberish) => isNumberish(name),\n /** 增加 */\n tabAdd: () => true\n});\n\n\n\n;\n\nconst vm = getCurrentInstance()!;\n\nconst slots = useSlots();\n\n// tab-nav 实例\nconst nav$ = ref();\n\n// 默认的激活的 tab\nconst currentName = ref<Numberish>(__props.modelValue ?? '0');\n\n// 更新当前 current tab 触发 tabChange 以及更新 modelValue\nconst changeCurrentName = (value: Numberish) => {\n currentName.value = value;\n emit('update:modelValue', value);\n emit('tabChange', value);\n};\n\n// value 值为当前点击的 tab 值\nconst setCurrentName = async (value?: Numberish) => {\n // 如果 currentName 等于原值,或者 value 不存在,不执行\n if (currentName.value === value || isUndefined(value)) return;\n\n try {\n // 切换标签之前的钩子函数, 若返回 false 或者返回被 reject 的 Promise,则阻止切换 */\n const canLeave = await __props.beforeLeave?.(value, currentName.value);\n if (canLeave !== false) {\n // 更新 tab 值\n changeCurrentName(value);\n //\n nav$.value?.removeFocus?.();\n }\n } catch {}\n};\n\n/**\n * @description tab 点击事件\n * @author wfd\n * @date 2022/10/18 09:07\n * @example\n * @param {TabsPaneContext} tab 当前被点击的 tab 信息\n * @param {Numberish} tabName 被点击的 tab 值\n * @param {Event} event\n */\nconst handleTabClick = (tab: TabsPaneContext, tabName: Numberish, event: Event) => {\n // 如果 TabPaneProps 中设置了 disabled 则禁止点击\n if (tab.props.disabled) return;\n // 更新 currentName\n setCurrentName(tabName);\n // 抛出 tabClick 事件\n emit('tabClick', tab, event);\n};\n\nconst handleTabRemove = (pane: TabsPaneContext, ev: Event) => {\n if (pane.props.disabled || isUndefined(pane.props.name)) return;\n ev.stopPropagation();\n emit('edit', pane.props.name, 'remove');\n emit('tabRemove', pane.props.name);\n};\n\n// 监听 modelValue 改变触发改变 currentName\nwatch(\n () => __props.modelValue,\n (modelValue) => setCurrentName(modelValue)\n);\n\n// 当前激活的 tab 变化触发 nav$ scrollToActiveTab 方法\nwatch(currentName, async () => {\n await nextTick();\n nav$.value?.scrollToActiveTab();\n});\n\n// 增加 tab 事件\nconst handleTabAdd = () => {\n emit('edit', undefined, 'add');\n emit('tabAdd');\n};\n\nconst handleContextmenu = (pane: TabsPaneContext, index: number, ev: Event) => {\n emit('tabContextMenu', pane, index, ev);\n};\n\n// 默认渲染的内容区域\nconst panels = computed(() => {\n return <div class={ns.e('content')}>{slots.default?.()}</div>;\n});\n\n// 找出当前 tab 组件下 vri-tab-pane 的组件实例对象\nconst { children: panes, addChild: registerPane, removeChild: unregisterPane } = useOrderedChildren<TabsPaneContext>(getCurrentInstance()!, 'vri-tab-pane');\n\nprovide(TabsRootContextKey, {\n props: vm.props as unknown as TabsProps,\n currentName,\n registerPane,\n unregisterPane\n});\n\ndefineExpose({\n currentName\n});\n\n// 图标相关\nconst _addIconCfg = computed(() => {\n return {\n icon: 'vi-add',\n color: 'black',\n size: 12,\n ...__props.addIconCfg\n };\n});\n\nconst _closeIconCfg = computed(() => {\n return {\n icon: 'vi-close',\n size: 12,\n ...__props.closeIconCfg\n };\n});\n\nconst _arrowLeftIconCfg = computed(() => {\n return {\n icon: 'vi-arrow-left',\n size: 18,\n ...__props.arrowLeftIconCfg\n };\n});\n\nconst _arrowRightIconCfg = computed(() => {\n return {\n icon: 'vi-arrow-right',\n size: 18,\n ...__props.arrowRightIconCfg\n };\n});\n\nconst header = computed(() => {\n return (\n <div class={[ns.e('header'), ns.is(__props.tabPosition)]}>\n <TabNav\n ref={nav$}\n currentName={currentName.value}\n panes={panes.value}\n stretch={__props.stretch}\n closeIconCfg={_closeIconCfg.value}\n addIconCfg={_addIconCfg.value}\n arrowRightIconCfg={_arrowRightIconCfg.value}\n arrowLeftIconCfg={_arrowLeftIconCfg.value}\n editable={__props.editable}\n addable={__props.addable}\n type={__props.type}\n onTabClick={handleTabClick}\n onTabRemove={handleTabRemove}\n onTabAdd={handleTabAdd}\n onTabContextmenu={handleContextmenu}\n />\n {slots.headerRight?.()}\n </div>\n );\n});\n\ndefineRender(() => {\n return (\n <div\n class={[\n ns.b(),\n ns.m(__props.tabPosition),\n {\n [ns.m('card')]: __props.type === 'card',\n [ns.m('border-card')]: __props.type === 'border-card'\n }\n ]}\n >\n {...__props.tabPosition !== 'bottom' ? [header.value, panels.value] : [panels.value, header.value]}\n </div>\n );\n});\n</script>\n"],"names":["ns","useNamespace","__default__","DO_defineComponent","name","b","vm","getCurrentInstance","slots","useSlots","nav$","ref","currentName","__props","modelValue","changeCurrentName","value","emit","setCurrentName","isUndefined","beforeLeave","removeFocus","handleTabClick","tab","tabName","event","props","disabled","handleTabRemove","pane","ev","stopPropagation","watch","nextTick","scrollToActiveTab","handleTabAdd","undefined","handleContextmenu","index","panels","computed","_createVNode","e","default","children","panes","addChild","registerPane","removeChild","unregisterPane","useOrderedChildren","provide","TabsRootContextKey","expose","_addIconCfg","icon","color","size","addIconCfg","_closeIconCfg","closeIconCfg","_arrowLeftIconCfg","arrowLeftIconCfg","_arrowRightIconCfg","arrowRightIconCfg","header","is","tabPosition","TabNav","stretch","editable","addable","type","headerRight","m"],"mappings":"qVACMA,EAAuBC,EAAAA,aAAa,MAAM,EAGhDC,EAA6BC,EAAAA,gBAAmB,CAC9CC,KAAMJ,EAAGK,EAAC,CACZ,CAAC,qkBAoED,MAAMC,EAAKC,EAAAA,qBAELC,EAAQC,EAAAA,WAGRC,EAAOC,EAAAA,MAGPC,EAAcD,EAAG,IAAYE,EAAQC,YAAc,GAAG,EAGtDC,EAAqBC,GAAqB,CAC9CJ,EAAYI,MAAQA,EACpBC,EAAK,oBAAqBD,CAAK,EAC/BC,EAAK,YAAaD,CAAK,GAInBE,EAAiB,MAAOF,GAAsB,WAElD,GAAIJ,EAAAA,EAAYI,QAAUA,GAASG,EAAAA,YAAYH,CAAK,GAEpD,GAAI,CAEe,OAA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EAAG7D,EAAQ2D,OAAS,OACjC,CAACxE,EAAG0E,EAAE,aAAa,CAAC,EAAG7D,EAAQ2D,OAAS,cACzC,GAGC3D,CAAAA,GAAAA,EAAQsD,cAAgB,SAAW,CAACF,EAAOjD,MAAOuB,EAAOvB,KAAK,EAAI,CAACuB,EAAOvB,MAAOiD,EAAOjD,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ComputedRef, InjectionKey, Ref, Slots, UnwrapRef } from 'vue';
|
|
2
|
+
import { type IconProps } from 'vft/es/components';
|
|
3
|
+
export type TabsPaneContext = UnwrapRef<{
|
|
4
|
+
uid: number;
|
|
5
|
+
slots: Slots;
|
|
6
|
+
props: TabPaneProps;
|
|
7
|
+
paneName: ComputedRef<string | number | undefined>;
|
|
8
|
+
active: ComputedRef<boolean>;
|
|
9
|
+
index: Ref<string | undefined>;
|
|
10
|
+
isClosable: ComputedRef<boolean>;
|
|
11
|
+
attrs: Record<string, any>;
|
|
12
|
+
}>;
|
|
13
|
+
export type TabsType = 'card' | 'border-card' | '';
|
|
14
|
+
export interface TabsRootContext {
|
|
15
|
+
props: TabsProps;
|
|
16
|
+
currentName: Ref<string | number>;
|
|
17
|
+
registerPane: (pane: TabsPaneContext) => void;
|
|
18
|
+
unregisterPane: (uid: number) => void;
|
|
19
|
+
}
|
|
20
|
+
export interface TabPaneProps {
|
|
21
|
+
/** 选项卡标题 */
|
|
22
|
+
label: string;
|
|
23
|
+
/** 与选项卡绑定值 value 对应的标识符,表示选项卡别名 */
|
|
24
|
+
name: Numberish;
|
|
25
|
+
/** 标签是否可关闭 */
|
|
26
|
+
closable: boolean;
|
|
27
|
+
/** 是否禁用 */
|
|
28
|
+
disabled: boolean;
|
|
29
|
+
/** 标签是否延迟渲染 */
|
|
30
|
+
lazy: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface TabsProps {
|
|
33
|
+
/** 风格类型 */
|
|
34
|
+
type?: TabsType;
|
|
35
|
+
/** 标签是否可关闭 */
|
|
36
|
+
closable?: boolean;
|
|
37
|
+
/** 标签是否可增加 */
|
|
38
|
+
addable?: boolean;
|
|
39
|
+
/** 绑定值,选中选项卡的 name */
|
|
40
|
+
modelValue: Numberish;
|
|
41
|
+
/** 标签是否同时可增加和关闭 */
|
|
42
|
+
editable?: boolean;
|
|
43
|
+
/** 选项卡所在位置 */
|
|
44
|
+
tabPosition?: 'top' | 'right' | 'bottom' | 'left';
|
|
45
|
+
/** 切换标签之前的钩子函数, 若返回 false 或者返回被 reject 的 Promise,则阻止切换 */
|
|
46
|
+
beforeLeave?: Function;
|
|
47
|
+
stretch?: boolean;
|
|
48
|
+
closeIconCfg?: IconProps;
|
|
49
|
+
addIconCfg?: IconProps;
|
|
50
|
+
arrowLeftIconCfg?: IconProps;
|
|
51
|
+
arrowRightIconCfg?: IconProps;
|
|
52
|
+
}
|
|
53
|
+
export declare const TabsRootContextKey: InjectionKey<TabsRootContext>;
|
|
54
|
+
export interface Scrollable {
|
|
55
|
+
next?: boolean;
|
|
56
|
+
prev?: number;
|
|
57
|
+
}
|
|
58
|
+
export type TabsPanes = Record<number, TabsPaneContext>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../packages/components/tabs/types.ts"],"sourcesContent":["import type { ComputedRef, InjectionKey, Ref, Slots, UnwrapRef } from 'vue';\nimport { type IconProps } from '@vft-ui/components';\n\nexport type TabsPaneContext = UnwrapRef<{\n uid: number;\n slots: Slots;\n props: TabPaneProps;\n paneName: ComputedRef<string | number | undefined>;\n active: ComputedRef<boolean>;\n index: Ref<string | undefined>;\n isClosable: ComputedRef<boolean>;\n attrs: Record<string, any>;\n}>;\n\nexport type TabsType = 'card' | 'border-card' | '';\n\nexport interface TabsRootContext {\n props: TabsProps;\n currentName: Ref<string | number>;\n registerPane: (pane: TabsPaneContext) => void;\n unregisterPane: (uid: number) => void;\n}\n\nexport interface TabPaneProps {\n /** 选项卡标题 */\n label: string;\n /** 与选项卡绑定值 value 对应的标识符,表示选项卡别名 */\n name: Numberish;\n /** 标签是否可关闭 */\n closable: boolean;\n /** 是否禁用 */\n disabled: boolean;\n /** 标签是否延迟渲染 */\n lazy: boolean;\n}\n\nexport interface TabsProps {\n /** 风格类型 */\n type?: TabsType;\n /** 标签是否可关闭 */\n closable?: boolean;\n /** 标签是否可增加 */\n addable?: boolean;\n /** 绑定值,选中选项卡的 name */\n modelValue: Numberish;\n /** 标签是否同时可增加和关闭 */\n editable?: boolean;\n /** 选项卡所在位置 */\n tabPosition?: 'top' | 'right' | 'bottom' | 'left';\n /** 切换标签之前的钩子函数, 若返回 false 或者返回被 reject 的 Promise,则阻止切换 */\n beforeLeave?: Function;\n stretch?: boolean;\n closeIconCfg?: IconProps;\n addIconCfg?: IconProps;\n arrowLeftIconCfg?: IconProps;\n arrowRightIconCfg?: IconProps;\n}\n\nexport const TabsRootContextKey: InjectionKey<TabsRootContext> = Symbol('tabsRootContextKey');\n\nexport interface Scrollable {\n next?: boolean;\n prev?: number;\n}\n\nexport type TabsPanes = Record<number, TabsPaneContext>;\n"],"names":["TabsRootContextKey"],"mappings":"gFA0Da,MAAAA,EAAoD,OAAO,oBAAoB"}
|
package/lib/hooks/index.d.ts
CHANGED
package/lib/hooks/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./use-namespace/index.js");exports._bem=e._bem;exports.defaultNamespace=e.defaultNamespace;exports.useNamespace=e.useNamespace;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./use-namespace/index.js"),r=require("./use-ordered-children/index.js");exports._bem=e._bem;exports.defaultNamespace=e.defaultNamespace;exports.useNamespace=e.useNamespace;exports.useOrderedChildren=r.useOrderedChildren;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentInternalInstance } from 'vue';
|
|
2
|
+
export declare const useOrderedChildren: <T extends {
|
|
3
|
+
uid: number;
|
|
4
|
+
}>(vm: ComponentInternalInstance, childComponentName: string) => {
|
|
5
|
+
children: import("vue").ShallowRef<T[]>;
|
|
6
|
+
addChild: (child: T) => void;
|
|
7
|
+
removeChild: (uid: number) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue");require("@vue/shared");const u=require("../../utils/vue/vnode.js");require("@vft/utils");const c=(n,o,d)=>u.flattedChildren(n.subTree).filter(e=>{var r;return i.isVNode(e)&&((r=e.type)==null?void 0:r.name)===o&&!!e.component}).map(e=>e.component.uid).map(e=>d[e]).filter(e=>!!e),a=(n,o)=>{const d={},t=i.shallowRef([]);return{children:t,addChild:r=>{d[r.uid]=r,t.value=c(n,o,d)},removeChild:r=>{delete d[r],t.value=t.value.filter(s=>s.uid!==r)}}};exports.useOrderedChildren=a;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/hooks/use-ordered-children/index.ts"],"sourcesContent":["import { isVNode, shallowRef } from 'vue';\nimport { flattedChildren } from '@vft-ui/utils'\n\n\nimport type { ComponentInternalInstance, VNode } from 'vue'\n\nconst getOrderedChildren = <T> (\n\tvm: ComponentInternalInstance,\n\tchildComponentName: string,\n\tchildren: Record<number, T>\n): T[] => {\n\tconst nodes = flattedChildren(vm.subTree).filter(\n\t\t(n): n is VNode =>\n\t\t\tisVNode(n) &&\n\t\t\t(n.type as any)?.name === childComponentName &&\n\t\t\t!!n.component\n\t)\n\tconst uids = nodes.map((n) => n.component!.uid)\n\treturn uids.map((uid) => children[uid]).filter((p) => !!p)\n}\n\nexport const useOrderedChildren = <T extends {uid: number}> (\n\tvm: ComponentInternalInstance,\n\tchildComponentName: string\n) => {\n\tconst children: Record<number, T> = {}\n\tconst orderedChildren = shallowRef<T[]>([])\n\t\n\tconst addChild = (child: T) => {\n\t\tchildren[child.uid] = child\n\t\torderedChildren.value = getOrderedChildren(vm, childComponentName, children)\n\t}\n\tconst removeChild = (uid: number) => {\n\t\tdelete children[uid]\n\t\torderedChildren.value = orderedChildren.value.filter(\n\t\t\t(children) => children.uid !== uid\n\t\t)\n\t}\n\t\n\treturn {\n\t\tchildren: orderedChildren,\n\t\taddChild,\n\t\tremoveChild,\n\t}\n}\n"],"names":["getOrderedChildren","vm","childComponentName","children","flattedChildren","n","isVNode","_a","uid","p","useOrderedChildren","orderedChildren","shallowRef","child"],"mappings":"gMAMA,MAAMA,EAAqB,CAC1BC,EACAC,EACAC,IAEcC,EAAA,gBAAgBH,EAAG,OAAO,EAAE,OACxCI,GACAC,OAAAA,OAAAA,EAAAA,QAAQD,CAAC,KACRE,EAAAF,EAAE,OAAF,YAAAE,EAAgB,QAASL,GAC1B,CAAC,CAACG,EAAE,UAAA,EAEa,IAAKA,GAAMA,EAAE,UAAW,GAAG,EAClC,IAAKG,GAAQL,EAASK,CAAG,CAAC,EAAE,OAAQC,GAAM,CAAC,CAACA,CAAC,EAG7CC,EAAqB,CACjCT,EACAC,IACI,CACJ,MAAMC,EAA8B,CAAA,EAC9BQ,EAAkBC,aAAgB,CAAA,CAAE,EAanC,MAAA,CACN,SAAUD,EACV,SAbiBE,GAAa,CACrBV,EAAAU,EAAM,GAAG,EAAIA,EACtBF,EAAgB,MAAQX,EAAmBC,EAAIC,EAAoBC,CAAQ,CAAA,EAY3E,YAVoBK,GAAgB,CACpC,OAAOL,EAASK,CAAG,EACHG,EAAA,MAAQA,EAAgB,MAAM,OAC5CR,GAAaA,EAAS,MAAQK,CAAA,CAChC,CAMA,CAEF"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import installer from './defaults';
|
|
2
2
|
export * from 'vft/es/components';
|
|
3
3
|
export * from 'vft/es/constants';
|
|
4
|
-
export * from 'vft/es/
|
|
4
|
+
export * from 'vft/es/hooks';
|
|
5
5
|
export * from './make-installer';
|
|
6
6
|
export declare const install: (app: import("vue").App<any>, options?: any) => void;
|
|
7
7
|
export declare const version: string;
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./defaults.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./defaults.js"),a=require("./components/divider/index.js"),o=require("./components/icon/index.js"),u=require("./components/avatar/index.js"),E=require("./components/empty/index.js"),c=require("./components/result/index.js"),d=require("./components/exception/index.js"),r=require("./components/tabs/index.js"),l=require("./constants/aria.js"),s=require("./constants/date.js"),t=require("./constants/event.js"),f=require("./constants/key.js"),i=require("./constants/size.js"),n=require("./hooks/use-namespace/index.js"),V=require("./hooks/use-ordered-children/index.js"),T=require("./make-installer.js"),m=require("dayjs"),p=require("./components/empty/constants.js"),q=require("./components/tabs/types.js"),N=e.default.install,_=e.default.version;exports.default=e.default;exports.VftDivider=a.VftDivider;exports.VftIcon=o.VftIcon;exports.VftAvatar=u.VftAvatar;exports.VftEmpty=E.VftEmpty;exports.VftResult=c.VftResult;exports.VftException=d.VftException;exports.VftTabPane=r.VftTabPane;exports.VftTabs=r.VftTabs;exports.EVENT_CODE=l.EVENT_CODE;exports.WEEK_DAYS=s.WEEK_DAYS;exports.datePickTypes=s.datePickTypes;exports.CHANGE_EVENT=t.CHANGE_EVENT;exports.INPUT_EVENT=t.INPUT_EVENT;exports.UPDATE_MODEL_EVENT=t.UPDATE_MODEL_EVENT;exports.INSTALLED_KEY=f.INSTALLED_KEY;exports.componentSizeMap=i.componentSizeMap;exports.componentSizes=i.componentSizes;exports._bem=n._bem;exports.defaultNamespace=n.defaultNamespace;exports.useNamespace=n.useNamespace;exports.useOrderedChildren=V.useOrderedChildren;exports.makeInstaller=T.makeInstaller;exports.dayjs=m;exports.EmptyEnum=p.EmptyEnum;exports.TabsRootContextKey=q.TabsRootContextKey;exports.install=N;exports.version=_;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../packages/vft/index.ts"],"sourcesContent":["import installer from './defaults'\nexport * from '@vft-ui/components'\nexport * from '@vft-ui/constants'\nexport * from '@vft-ui/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../packages/vft/index.ts"],"sourcesContent":["import installer from './defaults'\nexport * from '@vft-ui/components'\nexport * from '@vft-ui/constants'\nexport * from '@vft-ui/hooks'\nexport * from './make-installer'\n\nexport const install = installer.install\nexport const version = installer.version\nexport default installer\n\nexport { default as dayjs } from 'dayjs'\n"],"names":["install","installer","version"],"mappings":"+zBAMaA,EAAUC,EAAU,QAAA,QACpBC,EAAUD,EAAAA,QAAU"}
|
package/lib/package.json.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.0.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.0.6";exports.version=e;
|
|
2
2
|
//# sourceMappingURL=package.json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/lib/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./vue/install.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./vue/install.js"),e=require("./vue/vnode.js"),i=require("./helper.js"),r=require("./error.js");exports.withInstall=t.withInstall;exports.withInstallDirective=t.withInstallDirective;exports.withInstallFunction=t.withInstallFunction;exports.withNoopInstall=t.withNoopInstall;exports.PatchFlags=e.PatchFlags;exports.ensureOnlyChild=e.ensureOnlyChild;exports.flattedChildren=e.flattedChildren;exports.getFirstValidNode=e.getFirstValidNode;exports.getNormalizedProps=e.getNormalizedProps;exports.isComment=e.isComment;exports.isFragment=e.isFragment;exports.isTemplate=e.isTemplate;exports.isText=e.isText;exports.isValidElementNode=e.isValidElementNode;exports.renderBlock=e.renderBlock;exports.renderIf=e.renderIf;exports.getSizeType=i.getSizeType;exports.debugWarn=r.debugWarn;exports.throwError=r.throwError;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/utils/vue/index.d.ts
CHANGED
package/lib/utils/vue/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./install.js");exports.withInstall=t.withInstall;exports.withInstallDirective=t.withInstallDirective;exports.withInstallFunction=t.withInstallFunction;exports.withNoopInstall=t.withNoopInstall;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./install.js"),e=require("./vnode.js");exports.withInstall=t.withInstall;exports.withInstallDirective=t.withInstallDirective;exports.withInstallFunction=t.withInstallFunction;exports.withNoopInstall=t.withNoopInstall;exports.PatchFlags=e.PatchFlags;exports.ensureOnlyChild=e.ensureOnlyChild;exports.flattedChildren=e.flattedChildren;exports.getFirstValidNode=e.getFirstValidNode;exports.getNormalizedProps=e.getNormalizedProps;exports.isComment=e.isComment;exports.isFragment=e.isFragment;exports.isTemplate=e.isTemplate;exports.isText=e.isText;exports.isValidElementNode=e.isValidElementNode;exports.renderBlock=e.renderBlock;exports.renderIf=e.renderIf;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createBlock } from 'vue';
|
|
2
|
+
import type { VNode, VNodeArrayChildren, VNodeChild, VNodeNormalizedChildren } from 'vue';
|
|
3
|
+
export declare enum PatchFlags {
|
|
4
|
+
TEXT = 1,
|
|
5
|
+
CLASS = 2,
|
|
6
|
+
STYLE = 4,
|
|
7
|
+
PROPS = 8,
|
|
8
|
+
FULL_PROPS = 16,
|
|
9
|
+
HYDRATE_EVENTS = 32,
|
|
10
|
+
STABLE_FRAGMENT = 64,
|
|
11
|
+
KEYED_FRAGMENT = 128,
|
|
12
|
+
UNKEYED_FRAGMENT = 256,
|
|
13
|
+
NEED_PATCH = 512,
|
|
14
|
+
DYNAMIC_SLOTS = 1024,
|
|
15
|
+
HOISTED = -1,
|
|
16
|
+
BAIL = -2
|
|
17
|
+
}
|
|
18
|
+
export type VNodeChildAtom = Exclude<VNodeChild, Array<any>>;
|
|
19
|
+
export type RawSlots = Exclude<VNodeNormalizedChildren, Array<any> | null | string>;
|
|
20
|
+
export declare function isFragment(node: VNode): boolean;
|
|
21
|
+
export declare function isFragment(node: unknown): node is VNode;
|
|
22
|
+
export declare function isText(node: VNode): boolean;
|
|
23
|
+
export declare function isText(node: unknown): node is VNode;
|
|
24
|
+
export declare function isComment(node: VNode): boolean;
|
|
25
|
+
export declare function isComment(node: unknown): node is VNode;
|
|
26
|
+
export declare function isTemplate(node: VNode): boolean;
|
|
27
|
+
export declare function isTemplate(node: unknown): node is VNode;
|
|
28
|
+
/**
|
|
29
|
+
* determine if the element is a valid element type rather than fragments and comment e.g. <template> v-if
|
|
30
|
+
* @param node {VNode} node to be tested
|
|
31
|
+
*/
|
|
32
|
+
export declare function isValidElementNode(node: VNode): boolean;
|
|
33
|
+
export declare function isValidElementNode(node: unknown): node is VNode;
|
|
34
|
+
export declare const getFirstValidNode: (nodes: VNodeNormalizedChildren, maxDepth?: number) => string | number | boolean | void | VNodeArrayChildren | {
|
|
35
|
+
[name: string]: unknown;
|
|
36
|
+
$stable?: boolean | undefined;
|
|
37
|
+
} | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}> | null | undefined;
|
|
40
|
+
export declare function renderIf(condition: boolean, ...args: Parameters<typeof createBlock>): VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}>;
|
|
43
|
+
export declare function renderBlock(...args: Parameters<typeof createBlock>): VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
}>;
|
|
46
|
+
export declare const getNormalizedProps: (node: VNode) => Record<string, any>;
|
|
47
|
+
export declare const ensureOnlyChild: (children: VNodeArrayChildren | undefined) => VNodeArrayChildren | (string | number | boolean | void | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
}> | null | undefined);
|
|
50
|
+
export type FlattenVNodes = Array<VNodeChildAtom | RawSlots>;
|
|
51
|
+
export declare const flattedChildren: (children: FlattenVNodes | VNode | VNodeNormalizedChildren) => FlattenVNodes;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),u=require("@vue/shared"),S=require("../error.js"),d="utils/vue/vnode";var f=(e=>(e[e.TEXT=1]="TEXT",e[e.CLASS=2]="CLASS",e[e.STYLE=4]="STYLE",e[e.PROPS=8]="PROPS",e[e.FULL_PROPS=16]="FULL_PROPS",e[e.HYDRATE_EVENTS=32]="HYDRATE_EVENTS",e[e.STABLE_FRAGMENT=64]="STABLE_FRAGMENT",e[e.KEYED_FRAGMENT=128]="KEYED_FRAGMENT",e[e.UNKEYED_FRAGMENT=256]="UNKEYED_FRAGMENT",e[e.NEED_PATCH=512]="NEED_PATCH",e[e.DYNAMIC_SLOTS=1024]="DYNAMIC_SLOTS",e[e.HOISTED=-1]="HOISTED",e[e.BAIL=-2]="BAIL",e))(f||{});function E(e){return r.isVNode(e)&&e.type===r.Fragment}function V(e){return r.isVNode(e)&&e.type===r.Text}function T(e){return r.isVNode(e)&&e.type===r.Comment}const y="template";function p(e){return r.isVNode(e)&&e.type===y}function C(e){return r.isVNode(e)&&!E(e)&&!T(e)}function N(e,n){if(!T(e))return E(e)||p(e)?n>0?A(e.children,n-1):void 0:e}const A=(e,n=3)=>Array.isArray(e)?N(e[0],n):N(e,n);function L(e,...n){return e?m(...n):r.createCommentVNode("v-if",!0)}function m(...e){return r.openBlock(),r.createBlock(...e)}const O=e=>{if(!r.isVNode(e))return S.debugWarn(d,"[getNormalizedProps] must be a VNode"),{};const n=e.props||{},i=(r.isVNode(e.type)?e.type.props:void 0)||{},t={};return Object.keys(i).forEach(o=>{u.hasOwn(i[o],"default")&&(t[o]=i[o].default)}),Object.keys(n).forEach(o=>{t[u.camelize(o)]=n[o]}),t},_=e=>{if(!u.isArray(e)||e.length>1)throw new Error("expect to receive a single Vue element child");return e[0]},s=e=>{const n=u.isArray(e)?e:[e],i=[];return n.forEach(t=>{var o;u.isArray(t)?i.push(...s(t)):r.isVNode(t)&&u.isArray(t.children)?i.push(...s(t.children)):(i.push(t),r.isVNode(t)&&((o=t.component)!=null&&o.subTree)&&i.push(...s(t.component.subTree)))}),i};exports.PatchFlags=f;exports.ensureOnlyChild=_;exports.flattedChildren=s;exports.getFirstValidNode=A;exports.getNormalizedProps=O;exports.isComment=T;exports.isFragment=E;exports.isTemplate=p;exports.isText=V;exports.isValidElementNode=C;exports.renderBlock=m;exports.renderIf=L;
|
|
2
|
+
//# sourceMappingURL=vnode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vnode.js","sources":["../../../../../packages/utils/vue/vnode.ts"],"sourcesContent":["import {\n Comment,\n Fragment,\n Text,\n createBlock,\n createCommentVNode,\n isVNode,\n openBlock,\n} from 'vue'\nimport { camelize, isArray } from '@vue/shared'\nimport { hasOwn } from '@vue/shared'\nimport { debugWarn } from '../error'\nimport type {\n VNode,\n VNodeArrayChildren,\n VNodeChild,\n VNodeNormalizedChildren,\n} from 'vue'\n\nconst SCOPE = 'utils/vue/vnode'\n\nexport enum PatchFlags {\n TEXT = 1,\n CLASS = 2,\n STYLE = 4,\n PROPS = 8,\n FULL_PROPS = 16,\n HYDRATE_EVENTS = 32,\n STABLE_FRAGMENT = 64,\n KEYED_FRAGMENT = 128,\n UNKEYED_FRAGMENT = 256,\n NEED_PATCH = 512,\n DYNAMIC_SLOTS = 1024,\n HOISTED = -1,\n BAIL = -2,\n}\n\nexport type VNodeChildAtom = Exclude<VNodeChild, Array<any>>\nexport type RawSlots = Exclude<\n VNodeNormalizedChildren,\n Array<any> | null | string\n>\n\nexport function isFragment(node: VNode): boolean\nexport function isFragment(node: unknown): node is VNode\nexport function isFragment(node: unknown): node is VNode {\n return isVNode(node) && node.type === Fragment\n}\n\nexport function isText(node: VNode): boolean\nexport function isText(node: unknown): node is VNode\nexport function isText(node: unknown): node is VNode {\n return isVNode(node) && node.type === Text\n}\n\nexport function isComment(node: VNode): boolean\nexport function isComment(node: unknown): node is VNode\nexport function isComment(node: unknown): node is VNode {\n return isVNode(node) && node.type === Comment\n}\n\nconst TEMPLATE = 'template'\nexport function isTemplate(node: VNode): boolean\nexport function isTemplate(node: unknown): node is VNode\nexport function isTemplate(node: unknown): node is VNode {\n return isVNode(node) && node.type === TEMPLATE\n}\n\n/**\n * determine if the element is a valid element type rather than fragments and comment e.g. <template> v-if\n * @param node {VNode} node to be tested\n */\nexport function isValidElementNode(node: VNode): boolean\nexport function isValidElementNode(node: unknown): node is VNode\nexport function isValidElementNode(node: unknown): node is VNode {\n return isVNode(node) && !isFragment(node) && !isComment(node)\n}\n\n/**\n * get a valid child node (not fragment nor comment)\n * @param node {VNode} node to be searched\n * @param depth {number} depth to be searched\n */\nfunction getChildren(\n node: VNodeNormalizedChildren | VNodeChild,\n depth: number\n): VNodeNormalizedChildren | VNodeChild {\n if (isComment(node)) return\n if (isFragment(node) || isTemplate(node)) {\n return depth > 0 ? getFirstValidNode(node.children, depth - 1) : undefined\n }\n return node\n}\n\nexport const getFirstValidNode = (\n nodes: VNodeNormalizedChildren,\n maxDepth = 3\n) => {\n if (Array.isArray(nodes)) {\n return getChildren(nodes[0], maxDepth)\n } else {\n return getChildren(nodes, maxDepth)\n }\n}\n\nexport function renderIf(\n condition: boolean,\n ...args: Parameters<typeof createBlock>\n) {\n return condition ? renderBlock(...args) : createCommentVNode('v-if', true)\n}\n\nexport function renderBlock(...args: Parameters<typeof createBlock>) {\n return openBlock(), createBlock(...args)\n}\n\nexport const getNormalizedProps = (node: VNode) => {\n if (!isVNode(node)) {\n debugWarn(SCOPE, '[getNormalizedProps] must be a VNode')\n return {}\n }\n\n const raw = node.props || {}\n const type = (isVNode(node.type) ? node.type.props : undefined) || {}\n const props: Record<string, any> = {}\n\n Object.keys(type).forEach((key) => {\n if (hasOwn(type[key], 'default')) {\n props[key] = type[key].default\n }\n })\n\n Object.keys(raw).forEach((key) => {\n props[camelize(key)] = raw[key]\n })\n\n return props\n}\n\nexport const ensureOnlyChild = (children: VNodeArrayChildren | undefined) => {\n if (!isArray(children) || children.length > 1) {\n throw new Error('expect to receive a single Vue element child')\n }\n return children[0]\n}\n\nexport type FlattenVNodes = Array<VNodeChildAtom | RawSlots>\n\nexport const flattedChildren = (\n children: FlattenVNodes | VNode | VNodeNormalizedChildren\n): FlattenVNodes => {\n const vNodes = isArray(children) ? children : [children]\n const result: FlattenVNodes = []\n\n vNodes.forEach((child) => {\n if (isArray(child)) {\n result.push(...flattedChildren(child))\n } else if (isVNode(child) && isArray(child.children)) {\n result.push(...flattedChildren(child.children))\n } else {\n result.push(child)\n if (isVNode(child) && child.component?.subTree) {\n result.push(...flattedChildren(child.component.subTree))\n }\n }\n })\n return result\n}\n"],"names":["SCOPE","PatchFlags","isFragment","node","isVNode","Fragment","isText","Text","isComment","Comment","TEMPLATE","isTemplate","isValidElementNode","getChildren","depth","getFirstValidNode","nodes","maxDepth","renderIf","condition","args","renderBlock","createCommentVNode","openBlock","createBlock","getNormalizedProps","debugWarn","raw","type","props","key","hasOwn","camelize","ensureOnlyChild","children","isArray","flattedChildren","vNodes","result","child","_a"],"m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