@etsoo/react 1.5.29 → 1.5.32
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/__tests__/mu/NotifierMUTests.tsx +11 -2
- package/lib/app/ReactApp.d.ts +3 -1
- package/lib/app/ReactUtils.js +2 -2
- package/lib/mu/FlexBox.d.ts +2 -2
- package/lib/mu/ListMoreDisplay.d.ts +1 -1
- package/lib/mu/NotifierMU.d.ts +1 -1
- package/lib/mu/NotifierMU.js +4 -2
- package/lib/mu/pages/ViewPage.d.ts +1 -1
- package/lib/notifier/Notifier.d.ts +1 -1
- package/lib/notifier/Notifier.js +2 -1
- package/lib/states/IState.d.ts +3 -0
- package/lib/states/State.d.ts +1 -1
- package/package.json +33 -32
- package/src/app/ReactUtils.ts +2 -2
- package/src/mu/FlexBox.tsx +2 -2
- package/src/mu/ListMoreDisplay.tsx +1 -1
- package/src/mu/NotifierMU.tsx +4 -2
- package/src/mu/pages/ViewPage.tsx +1 -1
- package/src/notifier/Notifier.ts +1 -1
- package/src/states/IState.ts +4 -1
- package/src/states/RouterProps.ts +0 -1
- package/src/states/State.tsx +3 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { act } from 'react-dom/test-utils';
|
|
4
4
|
import { INotification, NotificationMessageType, NotifierMU } from '../../src';
|
|
5
5
|
|
|
6
|
+
// Without it will popup error:
|
|
7
|
+
// The current testing environment is not configured to support act
|
|
8
|
+
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
|
|
9
|
+
|
|
6
10
|
// Root
|
|
7
11
|
const root = document.body;
|
|
8
12
|
const container: HTMLElement = document.createElement('div');
|
|
@@ -10,7 +14,12 @@ root.append(container);
|
|
|
10
14
|
|
|
11
15
|
// The state provider
|
|
12
16
|
const Provider = NotifierMU.setup();
|
|
13
|
-
|
|
17
|
+
const reactRoot = createRoot(container); // createRoot(container!) if you use TypeScript
|
|
18
|
+
|
|
19
|
+
act(() => {
|
|
20
|
+
// Concorrent renderer needs act block
|
|
21
|
+
reactRoot.render(<Provider />);
|
|
22
|
+
});
|
|
14
23
|
|
|
15
24
|
// Notifier
|
|
16
25
|
const notifier = NotifierMU.instance;
|
package/lib/app/ReactApp.d.ts
CHANGED
|
@@ -22,7 +22,9 @@ export declare let globalApp: IReactApp<IAppSettings, any, IPageData>;
|
|
|
22
22
|
* @param props Props
|
|
23
23
|
* @returns Component
|
|
24
24
|
*/
|
|
25
|
-
export declare function ReactAppStateDetector(props: IStateProps): React.FunctionComponentElement<{
|
|
25
|
+
export declare function ReactAppStateDetector(props: IStateProps): React.FunctionComponentElement<{
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
}>;
|
|
26
28
|
/**
|
|
27
29
|
* Core application interface
|
|
28
30
|
*/
|
package/lib/app/ReactUtils.js
CHANGED
|
@@ -47,8 +47,8 @@ export var ReactUtils;
|
|
|
47
47
|
// Go(-1), a, index = 0
|
|
48
48
|
// View c, index = 1, directly push is wrong
|
|
49
49
|
if (index < stack.length) {
|
|
50
|
-
stack.splice(index
|
|
51
|
-
states.splice(index
|
|
50
|
+
stack.splice(index);
|
|
51
|
+
states.splice(index);
|
|
52
52
|
}
|
|
53
53
|
stack.push({
|
|
54
54
|
pathname,
|
package/lib/mu/FlexBox.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ import { StackProps } from '@mui/material';
|
|
|
5
5
|
* @param props Props
|
|
6
6
|
* @returns Component
|
|
7
7
|
*/
|
|
8
|
-
export declare function HBox(props:
|
|
8
|
+
export declare function HBox(props: Omit<StackProps, 'ref'>): JSX.Element;
|
|
9
9
|
/**
|
|
10
10
|
* Vertial box
|
|
11
11
|
* @param props Props
|
|
12
12
|
* @returns Component
|
|
13
13
|
*/
|
|
14
|
-
export declare function VBox(props:
|
|
14
|
+
export declare function VBox(props: Omit<StackProps, 'ref'>): JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { GridData, GridLoader } from '../components/GridLoader';
|
|
|
5
5
|
/**
|
|
6
6
|
* ListMoreDisplay props
|
|
7
7
|
*/
|
|
8
|
-
export interface ListMoreDisplayProps<T, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate> extends CardProps, GridLoader<T> {
|
|
8
|
+
export interface ListMoreDisplayProps<T, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate> extends Omit<CardProps, 'children'>, GridLoader<T> {
|
|
9
9
|
/**
|
|
10
10
|
* Children to display the list
|
|
11
11
|
*/
|
package/lib/mu/NotifierMU.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare class NotifierMU extends NotifierReact {
|
|
|
29
29
|
* @param className Style class name
|
|
30
30
|
* @returns Provider
|
|
31
31
|
*/
|
|
32
|
-
static setup(className?: string): React.FunctionComponent<import("../notifier/Notifier").NotificationReactRenderProps
|
|
32
|
+
static setup(className?: string): React.FunctionComponent<React.PropsWithChildren<import("../notifier/Notifier").NotificationReactRenderProps>>;
|
|
33
33
|
private static getOrigin;
|
|
34
34
|
/**
|
|
35
35
|
* Create align container
|
package/lib/mu/NotifierMU.js
CHANGED
|
@@ -311,8 +311,10 @@ export class NotifierMU extends NotifierReact {
|
|
|
311
311
|
*/
|
|
312
312
|
static setup(className = 'notifier-mu') {
|
|
313
313
|
// Create an instance
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
const instance = new NotifierMU();
|
|
315
|
+
const provider = instance.createProvider(className);
|
|
316
|
+
NotifierReact.updateInstance(instance);
|
|
317
|
+
return provider;
|
|
316
318
|
}
|
|
317
319
|
// Calculate origin from align property
|
|
318
320
|
static getOrigin(align) {
|
|
@@ -31,7 +31,7 @@ declare type ViewPageFieldType<T> = (string & keyof T) | [string & keyof T, Grid
|
|
|
31
31
|
/**
|
|
32
32
|
* View page props
|
|
33
33
|
*/
|
|
34
|
-
export interface ViewPageProps<T extends {}> extends
|
|
34
|
+
export interface ViewPageProps<T extends {}> extends Omit<CommonPageProps, 'children'> {
|
|
35
35
|
/**
|
|
36
36
|
* Actions
|
|
37
37
|
*/
|
|
@@ -125,6 +125,6 @@ export declare abstract class NotifierReact extends NotificationContainer<React.
|
|
|
125
125
|
* @param className Style class name
|
|
126
126
|
* @returns Provider
|
|
127
127
|
*/
|
|
128
|
-
createProvider(className?: string): React.FunctionComponent<NotificationReactRenderProps
|
|
128
|
+
createProvider(className?: string): React.FunctionComponent<React.PropsWithChildren<NotificationReactRenderProps>>;
|
|
129
129
|
}
|
|
130
130
|
export {};
|
package/lib/notifier/Notifier.js
CHANGED
|
@@ -16,7 +16,8 @@ export class NotifierReact extends NotificationContainer {
|
|
|
16
16
|
constructor() {
|
|
17
17
|
super((notification, dismiss) => {
|
|
18
18
|
// Make sure the state update is set
|
|
19
|
-
this.stateUpdate
|
|
19
|
+
if (this.stateUpdate)
|
|
20
|
+
this.stateUpdate({ notification, dismiss });
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
/**
|
package/lib/states/IState.d.ts
CHANGED
package/lib/states/State.d.ts
CHANGED
|
@@ -13,6 +13,6 @@ export declare class State {
|
|
|
13
13
|
*/
|
|
14
14
|
static create<S extends IState, A extends IAction, U extends IUpdate<S, A>, P extends IProviderProps<A>>(reducer: React.Reducer<S, A>, initState: S, calls: U, uiCreator?: IUICreator<S, A, P>): {
|
|
15
15
|
context: React.Context<U>;
|
|
16
|
-
provider: React.FunctionComponent<P
|
|
16
|
+
provider: React.FunctionComponent<React.PropsWithChildren<P>>;
|
|
17
17
|
};
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.32",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -46,52 +46,53 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/ETSOO/AppReact#readme",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@emotion/css": "^11.
|
|
50
|
-
"@emotion/react": "^11.
|
|
49
|
+
"@emotion/css": "^11.9.0",
|
|
50
|
+
"@emotion/react": "^11.9.0",
|
|
51
51
|
"@emotion/style": "^0.8.0",
|
|
52
52
|
"@emotion/styled": "^11.8.1",
|
|
53
|
-
"@etsoo/appscript": "^1.2.
|
|
54
|
-
"@etsoo/notificationbase": "^1.1.
|
|
55
|
-
"@etsoo/shared": "^1.1.
|
|
56
|
-
"@mui/icons-material": "^5.
|
|
57
|
-
"@mui/material": "^5.
|
|
53
|
+
"@etsoo/appscript": "^1.2.60",
|
|
54
|
+
"@etsoo/notificationbase": "^1.1.3",
|
|
55
|
+
"@etsoo/shared": "^1.1.38",
|
|
56
|
+
"@mui/icons-material": "^5.8.0",
|
|
57
|
+
"@mui/material": "^5.8.1",
|
|
58
58
|
"@reach/router": "^1.3.4",
|
|
59
59
|
"@types/pica": "^9.0.0",
|
|
60
60
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
61
61
|
"@types/reach__router": "^1.3.10",
|
|
62
|
-
"@types/react": "^
|
|
63
|
-
"@types/react-avatar-editor": "^
|
|
62
|
+
"@types/react": "^18.0.9",
|
|
63
|
+
"@types/react-avatar-editor": "^12.0.0",
|
|
64
64
|
"@types/react-beautiful-dnd": "^13.1.2",
|
|
65
|
-
"@types/react-dom": "^
|
|
65
|
+
"@types/react-dom": "^18.0.5",
|
|
66
66
|
"@types/react-input-mask": "^3.0.1",
|
|
67
67
|
"@types/react-window": "^1.8.5",
|
|
68
68
|
"pica": "^9.0.1",
|
|
69
69
|
"pulltorefreshjs": "^0.1.22",
|
|
70
|
-
"react": "^
|
|
71
|
-
"react-avatar-editor": "^
|
|
70
|
+
"react": "^18.1.0",
|
|
71
|
+
"react-avatar-editor": "^13.0.0",
|
|
72
72
|
"react-beautiful-dnd": "^13.1.0",
|
|
73
|
-
"react-dom": "^
|
|
74
|
-
"react-draggable": "^4.4.
|
|
73
|
+
"react-dom": "^18.1.0",
|
|
74
|
+
"react-draggable": "^4.4.5",
|
|
75
75
|
"react-imask": "^6.4.2",
|
|
76
|
-
"react-window": "^1.8.
|
|
76
|
+
"react-window": "^1.8.7"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@babel/cli": "^7.17.
|
|
80
|
-
"@babel/core": "^7.
|
|
81
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
82
|
-
"@babel/preset-env": "^7.
|
|
83
|
-
"@babel/runtime-corejs3": "^7.
|
|
84
|
-
"@types/jest": "^27.
|
|
85
|
-
"@types/react-test-renderer": "^
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
87
|
-
"@typescript-eslint/parser": "^5.
|
|
88
|
-
"eslint": "^8.
|
|
79
|
+
"@babel/cli": "^7.17.10",
|
|
80
|
+
"@babel/core": "^7.18.0",
|
|
81
|
+
"@babel/plugin-transform-runtime": "^7.18.0",
|
|
82
|
+
"@babel/preset-env": "^7.18.0",
|
|
83
|
+
"@babel/runtime-corejs3": "^7.18.0",
|
|
84
|
+
"@types/jest": "^27.5.1",
|
|
85
|
+
"@types/react-test-renderer": "^18.0.0",
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "^5.26.0",
|
|
87
|
+
"@typescript-eslint/parser": "^5.26.0",
|
|
88
|
+
"eslint": "^8.16.0",
|
|
89
89
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
90
|
-
"eslint-plugin-import": "^2.
|
|
91
|
-
"eslint-plugin-react": "^7.
|
|
92
|
-
"jest": "^
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
90
|
+
"eslint-plugin-import": "^2.26.0",
|
|
91
|
+
"eslint-plugin-react": "^7.30.0",
|
|
92
|
+
"jest": "^28.1.0",
|
|
93
|
+
"jest-environment-jsdom": "^28.1.0",
|
|
94
|
+
"react-test-renderer": "^18.1.0",
|
|
95
|
+
"ts-jest": "^28.0.3",
|
|
96
|
+
"typescript": "^4.6.4"
|
|
96
97
|
}
|
|
97
98
|
}
|
package/src/app/ReactUtils.ts
CHANGED
|
@@ -65,8 +65,8 @@ export namespace ReactUtils {
|
|
|
65
65
|
// Go(-1), a, index = 0
|
|
66
66
|
// View c, index = 1, directly push is wrong
|
|
67
67
|
if (index < stack.length) {
|
|
68
|
-
stack.splice(index
|
|
69
|
-
states.splice(index
|
|
68
|
+
stack.splice(index);
|
|
69
|
+
states.splice(index);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
stack.push({
|
package/src/mu/FlexBox.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import React from 'react';
|
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export function HBox(props:
|
|
9
|
+
export function HBox(props: Omit<StackProps, 'ref'>) {
|
|
10
10
|
return <Stack direction="row" width="100%" {...props} />;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -15,6 +15,6 @@ export function HBox(props: Exclude<StackProps, 'ref'>) {
|
|
|
15
15
|
* @param props Props
|
|
16
16
|
* @returns Component
|
|
17
17
|
*/
|
|
18
|
-
export function VBox(props:
|
|
18
|
+
export function VBox(props: Omit<StackProps, 'ref'>) {
|
|
19
19
|
return <Stack direction="column" {...props} />;
|
|
20
20
|
}
|
|
@@ -24,7 +24,7 @@ import { LoadingButton } from './LoadingButton';
|
|
|
24
24
|
export interface ListMoreDisplayProps<
|
|
25
25
|
T,
|
|
26
26
|
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
27
|
-
> extends CardProps,
|
|
27
|
+
> extends Omit<CardProps, 'children'>,
|
|
28
28
|
GridLoader<T> {
|
|
29
29
|
/**
|
|
30
30
|
* Children to display the list
|
package/src/mu/NotifierMU.tsx
CHANGED
|
@@ -487,8 +487,10 @@ export class NotifierMU extends NotifierReact {
|
|
|
487
487
|
*/
|
|
488
488
|
static setup(className = 'notifier-mu') {
|
|
489
489
|
// Create an instance
|
|
490
|
-
|
|
491
|
-
|
|
490
|
+
const instance = new NotifierMU();
|
|
491
|
+
const provider = instance.createProvider(className);
|
|
492
|
+
NotifierReact.updateInstance(instance);
|
|
493
|
+
return provider;
|
|
492
494
|
}
|
|
493
495
|
|
|
494
496
|
// Calculate origin from align property
|
package/src/notifier/Notifier.ts
CHANGED
|
@@ -163,7 +163,7 @@ export abstract class NotifierReact
|
|
|
163
163
|
protected constructor() {
|
|
164
164
|
super((notification, dismiss) => {
|
|
165
165
|
// Make sure the state update is set
|
|
166
|
-
this.stateUpdate
|
|
166
|
+
if (this.stateUpdate) this.stateUpdate({ notification, dismiss });
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
|
package/src/states/IState.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IAction, IState, UserKey } from '@etsoo/appscript';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* State UI creator
|
|
@@ -49,5 +49,8 @@ export interface IProviderUpdate<A extends IAction> {
|
|
|
49
49
|
* State provider props
|
|
50
50
|
*/
|
|
51
51
|
export interface IProviderProps<A extends IAction> {
|
|
52
|
+
/**
|
|
53
|
+
* Update callback
|
|
54
|
+
*/
|
|
52
55
|
update?: IProviderUpdate<A>;
|
|
53
56
|
}
|
package/src/states/State.tsx
CHANGED
|
@@ -27,7 +27,9 @@ export class State {
|
|
|
27
27
|
const context = React.createContext(calls);
|
|
28
28
|
|
|
29
29
|
// State context provider
|
|
30
|
-
const provider: React.FunctionComponent<P
|
|
30
|
+
const provider: React.FunctionComponent<React.PropsWithChildren<P>> = (
|
|
31
|
+
props
|
|
32
|
+
) => {
|
|
31
33
|
// Destruct
|
|
32
34
|
const { children, update } = props;
|
|
33
35
|
|