@sealcode/sealgen 0.19.28 → 0.19.30

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,4 @@
1
1
  export * from "./autocomplete.js";
2
- export * from "./big-radio-group.js";
3
2
  export * from "./checkbox-group.js";
4
3
  export * from "./checkbox.js";
5
4
  export { CheckboxedListInput } from "./checkboxed-list-input.js";
@@ -161,10 +161,7 @@ class StructuredArray extends FormFieldControl {
161
161
  ctx.body = this._render(
162
162
  ctx,
163
163
  form_id,
164
- await item.getDecodedBody(
165
- ctx.$context,
166
- {}
167
- )
164
+ await item.getDecodedBody(ctx.$context)
168
165
  );
169
166
  });
170
167
  }
@@ -1,5 +1,4 @@
1
1
  export * from "./autocomplete.js";
2
- export * from "./big-radio-group.js";
3
2
  export * from "./checkbox-group.js";
4
3
  export * from "./checkbox.js";
5
4
  import { CheckboxedListInput } from "./checkboxed-list-input.js";
@@ -73,7 +73,7 @@ class Tickable extends FormFieldControl {
73
73
  })();
74
74
  </script>
75
75
 
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
+ ${(~valid || !!field_message) && !this.options.hide_errors && fctx.validate ? `<div class="input__error">${Array.from(new Set([message, field_message?.message || false].filter((e) => !!e))).join(" \u2022 ")}</div>` : ""}
77
77
  `
78
78
  );
79
79
  }
@@ -20,8 +20,7 @@ class CollectionField extends FormField {
20
20
  const parsed_value = await this.sealiousField.decode(
21
21
  ctx.$context,
22
22
  encoded_value,
23
- null,
24
- this.sealiousField.typeName == "text" ? "original" : {}
23
+ null
25
24
  );
26
25
  return {
27
26
  parsable: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.19.28",
3
+ "version": "0.19.30",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -93,7 +93,7 @@
93
93
  "peerDependencies": {
94
94
  "koa": "^2.13.0",
95
95
  "koa-responsive-image-router": "^0.2.24",
96
- "sealious": "^0.21.36",
96
+ "sealious": "^0.21.38",
97
97
  "stimulus": "^3.2.2"
98
98
  }
99
99
  }
@@ -223,10 +223,10 @@ export class StructuredArray<
223
223
  ctx.body = this._render(
224
224
  ctx,
225
225
  form_id,
226
- (await item.getDecodedBody(
227
- ctx.$context,
228
- {}
229
- )) as unknown as Record<string, FormDataValue>
226
+ (await item.getDecodedBody(ctx.$context)) as unknown as Record<
227
+ string,
228
+ FormDataValue
229
+ >
230
230
  );
231
231
  });
232
232
  }
@@ -1,5 +1,4 @@
1
1
  export * from "./autocomplete.js";
2
- export * from "./big-radio-group.js";
3
2
  export * from "./checkbox-group.js";
4
3
  export * from "./checkbox.js";
5
4
  export { CheckboxedListInput } from "./checkboxed-list-input.js";
@@ -29,8 +29,9 @@ export class HTML extends FormControl {
29
29
  if (typeof this.renderer === "string") {
30
30
  return this.renderer;
31
31
  }
32
- return typeof this.renderer == "function"
33
- ? this.renderer(fctx)
34
- : this.renderer;
32
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
33
+ return typeof this.renderer == "function" ?
34
+ this.renderer(fctx)
35
+ : this.renderer;
35
36
  }
36
37
  }
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  import { Context } from "koa";
4
4
  import {
5
- Field as SealiousField,
5
+ ExtractFieldDecoded,
6
6
  FieldTypes as SealiousFieldTypes,
7
7
  } from "sealious";
8
8
  import { CollectionField } from "../fields/collection-field.js";
@@ -10,9 +10,6 @@ import { DropdownOptions, FreeformDropdown } from "./dropdown.js";
10
10
  import { Collection, CollectionItem } from "sealious";
11
11
  import { FormField } from "../../index.js";
12
12
 
13
- export type ExtractFieldDecoded<F extends SealiousField<any, any, any>> =
14
- F extends SealiousField<infer T, unknown, unknown> ? T : never;
15
-
16
13
  export class SingleReferenceDropdown<
17
14
  TargetCollection extends Collection,
18
15
  SealiousField extends SealiousFieldTypes.SingleReference,
@@ -133,7 +133,7 @@ export abstract class Tickable<T> extends FormFieldControl {
133
133
  !this.options.hide_errors &&
134
134
  fctx.validate
135
135
  ) ?
136
- `<div class="input__error">${Array.from(new Set([message, field_message!.message].filter((e) => !!e))).join(" • ")}</div>`
136
+ `<div class="input__error">${Array.from(new Set([message, field_message?.message || false].filter((e) => !!e))).join(" • ")}</div>`
137
137
  : ""}
138
138
  `
139
139
  );
@@ -40,8 +40,7 @@ export class CollectionField<
40
40
  const parsed_value = (await this.sealiousField.decode(
41
41
  ctx.$context,
42
42
  encoded_value,
43
- null,
44
- this.sealiousField.typeName == "text" ? "original" : {}
43
+ null
45
44
  )) as ExtractFieldDecoded<F>;
46
45
  return {
47
46
  parsable: true,
@@ -1,38 +0,0 @@
1
- import { tempstream } from "tempstream";
2
- import { FormFieldControl } from "./form-field-control.js";
3
- class BigRadioGroup extends FormFieldControl {
4
- constructor(field, options) {
5
- super([field]);
6
- this.field = field;
7
- this.options = options;
8
- }
9
- async render(fctx) {
10
- const { raw: current_value } = await this.field.getParsedValue(
11
- fctx.ctx,
12
- fctx.data.raw_values
13
- );
14
- return tempstream`<div class="bigradios">
15
- ${Object.entries(this.options).map(([key, { description }]) => {
16
- const id = `${this.field.name}-radio-${key}`;
17
- return tempstream`<input
18
- type="radio"
19
- name="${this.field.name}"
20
- value="${key}"
21
- id="${id}"
22
- style="display: none"
23
- ${fctx.form_id ? `form=${fctx.form_id}` : ""}
24
- ${this.field.required ? "required" : ""}
25
- ${key == current_value ? "checked" : ""}
26
- />
27
- <div class="bigradio">
28
- ${typeof description == "function" ? description(fctx) : description}
29
- <label class="bigradio__cta" for="${id}">Wybierz</label>
30
- </div>`;
31
- })}
32
- </div>`;
33
- }
34
- }
35
- export {
36
- BigRadioGroup
37
- };
38
- //# sourceMappingURL=big-radio-group.js.map
@@ -1,48 +0,0 @@
1
- import { FlatTemplatable, tempstream } from "tempstream";
2
- import { FormField } from "../fields/field.js";
3
- import { FormControlContext } from "./form-control.js";
4
- import { FormFieldControl } from "./form-field-control.js";
5
-
6
- export class BigRadioGroup extends FormFieldControl {
7
- constructor(
8
- public field: FormField,
9
- public options: Record<
10
- string,
11
- {
12
- description:
13
- | FlatTemplatable
14
- | ((fctx: FormControlContext) => FlatTemplatable);
15
- }
16
- >
17
- ) {
18
- super([field]);
19
- }
20
-
21
- async render(fctx: FormControlContext): Promise<FlatTemplatable> {
22
- const { raw: current_value } = await this.field.getParsedValue(
23
- fctx.ctx,
24
- fctx.data.raw_values
25
- );
26
- return tempstream /* HTML */ `<div class="bigradios">
27
- ${Object.entries(this.options).map(([key, { description }]) => {
28
- const id = `${this.field.name}-radio-${key}`;
29
- return tempstream /* HTML */ `<input
30
- type="radio"
31
- name="${this.field.name}"
32
- value="${key}"
33
- id="${id}"
34
- style="display: none"
35
- ${fctx.form_id ? `form=${fctx.form_id}` : ""}
36
- ${this.field.required ? "required" : ""}
37
- ${key == current_value ? "checked" : ""}
38
- />
39
- <div class="bigradio">
40
- ${typeof description == "function"
41
- ? description(fctx)
42
- : description}
43
- <label class="bigradio__cta" for="${id}">Wybierz</label>
44
- </div>`;
45
- })}
46
- </div>`;
47
- }
48
- }