@ecoding/components.antd 0.1.1 → 0.1.4

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.
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  interface IComfirm {
3
3
  title?: string;
4
4
  content?: React.ReactNode;
@@ -7,19 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import React from 'react';
11
- import { Modal } from 'antd';
12
- import { ExclamationCircleOutlined } from '@ant-design/icons';
10
+ import React from "react";
11
+ import { Modal } from "antd";
12
+ import { ExclamationCircleOutlined } from "@ant-design/icons";
13
13
  const confirm = {
14
14
  showDelete(opts) {
15
15
  let loading = false;
16
16
  Modal.confirm({
17
- okType: 'danger',
17
+ okType: "danger",
18
18
  icon: React.createElement(ExclamationCircleOutlined, null),
19
- title: opts.title || '确定要删除吗?',
20
- content: opts.content || '',
21
- okText: opts.okText || '确定',
22
- cancelText: opts.okText || '取消',
19
+ title: opts.title || "确定要删除吗?",
20
+ content: opts.content || "",
21
+ okText: opts.okText || "确定",
22
+ cancelText: opts.cancelText || "取消",
23
23
  onOk() {
24
24
  loading = true;
25
25
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
@@ -35,23 +35,23 @@ const confirm = {
35
35
  },
36
36
  onCancel() {
37
37
  if (loading) {
38
- return Promise.reject('正在请求中,不可关闭');
38
+ return Promise.reject("正在请求中,不可关闭");
39
39
  }
40
40
  if (opts.onCancel) {
41
41
  return opts.onCancel();
42
42
  }
43
- },
43
+ }
44
44
  });
45
45
  },
46
46
  show(opts) {
47
47
  let loading = false;
48
48
  Modal.confirm({
49
49
  icon: React.createElement(ExclamationCircleOutlined, null),
50
- title: opts.title || '标题',
51
- content: opts.content || '',
52
- okType: opts.okType || 'primary',
53
- okText: opts.okText || '确定',
54
- cancelText: opts.okText || '取消',
50
+ title: opts.title || "标题",
51
+ content: opts.content || "",
52
+ okType: opts.okType || "primary",
53
+ okText: opts.okText || "确定",
54
+ cancelText: opts.cancelText || "取消",
55
55
  onOk() {
56
56
  loading = true;
57
57
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
@@ -67,12 +67,12 @@ const confirm = {
67
67
  },
68
68
  onCancel() {
69
69
  if (loading) {
70
- return Promise.reject('正在请求中,不可关闭');
70
+ return Promise.reject("正在请求中,不可关闭");
71
71
  }
72
72
  if (opts.onCancel) {
73
73
  return opts.onCancel();
74
74
  }
75
- },
75
+ }
76
76
  });
77
77
  }
78
78
  };
@@ -34,7 +34,6 @@ class InjectNotification extends React.Component {
34
34
  }
35
35
  else {
36
36
  const temp = notices.splice(index, 1);
37
- console.log(notices.concat(temp));
38
37
  this.setState(Object.assign({}, {
39
38
  notices: notices.concat(temp),
40
39
  }));
@@ -32,9 +32,6 @@ LoadingFC.defaultProps = {
32
32
  };
33
33
  export default {
34
34
  show(props = {}) {
35
- if (notification) {
36
- notification.removeNotice('loading');
37
- }
38
35
  notification.notice(React.createElement(LoadingFC, Object.assign({}, props, { key: "loading" })));
39
36
  },
40
37
  hide(props = {}) {
@@ -62,7 +62,9 @@ const show = (props = {}) => {
62
62
  if (notification) {
63
63
  notification.removeNotice('toast');
64
64
  }
65
- notification.notice(React.createElement(ToastFC, Object.assign({}, props, { key: "toast" })));
65
+ setTimeout(() => {
66
+ notification.notice(React.createElement(ToastFC, Object.assign({}, props, { key: "toast" })));
67
+ }, 1);
66
68
  };
67
69
  export default {
68
70
  info(props = {}) {
@@ -35,14 +35,20 @@ class Notification extends React.Component {
35
35
  // 创造一个不重复的key
36
36
  const { notices } = this.state;
37
37
  const key = notice.key;
38
- const temp = notices.filter(item => item.key === key).length;
39
- if (!temp) {
38
+ const index = notices.findIndex(item => item.key === key);
39
+ if (index === -1) {
40
40
  // 不存在重复的 添加
41
41
  notices.push(notice);
42
42
  this.setState({
43
43
  notices,
44
44
  });
45
45
  }
46
+ else {
47
+ const temp = notices.splice(index, 1);
48
+ this.setState(Object.assign({}, {
49
+ notices: notices.concat(temp),
50
+ }));
51
+ }
46
52
  }
47
53
  // 删除一个监听项
48
54
  remove(key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
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": "ceb7610b08ba21a9f8617ef1ec29bc8ce68de1ea"
45
+ "gitHead": "41803868b11ed238f9ea335c2be473ee3523b874"
46
46
  }