Skip to content

Commit cc91fea

Browse files
committed
update zod to v4-mini and adjust schema definitions for compatibility
1 parent d039e7a commit cc91fea

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sqlpage_spreadsheet",
3-
"version": "0.5.1",
3+
"version": "0.6.0",
44
"description": "sqlpage spreadsheet component",
55
"source": "./src/spreadsheet_component.html",
66
"browserslist": "> 3%, last 2 versions, not dead",
@@ -25,7 +25,7 @@
2525
},
2626
"dependencies": {
2727
"@univerjs/presets": "^0.7.0",
28-
"zod": "^3.24.1"
28+
"zod": "^3.25"
2929
},
3030
"@parcel/bundler-default": {
3131
"minBundleSize": 60000

src/spreadsheet.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const univerPresetsSheets = import("@univerjs/presets/preset-sheets-core");
3030
const univerPresetsSheetsLocale = import(
3131
"@univerjs/presets/preset-sheets-core/locales/en-US"
3232
);
33-
const zod = import("zod");
33+
const zod = import("zod/v4-mini");
3434

3535
const NUMBER_CELL_TYPE: typeof CellValueType.NUMBER = 2;
3636
const DEBUG = window?.location?.search?.includes("_debug_spreadsheet");
@@ -299,33 +299,35 @@ function handleSetRangeValues(
299299
}
300300
}
301301

302-
type Zod = typeof import("zod");
302+
import type * as ZodNS from "zod/v4-mini";
303+
type Zod = typeof ZodNS.z;
303304

304305
const PropsSchema = (z: Zod) =>
305306
z.object({
306-
update_link: z.string().optional(),
307-
sheet_name: z.string().default("SQLPage Data"),
308-
freeze_x: z.number().int().nonnegative().default(0),
309-
freeze_y: z.number().int().nonnegative().default(0),
310-
column_width: z.number().int().nonnegative().optional(),
311-
row_height: z.number().int().nonnegative().optional(),
312-
show_grid: z.boolean().default(true),
307+
update_link: z.optional(z.string()),
308+
sheet_name: z._default(z.string(), "SQLPage Data"),
309+
freeze_x: z._default(z.number().check(z.int(), z.nonnegative()), 0),
310+
freeze_y: z._default(z.number().check(z.int(), z.nonnegative()), 0),
311+
column_width: z._default(z.number().check(z.int(), z.nonnegative()), 100),
312+
row_height: z._default(z.number().check(z.int(), z.nonnegative()), 20),
313+
show_grid: z._default(z.boolean(), true),
313314
});
314315

315-
type Props = Zod.infer<ReturnType<typeof PropsSchema>>;
316+
type Props = ZodNS.infer<ReturnType<typeof PropsSchema>>;
316317

317318
const CellPropsSchema = (z: Zod) => z.union([z.string(), z.number()]);
318319

319320
const DataArraySchema = (z: Zod) =>
320-
z
321-
.tuple([
322-
z.number().int().nonnegative(),
323-
z.number().int().nonnegative(),
321+
z.tuple(
322+
[
323+
z.number().check(z.int(), z.nonnegative()),
324+
z.number().check(z.int(), z.nonnegative()),
324325
z.union([z.string(), z.number(), z.null()]),
325-
])
326-
.rest(CellPropsSchema(z));
326+
],
327+
CellPropsSchema(z),
328+
);
327329

328-
type CellProps = Zod.infer<ReturnType<typeof CellPropsSchema>>;
330+
type CellProps = ZodNS.infer<ReturnType<typeof CellPropsSchema>>;
329331

330332
export async function renderSpreadsheetToElement(element: HTMLElement) {
331333
try {

0 commit comments

Comments
 (0)