@ecoding/components.antd 0.3.30 → 0.3.32

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.
@@ -7,6 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
10
21
  import React, { useEffect, useState, memo, useMemo } from "react";
11
22
  import { Select } from "antd";
12
23
  import { LoadingOutlined } from "@ant-design/icons";
@@ -22,6 +33,10 @@ const AsyncSlect = memo((props) => {
22
33
  const iface = useMemo(() => props.iface, [props.iface]);
23
34
  const data = useMemo(() => props.data, [props.data]);
24
35
  const searchIface = useMemo(() => props.searchIface, []);
36
+ const getRest = (p) => {
37
+ const { onChange, searchIface, data, iface } = p, rest = __rest(p, ["onChange", "searchIface", "data", "iface"]);
38
+ return rest;
39
+ };
25
40
  useEffect(() => {
26
41
  const ex = () => __awaiter(void 0, void 0, void 0, function* () {
27
42
  const innerEx = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -134,6 +149,6 @@ const AsyncSlect = memo((props) => {
134
149
  return option.children.join("").toLowerCase().indexOf(input.toLowerCase()) >= 0;
135
150
  }
136
151
  return option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
137
- }, allowClear: true, showSearch: true, onSearch: handleSearch, optionFilterProp: "children" }, props, { onChange: changeHandler }), children));
152
+ }, allowClear: true, showSearch: true, onSearch: handleSearch, optionFilterProp: "children" }, getRest(props), { onChange: changeHandler }), children));
138
153
  });
139
154
  export default AsyncSlect;
@@ -4,7 +4,6 @@ export interface IDrawerProps {
4
4
  key?: string;
5
5
  id?: string;
6
6
  className?: string;
7
- bodyStyle?: React.CSSProperties;
8
7
  closable?: boolean;
9
8
  maskClosable?: boolean;
10
9
  open?: boolean;
@@ -33,7 +32,7 @@ export interface IDrawerProps {
33
32
  disabled: boolean;
34
33
  };
35
34
  }
36
- export declare class Drawers extends React.Component<IDrawerProps> {
35
+ export declare class Drawers extends React.Component<IDrawerProps, IDrawerProps> {
37
36
  static defaultProps: {
38
37
  className: string;
39
38
  open: boolean;
@@ -63,9 +62,39 @@ export declare class Drawers extends React.Component<IDrawerProps> {
63
62
  component: null;
64
63
  };
65
64
  state: {
65
+ key?: string | undefined;
66
+ id?: string | undefined;
67
+ className?: string | undefined;
68
+ closable?: boolean | undefined;
69
+ maskClosable?: boolean | undefined;
70
+ open?: boolean | undefined;
71
+ width?: string | number | undefined;
72
+ zIndex?: number | undefined;
73
+ height?: string | number | undefined;
74
+ placement?: import("rc-drawer/lib/DrawerPopup").Placement | undefined;
75
+ okDanger?: boolean | undefined;
76
+ title?: React.ReactNode;
77
+ okType?: "link" | "text" | "dashed" | "default" | "primary" | undefined;
78
+ okText?: string | undefined;
79
+ cancelText?: string | undefined;
80
+ mask?: boolean | undefined;
81
+ footer?: React.ReactNode;
82
+ extra?: React.ReactNode;
83
+ onOk?: (() => Promise<any>) | undefined;
84
+ onOkAfter?: ((args: any) => void | Promise<any>) | undefined;
85
+ onCancel?: (() => Promise<any>) | undefined;
86
+ component?: React.ReactNode;
87
+ addonBefore?: React.ReactNode;
88
+ addonAfter?: React.ReactNode;
89
+ okButtonProps?: {
90
+ disabled: boolean;
91
+ } | undefined;
92
+ cancelButtonProps?: {
93
+ disabled: boolean;
94
+ } | undefined;
66
95
  loading: boolean;
67
- open: boolean | undefined;
68
96
  };
97
+ update(props: IDrawerProps): void;
69
98
  cancel: () => void;
70
99
  ok: () => void;
71
100
  render(): JSX.Element;
@@ -5,10 +5,7 @@ const timeout = 300;
5
5
  export class Drawers extends React.Component {
6
6
  constructor() {
7
7
  super(...arguments);
8
- this.state = {
9
- loading: false,
10
- open: this.props.open
11
- };
8
+ this.state = Object.assign({ loading: false }, this.props);
12
9
  this.cancel = () => {
13
10
  if (this.state.loading) {
14
11
  return;
@@ -24,36 +21,39 @@ export class Drawers extends React.Component {
24
21
  });
25
22
  };
26
23
  this.ok = () => {
27
- this.setState({
24
+ this.setState(Object.assign({}, this.state, {
28
25
  loading: true
29
- });
26
+ }));
30
27
  this.props.onOk &&
31
28
  this.props
32
29
  .onOk()
33
30
  .then((res) => {
34
- this.setState({
31
+ this.setState(Object.assign({}, this.state, {
35
32
  loading: false,
36
33
  open: false
37
- });
34
+ }));
38
35
  setTimeout(() => {
39
36
  InjectNotification.removeNotice(this.props.id);
40
37
  this.props.onOkAfter && this.props.onOkAfter(res);
41
38
  }, timeout);
42
39
  })
43
40
  .catch(() => {
44
- this.setState({
41
+ this.setState(Object.assign({}, this.state, {
45
42
  loading: false
46
- });
43
+ }));
47
44
  });
48
45
  };
49
46
  }
47
+ update(props) {
48
+ this.setState(props);
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, extra: this.props.extra === null ? null : this.props.extra ? (this.props.extra) : (React.createElement("div", { className: "tac" },
53
- this.props.addonBefore ? this.props.addonBefore : null,
54
- React.createElement(Button, Object.assign({}, this.props.cancelButtonProps, { className: "mr10", 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
- 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));
52
+ return (React.createElement(Drawer, { className: this.state.className, placement: this.state.placement, height: this.state.height, open: this.state.open, destroyOnClose: true, maskClosable: this.state.maskClosable, keyboard: false, title: this.state.title, extra: this.state.extra === null ? null : this.state.extra ? (this.state.extra) : (React.createElement("div", { className: "tac" },
53
+ this.state.addonBefore ? this.state.addonBefore : null,
54
+ React.createElement(Button, Object.assign({}, this.state.cancelButtonProps, { className: "mr10", key: "back", onClick: this.cancel }), this.state.cancelText),
55
+ React.createElement(Button, Object.assign({}, this.state.okButtonProps, { danger: this.state.okDanger, key: "submit", type: this.state.okType, loading: this.state.loading, onClick: this.ok }), this.state.okText),
56
+ this.state.addonAfter ? this.state.addonAfter : null)), width: this.state.width, zIndex: this.state.zIndex, mask: this.state.mask, onClose: this.cancel, closable: this.state.closable }, this.props.component ? this.props.component : null));
57
57
  }
58
58
  }
59
59
  Drawers.defaultProps = {
@@ -55,8 +55,7 @@ class InjectNotification extends React.Component {
55
55
  const key = props.id;
56
56
  const notice = notices.find(item => item.key === key);
57
57
  if (notice) {
58
- notice.props = Object.assign(notice.props, props);
59
- InjectNotification[key].forceUpdate();
58
+ InjectNotification[key].update(Object.assign({}, notice.props, props));
60
59
  }
61
60
  }
62
61
  getNoticeList() {
@@ -3,13 +3,16 @@ interface ILoadingFCProps {
3
3
  tip?: string;
4
4
  id?: string;
5
5
  key?: string;
6
+ style?: React.CSSProperties;
6
7
  }
7
- export declare class LoadingFC extends React.Component<ILoadingFCProps> {
8
+ export declare class LoadingFC extends React.Component<ILoadingFCProps, ILoadingFCProps> {
8
9
  static defaultProps: {
9
10
  tip: string;
10
11
  };
12
+ constructor(props: ILoadingFCProps);
11
13
  maskStyle: React.CSSProperties;
12
14
  alertStyle: React.CSSProperties;
15
+ update(props: ILoadingFCProps): void;
13
16
  render(): JSX.Element;
14
17
  }
15
18
  declare const _default: {
@@ -3,8 +3,8 @@ import { Spin } from 'antd';
3
3
  import InjectNotification from "../inject-notification";
4
4
  const timeout = 300;
5
5
  export class LoadingFC extends React.Component {
6
- constructor() {
7
- super(...arguments);
6
+ constructor(props) {
7
+ super(props);
8
8
  this.maskStyle = {
9
9
  position: 'fixed',
10
10
  top: 0,
@@ -24,12 +24,16 @@ export class LoadingFC extends React.Component {
24
24
  zIndex: 9002,
25
25
  transform: 'translate(-50%, -70%)'
26
26
  };
27
+ this.state = Object.assign({}, props);
28
+ }
29
+ update(props) {
30
+ this.setState(props);
27
31
  }
28
32
  render() {
29
33
  return (React.createElement(React.Fragment, null,
30
34
  React.createElement("div", { style: this.maskStyle }),
31
- React.createElement("div", { style: this.alertStyle, className: 'ecoding-spin' },
32
- React.createElement(Spin, { size: "large", tip: this.props.tip }, " "))));
35
+ React.createElement("div", { style: Object.assign({}, this.alertStyle, this.state.style), className: 'ecoding-spin' },
36
+ React.createElement(Spin, { size: "large", tip: this.state.tip, style: { width: 200 } }, " "))));
33
37
  }
34
38
  }
35
39
  LoadingFC.defaultProps = {
@@ -4,7 +4,6 @@ export interface IModalProps {
4
4
  id?: string;
5
5
  className?: string;
6
6
  open?: boolean;
7
- bodyStyle?: React.CSSProperties;
8
7
  width?: string | number;
9
8
  zIndex?: number;
10
9
  mask?: boolean;
@@ -56,8 +55,34 @@ export declare class Modals extends React.Component<IModalProps> {
56
55
  component: null;
57
56
  };
58
57
  state: {
58
+ key?: string | undefined;
59
+ id?: string | undefined;
60
+ className?: string | undefined;
61
+ open?: boolean | undefined;
62
+ width?: string | number | undefined;
63
+ zIndex?: number | undefined;
64
+ mask?: boolean | undefined;
65
+ title?: React.ReactNode;
66
+ okDanger?: boolean | undefined;
67
+ okType?: "link" | "text" | "dashed" | "default" | "primary" | undefined;
68
+ okText?: string | undefined;
69
+ cancelText?: string | undefined;
70
+ closable?: boolean | undefined;
71
+ maskClosable?: boolean | undefined;
72
+ footer?: React.ReactNode;
73
+ onOk?: (() => Promise<any>) | undefined;
74
+ onOkAfter?: ((args: any) => void | Promise<any>) | undefined;
75
+ onCancel?: (() => Promise<any>) | undefined;
76
+ component?: React.ReactNode;
77
+ addonBefore?: React.ReactNode;
78
+ addonAfter?: React.ReactNode;
79
+ okButtonProps?: {
80
+ disabled: boolean;
81
+ } | undefined;
82
+ cancelButtonProps?: {
83
+ disabled: boolean;
84
+ } | undefined;
59
85
  loading: boolean;
60
- open: boolean | undefined;
61
86
  };
62
87
  cancel: () => void;
63
88
  ok: () => void;
@@ -5,10 +5,7 @@ const timeout = 300;
5
5
  export class Modals extends React.Component {
6
6
  constructor() {
7
7
  super(...arguments);
8
- this.state = {
9
- loading: false,
10
- open: this.props.open
11
- };
8
+ this.state = Object.assign({ loading: false }, this.props);
12
9
  this.cancel = () => {
13
10
  if (this.state.loading) {
14
11
  return;
@@ -24,36 +21,36 @@ export class Modals extends React.Component {
24
21
  });
25
22
  };
26
23
  this.ok = () => {
27
- this.setState({
24
+ this.setState(Object.assign({}, this.state, {
28
25
  loading: true
29
- });
26
+ }));
30
27
  this.props.onOk &&
31
28
  this.props
32
29
  .onOk()
33
30
  .then((res) => {
34
- this.setState({
31
+ this.setState(Object.assign({}, this.state, {
35
32
  loading: false,
36
33
  open: false
37
- });
34
+ }));
38
35
  setTimeout(() => {
39
36
  InjectNotification.removeNotice(this.props.id);
40
37
  this.props.onOkAfter && this.props.onOkAfter(res);
41
38
  }, timeout);
42
39
  })
43
40
  .catch(() => {
44
- this.setState({
41
+ this.setState(Object.assign({}, this.state, {
45
42
  loading: false
46
- });
43
+ }));
47
44
  });
48
45
  };
49
46
  }
50
47
  render() {
51
48
  // if (!this.props.visible) return null;
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
- this.props.addonBefore ? this.props.addonBefore : null,
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
- this.props.addonAfter ? this.props.addonAfter : null)) }, this.props.component ? this.props.component : null));
49
+ return (React.createElement(Modal, { className: this.state.className, open: this.state.open, width: this.state.width, zIndex: this.state.zIndex, mask: this.state.mask, title: typeof this.state.title === "string" ? (React.createElement("div", { style: { boxShadow: "inset 0px -1px 0px #F0F0F0", marginBottom: "20px", paddingBottom: "12px" } }, this.state.title)) : (this.state.title), closable: this.state.closable, maskClosable: this.state.maskClosable, onCancel: this.cancel, destroyOnClose: true, keyboard: false, footer: this.state.footer === null ? null : this.state.footer ? (this.state.footer) : (React.createElement(React.Fragment, null,
50
+ this.state.addonBefore ? this.state.addonBefore : null,
51
+ React.createElement(Button, Object.assign({}, this.state.cancelButtonProps, { key: "back", onClick: this.cancel }), this.state.cancelText),
52
+ React.createElement(Button, Object.assign({}, this.state.okButtonProps, { danger: this.state.okDanger, key: "submit", type: this.state.okType, loading: this.state.loading, onClick: this.ok }), this.state.okText),
53
+ this.state.addonAfter ? this.state.addonAfter : null)) }, this.props.component ? this.props.component : null));
57
54
  }
58
55
  }
59
56
  Modals.defaultProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.3.30",
3
+ "version": "0.3.32",
4
4
  "author": "cxc",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -43,5 +43,5 @@
43
43
  "antd": "^5.8.4",
44
44
  "axios": "^1.1.2"
45
45
  },
46
- "gitHead": "5ea58b44f581ea22ba222331e44699a0da566b74"
46
+ "gitHead": "91de23836af8423f200834bdd68cf7b77a2a0424"
47
47
  }