@remoteoss/json-schema-form 0.1.0-beta.0

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.
@@ -0,0 +1,223 @@
1
+ import {
2
+ mockTextInput,
3
+ mockNumberInput,
4
+ mockEmailInput,
5
+ mockCheckboxInput,
6
+ mockFileInput,
7
+ mockSelectInputSolo,
8
+ } from './helpers';
9
+
10
+ export const schemaInputTypeTextarea = {
11
+ properties: {
12
+ comment: {
13
+ title: 'Your comment',
14
+ presentation: {
15
+ inputType: 'textarea',
16
+ },
17
+ maxLength: 250,
18
+ type: 'string',
19
+ },
20
+ },
21
+ required: ['comment'],
22
+ };
23
+
24
+ export const inputTypeCountriesSolo = {
25
+ title: 'Countries',
26
+ oneOf: [
27
+ { title: 'Afghanistan', const: 'Afghanistan' },
28
+ { title: 'Albania', const: 'Albania' },
29
+ { title: 'Algeria', const: 'Algeria' },
30
+ ],
31
+ type: 'string',
32
+ presentation: {
33
+ inputType: 'countries',
34
+ },
35
+ };
36
+
37
+ export const schemaInputTypeCountriesSolo = {
38
+ properties: {
39
+ birthplace: {
40
+ ...inputTypeCountriesSolo,
41
+ title: 'Birthplace',
42
+ description: 'Where were you born?',
43
+ },
44
+ },
45
+ required: ['birthplace'],
46
+ };
47
+
48
+ export const schemaInputTypeCountriesMultiple = {
49
+ properties: {
50
+ nationality: {
51
+ title: 'Nationality',
52
+ description: 'Where are you a legal citizen?',
53
+ items: {
54
+ anyOf: [
55
+ { title: 'Afghanistan', const: 'Afghanistan' },
56
+ { title: 'Albania', const: 'Albania' },
57
+ { title: 'Algeria', const: 'Algeria' },
58
+ ],
59
+ },
60
+ type: 'array',
61
+ presentation: {
62
+ inputType: 'countries',
63
+ },
64
+ },
65
+ },
66
+ required: ['nationality'],
67
+ };
68
+
69
+ export const schemaInputTypeFileUploadLater = {
70
+ properties: {
71
+ b_file: {
72
+ ...mockFileInput,
73
+ title: 'File skippable',
74
+ 'x-jsf-presentation': {
75
+ ...mockFileInput['x-jsf-presentation'],
76
+ skippableLabel: "I don't have this document yet.",
77
+ description:
78
+ 'File input, with attribute "allowLaterUpload". This tells the API to mark the file as skipped so that it is asked again later in the process.',
79
+ allowLaterUpload: true,
80
+ },
81
+ },
82
+ },
83
+ };
84
+
85
+ export const schemaInputTypeTel = {
86
+ properties: {
87
+ phone_number: {
88
+ title: 'Phone number',
89
+ description: 'Enter your telephone number',
90
+ type: 'string',
91
+ pattern: '^(\\+|00)[0-9]{6,}$',
92
+ maxLength: 30,
93
+ presentation: {
94
+ inputType: 'tel',
95
+ },
96
+ errorMessage: {
97
+ maxLength: 'Must be at most 30 digits',
98
+ pattern: 'Please insert only the country code and phone number, without letters or spaces',
99
+ },
100
+ },
101
+ },
102
+ required: ['phone_number'],
103
+ };
104
+
105
+ const mockTelInput = {
106
+ title: 'Phone number',
107
+ description: 'Enter your telephone number',
108
+ maxLength: 30,
109
+ presentation: {
110
+ inputType: 'tel',
111
+ },
112
+ pattern: '^(\\+|00)\\d*$',
113
+ type: 'string',
114
+ };
115
+
116
+ export const mockMoneyInput = {
117
+ title: 'Weekly salary',
118
+ description: 'This field has a min and max values. Max has a custom error message.',
119
+ presentation: {
120
+ inputType: 'money',
121
+ currency: 'EUR',
122
+ },
123
+ $comment: 'The value is in cents format. e.g. 1000 -> 10.00€',
124
+ minimum: 100000,
125
+ maximum: 500000,
126
+ 'x-jsf-errorMessage': {
127
+ type: 'Please, use US standard currency format. Ex: 1024.12',
128
+ maximum: 'No more than €5000.00',
129
+ },
130
+ type: 'integer',
131
+ };
132
+
133
+ export const schemaInputTypeMoney = {
134
+ properties: {
135
+ salary: mockMoneyInput,
136
+ },
137
+ required: ['salary'],
138
+ };
139
+
140
+ export const schemaCustomComponentWithAck = {
141
+ properties: {
142
+ salary: mockMoneyInput,
143
+ terms: mockCheckboxInput,
144
+ },
145
+ required: ['salary'],
146
+ };
147
+
148
+ export const schemaCustomComponent = {
149
+ properties: {
150
+ salary: {
151
+ title: 'Monthly gross salary',
152
+ description: 'This field gets represented by a custom UI Component.',
153
+ presentation: {
154
+ inputType: 'money',
155
+ currency: 'EUR',
156
+ },
157
+ type: 'integer',
158
+ 'x-jsf-errorMessage': {
159
+ type: 'Please, use US standard currency format. Ex: 1024.12',
160
+ },
161
+ },
162
+ },
163
+ required: ['salary'],
164
+ };
165
+
166
+ export const schemaInputTypeHidden = {
167
+ properties: {
168
+ a_hidden_field_text: {
169
+ ...mockTextInput,
170
+ title: 'Text hidden',
171
+ 'x-jsf-presentation': { inputType: 'hidden' },
172
+ default: '12345',
173
+ },
174
+ a_hidden_field_number: {
175
+ ...mockNumberInput,
176
+ title: 'Number hidden',
177
+ 'x-jsf-presentation': { inputType: 'hidden' },
178
+ default: 5,
179
+ },
180
+ a_hidden_field_tel: {
181
+ ...mockTelInput,
182
+ title: 'Tel hidden',
183
+ 'x-jsf-presentation': { inputType: 'hidden' },
184
+ default: '+123456789',
185
+ },
186
+ a_hidden_field_email: {
187
+ ...mockEmailInput,
188
+ title: 'Email hidden',
189
+ 'x-jsf-presentation': { inputType: 'hidden' },
190
+ default: 'test@remote.com',
191
+ },
192
+ a_hidden_field_money: {
193
+ ...mockMoneyInput,
194
+ title: 'Money hidden',
195
+ 'x-jsf-presentation': { inputType: 'hidden', currency: 'EUR' },
196
+ minimum: 0,
197
+ default: 12.3,
198
+ },
199
+ a_hidden_select: {
200
+ ...mockSelectInputSolo,
201
+ title: 'Select hidden',
202
+ 'x-jsf-presentation': { inputType: 'hidden' },
203
+ default: 'Travel Bonus',
204
+ },
205
+ a_hidden_select_multiple: {
206
+ ...schemaInputTypeCountriesMultiple.properties.nationality,
207
+ title: 'Select multi hidden',
208
+ default: ['Albania, Algeria'],
209
+ 'x-jsf-presentation': { inputType: 'hidden' },
210
+ const: ['Albania, Algeria'],
211
+ type: 'array',
212
+ },
213
+ },
214
+ required: [
215
+ 'a_hidden_field_text',
216
+ 'a_hidden_field_number',
217
+ 'a_hidden_field_tel',
218
+ 'a_hidden_field_email',
219
+ 'a_hidden_field_money',
220
+ 'a_hidden_select',
221
+ 'a_hidden_select_multiple,',
222
+ ],
223
+ };