AppPassword.vue 1.1KB

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