Advertisement
niedzwiedzw

Untitled

Jan 27th, 2022
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.83 KB | None | 0 0
  1. <template>
  2.   <div class="InputField">
  3.     <h3 v-if="label.length > 0" class="label">
  4.       {{ label }}
  5.     </h3>
  6.     <input
  7.      :type="type"
  8.      :value="value"
  9.      class="input-concave"
  10.      :disabled="disabled"
  11.      @input="onInput($event.target.value)"
  12.      :placeholder="placeholder"
  13.    />
  14.     <div class="errors" mode="in-out">
  15.         <li class="error" v-for="error in errors" :key="error" style="padding: 0.3rem;">
  16.             {{ error }}
  17.         </li>
  18.     </div>
  19.   </div>
  20. </template>
  21.  
  22. <script setup lang="ts">
  23.  
  24. import { parseInput, useValidation, Validator } from "@/validation";
  25. import { defineComponent, computed, defineEmits, defineProps, PropType } from "vue";
  26. import {computed} from 'vue';
  27.  
  28. const props = defineProps<{
  29.    type: string,
  30.    value: number | string,
  31.    nullValue?: number,
  32.    label: string,
  33.    validators: Function as PropType<() => Array<Validator<number>>>,
  34.     placeholder: string,
  35. }>();
  36. const emit = defineEmits<{
  37.    (eventName: 'input', value: string): void
  38. }>();
  39.  
  40. function onInput(value: string) {
  41.     emit("input", value);
  42. }
  43. const {} = useValidation(
  44.     computed(() => props.value),
  45.     props.validators
  46. );
  47. </script>
  48.  
  49. <style scoped lang="scss">
  50. @import "@/styles/main";
  51. .InputField {
  52.     @include grid-center-padding(1.5rem);
  53.     grid-auto-flow: column;
  54.     grid-template-columns: 2fr 1fr auto;
  55.     grid-gap: 2rem;
  56.     .label {
  57.         font-weight: bold;
  58.         // width: 300px;
  59.         text-align: center;
  60.     }
  61.     input {
  62.         width: 100%;
  63.         min-width: 3rem;
  64.     }
  65.     .input-concave {
  66.         @include input-concave;
  67.         &.disabled {
  68.            box-shadow: none;
  69.         }
  70.     }
  71.     .errors {
  72.         grid-column: 1 / -1;
  73.         grid-row: 2;
  74.         .error {
  75.             width: 25rem;
  76.            
  77.         }
  78.     }
  79.  
  80. }
  81. </style>
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement