AppPassword.vue 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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(
  26. () => props.label.toLowerCase().replace(/\s+/g, '-') + '-help'
  27. )
  28. </script>
  29. <template>
  30. <div class="field">
  31. <label :for="forLabel">{{ label }}</label>
  32. <Password
  33. class="w-full"
  34. input-class="w-full"
  35. promptLabel="Masukan kata sandi"
  36. weakLabel="Ah Lemah"
  37. mediumLabel="Lumayan"
  38. strongLabel="Wow Kuat"
  39. :disabled="disabled"
  40. :id="forLabel"
  41. :placeholder="placeholder"
  42. :aria-describedby="ariaDescribedbyLabel"
  43. :toggleMask="true"
  44. :value="modelValue"
  45. :model-value="modelValue"
  46. @input="$emit('update:modelValue', $event.target.value)"
  47. />
  48. <small
  49. v-if="error"
  50. :id="ariaDescribedbyLabel"
  51. :class="{ 'p-error': isError }"
  52. >
  53. {{ error }}
  54. </small>
  55. </div>
  56. </template>