tav-ui
Version:
32 lines (30 loc) • 735 B
JavaScript
function isFunction(val) {
return typeof val === "function";
}
function getSlot(slots, slot = "default", data) {
if (!slots || !Reflect.has(slots, slot))
return null;
if (!isFunction(slots[slot])) {
console.error(`${slot} is not a function!`);
return null;
}
const slotFn = slots[slot];
if (!slotFn)
return null;
return slotFn(data);
}
function extendSlots(slots, excludeKeys = []) {
const slotKeys = Object.keys(slots);
const ret = {};
slotKeys.map((key) => {
if (excludeKeys.includes(key)) {
return null;
} else {
ret[key] = () => getSlot(slots, key);
return ret[key];
}
});
return ret;
}
export { extendSlots, getSlot };
//# sourceMappingURL=tsxHelper2.mjs.map