@douyinfe/semi-ui 2.7.0 → 2.7.1

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.
@@ -897,4 +897,13 @@ export const InputFocus = () => {
897
897
  <Input ref={ref} onChange={() => console.log('ref', ref) } onFocus={() => console.log('focus')} />
898
898
  </>
899
899
  );
900
- };
900
+ };
901
+
902
+ export const TextAreaAutosize = () => {
903
+ return (
904
+ <div style={{ width: 200 }}>
905
+ <TextArea autosize />
906
+ </div>
907
+ )
908
+ };
909
+ TextAreaAutosize.storyName = "textarea autosize";
@@ -18,6 +18,7 @@ var _react = require("react");
18
18
 
19
19
  var _index = require("../index");
20
20
 
21
+ /* istanbul ignore next */
21
22
  function usePrevFocus() {
22
23
  const [prevFocusElement, setPrevFocus] = (0, _react.useState)((0, _index.getActiveElement)());
23
24
  (0, _react.useEffect)(() => {
@@ -57,6 +57,8 @@ const HookModal = (_a, ref) => {
57
57
  const {
58
58
  motion
59
59
  } = props;
60
+ /* istanbul ignore next */
61
+
60
62
  const mergedMotion = typeof motion === 'undefined' || motion ? (0, _assign.default)((0, _assign.default)({}, motion), {
61
63
  didLeave: function () {
62
64
  const didLeave = (0, _get2.default)(props.motion, 'didLeave');
@@ -463,7 +463,7 @@ class Tooltip extends _baseComponent.default {
463
463
  willUpdateStates.visible = visible;
464
464
  }
465
465
 
466
- this.setState(willUpdateStates, () => {
466
+ this.mounted && this.setState(willUpdateStates, () => {
467
467
  cb();
468
468
  });
469
469
  },
@@ -2,6 +2,8 @@ import _isFunction from "lodash/isFunction";
2
2
  import _get from "lodash/get";
3
3
  import { useState, useEffect } from 'react';
4
4
  import { getActiveElement } from '../index';
5
+
6
+ /* istanbul ignore next */
5
7
  export function usePrevFocus() {
6
8
  const [prevFocusElement, setPrevFocus] = useState(getActiveElement());
7
9
  useEffect(() => {
@@ -39,6 +39,8 @@ const HookModal = (_a, ref) => {
39
39
  const {
40
40
  motion
41
41
  } = props;
42
+ /* istanbul ignore next */
43
+
42
44
  const mergedMotion = typeof motion === 'undefined' || motion ? _Object$assign(_Object$assign({}, motion), {
43
45
  didLeave: function () {
44
46
  const didLeave = _get(props.motion, 'didLeave');
@@ -422,7 +422,7 @@ export default class Tooltip extends BaseComponent {
422
422
  willUpdateStates.visible = visible;
423
423
  }
424
424
 
425
- this.setState(willUpdateStates, () => {
425
+ this.mounted && this.setState(willUpdateStates, () => {
426
426
  cb();
427
427
  });
428
428
  },
@@ -1,5 +1,7 @@
1
1
  import React, { useState } from 'react';
2
- import { Select, Modal, Button, Tooltip, Popover } from '../../index';
2
+ import en_GB from '../../locale/source/en_GB';
3
+
4
+ import { Select, Modal, Button, Tooltip, Popover, ConfigProvider, Tag, Space } from '../../index';
3
5
  import CollapsibleInModal from './CollapsibleInModal';
4
6
  import DynamicContextDemo from './DynamicContext';
5
7
 
@@ -248,4 +250,94 @@ KeepDomNotLazy.story = {
248
250
  name: 'keepDOM && not lazy',
249
251
  };
250
252
 
253
+ export const UseModalDemo = () => {
254
+ const [modal, contextHolder] = Modal.useModal();
255
+ const config = { 'title': 'old title', 'content': 'old content' };
256
+
257
+ return (
258
+ <ConfigProvider locale={en_GB}>
259
+ <div>
260
+ <Button
261
+ onClick={() => {
262
+ const currentModal = modal.confirm(config);
263
+
264
+ setTimeout(() => {
265
+ currentModal.update({ title: "new title", content: "new content" });
266
+ }, 1000);
267
+ }}
268
+ >
269
+ Confirm Modal
270
+ </Button>
271
+ </div>
272
+ {contextHolder}
273
+ </ConfigProvider>
274
+ );
275
+ };
276
+ UseModalDemo.storyName = "useModal";
277
+
278
+ export const UseModalDestroy = () => {
279
+ const [modal, contextHolder] = Modal.useModal();
280
+ const config = { 'title': 'old title', 'content': 'old content' };
281
+
282
+ return (
283
+ <ConfigProvider locale={en_GB}>
284
+ <div>
285
+ <Button
286
+ onClick={() => {
287
+ const currentModal = modal.confirm(config);
288
+
289
+ setTimeout(() => {
290
+ currentModal.destroy();
291
+ }, 1000);
292
+ }}
293
+ >
294
+ Confirm Modal
295
+ </Button>
296
+ </div>
297
+ {contextHolder}
298
+ </ConfigProvider>
299
+ );
300
+ };
301
+ UseModalDestroy.storyName = "useModal destroy";
302
+
303
+ export const UseModalAfterClose = () => {
304
+ const [modal, contextHolder] = Modal.useModal();
305
+ const [closed, setClosed] = React.useState(false);
306
+ const [leave, setLeave] = React.useState(false);
307
+
308
+ const config = {
309
+ title: 'old title',
310
+ content: 'old content',
311
+ afterClose: () => {
312
+ setClosed(true);
313
+ },
314
+ motion: {
315
+ didLeave: () => {
316
+ console.log('didLeave');
317
+ setLeave(true);
318
+ }
319
+ }
320
+ };
251
321
 
322
+ return (
323
+ <ConfigProvider locale={en_GB}>
324
+ <Space>
325
+ <Button
326
+ onClick={() => {
327
+ const currentModal = modal.confirm(config);
328
+
329
+ setTimeout(() => {
330
+ currentModal.destroy();
331
+ }, 0);
332
+ }}
333
+ >
334
+ Confirm Modal
335
+ </Button>
336
+ <Tag>{`closed: ${closed}`}</Tag>
337
+ {/* <Tag>{`motion leave: ${leave}`}</Tag> */}
338
+ </Space>
339
+ {contextHolder}
340
+ </ConfigProvider>
341
+ );
342
+ };
343
+ UseModalAfterClose.storyName = "useModal afterClose";
@@ -35,6 +35,7 @@ const HookModal = ({ afterClose, config, ...props }: PropsWithChildren<HookModal
35
35
  }));
36
36
 
37
37
  const { motion } = props;
38
+ /* istanbul ignore next */
38
39
  const mergedMotion =
39
40
  typeof motion === 'undefined' || motion ?
40
41
  {
@@ -4,18 +4,32 @@ import { Button, ConfigProvider } from '../../../index';
4
4
  import Context from './context';
5
5
 
6
6
  function App({ children, globalVars }) {
7
- return <Context.Provider value={{ title: '1111', ...globalVars }}>{children}</Context.Provider>;
7
+ return (
8
+ <div data-cy="notice-container">
9
+ <Context.Provider value={{ title: '1111', ...globalVars }}>{children}</Context.Provider>
10
+ </div>
11
+ );
8
12
  }
9
13
 
10
14
  export default function Demo() {
11
- const [Notice, elements] = useNotification();
15
+ const [notice, elements] = useNotification();
16
+ const config = {
17
+ content: 'Hello World',
18
+ position: 'top',
19
+ title: <Context.Consumer>{({ title }) => <strong>{title}</strong>}</Context.Consumer>,
20
+ duration: 0,
21
+ };
12
22
 
13
23
  const addNotice = () => {
14
- Notice.addNotice({
15
- content: 'Hello World',
16
- position: 'top',
17
- title: <Context.Consumer>{({ title }) => <strong>{title}</strong>}</Context.Consumer>,
18
- });
24
+ const id1 = notice.info(config);
25
+ const id2 = notice.success(config);
26
+ const id3 = notice.warning(config);
27
+ const id4 = notice.error(config);
28
+ const id5 = notice.open(config);
29
+
30
+ // setTimeout(() => {
31
+ // notice.close(id5);
32
+ // }, 1000);
19
33
  };
20
34
 
21
35
  return (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -14,12 +14,12 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
- "@douyinfe/semi-animation": "2.7.0",
18
- "@douyinfe/semi-animation-react": "2.7.0",
19
- "@douyinfe/semi-foundation": "2.7.0",
20
- "@douyinfe/semi-icons": "2.7.0",
21
- "@douyinfe/semi-illustrations": "2.7.0",
22
- "@douyinfe/semi-theme-default": "2.7.0",
17
+ "@douyinfe/semi-animation": "2.7.1",
18
+ "@douyinfe/semi-animation-react": "2.7.1",
19
+ "@douyinfe/semi-foundation": "2.7.1",
20
+ "@douyinfe/semi-icons": "2.7.1",
21
+ "@douyinfe/semi-illustrations": "2.7.1",
22
+ "@douyinfe/semi-theme-default": "2.7.1",
23
23
  "@types/react-window": "^1.8.2",
24
24
  "async-validator": "^3.5.0",
25
25
  "classnames": "^2.2.6",
@@ -69,13 +69,13 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "b6e4e0a1e22d4dabe68cbf7e3d2cfd0202da0424",
72
+ "gitHead": "d0dbd6f932a74386b429dedbc32ae92d9e0af7b9",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",
76
76
  "@babel/preset-env": "^7.15.8",
77
77
  "@babel/preset-react": "^7.14.5",
78
- "@douyinfe/semi-scss-compile": "2.7.0",
78
+ "@douyinfe/semi-scss-compile": "2.7.1",
79
79
  "@storybook/addon-knobs": "^6.3.1",
80
80
  "@types/lodash": "^4.14.176",
81
81
  "babel-loader": "^8.2.2",
@@ -0,0 +1,33 @@
1
+ import React, { useState } from 'react';
2
+ import { Popconfirm, Table } from "@douyinfe/semi-ui";
3
+
4
+ export default function App() {
5
+ const [data, setData] = useState([{ a: 1 }]);
6
+ return (
7
+ <Table
8
+ dataSource={data}
9
+ columns={[
10
+ {
11
+ dataIndex: "a",
12
+ title: "a",
13
+ },
14
+ {
15
+ dataIndex: "b",
16
+ render: () => {
17
+ return (
18
+ <Popconfirm
19
+ onConfirm={() => {
20
+ setTimeout(() => {
21
+ setData([]);
22
+ });
23
+ }}
24
+ >
25
+ 删除
26
+ </Popconfirm>
27
+ );
28
+ },
29
+ },
30
+ ]}
31
+ />
32
+ );
33
+ }
@@ -3,4 +3,5 @@ export { default as FixedColumnsChange } from './FixedColumnsChange';
3
3
  export { default as FixedZIndex } from './FixedZIndex';
4
4
  export { default as FixedHeaderMerge } from './FixedHeaderMerge';
5
5
  export { default as FixedResizable } from './FixedResizable';
6
- export { default as FixedExpandedRow } from './FixedExpandedRow';
6
+ export { default as FixedExpandedRow } from './FixedExpandedRow';
7
+ export { default as FixedMemoryLeak } from './FixedMemoryLeak';
@@ -96,3 +96,44 @@ export const _Toast = () => (
96
96
  _Toast.story = {
97
97
  name: 'toast',
98
98
  };
99
+
100
+ const ReachableContext = React.createContext();
101
+
102
+ /**
103
+ * test with cypress
104
+ * @returns
105
+ */
106
+ export const useToastDemo = () => {
107
+ const [toast, contextHolder] = Toast.useToast();
108
+ const config = {
109
+ duration: 0,
110
+ title: 'This is a success message',
111
+ content: <ReachableContext.Consumer>{name => `ReachableContext: ${name}`}</ReachableContext.Consumer>,
112
+ };
113
+
114
+ return (
115
+ <ReachableContext.Provider value="Light">
116
+ <div>
117
+ <Button
118
+ onClick={() => {
119
+ toast.success(config);
120
+ toast.info(config);
121
+ toast.error(config);
122
+ toast.warning(config);
123
+ const id = toast.open(config);
124
+
125
+ setTimeout(() => {
126
+ toast.close(id);
127
+ }, 100);
128
+ }}
129
+ >
130
+ Hook Toast
131
+ </Button>
132
+ </div>
133
+ <div data-cy="context-holder">
134
+ {contextHolder}
135
+ </div>
136
+ </ReachableContext.Provider>
137
+ );
138
+ };
139
+ useToastDemo.storyName = "useToast";
package/tooltip/index.tsx CHANGED
@@ -302,7 +302,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
302
302
  } else {
303
303
  willUpdateStates.visible = visible;
304
304
  }
305
- this.setState(willUpdateStates as TooltipState, () => {
305
+ this.mounted && this.setState(willUpdateStates as TooltipState, () => {
306
306
  cb();
307
307
  });
308
308
  },