import React, { CSSProperties } from 'react'; import { useNode, UserComponent } from '@craftjs/core'; import { cssPropsToString } from '../../utils/style-helpers'; import { escapeHtml } from '../../utils/escape'; interface FormButtonProps { text?: string; style?: CSSProperties; } export const FormButton: UserComponent = ({ text = 'Submit', style = {}, }) => { const { connectors: { connect, drag }, selected, } = useNode((node) => ({ selected: node.events.selected, })); return ( ); }; /* ---------- Craft config ---------- */ FormButton.craft = { displayName: 'Submit Button', props: { text: 'Submit', style: { backgroundColor: '#3b82f6', color: '#ffffff', padding: '12px 32px', borderRadius: '6px', fontWeight: '600', fontSize: '16px', border: 'none', }, }, rules: { canDrag: () => true, canMoveIn: () => false, canMoveOut: () => true, }, }; /* ---------- HTML export ---------- */ (FormButton as any).toHtml = (props: FormButtonProps, _childrenHtml: string) => { const styleStr = cssPropsToString({ padding: '12px 32px', border: 'none', cursor: 'pointer', ...props.style, }); const escapedText = escapeHtml(props.text || 'Submit'); return { html: ``, }; };