@trops/dash-core 0.1.405 → 0.1.407
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 +69 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +69 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -26906,15 +26906,18 @@ function moveWidgetAcrossContainers(workspace, sourceGridId, sourceCell, targetG
|
|
|
26906
26906
|
|
|
26907
26907
|
// Build a list of every bucket with a stable name so we can locate
|
|
26908
26908
|
// grid containers across them and patch them back in place.
|
|
26909
|
+
//
|
|
26910
|
+
// IMPORTANT: pages are listed BEFORE the top-level `layout` bucket.
|
|
26911
|
+
// `handleClickSaveWorkspace` writes `workspace.layout = activePage.layout`
|
|
26912
|
+
// as a backward-compat mirror of the active page — so a dashboard
|
|
26913
|
+
// grid's id typically exists in BOTH `workspace.layout` AND
|
|
26914
|
+
// `workspace.pages[activeIdx].layout`. If we checked `layout` first,
|
|
26915
|
+
// findBucket would match there and we'd mutate a bucket React never
|
|
26916
|
+
// renders (renderers read from pages[i].layout), so the user would
|
|
26917
|
+
// see the widget "disappear" with no visible target update.
|
|
26918
|
+
// Sidebar is last because its ids (90000+) can never collide with
|
|
26919
|
+
// page grids.
|
|
26909
26920
|
var buckets = [];
|
|
26910
|
-
if (Array.isArray(workspace.layout)) {
|
|
26911
|
-
buckets.push({
|
|
26912
|
-
key: "layout",
|
|
26913
|
-
get: function get() {
|
|
26914
|
-
return workspace.layout;
|
|
26915
|
-
}
|
|
26916
|
-
});
|
|
26917
|
-
}
|
|
26918
26921
|
if (Array.isArray(workspace.pages)) {
|
|
26919
26922
|
var _loop = function _loop() {
|
|
26920
26923
|
var _workspace$pages$i;
|
|
@@ -26932,6 +26935,14 @@ function moveWidgetAcrossContainers(workspace, sourceGridId, sourceCell, targetG
|
|
|
26932
26935
|
_loop();
|
|
26933
26936
|
}
|
|
26934
26937
|
}
|
|
26938
|
+
if (Array.isArray(workspace.layout)) {
|
|
26939
|
+
buckets.push({
|
|
26940
|
+
key: "layout",
|
|
26941
|
+
get: function get() {
|
|
26942
|
+
return workspace.layout;
|
|
26943
|
+
}
|
|
26944
|
+
});
|
|
26945
|
+
}
|
|
26935
26946
|
if (Array.isArray(workspace.sidebarLayout)) {
|
|
26936
26947
|
buckets.push({
|
|
26937
26948
|
key: "sidebarLayout",
|
|
@@ -55708,12 +55719,53 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
55708
55719
|
useEffect(function () {
|
|
55709
55720
|
if (popout) return;
|
|
55710
55721
|
var handler = function handler(e) {
|
|
55722
|
+
var _sidebarWorkspaceRef$;
|
|
55711
55723
|
var detail = (e === null || e === void 0 ? void 0 : e.detail) || {};
|
|
55712
55724
|
if (!workspaceSelected) return;
|
|
55713
|
-
|
|
55725
|
+
|
|
55726
|
+
// CRITICAL: LayoutBuilder edits (deletes, same-container moves,
|
|
55727
|
+
// new widget drops) live in each LayoutBuilder's internal state
|
|
55728
|
+
// and propagate upward only via refs — they never write back
|
|
55729
|
+
// into `workspaceSelected`. So we must overlay the LIVE refs
|
|
55730
|
+
// before applying the cross-container move, otherwise we'd base
|
|
55731
|
+
// the move on stale state and clobber the user's unsaved edits
|
|
55732
|
+
// (they'd see deleted widgets reappear after a cross-container
|
|
55733
|
+
// drop). This mirrors `handleClickSaveWorkspace`'s own logic.
|
|
55734
|
+
var liveWorkspace = JSON.parse(JSON.stringify(workspaceSelected));
|
|
55735
|
+
liveWorkspace.pages = (liveWorkspace.pages || []).map(function (page) {
|
|
55736
|
+
var _pageRef$current;
|
|
55737
|
+
var pageRef = pageRefsMap.current[page.id];
|
|
55738
|
+
var liveLayout = pageRef === null || pageRef === void 0 || (_pageRef$current = pageRef.current) === null || _pageRef$current === void 0 ? void 0 : _pageRef$current.layout;
|
|
55739
|
+
return liveLayout ? _objectSpread$6(_objectSpread$6({}, page), {}, {
|
|
55740
|
+
layout: liveLayout
|
|
55741
|
+
}) : page;
|
|
55742
|
+
});
|
|
55743
|
+
if ((_sidebarWorkspaceRef$ = sidebarWorkspaceRef.current) !== null && _sidebarWorkspaceRef$ !== void 0 && _sidebarWorkspaceRef$.layout && Array.isArray(sidebarWorkspaceRef.current.layout)) {
|
|
55744
|
+
liveWorkspace.sidebarLayout = sidebarWorkspaceRef.current.layout;
|
|
55745
|
+
}
|
|
55746
|
+
var updated = moveWidgetAcrossContainers(liveWorkspace, detail.sourceGridContainerId, detail.sourceCellNumber, detail.targetGridContainerId, detail.targetCellNumber);
|
|
55714
55747
|
if (!updated) {
|
|
55715
55748
|
return;
|
|
55716
55749
|
}
|
|
55750
|
+
|
|
55751
|
+
// Sync the refs so when LayoutBuilder's useEffect re-seeds
|
|
55752
|
+
// currentWorkspace from the new workspace prop below, and the
|
|
55753
|
+
// refs are also updated for the next save/cross-move.
|
|
55754
|
+
(updated.pages || []).forEach(function (page) {
|
|
55755
|
+
if (!pageRefsMap.current[page.id]) {
|
|
55756
|
+
pageRefsMap.current[page.id] = {
|
|
55757
|
+
current: null
|
|
55758
|
+
};
|
|
55759
|
+
}
|
|
55760
|
+
pageRefsMap.current[page.id].current = {
|
|
55761
|
+
layout: page.layout
|
|
55762
|
+
};
|
|
55763
|
+
});
|
|
55764
|
+
if (sidebarWorkspaceRef.current) {
|
|
55765
|
+
sidebarWorkspaceRef.current = _objectSpread$6(_objectSpread$6({}, sidebarWorkspaceRef.current || {}), {}, {
|
|
55766
|
+
layout: updated.sidebarLayout || []
|
|
55767
|
+
});
|
|
55768
|
+
}
|
|
55717
55769
|
updateTabWorkspace(updated);
|
|
55718
55770
|
if (dashApi && credentials !== null && credentials !== void 0 && credentials.appId) {
|
|
55719
55771
|
try {
|
|
@@ -56245,9 +56297,9 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
56245
56297
|
// adding a new page (especially relevant when going from 1 → 2
|
|
56246
56298
|
// pages where the lone page's tab is hidden but its grid is live).
|
|
56247
56299
|
var existingPages = workspacePages.map(function (p) {
|
|
56248
|
-
var _pageRef$
|
|
56300
|
+
var _pageRef$current2;
|
|
56249
56301
|
var pageRef = pageRefsMap.current[p.id];
|
|
56250
|
-
var liveLayout = pageRef === null || pageRef === void 0 || (_pageRef$
|
|
56302
|
+
var liveLayout = pageRef === null || pageRef === void 0 || (_pageRef$current2 = pageRef.current) === null || _pageRef$current2 === void 0 ? void 0 : _pageRef$current2.layout;
|
|
56251
56303
|
return liveLayout ? _objectSpread$6(_objectSpread$6({}, p), {}, {
|
|
56252
56304
|
layout: liveLayout
|
|
56253
56305
|
}) : p;
|
|
@@ -56484,11 +56536,11 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
56484
56536
|
|
|
56485
56537
|
// Derive scrollable state from the active page's root layout item
|
|
56486
56538
|
function getRootScrollable() {
|
|
56487
|
-
var _pageRef$
|
|
56539
|
+
var _pageRef$current3, _ws$pages;
|
|
56488
56540
|
var ws = currentWorkspaceRef.current || workspaceSelected;
|
|
56489
56541
|
if (!ws) return false;
|
|
56490
56542
|
var pageRef = pageRefsMap.current[currentActivePageId];
|
|
56491
|
-
var layout = (pageRef === null || pageRef === void 0 || (_pageRef$
|
|
56543
|
+
var layout = (pageRef === null || pageRef === void 0 || (_pageRef$current3 = pageRef.current) === null || _pageRef$current3 === void 0 ? void 0 : _pageRef$current3.layout) || ((_ws$pages = ws.pages) === null || _ws$pages === void 0 || (_ws$pages = _ws$pages.find(function (p) {
|
|
56492
56544
|
return p.id === currentActivePageId;
|
|
56493
56545
|
})) === null || _ws$pages === void 0 ? void 0 : _ws$pages.layout);
|
|
56494
56546
|
if (!layout) return false;
|
|
@@ -56499,15 +56551,15 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
56499
56551
|
}
|
|
56500
56552
|
function handleClickSaveWorkspace() {
|
|
56501
56553
|
try {
|
|
56502
|
-
var _sidebarWorkspaceRef
|
|
56554
|
+
var _sidebarWorkspaceRef$2;
|
|
56503
56555
|
// we have to remove the widgetConfig which contains the component
|
|
56504
56556
|
// sanitize the workspace layout remove widgetConfig items
|
|
56505
56557
|
// Gather latest layout from each page's LayoutBuilder ref
|
|
56506
56558
|
var workspaceToSave = deepCopy(workspaceSelected);
|
|
56507
56559
|
workspaceToSave.pages = (workspaceToSave.pages || []).map(function (page) {
|
|
56508
|
-
var _pageRef$
|
|
56560
|
+
var _pageRef$current4;
|
|
56509
56561
|
var pageRef = pageRefsMap.current[page.id];
|
|
56510
|
-
var latestLayout = (pageRef === null || pageRef === void 0 || (_pageRef$
|
|
56562
|
+
var latestLayout = (pageRef === null || pageRef === void 0 || (_pageRef$current4 = pageRef.current) === null || _pageRef$current4 === void 0 ? void 0 : _pageRef$current4.layout) || page.layout || [];
|
|
56511
56563
|
return _objectSpread$6(_objectSpread$6({}, page), {}, {
|
|
56512
56564
|
layout: latestLayout.map(function (item) {
|
|
56513
56565
|
var copy = _objectSpread$6({}, item);
|
|
@@ -56526,7 +56578,7 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
56526
56578
|
}
|
|
56527
56579
|
|
|
56528
56580
|
// Gather sidebar layout from its LayoutBuilder ref
|
|
56529
|
-
if ((_sidebarWorkspaceRef$ = sidebarWorkspaceRef.current) !== null && _sidebarWorkspaceRef$ !== void 0 && _sidebarWorkspaceRef
|
|
56581
|
+
if ((_sidebarWorkspaceRef$2 = sidebarWorkspaceRef.current) !== null && _sidebarWorkspaceRef$2 !== void 0 && _sidebarWorkspaceRef$2.layout) {
|
|
56530
56582
|
workspaceToSave.sidebarLayout = sidebarWorkspaceRef.current.layout.map(function (item) {
|
|
56531
56583
|
var copy = _objectSpread$6({}, item);
|
|
56532
56584
|
delete copy.widgetConfig;
|