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.

VOverflowBtn.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. require('../../../src/stylus/components/_overflow-buttons.styl');
  6. var _VSelect = require('../VSelect/VSelect');
  7. var _VSelect2 = _interopRequireDefault(_VSelect);
  8. var _VAutocomplete = require('../VAutocomplete');
  9. var _VAutocomplete2 = _interopRequireDefault(_VAutocomplete);
  10. var _VTextField = require('../VTextField/VTextField');
  11. var _VTextField2 = _interopRequireDefault(_VTextField);
  12. var _VBtn = require('../VBtn');
  13. var _VBtn2 = _interopRequireDefault(_VBtn);
  14. var _console = require('../../util/console');
  15. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16. /* @vue/component */
  17. // Styles
  18. exports.default = _VAutocomplete2.default.extend({
  19. name: 'v-overflow-btn',
  20. props: {
  21. segmented: Boolean,
  22. editable: Boolean,
  23. transition: _VSelect2.default.options.props.transition
  24. },
  25. computed: {
  26. classes: function classes() {
  27. return Object.assign(_VAutocomplete2.default.options.computed.classes.call(this), {
  28. 'v-overflow-btn': true,
  29. 'v-overflow-btn--segmented': this.segmented,
  30. 'v-overflow-btn--editable': this.editable
  31. });
  32. },
  33. isAnyValueAllowed: function isAnyValueAllowed() {
  34. return this.editable || _VAutocomplete2.default.options.computed.isAnyValueAllowed.call(this);
  35. },
  36. isSingle: function isSingle() {
  37. return true;
  38. },
  39. computedItems: function computedItems() {
  40. return this.segmented ? this.allItems : this.filteredItems;
  41. },
  42. $_menuProps: function $_menuProps() {
  43. var props = _VAutocomplete2.default.options.computed.$_menuProps.call(this);
  44. props.transition = props.transition || 'v-menu-transition';
  45. return props;
  46. }
  47. },
  48. methods: {
  49. genSelections: function genSelections() {
  50. return this.editable ? _VAutocomplete2.default.options.methods.genSelections.call(this) : _VSelect2.default.options.methods.genSelections.call(this); // Override v-autocomplete's override
  51. },
  52. genCommaSelection: function genCommaSelection(item, index, last) {
  53. return this.segmented ? this.genSegmentedBtn(item) : _VSelect2.default.options.methods.genCommaSelection.call(this, item, index, last);
  54. },
  55. genInput: function genInput() {
  56. var input = _VTextField2.default.options.methods.genInput.call(this);
  57. input.data.domProps.value = this.editable ? this.internalSearch : '';
  58. input.data.attrs.readonly = !this.isAnyValueAllowed;
  59. return input;
  60. },
  61. genLabel: function genLabel() {
  62. if (this.editable && this.isFocused) return null;
  63. var label = _VTextField2.default.options.methods.genLabel.call(this);
  64. if (!label) return label;
  65. // Reset previously set styles from parent
  66. label.data.style = {};
  67. return label;
  68. },
  69. genSegmentedBtn: function genSegmentedBtn(item) {
  70. var _this = this;
  71. var itemValue = this.getValue(item);
  72. var itemObj = this.computedItems.find(function (i) {
  73. return _this.getValue(i) === itemValue;
  74. }) || item;
  75. if (!itemObj.text || !itemObj.callback) {
  76. (0, _console.consoleWarn)('When using \'segmented\' prop without a selection slot, items must contain both a text and callback property', this);
  77. return null;
  78. }
  79. return this.$createElement(_VBtn2.default, {
  80. props: { flat: true },
  81. on: {
  82. click: function click(e) {
  83. e.stopPropagation();
  84. itemObj.callback(e);
  85. }
  86. }
  87. }, [itemObj.text]);
  88. }
  89. }
  90. });
  91. // Extensions
  92. //# sourceMappingURL=VOverflowBtn.js.map