UNPKG

birdpaper-ui

Version:

一个通用的 vue3 UI组件库。A common vue3 UI component library.

62 lines (61 loc) 1.67 kB
"use strict"; const vue = require("vue"); const dom = require("../../utils/dom.js"); const _buttonGroup = /* @__PURE__ */ vue.defineComponent({ name: "ButtonGroup", props: { /** 按钮类型 Type of the button */ type: { type: String, default: "normal" }, /** 按钮尺寸 Size of the button */ size: { type: String, default: "normal" }, /** 按钮形状 Shape of the button */ shape: { type: String, default: "square" }, /** 按钮状态 Status of the button */ status: { type: String, default: "normal" }, /** 是否撑满父级 Block or not */ block: { type: Boolean, default: false } }, setup(props, { slots }) { const name = "bp-button-group"; const cls = vue.computed(() => { let clsName = [name]; !["plain", "dashed"].includes(props.type) && clsName.push(`${name}-type-${props.type}-status-${props.status}`); props.block && clsName.push(`${name}-block`); return clsName; }); const render = () => { var _a; const children = dom.getAllElements((_a = slots.default) == null ? void 0 : _a.call(slots), true).filter((item) => item.type !== vue.Comment); return vue.createVNode("div", { "class": cls.value }, [children.map((child, index) => { const btn = Object.assign({}, child); btn.props = vue.mergeProps(child.props, { ...props }); return vue.createVNode(vue.Fragment, { "key": child.key ?? `item-${index}` }, [btn]); })]); }; return render; } }); module.exports = _buttonGroup;