Line data Source code
1 12 : <template>
2 1 : <div :class="rootClass">
3 : {{ copy.requirements }}:
4 : <ul :class="listClass">
5 : <li :class="checks.length ? undefined : unmetClass">
6 : {{ copy.length }}
7 : </li>
8 : <li :class="checks.uppercase ? undefined : unmetClass">
9 : {{ copy.uppercase }}
10 : </li>
11 : <li :class="checks.lowercase ? undefined : unmetClass">
12 : {{ copy.lowercase }}
13 : </li>
14 : <li :class="checks.number ? undefined : unmetClass">
15 : {{ copy.number }}
16 : </li>
17 : <li :class="checks.special ? undefined : unmetClass">
18 : {{ copy.special }}
19 : </li>
20 : </ul>
21 : </div>
22 : </template>
23 :
24 : <script setup lang="ts">
25 : /**
26 : * The password rule list both hosts show while a new password is typed:
27 : * every rule, the unmet ones marked. Unstyled: copy is host-translated and
28 : * the look comes through the class props; when to show the list (dirty +
29 : * focused) stays with the host.
30 : */
31 : import { computed } from 'vue'
32 :
33 : import type { PasswordRule } from '@comfyorg/account-core/signInSchemas'
34 : import { passwordRuleChecks } from '@comfyorg/account-core/signInSchemas'
35 :
36 : export type PasswordRulesCopy = Readonly<
37 : Record<PasswordRule | 'requirements', string>
38 : >
39 :
40 : const { password, copy, rootClass, listClass, unmetClass } = defineProps<{
41 : password: string
42 : copy: PasswordRulesCopy
43 : rootClass?: string
44 : listClass?: string
45 : /** Applied to a rule the password does not yet satisfy. */
46 : unmetClass?: string
47 : }>()
48 :
49 1 : const checks = computed(() => passwordRuleChecks(password))
50 : </script>
|