mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 11:58:10 +08:00
Merge pull request #9900 from CheshireJCat/feat-confirmDialog-and-alert-action-support-className
feat: 事件动作confirmDialog和alert支持自定义className Close #9869
This commit is contained in:
commit
6e9ec275fe
@ -154,7 +154,8 @@ export class AlertAction implements RendererAction {
|
||||
) {
|
||||
event.context.env.alert?.(
|
||||
filter(action.dialog?.msg, event.data) ?? action.args?.msg,
|
||||
filter(action.dialog?.title, event.data) ?? action.args?.title
|
||||
filter(action.dialog?.title, event.data) ?? action.args?.title,
|
||||
filter(action.dialog?.className, event.data) ?? ''
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -199,7 +200,8 @@ export class ConfirmAction implements RendererAction {
|
||||
action.args?.confirmBtnLevel,
|
||||
cancelBtnLevel:
|
||||
filter(action.dialog?.cancelBtnLevel, event.data) ||
|
||||
action.args?.cancelBtnLevel
|
||||
action.args?.cancelBtnLevel,
|
||||
className: filter(action.dialog?.className, event.data) || ''
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -27,6 +27,7 @@ export interface AlertProps extends ThemeProps, LocaleProps {
|
||||
}
|
||||
|
||||
interface ConfirmOptions {
|
||||
className?: string;
|
||||
closeOnEsc?: AlertProps['closeOnEsc'];
|
||||
size?: AlertProps['size'];
|
||||
confirmBtnLevel?: AlertProps['confirmBtnLevel'];
|
||||
@ -49,6 +50,7 @@ export interface AlertState {
|
||||
size?: AlertProps['size'];
|
||||
confirmBtnLevel?: AlertProps['confirmBtnLevel'];
|
||||
cancelBtnLevel?: AlertProps['cancelBtnLevel'];
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export class Alert extends React.Component<AlertProps, AlertState> {
|
||||
@ -165,12 +167,13 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
||||
);
|
||||
}
|
||||
|
||||
alert(content: string, title?: string) {
|
||||
alert(content: string, title?: string, className?: string) {
|
||||
this.setState({
|
||||
title,
|
||||
content,
|
||||
show: true,
|
||||
confirm: false
|
||||
confirm: false,
|
||||
className
|
||||
});
|
||||
}
|
||||
|
||||
@ -198,6 +201,10 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
||||
typeof optionsOrCofnrimText === 'string'
|
||||
? false
|
||||
: optionsOrCofnrimText?.closeOnEsc,
|
||||
className:
|
||||
typeof optionsOrCofnrimText === 'string'
|
||||
? ''
|
||||
: optionsOrCofnrimText?.className,
|
||||
confirmBtnLevel:
|
||||
typeof optionsOrCofnrimText === 'string'
|
||||
? 'danger'
|
||||
@ -290,6 +297,7 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
||||
ref={this.modalRef}
|
||||
closeOnEsc={this.state.closeOnEsc}
|
||||
size={this.state.size}
|
||||
className={cx(this.state.className)}
|
||||
>
|
||||
{finalTitle ? (
|
||||
<div className={cx('Modal-header')}>
|
||||
@ -357,12 +365,13 @@ function renderForm(
|
||||
return renderSchemaFn?.(controls, value, callback, scopeRef, theme);
|
||||
}
|
||||
|
||||
export const alert: (content: string, title?: string) => Promise<void> = async (
|
||||
content,
|
||||
title
|
||||
) => {
|
||||
export const alert: (
|
||||
content: string,
|
||||
title?: string,
|
||||
className?: string
|
||||
) => Promise<void> = async (content, title, className) => {
|
||||
const instance = await Alert.getInstance();
|
||||
return instance.alert(content, title);
|
||||
return instance.alert(content, title, className);
|
||||
};
|
||||
export const confirm: (
|
||||
content: string | React.ReactNode,
|
||||
|
Loading…
Reference in New Issue
Block a user