@sealcode/sealgen 0.19.8 → 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.
- package/@types/forms/fields/phone-number-with-country-code.d.ts +3 -0
- package/@types/index.d.ts +1 -0
- package/lib/forms/fields/phone-number-with-country-code.js +16 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
- package/src/forms/fields/phone-number-with-country-code.ts +24 -0
- package/src/index.ts +1 -0
|
@@ -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
|
}
|
package/@types/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * as Components from "./components/components.js";
|
|
|
17
17
|
export * from "./mount.js";
|
|
18
18
|
export * from "./page/default-list-filters.js";
|
|
19
19
|
export * from "./forms/fields/get-field-for-sealious.js";
|
|
20
|
+
export * from "./forms/controls/form-control.js";
|
|
20
21
|
import { Context } from "koa";
|
|
21
22
|
import { Readable } from "node:stream";
|
|
22
23
|
export interface HTMLOptions {
|
|
@@ -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/lib/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import * as Components from "./components/components.js";
|
|
|
17
17
|
export * from "./mount.js";
|
|
18
18
|
export * from "./page/default-list-filters.js";
|
|
19
19
|
export * from "./forms/fields/get-field-for-sealious.js";
|
|
20
|
+
export * from "./forms/controls/form-control.js";
|
|
20
21
|
export {
|
|
21
22
|
Components,
|
|
22
23
|
Controls,
|
package/package.json
CHANGED
|
@@ -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
|
}
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * as Components from "./components/components.js";
|
|
|
17
17
|
export * from "./mount.js";
|
|
18
18
|
export * from "./page/default-list-filters.js";
|
|
19
19
|
export * from "./forms/fields/get-field-for-sealious.js";
|
|
20
|
+
export * from "./forms/controls/form-control.js";
|
|
20
21
|
|
|
21
22
|
import { Context } from "koa";
|
|
22
23
|
import { Readable } from "node:stream";
|