UNPKG

lynx-form-x

Version:

LynxFormX is a lightweight and intuitive form library built for the Lynx framework for mobile development. It streamlines form management by automatically binding fields, handling validation, and providing easy-to-use hooks for custom field manipulation—a

16 lines (15 loc) • 674 B
import { useContext } from '@lynx-js/react'; import { formContext } from './Form.jsx'; export const SubmitButton = ({ children, bindtap, disableOnSubmit, disabledClassName, className, ...props }) => { const form = useContext(formContext); return (<view className={disableOnSubmit && form.isSubmitting && disabledClassName ? `${className} ${disabledClassName}` : className} bindtap={(e) => { if (disableOnSubmit && form.isSubmitting) return; form.handleSubmit(); bindtap?.(e); }} {...props}> {typeof children === 'string' ? <text>{children}</text> : children} </view>); };