@carbonorm/carbonreact 4.0.6 → 4.0.8

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/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@carbonorm/carbonreact",
3
3
  "license": "MIT",
4
- "version": "4.0.6",
4
+ "version": "4.0.8",
5
5
  "browser": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "main": "dist/index.cjs.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "type": "module",
10
10
  "dependencies": {
11
- "@carbonorm/carbonnode": "^1.6.44",
11
+ "@carbonorm/carbonnode": "^2.0.0",
12
12
  "@fortawesome/fontawesome-svg-core": "^6.4.0",
13
13
  "@fortawesome/free-solid-svg-icons": "^6.4.0",
14
14
  "@fortawesome/react-fontawesome": "^0.2.0",
@@ -46,6 +46,7 @@ export function isJsonString(str: string) {
46
46
  return false;
47
47
  }
48
48
  return true;
49
+
49
50
  }
50
51
 
51
52
  abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactState> extends Component<{
@@ -61,17 +62,18 @@ abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactSta
61
62
 
62
63
  protected target: typeof CarbonReact;
63
64
 
64
- protected static _instance: typeof this;
65
+ protected static _instance: CarbonReact<any, any>;
65
66
 
66
- static get instance() {
67
- return this;
67
+ static getInstance<T extends CarbonReact<any, any>>(): T {
68
+ return this._instance as T;
68
69
  }
69
-
70
- static set instance(instance: typeof this) {
70
+ static get instance() {
71
+ return this.getInstance();
72
+ }
73
+ static set instance(instance: CarbonReact<any, any>) {
71
74
  this._instance = instance;
72
75
  }
73
76
 
74
-
75
77
  protected updateRestfulObjectArrays = <ObjectType extends { [key: string]: any; } = {}>
76
78
  (rest: Omit<iUpdateRestfulObjectArrays<ObjectType, S, P>, "instance">) => updateRestfulObjectArrays<ObjectType, S, P>({
77
79
  instance: this,
@@ -18,7 +18,7 @@ export interface iAlertButtonOptions {
18
18
  color: "default" | "primary" | "secondary" | "inherit" | "danger" | "info" | "success" | "warning" | undefined,
19
19
  }
20
20
 
21
- export interface iAlert<P,S> {
21
+ export interface iAlert<P,S extends iCarbonReactState> {
22
22
  title: string,
23
23
  text: string,
24
24
  instance: CarbonReact<P,S>,
@@ -33,7 +33,7 @@ export interface iAlert<P,S> {
33
33
  backendThrowable?: { [key: string]: any },
34
34
  }
35
35
 
36
- export function addAlert<P, S extends Partial<iCarbonReactState>>(props: iAlert<P, S>) {
36
+ export function addAlert<P, S extends iCarbonReactState>(props: iAlert<P, S>) {
37
37
  props.instance.setState(previousState => ({
38
38
  alertsWaiting: previousState.alertsWaiting.length === 0
39
39
  ? [props]
@@ -41,7 +41,7 @@ export function addAlert<P, S extends Partial<iCarbonReactState>>(props: iAlert<
41
41
  }));
42
42
  }
43
43
 
44
- export default function Alert<P,S extends Partial<iCarbonReactState>>({
44
+ export default function Alert<P,S extends iCarbonReactState>({
45
45
  instance
46
46
  }: { instance: CarbonReact<P,S> }) {
47
47
 
@@ -4,7 +4,7 @@ import {useEffectOnce} from "../../api/hoc/useEffectOnce";
4
4
  import {tC6Tables, tC6RestApi} from "@carbonorm/carbonnode";
5
5
 
6
6
 
7
- export interface iCarbonWebSocketProps<P,S> {
7
+ export interface iCarbonWebSocketProps<P,S extends iCarbonReactState> {
8
8
  url?: string,
9
9
  timeoutSeconds?: number,
10
10
  heartbeatSeconds?: number,
@@ -17,7 +17,7 @@ export interface iCarbonWebSocketProps<P,S> {
17
17
  * @function connect
18
18
  * This function establishes a connection with the websocket and also ensures constant reconnection if connection closes
19
19
  **/
20
- export function initiateWebsocket<P,S extends Partial<iCarbonReactState>>(props: iCarbonWebSocketProps<P,S>) {
20
+ export function initiateWebsocket<P,S extends iCarbonReactState>(props: iCarbonWebSocketProps<P,S>) {
21
21
 
22
22
  let {
23
23
  instance,
@@ -286,7 +286,7 @@ export function initiateWebsocket<P,S extends Partial<iCarbonReactState>>(props:
286
286
 
287
287
  }
288
288
 
289
- export default function <P,S extends Partial<iCarbonReactState>>(props: iCarbonWebSocketProps<P,S>) {
289
+ export default function <P,S extends iCarbonReactState>(props: iCarbonWebSocketProps<P,S>) {
290
290
 
291
291
  useEffectOnce(() => {
292
292