@superblocksteam/library 2.0.0-next.82 → 2.0.0-next.84

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.
Files changed (21) hide show
  1. package/dist/{allPaths-B5wfHhgn.js → allPaths-D-Ojg0WC.js} +2 -2
  2. package/dist/{allPaths-B5wfHhgn.js.map → allPaths-D-Ojg0WC.js.map} +1 -1
  3. package/dist/{allPaths-U6g9lWOX.js → allPaths-D6w1KOhK.js} +2 -2
  4. package/dist/{allPaths-U6g9lWOX.js.map → allPaths-D6w1KOhK.js.map} +1 -1
  5. package/dist/{allPathsLoader-DiEGmK_4.js → allPathsLoader-CwmAO7vH.js} +3 -3
  6. package/dist/{allPathsLoader-DiEGmK_4.js.map → allPathsLoader-CwmAO7vH.js.map} +1 -1
  7. package/dist/{allPathsLoader-TOKPYUgj.js → allPathsLoader-DCdJ8f7M.js} +3 -3
  8. package/dist/{allPathsLoader-TOKPYUgj.js.map → allPathsLoader-DCdJ8f7M.js.map} +1 -1
  9. package/dist/{index-b-4mZYkh.js → index-Bl_0WPlq.js} +214 -320
  10. package/dist/{index-b-4mZYkh.js.map → index-Bl_0WPlq.js.map} +1 -1
  11. package/dist/index.js +2 -2
  12. package/dist/{splitPathsBySizeLoader-DQcJgU2J.js → splitPathsBySizeLoader-DJhelNAf.js} +2 -2
  13. package/dist/{splitPathsBySizeLoader-DQcJgU2J.js.map → splitPathsBySizeLoader-DJhelNAf.js.map} +1 -1
  14. package/dist/{splitPathsBySizeLoader-uT6kxtxf.js → splitPathsBySizeLoader-usZfSm2b.js} +2 -2
  15. package/dist/{splitPathsBySizeLoader-uT6kxtxf.js.map → splitPathsBySizeLoader-usZfSm2b.js.map} +1 -1
  16. package/dist-types/edit-mode/features/connection-manager.d.ts +1 -2
  17. package/dist-types/edit-mode/source-update-api.d.ts +3 -20
  18. package/dist-types/lib/internal-details/lib/features/api-utils.d.ts +0 -1
  19. package/dist-types/lib/user-facing/components/table/table-utilities.d.ts +16 -7
  20. package/dist-types/lib/user-facing/components/table/table-widget.d.ts +1 -1
  21. package/package.json +3 -3
@@ -2690,14 +2690,14 @@ function getLoaderFn$1(options) {
2690
2690
  if (!(loader === "all")) return [3, 3];
2691
2691
  return [4, import(
2692
2692
  /* webpackChunkName: "blueprint-icons-all-paths-loader" */
2693
- "./allPathsLoader-TOKPYUgj.js"
2693
+ "./allPathsLoader-DCdJ8f7M.js"
2694
2694
  )];
2695
2695
  case 2:
2696
2696
  return [2, _b2.sent().allPathsLoader];
2697
2697
  case 3:
2698
2698
  return [4, import(
2699
2699
  /* webpackChunkName: "blueprint-icons-split-paths-by-size-loader" */
2700
- "./splitPathsBySizeLoader-uT6kxtxf.js"
2700
+ "./splitPathsBySizeLoader-usZfSm2b.js"
2701
2701
  )];
2702
2702
  case 4:
2703
2703
  return [2, _b2.sent().splitPathsBySizeLoader];
@@ -45807,22 +45807,48 @@ class SocketErrorException extends Error {
45807
45807
  this.message = message2;
45808
45808
  }
45809
45809
  }
45810
+ const INTENTIONAL_CLOSE_CODE = 4001;
45810
45811
  class ISocket {
45811
- constructor(ws2, requestHandlers, globalMiddlewares, timeouts, logger) {
45812
+ constructor(ws2, requestHandlers, globalMiddlewares, options) {
45812
45813
  this.responseHandler = /* @__PURE__ */ new Map();
45814
+ this.isClosed = false;
45813
45815
  this.ws = ws2;
45814
45816
  this.requestHandlers = requestHandlers;
45815
45817
  this.globalMiddlewares = globalMiddlewares;
45816
45818
  this.nxtRequestId = 0;
45817
- this.logger = logger ?? { error: console.error };
45818
- this.timeouts = timeouts;
45819
+ this.logger = this.logger ?? {
45820
+ error: console.error,
45821
+ warn: console.warn,
45822
+ info: console.info
45823
+ };
45824
+ this.timeouts = options.timeouts;
45819
45825
  this.resetConnectionTimeout();
45820
- this.ws.addEventListener("message", async (event) => {
45821
- const eventData = JSON.parse(event.data.toString());
45822
- return this.handleMessage(eventData);
45826
+ this.ws.addEventListener("message", (event) => {
45827
+ try {
45828
+ const eventData = JSON.parse(event.data.toString());
45829
+ void this.handleMessage(eventData);
45830
+ } catch (error) {
45831
+ this.logger.error(`Error parsing message: ${error}`);
45832
+ }
45833
+ });
45834
+ this.ws.addEventListener("close", (event) => {
45835
+ this.isClosed = true;
45836
+ if (event.code !== INTENTIONAL_CLOSE_CODE) {
45837
+ this.responseHandler.forEach((handler, key2) => {
45838
+ clearTimeout(handler.timeout);
45839
+ this.logger.error(`Rejecting pending requestId ${key2} due to connection close`);
45840
+ handler.reject({ code: 8, message: "Connection closed" });
45841
+ });
45842
+ this.responseHandler.clear();
45843
+ }
45844
+ options.onClose(event);
45823
45845
  });
45824
45846
  }
45825
45847
  async handleMessage(message2) {
45848
+ if (this.isClosed) {
45849
+ this.logger.error("Connection closed, ignoring message");
45850
+ return;
45851
+ }
45826
45852
  this.resetConnectionTimeout();
45827
45853
  if (message2.request) {
45828
45854
  const parts = message2.request.method.split(".");
@@ -45902,6 +45928,9 @@ class ISocket {
45902
45928
  return handler(params, ctx, client2, next2);
45903
45929
  }
45904
45930
  request(method4, params, authorization) {
45931
+ if (this.isClosed) {
45932
+ return Promise.reject(new SocketErrorException(10, "Connection closed"));
45933
+ }
45905
45934
  return new Promise((resolve, reject) => {
45906
45935
  const requestId = ++this.nxtRequestId;
45907
45936
  this.responseHandler.set(requestId, {
@@ -45950,9 +45979,7 @@ class ISocket {
45950
45979
  }
45951
45980
  handleConnectionTimeout() {
45952
45981
  return () => {
45953
- var _a2;
45954
- this.logger.error(`Connection timed out after ${(_a2 = this.timeouts) == null ? void 0 : _a2.connectionTimeoutInSeconds} seconds`);
45955
- this.close();
45982
+ this.close("Connection timeout");
45956
45983
  };
45957
45984
  }
45958
45985
  resetNoResponseTimeout(requestId) {
@@ -45979,14 +46006,8 @@ class ISocket {
45979
46006
  reject({ code: 7, message: message2 });
45980
46007
  };
45981
46008
  }
45982
- close() {
45983
- clearTimeout(this.connectionTimeout);
45984
- this.responseHandler.forEach((handler, key2) => {
45985
- clearTimeout(handler.timeout);
45986
- this.logger.error(`Rejecting pending requestId ${key2} due to connection close`);
45987
- handler.reject({ code: 8, message: "Connection closed" });
45988
- });
45989
- this.ws.close();
46009
+ close(reason) {
46010
+ this.ws.close(INTENTIONAL_CLOSE_CODE, reason);
45990
46011
  }
45991
46012
  }
45992
46013
  const proxyTarget = Object.freeze(() => {
@@ -46014,7 +46035,7 @@ function createIsocketProxy(socket, path2) {
46014
46035
  }
46015
46036
  function createISocketClient(socket) {
46016
46037
  return {
46017
- close: () => socket.close(),
46038
+ close: (reason) => socket.close(reason),
46018
46039
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
46019
46040
  call: createIsocketProxy(socket, void 0)
46020
46041
  };
@@ -46950,8 +46971,8 @@ function setHttpStatusFromError(span, error) {
46950
46971
  span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
46951
46972
  }
46952
46973
  class TracedSocket extends ISocket {
46953
- constructor(ws2, requestHandlers, globalMiddlewares, tracer, timeouts, logger) {
46954
- super(ws2, requestHandlers, globalMiddlewares, timeouts, logger);
46974
+ constructor(ws2, requestHandlers, globalMiddlewares, tracer, options) {
46975
+ super(ws2, requestHandlers, globalMiddlewares, options);
46955
46976
  this.activeSpanByRequestId = /* @__PURE__ */ new Map();
46956
46977
  this.middlewareSpanByReqId = /* @__PURE__ */ new Map();
46957
46978
  this.tracer = tracer;
@@ -47039,13 +47060,13 @@ class TracedSocket extends ISocket {
47039
47060
  this.lastActiveSpan.addEvent(eventName, attributes2, /* @__PURE__ */ new Date());
47040
47061
  }
47041
47062
  }
47042
- close() {
47063
+ close(reason) {
47043
47064
  for (const span of this.activeSpanByRequestId.values()) {
47044
47065
  span.end();
47045
47066
  }
47046
47067
  this.activeSpanByRequestId = /* @__PURE__ */ new Map();
47047
47068
  this.lastActiveSpan = void 0;
47048
- super.close();
47069
+ super.close(reason);
47049
47070
  }
47050
47071
  }
47051
47072
  var ws$1 = null;
@@ -47060,20 +47081,25 @@ if (typeof WebSocket !== "undefined") {
47060
47081
  } else if (typeof self !== "undefined") {
47061
47082
  ws$1 = self.WebSocket || self.MozWebSocket;
47062
47083
  }
47063
- function connectWebSocket(wsUrl, protocol) {
47084
+ function connectWebSocket(wsUrl, protocol, timeout2 = 3e4) {
47064
47085
  return new Promise((resolve, reject) => {
47065
47086
  const ws2 = new ws$1(wsUrl, protocol);
47087
+ const timeoutId = setTimeout(() => {
47088
+ reject(new Error("Connection timeout"));
47089
+ }, timeout2);
47066
47090
  ws2.addEventListener("open", () => {
47091
+ clearTimeout(timeoutId);
47067
47092
  resolve(ws2);
47068
47093
  });
47069
47094
  ws2.addEventListener("error", (error) => {
47095
+ clearTimeout(timeoutId);
47070
47096
  reject(error);
47071
47097
  });
47072
47098
  });
47073
47099
  }
47074
47100
  class ISocketWithClientAuth extends TracedSocket {
47075
- constructor(ws2, authorization, requestHandlers, globalMiddlewares, tracer, timeouts) {
47076
- super(ws2, requestHandlers, globalMiddlewares, tracer, timeouts);
47101
+ constructor(ws2, authorization, requestHandlers, globalMiddlewares, tracer, options) {
47102
+ super(ws2, requestHandlers, globalMiddlewares, tracer, options);
47077
47103
  this.hasSentAuth = false;
47078
47104
  this.authorization = authorization;
47079
47105
  }
@@ -95526,14 +95552,15 @@ class ApiManager {
95526
95552
  var _a2, _b2, _c2;
95527
95553
  const api2 = this.apisByName[apiName];
95528
95554
  editorBridge.setApiStarted(apiName);
95555
+ if (!api2) {
95556
+ console.error(`Api ${apiName} not found`);
95557
+ throw new Error(`Api ${apiName} not found`);
95558
+ }
95529
95559
  const inputs = getApiDeps(
95530
95560
  this.rootStore.entityManager,
95531
95561
  scopeId,
95532
95562
  this.apiNameToDepCandidates[apiName] ?? []
95533
95563
  );
95534
- if (!api2) {
95535
- throw new Error(`Api ${apiName} not found`);
95536
- }
95537
95564
  const orchestratorUrl = `${this.baseUrl}v2/execute`;
95538
95565
  const events2 = [];
95539
95566
  await ((_a2 = this.rootStore.editStore) == null ? void 0 : _a2.operationManager.ensureFilesSynced());
@@ -98160,16 +98187,13 @@ observerBatching(unstable_batchedUpdates);
98160
98187
  class ConnectionManager {
98161
98188
  // The status of the connection to the remote dev server
98162
98189
  constructor() {
98163
- __publicField(this, "socketInitialized", false);
98164
- // Set once after the socket is first initialized, since we do not want to show any connection warnings until then
98165
- __publicField(this, "connectionStatus", "disconnected");
98190
+ __publicField(this, "connectionStatus", "pre-init");
98166
98191
  makeAutoObservable(this);
98167
98192
  registerStores({
98168
98193
  ConnectionManager: this
98169
98194
  });
98170
98195
  }
98171
98196
  initializeSocket() {
98172
- this.socketInitialized = true;
98173
98197
  this.connectionStatus = "connecting";
98174
98198
  }
98175
98199
  connect() {
@@ -98226,73 +98250,47 @@ const generateId = () => {
98226
98250
  class OperationAPI {
98227
98251
  constructor(serverUrl) {
98228
98252
  __publicField(this, "socket");
98229
- __publicField(this, "editorMoveComponent", async (payload) => {
98230
- var _a2;
98231
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.moveComponent(payload);
98232
- });
98233
- __publicField(this, "editorCreateComponent", async (payload) => {
98234
- var _a2;
98235
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.createComponent(payload);
98236
- });
98237
- __publicField(this, "editorDeleteComponents", async (payload) => {
98238
- var _a2;
98239
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.deleteComponents(payload);
98240
- });
98241
- __publicField(this, "editorSetProperty", async (payload) => {
98242
- var _a2;
98243
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.setProperty(payload);
98244
- });
98245
- __publicField(this, "editorSetProperties", async (payload) => {
98246
- var _a2;
98247
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.setProperties(payload);
98248
- });
98249
- __publicField(this, "editorDeleteProperties", async (payload) => {
98250
- var _a2;
98251
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.deleteProperties(payload);
98252
- });
98253
- __publicField(this, "editorBatchUpdate", async (payload) => {
98254
- var _a2;
98255
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.batchUpdate(payload);
98256
- });
98257
- __publicField(this, "apiUpdate", async (payload) => {
98258
- var _a2;
98259
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.apiUpdate(payload);
98260
- });
98261
- __publicField(this, "editorAddEntity", async (payload) => {
98262
- var _a2;
98263
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.addEntity(payload);
98264
- });
98265
- __publicField(this, "editorUpdateEntity", async (payload) => {
98266
- var _a2;
98267
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.updateEntity(payload);
98268
- });
98269
- __publicField(this, "editorDeleteEntity", async (payload) => {
98270
- var _a2;
98271
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.deleteEntity(payload);
98272
- });
98273
- __publicField(this, "editorRenameElement", async (payload) => {
98274
- var _a2;
98275
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.renameElement(payload);
98276
- });
98277
- __publicField(this, "editorUpdateTheme", async (payload) => {
98278
- var _a2;
98279
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.updateTheme(payload);
98280
- });
98253
+ __publicField(this, "retryAttempts", 0);
98281
98254
  __publicField(this, "ensureFilesSynced", async () => {
98282
- var _a2;
98283
- return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.ensureFilesSynced();
98255
+ if (!this.socket) {
98256
+ throw new Error("Failed to connect to socket");
98257
+ }
98258
+ try {
98259
+ await this.socket.call.editor.ensureFilesSynced();
98260
+ } catch (error) {
98261
+ console.error("Error ensuring files synced", error);
98262
+ }
98284
98263
  });
98285
98264
  this.serverUrl = serverUrl;
98286
98265
  }
98287
98266
  async connect(peerId, userId) {
98288
- const socket = await connectSocket(this.serverUrl, peerId, userId);
98267
+ const socket = await connectSocket(this.serverUrl, {
98268
+ peerId,
98269
+ userId,
98270
+ onClose: () => {
98271
+ var _a2;
98272
+ console.log("App<>Dev box Socket closed, retrying...");
98273
+ (_a2 = rootStore.editStore) == null ? void 0 : _a2.connectionManager.disconnect();
98274
+ if (this.retryAttempts < 3) {
98275
+ this.connect(peerId, userId);
98276
+ } else {
98277
+ this.socket = void 0;
98278
+ }
98279
+ this.retryAttempts++;
98280
+ }
98281
+ });
98282
+ this.retryAttempts = 0;
98289
98283
  this.socket = socket;
98290
98284
  }
98291
98285
  }
98292
98286
  const sourceUpdateApi = new OperationAPI(
98293
98287
  typeof window !== "undefined" ? window.location.origin : ""
98294
98288
  );
98295
- async function connectSocket(serverUrl, peerId, userId) {
98289
+ async function connectSocket(serverUrl, {
98290
+ peerId,
98291
+ userId,
98292
+ onClose: onClose2
98293
+ }) {
98296
98294
  var _a2, _b2, _c2;
98297
98295
  if (!serverUrl) {
98298
98296
  return void 0;
@@ -98302,15 +98300,9 @@ async function connectSocket(serverUrl, peerId, userId) {
98302
98300
  if (userId) {
98303
98301
  wsUrl.searchParams.set("userId", userId);
98304
98302
  }
98305
- const onClose2 = () => {
98306
- var _a3;
98307
- console.log("App<>Dev box Socket closed");
98308
- (_a3 = rootStore.editStore) == null ? void 0 : _a3.connectionManager.disconnect();
98309
- };
98303
+ (_a2 = rootStore.editStore) == null ? void 0 : _a2.connectionManager.initializeSocket();
98310
98304
  try {
98311
98305
  const ws2 = await connectWebSocket(wsUrl.toString());
98312
- (_a2 = rootStore.editStore) == null ? void 0 : _a2.connectionManager.initializeSocket();
98313
- ws2.onclose = onClose2;
98314
98306
  const isocket = new ISocketWithClientAuth(
98315
98307
  ws2,
98316
98308
  void 0,
@@ -98408,8 +98400,16 @@ async function connectSocket(serverUrl, peerId, userId) {
98408
98400
  [],
98409
98401
  trace$1.getTracer("superblocks-ui-framework"),
98410
98402
  {
98411
- connectionTimeoutInSeconds: 6 * 60,
98412
- noResponseTimeoutInSeconds: 5 * 60
98403
+ onClose: (event) => {
98404
+ var _a3;
98405
+ onClose2(event);
98406
+ console.log("App<>Dev box Socket closed");
98407
+ (_a3 = rootStore.editStore) == null ? void 0 : _a3.connectionManager.disconnect();
98408
+ },
98409
+ timeouts: {
98410
+ connectionTimeoutInSeconds: void 0,
98411
+ noResponseTimeoutInSeconds: 60
98412
+ }
98413
98413
  }
98414
98414
  );
98415
98415
  const socket = createISocketClient(isocket);
@@ -144456,14 +144456,14 @@ function getLoaderFn(options) {
144456
144456
  if (!(loader === "all")) return [3, 3];
144457
144457
  return [4, import(
144458
144458
  /* webpackChunkName: "blueprint-icons-all-paths-loader" */
144459
- "./allPathsLoader-DiEGmK_4.js"
144459
+ "./allPathsLoader-CwmAO7vH.js"
144460
144460
  )];
144461
144461
  case 2:
144462
144462
  return [2, _b2.sent().allPathsLoader];
144463
144463
  case 3:
144464
144464
  return [4, import(
144465
144465
  /* webpackChunkName: "blueprint-icons-split-paths-by-size-loader" */
144466
- "./splitPathsBySizeLoader-DQcJgU2J.js"
144466
+ "./splitPathsBySizeLoader-DJhelNAf.js"
144467
144467
  )];
144468
144468
  case 4:
144469
144469
  return [2, _b2.sent().splitPathsBySizeLoader];
@@ -154787,7 +154787,8 @@ const renderCell = ({
154787
154787
  );
154788
154788
  }
154789
154789
  if (typeof value === "boolean") {
154790
- const ButtonIcon = value ? RadioButtonControlIcons["check"] : RadioButtonControlIcons[cellProps.booleanStyleFalse || "empty"];
154790
+ const falseStyle = typeof cellProps.booleanStyleFalse === "string" ? cellProps.booleanStyleFalse.toLowerCase() : "empty";
154791
+ const ButtonIcon = value ? RadioButtonControlIcons["check"] : RadioButtonControlIcons[falseStyle] ?? RadioButtonControlIcons["empty"];
154791
154792
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
154792
154793
  CellWrapper,
154793
154794
  {
@@ -154900,46 +154901,56 @@ const renderCell = ({
154900
154901
  }
154901
154902
  }
154902
154903
  };
154903
- const renderActions = (props, isHidden2, cellProperties, compactMode, theme) => {
154904
- if (!props.columnActions)
154905
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
154906
- CellWrapper,
154904
+ const TableButton = (props) => {
154905
+ const [loading, setLoading] = useState(false);
154906
+ const onComplete = () => {
154907
+ setLoading(false);
154908
+ };
154909
+ const [wrapperStyle, buttonStyle] = useMemo$2(() => {
154910
+ const mode = getCompactMode(props.compactMode);
154911
+ const rowHeight = TABLE_SIZES[mode].ROW_HEIGHT;
154912
+ const buttonHeight = `${Math.min(30, rowHeight - 8)}px`;
154913
+ const wrapperStyle2 = {
154914
+ height: buttonHeight,
154915
+ margin: "0 5px 0 0",
154916
+ overflow: "hidden"
154917
+ };
154918
+ return [
154919
+ wrapperStyle2,
154907
154920
  {
154908
- cellProperties,
154909
- isHidden: isHidden2,
154910
- compactMode
154921
+ height: buttonHeight,
154922
+ fontWeight: 400
154911
154923
  }
154912
- );
154913
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
154914
- CellWrapper,
154924
+ ];
154925
+ }, [props.compactMode]);
154926
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-test": `action-button`, style: wrapperStyle, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
154927
+ Button$3,
154915
154928
  {
154916
- cellProperties,
154917
- isHidden: isHidden2,
154918
- compactMode,
154919
- children: props.columnActions.map((action2, index2) => {
154920
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
154921
- TableAction,
154922
- {
154923
- action: action2,
154924
- rowIndex: props.rowIndex,
154925
- isSelected: props.isSelected,
154926
- isDisabled: props.isDisabled,
154927
- backgroundColor: props.backgroundColor,
154928
- buttonVariant: props.buttonVariant,
154929
- cellIcon: props.cellIcon,
154930
- cellIconPosition: props.cellIconPosition,
154931
- buttonLabelColor: props.buttonLabelColor,
154932
- onCommandClick: props.onCommandClick,
154933
- handleRowSelect: props.handleRowSelect,
154934
- compactMode: props.compactMode,
154935
- theme,
154936
- border: props.buttonBorder
154937
- },
154938
- index2
154939
- );
154940
- })
154929
+ theme: props.theme,
154930
+ textColor: props.buttonLabelColor,
154931
+ buttonStyle: props.buttonVariant,
154932
+ disabled: props.isDisabled,
154933
+ isLoading: loading,
154934
+ backgroundColor: props.backgroundColor,
154935
+ text: props.buttonLabel,
154936
+ border: props.buttonBorder,
154937
+ style: buttonStyle,
154938
+ useDynamicContrast: props.buttonVariant === "primary",
154939
+ icon: props.cellIcon ? /* @__PURE__ */ jsxRuntimeExports.jsx(DynamicSVG, { iconName: props.cellIcon, disablePointerEvents: true }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}),
154940
+ iconPosition: props.cellIconPosition,
154941
+ onClick: (e3) => {
154942
+ e3.stopPropagation();
154943
+ if (props.isDisabled) return;
154944
+ if (!props.isSelected) {
154945
+ props.handleRowSelect(props.rowIndex);
154946
+ }
154947
+ if (!loading) {
154948
+ setLoading(true);
154949
+ props.onClick(onComplete);
154950
+ }
154951
+ }
154941
154952
  }
154942
- );
154953
+ ) });
154943
154954
  };
154944
154955
  const renderLink = (props) => {
154945
154956
  var _a2;
@@ -155006,57 +155017,6 @@ const renderLink = (props) => {
155006
155017
  }
155007
155018
  );
155008
155019
  };
155009
- const TableAction = (props) => {
155010
- const [loading, setLoading] = useState(false);
155011
- const onComplete = () => {
155012
- setLoading(false);
155013
- };
155014
- const [wrapperStyle, buttonStyle] = useMemo$2(() => {
155015
- const mode = getCompactMode(props.compactMode);
155016
- const rowHeight = TABLE_SIZES[mode].ROW_HEIGHT;
155017
- const buttonHeight = `${Math.min(30, rowHeight - 8)}px`;
155018
- const wrapperStyle2 = {
155019
- height: buttonHeight,
155020
- margin: "0 5px 0 0",
155021
- overflow: "hidden"
155022
- };
155023
- return [
155024
- wrapperStyle2,
155025
- {
155026
- height: buttonHeight,
155027
- fontWeight: 400
155028
- }
155029
- ];
155030
- }, [props.compactMode]);
155031
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-test": `action-button`, style: wrapperStyle, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
155032
- Button$3,
155033
- {
155034
- theme: props.theme,
155035
- textColor: props.buttonLabelColor,
155036
- buttonStyle: props.buttonVariant,
155037
- disabled: props.isDisabled,
155038
- isLoading: loading,
155039
- backgroundColor: props.backgroundColor,
155040
- text: props.action.label,
155041
- border: props.border,
155042
- style: buttonStyle,
155043
- useDynamicContrast: props.buttonVariant === "primary",
155044
- icon: props.cellIcon ? /* @__PURE__ */ jsxRuntimeExports.jsx(DynamicSVG, { iconName: props.cellIcon, disablePointerEvents: true }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}),
155045
- iconPosition: props.cellIconPosition,
155046
- onClick: (e3) => {
155047
- e3.stopPropagation();
155048
- if (props.isDisabled) return;
155049
- if (!props.isSelected) {
155050
- props.handleRowSelect(props.rowIndex);
155051
- }
155052
- if (!loading) {
155053
- setLoading(true);
155054
- props.onCommandClick(onComplete);
155055
- }
155056
- }
155057
- }
155058
- ) });
155059
- };
155060
155020
  const renderEmptyRow = (columns, page, prepareRow, index2, columnSizeMap, resizingColumnIdRef) => {
155061
155021
  const canvasScaleFactor = 1;
155062
155022
  if (page.length) {
@@ -155222,16 +155182,6 @@ function getDefaultComputedValue(accessor, widgetName, isDerived) {
155222
155182
  accessor
155223
155183
  )} })}}`;
155224
155184
  }
155225
- function getTableStyles(props) {
155226
- return {
155227
- textColor: props.textColor,
155228
- textSize: props.textSize,
155229
- fontStyle: props.fontStyle,
155230
- cellBackground: props.cellBackground,
155231
- verticalAlign: props.verticalAlign,
155232
- horizontalAlign: props.horizontalAlign
155233
- };
155234
- }
155235
155185
  const getColumnWidthStyle = ({
155236
155186
  column: column2,
155237
155187
  columnSizeMap,
@@ -155312,11 +155262,9 @@ function collapseTableData(data2, largestRow) {
155312
155262
  );
155313
155263
  return filledData.filter((row) => row.length > 0).map((row) => row.filter((_22, colIdx) => !emptyColumns[colIdx]));
155314
155264
  }
155315
- function createTableColumns(props) {
155316
- const { columns = {}, tableData = [] } = props;
155265
+ function createTableColumns(columns = {}, tableData = [], tableStyles, widgetName) {
155317
155266
  const previousColumnIds = Object.keys(columns);
155318
155267
  const tableColumns = {};
155319
- const tableStyles = getTableStyles(props);
155320
155268
  const columnKeys = getAllTableColumnKeys(
155321
155269
  tableData,
155322
155270
  // if there is no table data, fallback to the previous column ids
@@ -155325,11 +155273,7 @@ function createTableColumns(props) {
155325
155273
  let index2 = 0;
155326
155274
  for (index2 = 0; index2 < columnKeys.length; index2++) {
155327
155275
  const i3 = columnKeys[index2];
155328
- const columnProperties = getDefaultColumnProperties(
155329
- i3,
155330
- index2,
155331
- props.widgetName
155332
- );
155276
+ const columnProperties = getDefaultColumnProperties(i3, index2, widgetName);
155333
155277
  tableColumns[columnProperties.id] = {
155334
155278
  ...columnProperties,
155335
155279
  ...tableStyles,
@@ -155345,7 +155289,7 @@ function createTableColumns(props) {
155345
155289
  const defaultProperties = getDefaultColumnProperties(
155346
155290
  derivedColumnKey,
155347
155291
  index2,
155348
- props.widgetName,
155292
+ widgetName,
155349
155293
  true
155350
155294
  );
155351
155295
  tableColumns[derivedColumnKey] = {
@@ -155463,7 +155407,19 @@ function getFilteredTableData(props) {
155463
155407
  $originalIndex: index2
155464
155408
  }));
155465
155409
  if (props.columns && lodashExports.isPlainObject(props.columns)) {
155466
- const columns = createTableColumns(props);
155410
+ const columns = createTableColumns(
155411
+ props.columns,
155412
+ props.tableData,
155413
+ {
155414
+ textColor: props.textColor,
155415
+ textSize: props.textSize,
155416
+ fontStyle: props.fontStyle,
155417
+ cellBackground: props.cellBackground,
155418
+ verticalAlign: props.verticalAlign,
155419
+ horizontalAlign: props.horizontalAlign
155420
+ },
155421
+ props.name ?? ""
155422
+ );
155467
155423
  const columnIds = Object.keys(columns ?? {});
155468
155424
  columnIds.forEach((columnId) => {
155469
155425
  const column2 = columns == null ? void 0 : columns[columnId];
@@ -155481,7 +155437,7 @@ function getFilteredTableData(props) {
155481
155437
  computedValues = column2.computedValue;
155482
155438
  }
155483
155439
  }
155484
- if (computedValues.length === 0 && column2.isDerived) {
155440
+ if (computedValues && computedValues.length === 0 && column2.isDerived) {
155485
155441
  computedValues = Array(derivedTableData.length).fill(
155486
155442
  column2.computedValue ?? ""
155487
155443
  );
@@ -155836,7 +155792,19 @@ const propertiesDefinition$9 = {
155836
155792
  // TODO(mark): this should be part of the composite prop config
155837
155793
  },
155838
155794
  propertyValue() {
155839
- return createTableColumns(this);
155795
+ return createTableColumns(
155796
+ this.columns,
155797
+ this.tableData,
155798
+ {
155799
+ textColor: this.textColor,
155800
+ textSize: this.textSize,
155801
+ fontStyle: this.fontStyle,
155802
+ cellBackground: this.cellBackground,
155803
+ verticalAlign: this.verticalAlign,
155804
+ horizontalAlign: this.horizontalAlign
155805
+ },
155806
+ this.name ?? ""
155807
+ );
155840
155808
  }
155841
155809
  })
155842
155810
  }),
@@ -170114,6 +170082,15 @@ const _TableWidget = class _TableWidget extends React__default.Component {
170114
170082
  });
170115
170083
  __publicField(this, "previousColumnsString", "");
170116
170084
  __publicField(this, "previousColumns", []);
170085
+ __publicField(this, "handleTableButtonClick", (columnId, onComplete) => {
170086
+ var _a2;
170087
+ const columnProperties = (_a2 = this.props.columns) == null ? void 0 : _a2[columnId];
170088
+ if ((columnProperties == null ? void 0 : columnProperties.onClick) && typeof columnProperties.onClick === "function") {
170089
+ columnProperties.onClick(this.getRowContext()).then(onComplete);
170090
+ } else {
170091
+ onComplete();
170092
+ }
170093
+ });
170117
170094
  __publicField(this, "getEmptyRow", () => {
170118
170095
  const columnKeys = getAllTableColumnKeys(this.props.tableData);
170119
170096
  const selectedRow = {};
@@ -170906,9 +170883,6 @@ const _TableWidget = class _TableWidget extends React__default.Component {
170906
170883
  componentDidMount() {
170907
170884
  this.addEventListeners();
170908
170885
  }
170909
- componentDidUpdate() {
170910
- this.addEventListeners();
170911
- }
170912
170886
  addEventListeners() {
170913
170887
  if (!this.tableElement) {
170914
170888
  this.tableElement = document.querySelector(
@@ -170924,18 +170898,9 @@ const _TableWidget = class _TableWidget extends React__default.Component {
170924
170898
  }
170925
170899
  getReactTableColumns() {
170926
170900
  const columnsArray = [];
170927
- const {
170928
- sortedColumn,
170929
- columnOrder,
170930
- columnSizeMap,
170931
- columns = {},
170932
- columnFreezes
170933
- } = this.props;
170901
+ const { sortedColumn, columnOrder, columnSizeMap, columns, columnFreezes } = this.props;
170902
+ let allColumns = columns;
170934
170903
  const tableProps = this.props;
170935
- let allColumns = Object.assign(
170936
- {},
170937
- createTableColumns(this.props) || columns
170938
- );
170939
170904
  const sortColumn = sortedColumn == null ? void 0 : sortedColumn.column;
170940
170905
  const sortOrder = sortedColumn == null ? void 0 : sortedColumn.asc;
170941
170906
  allColumns = reorderColumns(allColumns, columnOrder ?? [], columnFreezes);
@@ -171179,12 +171144,8 @@ const _TableWidget = class _TableWidget extends React__default.Component {
171179
171144
  rowIndex: currentRowIndex,
171180
171145
  isSelected: !!props.row.isSelected,
171181
171146
  isDisabled: cellProperties.isDisabled,
171182
- onCommandClick: (onComplete) => {
171183
- if (columnProperties.onClick && typeof columnProperties.onClick === "function") {
171184
- columnProperties.onClick(this.getRowContext()).then(onComplete);
171185
- } else {
171186
- onComplete();
171187
- }
171147
+ onClick: (onComplete) => {
171148
+ this.handleTableButtonClick(columnProperties.id, onComplete);
171188
171149
  },
171189
171150
  handleRowSelect: this.handleRowSelect,
171190
171151
  backgroundColor: cellProperties.buttonBackgroundColor,
@@ -171197,21 +171158,12 @@ const _TableWidget = class _TableWidget extends React__default.Component {
171197
171158
  ),
171198
171159
  cellIconPosition: cellProperties.cellIconPosition ?? "left",
171199
171160
  compactMode: this.props.compactMode,
171200
- columnActions: [
171201
- {
171202
- id: columnProperties.id,
171203
- label: cellProperties.buttonLabel ?? "Action",
171204
- actions: columnProperties.onClick ?? lodashExports.noop
171205
- }
171206
- ]
171161
+ id: columnProperties.id,
171162
+ buttonLabel: cellProperties.buttonLabel ?? "Action",
171163
+ isHidden: isHidden2,
171164
+ theme: this.props.theme
171207
171165
  };
171208
- return renderActions(
171209
- buttonProps,
171210
- isHidden2,
171211
- cellProperties,
171212
- this.props.compactMode,
171213
- this.props.theme
171214
- );
171166
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(TableButton, { ...buttonProps });
171215
171167
  } else if (columnProperties.columnType === "link") {
171216
171168
  return renderLink({
171217
171169
  cellProperties,
@@ -171611,27 +171563,6 @@ const SbTable = registerSbComponent(
171611
171563
  },
171612
171564
  [update]
171613
171565
  );
171614
- const transformedColumns = useMemo$2(() => {
171615
- const transformedColumns2 = {};
171616
- const columns = createTableColumns(props) ?? {};
171617
- for (const [key2, column2] of Object.entries(columns)) {
171618
- transformedColumns2[key2] = Object.fromEntries(
171619
- Object.entries(column2).map(([key22, value]) => {
171620
- if (typeof value === "function") {
171621
- return [
171622
- key22,
171623
- async (...args) => {
171624
- await (value == null ? void 0 : value(...args));
171625
- }
171626
- ];
171627
- }
171628
- return [key22, value];
171629
- })
171630
- );
171631
- transformedColumns2[key2].id = key2;
171632
- }
171633
- return transformedColumns2;
171634
- }, [props]);
171635
171566
  const passthroughProps = usePassthroughProps(props);
171636
171567
  const disableNudge = useCallback(
171637
171568
  (disable) => {
@@ -171670,6 +171601,19 @@ const SbTable = registerSbComponent(
171670
171601
  },
171671
171602
  [features.dragAndDrop]
171672
171603
  );
171604
+ const columns = createTableColumns(
171605
+ props.columns,
171606
+ props.tableData,
171607
+ {
171608
+ textColor: props.textColor,
171609
+ textSize: props.textSize,
171610
+ fontStyle: props.fontStyle,
171611
+ cellBackground: props.cellBackground,
171612
+ verticalAlign: props.verticalAlign,
171613
+ horizontalAlign: props.horizontalAlign
171614
+ },
171615
+ props.name ?? ""
171616
+ );
171673
171617
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ...passthroughProps, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
171674
171618
  TableWidget,
171675
171619
  {
@@ -171680,7 +171624,7 @@ const SbTable = registerSbComponent(
171680
171624
  searchPlaceholder: props.searchPlaceholder ?? "",
171681
171625
  searchText: props.searchText ?? "",
171682
171626
  paginationType: props.paginationType,
171683
- columns: transformedColumns,
171627
+ columns: columns ?? EMPTY_OBJ,
171684
171628
  filters: props.filters ?? EMPTY_OBJ,
171685
171629
  header: props.header ?? "",
171686
171630
  tableData: props.tableData ?? EMPTY_ARRAY,
@@ -177481,54 +177425,7 @@ function listenForUrlChange() {
177481
177425
  observer2.observe(bodyList, config2);
177482
177426
  return observer2;
177483
177427
  }
177484
- const ConnectionHandlerWrapper = observer(function ConnectionHandlerWrapper2(props) {
177485
- const [isRestarting, setIsRestarting] = useState(false);
177486
- const handleMouseMove = useCallback(async () => {
177487
- if (isRestarting) {
177488
- return;
177489
- }
177490
- setIsRestarting(true);
177491
- if (props.peerId) {
177492
- console.log("App<>Dev box Socket reconnecting");
177493
- await sourceUpdateApi.connect(props.peerId, props.userId);
177494
- setIsRestarting(false);
177495
- }
177496
- }, [props.peerId, props.userId, isRestarting]);
177497
- const showSpinner = editStore.connectionManager.socketInitialized && editStore.connectionManager.connectionStatus !== "connected";
177498
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
177499
- showSpinner && /* @__PURE__ */ jsxRuntimeExports.jsxs(
177500
- "div",
177501
- {
177502
- onMouseMove: handleMouseMove,
177503
- style: {
177504
- opacity: isRestarting ? 0.8 : 0,
177505
- width: "100%",
177506
- height: "100%",
177507
- backgroundColor: "black",
177508
- position: "absolute",
177509
- top: 0,
177510
- left: 0,
177511
- display: "flex",
177512
- justifyContent: "center",
177513
- alignItems: "center",
177514
- color: "white",
177515
- fontSize: "24px",
177516
- fontWeight: "bold",
177517
- zIndex: 1e3,
177518
- flexDirection: "column"
177519
- },
177520
- children: [
177521
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Reconnecting..." }),
177522
- /* @__PURE__ */ jsxRuntimeExports.jsx(Spinner$1, {})
177523
- ]
177524
- }
177525
- ),
177526
- props.children
177527
- ] });
177528
- });
177529
177428
  const IframeConnected = observer(function IframeConnected2(props) {
177530
- const [peerId, setPeerId] = useState();
177531
- const [userId, setUserId] = useState();
177532
177429
  useEffect(() => {
177533
177430
  if (!isEmbeddedBySuperblocksFirstParty()) {
177534
177431
  return;
@@ -177539,9 +177436,6 @@ const IframeConnected = observer(function IframeConnected2(props) {
177539
177436
  editorBridge.connected();
177540
177437
  rootStore.setEditStore(editStore);
177541
177438
  await sourceUpdateApi.connect(data2.payload.peerId, data2.payload.userId);
177542
- console.log("App<>Dev box Socket connected");
177543
- setPeerId(data2.payload.peerId);
177544
- setUserId(data2.payload.userId);
177545
177439
  editorBridge.updatePropertiesPanels(
177546
177440
  editStore.propertiesPanelManager.getNonDynamicPropertiesPanels()
177547
177441
  );
@@ -177571,10 +177465,10 @@ const IframeConnected = observer(function IframeConnected2(props) {
177571
177465
  }, []);
177572
177466
  const isPossiblyEditor = useMemo$2(isEmbeddedBySuperblocksFirstParty, []);
177573
177467
  if (isPossiblyEditor && editStore.isInitialized && typeof window !== "undefined") {
177574
- return /* @__PURE__ */ jsxRuntimeExports.jsx(ConnectionHandlerWrapper, { peerId, userId, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(DnDProvider, { children: [
177468
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(DnDProvider, { children: [
177575
177469
  /* @__PURE__ */ jsxRuntimeExports.jsx(NewComponentsDragLayer, {}),
177576
177470
  props.children
177577
- ] }) });
177471
+ ] });
177578
177472
  }
177579
177473
  return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: props.children });
177580
177474
  });
@@ -191011,4 +190905,4 @@ export {
191011
190905
  copyToClipboard as y,
191012
190906
  navigateTo as z
191013
190907
  };
191014
- //# sourceMappingURL=index-b-4mZYkh.js.map
190908
+ //# sourceMappingURL=index-Bl_0WPlq.js.map