AppPassword.vue 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <script setup>
  2. import { computed } from 'vue'
  3. const props = defineProps({
  4. label: {
  5. type: String,
  6. required: true,
  7. },
  8. labelClass: {
  9. type: String,
  10. },
  11. disabled: {
  12. type: Boolean,
  13. default: false,
  14. },
  15. placeholder: {
  16. type: String,
  17. required: true,
  18. },
  19. promptLabel: {
  20. type: String,
  21. default: 'Masukan kata sandi',
  22. },
  23. weakLabel: {
  24. type: String,
  25. default: 'Ah Lemah',
  26. },
  27. mediumLabel: {
  28. type: String,
  29. default: 'Lumayan',
  30. },
  31. strongLabel: {
  32. type: String,
  33. default: 'Wow Kuat',
  34. },
  35. error: {
  36. type: String,
  37. default: null,
  38. },
  39. modelValue: null,
  40. })
  41. const isError = computed(() => (props.error ? true : false))
  42. const forLabel = computed(() => props.label.toLowerCase().replace(/\s+/g, '-'))
  43. const ariaDescribedbyLabel = computed(
  44. () => props.label.toLowerCase().replace(/\s+/g, '-') + '-error'
  45. )
  46. </script>
  47. <template>
  48. <div class="field">
  49. <label :for="forLabel" :class="labelClass">{{ label }}</label>
  50. <Password
  51. class="w-full"
  52. input-class="w-full"
  53. :class="{ 'p-invalid': isError }"
  54. :promptLabel="promptLabel"
  55. :weakLabel="weakLabel"
  56. :mediumLabel="mediumLabel"
  57. :strongLabel="strongLabel"
  58. :disabled="disabled"
  59. :id="forLabel"
  60. :placeholder="placeholder"
  61. :toggleMask="true"
  62. :model-value="modelValue"
  63. @input="$emit('update:modelValue', $event.target.value)"
  64. />
  65. <small
  66. v-if="error"
  67. :id="ariaDescribedbyLabel"
  68. :class="{ 'p-error': isError }"
  69. >
  70. {{ error }}
  71. </small>
  72. </div>
  73. </template>