@etsoo/react 1.1.85 → 1.1.86
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 +3 -0
- package/lib/app/ReactApp.js +3 -0
- package/lib/mu/pages/CommonPage.js +12 -7
- package/lib/mu/pages/CommonPageProps.d.ts +7 -3
- package/package.json +1 -1
- package/src/app/ReactApp.ts +3 -0
- package/src/mu/pages/CommonPage.tsx +7 -2
- package/src/mu/pages/CommonPageProps.ts +8 -3
package/lib/app/ReactApp.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ import { UserAction, UserState } from '../states/UserState';
|
|
|
8
8
|
import { InputDialogProps } from './InputDialogProps';
|
|
9
9
|
/**
|
|
10
10
|
* React app state detector
|
|
11
|
+
* Case 1: undefined, when refresh the whole page
|
|
12
|
+
* Case 2: false, unauthorized
|
|
13
|
+
* Case 3: true, authorized or considered as authorized (maynot, like token expiry)
|
|
11
14
|
* @param props Props
|
|
12
15
|
* @returns Component
|
|
13
16
|
*/
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -5,6 +5,9 @@ import { UserActionType, UserState } from '../states/UserState';
|
|
|
5
5
|
let app;
|
|
6
6
|
/**
|
|
7
7
|
* React app state detector
|
|
8
|
+
* Case 1: undefined, when refresh the whole page
|
|
9
|
+
* Case 2: false, unauthorized
|
|
10
|
+
* Case 3: true, authorized or considered as authorized (maynot, like token expiry)
|
|
8
11
|
* @param props Props
|
|
9
12
|
* @returns Component
|
|
10
13
|
*/
|
|
@@ -22,7 +22,7 @@ export const CommonPageScrollContainer = global;
|
|
|
22
22
|
*/
|
|
23
23
|
export function CommonPage(props) {
|
|
24
24
|
// Destruct
|
|
25
|
-
const { children, disableGutters = true, fabButtons, fabSize = 'medium', maxWidth = false, moreActions, onRefresh, onUpdate, paddings = MUGlobal.pagePaddings, scrollContainer, pullContainer, sx = {}, ...rest } = props;
|
|
25
|
+
const { children, disableGutters = true, fabButtons, fabSize = 'medium', maxWidth = false, moreActions, onRefresh, onUpdate, onUpdateAll, paddings = MUGlobal.pagePaddings, scrollContainer, pullContainer, sx = {}, ...rest } = props;
|
|
26
26
|
// Merge style
|
|
27
27
|
Object.assign(sx, {
|
|
28
28
|
padding: paddings
|
|
@@ -30,14 +30,19 @@ export function CommonPage(props) {
|
|
|
30
30
|
// Labels
|
|
31
31
|
const labels = Labels.CommonPage;
|
|
32
32
|
// Update
|
|
33
|
-
const update =
|
|
34
|
-
?
|
|
35
|
-
:
|
|
33
|
+
const update = onUpdateAll
|
|
34
|
+
? onUpdateAll
|
|
35
|
+
: onUpdate
|
|
36
36
|
? (authorized) => {
|
|
37
|
-
if (authorized)
|
|
38
|
-
|
|
37
|
+
if (authorized == null || authorized)
|
|
38
|
+
onUpdate();
|
|
39
39
|
}
|
|
40
|
-
:
|
|
40
|
+
: onRefresh
|
|
41
|
+
? (authorized) => {
|
|
42
|
+
if (authorized)
|
|
43
|
+
onRefresh();
|
|
44
|
+
}
|
|
45
|
+
: undefined;
|
|
41
46
|
// Return the UI
|
|
42
47
|
return (React.createElement(React.Fragment, null,
|
|
43
48
|
update && React.createElement(ReactAppStateDetector, { update: update }),
|
|
@@ -21,13 +21,17 @@ export interface CommonPageProps extends Omit<ContainerProps, 'id'> {
|
|
|
21
21
|
*/
|
|
22
22
|
moreActions?: MoreAction[];
|
|
23
23
|
/**
|
|
24
|
-
* On refresh callback
|
|
24
|
+
* On refresh callback, only when authorized = true
|
|
25
25
|
*/
|
|
26
26
|
onRefresh?: () => void | PromiseLike<void>;
|
|
27
27
|
/**
|
|
28
|
-
* On page update, may uses onRefresh
|
|
28
|
+
* On page update, when authorized = null or true case, may uses onRefresh
|
|
29
29
|
*/
|
|
30
|
-
onUpdate?:
|
|
30
|
+
onUpdate?: () => void | PromiseLike<void>;
|
|
31
|
+
/**
|
|
32
|
+
* On page update, all cases with authorized
|
|
33
|
+
*/
|
|
34
|
+
onUpdateAll?: IStateUpdate;
|
|
31
35
|
/**
|
|
32
36
|
* Paddings
|
|
33
37
|
*/
|
package/package.json
CHANGED
package/src/app/ReactApp.ts
CHANGED
|
@@ -23,6 +23,9 @@ let app: IReactApp<IAppSettings, any>;
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* React app state detector
|
|
26
|
+
* Case 1: undefined, when refresh the whole page
|
|
27
|
+
* Case 2: false, unauthorized
|
|
28
|
+
* Case 3: true, authorized or considered as authorized (maynot, like token expiry)
|
|
26
29
|
* @param props Props
|
|
27
30
|
* @returns Component
|
|
28
31
|
*/
|
|
@@ -35,6 +35,7 @@ export function CommonPage(props: CommonPageProps) {
|
|
|
35
35
|
moreActions,
|
|
36
36
|
onRefresh,
|
|
37
37
|
onUpdate,
|
|
38
|
+
onUpdateAll,
|
|
38
39
|
paddings = MUGlobal.pagePaddings,
|
|
39
40
|
scrollContainer,
|
|
40
41
|
pullContainer,
|
|
@@ -51,8 +52,12 @@ export function CommonPage(props: CommonPageProps) {
|
|
|
51
52
|
const labels = Labels.CommonPage;
|
|
52
53
|
|
|
53
54
|
// Update
|
|
54
|
-
const update =
|
|
55
|
-
?
|
|
55
|
+
const update = onUpdateAll
|
|
56
|
+
? onUpdateAll
|
|
57
|
+
: onUpdate
|
|
58
|
+
? (authorized?: boolean) => {
|
|
59
|
+
if (authorized == null || authorized) onUpdate();
|
|
60
|
+
}
|
|
56
61
|
: onRefresh
|
|
57
62
|
? (authorized?: boolean) => {
|
|
58
63
|
if (authorized) onRefresh();
|
|
@@ -24,14 +24,19 @@ export interface CommonPageProps extends Omit<ContainerProps, 'id'> {
|
|
|
24
24
|
moreActions?: MoreAction[];
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* On refresh callback
|
|
27
|
+
* On refresh callback, only when authorized = true
|
|
28
28
|
*/
|
|
29
29
|
onRefresh?: () => void | PromiseLike<void>;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* On page update, may uses onRefresh
|
|
32
|
+
* On page update, when authorized = null or true case, may uses onRefresh
|
|
33
33
|
*/
|
|
34
|
-
onUpdate?:
|
|
34
|
+
onUpdate?: () => void | PromiseLike<void>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* On page update, all cases with authorized
|
|
38
|
+
*/
|
|
39
|
+
onUpdateAll?: IStateUpdate;
|
|
35
40
|
|
|
36
41
|
/**
|
|
37
42
|
* Paddings
|