@trops/dash-core 0.1.36 → 0.1.38

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.js CHANGED
@@ -30695,7 +30695,11 @@ var DashboardStage = function DashboardStage(_ref) {
30695
30695
  _ref$preview = _ref.preview,
30696
30696
  preview = _ref$preview === void 0 ? true : _ref$preview,
30697
30697
  _ref$backgroundColor = _ref.backgroundColor,
30698
- backgroundColor = _ref$backgroundColor === void 0 ? null : _ref$backgroundColor;
30698
+ backgroundColor = _ref$backgroundColor === void 0 ? null : _ref$backgroundColor,
30699
+ _ref$popout = _ref.popout,
30700
+ popout = _ref$popout === void 0 ? false : _ref$popout,
30701
+ _ref$popoutWorkspaceI = _ref.popoutWorkspaceId,
30702
+ popoutWorkspaceId = _ref$popoutWorkspaceI === void 0 ? null : _ref$popoutWorkspaceI;
30699
30703
  return /*#__PURE__*/jsxRuntime.jsx(React.Profiler, {
30700
30704
  id: "myapp",
30701
30705
  onRender: function onRender() {},
@@ -30708,7 +30712,9 @@ var DashboardStage = function DashboardStage(_ref) {
30708
30712
  credentials: credentials,
30709
30713
  workspace: workspace,
30710
30714
  preview: preview,
30711
- backgroundColor: backgroundColor
30715
+ backgroundColor: backgroundColor,
30716
+ popout: popout,
30717
+ popoutWorkspaceId: popoutWorkspaceId
30712
30718
  })
30713
30719
  })
30714
30720
  });
@@ -30722,6 +30728,10 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
30722
30728
  _ref2$preview = _ref2.preview,
30723
30729
  preview = _ref2$preview === void 0 ? true : _ref2$preview;
30724
30730
  _ref2.backgroundColor;
30731
+ var _ref2$popout = _ref2.popout,
30732
+ popout = _ref2$popout === void 0 ? false : _ref2$popout,
30733
+ _ref2$popoutWorkspace = _ref2.popoutWorkspaceId,
30734
+ popoutWorkspaceId = _ref2$popoutWorkspace === void 0 ? null : _ref2$popoutWorkspace;
30725
30735
  var _useContext = React.useContext(DashboardContext),
30726
30736
  pub = _useContext.pub;
30727
30737
  var appContext = React.useContext(AppContext);
@@ -30836,6 +30846,41 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
30836
30846
  // eslint-disable-next-line react-hooks/exhaustive-deps
30837
30847
  }, [workspace]);
30838
30848
 
30849
+ // ─── Popout: auto-load workspace by ID ──────────────────────────
30850
+ React.useEffect(function () {
30851
+ if (!popout || popoutWorkspaceId === null) return;
30852
+ if (workspaceConfig.length === 0) return;
30853
+ var target = workspaceConfig.find(function (ws) {
30854
+ return ws.id === popoutWorkspaceId;
30855
+ });
30856
+ if (target) {
30857
+ var _window$mainApi;
30858
+ handleOpenTab(target);
30859
+ if ((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && (_window$mainApi = _window$mainApi.popout) !== null && _window$mainApi !== void 0 && _window$mainApi.setTitle) {
30860
+ window.mainApi.popout.setTitle(popoutWorkspaceId, target.name || "Untitled");
30861
+ }
30862
+ }
30863
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30864
+ }, [popout, popoutWorkspaceId, workspaceConfig]);
30865
+
30866
+ // ─── Popout: listen for workspace:saved broadcasts ─────────────
30867
+ React.useEffect(function () {
30868
+ var _window$mainApi2;
30869
+ if (!popout) return;
30870
+ if (!((_window$mainApi2 = window.mainApi) !== null && _window$mainApi2 !== void 0 && _window$mainApi2.on)) return;
30871
+ var handler = function handler() {
30872
+ loadWorkspaces();
30873
+ };
30874
+ window.mainApi.on("workspace:saved", handler);
30875
+ return function () {
30876
+ var _window$mainApi3;
30877
+ if ((_window$mainApi3 = window.mainApi) !== null && _window$mainApi3 !== void 0 && _window$mainApi3.removeListener) {
30878
+ window.mainApi.removeListener("workspace:saved", handler);
30879
+ }
30880
+ };
30881
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30882
+ }, [popout]);
30883
+
30839
30884
  // ─── Tab Handlers ─────────────────────────────────────────────────
30840
30885
 
30841
30886
  function handleOpenTab(workspaceItem) {
@@ -30844,7 +30889,15 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
30844
30889
  return tab.id === workspaceItem.id;
30845
30890
  });
30846
30891
  if (existingTab) {
30847
- // Tab already open just switch to it
30892
+ // Sync fresh workspace data to existing tab
30893
+ setOpenTabs(function (prev) {
30894
+ return prev.map(function (tab) {
30895
+ return tab.id === existingTab.id ? _objectSpread(_objectSpread({}, tab), {}, {
30896
+ name: workspaceItem.name || "Untitled",
30897
+ workspace: workspaceItem
30898
+ }) : tab;
30899
+ });
30900
+ });
30848
30901
  setActiveTabId(existingTab.id);
30849
30902
  } else {
30850
30903
  // Open new tab
@@ -31211,6 +31264,12 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
31211
31264
  function handleToggleThemeVariant() {
31212
31265
  changeThemeVariant(themeVariant === "dark" ? "light" : "dark");
31213
31266
  }
31267
+ function handlePopout() {
31268
+ var _window$mainApi4;
31269
+ if (workspaceSelected && (_window$mainApi4 = window.mainApi) !== null && _window$mainApi4 !== void 0 && (_window$mainApi4 = _window$mainApi4.popout) !== null && _window$mainApi4 !== void 0 && _window$mainApi4.open) {
31270
+ window.mainApi.popout.open(workspaceSelected.id);
31271
+ }
31272
+ }
31214
31273
  return /*#__PURE__*/jsxRuntime.jsxs(LayoutContainer, {
31215
31274
  padding: false,
31216
31275
  space: false,
@@ -31223,7 +31282,7 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
31223
31282
  backend: reactDndHtml5Backend.HTML5Backend,
31224
31283
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
31225
31284
  className: "flex flex-row flex-1 overflow-hidden",
31226
- children: [/*#__PURE__*/jsxRuntime.jsx(DashSidebar, {
31285
+ children: [!popout && /*#__PURE__*/jsxRuntime.jsx(DashSidebar, {
31227
31286
  collapsed: sidebarCollapsed,
31228
31287
  onCollapsedChange: setSidebarCollapsed,
31229
31288
  workspaces: workspaceConfig,
@@ -31254,23 +31313,24 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
31254
31313
  children: workspaceSelected !== null ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
31255
31314
  children: [/*#__PURE__*/jsxRuntime.jsx(DashboardHeader, {
31256
31315
  workspace: workspaceSelected,
31257
- preview: previewMode,
31316
+ preview: popout ? true : previewMode,
31258
31317
  onNameChange: handleWorkspaceNameChange,
31259
- onClickEdit: handleToggleEditMode,
31260
- onSaveChanges: handleClickSaveWorkspace,
31318
+ onClickEdit: popout ? null : handleToggleEditMode,
31319
+ onPopout: popout ? null : handlePopout,
31320
+ onSaveChanges: popout ? null : handleClickSaveWorkspace,
31261
31321
  menuItems: menuItems,
31262
31322
  themes: themes || {},
31263
- onFolderChange: handleWorkspaceFolderChange,
31264
- onThemeChange: handleWorkspaceThemeChange,
31323
+ onFolderChange: popout ? null : handleWorkspaceFolderChange,
31324
+ onThemeChange: popout ? null : handleWorkspaceThemeChange,
31265
31325
  scrollableEnabled: getRootScrollable(),
31266
- onScrollableChange: handleScrollableChange
31326
+ onScrollableChange: popout ? null : handleScrollableChange
31267
31327
  }), /*#__PURE__*/jsxRuntime.jsx(DashboardThemeProvider, {
31268
31328
  themeKey: workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.themeKey,
31269
31329
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
31270
- className: "flex flex-col w-full flex-1 ".concat(previewMode === true ? "overflow-y-auto" : "overflow-clip"),
31330
+ className: "flex flex-col w-full flex-1 ".concat(popout || previewMode === true ? "overflow-y-auto" : "overflow-clip"),
31271
31331
  children: renderComponent(workspaceSelected)
31272
31332
  })
31273
- }), /*#__PURE__*/jsxRuntime.jsx(DashTabBar, {
31333
+ }), !popout && /*#__PURE__*/jsxRuntime.jsx(DashTabBar, {
31274
31334
  tabs: openTabs,
31275
31335
  activeTabId: activeTabId,
31276
31336
  onSwitchTab: handleSwitchTab,
@@ -31283,9 +31343,9 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
31283
31343
  icon: "clone",
31284
31344
  className: "h-12 w-12"
31285
31345
  }),
31286
- title: "No dashboards open",
31287
- description: "Press \u2318K to search dashboards, or create a new one.",
31288
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
31346
+ title: popout ? "Dashboard not found" : "No dashboards open",
31347
+ description: popout ? "The requested dashboard could not be loaded." : "Press \u2318K to search dashboards, or create a new one.",
31348
+ children: !popout && /*#__PURE__*/jsxRuntime.jsxs("div", {
31289
31349
  className: "flex flex-row gap-2",
31290
31350
  children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.ButtonIcon, {
31291
31351
  icon: "magnifying-glass",
@@ -31303,51 +31363,53 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
31303
31363
  })
31304
31364
  })
31305
31365
  })
31306
- }), !previewMode && workspaceSelected && /*#__PURE__*/jsxRuntime.jsx(WidgetSidebar, {
31366
+ }), !popout && !previewMode && workspaceSelected && /*#__PURE__*/jsxRuntime.jsx(WidgetSidebar, {
31307
31367
  collapsed: widgetSidebarCollapsed,
31308
31368
  onCollapsedChange: setWidgetSidebarCollapsed
31309
31369
  })]
31310
- }), /*#__PURE__*/jsxRuntime.jsx(AppSettingsModal, {
31311
- isOpen: isAppSettingsOpen,
31312
- setIsOpen: setIsAppSettingsOpen,
31313
- initialSection: appSettingsInitialSection,
31314
- workspaces: workspaceConfig,
31315
- menuItems: menuItems,
31316
- dashApi: dashApi,
31317
- credentials: credentials,
31318
- onReloadWorkspaces: loadWorkspaces,
31319
- onReloadMenuItems: loadMenuItems,
31320
- onOpenThemeEditor: function onOpenThemeEditor() {
31321
- setIsAppSettingsOpen(false);
31322
- setIsThemeManagerOpen(true);
31323
- }
31324
- }), /*#__PURE__*/jsxRuntime.jsx(ThemeManagerModal, {
31325
- open: isThemeManagerOpen,
31326
- setIsOpen: function setIsOpen() {
31327
- return setIsThemeManagerOpen(!isThemeManagerOpen);
31328
- },
31329
- onSave: function onSave(themeKey) {
31330
- changeCurrentTheme(themeKey);
31331
- setIsThemeManagerOpen(function () {
31332
- return false;
31333
- });
31334
- }
31335
- }), /*#__PURE__*/jsxRuntime.jsx(DashboardLoaderModal, {
31336
- open: isDashboardLoaderOpen,
31337
- setIsOpen: setIsDashboardLoaderOpen,
31338
- workspaces: workspaceConfig,
31339
- onSelecDashboard: handleSelectLoadDashboard,
31340
- onClose: function onClose() {
31341
- return handleCloseDashboardLoader();
31342
- }
31343
- }), /*#__PURE__*/jsxRuntime.jsx(LayoutManagerModal, {
31344
- open: isLayoutPickerOpen,
31345
- setIsOpen: setIsLayoutPickerOpen,
31346
- onCreateWorkspace: handleCreateFromTemplate,
31347
- menuItems: menuItems,
31348
- onSaveMenuItem: handleSaveNewMenuItem
31370
+ }), !popout && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
31371
+ children: [/*#__PURE__*/jsxRuntime.jsx(AppSettingsModal, {
31372
+ isOpen: isAppSettingsOpen,
31373
+ setIsOpen: setIsAppSettingsOpen,
31374
+ initialSection: appSettingsInitialSection,
31375
+ workspaces: workspaceConfig,
31376
+ menuItems: menuItems,
31377
+ dashApi: dashApi,
31378
+ credentials: credentials,
31379
+ onReloadWorkspaces: loadWorkspaces,
31380
+ onReloadMenuItems: loadMenuItems,
31381
+ onOpenThemeEditor: function onOpenThemeEditor() {
31382
+ setIsAppSettingsOpen(false);
31383
+ setIsThemeManagerOpen(true);
31384
+ }
31385
+ }), /*#__PURE__*/jsxRuntime.jsx(ThemeManagerModal, {
31386
+ open: isThemeManagerOpen,
31387
+ setIsOpen: function setIsOpen() {
31388
+ return setIsThemeManagerOpen(!isThemeManagerOpen);
31389
+ },
31390
+ onSave: function onSave(themeKey) {
31391
+ changeCurrentTheme(themeKey);
31392
+ setIsThemeManagerOpen(function () {
31393
+ return false;
31394
+ });
31395
+ }
31396
+ }), /*#__PURE__*/jsxRuntime.jsx(DashboardLoaderModal, {
31397
+ open: isDashboardLoaderOpen,
31398
+ setIsOpen: setIsDashboardLoaderOpen,
31399
+ workspaces: workspaceConfig,
31400
+ onSelecDashboard: handleSelectLoadDashboard,
31401
+ onClose: function onClose() {
31402
+ return handleCloseDashboardLoader();
31403
+ }
31404
+ }), /*#__PURE__*/jsxRuntime.jsx(LayoutManagerModal, {
31405
+ open: isLayoutPickerOpen,
31406
+ setIsOpen: setIsLayoutPickerOpen,
31407
+ onCreateWorkspace: handleCreateFromTemplate,
31408
+ menuItems: menuItems,
31409
+ onSaveMenuItem: handleSaveNewMenuItem
31410
+ })]
31349
31411
  })]
31350
- }), /*#__PURE__*/jsxRuntime.jsx(DashCommandPalette, {
31412
+ }), !popout && /*#__PURE__*/jsxRuntime.jsx(DashCommandPalette, {
31351
31413
  isOpen: isCommandPaletteOpen,
31352
31414
  setIsOpen: setIsCommandPaletteOpen,
31353
31415
  workspaces: workspaceConfig,
@@ -31480,6 +31542,8 @@ var DashboardHeader = function DashboardHeader(_ref) {
31480
31542
  preview = _ref.preview,
31481
31543
  _ref$onClickEdit = _ref.onClickEdit,
31482
31544
  onClickEdit = _ref$onClickEdit === void 0 ? null : _ref$onClickEdit,
31545
+ _ref$onPopout = _ref.onPopout,
31546
+ onPopout = _ref$onPopout === void 0 ? null : _ref$onPopout,
31483
31547
  onNameChange = _ref.onNameChange,
31484
31548
  _ref$onSaveChanges = _ref.onSaveChanges,
31485
31549
  onSaveChanges = _ref$onSaveChanges === void 0 ? null : _ref$onSaveChanges,
@@ -31519,10 +31583,17 @@ var DashboardHeader = function DashboardHeader(_ref) {
31519
31583
  }),
31520
31584
  padding: false,
31521
31585
  className: "font-bold text-base"
31522
- }), onClickEdit !== null && /*#__PURE__*/jsxRuntime.jsx(DashReact.ButtonIcon, {
31523
- icon: "pencil",
31524
- onClick: onClickEdit,
31525
- hoverBackgroundColor: "hover:bg-indigo-700"
31586
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
31587
+ className: "flex flex-row items-center gap-1",
31588
+ children: [onPopout !== null && /*#__PURE__*/jsxRuntime.jsx(DashReact.ButtonIcon, {
31589
+ icon: "arrow-up-right-from-square",
31590
+ onClick: onPopout,
31591
+ hoverBackgroundColor: "hover:bg-indigo-700"
31592
+ }), onClickEdit !== null && /*#__PURE__*/jsxRuntime.jsx(DashReact.ButtonIcon, {
31593
+ icon: "pencil",
31594
+ onClick: onClickEdit,
31595
+ hoverBackgroundColor: "hover:bg-indigo-700"
31596
+ })]
31526
31597
  })]
31527
31598
  }) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
31528
31599
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {