AppPassword.vue 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <script setup>
  2. import { computed } from 'vue'
  3. const props = defineProps({
  4. label: {
  5. type: String,
  6. required: true,
  7. },
  8. disabled: {
  9. type: Boolean,
  10. default: false,
  11. },
  12. placeholder: {
  13. type: String,
  14. required: true,
  15. },
  16. error: {
  17. type: String,
  18. default: null,
  19. },
  20. modelValue: null,
  21. })
  22. defineEmits(['update:modelValue'])
  23. const isError = computed(() => (props.error ? true : false))
  24. const forLabel = computed(() => props.label.toLowerCase().replace(/\s+/g, '-'))
  25. const ariaDescribedbyLabel = computed(() => props.label.toLowerCase().replace(/\s+/g, '-') + '-help')
  26. </script>
  27. <template>
  28. <div class="field">
  29. <label :for="forLabel">{{ label }}</label>
  30. <Password
  31. class="w-full"
  32. input-class="w-full"
  33. :disabled="disabled"
  34. :id="forLabel"
  35. :placeholder="placeholder"
  36. :aria-describedby="ariaDescribedbyLabel"
  37. :toggleMask="true"
  38. :value="modelValue"
  39. :model-value="modelValue"
  40. @input="$emit('update:modelValue', $event.target.value)"
  41. />
  42. <small v-if="error" :id="ariaDescribedbyLabel" :class="{ 'p-error': isError }">
  43. {{ error }}
  44. </small>
  45. </div>
  46. </template>