@gcforms/types 0.0.1
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/form-response-types.d.ts +9 -0
- package/dist/form-response-types.js +1 -0
- package/dist/form-types.d.ts +165 -0
- package/dist/form-types.js +21 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +2 -0
- package/package.json +22 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Responses = {
|
|
2
|
+
[key: string]: Response;
|
|
3
|
+
};
|
|
4
|
+
export type Response = string | string[] | number | Record<string, unknown>[] | FileInputResponse | FileInputResponse[] | Record<string, unknown>;
|
|
5
|
+
export type FileInputResponse = {
|
|
6
|
+
name: string | null;
|
|
7
|
+
size: number | null;
|
|
8
|
+
based64EncodedFile: string | null;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
export type TypeOmit<Type, Key extends PropertyKey> = {
|
|
2
|
+
[Property in keyof Type as Exclude<Property, Key>]: Type[Property];
|
|
3
|
+
};
|
|
4
|
+
export type FormChangeEvent = {
|
|
5
|
+
target: {
|
|
6
|
+
value: string | number | boolean | string[];
|
|
7
|
+
name?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export 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
|
+
export type GroupsType = Record<string, Group>;
|
|
23
|
+
export type FormValues = Record<string, string | string[]>;
|
|
24
|
+
export type ChoiceRule = {
|
|
25
|
+
elementId: string;
|
|
26
|
+
choiceId: string;
|
|
27
|
+
};
|
|
28
|
+
export type NextActionRule = {
|
|
29
|
+
groupId: string;
|
|
30
|
+
choiceId: string;
|
|
31
|
+
};
|
|
32
|
+
export type HTMLTextInputTypeAttribute = "text" | "email" | "name" | "number" | "password" | "search" | "tel" | "url";
|
|
33
|
+
export declare enum FormElementTypes {
|
|
34
|
+
textField = "textField",
|
|
35
|
+
textArea = "textArea",
|
|
36
|
+
dropdown = "dropdown",
|
|
37
|
+
radio = "radio",
|
|
38
|
+
checkbox = "checkbox",
|
|
39
|
+
fileInput = "fileInput",
|
|
40
|
+
richText = "richText",
|
|
41
|
+
dynamicRow = "dynamicRow",
|
|
42
|
+
attestation = "attestation",
|
|
43
|
+
address = "address",
|
|
44
|
+
addressComplete = "addressComplete",
|
|
45
|
+
name = "name",
|
|
46
|
+
firstMiddleLastName = "firstMiddleLastName",
|
|
47
|
+
departments = "departments",
|
|
48
|
+
contact = "contact",
|
|
49
|
+
combobox = "combobox",
|
|
50
|
+
formattedDate = "formattedDate"
|
|
51
|
+
}
|
|
52
|
+
export type ConditionalRule = {
|
|
53
|
+
choiceId: string;
|
|
54
|
+
};
|
|
55
|
+
export interface ValidationProperties {
|
|
56
|
+
required: boolean;
|
|
57
|
+
type?: HTMLTextInputTypeAttribute;
|
|
58
|
+
regex?: string;
|
|
59
|
+
maxLength?: number;
|
|
60
|
+
descriptionEN?: string;
|
|
61
|
+
descriptionFR?: string;
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
}
|
|
64
|
+
export interface PropertyChoices {
|
|
65
|
+
en: string;
|
|
66
|
+
fr: string;
|
|
67
|
+
[key: string]: string;
|
|
68
|
+
}
|
|
69
|
+
export type AddressComponents = {
|
|
70
|
+
canadianOnly?: boolean;
|
|
71
|
+
splitAddress?: boolean;
|
|
72
|
+
};
|
|
73
|
+
export interface DeliveryOption {
|
|
74
|
+
emailAddress: string;
|
|
75
|
+
emailSubjectEn?: string;
|
|
76
|
+
emailSubjectFr?: string;
|
|
77
|
+
[key: string]: string | undefined;
|
|
78
|
+
}
|
|
79
|
+
export interface ElementProperties {
|
|
80
|
+
titleEn: string;
|
|
81
|
+
titleFr: string;
|
|
82
|
+
placeholderEn?: string;
|
|
83
|
+
placeholderFr?: string;
|
|
84
|
+
descriptionEn?: string;
|
|
85
|
+
descriptionFr?: string;
|
|
86
|
+
validation?: ValidationProperties | undefined;
|
|
87
|
+
choices?: PropertyChoices[];
|
|
88
|
+
managedChoices?: string;
|
|
89
|
+
subElements?: FormElement[];
|
|
90
|
+
fileType?: string | undefined;
|
|
91
|
+
headingLevel?: string | undefined;
|
|
92
|
+
isSectional?: boolean;
|
|
93
|
+
maxNumberOfRows?: number;
|
|
94
|
+
autoComplete?: string;
|
|
95
|
+
dateFormat?: string;
|
|
96
|
+
conditionalRules?: ConditionalRule[];
|
|
97
|
+
full?: boolean;
|
|
98
|
+
addressComponents?: AddressComponents | undefined;
|
|
99
|
+
dynamicRow?: dynamicRowType;
|
|
100
|
+
[key: string]: string | number | boolean | Array<PropertyChoices> | Array<FormElement> | ValidationProperties | Array<ConditionalRule> | AddressComponents | dynamicRowType | undefined;
|
|
101
|
+
}
|
|
102
|
+
export interface BrandProperties {
|
|
103
|
+
name?: string;
|
|
104
|
+
logoEn: string;
|
|
105
|
+
logoFr: string;
|
|
106
|
+
logoTitleEn: string;
|
|
107
|
+
logoTitleFr: string;
|
|
108
|
+
urlEn?: string;
|
|
109
|
+
urlFr?: string;
|
|
110
|
+
disableGcBranding?: boolean;
|
|
111
|
+
[key: string]: string | boolean | undefined;
|
|
112
|
+
}
|
|
113
|
+
export interface FormElement {
|
|
114
|
+
id: number;
|
|
115
|
+
subId?: string;
|
|
116
|
+
type: FormElementTypes;
|
|
117
|
+
properties: ElementProperties;
|
|
118
|
+
onchange?: (event: FormChangeEvent) => void;
|
|
119
|
+
brand?: BrandProperties;
|
|
120
|
+
}
|
|
121
|
+
export interface FormProperties {
|
|
122
|
+
titleEn: string;
|
|
123
|
+
titleFr: string;
|
|
124
|
+
introduction?: Record<string, string>;
|
|
125
|
+
privacyPolicy?: Record<string, string>;
|
|
126
|
+
confirmation?: Record<string, string>;
|
|
127
|
+
closedMessage?: Record<string, string>;
|
|
128
|
+
layout: number[];
|
|
129
|
+
groups?: GroupsType;
|
|
130
|
+
groupsLayout?: string[];
|
|
131
|
+
elements: FormElement[];
|
|
132
|
+
lastGeneratedElementId?: number;
|
|
133
|
+
brand?: BrandProperties;
|
|
134
|
+
formPurpose?: string;
|
|
135
|
+
[key: string]: string | number | boolean | Array<string | number | FormElement> | Record<string, string> | BrandProperties | GroupsType | undefined;
|
|
136
|
+
}
|
|
137
|
+
export type dynamicRowType = {
|
|
138
|
+
rowTitleEn: string;
|
|
139
|
+
rowTitleFr: string;
|
|
140
|
+
addButtonTextEn: string;
|
|
141
|
+
removeButtonTextEn: string;
|
|
142
|
+
addButtonTextFr: string;
|
|
143
|
+
removeButtonTextFr: string;
|
|
144
|
+
};
|
|
145
|
+
export type FormRecord = {
|
|
146
|
+
id: string;
|
|
147
|
+
createdAt?: string;
|
|
148
|
+
updatedAt?: string;
|
|
149
|
+
name: string;
|
|
150
|
+
form: FormProperties;
|
|
151
|
+
isPublished: boolean;
|
|
152
|
+
deliveryOption?: DeliveryOption;
|
|
153
|
+
securityAttribute: SecurityAttribute;
|
|
154
|
+
closingDate?: string;
|
|
155
|
+
closedDetails?: ClosedDetails;
|
|
156
|
+
saveAndResume?: boolean;
|
|
157
|
+
[key: string]: string | boolean | FormProperties | DeliveryOption | ClosedDetails | undefined;
|
|
158
|
+
};
|
|
159
|
+
export type SecurityAttribute = "Unclassified" | "Protected A" | "Protected B";
|
|
160
|
+
export type FormPurpose = "" | "admin" | "nonAdmin";
|
|
161
|
+
export type ClosedDetails = {
|
|
162
|
+
messageEn?: string;
|
|
163
|
+
messageFr?: string;
|
|
164
|
+
};
|
|
165
|
+
export type PublicFormRecord = TypeOmit<FormRecord, "name" | "deliveryOption">;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// all the possible types of form elements
|
|
2
|
+
export var FormElementTypes;
|
|
3
|
+
(function (FormElementTypes) {
|
|
4
|
+
FormElementTypes["textField"] = "textField";
|
|
5
|
+
FormElementTypes["textArea"] = "textArea";
|
|
6
|
+
FormElementTypes["dropdown"] = "dropdown";
|
|
7
|
+
FormElementTypes["radio"] = "radio";
|
|
8
|
+
FormElementTypes["checkbox"] = "checkbox";
|
|
9
|
+
FormElementTypes["fileInput"] = "fileInput";
|
|
10
|
+
FormElementTypes["richText"] = "richText";
|
|
11
|
+
FormElementTypes["dynamicRow"] = "dynamicRow";
|
|
12
|
+
FormElementTypes["attestation"] = "attestation";
|
|
13
|
+
FormElementTypes["address"] = "address";
|
|
14
|
+
FormElementTypes["addressComplete"] = "addressComplete";
|
|
15
|
+
FormElementTypes["name"] = "name";
|
|
16
|
+
FormElementTypes["firstMiddleLastName"] = "firstMiddleLastName";
|
|
17
|
+
FormElementTypes["departments"] = "departments";
|
|
18
|
+
FormElementTypes["contact"] = "contact";
|
|
19
|
+
FormElementTypes["combobox"] = "combobox";
|
|
20
|
+
FormElementTypes["formattedDate"] = "formattedDate";
|
|
21
|
+
})(FormElementTypes || (FormElementTypes = {}));
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { dynamicRowType, FormElement, Group, FormElementTypes, ElementProperties, PropertyChoices, BrandProperties, DeliveryOption, ConditionalRule, FormRecord, SecurityAttribute, FormPurpose, PublicFormRecord, ValidationProperties, FormProperties, AddressComponents, ClosedDetails } from "./form-types";
|
|
2
|
+
export type { Response, Responses, FileInputResponse } from "./form-response-types";
|
|
3
|
+
export { type dynamicRowType };
|
|
4
|
+
export type { FormElement };
|
|
5
|
+
export { FormElementTypes };
|
|
6
|
+
export type { Group };
|
|
7
|
+
export type { ElementProperties };
|
|
8
|
+
export type { PropertyChoices };
|
|
9
|
+
export type { BrandProperties };
|
|
10
|
+
export type { DeliveryOption };
|
|
11
|
+
export type { ConditionalRule };
|
|
12
|
+
export type { FormRecord };
|
|
13
|
+
export type { SecurityAttribute };
|
|
14
|
+
export type { FormPurpose };
|
|
15
|
+
export type { PublicFormRecord };
|
|
16
|
+
export type { ValidationProperties };
|
|
17
|
+
export type { FormProperties };
|
|
18
|
+
export type { AddressComponents };
|
|
19
|
+
export type { ClosedDetails };
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gcforms/types",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"prepare": "yarn && yarn build"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^20.11.0",
|
|
20
|
+
"typescript": "^5.3.3"
|
|
21
|
+
}
|
|
22
|
+
}
|