@marimo-team/islands 0.23.10-dev9 → 0.23.11-dev67

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 (188) hide show
  1. package/dist/{ConnectedDataExplorerComponent-CyV83R2m.js → ConnectedDataExplorerComponent-Z3RP7Vmm.js} +31 -31
  2. package/dist/{ErrorBoundary-rULOrC_p.js → ErrorBoundary-DpbaKVv7.js} +1 -1
  3. package/dist/{any-language-editor-CiES2a2h.js → any-language-editor-CAgFD4Kd.js} +20 -20
  4. package/dist/assets/__vite-browser-external-eshhtsgZ.js +1 -0
  5. package/dist/assets/worker-CC0Oul9k.js +73 -0
  6. package/dist/{chat-ui-K84W5ecY.js → chat-ui-C4-GMW9y.js} +77 -77
  7. package/dist/{check-DTbrK0zt.js → check-BCaJeT-J.js} +1 -1
  8. package/dist/{chunk-5FQGJX7Z-BNjes6Yx.js → chunk-5FQGJX7Z-BbqSm5gU.js} +1227 -1222
  9. package/dist/{code-block-37QAKDTI-m92Yc8pv.js → code-block-37QAKDTI-O6IH6wAi.js} +1 -1
  10. package/dist/{code-visibility-v6ucEVUg.js → code-visibility-UH2371Sv.js} +1943 -1223
  11. package/dist/{copy-5jQ_kGE1.js → copy-UqRYxiOg.js} +1 -1
  12. package/dist/dist-7QfXoMdB.js +5 -0
  13. package/dist/{dist-DgnE8F-r.js → dist-A2846XWO.js} +1 -1
  14. package/dist/dist-BEXXyZig.js +5 -0
  15. package/dist/{dist-B3pZ0Ab6.js → dist-BR_gyG9L.js} +3 -3
  16. package/dist/{dist-CcXxepx6.js → dist-BSAt6RhH.js} +27 -27
  17. package/dist/{dist-Bde4a2kU.js → dist-BY018Paw.js} +8 -8
  18. package/dist/dist-BYj57OV4.js +5 -0
  19. package/dist/{dist-CUCNs1ja.js → dist-BaoDKvdy.js} +2 -2
  20. package/dist/{dist-Cy1WxgBD.js → dist-Bf7SHuNp.js} +5 -5
  21. package/dist/{dist-Bz_sYWbr.js → dist-Bk75fBZA.js} +2 -2
  22. package/dist/dist-BlSvQzNr.js +5 -0
  23. package/dist/{dist-C5VC_yzu.js → dist-BzEzfugY.js} +1 -1
  24. package/dist/dist-CCBlxAgS.js +8 -0
  25. package/dist/dist-CIDTVIUf.js +5 -0
  26. package/dist/{dist-CLUtPrdy.js → dist-CIYBwstr.js} +1 -1
  27. package/dist/{dist-BotSqB48.js → dist-C_Y3oV3C.js} +12 -12
  28. package/dist/{dist-BTfv03uy.js → dist-CcWX6tmx.js} +2 -2
  29. package/dist/{dist-BhM8gdSO.js → dist-CoXAujgg.js} +4 -4
  30. package/dist/{dist-4j4c7bjm.js → dist-CpxNdDkw.js} +3 -3
  31. package/dist/dist-CqQyhAM8.js +8 -0
  32. package/dist/dist-CwRu2Xzh.js +5 -0
  33. package/dist/{dist-BcuoonNH.js → dist-CxJDU6Bh.js} +9 -9
  34. package/dist/{dist-DxvORzUR.js → dist-D-W5ny5a.js} +8 -8
  35. package/dist/dist-D8CDTVgf.js +6 -0
  36. package/dist/dist-D8DNB0nO.js +8 -0
  37. package/dist/dist-DL6N_q-A.js +5 -0
  38. package/dist/{dist-BbbIBDiQ.js → dist-DMjWuVs8.js} +1 -1
  39. package/dist/dist-DOFbNV_b.js +8 -0
  40. package/dist/dist-DPrYzMY0.js +6 -0
  41. package/dist/{dist-h2c8sZvT.js → dist-DZORgqKY.js} +1 -1
  42. package/dist/{dist-B3P2fFpz.js → dist-DZo4nSS0.js} +14 -14
  43. package/dist/{dist-D4CewLk6.js → dist-Dax--nl9.js} +1 -1
  44. package/dist/{dist-DRfcqpxJ.js → dist-DgGbNavJ.js} +2 -2
  45. package/dist/{dist-C1BYNeCR.js → dist-Dk6PV_d3.js} +10 -10
  46. package/dist/{dist-fQ0ViXGs.js → dist-Dv_Y15yk.js} +107 -107
  47. package/dist/{dist-Bfwsv11D.js → dist-DyyjKEYf.js} +2 -2
  48. package/dist/{dist-p2qyWijU.js → dist-GZXUmt0b.js} +2 -2
  49. package/dist/{dist-CLJWPTX2.js → dist-LTU8Hdvn.js} +3 -3
  50. package/dist/{dist-DqAWR3CS.js → dist-M9Vag9Y0.js} +20 -20
  51. package/dist/{dist-DNdhYsgW.js → dist-U4F-tbMs.js} +79 -62
  52. package/dist/{dist-RqXTaiir.js → dist-abid3KgM.js} +11 -11
  53. package/dist/dist-cdmMjgsn.js +5 -0
  54. package/dist/dist-hT4QzYX-.js +1247 -0
  55. package/dist/{dist-luvabDEB.js → dist-t9Kf7xqC.js} +2 -2
  56. package/dist/{error-banner-5bz0L9hS.js → error-banner-CJXYJ6Sb.js} +11 -6
  57. package/dist/esm-BaH2eg5-.js +1171 -0
  58. package/dist/{esm-Duie8iU-.js → esm-ga2Bf3O2.js} +43 -43
  59. package/dist/{extends-CkydH1Q5.js → extends-D_hDsj6R.js} +4 -4
  60. package/dist/files/wasm-intro.py +11 -8
  61. package/dist/{formats-DHxc-FdY.js → formats-C4wO47tk.js} +1 -1
  62. package/dist/{glide-data-editor-CgIxTzAP.js → glide-data-editor-BPkCPs7L.js} +255 -255
  63. package/dist/{html-to-image-B93KtAVY.js → html-to-image-BwfcJJxA.js} +2412 -2282
  64. package/dist/{input-_2sjvfne.js → input-OdWHkobi.js} +263 -245
  65. package/dist/{label-LWtdw5i8.js → label-CC4ytI1X.js} +1 -1
  66. package/dist/main.js +7630 -7558
  67. package/dist/{mermaid-4DMBBIKO-DIdL224_.js → mermaid-4DMBBIKO-Eg3D4FVz.js} +1 -1
  68. package/dist/{mermaid-lXOw5Py9.js → mermaid-BotvIKg9.js} +4 -4
  69. package/dist/{process-output-BOXi9fnS.js → process-output-DsloEDna.js} +3 -3
  70. package/dist/{reveal-component-gRcjQbNL.js → reveal-component-BNU1V1x5.js} +698 -620
  71. package/dist/{spec-B96zNUEA.js → spec-X7FwLJni.js} +4 -4
  72. package/dist/{strings-Bu3vlb6W.js → strings-J57tzLr3.js} +47 -46
  73. package/dist/style.css +1 -1
  74. package/dist/{toDate-x-WRDCH7.js → toDate-d8RCRrRd.js} +2 -2
  75. package/dist/{tooltip-C5FYOpQc.js → tooltip-DpcyNkQ2.js} +2 -2
  76. package/dist/{types-CVvp1fKr.js → types-ChtMFmZ2.js} +1 -1
  77. package/dist/{useAsyncData-iRgKDT5s.js → useAsyncData-PonK__yh.js} +1 -1
  78. package/dist/{useDateFormatter-BA4FCquG.js → useDateFormatter-QB-3MpYr.js} +2 -2
  79. package/dist/{useDeepCompareMemoize-CkQ57VS2.js → useDeepCompareMemoize-D3NGWke6.js} +1 -1
  80. package/dist/{useLifecycle-BBO9PIph.js → useLifecycle-00mO3OSS.js} +2 -2
  81. package/dist/{useTheme-DHIrRQOe.js → useTheme-DEhDzATN.js} +1 -1
  82. package/dist/{vega-component-Dq-SH463.js → vega-component-DGPUhbDs.js} +8 -8
  83. package/dist/{zod-CoBiJ5v4.js → zod-aLSua2NL.js} +24 -23
  84. package/package.json +4 -3
  85. package/src/__tests__/setup.ts +16 -0
  86. package/src/components/chat/chat-display.tsx +2 -2
  87. package/src/components/data-table/TableBottomBar.tsx +1 -15
  88. package/src/components/data-table/TableTopBar.tsx +8 -13
  89. package/src/components/data-table/__tests__/TableBottomBar.test.tsx +6 -12
  90. package/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx +227 -0
  91. package/src/components/data-table/column-visibility-dropdown.tsx +204 -0
  92. package/src/components/data-table/data-table.tsx +1 -1
  93. package/src/components/data-table/filter-by-values-picker.tsx +39 -17
  94. package/src/components/data-table/filter-pills.tsx +1 -1
  95. package/src/components/datasources/__tests__/filter-empty.test.ts +183 -0
  96. package/src/components/datasources/datasources.tsx +92 -3
  97. package/src/components/editor/cell/code/cell-editor.tsx +70 -32
  98. package/src/components/editor/cell/code/code-placeholder.css +18 -0
  99. package/src/components/editor/cell/code/code-placeholder.tsx +47 -0
  100. package/src/components/editor/cell/code/language-toggle.tsx +7 -1
  101. package/src/components/editor/chrome/wrapper/app-chrome.tsx +97 -52
  102. package/src/components/editor/chrome/wrapper/lazy-panels.ts +91 -0
  103. package/src/components/editor/chrome/wrapper/sidebar.tsx +2 -0
  104. package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap +9 -2
  105. package/src/components/editor/connections/storage/__tests__/as-code.test.ts +62 -27
  106. package/src/components/editor/connections/storage/add-storage-form.tsx +5 -1
  107. package/src/components/editor/connections/storage/as-code.ts +20 -6
  108. package/src/components/editor/documentation.css +35 -0
  109. package/src/components/editor/file-tree/file-explorer.tsx +8 -18
  110. package/src/components/editor/file-tree/tree-actions.tsx +46 -1
  111. package/src/components/editor/notebook-cell.tsx +3 -3
  112. package/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts +20 -0
  113. package/src/components/editor/renderers/slides-layout/types.ts +1 -0
  114. package/src/components/markdown/__tests__/markdown-renderer.test.tsx +43 -0
  115. package/src/components/markdown/markdown-renderer.tsx +24 -1
  116. package/src/components/slides/__tests__/minimap-actions.test.tsx +166 -0
  117. package/src/components/slides/__tests__/reveal-component.test.ts +425 -0
  118. package/src/components/slides/minimap.tsx +127 -10
  119. package/src/components/slides/reveal-component.tsx +287 -61
  120. package/src/components/slides/slide-cell-view.tsx +26 -2
  121. package/src/components/slides/slide-form.tsx +26 -4
  122. package/src/components/storage/__tests__/storage-inspector.test.ts +180 -0
  123. package/src/components/storage/storage-inspector.tsx +535 -81
  124. package/src/components/ui/combobox.tsx +51 -32
  125. package/src/components/ui/number-field.tsx +5 -1
  126. package/src/components/ui/reorderable-list.tsx +13 -0
  127. package/src/components/ui/select-core/__tests__/use-select-list.test.ts +294 -0
  128. package/src/components/ui/select-core/__tests__/utils.test.ts +222 -0
  129. package/src/components/ui/select-core/index.ts +16 -0
  130. package/src/components/ui/select-core/option-row.tsx +33 -0
  131. package/src/components/ui/select-core/render-slot.ts +20 -0
  132. package/src/components/ui/select-core/select-list.tsx +248 -0
  133. package/src/components/ui/select-core/types.ts +44 -0
  134. package/src/components/ui/select-core/use-select-list.ts +347 -0
  135. package/src/components/ui/select-core/utils.ts +121 -0
  136. package/src/components/ui/toast.tsx +1 -0
  137. package/src/core/cells/__tests__/document-changes.test.ts +2 -2
  138. package/src/core/cells/__tests__/focus.test.ts +45 -2
  139. package/src/core/cells/focus.ts +1 -1
  140. package/src/core/cells/scrollCellIntoView.ts +4 -0
  141. package/src/core/cells/utils.ts +1 -1
  142. package/src/core/codemirror/__tests__/editor-mount-scheduler.test.ts +143 -0
  143. package/src/core/codemirror/copilot/getCodes.ts +3 -1
  144. package/src/core/codemirror/editor-mount-scheduler.ts +101 -0
  145. package/src/core/codemirror/language/languages/python.ts +2 -0
  146. package/src/core/codemirror/language/languages/sql/utils.ts +3 -1
  147. package/src/core/codemirror/lsp/__tests__/markdown-renderer.test.ts +41 -0
  148. package/src/core/codemirror/lsp/markdown-renderer.ts +59 -0
  149. package/src/core/datasets/data-source-connections.ts +2 -0
  150. package/src/core/errors/errors.ts +1 -1
  151. package/src/core/storage/__tests__/state.test.ts +49 -0
  152. package/src/core/storage/__tests__/useStorageEntries.test.tsx +199 -3
  153. package/src/core/storage/state.ts +124 -13
  154. package/src/core/storage/types.ts +6 -0
  155. package/src/core/wasm/worker/bootstrap.ts +12 -4
  156. package/src/plugins/core/__test__/registerReactComponent.test.ts +96 -0
  157. package/src/plugins/core/registerReactComponent.tsx +42 -10
  158. package/src/plugins/impl/MultiselectPlugin.tsx +19 -142
  159. package/src/plugins/impl/SearchableSelect.tsx +16 -97
  160. package/src/plugins/impl/SliderPlugin.tsx +132 -18
  161. package/src/plugins/impl/__tests__/DropdownPlugin.test.tsx +5 -2
  162. package/src/plugins/impl/__tests__/MultiSelectPlugin.test.ts +1 -1
  163. package/src/plugins/impl/__tests__/SliderPlugin.test.tsx +278 -8
  164. package/src/utils/__tests__/numbers.test.ts +20 -0
  165. package/src/utils/errors.ts +9 -0
  166. package/src/utils/lazy.ts +6 -1
  167. package/src/utils/numbers.ts +27 -0
  168. package/src/utils/schedule-task.ts +71 -0
  169. package/dist/assets/__vite-browser-external-Ci2ZQfXU.js +0 -1
  170. package/dist/assets/worker-ip3AI_sN.js +0 -73
  171. package/dist/dist-0Fif7jnk.js +0 -5
  172. package/dist/dist-B5h_9sHB.js +0 -6
  173. package/dist/dist-B9M6R5ye.js +0 -5
  174. package/dist/dist-BCt3tnck.js +0 -8
  175. package/dist/dist-BUIJwMwn.js +0 -8
  176. package/dist/dist-BpquMd3k.js +0 -5
  177. package/dist/dist-BzJsqYfz.js +0 -5
  178. package/dist/dist-CA5ELXAf.js +0 -6
  179. package/dist/dist-CLBRs6Uv.js +0 -5
  180. package/dist/dist-CStVCMbq.js +0 -5
  181. package/dist/dist-CZRIEY3Y.js +0 -8
  182. package/dist/dist-CuUHbFD0.js +0 -5
  183. package/dist/dist-DV7Iabxb.js +0 -8
  184. package/dist/dist-DhHh0jLg.js +0 -1247
  185. package/dist/dist-DuEeHMvL.js +0 -5
  186. package/dist/esm-CCuYCd3R.js +0 -1171
  187. package/src/plugins/impl/multiselectFilterFn.tsx +0 -22
  188. /package/src/components/{data-table → ui}/value-chips.tsx +0 -0
@@ -1,13 +1,10 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
- import { type JSX, useId, useMemo, useState } from "react";
3
- import { Virtuoso } from "react-virtuoso";
2
+ import { type JSX, useId, useMemo } from "react";
4
3
  import { z } from "zod";
5
- import { cn } from "@/utils/cn";
6
- import { Combobox, ComboboxItem } from "../../components/ui/combobox";
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 [searchQuery, setSearchQuery] = useState<string>("");
72
-
73
- const filteredOptions = useMemo(() => {
74
- if (!searchQuery) {
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
- <Combobox<string>
194
- displayValue={(option) => option}
195
- placeholder="Select..."
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
- onValueChange={handleValueChange}
202
- shouldFilter={false}
203
- search={searchQuery}
204
- onSearchChange={setSearchQuery}
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, useState } from "react";
3
- import { Virtuoso } from "react-virtuoso";
4
- import { Combobox, ComboboxItem } from "../../components/ui/combobox";
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
- const comboboxItem = (
72
- <ComboboxItem key={option} value={option}>
73
- {option}
74
- </ComboboxItem>
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
- <Combobox<string>
109
- displayValue={(option) => {
110
- if (option === NONE_KEY) {
111
- return "--";
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
- className={cn({
118
- "w-full": fullWidth,
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
  };
@@ -1,10 +1,15 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
- import { type JSX, useEffect, useId, useState } from "react";
2
+ import { type JSX, useEffect, useId, useMemo, useState } from "react";
3
3
  import { useLocale } from "react-aria";
4
4
  import { z } from "zod";
5
5
  import { NumberField } from "@/components/ui/number-field";
6
6
  import { cn } from "@/utils/cn";
7
- import { prettyScientificNumber } from "@/utils/numbers";
7
+ import { clamp } from "@/utils/math";
8
+ import {
9
+ maxFractionDigitsForSteps,
10
+ prettyScientificNumber,
11
+ roundToFractionDigits,
12
+ } from "@/utils/numbers";
8
13
  import { Slider } from "../../components/ui/slider";
9
14
  import type { IPlugin, IPluginProps, Setter } from "../types";
10
15
  import { Labeled } from "./common/labeled";
@@ -46,8 +51,9 @@ export class SliderPlugin implements IPlugin<T, Data> {
46
51
  render(props: IPluginProps<T, Data>): JSX.Element {
47
52
  // Create the valueMap function
48
53
  const valueMap = (sliderValue: number): number => {
49
- if (props.data.steps && props.data.steps.length > 0) {
50
- return props.data.steps[sliderValue];
54
+ const { steps } = props.data;
55
+ if (steps && steps.length > 0) {
56
+ return steps[clamp(sliderValue, 0, steps.length - 1)];
51
57
  }
52
58
  return sliderValue;
53
59
  };
@@ -69,6 +75,66 @@ interface SliderProps extends Data {
69
75
  valueMap: (sliderValue: number) => number;
70
76
  }
71
77
 
78
+ interface StepsConfig {
79
+ steps: T[];
80
+ fractionDigits: number;
81
+ minValue: number;
82
+ maxValue: number;
83
+ inputStep: number;
84
+ formatOptions: {
85
+ minimumFractionDigits: number;
86
+ maximumFractionDigits: number;
87
+ };
88
+ }
89
+
90
+ // Index of the step whose value is closest to `target`.
91
+ function nearestStepIndex(stepValues: T[], target: number): number {
92
+ let bestIndex = 0;
93
+ let bestDistance = Number.POSITIVE_INFINITY;
94
+ for (let i = 0; i < stepValues.length; i++) {
95
+ const distance = Math.abs(stepValues[i] - target);
96
+ if (distance < bestDistance) {
97
+ bestDistance = distance;
98
+ bestIndex = i;
99
+ }
100
+ }
101
+ return bestIndex;
102
+ }
103
+
104
+ // When `steps` are provided, the slider runs in *index* space (start=0,
105
+ // stop=len-1, step=1) while the input must display and accept the *actual*
106
+ // step values. This config maps the input back into value space.
107
+ function computeStepsConfig(steps: T[] | null): StepsConfig | null {
108
+ if (!steps || steps.length === 0) {
109
+ return null;
110
+ }
111
+ const sorted = steps.toSorted((a, b) => a - b);
112
+ // Smallest positive gap between consecutive step values, used as the input's
113
+ // increment/decrement amount. Falls back to 1 when undefined.
114
+ let inputStep = Number.POSITIVE_INFINITY;
115
+ for (let i = 1; i < sorted.length; i++) {
116
+ const gap = sorted[i] - sorted[i - 1];
117
+ if (gap > 0 && gap < inputStep) {
118
+ inputStep = gap;
119
+ }
120
+ }
121
+ if (!Number.isFinite(inputStep) || inputStep <= 0) {
122
+ inputStep = 1;
123
+ }
124
+ const fractionDigits = maxFractionDigitsForSteps(steps, inputStep);
125
+ return {
126
+ steps,
127
+ fractionDigits,
128
+ minValue: roundToFractionDigits(sorted[0], fractionDigits),
129
+ maxValue: roundToFractionDigits(sorted[sorted.length - 1], fractionDigits),
130
+ inputStep: roundToFractionDigits(inputStep, fractionDigits),
131
+ formatOptions: {
132
+ minimumFractionDigits: 0,
133
+ maximumFractionDigits: fractionDigits,
134
+ },
135
+ };
136
+ }
137
+
72
138
  const SliderComponent = ({
73
139
  label,
74
140
  setValue,
@@ -95,6 +161,64 @@ const SliderComponent = ({
95
161
  setInternalValue(value);
96
162
  }, [value]);
97
163
 
164
+ const stepsConfig = useMemo(() => computeStepsConfig(steps), [steps]);
165
+
166
+ const handleInputChange = (nextValue: number | null | undefined): void => {
167
+ if (stepsConfig) {
168
+ const { steps: stepValues, fractionDigits } = stepsConfig;
169
+ // Cleared input -> reset to the first step.
170
+ if (nextValue == null || Number.isNaN(nextValue)) {
171
+ setInternalValue(0);
172
+ setValue(0);
173
+ return;
174
+ }
175
+ const roundedNext = roundToFractionDigits(nextValue, fractionDigits);
176
+ let index = nearestStepIndex(stepValues, roundedNext);
177
+ // If the nearest step is the current one but the value actually moved
178
+ // (e.g. stepper arrows on non-uniform steps), nudge one index in the
179
+ // direction of travel so the input never gets "stuck". Caveat: a typed
180
+ // value closest to the current step but past it nudges too, so on
181
+ // non-uniform steps typing a nearby number can jump to the adjacent step.
182
+ const currentValue = roundToFractionDigits(
183
+ stepValues[internalValue] ?? stepValues[0],
184
+ fractionDigits,
185
+ );
186
+ if (index === internalValue && roundedNext !== currentValue) {
187
+ index =
188
+ roundedNext > currentValue
189
+ ? Math.min(internalValue + 1, stepValues.length - 1)
190
+ : Math.max(internalValue - 1, 0);
191
+ }
192
+ setInternalValue(index);
193
+ setValue(index);
194
+ return;
195
+ }
196
+
197
+ // No steps: the input value is the slider value directly.
198
+ const resolved =
199
+ nextValue == null || Number.isNaN(nextValue) ? Number(start) : nextValue;
200
+ setInternalValue(resolved);
201
+ setValue(resolved);
202
+ };
203
+
204
+ const inputProps = stepsConfig
205
+ ? {
206
+ value: roundToFractionDigits(
207
+ valueMap(internalValue),
208
+ stepsConfig.fractionDigits,
209
+ ),
210
+ minValue: stepsConfig.minValue,
211
+ maxValue: stepsConfig.maxValue,
212
+ step: stepsConfig.inputStep,
213
+ formatOptions: stepsConfig.formatOptions,
214
+ }
215
+ : {
216
+ value: valueMap(internalValue),
217
+ minValue: start,
218
+ maxValue: stop,
219
+ step,
220
+ };
221
+
98
222
  const sliderElement = (
99
223
  <Labeled
100
224
  label={label}
@@ -123,14 +247,14 @@ const SliderComponent = ({
123
247
  step={step}
124
248
  orientation={orientation}
125
249
  // Triggered on all value changes
126
- onValueChange={([nextValue]) => {
250
+ onValueChange={([nextValue]: number[]) => {
127
251
  setInternalValue(nextValue);
128
252
  if (!debounce) {
129
253
  setValue(nextValue);
130
254
  }
131
255
  }}
132
256
  // Triggered on mouse up
133
- onValueCommit={([nextValue]) => {
257
+ onValueCommit={([nextValue]: [number]) => {
134
258
  if (debounce) {
135
259
  setValue(nextValue);
136
260
  }
@@ -145,18 +269,8 @@ const SliderComponent = ({
145
269
  )}
146
270
  {includeInput && (
147
271
  <NumberField
148
- value={valueMap(internalValue)}
149
- onChange={(nextValue) => {
150
- // If nextValue is null/undefined/NaN (input cleared), set to start
151
- if (nextValue == null || Number.isNaN(nextValue)) {
152
- nextValue = Number(start);
153
- }
154
- setInternalValue(nextValue);
155
- setValue(nextValue);
156
- }}
157
- minValue={start}
158
- maxValue={stop}
159
- step={step}
272
+ {...inputProps}
273
+ onChange={handleInputChange}
160
274
  className="w-24"
161
275
  aria-label={`${label || "Slider"} value input`}
162
276
  isDisabled={disabled}
@@ -225,8 +225,11 @@ describe("DropdownPlugin", () => {
225
225
  screen.getByTestId("marimo-plugin-searchable-dropdown").firstChild!,
226
226
  );
227
227
 
228
- // Select none should clear value
229
- fireEvent.click(screen.getByText("--"));
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 "../multiselectFilterFn";
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));