@ecoding/components.antd 0.0.4 → 0.0.6

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.
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ export interface IModalProps {
3
+ className?: string;
4
+ open?: boolean;
5
+ bodyStyle?: React.CSSProperties;
6
+ width?: string;
7
+ zIndex?: number;
8
+ mask?: boolean;
9
+ title?: React.ReactNode;
10
+ okType?: "text" | "link" | "ghost" | "default" | "primary" | "dashed" | undefined;
11
+ okText?: string;
12
+ cancelText?: string;
13
+ closable?: boolean;
14
+ footer?: React.ReactNode;
15
+ onOk?: () => Promise<any>;
16
+ onOkAfter?: (args: any) => void | Promise<any>;
17
+ onCancel?: () => Promise<any>;
18
+ component?: React.ReactNode;
19
+ addonBefore?: React.ReactNode;
20
+ addonAfter?: React.ReactNode;
21
+ }
22
+ declare const _default: {
23
+ show(props?: IModalProps): void;
24
+ hide(props?: IModalProps): void;
25
+ };
26
+ export default _default;
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import { Modal, Button } from 'antd';
3
+ import Notification from '../../helpers/notification';
4
+ const notification = Notification.newInstance();
5
+ class Modals extends React.Component {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.state = {
9
+ loading: false,
10
+ open: true
11
+ };
12
+ this.cancel = () => {
13
+ if (this.state.loading) {
14
+ return;
15
+ }
16
+ this.props.onCancel &&
17
+ this.props.onCancel().then(() => {
18
+ this.setState({
19
+ open: false
20
+ });
21
+ // hideModal();
22
+ });
23
+ };
24
+ this.ok = () => {
25
+ this.setState({
26
+ loading: true
27
+ });
28
+ this.props.onOk &&
29
+ this.props
30
+ .onOk()
31
+ .then((res) => {
32
+ this.setState({
33
+ loading: false,
34
+ open: false
35
+ });
36
+ // hideModal();
37
+ this.props.onOkAfter && this.props.onOkAfter(res);
38
+ })
39
+ .catch(() => {
40
+ this.setState({
41
+ loading: false
42
+ });
43
+ });
44
+ };
45
+ }
46
+ render() {
47
+ // if (!this.props.visible) return null;
48
+ return (React.createElement(Modal, { className: this.props.className, open: this.state.open, bodyStyle: this.props.bodyStyle, width: this.props.width, zIndex: this.props.zIndex, mask: this.props.mask, title: this.props.title, closable: this.props.closable, onCancel: this.cancel, footer: this.props.footer === null ? null : this.props.footer ? (this.props.footer) : (React.createElement(React.Fragment, null,
49
+ this.props.addonBefore ? this.props.addonBefore : null,
50
+ React.createElement(Button, { key: "back", onClick: this.cancel }, this.props.cancelText),
51
+ React.createElement(Button, { key: "submit", type: this.props.okType, loading: this.state.loading, onClick: this.ok }, this.props.okText),
52
+ this.props.addonAfter ? this.props.addonAfter : null)), centered: true, destroyOnClose: true, keyboard: false }, this.props.component ? this.props.component : null));
53
+ }
54
+ }
55
+ Modals.defaultProps = {
56
+ tip: ''
57
+ };
58
+ export default {
59
+ show(props = {}) {
60
+ if (notification) {
61
+ notification.removeNotice('modals');
62
+ }
63
+ notification.notice(React.createElement(Modals, Object.assign({}, props, { key: "modals" })));
64
+ },
65
+ hide(props = {}) {
66
+ notification.removeNotice('modals');
67
+ }
68
+ };
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as Toast } from "./core/toast";
2
2
  export { default as Loading } from "./core/loading";
3
+ export { default as Modal } from "./core/modal";
3
4
  export { default as Confirm } from "./core/confirm";
4
5
  export { default as AsyncCascader } from "./core/async-cascader";
5
6
  export { default as LengthInput } from "./core/length-input";
package/lib/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as Toast } from "./core/toast";
2
2
  export { default as Loading } from "./core/loading";
3
+ export { default as Modal } from "./core/modal";
3
4
  export { default as Confirm } from "./core/confirm";
4
5
  export { default as AsyncCascader } from "./core/async-cascader";
5
6
  export { default as LengthInput } from "./core/length-input";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "author": "cxc",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -40,5 +40,5 @@
40
40
  "dependencies": {
41
41
  "react-quill": "^2.0.0"
42
42
  },
43
- "gitHead": "cff4572674ded5234d2444bdb5598555f7545503"
43
+ "gitHead": "05844c415468a69e3aa77f4e4748b4451b1d8a94"
44
44
  }