tdesign-vue
Version:
242 lines (234 loc) • 7.76 kB
JavaScript
/**
* tdesign v1.15.0
* (c) 2026 tdesign
* @license MIT
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var utils_renderTnode = require('../utils/render-tnode.js');
var skeleton_props = require('./props.js');
var configProvider_configReceiver = require('../config-provider/config-receiver.js');
var utils_mixins = require('../utils/mixins.js');
var isNumber = require('../_chunks/dep-268c68b1.js');
require('@babel/runtime/helpers/readOnlyError');
require('@babel/runtime/helpers/typeof');
require('vue');
require('@vue/composition-api');
require('../_chunks/dep-9c5b91d3.js');
require('../_chunks/dep-9a74c2be.js');
require('../_chunks/dep-689d381f.js');
require('../_chunks/dep-3b2292ce.js');
require('../_chunks/dep-10fcb46d.js');
require('../_chunks/dep-803744d9.js');
require('../_chunks/dep-ba7f5924.js');
require('../_chunks/dep-84027b7f.js');
require('../_chunks/dep-49400b00.js');
require('../_chunks/dep-f1081d8e.js');
require('../_chunks/dep-2c592e99.js');
require('../_chunks/dep-8eddb350.js');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-0c37520c.js');
require('../_chunks/dep-c13dcbfd.js');
require('dayjs');
require('../_chunks/dep-6f4e680e.js');
require('../_chunks/dep-bb0ececf.js');
require('../_chunks/dep-6eba4d23.js');
require('../_chunks/dep-010db548.js');
require('../_chunks/dep-8d206316.js');
require('../_chunks/dep-2bc87cc8.js');
require('../_chunks/dep-f77d6ad5.js');
require('../_chunks/dep-9dae8101.js');
require('../_chunks/dep-7c84d9a0.js');
require('../_chunks/dep-733a2279.js');
require('../_chunks/dep-d844c9ed.js');
require('../_chunks/dep-c05a9033.js');
require('../_chunks/dep-efe55b82.js');
require('../_chunks/dep-7da70ee1.js');
require('../_chunks/dep-124386d4.js');
require('../_chunks/dep-f5b14344.js');
require('../_chunks/dep-36c2788b.js');
require('../_chunks/dep-fa353fbb.js');
require('../_chunks/dep-d66ab3a4.js');
require('../_chunks/dep-d4d8c513.js');
require('../_common/js/global-config/t.js');
require('@babel/runtime/helpers/slicedToArray');
require('../_chunks/dep-a2217d56.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
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__default["default"](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 = configProvider_configReceiver.getClassPrefixMixins("skeleton");
var ThemeMap = {
text: [1],
avatar: [{
type: "circle",
size: "56px"
}],
paragraph: [1, 1, {
width: "70%"
}],
"avatar-text": [[{
type: "circle"
}, {
type: "text",
height: "32px"
}]],
tab: [{
height: "30px"
}, {
height: "200px"
}],
article: [{
type: "rect",
height: "30px",
width: "100%"
}, {
type: "rect",
height: "200px",
width: "100%"
}, [{
type: "text",
height: "30px"
}, {
type: "text",
height: "30px"
}, {
type: "text",
height: "30px"
}], [{
type: "text",
height: "30px"
}, {
type: "text",
height: "30px"
}], [{
type: "text",
height: "30px"
}, {
type: "text",
height: "30px"
}], [{
type: "text",
height: "30px"
}, {
type: "text",
height: "30px"
}]]
};
var _Skeleton = utils_mixins["default"](classPrefixMixins).extend({
name: "TSkeleton",
props: _objectSpread({}, skeleton_props["default"]),
data: function data() {
return {
delayShowLoading: this.delay <= 0 ? this.loading : false,
delayTimer: 0
};
},
watch: {
loading: {
handler: function handler(val) {
if (this.delay <= 0) {
this.delayShowLoading = this.loading;
return;
}
this.handleDelay(val);
},
immediate: true
}
},
methods: {
handleDelay: function handleDelay(loading) {
var _this = this;
if (loading) {
clearTimeout(this.delayTimer);
this.delayTimer = window.setTimeout(function () {
_this.delayShowLoading = _this.loading;
}, this.delay);
} else {
this.delayShowLoading = loading;
}
},
renderCols: function renderCols(_cols) {
var _this2 = this;
var h = this.$createElement;
var getColItemClass = function getColItemClass(obj) {
return ["".concat(_this2.componentName, "__col"), "".concat(_this2.componentName, "--type-").concat(obj.type || "text"), _defineProperty__default["default"]({}, "".concat(_this2.componentName, "--animation-").concat(_this2.animation), _this2.animation)];
};
var getColItemStyle = function getColItemStyle(obj) {
var styleName = ["width", "height", "marginRight", "marginLeft", "margin", "size", "background", "backgroundColor"];
var style = {};
styleName.forEach(function (name) {
if (name in obj) {
var px = isNumber.isNumber(obj[name]) ? "".concat(obj[name], "px") : obj[name];
if (name === "size") {
var _ref2 = [px, px];
style.width = _ref2[0];
style.height = _ref2[1];
} else {
style[name] = px;
}
}
});
return style;
};
var cols = [];
if (Array.isArray(_cols)) {
cols = _cols;
} else if (isNumber.isNumber(_cols)) {
cols = new Array(_cols).fill({
type: "text"
});
} else {
cols = [_cols];
}
return cols.map(function (obj) {
return h("div", {
"class": getColItemClass(obj),
"style": getColItemStyle(obj)
}, [typeof obj.content === "function" ? obj.content(_this2.$createElement) : obj.content]);
});
},
renderRowCol: function renderRowCol(_rowCol) {
var _this3 = this;
var h = this.$createElement;
var rowCol = _rowCol || this.rowCol;
var getBlockClass = function getBlockClass() {
return ["".concat(_this3.componentName, "__row")];
};
return rowCol.map(function (item) {
return h("div", {
"class": getBlockClass()
}, [_this3.renderCols(item)]);
});
}
},
render: function render() {
var h = arguments[0];
var content = utils_renderTnode.renderContent(this, "default", "content");
if (this.$scopedSlots["default"] && !this.delayShowLoading) {
return h("div", [content]);
}
if (!this.delayShowLoading) {
return;
}
var children = [];
if (this.theme && !this.rowCol) {
children.push(this.renderRowCol(ThemeMap[this.theme]));
}
if (this.rowCol) {
children.push(this.renderRowCol(this.rowCol));
}
if (!this.theme && !this.rowCol) {
children.push(this.renderRowCol([1, 1, 1, {
width: "70%"
}]));
}
return h("div", {
"class": this.componentName
}, [children]);
}
});
exports["default"] = _Skeleton;
//# sourceMappingURL=skeleton.js.map