2024-10-23 04:05:27 +00:00
|
|
|
<template>
|
|
|
|
<component :is="component" :id :name class="w-full" />
|
|
|
|
</template>
|
|
|
|
|
2024-10-23 21:57:52 +00:00
|
|
|
<script setup>
|
2024-10-23 04:05:27 +00:00
|
|
|
import * as PrimeVue from 'primevue/primevue';
|
2024-10-23 21:57:52 +00:00
|
|
|
import { computed, inject } from 'vue';
|
2024-10-23 04:05:27 +00:00
|
|
|
|
2024-10-23 21:57:52 +00:00
|
|
|
const props = defineProps({
|
|
|
|
as: {
|
|
|
|
type: String,
|
|
|
|
default: 'InputText'
|
2024-10-23 04:05:27 +00:00
|
|
|
},
|
2024-10-23 21:57:52 +00:00
|
|
|
schema: null,
|
|
|
|
defaultValue: {
|
|
|
|
default: ''
|
2024-10-23 04:05:27 +00:00
|
|
|
}
|
2024-10-23 21:57:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const $fcDynamicForm = inject('$fcDynamicForm', undefined);
|
|
|
|
const $fcDynamicFormField = inject('$fcDynamicFormField', undefined);
|
|
|
|
|
|
|
|
const id = computed(() => $fcDynamicFormField?.groupId);
|
|
|
|
const name = computed(() => $fcDynamicFormField?.name);
|
|
|
|
const component = computed(() => PrimeVue[props.as] ?? props.as);
|
|
|
|
|
|
|
|
$fcDynamicForm?.addField(name.value, props.schema, props.defaultValue);
|
2024-10-23 04:05:27 +00:00
|
|
|
</script>
|