UNPKG

vue-admin-core

Version:
84 lines (79 loc) 2.54 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); require('../../__builtins__/index.js'); require('../../form-layout/index.js'); var index = require('element-plus/es/utils/index'); var index$1 = require('../../form-layout/src/index.js'); var index$2 = require('../../__builtins__/configs/index.js'); const spaceProps = index.buildProps({ size: { type: [String, Number] }, direction: { type: String }, align: { type: String } }); const spaceSize = { small: 8, middle: 16, large: 24 }; const Space = vue.defineComponent({ name: "FSpace", props: spaceProps, setup(props, { slots }) { const layout = index$1.useFormLayout(); return () => { var _a, _b, _c, _d, _e; const { align, size = (_b = (_a = layout.value) == null ? void 0 : _a.spaceGap) != null ? _b : "small", direction = "horizontal" } = props; const prefixCls = `${index$2.stylePrefix}-space`; const children = (_c = slots.default) == null ? void 0 : _c.call(slots); let items = []; if (Array.isArray(children)) { if (children.length === 1) { if ((_d = children[0]["tag"]) == null ? void 0 : _d.endsWith("Fragment")) { items = (_e = children[0]["componentOptions"]) == null ? void 0 : _e.children; } else { items = children; } } else { items = children; } } const len = items.length; if (len === 0) { return null; } const mergedAlign = align === void 0 && direction === "horizontal" ? "center" : align; const marginDirection = "marginRight"; const someSpaceClass = { [prefixCls]: true, [`${prefixCls}-${direction}`]: true, [`${prefixCls}-align-${mergedAlign}`]: mergedAlign }; const itemClassName = `${prefixCls}-item`; const renderItems = items.map( (child, i) => vue.h( "div", { class: itemClassName, key: `${itemClassName}-${i}`, style: i === len - 1 ? {} : { [direction === "vertical" ? "marginBottom" : marginDirection]: typeof size === "string" ? `${spaceSize[size]}px` : `${size}px` } }, { default: () => [child] } ) ); return vue.h("div", { class: someSpaceClass }, { default: () => renderItems }); }; } }); exports.Space = Space; exports.default = Space; exports.spaceProps = spaceProps; //# sourceMappingURL=index.js.map