Move forms to sidepanel
表单组件迁移到 SidePanel 原 Popup 引导打开 SidePanel 优化表单组件和 Hooks,获取 Form 组件 Ref
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { FormHTMLAttributes } from "react";
|
||||
import { useImperativeHandle, type FormHTMLAttributes, useRef, forwardRef, type Ref } from "react";
|
||||
import { clsn } from "~utils";
|
||||
import styles from "./form.module.less";
|
||||
|
||||
@@ -6,12 +6,18 @@ interface FormProps extends FormHTMLAttributes<HTMLFormElement> {
|
||||
|
||||
}
|
||||
|
||||
function Form({ children, className, ...props }: FormProps) {
|
||||
function Form({ children, className, ...props }: FormProps, ref: Ref<HTMLFormElement>) {
|
||||
const formRef = useRef();
|
||||
|
||||
useImperativeHandle(ref, () => {
|
||||
return formRef.current;
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<form className={clsn(styles.form, className)} {...props}>
|
||||
<form ref={formRef} className={clsn(styles.form, className)} {...props}>
|
||||
{children}
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export default Form;
|
||||
export default forwardRef(Form);
|
||||
|
||||
Reference in New Issue
Block a user