UNPKG

tdesign-vue

Version:
166 lines (162 loc) 6.11 kB
/** * tdesign v1.12.1 * (c) 2025 tdesign * @license MIT */ import { h as helper } from '../_chunks/dep-323b993c.js'; import _slicedToArray from '@babel/runtime/helpers/slicedToArray'; import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { isObject } from 'lodash-es'; import props from './row-props.js'; import { calcSize } from '../utils/responsive.js'; import { getIEVersion } from '../_common/js/utils/helper.js'; import { getClassPrefixMixins } from '../config-provider/config-receiver.js'; import mixins from '../utils/mixins.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/objectWithoutProperties'; import 'vue'; import '../config-provider/context.js'; 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'; 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 classPrefixMixins = getClassPrefixMixins("row"); var _Row = mixins(classPrefixMixins).extend({ name: "TRow", props: _objectSpread({}, props), data: function data() { return { size: "md" }; }, provide: function provide() { return { rowContext: { gutter: this.gutter } }; }, computed: { classes: function classes() { var justify = this.justify, align = this.align; return [this.componentName, _defineProperty(_defineProperty({}, "".concat(this.componentName, "--").concat(justify), justify), "".concat(this.componentName, "--align-").concat(align), align)]; } }, mounted: function mounted() { this.updateSize(); this.handleIE(); window.addEventListener("resize", this.updateSize); }, watch: { gutter: function gutter() { this.handleIE(); }, size: function size() { this.handleIE(); } }, beforeDestroy: function beforeDestroy() { window.removeEventListener("resize", this.updateSize); }, methods: { updateSize: function updateSize() { this.size = calcSize(window.innerWidth); }, handleIE: function handleIE() { if (getIEVersion() <= 11) { var rowGap = this.rowGap(this.gutter, this.size); if (rowGap) { this.$el.setAttribute("row-gap", "".concat(rowGap)); } } }, calcRowStyle: function calcRowStyle(gutter, currentSize) { var rowStyle = {}; if (typeof gutter === "number") { Object.assign(rowStyle, { marginLeft: "".concat(gutter / -2, "px"), marginRight: "".concat(gutter / -2, "px") }); } else if (Array.isArray(gutter) && gutter.length) { if (typeof gutter[0] === "number") { Object.assign(rowStyle, { marginLeft: "".concat(gutter[0] / -2, "px"), marginRight: "".concat(gutter[0] / -2, "px") }); } if (typeof gutter[1] === "number") { Object.assign(rowStyle, { rowGap: "".concat(gutter[1], "px") }); } if (isObject(gutter[0]) && gutter[0][currentSize] !== void 0) { Object.assign(rowStyle, { marginLeft: "".concat(gutter[0][currentSize] / -2, "px"), marginRight: "".concat(gutter[0][currentSize] / -2, "px") }); } if (isObject(gutter[1]) && gutter[1][currentSize] !== void 0) { Object.assign(rowStyle, { rowGap: "".concat(gutter[1][currentSize], "px") }); } } else if (isObject(gutter) && gutter[currentSize]) { if (Array.isArray(gutter[currentSize]) && gutter[currentSize].length) { Object.assign(rowStyle, { marginLeft: "".concat(gutter[currentSize][0] / -2, "px"), marginRight: "".concat(gutter[currentSize][0] / -2, "px") }); Object.assign(rowStyle, { rowGap: "".concat(gutter[currentSize][1], "px") }); } else { Object.assign(rowStyle, { marginLeft: "".concat(gutter[currentSize] / -2, "px"), marginRight: "".concat(gutter[currentSize] / -2, "px") }); } } return rowStyle; }, rowGap: function rowGap(gutter, currentSize) { var rowGap; if (Array.isArray(gutter) && gutter.length) { if (typeof gutter[1] === "number") { var _gutter = _slicedToArray(gutter, 2); rowGap = _gutter[1]; } if (isObject(gutter[1]) && gutter[1][currentSize] !== void 0) { rowGap = gutter[1][currentSize]; } } else if (isObject(gutter) && gutter[currentSize]) { if (Array.isArray(gutter[currentSize]) && gutter[currentSize].length) { var _gutter$currentSize = _slicedToArray(gutter[currentSize], 2); rowGap = _gutter$currentSize[1]; } } return rowGap; } }, render: function render() { var h = arguments[0]; var tag = this.tag, classes = this.classes; var rowStyle = this.calcRowStyle(this.gutter, this.size); var attributes = { "class": classes, style: rowStyle, attrs: {} }; return h(tag, helper([{}, attributes]), [this.$slots["default"]]); } }); export { _Row as default }; //# sourceMappingURL=row.js.map