@carbonorm/carbonreact 4.0.15 → 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.
- package/dist/CarbonReact.d.ts +7 -2
- package/dist/index.cjs.js +23 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +25 -16
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/CarbonReact.tsx +39 -29
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import react, { useRef, useState, useEffect, Component, createContext, lazy } from 'react';
|
|
2
|
-
import { useNavigate } from 'react-router-dom';
|
|
2
|
+
import { useNavigate, HashRouter, MemoryRouter, BrowserRouter, Routes } from 'react-router-dom';
|
|
3
3
|
import { toast, ToastContainer } from 'react-toastify';
|
|
4
4
|
import OutsideClickHandler from 'react-outside-click-handler';
|
|
5
5
|
import { toastOptions, timeout, axiosInstance, isVerbose, checkAllRequestsComplete } from '@carbonorm/carbonnode';
|
|
@@ -4369,17 +4369,22 @@ function isJsonString(str) {
|
|
|
4369
4369
|
}
|
|
4370
4370
|
return true;
|
|
4371
4371
|
}
|
|
4372
|
+
var eRouterType;
|
|
4373
|
+
(function (eRouterType) {
|
|
4374
|
+
eRouterType[eRouterType["BrowserRouter"] = 0] = "BrowserRouter";
|
|
4375
|
+
eRouterType[eRouterType["HashRouter"] = 1] = "HashRouter";
|
|
4376
|
+
eRouterType[eRouterType["MemoryRouter"] = 2] = "MemoryRouter";
|
|
4377
|
+
})(eRouterType || (eRouterType = {}));
|
|
4372
4378
|
class CarbonReact extends Component {
|
|
4373
4379
|
static allInstances = new Map();
|
|
4374
|
-
static activeInstances = new Map();
|
|
4375
4380
|
context = createContext(this.state);
|
|
4376
4381
|
target;
|
|
4377
4382
|
static _instance;
|
|
4378
4383
|
static getInstance(instanceId) {
|
|
4379
4384
|
const identifier = this.generateIdentifier(instanceId);
|
|
4380
4385
|
if (undefined !== instanceId) {
|
|
4381
|
-
if (CarbonReact.
|
|
4382
|
-
return CarbonReact.
|
|
4386
|
+
if (CarbonReact.allInstances.has(identifier)) {
|
|
4387
|
+
return CarbonReact.allInstances.get(identifier);
|
|
4383
4388
|
}
|
|
4384
4389
|
throw new Error(`No instance has been instantiated yet for class (${this.name}) with instanceId (${instanceId})`);
|
|
4385
4390
|
}
|
|
@@ -4407,11 +4412,6 @@ class CarbonReact extends Component {
|
|
|
4407
4412
|
constructor(props) {
|
|
4408
4413
|
super(props);
|
|
4409
4414
|
const identifier = this.generateIdentifier();
|
|
4410
|
-
if (CarbonReact.activeInstances.has(identifier)) {
|
|
4411
|
-
throw new Error(`${identifier} instance already exists in the DOM! Each instance should have a unique instanceId.`);
|
|
4412
|
-
}
|
|
4413
|
-
// Register the new instance
|
|
4414
|
-
CarbonReact.activeInstances.set(identifier, this);
|
|
4415
4415
|
if (props.persistentState && CarbonReact.allInstances.has(identifier)) {
|
|
4416
4416
|
// Reuse the state from the existing instance
|
|
4417
4417
|
this.state = CarbonReact.allInstances.get(identifier).state;
|
|
@@ -4434,10 +4434,6 @@ class CarbonReact extends Component {
|
|
|
4434
4434
|
const className = this.constructor.name;
|
|
4435
4435
|
return this.props.instanceId ? `${className}-${this.props.instanceId}` : className;
|
|
4436
4436
|
}
|
|
4437
|
-
componentWillUnmount() {
|
|
4438
|
-
const identifier = this.generateIdentifier();
|
|
4439
|
-
CarbonReact.activeInstances.delete(identifier);
|
|
4440
|
-
}
|
|
4441
4437
|
shouldComponentUpdate(nextProps, nextState, _nextContext) {
|
|
4442
4438
|
changed(this.constructor.name + ' (C6Api)', 'props', this.props, nextProps);
|
|
4443
4439
|
changed(this.constructor.name + ' (C6Api)', 'state', this.state, nextState);
|
|
@@ -4453,6 +4449,18 @@ class CarbonReact extends Component {
|
|
|
4453
4449
|
}
|
|
4454
4450
|
}
|
|
4455
4451
|
}
|
|
4452
|
+
reactRouterContext(children) {
|
|
4453
|
+
switch (this.props.routerType) {
|
|
4454
|
+
case eRouterType.BrowserRouter:
|
|
4455
|
+
return jsxRuntime_1(BrowserRouter, { children: children });
|
|
4456
|
+
case eRouterType.MemoryRouter:
|
|
4457
|
+
return jsxRuntime_1(MemoryRouter, { initialEntries: ['/'], children: children });
|
|
4458
|
+
case eRouterType.HashRouter:
|
|
4459
|
+
return jsxRuntime_1(HashRouter, { children: children });
|
|
4460
|
+
default:
|
|
4461
|
+
throw new Error('Invalid routerType');
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4456
4464
|
render() {
|
|
4457
4465
|
console.log('CarbonORM TSX RENDER');
|
|
4458
4466
|
const colorHex = '#' + Math.random().toString(16).slice(-6);
|
|
@@ -4461,9 +4469,10 @@ class CarbonReact extends Component {
|
|
|
4461
4469
|
if (this.state.backendThrowable.length > 0) {
|
|
4462
4470
|
return jsxRuntime_2(jsxRuntime_3, { children: [nest, jsxRuntime_1(BackendThrowable, { instance: this })] });
|
|
4463
4471
|
}
|
|
4472
|
+
this.context = createContext(this.state);
|
|
4464
4473
|
const Context = this.context.Provider;
|
|
4465
|
-
return jsxRuntime_2(
|
|
4466
|
-
jsxRuntime_1(CarbonWebSocket, { ...(false !== this.props.websocket ? this.props.websocket : {}), instance: this }), jsxRuntime_1(Context, { value: this.state, children: this.props.children }), jsxRuntime_1(ToastContainer, {})] });
|
|
4474
|
+
return this.reactRouterContext(jsxRuntime_2(Routes, { children: [jsxRuntime_1(GlobalHistory, {}), this.props.websocket &&
|
|
4475
|
+
jsxRuntime_1(CarbonWebSocket, { ...(false !== this.props.websocket ? this.props.websocket : {}), instance: this }), jsxRuntime_1(Context, { value: this.state, children: this.props.children }), jsxRuntime_1(ToastContainer, {})] }));
|
|
4467
4476
|
}
|
|
4468
4477
|
}
|
|
4469
4478
|
|
|
@@ -4759,5 +4768,5 @@ function useWindowDimensions() {
|
|
|
4759
4768
|
return windowDimensions;
|
|
4760
4769
|
}
|
|
4761
4770
|
|
|
4762
|
-
export { AccessDenied, Alert, BackendThrowable, C6, COLUMNS, CarbonReact, CarbonWebSocket, ErrorHttpCode, GlobalHistory, Loading, Nest, PageNotFound, Popup, TABLES, addAlert, addValidSQL$1 as addValidSQL, carbons, changed, comments, deleteRestfulObjectArrays, documentation, eUpdateInsertMethod, feature_group_references, features, getRootStyleValue, getStatefulObjectWithWhere, getStyles, globalNavigate, group_references, groups, hexToRgb, history_logs, initialCarbonReactState, initialRequiredCarbonORMState, initialRestfulObjectsState, initiateWebsocket, isEdgeBrowser, isJsonString, isProduction, location_references, locations, parseMultipleJson, photos, range, reports, ScrollIntoViewDirective as scrollIntoView, setCookies, setUrl, setupTests, toDataURL, updateRestfulObjectArrays, uploadImage, uploadImageChange, useEffectOnce, user_followers, user_groups, user_messages, user_sessions, user_tasks, users, ValidSQL as validSQL, watchInputElementChangeEvent, useWindowDimensions as windowDimensions, wp_commentmeta, wp_comments, wp_links, wp_options, wp_postmeta, wp_posts, wp_term_relationships, wp_term_taxonomy, wp_termmeta, wp_terms, wp_usermeta, wp_users };
|
|
4771
|
+
export { AccessDenied, Alert, BackendThrowable, C6, COLUMNS, CarbonReact, CarbonWebSocket, ErrorHttpCode, GlobalHistory, Loading, Nest, PageNotFound, Popup, TABLES, addAlert, addValidSQL$1 as addValidSQL, carbons, changed, comments, deleteRestfulObjectArrays, documentation, eRouterType, eUpdateInsertMethod, feature_group_references, features, getRootStyleValue, getStatefulObjectWithWhere, getStyles, globalNavigate, group_references, groups, hexToRgb, history_logs, initialCarbonReactState, initialRequiredCarbonORMState, initialRestfulObjectsState, initiateWebsocket, isEdgeBrowser, isJsonString, isProduction, location_references, locations, parseMultipleJson, photos, range, reports, ScrollIntoViewDirective as scrollIntoView, setCookies, setUrl, setupTests, toDataURL, updateRestfulObjectArrays, uploadImage, uploadImageChange, useEffectOnce, user_followers, user_groups, user_messages, user_sessions, user_tasks, users, ValidSQL as validSQL, watchInputElementChangeEvent, useWindowDimensions as windowDimensions, wp_commentmeta, wp_comments, wp_links, wp_options, wp_postmeta, wp_posts, wp_term_relationships, wp_term_taxonomy, wp_termmeta, wp_terms, wp_usermeta, wp_users };
|
|
4763
4772
|
//# sourceMappingURL=index.esm.js.map
|