@marimo-team/islands 0.23.10-dev3 → 0.23.10-dev30
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/{ConnectedDataExplorerComponent-CyV83R2m.js → ConnectedDataExplorerComponent-DmBropAy.js} +31 -31
- package/dist/{ErrorBoundary-rULOrC_p.js → ErrorBoundary-DpbaKVv7.js} +1 -1
- package/dist/{any-language-editor-DfdpyDv_.js → any-language-editor-DNmoSiWL.js} +20 -20
- package/dist/assets/__vite-browser-external-eshhtsgZ.js +1 -0
- package/dist/assets/worker-CC0Oul9k.js +73 -0
- package/dist/{chat-ui-C1tL1pML.js → chat-ui-D6oraHT2.js} +76 -76
- package/dist/{check-DTbrK0zt.js → check-BCaJeT-J.js} +1 -1
- package/dist/{code-visibility-DfnO0DcH.js → code-visibility-wR7WSQ4c.js} +2166 -1292
- package/dist/{copy-BuQpJEzp.js → copy-UqRYxiOg.js} +33 -33
- package/dist/dist-7QfXoMdB.js +5 -0
- package/dist/{dist-DgnE8F-r.js → dist-A2846XWO.js} +1 -1
- package/dist/dist-BEXXyZig.js +5 -0
- package/dist/{dist-B3pZ0Ab6.js → dist-BR_gyG9L.js} +3 -3
- package/dist/{dist-CcXxepx6.js → dist-BSAt6RhH.js} +27 -27
- package/dist/{dist-Bde4a2kU.js → dist-BY018Paw.js} +8 -8
- package/dist/dist-BYj57OV4.js +5 -0
- package/dist/{dist-CUCNs1ja.js → dist-BaoDKvdy.js} +2 -2
- package/dist/{dist-Cy1WxgBD.js → dist-Bf7SHuNp.js} +5 -5
- package/dist/{dist-Bz_sYWbr.js → dist-Bk75fBZA.js} +2 -2
- package/dist/dist-BlSvQzNr.js +5 -0
- package/dist/{dist-C5VC_yzu.js → dist-BzEzfugY.js} +1 -1
- package/dist/dist-CCBlxAgS.js +8 -0
- package/dist/dist-CIDTVIUf.js +5 -0
- package/dist/{dist-CLUtPrdy.js → dist-CIYBwstr.js} +1 -1
- package/dist/{dist-BotSqB48.js → dist-C_Y3oV3C.js} +12 -12
- package/dist/{dist-BTfv03uy.js → dist-CcWX6tmx.js} +2 -2
- package/dist/{dist-BhM8gdSO.js → dist-CoXAujgg.js} +4 -4
- package/dist/{dist-4j4c7bjm.js → dist-CpxNdDkw.js} +3 -3
- package/dist/dist-CqQyhAM8.js +8 -0
- package/dist/dist-CwRu2Xzh.js +5 -0
- package/dist/{dist-BcuoonNH.js → dist-CxJDU6Bh.js} +9 -9
- package/dist/{dist-DxvORzUR.js → dist-D-W5ny5a.js} +8 -8
- package/dist/dist-D8CDTVgf.js +6 -0
- package/dist/dist-D8DNB0nO.js +8 -0
- package/dist/dist-DL6N_q-A.js +5 -0
- package/dist/{dist-BbbIBDiQ.js → dist-DMjWuVs8.js} +1 -1
- package/dist/dist-DOFbNV_b.js +8 -0
- package/dist/dist-DPrYzMY0.js +6 -0
- package/dist/{dist-h2c8sZvT.js → dist-DZORgqKY.js} +1 -1
- package/dist/{dist-B3P2fFpz.js → dist-DZo4nSS0.js} +14 -14
- package/dist/{dist-D4CewLk6.js → dist-Dax--nl9.js} +1 -1
- package/dist/{dist-DRfcqpxJ.js → dist-DgGbNavJ.js} +2 -2
- package/dist/{dist-C1BYNeCR.js → dist-Dk6PV_d3.js} +10 -10
- package/dist/{dist-fQ0ViXGs.js → dist-Dv_Y15yk.js} +107 -107
- package/dist/{dist-Bfwsv11D.js → dist-DyyjKEYf.js} +2 -2
- package/dist/{dist-p2qyWijU.js → dist-GZXUmt0b.js} +2 -2
- package/dist/{dist-CLJWPTX2.js → dist-LTU8Hdvn.js} +3 -3
- package/dist/{dist-DqAWR3CS.js → dist-M9Vag9Y0.js} +20 -20
- package/dist/{dist-DNdhYsgW.js → dist-U4F-tbMs.js} +79 -62
- package/dist/{dist-RqXTaiir.js → dist-abid3KgM.js} +11 -11
- package/dist/dist-cdmMjgsn.js +5 -0
- package/dist/dist-hT4QzYX-.js +1247 -0
- package/dist/{dist-luvabDEB.js → dist-t9Kf7xqC.js} +2 -2
- package/dist/{error-banner-5bz0L9hS.js → error-banner-Cc0I3C9e.js} +1 -1
- package/dist/esm-BaH2eg5-.js +1171 -0
- package/dist/{esm-Duie8iU-.js → esm-ga2Bf3O2.js} +43 -43
- package/dist/{extends-BgdxCfYu.js → extends-D_hDsj6R.js} +4 -4
- package/dist/{formats-DHxc-FdY.js → formats-C4wO47tk.js} +1 -1
- package/dist/{glide-data-editor-BOmK9ETQ.js → glide-data-editor-Qhu8oCX-.js} +12 -12
- package/dist/{html-to-image-CNa5ok96.js → html-to-image-UEH5lFDZ.js} +2318 -2275
- package/dist/{input-_2sjvfne.js → input-CMYy4hzj.js} +187 -185
- package/dist/{label-LWtdw5i8.js → label-CC4ytI1X.js} +1 -1
- package/dist/main.js +6941 -6913
- package/dist/{mermaid-lXOw5Py9.js → mermaid-zuLgJ8J8.js} +4 -4
- package/dist/{process-output-DKr4f1di.js → process-output-CyMLTogj.js} +3 -3
- package/dist/{reveal-component-UdMnCK5U.js → reveal-component-BjnkUAZ9.js} +697 -619
- package/dist/{spec-B96zNUEA.js → spec-X7FwLJni.js} +4 -4
- package/dist/{strings-Bu3vlb6W.js → strings-J57tzLr3.js} +47 -46
- package/dist/style.css +1 -1
- package/dist/{toDate-x-WRDCH7.js → toDate-d8RCRrRd.js} +2 -2
- package/dist/{tooltip-C5FYOpQc.js → tooltip-DpcyNkQ2.js} +2 -2
- package/dist/{types-CVvp1fKr.js → types-ChtMFmZ2.js} +1 -1
- package/dist/{useAsyncData-iRgKDT5s.js → useAsyncData-PonK__yh.js} +1 -1
- package/dist/{useDateFormatter-BA4FCquG.js → useDateFormatter-QB-3MpYr.js} +2 -2
- package/dist/{useDeepCompareMemoize-CkQ57VS2.js → useDeepCompareMemoize-D3NGWke6.js} +1 -1
- package/dist/{useLifecycle-BBO9PIph.js → useLifecycle-00mO3OSS.js} +2 -2
- package/dist/{useTheme-DHIrRQOe.js → useTheme-DEhDzATN.js} +1 -1
- package/dist/{vega-component-Dq-SH463.js → vega-component-9h1ACS78.js} +8 -8
- package/dist/{zod-CoBiJ5v4.js → zod-aLSua2NL.js} +24 -23
- package/package.json +3 -3
- package/src/components/data-table/TableBottomBar.tsx +1 -15
- package/src/components/data-table/TableTopBar.tsx +8 -13
- package/src/components/data-table/__tests__/TableBottomBar.test.tsx +6 -12
- package/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx +227 -0
- package/src/components/data-table/__tests__/data-table.test.tsx +154 -12
- package/src/components/data-table/column-visibility-dropdown.tsx +204 -0
- package/src/components/data-table/data-table.tsx +1 -1
- package/src/components/data-table/filter-by-values-picker.tsx +39 -17
- package/src/components/data-table/filter-pills.tsx +1 -1
- package/src/components/data-table/hover-tooltip/__tests__/content.test.ts +60 -0
- package/src/components/data-table/hover-tooltip/content.ts +44 -0
- package/src/components/data-table/hover-tooltip/hover-tooltip.tsx +55 -0
- package/src/components/data-table/hover-tooltip/use-table-hover-tooltip.ts +159 -0
- package/src/components/data-table/renderers.tsx +27 -43
- package/src/components/datasources/__tests__/filter-empty.test.ts +183 -0
- package/src/components/datasources/datasources.tsx +92 -3
- package/src/components/editor/cell/cell-context-menu.tsx +15 -2
- package/src/components/editor/cell/code/language-toggle.tsx +7 -1
- package/src/components/editor/chrome/wrapper/app-chrome.tsx +97 -52
- package/src/components/editor/chrome/wrapper/lazy-panels.ts +91 -0
- package/src/components/editor/chrome/wrapper/sidebar.tsx +2 -0
- package/src/components/editor/documentation.css +35 -0
- package/src/components/editor/file-tree/file-explorer.tsx +8 -18
- package/src/components/editor/file-tree/tree-actions.tsx +46 -1
- package/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts +20 -0
- package/src/components/editor/renderers/slides-layout/types.ts +1 -0
- package/src/components/slides/__tests__/minimap-actions.test.tsx +166 -0
- package/src/components/slides/__tests__/reveal-component.test.ts +425 -0
- package/src/components/slides/minimap.tsx +127 -10
- package/src/components/slides/reveal-component.tsx +287 -61
- package/src/components/slides/slide-cell-view.tsx +26 -2
- package/src/components/slides/slide-form.tsx +26 -4
- package/src/components/storage/__tests__/storage-inspector.test.ts +53 -0
- package/src/components/storage/storage-inspector.tsx +68 -48
- package/src/components/ui/__tests__/use-toast.test.ts +75 -0
- package/src/components/ui/combobox.tsx +51 -32
- package/src/components/ui/reorderable-list.tsx +13 -0
- package/src/components/ui/select-core/__tests__/use-select-list.test.ts +294 -0
- package/src/components/ui/select-core/__tests__/utils.test.ts +222 -0
- package/src/components/ui/select-core/index.ts +16 -0
- package/src/components/ui/select-core/option-row.tsx +33 -0
- package/src/components/ui/select-core/render-slot.ts +20 -0
- package/src/components/ui/select-core/select-list.tsx +248 -0
- package/src/components/ui/select-core/types.ts +44 -0
- package/src/components/ui/select-core/use-select-list.ts +347 -0
- package/src/components/ui/select-core/utils.ts +121 -0
- package/src/components/ui/use-toast.ts +33 -13
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +0 -28
- package/src/core/cells/__tests__/cell.test.ts +29 -2
- package/src/core/cells/cell.ts +5 -1
- package/src/core/codemirror/go-to-definition/commands.ts +4 -3
- package/src/core/codemirror/language/languages/python.ts +2 -0
- package/src/core/codemirror/language/languages/sql/utils.ts +3 -1
- package/src/core/codemirror/lsp/__tests__/markdown-renderer.test.ts +41 -0
- package/src/core/codemirror/lsp/markdown-renderer.ts +59 -0
- package/src/core/datasets/data-source-connections.ts +2 -0
- package/src/core/network/__tests__/requests-static.test.ts +30 -0
- package/src/core/network/requests-static.ts +14 -10
- package/src/core/wasm/worker/bootstrap.ts +12 -4
- package/src/plugins/impl/MultiselectPlugin.tsx +19 -142
- package/src/plugins/impl/SearchableSelect.tsx +16 -97
- package/src/plugins/impl/__tests__/DropdownPlugin.test.tsx +5 -2
- package/src/plugins/impl/__tests__/MultiSelectPlugin.test.ts +1 -1
- package/src/plugins/layout/DownloadPlugin.tsx +1 -1
- package/src/utils/lazy.ts +6 -1
- package/dist/assets/__vite-browser-external-Ci2ZQfXU.js +0 -1
- package/dist/assets/worker-ip3AI_sN.js +0 -73
- package/dist/dist-0Fif7jnk.js +0 -5
- package/dist/dist-B5h_9sHB.js +0 -6
- package/dist/dist-B9M6R5ye.js +0 -5
- package/dist/dist-BCt3tnck.js +0 -8
- package/dist/dist-BUIJwMwn.js +0 -8
- package/dist/dist-BpquMd3k.js +0 -5
- package/dist/dist-BzJsqYfz.js +0 -5
- package/dist/dist-CA5ELXAf.js +0 -6
- package/dist/dist-CLBRs6Uv.js +0 -5
- package/dist/dist-CStVCMbq.js +0 -5
- package/dist/dist-CZRIEY3Y.js +0 -8
- package/dist/dist-CuUHbFD0.js +0 -5
- package/dist/dist-DV7Iabxb.js +0 -8
- package/dist/dist-DhHh0jLg.js +0 -1247
- package/dist/dist-DuEeHMvL.js +0 -5
- package/dist/esm-BfhQmZjp.js +0 -1171
- package/src/plugins/impl/multiselectFilterFn.tsx +0 -22
- /package/src/components/{data-table → ui}/value-chips.tsx +0 -0
|
@@ -3,6 +3,18 @@ import { toast } from "@/components/ui/use-toast";
|
|
|
3
3
|
import { Logger } from "@/utils/Logger";
|
|
4
4
|
import type { EditRequests, RunRequests } from "./types";
|
|
5
5
|
|
|
6
|
+
const STATIC_NOTEBOOK_TOAST_ID = "static-notebook";
|
|
7
|
+
|
|
8
|
+
function showStaticNotebookToast() {
|
|
9
|
+
toast({
|
|
10
|
+
id: STATIC_NOTEBOOK_TOAST_ID,
|
|
11
|
+
once: true,
|
|
12
|
+
title: "Static notebook",
|
|
13
|
+
description:
|
|
14
|
+
"This notebook is not connected to a kernel. Any interactive elements will not work.",
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
export function createStaticRequests(): EditRequests & RunRequests {
|
|
7
19
|
const throwNotInEditMode = () => {
|
|
8
20
|
throw new Error("Unreachable. Expected to be in run mode");
|
|
@@ -10,11 +22,7 @@ export function createStaticRequests(): EditRequests & RunRequests {
|
|
|
10
22
|
|
|
11
23
|
return {
|
|
12
24
|
sendComponentValues: async () => {
|
|
13
|
-
|
|
14
|
-
title: "Static notebook",
|
|
15
|
-
description:
|
|
16
|
-
"This notebook is not connected to a kernel. Any interactive elements will not work.",
|
|
17
|
-
});
|
|
25
|
+
showStaticNotebookToast();
|
|
18
26
|
Logger.log("Updating UI elements is not supported in static mode");
|
|
19
27
|
return null;
|
|
20
28
|
},
|
|
@@ -27,11 +35,7 @@ export function createStaticRequests(): EditRequests & RunRequests {
|
|
|
27
35
|
return null;
|
|
28
36
|
},
|
|
29
37
|
sendFunctionRequest: async () => {
|
|
30
|
-
|
|
31
|
-
title: "Static notebook",
|
|
32
|
-
description:
|
|
33
|
-
"This notebook is not connected to a kernel. Any interactive elements will not work.",
|
|
34
|
-
});
|
|
38
|
+
showStaticNotebookToast();
|
|
35
39
|
Logger.log("Function requests are not supported in static mode");
|
|
36
40
|
return null;
|
|
37
41
|
},
|
|
@@ -55,6 +55,10 @@ export class DefaultWasmController implements WasmController {
|
|
|
55
55
|
// Load pyodide and packages
|
|
56
56
|
const span = t.startSpan("loadPyodide");
|
|
57
57
|
try {
|
|
58
|
+
// Without this, this fails in Firefox with
|
|
59
|
+
// `Could not extract indexURL path from pyodide module`
|
|
60
|
+
// This fixes for Firefox and does not break Chrome/others
|
|
61
|
+
const indexURL = `https://cdn.jsdelivr.net/pyodide/${opts.pyodideVersion}/full/`;
|
|
58
62
|
const pyodide = await loadPyodide({
|
|
59
63
|
// Perf: These get loaded while pyodide is being bootstrapped
|
|
60
64
|
packages: [
|
|
@@ -68,10 +72,14 @@ export class DefaultWasmController implements WasmController {
|
|
|
68
72
|
],
|
|
69
73
|
_makeSnapshot: MAKE_SNAPSHOT,
|
|
70
74
|
lockFileURL: `https://wasm.marimo.app/pyodide-lock.json?v=${opts.version}&pyodide=${opts.pyodideVersion}`,
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
+
indexURL,
|
|
76
|
+
// Since Pyodide 0.28.0, when lockFileURL is set, the package base URL
|
|
77
|
+
// defaults to the lockfile's URL (wasm.marimo.app) instead of indexURL.
|
|
78
|
+
// Unlike Node, browsers get no CDN fallback on a failed fetch, so we
|
|
79
|
+
// should pin packageBaseUrl back to the jsDelivr CDN to restore
|
|
80
|
+
// the resolution akin to pre-0.28.
|
|
81
|
+
packageBaseUrl: indexURL,
|
|
82
|
+
convertNullToNone: true,
|
|
75
83
|
});
|
|
76
84
|
this.pyodide = pyodide;
|
|
77
85
|
span.end("ok");
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
import { type JSX, useId, useMemo
|
|
3
|
-
import { Virtuoso } from "react-virtuoso";
|
|
2
|
+
import { type JSX, useId, useMemo } from "react";
|
|
4
3
|
import { z } from "zod";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { CommandSeparator } from "../../components/ui/command";
|
|
4
|
+
import type { Option } from "@/components/ui/select-core";
|
|
5
|
+
import { SelectList } from "@/components/ui/select-core";
|
|
8
6
|
import type { IPlugin, IPluginProps, Setter } from "../types";
|
|
9
7
|
import { Labeled } from "./common/labeled";
|
|
10
|
-
import { multiselectFilterFn } from "./multiselectFilterFn";
|
|
11
8
|
|
|
12
9
|
interface Data {
|
|
13
10
|
label: string | null;
|
|
@@ -55,9 +52,6 @@ interface MultiselectProps extends Data {
|
|
|
55
52
|
setValue: Setter<T>;
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
const SELECT_ALL_KEY = "__select_all__";
|
|
59
|
-
const DESELECT_ALL_KEY = "__deselect_all__";
|
|
60
|
-
|
|
61
55
|
export const Multiselect = ({
|
|
62
56
|
options,
|
|
63
57
|
label,
|
|
@@ -68,144 +62,27 @@ export const Multiselect = ({
|
|
|
68
62
|
disabled,
|
|
69
63
|
}: MultiselectProps): JSX.Element => {
|
|
70
64
|
const id = useId();
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return options;
|
|
76
|
-
}
|
|
77
|
-
return options.filter(
|
|
78
|
-
(option) => multiselectFilterFn(option, searchQuery) === 1,
|
|
79
|
-
);
|
|
80
|
-
}, [options, searchQuery]);
|
|
81
|
-
|
|
82
|
-
const handleValueChange = (newValues: string[] | null) => {
|
|
83
|
-
if (!newValues || newValues.length === 0) {
|
|
84
|
-
setValue([]);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Remove select all and deselect all from the new values
|
|
89
|
-
newValues = newValues.filter(
|
|
90
|
-
(value) => value !== SELECT_ALL_KEY && value !== DESELECT_ALL_KEY,
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
if (maxSelections === 1) {
|
|
94
|
-
// For single selection, just take the last selected value
|
|
95
|
-
setValue([newValues[newValues.length - 1]]);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (maxSelections != null && newValues.length > maxSelections) {
|
|
100
|
-
// When over max selections, remove oldest selections
|
|
101
|
-
newValues = newValues.slice(-maxSelections);
|
|
102
|
-
}
|
|
103
|
-
setValue(newValues);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const handleSelectAll = () => {
|
|
107
|
-
setValue(options);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const handleDeselectAll = () => {
|
|
111
|
-
setValue([]);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const extraOptions: React.ReactNode[] = [];
|
|
115
|
-
const selectAllEnabled = options.length > 0 && value.length < options.length;
|
|
116
|
-
const deselectAllEnabled = options.length > 0 && value.length > 0;
|
|
117
|
-
|
|
118
|
-
// Only show when more than 2 options
|
|
119
|
-
// Only show select all when maxSelections is not set
|
|
120
|
-
if (options.length > 2 && maxSelections == null) {
|
|
121
|
-
extraOptions.push(
|
|
122
|
-
<ComboboxItem
|
|
123
|
-
key={SELECT_ALL_KEY}
|
|
124
|
-
value={SELECT_ALL_KEY}
|
|
125
|
-
onSelect={handleSelectAll}
|
|
126
|
-
disabled={!selectAllEnabled}
|
|
127
|
-
>
|
|
128
|
-
Select all
|
|
129
|
-
</ComboboxItem>,
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (options.length > 2) {
|
|
134
|
-
extraOptions.push(
|
|
135
|
-
<ComboboxItem
|
|
136
|
-
key={DESELECT_ALL_KEY}
|
|
137
|
-
value={DESELECT_ALL_KEY}
|
|
138
|
-
onSelect={handleDeselectAll}
|
|
139
|
-
disabled={!deselectAllEnabled}
|
|
140
|
-
>
|
|
141
|
-
{maxSelections === 1 ? "Deselect" : "Deselect all"}
|
|
142
|
-
</ComboboxItem>,
|
|
143
|
-
<CommandSeparator key="_separator" />,
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const renderList = () => {
|
|
148
|
-
// List virtualization
|
|
149
|
-
if (filteredOptions.length > 200) {
|
|
150
|
-
return (
|
|
151
|
-
<Virtuoso
|
|
152
|
-
style={{ height: "200px" }}
|
|
153
|
-
totalCount={filteredOptions.length}
|
|
154
|
-
overscan={50}
|
|
155
|
-
itemContent={(i: number) => {
|
|
156
|
-
const comboboxItem = (
|
|
157
|
-
<ComboboxItem key={filteredOptions[i]} value={filteredOptions[i]}>
|
|
158
|
-
{filteredOptions[i]}
|
|
159
|
-
</ComboboxItem>
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
if (i === 0) {
|
|
163
|
-
return (
|
|
164
|
-
<>
|
|
165
|
-
{extraOptions}
|
|
166
|
-
{comboboxItem}
|
|
167
|
-
</>
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return comboboxItem;
|
|
172
|
-
}}
|
|
173
|
-
/>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const list = filteredOptions.map((option) => (
|
|
178
|
-
<ComboboxItem key={option} value={option}>
|
|
179
|
-
{option}
|
|
180
|
-
</ComboboxItem>
|
|
181
|
-
));
|
|
182
|
-
|
|
183
|
-
return (
|
|
184
|
-
<>
|
|
185
|
-
{extraOptions}
|
|
186
|
-
{list}
|
|
187
|
-
</>
|
|
188
|
-
);
|
|
189
|
-
};
|
|
65
|
+
const items = useMemo<Array<Option<string>>>(
|
|
66
|
+
() => options.map((option) => ({ value: option, label: option })),
|
|
67
|
+
[options],
|
|
68
|
+
);
|
|
190
69
|
|
|
191
70
|
return (
|
|
192
71
|
<Labeled label={label} id={id} fullWidth={fullWidth}>
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
multiple={true}
|
|
197
|
-
className={cn({
|
|
198
|
-
"w-full": fullWidth,
|
|
199
|
-
})}
|
|
72
|
+
<SelectList<string>
|
|
73
|
+
id={id}
|
|
74
|
+
options={items}
|
|
200
75
|
value={value}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
76
|
+
onChange={(next: string[] | string | null) =>
|
|
77
|
+
setValue((next as string[] | null) ?? [])
|
|
78
|
+
}
|
|
79
|
+
multiple={true}
|
|
80
|
+
maxSelections={maxSelections}
|
|
81
|
+
pinSelected={true}
|
|
82
|
+
compactChipTrigger={true}
|
|
83
|
+
fullWidth={fullWidth}
|
|
205
84
|
disabled={disabled}
|
|
206
|
-
|
|
207
|
-
{renderList()}
|
|
208
|
-
</Combobox>
|
|
85
|
+
/>
|
|
209
86
|
</Labeled>
|
|
210
87
|
);
|
|
211
88
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
import { type JSX, useId, useMemo
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { type JSX, useId, useMemo } from "react";
|
|
3
|
+
import type { Option } from "@/components/ui/select-core";
|
|
4
|
+
import { SelectList } from "@/components/ui/select-core";
|
|
5
5
|
import { cn } from "../../utils/cn";
|
|
6
6
|
import { Labeled } from "./common/labeled";
|
|
7
|
-
import { multiselectFilterFn } from "./multiselectFilterFn";
|
|
8
7
|
|
|
9
8
|
interface SearchableSelectProps {
|
|
10
9
|
options: string[];
|
|
@@ -16,8 +15,6 @@ interface SearchableSelectProps {
|
|
|
16
15
|
disabled: boolean;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
const NONE_KEY = "__none__";
|
|
20
|
-
|
|
21
18
|
export const SearchableSelect = (props: SearchableSelectProps): JSX.Element => {
|
|
22
19
|
const {
|
|
23
20
|
options,
|
|
@@ -29,104 +26,26 @@ export const SearchableSelect = (props: SearchableSelectProps): JSX.Element => {
|
|
|
29
26
|
disabled,
|
|
30
27
|
} = props;
|
|
31
28
|
const id = useId();
|
|
32
|
-
const [searchQuery, setSearchQuery] = useState<string>("");
|
|
33
|
-
|
|
34
|
-
const filteredOptions = useMemo(() => {
|
|
35
|
-
if (!searchQuery) {
|
|
36
|
-
return options;
|
|
37
|
-
}
|
|
38
|
-
return options.filter(
|
|
39
|
-
(option) => multiselectFilterFn(option, searchQuery) === 1,
|
|
40
|
-
);
|
|
41
|
-
}, [options, searchQuery]);
|
|
42
|
-
|
|
43
|
-
const handleValueChange = (newValue: string | null) => {
|
|
44
|
-
if (newValue == null) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (newValue === NONE_KEY) {
|
|
49
|
-
setValue(null);
|
|
50
|
-
} else {
|
|
51
|
-
setValue(newValue);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const renderList = () => {
|
|
56
|
-
const extraOptions = allowSelectNone ? (
|
|
57
|
-
<ComboboxItem key={NONE_KEY} value={NONE_KEY}>
|
|
58
|
-
--
|
|
59
|
-
</ComboboxItem>
|
|
60
|
-
) : null;
|
|
61
|
-
|
|
62
|
-
if (filteredOptions.length > 200) {
|
|
63
|
-
return (
|
|
64
|
-
<Virtuoso
|
|
65
|
-
style={{ height: "200px" }}
|
|
66
|
-
totalCount={filteredOptions.length}
|
|
67
|
-
overscan={50}
|
|
68
|
-
itemContent={(i: number) => {
|
|
69
|
-
const option = filteredOptions[i];
|
|
70
29
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
if (i === 0) {
|
|
78
|
-
return (
|
|
79
|
-
<>
|
|
80
|
-
{extraOptions}
|
|
81
|
-
{comboboxItem}
|
|
82
|
-
</>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return comboboxItem;
|
|
87
|
-
}}
|
|
88
|
-
/>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const list = filteredOptions.map((option) => (
|
|
93
|
-
<ComboboxItem key={option} value={option}>
|
|
94
|
-
{option}
|
|
95
|
-
</ComboboxItem>
|
|
96
|
-
));
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<>
|
|
100
|
-
{extraOptions}
|
|
101
|
-
{list}
|
|
102
|
-
</>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
30
|
+
const items = useMemo<Array<Option<string>>>(
|
|
31
|
+
() => options.map((option) => ({ value: option, label: option })),
|
|
32
|
+
[options],
|
|
33
|
+
);
|
|
105
34
|
|
|
106
35
|
return (
|
|
107
36
|
<Labeled label={label} id={id} fullWidth={fullWidth}>
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return option;
|
|
114
|
-
}}
|
|
115
|
-
placeholder="Select..."
|
|
37
|
+
<SelectList<string>
|
|
38
|
+
id={id}
|
|
39
|
+
options={items}
|
|
40
|
+
value={value}
|
|
41
|
+
onChange={(next) => setValue((next as string | null) ?? null)}
|
|
116
42
|
multiple={false}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
})}
|
|
120
|
-
value={value ?? NONE_KEY}
|
|
121
|
-
onValueChange={handleValueChange}
|
|
122
|
-
shouldFilter={false}
|
|
123
|
-
search={searchQuery}
|
|
124
|
-
onSearchChange={setSearchQuery}
|
|
43
|
+
allowSelectNone={allowSelectNone}
|
|
44
|
+
fullWidth={fullWidth}
|
|
125
45
|
disabled={disabled}
|
|
46
|
+
className={cn({ "w-full": fullWidth })}
|
|
126
47
|
data-testid="marimo-plugin-searchable-dropdown"
|
|
127
|
-
|
|
128
|
-
{renderList()}
|
|
129
|
-
</Combobox>
|
|
48
|
+
/>
|
|
130
49
|
</Labeled>
|
|
131
50
|
);
|
|
132
51
|
};
|
|
@@ -225,8 +225,11 @@ describe("DropdownPlugin", () => {
|
|
|
225
225
|
screen.getByTestId("marimo-plugin-searchable-dropdown").firstChild!,
|
|
226
226
|
);
|
|
227
227
|
|
|
228
|
-
//
|
|
229
|
-
|
|
228
|
+
// Re-picking the current value clears it when allowSelectNone
|
|
229
|
+
const bananaOption = screen
|
|
230
|
+
.getAllByRole("option")
|
|
231
|
+
.find((el) => el.textContent === "Banana");
|
|
232
|
+
fireEvent.click(bananaOption!);
|
|
230
233
|
expect(setValue).toHaveBeenCalledWith([]);
|
|
231
234
|
});
|
|
232
235
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { beforeEach, expect, it, vi } from "vitest";
|
|
3
3
|
import { initialModeAtom } from "@/core/mode";
|
|
4
4
|
import { store } from "@/core/state/jotai";
|
|
5
|
-
import { multiselectFilterFn } from "
|
|
5
|
+
import { multiselectFilterFn } from "@/components/ui/select-core";
|
|
6
6
|
|
|
7
7
|
function filterOptions(filter: string, items: string[]) {
|
|
8
8
|
return items.filter((option) => multiselectFilterFn(option, filter));
|
package/src/utils/lazy.ts
CHANGED
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
|
|
5
5
|
interface LazyComponentWithPreload<T> {
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Eagerly trigger the dynamic import. Returns the import promise so callers
|
|
8
|
+
* can await it or attach error handling; safe to call multiple times (the
|
|
9
|
+
* import is memoized).
|
|
10
|
+
*/
|
|
11
|
+
preload: () => Promise<{ default: React.ComponentType<T> }>;
|
|
7
12
|
Component: React.LazyExoticComponent<React.ComponentType<T>>;
|
|
8
13
|
}
|
|
9
14
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./worker-ip3AI_sN.js";var t=e(((e,t)=>{t.exports={}}));export default t();
|