@carbonorm/carbonreact 4.0.2 → 4.0.4

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/index.esm.js CHANGED
@@ -4359,11 +4359,16 @@ function isJsonString(str) {
4359
4359
  }
4360
4360
  class CarbonReact extends Component {
4361
4361
  static persistentStateMap = new Map();
4362
+ // Context is for functional components to access the state of this class efficiently
4362
4363
  context = createContext(this.state);
4363
- // Private static member
4364
- // we actually implement this in the constructor todo - test this
4365
- static instance;
4366
4364
  target;
4365
+ static _instance;
4366
+ static get instance() {
4367
+ return this;
4368
+ }
4369
+ static set instance(instance) {
4370
+ this._instance = instance;
4371
+ }
4367
4372
  updateRestfulObjectArrays = (rest) => updateRestfulObjectArrays({
4368
4373
  instance: this,
4369
4374
  ...rest
@@ -4383,7 +4388,7 @@ class CarbonReact extends Component {
4383
4388
  // this is the magic that allows each class that's extends this to have a static instance - a singleton pattern
4384
4389
  // new.target is a meta-property introduced in ES6 that references the constructor that was directly invoked with the new keyword.
4385
4390
  Object.assign(new.target, {
4386
- instance: this
4391
+ _instance: this
4387
4392
  });
4388
4393
  if (this.props.instanceId && CarbonReact.persistentStateMap.has(this.props.instanceId)) {
4389
4394
  this.state = CarbonReact.persistentStateMap.get(this.props.instanceId);
@@ -4427,11 +4432,11 @@ class CarbonReact extends Component {
4427
4432
  console.log('%c color (' + colorHex + ')', 'color: ' + colorHex);
4428
4433
  const nest = jsxRuntime_1(Nest, { position: 'fixed', backgroundColor: '', color: hexToRgb(colorHex), count: 100 });
4429
4434
  if (this.state.backendThrowable.length > 0) {
4430
- return jsxRuntime_2(jsxRuntime_3, { children: [nest, jsxRuntime_1(BackendThrowable, { instance: CarbonReact.instance })] });
4435
+ return jsxRuntime_2(jsxRuntime_3, { children: [nest, jsxRuntime_1(BackendThrowable, { instance: this })] });
4431
4436
  }
4432
4437
  const Context = this.context.Provider;
4433
4438
  return jsxRuntime_2(jsxRuntime_3, { children: [jsxRuntime_1(GlobalHistory, {}), this.props.websocket &&
4434
- jsxRuntime_1(CarbonWebSocket, { ...(true === this.props.websocket ? {} : this.props.websocket), instance: CarbonReact.instance }), jsxRuntime_1(Context, { value: this.state, children: this.props.children }), jsxRuntime_1(ToastContainer, {})] });
4439
+ 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, {})] });
4435
4440
  }
4436
4441
  }
4437
4442