@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.esm.js CHANGED
@@ -30676,7 +30676,11 @@ var DashboardStage = function DashboardStage(_ref) {
30676
30676
  _ref$preview = _ref.preview,
30677
30677
  preview = _ref$preview === void 0 ? true : _ref$preview,
30678
30678
  _ref$backgroundColor = _ref.backgroundColor,
30679
- backgroundColor = _ref$backgroundColor === void 0 ? null : _ref$backgroundColor;
30679
+ backgroundColor = _ref$backgroundColor === void 0 ? null : _ref$backgroundColor,
30680
+ _ref$popout = _ref.popout,
30681
+ popout = _ref$popout === void 0 ? false : _ref$popout,
30682
+ _ref$popoutWorkspaceI = _ref.popoutWorkspaceId,
30683
+ popoutWorkspaceId = _ref$popoutWorkspaceI === void 0 ? null : _ref$popoutWorkspaceI;
30680
30684
  return /*#__PURE__*/jsx(Profiler, {
30681
30685
  id: "myapp",
30682
30686
  onRender: function onRender() {},
@@ -30689,7 +30693,9 @@ var DashboardStage = function DashboardStage(_ref) {
30689
30693
  credentials: credentials,
30690
30694
  workspace: workspace,
30691
30695
  preview: preview,
30692
- backgroundColor: backgroundColor
30696
+ backgroundColor: backgroundColor,
30697
+ popout: popout,
30698
+ popoutWorkspaceId: popoutWorkspaceId
30693
30699
  })
30694
30700
  })
30695
30701
  });
@@ -30703,6 +30709,10 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
30703
30709
  _ref2$preview = _ref2.preview,
30704
30710
  preview = _ref2$preview === void 0 ? true : _ref2$preview;
30705
30711
  _ref2.backgroundColor;
30712
+ var _ref2$popout = _ref2.popout,
30713
+ popout = _ref2$popout === void 0 ? false : _ref2$popout,
30714
+ _ref2$popoutWorkspace = _ref2.popoutWorkspaceId,
30715
+ popoutWorkspaceId = _ref2$popoutWorkspace === void 0 ? null : _ref2$popoutWorkspace;
30706
30716
  var _useContext = useContext(DashboardContext),
30707
30717
  pub = _useContext.pub;
30708
30718
  var appContext = useContext(AppContext);
@@ -30817,6 +30827,41 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
30817
30827
  // eslint-disable-next-line react-hooks/exhaustive-deps
30818
30828
  }, [workspace]);
30819
30829
 
30830
+ // ─── Popout: auto-load workspace by ID ──────────────────────────
30831
+ useEffect(function () {
30832
+ if (!popout || popoutWorkspaceId === null) return;
30833
+ if (workspaceConfig.length === 0) return;
30834
+ var target = workspaceConfig.find(function (ws) {
30835
+ return ws.id === popoutWorkspaceId;
30836
+ });
30837
+ if (target) {
30838
+ var _window$mainApi;
30839
+ handleOpenTab(target);
30840
+ if ((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && (_window$mainApi = _window$mainApi.popout) !== null && _window$mainApi !== void 0 && _window$mainApi.setTitle) {
30841
+ window.mainApi.popout.setTitle(popoutWorkspaceId, target.name || "Untitled");
30842
+ }
30843
+ }
30844
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30845
+ }, [popout, popoutWorkspaceId, workspaceConfig]);
30846
+
30847
+ // ─── Popout: listen for workspace:saved broadcasts ─────────────
30848
+ useEffect(function () {
30849
+ var _window$mainApi2;
30850
+ if (!popout) return;
30851
+ if (!((_window$mainApi2 = window.mainApi) !== null && _window$mainApi2 !== void 0 && _window$mainApi2.on)) return;
30852
+ var handler = function handler() {
30853
+ loadWorkspaces();
30854
+ };
30855
+ window.mainApi.on("workspace:saved", handler);
30856
+ return function () {
30857
+ var _window$mainApi3;
30858
+ if ((_window$mainApi3 = window.mainApi) !== null && _window$mainApi3 !== void 0 && _window$mainApi3.removeListener) {
30859
+ window.mainApi.removeListener("workspace:saved", handler);
30860
+ }
30861
+ };
30862
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30863
+ }, [popout]);
30864
+
30820
30865
  // ─── Tab Handlers ─────────────────────────────────────────────────
30821
30866
 
30822
30867
  function handleOpenTab(workspaceItem) {
@@ -30825,7 +30870,15 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
30825
30870
  return tab.id === workspaceItem.id;
30826
30871
  });
30827
30872
  if (existingTab) {
30828
- // Tab already open just switch to it
30873
+ // Sync fresh workspace data to existing tab
30874
+ setOpenTabs(function (prev) {
30875
+ return prev.map(function (tab) {
30876
+ return tab.id === existingTab.id ? _objectSpread(_objectSpread({}, tab), {}, {
30877
+ name: workspaceItem.name || "Untitled",
30878
+ workspace: workspaceItem
30879
+ }) : tab;
30880
+ });
30881
+ });
30829
30882
  setActiveTabId(existingTab.id);
30830
30883
  } else {
30831
30884
  // Open new tab
@@ -31192,6 +31245,12 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
31192
31245
  function handleToggleThemeVariant() {
31193
31246
  changeThemeVariant(themeVariant === "dark" ? "light" : "dark");
31194
31247
  }
31248
+ function handlePopout() {
31249
+ var _window$mainApi4;
31250
+ if (workspaceSelected && (_window$mainApi4 = window.mainApi) !== null && _window$mainApi4 !== void 0 && (_window$mainApi4 = _window$mainApi4.popout) !== null && _window$mainApi4 !== void 0 && _window$mainApi4.open) {
31251
+ window.mainApi.popout.open(workspaceSelected.id);
31252
+ }
31253
+ }
31195
31254
  return /*#__PURE__*/jsxs(LayoutContainer, {
31196
31255
  padding: false,
31197
31256
  space: false,
@@ -31204,7 +31263,7 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
31204
31263
  backend: HTML5Backend,
31205
31264
  children: [/*#__PURE__*/jsxs("div", {
31206
31265
  className: "flex flex-row flex-1 overflow-hidden",
31207
- children: [/*#__PURE__*/jsx(DashSidebar, {
31266
+ children: [!popout && /*#__PURE__*/jsx(DashSidebar, {
31208
31267
  collapsed: sidebarCollapsed,
31209
31268
  onCollapsedChange: setSidebarCollapsed,
31210
31269
  workspaces: workspaceConfig,
@@ -31235,23 +31294,24 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
31235
31294
  children: workspaceSelected !== null ? /*#__PURE__*/jsxs(Fragment, {
31236
31295
  children: [/*#__PURE__*/jsx(DashboardHeader, {
31237
31296
  workspace: workspaceSelected,
31238
- preview: previewMode,
31297
+ preview: popout ? true : previewMode,
31239
31298
  onNameChange: handleWorkspaceNameChange,
31240
- onClickEdit: handleToggleEditMode,
31241
- onSaveChanges: handleClickSaveWorkspace,
31299
+ onClickEdit: popout ? null : handleToggleEditMode,
31300
+ onPopout: popout ? null : handlePopout,
31301
+ onSaveChanges: popout ? null : handleClickSaveWorkspace,
31242
31302
  menuItems: menuItems,
31243
31303
  themes: themes || {},
31244
- onFolderChange: handleWorkspaceFolderChange,
31245
- onThemeChange: handleWorkspaceThemeChange,
31304
+ onFolderChange: popout ? null : handleWorkspaceFolderChange,
31305
+ onThemeChange: popout ? null : handleWorkspaceThemeChange,
31246
31306
  scrollableEnabled: getRootScrollable(),
31247
- onScrollableChange: handleScrollableChange
31307
+ onScrollableChange: popout ? null : handleScrollableChange
31248
31308
  }), /*#__PURE__*/jsx(DashboardThemeProvider, {
31249
31309
  themeKey: workspaceSelected === null || workspaceSelected === void 0 ? void 0 : workspaceSelected.themeKey,
31250
31310
  children: /*#__PURE__*/jsx("div", {
31251
- className: "flex flex-col w-full flex-1 ".concat(previewMode === true ? "overflow-y-auto" : "overflow-clip"),
31311
+ className: "flex flex-col w-full flex-1 ".concat(popout || previewMode === true ? "overflow-y-auto" : "overflow-clip"),
31252
31312
  children: renderComponent(workspaceSelected)
31253
31313
  })
31254
- }), /*#__PURE__*/jsx(DashTabBar, {
31314
+ }), !popout && /*#__PURE__*/jsx(DashTabBar, {
31255
31315
  tabs: openTabs,
31256
31316
  activeTabId: activeTabId,
31257
31317
  onSwitchTab: handleSwitchTab,
@@ -31264,9 +31324,9 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
31264
31324
  icon: "clone",
31265
31325
  className: "h-12 w-12"
31266
31326
  }),
31267
- title: "No dashboards open",
31268
- description: "Press \u2318K to search dashboards, or create a new one.",
31269
- children: /*#__PURE__*/jsxs("div", {
31327
+ title: popout ? "Dashboard not found" : "No dashboards open",
31328
+ description: popout ? "The requested dashboard could not be loaded." : "Press \u2318K to search dashboards, or create a new one.",
31329
+ children: !popout && /*#__PURE__*/jsxs("div", {
31270
31330
  className: "flex flex-row gap-2",
31271
31331
  children: [/*#__PURE__*/jsx(ButtonIcon, {
31272
31332
  icon: "magnifying-glass",
@@ -31284,51 +31344,53 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
31284
31344
  })
31285
31345
  })
31286
31346
  })
31287
- }), !previewMode && workspaceSelected && /*#__PURE__*/jsx(WidgetSidebar, {
31347
+ }), !popout && !previewMode && workspaceSelected && /*#__PURE__*/jsx(WidgetSidebar, {
31288
31348
  collapsed: widgetSidebarCollapsed,
31289
31349
  onCollapsedChange: setWidgetSidebarCollapsed
31290
31350
  })]
31291
- }), /*#__PURE__*/jsx(AppSettingsModal, {
31292
- isOpen: isAppSettingsOpen,
31293
- setIsOpen: setIsAppSettingsOpen,
31294
- initialSection: appSettingsInitialSection,
31295
- workspaces: workspaceConfig,
31296
- menuItems: menuItems,
31297
- dashApi: dashApi,
31298
- credentials: credentials,
31299
- onReloadWorkspaces: loadWorkspaces,
31300
- onReloadMenuItems: loadMenuItems,
31301
- onOpenThemeEditor: function onOpenThemeEditor() {
31302
- setIsAppSettingsOpen(false);
31303
- setIsThemeManagerOpen(true);
31304
- }
31305
- }), /*#__PURE__*/jsx(ThemeManagerModal, {
31306
- open: isThemeManagerOpen,
31307
- setIsOpen: function setIsOpen() {
31308
- return setIsThemeManagerOpen(!isThemeManagerOpen);
31309
- },
31310
- onSave: function onSave(themeKey) {
31311
- changeCurrentTheme(themeKey);
31312
- setIsThemeManagerOpen(function () {
31313
- return false;
31314
- });
31315
- }
31316
- }), /*#__PURE__*/jsx(DashboardLoaderModal, {
31317
- open: isDashboardLoaderOpen,
31318
- setIsOpen: setIsDashboardLoaderOpen,
31319
- workspaces: workspaceConfig,
31320
- onSelecDashboard: handleSelectLoadDashboard,
31321
- onClose: function onClose() {
31322
- return handleCloseDashboardLoader();
31323
- }
31324
- }), /*#__PURE__*/jsx(LayoutManagerModal, {
31325
- open: isLayoutPickerOpen,
31326
- setIsOpen: setIsLayoutPickerOpen,
31327
- onCreateWorkspace: handleCreateFromTemplate,
31328
- menuItems: menuItems,
31329
- onSaveMenuItem: handleSaveNewMenuItem
31351
+ }), !popout && /*#__PURE__*/jsxs(Fragment, {
31352
+ children: [/*#__PURE__*/jsx(AppSettingsModal, {
31353
+ isOpen: isAppSettingsOpen,
31354
+ setIsOpen: setIsAppSettingsOpen,
31355
+ initialSection: appSettingsInitialSection,
31356
+ workspaces: workspaceConfig,
31357
+ menuItems: menuItems,
31358
+ dashApi: dashApi,
31359
+ credentials: credentials,
31360
+ onReloadWorkspaces: loadWorkspaces,
31361
+ onReloadMenuItems: loadMenuItems,
31362
+ onOpenThemeEditor: function onOpenThemeEditor() {
31363
+ setIsAppSettingsOpen(false);
31364
+ setIsThemeManagerOpen(true);
31365
+ }
31366
+ }), /*#__PURE__*/jsx(ThemeManagerModal, {
31367
+ open: isThemeManagerOpen,
31368
+ setIsOpen: function setIsOpen() {
31369
+ return setIsThemeManagerOpen(!isThemeManagerOpen);
31370
+ },
31371
+ onSave: function onSave(themeKey) {
31372
+ changeCurrentTheme(themeKey);
31373
+ setIsThemeManagerOpen(function () {
31374
+ return false;
31375
+ });
31376
+ }
31377
+ }), /*#__PURE__*/jsx(DashboardLoaderModal, {
31378
+ open: isDashboardLoaderOpen,
31379
+ setIsOpen: setIsDashboardLoaderOpen,
31380
+ workspaces: workspaceConfig,
31381
+ onSelecDashboard: handleSelectLoadDashboard,
31382
+ onClose: function onClose() {
31383
+ return handleCloseDashboardLoader();
31384
+ }
31385
+ }), /*#__PURE__*/jsx(LayoutManagerModal, {
31386
+ open: isLayoutPickerOpen,
31387
+ setIsOpen: setIsLayoutPickerOpen,
31388
+ onCreateWorkspace: handleCreateFromTemplate,
31389
+ menuItems: menuItems,
31390
+ onSaveMenuItem: handleSaveNewMenuItem
31391
+ })]
31330
31392
  })]
31331
- }), /*#__PURE__*/jsx(DashCommandPalette, {
31393
+ }), !popout && /*#__PURE__*/jsx(DashCommandPalette, {
31332
31394
  isOpen: isCommandPaletteOpen,
31333
31395
  setIsOpen: setIsCommandPaletteOpen,
31334
31396
  workspaces: workspaceConfig,
@@ -31461,6 +31523,8 @@ var DashboardHeader = function DashboardHeader(_ref) {
31461
31523
  preview = _ref.preview,
31462
31524
  _ref$onClickEdit = _ref.onClickEdit,
31463
31525
  onClickEdit = _ref$onClickEdit === void 0 ? null : _ref$onClickEdit,
31526
+ _ref$onPopout = _ref.onPopout,
31527
+ onPopout = _ref$onPopout === void 0 ? null : _ref$onPopout,
31464
31528
  onNameChange = _ref.onNameChange,
31465
31529
  _ref$onSaveChanges = _ref.onSaveChanges,
31466
31530
  onSaveChanges = _ref$onSaveChanges === void 0 ? null : _ref$onSaveChanges,
@@ -31500,10 +31564,17 @@ var DashboardHeader = function DashboardHeader(_ref) {
31500
31564
  }),
31501
31565
  padding: false,
31502
31566
  className: "font-bold text-base"
31503
- }), onClickEdit !== null && /*#__PURE__*/jsx(ButtonIcon, {
31504
- icon: "pencil",
31505
- onClick: onClickEdit,
31506
- hoverBackgroundColor: "hover:bg-indigo-700"
31567
+ }), /*#__PURE__*/jsxs("div", {
31568
+ className: "flex flex-row items-center gap-1",
31569
+ children: [onPopout !== null && /*#__PURE__*/jsx(ButtonIcon, {
31570
+ icon: "arrow-up-right-from-square",
31571
+ onClick: onPopout,
31572
+ hoverBackgroundColor: "hover:bg-indigo-700"
31573
+ }), onClickEdit !== null && /*#__PURE__*/jsx(ButtonIcon, {
31574
+ icon: "pencil",
31575
+ onClick: onClickEdit,
31576
+ hoverBackgroundColor: "hover:bg-indigo-700"
31577
+ })]
31507
31578
  })]
31508
31579
  }) : /*#__PURE__*/jsxs(Fragment, {
31509
31580
  children: [/*#__PURE__*/jsxs("div", {