UNPKG

vue-ant-patterns

Version:

vue-ant-patterns

77 lines (72 loc) 2.32 kB
import _extends from 'babel-runtime/helpers/extends'; /* * @Author: w.pengfei * @Date: 2020-07-21 19:44:54 * @LastEditTime: 2020-07-21 19:47:24 * @Description: '' * @LastEditors: w.pengfei */ import { isValidElement } from 'ant-design-vue/es/_util/props-util'; export var setSlot = function setSlot(list, slot, cb) { var arr = []; var obj = { slot: true, slotHandler: slot }; list.map(function (it, idx) { var panelObj = { panel: it }; var o = cb ? cb(it) : slot(panelObj) ? panelObj : null; o = _extends({}, obj, o); arr.push(it, o); }); return arr; }; export var setSectionSlot = function setSectionSlot(panel, sectionList, slot) { var list = setSlot(sectionList, slot, function (item) { var obj = { panel: panel, section: item }; return slot(obj) ? obj : null; }); return list; }; export var setFieldSlot = function setFieldSlot(panel, section, fieldsList, slot) { var list = setSlot(fieldsList, slot, function (item) { var obj = { panel: panel, section: section, field: item }; return slot(obj) ? obj : null; }); return list; }; export var replaceSlot = function replaceSlot(list, slot, cb) { var obj = { slot: true, slotHandler: slot }; var arr = list.map(function (it, idx) { var panelObj = { panel: it }; var custonSlotObj = cb ? cb(it) : slot(panelObj) ? panelObj : null; if (custonSlotObj) { return _extends({}, custonSlotObj, obj); } return it; }); return arr.filter(function (T) { return T; }); }; export var replaceSectionSlot = function replaceSectionSlot(panel, sectionList, slot) { var list = replaceSlot(sectionList, slot, function (item) { var obj = { panel: panel, section: item }; return slot(obj) ? obj : null; }); return list; }; export var replaceFieldSlot = function replaceFieldSlot(panel, section, fieldsList, slot) { var list = replaceSlot(fieldsList, slot, function (item) { var obj = { panel: panel, section: section, field: item }; return slot(obj) ? obj : null; }); return list; }; export var filterSlot = function filterSlot() { var slots = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; return slots.map(function (it) { if (isValidElement(it)) { return it; } }).filter(function (t) { return t; }); };