@trops/dash-core 0.1.352 → 0.1.354

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.js CHANGED
@@ -25346,9 +25346,15 @@ var LayoutGridContainer = /*#__PURE__*/React.memo(function (_ref3) {
25346
25346
  }
25347
25347
  var rendered = renderComponent(cellComponent.component, cellComponent.id, cellComponent, null);
25348
25348
  if (onWidgetPopout && cellComponent.component) {
25349
+ // Prefer uuid over id — uuid is `${dashboardId}-${component}-${id}`
25350
+ // which is globally unique, while id is only unique within a
25351
+ // single page/container. Passing bare id causes WidgetPopoutStage
25352
+ // to find-first-match across layout/pages and render the wrong
25353
+ // widget when two pages share the same numeric id.
25354
+ var popoutKey = cellComponent.uuid || cellComponent.id;
25349
25355
  return /*#__PURE__*/jsxRuntime.jsx(PopoutOverlay, {
25350
25356
  onPopout: function onPopout() {
25351
- return onWidgetPopout(cellComponent.id);
25357
+ return onWidgetPopout(popoutKey);
25352
25358
  },
25353
25359
  children: rendered
25354
25360
  });
@@ -53723,10 +53729,29 @@ var WidgetPopoutInner = function WidgetPopoutInner(_ref2) {
53723
53729
  }
53724
53730
  setWorkspace(target);
53725
53731
 
53726
- // Find the widget across all layout locations
53727
- var widget = target.layout.find(function (item) {
53728
- return item.id === widgetId;
53729
- });
53732
+ // `widgetId` carries the layout item's uuid. That uuid is
53733
+ // `${dashboardId}-${component}-${id}`
53734
+ // but the dashboardId prefix can differ between the main
53735
+ // window's LayoutModel instance and the one rebuilt here,
53736
+ // so we match on several shapes to be robust:
53737
+ //
53738
+ // 1. full uuid match (preferred)
53739
+ // 2. trailing `component-id` suffix (strip dashboardId)
53740
+ // 3. bare numeric id (legacy callers that pre-date uuid)
53741
+ //
53742
+ // Extract the suffix once: everything after the first "-"
53743
+ // when the string starts with a dashboard-looking prefix.
53744
+ var tail = String(widgetId).split("-").slice(-2).join("-");
53745
+ var matches = function matches(item) {
53746
+ if (item.uuid === widgetId) return true;
53747
+ if (item.uuid && item.uuid.endsWith("-" + tail)) return true;
53748
+ var itemTail = "".concat(item.component, "-").concat(item.id);
53749
+ if (itemTail === widgetId) return true;
53750
+ if (itemTail === tail) return true;
53751
+ if (item.id === widgetId) return true;
53752
+ return false;
53753
+ };
53754
+ var widget = target.layout.find(matches);
53730
53755
  if (!widget && target.pages && Array.isArray(target.pages)) {
53731
53756
  var _iterator = _createForOfIteratorHelper$2(target.pages),
53732
53757
  _step;
@@ -53734,9 +53759,7 @@ var WidgetPopoutInner = function WidgetPopoutInner(_ref2) {
53734
53759
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
53735
53760
  var page = _step.value;
53736
53761
  if (page.layout && Array.isArray(page.layout)) {
53737
- widget = page.layout.find(function (item) {
53738
- return item.id === widgetId;
53739
- });
53762
+ widget = page.layout.find(matches);
53740
53763
  if (widget) break;
53741
53764
  }
53742
53765
  }
@@ -53747,11 +53770,41 @@ var WidgetPopoutInner = function WidgetPopoutInner(_ref2) {
53747
53770
  }
53748
53771
  }
53749
53772
  if (!widget && target.sidebarLayout && Array.isArray(target.sidebarLayout)) {
53750
- widget = target.sidebarLayout.find(function (item) {
53751
- return item.id === widgetId;
53752
- });
53773
+ widget = target.sidebarLayout.find(matches);
53753
53774
  }
53754
53775
  if (!widget) {
53776
+ // Diagnostic dump — helps pinpoint id/uuid mismatches when
53777
+ // the user reports a "Widget not available" popout.
53778
+ var dump = {
53779
+ searchedFor: widgetId,
53780
+ suffix: tail,
53781
+ mainLayout: (target.layout || []).map(function (i) {
53782
+ return {
53783
+ id: i.id,
53784
+ uuid: i.uuid,
53785
+ component: i.component
53786
+ };
53787
+ }),
53788
+ pages: (target.pages || []).map(function (p) {
53789
+ return {
53790
+ pageId: p.id,
53791
+ items: (p.layout || []).map(function (i) {
53792
+ return {
53793
+ id: i.id,
53794
+ uuid: i.uuid,
53795
+ component: i.component
53796
+ };
53797
+ })
53798
+ };
53799
+ }),
53800
+ sidebar: (target.sidebarLayout || []).map(function (i) {
53801
+ return {
53802
+ id: i.id,
53803
+ uuid: i.uuid,
53804
+ component: i.component
53805
+ };
53806
+ })
53807
+ };
53755
53808
  setError("Widget not found in workspace");
53756
53809
  return;
53757
53810
  }