@carbonorm/carbonreact 3.5.3 → 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.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
@@ -4138,8 +4157,9 @@ function initiateWebsocket({ TABLES = undefined, WsLiveUpdates = undefined, url
4138
4157
  ...REQUEST
4139
4158
  };
4140
4159
  });
4141
- console.log('updatedElements', updatedElements);
4142
- WsLiveUpdates[TABLE_NAME_SHORT][METHOD]({}, updatedElements);
4160
+ updatedElements.forEach((row) => {
4161
+ WsLiveUpdates[TABLE_NAME_SHORT][METHOD]({}, row);
4162
+ });
4143
4163
  }
4144
4164
  });
4145
4165
  };
@@ -4236,8 +4256,10 @@ function isJsonString(str) {
4236
4256
  }
4237
4257
  return true;
4238
4258
  }
4259
+ // Create a context
4239
4260
  const CarbonReact = class extends react.Component {
4240
4261
  static instance;
4262
+ context = react.createContext(this.state);
4241
4263
  static persistentState = undefined;
4242
4264
  static lastLocation = window.location.pathname;
4243
4265
  // @link https://github.com/welldone-software/why-did-you-render
@@ -4245,6 +4267,7 @@ const CarbonReact = class extends react.Component {
4245
4267
  static whyDidYouRender = true;
4246
4268
  constructor(props) {
4247
4269
  super(props);
4270
+ console.log('CarbonORM TSX CONSTRUCTOR');
4248
4271
  if (CarbonReact.persistentState !== undefined && this.props.shouldStatePersist !== false) {
4249
4272
  this.state = CarbonReact.persistentState;
4250
4273
  }
@@ -4272,8 +4295,8 @@ const CarbonReact = class extends react.Component {
4272
4295
  else {
4273
4296
  CarbonReact.persistentState = nextState;
4274
4297
  }
4275
- changed(this.constructor.name + ' (DigApi)', 'props', this.props, nextProps);
4276
- 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);
4277
4300
  return true;
4278
4301
  }
4279
4302
  componentDidUpdate(_prevProps, _prevState, _snapshot) {
@@ -4294,7 +4317,8 @@ const CarbonReact = class extends react.Component {
4294
4317
  if (this.state.backendThrowable.length > 0) {
4295
4318
  return jsxRuntime_2(jsxRuntime_3, { children: [nest, jsxRuntime_1(BackendThrowable, {})] });
4296
4319
  }
4297
- 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, {}), jsxRuntime_1(CarbonWebSocket, {}), jsxRuntime_1(Context, { value: this.state, children: this.props.children }), jsxRuntime_1(reactToastify.ToastContainer, {})] });
4298
4322
  }
4299
4323
  };
4300
4324