@trops/dash-core 0.1.334 → 0.1.335
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 +57 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +57 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27316,6 +27316,34 @@ var SettingsModel = function SettingsModel() {
|
|
|
27316
27316
|
return obj;
|
|
27317
27317
|
};
|
|
27318
27318
|
|
|
27319
|
+
/**
|
|
27320
|
+
* Default layout for a brand-new workspace: a single 1x1 grid container
|
|
27321
|
+
* with one empty cell. Mirrors DashboardModel._initializeLayout().
|
|
27322
|
+
*/
|
|
27323
|
+
function defaultGridLayout() {
|
|
27324
|
+
return [LayoutModel({
|
|
27325
|
+
id: 1,
|
|
27326
|
+
order: 1,
|
|
27327
|
+
type: "grid",
|
|
27328
|
+
component: "LayoutGridContainer",
|
|
27329
|
+
hasChildren: 1,
|
|
27330
|
+
scrollable: false,
|
|
27331
|
+
parent: 0,
|
|
27332
|
+
menuId: 1,
|
|
27333
|
+
width: "w-full",
|
|
27334
|
+
height: "h-full",
|
|
27335
|
+
grid: {
|
|
27336
|
+
rows: 1,
|
|
27337
|
+
cols: 1,
|
|
27338
|
+
gap: "gap-2",
|
|
27339
|
+
1.1: {
|
|
27340
|
+
component: null,
|
|
27341
|
+
hide: false
|
|
27342
|
+
}
|
|
27343
|
+
}
|
|
27344
|
+
}, [])];
|
|
27345
|
+
}
|
|
27346
|
+
|
|
27319
27347
|
/**
|
|
27320
27348
|
* A Model for a Workspace (Dashboard)
|
|
27321
27349
|
* The Workspace in this instance is the entire Dashboard Layout inclusive of the workspaces and widgets
|
|
@@ -27348,20 +27376,22 @@ var WorkspaceModel = function WorkspaceModel(workspaceItem) {
|
|
|
27348
27376
|
workspace.type = "type" in obj ? sanitizeType(obj["type"]) : "workspace";
|
|
27349
27377
|
workspace.label = "label" in obj ? obj["label"] : "New Dashboard";
|
|
27350
27378
|
workspace.version = "version" in obj ? obj["version"] : 1;
|
|
27351
|
-
workspace.layout = "layout" in obj ? obj["layout"] :
|
|
27379
|
+
workspace.layout = "layout" in obj && Array.isArray(obj["layout"]) && obj["layout"].length > 0 ? obj["layout"] : defaultGridLayout();
|
|
27352
27380
|
workspace.pages = "pages" in obj ? obj["pages"] : [];
|
|
27353
27381
|
workspace.activePageId = "activePageId" in obj ? obj["activePageId"] : null;
|
|
27354
27382
|
|
|
27355
27383
|
// Always-pages model: every workspace must have at least one page.
|
|
27356
|
-
// If the source data is single-page (empty pages array
|
|
27357
|
-
// layout
|
|
27358
|
-
//
|
|
27384
|
+
// If the source data is single-page (empty pages array), wrap the
|
|
27385
|
+
// layout into pages[0] so renderers always have a page to display.
|
|
27386
|
+
// The page is named "Page 1" — when only one page exists, the
|
|
27387
|
+
// PageTabBar hides it; when the user adds a second page, both
|
|
27388
|
+
// "Page 1" and the new page become visible. Idempotent.
|
|
27359
27389
|
if (!Array.isArray(workspace.pages) || workspace.pages.length === 0) {
|
|
27360
27390
|
var page = {
|
|
27361
27391
|
id: "page-".concat(workspace.id || Date.now()),
|
|
27362
|
-
name:
|
|
27392
|
+
name: "Page 1",
|
|
27363
27393
|
order: 0,
|
|
27364
|
-
layout: workspace.layout
|
|
27394
|
+
layout: workspace.layout
|
|
27365
27395
|
};
|
|
27366
27396
|
workspace.pages = [page];
|
|
27367
27397
|
workspace.activePageId = page.id;
|
|
@@ -49064,7 +49094,7 @@ var PageTabBar = function PageTabBar(_ref) {
|
|
|
49064
49094
|
};
|
|
49065
49095
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
49066
49096
|
className: "flex flex-row items-center shrink-0 overflow-x-auto gap-1 px-2 py-1.5 border-b ".concat(currentTheme["border-primary-dark"] || "border-gray-700", " ").concat(currentTheme["bg-primary-medium"] || "bg-gray-800/50", " scrollbar-none"),
|
|
49067
|
-
children: [sortedPages.map(function (page) {
|
|
49097
|
+
children: [pages.length > 1 && sortedPages.map(function (page) {
|
|
49068
49098
|
var isActive = page.id === activePageId;
|
|
49069
49099
|
var isDragOver = page.id === dragOverId;
|
|
49070
49100
|
return /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
@@ -49136,7 +49166,7 @@ var PageTabBar = function PageTabBar(_ref) {
|
|
|
49136
49166
|
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
49137
49167
|
children: "Add Page"
|
|
49138
49168
|
})]
|
|
49139
|
-
}), editMode && onScrollableChange && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
49169
|
+
}), editMode && pages.length > 1 && onScrollableChange && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
49140
49170
|
className: "ml-auto flex items-center shrink-0",
|
|
49141
49171
|
children: /*#__PURE__*/jsxRuntime.jsx(DashReact.Toggle, {
|
|
49142
49172
|
text: "Scrollable",
|
|
@@ -51828,7 +51858,18 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51828
51858
|
}, [currentActivePageId, workspacePages, workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.id, workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.name]);
|
|
51829
51859
|
function handleAddPage() {
|
|
51830
51860
|
if (!workspaceSelected) return;
|
|
51831
|
-
|
|
51861
|
+
// Sync existing pages with their live layouts from refs so any
|
|
51862
|
+
// unsaved user edits to the current page are preserved when
|
|
51863
|
+
// adding a new page (especially relevant when going from 1 → 2
|
|
51864
|
+
// pages where the lone page's tab is hidden but its grid is live).
|
|
51865
|
+
var existingPages = workspacePages.map(function (p) {
|
|
51866
|
+
var _pageRef$current;
|
|
51867
|
+
var pageRef = pageRefsMap.current[p.id];
|
|
51868
|
+
var liveLayout = pageRef === null || pageRef === void 0 || (_pageRef$current = pageRef.current) === null || _pageRef$current === void 0 ? void 0 : _pageRef$current.layout;
|
|
51869
|
+
return liveLayout ? _objectSpread$5(_objectSpread$5({}, p), {}, {
|
|
51870
|
+
layout: liveLayout
|
|
51871
|
+
}) : p;
|
|
51872
|
+
});
|
|
51832
51873
|
var newPage = DashboardModel.createPage("Page ".concat(existingPages.length + 1));
|
|
51833
51874
|
newPage.order = existingPages.length;
|
|
51834
51875
|
var updatedWorkspace = _objectSpread$5(_objectSpread$5({}, workspaceSelected), {}, {
|
|
@@ -52061,11 +52102,11 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
52061
52102
|
|
|
52062
52103
|
// Derive scrollable state from the active page's root layout item
|
|
52063
52104
|
function getRootScrollable() {
|
|
52064
|
-
var _pageRef$
|
|
52105
|
+
var _pageRef$current2, _ws$pages;
|
|
52065
52106
|
var ws = currentWorkspaceRef.current || workspaceSelected;
|
|
52066
52107
|
if (!ws) return false;
|
|
52067
52108
|
var pageRef = pageRefsMap.current[currentActivePageId];
|
|
52068
|
-
var layout = (pageRef === null || pageRef === void 0 || (_pageRef$
|
|
52109
|
+
var layout = (pageRef === null || pageRef === void 0 || (_pageRef$current2 = pageRef.current) === null || _pageRef$current2 === void 0 ? void 0 : _pageRef$current2.layout) || ((_ws$pages = ws.pages) === null || _ws$pages === void 0 || (_ws$pages = _ws$pages.find(function (p) {
|
|
52069
52110
|
return p.id === currentActivePageId;
|
|
52070
52111
|
})) === null || _ws$pages === void 0 ? void 0 : _ws$pages.layout);
|
|
52071
52112
|
if (!layout) return false;
|
|
@@ -52082,9 +52123,9 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
52082
52123
|
// Gather latest layout from each page's LayoutBuilder ref
|
|
52083
52124
|
var workspaceToSave = DashReact.deepCopy(workspaceSelected);
|
|
52084
52125
|
workspaceToSave.pages = (workspaceToSave.pages || []).map(function (page) {
|
|
52085
|
-
var _pageRef$
|
|
52126
|
+
var _pageRef$current3;
|
|
52086
52127
|
var pageRef = pageRefsMap.current[page.id];
|
|
52087
|
-
var latestLayout = (pageRef === null || pageRef === void 0 || (_pageRef$
|
|
52128
|
+
var latestLayout = (pageRef === null || pageRef === void 0 || (_pageRef$current3 = pageRef.current) === null || _pageRef$current3 === void 0 ? void 0 : _pageRef$current3.layout) || page.layout || [];
|
|
52088
52129
|
return _objectSpread$5(_objectSpread$5({}, page), {}, {
|
|
52089
52130
|
layout: latestLayout.map(function (item) {
|
|
52090
52131
|
var copy = _objectSpread$5({}, item);
|
|
@@ -52369,7 +52410,9 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
52369
52410
|
onFolderChange: popout ? null : handleWorkspaceFolderChange,
|
|
52370
52411
|
onThemeChange: popout ? null : handleWorkspaceThemeChange,
|
|
52371
52412
|
sidebarEnabled: sidebarEnabled,
|
|
52372
|
-
onSidebarChange: popout ? null : handleSidebarToggle
|
|
52413
|
+
onSidebarChange: popout ? null : handleSidebarToggle,
|
|
52414
|
+
scrollableEnabled: workspacePages.length <= 1 ? getRootScrollable() : undefined,
|
|
52415
|
+
onScrollableChange: workspacePages.length <= 1 && !popout ? handleScrollableChange : null
|
|
52373
52416
|
}), /*#__PURE__*/jsxRuntime.jsxs(DashboardThemeProvider, {
|
|
52374
52417
|
themeKey: workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.themeKey,
|
|
52375
52418
|
children: [hasMissing && missingComponents.length >= 2 && !dismissedMissingForWorkspace.has(workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.id) && /*#__PURE__*/jsxRuntime.jsxs("div", {
|