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.

62 lines
1.3 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="tw-flex tw-flex-col">
  3. <label class="tw-mb-[10px] tw-font-normal" :for="input.id"><span>{{ $t(input.label)
  4. }}<span v-if="input.required" class="required">*</span></span></label>
  5. <input :id="input.id" :class="[validation ? '' : 'tw-border-error-default']" :type="input.type" :value="value" :maxlength="maxlength"
  6. v-model="inputVal" />
  7. <div v-show="errorText" class="tw-text-error-default tw-text-[14px] tw-font-medium tw-leading-[18px] tw-mt-[4px]">
  8. {{ errorText }}
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. name: "ElementInput",
  15. props: {
  16. input: {
  17. type: Object,
  18. },
  19. default: {
  20. type: String,
  21. },
  22. validation: {
  23. type: Boolean,
  24. },
  25. errorText: {
  26. type: String,
  27. },
  28. maxlength:{
  29. type: Number,
  30. default: 50,
  31. },
  32. },
  33. data() {
  34. return {
  35. value: this.default ? this.default : "",
  36. };
  37. },
  38. mounted() { },
  39. watch: {
  40. default: {
  41. handler: function () {
  42. this.value = this.default;
  43. },
  44. },
  45. },
  46. computed: {
  47. inputVal: {
  48. get() {
  49. return this.value;
  50. },
  51. set(val) {
  52. this.value = val;
  53. this.$emit("change", val);
  54. },
  55. },
  56. },
  57. };
  58. </script>
  59. <style lang="scss" scoped>
  60. </style>