UNPKG

@inkline/paper

Version:

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

19 lines (15 loc) 626 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSlotChildren = void 0; 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(); }; exports.getSlotChildren = getSlotChildren;