@marimo-team/islands 0.23.10-dev25 → 0.23.10-dev27
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/{code-visibility-CXkMXcdB.js → code-visibility-DI2QSiFC.js} +1646 -1179
- package/dist/main.js +7312 -7424
- package/dist/{reveal-component-dIolR_34.js → reveal-component-BA7HaWOX.js} +410 -333
- package/package.json +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/editor/cell/code/language-toggle.tsx +7 -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__/reveal-component.test.ts +425 -0
- package/src/components/slides/reveal-component.tsx +283 -61
- package/src/components/slides/slide-cell-view.tsx +26 -2
- package/src/components/slides/slide-form.tsx +26 -4
- package/src/components/ui/combobox.tsx +51 -32
- 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/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/impl/multiselectFilterFn.tsx +0 -22
- /package/src/components/{data-table → ui}/value-chips.tsx +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import type { BulkActionSpec, Option } from "./types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Override cmdk's relevance-sorting filter with a stricter membership test: an
|
|
6
|
+
* option matches only when every whitespace-separated query word appears in it
|
|
7
|
+
* (case-insensitive), in any order. More lenient than exact match, stricter than
|
|
8
|
+
* fuzzy.
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* - "foo bar" matches "foo bar"
|
|
12
|
+
* - "bar foo" matches "foo bar"
|
|
13
|
+
* - "foob" does not match "foo bar"
|
|
14
|
+
*/
|
|
15
|
+
export function multiselectFilterFn(option: string, value: string): number {
|
|
16
|
+
const words = value.split(/\s+/);
|
|
17
|
+
const match = words.every((word) =>
|
|
18
|
+
option.toLowerCase().includes(word.toLowerCase()),
|
|
19
|
+
);
|
|
20
|
+
return match ? 1 : 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Union: append the not-yet-selected members of `toAdd`, preserving order. */
|
|
24
|
+
export function selectMatching<V>(selected: V[], toAdd: V[]): V[] {
|
|
25
|
+
const set = new Set(selected);
|
|
26
|
+
return [...set, ...toAdd.filter((v) => !set.has(v))];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Difference: drop every member of `toRemove` from `selected`. */
|
|
30
|
+
export function deselectMatching<V>(selected: V[], toRemove: V[]): V[] {
|
|
31
|
+
const set = new Set(toRemove);
|
|
32
|
+
return selected.filter((v) => !set.has(v));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Order options for the idle (no active search) menu: pinned selections first in
|
|
37
|
+
* pin insertion order (so a freshly added selection appears after earlier ones),
|
|
38
|
+
* then everything else in option order. `pinnedSelection` is a frozen snapshot
|
|
39
|
+
* taken when the menu opens, so toggling an item does not reorder the list under
|
|
40
|
+
* the cursor. Returns the count of pinned options alongside the list so callers
|
|
41
|
+
* don't have to re-scan to find where the pinned block ends.
|
|
42
|
+
*/
|
|
43
|
+
export function getVisibleOptions<V>(
|
|
44
|
+
options: Array<Option<V>>,
|
|
45
|
+
pinnedSelection: ReadonlySet<V>,
|
|
46
|
+
): { visibleOptions: Array<Option<V>>; pinnedCount: number } {
|
|
47
|
+
const byValue = new Map(options.map((o) => [o.value, o] as const));
|
|
48
|
+
const pinned: Array<Option<V>> = [];
|
|
49
|
+
for (const value of pinnedSelection) {
|
|
50
|
+
const option = byValue.get(value);
|
|
51
|
+
if (option) {
|
|
52
|
+
pinned.push(option);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const rest = options.filter((o) => !pinnedSelection.has(o.value));
|
|
56
|
+
return { visibleOptions: [...pinned, ...rest], pinnedCount: pinned.length };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Decide which bulk rows the menu shows for the current search/cap state.
|
|
61
|
+
*
|
|
62
|
+
* When searching, the select-side spec carries the unselected matches and the
|
|
63
|
+
* deselect-side spec carries the selected matches (each omitted when empty).
|
|
64
|
+
* When idle, the spec is just `select-all` / `deselect-all` with an `enabled`
|
|
65
|
+
* flag for the disabled-but-visible state. `maxSelections` hides the select-
|
|
66
|
+
* side everywhere (a bulk select could exceed the cap); `maxSelections === 1`
|
|
67
|
+
* suppresses bulk rows entirely. Returns `[]` when bulk rows shouldn't show.
|
|
68
|
+
*
|
|
69
|
+
* Specs come in select-then-deselect order so the facade can render them as-is.
|
|
70
|
+
*/
|
|
71
|
+
export function getBulkActions<V>(params: {
|
|
72
|
+
options: Array<Option<V>>;
|
|
73
|
+
filteredOptions: Array<Option<V>>;
|
|
74
|
+
value: V[];
|
|
75
|
+
searchQuery: string;
|
|
76
|
+
maxSelections: number | undefined;
|
|
77
|
+
}): Array<BulkActionSpec<V>> {
|
|
78
|
+
const { options, filteredOptions, value, searchQuery, maxSelections } =
|
|
79
|
+
params;
|
|
80
|
+
|
|
81
|
+
if (options.length <= 2 || maxSelections === 1) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const capped = maxSelections != null;
|
|
86
|
+
const specs: Array<BulkActionSpec<V>> = [];
|
|
87
|
+
|
|
88
|
+
if (searchQuery !== "") {
|
|
89
|
+
if (filteredOptions.length === 0) {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
const selected = new Set(value);
|
|
93
|
+
const selectedMatches: Array<Option<V>> = [];
|
|
94
|
+
const unselectedMatches: Array<Option<V>> = [];
|
|
95
|
+
for (const option of filteredOptions) {
|
|
96
|
+
if (selected.has(option.value)) {
|
|
97
|
+
selectedMatches.push(option);
|
|
98
|
+
} else if (!option.disabled) {
|
|
99
|
+
// Disabled rows can't be picked individually, so bulk select skips them too.
|
|
100
|
+
unselectedMatches.push(option);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!capped && unselectedMatches.length > 0) {
|
|
104
|
+
specs.push({ kind: "select-matching", items: unselectedMatches });
|
|
105
|
+
}
|
|
106
|
+
if (selectedMatches.length > 0) {
|
|
107
|
+
specs.push({ kind: "deselect-matching", items: selectedMatches });
|
|
108
|
+
}
|
|
109
|
+
return specs;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!capped) {
|
|
113
|
+
const selected = new Set(value);
|
|
114
|
+
specs.push({
|
|
115
|
+
kind: "select-all",
|
|
116
|
+
enabled: options.some((o) => !o.disabled && !selected.has(o.value)),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
specs.push({ kind: "deselect-all", enabled: value.length > 0 });
|
|
120
|
+
return specs;
|
|
121
|
+
}
|
|
@@ -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));
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* We override the default filter function which focuses on sorting by relevance with a fuzzy-match,
|
|
5
|
-
* instead of filtering out.
|
|
6
|
-
* The default filter function is `command-score`.
|
|
7
|
-
*
|
|
8
|
-
* Our filter function only matches if all words in the value are present in the option.
|
|
9
|
-
* This is more strict than the default, but more lenient than an exact match.
|
|
10
|
-
*
|
|
11
|
-
* Examples:
|
|
12
|
-
* - "foo bar" matches "foo bar"
|
|
13
|
-
* - "bar foo" matches "foo bar"
|
|
14
|
-
* - "foob" does not matches "foo bar"
|
|
15
|
-
*/
|
|
16
|
-
export function multiselectFilterFn(option: string, value: string): number {
|
|
17
|
-
const words = value.split(/\s+/);
|
|
18
|
-
const match = words.every((word) =>
|
|
19
|
-
option.toLowerCase().includes(word.toLowerCase()),
|
|
20
|
-
);
|
|
21
|
-
return match ? 1 : 0;
|
|
22
|
-
}
|
|
File without changes
|