@sealcode/sealgen 0.15.42 → 0.15.44
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/src/components/toggle-modal.d.ts +1 -2
- package/@types/src/forms/controls/array.d.ts +3 -3
- package/@types/src/forms/controls/autocomplete.d.ts +1 -2
- package/@types/src/forms/controls/checkboxed-list-input.d.ts +1 -2
- package/@types/src/forms/controls/collapsible-field-group.d.ts +1 -2
- package/@types/src/forms/controls/derived-frame.d.ts +1 -2
- package/@types/src/forms/controls/file.d.ts +1 -2
- package/@types/src/forms/controls/multiple-files.d.ts +1 -2
- package/@types/src/forms/controls/table.d.ts +1 -1
- package/@types/src/utils/input-wrapper.d.ts +1 -3
- package/lib/forms/controls/table.js +50 -52
- package/lib/templates/shared/handlers/file.js +7 -2
- package/package.json +2 -2
- package/src/forms/controls/table.ts +41 -42
- package/src/templates/shared/handlers/file.ts +7 -2
- package/src/utils/input-wrapper.ts +1 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { FlatTemplatable } from "tempstream";
|
|
3
2
|
export declare function toggleModal(options: {
|
|
4
3
|
name: string;
|
|
5
4
|
contentWrapped: (id: string) => FlatTemplatable | Promise<FlatTemplatable>;
|
|
6
5
|
contentUnwrapped: (id: string) => FlatTemplatable | Promise<FlatTemplatable>;
|
|
7
|
-
}):
|
|
6
|
+
}): Promise<string>;
|
|
@@ -26,10 +26,10 @@ export declare class StructuredArray<Subfields extends Record<string, Field<any>
|
|
|
26
26
|
getDefaultItemBody(): Promise<{}>;
|
|
27
27
|
makeSubfield(_field_name: string): FormField;
|
|
28
28
|
renderItemControl(ctx: Context, form_id: string, control: FormControl | UnboundControlStorage, item: FieldsetOutput<Subfields>, index: number): Promise<(string | number | import("stream").Readable | null) | (string | number | import("stream").Readable | null)[] | Promise<string | number | import("stream").Readable | null>[]>;
|
|
29
|
-
renderItem(ctx: Context, form_id: string, item: FieldsetOutput<Subfields>, index: number): Promise<
|
|
29
|
+
renderItem(ctx: Context, form_id: string, item: FieldsetOutput<Subfields>, index: number): Promise<string>;
|
|
30
30
|
getItems(ctx: Context, raw_values: Record<string, FormDataValue>): Promise<FieldsetOutput<Subfields>[]>;
|
|
31
|
-
_render(ctx: Context, form_id: string, raw_values: Record<string, FormDataValue>): Promise<
|
|
32
|
-
render(fctx: FormControlContext): Promise<
|
|
31
|
+
_render(ctx: Context, form_id: string, raw_values: Record<string, FormDataValue>): Promise<string>;
|
|
32
|
+
render(fctx: FormControlContext): Promise<string>;
|
|
33
33
|
getTargetItemID(ctx: Context): Promise<string>;
|
|
34
34
|
mount(router: Router): void;
|
|
35
35
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { Context } from "koa";
|
|
3
2
|
import { PickFromListField } from "../fields/pick-from-list.js";
|
|
4
3
|
import { FormControlContext } from "./form-control.js";
|
|
@@ -19,5 +18,5 @@ export declare class Autocomplete extends SimpleInput<string | null> {
|
|
|
19
18
|
getInputAttributes(fctx: FormControlContext): Promise<{
|
|
20
19
|
list: string;
|
|
21
20
|
}>;
|
|
22
|
-
postInput(ctx: Context): Promise<
|
|
21
|
+
postInput(ctx: Context): Promise<string>;
|
|
23
22
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { CheckboxedListField } from "../fields/checkboxed-list.js";
|
|
3
2
|
import { FormControlContext } from "./form-control.js";
|
|
4
3
|
import { FormFieldControl } from "./form-field-control.js";
|
|
@@ -10,5 +9,5 @@ export declare class CheckboxedListInput extends FormFieldControl {
|
|
|
10
9
|
constructor(field: CheckboxedListField<boolean>, options?: {
|
|
11
10
|
label: string;
|
|
12
11
|
});
|
|
13
|
-
render(fctx: FormControlContext): Promise<
|
|
12
|
+
render(fctx: FormControlContext): Promise<string>;
|
|
14
13
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { FlatTemplatable } from "tempstream";
|
|
3
2
|
import { FieldGroup } from "./field-group.js";
|
|
4
3
|
import { FormControl } from "./form-control.js";
|
|
@@ -15,7 +14,7 @@ export declare class CollapsibleFieldGroup extends FieldGroup {
|
|
|
15
14
|
options: CollapsibleFieldGroupOptions;
|
|
16
15
|
collapseID: string;
|
|
17
16
|
constructor(controls: FormControl[], options?: CollapsibleFieldGroupOptions);
|
|
18
|
-
getGroupLabelProps():
|
|
17
|
+
getGroupLabelProps(): Promise<string>;
|
|
19
18
|
preLabelContainer(): FlatTemplatable;
|
|
20
19
|
postLabel(): FlatTemplatable;
|
|
21
20
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
2
|
/// <reference types="koa__router" />
|
|
4
3
|
import Router from "@koa/router";
|
|
5
4
|
import { Context } from "koa";
|
|
@@ -17,6 +16,6 @@ export declare class DerivedFrame extends Derived<{
|
|
|
17
16
|
generateFrameContent: (ctx: FormControlContext, args: ParsedUrlQuery) => Promise<FlatTemplatable>;
|
|
18
17
|
frame_id: string;
|
|
19
18
|
constructor(frame_name: string, fields: FormField[], generateFrameContent: (ctx: FormControlContext, args: ParsedUrlQuery) => Promise<FlatTemplatable>, frame_id?: string);
|
|
20
|
-
renderBackendResponseFrame(_ctx: Context, content: FlatTemplatable):
|
|
19
|
+
renderBackendResponseFrame(_ctx: Context, content: FlatTemplatable): Promise<string>;
|
|
21
20
|
mount(router: Router): void;
|
|
22
21
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { Context } from "koa";
|
|
3
2
|
import { FilePointer } from "@sealcode/file-manager";
|
|
4
3
|
import { FlatTemplatable } from "tempstream";
|
|
@@ -9,6 +8,6 @@ import { SimpleInput } from "./simple-input.js";
|
|
|
9
8
|
export declare class File extends SimpleInput<FileContainer> {
|
|
10
9
|
getType(): string;
|
|
11
10
|
renderFilePreview(_ctx: Context, file: FilePointer | null): Promise<FlatTemplatable>;
|
|
12
|
-
preInput(fctx: FormControlContext, data: Record<string, FormDataValue>): Promise<
|
|
11
|
+
preInput(fctx: FormControlContext, data: Record<string, FormDataValue>): Promise<string>;
|
|
13
12
|
getInputAttributes(fctx: FormControlContext): Promise<Record<string, string | boolean>>;
|
|
14
13
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="koa__router" />
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
2
|
import Router from "@koa/router";
|
|
4
3
|
import { Collection, CollectionItem, Field as SealiousField } from "sealious";
|
|
5
4
|
import { Context } from "koa";
|
|
@@ -23,7 +22,7 @@ export declare class MultipleFiles extends FormFieldControl {
|
|
|
23
22
|
addFileAssociation(ctx: Context, file: FilePointer): Promise<void>;
|
|
24
23
|
getFrameRelativeURL(): string;
|
|
25
24
|
getFrameID(): string;
|
|
26
|
-
renderFrame(_ctx: Context, content?: FlatTemplatable):
|
|
25
|
+
renderFrame(_ctx: Context, content?: FlatTemplatable): Promise<string>;
|
|
27
26
|
render(fctx: FormControlContext): FlatTemplatable | Promise<FlatTemplatable>;
|
|
28
27
|
getReferencingCollection(): Collection;
|
|
29
28
|
getFileField(): SealiousField<any> | null;
|
|
@@ -8,7 +8,7 @@ import { Form } from "../form.js";
|
|
|
8
8
|
import { FormControl, FormControlContext } from "./form-control.js";
|
|
9
9
|
export type TableControlOptions<F extends Record<string, FormField>> = {
|
|
10
10
|
render_fields: {
|
|
11
|
-
[field_name in keyof F]: (fctx: FormControlContext, name: string, value: string) =>
|
|
11
|
+
[field_name in keyof F]: (fctx: FormControlContext, name: string, value: string) => FlatTemplatable | Promise<FlatTemplatable>;
|
|
12
12
|
};
|
|
13
13
|
allow_removing?: boolean;
|
|
14
14
|
label_add?: string;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { Readable } from "stream";
|
|
3
1
|
import { FlatTemplatable } from "tempstream";
|
|
4
2
|
export declare function getRequiredClass(isRequired: boolean): string;
|
|
5
|
-
export declare function inputWrapper(type: string, modifiers: string[], input: FlatTemplatable):
|
|
3
|
+
export declare function inputWrapper(type: string, modifiers: string[], input: FlatTemplatable): Promise<string>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { hasShape, is, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import qs from "qs";
|
|
3
|
+
import { tempstream } from "tempstream";
|
|
3
4
|
import { FormControl } from "./form-control.js";
|
|
4
5
|
class Table extends FormControl {
|
|
5
6
|
constructor(table_field, options) {
|
|
@@ -16,79 +17,76 @@ class Table extends FormControl {
|
|
|
16
17
|
if (!rows) {
|
|
17
18
|
rows = [];
|
|
18
19
|
}
|
|
19
|
-
return
|
|
20
|
-
/* HTML */
|
|
21
|
-
`<turbo-frame
|
|
20
|
+
return tempstream`<turbo-frame
|
|
22
21
|
id="${this.getFrameID()}"
|
|
23
22
|
class="${[
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
"form-input__wrapper",
|
|
24
|
+
"form-input__wrapper--type--table",
|
|
25
|
+
"form-input__wrapper--options-count--" + rows.length.toString(),
|
|
26
|
+
...rows.length >= 5 ? ["form-input__wrapper--options-count--5-or-more"] : [],
|
|
27
|
+
...rows.length >= 10 ? ["form-input__wrapper--options-count--10-or-more"] : [],
|
|
28
|
+
...rows.length >= 15 ? ["form-input__wrapper--options-count--15-or-more"] : [],
|
|
29
|
+
...rows.length >= 20 ? ["form-input__wrapper--options-count--20-or-more"] : []
|
|
30
|
+
].join(" ")}"
|
|
32
31
|
>
|
|
33
32
|
<label>${this.options.label}</label>
|
|
34
33
|
<div class="table__wrapper">
|
|
35
34
|
<table>
|
|
36
35
|
<tbody>
|
|
37
36
|
${rows?.map((row, row_index) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
return (
|
|
38
|
+
/* HTML */
|
|
39
|
+
tempstream`<tr>
|
|
41
40
|
${Object.entries(this.table_field.columns).map(([key]) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
return tempstream`<td>${this.options.render_fields[key](
|
|
42
|
+
fctx,
|
|
43
|
+
`${this.table_field.name}[${row_index}][${key}]`,
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
45
|
+
row[key]
|
|
46
|
+
)}</td>`;
|
|
47
|
+
})}
|
|
49
48
|
${this.options.allow_removing ? (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
49
|
+
/* HTML */
|
|
50
|
+
`<td>
|
|
51
|
+
<input
|
|
52
|
+
type="submit"
|
|
53
|
+
data-turbo-frame="${this.getFrameID()}"
|
|
54
|
+
value="${this.options.label_remove || "remove"}"
|
|
55
|
+
form="${fctx.form_id}"
|
|
56
|
+
formnovalidate
|
|
57
|
+
formaction="${this.getActionURL(
|
|
58
|
+
this.table_field.name,
|
|
59
|
+
{
|
|
60
|
+
remove: {
|
|
61
|
+
index: row_index
|
|
64
62
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
}
|
|
64
|
+
)}"
|
|
65
|
+
/>
|
|
66
|
+
</td>`
|
|
67
|
+
) : ""}
|
|
69
68
|
</tr>`
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
);
|
|
70
|
+
})}
|
|
72
71
|
</tbody>
|
|
73
72
|
</table>
|
|
74
73
|
${this.options.allow_adding ? (
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
/* HTML */
|
|
75
|
+
`<input
|
|
77
76
|
type="submit"
|
|
78
77
|
value="${this.options.label_add || "add"}"
|
|
79
78
|
form="${fctx.form_id}"
|
|
80
79
|
formnovalidate
|
|
81
80
|
formaction="${this.getActionURL(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
this.table_field.name,
|
|
82
|
+
{
|
|
83
|
+
insert: { index: rows.length, value: {} }
|
|
84
|
+
}
|
|
85
|
+
)}"
|
|
87
86
|
/>`
|
|
88
|
-
|
|
87
|
+
) : ""}
|
|
89
88
|
</div>
|
|
90
|
-
</turbo-frame
|
|
91
|
-
);
|
|
89
|
+
</turbo-frame>`;
|
|
92
90
|
}
|
|
93
91
|
getFrameID() {
|
|
94
92
|
return `array-frame-${this.table_field.name}`;
|
|
@@ -147,7 +145,7 @@ class Table extends FormControl {
|
|
|
147
145
|
}
|
|
148
146
|
ctx.override_reaction = {
|
|
149
147
|
action: "stay",
|
|
150
|
-
content: form.render(
|
|
148
|
+
content: await form.render(
|
|
151
149
|
ctx,
|
|
152
150
|
{
|
|
153
151
|
raw_values: await form.extractRawValues(ctx),
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { toCamelCase } from "js-convert-case";
|
|
2
|
-
const file_handler = async (_, { name, is_required },
|
|
2
|
+
const file_handler = async (_, { name, is_required }, importPath, { is_required_expr }) => {
|
|
3
3
|
const tempname = toCamelCase("prepared-" + name);
|
|
4
4
|
return {
|
|
5
|
+
imports: {
|
|
6
|
+
shared: `import { TheFileManager } from "${importPath(
|
|
7
|
+
"src/back/file-manager.js"
|
|
8
|
+
)}";`
|
|
9
|
+
},
|
|
5
10
|
field: `${name}: new Fields.File(${is_required_expr}, TheFileManager)`,
|
|
6
11
|
initial_value_edit: `{old: item.get("${name}")}`,
|
|
7
|
-
pre_edit: `const ${tempname} = data
|
|
12
|
+
pre_edit: `const ${tempname} = data.["${name}"]?.new || data.["${name}"]?.old;
|
|
8
13
|
if(!${tempname}){
|
|
9
14
|
throw new Error("Missing field: ${name}")
|
|
10
15
|
}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealcode/sealgen",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.44",
|
|
4
4
|
"description": "Module to automate adding routes and collections to a sealious application",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"prettier": "^2.7.1",
|
|
75
75
|
"prompts": "^2.4.2",
|
|
76
76
|
"recursive-readdir": "^2.2.3",
|
|
77
|
-
"tempstream": "^0.
|
|
77
|
+
"tempstream": "^0.4.0",
|
|
78
78
|
"tiny-glob": "^0.2.9",
|
|
79
79
|
"ws": "^8.16.0",
|
|
80
80
|
"yargs": "^17.6.2"
|
|
@@ -5,7 +5,7 @@ import Router from "@koa/router";
|
|
|
5
5
|
import { hasShape, is, predicates } from "@sealcode/ts-predicates";
|
|
6
6
|
import { Context } from "koa";
|
|
7
7
|
import qs from "qs";
|
|
8
|
-
import { FlatTemplatable } from "tempstream";
|
|
8
|
+
import { FlatTemplatable, tempstream } from "tempstream";
|
|
9
9
|
import { FormField } from "../fields/field.js";
|
|
10
10
|
import { Table as TableField } from "../fields/table.js";
|
|
11
11
|
import { FormReaction } from "../form-types.js";
|
|
@@ -18,7 +18,7 @@ export type TableControlOptions<F extends Record<string, FormField>> = {
|
|
|
18
18
|
fctx: FormControlContext,
|
|
19
19
|
name: string,
|
|
20
20
|
value: string
|
|
21
|
-
) =>
|
|
21
|
+
) => FlatTemplatable | Promise<FlatTemplatable>;
|
|
22
22
|
};
|
|
23
23
|
allow_removing?: boolean;
|
|
24
24
|
label_add?: string;
|
|
@@ -51,7 +51,7 @@ export class Table<F extends Record<string, FormField>> extends FormControl {
|
|
|
51
51
|
if (!rows) {
|
|
52
52
|
rows = [];
|
|
53
53
|
}
|
|
54
|
-
return /* HTML */ `<turbo-frame
|
|
54
|
+
return tempstream/* HTML */ `<turbo-frame
|
|
55
55
|
id="${this.getFrameID()}"
|
|
56
56
|
class="${[
|
|
57
57
|
"form-input__wrapper",
|
|
@@ -75,45 +75,44 @@ export class Table<F extends Record<string, FormField>> extends FormControl {
|
|
|
75
75
|
<div class="table__wrapper">
|
|
76
76
|
<table>
|
|
77
77
|
<tbody>
|
|
78
|
-
${rows
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
]
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
78
|
+
${rows?.map((row, row_index) => {
|
|
79
|
+
return /* HTML */ tempstream`<tr>
|
|
80
|
+
${Object.entries(this.table_field.columns).map(([key]) => {
|
|
81
|
+
return tempstream`<td>${this.options.render_fields[
|
|
82
|
+
key
|
|
83
|
+
](
|
|
84
|
+
fctx,
|
|
85
|
+
`${this.table_field.name}[${row_index}][${key}]`,
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
87
|
+
row[key] as string
|
|
88
|
+
)}</td>`;
|
|
89
|
+
})}
|
|
90
|
+
${
|
|
91
|
+
this.options.allow_removing
|
|
92
|
+
? /* HTML */ `<td>
|
|
93
|
+
<input
|
|
94
|
+
type="submit"
|
|
95
|
+
data-turbo-frame="${this.getFrameID()}"
|
|
96
|
+
value="${this.options
|
|
97
|
+
.label_remove ||
|
|
98
|
+
"remove"}"
|
|
99
|
+
form="${fctx.form_id}"
|
|
100
|
+
formnovalidate
|
|
101
|
+
formaction="${this.getActionURL(
|
|
102
|
+
this.table_field
|
|
103
|
+
.name,
|
|
104
|
+
{
|
|
105
|
+
remove: {
|
|
106
|
+
index: row_index,
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
)}"
|
|
110
|
+
/>
|
|
111
|
+
</td>`
|
|
112
|
+
: ""
|
|
113
|
+
}
|
|
114
114
|
</tr>`;
|
|
115
|
-
|
|
116
|
-
.join("")}
|
|
115
|
+
})}
|
|
117
116
|
</tbody>
|
|
118
117
|
</table>
|
|
119
118
|
${this.options.allow_adding
|
|
@@ -202,7 +201,7 @@ export class Table<F extends Record<string, FormField>> extends FormControl {
|
|
|
202
201
|
}
|
|
203
202
|
ctx.override_reaction = {
|
|
204
203
|
action: "stay",
|
|
205
|
-
content: form.render(
|
|
204
|
+
content: await form.render(
|
|
206
205
|
ctx,
|
|
207
206
|
{
|
|
208
207
|
raw_values: await form.extractRawValues(ctx),
|
|
@@ -7,12 +7,17 @@ import {
|
|
|
7
7
|
export const file_handler: FieldHandler<
|
|
8
8
|
FieldHandlerResult,
|
|
9
9
|
Partial<FieldHandlerResult>
|
|
10
|
-
> = async (_, { name, is_required },
|
|
10
|
+
> = async (_, { name, is_required }, importPath, { is_required_expr }) => {
|
|
11
11
|
const tempname = toCamelCase("prepared-" + name);
|
|
12
12
|
return {
|
|
13
|
+
imports: {
|
|
14
|
+
shared: `import { TheFileManager } from "${importPath(
|
|
15
|
+
"src/back/file-manager.js"
|
|
16
|
+
)}";`,
|
|
17
|
+
},
|
|
13
18
|
field: `${name}: new Fields.File(${is_required_expr}, TheFileManager)`,
|
|
14
19
|
initial_value_edit: `{old: item.get("${name}")}`,
|
|
15
|
-
pre_edit: `const ${tempname} = data
|
|
20
|
+
pre_edit: `const ${tempname} = data.["${name}"]?.new || data.["${name}"]?.old;
|
|
16
21
|
if(!${tempname}){
|
|
17
22
|
throw new Error("Missing field: ${name}")
|
|
18
23
|
}`,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Readable } from "stream";
|
|
2
1
|
import { FlatTemplatable, tempstream } from "tempstream";
|
|
3
2
|
|
|
4
3
|
export function getRequiredClass(isRequired: boolean): string {
|
|
@@ -13,7 +12,7 @@ export function inputWrapper(
|
|
|
13
12
|
type: string,
|
|
14
13
|
modifiers: string[],
|
|
15
14
|
input: FlatTemplatable
|
|
16
|
-
):
|
|
15
|
+
): Promise<string> {
|
|
17
16
|
return tempstream/* HTML */ `<div
|
|
18
17
|
class="form-input form-input--type-${type} form-input__wrapper ${getModifierClasses(
|
|
19
18
|
modifiers
|