@sealcode/sealgen 0.5.11 → 0.5.12

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,8 +1,11 @@
1
+ import { Context } from "koa";
1
2
  import { FlatTemplatable } from "tempstream";
3
+ import { FormField } from "../fields/field";
4
+ import { FormDataValue } from "../form";
2
5
  import { FormFieldControl } from "./form-field-control";
3
6
  export declare class HiddenInput extends FormFieldControl {
4
- name: string;
7
+ field: FormField;
5
8
  value: FlatTemplatable;
6
- constructor(name: string, value: FlatTemplatable);
7
- render(): FlatTemplatable | Promise<FlatTemplatable>;
9
+ constructor(field: FormField, value: FlatTemplatable);
10
+ render(ctx: Context, data: Record<string, FormDataValue>): Promise<FlatTemplatable>;
8
11
  }
@@ -4,13 +4,14 @@ exports.HiddenInput = void 0;
4
4
  const tempstream_1 = require("tempstream");
5
5
  const form_field_control_1 = require("./form-field-control");
6
6
  class HiddenInput extends form_field_control_1.FormFieldControl {
7
- constructor(name, value) {
8
- super([]);
9
- this.name = name;
7
+ constructor(field, value) {
8
+ super([field]);
9
+ this.field = field;
10
10
  this.value = value;
11
11
  }
12
- render() {
13
- return tempstream_1.tempstream `<input type="hidden" name="${this.name}" value="${this.value}">`;
12
+ async render(ctx, data) {
13
+ const { raw } = await this.field.getValue(ctx, data);
14
+ return tempstream_1.tempstream `<input type="hidden" name="${this.field.name}" value="${(raw || "").toString()}">`;
14
15
  }
15
16
  }
16
17
  exports.HiddenInput = HiddenInput;
@@ -1 +1 @@
1
- {"version":3,"file":"hidden-input.js","sourceRoot":"","sources":["../../../src/forms/controls/hidden-input.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AACzD,6DAAwD;AAExD,MAAa,WAAY,SAAQ,qCAAgB;IAChD,YAAmB,IAAY,EAAS,KAAsB;QAC7D,KAAK,CAAC,EAAE,CAAC,CAAC;QADQ,SAAI,GAAJ,IAAI,CAAQ;QAAS,UAAK,GAAL,KAAK,CAAiB;IAE9D,CAAC;IAED,MAAM;QACL,OAAO,uBAAU,CAAA,8BAA8B,IAAI,CAAC,IAAI,YAAY,IAAI,CAAC,KAAK,IAAI,CAAC;IACpF,CAAC;CACD;AARD,kCAQC"}
1
+ {"version":3,"file":"hidden-input.js","sourceRoot":"","sources":["../../../src/forms/controls/hidden-input.ts"],"names":[],"mappings":";;;AACA,2CAAyD;AAGzD,6DAAwD;AAExD,MAAa,WAAY,SAAQ,qCAAgB;IAChD,YAAmB,KAAgB,EAAS,KAAsB;QACjE,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QADG,UAAK,GAAL,KAAK,CAAW;QAAS,UAAK,GAAL,KAAK,CAAiB;IAElE,CAAC;IAED,KAAK,CAAC,MAAM,CACX,GAAY,EACZ,IAAmC;QAEnC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACrD,OAAO,uBAAU,CAAA,8BAChB,IAAI,CAAC,KAAK,CAAC,IACZ,YAAY,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC;IACxC,CAAC;CACD;AAdD,kCAcC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.5.11",
3
+ "version": "0.5.12",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,12 +1,21 @@
1
+ import { Context } from "koa";
1
2
  import { FlatTemplatable, tempstream } from "tempstream";
3
+ import { FormField } from "../fields/field";
4
+ import { FormDataValue } from "../form";
2
5
  import { FormFieldControl } from "./form-field-control";
3
6
 
4
7
  export class HiddenInput extends FormFieldControl {
5
- constructor(public name: string, public value: FlatTemplatable) {
6
- super([]);
8
+ constructor(public field: FormField, public value: FlatTemplatable) {
9
+ super([field]);
7
10
  }
8
11
 
9
- render(): FlatTemplatable | Promise<FlatTemplatable> {
10
- return tempstream`<input type="hidden" name="${this.name}" value="${this.value}">`;
12
+ async render(
13
+ ctx: Context,
14
+ data: Record<string, FormDataValue>
15
+ ): Promise<FlatTemplatable> {
16
+ const { raw } = await this.field.getValue(ctx, data);
17
+ return tempstream`<input type="hidden" name="${
18
+ this.field.name
19
+ }" value="${(raw || "").toString()}">`;
11
20
  }
12
21
  }