@marimo-team/islands 0.23.7-dev46 → 0.23.7-dev48

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 (27) hide show
  1. package/dist/{chat-ui-CufH8sfF.js → chat-ui-D8ZxPNTR.js} +3 -3
  2. package/dist/{code-visibility-Dg16kN_f.js → code-visibility-An0P9cL_.js} +1265 -935
  3. package/dist/{glide-data-editor-BK9s_dqy.js → glide-data-editor-DucgdjRo.js} +1 -1
  4. package/dist/{html-to-image-DxWM1HVj.js → html-to-image-DaPPaVDP.js} +1 -1
  5. package/dist/{input-Cc1Vvw9A.js → input-D4kjoQUB.js} +2 -0
  6. package/dist/main.js +8 -8
  7. package/dist/{process-output-DBYxXdrN.js → process-output-n0RJTxcC.js} +1 -1
  8. package/dist/{reveal-component-pYmvK2-h.js → reveal-component-B23qYh6r.js} +3 -3
  9. package/dist/style.css +1 -1
  10. package/package.json +1 -1
  11. package/src/components/data-table/__tests__/column-header.test.ts +3 -1
  12. package/src/components/data-table/__tests__/column-header.test.tsx +203 -0
  13. package/src/components/data-table/__tests__/filter-by-values-picker.test.tsx +112 -0
  14. package/src/components/data-table/__tests__/filter-pill-editor.test.tsx +175 -0
  15. package/src/components/data-table/__tests__/filters.test.ts +112 -36
  16. package/src/components/data-table/column-header.tsx +210 -157
  17. package/src/components/data-table/filter-by-values-picker.tsx +70 -9
  18. package/src/components/data-table/filter-pill-editor.tsx +289 -144
  19. package/src/components/data-table/filter-pills.tsx +49 -8
  20. package/src/components/data-table/filters.ts +131 -36
  21. package/src/components/data-table/header-items.tsx +8 -1
  22. package/src/components/data-table/operator-labels.ts +25 -0
  23. package/src/components/data-table/regex-input.tsx +61 -0
  24. package/src/components/ui/combobox.tsx +3 -2
  25. package/src/components/ui/number-field.tsx +2 -0
  26. package/src/plugins/impl/data-frames/forms/__tests__/__snapshots__/form.test.tsx.snap +24 -24
  27. package/src/plugins/impl/data-frames/schema.ts +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.23.7-dev46",
3
+ "version": "0.23.7-dev48",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -49,7 +49,9 @@ describe("seedFromFilter", () => {
49
49
  values: [],
50
50
  operator: "in",
51
51
  });
52
- expect(seedFromFilter(Filter.number({ min: 0, max: 10 }))).toEqual({
52
+ expect(
53
+ seedFromFilter(Filter.number({ operator: "between", min: 0, max: 10 })),
54
+ ).toEqual({
53
55
  values: [],
54
56
  operator: "in",
55
57
  });
@@ -0,0 +1,203 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+ import type { Column } from "@tanstack/react-table";
3
+ import { fireEvent, render, screen, within } from "@testing-library/react";
4
+ import { beforeAll, describe, expect, it, vi } from "vitest";
5
+ import { NumberFilterMenu, TextFilterMenu } from "../column-header";
6
+ import { Filter } from "../filters";
7
+
8
+ beforeAll(() => {
9
+ global.HTMLElement.prototype.scrollIntoView = () => {
10
+ // jsdom does not implement scrollIntoView; Radix calls it on open.
11
+ };
12
+ // Radix Select gates pointer interactions on hasPointerCapture; jsdom omits it.
13
+ if (!global.HTMLElement.prototype.hasPointerCapture) {
14
+ global.HTMLElement.prototype.hasPointerCapture = () => false;
15
+ }
16
+ if (!global.HTMLElement.prototype.releasePointerCapture) {
17
+ global.HTMLElement.prototype.releasePointerCapture = () => {
18
+ // no-op
19
+ };
20
+ }
21
+ });
22
+
23
+ function mockColumn(initial?: ReturnType<typeof Filter.number>): Column<
24
+ unknown,
25
+ unknown
26
+ > & {
27
+ setFilterValue: ReturnType<typeof vi.fn>;
28
+ } {
29
+ let filterValue = initial;
30
+ const setFilterValue = vi.fn((next) => {
31
+ filterValue = next;
32
+ });
33
+ return {
34
+ id: "age",
35
+ columnDef: { meta: { dataType: "number", filterType: "number" } },
36
+ getFilterValue: () => filterValue,
37
+ setFilterValue,
38
+ } as unknown as Column<unknown, unknown> & {
39
+ setFilterValue: ReturnType<typeof vi.fn>;
40
+ };
41
+ }
42
+
43
+ describe("NumberFilterMenu", () => {
44
+ it("shows all expected operators in the dropdown", () => {
45
+ const column = mockColumn();
46
+ render(<NumberFilterMenu column={column} />);
47
+ const trigger = screen.getByRole("combobox");
48
+ fireEvent.click(trigger);
49
+ const listbox = screen.getByRole("listbox");
50
+ const labels = within(listbox)
51
+ .getAllByRole("option")
52
+ .map((o) => o.textContent);
53
+ expect(labels).toEqual([
54
+ "Between",
55
+ "Equals",
56
+ "Doesn't equal",
57
+ "Greater than",
58
+ "Greater than or equal",
59
+ "Less than",
60
+ "Less than or equal",
61
+ "Is null",
62
+ "Is not null",
63
+ ]);
64
+ });
65
+
66
+ it("between mode disables Apply until both min and max are defined", () => {
67
+ const column = mockColumn();
68
+ render(<NumberFilterMenu column={column} />);
69
+ const apply = screen.getByRole("button", { name: /apply/i });
70
+ expect(apply).toBeDisabled();
71
+
72
+ const min = screen.getByLabelText("min");
73
+ fireEvent.change(min, { target: { value: "1" } });
74
+ fireEvent.blur(min);
75
+ expect(apply).toBeDisabled();
76
+
77
+ const max = screen.getByLabelText("max");
78
+ fireEvent.change(max, { target: { value: "10" } });
79
+ fireEvent.blur(max);
80
+ expect(apply).not.toBeDisabled();
81
+ });
82
+
83
+ it("comparison mode shows a single value field seeded from current filter", () => {
84
+ const column = mockColumn(Filter.number({ operator: ">", value: 18 }));
85
+ render(<NumberFilterMenu column={column} />);
86
+ const value = screen.getByLabelText("value") as HTMLInputElement;
87
+ expect(value).toBeInTheDocument();
88
+ expect(value.value).toBe("18");
89
+ expect(screen.queryByLabelText("min")).not.toBeInTheDocument();
90
+ expect(screen.queryByLabelText("max")).not.toBeInTheDocument();
91
+ });
92
+
93
+ it("selecting a nullish operator hides value inputs and commits on Apply", () => {
94
+ const column = mockColumn();
95
+ render(<NumberFilterMenu column={column} />);
96
+ fireEvent.click(screen.getByRole("combobox"));
97
+ const listbox = screen.getByRole("listbox");
98
+ fireEvent.click(within(listbox).getByText("Is null"));
99
+ expect(column.setFilterValue).not.toHaveBeenCalled();
100
+ expect(screen.queryByLabelText("min")).not.toBeInTheDocument();
101
+ expect(screen.queryByLabelText("max")).not.toBeInTheDocument();
102
+ expect(screen.queryByLabelText("value")).not.toBeInTheDocument();
103
+ fireEvent.click(screen.getByRole("button", { name: /apply/i }));
104
+ expect(column.setFilterValue).toHaveBeenCalledWith(
105
+ Filter.number({ operator: "is_null" }),
106
+ );
107
+ });
108
+ });
109
+
110
+ function mockTextColumn(initial?: ReturnType<typeof Filter.text>): Column<
111
+ unknown,
112
+ unknown
113
+ > & {
114
+ setFilterValue: ReturnType<typeof vi.fn>;
115
+ } {
116
+ let filterValue = initial;
117
+ const setFilterValue = vi.fn((next) => {
118
+ filterValue = next;
119
+ });
120
+ return {
121
+ id: "name",
122
+ columnDef: { meta: { dataType: "string", filterType: "text" } },
123
+ getFilterValue: () => filterValue,
124
+ setFilterValue,
125
+ } as unknown as Column<unknown, unknown> & {
126
+ setFilterValue: ReturnType<typeof vi.fn>;
127
+ };
128
+ }
129
+
130
+ describe("TextFilterMenu", () => {
131
+ it("shows all 11 text operators in the dropdown", () => {
132
+ const column = mockTextColumn();
133
+ render(<TextFilterMenu column={column} />);
134
+ fireEvent.click(screen.getByRole("combobox"));
135
+ const listbox = screen.getByRole("listbox");
136
+ const labels = within(listbox)
137
+ .getAllByRole("option")
138
+ .map((o) => o.textContent);
139
+ expect(labels).toEqual([
140
+ "Contains",
141
+ "Equals",
142
+ "Doesn't equal",
143
+ "Matches regex",
144
+ "Starts with",
145
+ "Ends with",
146
+ "Is in",
147
+ "Not in",
148
+ "Is empty",
149
+ "Is null",
150
+ "Is not null",
151
+ ]);
152
+ });
153
+
154
+ it("single-string operator renders a text input seeded from current filter", () => {
155
+ const column = mockTextColumn(
156
+ Filter.text({ operator: "equals", text: "alice" }),
157
+ );
158
+ render(<TextFilterMenu column={column} />);
159
+ const input = screen.getByPlaceholderText("Text...") as HTMLInputElement;
160
+ expect(input).toBeInTheDocument();
161
+ expect(input.value).toBe("alice");
162
+ });
163
+
164
+ it("'in' operator renders the creatable values picker", async () => {
165
+ const column = mockTextColumn(
166
+ Filter.text({ operator: "in", values: ["a", "b"] }),
167
+ );
168
+ const calculateTopKRows = vi.fn(async () => ({
169
+ data: [["a", 1] as [unknown, number]],
170
+ }));
171
+ render(
172
+ <TextFilterMenu column={column} calculateTopKRows={calculateTopKRows} />,
173
+ );
174
+ expect(
175
+ await screen.findByPlaceholderText(/Search or add a value/i),
176
+ ).toBeInTheDocument();
177
+ expect(screen.queryByPlaceholderText("Text...")).not.toBeInTheDocument();
178
+ });
179
+
180
+ it("selecting is_empty hides the value UI and commits on Apply", () => {
181
+ const column = mockTextColumn();
182
+ render(<TextFilterMenu column={column} />);
183
+ fireEvent.click(screen.getByRole("combobox"));
184
+ const listbox = screen.getByRole("listbox");
185
+ fireEvent.click(within(listbox).getByText("Is empty"));
186
+ expect(column.setFilterValue).not.toHaveBeenCalled();
187
+ expect(screen.queryByPlaceholderText("Text...")).not.toBeInTheDocument();
188
+ fireEvent.click(screen.getByRole("button", { name: /apply/i }));
189
+ expect(column.setFilterValue).toHaveBeenCalledWith(
190
+ Filter.text({ operator: "is_empty" }),
191
+ );
192
+ });
193
+
194
+ it("apply is disabled when scalar text is empty", () => {
195
+ const column = mockTextColumn();
196
+ render(<TextFilterMenu column={column} />);
197
+ expect(screen.getByRole("button", { name: /apply/i })).toBeDisabled();
198
+ fireEvent.change(screen.getByPlaceholderText("Text..."), {
199
+ target: { value: "x" },
200
+ });
201
+ expect(screen.getByRole("button", { name: /apply/i })).not.toBeDisabled();
202
+ });
203
+ });
@@ -0,0 +1,112 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+ import type { Column } from "@tanstack/react-table";
3
+ import { fireEvent, render, screen } from "@testing-library/react";
4
+ import { beforeAll, describe, expect, it, vi } from "vitest";
5
+ import { FilterByValuesList } from "../filter-by-values-picker";
6
+
7
+ beforeAll(() => {
8
+ global.HTMLElement.prototype.scrollIntoView = () => {
9
+ // jsdom does not implement scrollIntoView; cmdk calls it on selection.
10
+ };
11
+ });
12
+
13
+ function mockColumn(): Column<unknown, unknown> {
14
+ return {
15
+ id: "name",
16
+ columnDef: { meta: { dataType: "string" } },
17
+ } as unknown as Column<unknown, unknown>;
18
+ }
19
+
20
+ async function calculateTopK() {
21
+ return {
22
+ data: [
23
+ ["alice", 3],
24
+ ["bob", 1],
25
+ ] as Array<[string, number]>,
26
+ };
27
+ }
28
+
29
+ describe("FilterByValuesList — creatable", () => {
30
+ it("shows '+ Add \"X\"' item when creatable and query is non-empty", async () => {
31
+ const onChange = vi.fn();
32
+ render(
33
+ <FilterByValuesList
34
+ column={mockColumn()}
35
+ calculateTopKRows={calculateTopK}
36
+ chosenValues={new Set()}
37
+ onChange={onChange}
38
+ creatable={true}
39
+ />,
40
+ );
41
+ await screen.findByText("alice");
42
+ const input = screen.getByPlaceholderText(/Search or add/i);
43
+ fireEvent.change(input, { target: { value: "carol" } });
44
+ expect(await screen.findByText(/\+ Add "carol"/)).toBeInTheDocument();
45
+ });
46
+
47
+ it("commits the literal when '+ Add' is selected", async () => {
48
+ const onChange = vi.fn();
49
+ render(
50
+ <FilterByValuesList
51
+ column={mockColumn()}
52
+ calculateTopKRows={calculateTopK}
53
+ chosenValues={new Set()}
54
+ onChange={onChange}
55
+ creatable={true}
56
+ />,
57
+ );
58
+ await screen.findByText("alice");
59
+ const input = screen.getByPlaceholderText(/Search or add/i);
60
+ fireEvent.change(input, { target: { value: "carol" } });
61
+ fireEvent.click(await screen.findByText(/\+ Add "carol"/));
62
+ expect(onChange).toHaveBeenCalledWith(["carol"]);
63
+ });
64
+
65
+ it("Enter key in creatable mode commits the query as a value", async () => {
66
+ const onChange = vi.fn();
67
+ render(
68
+ <FilterByValuesList
69
+ column={mockColumn()}
70
+ calculateTopKRows={calculateTopK}
71
+ chosenValues={new Set()}
72
+ onChange={onChange}
73
+ creatable={true}
74
+ />,
75
+ );
76
+ await screen.findByText("alice");
77
+ const input = screen.getByPlaceholderText(/Search or add/i);
78
+ fireEvent.change(input, { target: { value: "dave" } });
79
+ fireEvent.keyDown(input, { key: "Enter" });
80
+ expect(onChange).toHaveBeenCalledWith(["dave"]);
81
+ });
82
+
83
+ it("does NOT show '+ Add' when creatable is false", async () => {
84
+ render(
85
+ <FilterByValuesList
86
+ column={mockColumn()}
87
+ calculateTopKRows={calculateTopK}
88
+ chosenValues={new Set()}
89
+ onChange={vi.fn()}
90
+ creatable={false}
91
+ />,
92
+ );
93
+ await screen.findByText("alice");
94
+ const input = screen.getByPlaceholderText(/Search among/i);
95
+ fireEvent.change(input, { target: { value: "carol" } });
96
+ expect(screen.queryByText(/\+ Add/)).not.toBeInTheDocument();
97
+ });
98
+
99
+ it("renders chosen values that are not in top-K with — count", async () => {
100
+ render(
101
+ <FilterByValuesList
102
+ column={mockColumn()}
103
+ calculateTopKRows={calculateTopK}
104
+ chosenValues={new Set(["zara"])}
105
+ onChange={vi.fn()}
106
+ />,
107
+ );
108
+ await screen.findByText("alice");
109
+ expect(screen.getByText("zara")).toBeInTheDocument();
110
+ expect(screen.getByText("—")).toBeInTheDocument();
111
+ });
112
+ });
@@ -0,0 +1,175 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+ import type { Column, Table } from "@tanstack/react-table";
3
+ import { fireEvent, render, screen } from "@testing-library/react";
4
+ import { beforeAll, describe, expect, it, vi } from "vitest";
5
+ import { TooltipProvider } from "@/components/ui/tooltip";
6
+ import { FilterPillEditor } from "../filter-pill-editor";
7
+ import { Filter } from "../filters";
8
+
9
+ const renderWithProviders = (ui: React.ReactElement) =>
10
+ render(<TooltipProvider>{ui}</TooltipProvider>);
11
+
12
+ beforeAll(() => {
13
+ global.HTMLElement.prototype.scrollIntoView = () => {
14
+ // jsdom does not implement scrollIntoView; cmdk calls it on selection.
15
+ };
16
+ // jsdom lacks hasPointerCapture used by radix Select
17
+ if (!global.HTMLElement.prototype.hasPointerCapture) {
18
+ global.HTMLElement.prototype.hasPointerCapture = () => false;
19
+ }
20
+ if (!global.HTMLElement.prototype.scrollTo) {
21
+ global.HTMLElement.prototype.scrollTo = () => {
22
+ // noop for jsdom
23
+ };
24
+ }
25
+ });
26
+
27
+ function makeColumn(
28
+ id: string,
29
+ filterType: "text" | "number" | "boolean" | "select",
30
+ ): Column<unknown, unknown> {
31
+ return {
32
+ id,
33
+ columnDef: { meta: { filterType, dataType: "string" } },
34
+ } as unknown as Column<unknown, unknown>;
35
+ }
36
+
37
+ function mockTable(): Table<unknown> {
38
+ const columns = [makeColumn("name", "text"), makeColumn("age", "number")];
39
+ return {
40
+ getAllColumns: () => columns,
41
+ getColumn: (id: string) => columns.find((c) => c.id === id),
42
+ setColumnFilters: vi.fn(),
43
+ } as unknown as Table<unknown>;
44
+ }
45
+
46
+ async function calculateTopK() {
47
+ return {
48
+ data: [
49
+ ["alice", 3],
50
+ ["bob", 1],
51
+ ] as Array<[string, number]>,
52
+ };
53
+ }
54
+
55
+ describe("FilterPillEditor — snapshot rehydration", () => {
56
+ it("rehydrates a number > snapshot with seeded value", () => {
57
+ renderWithProviders(
58
+ <FilterPillEditor
59
+ snapshot={{
60
+ columnId: "age",
61
+ value: Filter.number({ operator: ">", value: 18 }),
62
+ }}
63
+ table={mockTable()}
64
+ onClose={vi.fn()}
65
+ />,
66
+ );
67
+ expect(screen.getByDisplayValue("18")).toBeInTheDocument();
68
+ expect(screen.getByLabelText("value")).toBeInTheDocument();
69
+ // No min/max range fields rendered for comparison operator.
70
+ expect(screen.queryByLabelText("min")).not.toBeInTheDocument();
71
+ expect(screen.queryByLabelText("max")).not.toBeInTheDocument();
72
+ });
73
+
74
+ it("rehydrates a number between snapshot with seeded min/max", () => {
75
+ renderWithProviders(
76
+ <FilterPillEditor
77
+ snapshot={{
78
+ columnId: "age",
79
+ value: Filter.number({ operator: "between", min: 1, max: 9 }),
80
+ }}
81
+ table={mockTable()}
82
+ onClose={vi.fn()}
83
+ />,
84
+ );
85
+ expect(screen.getByDisplayValue("1")).toBeInTheDocument();
86
+ expect(screen.getByDisplayValue("9")).toBeInTheDocument();
87
+ });
88
+
89
+ it("rehydrates a text in snapshot seeding the creatable picker", async () => {
90
+ renderWithProviders(
91
+ <FilterPillEditor
92
+ snapshot={{
93
+ columnId: "name",
94
+ value: Filter.text({ operator: "in", values: ["a", "b"] }),
95
+ }}
96
+ table={mockTable()}
97
+ calculateTopKRows={calculateTopK}
98
+ onClose={vi.fn()}
99
+ />,
100
+ );
101
+ expect(await screen.findByText("[a, b]")).toBeInTheDocument();
102
+ });
103
+
104
+ it("rehydrates a text contains snapshot with seeded text", () => {
105
+ renderWithProviders(
106
+ <FilterPillEditor
107
+ snapshot={{
108
+ columnId: "name",
109
+ value: Filter.text({ operator: "contains", text: "hello" }),
110
+ }}
111
+ table={mockTable()}
112
+ onClose={vi.fn()}
113
+ />,
114
+ );
115
+ expect(screen.getByDisplayValue("hello")).toBeInTheDocument();
116
+ });
117
+
118
+ it("hides the value slot for is_null/is_not_null/is_empty", () => {
119
+ const { rerender } = renderWithProviders(
120
+ <FilterPillEditor
121
+ snapshot={{
122
+ columnId: "name",
123
+ value: Filter.text({ operator: "is_null" }),
124
+ }}
125
+ table={mockTable()}
126
+ onClose={vi.fn()}
127
+ />,
128
+ );
129
+ expect(screen.queryByText("Value")).not.toBeInTheDocument();
130
+
131
+ rerender(
132
+ <TooltipProvider>
133
+ <FilterPillEditor
134
+ snapshot={{
135
+ columnId: "name",
136
+ value: Filter.text({ operator: "is_empty" }),
137
+ }}
138
+ table={mockTable()}
139
+ onClose={vi.fn()}
140
+ />
141
+ </TooltipProvider>,
142
+ );
143
+ expect(screen.queryByText("Value")).not.toBeInTheDocument();
144
+ });
145
+ });
146
+
147
+ describe("FilterPillEditor — apply", () => {
148
+ it("commits a number > filter via setColumnFilters", () => {
149
+ const table = mockTable();
150
+ const onClose = vi.fn();
151
+ renderWithProviders(
152
+ <FilterPillEditor
153
+ snapshot={{
154
+ columnId: "age",
155
+ value: Filter.number({ operator: ">", value: 18 }),
156
+ }}
157
+ table={table}
158
+ onClose={onClose}
159
+ />,
160
+ );
161
+ fireEvent.click(screen.getByLabelText("Apply filter"));
162
+ expect(table.setColumnFilters).toHaveBeenCalledTimes(1);
163
+ expect(onClose).toHaveBeenCalledTimes(1);
164
+
165
+ const updater = (table.setColumnFilters as ReturnType<typeof vi.fn>).mock
166
+ .calls[0][0];
167
+ const next = updater([]);
168
+ expect(next).toEqual([
169
+ {
170
+ id: "age",
171
+ value: { type: "number", operator: ">", value: 18 },
172
+ },
173
+ ]);
174
+ });
175
+ });