@ecoding/components.antd 0.0.7 → 0.0.9

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,56 @@
1
+ import React from 'react';
2
+ export interface IDrawerProps {
3
+ key?: string;
4
+ id?: string;
5
+ className?: string;
6
+ bodyStyle?: React.CSSProperties;
7
+ closable?: boolean;
8
+ maskClosable?: boolean;
9
+ open?: boolean;
10
+ width?: string;
11
+ zIndex?: number;
12
+ title?: React.ReactNode;
13
+ okType?: "text" | "link" | "ghost" | "default" | "primary" | "dashed" | undefined;
14
+ okText?: string;
15
+ cancelText?: string;
16
+ mask?: boolean;
17
+ footer?: React.ReactNode;
18
+ onOk?: () => Promise<any>;
19
+ onOkAfter?: (args: any) => void | Promise<any>;
20
+ onCancel?: () => Promise<any>;
21
+ component?: React.ReactNode;
22
+ addonBefore?: React.ReactNode;
23
+ addonAfter?: React.ReactNode;
24
+ }
25
+ export declare class Drawers extends React.Component<IDrawerProps> {
26
+ static defaultProps: {
27
+ className: string;
28
+ open: boolean;
29
+ bodyStyle: {};
30
+ width: string;
31
+ zIndex: number;
32
+ mask: boolean;
33
+ title: string;
34
+ okType: string;
35
+ okText: string;
36
+ cancelText: string;
37
+ maskClosable: boolean;
38
+ closable: boolean;
39
+ footer: string;
40
+ onOk: () => Promise<void>;
41
+ onCancel: () => Promise<void>;
42
+ component: null;
43
+ };
44
+ state: {
45
+ loading: boolean;
46
+ open: boolean | undefined;
47
+ };
48
+ cancel: () => void;
49
+ ok: () => void;
50
+ render(): JSX.Element;
51
+ }
52
+ declare const _default: {
53
+ show(props?: IDrawerProps): void;
54
+ hide(props?: IDrawerProps): void;
55
+ };
56
+ export default _default;
@@ -0,0 +1,104 @@
1
+ import React from 'react';
2
+ import { Drawer, Button } from 'antd';
3
+ import InjectNotification from '../inject-notification';
4
+ const timeout = 300;
5
+ export class Drawers extends React.Component {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.state = {
9
+ loading: false,
10
+ open: this.props.open
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
+ setTimeout(() => {
22
+ InjectNotification.removeNotice(this.props.id);
23
+ }, timeout);
24
+ });
25
+ };
26
+ this.ok = () => {
27
+ this.setState({
28
+ loading: true
29
+ });
30
+ this.props.onOk &&
31
+ this.props
32
+ .onOk()
33
+ .then((res) => {
34
+ this.setState({
35
+ loading: false,
36
+ open: false
37
+ });
38
+ setTimeout(() => {
39
+ InjectNotification.removeNotice(this.props.id);
40
+ this.props.onOkAfter && this.props.onOkAfter(res);
41
+ }, timeout);
42
+ })
43
+ .catch(() => {
44
+ this.setState({
45
+ loading: false
46
+ });
47
+ });
48
+ };
49
+ }
50
+ render() {
51
+ // if (!this.props.visible) return null;
52
+ return (React.createElement(Drawer, { className: this.props.className, bodyStyle: this.props.bodyStyle, open: this.props.open, destroyOnClose: true, maskClosable: this.props.maskClosable, keyboard: false, title: this.props.title, footer: this.props.footer === null ? null : this.props.footer ? (this.props.footer) : (React.createElement("div", { className: "tac" },
53
+ this.props.addonBefore ? this.props.addonBefore : null,
54
+ React.createElement(Button, { className: "mr10", key: "back", onClick: this.cancel }, this.props.cancelText),
55
+ React.createElement(Button, { key: "submit", type: this.props.okType, loading: this.state.loading, onClick: this.ok }, this.props.okText),
56
+ this.props.addonAfter ? this.props.addonAfter : null)), width: this.props.width, zIndex: this.props.zIndex, mask: this.props.mask, onClose: this.cancel, closable: this.props.closable }, this.props.component ? this.props.component : null));
57
+ }
58
+ }
59
+ Drawers.defaultProps = {
60
+ className: "g-drawer",
61
+ open: false,
62
+ bodyStyle: {},
63
+ width: "60vw",
64
+ zIndex: 900,
65
+ mask: true,
66
+ title: "标题",
67
+ okType: "primary",
68
+ okText: "保存",
69
+ cancelText: "取消",
70
+ maskClosable: true,
71
+ closable: true,
72
+ footer: "",
73
+ onOk: function () {
74
+ return Promise.resolve();
75
+ },
76
+ onCancel: function () {
77
+ return Promise.resolve();
78
+ },
79
+ component: null
80
+ };
81
+ export default {
82
+ show(props = {}) {
83
+ props.open = true;
84
+ props.id = props.id || props.key || "drawers";
85
+ if (props.footer !== null && !props.footer) {
86
+ props.footer = "";
87
+ }
88
+ if (!props.okText) {
89
+ props.okText = "保存";
90
+ }
91
+ if (!props.cancelText) {
92
+ props.cancelText = "取消";
93
+ }
94
+ InjectNotification.notice(React.createElement(Drawers, Object.assign({}, props, { key: props.id })));
95
+ },
96
+ hide(props = {}) {
97
+ props.open = false;
98
+ props.footer = "";
99
+ props.id = props.id || "drawers";
100
+ setTimeout(() => {
101
+ InjectNotification.removeNotice(props.id);
102
+ }, timeout);
103
+ }
104
+ };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Modal, Button } from 'antd';
3
- import InjectNotification from '../../helpers/inject.notification';
3
+ import InjectNotification from '../inject-notification';
4
4
  const timeout = 300;
5
5
  export class Modals extends React.Component {
6
6
  constructor() {
package/lib/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { default as Toast } from "./core/toast";
2
2
  export { default as Loading } from "./core/loading";
3
3
  export { default as Modal } from "./core/modal";
4
+ export { default as Drawer } from "./core/drawer";
5
+ export { default as InjectNotification } from "./core/inject-notification";
4
6
  export { default as Confirm } from "./core/confirm";
5
7
  export { default as AsyncCascader } from "./core/async-cascader";
6
8
  export { default as LengthInput } from "./core/length-input";
package/lib/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  export { default as Toast } from "./core/toast";
2
2
  export { default as Loading } from "./core/loading";
3
3
  export { default as Modal } from "./core/modal";
4
+ export { default as Drawer } from "./core/drawer";
5
+ export { default as InjectNotification } from "./core/inject-notification";
4
6
  export { default as Confirm } from "./core/confirm";
5
7
  export { default as AsyncCascader } from "./core/async-cascader";
6
8
  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.7",
3
+ "version": "0.0.9",
4
4
  "author": "cxc",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -42,5 +42,5 @@
42
42
  "dependencies": {
43
43
  "react-quill": "^2.0.0"
44
44
  },
45
- "gitHead": "d41d5a815bc583f5499c1d0120a833a0622538f5"
45
+ "gitHead": "5a45275024954892efa6a3c6720579faa8f314aa"
46
46
  }