acud 0.0.64 → 0.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/acud.css +131 -39
  2. package/dist/acud.css.map +1 -1
  3. package/dist/acud.js +799 -212
  4. package/dist/acud.js.map +1 -1
  5. package/dist/acud.min.css +1 -1
  6. package/dist/acud.min.css.map +1 -1
  7. package/dist/acud.min.js +11 -7
  8. package/dist/acud.min.js.map +1 -1
  9. package/es/breadcrumb/BreadcrumbItem.d.ts +1 -1
  10. package/es/breadcrumb/BreadcrumbItem.js +16 -4
  11. package/es/dialog-box/style/index.css +4 -4
  12. package/es/dropdown/dropdown-button.js +8 -4
  13. package/es/dropdown/style/index.css +2 -1
  14. package/es/dropdown/style/index.less +2 -1
  15. package/es/modal/DialogBox.d.ts +46 -0
  16. package/es/modal/DialogBox.js +152 -0
  17. package/es/modal/Modal.d.ts +5 -2
  18. package/es/modal/Modal.js +6 -4
  19. package/es/modal/dialog.d.ts +17 -0
  20. package/es/modal/dialog.js +123 -0
  21. package/es/modal/index.d.ts +11 -2
  22. package/es/modal/index.js +10 -1
  23. package/es/modal/style/index.css +79 -13
  24. package/es/modal/style/index.less +93 -6
  25. package/es/modal/style/mixin.less +4 -4
  26. package/es/progress/style/common.less +5 -3
  27. package/es/progress/style/index.css +2 -1
  28. package/es/radio/index.d.ts +3 -0
  29. package/es/style/themes/dark/components/modal.less +14 -9
  30. package/es/style/themes/default/components/modal.less +15 -15
  31. package/es/tabs/src/TabNavList/index.js +2 -2
  32. package/es/tabs/style/index.css +0 -1
  33. package/es/tabs/style/index.less +0 -1
  34. package/es/time-picker/style/index.css +1 -0
  35. package/es/time-picker/style/index.less +1 -0
  36. package/es/transfer/{dataSource.d.ts → DataSource.d.ts} +1 -1
  37. package/es/transfer/{dataSource.js → DataSource.js} +37 -6
  38. package/{lib/transfer/sourceList.d.ts → es/transfer/SourceList.d.ts} +2 -2
  39. package/es/transfer/{sourceList.js → SourceList.js} +0 -0
  40. package/es/transfer/{target.d.ts → Target.d.ts} +1 -1
  41. package/es/transfer/{target.js → Target.js} +60 -4
  42. package/{lib/transfer/targetList.d.ts → es/transfer/TargetList.d.ts} +2 -2
  43. package/es/transfer/{targetList.js → TargetList.js} +0 -0
  44. package/es/transfer/index.d.ts +3 -0
  45. package/es/transfer/index.js +9 -4
  46. package/es/transfer/style/css.js +3 -1
  47. package/es/transfer/style/index.css +25 -5
  48. package/es/transfer/style/index.d.ts +1 -0
  49. package/es/transfer/style/index.js +3 -1
  50. package/es/transfer/style/index.less +30 -5
  51. package/es/upload/UploadList/ListItem.js +7 -2
  52. package/es/upload/UploadList/index.js +4 -7
  53. package/es/upload/style/index.css +17 -13
  54. package/es/upload/style/index.less +25 -20
  55. package/es/upload/utils.js +1 -1
  56. package/lib/breadcrumb/BreadcrumbItem.d.ts +1 -1
  57. package/lib/breadcrumb/BreadcrumbItem.js +21 -8
  58. package/lib/dialog-box/style/index.css +4 -4
  59. package/lib/dropdown/dropdown-button.js +8 -4
  60. package/lib/dropdown/style/index.css +2 -1
  61. package/lib/dropdown/style/index.less +2 -1
  62. package/lib/modal/DialogBox.d.ts +46 -0
  63. package/lib/modal/DialogBox.js +179 -0
  64. package/lib/modal/Modal.d.ts +5 -2
  65. package/lib/modal/Modal.js +6 -4
  66. package/lib/modal/dialog.d.ts +17 -0
  67. package/lib/modal/dialog.js +145 -0
  68. package/lib/modal/index.d.ts +11 -2
  69. package/lib/modal/index.js +13 -1
  70. package/lib/modal/style/index.css +79 -13
  71. package/lib/modal/style/index.less +93 -6
  72. package/lib/modal/style/mixin.less +4 -4
  73. package/lib/progress/style/common.less +5 -3
  74. package/lib/progress/style/index.css +2 -1
  75. package/lib/radio/index.d.ts +3 -0
  76. package/lib/style/themes/dark/components/modal.less +14 -9
  77. package/lib/style/themes/default/components/modal.less +15 -15
  78. package/lib/tabs/src/TabNavList/index.js +2 -2
  79. package/lib/tabs/style/index.css +0 -1
  80. package/lib/tabs/style/index.less +0 -1
  81. package/lib/time-picker/style/index.css +1 -0
  82. package/lib/time-picker/style/index.less +1 -0
  83. package/lib/transfer/{dataSource.d.ts → DataSource.d.ts} +1 -1
  84. package/lib/transfer/{dataSource.js → DataSource.js} +38 -6
  85. package/{es/transfer/sourceList.d.ts → lib/transfer/SourceList.d.ts} +2 -2
  86. package/lib/transfer/{sourceList.js → SourceList.js} +0 -0
  87. package/lib/transfer/{target.d.ts → Target.d.ts} +1 -1
  88. package/lib/transfer/{target.js → Target.js} +63 -5
  89. package/{es/transfer/targetList.d.ts → lib/transfer/TargetList.d.ts} +2 -2
  90. package/lib/transfer/{targetList.js → TargetList.js} +0 -0
  91. package/lib/transfer/index.d.ts +3 -0
  92. package/lib/transfer/index.js +11 -7
  93. package/lib/transfer/style/css.js +3 -1
  94. package/lib/transfer/style/index.css +25 -5
  95. package/lib/transfer/style/index.d.ts +1 -0
  96. package/lib/transfer/style/index.js +3 -1
  97. package/lib/transfer/style/index.less +30 -5
  98. package/lib/upload/UploadList/ListItem.js +7 -2
  99. package/lib/upload/UploadList/index.js +4 -7
  100. package/lib/upload/style/index.css +17 -13
  101. package/lib/upload/style/index.less +25 -20
  102. package/lib/upload/utils.js +1 -1
  103. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import { BaseDropdownProps } from '../dropdown/dropdown';
3
3
  export interface BreadcrumbItemProps {
4
4
  prefixCls?: string;
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
3
 
3
4
  var __rest = this && this.__rest || function (s, e) {
4
5
  var t = {};
@@ -13,8 +14,8 @@ var __rest = this && this.__rest || function (s, e) {
13
14
  return t;
14
15
  };
15
16
 
16
- import * as React from 'react';
17
- import { OutlinedDown } from 'acud-icon';
17
+ import React, { useCallback, useState } from 'react';
18
+ import { OutlinedDown, OutlinedUp } from 'acud-icon';
18
19
  import DropDown from '../dropdown/dropdown';
19
20
  import { ConfigContext } from '../config-provider';
20
21
 
@@ -27,21 +28,32 @@ var BreadcrumbItem = function BreadcrumbItem(_a) {
27
28
  dropdownProps = _a.dropdownProps,
28
29
  restProps = __rest(_a, ["prefixCls", "separator", "children", "overlay", "dropdownProps"]);
29
30
 
31
+ var _useState = useState(false),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ visible = _useState2[0],
34
+ setVisible = _useState2[1];
35
+
30
36
  var _React$useContext = React.useContext(ConfigContext),
31
37
  getPrefixCls = _React$useContext.getPrefixCls;
32
38
 
33
39
  var prefixCls = getPrefixCls('breadcrumb', customizePrefixCls);
40
+ var handleVisibleChange = useCallback(function (visible) {
41
+ setVisible(visible);
42
+ }, []);
34
43
  /** If overlay is have Wrap a DropDown */
35
44
 
36
45
  var renderBreadcrumbNode = function renderBreadcrumbNode(breadcrumbItem) {
37
46
  if (overlay) {
38
47
  return /*#__PURE__*/React.createElement(DropDown, _extends({
39
48
  overlay: overlay,
49
+ visible: visible,
40
50
  placement: "bottomCenter",
41
51
  overlayClassName: "".concat(prefixCls, "-dropdown")
42
- }, dropdownProps), /*#__PURE__*/React.createElement("span", {
52
+ }, dropdownProps, {
53
+ onVisibleChange: handleVisibleChange
54
+ }), /*#__PURE__*/React.createElement("span", {
43
55
  className: "".concat(prefixCls, "-overlay-link")
44
- }, breadcrumbItem, /*#__PURE__*/React.createElement(OutlinedDown, null)));
56
+ }, breadcrumbItem, visible ? /*#__PURE__*/React.createElement(OutlinedUp, null) : /*#__PURE__*/React.createElement(OutlinedDown, null)));
45
57
  }
46
58
 
47
59
  return breadcrumbItem;
@@ -58,19 +58,19 @@
58
58
  }
59
59
  .acud-dialogbox-sm {
60
60
  width: 520px;
61
- max-height: 240px;
61
+ max-height: 560px;
62
62
  }
63
63
  .acud-dialogbox-md {
64
64
  width: 800px;
65
- max-height: 400px;
65
+ max-height: 560px;
66
66
  }
67
67
  .acud-dialogbox-lg {
68
68
  width: 1120px;
69
- max-height: 480px;
69
+ max-height: 560px;
70
70
  }
71
71
  .acud-dialogbox-xl {
72
72
  width: 1200px;
73
- max-height: 480px;
73
+ max-height: 560px;
74
74
  }
75
75
  .acud-dialogbox-content {
76
76
  position: relative;
@@ -35,8 +35,10 @@ var DropdownButton = function DropdownButton(props) {
35
35
  trigger = props.trigger,
36
36
  visible = props.visible,
37
37
  onVisibleChange = props.onVisibleChange,
38
- onClick = props.onClick,
39
- restProps = __rest(props, ["children", "overlay", "disabled", "trigger", "visible", "onVisibleChange", "onClick"]); // 菜单可见,需要将ICON旋转
38
+ overlayClassName = props.overlayClassName,
39
+ overlayStyle = props.overlayStyle,
40
+ getPopupContainer = props.getPopupContainer,
41
+ restProps = __rest(props, ["children", "overlay", "disabled", "trigger", "visible", "onVisibleChange", "overlayClassName", "overlayStyle", "getPopupContainer"]); // 菜单可见,需要将ICON旋转
40
42
 
41
43
 
42
44
  var _useState = useState(!!visible),
@@ -53,13 +55,15 @@ var DropdownButton = function DropdownButton(props) {
53
55
  }, []);
54
56
  var arrowCls = classNames((_classNames = {}, _defineProperty(_classNames, 'acud-btn-group-expand', popupVisible), _defineProperty(_classNames, 'acud-btn-group-border-left', restProps.type === 'primary'), _classNames));
55
57
  return /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, _extends({
56
- disabled: disabled,
57
- onClick: onClick
58
+ disabled: disabled
58
59
  }, restProps), children), /*#__PURE__*/React.createElement(Dropdown, {
59
60
  disabled: disabled,
60
61
  placement: "bottomRight",
61
62
  trigger: trigger,
62
63
  overlay: overlay,
64
+ overlayClassName: overlayClassName,
65
+ overlayStyle: overlayStyle,
66
+ getPopupContainer: getPopupContainer,
63
67
  visible: popupVisible,
64
68
  onVisibleChange: handleVisibleChange
65
69
  }, /*#__PURE__*/React.createElement(Button, _extends({
@@ -93,9 +93,10 @@
93
93
  margin-top: -8px;
94
94
  font-size: 12px;
95
95
  line-height: 16px;
96
+ transition: transform 0.48s;
96
97
  }
97
98
  .acud-dropdown-trigger-arrow-expand {
98
- transform: rotate(-180deg);
99
+ transform: rotate(180deg);
99
100
  }
100
101
  .acud-dropdown-trigger-arrow > svg {
101
102
  width: 16px;
@@ -72,9 +72,10 @@
72
72
  margin-top: -2 * @P;
73
73
  font-size: @T2;
74
74
  line-height: 4 * @P;
75
+ transition: transform .48s;
75
76
 
76
77
  &-expand {
77
- transform: rotate(-180deg);
78
+ transform: rotate(180deg);
78
79
  }
79
80
 
80
81
  & > svg {
@@ -0,0 +1,46 @@
1
+ import * as React from 'react';
2
+ export interface ModalFuncProps {
3
+ /** 对话框标题 */
4
+ title?: string;
5
+ /** 对话框内容 */
6
+ content?: React.ReactNode;
7
+ /** 点击确定回调 */
8
+ onOk?: (e: React.MouseEvent<HTMLElement>) => (void | Promise<any>);
9
+ /** 点击模态框右上角叉、取消按钮、Props.maskClosable 值为 true 时的遮罩层或键盘按下 Esc 时的回调 */
10
+ onCancel?: (e: React.MouseEvent<HTMLElement>) => void;
11
+ afterClose?: () => void;
12
+ /** 弹框宽度 */
13
+ width?: number;
14
+ /** 弹框高度 */
15
+ height?: number;
16
+ /** 确认按钮文字 */
17
+ okText?: string;
18
+ /** 取消按钮文字 */
19
+ cancelText?: string;
20
+ /** 点击蒙层是否允许关闭 */
21
+ maskClosable?: boolean;
22
+ /** 是否强制渲染 DialogBox */
23
+ forceRender?: boolean;
24
+ /** 关闭时是否销毁 DialogBox 里的子元素 */
25
+ destroyOnClose?: boolean;
26
+ style?: React.CSSProperties;
27
+ className?: string;
28
+ /** 指定DialogBox挂载的html节点 */
29
+ getContainer?: string | HTMLElement | (() => HTMLElement) | false | null;
30
+ /** 设置 DialogBox 的 z-index */
31
+ zIndex?: number;
32
+ /** 是否支持键盘 esc 关闭 */
33
+ keyboard?: boolean;
34
+ /** 自定义关闭图标 */
35
+ closeIcon?: React.ReactNode;
36
+ }
37
+ export interface DialogBoxProps extends ModalFuncProps {
38
+ /** 是否有取消按钮 */
39
+ cancelBtn?: boolean;
40
+ onClose?: (...args: any[]) => void;
41
+ visible?: boolean;
42
+ type: 'confirm' | 'success' | 'info' | 'error' | 'warning';
43
+ confirmLoading?: boolean;
44
+ }
45
+ declare const DialogBox: React.FC<DialogBoxProps>;
46
+ export default DialogBox;
@@ -0,0 +1,152 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+
4
+ var __rest = this && this.__rest || function (s, e) {
5
+ var t = {};
6
+
7
+ for (var p in s) {
8
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
9
+ }
10
+
11
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
12
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
13
+ }
14
+ return t;
15
+ };
16
+
17
+ import * as React from 'react';
18
+ import FilledError from "acud-icon/es/icons/FilledError";
19
+ import OutlinedClose from "acud-icon/es/icons/OutlinedClose";
20
+ import FilledSuccess from "acud-icon/es/icons/FilledSuccess";
21
+ import FilledWarn from "acud-icon/es/icons/FilledWarn";
22
+ import FilledInfo from "acud-icon/es/icons/FilledInfo";
23
+ import classNames from 'classnames';
24
+ import { ConfigContext } from '../config-provider';
25
+ import Button from '../button';
26
+ import Modal from './Modal';
27
+ var DialogType = {
28
+ success: {
29
+ className: 'sucess',
30
+ icon: /*#__PURE__*/React.createElement(FilledSuccess, {
31
+ color: "@S6"
32
+ })
33
+ },
34
+ warning: {
35
+ className: 'warning',
36
+ icon: /*#__PURE__*/React.createElement(FilledWarn, {
37
+ color: "@W6"
38
+ })
39
+ },
40
+ confirm: {
41
+ className: 'confirm',
42
+ icon: /*#__PURE__*/React.createElement(FilledWarn, {
43
+ color: "@W6"
44
+ })
45
+ },
46
+ info: {
47
+ className: 'info',
48
+ icon: /*#__PURE__*/React.createElement(FilledInfo, {
49
+ color: "@B6"
50
+ })
51
+ },
52
+ error: {
53
+ className: 'error',
54
+ icon: /*#__PURE__*/React.createElement(FilledError, {
55
+ color: "@E6"
56
+ })
57
+ }
58
+ };
59
+
60
+ var DialogBox = function DialogBox(props) {
61
+ var _React$useContext = React.useContext(ConfigContext),
62
+ getPopupContainer = _React$useContext.getPopupContainer,
63
+ getPrefixCls = _React$useContext.getPrefixCls;
64
+
65
+ var prefixCls = getPrefixCls('modal-dialogbox');
66
+ var closeIconToRender = /*#__PURE__*/React.createElement("span", {
67
+ className: "".concat(prefixCls, "-close-x")
68
+ }, /*#__PURE__*/React.createElement(OutlinedClose, {
69
+ className: "".concat(prefixCls, "-close-icon")
70
+ }));
71
+
72
+ var visible = props.visible,
73
+ className = props.className,
74
+ title = props.title,
75
+ content = props.content,
76
+ type = props.type,
77
+ cancelBtn = props.cancelBtn,
78
+ okText = props.okText,
79
+ confirmLoading = props.confirmLoading,
80
+ onOk = props.onOk,
81
+ onClose = props.onClose,
82
+ restProps = __rest(props, ["visible", "className", "title", "content", "type", "cancelBtn", "okText", "confirmLoading", "onOk", "onClose"]);
83
+
84
+ var _React$useState = React.useState(false),
85
+ _React$useState2 = _slicedToArray(_React$useState, 2),
86
+ loading = _React$useState2[0],
87
+ toggleLoading = _React$useState2[1];
88
+
89
+ var okBtnLoading = React.useMemo(function () {
90
+ if (typeof confirmLoading === 'boolean') {
91
+ return confirmLoading;
92
+ }
93
+
94
+ return loading;
95
+ }, [confirmLoading, loading]);
96
+ var handleOk = React.useCallback(function (e) {
97
+ var okResult = onOk === null || onOk === void 0 ? void 0 : onOk(e);
98
+
99
+ if (okResult && typeof okResult.then === 'function') {
100
+ toggleLoading(true);
101
+ okResult.then(function () {
102
+ console.log('then: close');
103
+ toggleLoading(false);
104
+ onClose === null || onClose === void 0 ? void 0 : onClose.apply(void 0, arguments);
105
+ }, function (e) {
106
+ console.error(e);
107
+ toggleLoading(false);
108
+ });
109
+ } else {
110
+ onClose === null || onClose === void 0 ? void 0 : onClose(e);
111
+ }
112
+ }, [onOk, onClose]);
113
+ var handleCancel = React.useCallback(function () {
114
+ onClose === null || onClose === void 0 ? void 0 : onClose({
115
+ triggerCancel: true
116
+ });
117
+ }, [onClose]);
118
+ var titleNode = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
119
+ className: "".concat(prefixCls, "-icon")
120
+ }, DialogType[type].icon), /*#__PURE__*/React.createElement("div", {
121
+ className: "".concat(prefixCls, "-title")
122
+ }, title));
123
+ var footer = React.useMemo(function () {
124
+ if (!cancelBtn) {
125
+ return /*#__PURE__*/React.createElement(Button, {
126
+ type: "primary",
127
+ loading: okBtnLoading,
128
+ onClick: handleOk
129
+ }, okText);
130
+ }
131
+ }, [okText, cancelBtn, okBtnLoading, handleOk]);
132
+ return /*#__PURE__*/React.createElement(Modal, _extends({}, restProps, {
133
+ confirmLoading: okBtnLoading,
134
+ footer: footer,
135
+ title: titleNode,
136
+ className: classNames(className, "".concat(prefixCls), "".concat(prefixCls, "-").concat(type)),
137
+ getContainer: getPopupContainer,
138
+ visible: visible,
139
+ closeIcon: closeIconToRender,
140
+ onCancel: handleCancel,
141
+ onOk: handleOk,
142
+ okText: okText
143
+ }), /*#__PURE__*/React.createElement("div", {
144
+ className: "".concat(prefixCls, "-content")
145
+ }, content));
146
+ };
147
+
148
+ DialogBox.defaultProps = {
149
+ visible: true,
150
+ type: 'info'
151
+ };
152
+ export default DialogBox;
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { ButtonProps } from '../button';
2
3
  declare enum SizeType {
3
4
  'small' = "sm",
4
5
  'normal' = "md",
@@ -14,15 +15,17 @@ export interface ModalProps {
14
15
  confirmLoading?: boolean;
15
16
  /** 弹框标题 */
16
17
  title?: React.ReactNode;
18
+ /** 确认按钮 props */
19
+ okButtonProps?: ButtonProps;
17
20
  /** 点击确定回调 */
18
21
  onOk?: (e: React.MouseEvent<HTMLElement>) => void;
22
+ /** 取消按钮 props */
23
+ cancelButtonProps?: ButtonProps;
19
24
  /** 点击模态框右上角叉、取消按钮、Props.maskClosable 值为 true 时的遮罩层或键盘按下 Esc 时的回调 */
20
25
  onCancel?: (e: React.MouseEvent<HTMLElement>) => void;
21
26
  afterClose?: () => void;
22
27
  /** 弹框宽度 */
23
28
  width?: number;
24
- /** 弹框高度 */
25
- height?: number;
26
29
  /** 底部内容 */
27
30
  footer?: React.ReactNode;
28
31
  /** 确认按钮文字 */
package/es/modal/Modal.js CHANGED
@@ -63,15 +63,17 @@ var Modal = function Modal(props) {
63
63
  var renderFooter = function renderFooter() {
64
64
  var okText = props.okText,
65
65
  cancelText = props.cancelText,
66
- confirmLoading = props.confirmLoading;
67
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
66
+ confirmLoading = props.confirmLoading,
67
+ okButtonProps = props.okButtonProps,
68
+ cancelButtonProps = props.cancelButtonProps;
69
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({
68
70
  onClick: handleCancel,
69
71
  type: "default"
70
- }, cancelText || '取消'), /*#__PURE__*/React.createElement(Button, {
72
+ }, cancelButtonProps), cancelText || '取消'), /*#__PURE__*/React.createElement(Button, _extends({
71
73
  onClick: handleOk,
72
74
  loading: confirmLoading,
73
75
  type: "primary"
74
- }, okText || '确定'));
76
+ }, okButtonProps), okText || '确定'));
75
77
  };
76
78
 
77
79
  var visible = props.visible,
@@ -0,0 +1,17 @@
1
+ import { ModalFuncProps } from './DialogBox';
2
+ export declare function destroyAll(): void;
3
+ export declare function confirm(config: ModalFuncProps): {
4
+ destroy: (...args: any[]) => void;
5
+ };
6
+ export declare function success(config: ModalFuncProps): {
7
+ destroy: (...args: any[]) => void;
8
+ };
9
+ export declare function info(config: ModalFuncProps): {
10
+ destroy: (...args: any[]) => void;
11
+ };
12
+ export declare function warning(config: ModalFuncProps): {
13
+ destroy: (...args: any[]) => void;
14
+ };
15
+ export declare function error(config: ModalFuncProps): {
16
+ destroy: (...args: any[]) => void;
17
+ };
@@ -0,0 +1,123 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import React from 'react';
3
+ import { render as reactRender, unmountComponentAtNode } from 'react-dom';
4
+ import DialogBox from './DialogBox';
5
+ var destroyFns = [];
6
+
7
+ function renderDialogBox(config) {
8
+ var currentConfig = _extends(_extends({}, config), {
9
+ visible: true,
10
+ onClose: close
11
+ });
12
+
13
+ var container = document.createDocumentFragment();
14
+
15
+ function render(dialogConfig) {
16
+ setTimeout(function () {
17
+ reactRender( /*#__PURE__*/React.createElement(DialogBox, dialogConfig), container);
18
+ });
19
+ }
20
+
21
+ function destroy() {
22
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
23
+ args[_key] = arguments[_key];
24
+ }
25
+
26
+ var triggerCancel = args.some(function (param) {
27
+ return param && param.triggerCancel;
28
+ });
29
+
30
+ if (config.onCancel && triggerCancel) {
31
+ // @ts-ignore
32
+ config.onCancel.apply(config, args);
33
+ }
34
+
35
+ for (var i = 0; i < destroyFns.length; i++) {
36
+ var fn = destroyFns[i];
37
+
38
+ if (fn === close) {
39
+ destroyFns.splice(i, 1);
40
+ break;
41
+ }
42
+ }
43
+
44
+ unmountComponentAtNode(container);
45
+ }
46
+
47
+ function close() {
48
+ var _this = this;
49
+
50
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
51
+ args[_key2] = arguments[_key2];
52
+ }
53
+
54
+ render(_extends(_extends({}, currentConfig), {
55
+ visible: false,
56
+ afterClose: function afterClose() {
57
+ if (typeof config.afterClose === 'function') {
58
+ config.afterClose();
59
+ }
60
+
61
+ destroy.apply(_this, args);
62
+ }
63
+ }));
64
+ }
65
+
66
+ render(currentConfig);
67
+ destroyFns.push(close);
68
+ return {
69
+ destroy: close
70
+ };
71
+ }
72
+
73
+ export function destroyAll() {
74
+ while (destroyFns.length) {
75
+ var close = destroyFns.pop();
76
+
77
+ if (close) {
78
+ close();
79
+ }
80
+ }
81
+ }
82
+ export function confirm(config) {
83
+ return renderDialogBox(_extends(_extends({}, config), {
84
+ type: 'confirm',
85
+ cancelBtn: true
86
+ }));
87
+ }
88
+ export function success(config) {
89
+ var _a;
90
+
91
+ return renderDialogBox(_extends(_extends({}, config), {
92
+ type: 'success',
93
+ cancelBtn: false,
94
+ okText: (_a = config.okText) !== null && _a !== void 0 ? _a : '关闭'
95
+ }));
96
+ }
97
+ export function info(config) {
98
+ var _a;
99
+
100
+ return renderDialogBox(_extends(_extends({}, config), {
101
+ type: 'info',
102
+ cancelBtn: false,
103
+ okText: (_a = config.okText) !== null && _a !== void 0 ? _a : '确定'
104
+ }));
105
+ }
106
+ export function warning(config) {
107
+ var _a;
108
+
109
+ return renderDialogBox(_extends(_extends({}, config), {
110
+ type: 'warning',
111
+ cancelBtn: false,
112
+ okText: (_a = config.okText) !== null && _a !== void 0 ? _a : '关闭'
113
+ }));
114
+ }
115
+ export function error(config) {
116
+ var _a;
117
+
118
+ return renderDialogBox(_extends(_extends({}, config), {
119
+ type: 'error',
120
+ cancelBtn: false,
121
+ okText: (_a = config.okText) !== null && _a !== void 0 ? _a : '重试'
122
+ }));
123
+ }
@@ -1,2 +1,11 @@
1
- import Modal from './Modal';
2
- export default Modal;
1
+ /// <reference types="react" />
2
+ import { confirm, success, info, error, warning, destroyAll } from './dialog';
3
+ declare const _default: import("react").FC<import("./Modal").ModalProps> & {
4
+ confirm: typeof confirm;
5
+ success: typeof success;
6
+ info: typeof info;
7
+ error: typeof error;
8
+ warning: typeof warning;
9
+ destroyAll: typeof destroyAll;
10
+ };
11
+ export default _default;
package/es/modal/index.js CHANGED
@@ -1,2 +1,11 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import Modal from './Modal';
2
- export default Modal;
3
+ import { confirm, success, info, error, warning, destroyAll } from './dialog';
4
+ export default _extends(Modal, {
5
+ confirm: confirm,
6
+ success: success,
7
+ info: info,
8
+ error: error,
9
+ warning: warning,
10
+ destroyAll: destroyAll
11
+ });