diff --git a/src/Form/components/FormFooter.tsx b/src/Form/components/FormFooter.tsx index 6008357f..792fe715 100644 --- a/src/Form/components/FormFooter.tsx +++ b/src/Form/components/FormFooter.tsx @@ -7,9 +7,9 @@ import { type DivProps } from '@/types'; export type FormFooterProps = DivProps; -const FormFooter = memo(({ className, children, ...rest }) => { +const FormFooter = memo(({ children, ...rest }) => { return ( - + {children} ); diff --git a/src/Form/index.tsx b/src/Form/index.tsx index be59993a..f15f8995 100644 --- a/src/Form/index.tsx +++ b/src/Form/index.tsx @@ -1,7 +1,7 @@ 'use client'; import { Form as AntForm, FormProps as AntFormProps, type FormInstance } from 'antd'; -import { type ReactNode, RefAttributes, forwardRef } from 'react'; +import { CSSProperties, type ReactNode, RefAttributes, forwardRef } from 'react'; import FormFooter from './components/FormFooter'; import FormGroup, { type FormGroupProps, FormVariant, ItemsType } from './components/FormGroup'; @@ -18,12 +18,18 @@ export interface ItemGroup { export interface FormProps extends Omit { children?: ReactNode; + classNames?: { + footer?: string; + }; collapsible?: boolean; footer?: ReactNode; gap?: number | string; itemMinWidth?: FormItemProps['minWidth']; items?: ItemGroup[] | FormItemProps[]; itemsType?: ItemsType; + styles?: { + footer?: CSSProperties; + }; variant?: FormVariant; } @@ -41,11 +47,13 @@ const FormParent = forwardRef( gap, style, collapsible, + classNames = {}, + styles = {}, ...rest }, ref, ) => { - const { cx, styles } = useStyles(); + const { cx, styles: s } = useStyles(); const mapFlat = (item: FormItemProps, itemIndex: number) => ( @@ -68,7 +76,7 @@ const FormParent = forwardRef( return ( ( ) ) : undefined} {children} - {footer && {footer}} + {footer && ( + + {footer} + + )} ); }, diff --git a/src/FormModal/demos/MultiForm.tsx b/src/FormModal/demos/MultiForm.tsx index 409da3d2..a438932f 100644 --- a/src/FormModal/demos/MultiForm.tsx +++ b/src/FormModal/demos/MultiForm.tsx @@ -1,9 +1,15 @@ import { Form, FormModal } from '@lobehub/ui'; import { StoryBook, useControls, useCreateStore } from '@lobehub/ui/storybook'; -import { Button, InputNumber, Segmented, Select, Switch } from 'antd'; +import { Button } from 'antd'; import { useState } from 'react'; +import { items } from './data'; + const { useForm } = Form; + +// @ts-ignore +const [formItem1, formItem2] = items; + const setting = { i18n: 'en', liteAnimation: false, @@ -33,14 +39,6 @@ export default () => { setIsModalOpen(true); }; - const handleSubmit = () => { - setLoading(true); - setTimeout(() => { - form.submit(); - setLoading(false); - }, 2000); - }; - const handleCancel = () => { setIsModalOpen(false); }; @@ -52,14 +50,18 @@ export default () => { { + setLoading(true); console.table(values); + setTimeout(() => { + setLoading(false); + setIsModalOpen(false); + }, 2000); }} > {
- ), - desc: 'Editor language', - label: 'Language', - name: 'i18n', - }, - { - children: , - desc: 'Reduce the blur effect and background flow color, which can improve smoothness and save CPU usage', - label: 'Reduce Animation', - minWidth: undefined, - name: 'liteAnimation', - valuePropName: 'checked', - }, - ], - title: 'Theme Settings', - }, - ]} + items={[formItem1]} itemsType={'group'} variant={variant} /> , - desc: 'Whether to expand the sidebar by default when starting', - label: 'Default Expand', - minWidth: undefined, - name: 'sidebarExpand', - valuePropName: 'checked', - }, - { - children: ( - - ), - desc: 'Fixed as grid mode for constant display, auto-expand when the mouse moves to the side in floating mode', - label: 'Display Mode', - minWidth: undefined, - name: 'sidebarFixedMode', - }, - { - children: , - desc: 'Default width of the sidebar when starting', - label: 'Default Width', - minWidth: undefined, - name: 'sidebarWidth', - }, - ], - title: 'Quick Setting Sidebar', - }, - ]} + items={[formItem2]} itemsType={'group'} variant={variant} /> diff --git a/src/FormModal/index.md b/src/FormModal/index.md index b7a0964d..1e40369f 100644 --- a/src/FormModal/index.md +++ b/src/FormModal/index.md @@ -18,4 +18,4 @@ title: FormModal ## APIs - + diff --git a/src/FormModal/index.tsx b/src/FormModal/index.tsx index 90e092ec..ad2ead30 100644 --- a/src/FormModal/index.tsx +++ b/src/FormModal/index.tsx @@ -1,7 +1,6 @@ import { Button } from 'antd'; import { useResponsive } from 'antd-style'; import { forwardRef } from 'react'; -import { Flexbox } from 'react-layout-kit'; import Form, { type FormInstance, type FormProps } from '@/Form'; import Modal, { type ModalProps } from '@/Modal'; @@ -59,7 +58,6 @@ const FormModal = forwardRef( style, closable, styles = {}, - children, allowFullscreen, title, wrapClassName, @@ -137,23 +135,12 @@ const FormModal = forwardRef( > - {children} - - {footer || ( + footer={ + footer || ( - )} - - + ) + } + gap={gap || (variant === 'pure' ? 24 : gap)} + onFinish={onFinish} + ref={ref} + style={formStyle} + styles={{ + footer: footerStyle, + }} + variant={variant} + {...rest} + /> ); },