VStepper.mjs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // @ts-nocheck
  2. /* eslint-disable */
  3. // Styles
  4. import "./VStepper.css";
  5. // Extensions
  6. import VSheet from "../VSheet/index.mjs"; // Components
  7. // Mixins
  8. import { provide as RegistrableProvide } from "../../mixins/registrable.mjs";
  9. import Proxyable from "../../mixins/proxyable.mjs"; // Utilities
  10. import mixins from "../../util/mixins.mjs";
  11. import { breaking } from "../../util/console.mjs"; // Types
  12. const baseMixins = mixins(VSheet, RegistrableProvide('stepper'), Proxyable);
  13. /* @vue/component */
  14. export default baseMixins.extend({
  15. name: 'v-stepper',
  16. provide() {
  17. return {
  18. stepClick: this.stepClick,
  19. isVertical: this.vertical
  20. };
  21. },
  22. props: {
  23. altLabels: Boolean,
  24. nonLinear: Boolean,
  25. flat: Boolean,
  26. vertical: Boolean
  27. },
  28. data() {
  29. const data = {
  30. isBooted: false,
  31. steps: [],
  32. content: [],
  33. isReverse: false
  34. };
  35. data.internalLazyValue = this.value != null ? this.value : (data[0] || {}).step || 1;
  36. return data;
  37. },
  38. computed: {
  39. classes() {
  40. return {
  41. 'v-stepper--flat': this.flat,
  42. 'v-stepper--is-booted': this.isBooted,
  43. 'v-stepper--vertical': this.vertical,
  44. 'v-stepper--alt-labels': this.altLabels,
  45. 'v-stepper--non-linear': this.nonLinear,
  46. ...VSheet.options.computed.classes.call(this)
  47. };
  48. },
  49. styles() {
  50. return {
  51. ...VSheet.options.computed.styles.call(this)
  52. };
  53. }
  54. },
  55. watch: {
  56. internalValue(val, oldVal) {
  57. this.isReverse = Number(val) < Number(oldVal);
  58. oldVal && (this.isBooted = true);
  59. this.updateView();
  60. }
  61. },
  62. created() {
  63. /* istanbul ignore next */
  64. if (this.$listeners.input) {
  65. breaking('@input', '@change', this);
  66. }
  67. },
  68. mounted() {
  69. this.updateView();
  70. },
  71. methods: {
  72. register(item) {
  73. if (item.$options.name === 'v-stepper-step') {
  74. this.steps.push(item);
  75. } else if (item.$options.name === 'v-stepper-content') {
  76. item.isVertical = this.vertical;
  77. this.content.push(item);
  78. }
  79. },
  80. unregister(item) {
  81. if (item.$options.name === 'v-stepper-step') {
  82. this.steps = this.steps.filter(i => i !== item);
  83. } else if (item.$options.name === 'v-stepper-content') {
  84. item.isVertical = this.vertical;
  85. this.content = this.content.filter(i => i !== item);
  86. }
  87. },
  88. stepClick(step) {
  89. this.$nextTick(() => this.internalValue = step);
  90. },
  91. updateView() {
  92. for (let index = this.steps.length; --index >= 0;) {
  93. this.steps[index].toggle(this.internalValue);
  94. }
  95. for (let index = this.content.length; --index >= 0;) {
  96. this.content[index].toggle(this.internalValue, this.isReverse);
  97. }
  98. }
  99. },
  100. render(h) {
  101. return h(this.tag, {
  102. staticClass: 'v-stepper',
  103. class: this.classes,
  104. style: this.styles
  105. }, this.$slots.default);
  106. }
  107. });
  108. //# sourceMappingURL=VStepper.mjs.map