@carbonorm/carbonreact 4.0.16 → 4.0.17

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.
@@ -17,10 +17,16 @@ export interface iCarbonReactState {
17
17
  export declare const initialRequiredCarbonORMState: iCarbonReactState;
18
18
  export declare const initialCarbonReactState: iCarbonReactState & iRestfulObjectArrayTypes;
19
19
  export declare function isJsonString(str: string): boolean;
20
+ export declare enum eRouterType {
21
+ BrowserRouter = 0,
22
+ HashRouter = 1,
23
+ MemoryRouter = 2
24
+ }
20
25
  declare abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactState> extends Component<{
21
26
  children?: ReactNode | ReactNode[];
22
27
  instanceId?: string;
23
28
  persistentState?: boolean;
29
+ routerType?: eRouterType;
24
30
  websocket?: Omit<iCarbonWebSocketProps<P, S>, "instance"> | false;
25
31
  } & P, S> {
26
32
  private static allInstances;
@@ -48,6 +54,7 @@ declare abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbon
48
54
  private generateIdentifier;
49
55
  shouldComponentUpdate(nextProps: Readonly<P>, nextState: Readonly<S>, _nextContext: any): boolean;
50
56
  componentDidUpdate(_prevProps: Readonly<P>, _prevState: Readonly<S>, _snapshot?: any): void;
57
+ reactRouterContext(children: ReactElement): import("react/jsx-runtime").JSX.Element;
51
58
  render(): ReactElement;
52
59
  }
53
60
  export default CarbonReact;
package/dist/index.cjs.js CHANGED
@@ -4371,6 +4371,12 @@ function isJsonString(str) {
4371
4371
  }
4372
4372
  return true;
4373
4373
  }
4374
+ exports.eRouterType = void 0;
4375
+ (function (eRouterType) {
4376
+ eRouterType[eRouterType["BrowserRouter"] = 0] = "BrowserRouter";
4377
+ eRouterType[eRouterType["HashRouter"] = 1] = "HashRouter";
4378
+ eRouterType[eRouterType["MemoryRouter"] = 2] = "MemoryRouter";
4379
+ })(exports.eRouterType || (exports.eRouterType = {}));
4374
4380
  class CarbonReact extends react.Component {
4375
4381
  static allInstances = new Map();
4376
4382
  context = react.createContext(this.state);
@@ -4445,6 +4451,18 @@ class CarbonReact extends react.Component {
4445
4451
  }
4446
4452
  }
4447
4453
  }
4454
+ reactRouterContext(children) {
4455
+ switch (this.props.routerType) {
4456
+ case exports.eRouterType.BrowserRouter:
4457
+ return jsxRuntime_1(reactRouterDom.BrowserRouter, { children: children });
4458
+ case exports.eRouterType.MemoryRouter:
4459
+ return jsxRuntime_1(reactRouterDom.MemoryRouter, { initialEntries: ['/'], children: children });
4460
+ case exports.eRouterType.HashRouter:
4461
+ return jsxRuntime_1(reactRouterDom.HashRouter, { children: children });
4462
+ default:
4463
+ throw new Error('Invalid routerType');
4464
+ }
4465
+ }
4448
4466
  render() {
4449
4467
  console.log('CarbonORM TSX RENDER');
4450
4468
  const colorHex = '#' + Math.random().toString(16).slice(-6);
@@ -4453,9 +4471,10 @@ class CarbonReact extends react.Component {
4453
4471
  if (this.state.backendThrowable.length > 0) {
4454
4472
  return jsxRuntime_2(jsxRuntime_3, { children: [nest, jsxRuntime_1(BackendThrowable, { instance: this })] });
4455
4473
  }
4474
+ this.context = react.createContext(this.state);
4456
4475
  const Context = this.context.Provider;
4457
- return jsxRuntime_2(jsxRuntime_3, { children: [jsxRuntime_1(GlobalHistory, {}), this.props.websocket &&
4458
- jsxRuntime_1(CarbonWebSocket, { ...(false !== this.props.websocket ? this.props.websocket : {}), instance: this }), jsxRuntime_1(Context, { value: this.state, children: this.props.children }), jsxRuntime_1(reactToastify.ToastContainer, {})] });
4476
+ return this.reactRouterContext(jsxRuntime_2(reactRouterDom.Routes, { children: [jsxRuntime_1(GlobalHistory, {}), this.props.websocket &&
4477
+ jsxRuntime_1(CarbonWebSocket, { ...(false !== this.props.websocket ? this.props.websocket : {}), instance: this }), jsxRuntime_1(Context, { value: this.state, children: this.props.children }), jsxRuntime_1(reactToastify.ToastContainer, {})] }));
4459
4478
  }
4460
4479
  }
4461
4480