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.

63 lines
1.4 KiB

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="select.id"><span>{{ $t(select.label)
  4. }}<span v-if="select.required" class="required">*</span></span></label>
  5. <select :class="['tw-pr-[40px]',validation ? '' : 'tw-border-error-default']" :name="select.id" v-model="value"
  6. @change="inputVal">
  7. <option :value="0">{{ $t("Select option") }}</option>
  8. <option v-for="{ id, name } in selectList" :key="id" :value="id">
  9. {{ name }}
  10. </option>
  11. </select>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: "ElementSelect",
  17. props: {
  18. select: {
  19. type: Object,
  20. },
  21. selectList: {
  22. type: Array,
  23. },
  24. default: {
  25. type: String,
  26. },
  27. validation: {
  28. type: Boolean,
  29. },
  30. },
  31. data() {
  32. return {
  33. value: this.default ?? null,
  34. };
  35. },
  36. mounted() { },
  37. watch: {
  38. default: {
  39. handler: function () {
  40. this.value = this.default;
  41. },
  42. },
  43. },
  44. methods: {
  45. inputVal() {
  46. this.$emit("change", this.value);
  47. },
  48. },
  49. };
  50. </script>
  51. <style lang="scss" scoped>
  52. select {
  53. -moz-appearance: none;
  54. /* Firefox */
  55. -webkit-appearance: none;
  56. /* Safari and Chrome */
  57. appearance: none;
  58. background-image: url("~/assets/svg/down-arrow.svg");
  59. background-size: 9px 6px;
  60. background-position: right 20px center;
  61. background-repeat: no-repeat;
  62. }
  63. </style>