steps.mjs 1.3 KB

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