fuma 0.1.16 → 0.1.18
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/ui/form/Form.svelte +1 -1
- package/dist/ui/form/FormInput.svelte +7 -0
- package/dist/ui/form/form.d.ts +3 -3
- package/dist/ui/form/form.js +2 -2
- package/dist/ui/form/formInput.d.ts +58 -0
- package/dist/ui/form/formInput.js +21 -0
- package/dist/ui/form/index.d.ts +2 -1
- package/dist/ui/form/index.js +2 -1
- package/package.json +1 -1
- package/dist/ui/form/Input.svelte +0 -41
package/dist/ui/form/Form.svelte
CHANGED
|
@@ -6,7 +6,7 @@ import { createEventDispatcher, onMount } from "svelte";
|
|
|
6
6
|
import { fade } from "svelte/transition";
|
|
7
7
|
import { page } from "$app/stores";
|
|
8
8
|
import { useForm } from "../../validation/form.js";
|
|
9
|
-
import Input from "./
|
|
9
|
+
import Input from "./FormInput.svelte";
|
|
10
10
|
import FormSection from "./FormSection.svelte";
|
|
11
11
|
let klass = "";
|
|
12
12
|
export { klass as class };
|
package/dist/ui/form/form.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
2
|
import type { ComponentProps } from 'svelte';
|
|
3
|
-
import { type
|
|
3
|
+
import { type FormInputsProps, type FormInputsType } from './formInput.js';
|
|
4
4
|
import type FormSection from './FormSection.svelte';
|
|
5
5
|
type Shape = z.ZodRawShape;
|
|
6
6
|
type PickOne<T> = {
|
|
@@ -14,11 +14,11 @@ export type FormField<M extends Shape> = {
|
|
|
14
14
|
colSpan?: number;
|
|
15
15
|
/** hide field if true */
|
|
16
16
|
hide?: BoolOrFunction<M>;
|
|
17
|
-
} & PickOne<
|
|
17
|
+
} & PickOne<FormInputsProps>;
|
|
18
18
|
export type FormSectionProps<M extends Shape> = ComponentProps<FormSection> & {
|
|
19
19
|
/** hide group if true */
|
|
20
20
|
hide?: BoolOrFunction<M>;
|
|
21
21
|
};
|
|
22
22
|
export declare function initData<M extends Shape>(fields: FormField<M>[][]): FormData<M>;
|
|
23
|
-
export declare function getFieldType<M extends Shape>(field: FormField<M>):
|
|
23
|
+
export declare function getFieldType<M extends Shape>(field: FormField<M>): FormInputsType;
|
|
24
24
|
export {};
|
package/dist/ui/form/form.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formInputsType } from './formInput.js';
|
|
2
2
|
export function initData(fields) {
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
return fields.flat().reduce((acc, cur) => {
|
|
@@ -8,7 +8,7 @@ export function initData(fields) {
|
|
|
8
8
|
}, {});
|
|
9
9
|
}
|
|
10
10
|
export function getFieldType(field) {
|
|
11
|
-
const inputType =
|
|
11
|
+
const inputType = formInputsType.find((t) => field[t]);
|
|
12
12
|
if (!inputType)
|
|
13
13
|
return 'text';
|
|
14
14
|
return inputType;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import { InputText, InputTextarea, InputBoolean, InputDate, InputDatetime, InputNumber, InputPassword, InputRadio, InputSelect, InputRelation, InputRelations } from '../input/index.js';
|
|
3
|
+
export declare const formInputs: {
|
|
4
|
+
readonly text: typeof InputText;
|
|
5
|
+
readonly textarea: typeof InputTextarea;
|
|
6
|
+
readonly boolean: typeof InputBoolean;
|
|
7
|
+
readonly date: typeof InputDate;
|
|
8
|
+
readonly datetime: typeof InputDatetime;
|
|
9
|
+
readonly number: typeof InputNumber;
|
|
10
|
+
readonly password: typeof InputPassword;
|
|
11
|
+
readonly select: typeof InputSelect;
|
|
12
|
+
readonly radio: typeof InputRadio;
|
|
13
|
+
readonly relation: typeof InputRelation<any>;
|
|
14
|
+
readonly relations: typeof InputRelations<any>;
|
|
15
|
+
};
|
|
16
|
+
export type FormInputs = typeof formInputs;
|
|
17
|
+
export type FormInputsType = keyof FormInputs;
|
|
18
|
+
export type FormInputProps<T extends FormInputsType> = ComponentProps<InstanceType<FormInputs[T]>>;
|
|
19
|
+
export type FormInputsProps = {
|
|
20
|
+
[T in FormInputsType]: FormInputProps<T>;
|
|
21
|
+
};
|
|
22
|
+
export declare const formInputsType: ("number" | "boolean" | "select" | "date" | "textarea" | "text" | "password" | "radio" | "datetime" | "relation" | "relations")[];
|
|
23
|
+
export declare function relationProps<Item extends {
|
|
24
|
+
id: string;
|
|
25
|
+
}>(props: ComponentProps<InstanceType<typeof InputRelation<Item>>>): {
|
|
26
|
+
key?: string | undefined;
|
|
27
|
+
label?: string | undefined;
|
|
28
|
+
search: (q: string) => Promise<Item[]>;
|
|
29
|
+
createUrl?: string | undefined;
|
|
30
|
+
createTitle?: string | undefined;
|
|
31
|
+
value?: Item | null | undefined;
|
|
32
|
+
error?: string | undefined;
|
|
33
|
+
placeholder?: string | undefined;
|
|
34
|
+
tippyProps?: Partial<import("tippy.js").Props> | undefined;
|
|
35
|
+
flatMode?: boolean | undefined;
|
|
36
|
+
slotItem?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
|
|
37
|
+
slotSuggestion?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
|
|
38
|
+
class?: string | undefined;
|
|
39
|
+
classList?: string | undefined;
|
|
40
|
+
clear?: (() => Promise<void>) | undefined;
|
|
41
|
+
};
|
|
42
|
+
export declare function relationsProps<Item extends {
|
|
43
|
+
id: string;
|
|
44
|
+
}>(props: ComponentProps<InstanceType<typeof InputRelations<Item>>>): {
|
|
45
|
+
key?: string | undefined;
|
|
46
|
+
label?: string | undefined;
|
|
47
|
+
search: (q: string) => Promise<Item[]>;
|
|
48
|
+
createUrl?: string | undefined;
|
|
49
|
+
createTitle?: string | undefined;
|
|
50
|
+
error?: string | undefined;
|
|
51
|
+
placeholder?: string | undefined;
|
|
52
|
+
flatMode?: boolean | undefined;
|
|
53
|
+
slotItem?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
|
|
54
|
+
slotSuggestion?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
|
|
55
|
+
class?: string | undefined;
|
|
56
|
+
classList?: string | undefined;
|
|
57
|
+
value?: Item[] | null | undefined;
|
|
58
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InputText, InputTextarea, InputBoolean, InputDate, InputDatetime, InputNumber, InputPassword, InputRadio, InputSelect, InputRelation, InputRelations } from '../input/index.js';
|
|
2
|
+
export const formInputs = {
|
|
3
|
+
text: InputText,
|
|
4
|
+
textarea: InputTextarea,
|
|
5
|
+
boolean: InputBoolean,
|
|
6
|
+
date: InputDate,
|
|
7
|
+
datetime: InputDatetime,
|
|
8
|
+
number: InputNumber,
|
|
9
|
+
password: InputPassword,
|
|
10
|
+
select: InputSelect,
|
|
11
|
+
radio: InputRadio,
|
|
12
|
+
relation: InputRelation,
|
|
13
|
+
relations: InputRelations
|
|
14
|
+
};
|
|
15
|
+
export const formInputsType = Object.keys(formInputs);
|
|
16
|
+
export function relationProps(props) {
|
|
17
|
+
return props;
|
|
18
|
+
}
|
|
19
|
+
export function relationsProps(props) {
|
|
20
|
+
return props;
|
|
21
|
+
}
|
package/dist/ui/form/index.d.ts
CHANGED
package/dist/ui/form/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<script context="module">import {
|
|
2
|
-
InputText,
|
|
3
|
-
InputTextarea,
|
|
4
|
-
InputBoolean,
|
|
5
|
-
InputDate,
|
|
6
|
-
InputDatetime,
|
|
7
|
-
InputNumber,
|
|
8
|
-
InputPassword,
|
|
9
|
-
InputRadio,
|
|
10
|
-
InputSelect,
|
|
11
|
-
InputRelation,
|
|
12
|
-
InputRelations
|
|
13
|
-
} from "../input/index.js";
|
|
14
|
-
export const inputs = {
|
|
15
|
-
text: InputText,
|
|
16
|
-
textarea: InputTextarea,
|
|
17
|
-
boolean: InputBoolean,
|
|
18
|
-
date: InputDate,
|
|
19
|
-
datetime: InputDatetime,
|
|
20
|
-
number: InputNumber,
|
|
21
|
-
password: InputPassword,
|
|
22
|
-
radio: InputRadio,
|
|
23
|
-
select: InputSelect,
|
|
24
|
-
relation: InputRelation,
|
|
25
|
-
relations: InputRelations
|
|
26
|
-
};
|
|
27
|
-
export const inputsType = Object.keys(inputs);
|
|
28
|
-
export function relationProps(props) {
|
|
29
|
-
return props;
|
|
30
|
-
}
|
|
31
|
-
export function relationsProps(props) {
|
|
32
|
-
return props;
|
|
33
|
-
}
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<script>let inputType;
|
|
37
|
-
export { inputType as type };
|
|
38
|
-
export let value;
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
<svelte:component this={inputs[inputType]} bind:value {...$$restProps} />
|