@sealcode/sealgen 0.8.18 → 0.8.19

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.
@@ -9,13 +9,16 @@ export declare class Textarea<Required extends boolean> extends SimpleInput<stri
9
9
  rows?: number;
10
10
  cols?: number;
11
11
  description?: string;
12
+ autogrow?: boolean;
12
13
  };
13
14
  constructor(field: FormField<boolean, string | null>, options?: SimpleInputOptions & {
14
15
  label?: string;
15
16
  rows?: number;
16
17
  cols?: number;
17
18
  description?: string;
19
+ autogrow?: boolean;
18
20
  });
19
21
  renderDescription(): string;
22
+ getInputAttributes(ctx: Context, data: Record<string, FormDataValue>, field_prefix: string, form_id: string): Promise<Record<string, string | boolean>>;
20
23
  renderInput(ctx: Context, attributes: string, data: Record<string, FormDataValue>): Promise<string>;
21
24
  }
@@ -15,6 +15,19 @@ class Textarea extends simple_input_1.SimpleInput {
15
15
  </div>`
16
16
  : "";
17
17
  }
18
+ async getInputAttributes(ctx, data, field_prefix, form_id) {
19
+ const original = (await super.getInputAttributes(ctx, data, field_prefix, form_id));
20
+ let onkeydown = original.onkeydown || "";
21
+ if (this.options.autogrow) {
22
+ onkeydown += `;this.style.height = '5px';this.style.height = Math.max((this.scrollHeight)+32, ${((this.options.rows || 2) + 1) * 16} )+'px';`;
23
+ }
24
+ return {
25
+ ...original,
26
+ rows: this.options.rows ? this.options.rows.toString() : false,
27
+ cols: this.options.cols ? this.options.cols.toString() : false,
28
+ onkeydown,
29
+ };
30
+ }
18
31
  async renderInput(ctx, attributes, data) {
19
32
  const { parsed: value } = await this.field.getValue(ctx, data);
20
33
  return /* HTML */ `<textarea ${attributes}>${value}</textarea>`;
@@ -1 +1 @@
1
- {"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../../src/forms/controls/textarea.ts"],"names":[],"mappings":";;;AAOA,iDAAiE;AAEjE,MAAa,QAAmC,SAAQ,0BAEvD;IACA,YACQ,KAAwC,EACxC,UAKH,EAAE;QAE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S,GAAG,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC;QACzC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YAC1B,SAAS,IAAI,mFACZ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAClC,UAAU,CAAC;SACX;QACD,OAAO;YACN,GAAG,QAAQ;YACX,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK;YAC9D,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK;YAC9D,SAAS;SACT,CAAC;IACH,CAAC;IAED,KAAK,CAAC,WAAW,CAChB,GAAY,EACZ,UAAkB,EAClB,IAAmC;QAEnC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC/D,OAAO,UAAU,CAAC,aAAa,UAAU,IAAI,KAAK,aAAa,CAAC;IACjE,CAAC;CACD;AA1DD,4BA0DC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.8.18",
3
+ "version": "0.8.19",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -17,6 +17,7 @@ export class Textarea<Required extends boolean> extends SimpleInput<
17
17
  rows?: number;
18
18
  cols?: number;
19
19
  description?: string;
20
+ autogrow?: boolean;
20
21
  } = {}
21
22
  ) {
22
23
  super(field, options);
@@ -30,6 +31,32 @@ export class Textarea<Required extends boolean> extends SimpleInput<
30
31
  : "";
31
32
  }
32
33
 
34
+ async getInputAttributes(
35
+ ctx: Context,
36
+ data: Record<string, FormDataValue>,
37
+ field_prefix: string,
38
+ form_id: string
39
+ ): Promise<Record<string, string | boolean>> {
40
+ const original = (await super.getInputAttributes(
41
+ ctx,
42
+ data,
43
+ field_prefix,
44
+ form_id
45
+ )) as Record<string, string | boolean>;
46
+ let onkeydown = original.onkeydown || "";
47
+ if (this.options.autogrow) {
48
+ onkeydown += `;this.style.height = '5px';this.style.height = Math.max((this.scrollHeight)+32, ${
49
+ ((this.options.rows || 2) + 1) * 16
50
+ } )+'px';`;
51
+ }
52
+ return {
53
+ ...original,
54
+ rows: this.options.rows ? this.options.rows.toString() : false,
55
+ cols: this.options.cols ? this.options.cols.toString() : false,
56
+ onkeydown,
57
+ };
58
+ }
59
+
33
60
  async renderInput(
34
61
  ctx: Context,
35
62
  attributes: string,