index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. var utils_1 = require("../common/utils");
  5. component_1.VantComponent({
  6. field: true,
  7. classes: ['input-class', 'right-icon-class'],
  8. props: {
  9. size: String,
  10. icon: String,
  11. label: String,
  12. error: Boolean,
  13. fixed: Boolean,
  14. focus: Boolean,
  15. center: Boolean,
  16. isLink: Boolean,
  17. leftIcon: String,
  18. rightIcon: String,
  19. disabled: Boolean,
  20. autosize: Boolean,
  21. readonly: Boolean,
  22. required: Boolean,
  23. password: Boolean,
  24. iconClass: String,
  25. clearable: Boolean,
  26. clickable: Boolean,
  27. inputAlign: String,
  28. placeholder: String,
  29. customStyle: String,
  30. confirmType: String,
  31. confirmHold: Boolean,
  32. holdKeyboard: Boolean,
  33. errorMessage: String,
  34. arrowDirection: String,
  35. placeholderStyle: String,
  36. errorMessageAlign: String,
  37. selectionEnd: {
  38. type: Number,
  39. value: -1
  40. },
  41. selectionStart: {
  42. type: Number,
  43. value: -1
  44. },
  45. showConfirmBar: {
  46. type: Boolean,
  47. value: true
  48. },
  49. adjustPosition: {
  50. type: Boolean,
  51. value: true
  52. },
  53. cursorSpacing: {
  54. type: Number,
  55. value: 50
  56. },
  57. maxlength: {
  58. type: Number,
  59. value: -1
  60. },
  61. type: {
  62. type: String,
  63. value: 'text'
  64. },
  65. border: {
  66. type: Boolean,
  67. value: true
  68. },
  69. titleWidth: {
  70. type: String,
  71. value: '90px'
  72. }
  73. },
  74. data: {
  75. focused: false,
  76. system: utils_1.getSystemInfoSync().system.split(' ').shift().toLowerCase()
  77. },
  78. methods: {
  79. onInput: function (event) {
  80. var _this = this;
  81. var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a;
  82. this.setData({ value: value });
  83. wx.nextTick(function () {
  84. _this.emitChange(value);
  85. });
  86. },
  87. onFocus: function (event) {
  88. this.setData({ focused: true });
  89. this.$emit('focus', event.detail);
  90. },
  91. onBlur: function (event) {
  92. this.setData({ focused: false });
  93. this.$emit('blur', event.detail);
  94. },
  95. onClickIcon: function () {
  96. this.$emit('click-icon');
  97. },
  98. onClear: function () {
  99. var _this = this;
  100. this.setData({ value: '' });
  101. wx.nextTick(function () {
  102. _this.emitChange('');
  103. _this.$emit('clear', '');
  104. });
  105. },
  106. onConfirm: function () {
  107. this.$emit('confirm', this.data.value);
  108. },
  109. emitChange: function (value) {
  110. this.$emit('input', value);
  111. this.$emit('change', value);
  112. },
  113. noop: function () { }
  114. }
  115. });