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.

VBtn.js 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  6. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Styles
  7. // Components
  8. // Mixins
  9. // Utilities
  10. require('../../../src/stylus/components/_buttons.styl');
  11. var _mixins = require('../../util/mixins');
  12. var _mixins2 = _interopRequireDefault(_mixins);
  13. var _VProgressCircular = require('../VProgressCircular');
  14. var _VProgressCircular2 = _interopRequireDefault(_VProgressCircular);
  15. var _colorable = require('../../mixins/colorable');
  16. var _colorable2 = _interopRequireDefault(_colorable);
  17. var _groupable = require('../../mixins/groupable');
  18. var _positionable = require('../../mixins/positionable');
  19. var _positionable2 = _interopRequireDefault(_positionable);
  20. var _routable = require('../../mixins/routable');
  21. var _routable2 = _interopRequireDefault(_routable);
  22. var _themeable = require('../../mixins/themeable');
  23. var _themeable2 = _interopRequireDefault(_themeable);
  24. var _toggleable = require('../../mixins/toggleable');
  25. var _helpers = require('../../util/helpers');
  26. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  28. var baseMixins = (0, _mixins2.default)(_colorable2.default, _routable2.default, _positionable2.default, _themeable2.default, (0, _groupable.factory)('btnToggle'), (0, _toggleable.factory)('inputValue')
  29. /* @vue/component */
  30. );
  31. exports.default = baseMixins.extend().extend({
  32. name: 'v-btn',
  33. props: {
  34. activeClass: {
  35. type: String,
  36. default: 'v-btn--active'
  37. },
  38. block: Boolean,
  39. depressed: Boolean,
  40. fab: Boolean,
  41. flat: Boolean,
  42. icon: Boolean,
  43. large: Boolean,
  44. loading: Boolean,
  45. outline: Boolean,
  46. ripple: {
  47. type: [Boolean, Object],
  48. default: null
  49. },
  50. round: Boolean,
  51. small: Boolean,
  52. tag: {
  53. type: String,
  54. default: 'button'
  55. },
  56. type: {
  57. type: String,
  58. default: 'button'
  59. },
  60. value: null
  61. },
  62. computed: {
  63. classes: function classes() {
  64. var _extends2;
  65. return _extends((_extends2 = {
  66. 'v-btn': true
  67. }, _defineProperty(_extends2, this.activeClass, this.isActive), _defineProperty(_extends2, 'v-btn--absolute', this.absolute), _defineProperty(_extends2, 'v-btn--block', this.block), _defineProperty(_extends2, 'v-btn--bottom', this.bottom), _defineProperty(_extends2, 'v-btn--disabled', this.disabled), _defineProperty(_extends2, 'v-btn--flat', this.flat), _defineProperty(_extends2, 'v-btn--floating', this.fab), _defineProperty(_extends2, 'v-btn--fixed', this.fixed), _defineProperty(_extends2, 'v-btn--icon', this.icon), _defineProperty(_extends2, 'v-btn--large', this.large), _defineProperty(_extends2, 'v-btn--left', this.left), _defineProperty(_extends2, 'v-btn--loader', this.loading), _defineProperty(_extends2, 'v-btn--outline', this.outline), _defineProperty(_extends2, 'v-btn--depressed', this.depressed && !this.flat || this.outline), _defineProperty(_extends2, 'v-btn--right', this.right), _defineProperty(_extends2, 'v-btn--round', this.round), _defineProperty(_extends2, 'v-btn--router', this.to), _defineProperty(_extends2, 'v-btn--small', this.small), _defineProperty(_extends2, 'v-btn--top', this.top), _extends2), this.themeClasses);
  68. },
  69. computedRipple: function computedRipple() {
  70. var defaultRipple = this.icon || this.fab ? { circle: true } : true;
  71. if (this.disabled) return false;else return this.ripple !== null ? this.ripple : defaultRipple;
  72. }
  73. },
  74. watch: {
  75. '$route': 'onRouteChange'
  76. },
  77. methods: {
  78. // Prevent focus to match md spec
  79. click: function click(e) {
  80. !this.fab && e.detail && this.$el.blur();
  81. this.$emit('click', e);
  82. this.btnToggle && this.toggle();
  83. },
  84. genContent: function genContent() {
  85. return this.$createElement('div', { 'class': 'v-btn__content' }, this.$slots.default);
  86. },
  87. genLoader: function genLoader() {
  88. return this.$createElement('span', {
  89. class: 'v-btn__loading'
  90. }, this.$slots.loader || [this.$createElement(_VProgressCircular2.default, {
  91. props: {
  92. indeterminate: true,
  93. size: 23,
  94. width: 2
  95. }
  96. })]);
  97. },
  98. onRouteChange: function onRouteChange() {
  99. var _this = this;
  100. if (!this.to || !this.$refs.link) return;
  101. var path = '_vnode.data.class.' + this.activeClass;
  102. this.$nextTick(function () {
  103. if ((0, _helpers.getObjectValueByPath)(_this.$refs.link, path)) {
  104. _this.toggle();
  105. }
  106. });
  107. }
  108. },
  109. render: function render(h) {
  110. var setColor = !this.outline && !this.flat && !this.disabled ? this.setBackgroundColor : this.setTextColor;
  111. var _generateRouteLink = this.generateRouteLink(this.classes),
  112. tag = _generateRouteLink.tag,
  113. data = _generateRouteLink.data;
  114. var children = [this.genContent(), this.loading && this.genLoader()];
  115. if (tag === 'button') data.attrs.type = this.type;
  116. data.attrs.value = ['string', 'number'].includes(_typeof(this.value)) ? this.value : JSON.stringify(this.value);
  117. if (this.btnToggle) {
  118. data.ref = 'link';
  119. }
  120. return h(tag, setColor(this.color, data), children);
  121. }
  122. });
  123. //# sourceMappingURL=VBtn.js.map