ant-design/components/modal/index.tsx
二货机器人 d02c486052
feat: Modal support hooks (#20949)
* init hooks

* portal it in

* children with 2 context demo

* Remove config since not more second demo

* Quit with same Component for logic reuse

* add rest functions

* use localeReceiver

* use localeReceiver

* update test case

* fix lint

* update docs

* update demo title
2020-02-03 13:00:35 +08:00

51 lines
1.1 KiB
TypeScript

import OriginModal, { ModalFuncProps, destroyFns } from './Modal';
import confirm, {
withWarn,
withInfo,
withSuccess,
withError,
withConfirm,
ModalStaticFunctions,
} from './confirm';
export { ActionButtonProps } from './ActionButton';
export { ModalProps, ModalFuncProps } from './Modal';
function modalWarn(props: ModalFuncProps) {
return confirm(withWarn(props));
}
type Modal = typeof OriginModal & ModalStaticFunctions;
const Modal = OriginModal as Modal;
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();
}
}
};
export default Modal;