@sealcode/sealgen 0.4.0 → 0.5.0
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/checkboxed-list-input.d.ts +2 -2
- package/@types/forms/controls/dropdown.d.ts +2 -2
- package/@types/forms/controls/editable-collection-subset.d.ts +2 -2
- package/@types/forms/controls/form-control.d.ts +2 -2
- package/@types/forms/controls/form-field-control.d.ts +2 -2
- package/@types/forms/controls/form-header.d.ts +4 -4
- package/@types/forms/controls/simple-input.d.ts +4 -2
- package/@types/forms/fields/checkboxed-list.d.ts +7 -7
- package/@types/forms/fields/collection-field.d.ts +3 -3
- package/@types/forms/fields/field.d.ts +6 -6
- package/@types/forms/fields/number.d.ts +3 -3
- package/@types/forms/fields/pick-from-list.d.ts +7 -7
- package/@types/forms/fields/simple-form-field.d.ts +2 -2
- package/@types/forms/form.d.ts +10 -10
- package/@types/index.d.ts +5 -3
- package/@types/make-hidden-inputs.d.ts +5 -4
- package/@types/page/access-control.d.ts +2 -2
- package/@types/page/list.d.ts +14 -14
- package/@types/page/mountable.d.ts +9 -9
- package/@types/page/page.d.ts +6 -6
- package/@types/page/props-parser.d.ts +4 -4
- package/@types/utils/translate.d.ts +3 -0
- package/@types/utils/url-with-new-params.d.ts +2 -2
- package/lib/build.js +2 -1
- package/lib/build.js.map +1 -1
- package/lib/forms/controls/checkboxed-list-input.js.map +1 -1
- package/lib/forms/controls/dropdown.js.map +1 -1
- package/lib/forms/controls/editable-collection-subset.js.map +1 -1
- package/lib/forms/controls/form-header.js.map +1 -1
- package/lib/forms/controls/simple-input.js +4 -2
- package/lib/forms/controls/simple-input.js.map +1 -1
- package/lib/forms/fields/checkboxed-list.js.map +1 -1
- package/lib/forms/fields/collection-field.js.map +1 -1
- package/lib/forms/fields/field.js +5 -1
- package/lib/forms/fields/field.js.map +1 -1
- package/lib/forms/fields/number.js.map +1 -1
- package/lib/forms/fields/pick-from-list.js.map +1 -1
- package/lib/forms/fields/simple-form-field.js.map +1 -1
- package/lib/forms/form.js +6 -3
- package/lib/forms/form.js.map +1 -1
- package/lib/generate-routes.js +18 -2
- package/lib/generate-routes.js.map +1 -1
- package/lib/index.js +16 -2
- package/lib/index.js.map +1 -1
- package/lib/make-hidden-inputs.js.map +1 -1
- package/lib/page/access-control.js.map +1 -1
- package/lib/page/list.js +2 -1
- package/lib/page/list.js.map +1 -1
- package/lib/page/mountable.js.map +1 -1
- package/lib/page/page.js.map +1 -1
- package/lib/page/props-parser.js.map +1 -1
- package/lib/templates/form.js +9 -16
- package/lib/templates/form.js.map +1 -1
- package/lib/templates/list.js +4 -4
- package/lib/templates/list.js.map +1 -1
- package/lib/templates/page.js +3 -3
- package/lib/utils/translate.js +10 -0
- package/lib/utils/translate.js.map +1 -0
- package/lib/utils/url-with-new-params.js.map +1 -1
- package/package.json +3 -2
- package/src/build.ts +2 -1
- package/src/forms/controls/checkboxed-list-input.ts +2 -2
- package/src/forms/controls/dropdown.ts +2 -2
- package/src/forms/controls/editable-collection-subset.ts +2 -2
- package/src/forms/controls/form-control.ts +2 -2
- package/src/forms/controls/form-field-control.ts +2 -2
- package/src/forms/controls/form-header.ts +3 -3
- package/src/forms/controls/simple-input.ts +7 -6
- package/src/forms/fields/checkboxed-list.ts +5 -5
- package/src/forms/fields/collection-field.ts +3 -3
- package/src/forms/fields/field.ts +17 -7
- package/src/forms/fields/number.ts +3 -3
- package/src/forms/fields/pick-from-list.ts +5 -5
- package/src/forms/fields/simple-form-field.ts +2 -2
- package/src/forms/form.ts +15 -12
- package/src/generate-routes.ts +18 -2
- package/src/index.ts +5 -3
- package/src/make-hidden-inputs.ts +6 -5
- package/src/page/access-control.ts +2 -2
- package/src/page/list.ts +17 -24
- package/src/page/mountable.ts +11 -11
- package/src/page/page.ts +5 -5
- package/src/page/props-parser.ts +4 -7
- package/src/templates/form.ts +9 -16
- package/src/templates/list.ts +4 -4
- package/src/templates/page.ts +3 -3
- package/src/utils/translate.ts +13 -0
- package/src/utils/url-with-new-params.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { Context } from "koa";
|
|
3
3
|
import { ChekboxedListField } from "../fields/field";
|
|
4
4
|
import { FormDataValue } from "../form";
|
|
5
5
|
import { FormFieldControl } from "./controls";
|
|
@@ -11,5 +11,5 @@ export declare class CheckboxedListInput extends FormFieldControl {
|
|
|
11
11
|
constructor(field: ChekboxedListField, options?: {
|
|
12
12
|
label: string;
|
|
13
13
|
});
|
|
14
|
-
render(ctx:
|
|
14
|
+
render(ctx: Context, data: Record<string, FormDataValue>): Promise<import("stream").Readable>;
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { Context } from "koa";
|
|
3
3
|
import { FormField, PickFromListField } from "../fields/field";
|
|
4
4
|
import { FormDataValue } from "../form";
|
|
5
5
|
import { FormFieldControl } from "./controls";
|
|
@@ -15,5 +15,5 @@ export declare class Dropdown extends FormFieldControl {
|
|
|
15
15
|
autosubmit?: boolean;
|
|
16
16
|
autocomplete?: boolean;
|
|
17
17
|
});
|
|
18
|
-
render<Fields extends Record<string, FormField>>(ctx:
|
|
18
|
+
render<Fields extends Record<string, FormField>>(ctx: Context, data: Record<string, FormDataValue>): Promise<import("stream").Readable>;
|
|
19
19
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FlatTemplatable } from "tempstream";
|
|
3
3
|
import { PickFromListField } from "../fields/field";
|
|
4
4
|
import { FormDataValue } from "../form";
|
|
@@ -16,6 +16,6 @@ export declare class EditableCollectionSubset extends FormFieldControl {
|
|
|
16
16
|
listLabel?: string | undefined;
|
|
17
17
|
selectLabel?: string | undefined;
|
|
18
18
|
constructor(field: PickFromListField, actionname: string, listLabel?: string | undefined, selectLabel?: string | undefined);
|
|
19
|
-
render(ctx:
|
|
19
|
+
render(ctx: Context, data: Record<string, FormDataValue>): Promise<FlatTemplatable>;
|
|
20
20
|
role: "input";
|
|
21
21
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FlatTemplatable } from "tempstream";
|
|
3
3
|
import { FormDataValue, FormMessage } from "../form";
|
|
4
4
|
export declare abstract class FormControl {
|
|
5
|
-
abstract render(ctx:
|
|
5
|
+
abstract render(ctx: Context, data: Record<string, FormDataValue>, messages: FormMessage[]): FlatTemplatable | Promise<FlatTemplatable>;
|
|
6
6
|
abstract role: "input" | "decoration" | "messages" | "submit";
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FlatTemplatable } from "tempstream";
|
|
3
3
|
import { FormField } from "../fields/field";
|
|
4
4
|
import { FieldValueType, FormDataValue } from "../form";
|
|
@@ -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:
|
|
13
|
+
abstract render(ctx: Context, data: Record<string, FormDataValue>): FlatTemplatable | Promise<FlatTemplatable>;
|
|
14
14
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FormControl } from "./controls";
|
|
3
3
|
export declare class FormHeader extends FormControl {
|
|
4
4
|
text: string;
|
|
5
|
-
isVisible: (ctx:
|
|
5
|
+
isVisible: (ctx: Context) => Promise<boolean>;
|
|
6
6
|
role: "decoration";
|
|
7
|
-
constructor(text: string, isVisible?: (ctx:
|
|
8
|
-
render(ctx:
|
|
7
|
+
constructor(text: string, isVisible?: (ctx: Context) => Promise<boolean>);
|
|
8
|
+
render(ctx: Context): Promise<string>;
|
|
9
9
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FormField } from "../fields/field";
|
|
3
3
|
import { FormDataValue } from "../form";
|
|
4
4
|
import { FormFieldControl } from "./controls";
|
|
@@ -8,6 +8,7 @@ export declare class SimpleInput extends FormFieldControl {
|
|
|
8
8
|
id?: string;
|
|
9
9
|
label?: string;
|
|
10
10
|
autocomplete?: boolean;
|
|
11
|
+
hide_errors?: boolean;
|
|
11
12
|
type?: "color" | "date" | "email" | "file" | "month" | "number" | "password" | "search" | "tel" | "text" | "time" | "url" | "week";
|
|
12
13
|
value?: string;
|
|
13
14
|
placeholder?: string;
|
|
@@ -18,11 +19,12 @@ export declare class SimpleInput extends FormFieldControl {
|
|
|
18
19
|
id?: string;
|
|
19
20
|
label?: string;
|
|
20
21
|
autocomplete?: boolean;
|
|
22
|
+
hide_errors?: boolean;
|
|
21
23
|
type?: "color" | "date" | "email" | "file" | "month" | "number" | "password" | "search" | "tel" | "text" | "time" | "url" | "week";
|
|
22
24
|
value?: string;
|
|
23
25
|
placeholder?: string;
|
|
24
26
|
readonly?: boolean;
|
|
25
27
|
step?: number;
|
|
26
28
|
});
|
|
27
|
-
render<Fields extends Record<string, FormField>>(ctx:
|
|
29
|
+
render<Fields extends Record<string, FormField>>(ctx: Context, data: Record<string, FormDataValue>): Promise<string>;
|
|
28
30
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FormDataValue } from "../form";
|
|
3
3
|
import { FieldParseResult, FormField, FormFieldValidationResponse } from "./field";
|
|
4
4
|
export declare class ChekboxedListField extends FormField<Record<string, "on">> {
|
|
5
5
|
required: boolean;
|
|
6
|
-
generateOptions: (ctx:
|
|
6
|
+
generateOptions: (ctx: Context) => Promise<Record<string, string> | {
|
|
7
7
|
[i: string]: string;
|
|
8
8
|
}>;
|
|
9
|
-
isVisible: (ctx:
|
|
10
|
-
constructor(required: boolean, generateOptions: (ctx:
|
|
9
|
+
isVisible: (ctx: Context) => Promise<boolean>;
|
|
10
|
+
constructor(required: boolean, generateOptions: (ctx: Context) => Promise<Record<string, string> | {
|
|
11
11
|
[i: string]: string;
|
|
12
|
-
}>, isVisible?: (ctx:
|
|
13
|
-
isValueValid(_:
|
|
14
|
-
parse(_:
|
|
12
|
+
}>, isVisible?: (ctx: Context) => Promise<boolean>);
|
|
13
|
+
isValueValid(_: Context, value: unknown): Promise<FormFieldValidationResponse>;
|
|
14
|
+
parse(_: Context, raw_value: FormDataValue): Promise<FieldParseResult<Record<string, "on">>>;
|
|
15
15
|
getEmptyValue(): Record<string, "on">;
|
|
16
16
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { Depromisify, Field, FieldOutput } from "sealious";
|
|
3
3
|
import { FormDataValue } from "../form";
|
|
4
4
|
import { FieldParseResult, FormField, FormFieldValidationResponse } from "./field";
|
|
5
5
|
export declare class CollectionField<F extends Field> extends FormField<FieldOutput<F>> {
|
|
6
6
|
sealiousField: F;
|
|
7
7
|
constructor(required: boolean, sealiousField: F);
|
|
8
|
-
parse(ctx:
|
|
9
|
-
isValueValid(ctx:
|
|
8
|
+
parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<FieldOutput<F>>>;
|
|
9
|
+
isValueValid(ctx: Context, value: FieldOutput<F>): Promise<FormFieldValidationResponse>;
|
|
10
10
|
getEmptyValue(): Depromisify<ReturnType<F["decode"]>>;
|
|
11
11
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FormDataValue } from "../form";
|
|
3
3
|
export declare type FormFieldValidationResponse = {
|
|
4
4
|
valid: boolean;
|
|
5
5
|
message: string;
|
|
6
6
|
};
|
|
7
|
-
export declare type FormFieldValidationFn<ValueType> = (ctx:
|
|
7
|
+
export declare type FormFieldValidationFn<ValueType> = (ctx: Context, value: ValueType, field: FormField<ValueType>) => Promise<FormFieldValidationResponse>;
|
|
8
8
|
export declare type FieldParsedValue<T> = T extends FormField<infer R> ? R : never;
|
|
9
9
|
export declare type FieldParseResult<T> = {
|
|
10
10
|
parsable: false;
|
|
@@ -20,11 +20,11 @@ export declare abstract class FormField<ParsedValue extends unknown = unknown> {
|
|
|
20
20
|
name: string;
|
|
21
21
|
constructor(required?: boolean);
|
|
22
22
|
init(fieldname: string): void;
|
|
23
|
-
_validate(ctx:
|
|
23
|
+
_validate(ctx: Context, value: ParsedValue): Promise<FormFieldValidationResponse>;
|
|
24
24
|
abstract getEmptyValue(): ParsedValue;
|
|
25
|
-
isValueValid(ctx:
|
|
26
|
-
abstract parse(ctx:
|
|
27
|
-
getValue(ctx:
|
|
25
|
+
isValueValid(ctx: Context, value: ParsedValue): Promise<FormFieldValidationResponse>;
|
|
26
|
+
abstract parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<ParsedValue>>;
|
|
27
|
+
getValue(ctx: Context, all_form_values: Record<string, FormDataValue>): Promise<{
|
|
28
28
|
valid: boolean;
|
|
29
29
|
message: string;
|
|
30
30
|
parsed: ParsedValue;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FormDataValue } from "../form";
|
|
3
3
|
import { FieldParseResult, FormField } from "./field";
|
|
4
4
|
export declare class NumberField<DefaultValue extends number | null = null> extends FormField<number | DefaultValue> {
|
|
5
5
|
default_value: DefaultValue;
|
|
6
6
|
constructor(required: boolean | undefined, default_value: DefaultValue);
|
|
7
|
-
isValueValid(_:
|
|
7
|
+
isValueValid(_: Context, value: unknown): Promise<{
|
|
8
8
|
valid: boolean;
|
|
9
9
|
message: string;
|
|
10
10
|
}>;
|
|
11
|
-
parse(_:
|
|
11
|
+
parse(_: Context, value: FormDataValue): Promise<FieldParseResult<number>>;
|
|
12
12
|
getEmptyValue(): DefaultValue;
|
|
13
13
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FormFieldValidationResponse } from "./field";
|
|
3
3
|
import { SimpleFormField } from "./simple-form-field";
|
|
4
4
|
export declare class PickFromListField extends SimpleFormField {
|
|
5
5
|
required: boolean;
|
|
6
|
-
generateOptions: (ctx:
|
|
6
|
+
generateOptions: (ctx: Context) => Promise<Record<string, string> | {
|
|
7
7
|
[i: string]: string;
|
|
8
8
|
}>;
|
|
9
|
-
customValidation: (ctx:
|
|
10
|
-
constructor(required: boolean, generateOptions: (ctx:
|
|
9
|
+
customValidation: (ctx: Context, value: unknown, instance: PickFromListField) => Promise<FormFieldValidationResponse>;
|
|
10
|
+
constructor(required: boolean, generateOptions: (ctx: Context) => Promise<Record<string, string> | {
|
|
11
11
|
[i: string]: string;
|
|
12
|
-
}>, customValidation?: (ctx:
|
|
13
|
-
isValueValid(ctx:
|
|
14
|
-
valueInList(ctx:
|
|
12
|
+
}>, customValidation?: (ctx: Context, value: unknown, instance: PickFromListField) => Promise<FormFieldValidationResponse>);
|
|
13
|
+
isValueValid(ctx: Context, value: string): Promise<FormFieldValidationResponse>;
|
|
14
|
+
valueInList(ctx: Context, value: unknown): Promise<FormFieldValidationResponse>;
|
|
15
15
|
getEmptyValue(): string;
|
|
16
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FieldParseResult, FormField } from "./field";
|
|
2
2
|
import { FormDataValue } from "../form";
|
|
3
|
-
import {
|
|
3
|
+
import { Context } from "koa";
|
|
4
4
|
export declare class SimpleFormField extends FormField<string | null> {
|
|
5
|
-
parse(_:
|
|
5
|
+
parse(_: Context, raw_value: FormDataValue): Promise<FieldParseResult<string>>;
|
|
6
6
|
getEmptyValue(): string;
|
|
7
7
|
}
|
package/@types/forms/form.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="koa__router" />
|
|
2
|
-
import {
|
|
2
|
+
import { Context } from "koa";
|
|
3
3
|
import Router from "@koa/router";
|
|
4
|
-
import { FlatTemplatable
|
|
4
|
+
import { FlatTemplatable } from "tempstream";
|
|
5
5
|
import { FormField } from "./fields/field";
|
|
6
6
|
import { Fields, Mountable, PageErrorMessage } from "../page/mountable";
|
|
7
7
|
export declare type FormDataPrimitive = string | string[] | undefined;
|
|
@@ -21,17 +21,17 @@ export declare type FormData<Fieldnames extends string = string> = {
|
|
|
21
21
|
export declare abstract class Form<F extends Fields> extends Mountable<F> {
|
|
22
22
|
defaultSuccessMessage: string;
|
|
23
23
|
submitButtonText: string;
|
|
24
|
-
canAccess(_:
|
|
24
|
+
canAccess(_: Context): Promise<{
|
|
25
25
|
canAccess: boolean;
|
|
26
26
|
message: string;
|
|
27
27
|
}>;
|
|
28
|
-
renderError(_:
|
|
29
|
-
render(ctx:
|
|
28
|
+
renderError(_: Context, error: PageErrorMessage): Promise<FlatTemplatable>;
|
|
29
|
+
render(ctx: Context, data: FormData): Promise<FlatTemplatable>;
|
|
30
30
|
makeFormTag(): FlatTemplatable;
|
|
31
|
-
onValuesInvalid(ctx:
|
|
32
|
-
onError(ctx:
|
|
33
|
-
abstract onSubmit(ctx:
|
|
34
|
-
onSuccess(ctx:
|
|
31
|
+
onValuesInvalid(ctx: Context, form_messages: FormMessage[]): Promise<void>;
|
|
32
|
+
onError(ctx: Context, data: FormData, error: unknown): Promise<void>;
|
|
33
|
+
abstract onSubmit(ctx: Context, data: FormData): void | Promise<void>;
|
|
34
|
+
onSuccess(ctx: Context, data: FormData): Promise<void>;
|
|
35
35
|
mount(router: Router, path: string): void;
|
|
36
|
-
extractRawValues(ctx:
|
|
36
|
+
extractRawValues(ctx: Context): Record<string, FormDataValue>;
|
|
37
37
|
}
|
package/@types/index.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import Sealious from "sealious";
|
|
1
|
+
import Sealious, { App } from "sealious";
|
|
2
2
|
import { FormDataValue } from "./forms/form";
|
|
3
3
|
declare module "koa" {
|
|
4
4
|
interface BaseContext {
|
|
5
5
|
$context: Sealious.Context;
|
|
6
|
+
$app: App;
|
|
6
7
|
$body: Record<string, FormDataValue>;
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
|
-
export * from "./forms/controls/controls";
|
|
10
|
-
export * from "./forms/fields/field";
|
|
10
|
+
export * as Controls from "./forms/controls/controls";
|
|
11
|
+
export * as Fields from "./forms/fields/field";
|
|
11
12
|
export * from "./page/mountable";
|
|
12
13
|
export * from "./page/page";
|
|
13
14
|
export * from "./forms/form";
|
|
14
15
|
export * from "./page/props-parser";
|
|
15
16
|
export * from "./utils/utils";
|
|
16
17
|
export * from "./page/list";
|
|
18
|
+
export * from "./utils/translate";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { FormDataValue
|
|
4
|
-
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FlatTemplatable } from "tempstream";
|
|
3
|
+
import { FormDataValue } from ".";
|
|
4
|
+
import { FormField } from "./forms/fields/field";
|
|
5
|
+
export declare function makeHiddenInputs(ctx: Context, fields: Record<string, FormField>, values: Record<string, FormDataValue>, fields_to_skip: string[]): FlatTemplatable;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { ActionName, Collection } from "sealious";
|
|
3
|
-
export declare function peopleWhoCan(action: ActionName, collection: Collection): (ctx:
|
|
3
|
+
export declare function peopleWhoCan(action: ActionName, collection: Collection): (ctx: Context) => Promise<{
|
|
4
4
|
canAccess: boolean;
|
|
5
5
|
message: string;
|
|
6
6
|
}>;
|
package/@types/page/list.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { Collection, CollectionItem, ItemList } from "sealious";
|
|
3
3
|
import { Templatable, FlatTemplatable } from "tempstream";
|
|
4
4
|
import { Page } from "./page";
|
|
@@ -13,27 +13,27 @@ export declare const BaseListPageFields: {
|
|
|
13
13
|
readonly itemsPerPage: NumberField<12>;
|
|
14
14
|
};
|
|
15
15
|
export declare abstract class ListPage<ItemType, F extends typeof BaseListPageFields> extends Page<F> {
|
|
16
|
-
abstract getItems(ctx:
|
|
17
|
-
abstract getTotalPages(ctx:
|
|
18
|
-
abstract renderItem(ctx:
|
|
16
|
+
abstract getItems(ctx: Context, page: number, itemsPerPage: number, values: Record<string, FormDataValue>): Promise<ItemType[]>;
|
|
17
|
+
abstract getTotalPages(ctx: Context, itemsPerPage: number, values: Record<string, FormDataValue>): Promise<number>;
|
|
18
|
+
abstract renderItem(ctx: Context, item: ItemType): Promise<FlatTemplatable>;
|
|
19
19
|
filterFields: Record<string, FormField>;
|
|
20
20
|
filterControls: FormFieldControl[];
|
|
21
21
|
init(): void;
|
|
22
|
-
renderListContainer(_:
|
|
23
|
-
render(ctx:
|
|
24
|
-
renderPagination(ctx:
|
|
22
|
+
renderListContainer(_: Context, content: Templatable): FlatTemplatable;
|
|
23
|
+
render(ctx: Context): Promise<FlatTemplatable>;
|
|
24
|
+
renderPagination(ctx: Context, values: Record<string, FormDataValue>): Promise<FlatTemplatable>;
|
|
25
25
|
private renderPageButton;
|
|
26
|
-
getFilterValues(ctx:
|
|
27
|
-
renderFilters(ctx:
|
|
26
|
+
getFilterValues(ctx: Context): Promise<Record<string, unknown>>;
|
|
27
|
+
renderFilters(ctx: Context): FlatTemplatable;
|
|
28
28
|
}
|
|
29
29
|
export declare abstract class SealiousItemListPage<C extends Collection, F extends typeof BaseListPageFields> extends ListPage<CollectionItem<C>, F> {
|
|
30
30
|
collection: C;
|
|
31
31
|
constructor(collection: C);
|
|
32
|
-
getTotalPages(ctx:
|
|
33
|
-
protected addFilter(ctx:
|
|
34
|
-
getItems(ctx:
|
|
35
|
-
renderItem(_:
|
|
36
|
-
canAccess: (ctx:
|
|
32
|
+
getTotalPages(ctx: Context, itemsPerPage: number): Promise<number>;
|
|
33
|
+
protected addFilter(ctx: Context, list: ItemList<C>): Promise<void>;
|
|
34
|
+
getItems(ctx: Context, page: number, itemsPerPage: number): Promise<CollectionItem<C>[]>;
|
|
35
|
+
renderItem(_: Context, item: CollectionItem<C>): Promise<FlatTemplatable>;
|
|
36
|
+
canAccess: (ctx: Context) => Promise<{
|
|
37
37
|
canAccess: boolean;
|
|
38
38
|
message: string;
|
|
39
39
|
}>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="koa__router" />
|
|
2
2
|
import Router from "@koa/router";
|
|
3
3
|
import { FormControl } from "../forms/controls/form-control";
|
|
4
|
-
import {
|
|
5
|
-
import { FlatTemplatable
|
|
4
|
+
import { Context } from "koa";
|
|
5
|
+
import { FlatTemplatable } from "tempstream";
|
|
6
6
|
import { FormField } from "../forms/fields/field";
|
|
7
7
|
import { FormData, FormDataValue, FormMessage } from "../forms/form";
|
|
8
8
|
export declare type PageErrorMessage = {
|
|
@@ -15,22 +15,22 @@ export declare abstract class Mountable<F extends Fields = Fields> {
|
|
|
15
15
|
constructor();
|
|
16
16
|
abstract controls: FormControl[];
|
|
17
17
|
abstract mount(router: Router, path: string): void;
|
|
18
|
-
abstract canAccess(ctx:
|
|
18
|
+
abstract canAccess(ctx: Context): Promise<{
|
|
19
19
|
canAccess: boolean;
|
|
20
20
|
message: string;
|
|
21
21
|
}>;
|
|
22
|
-
abstract renderError(ctx:
|
|
23
|
-
abstract extractRawValues(ctx:
|
|
24
|
-
validateValues(ctx:
|
|
22
|
+
abstract renderError(ctx: Context, error: PageErrorMessage): Promise<FlatTemplatable>;
|
|
23
|
+
abstract extractRawValues(ctx: Context): Record<string, FormDataValue>;
|
|
24
|
+
validateValues(ctx: Context, data: Record<string, FormDataValue>): Promise<{
|
|
25
25
|
valid: boolean;
|
|
26
26
|
error: string;
|
|
27
27
|
}>;
|
|
28
|
-
protected validate(ctx:
|
|
28
|
+
protected validate(ctx: Context, values: Record<string, FormDataValue>): Promise<{
|
|
29
29
|
valid: boolean;
|
|
30
30
|
field_errors: Partial<Record<keyof Fields, string>>;
|
|
31
31
|
form_messages: FormMessage[];
|
|
32
32
|
}>;
|
|
33
33
|
init(): void;
|
|
34
|
-
renderControls(ctx:
|
|
35
|
-
renderMessages(_:
|
|
34
|
+
renderControls(ctx: Context, data: FormData<keyof Fields>): FlatTemplatable;
|
|
35
|
+
renderMessages(_: Context, data: FormData<keyof Fields>): FlatTemplatable;
|
|
36
36
|
}
|
package/@types/page/page.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="koa__router" />
|
|
2
2
|
import Router from "@koa/router";
|
|
3
|
-
import {
|
|
4
|
-
import { FlatTemplatable
|
|
3
|
+
import { Context } from "koa";
|
|
4
|
+
import { FlatTemplatable } from "tempstream";
|
|
5
5
|
import { FormDataValue } from "../forms/form";
|
|
6
6
|
import { Fields, Mountable, PageErrorMessage } from "./mountable";
|
|
7
7
|
import { PagePropsParser } from "./props-parser";
|
|
@@ -9,11 +9,11 @@ export declare abstract class Page<F extends Fields = Record<string, never>> ext
|
|
|
9
9
|
propsParser: PagePropsParser<Record<keyof Fields, unknown>>;
|
|
10
10
|
controls: never[];
|
|
11
11
|
mount(router: Router, path: string): void;
|
|
12
|
-
canAccess(_:
|
|
12
|
+
canAccess(_: Context): Promise<{
|
|
13
13
|
canAccess: boolean;
|
|
14
14
|
message: string;
|
|
15
15
|
}>;
|
|
16
|
-
renderError(_:
|
|
17
|
-
abstract render(ctx:
|
|
18
|
-
extractRawValues(ctx:
|
|
16
|
+
renderError(_: Context, error: PageErrorMessage): Promise<FlatTemplatable>;
|
|
17
|
+
abstract render(ctx: Context): Promise<FlatTemplatable>;
|
|
18
|
+
extractRawValues(ctx: Context): Record<string, FormDataValue>;
|
|
19
19
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FormData, FormDataValue } from "..";
|
|
3
3
|
import { BasePageProps } from "./list";
|
|
4
4
|
export declare type EncodedProps = Record<string, unknown>;
|
|
5
5
|
export declare abstract class PagePropsParser<PropsType> {
|
|
6
|
-
abstract decode(ctx:
|
|
6
|
+
abstract decode(ctx: Context): Record<string, FormDataValue>;
|
|
7
7
|
abstract encode(props: Record<string, FormData>): EncodedProps;
|
|
8
8
|
abstract getHTMLInputName(prop_name: string): string;
|
|
9
|
-
overwriteProp(ctx:
|
|
9
|
+
overwriteProp(ctx: Context, new_props: Partial<PropsType>): EncodedProps;
|
|
10
10
|
}
|
|
11
11
|
export declare class AllQueryParams<PropsType extends BasePageProps> extends PagePropsParser<PropsType> {
|
|
12
|
-
decode(ctx:
|
|
12
|
+
decode(ctx: Context): Record<string, FormDataValue>;
|
|
13
13
|
encode(props: PropsType): Record<string, unknown>;
|
|
14
14
|
getHTMLInputName(prop_name: string): string;
|
|
15
15
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function UrlWithNewParams(ctx:
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
export declare function UrlWithNewParams(ctx: Context, query_params: Record<string, unknown>): string;
|
package/lib/build.js
CHANGED
|
@@ -62,7 +62,7 @@ async function complex_build(watch) {
|
|
|
62
62
|
console.log(`Built main.scss [on ${path}]`);
|
|
63
63
|
}
|
|
64
64
|
catch (e) {
|
|
65
|
-
console.error(e);
|
|
65
|
+
console.error(e.message);
|
|
66
66
|
await sleep_1.sleep(200);
|
|
67
67
|
scss_build
|
|
68
68
|
?.rebuild?.()
|
|
@@ -110,6 +110,7 @@ async function buildProject(...args) {
|
|
|
110
110
|
catch (e) {
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
112
112
|
console.error(e.message);
|
|
113
|
+
await buildProject(...args);
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
exports.buildProject = buildProject;
|
package/lib/build.js.map
CHANGED
|
@@ -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QACX,WAAW,EAAE,CAAC,sBAAsB,CAAC;QACrC,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,yBAAyB;QAClC,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,IAAI;QACZ,KAAK;KACL,CAAC,CAAC;IAEH,IAAI;QACH,MAAM,aAAa,CAAC,KAAK,CAAC,CAAC;KAC3B;IAAC,OAAO,CAAC,EAAE;QACX,sEAAsE;QACtE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACzB,MAAM,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;KAC5B;AACF,CAAC;AAlBD,oCAkBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkboxed-list-input.js","sourceRoot":"","sources":["../../../src/forms/controls/checkboxed-list-input.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAEzD,2CAAwC;AAGxC,yCAA8C;AAE9C,MAAa,mBAAoB,SAAQ,2BAAgB;IACxD,YACQ,KAAyB,EACzB,UAA6B,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE;QAEzD,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAHR,UAAK,GAAL,KAAK,CAAoB;QACzB,YAAO,GAAP,OAAO,CAA2C;IAG1D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"checkboxed-list-input.js","sourceRoot":"","sources":["../../../src/forms/controls/checkboxed-list-input.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAEzD,2CAAwC;AAGxC,yCAA8C;AAE9C,MAAa,mBAAoB,SAAQ,2BAAgB;IACxD,YACQ,KAAyB,EACzB,UAA6B,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE;QAEzD,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAHR,UAAK,GAAL,KAAK,CAAoB;QACzB,YAAO,GAAP,OAAO,CAA2C;IAG1D,CAAC;IAED,KAA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AC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CACtD,CAAC,OAAO,EAAE,EAAE,CACX,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAC1B,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CACjB,kBAAkB,KAAK,KACtB,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,YAAY;YAC5B,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,EACJ,IAAI,IAAI,WAAW,CACpB,CACF;aACQ,CAAC;IACb,CAAC;CACD;AA7CD,4BA6CC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editable-collection-subset.js","sourceRoot":"","sources":["../../../src/forms/controls/editable-collection-subset.ts"],"names":[],"mappings":";;;AACA,2CAAyD;AAGzD,yCAA8C;AAE9C;;;;;;GAMG;AACH,MAAa,wBAAyB,SAAQ,2BAAgB;IAC7D,YACQ,KAAwB,EACxB,UAAkB,EAClB,SAAkB,EAClB,WAAoB;QAE3B,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QALR,UAAK,GAAL,KAAK,CAAmB;QACxB,eAAU,GAAV,UAAU,CAAQ;QAClB,cAAS,GAAT,SAAS,CAAS;QAClB,gBAAW,GAAX,WAAW,CAAS;QA0E5B,SAAI,GAAU,OAAO,CAAC;IAvEtB,CAAC;IAED,KAAK,CAAC,MAAM,CACX,
|
|
1
|
+
{"version":3,"file":"editable-collection-subset.js","sourceRoot":"","sources":["../../../src/forms/controls/editable-collection-subset.ts"],"names":[],"mappings":";;;AACA,2CAAyD;AAGzD,yCAA8C;AAE9C;;;;;;GAMG;AACH,MAAa,wBAAyB,SAAQ,2BAAgB;IAC7D,YACQ,KAAwB,EACxB,UAAkB,EAClB,SAAkB,EAClB,WAAoB;QAE3B,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QALR,UAAK,GAAL,KAAK,CAAmB;Q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C,KAAK,CAAC,EAAE,EAAE,CACX,CAAC,CAAC,MAAM,IAAK,EAAe,CAAC,CAAC,QAAQ,CACrC,KAAK,CACL,CACF;aACA,GAAG,CACH,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CACjB,kBAAkB,KAAK,KAAK,IAAI,WAAW,CAC5C,CACH;;iCAE2B,IAAI,CAAC,UAAU;;;OAGzC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE;;;SAGnD,CAAC;IACT,CAAC;CAED;AAhFD,4DAgFC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-header.js","sourceRoot":"","sources":["../../../src/forms/controls/form-header.ts"],"names":[],"mappings":";;;AACA,yCAAyC;AAEzC,MAAa,UAAW,SAAQ,sBAAW;IAE1C,YACQ,IAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"form-header.js","sourceRoot":"","sources":["../../../src/forms/controls/form-header.ts"],"names":[],"mappings":";;;AACA,yCAAyC;AAEzC,MAAa,UAAW,SAAQ,sBAAW;IAE1C,YACQ,IAAY,EACZ,YAAgD,KAAK,IAAI,EAAE,CAAC,IAAI;QAEvE,KAAK,EAAE,CAAC;QAHD,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAAT,SAAS,CAAuD;QAHxE,SAAI,GAAU,YAAY,CAAC;IAM3B,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,GAAY;QACxB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACzC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,CAAC;CACD;AAZD,gCAYC"}
|
|
@@ -18,7 +18,7 @@ class SimpleInput extends controls_1.FormFieldControl {
|
|
|
18
18
|
const placeholder = this.options.placeholder || type;
|
|
19
19
|
const readonly = this.options.readonly || false;
|
|
20
20
|
const required = this.field.required;
|
|
21
|
-
return /* HTML */ `<div class="input">
|
|
21
|
+
return /* HTML */ `<div class="form-input form-input__wrapper">
|
|
22
22
|
<label for="${id}">${label}</label>
|
|
23
23
|
<input
|
|
24
24
|
id="${id}"
|
|
@@ -36,7 +36,9 @@ class SimpleInput extends controls_1.FormFieldControl {
|
|
|
36
36
|
${!this.options.autocomplete ? `autocomplete="off"` : ""}
|
|
37
37
|
${this.options.step ? `step="${this.options.step}"` : ""}
|
|
38
38
|
/>
|
|
39
|
-
${~valid
|
|
39
|
+
${~valid && !this.options.hide_errors
|
|
40
|
+
? `<div class="input__error">${message}</div>`
|
|
41
|
+
: ""}
|
|
40
42
|
</div>`;
|
|
41
43
|
}
|
|
42
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-input.js","sourceRoot":"","sources":["../../../src/forms/controls/simple-input.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"simple-input.js","sourceRoot":"","sources":["../../../src/forms/controls/simple-input.ts"],"names":[],"mappings":";;;AAGA,yCAA8C;AAE9C,MAAa,WAAY,SAAQ,2BAAgB;IAChD,YACQ,KAAgB,EAChB,UAuBH,EAAE;QAEN,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QA1BR,UAAK,GAAL,KAAK,CAAW;QAChB,YAAO,GAAP,OAAO,CAuBR;IAGP,CAAC;IAED,KAAK,CAAC,MAAM,CACX,GAAY,EACZ,IAAmC;QAEnC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;QAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC;QACzC,yEAA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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkboxed-list.js","sourceRoot":"","sources":["../../../src/forms/fields/checkboxed-list.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAGzD,mCAIiB;AAEjB,MAAa,kBAAmB,SAAQ,iBAA+B;IACtE,YACQ,WAAoB,KAAK,EACzB,eAEuD,EACvD,
|
|
1
|
+
{"version":3,"file":"checkboxed-list.js","sourceRoot":"","sources":["../../../src/forms/fields/checkboxed-list.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAGzD,mCAIiB;AAEjB,MAAa,kBAAmB,SAAQ,iBAA+B;IACtE,YACQ,WAAoB,KAAK,EACzB,eAEuD,EACvD,YAAgD,GAAG,EAAE,CAC3D,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;QAEtB,KAAK,CAAC,QAAQ,CAAC,CAAC;QAPT,aAAQ,GAAR,QAAQ,CAAiB;QACzB,oBAAe,GAAf,eAAe,CAEwC;QACvD,cAAS,GAAT,SAAS,CACM;IAGvB,CAAC;IAEM,KAAK,CAAC,YAAY,CACxB,CAAU,EACV,KAAc;QAEd,IAAI,kBAAE,CAAC,KAAK,EAAE,0BAAU,CAAC,MAAM,CAAC,EAAE;YACjC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;SACtD;QACD,IAAI,kBAAE,CAAC,KAAK,EAAE,0BAAU,CAAC,IAAI,CAAC,EAAE;YAC/B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;SACtD;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,KAAK,CACV,CAAU,EACV,SAAwB;QAExB,IAAI,kBAAE,CAAC,SAAS,EAAE,0BAAU,CAAC,MAAM,CAAC,EAAE;YACrC,OAAO;gBACN,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,MAAM,CAAC,WAAW,CAC/B,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAC/B,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAC7B,CACuB;gBACzB,KAAK,EAAE,IAAI;aACX,CAAC;SACF;aAAM;YACN,OAAO;gBACN,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,KAAK;gBACf,KAAK,EAAE,oBAAoB;aAC3B,CAAC;SACF;IACF,CAAC;IAEM,aAAa;QACnB,OAAO,EAAE,CAAC;IACX,CAAC;CACD;AAnDD,gDAmDC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-field.js","sourceRoot":"","sources":["../../../src/forms/fields/collection-field.ts"],"names":[],"mappings":";;;AAIA,mCAIiB;AAEjB,MAAa,eAAiC,SAAQ,iBAErD;IACA,YAAY,QAAiB,EAAS,aAAgB;QACrD,KAAK,CAAC,QAAQ,CAAC,CAAC;QADqB,kBAAa,GAAb,aAAa,CAAG;IAEtD,CAAC;IAED,KAAK,CAAC,KAAK,CACV,
|
|
1
|
+
{"version":3,"file":"collection-field.js","sourceRoot":"","sources":["../../../src/forms/fields/collection-field.ts"],"names":[],"mappings":";;;AAIA,mCAIiB;AAEjB,MAAa,eAAiC,SAAQ,iBAErD;IACA,YAAY,QAAiB,EAAS,aAAgB;QACrD,KAAK,CAAC,QAAQ,CAAC,CAAC;QADqB,kBAAa,GAAb,aAAa,CAAG;IAEtD,CAAC;IAED,KAAK,CAAC,KAAK,CACV,GAAY,EACZ,SAAwB;QAExB,MAAM,aAAa,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CACrD,GAAG,CAAC,QAAQ,EACZ,SAAS,CACT,CAAyC,CAAC;QAC3C,MAAM,YAAY,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CACpD,GAAG,CAAC,QAAQ,EACZ,aAAa,EACb,IAAI,EACJ,EAAE,CACF,CAAyC,CAAC;QAC3C,OAAO;YACN,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,IAAI;YACX,YAAY;SACZ,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,YAAY,CACxB,GAAY,EACZ,KAAqB;QAErB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAC5D,GAAG,CAAC,QAAQ,EACZ,KAAK,EACL,SAAS,CACT,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACpE,CAAC;IAEM,aAAa;QACnB,OAAO,EAAqD,CAAC;IAC9D,CAAC;CACD;AA3CD,0CA2CC"}
|
|
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.FormField = void 0;
|
|
14
|
+
const translate_1 = require("../../utils/translate");
|
|
14
15
|
class FormField {
|
|
15
16
|
constructor(required = false) {
|
|
16
17
|
this.required = required;
|
|
@@ -21,7 +22,10 @@ class FormField {
|
|
|
21
22
|
async _validate(ctx, value) {
|
|
22
23
|
if (this.required &&
|
|
23
24
|
(value === "" || value === null || value === undefined)) {
|
|
24
|
-
return {
|
|
25
|
+
return {
|
|
26
|
+
valid: false,
|
|
27
|
+
message: translate_1.t(ctx, "field_is_required", [], "This field is required"),
|
|
28
|
+
};
|
|
25
29
|
}
|
|
26
30
|
return this.isValueValid(ctx, value);
|
|
27
31
|
}
|