@carbonorm/carbonreact 3.5.4 → 3.6.1

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.cjs.js CHANGED
@@ -1223,6 +1223,7 @@ function validateFragmentProps(fragment) {
1223
1223
  }
1224
1224
  }
1225
1225
 
1226
+ var didWarnAboutKeySpread = {};
1226
1227
  function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1227
1228
  {
1228
1229
  var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
@@ -1293,6 +1294,24 @@ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1293
1294
  }
1294
1295
  }
1295
1296
 
1297
+ {
1298
+ if (hasOwnProperty.call(props, 'key')) {
1299
+ var componentName = getComponentNameFromType(type);
1300
+ var keys = Object.keys(props).filter(function (k) {
1301
+ return k !== 'key';
1302
+ });
1303
+ var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';
1304
+
1305
+ if (!didWarnAboutKeySpread[componentName + beforeExample]) {
1306
+ var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';
1307
+
1308
+ 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);
1309
+
1310
+ didWarnAboutKeySpread[componentName + beforeExample] = true;
1311
+ }
1312
+ }
1313
+ }
1314
+
1296
1315
  if (type === REACT_FRAGMENT_TYPE) {
1297
1316
  validateFragmentProps(element);
1298
1317
  } else {
@@ -4045,7 +4064,7 @@ const useEffectOnce = (effect) => {
4045
4064
  * @function connect
4046
4065
  * This function establishes a connection with the websocket and also ensures constant reconnection if connection closes
4047
4066
  **/
4048
- function initiateWebsocket({ TABLES = undefined, WsLiveUpdates = undefined, url = 'ws://localhost:8080/ws', timeoutSeconds = 250, heartbeatSeconds = 60 } = {}) {
4067
+ function initiateWebsocket({ TABLES = undefined, WsLiveUpdates = undefined, url = 'ws' + (window.location.protocol === 'https:' ? 's' : '') + '://' + window.location.host + '/carbonorm/websocket', timeoutSeconds = 250, heartbeatSeconds = 60 } = {}) {
4049
4068
  const { websocket } = CarbonReact.instance.state;
4050
4069
  if (!("WebSocket" in window)) {
4051
4070
  // todo - store that this has been shown in the state
@@ -4237,8 +4256,10 @@ function isJsonString(str) {
4237
4256
  }
4238
4257
  return true;
4239
4258
  }
4259
+ // Create a context
4240
4260
  const CarbonReact = class extends react.Component {
4241
4261
  static instance;
4262
+ context = react.createContext(this.state);
4242
4263
  static persistentState = undefined;
4243
4264
  static lastLocation = window.location.pathname;
4244
4265
  // @link https://github.com/welldone-software/why-did-you-render
@@ -4246,6 +4267,7 @@ const CarbonReact = class extends react.Component {
4246
4267
  static whyDidYouRender = true;
4247
4268
  constructor(props) {
4248
4269
  super(props);
4270
+ console.log('CarbonORM TSX CONSTRUCTOR');
4249
4271
  if (CarbonReact.persistentState !== undefined && this.props.shouldStatePersist !== false) {
4250
4272
  this.state = CarbonReact.persistentState;
4251
4273
  }
@@ -4273,8 +4295,8 @@ const CarbonReact = class extends react.Component {
4273
4295
  else {
4274
4296
  CarbonReact.persistentState = nextState;
4275
4297
  }
4276
- changed(this.constructor.name + ' (DigApi)', 'props', this.props, nextProps);
4277
- changed(this.constructor.name + ' (DigApi)', 'state', this.state, nextState);
4298
+ changed(this.constructor.name + ' (C6Api)', 'props', this.props, nextProps);
4299
+ changed(this.constructor.name + ' (C6Api)', 'state', this.state, nextState);
4278
4300
  return true;
4279
4301
  }
4280
4302
  componentDidUpdate(_prevProps, _prevState, _snapshot) {
@@ -4295,7 +4317,9 @@ const CarbonReact = class extends react.Component {
4295
4317
  if (this.state.backendThrowable.length > 0) {
4296
4318
  return jsxRuntime_2(jsxRuntime_3, { children: [nest, jsxRuntime_1(BackendThrowable, {})] });
4297
4319
  }
4298
- return jsxRuntime_2(jsxRuntime_3, { children: [jsxRuntime_1(GlobalHistory, {}), jsxRuntime_1(CarbonWebSocket, {}), this.props.children, jsxRuntime_1(reactToastify.ToastContainer, {})] });
4320
+ const Context = this.context.Provider;
4321
+ return jsxRuntime_2(jsxRuntime_3, { children: [jsxRuntime_1(GlobalHistory, {}), this.props.websocket &&
4322
+ jsxRuntime_1(CarbonWebSocket, { ...(true === this.props.websocket ? {} : this.props.websocket) }), jsxRuntime_1(Context, { value: this.state, children: this.props.children }), jsxRuntime_1(reactToastify.ToastContainer, {})] });
4299
4323
  }
4300
4324
  };
4301
4325