@sealcode/sealgen 0.19.26 → 0.19.29
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/dropdown.d.ts +6 -6
- package/@types/forms/controls/single-reference.d.ts +9 -6
- package/@types/forms/fields/field.d.ts +2 -2
- package/@types/forms/fields/pick-from-list.d.ts +2 -2
- package/@types/forms/fields/simple-form-field.d.ts +1 -1
- package/@types/forms/multiform.d.ts +4 -3
- package/@types/page/stateful-page.d.ts +1 -1
- package/@types/src/add-collection.d.ts +1 -0
- package/@types/src/add-crud.d.ts +3 -0
- package/@types/src/add-crud.test.d.ts +1 -0
- package/@types/src/add-jdd-component.d.ts +1 -0
- package/@types/src/add-list-route.test.d.ts +1 -0
- package/@types/src/add-route.d.ts +3 -0
- package/@types/src/add-route.test.d.ts +1 -0
- package/@types/src/build.d.ts +3 -0
- package/@types/src/builders/backend-ts-builder.d.ts +7 -0
- package/@types/src/builders/builder.d.ts +11 -0
- package/@types/src/builders/colors-builder.d.ts +10 -0
- package/@types/src/builders/css-builder.d.ts +19 -0
- package/@types/src/builders/fonts-builder.d.ts +7 -0
- package/@types/src/builders/frontend-ts-builder.d.ts +11 -0
- package/@types/src/cli.d.ts +2 -0
- package/@types/src/components/components.d.ts +2 -0
- package/@types/src/components/tabs.d.ts +2 -0
- package/@types/src/components/toggle-modal.d.ts +6 -0
- package/@types/src/controllers/password-generate-button.stimulus.d.ts +5 -0
- package/@types/src/controllers/sealgen-table.stimulus.d.ts +13 -0
- package/@types/src/embeddable-file-extensions.d.ts +1 -0
- package/@types/src/esbuild-plugins/load-assets.d.ts +5 -0
- package/@types/src/esbuild-plugins/rewrite-asset-imports.d.ts +5 -0
- package/@types/src/example.test.d.ts +1 -0
- package/@types/src/forms/controls/array.d.ts +33 -0
- package/@types/src/forms/controls/autocomplete.d.ts +22 -0
- package/@types/src/forms/controls/big-radio-group.d.ts +14 -0
- package/@types/src/forms/controls/checkbox-group.d.ts +21 -0
- package/@types/src/forms/controls/checkbox.d.ts +17 -0
- package/@types/src/forms/controls/checkboxed-list-input.d.ts +21 -0
- package/@types/src/forms/controls/checkboxed-list-input.test.d.ts +1 -0
- package/@types/src/forms/controls/collapsible-checkbox-group.d.ts +11 -0
- package/@types/src/forms/controls/collapsible-field-group.d.ts +21 -0
- package/@types/src/forms/controls/controls.d.ts +32 -0
- package/@types/src/forms/controls/derived-frame.d.ts +19 -0
- package/@types/src/forms/controls/derived.d.ts +13 -0
- package/@types/src/forms/controls/dropdown.d.ts +30 -0
- package/@types/src/forms/controls/editable-collection-subset.d.ts +20 -0
- package/@types/src/forms/controls/field-group.d.ts +23 -0
- package/@types/src/forms/controls/file.d.ts +12 -0
- package/@types/src/forms/controls/file.test.d.ts +1 -0
- package/@types/src/forms/controls/form-control.d.ts +23 -0
- package/@types/src/forms/controls/form-field-control.d.ts +13 -0
- package/@types/src/forms/controls/form-header.d.ts +8 -0
- package/@types/src/forms/controls/form-paragraph.d.ts +7 -0
- package/@types/src/forms/controls/frame.d.ts +17 -0
- package/@types/src/forms/controls/hidden-input.d.ts +9 -0
- package/@types/src/forms/controls/html.d.ts +11 -0
- package/@types/src/forms/controls/hybrid.d.ts +10 -0
- package/@types/src/forms/controls/image.d.ts +19 -0
- package/@types/src/forms/controls/image.test.d.ts +1 -0
- package/@types/src/forms/controls/multiple-files.d.ts +42 -0
- package/@types/src/forms/controls/multiple-images.d.ts +19 -0
- package/@types/src/forms/controls/number.d.ts +13 -0
- package/@types/src/forms/controls/password-with-generator.d.ts +6 -0
- package/@types/src/forms/controls/radio.d.ts +16 -0
- package/@types/src/forms/controls/simple-input.d.ts +35 -0
- package/@types/src/forms/controls/single-reference.d.ts +14 -0
- package/@types/src/forms/controls/single-reference.test.d.ts +1 -0
- package/@types/src/forms/controls/table.d.ts +41 -0
- package/@types/src/forms/controls/textarea.d.ts +25 -0
- package/@types/src/forms/controls/tickable.d.ts +25 -0
- package/@types/src/forms/fields/boolean.d.ts +22 -0
- package/@types/src/forms/fields/boolean.test.d.ts +1 -0
- package/@types/src/forms/fields/checkboxed-list.d.ts +23 -0
- package/@types/src/forms/fields/collection-field.d.ts +22 -0
- package/@types/src/forms/fields/color.d.ts +4 -0
- package/@types/src/forms/fields/coordinates.d.ts +14 -0
- package/@types/src/forms/fields/date.d.ts +13 -0
- package/@types/src/forms/fields/datetime.d.ts +14 -0
- package/@types/src/forms/fields/deep-reverse-single-reference-list.d.ts +20 -0
- package/@types/src/forms/fields/deep-reverse-single-reference-table.d.ts +16 -0
- package/@types/src/forms/fields/email.d.ts +10 -0
- package/@types/src/forms/fields/email.test.d.ts +1 -0
- package/@types/src/forms/fields/enum-multiple-sealious.d.ts +16 -0
- package/@types/src/forms/fields/existing-sealious-value.d.ts +6 -0
- package/@types/src/forms/fields/field.d.ts +85 -0
- package/@types/src/forms/fields/field.test.d.ts +1 -0
- package/@types/src/forms/fields/fields.d.ts +34 -0
- package/@types/src/forms/fields/file.d.ts +25 -0
- package/@types/src/forms/fields/file.test.d.ts +1 -0
- package/@types/src/forms/fields/float.d.ts +4 -0
- package/@types/src/forms/fields/get-field-for-sealious.d.ts +33 -0
- package/@types/src/forms/fields/html.d.ts +6 -0
- package/@types/src/forms/fields/hybrid.d.ts +11 -0
- package/@types/src/forms/fields/image.d.ts +5 -0
- package/@types/src/forms/fields/int.d.ts +6 -0
- package/@types/src/forms/fields/item-draft.d.ts +20 -0
- package/@types/src/forms/fields/json.d.ts +13 -0
- package/@types/src/forms/fields/markdown.d.ts +6 -0
- package/@types/src/forms/fields/multiple-files.d.ts +16 -0
- package/@types/src/forms/fields/number.d.ts +25 -0
- package/@types/src/forms/fields/number.test.d.ts +1 -0
- package/@types/src/forms/fields/password.d.ts +10 -0
- package/@types/src/forms/fields/phone-number-with-country-code.d.ts +13 -0
- package/@types/src/forms/fields/phone-number.d.ts +17 -0
- package/@types/src/forms/fields/pick-from-list-sealious.d.ts +11 -0
- package/@types/src/forms/fields/pick-from-list.d.ts +15 -0
- package/@types/src/forms/fields/pick-from-list.test.d.ts +1 -0
- package/@types/src/forms/fields/proxy-field.d.ts +15 -0
- package/@types/src/forms/fields/regexp.d.ts +21 -0
- package/@types/src/forms/fields/regexp.test.d.ts +1 -0
- package/@types/src/forms/fields/simple-form-field.d.ts +31 -0
- package/@types/src/forms/fields/single-reference.d.ts +19 -0
- package/@types/src/forms/fields/structured-array.d.ts +23 -0
- package/@types/src/forms/fields/table.d.ts +16 -0
- package/@types/src/forms/fields/text.d.ts +6 -0
- package/@types/src/forms/fields/url.d.ts +6 -0
- package/@types/src/forms/form-types.d.ts +28 -0
- package/@types/src/forms/form.d.ts +34 -0
- package/@types/src/forms/form.test.d.ts +6 -0
- package/@types/src/forms/multiform.d.ts +23 -0
- package/@types/src/forms/multiform.test.d.ts +1 -0
- package/@types/src/generate-collections.d.ts +2 -0
- package/@types/src/generate-components.d.ts +1 -0
- package/@types/src/generate-routes.d.ts +5 -0
- package/@types/src/generate-routes.test.d.ts +1 -0
- package/@types/src/generate-stimulus.d.ts +1 -0
- package/@types/src/get-fonts.d.ts +2 -0
- package/@types/src/index.d.ts +48 -0
- package/@types/src/make-env.d.ts +1 -0
- package/@types/src/make-hidden-inputs.d.ts +5 -0
- package/@types/src/mount.d.ts +6 -0
- package/@types/src/notifier.d.ts +2 -0
- package/@types/src/page/access-control.d.ts +6 -0
- package/@types/src/page/default-list-filters.d.ts +18 -0
- package/@types/src/page/list.d.ts +49 -0
- package/@types/src/page/mountable-with-fields.d.ts +49 -0
- package/@types/src/page/mountable-with-fields.test.d.ts +1 -0
- package/@types/src/page/mountable.d.ts +10 -0
- package/@types/src/page/page.d.ts +18 -0
- package/@types/src/page/props-parser.d.ts +15 -0
- package/@types/src/page/sealious-list.d.ts +20 -0
- package/@types/src/page/sealious-list.test.d.ts +1 -0
- package/@types/src/page/stateful-page.d.ts +63 -0
- package/@types/src/page/stateful-page.test.d.ts +1 -0
- package/@types/src/register-external.d.ts +2 -0
- package/@types/src/register-external.test.d.ts +1 -0
- package/@types/src/run.d.ts +1 -0
- package/@types/src/sanitize.d.ts +1 -0
- package/@types/src/target-locreq.d.ts +4 -0
- package/@types/src/templates/collection.d.ts +1 -0
- package/@types/src/templates/form.d.ts +14 -0
- package/@types/src/templates/form.test.d.ts +1 -0
- package/@types/src/templates/jdd-component.d.ts +1 -0
- package/@types/src/templates/jdd-editor.d.ts +1 -0
- package/@types/src/templates/list.d.ts +1 -0
- package/@types/src/templates/long-running-process.d.ts +1 -0
- package/@types/src/templates/multiform.d.ts +1 -0
- package/@types/src/templates/page.d.ts +1 -0
- package/@types/src/templates/post.d.ts +1 -0
- package/@types/src/templates/redirect.d.ts +1 -0
- package/@types/src/templates/route-test.d.ts +1 -0
- package/@types/src/templates/shared/collection-create-form.d.ts +1 -0
- package/@types/src/templates/shared/collection-edit-form.d.ts +1 -0
- package/@types/src/templates/shared/collection-list.d.ts +16 -0
- package/@types/src/templates/shared/item-delete.d.ts +1 -0
- package/@types/src/templates/shared/shared-crud-form-fields.d.ts +1 -0
- package/@types/src/templates/stateful-page.d.ts +1 -0
- package/@types/src/templates/stimulus-controller.d.ts +1 -0
- package/@types/src/templates/templates.d.ts +1 -0
- package/@types/src/test_utils/exec_async.d.ts +1 -0
- package/@types/src/test_utils/locator_is_visible.d.ts +2 -0
- package/@types/src/test_utils/test-on-real-app.d.ts +26 -0
- package/@types/src/utils/assert-throws.d.ts +1 -0
- package/@types/src/utils/base64.d.ts +2 -0
- package/@types/src/utils/browser-creator.d.ts +1 -0
- package/@types/src/utils/escape-url-params.d.ts +2 -0
- package/@types/src/utils/exec.d.ts +5 -0
- package/@types/src/utils/extract-fields-from-collection.d.ts +14 -0
- package/@types/src/utils/format-external-url.d.ts +1 -0
- package/@types/src/utils/import-path.d.ts +2 -0
- package/@types/src/utils/input-wrapper.d.ts +5 -0
- package/@types/src/utils/list-collections.d.ts +1 -0
- package/@types/src/utils/make-slug.d.ts +1 -0
- package/@types/src/utils/module-dirname.d.ts +1 -0
- package/@types/src/utils/natural-numbers.d.ts +1 -0
- package/@types/src/utils/prettier.d.ts +3 -0
- package/@types/src/utils/question.d.ts +1 -0
- package/@types/src/utils/render-attributes.d.ts +1 -0
- package/@types/src/utils/sleep.d.ts +1 -0
- package/@types/src/utils/translate.d.ts +4 -0
- package/@types/src/utils/url-with-new-params.d.ts +2 -0
- package/@types/src/utils/utils.d.ts +17 -0
- package/@types/src/utils/walk.d.ts +1 -0
- package/@types/src/utils/with-fallback.d.ts +2 -0
- package/@types/src/utils/wrap-attributes.d.ts +3 -0
- package/@types/src/utils/write-file.d.ts +1 -0
- package/lib/add-route.js +1 -3
- package/lib/builders/colors-builder.js +4 -5
- package/lib/forms/controls/file.js +1 -1
- package/lib/forms/controls/multiple-files.js +6 -5
- package/lib/forms/controls/single-reference.js +4 -1
- package/lib/forms/controls/tickable.js +1 -1
- package/lib/forms/fields/file.js +5 -5
- package/lib/forms/fields/image.js +1 -3
- package/lib/forms/fields/phone-number-with-country-code.js +0 -1
- package/lib/forms/fields/simple-form-field.js +1 -1
- package/lib/forms/fields/structured-array.js +1 -2
- package/lib/get-fonts.js +5 -1
- package/lib/page/mountable-with-fields.js +1 -2
- package/lib/page/mountable-with-fields.test.js +1 -1
- package/lib/page/sealious-list.js +3 -1
- package/package.json +2 -2
- package/src/build.ts +1 -2
- package/src/cli.ts +4 -5
- package/src/forms/controls/controls.ts +0 -1
- package/src/forms/controls/dropdown.ts +15 -13
- package/src/forms/controls/file.ts +1 -1
- package/src/forms/controls/html.ts +4 -3
- package/src/forms/controls/multiple-files.ts +9 -12
- package/src/forms/controls/number.ts +8 -8
- package/src/forms/controls/single-reference.ts +25 -12
- package/src/forms/controls/table.ts +2 -2
- package/src/forms/controls/textarea.ts +4 -3
- package/src/forms/controls/tickable.ts +2 -2
- package/src/forms/fields/deep-reverse-single-reference-list.ts +2 -5
- package/src/forms/fields/deep-reverse-single-reference-table.ts +16 -14
- package/src/forms/fields/field.ts +4 -4
- package/src/forms/fields/file.ts +27 -21
- package/src/forms/fields/image.ts +1 -5
- package/src/forms/fields/phone-number-with-country-code.ts +1 -2
- package/src/forms/fields/pick-from-list.ts +2 -2
- package/src/forms/fields/simple-form-field.ts +3 -3
- package/src/forms/fields/structured-array.ts +2 -3
- package/src/forms/fields/table.ts +4 -7
- package/src/forms/multiform.ts +9 -6
- package/src/generate-routes.ts +3 -3
- package/src/get-fonts.ts +7 -3
- package/src/notifier.ts +1 -2
- package/src/page/list.ts +4 -4
- package/src/page/mountable-with-fields.test.ts +1 -1
- package/src/page/mountable-with-fields.ts +4 -4
- package/src/page/sealious-list.ts +17 -8
- package/src/page/stateful-page.ts +1 -1
- package/src/templates/jdd-editor.ts +1 -1
- package/src/test_utils/test-on-real-app.ts +5 -5
- package/tsconfig.json +2 -0
- package/src/forms/controls/big-radio-group.ts +0 -48
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Predicate, predicates } from "@sealcode/ts-predicates";
|
|
2
|
+
import { Context } from "koa";
|
|
3
|
+
import { Collection, CollectionItem } from "sealious";
|
|
4
|
+
import { FormControl, FormControlContext } from "../controls/form-control.js";
|
|
5
|
+
import { FormDataValue, FormData } from "../form-types.js";
|
|
6
|
+
import { ExtractedFieldInfo } from "../../utils/extract-fields-from-collection.js";
|
|
7
|
+
export type FormFieldValidationResponse = {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
export type FormDisplayInfo<C extends Collection> = {
|
|
12
|
+
field: keyof C["fields"];
|
|
13
|
+
label: string;
|
|
14
|
+
format?: (value: unknown, item: CollectionItem<C>) => JSX.Element;
|
|
15
|
+
};
|
|
16
|
+
export type FormFieldValidationFn<ValueType> = (ctx: Context, value: ValueType, field: FormField<boolean, ValueType>) => Promise<FormFieldValidationResponse>;
|
|
17
|
+
export type FieldParsedValue<T> = T extends FormField<infer R> ? R : never;
|
|
18
|
+
export type GetPredicate<F extends FormField> = F extends FormField<true> ? F["predicate"] : F["predicate"] | typeof predicates.undefined;
|
|
19
|
+
export type FieldsToShape<T extends Record<string, FormField>> = {
|
|
20
|
+
[property in keyof T]: GetPredicate<T[property]>;
|
|
21
|
+
};
|
|
22
|
+
export declare function fieldsToShape<Fields extends Record<string, FormField>>(obj: Fields): FieldsToShape<Fields>;
|
|
23
|
+
export type FieldParseResult<T> = {
|
|
24
|
+
parsable: true;
|
|
25
|
+
error: null;
|
|
26
|
+
parsed_value: T;
|
|
27
|
+
} | {
|
|
28
|
+
parsable: false;
|
|
29
|
+
error: string;
|
|
30
|
+
parsed_value: null;
|
|
31
|
+
};
|
|
32
|
+
export declare abstract class FormField<Required extends boolean = boolean, ParsedValue = unknown, DefaultFormControl extends FormControl = FormControl, SealiousValue = any> {
|
|
33
|
+
readonly required: Required;
|
|
34
|
+
name: string;
|
|
35
|
+
label: string;
|
|
36
|
+
constructor(required: Required);
|
|
37
|
+
predicate: Predicate;
|
|
38
|
+
mapToFilter: (parsed: ParsedValue) => any;
|
|
39
|
+
disabled: boolean;
|
|
40
|
+
init(): Promise<void>;
|
|
41
|
+
setName(name: string): this;
|
|
42
|
+
setDisabled(status: boolean): this;
|
|
43
|
+
setLabel(label: string): this;
|
|
44
|
+
_validate(ctx: Context, value: ParsedValue): Promise<FormFieldValidationResponse>;
|
|
45
|
+
abstract getEmptyValue(): ParsedValue;
|
|
46
|
+
isValueValid(_ctx: Context, _value: ParsedValue): Promise<FormFieldValidationResponse>;
|
|
47
|
+
abstract parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<ParsedValue>>;
|
|
48
|
+
getParsedValue(ctx: Context, all_form_values: Record<string, FormDataValue>, validate: true): Promise<{
|
|
49
|
+
valid: boolean;
|
|
50
|
+
message: string;
|
|
51
|
+
parsed: ParsedValue | null;
|
|
52
|
+
raw: FormDataValue;
|
|
53
|
+
}>;
|
|
54
|
+
getParsedValue(ctx: Context, all_form_values: Record<string, FormDataValue>, validate?: false): Promise<{
|
|
55
|
+
message: string;
|
|
56
|
+
parsed: ParsedValue | null;
|
|
57
|
+
raw: FormDataValue;
|
|
58
|
+
}>;
|
|
59
|
+
setMapToFilter(fn: (parsed: ParsedValue) => unknown): this;
|
|
60
|
+
getDatabaseValue(ctx: Context, data: Record<string, FormDataValue>): Promise<unknown>;
|
|
61
|
+
abstract getControl(): DefaultFormControl;
|
|
62
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<SealiousValue>;
|
|
63
|
+
sealiousValueToForm(ctx: Context, sealiousValue: SealiousValue | null, item: CollectionItem<any>): Promise<FormDataValue>;
|
|
64
|
+
postSealiousCreate(ctx: Context, created_item: CollectionItem<any>, form_data: FormData): Promise<void>;
|
|
65
|
+
postSealiousEdit(ctx: Context, edited_item: CollectionItem<any>, form_data: FormData): Promise<void>;
|
|
66
|
+
generateFieldDeclaration(field_info: ExtractedFieldInfo, vars: {
|
|
67
|
+
form_field_types: string;
|
|
68
|
+
sealious_field: string;
|
|
69
|
+
}): string;
|
|
70
|
+
generateCreateValueGetter(field_info: ExtractedFieldInfo, vars: {
|
|
71
|
+
form_field_types: string;
|
|
72
|
+
sealious_field: string;
|
|
73
|
+
form_fields: string;
|
|
74
|
+
}): string;
|
|
75
|
+
generateInitialValue(field_info: ExtractedFieldInfo, vars: {
|
|
76
|
+
form_field_types: string;
|
|
77
|
+
form_fields: string;
|
|
78
|
+
}): string;
|
|
79
|
+
generateImportsForFieldList(field_info: ExtractedFieldInfo): {
|
|
80
|
+
what: string;
|
|
81
|
+
from: string;
|
|
82
|
+
as?: string;
|
|
83
|
+
type?: boolean;
|
|
84
|
+
}[];
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export * from "./boolean.js";
|
|
2
|
+
export * from "./checkboxed-list.js";
|
|
3
|
+
export * from "./collection-field.js";
|
|
4
|
+
export * from "./color.js";
|
|
5
|
+
export * from "./coordinates.js";
|
|
6
|
+
export * from "./date.js";
|
|
7
|
+
export * from "./datetime.js";
|
|
8
|
+
export * from "./deep-reverse-single-reference-list.js";
|
|
9
|
+
export * from "./deep-reverse-single-reference-table.js";
|
|
10
|
+
export * from "./email.js";
|
|
11
|
+
export * from "./enum-multiple-sealious.js";
|
|
12
|
+
export * from "./existing-sealious-value.js";
|
|
13
|
+
export * from "./file.js";
|
|
14
|
+
export * from "./float.js";
|
|
15
|
+
export * from "./html.js";
|
|
16
|
+
export * from "./image.js";
|
|
17
|
+
export * from "./int.js";
|
|
18
|
+
export * from "./item-draft.js";
|
|
19
|
+
export * from "./json.js";
|
|
20
|
+
export * from "./markdown.js";
|
|
21
|
+
export * from "./multiple-files.js";
|
|
22
|
+
export * from "./number.js";
|
|
23
|
+
export * from "./password.js";
|
|
24
|
+
export * from "./phone-number-with-country-code.js";
|
|
25
|
+
export * from "./phone-number.js";
|
|
26
|
+
export * from "./pick-from-list-sealious.js";
|
|
27
|
+
export * from "./pick-from-list.js";
|
|
28
|
+
export * from "./regexp.js";
|
|
29
|
+
export * from "./simple-form-field.js";
|
|
30
|
+
export * from "./single-reference.js";
|
|
31
|
+
export * from "./structured-array.js";
|
|
32
|
+
export * from "./table.js";
|
|
33
|
+
export * from "./text.js";
|
|
34
|
+
export * from "./url.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FilePointer } from "@sealcode/file-manager";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
5
|
+
import { File as FileControl } from "../controls/file.js";
|
|
6
|
+
import { FormControl, FormControlContext } from "../controls/form-control.js";
|
|
7
|
+
export type FileContainer = {
|
|
8
|
+
old: FilePointer | null;
|
|
9
|
+
new: FilePointer | null;
|
|
10
|
+
};
|
|
11
|
+
export declare class File<Required extends boolean> extends FormField<Required, FileContainer, FormControl> {
|
|
12
|
+
readonly required: Required;
|
|
13
|
+
constructor(required: Required);
|
|
14
|
+
parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<FileContainer>>;
|
|
15
|
+
getDatabaseValue(ctx: Context, data: Record<string, FormDataValue>): Promise<FilePointer | undefined>;
|
|
16
|
+
getEmptyValue(): {
|
|
17
|
+
old: null;
|
|
18
|
+
new: null;
|
|
19
|
+
};
|
|
20
|
+
getControl(): FileControl;
|
|
21
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<FilePointer | undefined>;
|
|
22
|
+
sealiousValueToForm(ctx: Context, sealiousValue: FilePointer | string | null): Promise<{
|
|
23
|
+
old: FilePointer | undefined;
|
|
24
|
+
} | Record<string, never>>;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Collection, Field as SealiousField, FieldTypes as SealiousFieldTypes, RequiredField as SealiousRequiredField } from "sealious";
|
|
2
|
+
import { Boolean as BooleanField } from "./boolean.js";
|
|
3
|
+
import { SimpleFormField, TextBasedSimpleField } from "./simple-form-field.js";
|
|
4
|
+
import { File } from "./file.js";
|
|
5
|
+
import { CollectionField } from "./collection-field.js";
|
|
6
|
+
import { StructuredArray as StructuredArrayField } from "./structured-array.js";
|
|
7
|
+
import { Color } from "./color.js";
|
|
8
|
+
import { DateField } from "./date.js";
|
|
9
|
+
import { DateTime } from "./datetime.js";
|
|
10
|
+
import { EmailField } from "./email.js";
|
|
11
|
+
import { Float } from "./float.js";
|
|
12
|
+
import { HTML } from "./html.js";
|
|
13
|
+
import { Int } from "./int.js";
|
|
14
|
+
import { JSONField } from "./json.js";
|
|
15
|
+
import { Password } from "./password.js";
|
|
16
|
+
import { Text } from "./text.js";
|
|
17
|
+
import { Markdown } from "./markdown.js";
|
|
18
|
+
import { DeepReverseSingleReferenceTable } from "./deep-reverse-single-reference-table.js";
|
|
19
|
+
import { DeepReverseSingleReferenceList } from "./deep-reverse-single-reference-list.js";
|
|
20
|
+
import { Coordinates } from "./coordinates.js";
|
|
21
|
+
import { SimpleInput } from "../controls/simple-input.js";
|
|
22
|
+
import { FormField } from "./field.js";
|
|
23
|
+
import { PickFromListSealious } from "./pick-from-list-sealious.js";
|
|
24
|
+
import { SingleReference } from "./single-reference.js";
|
|
25
|
+
import { ExtractedFieldInfo } from "../../utils/extract-fields-from-collection.js";
|
|
26
|
+
import { EnumMultipleSealious } from "./enum-multiple-sealious.js";
|
|
27
|
+
import { URLField } from "./url.js";
|
|
28
|
+
import { Image } from "./image.js";
|
|
29
|
+
import { PhoneNumberWithCountryCode } from "./phone-number-with-country-code.js";
|
|
30
|
+
import { ItemDraft } from "./item-draft.js";
|
|
31
|
+
export type SealiousToFormField<T> = T extends SealiousFieldTypes.Boolean ? BooleanField<false> : T extends SealiousFieldTypes.Color ? Color<false> : T extends SealiousFieldTypes.ControlAccess<infer R> ? SealiousToFormField<R> : T extends SealiousFieldTypes.Date ? DateField<false> : T extends SealiousFieldTypes.DateTime ? DateTime<false> : T extends SealiousFieldTypes.DeepReverseSingleReference ? DeepReverseSingleReferenceList | DeepReverseSingleReferenceTable : T extends SealiousFieldTypes.DisallowUpdate<any, any, any, infer R> ? SealiousToFormField<R> : T extends SealiousFieldTypes.Email ? EmailField<false> : T extends SealiousFieldTypes.Enum<any> ? PickFromListSealious<false> : T extends SealiousFieldTypes.EnumMultiple<infer R> ? R extends string[] ? EnumMultipleSealious<R> : TextBasedSimpleField<false> : T extends SealiousFieldTypes.File ? File<false> : T extends SealiousFieldTypes.Float ? Float<false> : T extends SealiousFieldTypes.HTML ? HTML<false> : T extends SealiousFieldTypes.Image ? Image<false> : T extends SealiousFieldTypes.Int ? Int<false> : T extends SealiousFieldTypes.ItemDraft<infer C extends Collection> ? ItemDraft<C> : T extends SealiousFieldTypes.JsonObject ? JSONField<false> : T extends SealiousFieldTypes.JDD ? TextBasedSimpleField<false, SimpleInput> : T extends SealiousFieldTypes.Password ? Password<false> : T extends SealiousFieldTypes.PhoneNumber ? PhoneNumberWithCountryCode<false> : T extends SealiousFieldTypes.ReverseSingleReference ? TextBasedSimpleField<false, SimpleInput> : T extends SealiousFieldTypes.SecretToken ? TextBasedSimpleField<false, SimpleInput> : T extends SealiousFieldTypes.SettableBy<infer R> ? SealiousToFormField<R> : T extends SealiousFieldTypes.SingleReference ? SingleReference<Collection, boolean, T> : T extends SealiousFieldTypes.Text ? Text<false> : T extends SealiousFieldTypes.Username ? CollectionField<SealiousFieldTypes.Username, false> : T extends SealiousFieldTypes.ValueExistingInCollection ? SimpleFormField<false> : T extends SealiousFieldTypes.ValueNotExistingInCollection ? SimpleFormField<false> : T extends SealiousRequiredField<any, any, any> ? SimpleFormField<false> : T extends SealiousFieldTypes.Url ? URLField<false> : T extends SealiousFieldTypes.Money ? SimpleFormField<false> : T extends SealiousFieldTypes.Markdown ? Markdown<false> : T extends SealiousFieldTypes.Coordinates ? Coordinates<false> : T extends SealiousFieldTypes.StructuredArray<infer R> ? StructuredArrayField<R> : TextBasedSimpleField<any>;
|
|
32
|
+
export declare function sealiousToFormField<SF extends SealiousField<any>>(sealious_field: SF): SealiousToFormField<SF>;
|
|
33
|
+
export declare function sealiousFieldInfoToFormField(field_info: ExtractedFieldInfo): Promise<FormField>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Textarea } from "../controls/textarea.js";
|
|
2
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
3
|
+
export declare class HTML<Required extends boolean> extends TextBasedSimpleField<Required, Textarea> {
|
|
4
|
+
constructor(required: Required);
|
|
5
|
+
getControl(): Textarea;
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { Hybrid as HybridControl } from "../controls/hybrid.js";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
5
|
+
export declare class Hybrid<Fields extends Record<string, FormField>> extends FormField<true, Record<string, unknown>> {
|
|
6
|
+
subfields: Fields;
|
|
7
|
+
constructor(subfields: Fields);
|
|
8
|
+
getEmptyValue(): Record<string, unknown>;
|
|
9
|
+
parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<Record<string, unknown>>>;
|
|
10
|
+
getControl(): HybridControl;
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormControlContext } from "../controls/form-control.js";
|
|
2
|
+
import { NumberBasedSimpleField } from "./simple-form-field.js";
|
|
3
|
+
export declare class Int<Required extends boolean> extends NumberBasedSimpleField<Required> {
|
|
4
|
+
constructor(required: Required);
|
|
5
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<number | undefined>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Collection, FieldTypes as SealiousFieldTypes } from "sealious";
|
|
2
|
+
import { Hybrid } from "./hybrid.js";
|
|
3
|
+
import { FormField } from "./field.js";
|
|
4
|
+
import { ExtractedFieldInfo } from "../../utils/extract-fields-from-collection.js";
|
|
5
|
+
export declare class ItemDraft<C extends Collection> extends Hybrid<{
|
|
6
|
+
[name in keyof C["fields"]]: FormField;
|
|
7
|
+
}> {
|
|
8
|
+
sealious_field: SealiousFieldTypes.ItemDraft<C>;
|
|
9
|
+
constructor(sealious_field: SealiousFieldTypes.ItemDraft<C>);
|
|
10
|
+
generateFieldDeclaration(field_info: ExtractedFieldInfo, vars: {
|
|
11
|
+
form_field_types: string;
|
|
12
|
+
sealious_field: string;
|
|
13
|
+
}): string;
|
|
14
|
+
generateImportsForFieldList(field_info: ExtractedFieldInfo): {
|
|
15
|
+
what: string;
|
|
16
|
+
from: string;
|
|
17
|
+
as?: string;
|
|
18
|
+
type?: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FormControlContext } from "../controls/form-control.js";
|
|
3
|
+
import { Textarea } from "../controls/textarea.js";
|
|
4
|
+
import { FormDataValue } from "../form-types.js";
|
|
5
|
+
import { FieldParseResult } from "./field.js";
|
|
6
|
+
import { SimpleFormField } from "./simple-form-field.js";
|
|
7
|
+
export declare class JSONField<Required extends boolean> extends SimpleFormField<Required, Textarea, Record<string, unknown>> {
|
|
8
|
+
constructor(required: Required);
|
|
9
|
+
getControl(): Textarea;
|
|
10
|
+
getEmptyValue(): Record<string, unknown>;
|
|
11
|
+
parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<Record<string, unknown>>>;
|
|
12
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<Record<string, unknown> | null>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Textarea } from "../controls/textarea.js";
|
|
2
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
3
|
+
export declare class Markdown<Required extends boolean> extends TextBasedSimpleField<Required, Textarea> {
|
|
4
|
+
constructor(required: Required);
|
|
5
|
+
getControl(): Textarea;
|
|
6
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FieldTypes as SealiousFieldTypes } from "sealious";
|
|
3
|
+
import { FormField } from "./field.js";
|
|
4
|
+
import { MultipleFiles as MultipleFilesControl } from "../controls/multiple-files.js";
|
|
5
|
+
export declare class MultipleFiles extends FormField<false, undefined, MultipleFilesControl> {
|
|
6
|
+
collection_field: SealiousFieldTypes.ReverseSingleReference;
|
|
7
|
+
getItemId: (ctx: Context) => Promise<string> | string;
|
|
8
|
+
constructor(collection_field: SealiousFieldTypes.ReverseSingleReference, getItemId: (ctx: Context) => Promise<string> | string);
|
|
9
|
+
getEmptyValue(): undefined;
|
|
10
|
+
parse(): Promise<{
|
|
11
|
+
readonly parsed_value: undefined;
|
|
12
|
+
readonly parsable: true;
|
|
13
|
+
readonly error: null;
|
|
14
|
+
}>;
|
|
15
|
+
getControl(): MultipleFilesControl;
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { SimpleInput } from "../controls/simple-input.js";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
5
|
+
export declare class NumberField<DefaultValue extends number | null = number, Required extends boolean = boolean> extends FormField<Required, number | DefaultValue, SimpleInput> {
|
|
6
|
+
default_value: DefaultValue;
|
|
7
|
+
options: Partial<{
|
|
8
|
+
max: number;
|
|
9
|
+
min: number;
|
|
10
|
+
decimalDigits: number;
|
|
11
|
+
}>;
|
|
12
|
+
constructor(required: Required, default_value: DefaultValue, options?: Partial<{
|
|
13
|
+
max: number;
|
|
14
|
+
min: number;
|
|
15
|
+
decimalDigits: number;
|
|
16
|
+
}>);
|
|
17
|
+
predicate: import("@sealcode/ts-predicates").Predicate<number>;
|
|
18
|
+
isValueValid(_: Context, value: unknown): Promise<{
|
|
19
|
+
valid: boolean;
|
|
20
|
+
message: string;
|
|
21
|
+
}>;
|
|
22
|
+
parse(_: Context, value: FormDataValue): Promise<FieldParseResult<number>>;
|
|
23
|
+
getEmptyValue(): DefaultValue;
|
|
24
|
+
getControl(): SimpleInput;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExtractedFieldInfo } from "../../utils/extract-fields-from-collection.js";
|
|
2
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
3
|
+
export declare class Password<Required extends boolean> extends TextBasedSimpleField<Required> {
|
|
4
|
+
constructor(required: Required);
|
|
5
|
+
sealiousValueToForm(): Promise<undefined>;
|
|
6
|
+
generateInitialValue(field_info: ExtractedFieldInfo, vars: {
|
|
7
|
+
form_field_types: string;
|
|
8
|
+
form_fields: string;
|
|
9
|
+
}): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FieldTypes as SealiousFieldTypes } from "sealious";
|
|
3
|
+
import { FormControl } from "../controls/controls.js";
|
|
4
|
+
import { FormDataValue } from "../form-types.js";
|
|
5
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
6
|
+
import { FormControlContext } from "../../index.js";
|
|
7
|
+
export declare class PhoneNumberWithCountryCode<Required extends boolean> extends FormField<Required, SealiousFieldTypes.PhoneNumberValue> {
|
|
8
|
+
getEmptyValue(): SealiousFieldTypes.PhoneNumberValue;
|
|
9
|
+
parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<SealiousFieldTypes.PhoneNumberValue>>;
|
|
10
|
+
getControl(): FormControl;
|
|
11
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<string>;
|
|
12
|
+
sealiousValueToForm(ctx: Context, sealiousValue: SealiousFieldTypes.PhoneNumberValue | null): Promise<FormDataValue>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FormControl } from "../controls/controls.js";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FormField } from "./field.js";
|
|
5
|
+
export declare class PhoneNumberWithoutCountryCode<Required extends boolean> extends FormField<Required, string> {
|
|
6
|
+
getEmptyValue(): string;
|
|
7
|
+
parse(ctx: Context, raw_value: FormDataValue): Promise<{
|
|
8
|
+
parsable: true;
|
|
9
|
+
parsed_value: string;
|
|
10
|
+
error: null;
|
|
11
|
+
} | {
|
|
12
|
+
parsable: false;
|
|
13
|
+
parsed_value: null;
|
|
14
|
+
error: string;
|
|
15
|
+
}>;
|
|
16
|
+
getControl(): FormControl;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FieldTypes as SealiousFieldTypes } from "sealious";
|
|
2
|
+
import { PickFromListField } from "./pick-from-list.js";
|
|
3
|
+
import { ExtractedFieldInfo } from "../../utils/extract-fields-from-collection.js";
|
|
4
|
+
export declare class PickFromListSealious<Required extends boolean> extends PickFromListField<Required> {
|
|
5
|
+
sealious_field: SealiousFieldTypes.Enum<string>;
|
|
6
|
+
constructor(sealious_field: SealiousFieldTypes.Enum<string>);
|
|
7
|
+
generateFieldDeclaration(field_info: ExtractedFieldInfo, vars: {
|
|
8
|
+
form_field_types: string;
|
|
9
|
+
sealious_field: string;
|
|
10
|
+
}): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { Dropdown, DropdownOption } from "../controls/dropdown.js";
|
|
3
|
+
import { FormFieldValidationResponse } from "./field.js";
|
|
4
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
5
|
+
export declare class PickFromListField<Required extends boolean> extends TextBasedSimpleField<Required, Dropdown> {
|
|
6
|
+
required: Required;
|
|
7
|
+
generateOptions: (ctx: Context) => Promise<DropdownOption[]>;
|
|
8
|
+
customValidation: (ctx: Context, value: unknown, instance: PickFromListField<Required>) => Promise<FormFieldValidationResponse>;
|
|
9
|
+
constructor(required: Required, generateOptions: (ctx: Context) => Promise<DropdownOption[]>, customValidation?: (ctx: Context, value: unknown, instance: PickFromListField<Required>) => Promise<FormFieldValidationResponse>);
|
|
10
|
+
predicate: import("@sealcode/ts-predicates").Predicate<string>;
|
|
11
|
+
isValueValid(ctx: Context, value: string): Promise<FormFieldValidationResponse>;
|
|
12
|
+
valueInList(ctx: Context, value: unknown): Promise<FormFieldValidationResponse>;
|
|
13
|
+
getEmptyValue(): string;
|
|
14
|
+
getControl(): Dropdown;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FormControl } from "../controls/form-control.js";
|
|
2
|
+
import { FormField } from "./field.js";
|
|
3
|
+
export declare class ProxyFormField<T> extends FormField<boolean, T, any> {
|
|
4
|
+
name: string;
|
|
5
|
+
empty_value: T;
|
|
6
|
+
parsed_value: T;
|
|
7
|
+
constructor(required: boolean, name: string, empty_value: T, parsed_value: T);
|
|
8
|
+
getEmptyValue(): T;
|
|
9
|
+
parse(): Promise<{
|
|
10
|
+
readonly parsable: true;
|
|
11
|
+
readonly error: null;
|
|
12
|
+
readonly parsed_value: T;
|
|
13
|
+
}>;
|
|
14
|
+
getControl(): FormControl;
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { SimpleInput } from "../controls/simple-input.js";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
5
|
+
import { FormControlContext } from "../controls/form-control.js";
|
|
6
|
+
export declare class RegExpField<Required extends boolean> extends FormField<Required, string, SimpleInput, string> {
|
|
7
|
+
regexp: RegExp;
|
|
8
|
+
error_message: string;
|
|
9
|
+
default_value: string;
|
|
10
|
+
constructor(required: Required, regexp: RegExp, error_message: string, default_value?: string);
|
|
11
|
+
predicate: import("@sealcode/ts-predicates").Predicate<string>;
|
|
12
|
+
isValueValid(_: Context, value: unknown): Promise<{
|
|
13
|
+
valid: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
}>;
|
|
16
|
+
parse(_: Context, value: FormDataValue): Promise<FieldParseResult<string>>;
|
|
17
|
+
getEmptyValue(): string;
|
|
18
|
+
getControl(): SimpleInput;
|
|
19
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<string>;
|
|
20
|
+
sealiousValueToForm(ctx: Context, sealious_value: string | null): Promise<FormDataValue>;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FormData, FormDataValue } from "../form-types.js";
|
|
2
|
+
import { Context } from "koa";
|
|
3
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
4
|
+
import { SimpleInput } from "../controls/simple-input.js";
|
|
5
|
+
import { FormControl } from "../controls/controls.js";
|
|
6
|
+
import { CollectionItem } from "sealious";
|
|
7
|
+
import { FormControlContext } from "../controls/form-control.js";
|
|
8
|
+
export declare abstract class SimpleFormField<Required extends boolean, DefaultControl extends FormControl = SimpleInput, Parsed = string> extends FormField<Required, Parsed, DefaultControl> {
|
|
9
|
+
type: string;
|
|
10
|
+
predicate: import("@sealcode/ts-predicates").Predicate<string>;
|
|
11
|
+
placeholder: string;
|
|
12
|
+
constructor(required: Required, type?: string);
|
|
13
|
+
sealiousValueToForm(_ctx: Context, value: unknown): Promise<FormDataValue>;
|
|
14
|
+
setPlaceholder(placeholder: string): this;
|
|
15
|
+
}
|
|
16
|
+
export declare class TextBasedSimpleField<Required extends boolean, DefaultControl extends FormControl = SimpleInput> extends SimpleFormField<Required, DefaultControl, string | null> {
|
|
17
|
+
parse(_: Context, raw_value: FormDataValue): Promise<FieldParseResult<string>>;
|
|
18
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<string | null>;
|
|
19
|
+
postSealiousCreate(_ctx: Context, _created_item: CollectionItem<any>, _formData: FormData): Promise<void>;
|
|
20
|
+
postSealiousEdit(ctx: Context, _edited_item: CollectionItem<any>, _formData: FormData): Promise<void>;
|
|
21
|
+
getControl(): DefaultControl;
|
|
22
|
+
getEmptyValue(): string;
|
|
23
|
+
}
|
|
24
|
+
export declare class NumberBasedSimpleField<Required extends boolean, DefaultControl extends FormControl = SimpleInput> extends SimpleFormField<Required, DefaultControl, number> {
|
|
25
|
+
parse(_: Context, raw_value: FormDataValue): Promise<FieldParseResult<number>>;
|
|
26
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<number | undefined>;
|
|
27
|
+
postSealiousCreate(): Promise<void>;
|
|
28
|
+
postSealiousEdit(): Promise<void>;
|
|
29
|
+
getControl(): DefaultControl;
|
|
30
|
+
getEmptyValue(): number;
|
|
31
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Collection, FieldTypes as SealiousFieldTypes } from "sealious";
|
|
2
|
+
import { CollectionField } from "./collection-field.js";
|
|
3
|
+
import { SingleReferenceDropdown } from "../controls/single-reference.js";
|
|
4
|
+
import { FormControlContext } from "../controls/form-control.js";
|
|
5
|
+
import { Context } from "koa";
|
|
6
|
+
import { ExtractedFieldInfo } from "../../utils/extract-fields-from-collection.js";
|
|
7
|
+
export declare class SingleReference<TargetCollection extends Collection, Required extends boolean, F extends SealiousFieldTypes.SingleReference> extends CollectionField<F, Required> {
|
|
8
|
+
getControl(): SingleReferenceDropdown<TargetCollection, F, Required>;
|
|
9
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<string | undefined>;
|
|
10
|
+
sealiousValueToForm(_ctx: Context, value: string | null): Promise<string | undefined>;
|
|
11
|
+
generateImportsForFieldList(field_info: ExtractedFieldInfo): {
|
|
12
|
+
what: string;
|
|
13
|
+
from: string;
|
|
14
|
+
}[];
|
|
15
|
+
generateFieldDeclaration(field_info: ExtractedFieldInfo, vars: {
|
|
16
|
+
form_field_types: string;
|
|
17
|
+
sealious_field: string;
|
|
18
|
+
}): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { Field as SealiousField, FieldTypes as SealiousFieldTypes } from "sealious";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { Table as TableControl } from "../controls/table.js";
|
|
5
|
+
import { SealiousToFormField } from "./get-field-for-sealious.js";
|
|
6
|
+
import { FormControlContext } from "../controls/form-control.js";
|
|
7
|
+
import { ExtractedFieldInfo } from "../../utils/extract-fields-from-collection.js";
|
|
8
|
+
import { Table } from "./table.js";
|
|
9
|
+
export declare class StructuredArray<SealiousFields extends Record<string, SealiousField<unknown>>> extends Table<{
|
|
10
|
+
[name in keyof SealiousFields]: SealiousToFormField<SealiousFields[name]>;
|
|
11
|
+
}> {
|
|
12
|
+
sealious_field: SealiousFieldTypes.StructuredArray<SealiousFields>;
|
|
13
|
+
constructor(sealious_field: SealiousFieldTypes.StructuredArray<SealiousFields>);
|
|
14
|
+
getControl(): TableControl<{
|
|
15
|
+
[name in keyof SealiousFields]: SealiousToFormField<SealiousFields[name]>;
|
|
16
|
+
}>;
|
|
17
|
+
generateFieldDeclaration(_field_info: ExtractedFieldInfo, vars: {
|
|
18
|
+
form_field_types: string;
|
|
19
|
+
sealious_field: string;
|
|
20
|
+
}): string;
|
|
21
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<import("./table.js").TableFieldParsed<{ [name in keyof SealiousFields]: SealiousToFormField<SealiousFields[name]>; }>>;
|
|
22
|
+
sealiousValueToForm(ctx: Context, sealiousValue: Record<string, FormDataValue | null>[] | null): Promise<FormDataValue>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FormDataValue } from "../form-types.js";
|
|
3
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
4
|
+
import { Table as TableControl } from "../controls/table.js";
|
|
5
|
+
export type ExtractFormFieldParsed<Field extends FormField> = Field extends FormField<true, infer T> ? NonNullable<T> : Field extends FormField<true, infer T> ? T : never;
|
|
6
|
+
export type TableFieldParsed<F extends Record<string, FormField>> = {
|
|
7
|
+
[field_name in keyof F]: ExtractFormFieldParsed<F[field_name]>;
|
|
8
|
+
}[];
|
|
9
|
+
export declare class Table<F extends Record<string, FormField>> extends FormField<false, TableFieldParsed<F>> {
|
|
10
|
+
columns: F;
|
|
11
|
+
constructor(columns: F);
|
|
12
|
+
getEmptyValue(): never[];
|
|
13
|
+
setName(name: string): this;
|
|
14
|
+
parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<TableFieldParsed<F>>>;
|
|
15
|
+
getControl(): TableControl<F>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormControlContext } from "../controls/form-control.js";
|
|
2
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
3
|
+
export declare class Text<Required extends boolean> extends TextBasedSimpleField<Required> {
|
|
4
|
+
constructor(required: Required);
|
|
5
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<string>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormControlContext } from "../controls/form-control.js";
|
|
2
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
3
|
+
export declare class URLField<Required extends boolean> extends TextBasedSimpleField<Required> {
|
|
4
|
+
constructor(required: Required);
|
|
5
|
+
getSealiousCreateValue(fctx: FormControlContext): Promise<string | null>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FilePointer } from "@sealcode/file-manager";
|
|
2
|
+
import type { FlatTemplatable } from "tempstream";
|
|
3
|
+
import type { FormField } from "./fields/field.js";
|
|
4
|
+
import { FieldMessages } from "./controls/form-control.js";
|
|
5
|
+
export type FormDataPrimitive = string | string[] | number | undefined | FilePointer;
|
|
6
|
+
export type FormDataValue = FormDataPrimitive | Record<string, FormDataPrimitive>;
|
|
7
|
+
export type FieldValueType<F extends FormField> = F extends FormField<infer R> ? R : never;
|
|
8
|
+
export type FormFieldsToValues<F extends Record<string, FormField<boolean, keyof F>>> = {
|
|
9
|
+
[Property in keyof F]: FieldValueType<F[Property]>;
|
|
10
|
+
};
|
|
11
|
+
export type FormMessage = {
|
|
12
|
+
type: "info" | "success" | "error";
|
|
13
|
+
text: string;
|
|
14
|
+
};
|
|
15
|
+
export type FormData<Fieldnames extends string = string> = {
|
|
16
|
+
raw_values: Record<Fieldnames, FormDataValue>;
|
|
17
|
+
messages: FormMessage[];
|
|
18
|
+
field_messages: FieldMessages<Fieldnames>;
|
|
19
|
+
};
|
|
20
|
+
export type FormReaction = {
|
|
21
|
+
action: "stay";
|
|
22
|
+
content: FlatTemplatable;
|
|
23
|
+
messages?: FormMessage[];
|
|
24
|
+
} | {
|
|
25
|
+
action: "redirect";
|
|
26
|
+
url: string;
|
|
27
|
+
messages?: FormMessage[];
|
|
28
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import Router from "@koa/router";
|
|
3
|
+
import { FormData, FormDataValue, FormMessage, FormReaction } from "./form-types.js";
|
|
4
|
+
import { Fields, MountableWithFields, PageErrorMessage } from "../page/mountable-with-fields.js";
|
|
5
|
+
import { Readable } from "stream";
|
|
6
|
+
import { FormField } from "../index.js";
|
|
7
|
+
import { FieldMessages } from "./controls/form-control.js";
|
|
8
|
+
export declare abstract class Form<F extends Fields, SubmitResult> extends MountableWithFields<F> {
|
|
9
|
+
defaultSuccessMessage: string;
|
|
10
|
+
submitButtonText: string;
|
|
11
|
+
action: string;
|
|
12
|
+
useTurbo: boolean;
|
|
13
|
+
form_id: string;
|
|
14
|
+
canAccess(_: Context): Promise<{
|
|
15
|
+
canAccess: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
}>;
|
|
18
|
+
renderError(_: Context, error: PageErrorMessage): Promise<JSX.Element | Readable>;
|
|
19
|
+
makeSubmitButton(): JSX.Element;
|
|
20
|
+
render(ctx: Context, data: FormData, show_field_errors: boolean): Promise<JSX.Element | Readable>;
|
|
21
|
+
makeFormClasses(_ctx: Context): Promise<string[]>;
|
|
22
|
+
makeOpenFormTag(ctx: Context): JSX.Element;
|
|
23
|
+
makeCloseFormTag(): JSX.Element;
|
|
24
|
+
onValuesInvalid(ctx: Context, form_messages: FormMessage[], field_errors: FieldMessages<keyof Fields>): Promise<FormReaction>;
|
|
25
|
+
onError(ctx: Context, data: FormData, error: unknown): Promise<FormReaction>;
|
|
26
|
+
abstract onSubmit(ctx: Context, data: FormData): SubmitResult | Promise<SubmitResult>;
|
|
27
|
+
onSuccess(ctx: Context, _data: FormData, _submitResult: SubmitResult): Promise<FormReaction>;
|
|
28
|
+
getRawValuesOnSuccess(ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
29
|
+
handlePost(ctx: Context): Promise<FormReaction>;
|
|
30
|
+
init(path: string, router: Router): void;
|
|
31
|
+
mount(router: Router, path: string): void;
|
|
32
|
+
extractRawValues(ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
33
|
+
static initFieldNames(fields: Record<string, FormField>): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Controls, Fields, Form, Mountable } from "../index.js";
|
|
2
|
+
declare const fields: {
|
|
3
|
+
text: Fields.TextBasedSimpleField<true, Controls.SimpleInput<import("./controls/simple-input.js").SimpleInputOptions>>;
|
|
4
|
+
};
|
|
5
|
+
export declare function form_factory(canAccessFun?: Mountable["canAccess"]): Form<typeof fields, void>;
|
|
6
|
+
export {};
|