| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <!--
- Champs de saisie d'un numéro de téléphone
- @see https://github.com/paul-thebaud/v-phone-inpu
- -->
- <template>
- <v-phone-input
- :model-value="modelValue"
- :rules="rules"
- :variant="variant"
- :label="label || field ? $t(label ?? field) : undefined"
- default-country="FR"
- :invalid-message="(n) => $t('invalid_phone_number', { example: n.example })"
- @update:model-value="onUpdate($event)"
- />
- </template>
- <script setup lang="ts">
- type ValidationRule = (value: string | number | null) => boolean | string
- defineProps({
- modelValue: {
- type: String,
- required: true,
- },
- /**
- * Nom de la propriété d'une entité lorsque l'input concerne cette propriété
- * - Utilisé par la validation
- * - Laisser null si le champ ne s'applique pas à une entité
- */
- field: {
- type: String,
- required: false,
- default: null,
- },
- /**
- * Label du champ
- * Si non défini, c'est le nom de propriété qui est utilisé
- */
- label: {
- type: String,
- required: false,
- default: null,
- },
- /**
- * Règles de validation
- * @see https://vuetify.cn/en/components/forms/#validation-with-submit-clear
- */
- rules: {
- type: Array as PropType<ValidationRule[]>,
- required: false,
- default: () => [],
- },
- /**
- * @see https://vuetifyjs.com/en/api/v-autocomplete/#props-variant
- */
- variant: {
- type: String as PropType<
- | 'filled'
- | 'outlined'
- | 'plain'
- | 'underlined'
- | 'solo'
- | 'solo-inverted'
- | 'solo-filled'
- | undefined
- >,
- required: false,
- default: 'outlined',
- },
- })
- const emit = defineEmits(['update:modelValue'])
- const onUpdate = (event: string | null) => {
- if (event === '') {
- event = null
- }
- emit('update:modelValue', event)
- }
- </script>
- <style lang="scss"></style>
|