mtxuilib 0.1.91 → 0.1.93
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/common/DebugFormState.d.ts +4 -0
- package/dist/common/DebugFormState.js +11 -0
- package/dist/form/EditFormToolbar.js +7 -2
- package/dist/ui-mt/inputs/TaskStatusInput.js +1 -1
- package/package.json +1 -1
- package/dist/lib/zod/common.z.d.ts +0 -71
- package/dist/lib/zod/common.z.js +0 -37
- package/dist/lib/zod/demo.z.d.ts +0 -1
- package/dist/lib/zod/demo.z.js +0 -3
- package/dist/lib/zod/listView.z.d.ts +0 -7688
- package/dist/lib/zod/listView.z.js +0 -131
- package/dist/lib/zod/meta.d.ts +0 -51
- package/dist/lib/zod/meta.js +0 -16
- package/dist/lib/zod/msg.z.d.ts +0 -9
- package/dist/lib/zod/msg.z.js +0 -4
- package/dist/lib/zod/taskStatus.z.d.ts +0 -17
- package/dist/lib/zod/taskStatus.z.js +0 -29
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
export const DebugFormState = (props) => {
|
|
4
|
+
const { form } = props;
|
|
5
|
+
useMemo(() => {
|
|
6
|
+
if (form?.formState?.errors && Object.keys(form?.formState?.errors).length > 0) {
|
|
7
|
+
console.warn("DebugFormState", form?.formState?.errors);
|
|
8
|
+
}
|
|
9
|
+
}, [form?.formState?.errors]);
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef, useState } from "react";
|
|
3
|
+
import { forwardRef, useMemo, useState } from "react";
|
|
4
4
|
import { useFormContext } from "react-hook-form";
|
|
5
5
|
import { cn } from "../lib/utils";
|
|
6
6
|
import { MtButton } from "../ui-mt/Button";
|
|
@@ -11,10 +11,15 @@ export const EditFormToolbar = forwardRef((props, forwardedRef) => {
|
|
|
11
11
|
const context = useFormContext();
|
|
12
12
|
const form = props.form ?? context;
|
|
13
13
|
const { formState } = form;
|
|
14
|
+
useMemo(() => {
|
|
15
|
+
if (form.formState.errors && Object.keys(form.formState.errors).length) {
|
|
16
|
+
console.log("表单不正确", form.formState.errors);
|
|
17
|
+
}
|
|
18
|
+
}, [form.formState.errors]);
|
|
14
19
|
if (!form) {
|
|
15
20
|
throw new Error("SubmitButton must be used within a Form or have a form prop");
|
|
16
21
|
}
|
|
17
|
-
return (_jsxs("div", { className: "flex w-full
|
|
22
|
+
return (_jsxs("div", { className: "flex w-full flex-col p-1", children: [!openConform && (_jsxs("div", { className: "flex justify-end gap-2", children: [_jsx(MtButton, { variant: "outline", className: " min-w-24", onClick: (e) => {
|
|
18
23
|
e.preventDefault();
|
|
19
24
|
if (enableCancelConform && form?.formState?.isDirty) {
|
|
20
25
|
setOpenConform(true);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { TASK_STATUS, taskStatusSchema } from "mtxlib/zod/taskStatus.z";
|
|
3
4
|
import { useMemo } from "react";
|
|
4
5
|
import { useFormContext } from "react-hook-form";
|
|
5
|
-
import { TASK_STATUS, taskStatusSchema } from "../../lib/zod/taskStatus.z";
|
|
6
6
|
import { MtButton } from "../Button";
|
|
7
7
|
export const TaskStatusInput = (props) => {
|
|
8
8
|
const { name } = props;
|
package/package.json
CHANGED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const numStringSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodType<string | number, z.ZodTypeDef, string | number>, string | number, string | number>, string | number, string | number>, number, string | number>;
|
|
3
|
-
export type NumString = z.infer<typeof numStringSchema>;
|
|
4
|
-
export type Literal = boolean | number | string;
|
|
5
|
-
export type Json = Literal | {
|
|
6
|
-
[key: string]: Json;
|
|
7
|
-
} | Json[];
|
|
8
|
-
export declare const literalSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
9
|
-
export declare const jsonSchema: z.ZodSchema<Json>;
|
|
10
|
-
export declare const deleteByIdSchema: z.ZodObject<{
|
|
11
|
-
id: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodType<string | number, z.ZodTypeDef, string | number>, string | number, string | number>, string | number, string | number>, number, string | number>>;
|
|
12
|
-
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
id?: number | undefined;
|
|
14
|
-
}, {
|
|
15
|
-
id?: string | number | undefined;
|
|
16
|
-
}>;
|
|
17
|
-
export declare const PaginateQuery: z.ZodObject<{
|
|
18
|
-
cursor: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
19
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
20
|
-
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
cursor?: string | null | undefined;
|
|
22
|
-
limit?: number | undefined;
|
|
23
|
-
}, {
|
|
24
|
-
cursor?: string | null | undefined;
|
|
25
|
-
limit?: number | undefined;
|
|
26
|
-
}>;
|
|
27
|
-
export declare const curdViewTypeSchema: z.ZodDefault<z.ZodEnum<["simple", "table", "card", "grid"]>>;
|
|
28
|
-
export type CurdViewType = z.infer<typeof curdViewTypeSchema>;
|
|
29
|
-
export declare const mutationCreateOutSchema: z.ZodObject<{
|
|
30
|
-
code: z.ZodOptional<z.ZodString>;
|
|
31
|
-
description: z.ZodOptional<z.ZodString>;
|
|
32
|
-
message: z.ZodOptional<z.ZodString>;
|
|
33
|
-
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
code?: string | undefined;
|
|
35
|
-
message?: string | undefined;
|
|
36
|
-
description?: string | undefined;
|
|
37
|
-
}, {
|
|
38
|
-
code?: string | undefined;
|
|
39
|
-
message?: string | undefined;
|
|
40
|
-
description?: string | undefined;
|
|
41
|
-
}>;
|
|
42
|
-
export declare const env: z.SafeParseReturnType<{
|
|
43
|
-
DATABASE_URL: string;
|
|
44
|
-
NODE_ENV: "production" | "test" | "development";
|
|
45
|
-
}, {
|
|
46
|
-
DATABASE_URL: string;
|
|
47
|
-
NODE_ENV: "production" | "test" | "development";
|
|
48
|
-
}>;
|
|
49
|
-
export declare const commonDeleteInput: z.ZodObject<{
|
|
50
|
-
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
51
|
-
}, "strip", z.ZodTypeAny, {
|
|
52
|
-
id: string | number;
|
|
53
|
-
}, {
|
|
54
|
-
id: string | number;
|
|
55
|
-
}>;
|
|
56
|
-
export declare const ogImageSchema: z.ZodObject<{
|
|
57
|
-
heading: z.ZodString;
|
|
58
|
-
type: z.ZodString;
|
|
59
|
-
mode: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
60
|
-
bountyPrice: z.ZodString;
|
|
61
|
-
}, "strip", z.ZodTypeAny, {
|
|
62
|
-
type: string;
|
|
63
|
-
heading: string;
|
|
64
|
-
mode: "light" | "dark";
|
|
65
|
-
bountyPrice: string;
|
|
66
|
-
}, {
|
|
67
|
-
type: string;
|
|
68
|
-
heading: string;
|
|
69
|
-
bountyPrice: string;
|
|
70
|
-
mode?: "light" | "dark" | undefined;
|
|
71
|
-
}>;
|
package/dist/lib/zod/common.z.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const numStringSchema = z
|
|
3
|
-
.custom()
|
|
4
|
-
.refine((value) => value ?? false, "Required")
|
|
5
|
-
.refine((value) => Number.isFinite(Number(value)), "Invalid number")
|
|
6
|
-
.transform((value) => Number(value));
|
|
7
|
-
export const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
8
|
-
export const jsonSchema = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]));
|
|
9
|
-
export const deleteByIdSchema = z.object({
|
|
10
|
-
id: numStringSchema.optional(),
|
|
11
|
-
});
|
|
12
|
-
export const PaginateQuery = z.object({
|
|
13
|
-
cursor: z.string().nullish().optional(),
|
|
14
|
-
limit: z.number().min(1).max(1000).optional(),
|
|
15
|
-
});
|
|
16
|
-
export const curdViewTypeSchema = z
|
|
17
|
-
.enum(["simple", "table", "card", "grid"])
|
|
18
|
-
.default("simple");
|
|
19
|
-
export const mutationCreateOutSchema = z.object({
|
|
20
|
-
code: z.string().optional(),
|
|
21
|
-
description: z.string().optional(),
|
|
22
|
-
message: z.string().optional(),
|
|
23
|
-
});
|
|
24
|
-
const envSchema = z.object({
|
|
25
|
-
DATABASE_URL: z.string().url(),
|
|
26
|
-
NODE_ENV: z.enum(["development", "test", "production"]),
|
|
27
|
-
});
|
|
28
|
-
export const env = envSchema.safeParse(process.env);
|
|
29
|
-
export const commonDeleteInput = z.object({
|
|
30
|
-
id: z.string().or(z.number()),
|
|
31
|
-
});
|
|
32
|
-
export const ogImageSchema = z.object({
|
|
33
|
-
heading: z.string(),
|
|
34
|
-
type: z.string(),
|
|
35
|
-
mode: z.enum(["light", "dark"]).default("dark"),
|
|
36
|
-
bountyPrice: z.string(),
|
|
37
|
-
});
|
package/dist/lib/zod/demo.z.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/lib/zod/demo.z.js
DELETED