AmAddressFormField.vue
5 days ago
AmAttachmentFormField.vue
5 days ago
AmCheckboxFormField.vue
5 days ago
AmContentFormField.vue
5 days ago
AmDatePickerFormField.vue
5 days ago
AmInputFormField.vue
5 days ago
AmPhoneFormField.vue
5 days ago
AmRadioFormField.vue
5 days ago
AmSelectFormField.vue
5 days ago
AmSocialButton.vue
5 days ago
AmInputFormField.vue
124 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 | > |
| 9 | <template #label> |
| 10 | <span class="am-ff__item-label" v-html="props.label" /> |
| 11 | </template> |
| 12 | <AmInput |
| 13 | v-model="model" |
| 14 | :name="props.itemName" |
| 15 | :type="props.itemType" |
| 16 | :clearable="props.clearable" |
| 17 | :readonly="props.readonly" |
| 18 | :show-password="props.showPassword" |
| 19 | :placeholder="props.placeholder" |
| 20 | :disabled="props.disabled" |
| 21 | :prefix-icon="props.prefixIcon" |
| 22 | :prepend="props.prepend" |
| 23 | :append="props.append" |
| 24 | :suffix-icon="props.suffixIcon" |
| 25 | @enter="emits('enter')" |
| 26 | /> |
| 27 | </el-form-item> |
| 28 | </template> |
| 29 | |
| 30 | <script setup> |
| 31 | // * _components |
| 32 | import AmInput from '../../_components/input/AmInput.vue' |
| 33 | |
| 34 | // * Import from Vue |
| 35 | import { computed, ref, toRefs } from 'vue' |
| 36 | |
| 37 | // * Form Item Props |
| 38 | let props = defineProps({ |
| 39 | modelValue: { |
| 40 | type: [String, Array, Object, Number], |
| 41 | required: true, |
| 42 | }, |
| 43 | itemName: { |
| 44 | type: String, |
| 45 | required: true, |
| 46 | }, |
| 47 | itemType: { |
| 48 | type: String, |
| 49 | default: 'text', |
| 50 | }, |
| 51 | label: { |
| 52 | type: String, |
| 53 | }, |
| 54 | labelPosition: { |
| 55 | type: String, |
| 56 | default: 'top', |
| 57 | }, |
| 58 | placeholder: { |
| 59 | type: String, |
| 60 | }, |
| 61 | visible: { |
| 62 | type: Boolean, |
| 63 | default: true, |
| 64 | }, |
| 65 | disabled: { |
| 66 | type: Boolean, |
| 67 | default: false, |
| 68 | }, |
| 69 | showPassword: { |
| 70 | type: Boolean, |
| 71 | default: false, |
| 72 | }, |
| 73 | clearable: { |
| 74 | type: Boolean, |
| 75 | default: false, |
| 76 | }, |
| 77 | readonly: { |
| 78 | type: Boolean, |
| 79 | default: false, |
| 80 | }, |
| 81 | prefixIcon: { |
| 82 | type: [String, Object], |
| 83 | default: '', |
| 84 | }, |
| 85 | prepend: { |
| 86 | type: [String, Object], |
| 87 | default: '', |
| 88 | }, |
| 89 | suffixIcon: { |
| 90 | type: [String, Object], |
| 91 | default: '', |
| 92 | }, |
| 93 | append: { |
| 94 | type: [String, Object], |
| 95 | default: '', |
| 96 | }, |
| 97 | }) |
| 98 | |
| 99 | // * Define Emits |
| 100 | const emits = defineEmits(['update:modelValue', 'enter']) |
| 101 | |
| 102 | // * Component model |
| 103 | let { modelValue } = toRefs(props) |
| 104 | let model = computed({ |
| 105 | get: () => modelValue.value, |
| 106 | set: (val) => { |
| 107 | emits('update:modelValue', val) |
| 108 | }, |
| 109 | }) |
| 110 | |
| 111 | // * Form Item Reference |
| 112 | let formFieldRef = ref(null) |
| 113 | |
| 114 | defineExpose({ |
| 115 | formFieldRef, |
| 116 | }) |
| 117 | </script> |
| 118 | |
| 119 | <script> |
| 120 | export default { |
| 121 | name: 'FirstNameFormField', |
| 122 | } |
| 123 | </script> |
| 124 |