UNPKG

tdesign-vue

Version:
40 lines (36 loc) 1.38 kB
/** * tdesign v1.14.1 * (c) 2025 tdesign * @license MIT */ import { getCurrentInstance } from '@vue/composition-api'; import { isArray } from 'lodash-es'; function useChildComponentSlots() { var instance = getCurrentInstance(); return function (childComponentName, slots) { var _slots, _slots$default; if (!slots) { var _instance$setupContex; slots = (_instance$setupContex = instance.setupContext) === null || _instance$setupContex === void 0 ? void 0 : _instance$setupContex.slots; } var content = ((_slots = slots) === null || _slots === void 0 || (_slots$default = _slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(_slots)) || []; var childList = []; var _getChildren = function getChildren(content2) { if (!isArray(content2)) return; content2.forEach(function (item) { if (item.children && isArray(item.children)) { _getChildren(item.children); } else { childList.push(item); } }); return childList; }; return _getChildren(content).filter(function (item) { var _item$tag; return (_item$tag = item.tag) === null || _item$tag === void 0 ? void 0 : _item$tag.endsWith(childComponentName); }); }; } export { useChildComponentSlots as default, useChildComponentSlots }; //# sourceMappingURL=slots.js.map