@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.esm.js CHANGED
@@ -25328,9 +25328,15 @@ var LayoutGridContainer = /*#__PURE__*/memo(function (_ref3) {
25328
25328
  }
25329
25329
  var rendered = renderComponent(cellComponent.component, cellComponent.id, cellComponent, null);
25330
25330
  if (onWidgetPopout && cellComponent.component) {
25331
+ // Prefer uuid over id — uuid is `${dashboardId}-${component}-${id}`
25332
+ // which is globally unique, while id is only unique within a
25333
+ // single page/container. Passing bare id causes WidgetPopoutStage
25334
+ // to find-first-match across layout/pages and render the wrong
25335
+ // widget when two pages share the same numeric id.
25336
+ var popoutKey = cellComponent.uuid || cellComponent.id;
25331
25337
  return /*#__PURE__*/jsx(PopoutOverlay, {
25332
25338
  onPopout: function onPopout() {
25333
- return onWidgetPopout(cellComponent.id);
25339
+ return onWidgetPopout(popoutKey);
25334
25340
  },
25335
25341
  children: rendered
25336
25342
  });
@@ -53705,10 +53711,29 @@ var WidgetPopoutInner = function WidgetPopoutInner(_ref2) {
53705
53711
  }
53706
53712
  setWorkspace(target);
53707
53713
 
53708
- // Find the widget across all layout locations
53709
- var widget = target.layout.find(function (item) {
53710
- return item.id === widgetId;
53711
- });
53714
+ // `widgetId` carries the layout item's uuid. That uuid is
53715
+ // `${dashboardId}-${component}-${id}`
53716
+ // but the dashboardId prefix can differ between the main
53717
+ // window's LayoutModel instance and the one rebuilt here,
53718
+ // so we match on several shapes to be robust:
53719
+ //
53720
+ // 1. full uuid match (preferred)
53721
+ // 2. trailing `component-id` suffix (strip dashboardId)
53722
+ // 3. bare numeric id (legacy callers that pre-date uuid)
53723
+ //
53724
+ // Extract the suffix once: everything after the first "-"
53725
+ // when the string starts with a dashboard-looking prefix.
53726
+ var tail = String(widgetId).split("-").slice(-2).join("-");
53727
+ var matches = function matches(item) {
53728
+ if (item.uuid === widgetId) return true;
53729
+ if (item.uuid && item.uuid.endsWith("-" + tail)) return true;
53730
+ var itemTail = "".concat(item.component, "-").concat(item.id);
53731
+ if (itemTail === widgetId) return true;
53732
+ if (itemTail === tail) return true;
53733
+ if (item.id === widgetId) return true;
53734
+ return false;
53735
+ };
53736
+ var widget = target.layout.find(matches);
53712
53737
  if (!widget && target.pages && Array.isArray(target.pages)) {
53713
53738
  var _iterator = _createForOfIteratorHelper$2(target.pages),
53714
53739
  _step;
@@ -53716,9 +53741,7 @@ var WidgetPopoutInner = function WidgetPopoutInner(_ref2) {
53716
53741
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
53717
53742
  var page = _step.value;
53718
53743
  if (page.layout && Array.isArray(page.layout)) {
53719
- widget = page.layout.find(function (item) {
53720
- return item.id === widgetId;
53721
- });
53744
+ widget = page.layout.find(matches);
53722
53745
  if (widget) break;
53723
53746
  }
53724
53747
  }
@@ -53729,11 +53752,41 @@ var WidgetPopoutInner = function WidgetPopoutInner(_ref2) {
53729
53752
  }
53730
53753
  }
53731
53754
  if (!widget && target.sidebarLayout && Array.isArray(target.sidebarLayout)) {
53732
- widget = target.sidebarLayout.find(function (item) {
53733
- return item.id === widgetId;
53734
- });
53755
+ widget = target.sidebarLayout.find(matches);
53735
53756
  }
53736
53757
  if (!widget) {
53758
+ // Diagnostic dump — helps pinpoint id/uuid mismatches when
53759
+ // the user reports a "Widget not available" popout.
53760
+ var dump = {
53761
+ searchedFor: widgetId,
53762
+ suffix: tail,
53763
+ mainLayout: (target.layout || []).map(function (i) {
53764
+ return {
53765
+ id: i.id,
53766
+ uuid: i.uuid,
53767
+ component: i.component
53768
+ };
53769
+ }),
53770
+ pages: (target.pages || []).map(function (p) {
53771
+ return {
53772
+ pageId: p.id,
53773
+ items: (p.layout || []).map(function (i) {
53774
+ return {
53775
+ id: i.id,
53776
+ uuid: i.uuid,
53777
+ component: i.component
53778
+ };
53779
+ })
53780
+ };
53781
+ }),
53782
+ sidebar: (target.sidebarLayout || []).map(function (i) {
53783
+ return {
53784
+ id: i.id,
53785
+ uuid: i.uuid,
53786
+ component: i.component
53787
+ };
53788
+ })
53789
+ };
53737
53790
  setError("Widget not found in workspace");
53738
53791
  return;
53739
53792
  }