@carbonorm/carbonreact 4.0.0 → 4.0.2

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.
@@ -19,12 +19,13 @@ export declare const initialCarbonReactState: iCarbonReactState & iRestfulObject
19
19
  export declare function isJsonString(str: string): boolean;
20
20
  declare abstract class CarbonReact<P = {}, S extends {
21
21
  [key: string]: any;
22
- } = {}> extends Component<{
22
+ } = typeof initialCarbonReactState> extends Component<{
23
23
  children?: ReactNode | ReactNode[];
24
24
  instanceId?: string;
25
25
  websocket?: Omit<iCarbonWebSocketProps, "instance"> | boolean;
26
- } & P, S & iCarbonReactState> {
27
- context: Context<S & iCarbonReactState>;
26
+ } & P, S> {
27
+ private static persistentStateMap;
28
+ context: Context<S>;
28
29
  protected static instance: CarbonReact;
29
30
  protected target: typeof CarbonReact;
30
31
  protected updateRestfulObjectArrays: <ObjectType extends {
@@ -40,8 +41,8 @@ declare abstract class CarbonReact<P = {}, S extends {
40
41
  shouldStatePersist?: boolean | undefined;
41
42
  websocket?: boolean | iCarbonWebSocketProps | undefined;
42
43
  } & P);
43
- shouldComponentUpdate(nextProps: Readonly<any>, nextState: Readonly<iCarbonReactState>, _nextContext: any): boolean;
44
- componentDidUpdate(_prevProps: Readonly<any>, _prevState: Readonly<iCarbonReactState>, _snapshot?: any): void;
44
+ shouldComponentUpdate(nextProps: Readonly<P>, nextState: Readonly<S>, _nextContext: any): boolean;
45
+ componentDidUpdate(_prevProps: Readonly<P>, _prevState: Readonly<S>, _snapshot?: any): void;
45
46
  render(): ReactElement;
46
47
  }
47
48
  export default CarbonReact;
@@ -14,7 +14,7 @@ export interface iUpdateRestfulObjectArrays<ObjectType extends {
14
14
  dataOrCallback: ObjectType[] | ((state: Readonly<S>, props: Readonly<P>) => ObjectType[] | null);
15
15
  stateKey: KeysMatching<S, tStatefulApiData<ObjectType>>;
16
16
  uniqueObjectId: keyof ObjectType | (keyof ObjectType)[];
17
- insertUpdateOrder: eUpdateInsertMethod;
17
+ insertUpdateOrder?: eUpdateInsertMethod;
18
18
  callback?: () => void;
19
19
  }
20
20
  /**
package/dist/index.cjs.js CHANGED
@@ -4359,8 +4359,8 @@ function isJsonString(str) {
4359
4359
  }
4360
4360
  return true;
4361
4361
  }
4362
- const persistentStateMap = new Map();
4363
4362
  class CarbonReact extends react.Component {
4363
+ static persistentStateMap = new Map();
4364
4364
  context = react.createContext(this.state);
4365
4365
  // Private static member
4366
4366
  // we actually implement this in the constructor todo - test this
@@ -4387,8 +4387,8 @@ class CarbonReact extends react.Component {
4387
4387
  Object.assign(new.target, {
4388
4388
  instance: this
4389
4389
  });
4390
- if (this.props.instanceId && persistentStateMap.has(this.props.instanceId)) {
4391
- this.state = persistentStateMap.get(this.props.instanceId);
4390
+ if (this.props.instanceId && CarbonReact.persistentStateMap.has(this.props.instanceId)) {
4391
+ this.state = CarbonReact.persistentStateMap.get(this.props.instanceId);
4392
4392
  }
4393
4393
  else {
4394
4394
  // This should only ever be done here, when the full state is being trashed.
@@ -4407,7 +4407,7 @@ class CarbonReact extends react.Component {
4407
4407
  }
4408
4408
  shouldComponentUpdate(nextProps, nextState, _nextContext) {
4409
4409
  if (this.props.instanceId) {
4410
- persistentStateMap.set(this.props.instanceId, nextState);
4410
+ CarbonReact.persistentStateMap.set(this.props.instanceId, nextState);
4411
4411
  }
4412
4412
  changed(this.constructor.name + ' (C6Api)', 'props', this.props, nextProps);
4413
4413
  changed(this.constructor.name + ' (C6Api)', 'state', this.state, nextState);