@etsoo/react 1.5.26 → 1.5.29
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/lib/app/ReactApp.js +6 -0
- package/lib/uses/useDimensions.js +1 -25
- package/package.json +9 -9
- package/src/app/ReactApp.ts +11 -0
- package/src/uses/useDimensions.ts +2 -31
package/lib/app/ReactApp.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ActionResultError, BridgeUtils, CoreApp, createClient } from '@etsoo/appscript';
|
|
2
|
+
import { NotificationMessageType } from '@etsoo/notificationbase';
|
|
2
3
|
import { WindowStorage } from '@etsoo/shared';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import { NotifierMU } from '../mu/NotifierMU';
|
|
@@ -68,6 +69,11 @@ export class ReactApp extends CoreApp {
|
|
|
68
69
|
BridgeUtils.host == null
|
|
69
70
|
? undefined
|
|
70
71
|
: ReactUtils.getMemoryHistory(BridgeUtils.host.getStartUrl());
|
|
72
|
+
if (BridgeUtils.host) {
|
|
73
|
+
BridgeUtils.host.onUpdate((app, version) => {
|
|
74
|
+
this.notifier.message(NotificationMessageType.Success, this.get('updateTip') + `(${[app, version].join(', ')})`, this.get('updateReady'));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
71
77
|
this.cultureState = new CultureState(settings.currentCulture);
|
|
72
78
|
this.pageState = new PageState();
|
|
73
79
|
globalApp = this;
|
|
@@ -49,6 +49,7 @@ export function useDimensions(elements, updateCallback, miliseconds = 50, equalC
|
|
|
49
49
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
50
50
|
// Update Rect
|
|
51
51
|
const indices = [];
|
|
52
|
+
const init = dimensions.current;
|
|
52
53
|
entries.forEach((entry) => {
|
|
53
54
|
const index = init.findIndex((item) => item[1] === entry.target);
|
|
54
55
|
if (index !== -1) {
|
|
@@ -78,31 +79,6 @@ export function useDimensions(elements, updateCallback, miliseconds = 50, equalC
|
|
|
78
79
|
delayed.call(undefined, update);
|
|
79
80
|
}
|
|
80
81
|
});
|
|
81
|
-
// Init
|
|
82
|
-
const init = [];
|
|
83
|
-
for (let e = 0; e < elements; e++) {
|
|
84
|
-
init.push(((index) => {
|
|
85
|
-
return [
|
|
86
|
-
(instance) => {
|
|
87
|
-
if (instance != null) {
|
|
88
|
-
// Current element
|
|
89
|
-
const currentElement = init[index][1];
|
|
90
|
-
if (currentElement != null) {
|
|
91
|
-
// Same target, return
|
|
92
|
-
if (currentElement == instance)
|
|
93
|
-
return;
|
|
94
|
-
// Cancel observation
|
|
95
|
-
resizeObserver.unobserve(currentElement);
|
|
96
|
-
}
|
|
97
|
-
// Update element
|
|
98
|
-
init[index][1] = instance;
|
|
99
|
-
// Start observe
|
|
100
|
-
resizeObserver.observe(instance);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
];
|
|
104
|
-
})(e));
|
|
105
|
-
}
|
|
106
82
|
// Layout ready
|
|
107
83
|
React.useEffect(() => {
|
|
108
84
|
return () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.29",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"@emotion/react": "^11.8.1",
|
|
51
51
|
"@emotion/style": "^0.8.0",
|
|
52
52
|
"@emotion/styled": "^11.8.1",
|
|
53
|
-
"@etsoo/appscript": "^1.2.
|
|
53
|
+
"@etsoo/appscript": "^1.2.58",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.2",
|
|
55
|
-
"@etsoo/shared": "^1.1.
|
|
56
|
-
"@mui/icons-material": "^5.4.
|
|
57
|
-
"@mui/material": "^5.4.
|
|
55
|
+
"@etsoo/shared": "^1.1.15",
|
|
56
|
+
"@mui/icons-material": "^5.4.4",
|
|
57
|
+
"@mui/material": "^5.4.4",
|
|
58
58
|
"@reach/router": "^1.3.4",
|
|
59
59
|
"@types/pica": "^9.0.0",
|
|
60
60
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@types/react": "^17.0.39",
|
|
63
63
|
"@types/react-avatar-editor": "^10.3.6",
|
|
64
64
|
"@types/react-beautiful-dnd": "^13.1.2",
|
|
65
|
-
"@types/react-dom": "^17.0.
|
|
65
|
+
"@types/react-dom": "^17.0.12",
|
|
66
66
|
"@types/react-input-mask": "^3.0.1",
|
|
67
67
|
"@types/react-window": "^1.8.5",
|
|
68
68
|
"pica": "^9.0.1",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"@babel/runtime-corejs3": "^7.17.2",
|
|
84
84
|
"@types/jest": "^27.4.1",
|
|
85
85
|
"@types/react-test-renderer": "^17.0.1",
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
87
|
-
"@typescript-eslint/parser": "^5.
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "^5.13.0",
|
|
87
|
+
"@typescript-eslint/parser": "^5.13.0",
|
|
88
88
|
"eslint": "^8.10.0",
|
|
89
89
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
90
90
|
"eslint-plugin-import": "^2.25.4",
|
|
@@ -92,6 +92,6 @@
|
|
|
92
92
|
"jest": "^27.5.1",
|
|
93
93
|
"react-test-renderer": "^17.0.2",
|
|
94
94
|
"ts-jest": "^27.1.3",
|
|
95
|
-
"typescript": "^4.
|
|
95
|
+
"typescript": "^4.6.2"
|
|
96
96
|
}
|
|
97
97
|
}
|
package/src/app/ReactApp.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
IUserData
|
|
11
11
|
} from '@etsoo/appscript';
|
|
12
12
|
import {
|
|
13
|
+
NotificationMessageType,
|
|
13
14
|
NotificationRenderProps,
|
|
14
15
|
NotificationReturn
|
|
15
16
|
} from '@etsoo/notificationbase';
|
|
@@ -225,6 +226,16 @@ export class ReactApp<
|
|
|
225
226
|
? undefined
|
|
226
227
|
: ReactUtils.getMemoryHistory(BridgeUtils.host.getStartUrl());
|
|
227
228
|
|
|
229
|
+
if (BridgeUtils.host) {
|
|
230
|
+
BridgeUtils.host.onUpdate((app, version) => {
|
|
231
|
+
this.notifier.message(
|
|
232
|
+
NotificationMessageType.Success,
|
|
233
|
+
this.get('updateTip') + `(${[app, version].join(', ')})`,
|
|
234
|
+
this.get('updateReady')
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
228
239
|
this.cultureState = new CultureState(settings.currentCulture);
|
|
229
240
|
this.pageState = new PageState<P>();
|
|
230
241
|
|
|
@@ -72,6 +72,8 @@ export function useDimensions(
|
|
|
72
72
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
73
73
|
// Update Rect
|
|
74
74
|
const indices: number[] = [];
|
|
75
|
+
const init = dimensions.current!;
|
|
76
|
+
|
|
75
77
|
entries.forEach((entry) => {
|
|
76
78
|
const index = init.findIndex((item) => item[1] === entry.target);
|
|
77
79
|
if (index !== -1) {
|
|
@@ -107,37 +109,6 @@ export function useDimensions(
|
|
|
107
109
|
}
|
|
108
110
|
});
|
|
109
111
|
|
|
110
|
-
// Init
|
|
111
|
-
const init: [React.RefCallback<Element>, Element?, DOMRect?][] = [];
|
|
112
|
-
for (let e = 0; e < elements; e++) {
|
|
113
|
-
init.push(
|
|
114
|
-
((index): [React.RefCallback<Element>] => {
|
|
115
|
-
return [
|
|
116
|
-
(instance) => {
|
|
117
|
-
if (instance != null) {
|
|
118
|
-
// Current element
|
|
119
|
-
const currentElement = init[index][1];
|
|
120
|
-
|
|
121
|
-
if (currentElement != null) {
|
|
122
|
-
// Same target, return
|
|
123
|
-
if (currentElement == instance) return;
|
|
124
|
-
|
|
125
|
-
// Cancel observation
|
|
126
|
-
resizeObserver.unobserve(currentElement);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Update element
|
|
130
|
-
init[index][1] = instance;
|
|
131
|
-
|
|
132
|
-
// Start observe
|
|
133
|
-
resizeObserver.observe(instance);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
];
|
|
137
|
-
})(e)
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
112
|
// Layout ready
|
|
142
113
|
React.useEffect(() => {
|
|
143
114
|
return () => {
|