schlechtenburg/src/components/TreeElement.ts

43 lines
903 B
TypeScript
Raw Normal View History

2020-05-20 14:21:08 +00:00
import {
reactive,
watchEffect,
PropType,
} from '@vue/composition-api';
type IComponentDefinition = { [name: string]: () => Promise<any> };
type ITreeElement = {
component: string;
id: string;
data: { [name: string]: any };
}
type ITreeElementProps = {
userComponents: IComponentDefinition;
id: string;
data: { [key: string]: any};
};
export const model = {
prop: 'tree',
event: 'tree-update',
};
export const treeElementProps = {
userComponents: {
type: (Object as unknown) as PropType<IComponentDefinition>,
required: true,
},
component: { type: Object, required: true },
id: { type: String, required: true },
data: { type: Object, default: () => ({}) },
};
// export function useActivation
export function useDynamicComponents(components: IComponentDefinition) {
const getComponent = (name: string) => components[name];
return { getComponent };
}