import { computed, ref, defineComponent, } from 'vue'; import { useDynamicBlocks, BlockDefinition, } from '../use-dynamic-blocks'; import { SbButton } from './Button'; import { SbModal } from './Modal'; import './BlockPicker.scss'; export const SbBlockPicker = defineComponent({ name: 'sb-block-picker', props: {}, setup(props, context) { const open = ref(false); const { customBlocks } = useDynamicBlocks(); const blockList = computed(() => Object.keys(customBlocks).map((key) => customBlocks[key])); const selectBlock = (block: BlockDefinition) => () => { open.value = false; context.emit('picked-block', { name: block.name, id: `${+(new Date())}`, data: block.getDefaultData(), }); }; return () => (
{ open.value = true; $event.stopPropagation(); }} >+ $event.stopPropagation()} onClose={() => { open.value = false; }} > {...blockList.value.map((block: BlockDefinition) => ( {block.name} ))}
); }, });