UNPKG

3.33 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _vue = require("vue");
9
10var _vueTypes = _interopRequireDefault(require("../_util/vue-types"));
11
12var _propsUtil = require("../_util/props-util");
13
14var _configProvider = require("../config-provider");
15
16var _type = require("../_util/type");
17
18function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
20function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
22function _isSlot(s) {
23 return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !(0, _vue.isVNode)(s);
24}
25
26var spaceSize = {
27 small: 8,
28 middle: 16,
29 large: 24
30};
31var Space = (0, _vue.defineComponent)({
32 name: 'ASpace',
33 props: {
34 prefixCls: _vueTypes.default.string,
35 size: {
36 type: [String, Number]
37 },
38 direction: _vueTypes.default.oneOf((0, _type.tuple)('horizontal', 'vertical')),
39 align: _vueTypes.default.oneOf((0, _type.tuple)('start', 'end', 'center', 'baseline'))
40 },
41 setup: function setup(props, _ref) {
42 var slots = _ref.slots;
43 var configProvider = (0, _vue.inject)('configProvider', _configProvider.defaultConfigProvider);
44 return function () {
45 var _someSpaceClass;
46
47 var _a;
48
49 var align = props.align,
50 _props$size = props.size,
51 size = _props$size === void 0 ? 'small' : _props$size,
52 _props$direction = props.direction,
53 direction = _props$direction === void 0 ? 'horizontal' : _props$direction,
54 customizePrefixCls = props.prefixCls;
55 var getPrefixCls = configProvider.getPrefixCls;
56 var prefixCls = getPrefixCls('space', customizePrefixCls);
57 var items = (0, _propsUtil.filterEmpty)((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots));
58 var len = items.length;
59
60 if (len === 0) {
61 return null;
62 }
63
64 var mergedAlign = align === undefined && direction === 'horizontal' ? 'center' : align;
65 var someSpaceClass = (_someSpaceClass = {}, _defineProperty(_someSpaceClass, prefixCls, true), _defineProperty(_someSpaceClass, "".concat(prefixCls, "-").concat(direction), true), _defineProperty(_someSpaceClass, "".concat(prefixCls, "-align-").concat(mergedAlign), mergedAlign), _someSpaceClass);
66 var itemClassName = "".concat(prefixCls, "-item");
67 var marginDirection = 'marginRight'; // directionConfig === 'rtl' ? 'marginLeft' : 'marginRight';
68
69 return (0, _vue.createVNode)("div", {
70 "class": someSpaceClass
71 }, [items.map(function (child, i) {
72 return (0, _vue.createVNode)("div", {
73 "class": itemClassName,
74 "key": "".concat(itemClassName, "-").concat(i),
75 "style": i === len - 1 ? {} : _defineProperty({}, direction === 'vertical' ? 'marginBottom' : marginDirection, typeof size === 'string' ? "".concat(spaceSize[size], "px") : "".concat(size, "px"))
76 }, _isSlot(child) ? child : {
77 default: function _default() {
78 return [child];
79 }
80 });
81 })]);
82 };
83 }
84});
85
86var _default2 = (0, _type.withInstall)(Space);
87
88exports.default = _default2;
\No newline at end of file