@sealcode/sealgen 0.19.9 → 0.19.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.
- package/@types/forms/fields/phone-number-with-country-code.d.ts +3 -0
- package/@types/utils/extract-fields-from-collection.d.ts +0 -4
- package/lib/forms/fields/phone-number-with-country-code.js +16 -0
- package/lib/utils/extract-fields-from-collection.js +2 -13
- package/package.json +1 -1
- package/src/forms/fields/phone-number-with-country-code.ts +24 -0
- package/src/utils/extract-fields-from-collection.ts +2 -15
|
@@ -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
|
}
|
|
@@ -6,11 +6,7 @@ export type ExtractedFieldInfo = {
|
|
|
6
6
|
referencing_collection: string | null;
|
|
7
7
|
referencing_field: string | null;
|
|
8
8
|
intermediary_field_that_points_there: string | null;
|
|
9
|
-
is_readonly: boolean;
|
|
10
9
|
is_required: boolean;
|
|
11
|
-
subfields: {
|
|
12
|
-
name: string;
|
|
13
|
-
}[];
|
|
14
10
|
};
|
|
15
11
|
export type ExtractedFieldInfoWithFormField = ExtractedFieldInfo & {
|
|
16
12
|
form_field: FormField;
|
|
@@ -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
|
|
@@ -25,14 +25,10 @@ for (const field_name in c.fields){
|
|
|
25
25
|
let referencing_collection = null;
|
|
26
26
|
let referencing_field = null;
|
|
27
27
|
let intermediary_field_that_points_there = null;
|
|
28
|
-
let is_readonly = false;
|
|
29
28
|
let is_required = field.required || false;
|
|
30
|
-
let subfields = [];
|
|
31
29
|
if(["derived-value", "cached-value", "settable-by", "control-access"].includes(type)){
|
|
32
30
|
type = field.virtual_field.typeName;
|
|
33
|
-
|
|
34
|
-
if(["derived-value", "cached-value", "reverse-single-reference"].includes(field.typeName)){
|
|
35
|
-
is_readonly = true;
|
|
31
|
+
field = field.virtual_field
|
|
36
32
|
}
|
|
37
33
|
if(type == "single-reference"){
|
|
38
34
|
target = field.target_collection;
|
|
@@ -46,10 +42,7 @@ for (const field_name in c.fields){
|
|
|
46
42
|
referencing_field = field.referencing_field;
|
|
47
43
|
intermediary_field_that_points_there = field.intermediary_field_that_points_there
|
|
48
44
|
}
|
|
49
|
-
|
|
50
|
-
subfields = Object.keys(field.subfields || field.virtual_field.subfields).map(key=>({name: key}));
|
|
51
|
-
}
|
|
52
|
-
fields.push({ name: field_name, type, target, referencing_collection, referencing_field, intermediary_field_that_points_there, is_readonly, is_required, subfields })
|
|
45
|
+
fields.push({ name: field_name, type, target, referencing_collection, referencing_field, intermediary_field_that_points_there, is_required })
|
|
53
46
|
}
|
|
54
47
|
console.log(JSON.stringify(fields));
|
|
55
48
|
`;
|
|
@@ -66,7 +59,6 @@ for (const field_name in c.fields){
|
|
|
66
59
|
predicates.shape({
|
|
67
60
|
name: predicates.string,
|
|
68
61
|
type: predicates.string,
|
|
69
|
-
is_readonly: predicates.boolean,
|
|
70
62
|
target: predicates.or(
|
|
71
63
|
predicates.string,
|
|
72
64
|
predicates.null
|
|
@@ -83,9 +75,6 @@ for (const field_name in c.fields){
|
|
|
83
75
|
intermediary_field_that_points_there: predicates.or(
|
|
84
76
|
predicates.string,
|
|
85
77
|
predicates.null
|
|
86
|
-
),
|
|
87
|
-
subfields: predicates.array(
|
|
88
|
-
predicates.shape({ name: predicates.string })
|
|
89
78
|
)
|
|
90
79
|
})
|
|
91
80
|
)
|
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
|
}
|
|
@@ -13,9 +13,7 @@ export type ExtractedFieldInfo = {
|
|
|
13
13
|
referencing_collection: string | null;
|
|
14
14
|
referencing_field: string | null;
|
|
15
15
|
intermediary_field_that_points_there: string | null;
|
|
16
|
-
is_readonly: boolean;
|
|
17
16
|
is_required: boolean;
|
|
18
|
-
subfields: { name: string }[];
|
|
19
17
|
};
|
|
20
18
|
|
|
21
19
|
export type ExtractedFieldInfoWithFormField = ExtractedFieldInfo & {
|
|
@@ -50,14 +48,10 @@ for (const field_name in c.fields){
|
|
|
50
48
|
let referencing_collection = null;
|
|
51
49
|
let referencing_field = null;
|
|
52
50
|
let intermediary_field_that_points_there = null;
|
|
53
|
-
let is_readonly = false;
|
|
54
51
|
let is_required = field.required || false;
|
|
55
|
-
let subfields = [];
|
|
56
52
|
if(["derived-value", "cached-value", "settable-by", "control-access"].includes(type)){
|
|
57
53
|
type = field.virtual_field.typeName;
|
|
58
|
-
|
|
59
|
-
if(["derived-value", "cached-value", "reverse-single-reference"].includes(field.typeName)){
|
|
60
|
-
is_readonly = true;
|
|
54
|
+
field = field.virtual_field
|
|
61
55
|
}
|
|
62
56
|
if(type == "single-reference"){
|
|
63
57
|
target = field.target_collection;
|
|
@@ -71,10 +65,7 @@ for (const field_name in c.fields){
|
|
|
71
65
|
referencing_field = field.referencing_field;
|
|
72
66
|
intermediary_field_that_points_there = field.intermediary_field_that_points_there
|
|
73
67
|
}
|
|
74
|
-
|
|
75
|
-
subfields = Object.keys(field.subfields || field.virtual_field.subfields).map(key=>({name: key}));
|
|
76
|
-
}
|
|
77
|
-
fields.push({ name: field_name, type, target, referencing_collection, referencing_field, intermediary_field_that_points_there, is_readonly, is_required, subfields })
|
|
68
|
+
fields.push({ name: field_name, type, target, referencing_collection, referencing_field, intermediary_field_that_points_there, is_required })
|
|
78
69
|
}
|
|
79
70
|
console.log(JSON.stringify(fields));
|
|
80
71
|
`;
|
|
@@ -93,7 +84,6 @@ for (const field_name in c.fields){
|
|
|
93
84
|
predicates.shape({
|
|
94
85
|
name: predicates.string,
|
|
95
86
|
type: predicates.string,
|
|
96
|
-
is_readonly: predicates.boolean,
|
|
97
87
|
target: predicates.or(
|
|
98
88
|
predicates.string,
|
|
99
89
|
predicates.null
|
|
@@ -111,9 +101,6 @@ for (const field_name in c.fields){
|
|
|
111
101
|
predicates.string,
|
|
112
102
|
predicates.null
|
|
113
103
|
),
|
|
114
|
-
subfields: predicates.array(
|
|
115
|
-
predicates.shape({ name: predicates.string })
|
|
116
|
-
),
|
|
117
104
|
})
|
|
118
105
|
)
|
|
119
106
|
)
|