@douyinfe/semi-ui 2.53.3-alpha.1 → 2.54.0-beta.0

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.
Files changed (39) hide show
  1. package/dist/css/semi.css +9 -0
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +603 -438
  4. package/dist/umd/semi-ui.js.map +1 -1
  5. package/dist/umd/semi-ui.min.js +1 -1
  6. package/dist/umd/semi-ui.min.js.map +1 -1
  7. package/lib/cjs/cascader/index.d.ts +3 -0
  8. package/lib/cjs/cascader/index.js +11 -4
  9. package/lib/cjs/collapsible/index.d.ts +1 -0
  10. package/lib/cjs/collapsible/index.js +4 -3
  11. package/lib/cjs/descriptions/descriptions-context.d.ts +2 -0
  12. package/lib/cjs/descriptions/index.d.ts +17 -4
  13. package/lib/cjs/descriptions/index.js +52 -16
  14. package/lib/cjs/descriptions/item.d.ts +1 -0
  15. package/lib/cjs/descriptions/item.js +20 -13
  16. package/lib/cjs/image/interface.d.ts +1 -0
  17. package/lib/cjs/image/previewInner.js +6 -0
  18. package/lib/cjs/modal/Modal.d.ts +4 -4
  19. package/lib/cjs/modal/Modal.js +12 -11
  20. package/lib/cjs/modal/confirm.d.ts +1 -1
  21. package/lib/cjs/toast/index.js +3 -0
  22. package/lib/cjs/typography/base.js +3 -3
  23. package/lib/es/cascader/index.d.ts +3 -0
  24. package/lib/es/cascader/index.js +11 -4
  25. package/lib/es/collapsible/index.d.ts +1 -0
  26. package/lib/es/collapsible/index.js +4 -3
  27. package/lib/es/descriptions/descriptions-context.d.ts +2 -0
  28. package/lib/es/descriptions/index.d.ts +17 -4
  29. package/lib/es/descriptions/index.js +52 -14
  30. package/lib/es/descriptions/item.d.ts +1 -0
  31. package/lib/es/descriptions/item.js +20 -13
  32. package/lib/es/image/interface.d.ts +1 -0
  33. package/lib/es/image/previewInner.js +6 -0
  34. package/lib/es/modal/Modal.d.ts +4 -4
  35. package/lib/es/modal/Modal.js +12 -11
  36. package/lib/es/modal/confirm.d.ts +1 -1
  37. package/lib/es/toast/index.js +3 -0
  38. package/lib/es/typography/base.js +3 -3
  39. package/package.json +8 -8
@@ -1,14 +1,17 @@
1
- import React, { PureComponent } from 'react';
1
+ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import '@douyinfe/semi-foundation/lib/es/descriptions/descriptions.css';
4
- import { DescriptionsAlign, DescriptionsContextValue } from './descriptions-context';
4
+ import { DescriptionsAlign, DescriptionLayout } from './descriptions-context';
5
5
  import Item from './item';
6
+ import DescriptionsFoundation, { DescriptionsAdapter } from '@douyinfe/semi-foundation/lib/es/descriptions/foundation';
7
+ import BaseComponent from '../_base/baseComponent';
6
8
  export type { DescriptionsItemProps } from './item';
7
9
  export type DescriptionsSize = 'small' | 'medium' | 'large';
8
10
  export interface Data {
9
11
  key?: React.ReactNode;
10
12
  value?: (() => React.ReactNode) | React.ReactNode;
11
13
  hidden?: boolean;
14
+ span?: number;
12
15
  }
13
16
  export interface DescriptionsProps {
14
17
  align?: DescriptionsAlign;
@@ -18,10 +21,12 @@ export interface DescriptionsProps {
18
21
  className?: string;
19
22
  children?: React.ReactNode;
20
23
  data?: Data[];
24
+ layout?: DescriptionLayout;
25
+ column?: number;
21
26
  }
22
- declare class Descriptions extends PureComponent<DescriptionsProps> {
27
+ declare class Descriptions extends BaseComponent<DescriptionsProps> {
23
28
  static Item: typeof Item;
24
- static contextType: React.Context<DescriptionsContextValue>;
29
+ static contextType: React.Context<import("./descriptions-context").DescriptionsContextValue>;
25
30
  static propTypes: {
26
31
  align: PropTypes.Requireable<string>;
27
32
  row: PropTypes.Requireable<boolean>;
@@ -35,13 +40,21 @@ declare class Descriptions extends PureComponent<DescriptionsProps> {
35
40
  className: PropTypes.Requireable<string>;
36
41
  style: PropTypes.Requireable<object>;
37
42
  }>[]>;
43
+ layout: PropTypes.Requireable<string>;
44
+ column: PropTypes.Requireable<number>;
38
45
  };
39
46
  static defaultProps: {
40
47
  align: string;
41
48
  row: boolean;
42
49
  size: string;
43
50
  data: Data[];
51
+ layout: string;
52
+ column: number;
44
53
  };
54
+ foundation: DescriptionsFoundation;
55
+ constructor(props: DescriptionsProps);
56
+ get adapter(): DescriptionsAdapter<DescriptionsProps>;
57
+ renderChildrenList: () => string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | JSX.Element[];
45
58
  render(): JSX.Element;
46
59
  }
47
60
  export default Descriptions;
@@ -7,7 +7,7 @@ var __rest = this && this.__rest || function (s, e) {
7
7
  }
8
8
  return t;
9
9
  };
10
- import React, { PureComponent } from 'react';
10
+ import React from 'react';
11
11
  import cls from 'classnames';
12
12
  import PropTypes from 'prop-types';
13
13
  import { strings, cssClasses } from '@douyinfe/semi-foundation/lib/es/descriptions/constants';
@@ -15,8 +15,43 @@ import '@douyinfe/semi-foundation/lib/es/descriptions/descriptions.css';
15
15
  import getDataAttr from '@douyinfe/semi-foundation/lib/es/utils/getDataAttr';
16
16
  import DescriptionsContext from './descriptions-context';
17
17
  import Item from './item';
18
+ import DescriptionsFoundation from '@douyinfe/semi-foundation/lib/es/descriptions/foundation';
19
+ import BaseComponent from '../_base/baseComponent';
18
20
  const prefixCls = cssClasses.PREFIX;
19
- class Descriptions extends PureComponent {
21
+ class Descriptions extends BaseComponent {
22
+ constructor(props) {
23
+ super(props);
24
+ this.renderChildrenList = () => {
25
+ const props = this.props;
26
+ const {
27
+ layout,
28
+ data,
29
+ children
30
+ } = props;
31
+ if (layout === 'horizontal') {
32
+ const horizontalList = this.foundation.getHorizontalList();
33
+ return horizontalList.map((row, index) => {
34
+ return /*#__PURE__*/React.createElement("tr", {
35
+ key: index
36
+ }, row.map((item, itemIndex) => _isPlainObject(item) ? /*#__PURE__*/React.createElement(Item, Object.assign({
37
+ itemKey: item.key
38
+ }, item, {
39
+ key: index + '-' + itemIndex
40
+ }), item.value) : null));
41
+ });
42
+ } else {
43
+ return data && data.length ? data.map((item, index) => _isPlainObject(item) ? /*#__PURE__*/React.createElement(Item, Object.assign({
44
+ itemKey: item.key
45
+ }, item, {
46
+ key: index
47
+ }), item.value) : null) : children;
48
+ }
49
+ };
50
+ this.foundation = new DescriptionsFoundation(this.adapter);
51
+ }
52
+ get adapter() {
53
+ return Object.assign({}, super.adapter);
54
+ }
20
55
  render() {
21
56
  const _a = this.props,
22
57
  {
@@ -26,27 +61,26 @@ class Descriptions extends PureComponent {
26
61
  className,
27
62
  style,
28
63
  children,
29
- data
64
+ data,
65
+ layout
30
66
  } = _a,
31
- rest = __rest(_a, ["align", "row", "size", "className", "style", "children", "data"]);
67
+ rest = __rest(_a, ["align", "row", "size", "className", "style", "children", "data", "layout"]);
32
68
  const classNames = cls(prefixCls, className, {
33
69
  [`${prefixCls}-${align}`]: !row,
34
70
  [`${prefixCls}-double`]: row,
35
- [`${prefixCls}-double-${size}`]: row
71
+ [`${prefixCls}-double-${size}`]: row,
72
+ [`${prefixCls}-horizontal`]: layout === 'horizontal',
73
+ [`${prefixCls}-vertical`]: layout === 'vertical'
36
74
  });
37
- const childrenList = data && data.length ? data.map((item, index) => _isPlainObject(item) ? /*#__PURE__*/React.createElement(Item, Object.assign({
38
- itemKey: item.key
39
- }, item, {
40
- key: index
41
- }), item.value) : null) : children;
42
75
  return /*#__PURE__*/React.createElement("div", Object.assign({
43
76
  className: classNames,
44
77
  style: style
45
78
  }, getDataAttr(rest)), /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement(DescriptionsContext.Provider, {
46
79
  value: {
47
- align
80
+ align,
81
+ layout
48
82
  }
49
- }, childrenList))));
83
+ }, this.renderChildrenList()))));
50
84
  }
51
85
  }
52
86
  Descriptions.Item = Item;
@@ -63,12 +97,16 @@ Descriptions.propTypes = {
63
97
  hidden: PropTypes.bool,
64
98
  className: PropTypes.string,
65
99
  style: PropTypes.object
66
- }))
100
+ })),
101
+ layout: PropTypes.oneOf(strings.LAYOUT_SET),
102
+ column: PropTypes.number
67
103
  };
68
104
  Descriptions.defaultProps = {
69
105
  align: 'center',
70
106
  row: false,
71
107
  size: 'medium',
72
- data: []
108
+ data: [],
109
+ layout: 'vertical',
110
+ column: 3
73
111
  };
74
112
  export default Descriptions;
@@ -8,6 +8,7 @@ export interface DescriptionsItemProps {
8
8
  children?: React.ReactNode | (() => React.ReactNode);
9
9
  style?: React.CSSProperties;
10
10
  itemKey?: React.ReactNode;
11
+ span?: number;
11
12
  }
12
13
  export default class Item extends PureComponent<DescriptionsItemProps> {
13
14
  static propTypes: {
@@ -22,38 +22,45 @@ export default class Item extends PureComponent {
22
22
  itemKey,
23
23
  hidden,
24
24
  className,
25
+ span,
25
26
  style,
26
27
  children
27
28
  } = _a,
28
- rest = __rest(_a, ["itemKey", "hidden", "className", "style", "children"]);
29
+ rest = __rest(_a, ["itemKey", "hidden", "className", "span", "style", "children"]);
29
30
  const {
30
- align
31
+ align,
32
+ layout
31
33
  } = this.context;
32
34
  if (hidden) {
33
35
  return null;
34
36
  }
35
- const item = align === 'plain' ? /*#__PURE__*/React.createElement("tr", Object.assign({
36
- className: className,
37
- style: style
38
- }, getDataAttr(rest)), /*#__PURE__*/React.createElement("td", {
39
- className: `${prefixCls}-item`
37
+ const plainItem = /*#__PURE__*/React.createElement("td", {
38
+ className: `${prefixCls}-item`,
39
+ colSpan: span || 1
40
40
  }, /*#__PURE__*/React.createElement("span", {
41
41
  className: keyCls
42
42
  }, itemKey, ":"), /*#__PURE__*/React.createElement("span", {
43
43
  className: valCls
44
- }, typeof children === 'function' ? children() : children))) : /*#__PURE__*/React.createElement("tr", Object.assign({
45
- className: className,
46
- style: style
47
- }, getDataAttr(rest)), /*#__PURE__*/React.createElement("th", {
44
+ }, typeof children === 'function' ? children() : children));
45
+ const alignItem = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("th", {
48
46
  className: `${prefixCls}-item ${prefixCls}-item-th`
49
47
  }, /*#__PURE__*/React.createElement("span", {
50
48
  className: keyCls
51
49
  }, itemKey)), /*#__PURE__*/React.createElement("td", {
52
- className: `${prefixCls}-item ${prefixCls}-item-td`
50
+ className: `${prefixCls}-item ${prefixCls}-item-td`,
51
+ colSpan: span || 1
53
52
  }, /*#__PURE__*/React.createElement("span", {
54
53
  className: valCls
55
54
  }, typeof children === 'function' ? children() : children)));
56
- return item;
55
+ const item = align === 'plain' ? /*#__PURE__*/React.createElement("tr", Object.assign({
56
+ className: className,
57
+ style: style
58
+ }, getDataAttr(rest)), plainItem) : /*#__PURE__*/React.createElement("tr", Object.assign({
59
+ className: className,
60
+ style: style
61
+ }, getDataAttr(rest)), alignItem);
62
+ const horizontalItem = align === 'plain' ? plainItem : alignItem;
63
+ return layout === 'horizontal' ? horizontalItem : item;
57
64
  }
58
65
  }
59
66
  Item.propTypes = {
@@ -71,6 +71,7 @@ export interface PreviewProps extends BaseProps {
71
71
  onRatioChange?: (type: RatioType) => void;
72
72
  onRotateLeft?: (angle: number) => void;
73
73
  onDownload?: (src: string, index: number) => void;
74
+ onDownloadError?: (src: string) => void;
74
75
  setDownloadName?: (src: string) => string;
75
76
  }
76
77
  export interface PreviewInnerProps extends Omit<PreviewProps, "previewCls" | "previewStyle"> {
@@ -91,6 +91,12 @@ export default class PreviewInner extends BaseComponent {
91
91
  } = this.props;
92
92
  _isFunction(onDownload) && onDownload(src, index);
93
93
  },
94
+ notifyDownloadError: src => {
95
+ const {
96
+ onDownloadError
97
+ } = this.props;
98
+ _isFunction(onDownloadError) && onDownloadError(src);
99
+ },
94
100
  registerKeyDownListener: () => {
95
101
  window && window.addEventListener("keydown", this.handleKeyDown);
96
102
  },
@@ -1,11 +1,11 @@
1
- import React, { CSSProperties, ReactNode } from 'react';
1
+ import '@douyinfe/semi-foundation/lib/es/modal/modal.css';
2
2
  import ModalFoundation, { ModalAdapter, ModalProps, ModalState } from '@douyinfe/semi-foundation/lib/es/modal/modalFoundation';
3
3
  import PropTypes from 'prop-types';
4
- import '@douyinfe/semi-foundation/lib/es/modal/modal.css';
4
+ import React, { CSSProperties, ReactNode } from 'react';
5
5
  import BaseComponent from '../_base/baseComponent';
6
- import useModal from './useModal';
7
6
  import { ButtonProps } from '../button/Button';
8
- export declare const destroyFns: any[];
7
+ import useModal from './useModal';
8
+ export declare let destroyFns: any[];
9
9
  export type ConfirmType = 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
10
10
  export type Directions = 'ltr' | 'rtl';
11
11
  export type { ModalState };
@@ -7,22 +7,22 @@ var __rest = this && this.__rest || function (s, e) {
7
7
  }
8
8
  return t;
9
9
  };
10
- import React from 'react';
11
10
  import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/modal/constants';
12
- import Button from '../button';
11
+ import '@douyinfe/semi-foundation/lib/es/modal/modal.css';
13
12
  import ModalFoundation from '@douyinfe/semi-foundation/lib/es/modal/modalFoundation';
14
- import ModalContent from './ModalContent';
15
- import Portal from '../_portal';
16
- import LocaleConsumer from '../locale/localeConsumer';
17
13
  import cls from 'classnames';
18
14
  import PropTypes from 'prop-types';
19
- import '@douyinfe/semi-foundation/lib/es/modal/modal.css';
15
+ import React from 'react';
20
16
  import BaseComponent from '../_base/baseComponent';
21
- import confirm, { withConfirm, withError, withInfo, withSuccess, withWarning } from './confirm';
22
- import useModal from './useModal';
23
17
  import CSSAnimation from "../_cssAnimation";
18
+ import Portal from '../_portal';
24
19
  import { getDefaultPropsFromGlobalConfig, getScrollbarWidth } from '../_utils';
25
- export const destroyFns = [];
20
+ import Button from '../button';
21
+ import LocaleConsumer from '../locale/localeConsumer';
22
+ import ModalContent from './ModalContent';
23
+ import confirm, { withConfirm, withError, withInfo, withSuccess, withWarning } from './confirm';
24
+ import useModal from './useModal';
25
+ export let destroyFns = [];
26
26
  class Modal extends BaseComponent {
27
27
  constructor(props) {
28
28
  super(props);
@@ -349,11 +349,12 @@ Modal.confirm = function (props) {
349
349
  return confirm(withConfirm(props));
350
350
  };
351
351
  Modal.destroyAll = function destroyAllFn() {
352
- while (destroyFns.length) {
353
- const close = destroyFns.pop();
352
+ for (let i = 0, len = destroyFns.length; i < len; i++) {
353
+ const close = destroyFns[i];
354
354
  if (close) {
355
355
  close();
356
356
  }
357
357
  }
358
+ destroyFns = [];
358
359
  };
359
360
  export default Modal;
@@ -166,6 +166,7 @@ export declare function withError(props: ModalReactProps): {
166
166
  icon: string | number | boolean | React.ReactFragment | JSX.Element;
167
167
  closable?: boolean;
168
168
  onCancel?: (e: React.MouseEvent<Element, MouseEvent>) => void | Promise<any>;
169
+ lazyRender?: boolean;
169
170
  bodyStyle?: React.CSSProperties;
170
171
  cancelButtonProps?: import("../button").BaseButtonProps;
171
172
  cancelText?: string;
@@ -180,7 +181,6 @@ export declare function withError(props: ModalReactProps): {
180
181
  okType?: import("@douyinfe/semi-foundation/lib/es/modal/modalFoundation").OKType;
181
182
  onOk?: (e: React.MouseEvent<Element, MouseEvent>) => void | Promise<any>;
182
183
  closeIcon?: React.ReactNode;
183
- lazyRender?: boolean;
184
184
  fullScreen?: boolean;
185
185
  footerFill?: boolean;
186
186
  type: "error";
@@ -178,6 +178,9 @@ const createBaseToast = () => {
178
178
  ToastList.defaultOpts[pos] = opts[pos];
179
179
  }
180
180
  });
181
+ if (typeof opts.theme === 'string' && strings.themes.includes(opts.theme)) {
182
+ ToastList.defaultOpts.theme = opts.theme;
183
+ }
181
184
  if (typeof opts.zIndex === 'number') {
182
185
  ToastList.defaultOpts.zIndex = opts.zIndex;
183
186
  }
@@ -424,7 +424,7 @@ export default class Base extends Component {
424
424
  ellipsisContent: props.children,
425
425
  expanded: false,
426
426
  // if text is truncated with js
427
- isTruncated: true,
427
+ isTruncated: false,
428
428
  prevChildren: null
429
429
  };
430
430
  this.wrapperRef = /*#__PURE__*/React.createRef();
@@ -445,10 +445,10 @@ export default class Base extends Component {
445
445
  newState.prevChildren = props.children;
446
446
  if (props.ellipsis && prevChildren !== props.children) {
447
447
  // reset ellipsis state if children update
448
- newState.isOverflowed = true;
448
+ newState.isOverflowed = false;
449
449
  newState.ellipsisContent = props.children;
450
450
  newState.expanded = false;
451
- newState.isTruncated = true;
451
+ newState.isTruncated = false;
452
452
  }
453
453
  return newState;
454
454
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.53.3-alpha.1",
3
+ "version": "2.54.0-beta.0",
4
4
  "description": "A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -20,12 +20,12 @@
20
20
  "@dnd-kit/core": "^6.0.8",
21
21
  "@dnd-kit/sortable": "^7.0.2",
22
22
  "@dnd-kit/utilities": "^3.2.1",
23
- "@douyinfe/semi-animation": "2.53.3-alpha.1",
24
- "@douyinfe/semi-animation-react": "2.53.3-alpha.1",
25
- "@douyinfe/semi-foundation": "2.53.3-alpha.1",
26
- "@douyinfe/semi-icons": "2.53.3-alpha.1",
27
- "@douyinfe/semi-illustrations": "2.53.3-alpha.1",
28
- "@douyinfe/semi-theme-default": "2.53.3-alpha.1",
23
+ "@douyinfe/semi-animation": "2.54.0-beta.0",
24
+ "@douyinfe/semi-animation-react": "2.54.0-beta.0",
25
+ "@douyinfe/semi-foundation": "2.54.0-beta.0",
26
+ "@douyinfe/semi-icons": "2.54.0-beta.0",
27
+ "@douyinfe/semi-illustrations": "2.54.0-beta.0",
28
+ "@douyinfe/semi-theme-default": "2.54.0-beta.0",
29
29
  "async-validator": "^3.5.0",
30
30
  "classnames": "^2.2.6",
31
31
  "copy-text-to-clipboard": "^2.1.1",
@@ -75,7 +75,7 @@
75
75
  ],
76
76
  "author": "",
77
77
  "license": "MIT",
78
- "gitHead": "fe551539e3e4e2480feedeced44dc4d8e9497a96",
78
+ "gitHead": "b661fb2006bd11849e02af7f8e1b412c59b94781",
79
79
  "devDependencies": {
80
80
  "@babel/plugin-proposal-decorators": "^7.15.8",
81
81
  "@babel/plugin-transform-runtime": "^7.15.8",