tdesign-vue
Version:
115 lines (111 loc) • 4.97 kB
JavaScript
/**
* tdesign v1.12.1
* (c) 2025 tdesign
* @license MIT
*/
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed } from '@vue/composition-api';
import props from './props.js';
import { usePrefixClass } from '../hooks/useConfig.js';
import { renderTNodeJSX } from '../utils/render-tnode.js';
import { getFlexGapPolyFill } from '../_common/js/utils/helper.js';
import '../config-provider/useConfig.js';
import '../config-provider/context.js';
import 'lodash-es';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-c44a474d.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-d639fbd7.js';
import 'dayjs';
import '../_chunks/dep-3c66615e.js';
import '../config-provider/type.js';
import '../_common/js/global-config/t.js';
import '@babel/runtime/helpers/readOnlyError';
import 'vue';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/objectWithoutProperties';
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var defaultNeedPolyfill = getFlexGapPolyFill();
var sizeMap = {
small: "8px",
medium: "16px",
large: "24px"
};
var _Space = defineComponent({
name: "TSpace",
props: _objectSpread(_objectSpread({}, props), {}, {
forceFlexGapPolyfill: Boolean
}),
setup: function setup(props2) {
var COMPONENT_NAME = usePrefixClass("space");
var needPolyfill = computed(function () {
return props2.forceFlexGapPolyfill || defaultNeedPolyfill;
});
var renderStyle = computed(function () {
var renderGap = "";
if (Array.isArray(props2.size)) {
renderGap = props2.size.map(function (s) {
if (typeof s === "number") return "".concat(s, "px");
if (typeof s === "string") return sizeMap[s] || s;
return s;
}).join(" ");
} else if (typeof props2.size === "string") {
renderGap = sizeMap[props2.size] || props2.size;
} else if (typeof props2.size === "number") {
renderGap = "".concat(props2.size, "px");
}
var style = {};
if (needPolyfill.value) {
var _renderGap$split = renderGap.split(" "),
_renderGap$split2 = _slicedToArray(_renderGap$split, 2),
columnGap = _renderGap$split2[0],
rowGap = _renderGap$split2[1];
style["--td-space-column-gap"] = columnGap;
style["--td-space-row-gap"] = rowGap || columnGap;
} else {
style.gap = renderGap;
}
return style;
});
var spaceClassNames = computed(function () {
return ["".concat(COMPONENT_NAME.value), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(COMPONENT_NAME.value, "-align-").concat(props2.align), props2.align), "".concat(COMPONENT_NAME.value, "-").concat(props2.direction), props2.direction), "".concat(COMPONENT_NAME.value, "--break-line"), props2.breakLine), "".concat(COMPONENT_NAME.value, "--polyfill"), needPolyfill.value)];
});
return {
COMPONENT_NAME: COMPONENT_NAME,
spaceClassNames: spaceClassNames,
renderStyle: renderStyle
};
},
render: function render() {
var _this = this;
var h = arguments[0];
var COMPONENT_NAME = this.COMPONENT_NAME,
spaceClassNames = this.spaceClassNames,
renderStyle = this.renderStyle;
var children = this.$slots["default"] || [];
var childCount = children === null || children === void 0 ? void 0 : children.length;
var renderChildren = function renderChildren() {
return children.map(function (child, index) {
if (!child.tag && !child.text) {
return child;
}
var separatorNode = renderTNodeJSX(_this, "separator");
var showSeparator = index + 1 !== childCount && separatorNode;
return [h("div", {
"class": "".concat(COMPONENT_NAME, "-item")
}, [child]), showSeparator ? h("div", {
"class": "".concat(COMPONENT_NAME, "-item-separator")
}, [separatorNode]) : null];
});
};
return h("div", {
"class": spaceClassNames,
"style": renderStyle
}, [renderChildren()]);
}
});
export { _Space as default };
//# sourceMappingURL=space.js.map