steps.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var vnode = require('../../../utils/vue/vnode.js');
  5. var shared = require('@vue/shared');
  6. var ElTourSteps = vue.defineComponent({
  7. name: "ElTourSteps",
  8. props: {
  9. current: {
  10. type: Number,
  11. default: 0
  12. }
  13. },
  14. emits: ["update-total"],
  15. setup(props, { slots, emit }) {
  16. let cacheTotal = 0;
  17. return () => {
  18. var _a, _b;
  19. const children = (_a = slots.default) == null ? void 0 : _a.call(slots);
  20. const result = [];
  21. let total = 0;
  22. function filterSteps(children2) {
  23. if (!shared.isArray(children2))
  24. return;
  25. children2.forEach((item) => {
  26. var _a2;
  27. const name = (_a2 = (item == null ? void 0 : item.type) || {}) == null ? void 0 : _a2.name;
  28. if (name === "ElTourStep") {
  29. result.push(item);
  30. total += 1;
  31. }
  32. });
  33. }
  34. if (children.length) {
  35. filterSteps(vnode.flattedChildren((_b = children[0]) == null ? void 0 : _b.children));
  36. }
  37. if (cacheTotal !== total) {
  38. cacheTotal = total;
  39. emit("update-total", total);
  40. }
  41. if (result.length) {
  42. return result[props.current];
  43. }
  44. return null;
  45. };
  46. }
  47. });
  48. exports["default"] = ElTourSteps;
  49. //# sourceMappingURL=steps.js.map