@sealcode/sealgen 0.14.15 → 0.14.16
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/forms/controls/photo.d.ts +1 -0
- package/@types/src/forms/controls/simple-input.d.ts +1 -0
- package/dist/forms/controls/photo.js +7 -1
- package/dist/forms/controls/simple-input.js +9 -2
- package/package.json +1 -1
- package/src/forms/controls/photo.ts +8 -1
- package/src/forms/controls/simple-input.ts +10 -2
|
@@ -28,5 +28,6 @@ export declare class SimpleInput<ParsedValue, Options extends SimpleInputOptions
|
|
|
28
28
|
getInputAttributes(fctx: FormControlContext): Promise<Record<string, string | boolean>>;
|
|
29
29
|
postInput(_: Context): Promise<FlatTemplatable>;
|
|
30
30
|
renderInput(_ctx: Context, attributes_str: string, _data: Record<string, FormDataValue>): Promise<FlatTemplatable>;
|
|
31
|
+
getWrapperModifiers(): string[];
|
|
31
32
|
render<Fields extends Record<string, FormField>>(fctx: FormControlContext): Promise<FlatTemplatable>;
|
|
32
33
|
}
|
|
@@ -29,9 +29,15 @@ class Photo extends File {
|
|
|
29
29
|
})}
|
|
30
30
|
</div>`;
|
|
31
31
|
}
|
|
32
|
+
getWrapperModifiers() {
|
|
33
|
+
return [
|
|
34
|
+
...super.getWrapperModifiers(),
|
|
35
|
+
"control-type__image",
|
|
36
|
+
"control-type__photo"
|
|
37
|
+
];
|
|
38
|
+
}
|
|
32
39
|
async getInputAttributes(fctx) {
|
|
33
40
|
const original = await super.getInputAttributes(fctx);
|
|
34
|
-
const { parsed } = await this.field.getValue(fctx.ctx, fctx.data);
|
|
35
41
|
return {
|
|
36
42
|
...original,
|
|
37
43
|
accept: "image/*",
|
|
@@ -55,16 +55,23 @@ class SimpleInput extends FormFieldControl {
|
|
|
55
55
|
async renderInput(_ctx, attributes_str, _data) {
|
|
56
56
|
return `<input ${attributes_str} />`;
|
|
57
57
|
}
|
|
58
|
+
getWrapperModifiers() {
|
|
59
|
+
return [
|
|
60
|
+
this.getID(),
|
|
61
|
+
this.getType(),
|
|
62
|
+
"type__" + this.getType(),
|
|
63
|
+
getRequiredClass(this.field.required)
|
|
64
|
+
];
|
|
65
|
+
}
|
|
58
66
|
async render(fctx) {
|
|
59
67
|
const id = this.getID();
|
|
60
68
|
const label = this.getLabel();
|
|
61
|
-
const type = this.getType();
|
|
62
69
|
const { valid, message } = await this.field.getValue(
|
|
63
70
|
fctx.ctx,
|
|
64
71
|
fctx.data
|
|
65
72
|
);
|
|
66
73
|
return inputWrapper(
|
|
67
|
-
|
|
74
|
+
this.getWrapperModifiers(),
|
|
68
75
|
tempstream`
|
|
69
76
|
${label ? `<label for="${id}">${label}</label>` : ""}
|
|
70
77
|
${await this.preInput(fctx.ctx, fctx.data)}
|
package/package.json
CHANGED
|
@@ -44,12 +44,19 @@ export class Photo extends File {
|
|
|
44
44
|
</div>`;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
getWrapperModifiers(): string[] {
|
|
48
|
+
return [
|
|
49
|
+
...super.getWrapperModifiers(),
|
|
50
|
+
"control-type__image",
|
|
51
|
+
"control-type__photo",
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
async getInputAttributes(fctx: FormControlContext) {
|
|
48
56
|
const original = (await super.getInputAttributes(fctx)) as Record<
|
|
49
57
|
string,
|
|
50
58
|
string | boolean
|
|
51
59
|
>;
|
|
52
|
-
const { parsed } = await this.field.getValue(fctx.ctx, fctx.data);
|
|
53
60
|
return {
|
|
54
61
|
...original,
|
|
55
62
|
accept: "image/*",
|
|
@@ -117,19 +117,27 @@ export class SimpleInput<
|
|
|
117
117
|
return `<input ${attributes_str} />`;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
getWrapperModifiers(): string[] {
|
|
121
|
+
return [
|
|
122
|
+
this.getID(),
|
|
123
|
+
this.getType(),
|
|
124
|
+
"type__" + this.getType(),
|
|
125
|
+
getRequiredClass(this.field.required),
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
|
|
120
129
|
async render<Fields extends Record<string, FormField>>(
|
|
121
130
|
fctx: FormControlContext
|
|
122
131
|
): Promise<FlatTemplatable> {
|
|
123
132
|
const id = this.getID();
|
|
124
133
|
const label = this.getLabel();
|
|
125
|
-
const type = this.getType();
|
|
126
134
|
|
|
127
135
|
const { valid, message } = await this.field.getValue(
|
|
128
136
|
fctx.ctx,
|
|
129
137
|
fctx.data
|
|
130
138
|
);
|
|
131
139
|
return inputWrapper(
|
|
132
|
-
|
|
140
|
+
this.getWrapperModifiers(),
|
|
133
141
|
tempstream/* HTML */ `
|
|
134
142
|
${label ? `<label for="${id}">${label}</label>` : ""}
|
|
135
143
|
${await this.preInput(fctx.ctx, fctx.data)}
|