2021-06-26 01:35:40 +00:00
|
|
|
import type { App, Plugin } from 'vue';
|
|
|
|
import type { ModalFunc, ModalFuncProps } from './Modal';
|
|
|
|
import Modal, { destroyFns } from './Modal';
|
2022-01-06 08:08:53 +00:00
|
|
|
import confirm, { withWarn, withInfo, withSuccess, withError, withConfirm } from './confirm';
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2022-03-12 01:56:32 +00:00
|
|
|
export type { ActionButtonProps } from '../_util/ActionButton';
|
2021-09-25 08:51:32 +00:00
|
|
|
export type { ModalProps, ModalFuncProps } from './Modal';
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2022-01-06 08:08:53 +00:00
|
|
|
function modalWarn(props: ModalFuncProps) {
|
|
|
|
return confirm(withWarn(props));
|
|
|
|
}
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2022-01-06 08:08:53 +00:00
|
|
|
Modal.info = function infoFn(props: ModalFuncProps) {
|
|
|
|
return confirm(withInfo(props));
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2022-01-06 08:08:53 +00:00
|
|
|
Modal.success = function successFn(props: ModalFuncProps) {
|
|
|
|
return confirm(withSuccess(props));
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2022-01-06 08:08:53 +00:00
|
|
|
Modal.error = function errorFn(props: ModalFuncProps) {
|
|
|
|
return confirm(withError(props));
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2022-01-06 08:08:53 +00:00
|
|
|
Modal.warning = modalWarn;
|
|
|
|
|
|
|
|
Modal.warn = modalWarn;
|
|
|
|
|
|
|
|
Modal.confirm = function confirmFn(props: ModalFuncProps) {
|
|
|
|
return confirm(withConfirm(props));
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-03-06 11:14:41 +00:00
|
|
|
|
2020-03-07 11:45:13 +00:00
|
|
|
Modal.destroyAll = function destroyAllFn() {
|
2019-04-17 02:21:28 +00:00
|
|
|
while (destroyFns.length) {
|
|
|
|
const close = destroyFns.pop();
|
|
|
|
if (close) {
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-09-19 05:21:57 +00:00
|
|
|
/* istanbul ignore next */
|
2021-06-23 15:08:16 +00:00
|
|
|
Modal.install = function (app: App) {
|
2020-06-15 15:47:49 +00:00
|
|
|
app.component(Modal.name, Modal);
|
2020-10-13 11:14:56 +00:00
|
|
|
return app;
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-09-19 05:21:57 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
export default Modal as typeof Modal &
|
|
|
|
Plugin & {
|
|
|
|
readonly info: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly success: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly error: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly warn: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly warning: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly confirm: ModalFunc;
|
2020-10-21 07:32:04 +00:00
|
|
|
|
2020-11-01 07:03:33 +00:00
|
|
|
readonly destroyAll: () => void;
|
|
|
|
};
|