Skip to content

Commit 0182a8e

Browse files
authored
fix zod schema type errors for data-table (#6606)
1 parent 793eee8 commit 0182a8e

File tree

2 files changed

+131
-137
lines changed

2 files changed

+131
-137
lines changed

frontend/src/plugins/impl/DataTablePlugin.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ type DataTableFunctions = {
225225

226226
type S = (number | string | { rowId: string; columnName?: string })[];
227227

228+
const cellHoverTextSchema = z
229+
.record(z.string(), z.record(z.string(), z.string().nullable()))
230+
.optional();
231+
228232
export const DataTablePlugin = createPlugin<S>("marimo-table")
229233
.withData(
230234
z.object({
@@ -267,7 +271,7 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")
267271
.record(z.string(), z.record(z.string(), z.object({}).passthrough()))
268272
.optional(),
269273
hoverTemplate: z.string().optional(),
270-
cellHoverTexts: z.record(z.record(z.string().nullable())).optional(),
274+
cellHoverTexts: cellHoverTextSchema,
271275
// Whether to load the data lazily.
272276
lazy: z.boolean().default(false),
273277
// If lazy, this will preload the first page of data
@@ -313,9 +317,7 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")
313317
z.record(z.string(), z.object({}).passthrough()),
314318
)
315319
.nullable(),
316-
cell_hover_texts: z
317-
.record(z.record(z.string().nullable()))
318-
.nullable(),
320+
cell_hover_texts: cellHoverTextSchema,
319321
}),
320322
),
321323
get_row_ids: rpc.input(z.object({}).passthrough()).output(
@@ -363,12 +365,7 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")
363365
data={props.data.data}
364366
value={props.value}
365367
setValue={props.setValue}
366-
cellHoverTexts={
367-
props.data.cellHoverTexts as Record<
368-
string,
369-
Record<string, string | null>
370-
>
371-
}
368+
cellHoverTexts={props.data.cellHoverTexts}
372369
/>
373370
</LazyDataTableComponent>
374371
</TableProviders>
@@ -490,10 +487,7 @@ export const LoadingDataTableComponent = memo(
490487
let tableData = props.data;
491488
let totalRows = props.totalRows;
492489
let cellStyles = props.cellStyles;
493-
let cellHoverTexts = props.cellHoverTexts as
494-
| Record<string, Record<string, string | null>>
495-
| undefined
496-
| null;
490+
let cellHoverTexts = props.cellHoverTexts;
497491

498492
const pageSizeChanged = paginationState.pageSize !== props.pageSize;
499493

0 commit comments

Comments
 (0)