@trops/dash-core 0.1.329 → 0.1.330

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
@@ -600,7 +600,7 @@ var DashboardApi = {
600
600
  */
601
601
  var DashboardActionsApi = {
602
602
  /**
603
- * Switch the active page in the current dashboard.
603
+ * Switch the active page by its internal ID.
604
604
  * @param {string} pageId - The ID of the page to switch to
605
605
  */
606
606
  switchPage: function switchPage(pageId) {
@@ -609,6 +609,17 @@ var DashboardActionsApi = {
609
609
  pageId: pageId
610
610
  }
611
611
  }));
612
+ },
613
+ /**
614
+ * Switch the active page by its display name.
615
+ * @param {string} pageName - The display name of the page (e.g. "Opp Detail")
616
+ */
617
+ switchPageByName: function switchPageByName(pageName) {
618
+ window.dispatchEvent(new CustomEvent("dash:switch-page", {
619
+ detail: {
620
+ pageName: pageName
621
+ }
622
+ }));
612
623
  }
613
624
  };
614
625
 
@@ -51501,14 +51512,23 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
51501
51512
  useEffect(function () {
51502
51513
  function onSwitchPage(e) {
51503
51514
  var _ref4 = e.detail || {},
51504
- pageId = _ref4.pageId;
51505
- if (pageId) setActivePageId(pageId);
51515
+ pageId = _ref4.pageId,
51516
+ pageName = _ref4.pageName;
51517
+ if (pageId) {
51518
+ setActivePageId(pageId);
51519
+ } else if (pageName) {
51520
+ var pages = (workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.pages) || [];
51521
+ var match = pages.find(function (p) {
51522
+ return p.name.toLowerCase() === pageName.toLowerCase();
51523
+ });
51524
+ if (match) setActivePageId(match.id);
51525
+ }
51506
51526
  }
51507
51527
  window.addEventListener("dash:switch-page", onSwitchPage);
51508
51528
  return function () {
51509
51529
  return window.removeEventListener("dash:switch-page", onSwitchPage);
51510
51530
  };
51511
- }, []);
51531
+ }, [workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.pages]);
51512
51532
  var workspacePages = (workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.pages) || [];
51513
51533
 
51514
51534
  // Memoize sorted pages so page object references stay stable across re-renders