UNPKG

@inkline/paper

Version:

Paper is a unified interface for defining components for Vue and React using a single code base.

10 lines (9 loc) 482 B
export const getSlotChildren = (name, slots, children) => { const isSlot = (el) => typeof el.type === "function" && Object.keys(slots).find((slotName) => el.type === slots[slotName]); return children.filter((el) => { const matchesNamedSlot = typeof el.type === "function" && el.type === slots[name]; return name === "default" ? matchesNamedSlot || !isSlot(el) : matchesNamedSlot; }).map((el) => { return isSlot(el) ? el.props?.children || [] : el; }).flat(); };