@sealcode/sealgen 0.19.9 → 0.19.11

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.
@@ -3,8 +3,11 @@ import { FieldTypes as SealiousFieldTypes } from "sealious";
3
3
  import { FormControl } from "../controls/controls.js";
4
4
  import { FormDataValue } from "../form-types.js";
5
5
  import { FieldParseResult, FormField } from "./field.js";
6
+ import { FormControlContext } from "../../index.js";
6
7
  export declare class PhoneNumberWithCountryCode<Required extends boolean> extends FormField<Required, SealiousFieldTypes.PhoneNumberValue> {
7
8
  getEmptyValue(): SealiousFieldTypes.PhoneNumberValue;
8
9
  parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<SealiousFieldTypes.PhoneNumberValue>>;
9
10
  getControl(): FormControl;
11
+ getSealiousCreateValue(fctx: FormControlContext): Promise<string>;
12
+ sealiousValueToForm(ctx: Context, sealiousValue: SealiousFieldTypes.PhoneNumberValue | null): Promise<FormDataValue>;
10
13
  }
@@ -43,6 +43,22 @@ class PhoneNumberWithCountryCode extends FormField {
43
43
  )
44
44
  });
45
45
  }
46
+ async getSealiousCreateValue(fctx) {
47
+ const { parsed } = await this.getParsedValue(
48
+ fctx.ctx,
49
+ fctx.data.raw_values
50
+ );
51
+ if (!parsed) {
52
+ return "";
53
+ }
54
+ return parsed.toString();
55
+ }
56
+ async sealiousValueToForm(ctx, sealiousValue) {
57
+ return sealiousValue ? {
58
+ country_code: sealiousValue.country_code,
59
+ number: sealiousValue.number
60
+ } : {};
61
+ }
46
62
  }
47
63
  export {
48
64
  PhoneNumberWithCountryCode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.19.9",
3
+ "version": "0.19.11",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -7,6 +7,7 @@ import { FormDataValue } from "../form-types.js";
7
7
  import { FieldParseResult, FormField } from "./field.js";
8
8
  import { PickFromListField } from "./pick-from-list.js";
9
9
  import { PhoneNumberWithoutCountryCode } from "./phone-number.js";
10
+ import { FormControlContext } from "../../index.js";
10
11
 
11
12
  export class PhoneNumberWithCountryCode<
12
13
  Required extends boolean,
@@ -56,4 +57,27 @@ export class PhoneNumberWithCountryCode<
56
57
  ),
57
58
  });
58
59
  }
60
+
61
+ async getSealiousCreateValue(fctx: FormControlContext): Promise<string> {
62
+ const { parsed } = await this.getParsedValue(
63
+ fctx.ctx,
64
+ fctx.data.raw_values
65
+ );
66
+ if (!parsed) {
67
+ return "";
68
+ }
69
+ return parsed.toString();
70
+ }
71
+
72
+ async sealiousValueToForm(
73
+ ctx: Context,
74
+ sealiousValue: SealiousFieldTypes.PhoneNumberValue | null
75
+ ): Promise<FormDataValue> {
76
+ return sealiousValue ?
77
+ {
78
+ country_code: sealiousValue.country_code,
79
+ number: sealiousValue.number,
80
+ }
81
+ : {};
82
+ }
59
83
  }