@trops/dash-core 0.1.329 → 0.1.331
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 +356 -69
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +356 -69
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -595,12 +595,15 @@ var DashboardApi = {
|
|
|
595
595
|
* Widgets can call these methods directly (not via events) to
|
|
596
596
|
* control the dashboard they are rendered in.
|
|
597
597
|
*
|
|
598
|
-
*
|
|
599
|
-
* stays decoupled from the React component tree.
|
|
598
|
+
* Write actions internally dispatch CustomEvents on `window` so the
|
|
599
|
+
* API stays decoupled from the React component tree. Read methods
|
|
600
|
+
* return values from `window.__dashState`, which DashboardStage
|
|
601
|
+
* keeps up-to-date as workspace/page state changes.
|
|
600
602
|
*/
|
|
601
603
|
var DashboardActionsApi = {
|
|
604
|
+
// ─── Page Navigation ──────────────────────────────────────────────
|
|
602
605
|
/**
|
|
603
|
-
* Switch the active page
|
|
606
|
+
* Switch the active page by its internal ID.
|
|
604
607
|
* @param {string} pageId - The ID of the page to switch to
|
|
605
608
|
*/
|
|
606
609
|
switchPage: function switchPage(pageId) {
|
|
@@ -609,6 +612,130 @@ var DashboardActionsApi = {
|
|
|
609
612
|
pageId: pageId
|
|
610
613
|
}
|
|
611
614
|
}));
|
|
615
|
+
},
|
|
616
|
+
/**
|
|
617
|
+
* Switch the active page by its display name.
|
|
618
|
+
* @param {string} pageName - The display name of the page (e.g. "Opp Detail")
|
|
619
|
+
*/
|
|
620
|
+
switchPageByName: function switchPageByName(pageName) {
|
|
621
|
+
window.dispatchEvent(new CustomEvent("dash:switch-page", {
|
|
622
|
+
detail: {
|
|
623
|
+
pageName: pageName
|
|
624
|
+
}
|
|
625
|
+
}));
|
|
626
|
+
},
|
|
627
|
+
/**
|
|
628
|
+
* Navigate to the previous page in history (browser-style back).
|
|
629
|
+
*/
|
|
630
|
+
goBack: function goBack() {
|
|
631
|
+
window.dispatchEvent(new CustomEvent("dash:go-back"));
|
|
632
|
+
},
|
|
633
|
+
// ─── Workspace Nav Sidebar (far-left DashSidebar) ─────────────────
|
|
634
|
+
/**
|
|
635
|
+
* Collapse the workspace nav sidebar.
|
|
636
|
+
*/
|
|
637
|
+
closeSidebar: function closeSidebar() {
|
|
638
|
+
window.dispatchEvent(new CustomEvent("dash:set-nav-sidebar", {
|
|
639
|
+
detail: {
|
|
640
|
+
collapsed: true
|
|
641
|
+
}
|
|
642
|
+
}));
|
|
643
|
+
},
|
|
644
|
+
/**
|
|
645
|
+
* Expand the workspace nav sidebar.
|
|
646
|
+
*/
|
|
647
|
+
openSidebar: function openSidebar() {
|
|
648
|
+
window.dispatchEvent(new CustomEvent("dash:set-nav-sidebar", {
|
|
649
|
+
detail: {
|
|
650
|
+
collapsed: false
|
|
651
|
+
}
|
|
652
|
+
}));
|
|
653
|
+
},
|
|
654
|
+
/**
|
|
655
|
+
* Toggle the workspace nav sidebar.
|
|
656
|
+
*/
|
|
657
|
+
toggleSidebar: function toggleSidebar() {
|
|
658
|
+
window.dispatchEvent(new CustomEvent("dash:toggle-nav-sidebar"));
|
|
659
|
+
},
|
|
660
|
+
// ─── Workspace (Dashboard) Navigation ─────────────────────────────
|
|
661
|
+
/**
|
|
662
|
+
* Open another dashboard in a tab by name.
|
|
663
|
+
* @param {string} name - The display name of the dashboard
|
|
664
|
+
*/
|
|
665
|
+
openDashboardByName: function openDashboardByName(name) {
|
|
666
|
+
window.dispatchEvent(new CustomEvent("dash:open-dashboard", {
|
|
667
|
+
detail: {
|
|
668
|
+
name: name
|
|
669
|
+
}
|
|
670
|
+
}));
|
|
671
|
+
},
|
|
672
|
+
/**
|
|
673
|
+
* Close a dashboard tab. Closes the active tab if no name is given.
|
|
674
|
+
* @param {string} [name] - Optional: name of the dashboard tab to close
|
|
675
|
+
*/
|
|
676
|
+
closeDashboard: function closeDashboard(name) {
|
|
677
|
+
window.dispatchEvent(new CustomEvent("dash:close-dashboard", {
|
|
678
|
+
detail: {
|
|
679
|
+
name: name
|
|
680
|
+
}
|
|
681
|
+
}));
|
|
682
|
+
},
|
|
683
|
+
// ─── Notifications (in-app toasts) ────────────────────────────────
|
|
684
|
+
/**
|
|
685
|
+
* Show an in-app toast notification.
|
|
686
|
+
* @param {string} message - The toast message
|
|
687
|
+
* @param {object} [options]
|
|
688
|
+
* @param {"success"|"error"|"info"|"warning"} [options.type="info"]
|
|
689
|
+
* @param {string} [options.title]
|
|
690
|
+
* @param {number} [options.duration=4000] - Auto-dismiss after ms
|
|
691
|
+
*/
|
|
692
|
+
notify: function notify(message) {
|
|
693
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
694
|
+
window.dispatchEvent(new CustomEvent("dash:notify", {
|
|
695
|
+
detail: {
|
|
696
|
+
message: message,
|
|
697
|
+
type: options.type || "info",
|
|
698
|
+
title: options.title,
|
|
699
|
+
duration: options.duration || 4000
|
|
700
|
+
}
|
|
701
|
+
}));
|
|
702
|
+
},
|
|
703
|
+
// ─── Read Methods (synchronous, from window.__dashState) ──────────
|
|
704
|
+
/**
|
|
705
|
+
* @returns {string|null} The ID of the active page
|
|
706
|
+
*/
|
|
707
|
+
getCurrentPageId: function getCurrentPageId() {
|
|
708
|
+
var _window$__dashState;
|
|
709
|
+
return ((_window$__dashState = window.__dashState) === null || _window$__dashState === void 0 ? void 0 : _window$__dashState.currentPageId) || null;
|
|
710
|
+
},
|
|
711
|
+
/**
|
|
712
|
+
* @returns {string|null} The display name of the active page
|
|
713
|
+
*/
|
|
714
|
+
getCurrentPageName: function getCurrentPageName() {
|
|
715
|
+
var _window$__dashState2;
|
|
716
|
+
return ((_window$__dashState2 = window.__dashState) === null || _window$__dashState2 === void 0 ? void 0 : _window$__dashState2.currentPageName) || null;
|
|
717
|
+
},
|
|
718
|
+
/**
|
|
719
|
+
* @returns {number|null} The ID of the active dashboard
|
|
720
|
+
*/
|
|
721
|
+
getCurrentDashboardId: function getCurrentDashboardId() {
|
|
722
|
+
var _window$__dashState3;
|
|
723
|
+
return ((_window$__dashState3 = window.__dashState) === null || _window$__dashState3 === void 0 ? void 0 : _window$__dashState3.currentDashboardId) || null;
|
|
724
|
+
},
|
|
725
|
+
/**
|
|
726
|
+
* @returns {string|null} The display name of the active dashboard
|
|
727
|
+
*/
|
|
728
|
+
getCurrentDashboardName: function getCurrentDashboardName() {
|
|
729
|
+
var _window$__dashState4;
|
|
730
|
+
return ((_window$__dashState4 = window.__dashState) === null || _window$__dashState4 === void 0 ? void 0 : _window$__dashState4.currentDashboardName) || null;
|
|
731
|
+
},
|
|
732
|
+
/**
|
|
733
|
+
* @returns {Array<{id: string, name: string, order: number}>}
|
|
734
|
+
* Pages in the current dashboard
|
|
735
|
+
*/
|
|
736
|
+
listPages: function listPages() {
|
|
737
|
+
var _window$__dashState5;
|
|
738
|
+
return ((_window$__dashState5 = window.__dashState) === null || _window$__dashState5 === void 0 ? void 0 : _window$__dashState5.pages) || [];
|
|
612
739
|
}
|
|
613
740
|
};
|
|
614
741
|
|
|
@@ -50984,22 +51111,28 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
50984
51111
|
widgetSidebarCollapsed = _useState0[0],
|
|
50985
51112
|
setWidgetSidebarCollapsed = _useState0[1];
|
|
50986
51113
|
|
|
50987
|
-
// ───
|
|
51114
|
+
// ─── In-app toasts (driven by DashboardActionsApi.notify) ────────
|
|
50988
51115
|
var _useState1 = useState([]),
|
|
50989
51116
|
_useState10 = _slicedToArray(_useState1, 2),
|
|
50990
|
-
|
|
50991
|
-
|
|
51117
|
+
toasts = _useState10[0],
|
|
51118
|
+
setToasts = _useState10[1];
|
|
51119
|
+
|
|
51120
|
+
// ─── Recents + Session ──────────────────────────────────────────
|
|
51121
|
+
var _useState11 = useState([]),
|
|
51122
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
51123
|
+
recentDashboards = _useState12[0],
|
|
51124
|
+
setRecentDashboards = _useState12[1];
|
|
50992
51125
|
var sessionRestored = useRef(false);
|
|
50993
51126
|
|
|
50994
51127
|
// ─── Registry Auth (for sidebar) ────────────────────────────────
|
|
50995
|
-
var
|
|
50996
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
50997
|
-
authStatus = _useState12[0],
|
|
50998
|
-
setAuthStatus = _useState12[1];
|
|
50999
|
-
var _useState13 = useState(null),
|
|
51128
|
+
var _useState13 = useState("loading"),
|
|
51000
51129
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
51001
|
-
|
|
51002
|
-
|
|
51130
|
+
authStatus = _useState14[0],
|
|
51131
|
+
setAuthStatus = _useState14[1];
|
|
51132
|
+
var _useState15 = useState(null),
|
|
51133
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
51134
|
+
authProfile = _useState16[0],
|
|
51135
|
+
setAuthProfile = _useState16[1];
|
|
51003
51136
|
|
|
51004
51137
|
// Derive workspaceSelected from active tab
|
|
51005
51138
|
var workspaceSelected = activeTabId ? (_openTabs$find$worksp = (_openTabs$find = openTabs.find(function (tab) {
|
|
@@ -51009,84 +51142,84 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51009
51142
|
/**
|
|
51010
51143
|
* @param {Boolean} previewMode this is a toggle telling the dash we are editing
|
|
51011
51144
|
*/
|
|
51012
|
-
var
|
|
51013
|
-
|
|
51014
|
-
previewMode =
|
|
51015
|
-
setPreviewMode =
|
|
51145
|
+
var _useState17 = useState(preview),
|
|
51146
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
51147
|
+
previewMode = _useState18[0],
|
|
51148
|
+
setPreviewMode = _useState18[1];
|
|
51016
51149
|
|
|
51017
51150
|
/**
|
|
51018
51151
|
* @param {String["layout", "workspace", "widget"]} editMode this is the actual mode we are in
|
|
51019
51152
|
*/
|
|
51020
|
-
var
|
|
51021
|
-
|
|
51022
|
-
editMode =
|
|
51153
|
+
var _useState19 = useState("all"),
|
|
51154
|
+
_useState20 = _slicedToArray(_useState19, 1),
|
|
51155
|
+
editMode = _useState20[0]; // for the time being use "all" as our "old" way
|
|
51023
51156
|
|
|
51024
51157
|
// Workspace Management (loading)
|
|
51025
|
-
var _useState19 = useState(false),
|
|
51026
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
51027
|
-
isLoadingWorkspaces = _useState20[0],
|
|
51028
|
-
setIsLoadingWorkspaces = _useState20[1];
|
|
51029
51158
|
var _useState21 = useState(false),
|
|
51030
51159
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
51031
|
-
|
|
51032
|
-
|
|
51033
|
-
var _useState23 = useState(
|
|
51160
|
+
isLoadingWorkspaces = _useState22[0],
|
|
51161
|
+
setIsLoadingWorkspaces = _useState22[1];
|
|
51162
|
+
var _useState23 = useState(false),
|
|
51034
51163
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
51035
|
-
|
|
51036
|
-
|
|
51164
|
+
isLoadingMenuItems = _useState24[0],
|
|
51165
|
+
setIsLoadingMenuItems = _useState24[1];
|
|
51037
51166
|
var _useState25 = useState([]),
|
|
51038
51167
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
51039
|
-
|
|
51040
|
-
|
|
51168
|
+
menuItems = _useState26[0],
|
|
51169
|
+
setMenuItems = _useState26[1];
|
|
51170
|
+
var _useState27 = useState([]),
|
|
51171
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
51172
|
+
workspaceConfig = _useState28[0],
|
|
51173
|
+
setWorkspaceConfig = _useState28[1];
|
|
51041
51174
|
|
|
51042
51175
|
// Modal state
|
|
51043
|
-
var _useState27 = useState(false),
|
|
51044
|
-
_useState28 = _slicedToArray(_useState27, 2),
|
|
51045
|
-
isThemeManagerOpen = _useState28[0],
|
|
51046
|
-
setIsThemeManagerOpen = _useState28[1];
|
|
51047
51176
|
var _useState29 = useState(false),
|
|
51048
51177
|
_useState30 = _slicedToArray(_useState29, 2),
|
|
51049
|
-
|
|
51050
|
-
|
|
51178
|
+
isThemeManagerOpen = _useState30[0],
|
|
51179
|
+
setIsThemeManagerOpen = _useState30[1];
|
|
51051
51180
|
var _useState31 = useState(false),
|
|
51052
51181
|
_useState32 = _slicedToArray(_useState31, 2),
|
|
51053
|
-
|
|
51054
|
-
|
|
51182
|
+
isDashboardLoaderOpen = _useState32[0],
|
|
51183
|
+
setIsDashboardLoaderOpen = _useState32[1];
|
|
51055
51184
|
var _useState33 = useState(false),
|
|
51056
51185
|
_useState34 = _slicedToArray(_useState33, 2),
|
|
51057
|
-
|
|
51058
|
-
|
|
51186
|
+
isLayoutPickerOpen = _useState34[0],
|
|
51187
|
+
setIsLayoutPickerOpen = _useState34[1];
|
|
51188
|
+
var _useState35 = useState(false),
|
|
51189
|
+
_useState36 = _slicedToArray(_useState35, 2),
|
|
51190
|
+
isWizardOpen = _useState36[0],
|
|
51191
|
+
setIsWizardOpen = _useState36[1];
|
|
51059
51192
|
|
|
51060
51193
|
// Missing widgets detection
|
|
51061
51194
|
var _useMissingWidgets = useMissingWidgets(workspaceSelected),
|
|
51062
51195
|
missingComponents = _useMissingWidgets.missingComponents,
|
|
51063
51196
|
hasMissing = _useMissingWidgets.hasMissing;
|
|
51064
|
-
var
|
|
51065
|
-
_useState36 = _slicedToArray(_useState35, 2),
|
|
51066
|
-
isMissingWidgetsModalOpen = _useState36[0],
|
|
51067
|
-
setIsMissingWidgetsModalOpen = _useState36[1];
|
|
51068
|
-
var _useState37 = useState(new Set()),
|
|
51197
|
+
var _useState37 = useState(false),
|
|
51069
51198
|
_useState38 = _slicedToArray(_useState37, 2),
|
|
51070
|
-
|
|
51071
|
-
|
|
51199
|
+
isMissingWidgetsModalOpen = _useState38[0],
|
|
51200
|
+
setIsMissingWidgetsModalOpen = _useState38[1];
|
|
51201
|
+
var _useState39 = useState(new Set()),
|
|
51202
|
+
_useState40 = _slicedToArray(_useState39, 2),
|
|
51203
|
+
dismissedMissingForWorkspace = _useState40[0],
|
|
51204
|
+
setDismissedMissingForWorkspace = _useState40[1];
|
|
51072
51205
|
|
|
51073
51206
|
// Unified App Settings Modal
|
|
51074
|
-
var
|
|
51075
|
-
_useState40 = _slicedToArray(_useState39, 2),
|
|
51076
|
-
isAppSettingsOpen = _useState40[0],
|
|
51077
|
-
setIsAppSettingsOpen = _useState40[1];
|
|
51078
|
-
var _useState41 = useState("dashboards"),
|
|
51207
|
+
var _useState41 = useState(false),
|
|
51079
51208
|
_useState42 = _slicedToArray(_useState41, 2),
|
|
51080
|
-
|
|
51081
|
-
|
|
51082
|
-
var _useState43 = useState(
|
|
51209
|
+
isAppSettingsOpen = _useState42[0],
|
|
51210
|
+
setIsAppSettingsOpen = _useState42[1];
|
|
51211
|
+
var _useState43 = useState("dashboards"),
|
|
51083
51212
|
_useState44 = _slicedToArray(_useState43, 2),
|
|
51084
|
-
|
|
51085
|
-
|
|
51086
|
-
var _useState45 = useState(
|
|
51213
|
+
appSettingsInitialSection = _useState44[0],
|
|
51214
|
+
setAppSettingsInitialSection = _useState44[1];
|
|
51215
|
+
var _useState45 = useState(null),
|
|
51087
51216
|
_useState46 = _slicedToArray(_useState45, 2),
|
|
51088
|
-
|
|
51089
|
-
|
|
51217
|
+
appSettingsInitialProvider = _useState46[0],
|
|
51218
|
+
setAppSettingsInitialProvider = _useState46[1];
|
|
51219
|
+
var _useState47 = useState(false),
|
|
51220
|
+
_useState48 = _slicedToArray(_useState47, 2),
|
|
51221
|
+
appSettingsCreateProvider = _useState48[0],
|
|
51222
|
+
setAppSettingsCreateProvider = _useState48[1];
|
|
51090
51223
|
function openAppSettings() {
|
|
51091
51224
|
var section = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "general";
|
|
51092
51225
|
var providerName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
@@ -51492,22 +51625,93 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51492
51625
|
}
|
|
51493
51626
|
|
|
51494
51627
|
// ─── Page State ──────────────────────────────────────────────────
|
|
51495
|
-
var
|
|
51496
|
-
|
|
51497
|
-
activePageId =
|
|
51498
|
-
setActivePageId =
|
|
51628
|
+
var _useState49 = useState(null),
|
|
51629
|
+
_useState50 = _slicedToArray(_useState49, 2),
|
|
51630
|
+
activePageId = _useState50[0],
|
|
51631
|
+
setActivePageId = _useState50[1];
|
|
51632
|
+
|
|
51633
|
+
// Page history stack for goBack() — pushes the previous page id
|
|
51634
|
+
// whenever a navigation happens through navigateToPage().
|
|
51635
|
+
var pageHistoryRef = useRef([]);
|
|
51636
|
+
|
|
51637
|
+
// Wrapper that records history before switching pages.
|
|
51638
|
+
// Pass recordHistory=false to switch without recording (e.g. for goBack).
|
|
51639
|
+
var navigateToPage = useCallback(function (pageId) {
|
|
51640
|
+
var recordHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
51641
|
+
if (!pageId) return;
|
|
51642
|
+
if (recordHistory) {
|
|
51643
|
+
var _workspaceSelected$pa, _workspaceSelected$pa2;
|
|
51644
|
+
var prevId = activePageId || (workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.activePageId) || ((_workspaceSelected$pa = workspaceSelected === null || workspaceSelected === void 0 || (_workspaceSelected$pa2 = workspaceSelected.pages) === null || _workspaceSelected$pa2 === void 0 || (_workspaceSelected$pa2 = _workspaceSelected$pa2[0]) === null || _workspaceSelected$pa2 === void 0 ? void 0 : _workspaceSelected$pa2.id) !== null && _workspaceSelected$pa !== void 0 ? _workspaceSelected$pa : null);
|
|
51645
|
+
if (prevId && prevId !== pageId) {
|
|
51646
|
+
pageHistoryRef.current.push(prevId);
|
|
51647
|
+
}
|
|
51648
|
+
}
|
|
51649
|
+
setActivePageId(pageId);
|
|
51650
|
+
}, [activePageId, workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.activePageId, workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.pages]);
|
|
51499
51651
|
|
|
51500
51652
|
// Listen for programmatic page switches via DashboardActionsApi
|
|
51501
51653
|
useEffect(function () {
|
|
51502
51654
|
function onSwitchPage(e) {
|
|
51503
51655
|
var _ref4 = e.detail || {},
|
|
51504
|
-
pageId = _ref4.pageId
|
|
51505
|
-
|
|
51656
|
+
pageId = _ref4.pageId,
|
|
51657
|
+
pageName = _ref4.pageName;
|
|
51658
|
+
if (pageId) {
|
|
51659
|
+
navigateToPage(pageId);
|
|
51660
|
+
} else if (pageName) {
|
|
51661
|
+
var pages = (workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.pages) || [];
|
|
51662
|
+
var match = pages.find(function (p) {
|
|
51663
|
+
return p.name.toLowerCase() === pageName.toLowerCase();
|
|
51664
|
+
});
|
|
51665
|
+
if (match) navigateToPage(match.id);
|
|
51666
|
+
}
|
|
51506
51667
|
}
|
|
51507
51668
|
window.addEventListener("dash:switch-page", onSwitchPage);
|
|
51508
51669
|
return function () {
|
|
51509
51670
|
return window.removeEventListener("dash:switch-page", onSwitchPage);
|
|
51510
51671
|
};
|
|
51672
|
+
}, [workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.pages, navigateToPage]);
|
|
51673
|
+
|
|
51674
|
+
// Listen for runtime UX actions: goBack, sidebar control, notify
|
|
51675
|
+
useEffect(function () {
|
|
51676
|
+
function onGoBack() {
|
|
51677
|
+
var prev = pageHistoryRef.current.pop();
|
|
51678
|
+
if (prev) setActivePageId(prev); // bypass history recording
|
|
51679
|
+
}
|
|
51680
|
+
function onSetNavSidebar(e) {
|
|
51681
|
+
var _e$detail;
|
|
51682
|
+
setSidebarCollapsed(!!((_e$detail = e.detail) !== null && _e$detail !== void 0 && _e$detail.collapsed));
|
|
51683
|
+
}
|
|
51684
|
+
function onToggleNavSidebar() {
|
|
51685
|
+
setSidebarCollapsed(function (c) {
|
|
51686
|
+
return !c;
|
|
51687
|
+
});
|
|
51688
|
+
}
|
|
51689
|
+
function onNotify(e) {
|
|
51690
|
+
var id = "".concat(Date.now(), "-").concat(Math.random());
|
|
51691
|
+
var toast = _objectSpread$5({
|
|
51692
|
+
id: id
|
|
51693
|
+
}, e.detail || {});
|
|
51694
|
+
setToasts(function (prev) {
|
|
51695
|
+
return [].concat(_toConsumableArray(prev), [toast]);
|
|
51696
|
+
});
|
|
51697
|
+
setTimeout(function () {
|
|
51698
|
+
setToasts(function (prev) {
|
|
51699
|
+
return prev.filter(function (t) {
|
|
51700
|
+
return t.id !== id;
|
|
51701
|
+
});
|
|
51702
|
+
});
|
|
51703
|
+
}, toast.duration || 4000);
|
|
51704
|
+
}
|
|
51705
|
+
window.addEventListener("dash:go-back", onGoBack);
|
|
51706
|
+
window.addEventListener("dash:set-nav-sidebar", onSetNavSidebar);
|
|
51707
|
+
window.addEventListener("dash:toggle-nav-sidebar", onToggleNavSidebar);
|
|
51708
|
+
window.addEventListener("dash:notify", onNotify);
|
|
51709
|
+
return function () {
|
|
51710
|
+
window.removeEventListener("dash:go-back", onGoBack);
|
|
51711
|
+
window.removeEventListener("dash:set-nav-sidebar", onSetNavSidebar);
|
|
51712
|
+
window.removeEventListener("dash:toggle-nav-sidebar", onToggleNavSidebar);
|
|
51713
|
+
window.removeEventListener("dash:notify", onNotify);
|
|
51714
|
+
};
|
|
51511
51715
|
}, []);
|
|
51512
51716
|
var workspacePages = (workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.pages) || [];
|
|
51513
51717
|
|
|
@@ -51524,6 +51728,71 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51524
51728
|
return "".concat(p.id, ":").concat(p.order, ":").concat(p.name);
|
|
51525
51729
|
}).join(",")]);
|
|
51526
51730
|
var currentActivePageId = activePageId || (workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.activePageId) || ((_workspacePages$0$id = (_workspacePages$ = workspacePages[0]) === null || _workspacePages$ === void 0 ? void 0 : _workspacePages$.id) !== null && _workspacePages$0$id !== void 0 ? _workspacePages$0$id : null);
|
|
51731
|
+
|
|
51732
|
+
// Stable refs for tab/dashboard handlers so the open/close-dashboard
|
|
51733
|
+
// listener doesn't have to re-subscribe on every render.
|
|
51734
|
+
var handleOpenTabRef = useRef(null);
|
|
51735
|
+
var handleCloseTabRef = useRef(null);
|
|
51736
|
+
var workspaceConfigRef = useRef([]);
|
|
51737
|
+
var openTabsRef = useRef([]);
|
|
51738
|
+
var activeTabIdRef = useRef(null);
|
|
51739
|
+
handleOpenTabRef.current = handleOpenTab;
|
|
51740
|
+
handleCloseTabRef.current = handleCloseTab;
|
|
51741
|
+
workspaceConfigRef.current = workspaceConfig;
|
|
51742
|
+
openTabsRef.current = openTabs;
|
|
51743
|
+
activeTabIdRef.current = activeTabId;
|
|
51744
|
+
|
|
51745
|
+
// Listen for open/close dashboard actions via DashboardActionsApi
|
|
51746
|
+
useEffect(function () {
|
|
51747
|
+
function onOpen(e) {
|
|
51748
|
+
var _e$detail2;
|
|
51749
|
+
var name = (_e$detail2 = e.detail) === null || _e$detail2 === void 0 ? void 0 : _e$detail2.name;
|
|
51750
|
+
if (!name) return;
|
|
51751
|
+
var ws = (workspaceConfigRef.current || []).find(function (w) {
|
|
51752
|
+
return (w.name || "").toLowerCase() === name.toLowerCase();
|
|
51753
|
+
});
|
|
51754
|
+
if (ws && handleOpenTabRef.current) handleOpenTabRef.current(ws);
|
|
51755
|
+
}
|
|
51756
|
+
function onClose(e) {
|
|
51757
|
+
var _e$detail3;
|
|
51758
|
+
var name = (_e$detail3 = e.detail) === null || _e$detail3 === void 0 ? void 0 : _e$detail3.name;
|
|
51759
|
+
if (name) {
|
|
51760
|
+
var tab = (openTabsRef.current || []).find(function (t) {
|
|
51761
|
+
return (t.name || "").toLowerCase() === name.toLowerCase();
|
|
51762
|
+
});
|
|
51763
|
+
if (tab && handleCloseTabRef.current) handleCloseTabRef.current(tab.id);
|
|
51764
|
+
} else if (activeTabIdRef.current && handleCloseTabRef.current) {
|
|
51765
|
+
handleCloseTabRef.current(activeTabIdRef.current);
|
|
51766
|
+
}
|
|
51767
|
+
}
|
|
51768
|
+
window.addEventListener("dash:open-dashboard", onOpen);
|
|
51769
|
+
window.addEventListener("dash:close-dashboard", onClose);
|
|
51770
|
+
return function () {
|
|
51771
|
+
window.removeEventListener("dash:open-dashboard", onOpen);
|
|
51772
|
+
window.removeEventListener("dash:close-dashboard", onClose);
|
|
51773
|
+
};
|
|
51774
|
+
}, []);
|
|
51775
|
+
|
|
51776
|
+
// Maintain window.__dashState so DashboardActionsApi read methods
|
|
51777
|
+
// (getCurrentPageName, listPages, etc.) return up-to-date values.
|
|
51778
|
+
useEffect(function () {
|
|
51779
|
+
var activePage = workspacePages.find(function (p) {
|
|
51780
|
+
return p.id === currentActivePageId;
|
|
51781
|
+
});
|
|
51782
|
+
window.__dashState = {
|
|
51783
|
+
currentPageId: currentActivePageId,
|
|
51784
|
+
currentPageName: (activePage === null || activePage === void 0 ? void 0 : activePage.name) || null,
|
|
51785
|
+
currentDashboardId: (workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.id) || null,
|
|
51786
|
+
currentDashboardName: (workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.name) || null,
|
|
51787
|
+
pages: workspacePages.map(function (p) {
|
|
51788
|
+
return {
|
|
51789
|
+
id: p.id,
|
|
51790
|
+
name: p.name,
|
|
51791
|
+
order: p.order
|
|
51792
|
+
};
|
|
51793
|
+
})
|
|
51794
|
+
};
|
|
51795
|
+
}, [currentActivePageId, workspacePages, workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.id, workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.name]);
|
|
51527
51796
|
function handleAddPage() {
|
|
51528
51797
|
if (!workspaceSelected) return;
|
|
51529
51798
|
var existingPages = _toConsumableArray(workspacePages);
|
|
@@ -51537,7 +51806,7 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51537
51806
|
handleWorkspaceChange(updatedWorkspace);
|
|
51538
51807
|
}
|
|
51539
51808
|
function handleSwitchPage(pageId) {
|
|
51540
|
-
|
|
51809
|
+
navigateToPage(pageId);
|
|
51541
51810
|
}
|
|
51542
51811
|
function handleRenamePage(pageId, newName) {
|
|
51543
51812
|
if (!workspaceSelected) return;
|
|
@@ -52008,7 +52277,25 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
52008
52277
|
direction: "col",
|
|
52009
52278
|
scrollable: false,
|
|
52010
52279
|
grow: true,
|
|
52011
|
-
children: [/*#__PURE__*/
|
|
52280
|
+
children: [toasts.length > 0 && /*#__PURE__*/jsx("div", {
|
|
52281
|
+
className: "fixed bottom-4 right-4 z-[9999] flex flex-col gap-2 pointer-events-none",
|
|
52282
|
+
children: toasts.map(function (t) {
|
|
52283
|
+
return /*#__PURE__*/jsx("div", {
|
|
52284
|
+
className: "pointer-events-auto",
|
|
52285
|
+
children: /*#__PURE__*/jsx(Toast, {
|
|
52286
|
+
title: t.title,
|
|
52287
|
+
message: t.message,
|
|
52288
|
+
onClose: function onClose() {
|
|
52289
|
+
return setToasts(function (prev) {
|
|
52290
|
+
return prev.filter(function (x) {
|
|
52291
|
+
return x.id !== t.id;
|
|
52292
|
+
});
|
|
52293
|
+
});
|
|
52294
|
+
}
|
|
52295
|
+
})
|
|
52296
|
+
}, t.id);
|
|
52297
|
+
})
|
|
52298
|
+
}), /*#__PURE__*/jsxs(DndProvider, {
|
|
52012
52299
|
backend: HTML5Backend,
|
|
52013
52300
|
children: [/*#__PURE__*/jsxs("div", {
|
|
52014
52301
|
className: "flex flex-row flex-1 overflow-hidden",
|