@douyinfe/semi-ui 2.37.0 → 2.38.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.
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { ContextValue } from '../configProvider/context';
4
4
  import '@douyinfe/semi-foundation/lib/cjs/badge/badge.css';
5
- export type BadgeType = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning';
5
+ export type BadgeType = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'success';
6
6
  export type BadgeTheme = 'solid' | 'light' | 'inverted';
7
7
  export type BadgePosition = 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
8
8
  export interface BadgeProps {
@@ -169,7 +169,7 @@ class Cascader extends _baseComponent.default {
169
169
  const renderPlusNChildren = /*#__PURE__*/_react.default.createElement("span", {
170
170
  className: plusNCls
171
171
  }, "+", hiddenTag.length);
172
- return showRestTagsPopover && !disabled ? /*#__PURE__*/_react.default.createElement(_index2.default, Object.assign({
172
+ return showRestTagsPopover ? /*#__PURE__*/_react.default.createElement(_index2.default, Object.assign({
173
173
  content: hiddenTag,
174
174
  showArrow: true,
175
175
  trigger: "hover",
@@ -15,6 +15,7 @@ var _previewFoundation = _interopRequireDefault(require("@douyinfe/semi-foundati
15
15
  var _uuid = require("@douyinfe/semi-foundation/lib/cjs/utils/uuid");
16
16
  var _constants = require("@douyinfe/semi-foundation/lib/cjs/image/constants");
17
17
  require("@douyinfe/semi-foundation/lib/cjs/image/image.css");
18
+ var _classnames = _interopRequireDefault(require("classnames"));
18
19
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
20
  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; }
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -147,10 +148,11 @@ class Preview extends _baseComponent.default {
147
148
  const _a = this.props,
148
149
  {
149
150
  src,
151
+ className,
150
152
  style,
151
153
  lazyLoad
152
154
  } = _a,
153
- restProps = __rest(_a, ["src", "style", "lazyLoad"]);
155
+ restProps = __rest(_a, ["src", "className", "style", "lazyLoad"]);
154
156
  const {
155
157
  currentIndex,
156
158
  visible
@@ -177,7 +179,7 @@ class Preview extends _baseComponent.default {
177
179
  }, /*#__PURE__*/_react.default.createElement("div", {
178
180
  id: this.previewGroupId,
179
181
  style: style,
180
- className: `${prefixCls}-preview-group`
182
+ className: (0, _classnames.default)(`${prefixCls}-preview-group`, className)
181
183
  }, newChildren), /*#__PURE__*/_react.default.createElement(_previewInner.default, Object.assign({}, restProps, {
182
184
  ref: this.previewRef,
183
185
  src: finalSrcList,
@@ -181,7 +181,7 @@ class Pagination extends _baseComponent.default {
181
181
  "aria-label": "Next",
182
182
  onClick: e => !isDisabled && this.foundation.goNext(e),
183
183
  className: nextClassName,
184
- "x-semi-prop": "prevText"
184
+ "x-semi-prop": "nextText"
185
185
  }, nextText || /*#__PURE__*/_react.default.createElement(_semiIcons.IconChevronRight, {
186
186
  size: "large"
187
187
  }));
@@ -4,9 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useToast;
7
- var _react = _interopRequireDefault(require("react"));
7
+ var _noop2 = _interopRequireDefault(require("lodash/noop"));
8
+ var _react = _interopRequireWildcard(require("react"));
8
9
  var _uuid = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/uuid"));
9
10
  var _HookToast = _interopRequireDefault(require("./HookToast"));
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ 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; }
10
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
14
  // const ref = null;
12
15
  // TODO: toast larger than N bars, automatic folding, allowing expansion, N configurable
@@ -35,7 +38,7 @@ function usePatchElement() {
35
38
  }
36
39
  function useToast() {
37
40
  const [elements, patchElement] = usePatchElement();
38
- const toastRef = new Map();
41
+ const toastRef = (0, _react.useRef)(new Map());
39
42
  const addToast = config => {
40
43
  const id = (0, _uuid.default)('semi_toast_');
41
44
  const mergeConfig = Object.assign(Object.assign({}, config), {
@@ -43,20 +46,25 @@ function useToast() {
43
46
  });
44
47
  // eslint-disable-next-line prefer-const
45
48
  let closeFunc;
46
- const ref = ele => {
47
- toastRef.set(id, ele);
48
- };
49
49
  const toast = /*#__PURE__*/_react.default.createElement(_HookToast.default, Object.assign({}, mergeConfig, {
50
50
  key: id,
51
51
  afterClose: instanceId => closeFunc(instanceId),
52
- ref: ref
52
+ ref: data => {
53
+ var _a;
54
+ toastRef.current.set(id, {
55
+ close: (_a = data === null || data === void 0 ? void 0 : data.close) !== null && _a !== void 0 ? _a : _noop2.default
56
+ });
57
+ }
53
58
  }));
54
59
  closeFunc = patchElement(toast, Object.assign({}, mergeConfig));
55
60
  return id;
56
61
  };
57
62
  const removeElement = id => {
58
- const ele = toastRef.get(id);
59
- ele && ele.close();
63
+ var _a;
64
+ const {
65
+ close
66
+ } = (_a = toastRef.current.get(id)) !== null && _a !== void 0 ? _a : {};
67
+ close === null || close === void 0 ? void 0 : close();
60
68
  };
61
69
  return [{
62
70
  success: config => addToast(Object.assign(Object.assign(Object.assign({}, defaultOpts), config), {
@@ -463,8 +463,8 @@ class Tree extends _baseComponent.default {
463
463
  notifyChange: value => {
464
464
  this.props.onChange && this.props.onChange(value);
465
465
  },
466
- notifySearch: input => {
467
- this.props.onSearch && this.props.onSearch(input);
466
+ notifySearch: (input, filteredExpandedKeys) => {
467
+ this.props.onSearch && this.props.onSearch(input, filteredExpandedKeys);
468
468
  },
469
469
  notifyRightClick: (e, node) => {
470
470
  this.props.onContextMenu && this.props.onContextMenu(e, node);
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { ContextValue } from '../configProvider/context';
4
4
  import '@douyinfe/semi-foundation/lib/es/badge/badge.css';
5
- export type BadgeType = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning';
5
+ export type BadgeType = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'success';
6
6
  export type BadgeTheme = 'solid' | 'light' | 'inverted';
7
7
  export type BadgePosition = 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
8
8
  export interface BadgeProps {
@@ -160,7 +160,7 @@ class Cascader extends BaseComponent {
160
160
  const renderPlusNChildren = /*#__PURE__*/React.createElement("span", {
161
161
  className: plusNCls
162
162
  }, "+", hiddenTag.length);
163
- return showRestTagsPopover && !disabled ? /*#__PURE__*/React.createElement(Popover, Object.assign({
163
+ return showRestTagsPopover ? /*#__PURE__*/React.createElement(Popover, Object.assign({
164
164
  content: hiddenTag,
165
165
  showArrow: true,
166
166
  trigger: "hover",
@@ -17,6 +17,7 @@ import PreviewFoundation from '@douyinfe/semi-foundation/lib/es/image/previewFou
17
17
  import { getUuidShort } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
18
18
  import { cssClasses } from '@douyinfe/semi-foundation/lib/es/image/constants';
19
19
  import '@douyinfe/semi-foundation/lib/es/image/image.css';
20
+ import cls from "classnames";
20
21
  const prefixCls = cssClasses.PREFIX;
21
22
  export default class Preview extends BaseComponent {
22
23
  get adapter() {
@@ -138,10 +139,11 @@ export default class Preview extends BaseComponent {
138
139
  const _a = this.props,
139
140
  {
140
141
  src,
142
+ className,
141
143
  style,
142
144
  lazyLoad
143
145
  } = _a,
144
- restProps = __rest(_a, ["src", "style", "lazyLoad"]);
146
+ restProps = __rest(_a, ["src", "className", "style", "lazyLoad"]);
145
147
  const {
146
148
  currentIndex,
147
149
  visible
@@ -168,7 +170,7 @@ export default class Preview extends BaseComponent {
168
170
  }, /*#__PURE__*/React.createElement("div", {
169
171
  id: this.previewGroupId,
170
172
  style: style,
171
- className: `${prefixCls}-preview-group`
173
+ className: cls(`${prefixCls}-preview-group`, className)
172
174
  }, newChildren), /*#__PURE__*/React.createElement(PreviewInner, Object.assign({}, restProps, {
173
175
  ref: this.previewRef,
174
176
  src: finalSrcList,
@@ -174,7 +174,7 @@ export default class Pagination extends BaseComponent {
174
174
  "aria-label": "Next",
175
175
  onClick: e => !isDisabled && this.foundation.goNext(e),
176
176
  className: nextClassName,
177
- "x-semi-prop": "prevText"
177
+ "x-semi-prop": "nextText"
178
178
  }, nextText || /*#__PURE__*/React.createElement(IconChevronRight, {
179
179
  size: "large"
180
180
  }));
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ import _noop from "lodash/noop";
2
+ import React, { useRef } from 'react';
2
3
  import getUuid from '@douyinfe/semi-foundation/lib/es/utils/uuid';
3
4
  import HookToast from './HookToast';
4
5
  // const ref = null;
@@ -28,7 +29,7 @@ function usePatchElement() {
28
29
  }
29
30
  export default function useToast() {
30
31
  const [elements, patchElement] = usePatchElement();
31
- const toastRef = new Map();
32
+ const toastRef = useRef(new Map());
32
33
  const addToast = config => {
33
34
  const id = getUuid('semi_toast_');
34
35
  const mergeConfig = Object.assign(Object.assign({}, config), {
@@ -36,20 +37,25 @@ export default function useToast() {
36
37
  });
37
38
  // eslint-disable-next-line prefer-const
38
39
  let closeFunc;
39
- const ref = ele => {
40
- toastRef.set(id, ele);
41
- };
42
40
  const toast = /*#__PURE__*/React.createElement(HookToast, Object.assign({}, mergeConfig, {
43
41
  key: id,
44
42
  afterClose: instanceId => closeFunc(instanceId),
45
- ref: ref
43
+ ref: data => {
44
+ var _a;
45
+ toastRef.current.set(id, {
46
+ close: (_a = data === null || data === void 0 ? void 0 : data.close) !== null && _a !== void 0 ? _a : _noop
47
+ });
48
+ }
46
49
  }));
47
50
  closeFunc = patchElement(toast, Object.assign({}, mergeConfig));
48
51
  return id;
49
52
  };
50
53
  const removeElement = id => {
51
- const ele = toastRef.get(id);
52
- ele && ele.close();
54
+ var _a;
55
+ const {
56
+ close
57
+ } = (_a = toastRef.current.get(id)) !== null && _a !== void 0 ? _a : {};
58
+ close === null || close === void 0 ? void 0 : close();
53
59
  };
54
60
  return [{
55
61
  success: config => addToast(Object.assign(Object.assign(Object.assign({}, defaultOpts), config), {
@@ -443,8 +443,8 @@ class Tree extends BaseComponent {
443
443
  notifyChange: value => {
444
444
  this.props.onChange && this.props.onChange(value);
445
445
  },
446
- notifySearch: input => {
447
- this.props.onSearch && this.props.onSearch(input);
446
+ notifySearch: (input, filteredExpandedKeys) => {
447
+ this.props.onSearch && this.props.onSearch(input, filteredExpandedKeys);
448
448
  },
449
449
  notifyRightClick: (e, node) => {
450
450
  this.props.onContextMenu && this.props.onContextMenu(e, node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.37.0",
3
+ "version": "2.38.0-beta.0",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -17,12 +17,12 @@
17
17
  "lib/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@douyinfe/semi-animation": "2.37.0",
21
- "@douyinfe/semi-animation-react": "2.37.0",
22
- "@douyinfe/semi-foundation": "2.37.0",
23
- "@douyinfe/semi-icons": "2.37.0",
24
- "@douyinfe/semi-illustrations": "2.37.0",
25
- "@douyinfe/semi-theme-default": "2.37.0",
20
+ "@douyinfe/semi-animation": "2.38.0-beta.0",
21
+ "@douyinfe/semi-animation-react": "2.38.0-beta.0",
22
+ "@douyinfe/semi-foundation": "2.38.0-beta.0",
23
+ "@douyinfe/semi-icons": "2.38.0-beta.0",
24
+ "@douyinfe/semi-illustrations": "2.38.0-beta.0",
25
+ "@douyinfe/semi-theme-default": "2.38.0-beta.0",
26
26
  "async-validator": "^3.5.0",
27
27
  "classnames": "^2.2.6",
28
28
  "copy-text-to-clipboard": "^2.1.1",
@@ -69,7 +69,7 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "3d2a2680186785f167b1bb0f9c719a2945c3c1f0",
72
+ "gitHead": "f9fa7bba4ffc5635489ad1687740b336b0395948",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",