index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. inputAlign: String,
  27. customStyle: String,
  28. confirmType: String,
  29. confirmHold: Boolean,
  30. errorMessage: String,
  31. placeholder: String,
  32. placeholderStyle: String,
  33. errorMessageAlign: String,
  34. selectionEnd: {
  35. type: Number,
  36. value: -1
  37. },
  38. selectionStart: {
  39. type: Number,
  40. value: -1
  41. },
  42. showConfirmBar: {
  43. type: Boolean,
  44. value: true
  45. },
  46. adjustPosition: {
  47. type: Boolean,
  48. value: true
  49. },
  50. cursorSpacing: {
  51. type: Number,
  52. value: 50
  53. },
  54. maxlength: {
  55. type: Number,
  56. value: -1
  57. },
  58. type: {
  59. type: String,
  60. value: 'text'
  61. },
  62. border: {
  63. type: Boolean,
  64. value: true
  65. },
  66. titleWidth: {
  67. type: String,
  68. value: '90px'
  69. }
  70. },
  71. data: {
  72. focused: false,
  73. system: utils_1.getSystemInfoSync().system.split(' ').shift().toLowerCase()
  74. },
  75. methods: {
  76. onInput: function (event) {
  77. var _this = this;
  78. var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a;
  79. this.set({ value: value }, function () {
  80. _this.emitChange(value);
  81. });
  82. },
  83. onFocus: function (event) {
  84. this.set({ focused: true });
  85. this.$emit('focus', event.detail);
  86. },
  87. onBlur: function (event) {
  88. this.set({ focused: false });
  89. this.$emit('blur', event.detail);
  90. },
  91. onClickIcon: function () {
  92. this.$emit('click-icon');
  93. },
  94. onClear: function () {
  95. var _this = this;
  96. this.set({ value: '' }, function () {
  97. _this.emitChange('');
  98. _this.$emit('clear', '');
  99. });
  100. },
  101. onConfirm: function () {
  102. this.$emit('confirm', this.data.value);
  103. },
  104. emitChange: function (value) {
  105. this.$emit('input', value);
  106. this.$emit('change', value);
  107. }
  108. }
  109. });