@sealcode/sealgen 0.19.0 → 0.19.2

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 (185) hide show
  1. package/@types/forms/fields/deep-reverse-single-reference-list.d.ts +1 -5
  2. package/@types/forms/fields/file.d.ts +1 -1
  3. package/@types/forms/fields/password.d.ts +1 -2
  4. package/@types/forms/fields/simple-form-field.d.ts +1 -1
  5. package/@types/forms/fields/single-reference.d.ts +1 -1
  6. package/@types/register-external.d.ts +2 -2
  7. package/@types/templates/form.d.ts +1 -3
  8. package/@types/templates/jdd-component.d.ts +1 -1
  9. package/@types/templates/page.d.ts +1 -1
  10. package/@types/templates/shared/shared-crud-form-fields.d.ts +1 -1
  11. package/@types/templates/templates.d.ts +1 -21
  12. package/eslint.config.mjs +56 -0
  13. package/lib/add-crud.js +1 -4
  14. package/lib/add-jdd-component.js +3 -3
  15. package/lib/add-route.js +2 -2
  16. package/lib/build.js +3 -3
  17. package/lib/builders/backend-ts-builder.js +0 -1
  18. package/lib/builders/colors-builder.js +11 -8
  19. package/lib/builders/fonts-builder.js +0 -1
  20. package/lib/builders/frontend-ts-builder.js +0 -1
  21. package/lib/cli.js +2 -2
  22. package/lib/components/tabs.js +36 -36
  23. package/lib/esbuild-plugins/rewrite-asset-imports.js +7 -10
  24. package/lib/forms/controls/array.js +5 -6
  25. package/lib/forms/controls/checkboxed-list-input.js +1 -2
  26. package/lib/forms/controls/checkboxed-list-input.test.js +6 -6
  27. package/lib/forms/controls/derived-frame.js +3 -3
  28. package/lib/forms/controls/dropdown.js +1 -2
  29. package/lib/forms/controls/file.test.js +1 -1
  30. package/lib/forms/controls/form-control.js +1 -1
  31. package/lib/forms/controls/image.test.js +2 -2
  32. package/lib/forms/controls/single-reference.test.js +1 -1
  33. package/lib/forms/controls/table.js +10 -15
  34. package/lib/forms/controls/textarea.js +1 -1
  35. package/lib/forms/fields/deep-reverse-single-reference-list.js +1 -1
  36. package/lib/forms/fields/field.test.js +3 -3
  37. package/lib/forms/fields/file.js +1 -1
  38. package/lib/forms/fields/file.test.js +1 -1
  39. package/lib/forms/fields/password.js +1 -1
  40. package/lib/forms/fields/simple-form-field.js +2 -1
  41. package/lib/forms/fields/single-reference.js +1 -1
  42. package/lib/forms/fields/structured-array.js +0 -2
  43. package/lib/forms/fields/table.js +1 -1
  44. package/lib/forms/form.js +0 -1
  45. package/lib/forms/form.test.js +2 -3
  46. package/lib/forms/multiform.js +6 -7
  47. package/lib/forms/multiform.test.js +2 -2
  48. package/lib/generate-collections.js +2 -3
  49. package/lib/generate-components.js +2 -3
  50. package/lib/generate-routes.js +3 -5
  51. package/lib/generate-routes.test.js +7 -16
  52. package/lib/generate-stimulus.js +4 -5
  53. package/lib/get-fonts.js +29 -27
  54. package/lib/make-env.js +1 -1
  55. package/lib/make-hidden-inputs.js +4 -4
  56. package/lib/mount.js +0 -1
  57. package/lib/notifier.js +3 -3
  58. package/lib/page/list.js +5 -7
  59. package/lib/page/mountable.js +0 -1
  60. package/lib/page/page.js +0 -1
  61. package/lib/register-external.js +4 -4
  62. package/lib/templates/form.js +1 -1
  63. package/lib/templates/jdd-component.js +1 -1
  64. package/lib/templates/jdd-editor.js +1 -1
  65. package/lib/templates/page.js +1 -1
  66. package/lib/templates/shared/collection-create-form.js +4 -5
  67. package/lib/templates/shared/collection-edit-form.js +4 -5
  68. package/lib/templates/shared/collection-list.js +2 -2
  69. package/lib/templates/shared/shared-crud-form-fields.js +3 -5
  70. package/lib/test_utils/exec_async.js +3 -3
  71. package/lib/test_utils/test-on-real-app.js +9 -11
  72. package/lib/utils/write-file.js +1 -1
  73. package/package.json +9 -8
  74. package/src/add-collection.ts +1 -3
  75. package/src/add-crud.ts +2 -7
  76. package/src/add-jdd-component.ts +4 -5
  77. package/src/add-route.ts +3 -6
  78. package/src/build.ts +3 -3
  79. package/src/builders/backend-ts-builder.ts +0 -1
  80. package/src/builders/builder.ts +4 -1
  81. package/src/builders/colors-builder.ts +11 -9
  82. package/src/builders/css-builder.ts +4 -1
  83. package/src/builders/fonts-builder.ts +0 -1
  84. package/src/builders/frontend-ts-builder.ts +0 -1
  85. package/src/cli.ts +2 -2
  86. package/src/components/tabs.ts +38 -37
  87. package/src/components/toggle-modal.ts +1 -1
  88. package/src/controllers/table-add-button.stimulus.ts +1 -1
  89. package/src/esbuild-plugins/rewrite-asset-imports.ts +7 -10
  90. package/src/forms/controls/array.ts +12 -16
  91. package/src/forms/controls/autocomplete.ts +1 -1
  92. package/src/forms/controls/big-radio-group.ts +2 -2
  93. package/src/forms/controls/checkbox-group.ts +1 -1
  94. package/src/forms/controls/checkboxed-list-input.test.ts +6 -6
  95. package/src/forms/controls/checkboxed-list-input.ts +18 -22
  96. package/src/forms/controls/derived-frame.ts +11 -10
  97. package/src/forms/controls/derived.ts +6 -5
  98. package/src/forms/controls/dropdown.ts +8 -11
  99. package/src/forms/controls/editable-collection-subset.ts +2 -1
  100. package/src/forms/controls/field-group.ts +1 -1
  101. package/src/forms/controls/file.test.ts +1 -1
  102. package/src/forms/controls/file.ts +4 -7
  103. package/src/forms/controls/form-control.ts +1 -1
  104. package/src/forms/controls/hidden-input.ts +1 -0
  105. package/src/forms/controls/html.ts +1 -0
  106. package/src/forms/controls/image.test.ts +2 -2
  107. package/src/forms/controls/image.ts +1 -1
  108. package/src/forms/controls/multiple-files.ts +5 -7
  109. package/src/forms/controls/multiple-images.ts +1 -1
  110. package/src/forms/controls/simple-input.ts +8 -4
  111. package/src/forms/controls/single-reference.test.ts +1 -1
  112. package/src/forms/controls/single-reference.ts +1 -1
  113. package/src/forms/controls/table.ts +16 -21
  114. package/src/forms/controls/textarea.ts +1 -1
  115. package/src/forms/controls/tickable.ts +0 -2
  116. package/src/forms/fields/boolean.ts +4 -1
  117. package/src/forms/fields/checkboxed-list.ts +1 -1
  118. package/src/forms/fields/collection-field.ts +5 -2
  119. package/src/forms/fields/color.ts +1 -1
  120. package/src/forms/fields/coordinates.ts +2 -2
  121. package/src/forms/fields/deep-reverse-single-reference-list.ts +2 -8
  122. package/src/forms/fields/deep-reverse-single-reference-table.ts +1 -1
  123. package/src/forms/fields/email.ts +1 -1
  124. package/src/forms/fields/enum-multiple-sealious.ts +1 -1
  125. package/src/forms/fields/existing-sealious-value.ts +1 -1
  126. package/src/forms/fields/field.test.ts +3 -3
  127. package/src/forms/fields/field.ts +6 -5
  128. package/src/forms/fields/file.test.ts +1 -1
  129. package/src/forms/fields/file.ts +2 -2
  130. package/src/forms/fields/float.ts +1 -1
  131. package/src/forms/fields/get-field-for-sealious.ts +97 -64
  132. package/src/forms/fields/int.ts +1 -1
  133. package/src/forms/fields/number.ts +2 -2
  134. package/src/forms/fields/password.ts +2 -6
  135. package/src/forms/fields/pick-from-list-sealious.ts +1 -1
  136. package/src/forms/fields/pick-from-list.ts +1 -1
  137. package/src/forms/fields/proxy-field.ts +1 -0
  138. package/src/forms/fields/simple-form-field.ts +13 -5
  139. package/src/forms/fields/single-reference.ts +2 -2
  140. package/src/forms/fields/structured-array.ts +2 -6
  141. package/src/forms/fields/table.ts +7 -15
  142. package/src/forms/fields/text.ts +1 -1
  143. package/src/forms/fields/url.ts +1 -1
  144. package/src/forms/form-types.ts +3 -4
  145. package/src/forms/form.test.ts +2 -3
  146. package/src/forms/form.ts +5 -7
  147. package/src/forms/multiform.test.ts +6 -6
  148. package/src/forms/multiform.ts +10 -10
  149. package/src/generate-collections.ts +2 -3
  150. package/src/generate-components.ts +2 -3
  151. package/src/generate-routes.test.ts +7 -16
  152. package/src/generate-routes.ts +6 -10
  153. package/src/generate-stimulus.ts +4 -6
  154. package/src/get-fonts.ts +32 -30
  155. package/src/make-env.ts +1 -1
  156. package/src/make-hidden-inputs.ts +8 -7
  157. package/src/mount.ts +2 -7
  158. package/src/notifier.ts +4 -6
  159. package/src/page/default-list-filters.ts +1 -0
  160. package/src/page/list.ts +18 -20
  161. package/src/page/mountable-with-fields.ts +3 -3
  162. package/src/page/mountable.ts +0 -1
  163. package/src/page/page.ts +2 -3
  164. package/src/page/props-parser.ts +1 -1
  165. package/src/page/sealious-list.ts +1 -1
  166. package/src/page/stateful-page.ts +6 -10
  167. package/src/register-external.ts +4 -4
  168. package/src/templates/form.ts +1 -2
  169. package/src/templates/jdd-component.ts +1 -1
  170. package/src/templates/jdd-editor.ts +2 -4
  171. package/src/templates/list.ts +0 -1
  172. package/src/templates/page.ts +1 -4
  173. package/src/templates/shared/collection-create-form.ts +5 -6
  174. package/src/templates/shared/collection-edit-form.ts +5 -6
  175. package/src/templates/shared/collection-list.ts +2 -2
  176. package/src/templates/shared/shared-crud-form-fields.ts +4 -9
  177. package/src/templates/templates.ts +5 -1
  178. package/src/test_utils/exec_async.ts +3 -4
  179. package/src/test_utils/test-on-real-app.ts +9 -11
  180. package/src/utils/browser-creator.js +0 -1
  181. package/src/utils/exec.ts +0 -1
  182. package/src/utils/input-wrapper.ts +1 -1
  183. package/src/utils/wrap-attributes.ts +1 -1
  184. package/src/utils/write-file.ts +1 -1
  185. package/.eslintrc.cjs +0 -44
@@ -17,7 +17,7 @@ export type DefaultCheckboxOptions = {
17
17
  };
18
18
 
19
19
  export class CheckboxGroup<
20
- Options extends DefaultCheckboxOptions = DefaultCheckboxOptions
20
+ Options extends DefaultCheckboxOptions = DefaultCheckboxOptions,
21
21
  > extends FormFieldControl {
22
22
  constructor(
23
23
  public field: CheckboxedListField<boolean, string>,
@@ -23,7 +23,7 @@ describe("checkboxed-list", () => {
23
23
 
24
24
  it("sends the values", async () => {
25
25
  const port = await getPort();
26
- console.log(`Using port ${port} form checkboxed-list-input.test.ts`);
26
+ console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
27
27
  const app = new Koa();
28
28
  const router = new Router();
29
29
 
@@ -71,7 +71,7 @@ describe("checkboxed-list", () => {
71
71
  describe("behavior with (non)required", () => {
72
72
  it("allows to send a form when no value is selected and fiels is not required", async () => {
73
73
  const port = await getPort();
74
- console.log(`Using port ${port} form checkboxed-list-input.test.ts`);
74
+ console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
75
75
  const app = new Koa();
76
76
  const router = new Router();
77
77
 
@@ -118,7 +118,7 @@ describe("checkboxed-list", () => {
118
118
 
119
119
  it("does not allow to send a form when no value is selected and field IS required", async () => {
120
120
  const port = await getPort();
121
- console.log(`Using port ${port} form checkboxed-list-input.test.ts`);
121
+ console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
122
122
  const app = new Koa();
123
123
  const router = new Router();
124
124
 
@@ -166,7 +166,7 @@ describe("checkboxed-list", () => {
166
166
 
167
167
  it("allows to send a form when no value is selected and field IS required", async () => {
168
168
  const port = await getPort();
169
- console.log(`Using port ${port} form checkboxed-list-input.test.ts`);
169
+ console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
170
170
  const app = new Koa();
171
171
  const router = new Router();
172
172
 
@@ -215,7 +215,7 @@ describe("checkboxed-list", () => {
215
215
 
216
216
  it("renders the label", async () => {
217
217
  const port = await getPort();
218
- console.log(`Using port ${port} form checkboxed-list-input.test.ts`);
218
+ console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
219
219
  const app = new Koa();
220
220
  const router = new Router();
221
221
 
@@ -258,7 +258,7 @@ describe("checkboxed-list", () => {
258
258
 
259
259
  it("groups checkboxes based on the value of the 'group' attribute", async () => {
260
260
  const port = await getPort();
261
- console.log(`Using port ${port} form checkboxed-list-input.test.ts`);
261
+ console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
262
262
  const app = new Koa();
263
263
  const router = new Router();
264
264
 
@@ -8,7 +8,7 @@ import { FormControlContext } from "./form-control.js";
8
8
  import { FormFieldControl } from "./form-field-control.js";
9
9
 
10
10
  export class CheckboxedListInput<
11
- Values extends string
11
+ Values extends string,
12
12
  > extends FormFieldControl {
13
13
  constructor(
14
14
  public field: CheckboxedListField<boolean, Values>,
@@ -54,7 +54,6 @@ export class CheckboxedListInput<
54
54
  if (!groups[option.group]) {
55
55
  groups[option.group] = [];
56
56
  }
57
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
58
57
  groups[option.group]!.push(option);
59
58
  }
60
59
  }
@@ -67,7 +66,7 @@ export class CheckboxedListInput<
67
66
  getRequiredClass(required),
68
67
  ...this.generateCountBasedClasses(options.length),
69
68
  ],
70
- tempstream/* HTML */ `<label
69
+ tempstream /* HTML */ `<label
71
70
  >${this.options.label || this.field.name}</label
72
71
  >
73
72
  ${~valid && fctx.validate
@@ -77,26 +76,23 @@ export class CheckboxedListInput<
77
76
  ${isVisible
78
77
  ? Object.entries(groups).map(
79
78
  ([group_label, options]) =>
80
- tempstream/* HTML */ ` <h3>
79
+ tempstream /* HTML */ ` <h3>
81
80
  ${group_label}
82
81
  </h3>
83
82
 
84
- ${
85
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
86
- options!.map(({ value, label }) =>
87
- this.renderOption({
88
- name,
89
- value,
90
- label,
91
- form_id: fctx.form_id,
92
- checked:
93
- pickedValues.includes(
94
- value
95
- ),
96
- })
97
- )
98
- }`
99
- )
83
+ ${options!.map(({ value, label }) =>
84
+ this.renderOption({
85
+ name,
86
+ value,
87
+ label,
88
+ form_id: fctx.form_id,
89
+ checked:
90
+ pickedValues.includes(
91
+ value
92
+ ),
93
+ })
94
+ )}`
95
+ )
100
96
  : ""}
101
97
  ${isVisible
102
98
  ? ungroupped.map(({ value, label }) =>
@@ -107,7 +103,7 @@ export class CheckboxedListInput<
107
103
  form_id: fctx.form_id,
108
104
  checked: pickedValues.includes(value),
109
105
  })
110
- )
106
+ )
111
107
  : ""}
112
108
  </ul>`
113
109
  );
@@ -126,7 +122,7 @@ export class CheckboxedListInput<
126
122
  label?: string;
127
123
  checked: boolean;
128
124
  }) {
129
- return tempstream/* HTML */ `<li>
125
+ return tempstream /* HTML */ `<li>
130
126
  ${inputWrapper(
131
127
  "checkbox",
132
128
  [name],
@@ -25,15 +25,16 @@ export class DerivedFrame extends Derived<{
25
25
  ) {
26
26
  super(
27
27
  fields,
28
- async (values, consts) => /* HTML */ `<turbo-frame
29
- id="${consts.frame_id}"
30
- src="./${consts.frame_id}?${Object.entries({
31
- ...consts,
32
- ...(values || {}),
33
- })
34
- .map(([key, value]) => `${key}=${value}`)
35
- .join("&")}"
36
- ></turbo-frame>`,
28
+ async (values, consts) =>
29
+ /* HTML */ `<turbo-frame
30
+ id="${consts.frame_id}"
31
+ src="./${consts.frame_id}?${Object.entries({
32
+ ...consts,
33
+ ...(values || {}),
34
+ })
35
+ .map(([key, value]) => `${key}=${value}`)
36
+ .join("&")}"
37
+ ></turbo-frame>`,
37
38
  async (fctx) => ({
38
39
  form_id: fctx.form_id,
39
40
  field_name_prefix: fctx.field_name_prefix,
@@ -44,7 +45,7 @@ export class DerivedFrame extends Derived<{
44
45
  }
45
46
 
46
47
  renderBackendResponseFrame(_ctx: Context, content: FlatTemplatable) {
47
- return tempstream/* HTML */ `<turbo-frame
48
+ return tempstream /* HTML */ `<turbo-frame
48
49
  id="${this.frame_id}"
49
50
  target="_top"
50
51
  >
@@ -1,3 +1,4 @@
1
+ /* eslint @typescript-eslint/no-redundant-type-constituents: off */
1
2
  import { randomUUID } from "crypto";
2
3
  import { FlatTemplatable, tempstream } from "tempstream";
3
4
  import { FormField } from "../fields/field.js";
@@ -5,7 +6,7 @@ import { FormDataValue } from "../form-types.js";
5
6
  import { FormControl, FormControlContext } from "./form-control.js";
6
7
 
7
8
  export class Derived<
8
- Consts extends Record<string, unknown | undefined>
9
+ Consts extends Record<string, unknown | undefined>,
9
10
  > extends FormControl {
10
11
  role = <const>"decoration";
11
12
 
@@ -17,7 +18,7 @@ export class Derived<
17
18
  ) => Promise<FlatTemplatable>,
18
19
  public getConsts: (
19
20
  fctx: FormControlContext
20
- ) => Promise<Consts> = async () => ({} as Consts)
21
+ ) => Promise<Consts> = async () => ({}) as Consts
21
22
  ) {
22
23
  super();
23
24
  }
@@ -44,7 +45,7 @@ export class Derived<
44
45
  `render(${values_code}, consts)
45
46
  .then(result=>document.querySelector("#${id}").innerHTML=result)`;
46
47
 
47
- return tempstream/* HTML */ `<div>
48
+ return tempstream /* HTML */ `<div>
48
49
  <script>
49
50
  (function () {
50
51
  const consts = ${"{" +
@@ -54,8 +55,8 @@ export class Derived<
54
55
  typeof value === "object"
55
56
  ? JSON.stringify(value)
56
57
  : typeof value == "string"
57
- ? '"' + value.toString() + '"'
58
- : (value as string).toString()
58
+ ? '"' + value.toString() + '"'
59
+ : (value as string).toString()
59
60
  }`;
60
61
  })
61
62
  .join(",") +
@@ -46,7 +46,7 @@ export class FreeformDropdown extends SimpleInput {
46
46
  ((original.onchange as string | undefined) ||
47
47
  "") + ";this.form.submit();",
48
48
  ],
49
- ]
49
+ ]
50
50
  : []),
51
51
  ]),
52
52
  } as Record<string, string>;
@@ -62,17 +62,14 @@ export class FreeformDropdown extends SimpleInput {
62
62
  data
63
63
  );
64
64
  return /* HTML */ tempstream`<select ${attributes_str}>
65
- ${
66
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
67
- Promise.resolve(this.generateOptions(ctx)).then((options) =>
68
- options.map(
69
- ({ value, label }) =>
70
- `<option value="${attribute(value)}" ${
71
- (value || "") == picked_value ? "selected" : ""
72
- }>${label}</option>`
73
- )
65
+ ${Promise.resolve(this.generateOptions(ctx)).then((options) =>
66
+ options.map(
67
+ ({ value, label }) =>
68
+ `<option value="${attribute(value)}" ${
69
+ (value || "") == picked_value ? "selected" : ""
70
+ }>${label}</option>`
74
71
  )
75
- }
72
+ )}
76
73
  </select>`;
77
74
  }
78
75
  }
@@ -1,3 +1,4 @@
1
+ /* eslint @typescript-eslint/no-base-to-string: off */
1
2
  import { FlatTemplatable, tempstream } from "tempstream";
2
3
  import { attribute } from "../../sanitize.js";
3
4
  import { PickFromListField } from "../fields/pick-from-list.js";
@@ -27,7 +28,7 @@ export class EditableCollectionSubset extends FormFieldControl {
27
28
  fctx.data.raw_values
28
29
  );
29
30
 
30
- return tempstream/* HTML */ `<div>
31
+ return tempstream /* HTML */ `<div>
31
32
  <ul>
32
33
  ${Promise.resolve(this.field.generateOptions(fctx.ctx)).then(
33
34
  (options) =>
@@ -41,7 +41,7 @@ export class FieldGroup extends FormFieldControl {
41
41
  async render(fctx: FormControlContext): Promise<FlatTemplatable> {
42
42
  const { label, classes } = this.options;
43
43
 
44
- return tempstream/* HTML */ `
44
+ return tempstream /* HTML */ `
45
45
  <div
46
46
  class="field-group ${(classes || []).join(" ")}"
47
47
  ${this.options.containerID
@@ -27,7 +27,7 @@ describe("file-control", () => {
27
27
 
28
28
  it("doesn't require image input if it already has old-value", async () => {
29
29
  const port = await getPort();
30
- console.log(`Using port ${port} for image.test.ts`);
30
+ console.info(`Using port ${port} for image.test.ts`);
31
31
  const app = new Koa();
32
32
  const router = new Router();
33
33
 
@@ -1,7 +1,4 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
2
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
3
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
4
- /* eslint-disable @typescript-eslint/no-unsafe-call */
1
+ /* eslint @typescript-eslint/no-unsafe-assignment: off, @typescript-eslint/no-unsafe-argument: off, @typescript-eslint/no-unsafe-member-access: off, @typescript-eslint/no-unsafe-call: off */
5
2
  import { Context } from "koa";
6
3
  import { FilePointer, PathFilePointer } from "@sealcode/file-manager";
7
4
  import { FlatTemplatable, tempstream } from "tempstream";
@@ -27,7 +24,7 @@ export class File extends SimpleInput {
27
24
  }
28
25
  if (file instanceof PathFilePointer) {
29
26
  const filename = await file.getOriginalFilename();
30
- return tempstream/* HTML */ `<div class="${class_name}">
27
+ return tempstream /* HTML */ `<div class="${class_name}">
31
28
  <div class="${class_name}__icon">
32
29
  <picture>
33
30
  <img
@@ -44,7 +41,7 @@ export class File extends SimpleInput {
44
41
  </div>
45
42
  </div>`;
46
43
  }
47
- return tempstream/* HTML */ `<div class="${class_name}">
44
+ return tempstream /* HTML */ `<div class="${class_name}">
48
45
  ${file.getOriginalFilename()}
49
46
  </div>`;
50
47
  }
@@ -57,7 +54,7 @@ export class File extends SimpleInput {
57
54
  if (parsed === null) {
58
55
  parsed = { old: null, new: null };
59
56
  }
60
- return tempstream/* HTML */ `${this.renderFilePreview(
57
+ return tempstream /* HTML */ `${this.renderFilePreview(
61
58
  fctx.ctx,
62
59
  parsed.old
63
60
  )}
@@ -26,6 +26,6 @@ export abstract class FormControl {
26
26
  ): FlatTemplatable | Promise<FlatTemplatable>;
27
27
  abstract role: "input" | "decoration" | "messages" | "submit";
28
28
 
29
- // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
30
  mount(_router: Router, _form: Form<any, any>) {}
31
31
  }
@@ -1,3 +1,4 @@
1
+ /* eslint @typescript-eslint/no-base-to-string: off */
1
2
  import { FlatTemplatable, tempstream } from "tempstream";
2
3
  import { attribute } from "../../sanitize.js";
3
4
  import { FormField } from "../fields/field.js";
@@ -12,6 +12,7 @@ export class HTML extends FormControl {
12
12
  constructor(role: "decoration" | "submit", renderer: Renderer);
13
13
  constructor(renderer: Renderer);
14
14
  constructor(
15
+ // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
15
16
  role_or_renderer: "decoration" | "submit" | Renderer,
16
17
  renderer_or_undefined?: Renderer | FlatTemplatable
17
18
  ) {
@@ -27,7 +27,7 @@ describe("photo-control", () => {
27
27
 
28
28
  it("sends the old photo if it wasn't changed and it has an initial value", async () => {
29
29
  const port = await getPort();
30
- console.log(`Using port ${port} for photo.test.ts`);
30
+ console.info(`Using port ${port} for photo.test.ts`);
31
31
  const app = new Koa();
32
32
  const router = new Router();
33
33
 
@@ -78,7 +78,7 @@ describe("photo-control", () => {
78
78
 
79
79
  it("doesn't require image input if it already has old-value", async () => {
80
80
  const port = await getPort();
81
- console.log(`Using port ${port} for photo.test.ts`);
81
+ console.info(`Using port ${port} for photo.test.ts`);
82
82
  const app = new Koa();
83
83
  const router = new Router();
84
84
 
@@ -28,7 +28,7 @@ export class Image extends File {
28
28
  if (!file) {
29
29
  return empty_container;
30
30
  }
31
- return tempstream/* HTML */ `<div class="${class_name}">
31
+ return tempstream /* HTML */ `<div class="${class_name}">
32
32
  ${ctx.$app.imageRouter.image(await file.getPath(), {
33
33
  resolutions: [100, 200],
34
34
  sizesAttr: "100px",
@@ -105,7 +105,7 @@ export class MultipleFiles extends FormFieldControl {
105
105
  }
106
106
 
107
107
  renderFrame(_ctx: Context, content?: FlatTemplatable) {
108
- return tempstream/* HTML */ `<turbo-frame
108
+ return tempstream /* HTML */ `<turbo-frame
109
109
  ${content ? "" : `src="./${this.getFrameRelativeURL()}"`}
110
110
  id="${this.getFrameID()}"
111
111
  target="_top"
@@ -168,7 +168,7 @@ export class MultipleFiles extends FormFieldControl {
168
168
  if (!(file instanceof PathFilePointer)) {
169
169
  return "";
170
170
  }
171
- return tempstream/* HTML */ `<li class="file-list-item">
171
+ return tempstream /* HTML */ `<li class="file-list-item">
172
172
  <a
173
173
  class="file-list-item__preview"
174
174
  href="${file.getURL()}"
@@ -215,9 +215,7 @@ export class MultipleFiles extends FormFieldControl {
215
215
  async renderFrameContent(ctx: Context): Promise<FlatTemplatable> {
216
216
  const files = (
217
217
  await Promise.all(
218
- (
219
- await this.getFileItems(ctx)
220
- )
218
+ (await this.getFileItems(ctx))
221
219
  .filter((item) => item) // filter out undefineds
222
220
  .map(async (item: CollectionItem<Collection>) => [
223
221
  item,
@@ -226,13 +224,13 @@ export class MultipleFiles extends FormFieldControl {
226
224
  )
227
225
  ).filter(([_, f]) => f !== null) as [
228
226
  CollectionItem<Collection>,
229
- FilePointer
227
+ FilePointer,
230
228
  ][];
231
229
 
232
230
  return inputWrapper(
233
231
  "multiple-files",
234
232
  ["multiple-files", this.field.name, ...this.getClassModifiers()],
235
- tempstream/* HTML */ `
233
+ tempstream /* HTML */ `
236
234
  <label>${this.options.label || this.field.name}</label>
237
235
  <ul class="multiple-files__list">
238
236
  ${files.map(([item, file]) =>
@@ -33,7 +33,7 @@ export class MultipleImages extends MultipleFiles {
33
33
  if (!path) {
34
34
  return "missing file";
35
35
  }
36
- return tempstream/* HTML */ `<li>
36
+ return tempstream /* HTML */ `<li>
37
37
  <a href="${file.getURL()}" data-turbo="false">
38
38
  ${this.imageRouter.image(path, {
39
39
  resolutions: [150, 300],
@@ -22,10 +22,14 @@ export type SimpleInputOptions = {
22
22
  };
23
23
 
24
24
  export class SimpleInput<
25
- Options extends SimpleInputOptions = SimpleInputOptions
25
+ Options extends SimpleInputOptions = SimpleInputOptions,
26
26
  > extends FormFieldControl {
27
27
  options: SimpleInputOptions;
28
- constructor(public field: FormField<boolean, any>, options?: Options) {
28
+ constructor(
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ public field: FormField<boolean, any>,
31
+ options?: Options
32
+ ) {
29
33
  super([field]);
30
34
  this.options = options || {};
31
35
  }
@@ -117,7 +121,7 @@ export class SimpleInput<
117
121
  return inputWrapper(
118
122
  "simple-input",
119
123
  this.getWrapperModifiers(),
120
- tempstream/* HTML */ `
124
+ tempstream /* HTML */ `
121
125
  ${label ? `<label for="${id}">${label}</label>` : ""}
122
126
  ${await this.preInput(fctx, fctx.data.raw_values)}
123
127
  ${this.renderInput(
@@ -131,7 +135,7 @@ export class SimpleInput<
131
135
  message,
132
136
  fctx.data.field_messages?.[this.field.name]
133
137
  ?.message,
134
- ]
138
+ ]
135
139
  .filter((e) => !!e)
136
140
  .join(" · ")}</div>`
137
141
  : ""}
@@ -39,7 +39,7 @@ describe("single-reference.test", () => {
39
39
  const form_file_path = "src/back/routes/some-form.form.ts";
40
40
  await test_app.addFile(
41
41
  form_file_path,
42
- await formTemplate("SomeForm", form_file_path, {
42
+ await formTemplate("SomeForm", {
43
43
  postimport: `import {Comments} from "../collections/collections.js"; import {Fields} from "@sealcode/sealgen";`,
44
44
  fields: `article: new Fields.CollectionField(true, Comments.fields.article),`,
45
45
  controls: `new Controls.SingleReferenceDropdown(fields.article, {getLabel: item=>item.get("title")}),`,
@@ -6,7 +6,7 @@ import { Collection, CollectionItem } from "sealious";
6
6
  export class SingleReferenceDropdown<
7
7
  TargetCollection extends Collection,
8
8
  F extends SealiousFieldTypes.SingleReference,
9
- Required extends boolean
9
+ Required extends boolean,
10
10
  > extends FreeformDropdown {
11
11
  constructor(
12
12
  public field: CollectionField<F, Required>,
@@ -77,7 +77,7 @@ export class Table<F extends Record<string, FormField>> extends FormControl {
77
77
  messages: [],
78
78
  field_messages: {},
79
79
  },
80
- }
80
+ }
81
81
  : {};
82
82
  };
83
83
 
@@ -92,25 +92,20 @@ export class Table<F extends Record<string, FormField>> extends FormControl {
92
92
  row_index: number | string
93
93
  ) => {
94
94
  return /* HTML */ tempstream`<tr>
95
- ${(
96
- await Promise.all(
97
- Object.entries(this.table_field.columns).map(
98
- ([column_name]) => {
99
- const inner_fctx = get_row_fctx(
100
- row,
101
- row_index
102
- );
103
- return tempstream`<td>${this.options.subfield_controls[
104
- column_name
105
- ].render({ ...fctx, ...inner_fctx })}</td>`;
106
- }
95
+ ${Promise.all(
96
+ Object.entries(this.table_field.columns)
97
+ .map(([column_name]) => {
98
+ const inner_fctx = get_row_fctx(row, row_index);
99
+ return tempstream`<td>${this.options.subfield_controls[
100
+ column_name
101
+ ].render({ ...fctx, ...inner_fctx })}</td>`;
102
+ })
103
+ .map(async (html) =>
104
+ (await html).replaceAll(
105
+ TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER,
106
+ row_index.toString()
107
+ )
107
108
  )
108
- )
109
- ).map((html) =>
110
- html.replaceAll(
111
- TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER,
112
- row_index.toString()
113
- )
114
109
  )}
115
110
  ${
116
111
  this.options.allow_removing
@@ -138,13 +133,13 @@ export class Table<F extends Record<string, FormField>> extends FormControl {
138
133
  )}"
139
134
  />
140
135
  </noscript>
141
- </td>`
136
+ </td>`
142
137
  : ""
143
138
  }
144
139
  </tr>`;
145
140
  };
146
141
 
147
- return tempstream/* HTML */ `<turbo-frame
142
+ return tempstream /* HTML */ `<turbo-frame
148
143
  id="${this.getFrameID()}"
149
144
  class="${[
150
145
  "form-input__wrapper",
@@ -22,7 +22,7 @@ export class Textarea extends SimpleInput {
22
22
  return this.options.description
23
23
  ? /* HTML */ `<div class="form-input__description">
24
24
  ${this.options.description}
25
- </div>`
25
+ </div>`
26
26
  : "";
27
27
  }
28
28
 
@@ -65,7 +65,6 @@ export abstract class Tickable<T> extends FormFieldControl {
65
65
  }
66
66
 
67
67
  async render(fctx: FormControlContext): Promise<FlatTemplatable> {
68
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
69
68
  const {
70
69
  parsed: _parsed,
71
70
  valid,
@@ -88,7 +87,6 @@ export abstract class Tickable<T> extends FormFieldControl {
88
87
  ? this.options.label
89
88
  : this.field.name;
90
89
 
91
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
92
90
  const readonly = this.options.readonly || false;
93
91
  const required = this.field.required;
94
92
 
@@ -14,7 +14,10 @@ export class Boolean<Required extends boolean> extends FormField<
14
14
  Checkbox
15
15
  > {
16
16
  predicate = predicates.boolean;
17
- constructor(required: Required, public error_message: string = "") {
17
+ constructor(
18
+ required: Required,
19
+ public error_message: string = ""
20
+ ) {
18
21
  super(required);
19
22
  }
20
23
 
@@ -16,7 +16,7 @@ export type CheckboxedListItem = {
16
16
 
17
17
  export class CheckboxedListField<
18
18
  Required extends boolean,
19
- Values extends string
19
+ Values extends string,
20
20
  > extends FormField<
21
21
  Required,
22
22
  Record<Values, "on">,
@@ -14,9 +14,12 @@ import { ExtractedFieldInfo } from "../../utils/extract-fields-from-collection.j
14
14
  export class CollectionField<
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  F extends Field<any>,
17
- Required extends boolean
17
+ Required extends boolean,
18
18
  > extends FormField<Required, ExtractFieldDecoded<F> | null, SimpleInput> {
19
- constructor(required: Required, public sealiousField: F) {
19
+ constructor(
20
+ required: Required,
21
+ public sealiousField: F
22
+ ) {
20
23
  super(required);
21
24
  }
22
25
 
@@ -1,7 +1,7 @@
1
1
  import { TextBasedSimpleField } from "./simple-form-field.js";
2
2
 
3
3
  export class Color<
4
- Required extends boolean
4
+ Required extends boolean,
5
5
  > extends TextBasedSimpleField<Required> {
6
6
  constructor(required: Required) {
7
7
  super(required, "color");
@@ -7,7 +7,7 @@ import { SimpleFormField } from "./simple-form-field.js";
7
7
 
8
8
  export class Coordinates<
9
9
  Required extends boolean,
10
- DefaultControl extends FormControl = SimpleInput
10
+ DefaultControl extends FormControl = SimpleInput,
11
11
  > extends SimpleFormField<Required, DefaultControl, [number, number]> {
12
12
  async parse(
13
13
  _: Context,
@@ -26,7 +26,7 @@ export class Coordinates<
26
26
  return {
27
27
  parsed_value: raw_value.map((e) => parseFloat(e)) as [
28
28
  number,
29
- number
29
+ number,
30
30
  ],
31
31
  parsable: true,
32
32
  error: null,