@carbonorm/carbonreact 3.5.4 → 3.6.0

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
@@ -1,4 +1,4 @@
1
- import react, { useRef, useState, useEffect, Component, lazy } from 'react';
1
+ import react, { useRef, useState, useEffect, Component, createContext, lazy } from 'react';
2
2
  import { toastOptions, clearCache, timeout, axiosInstance, isVerbose, checkAllRequestsComplete } from '@carbonorm/carbonnode';
3
3
  import { useNavigate } from 'react-router-dom';
4
4
  import { toast, ToastContainer } from 'react-toastify';
@@ -1221,6 +1221,7 @@ function validateFragmentProps(fragment) {
1221
1221
  }
1222
1222
  }
1223
1223
 
1224
+ var didWarnAboutKeySpread = {};
1224
1225
  function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1225
1226
  {
1226
1227
  var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
@@ -1291,6 +1292,24 @@ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1291
1292
  }
1292
1293
  }
1293
1294
 
1295
+ {
1296
+ if (hasOwnProperty.call(props, 'key')) {
1297
+ var componentName = getComponentNameFromType(type);
1298
+ var keys = Object.keys(props).filter(function (k) {
1299
+ return k !== 'key';
1300
+ });
1301
+ var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';
1302
+
1303
+ if (!didWarnAboutKeySpread[componentName + beforeExample]) {
1304
+ var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';
1305
+
1306
+ error('A props object containing a "key" prop is being spread into JSX:\n' + ' let props = %s;\n' + ' <%s {...props} />\n' + 'React keys must be passed directly to JSX without using spread:\n' + ' let props = %s;\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
1307
+
1308
+ didWarnAboutKeySpread[componentName + beforeExample] = true;
1309
+ }
1310
+ }
1311
+ }
1312
+
1294
1313
  if (type === REACT_FRAGMENT_TYPE) {
1295
1314
  validateFragmentProps(element);
1296
1315
  } else {
@@ -4043,7 +4062,7 @@ const useEffectOnce = (effect) => {
4043
4062
  * @function connect
4044
4063
  * This function establishes a connection with the websocket and also ensures constant reconnection if connection closes
4045
4064
  **/
4046
- function initiateWebsocket({ TABLES = undefined, WsLiveUpdates = undefined, url = 'ws://localhost:8080/ws', timeoutSeconds = 250, heartbeatSeconds = 60 } = {}) {
4065
+ function initiateWebsocket({ TABLES = undefined, WsLiveUpdates = undefined, url = 'ws' + (window.location.protocol === 'https:' ? 's' : '') + '://' + window.location.host + '/carbonorm/websocket', timeoutSeconds = 250, heartbeatSeconds = 60 } = {}) {
4047
4066
  const { websocket } = CarbonReact.instance.state;
4048
4067
  if (!("WebSocket" in window)) {
4049
4068
  // todo - store that this has been shown in the state
@@ -4235,8 +4254,10 @@ function isJsonString(str) {
4235
4254
  }
4236
4255
  return true;
4237
4256
  }
4257
+ // Create a context
4238
4258
  const CarbonReact = class extends Component {
4239
4259
  static instance;
4260
+ context = createContext(this.state);
4240
4261
  static persistentState = undefined;
4241
4262
  static lastLocation = window.location.pathname;
4242
4263
  // @link https://github.com/welldone-software/why-did-you-render
@@ -4244,6 +4265,7 @@ const CarbonReact = class extends Component {
4244
4265
  static whyDidYouRender = true;
4245
4266
  constructor(props) {
4246
4267
  super(props);
4268
+ console.log('CarbonORM TSX CONSTRUCTOR');
4247
4269
  if (CarbonReact.persistentState !== undefined && this.props.shouldStatePersist !== false) {
4248
4270
  this.state = CarbonReact.persistentState;
4249
4271
  }
@@ -4271,8 +4293,8 @@ const CarbonReact = class extends Component {
4271
4293
  else {
4272
4294
  CarbonReact.persistentState = nextState;
4273
4295
  }
4274
- changed(this.constructor.name + ' (DigApi)', 'props', this.props, nextProps);
4275
- changed(this.constructor.name + ' (DigApi)', 'state', this.state, nextState);
4296
+ changed(this.constructor.name + ' (C6Api)', 'props', this.props, nextProps);
4297
+ changed(this.constructor.name + ' (C6Api)', 'state', this.state, nextState);
4276
4298
  return true;
4277
4299
  }
4278
4300
  componentDidUpdate(_prevProps, _prevState, _snapshot) {
@@ -4293,7 +4315,8 @@ const CarbonReact = class extends Component {
4293
4315
  if (this.state.backendThrowable.length > 0) {
4294
4316
  return jsxRuntime_2(jsxRuntime_3, { children: [nest, jsxRuntime_1(BackendThrowable, {})] });
4295
4317
  }
4296
- return jsxRuntime_2(jsxRuntime_3, { children: [jsxRuntime_1(GlobalHistory, {}), jsxRuntime_1(CarbonWebSocket, {}), this.props.children, jsxRuntime_1(ToastContainer, {})] });
4318
+ const Context = this.context.Provider;
4319
+ return jsxRuntime_2(jsxRuntime_3, { children: [jsxRuntime_1(GlobalHistory, {}), jsxRuntime_1(CarbonWebSocket, {}), jsxRuntime_1(Context, { value: this.state, children: this.props.children }), jsxRuntime_1(ToastContainer, {})] });
4297
4320
  }
4298
4321
  };
4299
4322