@etsoo/react 1.5.28 → 1.5.31

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,8 +1,12 @@
1
1
  import React from 'react';
2
- import ReactDOM from 'react-dom';
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
- ReactDOM.render(<Provider />, container);
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;
@@ -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
  */
@@ -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, stack.length - index);
51
- states.splice(index, stack.length - index);
50
+ stack.splice(index);
51
+ states.splice(index);
52
52
  }
53
53
  stack.push({
54
54
  pathname,
@@ -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: Exclude<StackProps, 'ref'>): JSX.Element;
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: Exclude<StackProps, 'ref'>): JSX.Element;
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
  */
@@ -311,8 +311,10 @@ export class NotifierMU extends NotifierReact {
311
311
  */
312
312
  static setup(className = 'notifier-mu') {
313
313
  // Create an instance
314
- NotifierReact.updateInstance(new NotifierMU());
315
- return NotifierReact.instance.createProvider(className);
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 Exclude<CommonPageProps, 'children'> {
34
+ export interface ViewPageProps<T extends {}> extends Omit<CommonPageProps, 'children'> {
35
35
  /**
36
36
  * Actions
37
37
  */
@@ -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({ notification, dismiss });
19
+ if (this.stateUpdate)
20
+ this.stateUpdate({ notification, dismiss });
20
21
  });
21
22
  }
22
23
  /**
@@ -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
  * State UI creator
5
5
  */
@@ -42,5 +42,12 @@ export interface IProviderUpdate<A extends IAction> {
42
42
  * State provider props
43
43
  */
44
44
  export interface IProviderProps<A extends IAction> {
45
+ /**
46
+ * Children
47
+ */
48
+ children?: ReactNode | undefined;
49
+ /**
50
+ * Update callback
51
+ */
45
52
  update?: IProviderUpdate<A>;
46
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.5.28",
3
+ "version": "1.5.31",
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.7.1",
50
- "@emotion/react": "^11.8.1",
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.57",
54
- "@etsoo/notificationbase": "^1.1.2",
55
- "@etsoo/shared": "^1.1.14",
56
- "@mui/icons-material": "^5.4.2",
57
- "@mui/material": "^5.4.3",
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": "^17.0.39",
63
- "@types/react-avatar-editor": "^10.3.6",
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": "^17.0.11",
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": "^17.0.2",
71
- "react-avatar-editor": "^12.0.0",
70
+ "react": "^18.1.0",
71
+ "react-avatar-editor": "^13.0.0",
72
72
  "react-beautiful-dnd": "^13.1.0",
73
- "react-dom": "^17.0.2",
74
- "react-draggable": "^4.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.6"
76
+ "react-window": "^1.8.7"
77
77
  },
78
78
  "devDependencies": {
79
- "@babel/cli": "^7.17.6",
80
- "@babel/core": "^7.17.5",
81
- "@babel/plugin-transform-runtime": "^7.17.0",
82
- "@babel/preset-env": "^7.16.11",
83
- "@babel/runtime-corejs3": "^7.17.2",
84
- "@types/jest": "^27.4.1",
85
- "@types/react-test-renderer": "^17.0.1",
86
- "@typescript-eslint/eslint-plugin": "^5.12.1",
87
- "@typescript-eslint/parser": "^5.12.1",
88
- "eslint": "^8.10.0",
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.25.4",
91
- "eslint-plugin-react": "^7.29.2",
92
- "jest": "^27.5.1",
93
- "react-test-renderer": "^17.0.2",
94
- "ts-jest": "^27.1.3",
95
- "typescript": "^4.5.5"
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
  }
@@ -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, stack.length - index);
69
- states.splice(index, stack.length - index);
68
+ stack.splice(index);
69
+ states.splice(index);
70
70
  }
71
71
 
72
72
  stack.push({
@@ -6,7 +6,7 @@ import React from 'react';
6
6
  * @param props Props
7
7
  * @returns Component
8
8
  */
9
- export function HBox(props: Exclude<StackProps, 'ref'>) {
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: Exclude<StackProps, 'ref'>) {
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
@@ -487,8 +487,10 @@ export class NotifierMU extends NotifierReact {
487
487
  */
488
488
  static setup(className = 'notifier-mu') {
489
489
  // Create an instance
490
- NotifierReact.updateInstance(new NotifierMU());
491
- return NotifierReact.instance.createProvider(className);
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
@@ -58,7 +58,7 @@ type ViewPageFieldType<T> =
58
58
  * View page props
59
59
  */
60
60
  export interface ViewPageProps<T extends {}>
61
- extends Exclude<CommonPageProps, 'children'> {
61
+ extends Omit<CommonPageProps, 'children'> {
62
62
  /**
63
63
  * Actions
64
64
  */
@@ -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!({ notification, dismiss });
166
+ if (this.stateUpdate) this.stateUpdate({ notification, dismiss });
167
167
  });
168
168
  }
169
169
 
@@ -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,13 @@ export interface IProviderUpdate<A extends IAction> {
49
49
  * State provider props
50
50
  */
51
51
  export interface IProviderProps<A extends IAction> {
52
+ /**
53
+ * Children
54
+ */
55
+ children?: ReactNode | undefined;
56
+
57
+ /**
58
+ * Update callback
59
+ */
52
60
  update?: IProviderUpdate<A>;
53
61
  }
@@ -1,6 +1,5 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
2
  import { RouteComponentProps } from '@reach/router';
3
- import { Props } from 'react-input-mask';
4
3
 
5
4
  /**
6
5
  * Add / Edit page router props, include 'id' (/:id) or none when adding query parameter