@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.
@@ -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
  }
@@ -1,13 +1,17 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { render as copyRender } from './react-dom';
4
- export var ReactDOMRender = function ReactDOMRender(app, container, context) {
4
+ export var renderRootCache = {};
5
+ export var ReactDOMRender = function ReactDOMRender(app, container, context, rootCacheId, // root id in cache
6
+ root // use root in cache
7
+ ) {
5
8
  var _this = this;
6
9
 
7
10
  this.root = void 0;
8
11
  this.app = void 0;
9
12
  this.container = void 0;
10
13
  this.context = void 0;
14
+ this.rootCacheId = void 0;
11
15
 
12
16
  this.render = function (props) {
13
17
  var CustomApp = _this.app;
@@ -23,14 +27,30 @@ export var ReactDOMRender = function ReactDOMRender(app, container, context) {
23
27
  }
24
28
  };
25
29
 
30
+ this.setRootCache = function () {
31
+ if (_this.rootCacheId) {
32
+ renderRootCache[_this.rootCacheId] = _this.root;
33
+ }
34
+ };
35
+
36
+ this.clearRootCache = function () {
37
+ if (_this.rootCacheId) {
38
+ delete renderRootCache[_this.rootCacheId];
39
+ }
40
+ };
41
+
26
42
  this.unmount = function () {
27
43
  var _this$root;
28
44
 
29
45
  (_this$root = _this.root) == null ? void 0 : _this$root._unmount();
30
46
  _this.root = undefined;
47
+
48
+ _this.clearRootCache();
31
49
  };
32
50
 
33
51
  this.app = app;
34
52
  this.container = container;
35
53
  this.context = context;
54
+ this.rootCacheId = rootCacheId;
55
+ this.root = root;
36
56
  };
@@ -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;
@@ -3,9 +3,7 @@ import { appendElementById, removeElement } from '@arco-design/mobile-utils';
3
3
  import { ReactDOMRender } from '../_helpers/render';
4
4
  export function open(Component) {
5
5
  return function (config, context) {
6
- var baseProps = _extends({
7
- unmountOnExit: true
8
- }, config || {}, {
6
+ var baseProps = _extends({}, config || {}, {
9
7
  close: function close() {}
10
8
  }); // 不同的key用不同的容器挂载
11
9
  // @en Different keys are mounted in different containers
@@ -42,10 +40,7 @@ export function open(Component) {
42
40
 
43
41
  dynamicProps.onClose = function () {
44
42
  baseProps.onClose && baseProps.onClose();
45
-
46
- if (baseProps.unmountOnExit) {
47
- removeElement(div);
48
- }
43
+ removeElement(div);
49
44
  };
50
45
 
51
46
  dynamicProps.openIndex = -1;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import { appendElementById, removeElement, nextTick } from '@arco-design/mobile-utils';
3
- import { ReactDOMRender } from '../_helpers/render';
3
+ import { ReactDOMRender, renderRootCache } from '../_helpers/render';
4
4
  export function getOpenMethod(Component, containerId, normalize) {
5
5
  if (normalize === void 0) {
6
6
  normalize = function normalize(config) {
@@ -18,14 +18,14 @@ export function getOpenMethod(Component, containerId, normalize) {
18
18
 
19
19
 
20
20
  var id = "_" + (containerId || 'ARCO_MASKING') + "_DIV_" + (config.key || '') + "_";
21
-
22
- var _appendElementById = appendElementById(id, baseProps.getContainer),
23
- div = _appendElementById.child;
24
-
21
+ var existedDiv = baseProps.unmountOnExit ? null : document.getElementById(id);
22
+ var div = existedDiv || appendElementById(id, baseProps.getContainer).child;
25
23
  var leaving = false;
26
24
 
27
- var _ReactDOMRender = new ReactDOMRender(Component, div, context),
28
- render = _ReactDOMRender.render;
25
+ var _ReactDOMRender = new ReactDOMRender(Component, div, context, id, existedDiv ? renderRootCache[id] : undefined),
26
+ render = _ReactDOMRender.render,
27
+ unmount = _ReactDOMRender.unmount,
28
+ setRootCache = _ReactDOMRender.setRootCache;
29
29
 
30
30
  var dynamicProps = _extends({}, baseProps, {
31
31
  getContainer: function getContainer() {
@@ -50,11 +50,17 @@ export function getOpenMethod(Component, containerId, normalize) {
50
50
  baseProps.onClose && baseProps.onClose(scene);
51
51
 
52
52
  if (baseProps.unmountOnExit) {
53
+ unmount();
53
54
  removeElement(div);
54
55
  }
55
56
  };
56
57
 
57
58
  render(dynamicProps);
59
+
60
+ if (!baseProps.unmountOnExit) {
61
+ setRootCache();
62
+ }
63
+
58
64
  nextTick(function () {
59
65
  if (leaving) return;
60
66
  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,2 +1 @@
1
- import { BaseProps, SimpleBaseProps } from '../_helpers';
2
- export { BaseProps, SimpleBaseProps };
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco-design/mobile-react",
3
- "version": "2.30.8",
3
+ "version": "2.30.9",
4
4
  "description": "",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -15,7 +15,7 @@
15
15
  "author": "taoyiyue@bytedance.com",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "@arco-design/mobile-utils": "2.17.8",
18
+ "@arco-design/mobile-utils": "2.17.9",
19
19
  "@arco-design/transformable": "^1.0.0",
20
20
  "lodash.throttle": "^4.1.1",
21
21
  "resize-observer-polyfill": "^1.5.1"
@@ -49,5 +49,5 @@
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "gitHead": "2838b15919944eb0a2122b01cb1a9e8e0e0af75a"
52
+ "gitHead": "6831c908713b02b4f7738c793ea4118e17f03458"
53
53
  }
@@ -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
  }
@@ -16,17 +16,22 @@
16
16
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
17
17
 
18
18
  _exports.__esModule = true;
19
- _exports.ReactDOMRender = void 0;
19
+ _exports.renderRootCache = _exports.ReactDOMRender = void 0;
20
20
  _extends2 = _interopRequireDefault(_extends2);
21
21
  _react = _interopRequireDefault(_react);
22
+ var renderRootCache = {};
23
+ _exports.renderRootCache = renderRootCache;
22
24
 
23
- var ReactDOMRender = function ReactDOMRender(app, container, context) {
25
+ var ReactDOMRender = function ReactDOMRender(app, container, context, rootCacheId, // root id in cache
26
+ root // use root in cache
27
+ ) {
24
28
  var _this = this;
25
29
 
26
30
  this.root = void 0;
27
31
  this.app = void 0;
28
32
  this.container = void 0;
29
33
  this.context = void 0;
34
+ this.rootCacheId = void 0;
30
35
 
31
36
  this.render = function (props) {
32
37
  var CustomApp = _this.app;
@@ -41,16 +46,32 @@
41
46
  }
42
47
  };
43
48
 
49
+ this.setRootCache = function () {
50
+ if (_this.rootCacheId) {
51
+ renderRootCache[_this.rootCacheId] = _this.root;
52
+ }
53
+ };
54
+
55
+ this.clearRootCache = function () {
56
+ if (_this.rootCacheId) {
57
+ delete renderRootCache[_this.rootCacheId];
58
+ }
59
+ };
60
+
44
61
  this.unmount = function () {
45
62
  var _this$root;
46
63
 
47
64
  (_this$root = _this.root) == null ? void 0 : _this$root._unmount();
48
65
  _this.root = undefined;
66
+
67
+ _this.clearRootCache();
49
68
  };
50
69
 
51
70
  this.app = app;
52
71
  this.container = container;
53
72
  this.context = context;
73
+ this.rootCacheId = rootCacheId;
74
+ this.root = root;
54
75
  };
55
76
 
56
77
  _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;
@@ -21,9 +21,7 @@
21
21
 
22
22
  function open(Component) {
23
23
  return function (config, context) {
24
- var baseProps = (0, _extends2.default)({
25
- unmountOnExit: true
26
- }, config || {}, {
24
+ var baseProps = (0, _extends2.default)({}, config || {}, {
27
25
  close: function close() {}
28
26
  }); // 不同的key用不同的容器挂载
29
27
  // @en Different keys are mounted in different containers
@@ -59,10 +57,7 @@
59
57
 
60
58
  dynamicProps.onClose = function () {
61
59
  baseProps.onClose && baseProps.onClose();
62
-
63
- if (baseProps.unmountOnExit) {
64
- (0, _mobileUtils.removeElement)(div);
65
- }
60
+ (0, _mobileUtils.removeElement)(div);
66
61
  };
67
62
 
68
63
  dynamicProps.openIndex = -1;
@@ -36,14 +36,14 @@
36
36
  }); // 不同的key用不同的容器挂载
37
37
 
38
38
  var id = "_" + (containerId || 'ARCO_MASKING') + "_DIV_" + (config.key || '') + "_";
39
-
40
- var _appendElementById = (0, _mobileUtils.appendElementById)(id, baseProps.getContainer),
41
- div = _appendElementById.child;
42
-
39
+ var existedDiv = baseProps.unmountOnExit ? null : document.getElementById(id);
40
+ var div = existedDiv || (0, _mobileUtils.appendElementById)(id, baseProps.getContainer).child;
43
41
  var leaving = false;
44
42
 
45
- var _ReactDOMRender = new _render.ReactDOMRender(Component, div, context),
46
- render = _ReactDOMRender.render;
43
+ var _ReactDOMRender = new _render.ReactDOMRender(Component, div, context, id, existedDiv ? _render.renderRootCache[id] : undefined),
44
+ render = _ReactDOMRender.render,
45
+ unmount = _ReactDOMRender.unmount,
46
+ setRootCache = _ReactDOMRender.setRootCache;
47
47
 
48
48
  var dynamicProps = (0, _extends2.default)({}, baseProps, {
49
49
  getContainer: function getContainer() {
@@ -68,11 +68,17 @@
68
68
  baseProps.onClose && baseProps.onClose(scene);
69
69
 
70
70
  if (baseProps.unmountOnExit) {
71
+ unmount();
71
72
  (0, _mobileUtils.removeElement)(div);
72
73
  }
73
74
  };
74
75
 
75
76
  render(dynamicProps);
77
+
78
+ if (!baseProps.unmountOnExit) {
79
+ setRootCache();
80
+ }
81
+
76
82
  (0, _mobileUtils.nextTick)(function () {
77
83
  if (leaving) return;
78
84
  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,19 +1,17 @@
1
1
  (function (global, factory) {
2
2
  if (typeof define === "function" && define.amd) {
3
- define(["exports", "../_helpers"], factory);
3
+ define(["exports"], factory);
4
4
  } else if (typeof exports !== "undefined") {
5
- factory(exports, require("../_helpers"));
5
+ factory(exports);
6
6
  } else {
7
7
  var mod = {
8
8
  exports: {}
9
9
  };
10
- factory(mod.exports, global._helpers);
10
+ factory(mod.exports);
11
11
  global.type = mod.exports;
12
12
  }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _helpers) {
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
14
14
  "use strict";
15
15
 
16
16
  _exports.__esModule = true;
17
- _exports.BaseProps = _helpers.BaseProps;
18
- _exports.SimpleBaseProps = _helpers.SimpleBaseProps;
19
17
  });