@gcforms/types 0.0.9 → 0.0.10
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/dist/index.d.mts +172 -0
- package/dist/index.d.ts +172 -0
- package/dist/index.js +51 -0
- package/dist/index.mjs +24 -0
- package/package.json +4 -1
- package/src/form-response-types.ts +0 -18
- package/src/form-types.ts +0 -216
- package/src/index.ts +0 -39
- package/tsconfig.json +0 -14
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
type TypeOmit<Type, Key extends PropertyKey> = {
|
|
2
|
+
[Property in keyof Type as Exclude<Property, Key>]: Type[Property];
|
|
3
|
+
};
|
|
4
|
+
type FormChangeEvent = {
|
|
5
|
+
target: {
|
|
6
|
+
value: string | number | boolean | string[];
|
|
7
|
+
name?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type Group = {
|
|
13
|
+
name: string;
|
|
14
|
+
titleEn: string;
|
|
15
|
+
titleFr: string;
|
|
16
|
+
nextAction?: string | NextActionRule[];
|
|
17
|
+
elements: string[];
|
|
18
|
+
autoFlow?: boolean;
|
|
19
|
+
exitUrlEn?: string;
|
|
20
|
+
exitUrlFr?: string;
|
|
21
|
+
};
|
|
22
|
+
type GroupsType = Record<string, Group>;
|
|
23
|
+
type NextActionRule = {
|
|
24
|
+
groupId: string;
|
|
25
|
+
choiceId: string;
|
|
26
|
+
};
|
|
27
|
+
type HTMLTextInputTypeAttribute = "text" | "email" | "name" | "number" | "password" | "search" | "tel" | "url";
|
|
28
|
+
declare enum FormElementTypes {
|
|
29
|
+
textField = "textField",
|
|
30
|
+
textArea = "textArea",
|
|
31
|
+
dropdown = "dropdown",
|
|
32
|
+
radio = "radio",
|
|
33
|
+
checkbox = "checkbox",
|
|
34
|
+
fileInput = "fileInput",
|
|
35
|
+
richText = "richText",
|
|
36
|
+
dynamicRow = "dynamicRow",
|
|
37
|
+
attestation = "attestation",
|
|
38
|
+
address = "address",
|
|
39
|
+
addressComplete = "addressComplete",
|
|
40
|
+
name = "name",
|
|
41
|
+
firstMiddleLastName = "firstMiddleLastName",
|
|
42
|
+
departments = "departments",
|
|
43
|
+
contact = "contact",
|
|
44
|
+
combobox = "combobox",
|
|
45
|
+
formattedDate = "formattedDate"
|
|
46
|
+
}
|
|
47
|
+
type ConditionalRule = {
|
|
48
|
+
choiceId: string;
|
|
49
|
+
};
|
|
50
|
+
interface ValidationProperties {
|
|
51
|
+
required: boolean;
|
|
52
|
+
type?: HTMLTextInputTypeAttribute;
|
|
53
|
+
regex?: string;
|
|
54
|
+
maxLength?: number;
|
|
55
|
+
descriptionEN?: string;
|
|
56
|
+
descriptionFR?: string;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
interface PropertyChoices {
|
|
60
|
+
en: string;
|
|
61
|
+
fr: string;
|
|
62
|
+
[key: string]: string;
|
|
63
|
+
}
|
|
64
|
+
type AddressComponents = {
|
|
65
|
+
canadianOnly?: boolean;
|
|
66
|
+
splitAddress?: boolean;
|
|
67
|
+
};
|
|
68
|
+
interface DeliveryOption {
|
|
69
|
+
emailAddress: string;
|
|
70
|
+
emailSubjectEn?: string;
|
|
71
|
+
emailSubjectFr?: string;
|
|
72
|
+
[key: string]: string | undefined;
|
|
73
|
+
}
|
|
74
|
+
interface ElementProperties {
|
|
75
|
+
titleEn: string;
|
|
76
|
+
titleFr: string;
|
|
77
|
+
placeholderEn?: string;
|
|
78
|
+
placeholderFr?: string;
|
|
79
|
+
descriptionEn?: string;
|
|
80
|
+
descriptionFr?: string;
|
|
81
|
+
validation?: ValidationProperties | undefined;
|
|
82
|
+
choices?: PropertyChoices[];
|
|
83
|
+
managedChoices?: string;
|
|
84
|
+
subElements?: FormElement[];
|
|
85
|
+
fileType?: string | undefined;
|
|
86
|
+
headingLevel?: string | undefined;
|
|
87
|
+
isSectional?: boolean;
|
|
88
|
+
maxNumberOfRows?: number;
|
|
89
|
+
autoComplete?: string;
|
|
90
|
+
dateFormat?: string;
|
|
91
|
+
conditionalRules?: ConditionalRule[];
|
|
92
|
+
full?: boolean;
|
|
93
|
+
addressComponents?: AddressComponents | undefined;
|
|
94
|
+
dynamicRow?: dynamicRowType;
|
|
95
|
+
[key: string]: string | number | boolean | Array<PropertyChoices> | Array<FormElement> | ValidationProperties | Array<ConditionalRule> | AddressComponents | dynamicRowType | undefined;
|
|
96
|
+
}
|
|
97
|
+
interface BrandProperties {
|
|
98
|
+
name?: string;
|
|
99
|
+
logoEn: string;
|
|
100
|
+
logoFr: string;
|
|
101
|
+
logoTitleEn: string;
|
|
102
|
+
logoTitleFr: string;
|
|
103
|
+
urlEn?: string;
|
|
104
|
+
urlFr?: string;
|
|
105
|
+
disableGcBranding?: boolean;
|
|
106
|
+
[key: string]: string | boolean | undefined;
|
|
107
|
+
}
|
|
108
|
+
interface FormElement {
|
|
109
|
+
id: number;
|
|
110
|
+
subId?: string;
|
|
111
|
+
type: FormElementTypes;
|
|
112
|
+
properties: ElementProperties;
|
|
113
|
+
onchange?: (event: FormChangeEvent) => void;
|
|
114
|
+
brand?: BrandProperties;
|
|
115
|
+
}
|
|
116
|
+
interface FormProperties {
|
|
117
|
+
titleEn: string;
|
|
118
|
+
titleFr: string;
|
|
119
|
+
introduction?: Record<string, string>;
|
|
120
|
+
privacyPolicy?: Record<string, string>;
|
|
121
|
+
confirmation?: Record<string, string>;
|
|
122
|
+
closedMessage?: Record<string, string>;
|
|
123
|
+
layout: number[];
|
|
124
|
+
groups?: GroupsType;
|
|
125
|
+
groupsLayout?: string[];
|
|
126
|
+
elements: FormElement[];
|
|
127
|
+
lastGeneratedElementId?: number;
|
|
128
|
+
brand?: BrandProperties;
|
|
129
|
+
formPurpose?: string;
|
|
130
|
+
[key: string]: string | number | boolean | Array<string | number | FormElement> | Record<string, string> | BrandProperties | GroupsType | undefined;
|
|
131
|
+
}
|
|
132
|
+
type dynamicRowType = {
|
|
133
|
+
rowTitleEn: string;
|
|
134
|
+
rowTitleFr: string;
|
|
135
|
+
addButtonTextEn: string;
|
|
136
|
+
removeButtonTextEn: string;
|
|
137
|
+
addButtonTextFr: string;
|
|
138
|
+
removeButtonTextFr: string;
|
|
139
|
+
};
|
|
140
|
+
type FormRecord = {
|
|
141
|
+
id: string;
|
|
142
|
+
createdAt?: string;
|
|
143
|
+
updatedAt?: string;
|
|
144
|
+
name: string;
|
|
145
|
+
form: FormProperties;
|
|
146
|
+
isPublished: boolean;
|
|
147
|
+
deliveryOption?: DeliveryOption;
|
|
148
|
+
securityAttribute: SecurityAttribute;
|
|
149
|
+
closingDate?: string;
|
|
150
|
+
closedDetails?: ClosedDetails;
|
|
151
|
+
saveAndResume?: boolean;
|
|
152
|
+
[key: string]: string | boolean | FormProperties | DeliveryOption | ClosedDetails | undefined;
|
|
153
|
+
};
|
|
154
|
+
type SecurityAttribute = "Unclassified" | "Protected A" | "Protected B";
|
|
155
|
+
type FormPurpose = "" | "admin" | "nonAdmin";
|
|
156
|
+
type ClosedDetails = {
|
|
157
|
+
messageEn?: string;
|
|
158
|
+
messageFr?: string;
|
|
159
|
+
};
|
|
160
|
+
type PublicFormRecord = TypeOmit<FormRecord, "name" | "deliveryOption">;
|
|
161
|
+
|
|
162
|
+
type Responses = {
|
|
163
|
+
[key: string]: Response;
|
|
164
|
+
};
|
|
165
|
+
type Response = string | string[] | number | Record<string, unknown>[] | FileInputResponse | FileInputResponse[] | Record<string, unknown>;
|
|
166
|
+
type FileInputResponse = {
|
|
167
|
+
name: string | null;
|
|
168
|
+
size: number | null;
|
|
169
|
+
based64EncodedFile: string | null;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export { type AddressComponents, type BrandProperties, type ClosedDetails, type ConditionalRule, type DeliveryOption, type ElementProperties, type FileInputResponse, type FormElement, FormElementTypes, type FormProperties, type FormPurpose, type FormRecord, type Group, type PropertyChoices, type PublicFormRecord, type Response, type Responses, type SecurityAttribute, type ValidationProperties, type dynamicRowType };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
type TypeOmit<Type, Key extends PropertyKey> = {
|
|
2
|
+
[Property in keyof Type as Exclude<Property, Key>]: Type[Property];
|
|
3
|
+
};
|
|
4
|
+
type FormChangeEvent = {
|
|
5
|
+
target: {
|
|
6
|
+
value: string | number | boolean | string[];
|
|
7
|
+
name?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type Group = {
|
|
13
|
+
name: string;
|
|
14
|
+
titleEn: string;
|
|
15
|
+
titleFr: string;
|
|
16
|
+
nextAction?: string | NextActionRule[];
|
|
17
|
+
elements: string[];
|
|
18
|
+
autoFlow?: boolean;
|
|
19
|
+
exitUrlEn?: string;
|
|
20
|
+
exitUrlFr?: string;
|
|
21
|
+
};
|
|
22
|
+
type GroupsType = Record<string, Group>;
|
|
23
|
+
type NextActionRule = {
|
|
24
|
+
groupId: string;
|
|
25
|
+
choiceId: string;
|
|
26
|
+
};
|
|
27
|
+
type HTMLTextInputTypeAttribute = "text" | "email" | "name" | "number" | "password" | "search" | "tel" | "url";
|
|
28
|
+
declare enum FormElementTypes {
|
|
29
|
+
textField = "textField",
|
|
30
|
+
textArea = "textArea",
|
|
31
|
+
dropdown = "dropdown",
|
|
32
|
+
radio = "radio",
|
|
33
|
+
checkbox = "checkbox",
|
|
34
|
+
fileInput = "fileInput",
|
|
35
|
+
richText = "richText",
|
|
36
|
+
dynamicRow = "dynamicRow",
|
|
37
|
+
attestation = "attestation",
|
|
38
|
+
address = "address",
|
|
39
|
+
addressComplete = "addressComplete",
|
|
40
|
+
name = "name",
|
|
41
|
+
firstMiddleLastName = "firstMiddleLastName",
|
|
42
|
+
departments = "departments",
|
|
43
|
+
contact = "contact",
|
|
44
|
+
combobox = "combobox",
|
|
45
|
+
formattedDate = "formattedDate"
|
|
46
|
+
}
|
|
47
|
+
type ConditionalRule = {
|
|
48
|
+
choiceId: string;
|
|
49
|
+
};
|
|
50
|
+
interface ValidationProperties {
|
|
51
|
+
required: boolean;
|
|
52
|
+
type?: HTMLTextInputTypeAttribute;
|
|
53
|
+
regex?: string;
|
|
54
|
+
maxLength?: number;
|
|
55
|
+
descriptionEN?: string;
|
|
56
|
+
descriptionFR?: string;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
interface PropertyChoices {
|
|
60
|
+
en: string;
|
|
61
|
+
fr: string;
|
|
62
|
+
[key: string]: string;
|
|
63
|
+
}
|
|
64
|
+
type AddressComponents = {
|
|
65
|
+
canadianOnly?: boolean;
|
|
66
|
+
splitAddress?: boolean;
|
|
67
|
+
};
|
|
68
|
+
interface DeliveryOption {
|
|
69
|
+
emailAddress: string;
|
|
70
|
+
emailSubjectEn?: string;
|
|
71
|
+
emailSubjectFr?: string;
|
|
72
|
+
[key: string]: string | undefined;
|
|
73
|
+
}
|
|
74
|
+
interface ElementProperties {
|
|
75
|
+
titleEn: string;
|
|
76
|
+
titleFr: string;
|
|
77
|
+
placeholderEn?: string;
|
|
78
|
+
placeholderFr?: string;
|
|
79
|
+
descriptionEn?: string;
|
|
80
|
+
descriptionFr?: string;
|
|
81
|
+
validation?: ValidationProperties | undefined;
|
|
82
|
+
choices?: PropertyChoices[];
|
|
83
|
+
managedChoices?: string;
|
|
84
|
+
subElements?: FormElement[];
|
|
85
|
+
fileType?: string | undefined;
|
|
86
|
+
headingLevel?: string | undefined;
|
|
87
|
+
isSectional?: boolean;
|
|
88
|
+
maxNumberOfRows?: number;
|
|
89
|
+
autoComplete?: string;
|
|
90
|
+
dateFormat?: string;
|
|
91
|
+
conditionalRules?: ConditionalRule[];
|
|
92
|
+
full?: boolean;
|
|
93
|
+
addressComponents?: AddressComponents | undefined;
|
|
94
|
+
dynamicRow?: dynamicRowType;
|
|
95
|
+
[key: string]: string | number | boolean | Array<PropertyChoices> | Array<FormElement> | ValidationProperties | Array<ConditionalRule> | AddressComponents | dynamicRowType | undefined;
|
|
96
|
+
}
|
|
97
|
+
interface BrandProperties {
|
|
98
|
+
name?: string;
|
|
99
|
+
logoEn: string;
|
|
100
|
+
logoFr: string;
|
|
101
|
+
logoTitleEn: string;
|
|
102
|
+
logoTitleFr: string;
|
|
103
|
+
urlEn?: string;
|
|
104
|
+
urlFr?: string;
|
|
105
|
+
disableGcBranding?: boolean;
|
|
106
|
+
[key: string]: string | boolean | undefined;
|
|
107
|
+
}
|
|
108
|
+
interface FormElement {
|
|
109
|
+
id: number;
|
|
110
|
+
subId?: string;
|
|
111
|
+
type: FormElementTypes;
|
|
112
|
+
properties: ElementProperties;
|
|
113
|
+
onchange?: (event: FormChangeEvent) => void;
|
|
114
|
+
brand?: BrandProperties;
|
|
115
|
+
}
|
|
116
|
+
interface FormProperties {
|
|
117
|
+
titleEn: string;
|
|
118
|
+
titleFr: string;
|
|
119
|
+
introduction?: Record<string, string>;
|
|
120
|
+
privacyPolicy?: Record<string, string>;
|
|
121
|
+
confirmation?: Record<string, string>;
|
|
122
|
+
closedMessage?: Record<string, string>;
|
|
123
|
+
layout: number[];
|
|
124
|
+
groups?: GroupsType;
|
|
125
|
+
groupsLayout?: string[];
|
|
126
|
+
elements: FormElement[];
|
|
127
|
+
lastGeneratedElementId?: number;
|
|
128
|
+
brand?: BrandProperties;
|
|
129
|
+
formPurpose?: string;
|
|
130
|
+
[key: string]: string | number | boolean | Array<string | number | FormElement> | Record<string, string> | BrandProperties | GroupsType | undefined;
|
|
131
|
+
}
|
|
132
|
+
type dynamicRowType = {
|
|
133
|
+
rowTitleEn: string;
|
|
134
|
+
rowTitleFr: string;
|
|
135
|
+
addButtonTextEn: string;
|
|
136
|
+
removeButtonTextEn: string;
|
|
137
|
+
addButtonTextFr: string;
|
|
138
|
+
removeButtonTextFr: string;
|
|
139
|
+
};
|
|
140
|
+
type FormRecord = {
|
|
141
|
+
id: string;
|
|
142
|
+
createdAt?: string;
|
|
143
|
+
updatedAt?: string;
|
|
144
|
+
name: string;
|
|
145
|
+
form: FormProperties;
|
|
146
|
+
isPublished: boolean;
|
|
147
|
+
deliveryOption?: DeliveryOption;
|
|
148
|
+
securityAttribute: SecurityAttribute;
|
|
149
|
+
closingDate?: string;
|
|
150
|
+
closedDetails?: ClosedDetails;
|
|
151
|
+
saveAndResume?: boolean;
|
|
152
|
+
[key: string]: string | boolean | FormProperties | DeliveryOption | ClosedDetails | undefined;
|
|
153
|
+
};
|
|
154
|
+
type SecurityAttribute = "Unclassified" | "Protected A" | "Protected B";
|
|
155
|
+
type FormPurpose = "" | "admin" | "nonAdmin";
|
|
156
|
+
type ClosedDetails = {
|
|
157
|
+
messageEn?: string;
|
|
158
|
+
messageFr?: string;
|
|
159
|
+
};
|
|
160
|
+
type PublicFormRecord = TypeOmit<FormRecord, "name" | "deliveryOption">;
|
|
161
|
+
|
|
162
|
+
type Responses = {
|
|
163
|
+
[key: string]: Response;
|
|
164
|
+
};
|
|
165
|
+
type Response = string | string[] | number | Record<string, unknown>[] | FileInputResponse | FileInputResponse[] | Record<string, unknown>;
|
|
166
|
+
type FileInputResponse = {
|
|
167
|
+
name: string | null;
|
|
168
|
+
size: number | null;
|
|
169
|
+
based64EncodedFile: string | null;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export { type AddressComponents, type BrandProperties, type ClosedDetails, type ConditionalRule, type DeliveryOption, type ElementProperties, type FileInputResponse, type FormElement, FormElementTypes, type FormProperties, type FormPurpose, type FormRecord, type Group, type PropertyChoices, type PublicFormRecord, type Response, type Responses, type SecurityAttribute, type ValidationProperties, type dynamicRowType };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
FormElementTypes: () => FormElementTypes
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/form-types.ts
|
|
28
|
+
var FormElementTypes = /* @__PURE__ */ ((FormElementTypes2) => {
|
|
29
|
+
FormElementTypes2["textField"] = "textField";
|
|
30
|
+
FormElementTypes2["textArea"] = "textArea";
|
|
31
|
+
FormElementTypes2["dropdown"] = "dropdown";
|
|
32
|
+
FormElementTypes2["radio"] = "radio";
|
|
33
|
+
FormElementTypes2["checkbox"] = "checkbox";
|
|
34
|
+
FormElementTypes2["fileInput"] = "fileInput";
|
|
35
|
+
FormElementTypes2["richText"] = "richText";
|
|
36
|
+
FormElementTypes2["dynamicRow"] = "dynamicRow";
|
|
37
|
+
FormElementTypes2["attestation"] = "attestation";
|
|
38
|
+
FormElementTypes2["address"] = "address";
|
|
39
|
+
FormElementTypes2["addressComplete"] = "addressComplete";
|
|
40
|
+
FormElementTypes2["name"] = "name";
|
|
41
|
+
FormElementTypes2["firstMiddleLastName"] = "firstMiddleLastName";
|
|
42
|
+
FormElementTypes2["departments"] = "departments";
|
|
43
|
+
FormElementTypes2["contact"] = "contact";
|
|
44
|
+
FormElementTypes2["combobox"] = "combobox";
|
|
45
|
+
FormElementTypes2["formattedDate"] = "formattedDate";
|
|
46
|
+
return FormElementTypes2;
|
|
47
|
+
})(FormElementTypes || {});
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
FormElementTypes
|
|
51
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/form-types.ts
|
|
2
|
+
var FormElementTypes = /* @__PURE__ */ ((FormElementTypes2) => {
|
|
3
|
+
FormElementTypes2["textField"] = "textField";
|
|
4
|
+
FormElementTypes2["textArea"] = "textArea";
|
|
5
|
+
FormElementTypes2["dropdown"] = "dropdown";
|
|
6
|
+
FormElementTypes2["radio"] = "radio";
|
|
7
|
+
FormElementTypes2["checkbox"] = "checkbox";
|
|
8
|
+
FormElementTypes2["fileInput"] = "fileInput";
|
|
9
|
+
FormElementTypes2["richText"] = "richText";
|
|
10
|
+
FormElementTypes2["dynamicRow"] = "dynamicRow";
|
|
11
|
+
FormElementTypes2["attestation"] = "attestation";
|
|
12
|
+
FormElementTypes2["address"] = "address";
|
|
13
|
+
FormElementTypes2["addressComplete"] = "addressComplete";
|
|
14
|
+
FormElementTypes2["name"] = "name";
|
|
15
|
+
FormElementTypes2["firstMiddleLastName"] = "firstMiddleLastName";
|
|
16
|
+
FormElementTypes2["departments"] = "departments";
|
|
17
|
+
FormElementTypes2["contact"] = "contact";
|
|
18
|
+
FormElementTypes2["combobox"] = "combobox";
|
|
19
|
+
FormElementTypes2["formattedDate"] = "formattedDate";
|
|
20
|
+
return FormElementTypes2;
|
|
21
|
+
})(FormElementTypes || {});
|
|
22
|
+
export {
|
|
23
|
+
FormElementTypes
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gcforms/types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"author": "Canadian Digital Service",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"import": "./dist/index.mjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
19
22
|
"scripts": {
|
|
20
23
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
21
24
|
"prepare": "yarn && yarn build"
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type Responses = {
|
|
2
|
-
[key: string]: Response;
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
export type Response =
|
|
6
|
-
| string
|
|
7
|
-
| string[]
|
|
8
|
-
| number
|
|
9
|
-
| Record<string, unknown>[]
|
|
10
|
-
| FileInputResponse
|
|
11
|
-
| FileInputResponse[]
|
|
12
|
-
| Record<string, unknown>;
|
|
13
|
-
|
|
14
|
-
export type FileInputResponse = {
|
|
15
|
-
name: string | null;
|
|
16
|
-
size: number | null;
|
|
17
|
-
based64EncodedFile: string | null;
|
|
18
|
-
};
|
package/src/form-types.ts
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
// Utility type creator
|
|
2
|
-
export type TypeOmit<Type, Key extends PropertyKey> = {
|
|
3
|
-
[Property in keyof Type as Exclude<Property, Key>]: Type[Property];
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export type FormChangeEvent = {
|
|
7
|
-
target: {
|
|
8
|
-
value: string | number | boolean | string[];
|
|
9
|
-
name?: string;
|
|
10
|
-
type?: string;
|
|
11
|
-
checked?: boolean;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type Group = {
|
|
16
|
-
name: string;
|
|
17
|
-
titleEn: string;
|
|
18
|
-
titleFr: string;
|
|
19
|
-
nextAction?: string | NextActionRule[];
|
|
20
|
-
elements: string[]; // NOTE: these are elementIds
|
|
21
|
-
autoFlow?: boolean;
|
|
22
|
-
exitUrlEn?: string; // Used when a nextAction is set to "exit"
|
|
23
|
-
exitUrlFr?: string; // Used when a nextAction is set to "exit"
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type GroupsType = Record<string, Group>;
|
|
27
|
-
export type FormValues = Record<string, string | string[]>;
|
|
28
|
-
export type ChoiceRule = { elementId: string; choiceId: string };
|
|
29
|
-
export type NextActionRule = { groupId: string; choiceId: string };
|
|
30
|
-
export type HTMLTextInputTypeAttribute =
|
|
31
|
-
| "text"
|
|
32
|
-
| "email"
|
|
33
|
-
| "name"
|
|
34
|
-
| "number"
|
|
35
|
-
| "password"
|
|
36
|
-
| "search"
|
|
37
|
-
| "tel"
|
|
38
|
-
| "url";
|
|
39
|
-
|
|
40
|
-
// all the possible types of form elements
|
|
41
|
-
export enum FormElementTypes {
|
|
42
|
-
textField = "textField",
|
|
43
|
-
textArea = "textArea",
|
|
44
|
-
dropdown = "dropdown",
|
|
45
|
-
radio = "radio",
|
|
46
|
-
checkbox = "checkbox",
|
|
47
|
-
fileInput = "fileInput",
|
|
48
|
-
richText = "richText",
|
|
49
|
-
dynamicRow = "dynamicRow",
|
|
50
|
-
attestation = "attestation",
|
|
51
|
-
address = "address",
|
|
52
|
-
addressComplete = "addressComplete",
|
|
53
|
-
name = "name",
|
|
54
|
-
firstMiddleLastName = "firstMiddleLastName",
|
|
55
|
-
departments = "departments",
|
|
56
|
-
contact = "contact",
|
|
57
|
-
combobox = "combobox",
|
|
58
|
-
formattedDate = "formattedDate",
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type ConditionalRule = {
|
|
62
|
-
choiceId: string;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// used to define attributes on the validation object which controls form validation for
|
|
66
|
-
// individual field
|
|
67
|
-
export interface ValidationProperties {
|
|
68
|
-
required: boolean;
|
|
69
|
-
type?: HTMLTextInputTypeAttribute;
|
|
70
|
-
regex?: string;
|
|
71
|
-
maxLength?: number;
|
|
72
|
-
descriptionEN?: string;
|
|
73
|
-
descriptionFR?: string;
|
|
74
|
-
[key: string]: unknown;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// the choices available for fields with multiple options like dropdowns or radio buttons
|
|
78
|
-
export interface PropertyChoices {
|
|
79
|
-
en: string;
|
|
80
|
-
fr: string;
|
|
81
|
-
[key: string]: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type AddressComponents = {
|
|
85
|
-
canadianOnly?: boolean;
|
|
86
|
-
splitAddress?: boolean;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// defines the fields in the object that controls how form submissions are delivered
|
|
90
|
-
export interface DeliveryOption {
|
|
91
|
-
emailAddress: string;
|
|
92
|
-
emailSubjectEn?: string;
|
|
93
|
-
emailSubjectFr?: string;
|
|
94
|
-
[key: string]: string | undefined;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// used to define attributes for the properties of an element in the form
|
|
98
|
-
export interface ElementProperties {
|
|
99
|
-
titleEn: string;
|
|
100
|
-
titleFr: string;
|
|
101
|
-
placeholderEn?: string;
|
|
102
|
-
placeholderFr?: string;
|
|
103
|
-
descriptionEn?: string;
|
|
104
|
-
descriptionFr?: string;
|
|
105
|
-
validation?: ValidationProperties | undefined;
|
|
106
|
-
choices?: PropertyChoices[];
|
|
107
|
-
managedChoices?: string;
|
|
108
|
-
subElements?: FormElement[];
|
|
109
|
-
fileType?: string | undefined;
|
|
110
|
-
headingLevel?: string | undefined;
|
|
111
|
-
isSectional?: boolean;
|
|
112
|
-
maxNumberOfRows?: number;
|
|
113
|
-
autoComplete?: string;
|
|
114
|
-
dateFormat?: string;
|
|
115
|
-
conditionalRules?: ConditionalRule[];
|
|
116
|
-
full?: boolean;
|
|
117
|
-
addressComponents?: AddressComponents | undefined;
|
|
118
|
-
dynamicRow?: dynamicRowType;
|
|
119
|
-
[key: string]:
|
|
120
|
-
| string
|
|
121
|
-
| number
|
|
122
|
-
| boolean
|
|
123
|
-
| Array<PropertyChoices>
|
|
124
|
-
| Array<FormElement>
|
|
125
|
-
| ValidationProperties
|
|
126
|
-
| Array<ConditionalRule>
|
|
127
|
-
| AddressComponents
|
|
128
|
-
| dynamicRowType
|
|
129
|
-
| undefined;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// defines the fields in the object that controls form branding
|
|
133
|
-
export interface BrandProperties {
|
|
134
|
-
name?: string;
|
|
135
|
-
logoEn: string;
|
|
136
|
-
logoFr: string;
|
|
137
|
-
logoTitleEn: string;
|
|
138
|
-
logoTitleFr: string;
|
|
139
|
-
urlEn?: string;
|
|
140
|
-
urlFr?: string;
|
|
141
|
-
// if set to true the GC branding will be removed from the footer
|
|
142
|
-
disableGcBranding?: boolean;
|
|
143
|
-
[key: string]: string | boolean | undefined;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// used to define attributes for a form element or field
|
|
147
|
-
export interface FormElement {
|
|
148
|
-
id: number;
|
|
149
|
-
subId?: string;
|
|
150
|
-
type: FormElementTypes;
|
|
151
|
-
properties: ElementProperties;
|
|
152
|
-
onchange?: (event: FormChangeEvent) => void;
|
|
153
|
-
brand?: BrandProperties;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// defines the fields for the main form configuration object
|
|
157
|
-
export interface FormProperties {
|
|
158
|
-
titleEn: string;
|
|
159
|
-
titleFr: string;
|
|
160
|
-
introduction?: Record<string, string>;
|
|
161
|
-
privacyPolicy?: Record<string, string>;
|
|
162
|
-
confirmation?: Record<string, string>;
|
|
163
|
-
closedMessage?: Record<string, string>;
|
|
164
|
-
layout: number[];
|
|
165
|
-
groups?: GroupsType;
|
|
166
|
-
groupsLayout?: string[];
|
|
167
|
-
elements: FormElement[];
|
|
168
|
-
lastGeneratedElementId?: number;
|
|
169
|
-
brand?: BrandProperties;
|
|
170
|
-
formPurpose?: string;
|
|
171
|
-
[key: string]:
|
|
172
|
-
| string
|
|
173
|
-
| number
|
|
174
|
-
| boolean
|
|
175
|
-
| Array<string | number | FormElement>
|
|
176
|
-
| Record<string, string>
|
|
177
|
-
| BrandProperties
|
|
178
|
-
| GroupsType
|
|
179
|
-
| undefined;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export type dynamicRowType = {
|
|
183
|
-
rowTitleEn: string;
|
|
184
|
-
rowTitleFr: string;
|
|
185
|
-
addButtonTextEn: string;
|
|
186
|
-
removeButtonTextEn: string;
|
|
187
|
-
addButtonTextFr: string;
|
|
188
|
-
removeButtonTextFr: string;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
// defines the fields for the form record that is available in authenticated spaces and backend processes
|
|
192
|
-
export type FormRecord = {
|
|
193
|
-
id: string;
|
|
194
|
-
createdAt?: string;
|
|
195
|
-
updatedAt?: string;
|
|
196
|
-
name: string;
|
|
197
|
-
form: FormProperties;
|
|
198
|
-
isPublished: boolean;
|
|
199
|
-
deliveryOption?: DeliveryOption;
|
|
200
|
-
securityAttribute: SecurityAttribute;
|
|
201
|
-
closingDate?: string;
|
|
202
|
-
closedDetails?: ClosedDetails;
|
|
203
|
-
saveAndResume?: boolean;
|
|
204
|
-
[key: string]: string | boolean | FormProperties | DeliveryOption | ClosedDetails | undefined;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
export type SecurityAttribute = "Unclassified" | "Protected A" | "Protected B";
|
|
208
|
-
export type FormPurpose = "" | "admin" | "nonAdmin";
|
|
209
|
-
|
|
210
|
-
export type ClosedDetails = {
|
|
211
|
-
messageEn?: string;
|
|
212
|
-
messageFr?: string;
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
// defines the fields for the form record that is available to unauthenticated users
|
|
216
|
-
export type PublicFormRecord = TypeOmit<FormRecord, "name" | "deliveryOption">;
|
package/src/index.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
dynamicRowType,
|
|
3
|
-
FormElement,
|
|
4
|
-
Group,
|
|
5
|
-
FormElementTypes,
|
|
6
|
-
ElementProperties,
|
|
7
|
-
PropertyChoices,
|
|
8
|
-
BrandProperties,
|
|
9
|
-
DeliveryOption,
|
|
10
|
-
ConditionalRule,
|
|
11
|
-
FormRecord,
|
|
12
|
-
SecurityAttribute,
|
|
13
|
-
FormPurpose,
|
|
14
|
-
PublicFormRecord,
|
|
15
|
-
ValidationProperties,
|
|
16
|
-
FormProperties,
|
|
17
|
-
AddressComponents,
|
|
18
|
-
ClosedDetails,
|
|
19
|
-
} from "./form-types";
|
|
20
|
-
|
|
21
|
-
export type { Response, Responses, FileInputResponse } from "./form-response-types";
|
|
22
|
-
|
|
23
|
-
export { type dynamicRowType };
|
|
24
|
-
export type { FormElement };
|
|
25
|
-
export { FormElementTypes };
|
|
26
|
-
export type { Group };
|
|
27
|
-
export type { ElementProperties };
|
|
28
|
-
export type { PropertyChoices };
|
|
29
|
-
export type { BrandProperties };
|
|
30
|
-
export type { DeliveryOption };
|
|
31
|
-
export type { ConditionalRule };
|
|
32
|
-
export type { FormRecord };
|
|
33
|
-
export type { SecurityAttribute };
|
|
34
|
-
export type { FormPurpose };
|
|
35
|
-
export type { PublicFormRecord };
|
|
36
|
-
export type { ValidationProperties };
|
|
37
|
-
export type { FormProperties };
|
|
38
|
-
export type { AddressComponents };
|
|
39
|
-
export type { ClosedDetails };
|
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2020",
|
|
4
|
-
"downlevelIteration": true,
|
|
5
|
-
"module": "esnext",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": false,
|
|
10
|
-
"typeRoots": ["./src/@types"]
|
|
11
|
-
},
|
|
12
|
-
"include": ["src"],
|
|
13
|
-
"exclude": ["node_modules", "dist"]
|
|
14
|
-
}
|