@marimo-team/frontend 0.23.2-dev12 → 0.23.2-dev14
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/assets/{CellStatus-Bwtcvgko.js → CellStatus-CvVketBj.js} +1 -1
- package/dist/assets/{JsonOutput-ZBMYDZ3q.js → JsonOutput-CAXIiTe3.js} +9 -9
- package/dist/assets/{LazyAnyLanguageCodeMirror-CsrwfW0n.js → LazyAnyLanguageCodeMirror-fm2VqpnZ.js} +2 -2
- package/dist/assets/{MarimoErrorOutput-DLREr23s.js → MarimoErrorOutput-B6xkavKl.js} +1 -1
- package/dist/assets/{RenderHTML-5FjN3OZH.js → RenderHTML-Ds_EjQCe.js} +1 -1
- package/dist/assets/{add-cell-with-ai-DbPkyXyg.js → add-cell-with-ai-DHOdJYCW.js} +1 -1
- package/dist/assets/{add-connection-dialog-sNnLlFNN.js → add-connection-dialog-BwYyQhY7.js} +1 -1
- package/dist/assets/{agent-panel-DMb4Q9pS.js → agent-panel-ZshQwFmu.js} +1 -1
- package/dist/assets/{ai-model-dropdown-CZB8Xt_D.js → ai-model-dropdown-w8S2jfIS.js} +4 -4
- package/dist/assets/{any-language-editor-DkEDDsUJ.js → any-language-editor-ZhKJljlb.js} +1 -1
- package/dist/assets/{app-config-button-b2p8_NdZ.js → app-config-button-BckAiCUn.js} +1 -1
- package/dist/assets/{cell-editor-BhmiBBOV.js → cell-editor-DTbYhcg9.js} +8 -8
- package/dist/assets/{cell-link-DMyOfytV.js → cell-link-CA-zSpGe.js} +1 -1
- package/dist/assets/{cells-CAft_y9h.js → cells-CvCKjUwL.js} +9 -9
- package/dist/assets/{chat-display-CnlcyHaA.js → chat-display-DXwFwqdO.js} +1 -1
- package/dist/assets/{chat-panel-DujR1b5z.js → chat-panel-DkIDMOu6.js} +1 -1
- package/dist/assets/{chat-ui-D-qk0TXi.js → chat-ui-CzVvVdHB.js} +1 -1
- package/dist/assets/{column-preview-D2B6qQUU.js → column-preview-BhAfBc9w.js} +1 -1
- package/dist/assets/{command-palette-eS5sJOYR.js → command-palette-hvx9iar3.js} +1 -1
- package/dist/assets/{common-BK4i6reD.js → common-CoA1AJdr.js} +1 -1
- package/dist/assets/{components-Dta3XEEY.js → components-BhjaTG8G.js} +1 -1
- package/dist/assets/{components-CviIANwr.js → components-D21ZOc5-.js} +1 -1
- package/dist/assets/{datasource-C1kSlT4s.js → datasource-CGDFE2Dl.js} +1 -1
- package/dist/assets/{dependency-graph-panel-CMZnqwyn.js → dependency-graph-panel-DN6lUM5M.js} +1 -1
- package/dist/assets/{dist-DZJfxwLb.js → dist-CeWYEVw7.js} +2 -2
- package/dist/assets/{documentation-panel-D9WN55Gq.js → documentation-panel-BMEYjNmG.js} +1 -1
- package/dist/assets/{download-COyB8G-Y.js → download-Cz9yagTM.js} +1 -1
- package/dist/assets/{edit-page-DlRqSgY9.js → edit-page-C1FVJJdW.js} +3 -3
- package/dist/assets/{error-panel-5I4mWGfs.js → error-panel-DcmkhCxZ.js} +1 -1
- package/dist/assets/{esm-BqofWdD5.js → esm-xpEhG7KX.js} +1 -1
- package/dist/assets/{file-explorer-panel-B86r63YC.js → file-explorer-panel-BA3zZrWa.js} +1 -1
- package/dist/assets/{file-icons-CRsc39Ny.js → file-icons-CyM54ufD.js} +1 -1
- package/dist/assets/{floating-outline-Cj9Gdjkf.js → floating-outline-BYxKYVYd.js} +1 -1
- package/dist/assets/{focus-BtOH5aLt.js → focus-DfVKn9R8.js} +1 -1
- package/dist/assets/{form-Dd-gRdD5.js → form-0zEqjNB_.js} +1 -1
- package/dist/assets/{home-page-B320ImBG.js → home-page-DEeiEOHu.js} +1 -1
- package/dist/assets/{hooks-B5RY2sms.js → hooks-DlocGflD.js} +1 -1
- package/dist/assets/{html-to-image-WCAzCguU.js → html-to-image-D4jc7m52.js} +1 -1
- package/dist/assets/{index-BjVgEJVi.js → index-BpTrkr_e.js} +16 -16
- package/dist/assets/{kiosk-mode-CJ7p0kAg.js → kiosk-mode-gTTXVMNB.js} +1 -1
- package/dist/assets/{layout-CnhRBcnG.js → layout-XI0hPL8R.js} +1 -1
- package/dist/assets/{logs-panel-DG3RlQaY.js → logs-panel-CUw148Tx.js} +1 -1
- package/dist/assets/{markdown-renderer-BDdzHOwK.js → markdown-renderer-C88PtReb.js} +1 -1
- package/dist/assets/{name-cell-input-68gHDuvg.js → name-cell-input-CGI--sKC.js} +1 -1
- package/dist/assets/{outline-panel-Dr0105mz.js → outline-panel-DduwH0R5.js} +1 -1
- package/dist/assets/{packages-panel-CZHZDUXZ.js → packages-panel-B5Y9C0yo.js} +1 -1
- package/dist/assets/{panels-DkMIu1eO.js → panels-pUxQODxa.js} +1 -1
- package/dist/assets/{process-output-CGSREMph.js → process-output-DHZBktnU.js} +1 -1
- package/dist/assets/{readonly-python-code-3lQBDicq.js → readonly-python-code-Dq9SF5-p.js} +1 -1
- package/dist/assets/{run-page-DX60GJ1i.js → run-page-D2jwK6o6.js} +1 -1
- package/dist/assets/{scratchpad-panel-DxI-sH1n.js → scratchpad-panel-Csksnaaw.js} +1 -1
- package/dist/assets/{session-panel-DxZNtbiE.js → session-panel-BRmjEs5F.js} +1 -1
- package/dist/assets/{snippets-panel-CFXjJW29.js → snippets-panel-ubvMnyzj.js} +1 -1
- package/dist/assets/{state-BFn0AerH.js → state-Bf4SryDJ.js} +1 -1
- package/dist/assets/{state-CDUQVvOe.js → state-CwzLXxsb.js} +1 -1
- package/dist/assets/{textarea-CWy4stSy.js → textarea-BDH7sBL4.js} +1 -1
- package/dist/assets/{tracing-CIygWG5q.js → tracing-COHme3AD.js} +1 -1
- package/dist/assets/{tracing-panel-Dk7FE-7H.js → tracing-panel-D9XhFJ9Z.js} +2 -2
- package/dist/assets/{useAddCell-BZ5oFC7U.js → useAddCell-0FR_uwoE.js} +1 -1
- package/dist/assets/{useCellActionButton-Dd3hgOb6.js → useCellActionButton-B7pS3y8i.js} +1 -1
- package/dist/assets/{useDeleteCell-BHcPGuXL.js → useDeleteCell-BoljMURw.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-B94SJnJl.js → useDependencyPanelTab-CxZaWEsQ.js} +1 -1
- package/dist/assets/{useNotebookActions-PmHNCN16.js → useNotebookActions-D-wDki2H.js} +1 -1
- package/dist/assets/{useRunCells-BJn5ZEb6.js → useRunCells-CAi-cJkW.js} +1 -1
- package/dist/assets/{useSplitCell-Bfb8riCm.js → useSplitCell-D88B-tBq.js} +1 -1
- package/dist/index.html +25 -25
- package/package.json +1 -1
- package/src/components/data-table/__tests__/filters.test.ts +304 -0
- package/src/components/data-table/filters.ts +87 -33
- package/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap +4 -14
- package/src/core/codemirror/cells/extensions.ts +0 -4
- package/src/core/codemirror/keymaps/keymaps.ts +69 -2
- package/src/plugins/impl/DataTablePlugin.tsx +7 -20
- package/src/plugins/impl/data-frames/DataFramePlugin.tsx +4 -4
- package/src/plugins/impl/data-frames/schema.ts +41 -9
- package/src/plugins/impl/data-frames/utils/operators.ts +2 -0
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
"use no memo";
|
|
3
3
|
|
|
4
|
-
import type { RowData } from "@tanstack/react-table";
|
|
4
|
+
import type { ColumnFiltersState, RowData } from "@tanstack/react-table";
|
|
5
5
|
import type { DataType } from "@/core/kernel/messages";
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
FilterConditionType,
|
|
8
|
+
FilterGroupType,
|
|
9
|
+
} from "@/plugins/impl/data-frames/schema";
|
|
7
10
|
import type { ColumnId } from "@/plugins/impl/data-frames/types";
|
|
8
11
|
import type { OperatorType } from "@/plugins/impl/data-frames/utils/operators";
|
|
9
12
|
import { assertNever } from "@/utils/assertNever";
|
|
@@ -84,28 +87,34 @@ export type ColumnFilterForType<T extends FilterType> = T extends FilterType
|
|
|
84
87
|
export function filterToFilterCondition(
|
|
85
88
|
columnIdString: string,
|
|
86
89
|
filter: ColumnFilterValue | undefined,
|
|
87
|
-
):
|
|
90
|
+
): FilterConditionType[] {
|
|
88
91
|
if (!filter) {
|
|
89
92
|
return [];
|
|
90
93
|
}
|
|
91
94
|
const columnId = columnIdString as ColumnId;
|
|
92
95
|
|
|
93
96
|
if (filter.operator === "is_null" || filter.operator === "is_not_null") {
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
return [
|
|
98
|
+
{
|
|
99
|
+
column_id: columnId,
|
|
100
|
+
operator: filter.operator,
|
|
101
|
+
value: undefined,
|
|
102
|
+
type: "condition",
|
|
103
|
+
negate: false,
|
|
104
|
+
},
|
|
105
|
+
];
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
switch (filter.type) {
|
|
102
109
|
case "number": {
|
|
103
|
-
const conditions:
|
|
110
|
+
const conditions: FilterConditionType[] = [];
|
|
104
111
|
if (filter.min !== undefined) {
|
|
105
112
|
conditions.push({
|
|
106
113
|
column_id: columnId,
|
|
107
114
|
operator: ">=",
|
|
108
115
|
value: filter.min,
|
|
116
|
+
type: "condition",
|
|
117
|
+
negate: false,
|
|
109
118
|
});
|
|
110
119
|
}
|
|
111
120
|
if (filter.max !== undefined) {
|
|
@@ -113,23 +122,31 @@ export function filterToFilterCondition(
|
|
|
113
122
|
column_id: columnId,
|
|
114
123
|
operator: "<=",
|
|
115
124
|
value: filter.max,
|
|
125
|
+
type: "condition",
|
|
126
|
+
negate: false,
|
|
116
127
|
});
|
|
117
128
|
}
|
|
118
129
|
return conditions;
|
|
119
130
|
}
|
|
120
131
|
case "text":
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
return [
|
|
133
|
+
{
|
|
134
|
+
column_id: columnId,
|
|
135
|
+
operator: filter.operator,
|
|
136
|
+
value: filter.text,
|
|
137
|
+
type: "condition",
|
|
138
|
+
negate: false,
|
|
139
|
+
},
|
|
140
|
+
];
|
|
126
141
|
case "datetime": {
|
|
127
|
-
const conditions:
|
|
142
|
+
const conditions: FilterConditionType[] = [];
|
|
128
143
|
if (filter.min !== undefined) {
|
|
129
144
|
conditions.push({
|
|
130
145
|
column_id: columnId,
|
|
131
146
|
operator: ">=",
|
|
132
147
|
value: filter.min.toISOString(),
|
|
148
|
+
type: "condition",
|
|
149
|
+
negate: false,
|
|
133
150
|
});
|
|
134
151
|
}
|
|
135
152
|
if (filter.max !== undefined) {
|
|
@@ -137,17 +154,21 @@ export function filterToFilterCondition(
|
|
|
137
154
|
column_id: columnId,
|
|
138
155
|
operator: "<=",
|
|
139
156
|
value: filter.max.toISOString(),
|
|
157
|
+
type: "condition",
|
|
158
|
+
negate: false,
|
|
140
159
|
});
|
|
141
160
|
}
|
|
142
161
|
return conditions;
|
|
143
162
|
}
|
|
144
163
|
case "date": {
|
|
145
|
-
const conditions:
|
|
164
|
+
const conditions: FilterConditionType[] = [];
|
|
146
165
|
if (filter.min !== undefined) {
|
|
147
166
|
conditions.push({
|
|
148
167
|
column_id: columnId,
|
|
149
168
|
operator: ">=",
|
|
150
169
|
value: filter.min.toISOString(),
|
|
170
|
+
type: "condition",
|
|
171
|
+
negate: false,
|
|
151
172
|
});
|
|
152
173
|
}
|
|
153
174
|
if (filter.max !== undefined) {
|
|
@@ -155,17 +176,21 @@ export function filterToFilterCondition(
|
|
|
155
176
|
column_id: columnId,
|
|
156
177
|
operator: "<=",
|
|
157
178
|
value: filter.max.toISOString(),
|
|
179
|
+
type: "condition",
|
|
180
|
+
negate: false,
|
|
158
181
|
});
|
|
159
182
|
}
|
|
160
183
|
return conditions;
|
|
161
184
|
}
|
|
162
185
|
case "time": {
|
|
163
|
-
const conditions:
|
|
186
|
+
const conditions: FilterConditionType[] = [];
|
|
164
187
|
if (filter.min !== undefined) {
|
|
165
188
|
conditions.push({
|
|
166
189
|
column_id: columnId,
|
|
167
190
|
operator: ">=",
|
|
168
191
|
value: filter.min.toISOString(),
|
|
192
|
+
type: "condition",
|
|
193
|
+
negate: false,
|
|
169
194
|
});
|
|
170
195
|
}
|
|
171
196
|
if (filter.max !== undefined) {
|
|
@@ -173,24 +198,34 @@ export function filterToFilterCondition(
|
|
|
173
198
|
column_id: columnId,
|
|
174
199
|
operator: "<=",
|
|
175
200
|
value: filter.max.toISOString(),
|
|
201
|
+
type: "condition",
|
|
202
|
+
negate: false,
|
|
176
203
|
});
|
|
177
204
|
}
|
|
178
205
|
return conditions;
|
|
179
206
|
}
|
|
180
207
|
case "boolean":
|
|
181
208
|
if (filter.value) {
|
|
182
|
-
return
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
209
|
+
return [
|
|
210
|
+
{
|
|
211
|
+
column_id: columnId,
|
|
212
|
+
operator: "is_true",
|
|
213
|
+
value: undefined,
|
|
214
|
+
type: "condition",
|
|
215
|
+
negate: false,
|
|
216
|
+
},
|
|
217
|
+
];
|
|
187
218
|
}
|
|
188
219
|
if (!filter.value) {
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
220
|
+
return [
|
|
221
|
+
{
|
|
222
|
+
column_id: columnId,
|
|
223
|
+
operator: "is_false",
|
|
224
|
+
value: undefined,
|
|
225
|
+
type: "condition",
|
|
226
|
+
negate: false,
|
|
227
|
+
},
|
|
228
|
+
];
|
|
194
229
|
}
|
|
195
230
|
|
|
196
231
|
return [];
|
|
@@ -200,16 +235,35 @@ export function filterToFilterCondition(
|
|
|
200
235
|
Logger.warn("Invalid operator for select filter", {
|
|
201
236
|
operator: filter.operator,
|
|
202
237
|
});
|
|
203
|
-
operator = "in";
|
|
238
|
+
operator = "in";
|
|
204
239
|
}
|
|
205
|
-
return
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
240
|
+
return [
|
|
241
|
+
{
|
|
242
|
+
column_id: columnId,
|
|
243
|
+
operator,
|
|
244
|
+
value: filter.options,
|
|
245
|
+
type: "condition",
|
|
246
|
+
negate: false,
|
|
247
|
+
},
|
|
248
|
+
];
|
|
210
249
|
}
|
|
211
250
|
|
|
212
251
|
default:
|
|
213
252
|
assertNever(filter);
|
|
214
253
|
}
|
|
215
254
|
}
|
|
255
|
+
|
|
256
|
+
export function filtersToFilterGroup(
|
|
257
|
+
columnFilters: ColumnFiltersState,
|
|
258
|
+
): FilterGroupType {
|
|
259
|
+
const conditions = columnFilters.flatMap((filter) =>
|
|
260
|
+
filterToFilterCondition(filter.id, filter.value as ColumnFilterValue),
|
|
261
|
+
);
|
|
262
|
+
// To maintain existing behavior "and" all the conditions
|
|
263
|
+
return {
|
|
264
|
+
type: "group",
|
|
265
|
+
operator: "and",
|
|
266
|
+
children: conditions,
|
|
267
|
+
negate: false,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
@@ -9,9 +9,7 @@ exports[`snapshot all duplicate keymaps > default keymaps 2`] = `
|
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"key": "ArrowDown",
|
|
12
|
-
"preventDefault": true,
|
|
13
12
|
"run": "run",
|
|
14
|
-
"stopPropagation": true,
|
|
15
13
|
},
|
|
16
14
|
{
|
|
17
15
|
"key": "ArrowDown",
|
|
@@ -27,9 +25,7 @@ exports[`snapshot all duplicate keymaps > default keymaps 2`] = `
|
|
|
27
25
|
},
|
|
28
26
|
{
|
|
29
27
|
"key": "ArrowUp",
|
|
30
|
-
"preventDefault": true,
|
|
31
28
|
"run": "run",
|
|
32
|
-
"stopPropagation": true,
|
|
33
29
|
},
|
|
34
30
|
{
|
|
35
31
|
"key": "ArrowUp",
|
|
@@ -118,15 +114,12 @@ exports[`snapshot all duplicate keymaps > vim keymaps 2`] = `
|
|
|
118
114
|
},
|
|
119
115
|
{
|
|
120
116
|
"key": "ArrowDown",
|
|
121
|
-
"preventDefault": true,
|
|
122
117
|
"run": "run",
|
|
123
|
-
"stopPropagation": true,
|
|
124
118
|
},
|
|
125
119
|
{
|
|
126
120
|
"key": "ArrowDown",
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"shift": "selectLineDown",
|
|
121
|
+
"run": "<no name>",
|
|
122
|
+
"shift": "<no name>",
|
|
130
123
|
},
|
|
131
124
|
],
|
|
132
125
|
"ArrowUp": [
|
|
@@ -136,15 +129,12 @@ exports[`snapshot all duplicate keymaps > vim keymaps 2`] = `
|
|
|
136
129
|
},
|
|
137
130
|
{
|
|
138
131
|
"key": "ArrowUp",
|
|
139
|
-
"preventDefault": true,
|
|
140
132
|
"run": "run",
|
|
141
|
-
"stopPropagation": true,
|
|
142
133
|
},
|
|
143
134
|
{
|
|
144
135
|
"key": "ArrowUp",
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"shift": "selectLineUp",
|
|
136
|
+
"run": "<no name>",
|
|
137
|
+
"shift": "<no name>",
|
|
148
138
|
},
|
|
149
139
|
],
|
|
150
140
|
"Backspace": [
|
|
@@ -169,8 +169,6 @@ function cellKeymaps({
|
|
|
169
169
|
},
|
|
170
170
|
{
|
|
171
171
|
key: "ArrowUp",
|
|
172
|
-
preventDefault: true,
|
|
173
|
-
stopPropagation: true,
|
|
174
172
|
run: (ev) => {
|
|
175
173
|
// Skip if we are in the middle of an autocompletion
|
|
176
174
|
const hasAutocomplete = completionStatus(ev.state);
|
|
@@ -188,8 +186,6 @@ function cellKeymaps({
|
|
|
188
186
|
},
|
|
189
187
|
{
|
|
190
188
|
key: "ArrowDown",
|
|
191
|
-
preventDefault: true,
|
|
192
|
-
stopPropagation: true,
|
|
193
189
|
run: (ev) => {
|
|
194
190
|
// Skip if we are in the middle of an autocompletion
|
|
195
191
|
const hasAutocomplete = completionStatus(ev.state);
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
cursorCharLeft,
|
|
5
|
+
cursorCharRight,
|
|
6
|
+
cursorLineDown,
|
|
7
|
+
cursorLineUp,
|
|
4
8
|
insertNewlineAndIndent,
|
|
5
9
|
defaultKeymap as originalDefaultKeymap,
|
|
10
|
+
selectCharLeft,
|
|
11
|
+
selectCharRight,
|
|
12
|
+
selectLineDown,
|
|
13
|
+
selectLineUp,
|
|
6
14
|
toggleBlockComment,
|
|
7
15
|
toggleComment,
|
|
8
16
|
} from "@codemirror/commands";
|
|
@@ -13,7 +21,7 @@ import {
|
|
|
13
21
|
type KeyBinding,
|
|
14
22
|
keymap,
|
|
15
23
|
} from "@codemirror/view";
|
|
16
|
-
import { getCM, vim } from "@replit/codemirror-vim";
|
|
24
|
+
import { type CodeMirror, getCM, vim } from "@replit/codemirror-vim";
|
|
17
25
|
import type { KeymapConfig } from "@/core/config/config-schema";
|
|
18
26
|
import type { HotkeyProvider } from "@/core/hotkeys/hotkeys";
|
|
19
27
|
import { logNever } from "@/utils/assertNever";
|
|
@@ -62,6 +70,12 @@ export function keymapBundle(
|
|
|
62
70
|
},
|
|
63
71
|
),
|
|
64
72
|
),
|
|
73
|
+
// Arrow keys: use CodeMirror's cursor movement except in vim visual
|
|
74
|
+
// mode, where vim must handle them to maintain selection.
|
|
75
|
+
// The original cursorLineUp/Down bindings from the default keymap are
|
|
76
|
+
// filtered out (see defaultVimKeymap) because their preventDefault
|
|
77
|
+
// flag blocks vim's handler even when their run function returns false.
|
|
78
|
+
keymap.of(vimVisualModeArrowKeyBindings()),
|
|
65
79
|
// Base vim mode
|
|
66
80
|
vim({ status: false }),
|
|
67
81
|
// Custom vim keymaps for cell navigation
|
|
@@ -101,12 +115,22 @@ const overrideKeymap = (keymap: HotkeyProvider): readonly KeyBinding[] => {
|
|
|
101
115
|
};
|
|
102
116
|
|
|
103
117
|
const defaultVimKeymap = once(() => {
|
|
104
|
-
const toRemove = new Set([
|
|
118
|
+
const toRemove = new Set([
|
|
119
|
+
"Enter",
|
|
120
|
+
"Ctrl-v",
|
|
121
|
+
"ArrowUp",
|
|
122
|
+
"ArrowDown",
|
|
123
|
+
"ArrowLeft",
|
|
124
|
+
"ArrowRight",
|
|
125
|
+
]);
|
|
105
126
|
// Remove conflicting keys from the keymap
|
|
106
127
|
// Enter (<CR>) adds a new line
|
|
107
128
|
// - it should just go to the next line
|
|
108
129
|
// Ctrl-v goes to the bottom of the cell
|
|
109
130
|
// - should enter blockwise visual mode
|
|
131
|
+
// ArrowUp/ArrowDown (cursorLineUp/Down) always handle the event and have
|
|
132
|
+
// preventDefault, which blocks vim's handler from processing arrow keys.
|
|
133
|
+
// Replaced with visual-mode-aware wrappers in keymapBundle.
|
|
110
134
|
return defaultKeymap().filter(
|
|
111
135
|
(k) => !toRemove.has(k.key || k.mac || k.linux || k.win || ""),
|
|
112
136
|
);
|
|
@@ -155,6 +179,49 @@ function doubleCharacterListener(
|
|
|
155
179
|
]);
|
|
156
180
|
}
|
|
157
181
|
|
|
182
|
+
function isInVimVisualMode(cm: CodeMirror | undefined | null): boolean {
|
|
183
|
+
return cm?.state.vim?.visualMode === true;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* In vim visual mode, arrow keys must be handled by vim to maintain selection.
|
|
188
|
+
* Wrap each arrow key's run and shift so they defer to vim in visual mode,
|
|
189
|
+
* but use CodeMirror's cursor commands in all other modes.
|
|
190
|
+
*/
|
|
191
|
+
function vimVisualModeArrowKeyBindings(): KeyBinding[] {
|
|
192
|
+
const wrap =
|
|
193
|
+
(cmd: Command): Command =>
|
|
194
|
+
(view) => {
|
|
195
|
+
if (isInVimVisualMode(getCM(view))) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
return cmd(view);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
return [
|
|
202
|
+
{
|
|
203
|
+
key: "ArrowDown",
|
|
204
|
+
run: wrap(cursorLineDown),
|
|
205
|
+
shift: wrap(selectLineDown),
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
key: "ArrowUp",
|
|
209
|
+
run: wrap(cursorLineUp),
|
|
210
|
+
shift: wrap(selectLineUp),
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
key: "ArrowLeft",
|
|
214
|
+
run: wrap(cursorCharLeft),
|
|
215
|
+
shift: wrap(selectCharLeft),
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
key: "ArrowRight",
|
|
219
|
+
run: wrap(cursorCharRight),
|
|
220
|
+
shift: wrap(selectCharRight),
|
|
221
|
+
},
|
|
222
|
+
];
|
|
223
|
+
}
|
|
224
|
+
|
|
158
225
|
export const visibleForTesting = {
|
|
159
226
|
defaultKeymap,
|
|
160
227
|
defaultVimKeymap,
|
|
@@ -28,10 +28,7 @@ import { TablePanel } from "@/components/data-table/charts/charts";
|
|
|
28
28
|
import { hasChart } from "@/components/data-table/charts/storage";
|
|
29
29
|
import { ColumnChartSpecModel } from "@/components/data-table/column-summary/chart-spec-model";
|
|
30
30
|
import { ColumnChartContext } from "@/components/data-table/column-summary/column-summary";
|
|
31
|
-
import {
|
|
32
|
-
type ColumnFilterValue,
|
|
33
|
-
filterToFilterCondition,
|
|
34
|
-
} from "@/components/data-table/filters";
|
|
31
|
+
import { filtersToFilterGroup } from "@/components/data-table/filters";
|
|
35
32
|
import { usePanelOwnership } from "@/components/data-table/hooks/use-panel-ownership";
|
|
36
33
|
import { LoadingTable } from "@/components/data-table/loading-table";
|
|
37
34
|
import {
|
|
@@ -86,8 +83,8 @@ import { rpc } from "../core/rpc";
|
|
|
86
83
|
import { Banner } from "./common/error-banner";
|
|
87
84
|
import { Labeled } from "./common/labeled";
|
|
88
85
|
import {
|
|
89
|
-
|
|
90
|
-
type
|
|
86
|
+
FilterGroupSchema,
|
|
87
|
+
type FilterGroupType,
|
|
91
88
|
columnToFieldTypesSchema,
|
|
92
89
|
} from "./data-frames/schema";
|
|
93
90
|
|
|
@@ -213,7 +210,7 @@ type DataTableFunctions = {
|
|
|
213
210
|
descending: boolean;
|
|
214
211
|
}[];
|
|
215
212
|
query?: string;
|
|
216
|
-
filters?:
|
|
213
|
+
filters?: FilterGroupType;
|
|
217
214
|
page_number: number;
|
|
218
215
|
page_size: number;
|
|
219
216
|
max_columns?: number | null;
|
|
@@ -312,7 +309,7 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")
|
|
|
312
309
|
)
|
|
313
310
|
.optional(),
|
|
314
311
|
query: z.string().optional(),
|
|
315
|
-
filters:
|
|
312
|
+
filters: FilterGroupSchema.optional(),
|
|
316
313
|
page_number: z.number(),
|
|
317
314
|
page_size: z.number(),
|
|
318
315
|
max_columns: z.number().nullable().optional(),
|
|
@@ -578,12 +575,7 @@ export const LoadingDataTableComponent = memo(
|
|
|
578
575
|
query: searchQuery,
|
|
579
576
|
page_number: paginationState.pageIndex,
|
|
580
577
|
page_size: paginationState.pageSize,
|
|
581
|
-
filters: filters
|
|
582
|
-
return filterToFilterCondition(
|
|
583
|
-
filter.id,
|
|
584
|
-
filter.value as ColumnFilterValue,
|
|
585
|
-
);
|
|
586
|
-
}),
|
|
578
|
+
filters: filtersToFilterGroup(filters),
|
|
587
579
|
});
|
|
588
580
|
|
|
589
581
|
if (canShowInitialPage) {
|
|
@@ -641,12 +633,7 @@ export const LoadingDataTableComponent = memo(
|
|
|
641
633
|
page_size: 1,
|
|
642
634
|
sort: sortArgs,
|
|
643
635
|
query: searchQuery,
|
|
644
|
-
filters: filters
|
|
645
|
-
return filterToFilterCondition(
|
|
646
|
-
filter.id,
|
|
647
|
-
filter.value as ColumnFilterValue,
|
|
648
|
-
);
|
|
649
|
-
}),
|
|
636
|
+
filters: filtersToFilterGroup(filters),
|
|
650
637
|
// Do not clamp number of columns since we are viewing a single row
|
|
651
638
|
max_columns: null,
|
|
652
639
|
});
|
|
@@ -29,8 +29,8 @@ import { LoadingDataTableComponent, TableProviders } from "../DataTablePlugin";
|
|
|
29
29
|
import type { DataType } from "../vega/vega-loader";
|
|
30
30
|
import { TransformPanel, type TransformPanelHandle } from "./panel";
|
|
31
31
|
import {
|
|
32
|
-
|
|
33
|
-
type
|
|
32
|
+
FilterGroupSchema,
|
|
33
|
+
type FilterGroupType,
|
|
34
34
|
columnToFieldTypesSchema,
|
|
35
35
|
type Transformations,
|
|
36
36
|
} from "./schema";
|
|
@@ -75,7 +75,7 @@ type PluginFunctions = {
|
|
|
75
75
|
descending: boolean;
|
|
76
76
|
}[];
|
|
77
77
|
query?: string;
|
|
78
|
-
filters?:
|
|
78
|
+
filters?: FilterGroupType;
|
|
79
79
|
page_number: number;
|
|
80
80
|
page_size: number;
|
|
81
81
|
}) => Promise<{
|
|
@@ -138,7 +138,7 @@ export const DataFramePlugin = createPlugin<S>("marimo-dataframe")
|
|
|
138
138
|
)
|
|
139
139
|
.optional(),
|
|
140
140
|
query: z.string().optional(),
|
|
141
|
-
filters:
|
|
141
|
+
filters: FilterGroupSchema.optional(),
|
|
142
142
|
page_number: z.number(),
|
|
143
143
|
page_size: z.number(),
|
|
144
144
|
}),
|
|
@@ -73,16 +73,36 @@ const SortColumnTransformSchema = z.object({
|
|
|
73
73
|
.default("last"),
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
export const
|
|
76
|
+
export const FilterConditionSchema = z
|
|
77
77
|
.object({
|
|
78
78
|
column_id: column_id,
|
|
79
79
|
operator: z
|
|
80
80
|
.enum(Object.keys(ALL_OPERATORS) as [OperatorType, ...OperatorType[]])
|
|
81
81
|
.describe(FieldOptions.of({ label: " " })),
|
|
82
|
+
type: z.literal("condition").default("condition"),
|
|
82
83
|
value: z.any().describe(FieldOptions.of({ label: "Value" })),
|
|
84
|
+
negate: z.boolean().default(false),
|
|
83
85
|
})
|
|
84
86
|
.describe(FieldOptions.of({ direction: "row", special: "column_filter" }));
|
|
85
|
-
export type
|
|
87
|
+
export type FilterConditionType = z.infer<typeof FilterConditionSchema>;
|
|
88
|
+
|
|
89
|
+
export interface FilterGroupType {
|
|
90
|
+
type: "group";
|
|
91
|
+
operator: "and" | "or";
|
|
92
|
+
children: (FilterConditionType | FilterGroupType)[];
|
|
93
|
+
negate: boolean;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const FilterGroupSchema: z.ZodType<FilterGroupType> = z.lazy(() =>
|
|
97
|
+
z.object({
|
|
98
|
+
type: z.literal("group").default("group"),
|
|
99
|
+
operator: z.enum(["and", "or"]).default("and"),
|
|
100
|
+
children: z
|
|
101
|
+
.array(z.union([FilterConditionSchema, FilterGroupSchema]))
|
|
102
|
+
.default([]),
|
|
103
|
+
negate: z.boolean().default(false),
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
86
106
|
|
|
87
107
|
const FilterRowsTransformSchema = z.object({
|
|
88
108
|
type: z.literal("filter_rows"),
|
|
@@ -91,17 +111,29 @@ const FilterRowsTransformSchema = z.object({
|
|
|
91
111
|
.default("keep_rows")
|
|
92
112
|
.describe(FieldOptions.of({ special: "radio_group" })),
|
|
93
113
|
where: z
|
|
94
|
-
.array(
|
|
114
|
+
.array(FilterConditionSchema)
|
|
95
115
|
.min(1)
|
|
96
116
|
.describe(FieldOptions.of({ label: "Value", minLength: 1 }))
|
|
97
|
-
.
|
|
98
|
-
|
|
117
|
+
.default(() => [
|
|
118
|
+
{
|
|
119
|
+
column_id: "" as ColumnId,
|
|
120
|
+
operator: "==" as const,
|
|
121
|
+
value: "",
|
|
122
|
+
type: "condition" as const,
|
|
123
|
+
negate: false,
|
|
124
|
+
},
|
|
125
|
+
])
|
|
126
|
+
.transform((value): FilterGroupType => {
|
|
127
|
+
const validConditions = value.filter((condition) => {
|
|
99
128
|
return isConditionValueValid(condition.operator, condition.value);
|
|
100
129
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
130
|
+
return {
|
|
131
|
+
type: "group",
|
|
132
|
+
operator: "and",
|
|
133
|
+
children: validConditions,
|
|
134
|
+
negate: false,
|
|
135
|
+
};
|
|
136
|
+
}),
|
|
105
137
|
});
|
|
106
138
|
|
|
107
139
|
const GroupByTransformSchema = z
|
|
@@ -41,6 +41,7 @@ const createComparisonOperators = (schema: z.ZodType) => ({
|
|
|
41
41
|
">=": [schema],
|
|
42
42
|
"<": [schema],
|
|
43
43
|
"<=": [schema],
|
|
44
|
+
between: [z.object({ min: schema, max: schema })],
|
|
44
45
|
is_null: [],
|
|
45
46
|
is_not_null: [],
|
|
46
47
|
});
|
|
@@ -59,6 +60,7 @@ export const STRING_OPERATORS = {
|
|
|
59
60
|
ends_with: [Schema.string],
|
|
60
61
|
in: [Schema.stringMultiColumnValues],
|
|
61
62
|
not_in: [Schema.stringMultiColumnValues],
|
|
63
|
+
is_empty: [],
|
|
62
64
|
is_null: [],
|
|
63
65
|
is_not_null: [],
|
|
64
66
|
};
|