index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports["default"] = void 0;
  5. var _utils = require("../utils");
  6. var _icon = _interopRequireDefault(require("../icon"));
  7. var _use = (0, _utils.use)('step'),
  8. sfc = _use[0],
  9. bem = _use[1];
  10. var _default = sfc({
  11. beforeCreate: function beforeCreate() {
  12. var steps = this.$parent.steps;
  13. var index = this.$parent.slots().indexOf(this.$vnode);
  14. steps.splice(index === -1 ? steps.length : index, 0, this);
  15. },
  16. beforeDestroy: function beforeDestroy() {
  17. var index = this.$parent.steps.indexOf(this);
  18. if (index > -1) {
  19. this.$parent.steps.splice(index, 1);
  20. }
  21. },
  22. computed: {
  23. status: function status() {
  24. var index = this.$parent.steps.indexOf(this);
  25. var active = this.$parent.active;
  26. if (index < active) {
  27. return 'finish';
  28. }
  29. if (index === active) {
  30. return 'process';
  31. }
  32. }
  33. },
  34. render: function render(h) {
  35. var _ref;
  36. var status = this.status;
  37. var _this$$parent = this.$parent,
  38. activeIcon = _this$$parent.activeIcon,
  39. activeColor = _this$$parent.activeColor,
  40. direction = _this$$parent.direction;
  41. var titleStyle = status === 'process' && {
  42. color: activeColor
  43. };
  44. return h("div", {
  45. "class": ['van-hairline', bem([direction, (_ref = {}, _ref[status] = status, _ref)])]
  46. }, [h("div", {
  47. "class": bem('title'),
  48. "style": titleStyle
  49. }, [this.slots()]), h("div", {
  50. "class": bem('circle-container')
  51. }, [status !== 'process' ? h("i", {
  52. "class": bem('circle')
  53. }) : this.slots('active-icon') || h(_icon["default"], {
  54. "attrs": {
  55. "name": activeIcon
  56. },
  57. "style": {
  58. color: activeColor
  59. }
  60. })]), h("div", {
  61. "class": bem('line')
  62. })]);
  63. }
  64. });
  65. exports["default"] = _default;