@marimo-team/islands 0.18.5-dev186 → 0.18.5-dev189

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.
@@ -10946,7 +10946,6 @@ let __tla = (async () => {
10946
10946
  allowedFillDirections: "vertical",
10947
10947
  onKeyDown: Vr,
10948
10948
  height: e.length > 10 ? 450 : void 0,
10949
- width: "100%",
10950
10949
  rowMarkers: {
10951
10950
  kind: "both"
10952
10951
  },
package/dist/main.js CHANGED
@@ -30560,12 +30560,17 @@ ${c.sqlString}
30560
30560
  function isPanelHidden(e) {
30561
30561
  return !!(e.hidden || e.requiredCapability && !hasCapability(e.requiredCapability));
30562
30562
  }
30563
- require_compiler_runtime(), atomWithStorage("marimo:panel-layout", {
30563
+ require_compiler_runtime();
30564
+ const panelLayoutAtom = atomWithStorage("marimo:panel-layout", {
30564
30565
  sidebar: PANELS.filter((e) => !isPanelHidden(e) && e.defaultSection === "sidebar").map((e) => e.type),
30565
30566
  developerPanel: PANELS.filter((e) => !isPanelHidden(e) && e.defaultSection === "developer-panel").map((e) => e.type)
30566
30567
  }, jotaiJsonStorage, {
30567
30568
  getOnInit: true
30568
30569
  });
30570
+ function resolvePanelLocation(e) {
30571
+ let r = store.get(panelLayoutAtom);
30572
+ return r.sidebar.includes(e) ? "sidebar" : r.developerPanel.includes(e) ? "developer-panel" : null;
30573
+ }
30569
30574
  var KEY$4 = "marimo:sidebar", storage$1 = new ZodLocalStorage(object$1({
30570
30575
  selectedPanel: string$2().optional().transform((e) => e),
30571
30576
  isSidebarOpen: boolean$2(),
@@ -30581,16 +30586,30 @@ ${c.sqlString}
30581
30586
  };
30582
30587
  }
30583
30588
  var { reducer: reducer$4, createActions: createActions$3, valueAtom: chromeAtom, useActions: useActions$2 } = createReducerAndAtoms(() => storage$1.get(KEY$4), {
30584
- openApplication: (e, r) => ({
30585
- ...e,
30586
- selectedPanel: r,
30587
- isSidebarOpen: true
30588
- }),
30589
- toggleApplication: (e, r) => ({
30590
- ...e,
30591
- selectedPanel: r,
30592
- isSidebarOpen: e.isSidebarOpen ? e.selectedPanel !== r : true
30593
- }),
30589
+ openApplication: (e, r) => {
30590
+ let c = resolvePanelLocation(r);
30591
+ return c === "sidebar" ? {
30592
+ ...e,
30593
+ selectedPanel: r,
30594
+ isSidebarOpen: true
30595
+ } : c === "developer-panel" ? {
30596
+ ...e,
30597
+ selectedDeveloperPanelTab: r,
30598
+ isDeveloperPanelOpen: true
30599
+ } : e;
30600
+ },
30601
+ toggleApplication: (e, r) => {
30602
+ let c = resolvePanelLocation(r);
30603
+ return c === "sidebar" ? {
30604
+ ...e,
30605
+ selectedPanel: r,
30606
+ isSidebarOpen: e.isSidebarOpen ? e.selectedPanel !== r : true
30607
+ } : c === "developer-panel" ? {
30608
+ ...e,
30609
+ selectedDeveloperPanelTab: r,
30610
+ isDeveloperPanelOpen: e.isDeveloperPanelOpen ? e.selectedDeveloperPanelTab !== r : true
30611
+ } : e;
30612
+ },
30594
30613
  toggleSidebarPanel: (e) => ({
30595
30614
  ...e,
30596
30615
  isSidebarOpen: !e.isSidebarOpen
@@ -30606,15 +30625,6 @@ ${c.sqlString}
30606
30625
  setIsDeveloperPanelOpen: (e, r) => ({
30607
30626
  ...e,
30608
30627
  isDeveloperPanelOpen: r
30609
- }),
30610
- setSelectedDeveloperPanelTab: (e, r) => ({
30611
- ...e,
30612
- selectedDeveloperPanelTab: r
30613
- }),
30614
- openDeveloperPanelTab: (e, r) => ({
30615
- ...e,
30616
- isDeveloperPanelOpen: true,
30617
- selectedDeveloperPanelTab: r
30618
30628
  })
30619
30629
  }, [
30620
30630
  (e, r) => storage$1.set(KEY$4, r)
@@ -51361,7 +51371,7 @@ Database schema: ${c}`), (_a3 = r2.aiFix) == null ? void 0 : _a3.setAiCompletion
51361
51371
  if (r[2] !== v || r[3] !== d || r[4] !== h || r[5] !== f || r[6] !== c || r[7] !== y || r[8] !== _) {
51362
51372
  let e2 = c.filter(_temp7$2), z2 = c.filter(_temp8$1), G2 = c.filter(_temp9$1), q = c.filter(_temp0$1), LY = c.filter(_temp1$1), RY = c.filter(_temp10), zY = c.filter(_temp11), BY = c.filter(_temp12), VY = c.filter(_temp13), HY = c.filter(_temp14), UY = c.filter(_temp15), WY = c.filter(_temp16), GY = c.filter(_temp17), KY;
51363
51373
  r[15] === h ? KY = r[16] : (KY = () => {
51364
- h.openDeveloperPanelTab("scratchpad");
51374
+ h.openApplication("scratchpad");
51365
51375
  }, r[15] = h, r[16] = KY);
51366
51376
  let qY = KY, JY = () => {
51367
51377
  let r2 = [];
@@ -51389,7 +51399,7 @@ Database schema: ${c}`), (_a3 = r2.aiFix) == null ? void 0 : _a3.setAiCompletion
51389
51399
  size: "xs",
51390
51400
  variant: "outline",
51391
51401
  className: "mt-2 font-normal",
51392
- onClick: () => h.openDeveloperPanelTab("terminal"),
51402
+ onClick: () => h.openApplication("terminal"),
51393
51403
  children: [
51394
51404
  (0, import_jsx_runtime.jsx)(Terminal, {
51395
51405
  className: "h-3.5 w-3.5 mr-1.5"
@@ -72002,7 +72012,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
72002
72012
  function getVegaFieldTypes(e) {
72003
72013
  return !e || Object.keys(e).length === 0 ? "auto" : Objects.mapValues(e, (e2) => e2 === "date" || e2 === "time" ? "string" : e2 === "datetime" ? "date" : e2);
72004
72014
  }
72005
- var import_compiler_runtime$84 = require_compiler_runtime(), LazyDataEditor = import_react.lazy(() => import("./glide-data-editor-DWlk0mEY.js").then(async (m2) => {
72015
+ var import_compiler_runtime$84 = require_compiler_runtime(), LazyDataEditor = import_react.lazy(() => import("./glide-data-editor-BO13luOe.js").then(async (m2) => {
72006
72016
  await m2.__tla;
72007
72017
  return m2;
72008
72018
  }));
@@ -101061,7 +101071,7 @@ Defaulting to \`null\`.`;
101061
101071
  return Logger.warn("Failed to get version from mount config"), null;
101062
101072
  }
101063
101073
  }
101064
- const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.18.5-dev186"), showCodeInRunModeAtom = atom(true);
101074
+ const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.18.5-dev189"), showCodeInRunModeAtom = atom(true);
101065
101075
  atom(null);
101066
101076
  var VIRTUAL_FILE_REGEX = /\/@file\/([^\s"&'/]+)\.([\dA-Za-z]+)/g, VirtualFileTracker = class e {
101067
101077
  constructor() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.18.5-dev186",
3
+ "version": "0.18.5-dev189",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -3,10 +3,11 @@
3
3
  import { useAtomValue } from "jotai";
4
4
  import { atomWithStorage } from "jotai/utils";
5
5
  import { z } from "zod";
6
+ import { store } from "@/core/state/jotai";
6
7
  import { createReducerAndAtoms } from "@/utils/createReducer";
7
8
  import { jotaiJsonStorage } from "@/utils/storage/jotai";
8
9
  import { ZodLocalStorage } from "@/utils/storage/typed";
9
- import type { PanelType } from "./types";
10
+ import type { PanelSection, PanelType } from "./types";
10
11
  import { isPanelHidden, PANELS } from "./types";
11
12
 
12
13
  export interface ChromeState {
@@ -41,6 +42,20 @@ export const panelLayoutAtom = atomWithStorage<PanelLayout>(
41
42
  { getOnInit: true },
42
43
  );
43
44
 
45
+ /**
46
+ * Resolve which section a panel belongs to based on current layout.
47
+ */
48
+ function resolvePanelLocation(panelType: PanelType): PanelSection | null {
49
+ const layout = store.get(panelLayoutAtom);
50
+ if (layout.sidebar.includes(panelType)) {
51
+ return "sidebar";
52
+ }
53
+ if (layout.developerPanel.includes(panelType)) {
54
+ return "developer-panel";
55
+ }
56
+ return null;
57
+ }
58
+
44
59
  const KEY = "marimo:sidebar";
45
60
  const storage = new ZodLocalStorage<ChromeState>(
46
61
  z.object({
@@ -76,20 +91,52 @@ const {
76
91
  } = createReducerAndAtoms(
77
92
  () => storage.get(KEY),
78
93
  {
79
- openApplication: (state, selectedPanel: PanelType) => ({
80
- ...state,
81
- selectedPanel,
82
- isSidebarOpen: true,
83
- }),
84
- toggleApplication: (state, selectedPanel: PanelType) => ({
85
- ...state,
86
- selectedPanel,
87
- // If it was closed, open it
88
- // If it was open, keep it open unless it was the same application
89
- isSidebarOpen: state.isSidebarOpen
90
- ? state.selectedPanel !== selectedPanel
91
- : true,
92
- }),
94
+ openApplication: (state, selectedPanel: PanelType) => {
95
+ const location = resolvePanelLocation(selectedPanel);
96
+ if (location === "sidebar") {
97
+ return {
98
+ ...state,
99
+ selectedPanel,
100
+ isSidebarOpen: true,
101
+ };
102
+ }
103
+ if (location === "developer-panel") {
104
+ return {
105
+ ...state,
106
+ selectedDeveloperPanelTab: selectedPanel,
107
+ isDeveloperPanelOpen: true,
108
+ };
109
+ }
110
+ // Panel not found in layout, no-op
111
+ return state;
112
+ },
113
+ toggleApplication: (state, selectedPanel: PanelType) => {
114
+ const location = resolvePanelLocation(selectedPanel);
115
+ if (location === "sidebar") {
116
+ return {
117
+ ...state,
118
+ selectedPanel,
119
+ // If it was closed, open it
120
+ // If it was open, keep it open unless it was the same application
121
+ isSidebarOpen: state.isSidebarOpen
122
+ ? state.selectedPanel !== selectedPanel
123
+ : true,
124
+ };
125
+ }
126
+ if (location === "developer-panel") {
127
+ return {
128
+ ...state,
129
+ selectedDeveloperPanelTab: selectedPanel,
130
+ // If it was closed, open it
131
+ // If it was open, keep it open unless it was the same tab
132
+ isDeveloperPanelOpen: state.isDeveloperPanelOpen
133
+ ? state.selectedDeveloperPanelTab !== selectedPanel
134
+ : true,
135
+ };
136
+ }
137
+ // Panel not found in layout, no-op
138
+ return state;
139
+ },
93
140
  toggleSidebarPanel: (state) => ({
94
141
  ...state,
95
142
  isSidebarOpen: !state.isSidebarOpen,
@@ -106,15 +153,6 @@ const {
106
153
  ...state,
107
154
  isDeveloperPanelOpen: isOpen,
108
155
  }),
109
- setSelectedDeveloperPanelTab: (state, tab: PanelType) => ({
110
- ...state,
111
- selectedDeveloperPanelTab: tab,
112
- }),
113
- openDeveloperPanelTab: (state, tab: PanelType) => ({
114
- ...state,
115
- isDeveloperPanelOpen: true,
116
- selectedDeveloperPanelTab: tab,
117
- }),
118
156
  },
119
157
  [(_prevState, newState) => storage.set(KEY, newState)],
120
158
  );
@@ -75,12 +75,8 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
75
75
  selectedPanel,
76
76
  selectedDeveloperPanelTab,
77
77
  } = useChromeState();
78
- const {
79
- setIsSidebarOpen,
80
- setIsDeveloperPanelOpen,
81
- setSelectedDeveloperPanelTab,
82
- openApplication,
83
- } = useChromeActions();
78
+ const { setIsSidebarOpen, setIsDeveloperPanelOpen, openApplication } =
79
+ useChromeActions();
84
80
  const sidebarRef = React.useRef<ImperativePanelHandle>(null);
85
81
  const developerPanelRef = React.useRef<ImperativePanelHandle>(null);
86
82
  const { aiPanelTab, setAiPanelTab } = useAiPanelTab();
@@ -123,7 +119,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
123
119
  }
124
120
 
125
121
  // Select the dropped item in developer panel
126
- setSelectedDeveloperPanelTab(item.type);
122
+ openApplication(item.type);
127
123
  };
128
124
 
129
125
  // Get panels available for developer panel context menu
@@ -412,7 +408,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
412
408
  ariaLabel="Developer panel tabs"
413
409
  className="flex flex-row gap-1"
414
410
  minItems={0}
415
- onAction={(panel) => setSelectedDeveloperPanelTab(panel.type)}
411
+ onAction={(panel) => openApplication(panel.type)}
416
412
  renderItem={(panel) => (
417
413
  <div
418
414
  className={cn(
@@ -125,7 +125,7 @@ export const BackendConnectionStatus: React.FC = () => {
125
125
  if (isAppNotStarted(connection)) {
126
126
  void connectToRuntime();
127
127
  } else {
128
- void refetch();
128
+ refetch();
129
129
  }
130
130
  };
131
131
 
@@ -23,10 +23,8 @@ import { RuntimeSettings } from "./footer-items/runtime-settings";
23
23
  import { useSetDependencyPanelTab } from "./useDependencyPanelTab";
24
24
 
25
25
  export const Footer: React.FC = () => {
26
- const { isDeveloperPanelOpen, isSidebarOpen, selectedPanel } =
27
- useChromeState();
28
- const { toggleDeveloperPanel, openApplication, setIsSidebarOpen } =
29
- useChromeActions();
26
+ const { isDeveloperPanelOpen } = useChromeState();
27
+ const { toggleDeveloperPanel, toggleApplication } = useChromeActions();
30
28
  const setDependencyPanelTab = useSetDependencyPanelTab();
31
29
 
32
30
  const errorCount = useAtomValue(cellErrorCount);
@@ -42,7 +40,7 @@ export const Footer: React.FC = () => {
42
40
  const warningCount = 0;
43
41
 
44
42
  useHotkey("global.toggleTerminal", () => {
45
- toggleDeveloperPanel();
43
+ toggleApplication("terminal");
46
44
  });
47
45
 
48
46
  useHotkey("global.togglePanel", () => {
@@ -50,14 +48,8 @@ export const Footer: React.FC = () => {
50
48
  });
51
49
 
52
50
  useHotkey("global.toggleMinimap", () => {
53
- // If already on dependencies panel with minimap tab, close the sidebar
54
- if (isSidebarOpen && selectedPanel === "dependencies") {
55
- setIsSidebarOpen(false);
56
- } else {
57
- // Open sidebar with dependencies panel and switch to minimap tab
58
- openApplication("dependencies");
59
- setDependencyPanelTab("minimap");
60
- }
51
+ toggleApplication("dependencies");
52
+ setDependencyPanelTab("minimap");
61
53
  });
62
54
 
63
55
  return (
@@ -20,8 +20,7 @@ import {
20
20
 
21
21
  export const Sidebar: React.FC = () => {
22
22
  const { selectedPanel, selectedDeveloperPanelTab } = useChromeState();
23
- const { toggleApplication, setSelectedDeveloperPanelTab } =
24
- useChromeActions();
23
+ const { toggleApplication, openApplication } = useChromeActions();
25
24
  const [panelLayout, setPanelLayout] = useAtom(panelLayoutAtom);
26
25
 
27
26
  const renderIcon = ({ Icon }: PanelDescriptor, className?: string) => {
@@ -73,7 +72,7 @@ export const Sidebar: React.FC = () => {
73
72
  (id) => id !== item.type,
74
73
  );
75
74
  if (remainingDevPanels.length > 0) {
76
- setSelectedDeveloperPanelTab(remainingDevPanels[0]);
75
+ openApplication(remainingDevPanels[0]);
77
76
  }
78
77
  }
79
78
  }
@@ -142,7 +142,7 @@ export const MarimoErrorOutput = ({
142
142
  );
143
143
 
144
144
  const openScratchpad = () => {
145
- chromeActions.openDeveloperPanelTab("scratchpad");
145
+ chromeActions.openApplication("scratchpad");
146
146
  };
147
147
 
148
148
  const renderMessages = () => {
@@ -186,7 +186,7 @@ export const MarimoErrorOutput = ({
186
186
  size="xs"
187
187
  variant="outline"
188
188
  className="mt-2 font-normal"
189
- onClick={() => chromeActions.openDeveloperPanelTab("terminal")}
189
+ onClick={() => chromeActions.openApplication("terminal")}
190
190
  >
191
191
  <TerminalIcon className="h-3.5 w-3.5 mr-1.5" />
192
192
  <span>Open terminal</span>
@@ -25,11 +25,11 @@ import { useTerminalActions } from "./state";
25
25
  */
26
26
  export function useTerminalCommands() {
27
27
  const { addCommand } = useTerminalActions();
28
- const { openDeveloperPanelTab } = useChromeActions();
28
+ const { openApplication } = useChromeActions();
29
29
 
30
30
  const sendCommand = (text: string) => {
31
31
  // First, ensure the terminal is open
32
- openDeveloperPanelTab("terminal");
32
+ openApplication("terminal");
33
33
 
34
34
  // Add the command to the queue
35
35
  addCommand(text);
@@ -616,7 +616,6 @@ export const GlideDataEditor = <T,>({
616
616
  allowedFillDirections="vertical" // We can support all directions, but we need to handle datatype logic
617
617
  onKeyDown={onKeyDown}
618
618
  height={data.length > 10 ? 450 : undefined}
619
- width={"100%"}
620
619
  rowMarkers={{
621
620
  kind: "both",
622
621
  }}