diff --git a/examples/form-render-react/300-actions.md b/examples/form-render-react/300-actions.md index 650c564..44fcd09 100644 --- a/examples/form-render-react/300-actions.md +++ b/examples/form-render-react/300-actions.md @@ -450,13 +450,15 @@ export default Demo `IRegisterActionsFnParams` 参数详解如下表格 -| **参数** | **描述** | **类型** | -| ---------------- | ------------------------------------ | -------------------------------------- | -| **handleSubmit** | 当操作名称为 `submit` 时,存在该事件 | `() => void` | -| **handleReset** | 当操作名称为 `reset` 时,存在该事件 | `() => void` | -| **loading** | 提交与重置事件的 `loading` 状态 | `{ submit: boolean; reset: boolean; }` | -| **disabled** | 全局禁用状态 | `boolean` | -| **locale** | 当前语言数据 | `object` | +| **参数** | **描述** | **类型** | +| ---------------- | -------------------------------------- | -------------------------------------- | +| **handleSubmit** | 当操作名称为 `submit` 时,存在该事件 | `() => void` | +| **handleReset** | 当操作名称为 `reset` 时,存在该事件 | `() => void` | +| **loading** | 提交与重置事件的 `loading` 状态 | `{ submit: boolean; reset: boolean; }` | +| **disabled** | 全局禁用状态 | `boolean` | +| **locale** | 当前语言数据 | `object` | +| **submitText** | 提交按钮文案,优先级大于 locale 语言包 | `string` | +| **resetText** | 重置按钮文案,优先级大于 locale 语言包 | `string` | ## 其他相关 API 详解 diff --git a/packages/form-render-react/src/FormRender.tsx b/packages/form-render-react/src/FormRender.tsx index 616c703..f81d439 100644 --- a/packages/form-render-react/src/FormRender.tsx +++ b/packages/form-render-react/src/FormRender.tsx @@ -67,7 +67,9 @@ const FormRender = (formRenderProps: IFormRenderProps, ref?: Ref 'layoutRowGap', 'actions', 'registerActions', - 'readonlyPlaceholder' + 'readonlyPlaceholder', + 'submitText', + 'resetText' ), locale, actionsLoading, diff --git a/packages/form-render-react/src/components/Actions.tsx b/packages/form-render-react/src/components/Actions.tsx index 16e48a9..0265732 100644 --- a/packages/form-render-react/src/components/Actions.tsx +++ b/packages/form-render-react/src/components/Actions.tsx @@ -12,7 +12,7 @@ import type { IRegisterActions, IRegisterActionsFnParams } from '../typings' * 内置操作:提交、重置 */ const BUILTIN_ACTIONS: IRegisterActions = { - [ACTIONS.submit]: ({ loading, locale, disabled }) => ( + [ACTIONS.submit]: ({ loading, locale, disabled, submitText }) => ( ), - [ACTIONS.reset]: ({ handleReset, loading, locale, disabled }) => ( + [ACTIONS.reset]: ({ handleReset, loading, locale, disabled, resetText }) => ( ), } @@ -53,6 +53,8 @@ const Actions: FC = ({ disabled, ...spaceProps }) => { handleSubmit, layoutColumnGap, locale, + submitText, + resetText, } = useFormRenderContext() const isShowActions = utils.isArray(actions) && actions.length > 0 @@ -73,6 +75,8 @@ const Actions: FC = ({ disabled, ...spaceProps }) => { locale, disabled, loading: actionsLoading, + submitText, + resetText, } if (action === ACTIONS.submit) { diff --git a/packages/form-render-react/src/typings/index.d.ts b/packages/form-render-react/src/typings/index.d.ts index ff21a02..796261e 100644 --- a/packages/form-render-react/src/typings/index.d.ts +++ b/packages/form-render-react/src/typings/index.d.ts @@ -35,8 +35,12 @@ export interface IRegisterActionsFnParams { loading: IActionsLoading /** 全局禁用状态,@schema-render/core-react global-status */ disabled?: boolean - /* 语言 */ + /* 语言包 */ locale: T + /** 提交按钮文案 */ + submitText?: string + /** 重置按钮文案 */ + resetText?: string } /** @@ -150,6 +154,14 @@ export type IFormRenderProps = IPartPartial< * 注册操作行为,如果是 submit、reset 将覆盖原有样式 */ registerActions?: IRegisterActions + /** + * 提交按钮文案,优先级大于 locale 语言包 + */ + submitText?: string + /** + * 重置按钮文案,优先级大于 locale 语言包 + */ + resetText?: string /** * 提交事件 * @param value 表单数据 @@ -200,6 +212,8 @@ export type IFormRenderContext = Pick< | 'layoutColumnGap' | 'layoutRowGap' | 'readonlyPlaceholder' + | 'submitText' + | 'resetText' > & { locale: ILocale actionsLoading: IActionsLoading diff --git a/packages/search-react/src/Search.tsx b/packages/search-react/src/Search.tsx index 608ddfc..a3124a1 100644 --- a/packages/search-react/src/Search.tsx +++ b/packages/search-react/src/Search.tsx @@ -15,22 +15,31 @@ import { createActionsResetSchema } from './utils/actions' * 覆盖 submit、reset 操作,添加图标样式 */ const overrideDefaultActions: IRegisterActions = { - submit: ({ loading, locale }) => { + submit: ({ loading, locale, submitText, disabled }) => { return ( ) }, - reset: ({ loading, locale, handleReset }) => { + reset: ({ loading, locale, handleReset, resetText, disabled }) => { return ( - ) },