1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = exports.timelineProps = void 0;
|
7 |
|
8 | var _vue = require("vue");
|
9 |
|
10 | var _classNames2 = _interopRequireDefault(require("../_util/classNames"));
|
11 |
|
12 | var _vueTypes = _interopRequireDefault(require("../_util/vue-types"));
|
13 |
|
14 | var _propsUtil = require("../_util/props-util");
|
15 |
|
16 | var _initDefaultProps = _interopRequireDefault(require("../_util/props-util/initDefaultProps"));
|
17 |
|
18 | var _TimelineItem = _interopRequireDefault(require("./TimelineItem"));
|
19 |
|
20 | var _LoadingOutlined = _interopRequireDefault(require("@ant-design/icons-vue/LoadingOutlined"));
|
21 |
|
22 | var _configProvider = require("../config-provider");
|
23 |
|
24 | var _type = require("../_util/type");
|
25 |
|
26 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27 |
|
28 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
29 |
|
30 | 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."); }
|
31 |
|
32 | 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); }
|
33 |
|
34 | function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
35 |
|
36 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
37 |
|
38 | 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; }
|
39 |
|
40 | function _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; }
|
41 |
|
42 | function _isSlot(s) {
|
43 | return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !(0, _vue.isVNode)(s);
|
44 | }
|
45 |
|
46 | var timelineProps = {
|
47 | prefixCls: _vueTypes.default.string,
|
48 |
|
49 |
|
50 | pending: _vueTypes.default.any,
|
51 | pendingDot: _vueTypes.default.string,
|
52 | reverse: _vueTypes.default.looseBool,
|
53 | mode: _vueTypes.default.oneOf((0, _type.tuple)('left', 'alternate', 'right', ''))
|
54 | };
|
55 | exports.timelineProps = timelineProps;
|
56 |
|
57 | var _default2 = (0, _vue.defineComponent)({
|
58 | name: 'ATimeline',
|
59 | props: (0, _initDefaultProps.default)(timelineProps, {
|
60 | reverse: false,
|
61 | mode: ''
|
62 | }),
|
63 | setup: function setup() {
|
64 | return {
|
65 | configProvider: (0, _vue.inject)('configProvider', _configProvider.defaultConfigProvider)
|
66 | };
|
67 | },
|
68 | render: function render() {
|
69 | var _classNames;
|
70 |
|
71 | var _a, _b;
|
72 |
|
73 | var _getOptionProps = (0, _propsUtil.getOptionProps)(this),
|
74 | customizePrefixCls = _getOptionProps.prefixCls,
|
75 | reverse = _getOptionProps.reverse,
|
76 | mode = _getOptionProps.mode;
|
77 |
|
78 | var getPrefixCls = this.configProvider.getPrefixCls;
|
79 | var prefixCls = getPrefixCls('timeline', customizePrefixCls);
|
80 | var pendingDot = (0, _propsUtil.getComponent)(this, 'pendingDot');
|
81 | var pending = (0, _propsUtil.getComponent)(this, 'pending');
|
82 | var pendingNode = typeof pending === 'boolean' ? null : pending;
|
83 | var classString = (0, _classNames2.default)(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-pending"), !!pending), _defineProperty(_classNames, "".concat(prefixCls, "-reverse"), !!reverse), _defineProperty(_classNames, "".concat(prefixCls, "-").concat(mode), !!mode), _classNames));
|
84 | var children = (0, _propsUtil.filterEmpty)((_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a));
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | var pendingItem = pending ? (0, _vue.createVNode)(_TimelineItem.default, {
|
95 | "pending": !!pending,
|
96 | "dot": pendingDot || (0, _vue.createVNode)(_LoadingOutlined.default, null, null)
|
97 | }, _isSlot(pendingNode) ? pendingNode : {
|
98 | default: function _default() {
|
99 | return [pendingNode];
|
100 | }
|
101 | }) : null;
|
102 | var timeLineItems = reverse ? [pendingItem].concat(_toConsumableArray(children.reverse())) : [].concat(_toConsumableArray(children), [pendingItem]);
|
103 |
|
104 | var getPositionCls = function getPositionCls(ele, idx) {
|
105 | var eleProps = (0, _propsUtil.getPropsData)(ele);
|
106 |
|
107 | if (mode === 'alternate') {
|
108 | if (eleProps.position === 'right') return "".concat(prefixCls, "-item-right");
|
109 | if (eleProps.position === 'left') return "".concat(prefixCls, "-item-left");
|
110 | return idx % 2 === 0 ? "".concat(prefixCls, "-item-left") : "".concat(prefixCls, "-item-right");
|
111 | }
|
112 |
|
113 | if (mode === 'left') return "".concat(prefixCls, "-item-left");
|
114 | if (mode === 'right') return "".concat(prefixCls, "-item-right");
|
115 | if (eleProps.position === 'right') return "".concat(prefixCls, "-item-right");
|
116 | return '';
|
117 | };
|
118 |
|
119 |
|
120 | var truthyItems = timeLineItems.filter(function (item) {
|
121 | return !!item;
|
122 | });
|
123 | var itemsCount = truthyItems.length;
|
124 | var lastCls = "".concat(prefixCls, "-item-last");
|
125 | var items = truthyItems.map(function (ele, idx) {
|
126 | var pendingClass = idx === itemsCount - 2 ? lastCls : '';
|
127 | var readyClass = idx === itemsCount - 1 ? lastCls : '';
|
128 | return (0, _vue.cloneVNode)(ele, {
|
129 | class: (0, _classNames2.default)([!reverse && !!pending ? pendingClass : readyClass, getPositionCls(ele, idx)])
|
130 | });
|
131 | });
|
132 | return (0, _vue.createVNode)("ul", {
|
133 | "class": classString
|
134 | }, _isSlot(items) ? items : {
|
135 | default: function _default() {
|
136 | return [items];
|
137 | }
|
138 | });
|
139 | }
|
140 | });
|
141 |
|
142 | exports.default = _default2; |
\ | No newline at end of file |