@trops/dash-core 0.1.326 → 0.1.327
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 +106 -137
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +106 -137
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -27591,15 +27591,22 @@ var DashboardModel = /*#__PURE__*/function () {
|
|
|
27591
27591
|
this.sidebarLayout = "sidebarLayout" in obj ? obj.sidebarLayout : [];
|
|
27592
27592
|
this.sidebarWidth = "sidebarWidth" in obj ? obj.sidebarWidth : 280;
|
|
27593
27593
|
|
|
27594
|
-
// Multi-page support:
|
|
27594
|
+
// Multi-page support: every workspace always has at least one page.
|
|
27595
|
+
// Existing multi-page workspaces load as-is; single-page workspaces
|
|
27596
|
+
// are auto-migrated by wrapping their layout into a page.
|
|
27595
27597
|
if ("pages" in obj && Array.isArray(obj.pages) && obj.pages.length > 0) {
|
|
27596
27598
|
this.pages = obj.pages;
|
|
27597
27599
|
this.activePageId = obj.activePageId || obj.pages[0].id;
|
|
27598
27600
|
} else {
|
|
27599
|
-
//
|
|
27600
|
-
|
|
27601
|
-
|
|
27602
|
-
|
|
27601
|
+
// Auto-migrate: wrap existing layout into a single page
|
|
27602
|
+
var page = {
|
|
27603
|
+
id: "page-".concat(this.id || Date.now()),
|
|
27604
|
+
name: this.name || "Page 1",
|
|
27605
|
+
order: 0,
|
|
27606
|
+
layout: this.layout
|
|
27607
|
+
};
|
|
27608
|
+
this.pages = [page];
|
|
27609
|
+
this.activePageId = page.id;
|
|
27603
27610
|
}
|
|
27604
27611
|
obj = null;
|
|
27605
27612
|
|
|
@@ -27612,12 +27619,12 @@ var DashboardModel = /*#__PURE__*/function () {
|
|
|
27612
27619
|
_step;
|
|
27613
27620
|
try {
|
|
27614
27621
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
27615
|
-
var
|
|
27616
|
-
if (
|
|
27622
|
+
var _page = _step.value;
|
|
27623
|
+
if (_page.layout) {
|
|
27617
27624
|
var saved = this.layout;
|
|
27618
|
-
this.layout =
|
|
27625
|
+
this.layout = _page.layout;
|
|
27619
27626
|
this._normalizeAllGrids();
|
|
27620
|
-
|
|
27627
|
+
_page.layout = this.layout;
|
|
27621
27628
|
this.layout = saved;
|
|
27622
27629
|
}
|
|
27623
27630
|
}
|
|
@@ -27691,10 +27698,8 @@ var DashboardModel = /*#__PURE__*/function () {
|
|
|
27691
27698
|
themeKey: this.themeKey,
|
|
27692
27699
|
selectedProviders: this.selectedProviders
|
|
27693
27700
|
};
|
|
27694
|
-
|
|
27695
|
-
|
|
27696
|
-
ws.activePageId = this.activePageId;
|
|
27697
|
-
}
|
|
27701
|
+
ws.pages = this.pages;
|
|
27702
|
+
ws.activePageId = this.activePageId;
|
|
27698
27703
|
if (this.sidebarEnabled || ((_this$sidebarLayout = this.sidebarLayout) === null || _this$sidebarLayout === void 0 ? void 0 : _this$sidebarLayout.length) > 0) {
|
|
27699
27704
|
ws.sidebarEnabled = this.sidebarEnabled;
|
|
27700
27705
|
ws.sidebarLayout = this.sidebarLayout;
|
|
@@ -48786,7 +48791,11 @@ var PageTabBar = function PageTabBar(_ref) {
|
|
|
48786
48791
|
_ref$onReorderPages = _ref.onReorderPages,
|
|
48787
48792
|
onReorderPages = _ref$onReorderPages === void 0 ? null : _ref$onReorderPages,
|
|
48788
48793
|
_ref$editMode = _ref.editMode,
|
|
48789
|
-
editMode = _ref$editMode === void 0 ? false : _ref$editMode
|
|
48794
|
+
editMode = _ref$editMode === void 0 ? false : _ref$editMode,
|
|
48795
|
+
_ref$scrollableEnable = _ref.scrollableEnabled,
|
|
48796
|
+
scrollableEnabled = _ref$scrollableEnable === void 0 ? false : _ref$scrollableEnable,
|
|
48797
|
+
_ref$onScrollableChan = _ref.onScrollableChange,
|
|
48798
|
+
onScrollableChange = _ref$onScrollableChan === void 0 ? null : _ref$onScrollableChan;
|
|
48790
48799
|
var _useContext = useContext(ThemeContext),
|
|
48791
48800
|
currentTheme = _useContext.currentTheme;
|
|
48792
48801
|
var _useState = useState(null),
|
|
@@ -48939,6 +48948,13 @@ var PageTabBar = function PageTabBar(_ref) {
|
|
|
48939
48948
|
}), /*#__PURE__*/jsx("span", {
|
|
48940
48949
|
children: "Add Page"
|
|
48941
48950
|
})]
|
|
48951
|
+
}), editMode && onScrollableChange && /*#__PURE__*/jsx("div", {
|
|
48952
|
+
className: "ml-auto flex items-center shrink-0",
|
|
48953
|
+
children: /*#__PURE__*/jsx(Toggle, {
|
|
48954
|
+
text: "Scrollable",
|
|
48955
|
+
enabled: scrollableEnabled,
|
|
48956
|
+
setEnabled: onScrollableChange
|
|
48957
|
+
})
|
|
48942
48958
|
})]
|
|
48943
48959
|
});
|
|
48944
48960
|
};
|
|
@@ -51453,37 +51469,23 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51453
51469
|
activePageId = _useState48[0],
|
|
51454
51470
|
setActivePageId = _useState48[1];
|
|
51455
51471
|
var workspacePages = (workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.pages) || [];
|
|
51456
|
-
var hasPages = workspacePages.length > 0;
|
|
51457
51472
|
|
|
51458
51473
|
// Memoize sorted pages so page object references stay stable across re-renders
|
|
51459
51474
|
var sortedPagesForRender = useMemo(function () {
|
|
51460
|
-
return
|
|
51475
|
+
return _toConsumableArray(workspacePages).sort(function (a, b) {
|
|
51461
51476
|
return (a.order || 0) - (b.order || 0);
|
|
51462
|
-
})
|
|
51477
|
+
});
|
|
51463
51478
|
},
|
|
51464
51479
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51465
|
-
[
|
|
51480
|
+
[workspacePages.length,
|
|
51466
51481
|
// Re-sort when page names/order change but not on every parent render
|
|
51467
51482
|
workspacePages.map(function (p) {
|
|
51468
51483
|
return "".concat(p.id, ":").concat(p.order, ":").concat(p.name);
|
|
51469
51484
|
}).join(",")]);
|
|
51470
51485
|
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);
|
|
51471
51486
|
function handleAddPage() {
|
|
51472
|
-
var _workspaceSelected$la;
|
|
51473
51487
|
if (!workspaceSelected) return;
|
|
51474
51488
|
var existingPages = _toConsumableArray(workspacePages);
|
|
51475
|
-
|
|
51476
|
-
// If this is the first time adding a page to a single-page dashboard,
|
|
51477
|
-
// migrate the existing layout into page 1 first.
|
|
51478
|
-
if (existingPages.length === 0 && ((_workspaceSelected$la = workspaceSelected.layout) === null || _workspaceSelected$la === void 0 ? void 0 : _workspaceSelected$la.length) > 0) {
|
|
51479
|
-
var page1 = {
|
|
51480
|
-
id: "page-".concat(Date.now() - 1),
|
|
51481
|
-
name: workspaceSelected.name || "Page 1",
|
|
51482
|
-
order: 0,
|
|
51483
|
-
layout: workspaceSelected.layout
|
|
51484
|
-
};
|
|
51485
|
-
existingPages = [page1];
|
|
51486
|
-
}
|
|
51487
51489
|
var newPage = DashboardModel.createPage("Page ".concat(existingPages.length + 1));
|
|
51488
51490
|
newPage.order = existingPages.length;
|
|
51489
51491
|
var updatedWorkspace = _objectSpread$5(_objectSpread$5({}, workspaceSelected), {}, {
|
|
@@ -51515,17 +51517,6 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51515
51517
|
});
|
|
51516
51518
|
var newActiveId = currentActivePageId === pageId ? (_updatedPages$ = updatedPages[0]) === null || _updatedPages$ === void 0 ? void 0 : _updatedPages$.id : currentActivePageId;
|
|
51517
51519
|
setActivePageId(newActiveId);
|
|
51518
|
-
|
|
51519
|
-
// If only one page remains, convert back to single-page mode
|
|
51520
|
-
if (updatedPages.length === 1) {
|
|
51521
|
-
handleWorkspaceChange(_objectSpread$5(_objectSpread$5({}, workspaceSelected), {}, {
|
|
51522
|
-
layout: updatedPages[0].layout,
|
|
51523
|
-
pages: [],
|
|
51524
|
-
activePageId: null
|
|
51525
|
-
}));
|
|
51526
|
-
setActivePageId(null);
|
|
51527
|
-
return;
|
|
51528
|
-
}
|
|
51529
51520
|
handleWorkspaceChange(_objectSpread$5(_objectSpread$5({}, workspaceSelected), {}, {
|
|
51530
51521
|
pages: updatedPages,
|
|
51531
51522
|
activePageId: newActiveId
|
|
@@ -51584,45 +51575,28 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51584
51575
|
function renderComponent(workspaceItem) {
|
|
51585
51576
|
try {
|
|
51586
51577
|
if (workspaceItem === undefined) return null;
|
|
51587
|
-
|
|
51588
|
-
|
|
51589
|
-
|
|
51590
|
-
|
|
51591
|
-
|
|
51592
|
-
|
|
51593
|
-
|
|
51594
|
-
|
|
51595
|
-
|
|
51596
|
-
|
|
51597
|
-
|
|
51598
|
-
|
|
51599
|
-
|
|
51600
|
-
|
|
51601
|
-
|
|
51602
|
-
|
|
51603
|
-
|
|
51604
|
-
|
|
51605
|
-
|
|
51606
|
-
|
|
51607
|
-
|
|
51608
|
-
|
|
51609
|
-
}, page.id);
|
|
51610
|
-
})
|
|
51611
|
-
});
|
|
51612
|
-
}
|
|
51613
|
-
|
|
51614
|
-
// Single-page mode (backward compatible)
|
|
51615
|
-
return /*#__PURE__*/jsx(LayoutBuilder, {
|
|
51616
|
-
dashboardId: workspaceItem["id"],
|
|
51617
|
-
preview: previewMode,
|
|
51618
|
-
workspace: workspaceItem,
|
|
51619
|
-
onWorkspaceChange: handleWorkspaceChange,
|
|
51620
|
-
onProviderSelect: handleProviderSelect,
|
|
51621
|
-
onTogglePreview: handleToggleEditMode,
|
|
51622
|
-
editMode: editMode,
|
|
51623
|
-
workspaceRef: currentWorkspaceRef,
|
|
51624
|
-
onWidgetPopout: popout ? null : handleWidgetPopout
|
|
51625
|
-
}, "LayoutBuilder-".concat(workspaceItem["id"]));
|
|
51578
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
51579
|
+
children: sortedPagesForRender.map(function (page) {
|
|
51580
|
+
var isActive = page.id === currentActivePageId;
|
|
51581
|
+
return /*#__PURE__*/jsx("div", {
|
|
51582
|
+
style: {
|
|
51583
|
+
display: isActive ? "flex" : "none"
|
|
51584
|
+
},
|
|
51585
|
+
className: "flex-col w-full flex-1",
|
|
51586
|
+
children: /*#__PURE__*/jsx(PageLayoutBuilder, {
|
|
51587
|
+
page: page,
|
|
51588
|
+
workspaceItem: workspaceItem,
|
|
51589
|
+
previewMode: previewMode,
|
|
51590
|
+
editMode: editMode,
|
|
51591
|
+
onPageWorkspaceChange: handlePageWorkspaceChange,
|
|
51592
|
+
onProviderSelect: stableProviderSelect,
|
|
51593
|
+
onTogglePreview: stableTogglePreview,
|
|
51594
|
+
workspaceRef: getPageRef(page.id),
|
|
51595
|
+
onWidgetPopout: stableWidgetPopout
|
|
51596
|
+
})
|
|
51597
|
+
}, page.id);
|
|
51598
|
+
})
|
|
51599
|
+
});
|
|
51626
51600
|
} catch (e) {
|
|
51627
51601
|
return null;
|
|
51628
51602
|
}
|
|
@@ -51716,27 +51690,43 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51716
51690
|
updateTabWorkspace(tempWorkspace);
|
|
51717
51691
|
}
|
|
51718
51692
|
function handleScrollableChange(enabled) {
|
|
51719
|
-
var _tempWorkspace$layout;
|
|
51720
51693
|
if (!workspaceSelected) return;
|
|
51721
51694
|
var tempWorkspace = deepCopy(currentWorkspaceRef.current || workspaceSelected);
|
|
51722
|
-
//
|
|
51723
|
-
|
|
51724
|
-
|
|
51695
|
+
// Update the active page's root layout item
|
|
51696
|
+
tempWorkspace.pages = (tempWorkspace.pages || []).map(function (page) {
|
|
51697
|
+
if (page.id !== currentActivePageId) return page;
|
|
51698
|
+
return _objectSpread$5(_objectSpread$5({}, page), {}, {
|
|
51699
|
+
layout: (page.layout || []).map(function (item) {
|
|
51700
|
+
return item.parent === 0 ? _objectSpread$5(_objectSpread$5({}, item), {}, {
|
|
51701
|
+
scrollable: enabled
|
|
51702
|
+
}) : item;
|
|
51703
|
+
})
|
|
51704
|
+
});
|
|
51725
51705
|
});
|
|
51726
|
-
|
|
51727
|
-
|
|
51706
|
+
// Update page ref immediately so getRootScrollable() reads the new value
|
|
51707
|
+
var pageRef = pageRefsMap.current[currentActivePageId];
|
|
51708
|
+
if (pageRef !== null && pageRef !== void 0 && pageRef.current) {
|
|
51709
|
+
pageRef.current.layout = (pageRef.current.layout || []).map(function (item) {
|
|
51710
|
+
return item.parent === 0 ? _objectSpread$5(_objectSpread$5({}, item), {}, {
|
|
51711
|
+
scrollable: enabled
|
|
51712
|
+
}) : item;
|
|
51713
|
+
});
|
|
51728
51714
|
}
|
|
51729
|
-
// Update ref immediately so getRootScrollable() reads the new value
|
|
51730
|
-
// before LayoutBuilder's async useEffect syncs it
|
|
51731
51715
|
currentWorkspaceRef.current = tempWorkspace;
|
|
51732
51716
|
updateTabWorkspace(tempWorkspace);
|
|
51733
51717
|
}
|
|
51734
51718
|
|
|
51735
|
-
// Derive scrollable state from root layout item
|
|
51719
|
+
// Derive scrollable state from the active page's root layout item
|
|
51736
51720
|
function getRootScrollable() {
|
|
51721
|
+
var _pageRef$current, _ws$pages;
|
|
51737
51722
|
var ws = currentWorkspaceRef.current || workspaceSelected;
|
|
51738
|
-
if (!
|
|
51739
|
-
var
|
|
51723
|
+
if (!ws) return false;
|
|
51724
|
+
var pageRef = pageRefsMap.current[currentActivePageId];
|
|
51725
|
+
var layout = (pageRef === null || pageRef === void 0 || (_pageRef$current = pageRef.current) === null || _pageRef$current === void 0 ? void 0 : _pageRef$current.layout) || ((_ws$pages = ws.pages) === null || _ws$pages === void 0 || (_ws$pages = _ws$pages.find(function (p) {
|
|
51726
|
+
return p.id === currentActivePageId;
|
|
51727
|
+
})) === null || _ws$pages === void 0 ? void 0 : _ws$pages.layout);
|
|
51728
|
+
if (!layout) return false;
|
|
51729
|
+
var rootItem = layout.find(function (item) {
|
|
51740
51730
|
return item.parent === 0;
|
|
51741
51731
|
});
|
|
51742
51732
|
return (rootItem === null || rootItem === void 0 ? void 0 : rootItem.scrollable) || false;
|
|
@@ -51746,48 +51736,27 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51746
51736
|
var _sidebarWorkspaceRef$;
|
|
51747
51737
|
// we have to remove the widgetConfig which contains the component
|
|
51748
51738
|
// sanitize the workspace layout remove widgetConfig items
|
|
51749
|
-
|
|
51750
|
-
|
|
51751
|
-
|
|
51752
|
-
|
|
51753
|
-
|
|
51754
|
-
|
|
51755
|
-
|
|
51756
|
-
|
|
51757
|
-
|
|
51758
|
-
|
|
51759
|
-
|
|
51760
|
-
|
|
51761
|
-
return copy;
|
|
51762
|
-
})
|
|
51763
|
-
});
|
|
51764
|
-
});
|
|
51765
|
-
workspaceToSave.activePageId = currentActivePageId;
|
|
51766
|
-
// Also sanitize the root layout (may be stale from pre-pages era)
|
|
51767
|
-
workspaceToSave.layout = (workspaceToSave.layout || []).map(function (item) {
|
|
51768
|
-
var copy = _objectSpread$5({}, item);
|
|
51769
|
-
delete copy.widgetConfig;
|
|
51770
|
-
return copy;
|
|
51739
|
+
// Gather latest layout from each page's LayoutBuilder ref
|
|
51740
|
+
var workspaceToSave = deepCopy(workspaceSelected);
|
|
51741
|
+
workspaceToSave.pages = (workspaceToSave.pages || []).map(function (page) {
|
|
51742
|
+
var _pageRef$current2;
|
|
51743
|
+
var pageRef = pageRefsMap.current[page.id];
|
|
51744
|
+
var latestLayout = (pageRef === null || pageRef === void 0 || (_pageRef$current2 = pageRef.current) === null || _pageRef$current2 === void 0 ? void 0 : _pageRef$current2.layout) || page.layout || [];
|
|
51745
|
+
return _objectSpread$5(_objectSpread$5({}, page), {}, {
|
|
51746
|
+
layout: latestLayout.map(function (item) {
|
|
51747
|
+
var copy = _objectSpread$5({}, item);
|
|
51748
|
+
delete copy.widgetConfig;
|
|
51749
|
+
return copy;
|
|
51750
|
+
})
|
|
51771
51751
|
});
|
|
51772
|
-
}
|
|
51773
|
-
|
|
51774
|
-
|
|
51775
|
-
|
|
51776
|
-
|
|
51777
|
-
|
|
51778
|
-
|
|
51779
|
-
|
|
51780
|
-
if (refLayout) {
|
|
51781
|
-
workspaceToSave["layout"] = refLayout.map(function (layoutItem) {
|
|
51782
|
-
delete layoutItem["widgetConfig"];
|
|
51783
|
-
return layoutItem;
|
|
51784
|
-
});
|
|
51785
|
-
} else {
|
|
51786
|
-
workspaceToSave["layout"] = (workspaceToSave["layout"] || []).map(function (layoutItem) {
|
|
51787
|
-
delete layoutItem["widgetConfig"];
|
|
51788
|
-
return layoutItem;
|
|
51789
|
-
});
|
|
51790
|
-
}
|
|
51752
|
+
});
|
|
51753
|
+
workspaceToSave.activePageId = currentActivePageId;
|
|
51754
|
+
// Sync root layout from active page for backward compat
|
|
51755
|
+
var activePage = workspaceToSave.pages.find(function (p) {
|
|
51756
|
+
return p.id === currentActivePageId;
|
|
51757
|
+
});
|
|
51758
|
+
if (activePage) {
|
|
51759
|
+
workspaceToSave.layout = activePage.layout;
|
|
51791
51760
|
}
|
|
51792
51761
|
|
|
51793
51762
|
// Gather sidebar layout from its LayoutBuilder ref
|
|
@@ -52037,8 +52006,6 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
52037
52006
|
themes: themes || {},
|
|
52038
52007
|
onFolderChange: popout ? null : handleWorkspaceFolderChange,
|
|
52039
52008
|
onThemeChange: popout ? null : handleWorkspaceThemeChange,
|
|
52040
|
-
scrollableEnabled: getRootScrollable(),
|
|
52041
|
-
onScrollableChange: popout ? null : handleScrollableChange,
|
|
52042
52009
|
sidebarEnabled: sidebarEnabled,
|
|
52043
52010
|
onSidebarChange: popout ? null : handleSidebarToggle
|
|
52044
52011
|
}), /*#__PURE__*/jsxs(DashboardThemeProvider, {
|
|
@@ -52071,7 +52038,7 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
52071
52038
|
className: "h-3 w-3"
|
|
52072
52039
|
})
|
|
52073
52040
|
})]
|
|
52074
|
-
}),
|
|
52041
|
+
}), /*#__PURE__*/jsx(PageTabBar, {
|
|
52075
52042
|
pages: workspacePages,
|
|
52076
52043
|
activePageId: currentActivePageId,
|
|
52077
52044
|
onSwitchPage: handleSwitchPage,
|
|
@@ -52079,7 +52046,9 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
52079
52046
|
onRenamePage: handleRenamePage,
|
|
52080
52047
|
onDeletePage: handleDeletePage,
|
|
52081
52048
|
onReorderPages: handleReorderPages,
|
|
52082
|
-
editMode: !previewMode
|
|
52049
|
+
editMode: !previewMode,
|
|
52050
|
+
scrollableEnabled: getRootScrollable(),
|
|
52051
|
+
onScrollableChange: popout ? null : handleScrollableChange
|
|
52083
52052
|
}), /*#__PURE__*/jsxs("div", {
|
|
52084
52053
|
className: "flex flex-row flex-1 min-h-0 overflow-hidden",
|
|
52085
52054
|
children: [sidebarEnabled && !popout && /*#__PURE__*/jsx(PinnedSidebar, {
|