Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VStepperContent.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _transitions = require('../transitions');
  6. var _registrable = require('../../mixins/registrable');
  7. var _helpers = require('../../util/helpers');
  8. var _mixins = require('../../util/mixins');
  9. var _mixins2 = _interopRequireDefault(_mixins);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. // Helpers
  12. // Components
  13. exports.default = (0, _mixins2.default)((0, _registrable.inject)('stepper', 'v-stepper-content', 'v-stepper')
  14. /* @vue/component */
  15. ).extend({
  16. name: 'v-stepper-content',
  17. inject: {
  18. isVerticalProvided: {
  19. from: 'isVertical'
  20. }
  21. },
  22. props: {
  23. step: {
  24. type: [Number, String],
  25. required: true
  26. }
  27. },
  28. data: function data() {
  29. return {
  30. height: 0,
  31. // Must be null to allow
  32. // previous comparison
  33. isActive: null,
  34. isReverse: false,
  35. isVertical: this.isVerticalProvided
  36. };
  37. },
  38. computed: {
  39. classes: function classes() {
  40. return {
  41. 'v-stepper__content': true
  42. };
  43. },
  44. computedTransition: function computedTransition() {
  45. return this.isReverse ? _transitions.VTabReverseTransition : _transitions.VTabTransition;
  46. },
  47. styles: function styles() {
  48. if (!this.isVertical) return {};
  49. return {
  50. height: (0, _helpers.convertToUnit)(this.height)
  51. };
  52. },
  53. wrapperClasses: function wrapperClasses() {
  54. return {
  55. 'v-stepper__wrapper': true
  56. };
  57. }
  58. },
  59. watch: {
  60. isActive: function isActive(current, previous) {
  61. // If active and the previous state
  62. // was null, is just booting up
  63. if (current && previous == null) {
  64. this.height = 'auto';
  65. return;
  66. }
  67. if (!this.isVertical) return;
  68. if (this.isActive) this.enter();else this.leave();
  69. }
  70. },
  71. mounted: function mounted() {
  72. this.$refs.wrapper.addEventListener('transitionend', this.onTransition, false);
  73. this.stepper && this.stepper.register(this);
  74. },
  75. beforeDestroy: function beforeDestroy() {
  76. this.$refs.wrapper.removeEventListener('transitionend', this.onTransition, false);
  77. this.stepper && this.stepper.unregister(this);
  78. },
  79. methods: {
  80. onTransition: function onTransition(e) {
  81. if (!this.isActive || e.propertyName !== 'height') return;
  82. this.height = 'auto';
  83. },
  84. enter: function enter() {
  85. var _this = this;
  86. var scrollHeight = 0;
  87. // Render bug with height
  88. requestAnimationFrame(function () {
  89. scrollHeight = _this.$refs.wrapper.scrollHeight;
  90. });
  91. this.height = 0;
  92. // Give the collapsing element time to collapse
  93. setTimeout(function () {
  94. return _this.isActive && (_this.height = scrollHeight || 'auto');
  95. }, 450);
  96. },
  97. leave: function leave() {
  98. var _this2 = this;
  99. this.height = this.$refs.wrapper.clientHeight;
  100. setTimeout(function () {
  101. return _this2.height = 0;
  102. }, 10);
  103. },
  104. toggle: function toggle(step, reverse) {
  105. this.isActive = step.toString() === this.step.toString();
  106. this.isReverse = reverse;
  107. }
  108. },
  109. render: function render(h) {
  110. var contentData = {
  111. 'class': this.classes
  112. };
  113. var wrapperData = {
  114. 'class': this.wrapperClasses,
  115. style: this.styles,
  116. ref: 'wrapper'
  117. };
  118. if (!this.isVertical) {
  119. contentData.directives = [{
  120. name: 'show',
  121. value: this.isActive
  122. }];
  123. }
  124. var wrapper = h('div', wrapperData, [this.$slots.default]);
  125. var content = h('div', contentData, [wrapper]);
  126. return h(this.computedTransition, {
  127. on: this.$listeners
  128. }, [content]);
  129. }
  130. });
  131. // Util
  132. // Mixins
  133. //# sourceMappingURL=VStepperContent.js.map