fuma 0.3.0 → 0.3.4
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/private/api.d.ts +14 -0
- package/dist/private/api.js +2 -1
- package/dist/private/constant.d.ts +14 -0
- package/dist/private/constant.js +6 -0
- package/dist/private/model.d.ts +46 -8
- package/dist/private/model.js +14 -6
- package/dist/server/parseFormData.js +21 -7
- package/dist/server/try.js +0 -1
- package/dist/ui/form/Form.svelte +5 -1
- package/dist/ui/form/Form.svelte.d.ts +9 -9
- package/dist/ui/form/FormInput.svelte.d.ts +4 -0
- package/dist/ui/form/formInput.d.ts +2 -0
- package/dist/ui/input/InputBoolean.svelte +4 -2
- package/dist/ui/input/InputDate.svelte +10 -7
- package/dist/ui/input/InputDate.svelte.d.ts +1 -1
- package/dist/ui/input/InputDatetime.svelte +24 -12
- package/dist/ui/input/InputDatetime.svelte.d.ts +2 -2
- package/dist/ui/input/InputNumber.svelte +12 -11
- package/dist/ui/input/InputNumber.svelte.d.ts +1 -1
- package/dist/ui/input/InputRelation.svelte +5 -3
- package/dist/ui/input/InputRelation.svelte.d.ts +2 -0
- package/dist/ui/input/InputRelations.svelte +5 -2
- package/dist/ui/input/InputRelations.svelte.d.ts +2 -0
- package/dist/ui/input/InputSelect.svelte +5 -2
- package/dist/ui/input/InputSelect.svelte.d.ts +1 -0
- package/dist/ui/input/textRich/extensions.js +1 -1
- package/dist/ui/table/head/TableHeadNumber.svelte +1 -1
- package/dist/utils/constant.d.ts +4 -1
- package/dist/utils/constant.js +4 -1
- package/dist/utils/options.d.ts +2 -1
- package/dist/validation/zod.d.ts +33 -37
- package/dist/validation/zod.js +6 -24
- package/package.json +7 -2
package/dist/private/api.d.ts
CHANGED
|
@@ -21,6 +21,13 @@ export declare const apiConfig: {
|
|
|
21
21
|
tags: true;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
+
PostType: (search: string) => {
|
|
25
|
+
where: {
|
|
26
|
+
name: {
|
|
27
|
+
contains: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
24
31
|
};
|
|
25
32
|
export declare const api: import("../api/config.js").ApiClient<Prisma.TypeMap<import("@prisma/client/runtime/library").DefaultArgs>, {
|
|
26
33
|
Tag: (search: string) => {
|
|
@@ -44,4 +51,11 @@ export declare const api: import("../api/config.js").ApiClient<Prisma.TypeMap<im
|
|
|
44
51
|
tags: true;
|
|
45
52
|
};
|
|
46
53
|
};
|
|
54
|
+
PostType: (search: string) => {
|
|
55
|
+
where: {
|
|
56
|
+
name: {
|
|
57
|
+
contains: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
47
61
|
}>;
|
package/dist/private/api.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { mdiAccountGroup, mdiFileLockOutline, mdiWeb } from '@mdi/js';
|
|
2
|
+
export const POST_PUBLICATION = {
|
|
3
|
+
private: { label: 'Private', icon: mdiFileLockOutline },
|
|
4
|
+
friends: { label: 'Friends', icon: mdiAccountGroup },
|
|
5
|
+
public: { label: 'Public', icon: mdiWeb }
|
|
6
|
+
};
|
package/dist/private/model.d.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
export declare const modelPost: {
|
|
2
|
+
title: import("zod").ZodString;
|
|
2
3
|
content: import("zod").ZodString;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
isFavourite: import("zod").ZodBoolean;
|
|
5
|
+
likeCount: import("zod").ZodNumber;
|
|
6
|
+
writingAt: import("zod").ZodDate;
|
|
7
|
+
writingDuration: import("zod").ZodDate;
|
|
8
|
+
isInteressing: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
9
|
+
viewCounter: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
10
|
+
publishedAt: import("zod").ZodOptional<import("zod").ZodDate>;
|
|
11
|
+
publishedAtTime: import("zod").ZodOptional<import("zod").ZodDate>;
|
|
12
|
+
publication: import("zod").ZodEnum<["private", "friends", "public"]>;
|
|
13
|
+
type: import("zod").ZodEffects<import("zod").ZodObject<{
|
|
14
|
+
id: import("zod").ZodString;
|
|
15
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
16
|
+
id: string;
|
|
17
|
+
}, {
|
|
18
|
+
id: string;
|
|
19
|
+
}>, {
|
|
20
|
+
connect: {
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
id: string;
|
|
25
|
+
}>;
|
|
7
26
|
tags: import("zod").ZodEffects<import("zod").ZodArray<import("zod").ZodObject<{
|
|
8
27
|
id: import("zod").ZodString;
|
|
9
28
|
}, "strip", import("zod").ZodTypeAny, {
|
|
@@ -29,11 +48,30 @@ export declare const modelPostUpdate: {
|
|
|
29
48
|
}[]>>, {
|
|
30
49
|
id: string;
|
|
31
50
|
}[]>;
|
|
51
|
+
title: import("zod").ZodString;
|
|
32
52
|
content: import("zod").ZodString;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
isFavourite: import("zod").ZodBoolean;
|
|
54
|
+
likeCount: import("zod").ZodNumber;
|
|
55
|
+
writingAt: import("zod").ZodDate;
|
|
56
|
+
writingDuration: import("zod").ZodDate;
|
|
57
|
+
isInteressing: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
58
|
+
viewCounter: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
59
|
+
publishedAt: import("zod").ZodOptional<import("zod").ZodDate>;
|
|
60
|
+
publishedAtTime: import("zod").ZodOptional<import("zod").ZodDate>;
|
|
61
|
+
publication: import("zod").ZodEnum<["private", "friends", "public"]>;
|
|
62
|
+
type: import("zod").ZodEffects<import("zod").ZodObject<{
|
|
63
|
+
id: import("zod").ZodString;
|
|
64
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
65
|
+
id: string;
|
|
66
|
+
}, {
|
|
67
|
+
id: string;
|
|
68
|
+
}>, {
|
|
69
|
+
connect: {
|
|
70
|
+
id: string;
|
|
71
|
+
};
|
|
72
|
+
}, {
|
|
73
|
+
id: string;
|
|
74
|
+
}>;
|
|
37
75
|
};
|
|
38
76
|
export declare const modelTag: {
|
|
39
77
|
name: import("zod").ZodString;
|
package/dist/private/model.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { z } from '../validation/zod.js';
|
|
1
|
+
import { toTuple, z } from '../validation/zod.js';
|
|
2
|
+
import { POST_PUBLICATION } from './constant.js';
|
|
2
3
|
export const modelPost = {
|
|
4
|
+
title: z.string().min(1, 'Required'),
|
|
3
5
|
content: z.string().min(10),
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
isFavourite: z.boolean(),
|
|
7
|
+
likeCount: z.number(),
|
|
8
|
+
writingAt: z.date(),
|
|
9
|
+
writingDuration: z.date(),
|
|
10
|
+
isInteressing: z.boolean().optional(),
|
|
11
|
+
viewCounter: z.number().optional(),
|
|
12
|
+
publishedAt: z.date().optional(),
|
|
13
|
+
publishedAtTime: z.date().optional(),
|
|
14
|
+
publication: z.enum(toTuple(POST_PUBLICATION)),
|
|
15
|
+
type: z.relation.connect,
|
|
8
16
|
tags: z.relations.connect
|
|
9
17
|
};
|
|
10
18
|
export const modelPostUpdate = {
|
|
@@ -13,5 +21,5 @@ export const modelPostUpdate = {
|
|
|
13
21
|
tags: z.relations.set
|
|
14
22
|
};
|
|
15
23
|
export const modelTag = {
|
|
16
|
-
name: z.string().min(
|
|
24
|
+
name: z.string().min(1, 'Required')
|
|
17
25
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { USE_COERCE_BOOLEAN, USE_COERCE_DATE, USE_COERCE_JSON, USE_COERCE_NUMBER } from '../utils/constant.js';
|
|
2
2
|
import { jsonParse } from '../utils/jsonParse.js';
|
|
3
3
|
import z from 'zod';
|
|
4
4
|
export async function parseFormData(requestOrFormData, shapes, validation) {
|
|
@@ -7,7 +7,8 @@ export async function parseFormData(requestOrFormData, shapes, validation) {
|
|
|
7
7
|
const shema = z.object(firstShap).superRefine(validation || (() => { }));
|
|
8
8
|
unionShaps.forEach((shap) => shema.or(z.object(shap)));
|
|
9
9
|
const formDataFlateObject = Object.fromEntries(formData);
|
|
10
|
-
const
|
|
10
|
+
const formDataFlateObjectCoerced = coerceFlateData(formDataFlateObject);
|
|
11
|
+
const formDataObject = flateToNeestedObject(formDataFlateObjectCoerced);
|
|
11
12
|
const parsed = shema.safeParse(formDataObject);
|
|
12
13
|
if (parsed.success === false) {
|
|
13
14
|
const issueToPOJO = (issue) => ({
|
|
@@ -23,14 +24,27 @@ export async function parseFormData(requestOrFormData, shapes, validation) {
|
|
|
23
24
|
}
|
|
24
25
|
return { data: parsed.data, formData };
|
|
25
26
|
}
|
|
27
|
+
function coerceFlateData(flateData) {
|
|
28
|
+
const coerceMap = {
|
|
29
|
+
[USE_COERCE_JSON]: (value) => jsonParse(value, {}),
|
|
30
|
+
[USE_COERCE_DATE]: (value) => (value ? new Date(value) : undefined),
|
|
31
|
+
[USE_COERCE_NUMBER]: (value) => (value === '' || value === null ? null : +value),
|
|
32
|
+
[USE_COERCE_BOOLEAN]: (value) => value === 'true'
|
|
33
|
+
};
|
|
34
|
+
function coerceValue(value) {
|
|
35
|
+
if (typeof value !== 'string')
|
|
36
|
+
return value;
|
|
37
|
+
const coerce = Object.entries(coerceMap).find(([TOKEN]) => value.startsWith(TOKEN));
|
|
38
|
+
if (!coerce)
|
|
39
|
+
return value;
|
|
40
|
+
return coerce[1](value.replace(coerce[0], ''));
|
|
41
|
+
}
|
|
42
|
+
return Object.entries(flateData).reduce((acc, [key, value]) => ({ ...acc, [key]: coerceValue(value) }), {});
|
|
43
|
+
}
|
|
26
44
|
function flateToNeestedObject(flatObject) {
|
|
27
45
|
const obj = {};
|
|
28
46
|
Object.entries(flatObject).forEach(([key, value]) => {
|
|
29
|
-
|
|
30
|
-
const _value = useJsonParse ? jsonParse(value.replace(USE_JSON_PARSER, ''), null) : value;
|
|
31
|
-
if (useJsonParse)
|
|
32
|
-
console.log({ value, _value });
|
|
33
|
-
set(obj, key, _value);
|
|
47
|
+
set(obj, key, value);
|
|
34
48
|
});
|
|
35
49
|
return obj;
|
|
36
50
|
}
|
package/dist/server/try.js
CHANGED
package/dist/ui/form/Form.svelte
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
<script
|
|
4
4
|
|
|
5
|
-
generics="
|
|
5
|
+
generics="
|
|
6
|
+
Shape extends z.ZodRawShape,
|
|
7
|
+
ReturnData extends Record<string, unknown> = FormDataInput<Shape>,
|
|
8
|
+
Data extends FormDataInput<Shape> = FormDataInput<Shape>
|
|
9
|
+
"
|
|
6
10
|
>import { createEventDispatcher, onMount } from "svelte";
|
|
7
11
|
import { fade } from "svelte/transition";
|
|
8
12
|
import { page } from "$app/stores";
|
|
@@ -3,7 +3,7 @@ import type { z } from 'zod';
|
|
|
3
3
|
import type { FormDataInput } from './form.js';
|
|
4
4
|
import { type FormField, type FormSectionProps, type Nullable } from './form.js';
|
|
5
5
|
import { type UseFormOptions } from '../../validation/form.js';
|
|
6
|
-
declare class __sveltets_Render<Shape extends z.ZodRawShape, Data extends FormDataInput<Shape> = FormDataInput<Shape>> {
|
|
6
|
+
declare class __sveltets_Render<Shape extends z.ZodRawShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>> {
|
|
7
7
|
props(): {
|
|
8
8
|
class?: string | undefined;
|
|
9
9
|
classSection?: string | undefined;
|
|
@@ -15,7 +15,7 @@ declare class __sveltets_Render<Shape extends z.ZodRawShape, Data extends FormDa
|
|
|
15
15
|
actionCreate?: string | undefined;
|
|
16
16
|
actionDelete?: string | undefined;
|
|
17
17
|
actionUpdate?: string | undefined;
|
|
18
|
-
options?: UseFormOptions<
|
|
18
|
+
options?: UseFormOptions<ReturnData> | undefined;
|
|
19
19
|
data?: Nullable<Data> | undefined;
|
|
20
20
|
set?: (<K extends keyof Shape>(key: K, value: Nullable<Data>[K]) => void) | undefined;
|
|
21
21
|
update?: ((updater: (currentData: Nullable<Data>) => Nullable<Data>) => void) | undefined;
|
|
@@ -23,10 +23,10 @@ declare class __sveltets_Render<Shape extends z.ZodRawShape, Data extends FormDa
|
|
|
23
23
|
events(): {
|
|
24
24
|
success: CustomEvent<{
|
|
25
25
|
action: URL;
|
|
26
|
-
data?:
|
|
26
|
+
data?: ReturnData | undefined;
|
|
27
27
|
}>;
|
|
28
|
-
created: CustomEvent<
|
|
29
|
-
updated: CustomEvent<
|
|
28
|
+
created: CustomEvent<ReturnData>;
|
|
29
|
+
updated: CustomEvent<ReturnData>;
|
|
30
30
|
deleted: CustomEvent<void>;
|
|
31
31
|
} & {
|
|
32
32
|
[evt: string]: CustomEvent<any>;
|
|
@@ -35,10 +35,10 @@ declare class __sveltets_Render<Shape extends z.ZodRawShape, Data extends FormDa
|
|
|
35
35
|
default: {};
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
export type FormProps<Shape extends z.ZodRawShape, Data extends FormDataInput<Shape> = FormDataInput<Shape>> = ReturnType<__sveltets_Render<Shape, Data>['props']>;
|
|
39
|
-
export type FormEvents<Shape extends z.ZodRawShape, Data extends FormDataInput<Shape> = FormDataInput<Shape>> = ReturnType<__sveltets_Render<Shape, Data>['events']>;
|
|
40
|
-
export type FormSlots<Shape extends z.ZodRawShape, Data extends FormDataInput<Shape> = FormDataInput<Shape>> = ReturnType<__sveltets_Render<Shape, Data>['slots']>;
|
|
41
|
-
export default class Form<Shape extends z.ZodRawShape, Data extends FormDataInput<Shape> = FormDataInput<Shape>> extends SvelteComponent<FormProps<Shape, Data>, FormEvents<Shape, Data>, FormSlots<Shape, Data>> {
|
|
38
|
+
export type FormProps<Shape extends z.ZodRawShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>> = ReturnType<__sveltets_Render<Shape, ReturnData, Data>['props']>;
|
|
39
|
+
export type FormEvents<Shape extends z.ZodRawShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>> = ReturnType<__sveltets_Render<Shape, ReturnData, Data>['events']>;
|
|
40
|
+
export type FormSlots<Shape extends z.ZodRawShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>> = ReturnType<__sveltets_Render<Shape, ReturnData, Data>['slots']>;
|
|
41
|
+
export default class Form<Shape extends z.ZodRawShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>> extends SvelteComponent<FormProps<Shape, ReturnData, Data>, FormEvents<Shape, ReturnData, Data>, FormSlots<Shape, ReturnData, Data>> {
|
|
42
42
|
get set(): <K extends keyof Shape>(key: K, value: Nullable<Data>[K]) => void;
|
|
43
43
|
get update(): (updater: (currentData: Nullable<Data>) => Nullable<Data>) => void;
|
|
44
44
|
}
|
|
@@ -27,6 +27,7 @@ declare class __sveltets_Render<InputType extends FormInputsType> {
|
|
|
27
27
|
flatMode?: boolean | undefined;
|
|
28
28
|
slotItem?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
|
|
29
29
|
slotSuggestion?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
|
|
30
|
+
input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
|
|
30
31
|
class?: string | undefined;
|
|
31
32
|
classList?: string | undefined;
|
|
32
33
|
clear?: (() => Promise<void>) | undefined;
|
|
@@ -45,6 +46,7 @@ declare class __sveltets_Render<InputType extends FormInputsType> {
|
|
|
45
46
|
flatMode?: boolean | undefined;
|
|
46
47
|
slotItem?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
|
|
47
48
|
slotSuggestion?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
|
|
49
|
+
input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
|
|
48
50
|
class?: string | undefined;
|
|
49
51
|
classList?: string | undefined;
|
|
50
52
|
value?: any[] | null | undefined;
|
|
@@ -78,6 +80,7 @@ declare class __sveltets_Render<InputType extends FormInputsType> {
|
|
|
78
80
|
flatMode?: boolean | undefined;
|
|
79
81
|
slotItem?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
|
|
80
82
|
slotSuggestion?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
|
|
83
|
+
input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
|
|
81
84
|
class?: string | undefined;
|
|
82
85
|
classList?: string | undefined;
|
|
83
86
|
clear?: (() => Promise<void>) | undefined;
|
|
@@ -96,6 +99,7 @@ declare class __sveltets_Render<InputType extends FormInputsType> {
|
|
|
96
99
|
flatMode?: boolean | undefined;
|
|
97
100
|
slotItem?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
|
|
98
101
|
slotSuggestion?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
|
|
102
|
+
input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
|
|
99
103
|
class?: string | undefined;
|
|
100
104
|
classList?: string | undefined;
|
|
101
105
|
value?: any[] | null | undefined;
|
|
@@ -48,6 +48,7 @@ export declare function relationProps<Item extends {
|
|
|
48
48
|
flatMode?: boolean | undefined;
|
|
49
49
|
slotItem?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
|
|
50
50
|
slotSuggestion?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
|
|
51
|
+
input?: import("svelte/elements").HTMLInputAttributes | undefined;
|
|
51
52
|
class?: string | undefined;
|
|
52
53
|
classList?: string | undefined;
|
|
53
54
|
clear?: (() => Promise<void>) | undefined;
|
|
@@ -66,6 +67,7 @@ export declare function relationsProps<Item extends {
|
|
|
66
67
|
flatMode?: boolean | undefined;
|
|
67
68
|
slotItem?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
|
|
68
69
|
slotSuggestion?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
|
|
70
|
+
input?: import("svelte/elements").HTMLInputAttributes | undefined;
|
|
69
71
|
class?: string | undefined;
|
|
70
72
|
classList?: string | undefined;
|
|
71
73
|
value?: Item[] | null | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>import { createEventDispatcher } from "svelte";
|
|
2
2
|
import { FormControl, bindCheckedWithParams } from "./index.js";
|
|
3
|
+
import { USE_COERCE_BOOLEAN } from "../../utils/constant.js";
|
|
3
4
|
export let value = false;
|
|
4
5
|
export let input = {};
|
|
5
6
|
export let inputElement = void 0;
|
|
@@ -20,6 +21,7 @@ const dispatch = createEventDispatcher();
|
|
|
20
21
|
class="checkbox ml-1"
|
|
21
22
|
{...input}
|
|
22
23
|
/>
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
{#if value !== undefined}
|
|
25
|
+
<input type="hidden" name={key} value="{USE_COERCE_BOOLEAN}{value}" />
|
|
26
|
+
{/if}
|
|
25
27
|
</FormControl>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script>import { createEventDispatcher } from "svelte";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
import { FormControl } from "./index.js";
|
|
4
|
+
import { USE_COERCE_DATE } from "../../utils/constant.js";
|
|
5
|
+
export let value = void 0;
|
|
6
|
+
export let input = {};
|
|
4
7
|
$:
|
|
5
|
-
({
|
|
6
|
-
$:
|
|
7
|
-
({ class: inputClass, ...inputProps } = input || {});
|
|
8
|
-
export let value = _value;
|
|
8
|
+
({ class: inputClass = "", ...inputProps } = input);
|
|
9
9
|
const dispatch = createEventDispatcher();
|
|
10
10
|
const handleInput = ({ currentTarget }) => {
|
|
11
11
|
value = currentTarget.valueAsDate || null;
|
|
@@ -13,16 +13,19 @@ const handleInput = ({ currentTarget }) => {
|
|
|
13
13
|
};
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
|
-
<FormControl {
|
|
16
|
+
<FormControl {...$$restProps} let:key>
|
|
17
17
|
<input
|
|
18
18
|
value={value && dayjs(value).format('YYYY-MM-DD')}
|
|
19
19
|
on:input={handleInput}
|
|
20
20
|
on:focus
|
|
21
21
|
on:blur
|
|
22
22
|
type="date"
|
|
23
|
-
name={key}
|
|
24
23
|
id={key}
|
|
25
|
-
class="input input-bordered {inputClass
|
|
24
|
+
class="input input-bordered {inputClass}"
|
|
26
25
|
{...inputProps}
|
|
27
26
|
/>
|
|
27
|
+
|
|
28
|
+
{#if value !== undefined}
|
|
29
|
+
<input type="hidden" name={key} value="{USE_COERCE_DATE}{value?.toJSON()}" />
|
|
30
|
+
{/if}
|
|
28
31
|
</FormControl>
|
|
@@ -1,23 +1,35 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { USE_COERCE_DATE } from "../../utils/constant.js";
|
|
2
|
+
import { FormControl } from "./index.js";
|
|
3
|
+
import { createEventDispatcher } from "svelte";
|
|
4
|
+
import dayjs from "dayjs";
|
|
5
|
+
export let value = void 0;
|
|
6
|
+
export let input = {};
|
|
2
7
|
$:
|
|
3
|
-
({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
({ class: inputClass = "", ...inputProps } = input);
|
|
9
|
+
const dispatch = createEventDispatcher();
|
|
10
|
+
const handleInput = ({ currentTarget }) => {
|
|
11
|
+
value = getDateTime(currentTarget.value);
|
|
12
|
+
dispatch("input", value);
|
|
13
|
+
};
|
|
14
|
+
function getDateTime(v) {
|
|
15
|
+
if (typeof v !== "string")
|
|
16
|
+
return null;
|
|
17
|
+
return new Date(v);
|
|
18
|
+
}
|
|
7
19
|
</script>
|
|
8
20
|
|
|
9
|
-
<FormControl {
|
|
10
|
-
{#if value}
|
|
11
|
-
<input type="hidden" name={key} value={new Date(value).toJSON()} />
|
|
12
|
-
{/if}
|
|
21
|
+
<FormControl {...$$restProps} let:key>
|
|
13
22
|
<input
|
|
14
|
-
|
|
15
|
-
on:input
|
|
23
|
+
value={value && dayjs(value).format('YYYY-MM-DDThh:mm')}
|
|
24
|
+
on:input={handleInput}
|
|
16
25
|
on:focus
|
|
17
26
|
on:blur
|
|
18
27
|
type="datetime-local"
|
|
19
28
|
id={key}
|
|
20
|
-
class="input input-bordered {inputClass
|
|
29
|
+
class="input input-bordered {inputClass}"
|
|
21
30
|
{...inputProps}
|
|
22
31
|
/>
|
|
32
|
+
{#if value !== undefined}
|
|
33
|
+
<input type="hidden" name={key} value="{USE_COERCE_DATE}{value?.toJSON()}" />
|
|
34
|
+
{/if}
|
|
23
35
|
</FormControl>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
import { type InputProps } from './index.js';
|
|
3
3
|
declare const __propDef: {
|
|
4
|
-
props: InputProps
|
|
4
|
+
props: InputProps<Date | null | undefined>;
|
|
5
5
|
events: {
|
|
6
|
-
input: Event;
|
|
7
6
|
focus: FocusEvent;
|
|
8
7
|
blur: FocusEvent;
|
|
8
|
+
input: CustomEvent<Date | null>;
|
|
9
9
|
} & {
|
|
10
10
|
[evt: string]: CustomEvent<any>;
|
|
11
11
|
};
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export let value = _value;
|
|
1
|
+
<script>import { USE_COERCE_NUMBER } from "../../utils/constant.js";
|
|
2
|
+
import { FormControl } from "./index.js";
|
|
3
|
+
export let value = void 0;
|
|
4
|
+
export let input = void 0;
|
|
5
|
+
export let inputElement = void 0;
|
|
7
6
|
</script>
|
|
8
7
|
|
|
9
|
-
<FormControl {
|
|
8
|
+
<FormControl {...$$restProps} let:key>
|
|
10
9
|
<slot name="label_append" slot="label_append" />
|
|
11
10
|
<input
|
|
12
11
|
bind:value
|
|
13
|
-
bind:this={
|
|
12
|
+
bind:this={inputElement}
|
|
14
13
|
on:input
|
|
15
14
|
on:focus
|
|
16
15
|
on:blur
|
|
17
16
|
type="number"
|
|
18
|
-
name={key}
|
|
19
17
|
id={key}
|
|
20
18
|
inputmode="numeric"
|
|
21
|
-
class="input input-bordered
|
|
22
|
-
{...
|
|
19
|
+
class="input input-bordered"
|
|
20
|
+
{...input}
|
|
23
21
|
/>
|
|
22
|
+
{#if value !== undefined}
|
|
23
|
+
<input type="hidden" name={key} value="{USE_COERCE_NUMBER}{value}" />
|
|
24
|
+
{/if}
|
|
24
25
|
</FormControl>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import debounce from "debounce";
|
|
3
3
|
import { toast } from "svelte-sonner";
|
|
4
4
|
import { mdiClose } from "@mdi/js";
|
|
5
|
-
import {
|
|
5
|
+
import { USE_COERCE_JSON } from "../../utils/constant.js";
|
|
6
6
|
import { Icon } from "../icon/index.js";
|
|
7
7
|
import { Slot } from "../slot/index.js";
|
|
8
8
|
import { DropDown } from "../menu/index.js";
|
|
@@ -22,6 +22,7 @@ export let tippyProps = {};
|
|
|
22
22
|
export let flatMode = false;
|
|
23
23
|
export let slotItem = null;
|
|
24
24
|
export let slotSuggestion = slotItem;
|
|
25
|
+
export let input = void 0;
|
|
25
26
|
let klass = "";
|
|
26
27
|
export { klass as class };
|
|
27
28
|
export let classList = "";
|
|
@@ -72,7 +73,6 @@ async function handleBlur() {
|
|
|
72
73
|
<div class="input input-bordered flex grow items-center pr-2">
|
|
73
74
|
<input
|
|
74
75
|
type="text"
|
|
75
|
-
name={key}
|
|
76
76
|
id={key}
|
|
77
77
|
bind:this={inputElement}
|
|
78
78
|
bind:value={searchValue}
|
|
@@ -82,6 +82,8 @@ async function handleBlur() {
|
|
|
82
82
|
autocomplete="off"
|
|
83
83
|
{placeholder}
|
|
84
84
|
class="grow"
|
|
85
|
+
size={8}
|
|
86
|
+
{...input}
|
|
85
87
|
/>
|
|
86
88
|
|
|
87
89
|
<RelationAfter {isLoading} {createUrl} {createTitle} {createIcon} />
|
|
@@ -105,7 +107,7 @@ async function handleBlur() {
|
|
|
105
107
|
<input
|
|
106
108
|
type="hidden"
|
|
107
109
|
name={key}
|
|
108
|
-
value="{
|
|
110
|
+
value="{USE_COERCE_JSON}{JSON.stringify({ id: item.id })}"
|
|
109
111
|
/>
|
|
110
112
|
{/if}
|
|
111
113
|
</FormControl>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
2
3
|
import type { TippyProps } from '../../utils/tippy.js';
|
|
3
4
|
import type { ComponentAndProps } from '../../utils/component.js';
|
|
4
5
|
declare class __sveltets_Render<RelationItem extends {
|
|
@@ -18,6 +19,7 @@ declare class __sveltets_Render<RelationItem extends {
|
|
|
18
19
|
flatMode?: boolean | undefined;
|
|
19
20
|
slotItem?: ((item: RelationItem) => string | ComponentAndProps) | null | undefined;
|
|
20
21
|
slotSuggestion?: ((item: RelationItem) => string | ComponentAndProps) | null | undefined;
|
|
22
|
+
input?: HTMLInputAttributes | undefined;
|
|
21
23
|
class?: string | undefined;
|
|
22
24
|
classList?: string | undefined;
|
|
23
25
|
clear?: (() => Promise<void>) | undefined;
|
|
@@ -3,7 +3,7 @@ import { slide } from "svelte/transition";
|
|
|
3
3
|
import { toast } from "svelte-sonner";
|
|
4
4
|
import { mdiClose } from "@mdi/js";
|
|
5
5
|
import debounce from "debounce";
|
|
6
|
-
import {
|
|
6
|
+
import { USE_COERCE_JSON } from "../../utils/constant.js";
|
|
7
7
|
import { Icon } from "../icon/index.js";
|
|
8
8
|
import { Slot } from "../slot/index.js";
|
|
9
9
|
import { FormControl, SelectorList } from "./index.js";
|
|
@@ -20,6 +20,7 @@ export let placeholder = "";
|
|
|
20
20
|
export let flatMode = false;
|
|
21
21
|
export let slotItem = null;
|
|
22
22
|
export let slotSuggestion = slotItem;
|
|
23
|
+
export let input = void 0;
|
|
23
24
|
let klass = "";
|
|
24
25
|
export { klass as class };
|
|
25
26
|
export let classList = "";
|
|
@@ -120,6 +121,8 @@ async function handleBlur() {
|
|
|
120
121
|
autocomplete="off"
|
|
121
122
|
{placeholder}
|
|
122
123
|
class="grow"
|
|
124
|
+
size={8}
|
|
125
|
+
{...input}
|
|
123
126
|
/>
|
|
124
127
|
|
|
125
128
|
<RelationAfter {isLoading} {createUrl} {createTitle} {createIcon} />
|
|
@@ -131,7 +134,7 @@ async function handleBlur() {
|
|
|
131
134
|
<input
|
|
132
135
|
type="hidden"
|
|
133
136
|
name={key}
|
|
134
|
-
value="{
|
|
137
|
+
value="{USE_COERCE_JSON}{JSON.stringify(items?.map(({ id }) => ({ id })) || [])}"
|
|
135
138
|
/>
|
|
136
139
|
</FormControl>
|
|
137
140
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
2
3
|
import type { ComponentAndProps } from '../../utils/component.js';
|
|
3
4
|
declare class __sveltets_Render<RelationItem extends {
|
|
4
5
|
id: string;
|
|
@@ -15,6 +16,7 @@ declare class __sveltets_Render<RelationItem extends {
|
|
|
15
16
|
flatMode?: boolean | undefined;
|
|
16
17
|
slotItem?: ((item: RelationItem) => string | ComponentAndProps) | null | undefined;
|
|
17
18
|
slotSuggestion?: ((item: RelationItem) => string | ComponentAndProps) | null | undefined;
|
|
19
|
+
input?: HTMLInputAttributes | undefined;
|
|
18
20
|
class?: string | undefined;
|
|
19
21
|
classList?: string | undefined;
|
|
20
22
|
value?: RelationItem[] | null | undefined;
|
|
@@ -23,6 +23,7 @@ function onSelect(index) {
|
|
|
23
23
|
focusIndex = index;
|
|
24
24
|
value = _options[index].value;
|
|
25
25
|
dispatch("input", value);
|
|
26
|
+
dispatch("select", value);
|
|
26
27
|
dropDown.hide();
|
|
27
28
|
}
|
|
28
29
|
</script>
|
|
@@ -34,7 +35,7 @@ function onSelect(index) {
|
|
|
34
35
|
bind:this={button}
|
|
35
36
|
id={key}
|
|
36
37
|
type="button"
|
|
37
|
-
class="flex h-12 items-center gap-2 rounded-lg border pl-4 pr-2"
|
|
38
|
+
class="input-bordered flex h-12 items-center gap-2 rounded-lg border pl-4 pr-2 hover:bg-base-200/50"
|
|
38
39
|
>
|
|
39
40
|
{#if selectedOption}
|
|
40
41
|
{#if selectedOption.icon}
|
|
@@ -46,7 +47,9 @@ function onSelect(index) {
|
|
|
46
47
|
{/if}
|
|
47
48
|
<Icon class="ml-auto" path={mdiUnfoldMoreHorizontal} size={18} />
|
|
48
49
|
</button>
|
|
49
|
-
|
|
50
|
+
{#if value !== undefined}
|
|
51
|
+
<input type="hidden" name={key} {value} />
|
|
52
|
+
{/if}
|
|
50
53
|
</FormControl>
|
|
51
54
|
</svelte:fragment>
|
|
52
55
|
|
|
@@ -33,7 +33,7 @@ function handleReset() {
|
|
|
33
33
|
goto($urlParam.without(field.key, "skip", "take"), { noScroll: true, keepFocus: true });
|
|
34
34
|
}
|
|
35
35
|
function isDefined(v) {
|
|
36
|
-
return
|
|
36
|
+
return typeof v === "number";
|
|
37
37
|
}
|
|
38
38
|
$:
|
|
39
39
|
isNegatifRange = isDefined(min) && isDefined(max) && max < min;
|
package/dist/utils/constant.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const USE_COERCE_JSON = "I_LOVE_YOU_nXFVwk03nRbmhFukfyZLuzkddEd43LXIKs_";
|
|
2
|
+
export declare const USE_COERCE_DATE = "I_LOVE_YOU_TOO_nXFVwk03nRbmhFuskfyZLuzkEd43LXIKs_";
|
|
3
|
+
export declare const USE_COERCE_NUMBER = "HOHO_nXFVwk03nRbmhFukfyZaaLuzkEd43LXIKs_";
|
|
4
|
+
export declare const USE_COERCE_BOOLEAN = "YEP_nXFVwk04nRbmhFukfyZbaLuzkEd43LXIKs_";
|
package/dist/utils/constant.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const USE_COERCE_JSON = 'I_LOVE_YOU_nXFVwk03nRbmhFukfyZLuzkddEd43LXIKs_';
|
|
2
|
+
export const USE_COERCE_DATE = 'I_LOVE_YOU_TOO_nXFVwk03nRbmhFuskfyZLuzkEd43LXIKs_';
|
|
3
|
+
export const USE_COERCE_NUMBER = 'HOHO_nXFVwk03nRbmhFukfyZaaLuzkEd43LXIKs_';
|
|
4
|
+
export const USE_COERCE_BOOLEAN = 'YEP_nXFVwk04nRbmhFukfyZbaLuzkEd43LXIKs_';
|
package/dist/utils/options.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export type Option = {
|
|
|
3
3
|
label: string;
|
|
4
4
|
icon?: string;
|
|
5
5
|
};
|
|
6
|
-
export type
|
|
6
|
+
export type OptionRecord<Values extends string> = Record<Values, Omit<Option, 'value'>>;
|
|
7
|
+
export type Options = string | string[] | Option[] | Record<string, string> | OptionRecord<string>;
|
|
7
8
|
export declare function parseOptions(options: Options): Option[];
|
package/dist/validation/zod.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import zod from 'zod';
|
|
2
2
|
declare function json<T extends zod.ZodRawShape>(shap: T): zod.ZodUnion<[zod.ZodObject<T, "strip", zod.ZodTypeAny, { [k_1 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T>, { [k in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T>, { [k_2 in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k_2] ? never : k_2; }[keyof T]>[k_1]; }, { [k_2_1 in keyof zod.baseObjectInputType<T>]: zod.baseObjectInputType<T>[k_2_1]; }>, zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodObject<T, "strip", zod.ZodTypeAny, { [k_1 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T>, { [k in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T>, { [k_2 in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k_2] ? never : k_2; }[keyof T]>[k_1]; }, { [k_2_1 in keyof zod.baseObjectInputType<T>]: zod.baseObjectInputType<T>[k_2_1]; }>>]>;
|
|
3
3
|
declare function array<T extends zod.ZodTypeAny>(shap: T): zod.ZodUnion<[zod.ZodArray<T, "many">, zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodArray<T, "many">>]>;
|
|
4
|
-
declare function booleanAsString(): zod.ZodEffects<zod.ZodEnum<["true", "false"]>, boolean, "true" | "false">;
|
|
5
|
-
declare function dateOptional(): void;
|
|
6
4
|
type RelationsOperation = 'set' | 'disconnect' | 'delete' | 'connect';
|
|
7
5
|
export declare const z: {
|
|
8
6
|
json: typeof json;
|
|
@@ -142,42 +140,8 @@ export declare const z: {
|
|
|
142
140
|
start?: Date | undefined;
|
|
143
141
|
end?: Date | undefined;
|
|
144
142
|
}>>]>>;
|
|
145
|
-
boolean: zod.ZodOptional<zod.
|
|
143
|
+
boolean: zod.ZodOptional<zod.ZodBoolean>;
|
|
146
144
|
};
|
|
147
|
-
dateOptional: typeof dateOptional;
|
|
148
|
-
booleanAsString: typeof booleanAsString;
|
|
149
|
-
date: (params?: ({
|
|
150
|
-
errorMap?: zod.ZodErrorMap | undefined;
|
|
151
|
-
invalid_type_error?: string | undefined;
|
|
152
|
-
required_error?: string | undefined;
|
|
153
|
-
description?: string | undefined;
|
|
154
|
-
} & {
|
|
155
|
-
coerce?: boolean | undefined;
|
|
156
|
-
}) | undefined) => zod.ZodDate;
|
|
157
|
-
number: (params?: ({
|
|
158
|
-
errorMap?: zod.ZodErrorMap | undefined;
|
|
159
|
-
invalid_type_error?: string | undefined;
|
|
160
|
-
required_error?: string | undefined;
|
|
161
|
-
description?: string | undefined;
|
|
162
|
-
} & {
|
|
163
|
-
coerce?: boolean | undefined;
|
|
164
|
-
}) | undefined) => zod.ZodNumber;
|
|
165
|
-
bigint: (params?: ({
|
|
166
|
-
errorMap?: zod.ZodErrorMap | undefined;
|
|
167
|
-
invalid_type_error?: string | undefined;
|
|
168
|
-
required_error?: string | undefined;
|
|
169
|
-
description?: string | undefined;
|
|
170
|
-
} & {
|
|
171
|
-
coerce?: boolean | undefined;
|
|
172
|
-
}) | undefined) => zod.ZodBigInt;
|
|
173
|
-
boolean: (params?: ({
|
|
174
|
-
errorMap?: zod.ZodErrorMap | undefined;
|
|
175
|
-
invalid_type_error?: string | undefined;
|
|
176
|
-
required_error?: string | undefined;
|
|
177
|
-
description?: string | undefined;
|
|
178
|
-
} & {
|
|
179
|
-
coerce?: boolean | undefined;
|
|
180
|
-
}) | undefined) => zod.ZodBoolean;
|
|
181
145
|
z: typeof zod.z;
|
|
182
146
|
setErrorMap(map: zod.ZodErrorMap): void;
|
|
183
147
|
getErrorMap(): zod.ZodErrorMap;
|
|
@@ -316,6 +280,30 @@ export declare const z: {
|
|
|
316
280
|
}) | undefined) => zod.ZodDate;
|
|
317
281
|
};
|
|
318
282
|
any: (params?: zod.RawCreateParams) => zod.ZodAny;
|
|
283
|
+
bigint: (params?: ({
|
|
284
|
+
errorMap?: zod.ZodErrorMap | undefined;
|
|
285
|
+
invalid_type_error?: string | undefined;
|
|
286
|
+
required_error?: string | undefined;
|
|
287
|
+
description?: string | undefined;
|
|
288
|
+
} & {
|
|
289
|
+
coerce?: boolean | undefined;
|
|
290
|
+
}) | undefined) => zod.ZodBigInt;
|
|
291
|
+
boolean: (params?: ({
|
|
292
|
+
errorMap?: zod.ZodErrorMap | undefined;
|
|
293
|
+
invalid_type_error?: string | undefined;
|
|
294
|
+
required_error?: string | undefined;
|
|
295
|
+
description?: string | undefined;
|
|
296
|
+
} & {
|
|
297
|
+
coerce?: boolean | undefined;
|
|
298
|
+
}) | undefined) => zod.ZodBoolean;
|
|
299
|
+
date: (params?: ({
|
|
300
|
+
errorMap?: zod.ZodErrorMap | undefined;
|
|
301
|
+
invalid_type_error?: string | undefined;
|
|
302
|
+
required_error?: string | undefined;
|
|
303
|
+
description?: string | undefined;
|
|
304
|
+
} & {
|
|
305
|
+
coerce?: boolean | undefined;
|
|
306
|
+
}) | undefined) => zod.ZodDate;
|
|
319
307
|
discriminatedUnion: typeof zod.ZodDiscriminatedUnion.create;
|
|
320
308
|
effect: <I extends zod.ZodTypeAny>(schema: I, effect: zod.Effect<I["_output"]>, params?: zod.RawCreateParams) => zod.ZodEffects<I, I["_output"], zod.input<I>>;
|
|
321
309
|
enum: {
|
|
@@ -335,6 +323,14 @@ export declare const z: {
|
|
|
335
323
|
never: (params?: zod.RawCreateParams) => zod.ZodNever;
|
|
336
324
|
null: (params?: zod.RawCreateParams) => zod.ZodNull;
|
|
337
325
|
nullable: <T_26 extends zod.ZodTypeAny>(type: T_26, params?: zod.RawCreateParams) => zod.ZodNullable<T_26>;
|
|
326
|
+
number: (params?: ({
|
|
327
|
+
errorMap?: zod.ZodErrorMap | undefined;
|
|
328
|
+
invalid_type_error?: string | undefined;
|
|
329
|
+
required_error?: string | undefined;
|
|
330
|
+
description?: string | undefined;
|
|
331
|
+
} & {
|
|
332
|
+
coerce?: boolean | undefined;
|
|
333
|
+
}) | undefined) => zod.ZodNumber;
|
|
338
334
|
object: <T_27 extends zod.ZodRawShape>(shape: T_27, params?: zod.RawCreateParams) => zod.ZodObject<T_27, "strip", zod.ZodTypeAny, { [k_1_12 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_27>, { [k_25 in keyof zod.baseObjectOutputType<T_27>]: undefined extends zod.baseObjectOutputType<T_27>[k_25] ? never : k_25; }[keyof T_27]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_27>, { [k_26 in keyof zod.baseObjectOutputType<T_27>]: undefined extends zod.baseObjectOutputType<T_27>[k_26] ? never : k_26; }[keyof T_27]>[k_1_12]; }, { [k_2_13 in keyof zod.baseObjectInputType<T_27>]: zod.baseObjectInputType<T_27>[k_2_13]; }>;
|
|
339
335
|
oboolean: () => zod.ZodOptional<zod.ZodBoolean>;
|
|
340
336
|
onumber: () => zod.ZodOptional<zod.ZodNumber>;
|
package/dist/validation/zod.js
CHANGED
|
@@ -6,18 +6,6 @@ function json(shap) {
|
|
|
6
6
|
function array(shap) {
|
|
7
7
|
return zod.union([zod.array(shap), zod.string().transform(jsonParse).pipe(zod.array(shap))]);
|
|
8
8
|
}
|
|
9
|
-
function booleanAsString() {
|
|
10
|
-
return zod.enum(['true', 'false']).transform((value) => value === 'true');
|
|
11
|
-
}
|
|
12
|
-
function dateOptional() {
|
|
13
|
-
zod.union([
|
|
14
|
-
zod.date(),
|
|
15
|
-
zod
|
|
16
|
-
.string()
|
|
17
|
-
.optional()
|
|
18
|
-
.transform((v) => (v ? new Date(v) : v === '' ? null : undefined))
|
|
19
|
-
]);
|
|
20
|
-
}
|
|
21
9
|
const relation = {
|
|
22
10
|
connect: zod.object({ id: zod.string() }).transform((item) => ({ connect: item })),
|
|
23
11
|
create(shap) {
|
|
@@ -70,15 +58,15 @@ const relations = {
|
|
|
70
58
|
};
|
|
71
59
|
const filter = {
|
|
72
60
|
number: json({
|
|
73
|
-
min: zod.
|
|
74
|
-
max: zod.
|
|
61
|
+
min: zod.number().optional(),
|
|
62
|
+
max: zod.number().optional()
|
|
75
63
|
}).optional(),
|
|
76
64
|
multiselect: array(zod.string()).optional(),
|
|
77
65
|
range: json({
|
|
78
|
-
start: zod.
|
|
79
|
-
end: zod.
|
|
66
|
+
start: zod.date().optional(),
|
|
67
|
+
end: zod.date().optional()
|
|
80
68
|
}).optional(),
|
|
81
|
-
boolean:
|
|
69
|
+
boolean: zod.boolean().optional()
|
|
82
70
|
};
|
|
83
71
|
export const z = {
|
|
84
72
|
...zod,
|
|
@@ -87,12 +75,6 @@ export const z = {
|
|
|
87
75
|
arrayRaw: zod.array, // TODO: remove
|
|
88
76
|
relation,
|
|
89
77
|
relations,
|
|
90
|
-
filter
|
|
91
|
-
dateOptional,
|
|
92
|
-
booleanAsString, // TODO: rename stringAsBoolean
|
|
93
|
-
date: zod.coerce.date,
|
|
94
|
-
number: zod.coerce.number,
|
|
95
|
-
bigint: zod.coerce.bigint,
|
|
96
|
-
boolean: zod.coerce.boolean
|
|
78
|
+
filter
|
|
97
79
|
};
|
|
98
80
|
export const toTuple = Object.keys;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fuma",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "My fullstack material build with sveltekit, daisyui, zod, prisma, lucia",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jonas Voisard",
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"svelte": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"type": "module",
|
|
12
|
+
"prisma": {
|
|
13
|
+
"seed": "node --loader ts-node/esm prisma/seed.ts"
|
|
14
|
+
},
|
|
12
15
|
"exports": {
|
|
13
16
|
".": {
|
|
14
17
|
"types": "./dist/index.d.ts",
|
|
@@ -114,6 +117,7 @@
|
|
|
114
117
|
"svelte-easy-crop": "^2.0.3",
|
|
115
118
|
"svelte-sonner": "^0.3.22",
|
|
116
119
|
"tippy.js": "^6.3.7",
|
|
120
|
+
"ts-node": "^10.9.2",
|
|
117
121
|
"zod": "^3.22.4"
|
|
118
122
|
},
|
|
119
123
|
"scripts": {
|
|
@@ -128,6 +132,7 @@
|
|
|
128
132
|
"format": "prettier --write .",
|
|
129
133
|
"migrate": "prisma migrate dev",
|
|
130
134
|
"generate": "prisma generate",
|
|
131
|
-
"studio": "prisma studio"
|
|
135
|
+
"studio": "prisma studio",
|
|
136
|
+
"seed": "prisma db seed"
|
|
132
137
|
}
|
|
133
138
|
}
|