✨(component): select / tab slots 解析逻辑优化
This commit is contained in:
parent
753ef0fab2
commit
e2b14f9fd4
@ -108,4 +108,4 @@ export const transformPlacement = (
|
||||
}` as DropdownPlacement;
|
||||
}
|
||||
return placement;
|
||||
};
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ import LayTagInput from "../tagInput/index.vue";
|
||||
import LayDropdown from "../dropdown/index.vue";
|
||||
import LaySelectOption, { SelectOptionProps } from "../selectOption/index.vue";
|
||||
import { SelectSize } from "./interface";
|
||||
import { ShapeFlags } from "../dropdown/util";
|
||||
import { isArrayChildren } from "src/utils";
|
||||
|
||||
export interface SelectProps {
|
||||
name?: string;
|
||||
@ -76,7 +76,7 @@ var timer: any;
|
||||
|
||||
const getOption = (nodes: VNode[], newOptions: any[]) => {
|
||||
nodes?.map((item) => {
|
||||
if (item && item.shapeFlag && item.shapeFlag == ShapeFlags.ARRAY_CHILDREN) {
|
||||
if (isArrayChildren(item, item.children)) {
|
||||
getOption(item.children as VNode[], newOptions);
|
||||
} else {
|
||||
if ((item.type as Component).name == LaySelectOption.name) {
|
||||
|
@ -29,7 +29,7 @@ import {
|
||||
} from "vue";
|
||||
import { useResizeObserver } from "@vueuse/core";
|
||||
import { TabData, TabInjectKey, TabPosition } from "./interface";
|
||||
import { ShapeFlags } from "../dropdown/util";
|
||||
import { isArrayChildren } from "src/utils";
|
||||
|
||||
export interface TabProps {
|
||||
type?: string;
|
||||
@ -47,7 +47,7 @@ const childrens: Ref<VNode[]> = ref([]);
|
||||
|
||||
const setItemInstanceBySlot = function (nodes: VNode[]) {
|
||||
nodes?.map((item) => {
|
||||
if (item && item.shapeFlag && item.shapeFlag == ShapeFlags.ARRAY_CHILDREN) {
|
||||
if (isArrayChildren(item, item.children)) {
|
||||
setItemInstanceBySlot(item.children as VNode[]);
|
||||
} else {
|
||||
if ((item.type as Component).name == tabItem.name) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
export * from "./domUtil";
|
||||
export * from "./withInstall";
|
||||
export * from "./arrayUtil";
|
||||
export * from "./vueUtil";
|
||||
export * from "./vueUtil";
|
||||
|
@ -18,10 +18,16 @@ export const isElement = (vn: VNode) => {
|
||||
return Boolean(vn && vn.shapeFlag & ShapeFlags.ELEMENT);
|
||||
};
|
||||
|
||||
export const isComponent = (vn: VNode, type?: VNodeTypes): type is Component => {
|
||||
export const isComponent = (
|
||||
vn: VNode,
|
||||
type?: VNodeTypes
|
||||
): type is Component => {
|
||||
return Boolean(vn && vn.shapeFlag & ShapeFlags.COMPONENT);
|
||||
};
|
||||
|
||||
export const isArrayChildren = (vn: VNode, children: VNode["children"]): children is VNode[] => {
|
||||
export const isArrayChildren = (
|
||||
vn: VNode,
|
||||
children: VNode["children"]
|
||||
): children is VNode[] => {
|
||||
return Boolean(vn && vn.shapeFlag & ShapeFlags.ARRAY_CHILDREN);
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user