@arco-design/mobile-react 2.30.8 → 2.30.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/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.30.9](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.30.8...@arco-design/mobile-react@2.30.9) (2024-02-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * export type from `Skeleton` ([#233](https://github.com/arco-design/arco-design-mobile/issues/233)) ([7514ed9](https://github.com/arco-design/arco-design-mobile/commit/7514ed9baceccaf8f46c90b046bfe06594a66a59))
12
+ * warning for repeatedly calling createRoot in react18 of masking related components ([#231](https://github.com/arco-design/arco-design-mobile/issues/231)) ([6879ad7](https://github.com/arco-design/arco-design-mobile/commit/6879ad7f6225128b87bbf82aad34ba5836d4ac18))
13
+
14
+
15
+
16
+
17
+
6
18
  ## [2.30.8](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.30.7...@arco-design/mobile-react@2.30.8) (2024-01-31)
7
19
 
8
20
 
package/README.en-US.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="_b
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">Click here</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.30.7/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.30.7/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.30.8/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.30.8/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## Full import
package/README.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">戳这里获取</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.30.7/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.30.7/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.30.8/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.30.8/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## 引入全部
@@ -1,12 +1,17 @@
1
1
  import { FunctionComponent } from 'react';
2
2
  import { RootType } from './react-dom';
3
3
  import { GlobalContextParams } from '../context-provider';
4
+ export declare const renderRootCache: Record<string, RootType | undefined>;
4
5
  export declare class ReactDOMRender {
5
6
  root: RootType | undefined;
6
7
  app: FunctionComponent;
7
8
  container: Element | DocumentFragment;
8
9
  context: GlobalContextParams | undefined;
9
- constructor(app: FunctionComponent, container: Element | DocumentFragment, context?: GlobalContextParams);
10
+ rootCacheId: string | undefined;
11
+ constructor(app: FunctionComponent, container: Element | DocumentFragment, context?: GlobalContextParams, rootCacheId?: string, // root id in cache
12
+ root?: RootType);
10
13
  render: (props: any) => void;
14
+ setRootCache: () => void;
15
+ clearRootCache: () => void;
11
16
  unmount: () => void;
12
17
  }
@@ -3,7 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
- exports.ReactDOMRender = void 0;
6
+ exports.renderRootCache = exports.ReactDOMRender = void 0;
7
7
 
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
 
@@ -11,13 +11,19 @@ var _react = _interopRequireDefault(require("react"));
11
11
 
12
12
  var _reactDom = require("./react-dom");
13
13
 
14
- var ReactDOMRender = function ReactDOMRender(app, container, context) {
14
+ var renderRootCache = {};
15
+ exports.renderRootCache = renderRootCache;
16
+
17
+ var ReactDOMRender = function ReactDOMRender(app, container, context, rootCacheId, // root id in cache
18
+ root // use root in cache
19
+ ) {
15
20
  var _this = this;
16
21
 
17
22
  this.root = void 0;
18
23
  this.app = void 0;
19
24
  this.container = void 0;
20
25
  this.context = void 0;
26
+ this.rootCacheId = void 0;
21
27
 
22
28
  this.render = function (props) {
23
29
  var CustomApp = _this.app;
@@ -32,16 +38,32 @@ var ReactDOMRender = function ReactDOMRender(app, container, context) {
32
38
  }
33
39
  };
34
40
 
41
+ this.setRootCache = function () {
42
+ if (_this.rootCacheId) {
43
+ renderRootCache[_this.rootCacheId] = _this.root;
44
+ }
45
+ };
46
+
47
+ this.clearRootCache = function () {
48
+ if (_this.rootCacheId) {
49
+ delete renderRootCache[_this.rootCacheId];
50
+ }
51
+ };
52
+
35
53
  this.unmount = function () {
36
54
  var _this$root;
37
55
 
38
56
  (_this$root = _this.root) == null ? void 0 : _this$root._unmount();
39
57
  _this.root = undefined;
58
+
59
+ _this.clearRootCache();
40
60
  };
41
61
 
42
62
  this.app = app;
43
63
  this.container = container;
44
64
  this.context = context;
65
+ this.rootCacheId = rootCacheId;
66
+ this.root = root;
45
67
  };
46
68
 
47
69
  exports.ReactDOMRender = ReactDOMRender;
@@ -1,11 +1,11 @@
1
- @import "../../../style/mixin.less";
1
+ @import '../../../style/mixin.less';
2
2
 
3
3
  .@{prefix}-image {
4
4
  display: inline-block;
5
5
  position: relative;
6
6
 
7
7
  &.preview {
8
- transition: all .3s ease-in-out;
8
+ transition: all 0.3s ease-in-out;
9
9
 
10
10
  .image-container,
11
11
  .image-loading-container .image-loading,
@@ -109,7 +109,6 @@
109
109
  }
110
110
 
111
111
  .image-error-container {
112
-
113
112
  .image-retry-load {
114
113
  position: absolute;
115
114
  top: 0;
@@ -127,7 +126,6 @@
127
126
  }
128
127
 
129
128
  .image-loading-container {
130
-
131
129
  .image-loading {
132
130
  position: absolute;
133
131
  top: 0;
@@ -13,9 +13,7 @@ var _render = require("../_helpers/render");
13
13
 
14
14
  function open(Component) {
15
15
  return function (config, context) {
16
- var baseProps = (0, _extends2.default)({
17
- unmountOnExit: true
18
- }, config || {}, {
16
+ var baseProps = (0, _extends2.default)({}, config || {}, {
19
17
  close: function close() {}
20
18
  }); // 不同的key用不同的容器挂载
21
19
  // @en Different keys are mounted in different containers
@@ -51,10 +49,7 @@ function open(Component) {
51
49
 
52
50
  dynamicProps.onClose = function () {
53
51
  baseProps.onClose && baseProps.onClose();
54
-
55
- if (baseProps.unmountOnExit) {
56
- (0, _mobileUtils.removeElement)(div);
57
- }
52
+ (0, _mobileUtils.removeElement)(div);
58
53
  };
59
54
 
60
55
  dynamicProps.openIndex = -1;
@@ -28,14 +28,14 @@ function getOpenMethod(Component, containerId, normalize) {
28
28
  }); // 不同的key用不同的容器挂载
29
29
 
30
30
  var id = "_" + (containerId || 'ARCO_MASKING') + "_DIV_" + (config.key || '') + "_";
31
-
32
- var _appendElementById = (0, _mobileUtils.appendElementById)(id, baseProps.getContainer),
33
- div = _appendElementById.child;
34
-
31
+ var existedDiv = baseProps.unmountOnExit ? null : document.getElementById(id);
32
+ var div = existedDiv || (0, _mobileUtils.appendElementById)(id, baseProps.getContainer).child;
35
33
  var leaving = false;
36
34
 
37
- var _ReactDOMRender = new _render.ReactDOMRender(Component, div, context),
38
- render = _ReactDOMRender.render;
35
+ var _ReactDOMRender = new _render.ReactDOMRender(Component, div, context, id, existedDiv ? _render.renderRootCache[id] : undefined),
36
+ render = _ReactDOMRender.render,
37
+ unmount = _ReactDOMRender.unmount,
38
+ setRootCache = _ReactDOMRender.setRootCache;
39
39
 
40
40
  var dynamicProps = (0, _extends2.default)({}, baseProps, {
41
41
  getContainer: function getContainer() {
@@ -60,11 +60,17 @@ function getOpenMethod(Component, containerId, normalize) {
60
60
  baseProps.onClose && baseProps.onClose(scene);
61
61
 
62
62
  if (baseProps.unmountOnExit) {
63
+ unmount();
63
64
  (0, _mobileUtils.removeElement)(div);
64
65
  }
65
66
  };
66
67
 
67
68
  render(dynamicProps);
69
+
70
+ if (!baseProps.unmountOnExit) {
71
+ setRootCache();
72
+ }
73
+
68
74
  (0, _mobileUtils.nextTick)(function () {
69
75
  if (leaving) return;
70
76
  dynamicProps.visible = true;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { BaseProps, SimpleBaseProps } from '../_helpers';
3
- export { BaseProps, SimpleBaseProps };
3
+ export type { BaseProps, SimpleBaseProps };
4
4
  export interface SkeletonProps extends SimpleBaseProps {
5
5
  /**
6
6
  * 是否显示标题占位图
@@ -1,8 +1,3 @@
1
1
  "use strict";
2
2
 
3
- exports.__esModule = true;
4
-
5
- var _helpers = require("../_helpers");
6
-
7
- exports.BaseProps = _helpers.BaseProps;
8
- exports.SimpleBaseProps = _helpers.SimpleBaseProps;
3
+ exports.__esModule = true;
package/dist/index.js CHANGED
@@ -8556,10 +8556,13 @@
8556
8556
  });
8557
8557
  }
8558
8558
 
8559
+ var renderRootCache = {};
8560
+
8559
8561
  var ReactDOMRender =
8560
8562
  /** @class */
8561
8563
  function () {
8562
- function ReactDOMRender(app, container, context) {
8564
+ function ReactDOMRender(app, container, context, rootCacheId, // root id in cache
8565
+ root) {
8563
8566
  var _this = this;
8564
8567
 
8565
8568
  this.render = function (props) {
@@ -8576,16 +8579,32 @@
8576
8579
  }
8577
8580
  };
8578
8581
 
8582
+ this.setRootCache = function () {
8583
+ if (_this.rootCacheId) {
8584
+ renderRootCache[_this.rootCacheId] = _this.root;
8585
+ }
8586
+ };
8587
+
8588
+ this.clearRootCache = function () {
8589
+ if (_this.rootCacheId) {
8590
+ delete renderRootCache[_this.rootCacheId];
8591
+ }
8592
+ };
8593
+
8579
8594
  this.unmount = function () {
8580
8595
  var _a;
8581
8596
 
8582
8597
  (_a = _this.root) === null || _a === void 0 ? void 0 : _a._unmount();
8583
8598
  _this.root = undefined;
8599
+
8600
+ _this.clearRootCache();
8584
8601
  };
8585
8602
 
8586
8603
  this.app = app;
8587
8604
  this.container = container;
8588
8605
  this.context = context;
8606
+ this.rootCacheId = rootCacheId;
8607
+ this.root = root;
8589
8608
  }
8590
8609
 
8591
8610
  return ReactDOMRender;
@@ -8608,9 +8627,14 @@
8608
8627
 
8609
8628
 
8610
8629
  var id = "_" + (containerId || 'ARCO_MASKING') + "_DIV_" + (config.key || '') + "_";
8611
- var div = appendElementById(id, baseProps.getContainer).child;
8630
+ var existedDiv = baseProps.unmountOnExit ? null : document.getElementById(id);
8631
+ var div = existedDiv || appendElementById(id, baseProps.getContainer).child;
8612
8632
  var leaving = false;
8613
- var render = new ReactDOMRender(Component, div, context).render;
8633
+
8634
+ var _a = new ReactDOMRender(Component, div, context, id, existedDiv ? renderRootCache[id] : undefined),
8635
+ render = _a.render,
8636
+ unmount = _a.unmount,
8637
+ setRootCache = _a.setRootCache;
8614
8638
 
8615
8639
  var dynamicProps = __assign$3(__assign$3({}, baseProps), {
8616
8640
  getContainer: function getContainer() {
@@ -8635,11 +8659,17 @@
8635
8659
  baseProps.onClose && baseProps.onClose(scene);
8636
8660
 
8637
8661
  if (baseProps.unmountOnExit) {
8662
+ unmount();
8638
8663
  removeElement(div);
8639
8664
  }
8640
8665
  };
8641
8666
 
8642
8667
  render(dynamicProps);
8668
+
8669
+ if (!baseProps.unmountOnExit) {
8670
+ setRootCache();
8671
+ }
8672
+
8643
8673
  nextTick(function () {
8644
8674
  if (leaving) return;
8645
8675
  dynamicProps.visible = true;
@@ -20680,9 +20710,7 @@
20680
20710
 
20681
20711
  function open$1(Component) {
20682
20712
  return function (config, context) {
20683
- var baseProps = __assign$3(__assign$3({
20684
- unmountOnExit: true
20685
- }, config || {}), {
20713
+ var baseProps = __assign$3(__assign$3({}, config || {}), {
20686
20714
  close: function close() {}
20687
20715
  }); // 不同的key用不同的容器挂载
20688
20716
  // @en Different keys are mounted in different containers
@@ -20714,10 +20742,7 @@
20714
20742
 
20715
20743
  dynamicProps.onClose = function () {
20716
20744
  baseProps.onClose && baseProps.onClose();
20717
-
20718
- if (baseProps.unmountOnExit) {
20719
- removeElement(div);
20720
- }
20745
+ removeElement(div);
20721
20746
  };
20722
20747
 
20723
20748
  dynamicProps.openIndex = -1;