@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.js
CHANGED
|
@@ -26924,15 +26924,18 @@ function moveWidgetAcrossContainers(workspace, sourceGridId, sourceCell, targetG
|
|
|
26924
26924
|
|
|
26925
26925
|
// Build a list of every bucket with a stable name so we can locate
|
|
26926
26926
|
// grid containers across them and patch them back in place.
|
|
26927
|
+
//
|
|
26928
|
+
// IMPORTANT: pages are listed BEFORE the top-level `layout` bucket.
|
|
26929
|
+
// `handleClickSaveWorkspace` writes `workspace.layout = activePage.layout`
|
|
26930
|
+
// as a backward-compat mirror of the active page — so a dashboard
|
|
26931
|
+
// grid's id typically exists in BOTH `workspace.layout` AND
|
|
26932
|
+
// `workspace.pages[activeIdx].layout`. If we checked `layout` first,
|
|
26933
|
+
// findBucket would match there and we'd mutate a bucket React never
|
|
26934
|
+
// renders (renderers read from pages[i].layout), so the user would
|
|
26935
|
+
// see the widget "disappear" with no visible target update.
|
|
26936
|
+
// Sidebar is last because its ids (90000+) can never collide with
|
|
26937
|
+
// page grids.
|
|
26927
26938
|
var buckets = [];
|
|
26928
|
-
if (Array.isArray(workspace.layout)) {
|
|
26929
|
-
buckets.push({
|
|
26930
|
-
key: "layout",
|
|
26931
|
-
get: function get() {
|
|
26932
|
-
return workspace.layout;
|
|
26933
|
-
}
|
|
26934
|
-
});
|
|
26935
|
-
}
|
|
26936
26939
|
if (Array.isArray(workspace.pages)) {
|
|
26937
26940
|
var _loop = function _loop() {
|
|
26938
26941
|
var _workspace$pages$i;
|
|
@@ -26950,6 +26953,14 @@ function moveWidgetAcrossContainers(workspace, sourceGridId, sourceCell, targetG
|
|
|
26950
26953
|
_loop();
|
|
26951
26954
|
}
|
|
26952
26955
|
}
|
|
26956
|
+
if (Array.isArray(workspace.layout)) {
|
|
26957
|
+
buckets.push({
|
|
26958
|
+
key: "layout",
|
|
26959
|
+
get: function get() {
|
|
26960
|
+
return workspace.layout;
|
|
26961
|
+
}
|
|
26962
|
+
});
|
|
26963
|
+
}
|
|
26953
26964
|
if (Array.isArray(workspace.sidebarLayout)) {
|
|
26954
26965
|
buckets.push({
|
|
26955
26966
|
key: "sidebarLayout",
|
|
@@ -55726,12 +55737,53 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
55726
55737
|
React.useEffect(function () {
|
|
55727
55738
|
if (popout) return;
|
|
55728
55739
|
var handler = function handler(e) {
|
|
55740
|
+
var _sidebarWorkspaceRef$;
|
|
55729
55741
|
var detail = (e === null || e === void 0 ? void 0 : e.detail) || {};
|
|
55730
55742
|
if (!workspaceSelected) return;
|
|
55731
|
-
|
|
55743
|
+
|
|
55744
|
+
// CRITICAL: LayoutBuilder edits (deletes, same-container moves,
|
|
55745
|
+
// new widget drops) live in each LayoutBuilder's internal state
|
|
55746
|
+
// and propagate upward only via refs — they never write back
|
|
55747
|
+
// into `workspaceSelected`. So we must overlay the LIVE refs
|
|
55748
|
+
// before applying the cross-container move, otherwise we'd base
|
|
55749
|
+
// the move on stale state and clobber the user's unsaved edits
|
|
55750
|
+
// (they'd see deleted widgets reappear after a cross-container
|
|
55751
|
+
// drop). This mirrors `handleClickSaveWorkspace`'s own logic.
|
|
55752
|
+
var liveWorkspace = JSON.parse(JSON.stringify(workspaceSelected));
|
|
55753
|
+
liveWorkspace.pages = (liveWorkspace.pages || []).map(function (page) {
|
|
55754
|
+
var _pageRef$current;
|
|
55755
|
+
var pageRef = pageRefsMap.current[page.id];
|
|
55756
|
+
var liveLayout = pageRef === null || pageRef === void 0 || (_pageRef$current = pageRef.current) === null || _pageRef$current === void 0 ? void 0 : _pageRef$current.layout;
|
|
55757
|
+
return liveLayout ? _objectSpread$6(_objectSpread$6({}, page), {}, {
|
|
55758
|
+
layout: liveLayout
|
|
55759
|
+
}) : page;
|
|
55760
|
+
});
|
|
55761
|
+
if ((_sidebarWorkspaceRef$ = sidebarWorkspaceRef.current) !== null && _sidebarWorkspaceRef$ !== void 0 && _sidebarWorkspaceRef$.layout && Array.isArray(sidebarWorkspaceRef.current.layout)) {
|
|
55762
|
+
liveWorkspace.sidebarLayout = sidebarWorkspaceRef.current.layout;
|
|
55763
|
+
}
|
|
55764
|
+
var updated = moveWidgetAcrossContainers(liveWorkspace, detail.sourceGridContainerId, detail.sourceCellNumber, detail.targetGridContainerId, detail.targetCellNumber);
|
|
55732
55765
|
if (!updated) {
|
|
55733
55766
|
return;
|
|
55734
55767
|
}
|
|
55768
|
+
|
|
55769
|
+
// Sync the refs so when LayoutBuilder's useEffect re-seeds
|
|
55770
|
+
// currentWorkspace from the new workspace prop below, and the
|
|
55771
|
+
// refs are also updated for the next save/cross-move.
|
|
55772
|
+
(updated.pages || []).forEach(function (page) {
|
|
55773
|
+
if (!pageRefsMap.current[page.id]) {
|
|
55774
|
+
pageRefsMap.current[page.id] = {
|
|
55775
|
+
current: null
|
|
55776
|
+
};
|
|
55777
|
+
}
|
|
55778
|
+
pageRefsMap.current[page.id].current = {
|
|
55779
|
+
layout: page.layout
|
|
55780
|
+
};
|
|
55781
|
+
});
|
|
55782
|
+
if (sidebarWorkspaceRef.current) {
|
|
55783
|
+
sidebarWorkspaceRef.current = _objectSpread$6(_objectSpread$6({}, sidebarWorkspaceRef.current || {}), {}, {
|
|
55784
|
+
layout: updated.sidebarLayout || []
|
|
55785
|
+
});
|
|
55786
|
+
}
|
|
55735
55787
|
updateTabWorkspace(updated);
|
|
55736
55788
|
if (dashApi && credentials !== null && credentials !== void 0 && credentials.appId) {
|
|
55737
55789
|
try {
|
|
@@ -56263,9 +56315,9 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
56263
56315
|
// adding a new page (especially relevant when going from 1 → 2
|
|
56264
56316
|
// pages where the lone page's tab is hidden but its grid is live).
|
|
56265
56317
|
var existingPages = workspacePages.map(function (p) {
|
|
56266
|
-
var _pageRef$
|
|
56318
|
+
var _pageRef$current2;
|
|
56267
56319
|
var pageRef = pageRefsMap.current[p.id];
|
|
56268
|
-
var liveLayout = pageRef === null || pageRef === void 0 || (_pageRef$
|
|
56320
|
+
var liveLayout = pageRef === null || pageRef === void 0 || (_pageRef$current2 = pageRef.current) === null || _pageRef$current2 === void 0 ? void 0 : _pageRef$current2.layout;
|
|
56269
56321
|
return liveLayout ? _objectSpread$6(_objectSpread$6({}, p), {}, {
|
|
56270
56322
|
layout: liveLayout
|
|
56271
56323
|
}) : p;
|
|
@@ -56502,11 +56554,11 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
56502
56554
|
|
|
56503
56555
|
// Derive scrollable state from the active page's root layout item
|
|
56504
56556
|
function getRootScrollable() {
|
|
56505
|
-
var _pageRef$
|
|
56557
|
+
var _pageRef$current3, _ws$pages;
|
|
56506
56558
|
var ws = currentWorkspaceRef.current || workspaceSelected;
|
|
56507
56559
|
if (!ws) return false;
|
|
56508
56560
|
var pageRef = pageRefsMap.current[currentActivePageId];
|
|
56509
|
-
var layout = (pageRef === null || pageRef === void 0 || (_pageRef$
|
|
56561
|
+
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) {
|
|
56510
56562
|
return p.id === currentActivePageId;
|
|
56511
56563
|
})) === null || _ws$pages === void 0 ? void 0 : _ws$pages.layout);
|
|
56512
56564
|
if (!layout) return false;
|
|
@@ -56517,15 +56569,15 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
56517
56569
|
}
|
|
56518
56570
|
function handleClickSaveWorkspace() {
|
|
56519
56571
|
try {
|
|
56520
|
-
var _sidebarWorkspaceRef
|
|
56572
|
+
var _sidebarWorkspaceRef$2;
|
|
56521
56573
|
// we have to remove the widgetConfig which contains the component
|
|
56522
56574
|
// sanitize the workspace layout remove widgetConfig items
|
|
56523
56575
|
// Gather latest layout from each page's LayoutBuilder ref
|
|
56524
56576
|
var workspaceToSave = DashReact.deepCopy(workspaceSelected);
|
|
56525
56577
|
workspaceToSave.pages = (workspaceToSave.pages || []).map(function (page) {
|
|
56526
|
-
var _pageRef$
|
|
56578
|
+
var _pageRef$current4;
|
|
56527
56579
|
var pageRef = pageRefsMap.current[page.id];
|
|
56528
|
-
var latestLayout = (pageRef === null || pageRef === void 0 || (_pageRef$
|
|
56580
|
+
var latestLayout = (pageRef === null || pageRef === void 0 || (_pageRef$current4 = pageRef.current) === null || _pageRef$current4 === void 0 ? void 0 : _pageRef$current4.layout) || page.layout || [];
|
|
56529
56581
|
return _objectSpread$6(_objectSpread$6({}, page), {}, {
|
|
56530
56582
|
layout: latestLayout.map(function (item) {
|
|
56531
56583
|
var copy = _objectSpread$6({}, item);
|
|
@@ -56544,7 +56596,7 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
56544
56596
|
}
|
|
56545
56597
|
|
|
56546
56598
|
// Gather sidebar layout from its LayoutBuilder ref
|
|
56547
|
-
if ((_sidebarWorkspaceRef$ = sidebarWorkspaceRef.current) !== null && _sidebarWorkspaceRef$ !== void 0 && _sidebarWorkspaceRef
|
|
56599
|
+
if ((_sidebarWorkspaceRef$2 = sidebarWorkspaceRef.current) !== null && _sidebarWorkspaceRef$2 !== void 0 && _sidebarWorkspaceRef$2.layout) {
|
|
56548
56600
|
workspaceToSave.sidebarLayout = sidebarWorkspaceRef.current.layout.map(function (item) {
|
|
56549
56601
|
var copy = _objectSpread$6({}, item);
|
|
56550
56602
|
delete copy.widgetConfig;
|