Skip to content

Commit

Permalink
feat(form): helpMessage Increase function type value (#616)
Browse files Browse the repository at this point in the history
* feat(form): helpMessage

* feat(form): helpMessage
  • Loading branch information
Mikasa33 authored May 18, 2021
1 parent 0e440f0 commit f455fb9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/components/Form/src/components/FormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,14 @@
) : (
label
);
if (!helpMessage || (Array.isArray(helpMessage) && helpMessage.length === 0)) {
const getHelpMessage = isFunction(helpMessage) ? helpMessage(unref(getValues)) : helpMessage;
if (!getHelpMessage || (Array.isArray(getHelpMessage) && getHelpMessage.length === 0)) {
return renderLabel;
}
return (
<span>
{renderLabel}
<BasicHelp placement="top" class="mx-1" text={helpMessage} {...helpComponentProps} />
<BasicHelp placement="top" class="mx-1" text={getHelpMessage} {...helpComponentProps} />
</span>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export interface FormSchema {
// Auxiliary text
subLabel?: string;
// Help text on the right side of the text
helpMessage?: string | string[];
helpMessage?: string | string[] | ((renderCallbackParams: RenderCallbackParams) => string | string[]);
// BaseHelp component props
helpComponentProps?: Partial<HelpComponentProps>;
// Label width, if it is passed, the labelCol and WrapperCol configured by itemProps will be invalid
Expand Down

0 comments on commit f455fb9

Please sign in to comment.