index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import _extends from 'babel-runtime/helpers/extends';
  2. import Modal, { destroyFns } from './Modal';
  3. import modalConfirm from './confirm';
  4. import Icon from '../icon';
  5. import Base from '../base';
  6. // export { ActionButtonProps } from './ActionButton'
  7. // export { ModalProps, ModalFuncProps } from './Modal'
  8. var info = function info(props) {
  9. var config = _extends({
  10. type: 'info',
  11. icon: function icon(h) {
  12. return h(Icon, {
  13. attrs: { type: 'info-circle' }
  14. });
  15. },
  16. okCancel: false
  17. }, props);
  18. return modalConfirm(config);
  19. };
  20. var success = function success(props) {
  21. var config = _extends({
  22. type: 'success',
  23. icon: function icon(h) {
  24. return h(Icon, {
  25. attrs: { type: 'check-circle' }
  26. });
  27. },
  28. okCancel: false
  29. }, props);
  30. return modalConfirm(config);
  31. };
  32. var error = function error(props) {
  33. var config = _extends({
  34. type: 'error',
  35. icon: function icon(h) {
  36. return h(Icon, {
  37. attrs: { type: 'close-circle' }
  38. });
  39. },
  40. okCancel: false
  41. }, props);
  42. return modalConfirm(config);
  43. };
  44. var warning = function warning(props) {
  45. var config = _extends({
  46. type: 'warning',
  47. icon: function icon(h) {
  48. return h(Icon, {
  49. attrs: { type: 'exclamation-circle' }
  50. });
  51. },
  52. okCancel: false
  53. }, props);
  54. return modalConfirm(config);
  55. };
  56. var warn = warning;
  57. var confirm = function confirmFn(props) {
  58. var config = _extends({
  59. type: 'confirm',
  60. okCancel: true
  61. }, props);
  62. return modalConfirm(config);
  63. };
  64. Modal.info = info;
  65. Modal.success = success;
  66. Modal.error = error;
  67. Modal.warning = warning;
  68. Modal.warn = warn;
  69. Modal.confirm = confirm;
  70. Modal.destroyAll = function destroyAllFn() {
  71. while (destroyFns.length) {
  72. var close = destroyFns.pop();
  73. if (close) {
  74. close();
  75. }
  76. }
  77. };
  78. /* istanbul ignore next */
  79. Modal.install = function (Vue) {
  80. Vue.use(Base);
  81. Vue.component(Modal.name, Modal);
  82. };
  83. export default Modal;