UNPKG

@vrx-arco/pro-components

Version:

<p align="center"> <img src="https://vrx-arco.github.io/arco-design-pro/favicon.svg" width="200" height="250"> </p>

114 lines (113 loc) 2.72 kB
import { defineComponent, computed, createVNode, isVNode, Fragment } from "vue"; import { filterEmptyChildren, useEmptyComponentProvide } from "@vrx-arco/use"; import { Divider } from "@arco-design/web-vue"; import { style } from "../style/var.mjs"; function _isSlot(s) { return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s); } const SpaceDividerItem = /* @__PURE__ */ defineComponent({ name: "vrx-arco-space-divider-item", props: { direction: { type: String, default: "horizontal" }, size: Number, gap: [Number, String], type: String, divider: { type: Boolean, default: true } }, setup: (props, { slots }) => { const { empty } = useEmptyComponentProvide(); return () => { var _a; if (empty.value) { return; } return createVNode(Fragment, null, [props.divider && createVNode(Divider, { "direction": props.direction === "horizontal" ? "vertical" : "horizontal", "size": props.size, "margin": props.gap, "type": props.type }, null), (_a = slots.default) == null ? void 0 : _a.call(slots)]); }; } }); const SpaceDivider = /* @__PURE__ */ defineComponent({ name: "vrx-arco-space-divider", props: { /** * 布局方向 */ direction: { type: String, default: "horizontal" }, /** * 对齐方向 */ align: { type: String, default: "center" }, /** * 是否占满 */ fill: { type: Boolean, default: false }, wrap: { type: Boolean, default: false }, /** * 分割线宽度 */ size: Number, /** * 分割线间距 */ gap: [Number, String], type: String }, setup: (props, { slots }) => { const { bemClass } = style("space-divider"); const classname = computed(() => ({ [bemClass(props.fill ? "-fill" : void 0)]: true, [bemClass(`-align-${props.align}`)]: true, [bemClass("-wrap")]: props.wrap, [bemClass(`-${props.direction}`)]: true })); return () => { var _a; const children = filterEmptyChildren((_a = slots.default) == null ? void 0 : _a.call(slots)); return createVNode("div", { "class": classname.value }, [children.map((item, index) => createVNode(SpaceDividerItem, { "direction": props.direction, "size": props.size, "gap": props.gap, "type": props.type, "divider": index > 0, "key": index }, _isSlot(item) ? item : { default: () => [item] }))]); }; } }); export { SpaceDivider };