@ucloud-fe/react-components 1.3.5 → 1.3.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.
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CSSProperties, ReactNode, Component, PureComponent, HTMLAttributes } from 'react';
1
+ import type { CSSProperties, ReactNode, Component, PureComponent, HTMLAttributes, TextareaHTMLAttributes } from 'react';
2
2
 
3
3
  // 忽略 T 对象中 键在 K 中的所有的属性
4
4
  type Override<T1, T2> = Omit<T1, keyof T2> & T2;
@@ -20,14 +20,14 @@ export { default as Link } from './lib/components/Link';
20
20
 
21
21
  export { default as AutoComplete } from './lib/components/AutoComplete';
22
22
 
23
- export { default as Switch } from './lib/components/Switch';
23
+ export { default as Switch, SwitchProps } from './lib/components/Switch';
24
24
 
25
- export { default as Tabs } from './lib/components/Tabs';
25
+ export { default as Tabs, TabsProps, TabPaneProps } from './lib/components/Tabs';
26
26
 
27
27
  export { default as Input } from './lib/components/Input';
28
28
  import Input from './lib/components/Input';
29
29
 
30
- export { default as Checkbox } from './lib/components/Checkbox';
30
+ export { default as Checkbox, CheckboxProps } from './lib/components/Checkbox';
31
31
 
32
32
  export { default as Menu } from './lib/components/Menu';
33
33
 
@@ -147,11 +147,11 @@ export type NumberInputProps = Override<
147
147
  export declare class NumberInput extends Component<NumberInputProps> {}
148
148
 
149
149
  // Textarea
150
- export type TextareaProps = HTMLAttributes<HTMLTextAreaElement>;
150
+ export type TextareaProps = TextareaHTMLAttributes<HTMLTextAreaElement>;
151
151
  export declare class Textarea extends Component<TextareaProps> {}
152
152
 
153
153
  // Radio
154
- export type RadioStyleType = 'default' | 'button' | 'tag' | 'card' | 'text';
154
+ export type RadioStyleType = 'default' | 'button' | 'tag' | 'card' | 'text' | 'list';
155
155
  export interface RadioProps {
156
156
  checked?: boolean;
157
157
  defaultChecked?: boolean;
@@ -161,12 +161,13 @@ export interface RadioProps {
161
161
  styleType?: RadioStyleType;
162
162
  size?: SizeType;
163
163
  title?: ReactNode;
164
+ extra?: ReactNode;
164
165
  disabledLabel?: ReactNode;
165
166
  }
166
167
  interface RadioOption extends RadioProps {
167
168
  label?: ReactNode;
168
169
  }
169
- export type RadioOptions = RadioGroup[];
170
+ export type RadioOptions = RadioOption[];
170
171
  export interface RadioGroupProps {
171
172
  value?: any;
172
173
  defaultValue?: any;
@@ -188,7 +189,7 @@ export interface SliderMark {
188
189
  ratio?: number;
189
190
  }
190
191
  export interface SliderMarks {
191
- [key: string]: SliderMark;
192
+ [key: string]: SliderMark | ReactNode;
192
193
  }
193
194
  interface NumberInputTipFormatterOption {
194
195
  currentValue: number;
@@ -224,11 +225,15 @@ export declare class Slider extends Component<SliderProps> {}
224
225
  export interface UploadFile {
225
226
  name: string;
226
227
  uid: string;
227
- size: number;
228
- type: string;
228
+ size?: number;
229
229
  status?: 'uploading' | 'success' | 'error';
230
+ thumbnailUrl?: string;
231
+ url?: string;
232
+ type?: string;
230
233
  lastModified?: number;
231
234
  lastModifiedDate?: Date;
235
+ progress?: number;
236
+ error?: Error;
232
237
  }
233
238
  interface UpdateProgress {
234
239
  (progress: number): void;
@@ -245,6 +250,7 @@ export interface UploadCustomStyle {
245
250
  listMaxHeight?: string;
246
251
  [key: string]: any;
247
252
  }
253
+
248
254
  export interface UploadProps {
249
255
  onChange?: (fileList: UploadFile[]) => void;
250
256
  onAdd?: (fileList: UploadFile[]) => boolean;
@@ -261,8 +267,8 @@ export interface UploadProps {
261
267
  maxCount?: number;
262
268
  selector?: ReactNode;
263
269
  listType?: UploadListType;
264
- defaultFileList?: File[];
265
- fileList?: File[];
270
+ defaultFileList?: (File | UploadFile)[];
271
+ fileList?: (File | UploadFile)[];
266
272
  style?: CSSProperties;
267
273
  customStyle?: UploadCustomStyle;
268
274
  }
@@ -385,18 +391,10 @@ export interface EditableListProps {
385
391
  export declare class EditableList extends PureComponent<EditableListProps> {}
386
392
 
387
393
  // Notice
388
- export type NoticeStyleType = 'default' | 'success' | 'warning' | 'error' | 'disabled';
389
- export interface NoticeProps extends HTMLAttributes<HTMLDivElement> {
390
- closable?: boolean;
391
- icon?: ReactNode;
392
- onClose?: Function;
393
- styleType?: NoticeStyleType;
394
- action?: ReactNode;
395
- }
396
- export declare class Notice extends Component<NoticeProps> {}
394
+ export { default as Notice, NoticeProps } from './lib/components/Notice';
397
395
 
398
396
  // Badge
399
- export { default as Badge } from './lib/components/Badge';
397
+ export { default as Badge, BadgeProps } from './lib/components/Badge';
400
398
 
401
399
  // Tag
402
400
  export type TagStyleType =
@@ -427,7 +425,10 @@ export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
427
425
  icon?: 'circle-fill' | 'circle' | 'loading' | 'custom' | ReactNode;
428
426
  disabled?: boolean;
429
427
  }
430
- export declare class Tag extends PureComponent<TagProps> {}
428
+ export declare class TagIcon extends PureComponent<TagProps> {}
429
+ export declare class Tag extends PureComponent<TagProps> {
430
+ declare static Icon: typeof TagIcon;
431
+ }
431
432
 
432
433
  // Popover
433
434
  interface PopupAlign {
@@ -506,10 +507,12 @@ interface ModalConfirmHandle {
506
507
  interface ModalConfirm {
507
508
  (options: ModalProps): ModalConfirmHandle;
508
509
  }
510
+ export declare class ModalContent extends Component<HTMLAttributes<HTMLDivElement>> {}
509
511
  export declare class Modal extends Component<ModalProps> {
510
512
  static confirm: ModalConfirm;
511
513
  static alert: ModalConfirm;
512
514
  static open: ModalConfirm;
515
+ static Content: typeof ModalContent;
513
516
  }
514
517
 
515
518
  // Drawer
@@ -634,11 +637,13 @@ interface ColumnConfigButtonProps extends ButtonProps {
634
637
  declare class TableColumnConfigButton extends Component<ColumnConfigButtonProps> {}
635
638
  interface TableExpandedRowContentProps extends HTMLAttributes<HTMLDivElement> {}
636
639
  declare class TableExpandedRowContent extends Component<TableExpandedRowContentProps> {}
640
+ declare class HoverDisplayArea extends Component<HTMLAttributes<HTMLDivElement>> {}
637
641
  export declare class Table extends Component<TableProps> {
638
642
  static ColumnConfigButton: typeof TableColumnConfigButton;
639
643
  static SearchInput: typeof Input['Search'];
640
644
  static ActionList: typeof ActionList;
641
645
  static ExpandedRowContent: typeof TableExpandedRowContent;
646
+ static HoverDisplayArea: typeof HoverDisplayArea;
642
647
  static getColumnConfigFromLocalStorage: typeof Function;
643
648
  static setColumnConfigToLocalStorage: typeof Function;
644
649
  }
@@ -766,7 +771,7 @@ export type PaginationProps = Override<
766
771
  current?: number;
767
772
  defaultCurrent?: number;
768
773
  total?: number;
769
- showTotal?: number | GetPaginationShowTotal;
774
+ showTotal?: boolean | GetPaginationShowTotal;
770
775
  pageSize?: number;
771
776
  defaultPageSize?: number;
772
777
  onChange?: (page: number, pageSize: number) => void;
@@ -1,6 +1,6 @@
1
- import React, { MouseEvent, ReactNode } from 'react';
1
+ import React, { HTMLAttributes, MouseEvent, ReactNode } from 'react';
2
2
  import { ButtonProps } from '../../components/Button/Button';
3
- import { Size } from '../../type';
3
+ import { Override, Size } from '../../type';
4
4
  interface ActionInfo {
5
5
  /** 展示 */
6
6
  label?: ReactNode;
@@ -12,8 +12,12 @@ interface ActionInfo {
12
12
  tooltip?: ReactNode | any;
13
13
  /** 禁用 */
14
14
  disabled?: boolean;
15
+ /** 尺寸,仅展示在外可用 */
16
+ size?: Size;
17
+ /** 按钮的 styleType,仅展示在外可用 */
18
+ styleType?: ButtonProps['styleType'];
15
19
  }
16
- export interface ActionListProps {
20
+ export interface DefinedActionListProps {
17
21
  /** 操作列表 */
18
22
  actionList: ActionInfo[];
19
23
  /** 暴露的操作数量 */
@@ -29,5 +33,6 @@ export interface ActionListProps {
29
33
  /** 弹出层的 popover props */
30
34
  popoverProps?: any;
31
35
  }
32
- declare const _default: React.MemoExoticComponent<({ actionList, exposeCount, size, smart, buttonStyleType, popoverProps, dropdownButton, className, ...rest }: ActionListProps & Omit<React.HTMLAttributes<HTMLDivElement>, keyof ActionListProps>) => JSX.Element>;
36
+ export declare type ActionListProps = DefinedActionListProps & Override<HTMLAttributes<HTMLDivElement>, DefinedActionListProps>;
37
+ declare const _default: React.MemoExoticComponent<({ actionList, exposeCount, size, smart, buttonStyleType, popoverProps, dropdownButton, className, ...rest }: ActionListProps) => JSX.Element>;
33
38
  export default _default;
@@ -1,8 +1,10 @@
1
1
  /// <reference types="react" />
2
- declare const ExportActionList: import("react").NamedExoticComponent<import("./ActionList").ActionListProps & Omit<import("react").HTMLAttributes<HTMLDivElement>, keyof import("./ActionList").ActionListProps>> & {
3
- readonly type: ({ actionList, exposeCount, size, smart, buttonStyleType, popoverProps, dropdownButton, className, ...rest }: import("./ActionList").ActionListProps & Omit<import("react").HTMLAttributes<HTMLDivElement>, keyof import("./ActionList").ActionListProps>) => JSX.Element;
2
+ import { ActionListProps } from './ActionList';
3
+ declare const ExportActionList: import("react").NamedExoticComponent<import("./ActionList").DefinedActionListProps & Omit<import("react").HTMLAttributes<HTMLDivElement>, keyof import("./ActionList").DefinedActionListProps>> & {
4
+ readonly type: ({ actionList, exposeCount, size, smart, buttonStyleType, popoverProps, dropdownButton, className, ...rest }: ActionListProps) => JSX.Element;
4
5
  } & {
5
6
  Sizes: ["sm", "md", "lg"];
6
7
  ButtonStyleTypes: ["primary", "border", "border-gray"];
7
8
  };
8
9
  export default ExportActionList;
10
+ export type { ActionListProps };
@@ -5,7 +5,7 @@ declare const defaultProps: {
5
5
  color: string;
6
6
  zIndex: number;
7
7
  };
8
- declare type BadgeProps = {
8
+ export declare type BadgeProps = {
9
9
  /** 显示内容 */
10
10
  value?: ReactNode;
11
11
  /** 为数字时能显示的最大值,超过将显示最大值+ */
@@ -1,2 +1,7 @@
1
- import Badge from './Badge';
2
- export default Badge;
1
+ import Badge, { BadgeProps } from './Badge';
2
+ import Bubble from './Bubble';
3
+ declare const ExportBadge: typeof Badge & {
4
+ Bubble: typeof Bubble;
5
+ };
6
+ export default ExportBadge;
7
+ export type { BadgeProps };
@@ -7,10 +7,14 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _type = require("../../type");
11
+
10
12
  var _Badge = _interopRequireDefault(require("./Badge"));
11
13
 
12
14
  var _Bubble = _interopRequireDefault(require("./Bubble"));
13
15
 
14
- _Badge.default.Bubble = _Bubble.default;
15
- var _default = _Badge.default;
16
+ var ExportBadge = (0, _type.ExportComponent)(_Badge.default, {
17
+ Bubble: _Bubble.default
18
+ });
19
+ var _default = ExportBadge;
16
20
  exports.default = _default;
@@ -1,4 +1,4 @@
1
- import { HTMLAttributes } from 'react';
1
+ import { AnchorHTMLAttributes } from 'react';
2
2
  export interface ItemProps {
3
3
  /** 禁用 */
4
4
  disabled?: boolean;
@@ -10,7 +10,7 @@ export interface ItemProps {
10
10
  href?: string;
11
11
  }
12
12
  declare const Item: {
13
- ({ disabled, onClick, href, ...rest }: ItemProps & HTMLAttributes<HTMLElement>): JSX.Element;
13
+ ({ disabled, onClick, href, ...rest }: ItemProps & AnchorHTMLAttributes<HTMLAnchorElement>): JSX.Element;
14
14
  __IS_BREADCRUMB_ITEM: boolean;
15
15
  };
16
16
  export default Item;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  declare const ExportBreadcrumb: (({ separator, styleType, children, ...rest }: import("./Breadcrumb").BreadcrumbProps & import("react").HTMLAttributes<HTMLElement>) => JSX.Element) & {
3
3
  Item: {
4
- ({ disabled, onClick, href, ...rest }: import("./Item").ItemProps & import("react").HTMLAttributes<HTMLElement>): JSX.Element;
4
+ ({ disabled, onClick, href, ...rest }: import("./Item").ItemProps & import("react").AnchorHTMLAttributes<HTMLAnchorElement>): JSX.Element;
5
5
  __IS_BREADCRUMB_ITEM: boolean;
6
6
  };
7
7
  BackButton: (props: import("../Button/Button").ButtonProps & import("react").HTMLAttributes<HTMLButtonElement>) => JSX.Element;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
- declare const ExportCheckbox: import("react").NamedExoticComponent<import("./Checkbox").CheckboxProps & Omit<import("react").HTMLAttributes<HTMLElement>, keyof import("./Checkbox").CheckboxProps>> & {
3
- readonly type: ({ defaultChecked, checked: _checked, onChange: _onChange, value, onClick, disabledLabel, ...restProps }: import("./Checkbox").CheckboxProps & Omit<import("react").HTMLAttributes<HTMLElement>, keyof import("./Checkbox").CheckboxProps>) => JSX.Element;
2
+ import { CheckboxProps } from './Checkbox';
3
+ declare const ExportCheckbox: import("react").NamedExoticComponent<CheckboxProps & Omit<import("react").HTMLAttributes<HTMLElement>, keyof CheckboxProps>> & {
4
+ readonly type: ({ defaultChecked, checked: _checked, onChange: _onChange, value, onClick, disabledLabel, ...restProps }: CheckboxProps & Omit<import("react").HTMLAttributes<HTMLElement>, keyof CheckboxProps>) => JSX.Element;
4
5
  } & {
5
6
  Group: import("react").MemoExoticComponent<({ value: _value, defaultValue, onChange: _onChange, options, disabled, size, styleType, children, ...rest }: import("./Group").GroupProps) => JSX.Element>;
6
7
  /** @deprecated */
@@ -9,3 +10,4 @@ declare const ExportCheckbox: import("react").NamedExoticComponent<import("./Che
9
10
  Size: ["sm", "md", "lg"];
10
11
  };
11
12
  export default ExportCheckbox;
13
+ export type { CheckboxProps };
@@ -107,7 +107,12 @@ var addModal = function addModal(modal) {
107
107
 
108
108
  var cleanAllModal = function cleanAllModal() {
109
109
  (0, _newArrowCheck2.default)(this, _this);
110
- Object.keys(queueMap).forEach(cleanModal);
110
+ var remainModalCount = Object.keys(queueMap).length;
111
+
112
+ if (remainModalCount) {
113
+ Object.keys(queueMap).forEach(cleanModal);
114
+ return remainModalCount;
115
+ }
111
116
  }.bind(void 0);
112
117
 
113
118
  exports.destroyAll = cleanAllModal;
@@ -1,33 +1,16 @@
1
- export default Notice;
2
- declare class Notice extends React.Component<any, any, any> {
3
- static propTypes: {
4
- /** @ignore */
5
- className: PropTypes.Requireable<string>;
6
- /** 是否显示关闭按钮 */
7
- closable: PropTypes.Requireable<boolean>;
8
- /** 自定义前置icon,可传入Icon type或者自定义Icon,传入null、false隐藏,默认显示感叹号icon */
9
- icon: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
10
- /** @ignore */
11
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
12
- /** 关闭的回调 */
13
- onClose: PropTypes.Requireable<(...args: any[]) => any>;
14
- /** 样式类型 */
15
- styleType: PropTypes.Requireable<string>;
16
- /** 自定义操作 */
17
- action: PropTypes.Requireable<PropTypes.ReactNodeLike>;
18
- };
19
- static defaultProps: {
20
- closable: boolean;
21
- styleType: string;
22
- onClose: () => void;
23
- };
24
- constructor(props: any);
25
- constructor(props: any, context: any);
26
- onClose: (e: any) => void;
27
- }
28
- declare namespace Notice {
29
- export { StyleType };
30
- }
31
- import React from "react";
32
- import PropTypes from "prop-types";
33
- declare const StyleType: string[];
1
+ import React, { ReactNode, MouseEvent, HTMLAttributes } from 'react';
2
+ export declare const StyleTypes: ["default", "success", "warning", "error", "disabled"];
3
+ export declare type NoticeProps = {
4
+ /** 是否显示关闭按钮 */
5
+ closable?: boolean;
6
+ /** 自定义前置icon,可传入Icon type或者自定义Icon,传入null、false隐藏,默认显示感叹号icon */
7
+ icon?: null | false | string | ReactNode;
8
+ /** 关闭的回调 */
9
+ onClose?: (e: MouseEvent) => void;
10
+ /** 样式类型 */
11
+ styleType?: 'default' | 'success' | 'warning' | 'error' | 'disabled' | 'info';
12
+ /** 自定义操作 */
13
+ action?: ReactNode;
14
+ } & HTMLAttributes<HTMLDivElement>;
15
+ declare const _default: React.MemoExoticComponent<({ closable, icon: _icon, children, onClose, styleType, action, ...rest }: NoticeProps) => JSX.Element | null>;
16
+ export default _default;
@@ -7,30 +7,20 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.default = void 0;
10
+ exports.default = exports.StyleTypes = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
14
16
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
17
 
16
18
  var _newArrowCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/newArrowCheck"));
17
19
 
18
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
-
20
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
-
22
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
-
24
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
25
-
26
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
27
-
28
- var _isString2 = _interopRequireDefault(require("lodash/isString"));
20
+ var _propTypes = _interopRequireDefault(require("prop-types"));
29
21
 
30
22
  var _react = _interopRequireWildcard(require("react"));
31
23
 
32
- var _propTypes = _interopRequireDefault(require("prop-types"));
33
-
34
24
  var _Icon = _interopRequireDefault(require("../../components/Icon"));
35
25
 
36
26
  var _SvgIcon = _interopRequireDefault(require("../../components/SvgIcon"));
@@ -39,137 +29,98 @@ var _deprecatedLog = _interopRequireDefault(require("../../utils/deprecatedLog")
39
29
 
40
30
  var _style = require("./style");
41
31
 
42
- var _this3 = void 0;
32
+ var _noop = _interopRequireDefault(require("../../utils/noop"));
33
+
34
+ var _style2 = require("../../style");
43
35
 
44
36
  var _excluded = ["closable", "icon", "children", "onClose", "styleType", "action"];
45
37
 
38
+ var _this = void 0;
39
+
46
40
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
47
41
 
48
42
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
49
43
 
50
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
51
-
52
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
53
-
54
44
  var deprecatedLogForStyleTypeInfo = (0, _deprecatedLog.default)('Notice styleType "info"', '"success"');
55
- var StyleType = ['default', 'success', 'warning', 'error', 'disabled'];
56
-
57
- var Notice = /*#__PURE__*/function (_Component) {
58
- (0, _inherits2.default)(Notice, _Component);
59
-
60
- var _super = _createSuper(Notice);
61
-
62
- function Notice() {
63
- var _this2 = this;
64
-
65
- var _this;
66
-
67
- (0, _classCallCheck2.default)(this, Notice);
68
-
69
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
70
- args[_key] = arguments[_key];
45
+ var StyleTypes = (0, _style2.tuple)('default', 'success', 'warning', 'error', 'disabled');
46
+ exports.StyleTypes = StyleTypes;
47
+
48
+ var Notice = function Notice(_ref) {
49
+ var _this2 = this;
50
+
51
+ (0, _newArrowCheck2.default)(this, _this);
52
+ var _ref$closable = _ref.closable,
53
+ closable = _ref$closable === void 0 ? true : _ref$closable,
54
+ _icon = _ref.icon,
55
+ children = _ref.children,
56
+ _ref$onClose = _ref.onClose,
57
+ onClose = _ref$onClose === void 0 ? _noop.default : _ref$onClose,
58
+ _ref$styleType = _ref.styleType,
59
+ styleType = _ref$styleType === void 0 ? 'default' : _ref$styleType,
60
+ action = _ref.action,
61
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
62
+
63
+ var _useState = (0, _react.useState)(false),
64
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
65
+ closed = _useState2[0],
66
+ setClosed = _useState2[1];
67
+
68
+ var handleClose = (0, _react.useCallback)(function (e) {
69
+ (0, _newArrowCheck2.default)(this, _this2);
70
+ setClosed(true);
71
+ onClose(e);
72
+ }.bind(this), [onClose]);
73
+ (0, _react.useEffect)(function () {
74
+ (0, _newArrowCheck2.default)(this, _this2);
75
+
76
+ if (styleType === 'info') {
77
+ deprecatedLogForStyleTypeInfo();
71
78
  }
72
-
73
- _this = _super.call.apply(_super, [this].concat(args));
74
- _this.state = {
75
- closed: false
76
- };
77
-
78
- _this.onClose = function (e) {
79
- (0, _newArrowCheck2.default)(this, _this2);
80
- var onClose = _this.props.onClose;
81
-
82
- _this.setState({
83
- closed: true
84
- });
85
-
86
- onClose(e);
87
- }.bind(this);
88
-
89
- return _this;
79
+ }.bind(this), [styleType]);
80
+ var icon;
81
+
82
+ if (_icon === null || _icon === false) {
83
+ icon = null;
84
+ } else if (typeof _icon === 'string') {
85
+ icon = /*#__PURE__*/_react.default.createElement(_Icon.default, {
86
+ className: _style.iconCls,
87
+ type: _icon
88
+ });
89
+ } else if ( /*#__PURE__*/_react.default.isValidElement(_icon)) {
90
+ icon = _icon;
91
+ } else {
92
+ icon = /*#__PURE__*/_react.default.createElement(_SvgIcon.default, {
93
+ size: "15px",
94
+ className: _style.iconCls,
95
+ type: "exclamation-circle-filled"
96
+ });
90
97
  }
91
98
 
92
- (0, _createClass2.default)(Notice, [{
93
- key: "componentWillMount",
94
- value: function componentWillMount() {
95
- var styleType = this.props.styleType;
96
-
97
- if (styleType === 'info') {
98
- deprecatedLogForStyleTypeInfo();
99
- }
100
- }
101
- }, {
102
- key: "render",
103
- value: function render() {
104
- // eslint-disable-next-line no-unused-vars
105
- var _this$props = this.props,
106
- closable = _this$props.closable,
107
- _icon = _this$props.icon,
108
- children = _this$props.children,
109
- onClose = _this$props.onClose,
110
- styleType = _this$props.styleType,
111
- action = _this$props.action,
112
- rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
113
- var closed = this.state.closed;
114
- var icon;
115
-
116
- if (_icon === null || _icon === false) {
117
- icon = null;
118
- } else if ((0, _isString2.default)(_icon)) {
119
- icon = /*#__PURE__*/_react.default.createElement(_Icon.default, {
120
- className: _style.iconCls,
121
- type: _icon
122
- });
123
- } else if ( /*#__PURE__*/_react.default.isValidElement(_icon)) {
124
- icon = _icon;
125
- } else {
126
- icon = /*#__PURE__*/_react.default.createElement(_SvgIcon.default, {
127
- size: "15px",
128
- className: _style.iconCls,
129
- type: "exclamation-circle-filled"
130
- });
131
- }
132
-
133
- return closed ? null : /*#__PURE__*/_react.default.createElement(_style.NoticeWrap, (0, _extends2.default)({}, rest, {
134
- styleType: styleType
135
- }), icon && /*#__PURE__*/_react.default.createElement(_style.NoticeIconWrap, null, icon), /*#__PURE__*/_react.default.createElement(_style.ContentWrap, null, children), action && /*#__PURE__*/_react.default.createElement(_style.ActionWrap, null, action), closable && /*#__PURE__*/_react.default.createElement(_style.CloseWrap, null, /*#__PURE__*/_react.default.createElement(_style.CloseIcon, {
136
- type: "cross",
137
- onClick: this.onClose
138
- })));
139
- }
140
- }]);
141
- return Notice;
142
- }(_react.Component);
99
+ return closed ? null : /*#__PURE__*/_react.default.createElement(_style.NoticeWrap, (0, _extends2.default)({}, rest, {
100
+ styleType: styleType
101
+ }), icon && /*#__PURE__*/_react.default.createElement("span", {
102
+ className: _style.iconWrapCls
103
+ }, icon), /*#__PURE__*/_react.default.createElement("div", {
104
+ className: _style.contentCls
105
+ }, children), action && /*#__PURE__*/_react.default.createElement("span", {
106
+ className: _style.actionCls
107
+ }, action), closable && /*#__PURE__*/_react.default.createElement("span", {
108
+ className: _style.closeCls
109
+ }, /*#__PURE__*/_react.default.createElement(_SvgIcon.default, {
110
+ type: "cross",
111
+ className: _style.iconCls,
112
+ onClick: handleClose
113
+ })));
114
+ }.bind(void 0);
143
115
 
144
116
  Notice.propTypes = {
145
- /** @ignore */
146
- className: _propTypes.default.string,
147
-
148
- /** 是否显示关闭按钮 */
149
117
  closable: _propTypes.default.bool,
150
-
151
- /** 自定义前置icon,可传入Icon type或者自定义Icon,传入null、false隐藏,默认显示感叹号icon */
152
- icon: _propTypes.default.oneOfType([_propTypes.default.oneOf([null, false]), _propTypes.default.string, _propTypes.default.node]),
153
-
154
- /** @ignore */
155
- children: _propTypes.default.node,
156
-
157
- /** 关闭的回调 */
118
+ icon: _propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.oneOf([false]), _propTypes.default.string, _propTypes.default.node]),
158
119
  onClose: _propTypes.default.func,
159
-
160
- /** 样式类型 */
161
- styleType: _propTypes.default.oneOf(StyleType),
162
-
163
- /** 自定义操作 */
120
+ styleType: _propTypes.default.oneOf(['default', 'success', 'warning', 'error', 'disabled', 'info']),
164
121
  action: _propTypes.default.node
165
122
  };
166
- Notice.defaultProps = {
167
- closable: true,
168
- styleType: StyleType[0],
169
- onClose: function onClose() {
170
- (0, _newArrowCheck2.default)(this, _this3);
171
- }.bind(void 0)
172
- };
173
- Notice.StyleType = StyleType;
174
- var _default = Notice;
123
+
124
+ var _default = /*#__PURE__*/_react.default.memo(Notice);
125
+
175
126
  exports.default = _default;
@@ -1,2 +1,16 @@
1
- export default Notice;
2
- import Notice from "./Notice";
1
+ /// <reference types="react" />
2
+ import { NoticeProps } from './Notice';
3
+ declare const ExportNotice: import("react").NamedExoticComponent<{
4
+ closable?: boolean | undefined;
5
+ icon?: import("react").ReactNode;
6
+ onClose?: ((e: import("react").MouseEvent<Element, MouseEvent>) => void) | undefined;
7
+ styleType?: "default" | "disabled" | "success" | "warning" | "error" | "info" | undefined;
8
+ action?: import("react").ReactNode;
9
+ } & import("react").HTMLAttributes<HTMLDivElement>> & {
10
+ readonly type: ({ closable, icon: _icon, children, onClose, styleType, action, ...rest }: NoticeProps) => JSX.Element | null;
11
+ } & {
12
+ /** @deprecated */
13
+ StyleType: ["default", "success", "warning", "error", "disabled"];
14
+ };
15
+ export default ExportNotice;
16
+ export type { NoticeProps };