mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
f0c105d262
* feat: remove the hardcode of `use client` * chore: update `@ant-design/tools` * test: update * fix: incorrect dictionary * chore: update dep * ci: check use client * chore: update ci * fix: should be LIB_DIR * ci: should only run in dist * chore: update check tsx files
73 lines
1.7 KiB
TypeScript
73 lines
1.7 KiB
TypeScript
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';
|
|
|
|
function modalWarn(props: ModalFuncProps) {
|
|
return confirm(withWarn(props));
|
|
}
|
|
|
|
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;
|
|
|
|
Modal.info = function infoFn(props: ModalFuncProps) {
|
|
return confirm(withInfo(props));
|
|
};
|
|
|
|
Modal.success = function successFn(props: ModalFuncProps) {
|
|
return confirm(withSuccess(props));
|
|
};
|
|
|
|
Modal.error = function errorFn(props: ModalFuncProps) {
|
|
return confirm(withError(props));
|
|
};
|
|
|
|
Modal.warning = modalWarn;
|
|
|
|
Modal.warn = modalWarn;
|
|
|
|
Modal.confirm = function confirmFn(props: ModalFuncProps) {
|
|
return confirm(withConfirm(props));
|
|
};
|
|
|
|
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;
|