@sealcode/sealgen 0.19.15 → 0.19.17

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.
Files changed (122) hide show
  1. package/@types/app-config/get-app-port.d.ts +1 -0
  2. package/@types/app-config/load-app-config.d.ts +4 -0
  3. package/@types/app-config/resolve-app-config-path.d.ts +1 -0
  4. package/@types/forms/fields/structured-array.d.ts +2 -2
  5. package/@types/utils/translate.d.ts +2 -1
  6. package/lib/forms/controls/tickable.js +2 -1
  7. package/lib/forms/fields/collection-field.js +2 -1
  8. package/lib/forms/form.js +6 -1
  9. package/lib/generate-routes.js +23 -1
  10. package/lib/utils/translate.js +4 -4
  11. package/package.json +2 -2
  12. package/src/forms/controls/tickable.ts +14 -9
  13. package/src/forms/fields/collection-field.ts +2 -1
  14. package/src/forms/fields/structured-array.ts +2 -11
  15. package/src/forms/form.ts +11 -4
  16. package/src/generate-routes.ts +38 -9
  17. package/src/utils/translate.ts +7 -5
  18. package/.xunit +0 -75
  19. package/@types/add-verbose-crud.d.ts +0 -3
  20. package/@types/builders/colors-builder.d.sync-conflict-20250918-184323-TFDLWFG.ts +0 -10
  21. package/@types/builders/fonts-builder.d.sync-conflict-20250918-184322-TFDLWFG.ts +0 -7
  22. package/@types/controllers/table-add-button.d.ts +0 -6
  23. package/@types/crud-field-snippets.d.ts +0 -1
  24. package/@types/find-css-includes.d.ts +0 -1
  25. package/@types/forms/controls/array.d.sync-conflict-20250918-184306-TFDLWFG.ts +0 -33
  26. package/@types/forms/controls/array.sync-conflict-20250918-222045-TFDLWFG.d.ts +0 -33
  27. package/@types/forms/controls/autocomplete.d.sync-conflict-20250918-222042-TFDLWFG.ts +0 -22
  28. package/@types/forms/controls/checkbox-group.d.sync-conflict-20250918-184319-TFDLWFG.ts +0 -21
  29. package/@types/forms/controls/checkboxed-list-input.d.sync-conflict-20250918-184323-TFDLWFG.ts +0 -21
  30. package/@types/forms/controls/derived-frame.d.sync-conflict-20250918-184314-TFDLWFG.ts +0 -19
  31. package/@types/forms/controls/dropdown.d.sync-conflict-20250918-222044-TFDLWFG.ts +0 -30
  32. package/@types/forms/controls/file.d.sync-conflict-20250918-222045-TFDLWFG.ts +0 -13
  33. package/@types/forms/controls/form-control.d.sync-conflict-20250918-184322-TFDLWFG.ts +0 -19
  34. package/@types/forms/controls/form-control.d.sync-conflict-20250918-222046-TFDLWFG.ts +0 -19
  35. package/@types/forms/controls/multiple-files.d.sync-conflict-20250918-184318-TFDLWFG.ts +0 -42
  36. package/@types/forms/controls/multiple-photos.d.ts +0 -19
  37. package/@types/forms/controls/number.d.sync-conflict-20250918-222046-TFDLWFG.ts +0 -13
  38. package/@types/forms/controls/photo.d.sync-conflict-20250918-184321-TFDLWFG.ts +0 -19
  39. package/@types/forms/controls/photo.d.ts +0 -19
  40. package/@types/forms/controls/photo.test.d.ts +0 -1
  41. package/@types/forms/controls/reverse-single-reference.d.ts +0 -1
  42. package/@types/forms/controls/simple-input.d.sync-conflict-20250918-184310-TFDLWFG.ts +0 -33
  43. package/@types/forms/controls/simple-input.d.sync-conflict-20250918-222042-TFDLWFG.ts +0 -33
  44. package/@types/forms/controls/simple-input.sync-conflict-20250918-222045-TFDLWFG.d.ts +0 -33
  45. package/@types/forms/controls/table.d.sync-conflict-20250918-184302-TFDLWFG.ts +0 -39
  46. package/@types/forms/controls/table.sync-conflict-20250918-222042-TFDLWFG.d.ts +0 -39
  47. package/@types/forms/controls/textarea.d.sync-conflict-20250918-222045-TFDLWFG.ts +0 -25
  48. package/@types/forms/fields/boolean.d.sync-conflict-20250918-184325-TFDLWFG.ts +0 -22
  49. package/@types/forms/fields/boolean.sync-conflict-20250918-222042-TFDLWFG.d.ts +0 -22
  50. package/@types/forms/fields/checkboxed-list.d.sync-conflict-20250918-184325-TFDLWFG.ts +0 -23
  51. package/@types/forms/fields/collection-field.d.sync-conflict-20250918-184319-TFDLWFG.ts +0 -22
  52. package/@types/forms/fields/collection-field.d.sync-conflict-20250918-222047-TFDLWFG.ts +0 -22
  53. package/@types/forms/fields/coordinates.d.sync-conflict-20250918-222044-TFDLWFG.ts +0 -14
  54. package/@types/forms/fields/datetime.d.sync-conflict-20250918-222050-TFDLWFG.ts +0 -4
  55. package/@types/forms/fields/email.d.sync-conflict-20250918-184303-TFDLWFG.ts +0 -8
  56. package/@types/forms/fields/enum-multiple-sealious.sync-conflict-20250918-222047-TFDLWFG.d.ts +0 -16
  57. package/@types/forms/fields/enum-multiple.d.ts +0 -18
  58. package/@types/forms/fields/enum-multiple.test.d.ts +0 -1
  59. package/@types/forms/fields/enum.d.ts +0 -18
  60. package/@types/forms/fields/enum.test.d.ts +0 -1
  61. package/@types/forms/fields/field.d.sync-conflict-20250918-184306-TFDLWFG.ts +0 -70
  62. package/@types/forms/fields/fields.d.sync-conflict-20250918-184314-TFDLWFG.ts +0 -29
  63. package/@types/forms/fields/file.d.sync-conflict-20250918-184310-TFDLWFG.ts +0 -23
  64. package/@types/forms/fields/file.d.sync-conflict-20250918-222046-TFDLWFG.ts +0 -23
  65. package/@types/forms/fields/file.sync-conflict-20250918-222049-TFDLWFG.d.ts +0 -23
  66. package/@types/forms/fields/get-field-for-sealious.d.sync-conflict-20250918-222046-TFDLWFG.ts +0 -29
  67. package/@types/forms/fields/get-field-for-sealious.sync-conflict-20250918-222042-TFDLWFG.d.ts +0 -29
  68. package/@types/forms/fields/image.d.sync-conflict-20250918-222042-TFDLWFG.ts +0 -5
  69. package/@types/forms/fields/multiple-files.d.sync-conflict-20250918-184304-TFDLWFG.ts +0 -16
  70. package/@types/forms/fields/number.d.sync-conflict-20250918-184317-TFDLWFG.ts +0 -25
  71. package/@types/forms/fields/number.d.sync-conflict-20250918-222047-TFDLWFG.ts +0 -25
  72. package/@types/forms/fields/pick-from-list.d.sync-conflict-20250918-184322-TFDLWFG.ts +0 -15
  73. package/@types/forms/fields/proxy-field.d.sync-conflict-20250918-184307-TFDLWFG.ts +0 -15
  74. package/@types/forms/fields/regexp.d.sync-conflict-20250918-184305-TFDLWFG.ts +0 -21
  75. package/@types/forms/fields/regexp.d.sync-conflict-20250918-222045-TFDLWFG.ts +0 -21
  76. package/@types/forms/fields/regexp.sync-conflict-20250918-222047-TFDLWFG.d.ts +0 -21
  77. package/@types/forms/fields/reverse-single-reference.d.ts +0 -13
  78. package/@types/forms/fields/simple-form-field.d.sync-conflict-20250918-184309-TFDLWFG.ts +0 -29
  79. package/@types/forms/fields/simple-form-field.d.sync-conflict-20250918-222044-TFDLWFG.ts +0 -29
  80. package/@types/forms/fields/simple-form-field.sync-conflict-20250918-222049-TFDLWFG.d.ts +0 -29
  81. package/@types/forms/fields/single-reference.sync-conflict-20250918-222043-TFDLWFG.d.ts +0 -10
  82. package/@types/forms/fields/structured-array.d.sync-conflict-20250918-184302-TFDLWFG.ts +0 -27
  83. package/@types/forms/fields/structured-array.d.sync-conflict-20250918-222049-TFDLWFG.ts +0 -27
  84. package/@types/forms/fields/structured-array.sync-conflict-20250918-222047-TFDLWFG.d.ts +0 -27
  85. package/@types/forms/fields/table.d.sync-conflict-20250918-184303-TFDLWFG.ts +0 -16
  86. package/@types/forms/form-types.d.sync-conflict-20250918-222045-TFDLWFG.ts +0 -26
  87. package/@types/forms/form.d.sync-conflict-20250918-184315-TFDLWFG.ts +0 -32
  88. package/@types/forms/form.d.sync-conflict-20250918-222049-TFDLWFG.ts +0 -32
  89. package/@types/forms/form.sync-conflict-20250918-222049-TFDLWFG.d.ts +0 -33
  90. package/@types/forms/form.test.d.sync-conflict-20250918-184318-TFDLWFG.ts +0 -6
  91. package/@types/forms/form.test.d.sync-conflict-20250918-222047-TFDLWFG.ts +0 -6
  92. package/@types/forms/multiform.d.sync-conflict-20250918-184308-TFDLWFG.ts +0 -23
  93. package/@types/forms/multiform.sync-conflict-20250918-222044-TFDLWFG.d.ts +0 -23
  94. package/@types/index.d.sync-conflict-20250918-184316-TFDLWFG.ts +0 -46
  95. package/@types/mount.d.sync-conflict-20250918-184320-TFDLWFG.ts +0 -6
  96. package/@types/page/list.d.sync-conflict-20250918-184318-TFDLWFG.ts +0 -48
  97. package/@types/page/list.d.sync-conflict-20250918-222046-TFDLWFG.ts +0 -48
  98. package/@types/page/list.sync-conflict-20250918-222048-TFDLWFG.d.ts +0 -48
  99. package/@types/page/mountable-with-fields.d.sync-conflict-20250918-184321-TFDLWFG.ts +0 -42
  100. package/@types/page/mountable-with-fields.d.sync-conflict-20250918-222046-TFDLWFG.ts +0 -42
  101. package/@types/page/mountable-with-fields.sync-conflict-20250918-222044-TFDLWFG.d.ts +0 -42
  102. package/@types/page/mountable.d.sync-conflict-20250918-184306-TFDLWFG.ts +0 -10
  103. package/@types/page/page.d.sync-conflict-20250918-184320-TFDLWFG.ts +0 -18
  104. package/@types/page/props-parser.d.sync-conflict-20250918-184305-TFDLWFG.ts +0 -15
  105. package/@types/page/stateful-page.d.sync-conflict-20250918-184326-TFDLWFG.ts +0 -62
  106. package/@types/templates/shared/handlers/boolean.d.ts +0 -2
  107. package/@types/templates/shared/handlers/date.d.ts +0 -2
  108. package/@types/templates/shared/handlers/deep-reverse-single-reference.d.ts +0 -2
  109. package/@types/templates/shared/handlers/default.d.ts +0 -2
  110. package/@types/templates/shared/handlers/enum.d.ts +0 -2
  111. package/@types/templates/shared/handlers/file.d.ts +0 -2
  112. package/@types/templates/shared/handlers/image.d.ts +0 -2
  113. package/@types/templates/shared/handlers/int.d.ts +0 -2
  114. package/@types/templates/shared/handlers/jdd.d.ts +0 -2
  115. package/@types/templates/shared/handlers/single-reference.d.ts +0 -2
  116. package/@types/templates/shared/handlers/structured-array.d.ts +0 -2
  117. package/@types/templates/shared/shared-crud-form-fields.d.sync-conflict-20250918-184306-TFDLWFG.ts +0 -1
  118. package/@types/test_utils/test-on-real-app.d.sync-conflict-20250918-184320-TFDLWFG.ts +0 -26
  119. package/@types/utils/extract-fields-from-collection.d.sync-conflict-20250918-184312-TFDLWFG.ts +0 -18
  120. package/@types/utils/extract-fields-from-collection.sync-conflict-20250918-222045-TFDLWFG.d.ts +0 -18
  121. /package/@types/{add-crud.d.sync-conflict-20250918-184311-TFDLWFG.ts → app-config/get-app-port.test.d.ts} +0 -0
  122. /package/@types/{crud-field-snippets.d.sync-conflict-20250918-184323-TFDLWFG.ts → app-config/load-app-config.test.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ export declare function getAppPort(projectDir: string): Promise<number | null>;
@@ -0,0 +1,4 @@
1
+ export type AppConfigModule = {
2
+ PORT?: number;
3
+ };
4
+ export declare function loadAppConfigModule(projectDir: string): Promise<AppConfigModule | null>;
@@ -0,0 +1 @@
1
+ export declare function resolveAppConfigModulePath(projectDir: string): string;
@@ -1,5 +1,5 @@
1
1
  import { Context } from "koa";
2
- import { Field as SealiousField, FieldTypes as SealiousFieldTypes, FieldsetInput } from "sealious";
2
+ import { Field as SealiousField, FieldTypes as SealiousFieldTypes } from "sealious";
3
3
  import { FormDataValue } from "../form-types.js";
4
4
  import { Table as TableControl } from "../controls/table.js";
5
5
  import { SealiousToFormField } from "./get-field-for-sealious.js";
@@ -18,6 +18,6 @@ export declare class StructuredArray<SealiousFields extends Record<string, Seali
18
18
  form_field_types: string;
19
19
  sealious_field: string;
20
20
  }): string;
21
- getSealiousCreateValue(fctx: FormControlContext): Promise<SealiousFieldTypes.ArrayStorageInput<FieldsetInput<SealiousFields>>>;
21
+ getSealiousCreateValue(fctx: FormControlContext): Promise<import("./table.js").TableFieldParsed<{ [name in keyof SealiousFields]: SealiousToFormField<SealiousFields[name]>; }>>;
22
22
  sealiousValueToForm(ctx: Context, sealiousValue: Record<string, FormDataValue | null>[] | null): Promise<FormDataValue>;
23
23
  }
@@ -1,3 +1,4 @@
1
1
  import { Context } from "koa";
2
2
  import { Translation } from "sealious";
3
- export declare function t(ctx: Context, key: string, props: unknown[], default_translation: Translation): string;
3
+ /** deprecated */
4
+ export declare function t(ctx: Context, key: string, _props: unknown[], _default_translation: Translation): string;
@@ -30,6 +30,7 @@ class Tickable extends FormFieldControl {
30
30
  fctx.data.raw_values,
31
31
  true
32
32
  );
33
+ const field_message = fctx.data.field_messages[this.field.name];
33
34
  const parsed = _parsed === null ? this.options.default_value : _parsed;
34
35
  const value = this.getValueAttribute(
35
36
  fctx.ctx,
@@ -72,7 +73,7 @@ class Tickable extends FormFieldControl {
72
73
  })();
73
74
  </script>
74
75
 
75
- ${~valid && !this.options.hide_errors && fctx.validate ? `<div class="input__error">${message}</div>` : ""}
76
+ ${(~valid || !!field_message) && !this.options.hide_errors && fctx.validate ? `<div class="input__error">${Array.from(new Set([message, field_message.message].filter((e) => !!e))).join(" \u2022 ")}</div>` : ""}
76
77
  `
77
78
  );
78
79
  }
@@ -34,7 +34,8 @@ class CollectionField extends FormField {
34
34
  ctx.$context,
35
35
  value,
36
36
  void 0,
37
- null
37
+ null,
38
+ void 0
38
39
  );
39
40
  return { valid, message: reason || (!valid ? "Wrong value" : "") };
40
41
  }
package/lib/forms/form.js CHANGED
@@ -83,11 +83,16 @@ class Form extends MountableWithFields {
83
83
  }
84
84
  if (error instanceof SealiousErrors.FieldsError) {
85
85
  field_messages = Object.fromEntries(
86
- Object.entries(error.field_messages).map(([key, value]) => {
86
+ Object.entries(error.field_messages).filter(([key]) => key in this.fields).map(([key, value]) => {
87
87
  const message = value?.message || "";
88
88
  return [key, { type: "error", message }];
89
89
  })
90
90
  );
91
+ for (const [key, value] of Object.entries(error.field_messages)) {
92
+ if (!(key in this.fields)) {
93
+ error_message += " \xB7 " + value?.message;
94
+ }
95
+ }
91
96
  }
92
97
  const messages = [{ type: "error", text: error_message }];
93
98
  return {
@@ -70,8 +70,28 @@ async function generateRoutes() {
70
70
  ).replace(/\/\//g, "/")
71
71
  }))
72
72
  );
73
+ const url_tree = { children: {} };
74
+ sortRoutes(files).forEach(({ actionName, url }) => {
75
+ const elements = url.split("/").filter((e) => e != "");
76
+ let pointer = url_tree;
77
+ for (const [index, element] of elements.entries()) {
78
+ if (!pointer.children[element]) {
79
+ pointer.children[element] = { children: {} };
80
+ }
81
+ pointer = pointer.children[element];
82
+ if (index == elements.length - 1) {
83
+ pointer.actionName = actionName;
84
+ }
85
+ }
86
+ });
73
87
  const routes_content = `// DO NOT EDIT! This file is generated automaticaly with npm run generate-routes
74
88
 
89
+ export type URLTree = {
90
+ actionName?: string;
91
+ children: { [key: string]: URLTree };
92
+ };
93
+ export const url_tree = ${JSON.stringify(url_tree)};
94
+
75
95
  import type Router from "@koa/router";
76
96
  import { mount } from "@sealcode/sealgen";
77
97
  import * as URLs from "./urls.js"
@@ -88,7 +108,9 @@ ${sortRoutes(files).map(
88
108
  ({ actionName }) => ` mount(router, URLs.${actionName}URL, ${actionName});`
89
109
  ).join("\n")}
90
110
  }`;
91
- const urls_content = `${sortRoutes(files).map(({ actionName, url }) => generateURL(actionName, url)).join("\n")}
111
+ const urls_content = `/* DO NOT EDIT! This file is generated automaticall with npm run generate-routes. */
112
+
113
+ ${sortRoutes(files).map(({ actionName, url }) => generateURL(actionName, url)).join("\n")}
92
114
  `;
93
115
  await fs.writeFile(
94
116
  target_locreq.resolve("src/back/routes/routes.ts"),
@@ -1,9 +1,9 @@
1
- function t(ctx, key, props, default_translation) {
1
+ function t(ctx, key, _props, _default_translation) {
2
2
  return (
3
3
  /* HTML */
4
- `<span translation-key="${key.replace('"', '\\"')}"
5
- >${ctx.$app.getString(key, props, default_translation)}</span
6
- >`
4
+ `<span translation-key="${key.replace('"', '\\"')}">
5
+ ${ctx.i18n`${key}`}
6
+ </span>`
7
7
  );
8
8
  }
9
9
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.19.15",
3
+ "version": "0.19.17",
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.29",
95
+ "sealious": "^0.21.36",
96
96
  "stimulus": "^3.2.2"
97
97
  }
98
98
  }
@@ -74,6 +74,7 @@ export abstract class Tickable<T> extends FormFieldControl {
74
74
  fctx.data.raw_values,
75
75
  true
76
76
  );
77
+ const field_message = fctx.data.field_messages[this.field.name];
77
78
  const parsed = _parsed === null ? this.options.default_value : _parsed;
78
79
 
79
80
  const value = this.getValueAttribute(
@@ -83,9 +84,9 @@ export abstract class Tickable<T> extends FormFieldControl {
83
84
  );
84
85
  const id = this.makeInputID(fctx.ctx, fctx.data.raw_values, parsed);
85
86
  const label =
86
- this.options.label != undefined
87
- ? this.options.label
88
- : this.field.name;
87
+ this.options.label != undefined ?
88
+ this.options.label
89
+ : this.field.name;
89
90
 
90
91
  const readonly = this.options.readonly || false;
91
92
  const required = this.field.required;
@@ -102,9 +103,9 @@ export abstract class Tickable<T> extends FormFieldControl {
102
103
  this.field.name}"
103
104
  ${value ? `value="${attribute(value)}"` : ""}
104
105
  ${fctx.form_id ? `form="${fctx.form_id}"` : ""}
105
- ${this.isChecked(fctx.ctx, fctx.data.raw_values, parsed)
106
- ? "checked"
107
- : ""}
106
+ ${this.isChecked(fctx.ctx, fctx.data.raw_values, parsed) ?
107
+ "checked"
108
+ : ""}
108
109
  ${readonly ? "readonly" : ""}
109
110
  ${required ? "required" : ""}
110
111
  autocomplete="off"
@@ -127,9 +128,13 @@ export abstract class Tickable<T> extends FormFieldControl {
127
128
  })();
128
129
  </script>
129
130
 
130
- ${~valid && !this.options.hide_errors && fctx.validate
131
- ? `<div class="input__error">${message}</div>`
132
- : ""}
131
+ ${(
132
+ (~valid || !!field_message) &&
133
+ !this.options.hide_errors &&
134
+ fctx.validate
135
+ ) ?
136
+ `<div class="input__error">${Array.from(new Set([message, field_message.message].filter((e) => !!e))).join(" • ")}</div>`
137
+ : ""}
133
138
  `
134
139
  );
135
140
  }
@@ -58,7 +58,8 @@ export class CollectionField<
58
58
  ctx.$context,
59
59
  value,
60
60
  undefined,
61
- null
61
+ null,
62
+ undefined
62
63
  );
63
64
  return { valid, message: reason || (!valid ? "Wrong value" : "") };
64
65
  }
@@ -7,7 +7,6 @@ import { Context } from "koa";
7
7
  import {
8
8
  Field as SealiousField,
9
9
  FieldTypes as SealiousFieldTypes,
10
- FieldsetInput,
11
10
  } from "sealious";
12
11
  import { FormDataValue } from "../form-types.js";
13
12
  import { Table as TableControl } from "../controls/table.js";
@@ -74,20 +73,12 @@ export class StructuredArray<
74
73
  return `new ${vars.form_field_types}.${this.constructor.name}(${vars.sealious_field})`;
75
74
  }
76
75
 
77
- async getSealiousCreateValue(
78
- fctx: FormControlContext
79
- ): Promise<
80
- SealiousFieldTypes.ArrayStorageInput<FieldsetInput<SealiousFields>>
81
- > {
76
+ async getSealiousCreateValue(fctx: FormControlContext) {
82
77
  const { parsed } = await this.getParsedValue(
83
78
  fctx.ctx,
84
79
  fctx.data.raw_values
85
80
  );
86
- return (
87
- (parsed as SealiousFieldTypes.ArrayStorageInput<
88
- FieldsetInput<SealiousFields>
89
- >) || this.getEmptyValue()
90
- );
81
+ return parsed || this.getEmptyValue();
91
82
  }
92
83
 
93
84
  async sealiousValueToForm(
package/src/forms/form.ts CHANGED
@@ -136,11 +136,18 @@ export abstract class Form<
136
136
  }
137
137
  if (error instanceof SealiousErrors.FieldsError) {
138
138
  field_messages = Object.fromEntries(
139
- Object.entries(error.field_messages).map(([key, value]) => {
140
- const message = value?.message || "";
141
- return [key, { type: "error", message }];
142
- })
139
+ Object.entries(error.field_messages)
140
+ .filter(([key]) => key in this.fields)
141
+ .map(([key, value]) => {
142
+ const message = value?.message || "";
143
+ return [key, { type: "error", message }];
144
+ })
143
145
  );
146
+ for (const [key, value] of Object.entries(error.field_messages)) {
147
+ if (!(key in this.fields)) {
148
+ error_message += " · " + value?.message;
149
+ }
150
+ }
144
151
  }
145
152
  const messages = [<const>{ type: "error", text: error_message }];
146
153
  return {
@@ -35,9 +35,9 @@ export function generateURL(actionName: string, url: string) {
35
35
  .map((s) => s + ": string")
36
36
  .join(", ")})=>\`${parts
37
37
  .map((part) =>
38
- part.startsWith(":")
39
- ? "${" + part.slice(1) + "}"
40
- : encodeURIComponent(part)
38
+ part.startsWith(":") ?
39
+ "${" + part.slice(1) + "}"
40
+ : encodeURIComponent(part)
41
41
  )
42
42
  .join("/")}\`;
43
43
  ${actionName}URL.params = [${params
@@ -86,9 +86,9 @@ export async function generateRoutes(): Promise<void> {
86
86
  target_locreq.resolve("src/back/routes"),
87
87
  resolve(
88
88
  fullpath,
89
- basename(fullpath).startsWith("index.")
90
- ? "../"
91
- : ""
89
+ basename(fullpath).startsWith("index.") ?
90
+ "../"
91
+ : ""
92
92
  )
93
93
  ).replace(/\..+/, "") +
94
94
  "/"
@@ -96,8 +96,35 @@ export async function generateRoutes(): Promise<void> {
96
96
  }))
97
97
  );
98
98
 
99
+ type URLTree = {
100
+ actionName?: string;
101
+ children: { [key: string]: URLTree };
102
+ };
103
+
104
+ const url_tree: URLTree = { children: {} };
105
+ sortRoutes(files).forEach(({ actionName, url }) => {
106
+ const elements = url.split("/").filter((e) => e != "");
107
+ let pointer: URLTree = url_tree;
108
+ for (const [index, element] of elements.entries()) {
109
+ if (!pointer.children[element]) {
110
+ pointer.children[element] = { children: {} };
111
+ }
112
+ pointer = pointer.children[element];
113
+ if (index == elements.length - 1) {
114
+ (pointer as unknown as { actionName: string }).actionName =
115
+ actionName;
116
+ }
117
+ }
118
+ });
119
+
99
120
  const routes_content = `// DO NOT EDIT! This file is generated automaticaly with npm run generate-routes
100
121
 
122
+ export type URLTree = {
123
+ actionName?: string;
124
+ children: { [key: string]: URLTree };
125
+ };
126
+ export const url_tree = ${JSON.stringify(url_tree)};
127
+
101
128
  import type Router from "@koa/router";
102
129
  import { mount } from "@sealcode/sealgen";
103
130
  import * as URLs from "./urls.js"
@@ -121,9 +148,11 @@ ${sortRoutes(files)
121
148
  .join("\n")}
122
149
  }`;
123
150
 
124
- const urls_content = `${sortRoutes(files)
125
- .map(({ actionName, url }) => generateURL(actionName, url))
126
- .join("\n")}
151
+ const urls_content = `/* DO NOT EDIT! This file is generated automaticall with npm run generate-routes. */
152
+
153
+ ${sortRoutes(files)
154
+ .map(({ actionName, url }) => generateURL(actionName, url))
155
+ .join("\n")}
127
156
  `;
128
157
 
129
158
  await fs.writeFile(
@@ -1,13 +1,15 @@
1
+ /* eslint @typescript-eslint/no-unsafe-call: off, @typescript-eslint/no-unnecessary-type-assertion: off */
1
2
  import { Context } from "koa";
2
3
  import { Translation } from "sealious";
3
4
 
5
+ /** deprecated */
4
6
  export function t(
5
7
  ctx: Context,
6
8
  key: string,
7
- props: unknown[],
8
- default_translation: Translation
9
+ _props: unknown[],
10
+ _default_translation: Translation
9
11
  ) {
10
- return /* HTML */ `<span translation-key="${key.replace('"', '\\"')}"
11
- >${ctx.$app.getString(key, props, default_translation)}</span
12
- >`;
12
+ return /* HTML */ `<span translation-key="${key.replace('"', '\\"')}">
13
+ ${ctx.i18n`${key}`}
14
+ </span>`;
13
15
  }
package/.xunit DELETED
@@ -1,75 +0,0 @@
1
- <testsuite name="Mocha Tests" tests="73" failures="0" errors="0" skipped="0" timestamp="Sun, 21 Sep 2025 18:00:04 GMT" time="312.378">
2
- <testcase classname="single-reference" name="creates an item list page with working partial string search for text fields" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/add-list-route.test.js" time="26.145"/>
3
- <testcase classname="add route test" name="creates minimal sealious app and adds a simple route that works" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/add-route.test.js" time="20.509"/>
4
- <testcase classname="empty test" name="empty test" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/example.test.js" time="0"/>
5
- <testcase classname="checkboxed-list basic tests" name="sends the values" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.484"/>
6
- <testcase classname="checkboxed-list basic tests" name="renders the label" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.375"/>
7
- <testcase classname="checkboxed-list basic tests" name="groups checkboxes based on the value of the &#x27;group&#x27; attribute" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.57"/>
8
- <testcase classname="checkboxed-list basic tests behavior with (non)required" name="allows to send a form when no value is selected and fiels is not required" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.454"/>
9
- <testcase classname="checkboxed-list basic tests behavior with (non)required" name="does not allow to send a form when no value is selected and field IS required" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.559"/>
10
- <testcase classname="checkboxed-list basic tests behavior with (non)required" name="allows to send a form when no value is selected and field IS required" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.562"/>
11
- <testcase classname="file-control basic tests" name="doesn&#x27;t require image input if it already has old-value" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/file.test.js" time="0.537"/>
12
- <testcase classname="photo-control basic tests" name="sends the old photo if it wasn&#x27;t changed and it has an initial value" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/image.test.js" time="0.472"/>
13
- <testcase classname="photo-control basic tests" name="doesn&#x27;t require image input if it already has old-value" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/image.test.js" time="0.515"/>
14
- <testcase classname="single-reference.test" name="creates minimal sealious app and adds form using single-reference field that works" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/single-reference.test.js" time="28.324"/>
15
- <testcase classname="boolean field" name="validation logic" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/boolean.test.js" time="0"/>
16
- <testcase classname="boolean field" name="parse function" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/boolean.test.js" time="0.001"/>
17
- <testcase classname="email field" name="validation logic" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/email.test.js" time="0.001"/>
18
- <testcase classname="email field" name="parse function" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/email.test.js" time="0"/>
19
- <testcase classname="basic field basic tests" name="sends the values" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/field.test.js" time="0.331"/>
20
- <testcase classname="basic field basic tests" name="Doesn&#x27;t call &#x60;isValueValid&#x60; and &#x60;parse&#x60; if the value is empty" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/field.test.js" time="0.47"/>
21
- <testcase classname="basic field basic tests" name="Accepts a form where non-required values are empty" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/field.test.js" time="0.546"/>
22
- <testcase classname="file field" name="should handle as imple upload scenario" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/file.test.js" time="0.487"/>
23
- <testcase classname="number field" name="validation logic" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/number.test.js" time="0.001"/>
24
- <testcase classname="number field" name="parse function" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/number.test.js" time="0"/>
25
- <testcase classname="pick-from-list field" name="validation logic" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/pick-from-list.test.js" time="0.001"/>
26
- <testcase classname="regexp field" name="validation logic" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/regexp.test.js" time="0"/>
27
- <testcase classname="regexp field" name="parse function" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/regexp.test.js" time="0"/>
28
- <testcase classname="form test basic tests" name="does not allow to submit an empty form when there&#x27;s a required field" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.621"/>
29
- <testcase classname="form test basic tests" name="allows to submit a form when all required fields have a value" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.202"/>
30
- <testcase classname="form test basic tests" name="does not allow submitting an empty form by circumventing HTML-based validation" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.026"/>
31
- <testcase classname="form test canAccess tests" name="allows visit when configured when canAccess returns true" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.02"/>
32
- <testcase classname="form test canAccess tests" name="passes the context to canAccess (false case)" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.017"/>
33
- <testcase classname="form test canAccess tests" name="passes the context to canAccess (true case)" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.019"/>
34
- <testcase classname="form test canAccess tests declines access when canAccess returns false" name="prevents the form from rendering" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.014"/>
35
- <testcase classname="form test canAccess tests declines access when canAccess returns false" name="does not allow submitting of the form through axios" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.004"/>
36
- <testcase classname="form test validation e2e validation message" name="shows up when incorrect input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.267"/>
37
- <testcase classname="form test validation e2e validation message" name="doesn&#x27;t show when correct input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.643"/>
38
- <testcase classname="form test validation e2e field specific validation message" name="shows up when incorrect input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.242"/>
39
- <testcase classname="form test validation e2e field specific validation message" name="doesn&#x27;t show up when correct input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.135"/>
40
- <testcase classname="form test getInitialValues tests" name="fills the form with values from getInitialValues" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.058"/>
41
- <testcase classname="multiform test basic tests turbolinks + js enabled" name="checking whether only one submit handler is run" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.595"/>
42
- <testcase classname="multiform test basic tests turbolinks + js enabled" name="checking whether the input in the not submitted form prevails" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.007"/>
43
- <testcase classname="multiform test basic tests turbolinks + js disabled" name="checking whether only one submit handler is run" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.577"/>
44
- <testcase classname="multiform test basic tests turbolinks + js disabled" name="checking whether the input in the not submitted form prevails" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.008"/>
45
- <testcase classname="multiform test canAccess allow access to both forms when both canAccess return true" name="check wether it renders" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="1.023"/>
46
- <testcase classname="multiform test canAccess allow access to both forms when both canAccess return true" name="check wether you can submit through http (axios)" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.007"/>
47
- <testcase classname="multiform test canAccess deny access to both forms" name="check wether forms didnt render" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.481"/>
48
- <testcase classname="multiform test canAccess deny access to both forms" name="check wether it&#x27;s possible to submit through http" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.008"/>
49
- <testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether form1 renders" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.535"/>
50
- <testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether it&#x27;s possible to submit to form1 through http" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.003"/>
51
- <testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether form2 does not render" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.334"/>
52
- <testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether it&#x27;s possible to submit to form2 through http" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.003"/>
53
- <testcase classname="multiform test validation e2e basic tests" name="js enabled" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="1.319"/>
54
- <testcase classname="multiform test validation e2e basic tests" name="js disabled" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.948"/>
55
- <testcase classname="multiform test validation e2e field specific validation js enabled" name="validation message shows when incorrect input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.225"/>
56
- <testcase classname="multiform test validation e2e field specific validation js enabled" name="validation message doesn&#x27;t show when correct input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.127"/>
57
- <testcase classname="multiform test validation e2e field specific validation js disabled" name="validation message shows when incorrect input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.263"/>
58
- <testcase classname="multiform test validation e2e field specific validation js disabled" name="validation message doesn&#x27;t show when correct input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.134"/>
59
- <testcase classname="generate routes" name="handles a url with params" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/generate-routes.test.js" time="0.01"/>
60
- <testcase classname="generate routes" name="handles polish characters in the url" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/generate-routes.test.js" time="0.001"/>
61
- <testcase classname="generate routes" name="handles a url with params and diacritics" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/generate-routes.test.js" time="0.005"/>
62
- <testcase classname="generate routes" name="sorts routes from most specific first to least specific last, considering directory structure" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/generate-routes.test.js" time="0.001"/>
63
- <testcase classname="mountable-with-fields" name="properly types the getParsedValues method and respects required status" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/page/mountable-with-fields.test.js" time="0"/>
64
- <testcase classname="sealious-list test" name="creates minimal sealious app and adds a simple route that works" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/page/sealious-list.test.js" time="29.534"/>
65
- <testcase classname="stateful page" name="has types that allow for extracting action argument types" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/page/stateful-page.test.js" time="0"/>
66
- <testcase classname="stateful page" name="handles a basic case with action buttons" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/page/stateful-page.test.js" time="0"/>
67
- <testcase classname="register-external CLI commands package.json configuration" name="registers external controllers and verifies package.json is updated" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="19.565"/>
68
- <testcase classname="register-external CLI commands package.json configuration" name="registers external styles and verifies package.json is updated" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="17.792"/>
69
- <testcase classname="register-external CLI commands package.json configuration" name="registers both controllers and styles in the same project" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="22.799"/>
70
- <testcase classname="register-external CLI commands package.json configuration" name="handles duplicate registrations gracefully" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="22.786"/>
71
- <testcase classname="register-external CLI commands package.json configuration" name="preserves existing sealgen configuration when adding new entries" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="21.942"/>
72
- <testcase classname="register-external CLI commands build integration" name="registers external controllers and verifies they are included in build" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="22.953"/>
73
- <testcase classname="register-external CLI commands build integration" name="registers external styles and verifies they are included in build" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="29.347"/>
74
- <testcase classname="register-external CLI commands build integration" name="registers both external controllers and styles and verifies complete build integration" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="29.435"/>
75
- </testsuite>
@@ -1,3 +0,0 @@
1
- export declare function addVerboseCRUD(params: Partial<{
2
- [key in "collection" | "url"]: string;
3
- }>, app_directory?: string): Promise<void>;
@@ -1,10 +0,0 @@
1
- import { Builder } from "./builder.js";
2
- export declare const COLORS_TS_PATH = "src/back/colors.ts";
3
- export declare const COLORS_CSS_PATH = "src/colors.css";
4
- export declare const COLORS_HTML_PATH = "public/dist/colors.html";
5
- export declare class ColorsBuilder extends Builder {
6
- getName(): string;
7
- ownsFile(file_path: string): file_path is "src/back/colors.ts";
8
- dispose(): Promise<void>;
9
- _build(): Promise<void>;
10
- }
@@ -1,7 +0,0 @@
1
- import { Builder } from "./builder.js";
2
- export declare class FontsBuilder extends Builder {
3
- getName(): string;
4
- ownsFile(file_path: string): file_path is "src/fonts.json";
5
- dispose(): Promise<void>;
6
- _build(): Promise<void>;
7
- }
@@ -1,6 +0,0 @@
1
- import { Controller } from "stimulus";
2
- export default class extends Controller {
3
- static targets: string[];
4
- defaultRowsNumber: number;
5
- addRow(): void;
6
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- import Router from "@koa/router";
2
- import { Context } from "koa";
3
- import { Field, FieldsetOutput } from "sealious";
4
- import { FormField } from "../fields/field.js";
5
- import { StructuredArray as StructuredArrayField } from "../fields/structured-array.js";
6
- import { FormDataValue } from "../form-types.js";
7
- import { FormControl, FormControlContext } from "./form-control.js";
8
- import { FormFieldControl } from "./form-field-control.js";
9
- export type UnboundControlStorage<F extends {
10
- new (...args: any): FormFieldControl;
11
- } = {
12
- new (...args: any): FormFieldControl;
13
- }> = [F, string, ConstructorParameters<F>];
14
- export declare function UnboundControl<F extends {
15
- new (...args: any): FormFieldControl;
16
- }>(controlClass: F, arbitrary_field_name: string, params: ConstructorParameters<F>["1"]): UnboundControlStorage;
17
- export declare class StructuredArray<Subfields extends Record<string, Field<any>>> extends FormFieldControl {
18
- field: StructuredArrayField<Subfields>;
19
- item_controls: Array<FormControl | UnboundControlStorage>;
20
- constructor(field: StructuredArrayField<Subfields>, item_controls: Array<FormControl | UnboundControlStorage>);
21
- getFrameID(): string;
22
- getInnerFormID(): string;
23
- getActionURL(form_id?: string, action?: Record<string, unknown>): string;
24
- getDefaultItemBody(): Promise<{}>;
25
- makeSubfield(_field_name: string): FormField;
26
- 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>[]>;
27
- renderItem(ctx: Context, form_id: string, item: FieldsetOutput<Subfields>, index: number): Promise<string>;
28
- getItems(ctx: Context, raw_values: Record<string, FormDataValue>): Promise<FieldsetOutput<Subfields>[]>;
29
- _render(ctx: Context, form_id: string, raw_values: Record<string, FormDataValue>): Promise<string>;
30
- render(fctx: FormControlContext): Promise<string>;
31
- getTargetItemID(ctx: Context): Promise<string>;
32
- mount(router: Router): void;
33
- }
@@ -1,33 +0,0 @@
1
- import Router from "@koa/router";
2
- import { Context } from "koa";
3
- import { Field, FieldsetOutput } from "sealious";
4
- import { FormField } from "../fields/field.js";
5
- import { StructuredArray as StructuredArrayField } from "../fields/structured-array.js";
6
- import { FormDataValue } from "../form-types.js";
7
- import { FormControl, FormControlContext } from "./form-control.js";
8
- import { FormFieldControl } from "./form-field-control.js";
9
- export type UnboundControlStorage<F extends {
10
- new (...args: any): FormFieldControl;
11
- } = {
12
- new (...args: any): FormFieldControl;
13
- }> = [F, string, ConstructorParameters<F>];
14
- export declare function UnboundControl<F extends {
15
- new (...args: any): FormFieldControl;
16
- }>(controlClass: F, arbitrary_field_name: string, params: ConstructorParameters<F>["1"]): UnboundControlStorage;
17
- export declare class StructuredArray<Subfields extends Record<string, Field<any>>> extends FormFieldControl {
18
- field: StructuredArrayField<Subfields>;
19
- item_controls: Array<FormControl | UnboundControlStorage>;
20
- constructor(field: StructuredArrayField<Subfields>, item_controls: Array<FormControl | UnboundControlStorage>);
21
- getFrameID(): string;
22
- getInnerFormID(): string;
23
- getActionURL(form_id?: string, action?: Record<string, unknown>): string;
24
- getDefaultItemBody(): Promise<{}>;
25
- makeSubfield(_field_name: string): FormField;
26
- 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>[]>;
27
- renderItem(ctx: Context, form_id: string, item: FieldsetOutput<Subfields>, index: number): Promise<string>;
28
- getItems(ctx: Context, raw_values: Record<string, FormDataValue>): Promise<FieldsetOutput<Subfields>[]>;
29
- _render(ctx: Context, form_id: string, raw_values: Record<string, FormDataValue>): Promise<string>;
30
- render(fctx: FormControlContext): Promise<string>;
31
- getTargetItemID(ctx: Context): Promise<string>;
32
- mount(router: Router): void;
33
- }
@@ -1,22 +0,0 @@
1
- import { Context } from "koa";
2
- import { PickFromListField } from "../fields/pick-from-list.js";
3
- import { FormControlContext } from "./form-control.js";
4
- import { SimpleInput } from "./simple-input.js";
5
- export declare class Autocomplete extends SimpleInput<string | null> {
6
- field: PickFromListField<boolean>;
7
- options: {
8
- id?: string;
9
- label?: string;
10
- placeholder?: string;
11
- };
12
- constructor(field: PickFromListField<boolean>, options: {
13
- id?: string;
14
- label?: string;
15
- placeholder?: string;
16
- });
17
- getListID(): string;
18
- getInputAttributes(fctx: FormControlContext): Promise<{
19
- list: string;
20
- }>;
21
- postInput(ctx: Context): Promise<string>;
22
- }