@sealcode/sealgen 0.19.12 → 0.19.13

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.
@@ -1,5 +1,10 @@
1
+ import { ExtractedFieldInfo } from "../../utils/extract-fields-from-collection.js";
1
2
  import { TextBasedSimpleField } from "./simple-form-field.js";
2
3
  export declare class Password<Required extends boolean> extends TextBasedSimpleField<Required> {
3
4
  constructor(required: Required);
4
5
  sealiousValueToForm(): Promise<undefined>;
6
+ generateInitialValue(field_info: ExtractedFieldInfo, vars: {
7
+ form_field_types: string;
8
+ form_fields: string;
9
+ }): string;
5
10
  }
@@ -1,3 +1,4 @@
1
+ import { wrapAttribute, wrapKeyName } from "../../utils/wrap-attributes.js";
1
2
  import { TextBasedSimpleField } from "./simple-form-field.js";
2
3
  class Password extends TextBasedSimpleField {
3
4
  constructor(required) {
@@ -6,6 +7,9 @@ class Password extends TextBasedSimpleField {
6
7
  async sealiousValueToForm() {
7
8
  return void 0;
8
9
  }
10
+ generateInitialValue(field_info, vars) {
11
+ return `${wrapKeyName(field_info.name)}: await ${vars.form_fields}${wrapAttribute(field_info.name)}.sealiousValueToForm()`;
12
+ }
9
13
  }
10
14
  export {
11
15
  Password
@@ -26,11 +26,11 @@ class MountableWithFields extends Mountable {
26
26
  } else if (!this.fields) {
27
27
  throw new Error("Fields not defined and getter not provided");
28
28
  }
29
- this.controls = this.getControls(this.fields);
30
29
  for (const [field_name, field] of Object.entries(this.fields)) {
31
30
  void field.init();
32
31
  field.setName(field_name);
33
32
  }
33
+ this.controls = this.getControls(this.fields);
34
34
  this.initialized = true;
35
35
  }
36
36
  makeFormControlContext(ctx, data, validate, field_name_prefix = this.field_names_prefix, form_id = this.form_id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.19.12",
3
+ "version": "0.19.13",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -92,7 +92,7 @@
92
92
  "peerDependencies": {
93
93
  "koa": "^2.13.0",
94
94
  "koa-responsive-image-router": "^0.2.24",
95
- "sealious": "^0.21.20",
95
+ "sealious": "^0.21.29",
96
96
  "stimulus": "^3.2.2"
97
97
  }
98
98
  }
@@ -1,3 +1,5 @@
1
+ import { ExtractedFieldInfo } from "../../utils/extract-fields-from-collection.js";
2
+ import { wrapAttribute, wrapKeyName } from "../../utils/wrap-attributes.js";
1
3
  import { TextBasedSimpleField } from "./simple-form-field.js";
2
4
 
3
5
  export class Password<
@@ -10,4 +12,16 @@ export class Password<
10
12
  async sealiousValueToForm(): Promise<undefined> {
11
13
  return undefined;
12
14
  }
15
+
16
+ generateInitialValue(
17
+ field_info: ExtractedFieldInfo,
18
+ vars: {
19
+ form_field_types: string;
20
+ form_fields: string;
21
+ }
22
+ ): string {
23
+ return `${wrapKeyName(field_info.name)}: await ${
24
+ vars.form_fields
25
+ }${wrapAttribute(field_info.name)}.sealiousValueToForm()`;
26
+ }
13
27
  }
@@ -57,11 +57,11 @@ export abstract class MountableWithFields<
57
57
  } else if (!this.fields) {
58
58
  throw new Error("Fields not defined and getter not provided");
59
59
  }
60
- this.controls = this.getControls(this.fields);
61
60
  for (const [field_name, field] of Object.entries(this.fields)) {
62
61
  void field.init();
63
62
  field.setName(field_name);
64
63
  }
64
+ this.controls = this.getControls(this.fields);
65
65
  this.initialized = true;
66
66
  }
67
67