@etsoo/react 1.2.66 → 1.2.70
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.d.ts +7 -7
- package/lib/app/ReactApp.js +18 -18
- package/lib/mu/TabBox.d.ts +8 -4
- package/lib/mu/TabBox.js +4 -3
- package/package.json +4 -4
- package/src/app/ReactApp.ts +25 -20
- package/src/mu/TabBox.tsx +15 -7
package/lib/app/ReactApp.d.ts
CHANGED
|
@@ -82,11 +82,6 @@ export declare abstract class ReactApp<S extends IAppSettings, D extends IUser,
|
|
|
82
82
|
culture: string;
|
|
83
83
|
currency: string;
|
|
84
84
|
};
|
|
85
|
-
/**
|
|
86
|
-
* Try login
|
|
87
|
-
* Will update user state with UserActionType.Unauthorized
|
|
88
|
-
*/
|
|
89
|
-
tryLogin(): Promise<boolean>;
|
|
90
85
|
/**
|
|
91
86
|
* Set page data
|
|
92
87
|
* @param data Page data
|
|
@@ -115,7 +110,12 @@ export declare abstract class ReactApp<S extends IAppSettings, D extends IUser,
|
|
|
115
110
|
*/
|
|
116
111
|
userLogin(user: IUserData, refreshToken?: string, keep?: boolean): void;
|
|
117
112
|
/**
|
|
118
|
-
* User logout
|
|
113
|
+
* User logout
|
|
114
|
+
* @param clearToken Clear refresh token or not
|
|
115
|
+
*/
|
|
116
|
+
userLogout(clearToken?: boolean): void;
|
|
117
|
+
/**
|
|
118
|
+
* User unauthorized
|
|
119
119
|
*/
|
|
120
|
-
|
|
120
|
+
userUnauthorized(): void;
|
|
121
121
|
}
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -73,21 +73,6 @@ export class ReactApp extends CoreApp {
|
|
|
73
73
|
getMoneyFormatProps() {
|
|
74
74
|
return { culture: this.culture, currency: this.currency };
|
|
75
75
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Try login
|
|
78
|
-
* Will update user state with UserActionType.Unauthorized
|
|
79
|
-
*/
|
|
80
|
-
async tryLogin() {
|
|
81
|
-
const result = await super.tryLogin();
|
|
82
|
-
if (result && this.userStateDispatch != null) {
|
|
83
|
-
// There is delay during state update
|
|
84
|
-
// Not a good idea to try login multiple times with API calls
|
|
85
|
-
this.userStateDispatch({
|
|
86
|
-
type: UserActionType.Unauthorized
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return result;
|
|
90
|
-
}
|
|
91
76
|
/**
|
|
92
77
|
* Set page data
|
|
93
78
|
* @param data Page data
|
|
@@ -153,15 +138,30 @@ export class ReactApp extends CoreApp {
|
|
|
153
138
|
});
|
|
154
139
|
}
|
|
155
140
|
/**
|
|
156
|
-
* User logout
|
|
141
|
+
* User logout
|
|
142
|
+
* @param clearToken Clear refresh token or not
|
|
157
143
|
*/
|
|
158
|
-
userLogout() {
|
|
144
|
+
userLogout(clearToken = true) {
|
|
145
|
+
// Super call
|
|
146
|
+
super.userLogout(clearToken);
|
|
159
147
|
// Dispatch action
|
|
160
148
|
if (this.userStateDispatch != null)
|
|
161
149
|
this.userStateDispatch({
|
|
162
150
|
type: UserActionType.Logout
|
|
163
151
|
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* User unauthorized
|
|
155
|
+
*/
|
|
156
|
+
userUnauthorized() {
|
|
164
157
|
// Super call
|
|
165
|
-
super.
|
|
158
|
+
super.userUnauthorized();
|
|
159
|
+
if (this.userStateDispatch != null) {
|
|
160
|
+
// There is delay during state update
|
|
161
|
+
// Not a good idea to try login multiple times with API calls
|
|
162
|
+
this.userStateDispatch({
|
|
163
|
+
type: UserActionType.Unauthorized
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
166
|
}
|
|
167
167
|
}
|
package/lib/mu/TabBox.d.ts
CHANGED
|
@@ -17,14 +17,18 @@ export interface TabBoxPanel extends Omit<TabProps, 'value' | 'children'> {
|
|
|
17
17
|
* Tabs with box props
|
|
18
18
|
*/
|
|
19
19
|
export interface TabBoxPros extends BoxProps {
|
|
20
|
-
/**
|
|
21
|
-
* Root props
|
|
22
|
-
*/
|
|
23
|
-
root?: BoxProps;
|
|
24
20
|
/**
|
|
25
21
|
* Container props
|
|
26
22
|
*/
|
|
27
23
|
container?: Omit<TabsProps, 'value'>;
|
|
24
|
+
/**
|
|
25
|
+
* Add a hidden input and its name
|
|
26
|
+
*/
|
|
27
|
+
inputName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Root props
|
|
30
|
+
*/
|
|
31
|
+
root?: BoxProps;
|
|
28
32
|
/**
|
|
29
33
|
* Tabs
|
|
30
34
|
*/
|
package/lib/mu/TabBox.js
CHANGED
|
@@ -7,17 +7,18 @@ import React from 'react';
|
|
|
7
7
|
*/
|
|
8
8
|
export function TabBox(props) {
|
|
9
9
|
// Destruct
|
|
10
|
-
const { root, container = {}, tabs } = props;
|
|
10
|
+
const { inputName, root, container = {}, tabs } = props;
|
|
11
11
|
const { onChange, ...rest } = container;
|
|
12
12
|
// State
|
|
13
13
|
const [value, setValue] = React.useState(0);
|
|
14
14
|
// Layout
|
|
15
15
|
return (React.createElement(React.Fragment, null,
|
|
16
|
+
inputName && (React.createElement("input", { type: "hidden", name: inputName, value: value })),
|
|
16
17
|
React.createElement(Box, { ...root },
|
|
17
18
|
React.createElement(Tabs, { value: value, onChange: (event, newValue) => {
|
|
18
19
|
setValue(newValue);
|
|
19
20
|
if (onChange)
|
|
20
21
|
onChange(event, newValue);
|
|
21
|
-
}, ...rest }, tabs.map(({ children, panel, ...tabRest }, index) => (React.createElement(Tab, { value: index, ...tabRest }))))),
|
|
22
|
-
tabs.map(({ children, panel }, index) => (React.createElement(Box, { hidden: value !== index, ...panel }, children)))));
|
|
22
|
+
}, ...rest }, tabs.map(({ children, panel, ...tabRest }, index) => (React.createElement(Tab, { key: index, value: index, ...tabRest }))))),
|
|
23
|
+
tabs.map(({ children, panel }, index) => (React.createElement(Box, { key: index, hidden: value !== index, ...panel }, children)))));
|
|
23
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.70",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"@emotion/react": "^11.5.0",
|
|
51
51
|
"@emotion/style": "^0.8.0",
|
|
52
52
|
"@emotion/styled": "^11.3.0",
|
|
53
|
-
"@etsoo/appscript": "^1.1.
|
|
54
|
-
"@etsoo/notificationbase": "^1.0.
|
|
55
|
-
"@etsoo/shared": "^1.0.
|
|
53
|
+
"@etsoo/appscript": "^1.1.21",
|
|
54
|
+
"@etsoo/notificationbase": "^1.0.89",
|
|
55
|
+
"@etsoo/shared": "^1.0.58",
|
|
56
56
|
"@mui/icons-material": "^5.0.4",
|
|
57
57
|
"@mui/material": "^5.0.4",
|
|
58
58
|
"@reach/router": "^1.3.4",
|
package/src/app/ReactApp.ts
CHANGED
|
@@ -150,22 +150,6 @@ export abstract class ReactApp<
|
|
|
150
150
|
return { culture: this.culture, currency: this.currency };
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
/**
|
|
154
|
-
* Try login
|
|
155
|
-
* Will update user state with UserActionType.Unauthorized
|
|
156
|
-
*/
|
|
157
|
-
override async tryLogin() {
|
|
158
|
-
const result = await super.tryLogin();
|
|
159
|
-
if (result && this.userStateDispatch != null) {
|
|
160
|
-
// There is delay during state update
|
|
161
|
-
// Not a good idea to try login multiple times with API calls
|
|
162
|
-
this.userStateDispatch({
|
|
163
|
-
type: UserActionType.Unauthorized
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
153
|
/**
|
|
170
154
|
* Set page data
|
|
171
155
|
* @param data Page data
|
|
@@ -229,7 +213,11 @@ export abstract class ReactApp<
|
|
|
229
213
|
* @param refreshToken Refresh token
|
|
230
214
|
* @param keep Keep in local storage or not
|
|
231
215
|
*/
|
|
232
|
-
userLogin(
|
|
216
|
+
override userLogin(
|
|
217
|
+
user: IUserData,
|
|
218
|
+
refreshToken?: string,
|
|
219
|
+
keep?: boolean
|
|
220
|
+
): void {
|
|
233
221
|
// Changed
|
|
234
222
|
const dataChanged =
|
|
235
223
|
!this.authorized ||
|
|
@@ -249,16 +237,33 @@ export abstract class ReactApp<
|
|
|
249
237
|
}
|
|
250
238
|
|
|
251
239
|
/**
|
|
252
|
-
* User logout
|
|
240
|
+
* User logout
|
|
241
|
+
* @param clearToken Clear refresh token or not
|
|
253
242
|
*/
|
|
254
|
-
userLogout(): void {
|
|
243
|
+
override userLogout(clearToken: boolean = true): void {
|
|
244
|
+
// Super call
|
|
245
|
+
super.userLogout(clearToken);
|
|
246
|
+
|
|
255
247
|
// Dispatch action
|
|
256
248
|
if (this.userStateDispatch != null)
|
|
257
249
|
this.userStateDispatch({
|
|
258
250
|
type: UserActionType.Logout
|
|
259
251
|
});
|
|
252
|
+
}
|
|
260
253
|
|
|
254
|
+
/**
|
|
255
|
+
* User unauthorized
|
|
256
|
+
*/
|
|
257
|
+
override userUnauthorized() {
|
|
261
258
|
// Super call
|
|
262
|
-
super.
|
|
259
|
+
super.userUnauthorized();
|
|
260
|
+
|
|
261
|
+
if (this.userStateDispatch != null) {
|
|
262
|
+
// There is delay during state update
|
|
263
|
+
// Not a good idea to try login multiple times with API calls
|
|
264
|
+
this.userStateDispatch({
|
|
265
|
+
type: UserActionType.Unauthorized
|
|
266
|
+
});
|
|
267
|
+
}
|
|
263
268
|
}
|
|
264
269
|
}
|
package/src/mu/TabBox.tsx
CHANGED
|
@@ -21,14 +21,19 @@ export interface TabBoxPanel extends Omit<TabProps, 'value' | 'children'> {
|
|
|
21
21
|
*/
|
|
22
22
|
export interface TabBoxPros extends BoxProps {
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Container props
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
container?: Omit<TabsProps, 'value'>;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Add a hidden input and its name
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
inputName?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Root props
|
|
35
|
+
*/
|
|
36
|
+
root?: BoxProps;
|
|
32
37
|
|
|
33
38
|
/**
|
|
34
39
|
* Tabs
|
|
@@ -43,7 +48,7 @@ export interface TabBoxPros extends BoxProps {
|
|
|
43
48
|
*/
|
|
44
49
|
export function TabBox(props: TabBoxPros) {
|
|
45
50
|
// Destruct
|
|
46
|
-
const { root, container = {}, tabs } = props;
|
|
51
|
+
const { inputName, root, container = {}, tabs } = props;
|
|
47
52
|
const { onChange, ...rest } = container;
|
|
48
53
|
|
|
49
54
|
// State
|
|
@@ -52,6 +57,9 @@ export function TabBox(props: TabBoxPros) {
|
|
|
52
57
|
// Layout
|
|
53
58
|
return (
|
|
54
59
|
<React.Fragment>
|
|
60
|
+
{inputName && (
|
|
61
|
+
<input type="hidden" name={inputName} value={value} />
|
|
62
|
+
)}
|
|
55
63
|
<Box {...root}>
|
|
56
64
|
<Tabs
|
|
57
65
|
value={value}
|
|
@@ -62,12 +70,12 @@ export function TabBox(props: TabBoxPros) {
|
|
|
62
70
|
{...rest}
|
|
63
71
|
>
|
|
64
72
|
{tabs.map(({ children, panel, ...tabRest }, index) => (
|
|
65
|
-
<Tab value={index} {...tabRest} />
|
|
73
|
+
<Tab key={index} value={index} {...tabRest} />
|
|
66
74
|
))}
|
|
67
75
|
</Tabs>
|
|
68
76
|
</Box>
|
|
69
77
|
{tabs.map(({ children, panel }, index) => (
|
|
70
|
-
<Box hidden={value !== index} {...panel}>
|
|
78
|
+
<Box key={index} hidden={value !== index} {...panel}>
|
|
71
79
|
{children}
|
|
72
80
|
</Box>
|
|
73
81
|
))}
|