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.

VDatePickerHeader.js 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. 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; };
  6. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  7. // Components
  8. // Mixins
  9. // Utils
  10. require('../../../src/stylus/components/_date-picker-header.styl');
  11. var _VBtn = require('../VBtn');
  12. var _VBtn2 = _interopRequireDefault(_VBtn);
  13. var _VIcon = require('../VIcon');
  14. var _VIcon2 = _interopRequireDefault(_VIcon);
  15. var _colorable = require('../../mixins/colorable');
  16. var _colorable2 = _interopRequireDefault(_colorable);
  17. var _themeable = require('../../mixins/themeable');
  18. var _themeable2 = _interopRequireDefault(_themeable);
  19. var _util = require('./util');
  20. var _mixins = require('../../util/mixins');
  21. var _mixins2 = _interopRequireDefault(_mixins);
  22. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23. exports.default = (0, _mixins2.default)(_colorable2.default, _themeable2.default
  24. /* @vue/component */
  25. ).extend({
  26. name: 'v-date-picker-header',
  27. props: {
  28. disabled: Boolean,
  29. format: Function,
  30. locale: {
  31. type: String,
  32. default: 'en-us'
  33. },
  34. min: String,
  35. max: String,
  36. nextIcon: {
  37. type: String,
  38. default: '$vuetify.icons.next'
  39. },
  40. prevIcon: {
  41. type: String,
  42. default: '$vuetify.icons.prev'
  43. },
  44. readonly: Boolean,
  45. value: {
  46. type: [Number, String],
  47. required: true
  48. }
  49. },
  50. data: function data() {
  51. return {
  52. isReversing: false
  53. };
  54. },
  55. computed: {
  56. formatter: function formatter() {
  57. if (this.format) {
  58. return this.format;
  59. } else if (String(this.value).split('-')[1]) {
  60. return (0, _util.createNativeLocaleFormatter)(this.locale, { month: 'long', year: 'numeric', timeZone: 'UTC' }, { length: 7 });
  61. } else {
  62. return (0, _util.createNativeLocaleFormatter)(this.locale, { year: 'numeric', timeZone: 'UTC' }, { length: 4 });
  63. }
  64. }
  65. },
  66. watch: {
  67. value: function value(newVal, oldVal) {
  68. this.isReversing = newVal < oldVal;
  69. }
  70. },
  71. methods: {
  72. genBtn: function genBtn(change) {
  73. var _this = this;
  74. var disabled = this.disabled || change < 0 && this.min && this.calculateChange(change) < this.min || change > 0 && this.max && this.calculateChange(change) > this.max;
  75. return this.$createElement(_VBtn2.default, {
  76. props: {
  77. dark: this.dark,
  78. disabled: disabled,
  79. icon: true,
  80. light: this.light
  81. },
  82. nativeOn: {
  83. click: function click(e) {
  84. e.stopPropagation();
  85. _this.$emit('input', _this.calculateChange(change));
  86. }
  87. }
  88. }, [this.$createElement(_VIcon2.default, change < 0 === !this.$vuetify.rtl ? this.prevIcon : this.nextIcon)]);
  89. },
  90. calculateChange: function calculateChange(sign) {
  91. var _String$split$map = String(this.value).split('-').map(Number),
  92. _String$split$map2 = _slicedToArray(_String$split$map, 2),
  93. year = _String$split$map2[0],
  94. month = _String$split$map2[1];
  95. if (month == null) {
  96. return '' + (year + sign);
  97. } else {
  98. return (0, _util.monthChange)(String(this.value), sign);
  99. }
  100. },
  101. genHeader: function genHeader() {
  102. var _this2 = this;
  103. var color = !this.disabled && (this.color || 'accent');
  104. var header = this.$createElement('div', this.setTextColor(color, {
  105. key: String(this.value)
  106. }), [this.$createElement('button', {
  107. attrs: {
  108. type: 'button'
  109. },
  110. on: {
  111. click: function click() {
  112. return _this2.$emit('toggle');
  113. }
  114. }
  115. }, [this.$slots.default || this.formatter(String(this.value))])]);
  116. var transition = this.$createElement('transition', {
  117. props: {
  118. name: this.isReversing === !this.$vuetify.rtl ? 'tab-reverse-transition' : 'tab-transition'
  119. }
  120. }, [header]);
  121. return this.$createElement('div', {
  122. staticClass: 'v-date-picker-header__value',
  123. class: {
  124. 'v-date-picker-header__value--disabled': this.disabled
  125. }
  126. }, [transition]);
  127. }
  128. },
  129. render: function render() {
  130. return this.$createElement('div', {
  131. staticClass: 'v-date-picker-header',
  132. class: _extends({
  133. 'v-date-picker-header--disabled': this.disabled
  134. }, this.themeClasses)
  135. }, [this.genBtn(-1), this.genHeader(), this.genBtn(+1)]);
  136. }
  137. });
  138. //# sourceMappingURL=VDatePickerHeader.js.map