feat: modal method add wrapClassName
parent
41d8d0ec0f
commit
d38ecce22c
|
@ -17,6 +17,7 @@ import type { PanelMode, RangeValue } from '../../vc-picker/interface';
|
||||||
import type { RangePickerSharedProps } from '../../vc-picker/RangePicker';
|
import type { RangePickerSharedProps } from '../../vc-picker/RangePicker';
|
||||||
import devWarning from '../../vc-util/devWarning';
|
import devWarning from '../../vc-util/devWarning';
|
||||||
import { useInjectFormItemContext } from '../../form/FormItemContext';
|
import { useInjectFormItemContext } from '../../form/FormItemContext';
|
||||||
|
import omit from '../../_util/omit';
|
||||||
|
|
||||||
export default function generateRangePicker<DateType, ExtraProps = {}>(
|
export default function generateRangePicker<DateType, ExtraProps = {}>(
|
||||||
generateConfig: GenerateConfig<DateType>,
|
generateConfig: GenerateConfig<DateType>,
|
||||||
|
@ -160,7 +161,9 @@ export default function generateRangePicker<DateType, ExtraProps = {}>(
|
||||||
additionalOverrideProps = {
|
additionalOverrideProps = {
|
||||||
...additionalOverrideProps,
|
...additionalOverrideProps,
|
||||||
...(showTime ? getTimeProps({ format, picker, ...showTime }) : {}),
|
...(showTime ? getTimeProps({ format, picker, ...showTime }) : {}),
|
||||||
...(picker === 'time' ? getTimeProps({ format, ...restProps, picker }) : {}),
|
...(picker === 'time'
|
||||||
|
? getTimeProps({ format, ...omit(restProps, ['disabledTime']), picker })
|
||||||
|
: {}),
|
||||||
};
|
};
|
||||||
const pre = prefixCls.value;
|
const pre = prefixCls.value;
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -31,12 +31,10 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
{ flush: 'post' },
|
{ flush: 'post' },
|
||||||
);
|
);
|
||||||
const style = ref({});
|
|
||||||
const className = ref('');
|
|
||||||
const mergedMotion = computed(() => {
|
const mergedMotion = computed(() => {
|
||||||
const m =
|
const m =
|
||||||
motion.value || defaultMotions.value?.[fixedMode.value] || defaultMotions.value?.other;
|
motion.value || defaultMotions.value?.[fixedMode.value] || defaultMotions.value?.other;
|
||||||
const res = typeof m === 'function' ? m(undefined, style, className) : m;
|
const res = typeof m === 'function' ? m() : m;
|
||||||
return { ...res, appear: props.keyPath.length <= 1 };
|
return { ...res, appear: props.keyPath.length <= 1 };
|
||||||
});
|
});
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -46,12 +44,7 @@ export default defineComponent({
|
||||||
return (
|
return (
|
||||||
<MenuContextProvider mode={fixedMode.value}>
|
<MenuContextProvider mode={fixedMode.value}>
|
||||||
<Transition {...mergedMotion.value}>
|
<Transition {...mergedMotion.value}>
|
||||||
<SubMenuList
|
<SubMenuList v-show={mergedOpen.value} id={props.id}>
|
||||||
v-show={mergedOpen.value}
|
|
||||||
id={props.id}
|
|
||||||
style={style.value}
|
|
||||||
class={className.value}
|
|
||||||
>
|
|
||||||
{slots.default?.()}
|
{slots.default?.()}
|
||||||
</SubMenuList>
|
</SubMenuList>
|
||||||
</Transition>
|
</Transition>
|
||||||
|
|
|
@ -76,7 +76,7 @@ function getMessageInstance(args: MessageArgsProps, callback: (i: NotificationIn
|
||||||
transitionName,
|
transitionName,
|
||||||
hasTransitionName,
|
hasTransitionName,
|
||||||
style: { top: defaultTop }, // 覆盖原来的样式
|
style: { top: defaultTop }, // 覆盖原来的样式
|
||||||
getContainer,
|
getContainer: getContainer || args.getPopupContainer,
|
||||||
maxCount,
|
maxCount,
|
||||||
name: 'message',
|
name: 'message',
|
||||||
},
|
},
|
||||||
|
@ -91,7 +91,7 @@ function getMessageInstance(args: MessageArgsProps, callback: (i: NotificationIn
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
type NoticeType = 'info' | 'success' | 'error' | 'warning' | 'loading';
|
export type NoticeType = 'info' | 'success' | 'error' | 'warning' | 'loading';
|
||||||
|
|
||||||
export interface ThenableArgument {
|
export interface ThenableArgument {
|
||||||
(val: any): void;
|
(val: any): void;
|
||||||
|
@ -115,6 +115,7 @@ export interface MessageArgsProps {
|
||||||
type?: NoticeType;
|
type?: NoticeType;
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
rootPrefixCls?: string;
|
rootPrefixCls?: string;
|
||||||
|
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
icon?: (() => VueNode) | VueNode;
|
icon?: (() => VueNode) | VueNode;
|
||||||
key?: string | number;
|
key?: string | number;
|
||||||
|
|
|
@ -91,6 +91,7 @@ export default defineComponent<ConfirmDialogProps>({
|
||||||
focusTriggerAfterClose,
|
focusTriggerAfterClose,
|
||||||
rootPrefixCls,
|
rootPrefixCls,
|
||||||
bodyStyle,
|
bodyStyle,
|
||||||
|
wrapClassName,
|
||||||
} = props;
|
} = props;
|
||||||
const okType = props.okType || 'primary';
|
const okType = props.okType || 'primary';
|
||||||
const prefixCls = props.prefixCls || 'ant-modal';
|
const prefixCls = props.prefixCls || 'ant-modal';
|
||||||
|
@ -127,7 +128,10 @@ export default defineComponent<ConfirmDialogProps>({
|
||||||
<Dialog
|
<Dialog
|
||||||
prefixCls={prefixCls}
|
prefixCls={prefixCls}
|
||||||
class={classString}
|
class={classString}
|
||||||
wrapClassName={classNames({ [`${contentPrefixCls}-centered`]: !!centered })}
|
wrapClassName={classNames(
|
||||||
|
{ [`${contentPrefixCls}-centered`]: !!centered },
|
||||||
|
wrapClassName,
|
||||||
|
)}
|
||||||
onCancel={e => close({ triggerCancel: true }, e)}
|
onCancel={e => close({ triggerCancel: true }, e)}
|
||||||
visible={visible}
|
visible={visible}
|
||||||
title=""
|
title=""
|
||||||
|
|
|
@ -98,6 +98,7 @@ export interface ModalFuncProps {
|
||||||
okType?: LegacyButtonType;
|
okType?: LegacyButtonType;
|
||||||
cancelText?: string | (() => VueNode) | VueNode;
|
cancelText?: string | (() => VueNode) | VueNode;
|
||||||
icon?: (() => VueNode) | VueNode;
|
icon?: (() => VueNode) | VueNode;
|
||||||
|
wrapClassName?: String;
|
||||||
/* Deprecated */
|
/* Deprecated */
|
||||||
iconType?: string;
|
iconType?: string;
|
||||||
mask?: boolean;
|
mask?: boolean;
|
||||||
|
@ -108,7 +109,7 @@ export interface ModalFuncProps {
|
||||||
maskStyle?: CSSProperties;
|
maskStyle?: CSSProperties;
|
||||||
type?: 'info' | 'success' | 'error' | 'warn' | 'warning' | 'confirm';
|
type?: 'info' | 'success' | 'error' | 'warn' | 'warning' | 'confirm';
|
||||||
keyboard?: boolean;
|
keyboard?: boolean;
|
||||||
getContainer?: string | HTMLElement | getContainerFunc | false;
|
getContainer?: string | HTMLElement | getContainerFunc | false | null;
|
||||||
autoFocusButton?: null | 'ok' | 'cancel';
|
autoFocusButton?: null | 'ok' | 'cancel';
|
||||||
transitionName?: string;
|
transitionName?: string;
|
||||||
maskTransitionName?: string;
|
maskTransitionName?: string;
|
||||||
|
|
|
@ -25,13 +25,24 @@ exports[`renders ./components/modal/demo/button-props.vue correctly 1`] = `
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`renders ./components/modal/demo/confirm.vue correctly 1`] = `
|
exports[`renders ./components/modal/demo/confirm.vue correctly 1`] = `
|
||||||
<div><button class="ant-btn" type="button">
|
<div class="ant-space ant-space-horizontal ant-space-align-center" style="flex-wrap: wrap; margin-bottom: -8px;">
|
||||||
<!----><span>Confirm</span>
|
<div class="ant-space-item" style="margin-right: 8px; padding-bottom: 8px;"><button class="ant-btn" type="button">
|
||||||
</button><button class="ant-btn ant-btn-dashed" type="button">
|
<!----><span>Confirm</span>
|
||||||
<!----><span>Delete</span>
|
</button></div>
|
||||||
</button><button class="ant-btn ant-btn-dashed" type="button">
|
<!---->
|
||||||
<!----><span>With extra props</span>
|
<div class="ant-space-item" style="margin-right: 8px; padding-bottom: 8px;"><button class="ant-btn" type="button">
|
||||||
</button></div>
|
<!----><span>With promise</span>
|
||||||
|
</button></div>
|
||||||
|
<!---->
|
||||||
|
<div class="ant-space-item" style="margin-right: 8px; padding-bottom: 8px;"><button class="ant-btn ant-btn-dashed" type="button">
|
||||||
|
<!----><span>Delete</span>
|
||||||
|
</button></div>
|
||||||
|
<!---->
|
||||||
|
<div class="ant-space-item" style="padding-bottom: 8px;"><button class="ant-btn ant-btn-dashed" type="button">
|
||||||
|
<!----><span>With extra props</span>
|
||||||
|
</button></div>
|
||||||
|
<!---->
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`renders ./components/modal/demo/confirm-promise.vue correctly 1`] = `
|
exports[`renders ./components/modal/demo/confirm-promise.vue correctly 1`] = `
|
||||||
|
@ -63,15 +74,24 @@ exports[`renders ./components/modal/demo/fullscreen.vue correctly 1`] = `
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`renders ./components/modal/demo/info.vue correctly 1`] = `
|
exports[`renders ./components/modal/demo/info.vue correctly 1`] = `
|
||||||
<div><button class="ant-btn" type="button">
|
<div class="ant-space ant-space-horizontal ant-space-align-center" style="flex-wrap: wrap; margin-bottom: -8px;">
|
||||||
<!----><span>Info</span>
|
<div class="ant-space-item" style="margin-right: 8px; padding-bottom: 8px;"><button class="ant-btn" type="button">
|
||||||
</button><button class="ant-btn" type="button">
|
<!----><span>Info</span>
|
||||||
<!----><span>Success</span>
|
</button></div>
|
||||||
</button><button class="ant-btn" type="button">
|
<!---->
|
||||||
<!----><span>Error</span>
|
<div class="ant-space-item" style="margin-right: 8px; padding-bottom: 8px;"><button class="ant-btn" type="button">
|
||||||
</button><button class="ant-btn" type="button">
|
<!----><span>Success</span>
|
||||||
<!----><span>Warning</span>
|
</button></div>
|
||||||
</button></div>
|
<!---->
|
||||||
|
<div class="ant-space-item" style="margin-right: 8px; padding-bottom: 8px;"><button class="ant-btn" type="button">
|
||||||
|
<!----><span>Error</span>
|
||||||
|
</button></div>
|
||||||
|
<!---->
|
||||||
|
<div class="ant-space-item" style="padding-bottom: 8px;"><button class="ant-btn" type="button">
|
||||||
|
<!----><span>Warning</span>
|
||||||
|
</button></div>
|
||||||
|
<!---->
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`renders ./components/modal/demo/locale.vue correctly 1`] = `
|
exports[`renders ./components/modal/demo/locale.vue correctly 1`] = `
|
||||||
|
|
|
@ -12,8 +12,11 @@ title:
|
||||||
|
|
||||||
## en-US
|
## en-US
|
||||||
|
|
||||||
Asynchronously close a modal dialog when a user clicked OK button, for example,
|
|
||||||
you can use this pattern when you submit a form.
|
Asynchronously close a modal dialog when the OK button is pressed.
|
||||||
|
|
||||||
|
For example, you can use this pattern when you submit a form.
|
||||||
|
|
||||||
|
|
||||||
</docs>
|
</docs>
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,12 @@ To use `confirm()` to show a confirmation modal dialog.
|
||||||
</docs>
|
</docs>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<a-space wrap>
|
||||||
<a-button @click="showConfirm">Confirm</a-button>
|
<a-button @click="showConfirm">Confirm</a-button>
|
||||||
|
<a-button @click="showPromiseConfirm">With promise</a-button>
|
||||||
<a-button type="dashed" @click="showDeleteConfirm">Delete</a-button>
|
<a-button type="dashed" @click="showDeleteConfirm">Delete</a-button>
|
||||||
<a-button type="dashed" @click="showPropsConfirm">With extra props</a-button>
|
<a-button type="dashed" @click="showPropsConfirm">With extra props</a-button>
|
||||||
</div>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||||
|
@ -78,10 +79,29 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function showPromiseConfirm() {
|
||||||
|
Modal.confirm({
|
||||||
|
title: 'Do you want to delete these items?',
|
||||||
|
icon: createVNode(ExclamationCircleOutlined),
|
||||||
|
content: 'When clicked the OK button, this dialog will be closed after 1 second',
|
||||||
|
async onOk() {
|
||||||
|
try {
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
return console.log('Oops errors!');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onCancel() {},
|
||||||
|
});
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
showConfirm,
|
showConfirm,
|
||||||
showDeleteConfirm,
|
showDeleteConfirm,
|
||||||
showPropsConfirm,
|
showPropsConfirm,
|
||||||
|
showPromiseConfirm,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,12 +17,12 @@ In the various types of information modal dialog, only one button to close dialo
|
||||||
</docs>
|
</docs>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<a-space wrap>
|
||||||
<a-button @click="info">Info</a-button>
|
<a-button @click="info">Info</a-button>
|
||||||
<a-button @click="success">Success</a-button>
|
<a-button @click="success">Success</a-button>
|
||||||
<a-button @click="error">Error</a-button>
|
<a-button @click="error">Error</a-button>
|
||||||
<a-button @click="warning">Warning</a-button>
|
<a-button @click="warning">Warning</a-button>
|
||||||
</div>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Modal } from 'ant-design-vue';
|
import { Modal } from 'ant-design-vue';
|
||||||
|
|
|
@ -82,6 +82,7 @@ The items listed above are all functions, expecting a settings object as paramet
|
||||||
| cancelButtonProps | The cancel button props | [ButtonProps](/components/button) | - | |
|
| cancelButtonProps | The cancel button props | [ButtonProps](/components/button) | - | |
|
||||||
| title | Title | string\|vNode \|function(h) | - | |
|
| title | Title | string\|vNode \|function(h) | - | |
|
||||||
| width | Width of the modal dialog | string\|number | 416 | |
|
| width | Width of the modal dialog | string\|number | 416 | |
|
||||||
|
| wrapClassName | The class name of the container of the modal dialog | string | - | 3.0 |
|
||||||
| zIndex | The `z-index` of the Modal | Number | 1000 | |
|
| zIndex | The `z-index` of the Modal | Number | 1000 | |
|
||||||
| onCancel | Specify a function that will be called when the user clicks the Cancel button. The parameter of this function is a function whose execution should include closing the dialog. You can also just return a promise and when the promise is resolved, the modal dialog will also be closed | function | - | |
|
| onCancel | Specify a function that will be called when the user clicks the Cancel button. The parameter of this function is a function whose execution should include closing the dialog. You can also just return a promise and when the promise is resolved, the modal dialog will also be closed | function | - | |
|
||||||
| onOk | Specify a function that will be called when the user clicks the OK button. The parameter of this function is a function whose execution should include closing the dialog. You can also just return a promise and when the promise is resolved, the modal dialog will also be closed | function | - | |
|
| onOk | Specify a function that will be called when the user clicks the OK button. The parameter of this function is a function whose execution should include closing the dialog. You can also just return a promise and when the promise is resolved, the modal dialog will also be closed | function | - | |
|
||||||
|
|
|
@ -86,6 +86,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/3StSdUlSH/Modal.svg
|
||||||
| cancelButtonProps | cancel 按钮 props | [ButtonProps](/components/button) | - | |
|
| cancelButtonProps | cancel 按钮 props | [ButtonProps](/components/button) | - | |
|
||||||
| title | 标题 | string\|vNode \|function(h) | 无 | |
|
| title | 标题 | string\|vNode \|function(h) | 无 | |
|
||||||
| width | 宽度 | string\|number | 416 | |
|
| width | 宽度 | string\|number | 416 | |
|
||||||
|
| wrapClassName | 对话框外层容器的类名 | string | - | 3.0 |
|
||||||
| zIndex | 设置 Modal 的 `z-index` | Number | 1000 | |
|
| zIndex | 设置 Modal 的 `z-index` | Number | 1000 | |
|
||||||
| onCancel | 取消回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 | |
|
| onCancel | 取消回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 | |
|
||||||
| onOk | 点击确定回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 | |
|
| onOk | 点击确定回调,参数为关闭函数,返回 promise 时 resolve 后自动关闭 | function | 无 | |
|
||||||
|
|
|
@ -28,7 +28,7 @@ export type SharedTimeProps<DateType> = {
|
||||||
/** @deprecated Please use `disabledTime` instead. */
|
/** @deprecated Please use `disabledTime` instead. */
|
||||||
disabledSeconds?: DisabledTimes['disabledSeconds'];
|
disabledSeconds?: DisabledTimes['disabledSeconds'];
|
||||||
|
|
||||||
// disabledTime?: (date: DateType, type?: RangeType) => DisabledTimes;
|
disabledTime?: (date: DateType) => DisabledTimes;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TimePanelProps<DateType> = {
|
export type TimePanelProps<DateType> = {
|
||||||
|
|
Loading…
Reference in New Issue