@sealcode/sealgen 0.8.3 → 0.8.5
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/@types/forms/controls/autocomplete.d.ts +1 -1
- package/@types/forms/controls/checkbox-group.d.ts +3 -2
- package/@types/forms/controls/collapsible-checkbox-group.d.ts +1 -1
- package/@types/forms/controls/collapsible-field-group.d.ts +1 -1
- package/@types/forms/controls/controls.d.ts +3 -0
- package/@types/forms/controls/dropdown.d.ts +6 -5
- package/@types/forms/controls/field-group.d.ts +3 -3
- package/@types/forms/controls/file.d.ts +14 -0
- package/@types/forms/controls/form-control.d.ts +4 -1
- package/@types/forms/controls/form-field-control.d.ts +1 -1
- package/@types/forms/controls/multiple-files.d.ts +31 -0
- package/@types/forms/controls/number.d.ts +17 -0
- package/@types/forms/controls/simple-input.d.ts +20 -27
- package/@types/forms/controls/textarea.d.ts +9 -7
- package/@types/forms/fields/field.d.ts +4 -1
- package/@types/forms/fields/file.d.ts +16 -0
- package/@types/forms/fields/files-multiple.d.ts +12 -0
- package/@types/forms/fields/multiple-files.d.ts +14 -0
- package/@types/forms/fields/number.d.ts +10 -1
- package/@types/forms/form.d.ts +7 -4
- package/@types/forms/multiform.d.ts +3 -3
- package/@types/page/list.d.ts +1 -1
- package/@types/page/mountable-with-fields.d.ts +3 -2
- package/@types/page/page.d.ts +1 -1
- package/@types/sanitize.d.ts +1 -1
- package/lib/forms/controls/autocomplete.js.map +1 -1
- package/lib/forms/controls/checkbox-group.js +11 -5
- package/lib/forms/controls/checkbox-group.js.map +1 -1
- package/lib/forms/controls/collapsible-checkbox-group.js +2 -2
- package/lib/forms/controls/collapsible-checkbox-group.js.map +1 -1
- package/lib/forms/controls/collapsible-field-group.js.map +1 -1
- package/lib/forms/controls/controls.js +3 -0
- package/lib/forms/controls/controls.js.map +1 -1
- package/lib/forms/controls/derived.js +12 -11
- package/lib/forms/controls/derived.js.map +1 -1
- package/lib/forms/controls/dropdown.js +25 -18
- package/lib/forms/controls/dropdown.js.map +1 -1
- package/lib/forms/controls/field-group.js +3 -3
- package/lib/forms/controls/field-group.js.map +1 -1
- package/lib/forms/controls/file.js +38 -0
- package/lib/forms/controls/file.js.map +1 -0
- package/lib/forms/controls/form-control.js +1 -0
- package/lib/forms/controls/form-control.js.map +1 -1
- package/lib/forms/controls/form-field-control.js.map +1 -1
- package/lib/forms/controls/multiple-files.js +137 -0
- package/lib/forms/controls/multiple-files.js.map +1 -0
- package/lib/forms/controls/number.js +34 -0
- package/lib/forms/controls/number.js.map +1 -0
- package/lib/forms/controls/simple-input.js +20 -10
- package/lib/forms/controls/simple-input.js.map +1 -1
- package/lib/forms/controls/textarea.js +13 -22
- package/lib/forms/controls/textarea.js.map +1 -1
- package/lib/forms/fields/enum-multiple.js +4 -1
- package/lib/forms/fields/enum-multiple.js.map +1 -1
- package/lib/forms/fields/field.js +8 -1
- package/lib/forms/fields/field.js.map +1 -1
- package/lib/forms/fields/file.js +58 -0
- package/lib/forms/fields/file.js.map +1 -0
- package/lib/forms/fields/files-multiple.js +18 -0
- package/lib/forms/fields/files-multiple.js.map +1 -0
- package/lib/forms/fields/multiple-files.js +19 -0
- package/lib/forms/fields/multiple-files.js.map +1 -0
- package/lib/forms/fields/number.js +6 -2
- package/lib/forms/fields/number.js.map +1 -1
- package/lib/forms/form.js +38 -21
- package/lib/forms/form.js.map +1 -1
- package/lib/forms/multiform.js +8 -8
- package/lib/forms/multiform.js.map +1 -1
- package/lib/page/list.js +9 -6
- package/lib/page/list.js.map +1 -1
- package/lib/page/mountable-with-fields.js +16 -3
- package/lib/page/mountable-with-fields.js.map +1 -1
- package/lib/page/page.js +1 -1
- package/lib/page/page.js.map +1 -1
- package/lib/sanitize.js +3 -0
- package/lib/sanitize.js.map +1 -1
- package/lib/tests/manual/multiform.js +13 -13
- package/lib/tests/manual/multiform.js.map +1 -1
- package/package.json +2 -2
- package/src/forms/controls/autocomplete.ts +1 -5
- package/src/forms/controls/checkbox-group.ts +17 -6
- package/src/forms/controls/collapsible-checkbox-group.ts +10 -2
- package/src/forms/controls/collapsible-field-group.ts +2 -4
- package/src/forms/controls/controls.ts +3 -0
- package/src/forms/controls/derived.ts +12 -11
- package/src/forms/controls/dropdown.ts +51 -34
- package/src/forms/controls/field-group.ts +6 -4
- package/src/forms/controls/file.ts +50 -0
- package/src/forms/controls/form-control.ts +5 -1
- package/src/forms/controls/form-field-control.ts +2 -1
- package/src/forms/controls/multiple-files.ts +213 -0
- package/src/forms/controls/number.ts +52 -0
- package/src/forms/controls/simple-input.ts +67 -37
- package/src/forms/controls/textarea.ts +23 -24
- package/src/forms/fields/enum-multiple.ts +3 -1
- package/src/forms/fields/field.ts +12 -2
- package/src/forms/fields/file.ts +86 -0
- package/src/forms/fields/multiple-files.ts +20 -0
- package/src/forms/fields/number.ts +17 -2
- package/src/forms/form.ts +84 -42
- package/src/forms/forms.scss +4 -1
- package/src/forms/multiform.ts +26 -13
- package/src/page/list.ts +10 -7
- package/src/page/mountable-with-fields.ts +26 -4
- package/src/page/page.ts +3 -1
- package/src/sanitize.ts +4 -1
- package/src/tests/manual/multiform.ts +19 -13
|
@@ -2,7 +2,7 @@ import { Context } from "koa";
|
|
|
2
2
|
import { PickFromListField } from "../fields/pick-from-list";
|
|
3
3
|
import { FormDataValue } from "../form";
|
|
4
4
|
import { SimpleInput } from "./simple-input";
|
|
5
|
-
export declare class Autocomplete extends SimpleInput {
|
|
5
|
+
export declare class Autocomplete extends SimpleInput<string | null> {
|
|
6
6
|
field: PickFromListField<boolean>;
|
|
7
7
|
options: {
|
|
8
8
|
id?: string;
|
|
@@ -11,11 +11,12 @@ export declare type DefaultCheckboxOptions = {
|
|
|
11
11
|
readonly?: boolean;
|
|
12
12
|
name?: string;
|
|
13
13
|
checkboxNameToLabel?: (name: string) => string;
|
|
14
|
+
classes?: string[];
|
|
14
15
|
};
|
|
15
16
|
export declare class CheckboxGroup<Options extends DefaultCheckboxOptions = DefaultCheckboxOptions> extends FormFieldControl {
|
|
16
17
|
field: EnumMultipleField<readonly string[], boolean>;
|
|
17
18
|
options: Options;
|
|
18
19
|
constructor(field: EnumMultipleField<readonly string[], boolean>, options?: Options);
|
|
19
|
-
wrapGroup(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[], field_prefix: string, form_id: string, checkboxes: CheckboxWithValue[]): Promise<FlatTemplatable>;
|
|
20
|
-
render<Fields extends Record<string, FormField>>(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[], field_prefix: string, form_id: string): Promise<FlatTemplatable>;
|
|
20
|
+
wrapGroup(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[], field_prefix: string, form_id: string, checkboxes: CheckboxWithValue[], show_field_errors: boolean): Promise<FlatTemplatable>;
|
|
21
|
+
render<Fields extends Record<string, FormField>>(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[], field_prefix: string, form_id: string, show_field_errors: boolean): Promise<FlatTemplatable>;
|
|
21
22
|
}
|
|
@@ -8,5 +8,5 @@ export declare class CollapsibleCheckboxGroup extends CheckboxGroup<DefaultCheck
|
|
|
8
8
|
textWhenClosed?: string;
|
|
9
9
|
groupID?: string;
|
|
10
10
|
}> {
|
|
11
|
-
wrapGroup(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[], field_prefix: string, form_id: string, checkboxes: CheckboxWithValue[]): Promise<FlatTemplatable>;
|
|
11
|
+
wrapGroup(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[], field_prefix: string, form_id: string, checkboxes: CheckboxWithValue[], show_field_errors: boolean): Promise<FlatTemplatable>;
|
|
12
12
|
}
|
|
@@ -3,7 +3,7 @@ import { FieldGroup } from "./field-group";
|
|
|
3
3
|
import { FormControl } from "./form-control";
|
|
4
4
|
declare type CollapsibleFieldGroupOptions = {
|
|
5
5
|
label?: string;
|
|
6
|
-
classes?: string;
|
|
6
|
+
classes?: string[];
|
|
7
7
|
openOnStart?: boolean;
|
|
8
8
|
textWhenOpen?: string;
|
|
9
9
|
textWhenClosed?: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Context } from "koa";
|
|
3
|
-
import {
|
|
2
|
+
import { FlatTemplatable } from "tempstream";
|
|
3
|
+
import { PickFromListField } from "../fields/field";
|
|
4
4
|
import { FormDataValue } from "../form";
|
|
5
|
-
import {
|
|
6
|
-
export declare class Dropdown extends
|
|
5
|
+
import { SimpleInput } from "./simple-input";
|
|
6
|
+
export declare class Dropdown extends SimpleInput<string | null> {
|
|
7
7
|
field: PickFromListField<boolean>;
|
|
8
8
|
options: {
|
|
9
9
|
label: string;
|
|
@@ -15,5 +15,6 @@ export declare class Dropdown extends FormFieldControl {
|
|
|
15
15
|
autosubmit?: boolean;
|
|
16
16
|
autocomplete?: boolean;
|
|
17
17
|
});
|
|
18
|
-
|
|
18
|
+
getInputAttributes(ctx: Context, data: Record<string, FormDataValue>, field_prefix: string, form_id: string): Promise<Record<string, string | boolean>>;
|
|
19
|
+
renderInput(ctx: Context, attributes_str: string, data: Record<string, FormDataValue>): Promise<FlatTemplatable>;
|
|
19
20
|
}
|
|
@@ -7,12 +7,12 @@ export declare class FieldGroup extends FormFieldControl {
|
|
|
7
7
|
controls: FormControl[];
|
|
8
8
|
options: {
|
|
9
9
|
label?: string;
|
|
10
|
-
classes?: string;
|
|
10
|
+
classes?: string[];
|
|
11
11
|
containerID?: string;
|
|
12
12
|
};
|
|
13
13
|
constructor(controls: FormControl[], options?: {
|
|
14
14
|
label?: string;
|
|
15
|
-
classes?: string;
|
|
15
|
+
classes?: string[];
|
|
16
16
|
containerID?: string;
|
|
17
17
|
});
|
|
18
18
|
preLabel(): FlatTemplatable;
|
|
@@ -21,5 +21,5 @@ export declare class FieldGroup extends FormFieldControl {
|
|
|
21
21
|
preFields(): FlatTemplatable;
|
|
22
22
|
postFields(): FlatTemplatable;
|
|
23
23
|
getGroupLabelProps(): FlatTemplatable;
|
|
24
|
-
render(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[], field_prefix: string, form_id: string): Promise<FlatTemplatable>;
|
|
24
|
+
render(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[], field_prefix: string, form_id: string, show_field_errors: boolean): Promise<FlatTemplatable>;
|
|
25
25
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FileContainer } from "../fields/file";
|
|
3
|
+
import { FormDataValue } from "../form";
|
|
4
|
+
import { SimpleInput } from "./simple-input";
|
|
5
|
+
export declare class File extends SimpleInput<FileContainer> {
|
|
6
|
+
getType(): string;
|
|
7
|
+
preInput(ctx: Context, data: Record<string, FormDataValue>): Promise<string>;
|
|
8
|
+
getInputAttributes(ctx: Context, data: Record<string, FormDataValue>, field_prefix: string, form_id: string): Promise<{
|
|
9
|
+
name: string;
|
|
10
|
+
required: boolean | "";
|
|
11
|
+
value: boolean;
|
|
12
|
+
onchange: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
/// <reference types="koa__router" />
|
|
2
|
+
import Router from "@koa/router";
|
|
1
3
|
import { Context } from "koa";
|
|
2
4
|
import { FlatTemplatable } from "tempstream";
|
|
3
5
|
import { FormDataValue, FormMessage } from "../form";
|
|
4
6
|
export declare abstract class FormControl {
|
|
5
|
-
abstract render(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[], field_name_prefix: string, form_id: string): FlatTemplatable | Promise<FlatTemplatable>;
|
|
7
|
+
abstract render(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[], field_name_prefix: string, form_id: string, validate: boolean): FlatTemplatable | Promise<FlatTemplatable>;
|
|
6
8
|
abstract role: "input" | "decoration" | "messages" | "submit";
|
|
9
|
+
mount(router: Router): void;
|
|
7
10
|
}
|
|
@@ -10,5 +10,5 @@ export declare abstract class FormFieldControl extends FormControl {
|
|
|
10
10
|
fields: FormField[];
|
|
11
11
|
role: "input";
|
|
12
12
|
constructor(fields: FormField[]);
|
|
13
|
-
abstract render(ctx: Context, data: Record<string, FormDataValue>, messages: [], field_name_prefix: string, form_id: string): FlatTemplatable | Promise<FlatTemplatable>;
|
|
13
|
+
abstract render(ctx: Context, data: Record<string, FormDataValue>, messages: [], field_name_prefix: string, form_id: string, validate: boolean): FlatTemplatable | Promise<FlatTemplatable>;
|
|
14
14
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="koa__router" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import Router from "@koa/router";
|
|
4
|
+
import { Collection, CollectionItem, File as SealiousFile, Field as SealiousField } from "sealious";
|
|
5
|
+
import { Context } from "koa";
|
|
6
|
+
import { FlatTemplatable } from "tempstream";
|
|
7
|
+
import { MultipleFiles as MultipleFilesField } from "../fields/multiple-files";
|
|
8
|
+
import { FormDataValue } from "../form";
|
|
9
|
+
import { FormFieldControl } from "./form-field-control";
|
|
10
|
+
export declare type MultipleFilesOptions = {
|
|
11
|
+
label?: string;
|
|
12
|
+
uploadLabel?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare class MultipleFiles extends FormFieldControl {
|
|
15
|
+
field: MultipleFilesField;
|
|
16
|
+
options: MultipleFilesOptions;
|
|
17
|
+
constructor(field: MultipleFilesField, options?: MultipleFilesOptions);
|
|
18
|
+
mount(router: Router): void;
|
|
19
|
+
deleteFileAssociation(ctx: Context, file_item_id: string): Promise<void>;
|
|
20
|
+
addFileAssociation(ctx: Context, file: SealiousFile): Promise<void>;
|
|
21
|
+
getFrameRelativeURL(): string;
|
|
22
|
+
getFrameID(): string;
|
|
23
|
+
renderFrame(ctx: Context, content?: FlatTemplatable): import("stream").Readable;
|
|
24
|
+
render(ctx: Context, _data: Record<string, FormDataValue>, _messages: [], field_name_prefix: string, form_id: string, validate: boolean): FlatTemplatable | Promise<FlatTemplatable>;
|
|
25
|
+
getReferencingCollection(): Collection;
|
|
26
|
+
getFileField(): SealiousField | null;
|
|
27
|
+
extractFileFromItem(item: CollectionItem): Promise<SealiousFile | null>;
|
|
28
|
+
renderFileItem(fileItem: CollectionItem, file: SealiousFile): Promise<FlatTemplatable>;
|
|
29
|
+
getFileItems(ctx: Context): Promise<CollectionItem<any>[]>;
|
|
30
|
+
renderFrameContent(ctx: Context): Promise<FlatTemplatable>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FlatTemplatable } from "tempstream";
|
|
3
|
+
import { NumberField } from "../fields/field";
|
|
4
|
+
import { FormDataValue } from "../form";
|
|
5
|
+
import { SimpleInput, SimpleInputOptions } from "./simple-input";
|
|
6
|
+
export declare type NumberOptions = SimpleInputOptions & Partial<{
|
|
7
|
+
step: number;
|
|
8
|
+
suffix: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare class Number extends SimpleInput<number | null> {
|
|
11
|
+
field: NumberField;
|
|
12
|
+
options: NumberOptions;
|
|
13
|
+
constructor(field: NumberField, options: NumberOptions);
|
|
14
|
+
getType(): string;
|
|
15
|
+
postInput(_: Context): Promise<FlatTemplatable>;
|
|
16
|
+
getInputAttributes(ctx: Context, data: Record<string, FormDataValue>, field_prefix: string, form_id: string): Promise<Record<string, string | boolean>>;
|
|
17
|
+
}
|
|
@@ -3,36 +3,29 @@ import { FlatTemplatable } from "tempstream";
|
|
|
3
3
|
import { FormField } from "../fields/field";
|
|
4
4
|
import { FormDataValue, FormMessage } from "../form";
|
|
5
5
|
import { FormFieldControl } from "./controls";
|
|
6
|
-
export declare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
autocomplete?: boolean;
|
|
23
|
-
hide_errors?: boolean;
|
|
24
|
-
type?: "color" | "date" | "email" | "file" | "month" | "number" | "password" | "search" | "tel" | "text" | "time" | "url" | "week";
|
|
25
|
-
value?: string;
|
|
26
|
-
placeholder?: string;
|
|
27
|
-
readonly?: boolean;
|
|
28
|
-
step?: number;
|
|
29
|
-
});
|
|
6
|
+
export declare type SimpleInputOptions = {
|
|
7
|
+
id?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
autocomplete?: boolean;
|
|
10
|
+
hide_errors?: boolean;
|
|
11
|
+
type?: "color" | "date" | "email" | "file" | "month" | "number" | "password" | "search" | "tel" | "text" | "time" | "url" | "week";
|
|
12
|
+
value?: string;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
readonly?: boolean;
|
|
15
|
+
step?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare class SimpleInput<ParsedValue, Options extends SimpleInputOptions = SimpleInputOptions> extends FormFieldControl {
|
|
18
|
+
field: FormField<boolean, ParsedValue>;
|
|
19
|
+
options: SimpleInputOptions;
|
|
20
|
+
constructor(field: FormField<boolean, ParsedValue>, options?: Options);
|
|
21
|
+
preInput(_ctx: Context, _data: Record<string, FormDataValue>): Promise<FlatTemplatable>;
|
|
30
22
|
getType(): string;
|
|
31
23
|
getLabel(): string;
|
|
32
24
|
getID(): string;
|
|
33
25
|
getPlaceholder(): string;
|
|
34
|
-
getInputAttributes(ctx: Context, data: Record<string, FormDataValue>, field_prefix: string, form_id: string): Promise<Record<string, string |
|
|
35
|
-
renderAttributes(attrs: Record<string, string |
|
|
26
|
+
getInputAttributes(ctx: Context, data: Record<string, FormDataValue>, field_prefix: string, form_id: string): Promise<Record<string, string | boolean>>;
|
|
27
|
+
renderAttributes(attrs: Record<string, string | boolean>): string;
|
|
36
28
|
postInput(ctx: Context): Promise<FlatTemplatable>;
|
|
37
|
-
|
|
29
|
+
renderInput(ctx: Context, attributes_str: string, data: Record<string, FormDataValue>): Promise<FlatTemplatable>;
|
|
30
|
+
render<Fields extends Record<string, FormField>>(ctx: Context, data: Record<string, FormDataValue>, _messages: FormMessage[], field_prefix: string, form_id: string, show_errors: boolean): Promise<FlatTemplatable>;
|
|
38
31
|
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { Context } from "koa";
|
|
2
|
-
import { FlatTemplatable } from "tempstream";
|
|
3
2
|
import { FormField } from "../fields/field";
|
|
4
3
|
import { FormDataValue } from "../form";
|
|
5
|
-
import {
|
|
6
|
-
export declare class Textarea extends
|
|
7
|
-
field: FormField
|
|
8
|
-
options: {
|
|
4
|
+
import { SimpleInput, SimpleInputOptions } from "./simple-input";
|
|
5
|
+
export declare class Textarea<Required extends boolean> extends SimpleInput<string> {
|
|
6
|
+
field: FormField<boolean, string>;
|
|
7
|
+
options: SimpleInputOptions & {
|
|
9
8
|
label?: string;
|
|
10
9
|
rows?: number;
|
|
11
10
|
cols?: number;
|
|
11
|
+
description?: string;
|
|
12
12
|
};
|
|
13
|
-
constructor(field: FormField, options?: {
|
|
13
|
+
constructor(field: FormField<boolean, string>, options?: SimpleInputOptions & {
|
|
14
14
|
label?: string;
|
|
15
15
|
rows?: number;
|
|
16
16
|
cols?: number;
|
|
17
|
+
description?: string;
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
+
renderDescription(): string;
|
|
20
|
+
renderInput(ctx: Context, attributes: string, data: Record<string, FormDataValue>): Promise<string>;
|
|
19
21
|
}
|
|
@@ -27,7 +27,7 @@ export declare abstract class FormField<Required extends boolean = boolean, Pars
|
|
|
27
27
|
constructor(required: Required);
|
|
28
28
|
predicate: Predicate;
|
|
29
29
|
mapToFilter: (parsed: ParsedValue) => unknown;
|
|
30
|
-
init(fieldname: string): void
|
|
30
|
+
init(fieldname: string): Promise<void>;
|
|
31
31
|
_validate(ctx: Context, value: ParsedValue): Promise<FormFieldValidationResponse>;
|
|
32
32
|
abstract getEmptyValue(): ParsedValue;
|
|
33
33
|
isValueValid(ctx: Context, value: ParsedValue): Promise<FormFieldValidationResponse>;
|
|
@@ -39,6 +39,7 @@ export declare abstract class FormField<Required extends boolean = boolean, Pars
|
|
|
39
39
|
raw: FormDataValue;
|
|
40
40
|
}>;
|
|
41
41
|
setMapToFilter(fn: (parsed: ParsedValue) => unknown): this;
|
|
42
|
+
getDatabaseValue(ctx: Context, data: Record<string, FormDataValue>): Promise<unknown>;
|
|
42
43
|
}
|
|
43
44
|
export * from "./simple-form-field";
|
|
44
45
|
export * from "./checkboxed-list";
|
|
@@ -51,3 +52,5 @@ export * from "./enum";
|
|
|
51
52
|
export * from "./boolean";
|
|
52
53
|
export * from "./enum-multiple";
|
|
53
54
|
export * from "./existing-sealious-value";
|
|
55
|
+
export * from "./file";
|
|
56
|
+
export * from "./multiple-files";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { File as SealiousFile } from "sealious";
|
|
3
|
+
import { FormDataValue } from "../form";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field";
|
|
5
|
+
export declare type FileContainer = {
|
|
6
|
+
old: SealiousFile | null;
|
|
7
|
+
new: SealiousFile | null;
|
|
8
|
+
};
|
|
9
|
+
export declare class File<Required extends boolean> extends FormField<Required, FileContainer> {
|
|
10
|
+
parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<FileContainer>>;
|
|
11
|
+
getDatabaseValue(ctx: Context, data: Record<string, FormDataValue>): Promise<SealiousFile | undefined>;
|
|
12
|
+
getEmptyValue(): {
|
|
13
|
+
old: null;
|
|
14
|
+
new: null;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FieldTypes as SealiousFieldTypes } from "sealious";
|
|
2
|
+
import { FormField } from "./field";
|
|
3
|
+
export declare class MultipleFilesField extends FormField<false> {
|
|
4
|
+
collection_field: SealiousFieldTypes.ReverseSingleReference;
|
|
5
|
+
constructor(collection_field: SealiousFieldTypes.ReverseSingleReference);
|
|
6
|
+
getEmptyValue(): undefined;
|
|
7
|
+
parse(): Promise<{
|
|
8
|
+
readonly parsed_value: undefined;
|
|
9
|
+
readonly parsable: true;
|
|
10
|
+
readonly error: null;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FieldTypes as SealiousFieldTypes } from "sealious";
|
|
3
|
+
import { FormField } from "./field";
|
|
4
|
+
export declare class MultipleFiles extends FormField<false> {
|
|
5
|
+
collection_field: SealiousFieldTypes.ReverseSingleReference;
|
|
6
|
+
getItemId: (ctx: Context) => Promise<string> | string;
|
|
7
|
+
constructor(collection_field: SealiousFieldTypes.ReverseSingleReference, getItemId: (ctx: Context) => Promise<string> | string);
|
|
8
|
+
getEmptyValue(): undefined;
|
|
9
|
+
parse(): Promise<{
|
|
10
|
+
readonly parsed_value: undefined;
|
|
11
|
+
readonly parsable: true;
|
|
12
|
+
readonly error: null;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
@@ -3,7 +3,16 @@ import { FormDataValue } from "../form";
|
|
|
3
3
|
import { FieldParseResult, FormField } from "./field";
|
|
4
4
|
export declare class NumberField<DefaultValue extends number | null = null, Required extends boolean = boolean> extends FormField<Required, number | DefaultValue> {
|
|
5
5
|
default_value: DefaultValue;
|
|
6
|
-
|
|
6
|
+
options: Partial<{
|
|
7
|
+
max: number;
|
|
8
|
+
min: number;
|
|
9
|
+
decimalDigits: number;
|
|
10
|
+
}>;
|
|
11
|
+
constructor(required: Required, default_value: DefaultValue, options?: Partial<{
|
|
12
|
+
max: number;
|
|
13
|
+
min: number;
|
|
14
|
+
decimalDigits: number;
|
|
15
|
+
}>);
|
|
7
16
|
predicate: import("@sealcode/ts-predicates").Predicate<number>;
|
|
8
17
|
isValueValid(_: Context, value: unknown): Promise<{
|
|
9
18
|
valid: boolean;
|
package/@types/forms/form.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="koa__router" />
|
|
2
2
|
import { Context } from "koa";
|
|
3
|
+
import { File as SealiousFile } from "sealious";
|
|
3
4
|
import Router from "@koa/router";
|
|
4
5
|
import { FlatTemplatable } from "tempstream";
|
|
5
6
|
import { FormField } from "./fields/field";
|
|
6
7
|
import { Fields, MountableWithFields, PageErrorMessage } from "../page/mountable-with-fields";
|
|
7
8
|
export declare type FormDataPrimitive = string | string[] | number | undefined;
|
|
8
|
-
export declare type FormDataValue = FormDataPrimitive | Record<string, FormDataPrimitive
|
|
9
|
+
export declare type FormDataValue = FormDataPrimitive | Record<string, FormDataPrimitive> | SealiousFile;
|
|
9
10
|
export declare type FieldValueType<F extends FormField> = F extends FormField<infer R> ? R : never;
|
|
10
11
|
export declare type FormFieldsToValues<F extends Record<string, FormField<boolean, keyof F>>> = {
|
|
11
12
|
[Property in keyof F]: FieldValueType<F[Property]>;
|
|
@@ -32,21 +33,23 @@ export declare abstract class Form<F extends Fields, SubmitResult extends any> e
|
|
|
32
33
|
submitButtonText: string;
|
|
33
34
|
action: string;
|
|
34
35
|
useTurbo: boolean;
|
|
36
|
+
form_id: string;
|
|
35
37
|
canAccess(_: Context): Promise<{
|
|
36
38
|
canAccess: boolean;
|
|
37
39
|
message: string;
|
|
38
40
|
}>;
|
|
39
41
|
renderError(_: Context, error: PageErrorMessage): Promise<FlatTemplatable>;
|
|
40
42
|
makeSubmitButton(): FlatTemplatable;
|
|
41
|
-
render(ctx: Context, data: FormData): Promise<FlatTemplatable>;
|
|
43
|
+
render(ctx: Context, data: FormData, show_field_errors: boolean): Promise<FlatTemplatable>;
|
|
42
44
|
makeFormClasses(_ctx: Context): Promise<string[]>;
|
|
43
45
|
makeOpenFormTag(ctx: Context): FlatTemplatable;
|
|
44
46
|
makeCloseFormTag(): FlatTemplatable;
|
|
45
|
-
onValuesInvalid(ctx: Context, form_messages: FormMessage[]): Promise<FormReaction>;
|
|
47
|
+
onValuesInvalid(ctx: Context, form_messages: FormMessage[], _field_errors: Partial<Record<keyof Fields, string>>): Promise<FormReaction>;
|
|
46
48
|
onError(ctx: Context, data: FormData, error: unknown): Promise<FormReaction>;
|
|
47
49
|
abstract onSubmit(ctx: Context, data: FormData): SubmitResult | Promise<SubmitResult>;
|
|
48
50
|
onSuccess(ctx: Context, data: FormData, _submitResult: SubmitResult): Promise<FormReaction>;
|
|
51
|
+
getRawValuesOnSuccess(ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
49
52
|
handlePost(ctx: Context): Promise<FormReaction>;
|
|
50
53
|
mount(router: Router, path: string): void;
|
|
51
|
-
extractRawValues(ctx: Context): Record<string, FormDataValue
|
|
54
|
+
extractRawValues(ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
52
55
|
}
|
|
@@ -9,15 +9,15 @@ export declare class Multiform extends MountableWithFields {
|
|
|
9
9
|
name: string;
|
|
10
10
|
forms: Record<string, Form<Fields, unknown>>;
|
|
11
11
|
init(): void;
|
|
12
|
-
extractRawValues(ctx: Context): Record<string, FormDataValue
|
|
12
|
+
extractRawValues(ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
13
13
|
canAccess(): Promise<{
|
|
14
14
|
canAccess: boolean;
|
|
15
15
|
message: string;
|
|
16
16
|
}>;
|
|
17
17
|
getSubformsToRender(ctx: Context): Array<readonly [string, Form<any, unknown>]>;
|
|
18
|
-
renderSubform(ctx: Context, sub_form_name: string): Promise<FlatTemplatable>;
|
|
18
|
+
renderSubform(ctx: Context, sub_form_name: string, show_field_errors: boolean): Promise<FlatTemplatable>;
|
|
19
19
|
getSubformRawValues(ctx: Context, sub_form_name: string): Record<string, FormDataValue>;
|
|
20
|
-
render(ctx: Context, messages: FormMessage[], prerenderedForms
|
|
20
|
+
render(ctx: Context, messages: FormMessage[], prerenderedForms: Record<string, FlatTemplatable | undefined> | undefined, show_field_errors: boolean): Promise<FlatTemplatable>;
|
|
21
21
|
makeBottomScript(): string;
|
|
22
22
|
mount(router: Router, path: string): void;
|
|
23
23
|
}
|
package/@types/page/list.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare abstract class ListPage<ItemType, F extends typeof BaseListPageFi
|
|
|
25
25
|
renderPagination(ctx: Context, values: Record<string, FormDataValue>): Promise<FlatTemplatable>;
|
|
26
26
|
private renderPageButton;
|
|
27
27
|
getFilterValues(ctx: Context): Promise<Record<string, unknown>>;
|
|
28
|
-
renderFilters(ctx: Context): FlatTemplatable
|
|
28
|
+
renderFilters(ctx: Context): Promise<FlatTemplatable>;
|
|
29
29
|
}
|
|
30
30
|
export declare abstract class SealiousItemListPage<C extends Collection, F extends typeof BaseListPageFields> extends ListPage<CollectionItem<C>, F> {
|
|
31
31
|
collection: C;
|
|
@@ -26,9 +26,10 @@ export declare abstract class MountableWithFields<F extends Fields = Fields> ext
|
|
|
26
26
|
field_errors: Partial<Record<keyof Fields, string>>;
|
|
27
27
|
form_messages: FormMessage[];
|
|
28
28
|
}>;
|
|
29
|
-
renderControls(ctx: Context, data: FormData<keyof Fields
|
|
29
|
+
renderControls(ctx: Context, data: FormData<keyof Fields>, validate: boolean): FlatTemplatable;
|
|
30
30
|
renderError(_: Context, error: PageErrorMessage): Promise<FlatTemplatable>;
|
|
31
31
|
renderMessages(_: Context, data: FormData<keyof Fields>): FlatTemplatable;
|
|
32
|
-
abstract extractRawValues(ctx: Context): Record<string, FormDataValue
|
|
32
|
+
abstract extractRawValues(ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
33
33
|
getParsedValues(ctx: Context): Promise<ShapeToType<FieldsToShape<F>>>;
|
|
34
|
+
getDatabaseValues(ctx: Context): Promise<ShapeToType<FieldsToShape<F>>>;
|
|
34
35
|
}
|
package/@types/page/page.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ export declare abstract class Page<F extends Fields = Record<string, never>> ext
|
|
|
15
15
|
}>;
|
|
16
16
|
renderError(_: Context, error: PageErrorMessage): Promise<FlatTemplatable>;
|
|
17
17
|
abstract render(ctx: Context): Promise<FlatTemplatable>;
|
|
18
|
-
extractRawValues(ctx: Context): Record<string, FormDataValue
|
|
18
|
+
extractRawValues(ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
19
19
|
}
|
package/@types/sanitize.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function attribute(raw: string): string;
|
|
1
|
+
export declare function attribute(raw: string | number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.js","sourceRoot":"","sources":["../../../src/forms/controls/autocomplete.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"autocomplete.js","sourceRoot":"","sources":["../../../src/forms/controls/autocomplete.ts"],"names":[],"mappings":";;;AAGA,iDAA6C;AAE7C,MAAa,YAAa,SAAQ,0BAA0B;IAC3D,YACQ,KAAiC,EACjC,OAA8D;QAErE,KAAK,CAAC,KAAK,CAAC,CAAC;QAHN,UAAK,GAAL,KAAK,CAA4B;QACjC,YAAO,GAAP,OAAO,CAAuD;IAGtE,CAAC;IAED,SAAS;QACR,OAAO,IAAI,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,kBAAkB,CACvB,GAAY,EACZ,IAAmC,EACnC,YAAoB,EACpB,OAAe;QAEf,OAAO;YACN,GAAG,CAAC,MAAM,KAAK,CAAC,kBAAkB,CACjC,GAAG,EACH,IAAI,EACJ,YAAY,EACZ,OAAO,CACP,CAAC;YACF,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE;SACtB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAY;QAC3B,OAAO,UAAU,CAAC,iBAAiB,IAAI,CAAC,SAAS,EAAE;KAChD,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAC1D,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,GAAG,WAAW,CACtD;cACU,CAAC;IACd,CAAC;CACD;AApCD,oCAoCC"}
|
|
@@ -10,17 +10,23 @@ class CheckboxGroup extends controls_1.FormFieldControl {
|
|
|
10
10
|
this.field = field;
|
|
11
11
|
this.options = options;
|
|
12
12
|
}
|
|
13
|
-
wrapGroup(ctx, data, messages, field_prefix, form_id, checkboxes) {
|
|
14
|
-
return new controls_1.FieldGroup(checkboxes, {
|
|
13
|
+
wrapGroup(ctx, data, messages, field_prefix, form_id, checkboxes, show_field_errors) {
|
|
14
|
+
return new controls_1.FieldGroup(checkboxes, {
|
|
15
|
+
label: this.options.label,
|
|
16
|
+
classes: [
|
|
17
|
+
...(this.options.classes || []),
|
|
18
|
+
"field-group--checkboxes",
|
|
19
|
+
],
|
|
20
|
+
}).render(ctx, data, messages, field_prefix, form_id, show_field_errors);
|
|
15
21
|
}
|
|
16
|
-
async render(ctx, data, messages, field_prefix, form_id) {
|
|
22
|
+
async render(ctx, data, messages, field_prefix, form_id, show_field_errors) {
|
|
17
23
|
const { parsed: values } = await this.field.getValue(ctx, data);
|
|
18
|
-
const checkboxes = this.field.options.map((option) => new checkbox_1.CheckboxWithValue(new proxy_field_1.ProxyFormField(false, this.field.name
|
|
24
|
+
const checkboxes = this.field.options.map((option) => new checkbox_1.CheckboxWithValue(new proxy_field_1.ProxyFormField(false, this.field.name, false, values.includes(option)), {
|
|
19
25
|
id: this.field.name + "__" + option,
|
|
20
26
|
label: (this.options.checkboxNameToLabel ||
|
|
21
27
|
((s) => s))(option),
|
|
22
28
|
}, option));
|
|
23
|
-
return this.wrapGroup(ctx, data, messages, field_prefix, form_id, checkboxes);
|
|
29
|
+
return this.wrapGroup(ctx, data, messages, field_prefix, form_id, checkboxes, show_field_errors);
|
|
24
30
|
}
|
|
25
31
|
}
|
|
26
32
|
exports.CheckboxGroup = CheckboxGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox-group.js","sourceRoot":"","sources":["../../../src/forms/controls/checkbox-group.ts"],"names":[],"mappings":";;;AAGA,uDAAuD;AAEvD,yCAA+C;AAC/C,yCAA0D;
|
|
1
|
+
{"version":3,"file":"checkbox-group.js","sourceRoot":"","sources":["../../../src/forms/controls/checkbox-group.ts"],"names":[],"mappings":";;;AAGA,uDAAuD;AAEvD,yCAA+C;AAC/C,yCAA0D;AAY1D,MAAa,aAEX,SAAQ,2BAAgB;IACzB,YACQ,KAAoD,EACpD,UAAmB,EAAa;QAEvC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAHR,UAAK,GAAL,KAAK,CAA+C;QACpD,YAAO,GAAP,OAAO,CAAyB;IAGxC,CAAC;IAED,SAAS,CACR,GAAY,EACZ,IAAmC,EACnC,QAAuB,EACvB,YAAoB,EACpB,OAAe,EACf,UAA+B,EAC/B,iBAA0B;QAE1B,OAAO,IAAI,qBAAU,CAAC,UAAU,EAAE;YACjC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;YACzB,OAAO,EAAE;gBACR,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC/B,yBAAyB;aACzB;SACD,CAAC,CAAC,MAAM,CACR,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,iBAAiB,CACjB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CACX,GAAY,EACZ,IAAmC,EACnC,QAAuB,EACvB,YAAoB,EACpB,OAAe,EACf,iBAA0B;QAE1B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAChE,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CACxC,CAAC,MAAM,EAAE,EAAE,CACV,IAAI,4BAAiB,CACpB,IAAI,4BAAc,CACjB,KAAK,EACL,IAAI,CAAC,KAAK,CAAC,IAAI,EACf,KAAK,EACL,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CACvB,EACD;YACC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,GAAG,MAAM;YACnC,KAAK,EAAE,CACN,IAAI,CAAC,OAAO,CAAC,mBAAmB;gBAChC,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAClB,CAAC,MAAM,CAAC;SACT,EACD,MAAM,CACN,CACF,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CACpB,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,UAAU,EACV,iBAAiB,CACjB,CAAC;IACH,CAAC;CACD;AAzED,sCAyEC"}
|
|
@@ -4,13 +4,13 @@ exports.CollapsibleCheckboxGroup = void 0;
|
|
|
4
4
|
const checkbox_group_1 = require("./checkbox-group");
|
|
5
5
|
const collapsible_field_group_1 = require("./collapsible-field-group");
|
|
6
6
|
class CollapsibleCheckboxGroup extends checkbox_group_1.CheckboxGroup {
|
|
7
|
-
wrapGroup(ctx, data, messages, field_prefix, form_id, checkboxes) {
|
|
7
|
+
wrapGroup(ctx, data, messages, field_prefix, form_id, checkboxes, show_field_errors) {
|
|
8
8
|
return new collapsible_field_group_1.CollapsibleFieldGroup(checkboxes, {
|
|
9
9
|
label: this.options.label,
|
|
10
10
|
textWhenOpen: this.options.textWhenOpen,
|
|
11
11
|
textWhenClosed: this.options.textWhenClosed,
|
|
12
12
|
groupID: this.options.groupID,
|
|
13
|
-
}).render(ctx, data, messages, field_prefix, form_id);
|
|
13
|
+
}).render(ctx, data, messages, field_prefix, form_id, show_field_errors);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
exports.CollapsibleCheckboxGroup = CollapsibleCheckboxGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collapsible-checkbox-group.js","sourceRoot":"","sources":["../../../src/forms/controls/collapsible-checkbox-group.ts"],"names":[],"mappings":";;;AAKA,qDAAyE;AACzE,uEAAkE;AAElE,MAAa,wBAAyB,SAAQ,8BAM7C;IACA,SAAS,CACR,GAAY,EACZ,IAAmC,EACnC,QAAuB,EACvB,YAAoB,EACpB,OAAe,EACf,UAA+B
|
|
1
|
+
{"version":3,"file":"collapsible-checkbox-group.js","sourceRoot":"","sources":["../../../src/forms/controls/collapsible-checkbox-group.ts"],"names":[],"mappings":";;;AAKA,qDAAyE;AACzE,uEAAkE;AAElE,MAAa,wBAAyB,SAAQ,8BAM7C;IACA,SAAS,CACR,GAAY,EACZ,IAAmC,EACnC,QAAuB,EACvB,YAAoB,EACpB,OAAe,EACf,UAA+B,EAC/B,iBAA0B;QAE1B,OAAO,IAAI,+CAAqB,CAAC,UAAU,EAAE;YAC5C,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;YACzB,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;YACvC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc;YAC3C,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;SAC7B,CAAC,CAAC,MAAM,CACR,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,iBAAiB,CACjB,CAAC;IACH,CAAC;CACD;AA9BD,4DA8BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collapsible-field-group.js","sourceRoot":"","sources":["../../../src/forms/controls/collapsible-field-group.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"collapsible-field-group.js","sourceRoot":"","sources":["../../../src/forms/controls/collapsible-field-group.ts"],"names":[],"mappings":";;;AACA,+CAA2C;AAC3C,mCAAoC;AAYpC,MAAa,qBAAsB,SAAQ,wBAAU;IAEpD,YACQ,QAAuB,EACvB,UAAwC,EAAE;QAEjD,KAAK,CAAC,EAAE,CAAC,CAAC;QAHH,aAAQ,GAAR,QAAQ,CAAe;QACvB,YAAO,GAAP,OAAO,CAAmC;QAGjD,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,SAAS,EAAE;YACtC,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,GAAG,GAAG,mBAAU,EAAE,CAAC,CAAC,0DAA0D;SACrG;QACD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC;IACrD,CAAC;IAED,kBAAkB;QACjB,OAAO,KAAK,CAAC,kBAAkB,EAAE,GAAG,SAAS,IAAI,CAAC,UAAU,GAAG,CAAC;IACjE,CAAC;IAED,iBAAiB;QAChB,OAAO,UAAU,CAAC;YACR,IAAI,CAAC,UAAU;;;;YAIf,IAAI,CAAC,UAAU;;;;YAIf,IAAI,CAAC,UAAU;;;;YAIf,IAAI,CAAC,UAAU;;;;;;YAMf,IAAI,CAAC,UAAU;;;;;;YAMf,IAAI,CAAC,UAAU;;;;;;YAMf,IAAI,CAAC,UAAU;;;;;;;;UAQjB,IAAI,CAAC,UAAU;MACnB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;MACzC,CAAC;IACN,CAAC;IAED,SAAS;QACR,OAAO,UAAU,CAAC;;UAEV,IAAI,CAAC,UAAU;;;;;MAKnB,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,OAAO;;;;;MAKpC,IAAI,CAAC,OAAO,CAAC,cAAc,IAAI,MAAM;;WAEhC,CAAC;IACX,CAAC;CACD;AA/ED,sDA+EC"}
|
|
@@ -46,4 +46,7 @@ __exportStar(require("./checkbox-group"), exports);
|
|
|
46
46
|
__exportStar(require("./collapsible-field-group"), exports);
|
|
47
47
|
__exportStar(require("./collapsible-checkbox-group"), exports);
|
|
48
48
|
__exportStar(require("./autocomplete"), exports);
|
|
49
|
+
__exportStar(require("./file"), exports);
|
|
50
|
+
__exportStar(require("./multiple-files"), exports);
|
|
51
|
+
__exportStar(require("./number"), exports);
|
|
49
52
|
//# sourceMappingURL=controls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../../src/forms/controls/controls.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,2EAAwE;AAA/D,sIAAA,wBAAwB,OAAA;AACjC,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,0CAAwB;AACxB,oDAAkC;AAClC,mDAAiC;AACjC,4DAA0C;AAC1C,+DAA6C;AAC7C,iDAA+B"}
|
|
1
|
+
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../../src/forms/controls/controls.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,2EAAwE;AAA/D,sIAAA,wBAAwB,OAAA;AACjC,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,0CAAwB;AACxB,oDAAkC;AAClC,mDAAiC;AACjC,4DAA0C;AAC1C,+DAA6C;AAC7C,iDAA+B;AAC/B,yCAAuB;AACvB,mDAAiC;AACjC,2CAAyB"}
|
|
@@ -26,16 +26,17 @@ class Derived extends form_control_1.FormControl {
|
|
|
26
26
|
})
|
|
27
27
|
.join(",")},
|
|
28
28
|
};
|
|
29
|
-
const
|
|
29
|
+
const form_container =
|
|
30
|
+
document.currentScript.closest(".form-container");
|
|
30
31
|
const render = ${this._render.toString()};
|
|
31
32
|
function getValues() {
|
|
32
33
|
return Object.fromEntries(
|
|
33
34
|
${JSON.stringify(this.fields.map((field) => field.name))}.map((field_name) => {
|
|
34
|
-
let input =
|
|
35
|
+
let input = form_container.querySelector(
|
|
35
36
|
\`input[name="\${field_name}"]\`
|
|
36
37
|
);
|
|
37
38
|
if (input.type === "radio") {
|
|
38
|
-
input =
|
|
39
|
+
input = form_container.querySelector(
|
|
39
40
|
\`input[name="\${field_name}"]:checked\`
|
|
40
41
|
);
|
|
41
42
|
}
|
|
@@ -44,14 +45,14 @@ class Derived extends form_control_1.FormControl {
|
|
|
44
45
|
);
|
|
45
46
|
}
|
|
46
47
|
function setupWatcher(field_name) {
|
|
47
|
-
|
|
48
|
-
\`input[name="\${field_name}"]\`
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
form_container
|
|
49
|
+
.querySelectorAll(\`input[name="\${field_name}"]\`)
|
|
50
|
+
.forEach((input) => {
|
|
51
|
+
input.onchange = () => {
|
|
52
|
+
document.querySelector("#${id}").innerHTML =
|
|
53
|
+
render(getValues(), consts);
|
|
54
|
+
};
|
|
55
|
+
});
|
|
55
56
|
}
|
|
56
57
|
${JSON.stringify(this.fields.map((field) => field.name))}.forEach(setupWatcher);
|
|
57
58
|
setTimeout(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derived.js","sourceRoot":"","sources":["../../../src/forms/controls/derived.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AACpC,2CAAyD;AAEzD,iDAA6C;AAE7C,MAAa,OAEX,SAAQ,0BAAW;IAGpB,YACQ,MAAmB,EACnB,OAGI,EACJ,MAAc;QAErB,KAAK,EAAE,CAAC;QAPD,WAAM,GAAN,MAAM,CAAa;QACnB,YAAO,GAAP,OAAO,CAGH;QACJ,WAAM,GAAN,MAAM,CAAQ;QARtB,SAAI,GAAU,YAAY,CAAC;IAW3B,CAAC;IAED,MAAM;QACL,MAAM,EAAE,GAAG,GAAG,GAAG,mBAAU,EAAE,CAAC,CAAC,qEAAqE;QACpG,OAAO,uBAAU,CAAA,UAAU,CAAC;;;;QAItB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;aACjC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACrB,OAAO,IAAI,GAAG,MACb,OAAO,KAAK,KAAK,QAAQ;gBACxB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;gBACvB,CAAC,CAAE,KAAgB,CAAC,QAAQ,EAC9B,EAAE,CAAC;QACJ,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC
|
|
1
|
+
{"version":3,"file":"derived.js","sourceRoot":"","sources":["../../../src/forms/controls/derived.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AACpC,2CAAyD;AAEzD,iDAA6C;AAE7C,MAAa,OAEX,SAAQ,0BAAW;IAGpB,YACQ,MAAmB,EACnB,OAGI,EACJ,MAAc;QAErB,KAAK,EAAE,CAAC;QAPD,WAAM,GAAN,MAAM,CAAa;QACnB,YAAO,GAAP,OAAO,CAGH;QACJ,WAAM,GAAN,MAAM,CAAQ;QARtB,SAAI,GAAU,YAAY,CAAC;IAW3B,CAAC;IAED,MAAM;QACL,MAAM,EAAE,GAAG,GAAG,GAAG,mBAAU,EAAE,CAAC,CAAC,qEAAqE;QACpG,OAAO,uBAAU,CAAA,UAAU,CAAC;;;;QAItB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;aACjC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACrB,OAAO,IAAI,GAAG,MACb,OAAO,KAAK,KAAK,QAAQ;gBACxB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;gBACvB,CAAC,CAAE,KAAgB,CAAC,QAAQ,EAC9B,EAAE,CAAC;QACJ,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC;;;;sBAIK,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;;;SAGpC,IAAI,CAAC,SAAS,CACf,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CACtC;;;;;;;;;;;;;;;;;;oCAkB4B,EAAE;;;;;OAK/B,IAAI,CAAC,SAAS,CACf,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CACtC;;;mCAG6B,EAAE;;;;;;cAMvB,EAAE,KAAK,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC;SACzC,CAAC;IACT,CAAC;CACD;AA5ED,0BA4EC"}
|