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.

VTextarea.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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; }; // Styles
  6. // Extensions
  7. require('../../../src/stylus/components/_textarea.styl');
  8. var _VTextField = require('../VTextField/VTextField');
  9. var _VTextField2 = _interopRequireDefault(_VTextField);
  10. var _console = require('../../util/console');
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. /* @vue/component */
  13. exports.default = {
  14. name: 'v-textarea',
  15. extends: _VTextField2.default,
  16. props: {
  17. autoGrow: Boolean,
  18. noResize: Boolean,
  19. outline: Boolean,
  20. rowHeight: {
  21. type: [Number, String],
  22. default: 24,
  23. validator: function validator(v) {
  24. return !isNaN(parseFloat(v));
  25. }
  26. },
  27. rows: {
  28. type: [Number, String],
  29. default: 5,
  30. validator: function validator(v) {
  31. return !isNaN(parseInt(v, 10));
  32. }
  33. }
  34. },
  35. computed: {
  36. classes: function classes() {
  37. return _extends({
  38. 'v-textarea': true,
  39. 'v-textarea--auto-grow': this.autoGrow,
  40. 'v-textarea--no-resize': this.noResizeHandle
  41. }, _VTextField2.default.options.computed.classes.call(this, null));
  42. },
  43. dynamicHeight: function dynamicHeight() {
  44. return this.autoGrow ? this.inputHeight : 'auto';
  45. },
  46. isEnclosed: function isEnclosed() {
  47. return this.textarea || _VTextField2.default.options.computed.isEnclosed.call(this);
  48. },
  49. noResizeHandle: function noResizeHandle() {
  50. return this.noResize || this.autoGrow;
  51. }
  52. },
  53. watch: {
  54. lazyValue: function lazyValue() {
  55. !this.internalChange && this.autoGrow && this.$nextTick(this.calculateInputHeight);
  56. }
  57. },
  58. mounted: function mounted() {
  59. var _this = this;
  60. setTimeout(function () {
  61. _this.autoGrow && _this.calculateInputHeight();
  62. }, 0);
  63. // TODO: remove (2.0)
  64. if (this.autoGrow && this.noResize) {
  65. (0, _console.consoleInfo)('"no-resize" is now implied when using "auto-grow", and can be removed', this);
  66. }
  67. },
  68. methods: {
  69. calculateInputHeight: function calculateInputHeight() {
  70. var input = this.$refs.input;
  71. if (input) {
  72. input.style.height = 0;
  73. var height = input.scrollHeight;
  74. var minHeight = parseInt(this.rows, 10) * parseFloat(this.rowHeight);
  75. // This has to be done ASAP, waiting for Vue
  76. // to update the DOM causes ugly layout jumping
  77. input.style.height = Math.max(minHeight, height) + 'px';
  78. }
  79. },
  80. genInput: function genInput() {
  81. var input = _VTextField2.default.options.methods.genInput.call(this);
  82. input.tag = 'textarea';
  83. delete input.data.attrs.type;
  84. input.data.attrs.rows = this.rows;
  85. return input;
  86. },
  87. onInput: function onInput(e) {
  88. _VTextField2.default.options.methods.onInput.call(this, e);
  89. this.autoGrow && this.calculateInputHeight();
  90. },
  91. onKeyDown: function onKeyDown(e) {
  92. // Prevents closing of a
  93. // dialog when pressing
  94. // enter
  95. if (this.isFocused && e.keyCode === 13) {
  96. e.stopPropagation();
  97. }
  98. this.internalChange = true;
  99. this.$emit('keydown', e);
  100. }
  101. }
  102. };
  103. //# sourceMappingURL=VTextarea.js.map