AmAddressFormField.vue
1 year ago
AmAttachmentFormField.vue
1 year ago
AmCheckboxFormField.vue
2 years ago
AmContentFormField.vue
2 years ago
AmDatePickerFormField.vue
2 years ago
AmInputFormField.vue
2 years ago
AmPhoneFormField.vue
1 year ago
AmRadioFormField.vue
2 years ago
AmSelectFormField.vue
1 year ago
AmPhoneFormField.vue
151 lines
| 1 | <template> |
| 2 | <el-form-item |
| 3 | v-if="props.visible" |
| 4 | ref="formFieldRef" |
| 5 | class="am-ff__item" |
| 6 | :prop="props.itemName" |
| 7 | :label-position="props.labelPosition" |
| 8 | :style="cssVars" |
| 9 | style="z-index: 10" |
| 10 | > |
| 11 | <template #label> |
| 12 | <span class="am-ff__item-label" v-html="props.label" /> |
| 13 | </template> |
| 14 | <AmInputPhone |
| 15 | v-model="model" |
| 16 | :name="props.itemName" |
| 17 | :placeholder="props.placeholder" |
| 18 | :default-code="props.defaultCode" |
| 19 | :disabled="props.disabled" |
| 20 | style="position: relative" |
| 21 | @country-phone-iso-updated="countryPhoneIsoUpdated" |
| 22 | /> |
| 23 | <div |
| 24 | v-if="props.isWhatsApp" |
| 25 | class="am-whatsapp-opt-in-text" |
| 26 | > |
| 27 | {{ props.whatsAppLabel }} |
| 28 | </div> |
| 29 | </el-form-item> |
| 30 | </template> |
| 31 | |
| 32 | <script setup> |
| 33 | // * _components |
| 34 | import AmInputPhone from '../../_components/input-phone/AmInputPhone.vue' |
| 35 | |
| 36 | // * Import from Vue |
| 37 | import { |
| 38 | computed, |
| 39 | inject, |
| 40 | ref, |
| 41 | toRefs |
| 42 | } from "vue"; |
| 43 | |
| 44 | // * Composables |
| 45 | import { useColorTransparency } from "../../../assets/js/common/colorManipulation"; |
| 46 | |
| 47 | // * Form Item Props |
| 48 | let props = defineProps({ |
| 49 | modelValue: { |
| 50 | type: [String, Number, Object, Array], |
| 51 | required: true |
| 52 | }, |
| 53 | itemName: { |
| 54 | type: String, |
| 55 | required: true |
| 56 | }, |
| 57 | label: { |
| 58 | type: String |
| 59 | }, |
| 60 | whatsAppLabel: { |
| 61 | type: String |
| 62 | }, |
| 63 | labelPosition: { |
| 64 | type: String, |
| 65 | default: 'top' |
| 66 | }, |
| 67 | placeholder: { |
| 68 | type: String |
| 69 | }, |
| 70 | phoneError: { |
| 71 | type: Boolean, |
| 72 | default: false |
| 73 | }, |
| 74 | visible: { |
| 75 | type: Boolean, |
| 76 | default: true |
| 77 | }, |
| 78 | defaultCode: { |
| 79 | type: String, |
| 80 | default: '' |
| 81 | }, |
| 82 | isWhatsApp: { |
| 83 | type: [Boolean, String, Number], |
| 84 | default: false |
| 85 | }, |
| 86 | countryPhoneIso: { |
| 87 | type: [String, Object, Array, Number], |
| 88 | required: true |
| 89 | }, |
| 90 | disabled: { |
| 91 | type: Boolean, |
| 92 | default: false |
| 93 | } |
| 94 | }) |
| 95 | |
| 96 | // * Define Emits |
| 97 | const emits = defineEmits(['update:modelValue', 'update:countryPhoneIso']) |
| 98 | |
| 99 | // * Component model |
| 100 | let { modelValue } = toRefs(props) |
| 101 | let model = computed({ |
| 102 | get: () => modelValue.value, |
| 103 | set: (val) => { |
| 104 | emits('update:modelValue', val ? val : '') |
| 105 | } |
| 106 | }) |
| 107 | |
| 108 | function countryPhoneIsoUpdated (val) { |
| 109 | emits('update:countryPhoneIso', val) |
| 110 | } |
| 111 | |
| 112 | // * Colors |
| 113 | let amColors = inject('amColors') |
| 114 | let cssVars = computed(() => { |
| 115 | return { |
| 116 | // is - Info Step, wa - WhatsApp |
| 117 | '--am-c-is-wa-text': useColorTransparency(amColors.value.colorMainText, 0.5), |
| 118 | // ! Inline styles need to be removed |
| 119 | 'margin-bottom': props.isWhatsApp && !props.phoneError ? '10px' : '24px' |
| 120 | } |
| 121 | }) |
| 122 | |
| 123 | let formFieldRef = ref(null) |
| 124 | |
| 125 | defineExpose({ |
| 126 | formFieldRef |
| 127 | }) |
| 128 | </script> |
| 129 | |
| 130 | <script> |
| 131 | export default { |
| 132 | name: "PhoneFormField" |
| 133 | } |
| 134 | </script> |
| 135 | |
| 136 | <style lang="scss"> |
| 137 | .amelia-v2-booking { |
| 138 | #amelia-container { |
| 139 | .am-fs__info-form__item, .am-ff__item { |
| 140 | .am-whatsapp-opt-in-text { |
| 141 | color: var(--am-c-is-wa-text); |
| 142 | font-weight: 400; |
| 143 | font-size: 10px; |
| 144 | line-height: 16px; |
| 145 | word-break: break-word; |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | </style> |
| 151 |