@ecoding/components.antd 0.2.4 → 0.2.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.
@@ -19,6 +19,7 @@ export interface IDrawerProps {
19
19
  cancelText?: string;
20
20
  mask?: boolean;
21
21
  footer?: React.ReactNode;
22
+ extra?: React.ReactNode;
22
23
  onOk?: () => Promise<any>;
23
24
  onOkAfter?: (args: any) => void | Promise<any>;
24
25
  onCancel?: () => Promise<any>;
@@ -43,7 +44,8 @@ export declare class Drawers extends React.Component<IDrawerProps> {
43
44
  cancelText: string;
44
45
  maskClosable: boolean;
45
46
  closable: boolean;
46
- footer: string;
47
+ footer: null;
48
+ extra: string;
47
49
  onOk: () => Promise<void>;
48
50
  onCancel: () => Promise<void>;
49
51
  component: null;
@@ -58,6 +60,7 @@ export declare class Drawers extends React.Component<IDrawerProps> {
58
60
  }
59
61
  declare const _default: {
60
62
  show(props?: IDrawerProps): void;
63
+ update(props?: Omit<IDrawerProps, "component">): void;
61
64
  hide(props?: IDrawerProps): void;
62
65
  };
63
66
  export default _default;
@@ -49,7 +49,7 @@ export class Drawers extends React.Component {
49
49
  }
50
50
  render() {
51
51
  // if (!this.props.visible) return null;
52
- return (React.createElement(Drawer, { className: this.props.className, bodyStyle: this.props.bodyStyle, placement: this.props.placement, height: this.props.height, open: this.state.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" },
52
+ return (React.createElement(Drawer, { className: this.props.className, bodyStyle: this.props.bodyStyle, placement: this.props.placement, height: this.props.height, open: this.state.open, destroyOnClose: true, maskClosable: this.props.maskClosable, keyboard: false, title: this.props.title, extra: this.props.extra === null ? null : this.props.extra ? (this.props.extra) : (React.createElement("div", { className: "tac" },
53
53
  this.props.addonBefore ? this.props.addonBefore : null,
54
54
  React.createElement(Button, { className: "mr10", key: "back", onClick: this.cancel }, this.props.cancelText),
55
55
  React.createElement(Button, { danger: this.props.okDanger, key: "submit", type: this.props.okType, loading: this.state.loading, onClick: this.ok }, this.props.okText),
@@ -72,7 +72,8 @@ Drawers.defaultProps = {
72
72
  cancelText: "取消",
73
73
  maskClosable: true,
74
74
  closable: true,
75
- footer: "",
75
+ footer: null,
76
+ extra: "",
76
77
  onOk: function () {
77
78
  return Promise.resolve();
78
79
  },
@@ -96,6 +97,11 @@ export default {
96
97
  }
97
98
  InjectNotification.notice(React.createElement(Drawers, Object.assign({}, props, { key: props.id })));
98
99
  },
100
+ update(props = {}) {
101
+ props.open = true;
102
+ props.id = props.id || props.key || "drawers";
103
+ InjectNotification.updateNotice(props);
104
+ },
99
105
  hide(props = {}) {
100
106
  props.open = false;
101
107
  props.footer = "";
@@ -6,9 +6,11 @@ interface IState {
6
6
  declare class InjectNotification extends React.Component<any, IState> {
7
7
  static notice(component: any): void;
8
8
  static removeNotice(key: any): void;
9
+ static updateNotice(props: any): void;
9
10
  constructor(props: any);
10
11
  add(notice: React.Attributes): void;
11
12
  remove(key: string): void;
13
+ update(props: any): void;
12
14
  getNoticeList(): React.Attributes[];
13
15
  componentDidMount(): void;
14
16
  render(): React.ReactPortal | null;
@@ -11,6 +11,9 @@ class InjectNotification extends React.Component {
11
11
  static removeNotice(key) {
12
12
  instanceEvent.emit("InjectNotification/HIDE", key);
13
13
  }
14
+ static updateNotice(props) {
15
+ instanceEvent.emit("InjectNotification/UPDATE", props);
16
+ }
14
17
  constructor(props) {
15
18
  super(props);
16
19
  this.state = {
@@ -47,6 +50,17 @@ class InjectNotification extends React.Component {
47
50
  };
48
51
  });
49
52
  }
53
+ update(props) {
54
+ const { notices } = this.state;
55
+ const key = props.id;
56
+ const index = notices.findIndex(item => item.key === key);
57
+ const temp = notices.splice(index, 1);
58
+ if (temp && temp.length > 0) {
59
+ const notice = temp[0];
60
+ notice.props = Object.assign(notice.props, props);
61
+ InjectNotification[key].forceUpdate();
62
+ }
63
+ }
50
64
  getNoticeList() {
51
65
  const { notices } = this.state;
52
66
  return notices.map((notice, i) => {
@@ -60,6 +74,7 @@ class InjectNotification extends React.Component {
60
74
  });
61
75
  instanceEvent.on("InjectNotification/SHOW", this.add, this);
62
76
  instanceEvent.on("InjectNotification/HIDE", this.remove, this);
77
+ instanceEvent.on("InjectNotification/UPDATE", this.update, this);
63
78
  }
64
79
  render() {
65
80
  const noticesDOM = this.getNoticeList();
@@ -22,6 +22,12 @@ export interface IModalProps {
22
22
  component?: React.ReactNode;
23
23
  addonBefore?: React.ReactNode;
24
24
  addonAfter?: React.ReactNode;
25
+ okButtonProps?: {
26
+ disabled: boolean;
27
+ };
28
+ cancelButtonProps?: {
29
+ disabled: boolean;
30
+ };
25
31
  }
26
32
  export declare class Modals extends React.Component<IModalProps> {
27
33
  static defaultProps: {
@@ -38,6 +44,12 @@ export declare class Modals extends React.Component<IModalProps> {
38
44
  okDanger: boolean;
39
45
  closable: boolean;
40
46
  maskClosable: boolean;
47
+ okButtonProps: {
48
+ disabled: boolean;
49
+ };
50
+ cancelButtonProps: {
51
+ disabled: boolean;
52
+ };
41
53
  footer: string;
42
54
  onOk: () => Promise<void>;
43
55
  onCancel: () => Promise<void>;
@@ -53,6 +65,7 @@ export declare class Modals extends React.Component<IModalProps> {
53
65
  }
54
66
  declare const _default: {
55
67
  show(props?: IModalProps): void;
68
+ update(props?: Omit<IModalProps, "component">): void;
56
69
  hide(props?: IModalProps): void;
57
70
  };
58
71
  export default _default;
@@ -51,8 +51,8 @@ export class Modals extends React.Component {
51
51
  // if (!this.props.visible) return null;
52
52
  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: typeof this.props.title === "string" ? (React.createElement("div", { style: { boxShadow: "inset 0px -1px 0px #F0F0F0", marginBottom: "20px", paddingBottom: "12px" } }, this.props.title)) : (this.props.title), closable: this.props.closable, maskClosable: this.props.maskClosable, onCancel: this.cancel, destroyOnClose: true, keyboard: false, footer: this.props.footer === null ? null : this.props.footer ? (this.props.footer) : (React.createElement(React.Fragment, null,
53
53
  this.props.addonBefore ? this.props.addonBefore : null,
54
- React.createElement(Button, { key: "back", onClick: this.cancel }, this.props.cancelText),
55
- React.createElement(Button, { danger: this.props.okDanger, key: "submit", type: this.props.okType, loading: this.state.loading, onClick: this.ok }, this.props.okText),
54
+ React.createElement(Button, Object.assign({}, this.props.cancelButtonProps, { key: "back", onClick: this.cancel }), this.props.cancelText),
55
+ React.createElement(Button, Object.assign({}, this.props.okButtonProps, { danger: this.props.okDanger, key: "submit", type: this.props.okType, loading: this.state.loading, onClick: this.ok }), this.props.okText),
56
56
  this.props.addonAfter ? this.props.addonAfter : null)) }, this.props.component ? this.props.component : null));
57
57
  }
58
58
  }
@@ -70,6 +70,8 @@ Modals.defaultProps = {
70
70
  okDanger: false,
71
71
  closable: true,
72
72
  maskClosable: true,
73
+ okButtonProps: { disabled: false },
74
+ cancelButtonProps: { disabled: false },
73
75
  footer: "",
74
76
  onOk: function () {
75
77
  return Promise.resolve();
@@ -92,7 +94,12 @@ export default {
92
94
  if (!props.cancelText) {
93
95
  props.cancelText = "取消";
94
96
  }
95
- InjectNotification.notice(React.createElement(Modals, Object.assign({}, props, { key: props.id })));
97
+ InjectNotification.notice(React.createElement(Modals, Object.assign({ ref: ref => InjectNotification[props.id] = ref }, props, { key: props.id })));
98
+ },
99
+ update(props = {}) {
100
+ props.open = true;
101
+ props.id = props.id || props.key || "modals";
102
+ InjectNotification.updateNotice(props);
96
103
  },
97
104
  hide(props = {}) {
98
105
  props.open = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "author": "cxc",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -44,5 +44,5 @@
44
44
  "dependencies": {
45
45
  "react-quill": "^2.0.0"
46
46
  },
47
- "gitHead": "04b073fbe3794d41e10954744ee44e1059434b0d"
47
+ "gitHead": "854a6011b72e60c70cc7ba0fb949075fcddf7bd9"
48
48
  }