@trops/dash-core 0.1.333 → 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 +67 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +67 -9
- 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,9 +27376,26 @@ 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;
|
|
27382
|
+
|
|
27383
|
+
// Always-pages model: every workspace must have at least one page.
|
|
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.
|
|
27389
|
+
if (!Array.isArray(workspace.pages) || workspace.pages.length === 0) {
|
|
27390
|
+
var page = {
|
|
27391
|
+
id: "page-".concat(workspace.id || Date.now()),
|
|
27392
|
+
name: "Page 1",
|
|
27393
|
+
order: 0,
|
|
27394
|
+
layout: workspace.layout
|
|
27395
|
+
};
|
|
27396
|
+
workspace.pages = [page];
|
|
27397
|
+
workspace.activePageId = page.id;
|
|
27398
|
+
}
|
|
27354
27399
|
workspace.sidebarEnabled = "sidebarEnabled" in obj ? obj["sidebarEnabled"] : false;
|
|
27355
27400
|
workspace.sidebarLayout = "sidebarLayout" in obj ? obj["sidebarLayout"] : [];
|
|
27356
27401
|
workspace.sidebarWidth = "sidebarWidth" in obj ? obj["sidebarWidth"] : 280;
|
|
@@ -49049,7 +49094,7 @@ var PageTabBar = function PageTabBar(_ref) {
|
|
|
49049
49094
|
};
|
|
49050
49095
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
49051
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"),
|
|
49052
|
-
children: [sortedPages.map(function (page) {
|
|
49097
|
+
children: [pages.length > 1 && sortedPages.map(function (page) {
|
|
49053
49098
|
var isActive = page.id === activePageId;
|
|
49054
49099
|
var isDragOver = page.id === dragOverId;
|
|
49055
49100
|
return /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
@@ -49121,7 +49166,7 @@ var PageTabBar = function PageTabBar(_ref) {
|
|
|
49121
49166
|
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
49122
49167
|
children: "Add Page"
|
|
49123
49168
|
})]
|
|
49124
|
-
}), editMode && onScrollableChange && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
49169
|
+
}), editMode && pages.length > 1 && onScrollableChange && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
49125
49170
|
className: "ml-auto flex items-center shrink-0",
|
|
49126
49171
|
children: /*#__PURE__*/jsxRuntime.jsx(DashReact.Toggle, {
|
|
49127
49172
|
text: "Scrollable",
|
|
@@ -51813,7 +51858,18 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
51813
51858
|
}, [currentActivePageId, workspacePages, workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.id, workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.name]);
|
|
51814
51859
|
function handleAddPage() {
|
|
51815
51860
|
if (!workspaceSelected) return;
|
|
51816
|
-
|
|
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
|
+
});
|
|
51817
51873
|
var newPage = DashboardModel.createPage("Page ".concat(existingPages.length + 1));
|
|
51818
51874
|
newPage.order = existingPages.length;
|
|
51819
51875
|
var updatedWorkspace = _objectSpread$5(_objectSpread$5({}, workspaceSelected), {}, {
|
|
@@ -52046,11 +52102,11 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
52046
52102
|
|
|
52047
52103
|
// Derive scrollable state from the active page's root layout item
|
|
52048
52104
|
function getRootScrollable() {
|
|
52049
|
-
var _pageRef$
|
|
52105
|
+
var _pageRef$current2, _ws$pages;
|
|
52050
52106
|
var ws = currentWorkspaceRef.current || workspaceSelected;
|
|
52051
52107
|
if (!ws) return false;
|
|
52052
52108
|
var pageRef = pageRefsMap.current[currentActivePageId];
|
|
52053
|
-
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) {
|
|
52054
52110
|
return p.id === currentActivePageId;
|
|
52055
52111
|
})) === null || _ws$pages === void 0 ? void 0 : _ws$pages.layout);
|
|
52056
52112
|
if (!layout) return false;
|
|
@@ -52067,9 +52123,9 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
52067
52123
|
// Gather latest layout from each page's LayoutBuilder ref
|
|
52068
52124
|
var workspaceToSave = DashReact.deepCopy(workspaceSelected);
|
|
52069
52125
|
workspaceToSave.pages = (workspaceToSave.pages || []).map(function (page) {
|
|
52070
|
-
var _pageRef$
|
|
52126
|
+
var _pageRef$current3;
|
|
52071
52127
|
var pageRef = pageRefsMap.current[page.id];
|
|
52072
|
-
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 || [];
|
|
52073
52129
|
return _objectSpread$5(_objectSpread$5({}, page), {}, {
|
|
52074
52130
|
layout: latestLayout.map(function (item) {
|
|
52075
52131
|
var copy = _objectSpread$5({}, item);
|
|
@@ -52354,7 +52410,9 @@ var DashboardStageInner = function DashboardStageInner(_ref3) {
|
|
|
52354
52410
|
onFolderChange: popout ? null : handleWorkspaceFolderChange,
|
|
52355
52411
|
onThemeChange: popout ? null : handleWorkspaceThemeChange,
|
|
52356
52412
|
sidebarEnabled: sidebarEnabled,
|
|
52357
|
-
onSidebarChange: popout ? null : handleSidebarToggle
|
|
52413
|
+
onSidebarChange: popout ? null : handleSidebarToggle,
|
|
52414
|
+
scrollableEnabled: workspacePages.length <= 1 ? getRootScrollable() : undefined,
|
|
52415
|
+
onScrollableChange: workspacePages.length <= 1 && !popout ? handleScrollableChange : null
|
|
52358
52416
|
}), /*#__PURE__*/jsxRuntime.jsxs(DashboardThemeProvider, {
|
|
52359
52417
|
themeKey: workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.themeKey,
|
|
52360
52418
|
children: [hasMissing && missingComponents.length >= 2 && !dismissedMissingForWorkspace.has(workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.id) && /*#__PURE__*/jsxRuntime.jsxs("div", {
|