@sealcode/sealgen 0.19.34 → 0.19.37

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/index.d.ts CHANGED
@@ -34,14 +34,18 @@ export interface HTMLHeadOptions {
34
34
  }
35
35
  export interface HTMLArgs {
36
36
  ctx: Context;
37
- title: string | Promise<string>;
37
+ title: string | Promise<string> | {
38
+ toString(): string;
39
+ };
38
40
  body: string | Promise<string> | Readable;
39
41
  htmlOptions?: Partial<HTMLOptions>;
40
42
  makeHead?: (args: HTMLHeadOptions) => string | Promise<string> | Readable | Promise<Readable>;
41
43
  metaImage?: string;
42
44
  canonicalPath?: string;
43
45
  css_clumps?: string[];
44
- description: string;
46
+ description: string | {
47
+ toString(): string;
48
+ };
45
49
  hideNavigation?: boolean;
46
50
  }
47
51
  export type HTMLFunc = (args: HTMLArgs) => Readable | Promise<Readable>;
@@ -18,14 +18,18 @@ class Table extends FormControl {
18
18
  const get_row_fctx = (row, row_index) => {
19
19
  return typeof row_index == "number" ? {
20
20
  data: {
21
- raw_values: Object.fromEntries(
22
- Object.entries(
23
- row
24
- ).map(([key, value]) => [
25
- this.table_field.columns[key].name,
26
- value
27
- ])
28
- ) || {},
21
+ raw_values: {
22
+ [this.table_field.name]: {
23
+ [TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER]: Object.fromEntries(
24
+ Object.entries(
25
+ row
26
+ ).map(([key, value]) => [
27
+ this.table_field.columns[key].name.split("][").at(-1).replace("]", ""),
28
+ value
29
+ ])
30
+ ) || {}
31
+ }
32
+ },
29
33
  messages: [],
30
34
  field_messages: {}
31
35
  }
@@ -103,6 +107,13 @@ class Table extends FormControl {
103
107
  data-table-placeholder="${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}"
104
108
  >
105
109
  <table data-sealgen-table-target="table">
110
+ <thead>
111
+ <tr>
112
+ ${Object.keys(this.table_field?.columns).map(
113
+ (c) => `<th>${c}</th>`
114
+ )}
115
+ </tr>
116
+ </thead>
106
117
  <tbody>
107
118
  ${rows?.map((row, index) => make_row(row, index))}
108
119
  </tbody>
@@ -53,7 +53,7 @@ class CollectionField extends FormField {
53
53
  async isValueValid(ctx, value) {
54
54
  const { valid, reason } = await this.sealiousField.checkValue(
55
55
  ctx.$context,
56
- this.parsedToSealious(value),
56
+ await this.parsedToSealious(value),
57
57
  void 0,
58
58
  null,
59
59
  void 0
@@ -29,7 +29,7 @@ class FormField {
29
29
  return this;
30
30
  }
31
31
  getValuePath() {
32
- return (this.value_path || this.name).replaceAll("][", ".").replaceAll("[", ".");
32
+ return (this.value_path || this.name).replaceAll("][", ".").replaceAll("[", ".").replaceAll("]", "");
33
33
  }
34
34
  setValuePath(path) {
35
35
  this.value_path = path;
@@ -18,6 +18,7 @@ class Table extends FormField {
18
18
  field.setName(
19
19
  `${this.name}[${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}][${column_name}]`
20
20
  );
21
+ field.setLabel(" ");
21
22
  }
22
23
  return this;
23
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.19.34",
3
+ "version": "0.19.37",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -66,15 +66,23 @@ export class Table<F extends Record<string, FormField>> extends FormControl {
66
66
  return typeof row_index == "number" ?
67
67
  {
68
68
  data: {
69
- raw_values:
70
- (Object.fromEntries(
71
- Object.entries(
72
- row as Record<string, unknown>
73
- ).map(([key, value]) => [
74
- this.table_field.columns[key]!.name,
75
- value,
76
- ])
77
- ) as any) || {},
69
+ raw_values: {
70
+ [this.table_field.name]: {
71
+ [TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER]:
72
+ (Object.fromEntries(
73
+ Object.entries(
74
+ row as Record<string, unknown>
75
+ ).map(([key, value]) => [
76
+ this.table_field.columns[
77
+ key
78
+ ]!.name.split("][")
79
+ .at(-1)!
80
+ .replace("]", ""),
81
+ value,
82
+ ])
83
+ ) as any) || {},
84
+ },
85
+ },
78
86
  messages: [],
79
87
  field_messages: {},
80
88
  },
@@ -176,6 +184,13 @@ export class Table<F extends Record<string, FormField>> extends FormControl {
176
184
  data-table-placeholder="${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}"
177
185
  >
178
186
  <table data-sealgen-table-target="table">
187
+ <thead>
188
+ <tr>
189
+ ${Object.keys(this.table_field?.columns).map(
190
+ (c) => `<th>${c}</th>`
191
+ )}
192
+ </tr>
193
+ </thead>
179
194
  <tbody>
180
195
  ${rows?.map((row, index) => make_row(row, index))}
181
196
  </tbody>
@@ -94,7 +94,7 @@ export class CollectionField<
94
94
  ): Promise<FormFieldValidationResponse> {
95
95
  const { valid, reason } = await this.sealiousField.checkValue(
96
96
  ctx.$context,
97
- this.parsedToSealious(value),
97
+ await this.parsedToSealious(value),
98
98
  undefined,
99
99
  null,
100
100
  undefined
@@ -94,7 +94,8 @@ export abstract class FormField<
94
94
  public getValuePath() {
95
95
  return (this.value_path || this.name)
96
96
  .replaceAll("][", ".")
97
- .replaceAll("[", ".");
97
+ .replaceAll("[", ".")
98
+ .replaceAll("]", "");
98
99
  }
99
100
 
100
101
  public setValuePath(path: string) {
@@ -35,6 +35,7 @@ export class Table<F extends Record<string, FormField>> extends FormField<
35
35
  field.setName(
36
36
  `${this.name}[${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}][${column_name}]`
37
37
  );
38
+ field.setLabel(" ");
38
39
  }
39
40
  return this;
40
41
  }
package/src/index.ts CHANGED
@@ -38,7 +38,7 @@ export interface HTMLHeadOptions {
38
38
 
39
39
  export interface HTMLArgs {
40
40
  ctx: Context;
41
- title: string | Promise<string>;
41
+ title: string | Promise<string> | { toString(): string };
42
42
  body: string | Promise<string> | Readable;
43
43
  htmlOptions?: Partial<HTMLOptions>;
44
44
  makeHead?: (
@@ -47,7 +47,7 @@ export interface HTMLArgs {
47
47
  metaImage?: string;
48
48
  canonicalPath?: string;
49
49
  css_clumps?: string[];
50
- description: string;
50
+ description: string | { toString(): string };
51
51
  hideNavigation?: boolean;
52
52
  }
53
53