@marimo-team/islands 0.24.1-dev41 → 0.24.1-dev43

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.
Files changed (33) hide show
  1. package/dist/{ConnectedDataExplorerComponent-4UvlnITc.js → ConnectedDataExplorerComponent-CxLgYj_n.js} +1038 -1038
  2. package/dist/{any-language-editor-ClDhQoll.js → any-language-editor-BrPYtXHK.js} +1 -1
  3. package/dist/{chat-ui-BzZL5_XE.js → chat-ui-Mjq3lBLn.js} +1335 -1335
  4. package/dist/{common-DVtMyyCC.js → common-IoLWZR0C.js} +20955 -20975
  5. package/dist/{input-CIaA2N0m.js → dropdown-menu-DEu759Oe.js} +930 -927
  6. package/dist/{error-banner-BbxpEiD5.js → error-banner-BT4uIIQ2.js} +190 -192
  7. package/dist/{glide-data-editor-CgO5z9xu.js → glide-data-editor-C2RTkAgQ.js} +51 -51
  8. package/dist/{html-to-image-DPAZGZSi.js → html-to-image-hKcfSWj_.js} +5795 -5590
  9. package/dist/main.js +8696 -8703
  10. package/dist/{mermaid-BBTUHwCi.js → mermaid-OsTxhZOI.js} +12 -12
  11. package/dist/{process-output-oZcxC_tq.js → process-output-BkHK-KDc.js} +6 -6
  12. package/dist/{reveal-component-BHpu6-qW.js → reveal-component-DUBiSLUI.js} +11 -11
  13. package/dist/{strings-CoQ5sA4r.js → select-Bakm9EUs.js} +50 -53
  14. package/dist/{spec-6c0_fLYz.js → spec-DqUrBQpS.js} +2 -2
  15. package/dist/style.css +1 -1
  16. package/dist/{useDateFormatter-6ImHK1ln.js → useDateFormatter-DjRKOAkR.js} +1 -1
  17. package/dist/{vega-component-DlnGFDeY.js → vega-component-A2xO4BUa.js} +17 -17
  18. package/package.json +1 -1
  19. package/src/components/chat/acp/agent-panel.tsx +4 -6
  20. package/src/components/data-table/columns.tsx +130 -132
  21. package/src/components/datasources/datasources.tsx +16 -17
  22. package/src/components/editor/actions/useNotebookActions.tsx +50 -0
  23. package/src/components/editor/chrome/panels/components.tsx +1 -1
  24. package/src/components/editor/connections/__tests__/add-connection-button.test.tsx +129 -0
  25. package/src/components/editor/connections/add-connection-button.tsx +132 -0
  26. package/src/components/editor/connections/components.tsx +11 -0
  27. package/src/components/editor/connections/quick-add-data-sources.tsx +11 -11
  28. package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +109 -1
  29. package/src/components/storage/storage-inspector.tsx +15 -17
  30. package/src/core/codemirror/language/panel/sql.test.tsx +69 -0
  31. package/src/core/codemirror/language/panel/sql.tsx +81 -4
  32. package/src/core/codemirror/markdown/commands.ts +1 -1
  33. package/src/core/codemirror/markdown/completions.ts +15 -17
@@ -10,10 +10,12 @@ import {
10
10
  CircleHelpIcon,
11
11
  DatabaseZap,
12
12
  SearchCheck,
13
+ SparklesIcon,
13
14
  } from "lucide-react";
14
15
  import { getCellForDomProps } from "@/components/data-table/cell-utils";
15
16
  import { transformDisplayName } from "@/components/databases/display";
16
17
  import { DatabaseLogo } from "@/components/databases/icon";
18
+ import { useAddDetectedDataSource } from "@/components/editor/connections/components";
17
19
  import { Button } from "@/components/ui/button";
18
20
  import {
19
21
  Select,
@@ -31,11 +33,13 @@ import {
31
33
  dataConnectionsMapAtom,
32
34
  setLatestEngineSelected,
33
35
  } from "@/core/datasets/data-source-connections";
36
+ import type { DetectedDataSource } from "@/core/datasets/data-source-discovery";
34
37
  import {
35
38
  type ConnectionName,
36
39
  INTERNAL_SQL_ENGINES,
37
40
  } from "@/core/datasets/engines";
38
41
  import type { DataSourceConnection } from "@/core/kernel/messages";
42
+ import { useDetectedDataSources } from "@/hooks/useDataSourceDiscovery";
39
43
  import { useNonce } from "@/hooks/useNonce";
40
44
  import { clearAllSqlValidationErrors } from "../languages/sql/banner-validation-errors";
41
45
  import { type SQLMode, useSQLMode } from "../languages/sql/sql-mode";
@@ -46,19 +50,61 @@ interface SelectProps {
46
50
  cellId: CellId;
47
51
  }
48
52
 
49
- export const SQLEngineSelect: React.FC<SelectProps> = ({
53
+ export const SQLEngineSelect: React.FC<SelectProps> = (props) => {
54
+ const detectedDataSources = useDetectedDataSources("database");
55
+
56
+ if (detectedDataSources.length === 0) {
57
+ return (
58
+ <SQLEngineSelectImpl
59
+ {...props}
60
+ detectedDataSources={detectedDataSources}
61
+ />
62
+ );
63
+ }
64
+
65
+ return (
66
+ <SQLEngineSelectWithDetectedSources
67
+ {...props}
68
+ detectedDataSources={detectedDataSources}
69
+ />
70
+ );
71
+ };
72
+
73
+ const SQLEngineSelectWithDetectedSources: React.FC<
74
+ SelectProps & { detectedDataSources: DetectedDataSource[] }
75
+ > = ({ detectedDataSources, ...props }) => {
76
+ const addDetectedDataSource = useAddDetectedDataSource();
77
+ return (
78
+ <SQLEngineSelectImpl
79
+ {...props}
80
+ detectedDataSources={detectedDataSources}
81
+ addDetectedDataSource={addDetectedDataSource}
82
+ />
83
+ );
84
+ };
85
+
86
+ const SQLEngineSelectImpl: React.FC<
87
+ SelectProps & {
88
+ detectedDataSources: DetectedDataSource[];
89
+ addDetectedDataSource?: (source: DetectedDataSource) => void;
90
+ }
91
+ > = ({
50
92
  selectedEngine,
51
93
  onChange,
52
94
  cellId,
95
+ detectedDataSources,
96
+ addDetectedDataSource,
53
97
  }) => {
54
98
  const connectionsMap = useAtomValue(dataConnectionsMapAtom);
55
99
 
56
100
  const internalEngineConnections: DataSourceConnection[] = [];
57
101
  const userDefinedConnections: DataSourceConnection[] = [];
58
102
  for (const [connName, connection] of connectionsMap.entries()) {
59
- INTERNAL_SQL_ENGINES.has(connName)
60
- ? internalEngineConnections.push(connection)
61
- : userDefinedConnections.push(connection);
103
+ if (INTERNAL_SQL_ENGINES.has(connName)) {
104
+ internalEngineConnections.push(connection);
105
+ } else {
106
+ userDefinedConnections.push(connection);
107
+ }
62
108
  }
63
109
 
64
110
  // Use nonce to force re-render as languageAdapter.engine may not trigger change
@@ -74,6 +120,17 @@ export const SQLEngineSelect: React.FC<SelectProps> = ({
74
120
  return;
75
121
  }
76
122
 
123
+ if (value.startsWith(DETECTED_SOURCE_PREFIX)) {
124
+ const sourceId = value.slice(DETECTED_SOURCE_PREFIX.length);
125
+ const source = detectedDataSources.find(
126
+ (source) => source.id === sourceId,
127
+ );
128
+ if (source && addDetectedDataSource) {
129
+ addDetectedDataSource(source);
130
+ }
131
+ return;
132
+ }
133
+
77
134
  const nextEngine = connectionsMap.get(value as ConnectionName);
78
135
  if (nextEngine) {
79
136
  rerender();
@@ -125,6 +182,25 @@ export const SQLEngineSelect: React.FC<SelectProps> = ({
125
182
  {renderConnections(userDefinedConnections)}
126
183
  {userDefinedConnections.length > 0 && <SelectSeparator />}
127
184
  {renderConnections(internalEngineConnections)}
185
+ {detectedDataSources.length > 0 && (
186
+ <>
187
+ <SelectSeparator />
188
+ <SelectLabel>Detected in your environment</SelectLabel>
189
+ {detectedDataSources.map((source) => (
190
+ <SelectItem
191
+ key={source.id}
192
+ value={`${DETECTED_SOURCE_PREFIX}${source.id}`}
193
+ >
194
+ <div className="flex items-center gap-1">
195
+ <SparklesIcon className="h-3 w-3 text-(--blue-9)" />
196
+ <span className="truncate ml-0.5">
197
+ Add {source.displayName} connection
198
+ </span>
199
+ </div>
200
+ </SelectItem>
201
+ ))}
202
+ </>
203
+ )}
128
204
  <SelectSeparator />
129
205
  <SelectItem className="text-muted-foreground" value={HELP_KEY}>
130
206
  <a
@@ -145,6 +221,7 @@ export const SQLEngineSelect: React.FC<SelectProps> = ({
145
221
  };
146
222
 
147
223
  const HELP_KEY = "__help__";
224
+ const DETECTED_SOURCE_PREFIX = "__detected_source__:";
148
225
  const HELP_URL =
149
226
  "http://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database";
150
227
 
@@ -41,7 +41,7 @@ function toggleAllLines({
41
41
  }
42
42
  }
43
43
 
44
- for (let pos = selection.from; pos <= selection.to; ) {
44
+ for (let pos = selection.from; pos <= selection.to;) {
45
45
  const line = view.state.doc.lineAt(pos);
46
46
  const lineText = line.text;
47
47
 
@@ -94,23 +94,21 @@ const getLucideIconList = once(async (): Promise<Completion[]> => {
94
94
  return `https://cdn.jsdelivr.net/npm/lucide-static@0.452.0/icons/${iconName}.svg`;
95
95
  };
96
96
 
97
- return Object.entries(iconList).map(
98
- ([iconName, aliases]): Completion => ({
99
- label: `::${iconName}`,
100
- displayLabel: iconName,
101
- type: "lucide-icon",
102
- boost: 10,
103
- apply: `::lucide:${iconName}::`,
104
- detail: aliases.join(", "),
105
- info: () => {
106
- const img = document.createElement("img");
107
- img.src = asSvg(iconName);
108
- img.style.width = "24px";
109
- img.style.height = "24px";
110
- return img;
111
- },
112
- }),
113
- );
97
+ return Object.entries(iconList).map(([iconName, aliases]): Completion => ({
98
+ label: `::${iconName}`,
99
+ displayLabel: iconName,
100
+ type: "lucide-icon",
101
+ boost: 10,
102
+ apply: `::lucide:${iconName}::`,
103
+ detail: aliases.join(", "),
104
+ info: () => {
105
+ const img = document.createElement("img");
106
+ img.src = asSvg(iconName);
107
+ img.style.width = "24px";
108
+ img.style.height = "24px";
109
+ return img;
110
+ },
111
+ }));
114
112
  });
115
113
 
116
114
  // Completion provider for LaTeX-style UTF-8 symbols