1 | import { isVNode as _isVNode, createVNode as _createVNode } from "vue";
|
2 |
|
3 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
4 |
|
5 | function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
6 |
|
7 | function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
8 |
|
9 | function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
10 |
|
11 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
12 |
|
13 | function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
14 |
|
15 | import { defineComponent } from 'vue';
|
16 | import PropTypes from '../_util/vue-types';
|
17 |
|
18 | function _isSlot(s) {
|
19 | return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
|
20 | }
|
21 |
|
22 | var widthUnit = PropTypes.oneOfType([PropTypes.number, PropTypes.string]);
|
23 | var skeletonParagraphProps = {
|
24 | prefixCls: PropTypes.string,
|
25 | width: PropTypes.oneOfType([widthUnit, PropTypes.arrayOf(widthUnit)]),
|
26 | rows: PropTypes.number
|
27 | };
|
28 | export var SkeletonParagraphProps = PropTypes.shape(skeletonParagraphProps);
|
29 | var Paragraph = defineComponent({
|
30 | props: skeletonParagraphProps,
|
31 | methods: {
|
32 | getWidth: function getWidth(index) {
|
33 | var width = this.width,
|
34 | _this$rows = this.rows,
|
35 | rows = _this$rows === void 0 ? 2 : _this$rows;
|
36 |
|
37 | if (Array.isArray(width)) {
|
38 | return width[index];
|
39 | }
|
40 |
|
41 |
|
42 | if (rows - 1 === index) {
|
43 | return width;
|
44 | }
|
45 |
|
46 | return undefined;
|
47 | }
|
48 | },
|
49 | render: function render() {
|
50 | var _this = this;
|
51 |
|
52 | var _this$$props = this.$props,
|
53 | prefixCls = _this$$props.prefixCls,
|
54 | rows = _this$$props.rows;
|
55 |
|
56 | var rowList = _toConsumableArray(Array(rows)).map(function (_, index) {
|
57 | var width = _this.getWidth(index);
|
58 |
|
59 | return _createVNode("li", {
|
60 | "key": index,
|
61 | "style": {
|
62 | width: typeof width === 'number' ? "".concat(width, "px") : width
|
63 | }
|
64 | }, null);
|
65 | });
|
66 |
|
67 | return _createVNode("ul", {
|
68 | "class": prefixCls
|
69 | }, _isSlot(rowList) ? rowList : {
|
70 | default: function _default() {
|
71 | return [rowList];
|
72 | }
|
73 | });
|
74 | }
|
75 | });
|
76 | export default Paragraph; |
\ | No newline at end of file |