Skip to content

Commit 68c3bd9

Browse files
Merge pull request #200 from onebeyond/improve-country-question
Add a new country question
2 parents e6815db + bddcea4 commit 68c3bd9

24 files changed

+3042
-1839
lines changed

README.md

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ Reminder: A custom link it will be indicated by the start of a '#' in the markdo
133133
https://user-images.githubusercontent.com/79102959/134894112-e4f38ced-0992-428c-95c3-bcdce20cd858.mp4
134134

135135

136-
137136
## Country
138137
| Option | Description | Type | Default |
139138
|--- |--- |:---: |:---: |
@@ -172,23 +171,24 @@ Reminder: the 'countryAndRegions' prop that can be sent in the ReactFormBuilder
172171
```
173172

174173
### Custom list country example:
175-
```yaml
174+
175+
```json
176176
{
177177
{
178-
countryName: 'MyOwnCountry1',
179-
countryShortCode: 'MC1'
178+
"countryName": "MyOwnCountry1",
179+
"countryShortCode": "MC1"
180180
},
181181
{
182-
countryName: 'MyOwnCountry2',
183-
countryShortCode: 'MC2'
182+
"countryName": "MyOwnCountry2",
183+
"countryShortCode": "MC2"
184184
},
185185
{
186-
countryName: 'MyOwnCountry3',
187-
countryShortCode: 'MC3'
186+
"countryName": "MyOwnCountry3",
187+
"countryShortCode": "MC3"
188188
},
189189
{
190-
countryName: 'MyOwnCountry4',
191-
countryShortCode: 'MC4'
190+
"countryName": "MyOwnCountry4",
191+
"countryShortCode": "MC4"
192192
}
193193
}
194194

@@ -207,10 +207,62 @@ Reminder: the 'countryAndRegions' prop that can be sent in the ReactFormBuilder
207207
}
208208
```
209209

210-
211210
https://user-images.githubusercontent.com/79102959/134897712-95e4391c-cfbb-42cd-b813-06596d9b7096.mov
212211

212+
## Country v2
213+
214+
| Option | Description | Type | Default |
215+
| ------ | ----------- | :---: | :---: |
216+
| name* | Country component name | string | |
217+
| type* | Must be `country_v2` | string | |
218+
| label | Text shown over the country question | string | '' |
219+
| placeholder | Placeholder displayed in the select | string | '' |
220+
| **config** | See table below | json | {} |
221+
| **errorMessages** | Validation errors | json | {} |
222+
| **registerConfig** | Validation rules | json | {} |
223+
224+
### **config** options
213225

226+
| Option | Description | Type | Default |
227+
| ------ | ----------- | :---: | :---: |
228+
| whitelist | List of ISO 3166-1 alpha-2 codes of the countries allowed in the list. This is mutually exclusive with `blacklist` and `whitelist`takes precedence. | string[] | [] |
229+
| blacklist | List of ISO 3166-1 alpha-2 codes of the countries not allowed in the list. This is mutually exclusive with `whitelist` and `whitelist`takes precedence. | string[] | [] |
230+
| priorityOptions | List of ISO 3166-1 alpha-2 codes of the countries to be displayed first in the list. Ex: ['GB', 'ES'] | string[] | [] |
231+
| search | Allows the user to search typing in the select control | boolean | false |
232+
| flag | Shows the flag of the country before the name | boolean | false |
233+
234+
The countires will be displayed in the language according to the `language` attribute of the FormBuilder. It should use the ISO 639-1 code of the language to display countries names. [Available laguages](https://github.com/michaelwittig/node-i18n-iso-countries?tab=readme-ov-file#supported-languages-iso-639-1).
235+
236+
### Country v2 example:
237+
238+
```json
239+
{
240+
"name": "country_of_residence",
241+
"placeholder": "Select your country of residence",
242+
"type": "country_v2",
243+
"label": "Country of residence",
244+
"errorMessages": {
245+
"required": "This field is required"
246+
},
247+
"registerConfig": {
248+
"required": true
249+
},
250+
"config": {
251+
"whitelist": [
252+
"DE",
253+
"ES",
254+
"FR",
255+
"IT",
256+
"PT"
257+
],
258+
"priorityOptions": [
259+
"ES",
260+
"PT"
261+
],
262+
"flag": true
263+
}
264+
}
265+
```
214266

215267
## Date
216268
| Option | Description | Type | Default |
@@ -930,9 +982,11 @@ Next, we can see different attributes and tags to adjust the accessibility of th
930982
<div>
931983
<p> I confirm I am aged 18 years or older, a resident of the United Kingdom and have read and agree to the competition terms and condition and privacy policy</p>
932984
</div>
933-
934985
```
935986
987+
# Storybook
988+
989+
TODO: npx storybook@next automigrate
936990
937991
# To contribute
938992

example/.eslintrc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var OFF = 0,
1+
const OFF = 0,
22
WARN = 1,
33
ERROR = 2
44

@@ -223,6 +223,7 @@ module.exports = exports = {
223223
'spaced-comment': [WARN, 'always'],
224224
'import/no-duplicates': WARN,
225225
'react/jsx-no-bind': WARN,
226-
'wrap-regex': WARN
226+
'wrap-regex': WARN,
227+
'no-console': WARN,
227228
}
228229
}

0 commit comments

Comments
 (0)