ant-design/components/modal/index.tsx

75 lines
1.7 KiB
TypeScript
Raw Normal View History

feat: prepend use-client directive for with Next.js App Router (#43573) * fix: prepend use-client directive for with Next.js App Router * Update components/affix/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/badge/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/divider/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/cascader/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/list/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/mentions/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/qrcode/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/select/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/spin/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/steps/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/time-picker/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/transfer/index.tsx Signed-off-by: lijianan <574980606@qq.com> * Update components/tree-select/index.tsx Signed-off-by: lijianan <574980606@qq.com> --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: MadCcc <1075746765@qq.com>
2023-07-15 12:57:03 +08:00
'use client';
import type { ModalStaticFunctions } from './confirm';
import confirm, {
modalGlobalConfig,
withConfirm,
withError,
withInfo,
withSuccess,
withWarn,
} from './confirm';
import destroyFns from './destroyFns';
import type { ModalFuncProps } from './interface';
import OriginModal from './Modal';
import PurePanel from './PurePanel';
import useModal from './useModal';
export type { ModalFuncProps, ModalLocale, ModalProps } from './interface';
2019-08-05 18:38:10 +08:00
function modalWarn(props: ModalFuncProps) {
return confirm(withWarn(props));
2019-08-05 18:38:10 +08:00
}
type ModalType = typeof OriginModal &
ModalStaticFunctions & {
useModal: typeof useModal;
destroyAll: () => void;
config: typeof modalGlobalConfig;
/** @private Internal Component. Do not use in your production. */
_InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
};
const Modal = OriginModal as ModalType;
Modal.useModal = useModal;
2019-08-11 19:38:08 +08:00
Modal.info = function infoFn(props: ModalFuncProps) {
return confirm(withInfo(props));
2015-09-07 11:48:57 +08:00
};
2019-08-11 19:38:08 +08:00
Modal.success = function successFn(props: ModalFuncProps) {
return confirm(withSuccess(props));
2015-09-07 11:48:57 +08:00
};
2019-08-11 19:38:08 +08:00
Modal.error = function errorFn(props: ModalFuncProps) {
return confirm(withError(props));
2015-09-07 11:48:57 +08:00
};
2019-08-05 18:38:10 +08:00
Modal.warning = modalWarn;
Modal.warn = modalWarn;
2016-04-11 14:59:37 +08:00
2019-08-11 19:38:08 +08:00
Modal.confirm = function confirmFn(props: ModalFuncProps) {
return confirm(withConfirm(props));
2015-09-07 11:48:57 +08:00
};
2019-08-11 19:38:08 +08:00
Modal.destroyAll = function destroyAllFn() {
while (destroyFns.length) {
const close = destroyFns.pop();
if (close) {
close();
}
}
};
Modal.config = modalGlobalConfig;
Modal._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
if (process.env.NODE_ENV !== 'production') {
Modal.displayName = 'Modal';
}
export default Modal;