@zengenti/contensis-react-base 3.0.2-beta.2 → 3.0.2-beta.21

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.
Files changed (110) hide show
  1. package/cjs/{App-ee485b92.js → App-21a7d836.js} +120 -432
  2. package/cjs/App-21a7d836.js.map +1 -0
  3. package/cjs/ContensisDeliveryApi-c079b03a.js +231 -0
  4. package/cjs/ContensisDeliveryApi-c079b03a.js.map +1 -0
  5. package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-7f0d107a.js} +23 -37
  6. package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-7f0d107a.js.map} +1 -1
  7. package/cjs/{ToJs-a9a8522b.js → ToJs-6e9cfa69.js} +3 -4
  8. package/cjs/{ToJs-a9a8522b.js.map → ToJs-6e9cfa69.js.map} +1 -1
  9. package/cjs/client.js +20 -27
  10. package/cjs/client.js.map +1 -1
  11. package/cjs/contensis-react-base.js +124 -188
  12. package/cjs/contensis-react-base.js.map +1 -1
  13. package/cjs/forms.js +1488 -272
  14. package/cjs/forms.js.map +1 -1
  15. package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-7c363211.js} +1 -4
  16. package/cjs/{fromJSLeaveImmer-e74c673c.js.map → fromJSLeaveImmer-7c363211.js.map} +1 -1
  17. package/cjs/{login-840860bc.js → login-2a6b5be0.js} +64 -113
  18. package/cjs/login-2a6b5be0.js.map +1 -0
  19. package/cjs/{reducers-3a4f8971.js → reducers-9afb5f89.js} +14 -31
  20. package/cjs/reducers-9afb5f89.js.map +1 -0
  21. package/cjs/redux.js +17 -17
  22. package/cjs/redux.js.map +1 -1
  23. package/cjs/routing.js +6 -7
  24. package/cjs/routing.js.map +1 -1
  25. package/cjs/{sagas-8a20e424.js → sagas-e04b94c1.js} +225 -301
  26. package/cjs/sagas-e04b94c1.js.map +1 -0
  27. package/cjs/search.js +68 -94
  28. package/cjs/search.js.map +1 -1
  29. package/cjs/{selectors-656da4b7.js → selectors-bcca60f4.js} +89 -8
  30. package/cjs/selectors-bcca60f4.js.map +1 -0
  31. package/cjs/urls-6fcaf4c6.js.map +1 -1
  32. package/cjs/user.js +4 -13
  33. package/cjs/user.js.map +1 -1
  34. package/cjs/util.js +45 -53
  35. package/cjs/util.js.map +1 -1
  36. package/cjs/{version-78dfc3bd.js → version-4077e706.js} +50 -159
  37. package/cjs/version-4077e706.js.map +1 -0
  38. package/cjs/version-fe28099e.js +98 -0
  39. package/cjs/version-fe28099e.js.map +1 -0
  40. package/esm/{App-640239d2.js → App-2af18a99.js} +102 -412
  41. package/esm/App-2af18a99.js.map +1 -0
  42. package/esm/ContensisDeliveryApi-5660ee0e.js +227 -0
  43. package/esm/ContensisDeliveryApi-5660ee0e.js.map +1 -0
  44. package/esm/{RouteLoader-5171c63f.js → RouteLoader-6eac364e.js} +22 -36
  45. package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-6eac364e.js.map} +1 -1
  46. package/esm/{ToJs-4e02a04d.js → ToJs-9b30636a.js} +3 -4
  47. package/esm/{ToJs-4e02a04d.js.map → ToJs-9b30636a.js.map} +1 -1
  48. package/esm/client.js +15 -22
  49. package/esm/client.js.map +1 -1
  50. package/esm/contensis-react-base.js +119 -183
  51. package/esm/contensis-react-base.js.map +1 -1
  52. package/esm/forms.js +1490 -274
  53. package/esm/forms.js.map +1 -1
  54. package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-e2dacd63.js} +1 -4
  55. package/esm/{fromJSLeaveImmer-0114ffcf.js.map → fromJSLeaveImmer-e2dacd63.js.map} +1 -1
  56. package/esm/{login-57395c9c.js → login-71ff3fcb.js} +63 -112
  57. package/esm/login-71ff3fcb.js.map +1 -0
  58. package/esm/{reducers-8e5d6232.js → reducers-3d5c37d1.js} +14 -31
  59. package/esm/reducers-3d5c37d1.js.map +1 -0
  60. package/esm/redux.js +9 -8
  61. package/esm/redux.js.map +1 -1
  62. package/esm/routing.js +3 -4
  63. package/esm/routing.js.map +1 -1
  64. package/esm/{sagas-e576b6f6.js → sagas-933a8fc8.js} +177 -254
  65. package/esm/sagas-933a8fc8.js.map +1 -0
  66. package/esm/search.js +69 -95
  67. package/esm/search.js.map +1 -1
  68. package/esm/{selectors-a5e5835b.js → selectors-74de49a3.js} +75 -8
  69. package/esm/selectors-74de49a3.js.map +1 -0
  70. package/esm/urls-eac9a747.js.map +1 -1
  71. package/esm/user.js +6 -15
  72. package/esm/user.js.map +1 -1
  73. package/esm/util.js +42 -53
  74. package/esm/util.js.map +1 -1
  75. package/esm/version-b15807c5.js +87 -0
  76. package/esm/version-b15807c5.js.map +1 -0
  77. package/esm/{version-e3a5ec66.js → version-ef107106.js} +37 -142
  78. package/esm/version-ef107106.js.map +1 -0
  79. package/models/redux/appstate.d.ts +1 -0
  80. package/models/routing/redux/selectors.d.ts +2 -1
  81. package/models/search/models/Queries.d.ts +2 -1
  82. package/models/search/models/Search.d.ts +2 -0
  83. package/models/search/models/SearchActions.d.ts +3 -3
  84. package/models/search/redux/actions.d.ts +6 -6
  85. package/models/search/redux/util.d.ts +1 -1
  86. package/models/search/search/expressions.d.ts +1 -1
  87. package/models/server/features/linkdepth-api/search.d.ts +1 -1
  88. package/models/util/ContensisDeliveryApi.d.ts +6 -0
  89. package/models/util/index.d.ts +1 -0
  90. package/package.json +1 -1
  91. package/cjs/App-ee485b92.js.map +0 -1
  92. package/cjs/actions-8dc9e8de.js +0 -87
  93. package/cjs/actions-8dc9e8de.js.map +0 -1
  94. package/cjs/login-840860bc.js.map +0 -1
  95. package/cjs/reducers-3a4f8971.js.map +0 -1
  96. package/cjs/sagas-8a20e424.js.map +0 -1
  97. package/cjs/selectors-656da4b7.js.map +0 -1
  98. package/cjs/version-78dfc3bd.js.map +0 -1
  99. package/cjs/version-eba6d09b.js +0 -20
  100. package/cjs/version-eba6d09b.js.map +0 -1
  101. package/esm/App-640239d2.js.map +0 -1
  102. package/esm/actions-180948dd.js +0 -72
  103. package/esm/actions-180948dd.js.map +0 -1
  104. package/esm/login-57395c9c.js.map +0 -1
  105. package/esm/reducers-8e5d6232.js.map +0 -1
  106. package/esm/sagas-e576b6f6.js.map +0 -1
  107. package/esm/selectors-a5e5835b.js.map +0 -1
  108. package/esm/version-2485e2fb.js +0 -15
  109. package/esm/version-2485e2fb.js.map +0 -1
  110. package/esm/version-e3a5ec66.js.map +0 -1
package/esm/forms.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { produce } from 'immer';
2
- import { takeEvery, takeLatest, put, call, select, all } from '@redux-saga/core/effects';
2
+ import { takeEvery, takeLatest, put, select, all, call } from '@redux-saga/core/effects';
3
3
  import { createSelector } from 'reselect';
4
4
  import { selectors as selectors$1 } from '@zengenti/contensis-react-base/routing';
5
- import React, { createContext, useState, useEffect } from 'react';
5
+ import React, { createContext, useState, useEffect, useRef, forwardRef } from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { useSelector, useDispatch } from 'react-redux';
8
8
  import styled, { ThemeProvider as ThemeProvider$1, css } from 'styled-components';
@@ -26,7 +26,8 @@ const SET_FIELD_ERROR = `${ACTION_PREFIX}SET_FIELD_ERROR`;
26
26
  const SET_DATE_RANGE_VALUES = `${ACTION_PREFIX}SET_DATE_RANGE_VALUES`;
27
27
  const SET_FORM_ENTRIES = `${ACTION_PREFIX}SET_FORM_ENTRIES`;
28
28
  const SET_SUCCESS_MESSAGE = `${ACTION_PREFIX}SET_SUCCESS_MESSAGE`;
29
- const SET_CHECKBOX_VALUE = `${ACTION_PREFIX}SET_CHECKBOX_VALUE`;
29
+ const SET_MULTIPLE_CHECKBOX_VALUE = `${ACTION_PREFIX}SET_MULTIPLE_CHECKBOX_VALUE`;
30
+ const SET_SINGLE_CHECKBOX_VALUE = `${ACTION_PREFIX}SET_SINGLE_CHECKBOX_VALUE`;
30
31
 
31
32
  const initialSettings = {
32
33
  recaptcha: {
@@ -75,7 +76,6 @@ var reducer = produce((state, action) => {
75
76
  state[formId] = initialFormData;
76
77
  return;
77
78
  }
78
-
79
79
  case SET_FORM_DATA:
80
80
  {
81
81
  const {
@@ -96,7 +96,6 @@ var reducer = produce((state, action) => {
96
96
  state[formId].settings = settings;
97
97
  return;
98
98
  }
99
-
100
99
  case SET_CURRENT_PAGE:
101
100
  {
102
101
  const {
@@ -110,7 +109,6 @@ var reducer = produce((state, action) => {
110
109
  state[formId].pagingInfo.pageCount = pageCount;
111
110
  return;
112
111
  }
113
-
114
112
  case SET_FIELD_VALUE:
115
113
  {
116
114
  const {
@@ -121,32 +119,40 @@ var reducer = produce((state, action) => {
121
119
  state[formId].data[id] = value;
122
120
  return;
123
121
  }
124
-
125
122
  case SET_DEFAULT_FIELD_VALUE:
126
123
  {
127
124
  const {
128
125
  formId,
129
126
  value
130
127
  } = action || {};
131
- state[formId].data = value;
128
+ state[formId].data = {
129
+ ...state[formId].data,
130
+ ...value
131
+ };
132
132
  return;
133
133
  }
134
-
135
- case SET_CHECKBOX_VALUE:
134
+ case SET_SINGLE_CHECKBOX_VALUE:
136
135
  {
137
136
  const {
138
137
  formId,
139
138
  id,
140
- value,
141
- isChecked
139
+ value
142
140
  } = action || {};
143
- let values = state[formId].data[id] || [];
144
- if (isChecked) state[formId].data[id] = { ...values,
141
+ state[formId].data[id] = value;
142
+ return;
143
+ }
144
+ case SET_MULTIPLE_CHECKBOX_VALUE:
145
+ {
146
+ const {
147
+ formId,
148
+ id,
149
+ label,
145
150
  value
146
- };else state[formId].data[id] = values.filter(v => v !== value);
151
+ } = action || {};
152
+ const checked = state[formId].data[id] || [];
153
+ if (value) state[formId].data[id] = [...checked, label];else state[formId].data[id] = checked.filter(v => v !== label);
147
154
  return;
148
155
  }
149
-
150
156
  case SET_DATE_RANGE_VALUES:
151
157
  {
152
158
  const {
@@ -158,7 +164,6 @@ var reducer = produce((state, action) => {
158
164
  state[formId].data[id][dateType] = value;
159
165
  return;
160
166
  }
161
-
162
167
  case SET_FIELD_ERROR:
163
168
  {
164
169
  const {
@@ -168,7 +173,6 @@ var reducer = produce((state, action) => {
168
173
  state[formId].fieldErrors = value;
169
174
  return;
170
175
  }
171
-
172
176
  case SET_SUBMITTING_FORM:
173
177
  {
174
178
  const {
@@ -178,7 +182,6 @@ var reducer = produce((state, action) => {
178
182
  state[formId].status.isSubmitting = isSubmitting;
179
183
  return;
180
184
  }
181
-
182
185
  case SUBMIT_FORM_SUCCESS:
183
186
  {
184
187
  const {
@@ -190,7 +193,6 @@ var reducer = produce((state, action) => {
190
193
  state[formId].status.validation.sent = false;
191
194
  return;
192
195
  }
193
-
194
196
  case SUBMIT_FORM_FOR_VALIDATION:
195
197
  {
196
198
  const {
@@ -202,17 +204,15 @@ var reducer = produce((state, action) => {
202
204
  state[formId].status.hasError = false;
203
205
  return;
204
206
  }
205
-
206
207
  case SET_SUCCESS_MESSAGE:
207
208
  {
208
209
  const {
209
210
  formId,
210
211
  message
211
212
  } = action || {};
212
- state[formId].status.message.success = message;
213
+ state[formId].status.messages.success = message;
213
214
  return;
214
215
  }
215
-
216
216
  case SUBMIT_FORM_ERROR:
217
217
  {
218
218
  const {
@@ -223,7 +223,6 @@ var reducer = produce((state, action) => {
223
223
  state[formId].status.validation.sent = false;
224
224
  return;
225
225
  }
226
-
227
226
  case SET_FORM_ENTRIES:
228
227
  {
229
228
  const {
@@ -239,7 +238,6 @@ var reducer = produce((state, action) => {
239
238
  state[formId].entries = entryObject;
240
239
  return;
241
240
  }
242
-
243
241
  case SET_ERROR:
244
242
  {
245
243
  const {
@@ -249,7 +247,6 @@ var reducer = produce((state, action) => {
249
247
  state[formId].status.isSubmitting = false;
250
248
  return;
251
249
  }
252
-
253
250
  default:
254
251
  return state;
255
252
  }
@@ -259,7 +256,6 @@ const selectForms = state => state.forms;
259
256
  const makeSelectPagedFields = formId => createSelector(selectForms, forms => {
260
257
  if (forms !== null && forms !== void 0 && forms[formId]) {
261
258
  var _forms$formId, _forms$formId2;
262
-
263
259
  const pagingInfo = forms === null || forms === void 0 ? void 0 : (_forms$formId = forms[formId]) === null || _forms$formId === void 0 ? void 0 : _forms$formId.pagingInfo;
264
260
  const fields = forms === null || forms === void 0 ? void 0 : (_forms$formId2 = forms[formId]) === null || _forms$formId2 === void 0 ? void 0 : _forms$formId2.fields;
265
261
  if ((fields === null || fields === void 0 ? void 0 : fields.length) > 0 && pagingInfo.pageCount > 1) return fields.filter(f => f.groupId == pagingInfo.currentPageId);else return fields;
@@ -267,77 +263,62 @@ const makeSelectPagedFields = formId => createSelector(selectForms, forms => {
267
263
  });
268
264
  const makeSelectFormStatus = formId => createSelector(selectForms, forms => {
269
265
  var _forms$formId3;
270
-
271
266
  return forms === null || forms === void 0 ? void 0 : (_forms$formId3 = forms[formId]) === null || _forms$formId3 === void 0 ? void 0 : _forms$formId3.status;
272
267
  });
273
268
  const makeSelectPagingInfo = formId => createSelector(selectForms, forms => {
274
269
  var _forms$formId4;
275
-
276
270
  return forms === null || forms === void 0 ? void 0 : (_forms$formId4 = forms[formId]) === null || _forms$formId4 === void 0 ? void 0 : _forms$formId4.pagingInfo;
277
271
  });
278
272
  const makeSelectFormSettings = formId => createSelector(selectForms, forms => {
279
273
  var _forms$formId5;
280
-
281
274
  return forms === null || forms === void 0 ? void 0 : (_forms$formId5 = forms[formId]) === null || _forms$formId5 === void 0 ? void 0 : _forms$formId5.settings;
282
275
  });
283
276
  const makeSelectFormFieldErrors = formId => createSelector(selectForms, forms => {
284
277
  var _forms$formId6;
285
-
286
278
  return forms === null || forms === void 0 ? void 0 : (_forms$formId6 = forms[formId]) === null || _forms$formId6 === void 0 ? void 0 : _forms$formId6.fieldErrors;
287
279
  });
288
280
  const makeSelectFormEntries = formId => createSelector(selectForms, forms => {
289
281
  var _forms$formId7;
290
-
291
282
  return forms === null || forms === void 0 ? void 0 : (_forms$formId7 = forms[formId]) === null || _forms$formId7 === void 0 ? void 0 : _forms$formId7.entries;
292
283
  });
293
284
  const makeSelectFormPostData = formId => createSelector(selectForms, forms => {
294
285
  var _forms$formId8;
295
-
296
286
  return forms === null || forms === void 0 ? void 0 : (_forms$formId8 = forms[formId]) === null || _forms$formId8 === void 0 ? void 0 : _forms$formId8.data;
297
287
  });
298
288
  const makeSelectIsLoading = formId => createSelector(selectForms, forms => {
299
289
  var _forms$formId9;
300
-
301
290
  return forms === null || forms === void 0 ? void 0 : (_forms$formId9 = forms[formId]) === null || _forms$formId9 === void 0 ? void 0 : _forms$formId9.status.isLoading;
302
291
  });
303
292
  const makeSelectIsSubmitting = formId => createSelector(selectForms, forms => {
304
293
  var _forms$formId10;
305
-
306
294
  return forms === null || forms === void 0 ? void 0 : (_forms$formId10 = forms[formId]) === null || _forms$formId10 === void 0 ? void 0 : _forms$formId10.status.isSubmitting;
307
295
  });
308
296
  const makeSelectHasSuccess = formId => createSelector(selectForms, forms => {
309
297
  var _forms$formId11;
310
-
311
298
  return forms === null || forms === void 0 ? void 0 : (_forms$formId11 = forms[formId]) === null || _forms$formId11 === void 0 ? void 0 : _forms$formId11.status.hasSuccess;
312
299
  });
313
300
  const makeSelectHasError = formId => createSelector(selectForms, forms => {
314
301
  var _forms$formId12;
315
-
316
302
  return forms === null || forms === void 0 ? void 0 : (_forms$formId12 = forms[formId]) === null || _forms$formId12 === void 0 ? void 0 : _forms$formId12.status.hasError;
317
303
  });
318
304
  const makeSelectFormFields = formId => createSelector(selectForms, forms => {
319
305
  var _forms$formId13;
320
-
321
306
  return forms === null || forms === void 0 ? void 0 : (_forms$formId13 = forms[formId]) === null || _forms$formId13 === void 0 ? void 0 : _forms$formId13.fields;
322
307
  });
323
308
  const makeSelectDefaultLang = formId => createSelector(selectForms, forms => {
324
309
  var _forms$formId14;
325
-
326
310
  return forms === null || forms === void 0 ? void 0 : (_forms$formId14 = forms[formId]) === null || _forms$formId14 === void 0 ? void 0 : _forms$formId14.defaultLanguage;
327
311
  });
328
312
  const makeSelectFormSuccessMessage = formId => createSelector(selectForms, forms => {
329
313
  var _forms$formId15;
330
-
331
314
  return forms === null || forms === void 0 ? void 0 : (_forms$formId15 = forms[formId]) === null || _forms$formId15 === void 0 ? void 0 : _forms$formId15.status.messages.success;
332
315
  });
333
316
  const makeSelectFormValidationSent = formId => createSelector(selectForms, forms => {
334
317
  var _forms$formId16;
335
-
336
318
  return forms === null || forms === void 0 ? void 0 : (_forms$formId16 = forms[formId]) === null || _forms$formId16 === void 0 ? void 0 : _forms$formId16.status.validation.sent;
337
319
  });
338
- const makeSelectFormGroup$1 = formId => createSelector(selectForms, forms => {
320
+ const makeSelectFormGroup = formId => createSelector(selectForms, forms => {
339
321
  var _forms$formId17;
340
-
341
322
  return forms === null || forms === void 0 ? void 0 : (_forms$formId17 = forms[formId]) === null || _forms$formId17 === void 0 ? void 0 : _forms$formId17.groups;
342
323
  });
343
324
  const selectors = {
@@ -356,7 +337,7 @@ const selectors = {
356
337
  makeSelectDefaultLang,
357
338
  makeSelectFormSuccessMessage,
358
339
  makeSelectFormValidationSent,
359
- makeSelectFormGroup: makeSelectFormGroup$1,
340
+ makeSelectFormGroup,
360
341
  makeSelectHasError
361
342
  };
362
343
 
@@ -400,11 +381,11 @@ const postForm = async formObj => {
400
381
  const submitted = await request(URI, options);
401
382
  return submitted;
402
383
  };
403
-
404
384
  const request = async (url, options) => {
405
385
  return fetch(url, options).then(response => response.json()).then(result => {
406
386
  return result;
407
- }) // eslint-disable-next-line no-console
387
+ })
388
+ // eslint-disable-next-line no-console
408
389
  .catch(error => console.log('error', error));
409
390
  };
410
391
 
@@ -412,14 +393,12 @@ const domains = ['1033edge.com', '11mail.com', '123.com', '123box.net', '123indi
412
393
 
413
394
  const doA11yValidation = (v, field, formValidationSent) => {
414
395
  const error = doValidateField(field, v);
415
-
416
396
  if (JSON.stringify(field.validations) !== '{}') {
417
397
  if (((v === null || v === void 0 ? void 0 : v.length) >= 1 || formValidationSent) && (error === null || error === void 0 ? void 0 : error.fieldId) === field.id) return 'true';else if ((v === null || v === void 0 ? void 0 : v.length) >= 1) return 'false';else return '';
418
398
  }
419
399
  };
420
400
  const doValidateField = (field, value) => {
421
401
  var _field$validations, _field$validations$re;
422
-
423
402
  const isRequired = field.validations && field.validations.required;
424
403
  const minLength = field.validations && field.validations.minLength;
425
404
  const maxLength = field.validations && field.validations.maxLength;
@@ -427,10 +406,8 @@ const doValidateField = (field, value) => {
427
406
  const integer = field.dataType === 'integer';
428
407
  const decimal = field.dataType === 'decimal';
429
408
  const isBusinessEmail = field.id === 'businessEmail';
430
-
431
409
  if (isRequired && (value === null || value === void 0 ? void 0 : value.length) <= 0) {
432
410
  var _isRequired$message, _field$name;
433
-
434
411
  const errorMessage = (isRequired === null || isRequired === void 0 ? void 0 : (_isRequired$message = isRequired.message) === null || _isRequired$message === void 0 ? void 0 : _isRequired$message['en-GB']) || `${(_field$name = field.name) === null || _field$name === void 0 ? void 0 : _field$name['en-GB']} is required`;
435
412
  return {
436
413
  fieldId: field.id,
@@ -438,7 +415,6 @@ const doValidateField = (field, value) => {
438
415
  message: errorMessage
439
416
  };
440
417
  }
441
-
442
418
  if (minLength && minLength.value > value.length) {
443
419
  const errorMessage = minLength.message ? minLength.message['en-GB'] : `Minimum characters ${minLength.value}`;
444
420
  return {
@@ -447,7 +423,6 @@ const doValidateField = (field, value) => {
447
423
  message: errorMessage
448
424
  };
449
425
  }
450
-
451
426
  if (maxLength && maxLength.value < value.length) {
452
427
  const errorMessage = maxLength.message && maxLength.message['en-GB'] ? maxLength.message['en-GB'] : `Maximum characters ${maxLength.value}`;
453
428
  return {
@@ -457,14 +432,10 @@ const doValidateField = (field, value) => {
457
432
  };
458
433
  }
459
434
  /** Check Regex and Business Emails */
460
-
461
-
462
435
  if (hasRegex && value.length >= 1) {
463
436
  var _r$message;
464
-
465
437
  const r = field.validations.regex;
466
438
  const msg = (r === null || r === void 0 ? void 0 : (_r$message = r.message) === null || _r$message === void 0 ? void 0 : _r$message['en-GB']) || `${field.name['en-GB']} is invalid`;
467
-
468
439
  if (isValidRegex(field, value) && isBusinessEmail) {
469
440
  if (!isBusinessEmailValid(field, value)) {
470
441
  return {
@@ -481,10 +452,8 @@ const doValidateField = (field, value) => {
481
452
  };
482
453
  }
483
454
  }
484
-
485
455
  if (integer) {
486
456
  const isInteger = value % 1 === 0;
487
-
488
457
  if (!isInteger) {
489
458
  const errorMessage = `${value} is not an ${field.dataType}`;
490
459
  return {
@@ -494,10 +463,8 @@ const doValidateField = (field, value) => {
494
463
  };
495
464
  }
496
465
  }
497
-
498
466
  if (decimal) {
499
467
  const isDecimal = value % 1 !== 0;
500
-
501
468
  if (!isDecimal) {
502
469
  const errorMessage = `${value} is not an ${field.dataType}`;
503
470
  return {
@@ -508,13 +475,11 @@ const doValidateField = (field, value) => {
508
475
  }
509
476
  }
510
477
  };
511
-
512
478
  const isValidRegex = (field, value) => {
513
479
  const regex = field.validations.regex.pattern;
514
480
  const regexPattern = RegExp(regex);
515
481
  if (!regexPattern.test(value)) return false;else return true;
516
482
  };
517
-
518
483
  const isBusinessEmailValid = (field, value) => {
519
484
  const domain = value.split('@').pop();
520
485
  if (!domains.includes(domain)) return true;else return false;
@@ -522,7 +487,6 @@ const isBusinessEmailValid = (field, value) => {
522
487
 
523
488
  const doCreateMessage = (type, minLength, maxLength, currentLength, defaultLanguage) => {
524
489
  if (!type) return null;
525
-
526
490
  switch (type) {
527
491
  case 'min':
528
492
  {
@@ -530,28 +494,24 @@ const doCreateMessage = (type, minLength, maxLength, currentLength, defaultLangu
530
494
  const minLengthVal = minLength && minLength.value;
531
495
  const errorMessage = minLength && minLength.message && minLength.message[defaultLanguage];
532
496
  const minText = `Minimum of ${minLengthVal.toString()} characters`;
533
-
534
497
  if (errorMessage) {
535
498
  return errorMessage;
536
499
  } else {
537
500
  return minText;
538
501
  }
539
502
  }
540
-
541
503
  case 'max':
542
504
  {
543
505
  if (!maxLength) return;
544
506
  const maxLengthVal = maxLength && maxLength.value;
545
507
  const errorMessage = maxLength && maxLength.message && maxLength.message[defaultLanguage];
546
508
  const maxText = `Maximum of ${maxLengthVal.toString()} characters`;
547
-
548
509
  if (errorMessage) {
549
510
  return errorMessage;
550
511
  } else {
551
512
  return maxText;
552
513
  }
553
514
  }
554
-
555
515
  case 'between':
556
516
  {
557
517
  if (!maxLength || !minLength) return;
@@ -559,7 +519,6 @@ const doCreateMessage = (type, minLength, maxLength, currentLength, defaultLangu
559
519
  const maxLengthVal = maxLength && maxLength.value;
560
520
  const errorMessage = minLength && minLength.message && minLength.message[defaultLanguage];
561
521
  const rangeText = `Between ${minLengthVal.toString()}-${maxLengthVal.toString()} characters)`;
562
-
563
522
  if (errorMessage) {
564
523
  return errorMessage;
565
524
  } else if (currentLength < minLengthVal) {
@@ -572,16 +531,16 @@ const doCreateMessage = (type, minLength, maxLength, currentLength, defaultLangu
572
531
  return rangeText;
573
532
  }
574
533
  }
575
-
576
534
  default:
577
535
  return null;
578
536
  }
579
537
  };
580
538
  const getFieldType = field => {
581
539
  var _field$editor, _field$editor$propert;
582
-
583
540
  if (!field) return null;
584
-
541
+ if (field.id === 'country' && field.dataType === 'string') {
542
+ return 'country';
543
+ }
585
544
  if (field.dataType === 'string' && field.editor && field.editor.id === 'multiline') {
586
545
  return 'textarea';
587
546
  } else if (field.dataType === 'string' && field.editor && field.editor.id === 'list-dropdown') {
@@ -605,8 +564,9 @@ const getFieldType = field => {
605
564
  }
606
565
  };
607
566
 
608
- const sagas = [takeEvery(SUBMIT_FORM_SUCCESS, onFormSuccess), takeEvery(SUBMIT_FORM_FOR_VALIDATION, doValidateForm), takeEvery(SUBMIT_FORM, onSubmitForm), takeEvery(SET_FORM_ID, doFetchForm), takeLatest(VALIDATE_FIELD, onValidateField$1), takeEvery(PAGE_FORWARD, doTogglePage), takeEvery(PAGE_BACK, doTogglePage), takeEvery(SET_FORM_DATA, getEntryPickerData), takeLatest(SET_FORM_DATA, setDefaultValueFields)];
609
-
567
+ const sagas = [takeEvery(SUBMIT_FORM_SUCCESS, onFormSuccess), takeEvery(SUBMIT_FORM_FOR_VALIDATION, doValidateForm), takeEvery(SUBMIT_FORM, onSubmitForm), takeEvery(SET_FORM_ID, doFetchForm),
568
+ // takeLatest(VALIDATE_FIELD, onValidateField),
569
+ takeEvery(PAGE_FORWARD, doTogglePage), takeEvery(PAGE_BACK, doTogglePage), takeEvery(SET_FORM_DATA, getEntryPickerData), takeLatest(SET_FORM_DATA, setDefaultValueFields)];
610
570
  function* doValidateForm(action) {
611
571
  const {
612
572
  formId
@@ -617,89 +577,51 @@ function* doValidateForm(action) {
617
577
  formId
618
578
  });
619
579
  }
580
+ // function* onValidateField(action) {
581
+ // const { formId, id, value } = action;
582
+ // if (value?.length >= 1) yield call(onValidateSingleField, formId, id, value);
583
+ // }
620
584
 
621
- function* onValidateField$1(action) {
622
- const {
623
- formId,
624
- id,
625
- value
626
- } = action;
627
- if ((value === null || value === void 0 ? void 0 : value.length) >= 1) yield call(onValidateSingleField, formId, id, value);
628
- }
629
-
630
- function* validateGroupfields(formId, groupId) {
585
+ function* onValidateGroupFields(formId, groupId) {
631
586
  const state = yield select();
632
587
  const selectPostData = makeSelectFormPostData(formId);
633
588
  const postData = selectPostData(state);
634
589
  const selectFormFields = makeSelectFormFields(formId);
635
590
  const fields = selectFormFields(state);
636
- const groupFields = fields.filter(f => f.groupid == groupId);
637
- let newErrors = [];
591
+ const groupFields = fields.filter(f => f.groupId == groupId);
592
+ let errors = [];
638
593
  groupFields.forEach(field => {
639
- let val = '';
640
-
641
- if (postData[field.id]) {
642
- val = postData[field.id];
643
- }
644
-
645
- const err = doValidateField(field, val);
646
- if (err) newErrors.push(err);
594
+ let value = '';
595
+ if (postData[field.id]) value = postData[field.id];
596
+ const error = doValidateField(field, value);
597
+ if (error) errors.push(error);
647
598
  });
648
599
  yield put({
649
600
  type: SET_FIELD_ERROR,
650
601
  formId: formId,
651
- value: newErrors
602
+ value: errors
652
603
  });
604
+ return errors;
653
605
  }
654
-
655
606
  function* onValidateAllFields(formId) {
656
607
  const state = yield select();
657
608
  const selectPostData = makeSelectFormPostData(formId);
658
609
  const postData = selectPostData(state);
659
610
  const selectFormFields = makeSelectFormFields(formId);
660
611
  const fields = selectFormFields(state);
661
- let newErrors = [];
612
+ const errors = [];
662
613
  fields.forEach(field => {
663
- let val = '';
664
-
665
- if (postData[field.id]) {
666
- val = postData[field.id];
667
- }
668
-
669
- const err = doValidateField(field, val);
670
- if (err) newErrors.push(err);
614
+ let value = '';
615
+ if (postData[field.id]) value = postData[field.id];
616
+ const error = doValidateField(field, value);
617
+ if (error) errors.push(error);
671
618
  });
672
619
  yield put({
673
620
  type: SET_FIELD_ERROR,
674
621
  formId: formId,
675
- value: newErrors
622
+ value: errors
676
623
  });
677
624
  }
678
-
679
- function* onValidateSingleField(formId, fieldId, value) {
680
- const state = yield select();
681
- const selectFormFields = makeSelectFormFields(formId);
682
- const fields = selectFormFields(state);
683
- const selectFormFieldErrors = makeSelectFormFieldErrors(formId);
684
- const errors = selectFormFieldErrors(state);
685
- const fieldData = fields.find(f => f.id == fieldId);
686
- const newErrors = []; //loop through current errors to remove any of the item we currently edit
687
-
688
- errors.forEach(error => {
689
- if (error.fieldId !== fieldId) {
690
- //push any existing errors to new array
691
- newErrors.push(error);
692
- }
693
- });
694
- const err = doValidateField(fieldData, value);
695
- if (err) newErrors.push(err);
696
- yield put({
697
- type: SET_FIELD_ERROR,
698
- formId: formId,
699
- value: newErrors
700
- });
701
- }
702
-
703
625
  function* doTogglePage(action) {
704
626
  const {
705
627
  formId,
@@ -708,30 +630,34 @@ function* doTogglePage(action) {
708
630
  const state = yield select();
709
631
  const selectFormGroups = makeSelectFormGroup(formId);
710
632
  const formGroups = selectFormGroups(state);
711
-
712
633
  if (action.type === PAGE_FORWARD) {
713
- yield validateGroupfields(formId, formGroups[pageIndex].id);
634
+ const errors = yield onValidateGroupFields(formId, formGroups[pageIndex - 1].id);
635
+ if (errors && errors.length <= 0) {
636
+ yield put({
637
+ type: SET_CURRENT_PAGE,
638
+ formId: formId,
639
+ pageId: formGroups[pageIndex].id,
640
+ pageCount: formGroups.length,
641
+ pageIndex: pageIndex
642
+ });
643
+ }
644
+ } else if (action.type === PAGE_BACK) {
645
+ yield put({
646
+ type: SET_CURRENT_PAGE,
647
+ formId: formId,
648
+ pageId: formGroups[pageIndex].id,
649
+ pageCount: formGroups.length,
650
+ pageIndex: pageIndex
651
+ });
714
652
  }
715
-
716
- yield put({
717
- type: SET_CURRENT_PAGE,
718
- formId: formId,
719
- pageId: formGroups[pageIndex].id,
720
- pageCount: formGroups.length,
721
- pageIndex: pageIndex
722
- });
723
653
  }
724
-
725
654
  function* doFetchForm(action) {
726
655
  var _schema$groups;
727
-
728
656
  const formId = action.formId;
729
657
  const schema = yield getFormSchema(formId);
730
658
  const groups = schema === null || schema === void 0 ? void 0 : (_schema$groups = schema.groups) === null || _schema$groups === void 0 ? void 0 : _schema$groups.filter(group => group.id !== 'private' && group.id !== 'settings');
731
-
732
659
  if (formId && schema) {
733
660
  var _schema$groups2, _submitButtonText$def;
734
-
735
661
  if ((schema === null || schema === void 0 ? void 0 : (_schema$groups2 = schema.groups) === null || _schema$groups2 === void 0 ? void 0 : _schema$groups2.length) > 0) {
736
662
  yield put({
737
663
  type: SET_CURRENT_PAGE,
@@ -741,10 +667,10 @@ function* doFetchForm(action) {
741
667
  pageCount: groups.length
742
668
  });
743
669
  }
744
-
745
670
  const submitButtonText = schema.fields.find(f => f.id === 'submitButtonText');
746
671
  const fields = schema === null || schema === void 0 ? void 0 : schema.fields.map(field => {
747
- return { ...field,
672
+ return {
673
+ ...field,
748
674
  type: getFieldType(field)
749
675
  };
750
676
  });
@@ -760,27 +686,26 @@ function* doFetchForm(action) {
760
686
  });
761
687
  }
762
688
  }
763
-
764
689
  function* onFormSuccess(action) {
765
690
  const state = yield select();
766
691
  const selectFormFields = makeSelectFormFields(action.formId);
767
692
  const fields = selectFormFields(state);
768
693
  const redirect = fields.find(f => f.id === 'formSettingsRedirect');
769
694
  const message = fields.find(f => f.id === 'formSettingsMessage');
770
-
771
695
  if (redirect !== null && redirect !== void 0 && redirect.default) {
772
696
  window.location.href = redirect.default['en-GB'];
773
697
  }
774
-
775
698
  if (message !== null && message !== void 0 && message.default) {
776
- yield put({
777
- type: SET_SUCCESS_MESSAGE,
778
- message: message.default['en-GB'],
779
- formId: action.formId
780
- });
699
+ const m = message.default['en-GB'];
700
+ if (m) {
701
+ yield put({
702
+ type: SET_SUCCESS_MESSAGE,
703
+ message: m,
704
+ formId: action.formId
705
+ });
706
+ }
781
707
  }
782
708
  }
783
-
784
709
  function* onSubmitForm(action) {
785
710
  const {
786
711
  formId
@@ -789,10 +714,8 @@ function* onSubmitForm(action) {
789
714
  const selectFormFieldErrors = makeSelectFormFieldErrors(formId);
790
715
  const errors = selectFormFieldErrors(state);
791
716
  const canSubmit = (errors === null || errors === void 0 ? void 0 : errors.length) === 0;
792
-
793
717
  if (canSubmit) {
794
718
  var _formResObj$sys;
795
-
796
719
  yield put({
797
720
  type: SET_SUBMITTING_FORM,
798
721
  isSubmitting: true,
@@ -805,7 +728,6 @@ function* onSubmitForm(action) {
805
728
  formPost: rawData.data
806
729
  };
807
730
  const formResObj = yield postForm(formObj);
808
-
809
731
  if (formResObj !== null && formResObj !== void 0 && (_formResObj$sys = formResObj.sys) !== null && _formResObj$sys !== void 0 && _formResObj$sys.id) {
810
732
  yield put({
811
733
  type: SUBMIT_FORM_SUCCESS,
@@ -819,7 +741,6 @@ function* onSubmitForm(action) {
819
741
  }
820
742
  }
821
743
  }
822
-
823
744
  function* setDefaultValueFields(action) {
824
745
  const {
825
746
  formId,
@@ -831,15 +752,12 @@ function* setDefaultValueFields(action) {
831
752
  fields.forEach(field => {
832
753
  if (field.dataType == 'string' && field.default) {
833
754
  const val = field.default[defaultLanguage];
834
-
835
755
  if (val) {
836
756
  fieldObj[field.id] = val;
837
757
  }
838
758
  }
839
-
840
759
  if (field.id == 'sourceEntry') {
841
760
  const val = entryId;
842
-
843
761
  if (val) {
844
762
  fieldObj[field.id] = val;
845
763
  }
@@ -851,7 +769,6 @@ function* setDefaultValueFields(action) {
851
769
  value: fieldObj
852
770
  });
853
771
  }
854
-
855
772
  function* getEntryPickerData(action) {
856
773
  const {
857
774
  formId,
@@ -859,7 +776,6 @@ function* getEntryPickerData(action) {
859
776
  } = action;
860
777
  const entriesToGet = fields.filter(f => f.dataFormat == 'entry');
861
778
  let entriesList = [];
862
-
863
779
  if (entriesToGet) {
864
780
  entriesList = yield all(entriesToGet.map(entry => {
865
781
  const entriesObj = {
@@ -882,7 +798,6 @@ const action = (type, payload = {}) => ({
882
798
  type,
883
799
  ...payload
884
800
  });
885
-
886
801
  const onSubmit = formId => action(SUBMIT_FORM_FOR_VALIDATION, {
887
802
  formId
888
803
  });
@@ -894,11 +809,16 @@ const setValue = (formId, id, value) => action(SET_FIELD_VALUE, {
894
809
  id,
895
810
  value
896
811
  });
897
- const setCheckboxValue = (formId, id, value, isChecked) => action(SET_CHECKBOX_VALUE, {
812
+ const setSingleCheckboxValue = (formId, id, value) => action(SET_SINGLE_CHECKBOX_VALUE, {
898
813
  formId,
899
814
  id,
900
- value,
901
- isChecked
815
+ value
816
+ });
817
+ const setMultipleCheckboxValue = (formId, id, label, value) => action(SET_MULTIPLE_CHECKBOX_VALUE, {
818
+ formId,
819
+ id,
820
+ label,
821
+ value
902
822
  });
903
823
  const setDateRangeValues = (formId, id, dateType, value) => action(SET_DATE_RANGE_VALUES, {
904
824
  formId,
@@ -923,15 +843,14 @@ const actions = {
923
843
  onSubmit,
924
844
  setFormId,
925
845
  setValue,
926
- setCheckboxValue,
927
- setDateRangeValues,
846
+ setSingleCheckboxValue,
847
+ setMultipleCheckboxValue,
928
848
  onValidateField,
929
849
  doTogglePageForward,
930
850
  doTogglePageBack
931
851
  };
932
852
 
933
853
  const ThemeContext = /*#__PURE__*/createContext();
934
-
935
854
  const ThemeProvider = ({
936
855
  children,
937
856
  theme
@@ -942,7 +861,6 @@ const ThemeProvider = ({
942
861
  theme: theme
943
862
  }, children));
944
863
  };
945
-
946
864
  ThemeProvider.propTypes = {
947
865
  children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
948
866
  theme: PropTypes.object
@@ -988,7 +906,7 @@ const FormStyled = styled.form.withConfig({
988
906
  theme,
989
907
  useDefaultTheme
990
908
  }) => {
991
- return css(["", ""], useDefaultTheme && css(["> div:not(:first-child){margin-top:16px;}padding:0 16px;.success-message{font-size:18px;margin:0;}.visuallyHidden{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden;}.loading{display:block;margin:24px auto;}label{display:inline-block;.isRequired{color:", ";}}input,textarea,select{display:block;font-family:inherit;background-color:", ";border-radius:3px;border:1px solid ", ";height:40px;padding:8px;margin-top:4px;width:100%;}input:-webkit-autofill,input:-webkit-autofill:hover,input:-webkit-autofill:focus,input:-webkit-autofill:active{-webkit-box-shadow:0 0 0 30px ", " inset;}textarea{height:200px;resize:none;}[aria-invalid='false']{background:", ";border:1px solid ", ";&:-webkit-autofill,&:-webkit-autofill:hover,&:-webkit-autofill:focus,&:-webkit-autofill:active{-webkit-box-shadow:0 0 0 30px", " inset;}}[aria-invalid='true']{background:", ";border:1px solid ", ";&:-webkit-autofill,&:-webkit-autofill:hover,&:-webkit-autofill:focus,&:-webkit-autofill:active{-webkit-box-shadow:0 0 0 30px", " inset;}}input ~ .svg{position:absolute;right:8px;top:50%;transform:translateY(-50%);}textarea ~ .svg{position:absolute;right:8px;top:8px;}"], theme.colors.red_darker, theme.colors.white, theme.colors.light_grey_darkest, theme.colors.white, theme.colors.green_lightest, theme.colors.green_darker, theme.colors.green_lightest, theme.colors.red_lightest, theme.colors.red_darker, theme.colors.red_lightest));
909
+ return css(["", ""], useDefaultTheme && css(["> div:not(:first-child){margin-top:16px;}padding:0 16px;.success-message{font-size:18px;margin:0;}.visuallyHidden{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden;}.loading{display:block;margin:24px auto;}label{display:inline-block;.isRequired{color:", ";}}input,textarea,select{display:block;font-family:inherit;background-color:", ";border-radius:3px;border:1px solid ", ";height:40px;padding:8px;margin-top:4px;width:100%;}input:-webkit-autofill,input:-webkit-autofill:hover,input:-webkit-autofill:focus,input:-webkit-autofill:active{-webkit-box-shadow:0 0 0 30px ", " inset;}textarea{height:200px;resize:none;}[aria-invalid='false']{background:", ";border:1px solid ", ";&:-webkit-autofill,&:-webkit-autofill:hover,&:-webkit-autofill:focus,&:-webkit-autofill:active{-webkit-box-shadow:0 0 0 30px", " inset;}}[aria-invalid='true']{background:", ";border:1px solid ", ";&:-webkit-autofill,&:-webkit-autofill:hover,&:-webkit-autofill:focus,&:-webkit-autofill:active{-webkit-box-shadow:0 0 0 30px", " inset;}}input ~ .svg{position:absolute;right:8px;top:50%;transform:translateY(-50%);}textarea ~ .svg{position:absolute;right:8px;top:8px;}button:not(:last-of-type){margin-right:16px;}"], theme.colors.red_darker, theme.colors.white, theme.colors.light_grey_darkest, theme.colors.white, theme.colors.green_lightest, theme.colors.green_darker, theme.colors.green_lightest, theme.colors.red_lightest, theme.colors.red_darker, theme.colors.red_lightest));
992
910
  });
993
911
 
994
912
  const Label = ({
@@ -1001,13 +919,12 @@ const Label = ({
1001
919
  return /*#__PURE__*/React.createElement("label", {
1002
920
  className: `${className} ${isHidden ? 'visuallyHidden' : ''}`,
1003
921
  htmlFor: id
1004
- }, label, isRequired && /*#__PURE__*/React.createElement("span", {
1005
- className: "isRequired"
1006
- }, "*"), isRequired && /*#__PURE__*/React.createElement("span", {
1007
- className: "visuallyHidden"
1008
- }, " (required)"));
922
+ }, label, isRequired ? /*#__PURE__*/React.createElement("span", {
923
+ className: "label__required"
924
+ }, "(required)") : /*#__PURE__*/React.createElement("span", {
925
+ className: "label__optional"
926
+ }, "(optional)"));
1009
927
  };
1010
-
1011
928
  Label.propTypes = {
1012
929
  className: PropTypes.string,
1013
930
  label: PropTypes.string,
@@ -1065,7 +982,6 @@ const TextfieldStyled = styled.div.withConfig({
1065
982
  }) => {
1066
983
  return css(["display:", ";"], isHidden ? 'none' : 'block');
1067
984
  });
1068
-
1069
985
  const Textfield = ({
1070
986
  className,
1071
987
  field,
@@ -1157,7 +1073,6 @@ const Textfield = ({
1157
1073
  d: "m2 8 4.418 4.667L14 4.659l-1.246-1.326-6.336 6.692-3.18-3.332L2 8Z"
1158
1074
  }))));
1159
1075
  };
1160
-
1161
1076
  Textfield.propTypes = {
1162
1077
  className: PropTypes.string,
1163
1078
  field: PropTypes.any,
@@ -1264,7 +1179,6 @@ const Textarea = ({
1264
1179
  d: "m2 8 4.418 4.667L14 4.659l-1.246-1.326-6.336 6.692-3.18-3.332L2 8Z"
1265
1180
  }))));
1266
1181
  };
1267
-
1268
1182
  Textarea.propTypes = {
1269
1183
  className: PropTypes.string,
1270
1184
  field: PropTypes.any,
@@ -1302,7 +1216,6 @@ const HiddenField = ({
1302
1216
  isHidden: true
1303
1217
  });
1304
1218
  };
1305
-
1306
1219
  HiddenField.propTypes = {
1307
1220
  className: PropTypes.string,
1308
1221
  id: PropTypes.string,
@@ -1350,7 +1263,6 @@ const Dropdown = ({
1350
1263
  }, val[defaultLanguage]);
1351
1264
  })));
1352
1265
  };
1353
-
1354
1266
  Dropdown.propTypes = {
1355
1267
  className: PropTypes.string,
1356
1268
  formId: PropTypes.string,
@@ -1370,11 +1282,9 @@ const CheckboxStyled = styled.div.withConfig({
1370
1282
  }) => {
1371
1283
  return css(["", ""], useDefaultTheme && css([".checkbox-wrapper{display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:center;input{height:auto;width:auto;margin:0 4px 0 0;}label{display:inline-block;}}"]));
1372
1284
  });
1373
-
1374
1285
  const Checkbox = ({
1375
1286
  className,
1376
1287
  formId,
1377
- setCheckboxValue,
1378
1288
  id,
1379
1289
  type,
1380
1290
  label,
@@ -1387,18 +1297,16 @@ const Checkbox = ({
1387
1297
  // NF change rules of hooks
1388
1298
  let isDefaultChecked = defaultValue && defaultValue[defaultLanguage];
1389
1299
  const [isChecked, setIsChecked] = useState(isDefaultChecked || '');
1390
-
1300
+ const dispatch = useDispatch();
1391
1301
  switch (type) {
1392
1302
  case 'multiple':
1393
1303
  {
1394
1304
  if (!validations) return null;
1395
1305
  const isRequired = validations && validations.required ? true : false;
1396
1306
  const cbValues = validations && validations.allowedValues && validations.allowedValues.values;
1397
-
1398
- const _handleChange = (value, isChecked) => {
1399
- setCheckboxValue(formId, id, value, isChecked);
1307
+ const _handleChange = (label, value) => {
1308
+ dispatch(setMultipleCheckboxValue(formId, id, label, value));
1400
1309
  };
1401
-
1402
1310
  if (!cbValues || cbValues.length < 1) return null;
1403
1311
  return /*#__PURE__*/React.createElement(CheckboxStyled, {
1404
1312
  className: `checkbox-container`,
@@ -1419,21 +1327,19 @@ const Checkbox = ({
1419
1327
  value: val[defaultLanguage],
1420
1328
  className: `${className ? className : ''} input-checkbox`,
1421
1329
  onChange: e => _handleChange(e.target.value, e.target.checked)
1422
- }), /*#__PURE__*/React.createElement(Label, {
1330
+ }), /*#__PURE__*/React.createElement("label", {
1331
+ className: "label-checkbox",
1423
1332
  id: `checkbox-${idx}`,
1424
- label: val[defaultLanguage],
1425
- className: "label-checkbox"
1426
- }));
1333
+ htmlFor: `checkbox-${idx}`
1334
+ }, val[defaultLanguage]));
1427
1335
  }));
1428
1336
  }
1429
-
1430
1337
  case 'single':
1431
1338
  {
1432
- const _handleChange = isChecked => {
1433
- setIsChecked(isChecked);
1434
- setCheckboxValue(formId, id, isChecked);
1339
+ const _handleChange = value => {
1340
+ setIsChecked(value);
1341
+ dispatch(setSingleCheckboxValue(formId, id, value));
1435
1342
  };
1436
-
1437
1343
  return /*#__PURE__*/React.createElement(CheckboxStyled, {
1438
1344
  className: `checkbox-container`,
1439
1345
  useDefaultTheme: useDefaultTheme
@@ -1455,14 +1361,12 @@ const Checkbox = ({
1455
1361
  }
1456
1362
  }
1457
1363
  };
1458
-
1459
1364
  Checkbox.propTypes = {
1460
1365
  className: PropTypes.string,
1461
1366
  formId: PropTypes.string,
1462
1367
  id: PropTypes.string,
1463
1368
  type: PropTypes.string,
1464
1369
  label: PropTypes.string,
1465
- setCheckboxValue: PropTypes.func,
1466
1370
  validations: PropTypes.object,
1467
1371
  defaultLanguage: PropTypes.string,
1468
1372
  name: PropTypes.object,
@@ -1477,7 +1381,6 @@ const RadioButtonStyled = styled.div.withConfig({
1477
1381
  }) => {
1478
1382
  return css(["", ""], useDefaultTheme && css([".radio-wrapper{display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:center;input{height:auto;width:auto;margin:0 4px 0 0;}label{display:inline-block;}}"]));
1479
1383
  });
1480
-
1481
1384
  const RadioButton = ({
1482
1385
  className,
1483
1386
  formId,
@@ -1514,14 +1417,13 @@ const RadioButton = ({
1514
1417
  onChange: e => {
1515
1418
  setValue(formId, id, e.target.value);
1516
1419
  }
1517
- }), /*#__PURE__*/React.createElement(Label, {
1420
+ }), /*#__PURE__*/React.createElement("label", {
1421
+ className: "label-radio",
1518
1422
  id: val[defaultLanguage],
1519
- label: val[defaultLanguage],
1520
- className: "label-radio"
1521
- }));
1423
+ htmlFor: val[defaultLanguage]
1424
+ }, val[defaultLanguage]));
1522
1425
  }));
1523
1426
  };
1524
-
1525
1427
  RadioButton.propTypes = {
1526
1428
  className: PropTypes.string,
1527
1429
  formId: PropTypes.string,
@@ -1553,6 +1455,7 @@ RadioButton.propTypes = {
1553
1455
  //m > minutes, eg ...T16:05:00 = 5
1554
1456
  //t > abbreviated AM / PM, e.g. A or P
1555
1457
  //tt > AM / PM, e.g. AM or PM
1458
+
1556
1459
  const formatDate = (date, format = 'dd MMMM yyyy') => {
1557
1460
  if (!date) return null;
1558
1461
  const dateObj = new Date(date);
@@ -1564,8 +1467,9 @@ const formatDate = (date, format = 'dd MMMM yyyy') => {
1564
1467
  const dayNameInt = dateObj.getDay();
1565
1468
  const timeArr = dateString[1].split(':');
1566
1469
  const hour = timeArr[0];
1567
- const minute = timeArr[1]; //convert to abstract strings to avoid character replacement along the chain, eg. Monday would match 'M' month single parameter
1470
+ const minute = timeArr[1];
1568
1471
 
1472
+ //convert to abstract strings to avoid character replacement along the chain, eg. Monday would match 'M' month single parameter
1569
1473
  const YEAR = ['&&', '&'];
1570
1474
  const MONTH = ['££££', '£££', '££', '£'];
1571
1475
  const DAY = ['%%%%', '%%%', '%%', '%'];
@@ -1577,16 +1481,13 @@ const formatDate = (date, format = 'dd MMMM yyyy') => {
1577
1481
  .replace('MMMM', MONTH[0]).replace('MMM', MONTH[1]).replace('MM', MONTH[2]).replace('M', MONTH[3]).replace('dddd', DAY[0]).replace('ddd', DAY[1]).replace('dd', DAY[2]).replace('d', DAY[3]).replace('HH', HOUR24[0]).replace('H', HOUR24[1]).replace('hh', HOUR12[0]).replace('h', HOUR12[1]).replace('mm', MINUTE[0]).replace('m', MINUTE[1]).replace('tt', TF[0]).replace('t', TF[1]).replace(YEAR[0], year).replace(YEAR[1], year.slice(-2)).replace(MONTH[0], monthsLong[parseInt(month, 10)]).replace(MONTH[1], monthsShort[parseInt(month, 10)]).replace(MONTH[2], month).replace(MONTH[3], parseInt(month, 10)).replace(DAY[0], daysLong[dayNameInt]).replace(DAY[1], daysShort[dayNameInt]).replace(DAY[2], day).replace(DAY[3], parseInt(day, 10)).replace(HOUR24[0], hour).replace(HOUR24[1], parseInt(hour, 10)).replace(HOUR12[0], parseHour(hour)).replace(HOUR12[1], parseInt(parseHour(hour), 10)).replace(MINUTE[0], minute).replace(MINUTE[1], parseInt(minute, 10)).replace(TF[0], parseTF(hour)).replace(TF[1], parseTF(hour).slice(0, -1));
1578
1482
  return formattedDate;
1579
1483
  };
1580
-
1581
1484
  const monthsShort = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
1582
1485
  const monthsLong = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
1583
1486
  const daysShort = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
1584
1487
  const daysLong = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
1585
-
1586
1488
  const parseHour = hour => {
1587
1489
  return hour > 12 ? hour - 12 : hour;
1588
1490
  };
1589
-
1590
1491
  const parseTF = hour => {
1591
1492
  return hour > 11 ? 'PM' : 'AM';
1592
1493
  };
@@ -1604,13 +1505,11 @@ const SingleDate = ({
1604
1505
  const onlyPassedDates = validations && validations.pastDateTime;
1605
1506
  const d = new Date();
1606
1507
  const todaysDate = d.toISOString();
1607
-
1608
1508
  const _handleChange = (formId, id, value) => {
1609
1509
  const d = new Date(value);
1610
1510
  const isoDate = d.toISOString();
1611
1511
  setValue(formId, id, isoDate);
1612
1512
  };
1613
-
1614
1513
  return /*#__PURE__*/React.createElement("div", {
1615
1514
  className: "date-container"
1616
1515
  }, /*#__PURE__*/React.createElement(Label, {
@@ -1627,7 +1526,6 @@ const SingleDate = ({
1627
1526
  onChange: e => _handleChange(formId, id, e.target.value)
1628
1527
  }));
1629
1528
  };
1630
-
1631
1529
  SingleDate.propTypes = {
1632
1530
  className: PropTypes.string,
1633
1531
  formId: PropTypes.string,
@@ -1646,7 +1544,6 @@ const DateRangeStyled = styled.div.withConfig({
1646
1544
  }) => {
1647
1545
  return css(["", ""], useDefaultTheme && css([".daterange-wrapper{display:flex;flex-direction:column;input{&:first-child{margin:0 0 8px 0;}}}"]));
1648
1546
  });
1649
-
1650
1547
  const DateRange = ({
1651
1548
  className,
1652
1549
  id,
@@ -1662,15 +1559,12 @@ const DateRange = ({
1662
1559
  const todaysDate = d.toISOString();
1663
1560
  const [toDate, setToDate] = useState('');
1664
1561
  const [fromDate, setFromDate] = useState('');
1665
-
1666
1562
  const _handleDateChange = (dateType, formId, id, value) => {
1667
1563
  _updateDateProps(dateType, value);
1668
-
1669
1564
  const d = new Date(value);
1670
1565
  const isoDate = d.toISOString();
1671
1566
  setDateRangeValues(formId, id, dateType, isoDate);
1672
1567
  };
1673
-
1674
1568
  const _updateDateProps = (type, date) => {
1675
1569
  switch (type) {
1676
1570
  case 'from':
@@ -1680,7 +1574,6 @@ const DateRange = ({
1680
1574
  setFromDate(newDate);
1681
1575
  break;
1682
1576
  }
1683
-
1684
1577
  case 'to':
1685
1578
  {
1686
1579
  const d = new Date(date);
@@ -1688,12 +1581,10 @@ const DateRange = ({
1688
1581
  setToDate(newDate);
1689
1582
  break;
1690
1583
  }
1691
-
1692
1584
  default:
1693
1585
  return;
1694
1586
  }
1695
1587
  };
1696
-
1697
1588
  return /*#__PURE__*/React.createElement(DateRangeStyled, {
1698
1589
  className: `daterange-container`,
1699
1590
  useDefaultTheme: useDefaultTheme
@@ -1730,7 +1621,6 @@ const DateRange = ({
1730
1621
  onChange: e => _handleDateChange('to', formId, id, e.target.value)
1731
1622
  })));
1732
1623
  };
1733
-
1734
1624
  DateRange.propTypes = {
1735
1625
  className: PropTypes.string,
1736
1626
  formId: PropTypes.string,
@@ -1750,7 +1640,6 @@ const EntryPickerStyled = styled.div.withConfig({
1750
1640
  }) => {
1751
1641
  return css(["", ""], useDefaultTheme && css([".radio-wrapper,.checkbox-wrapper{display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:center;input{height:auto;width:auto;margin:0 4px 0 0;}label{display:inline-block;}}"]));
1752
1642
  });
1753
-
1754
1643
  const EntryPicker = ({
1755
1644
  className,
1756
1645
  results,
@@ -1765,7 +1654,6 @@ const EntryPicker = ({
1765
1654
  if (!results || results.length > 3) return null;
1766
1655
  const isRequired = validations && validations.required ? true : false;
1767
1656
  let valArr = [];
1768
-
1769
1657
  const _handleChange = (formId, id, value, isChecked) => {
1770
1658
  if (type === 'checkbox') {
1771
1659
  if (isChecked) {
@@ -1773,13 +1661,11 @@ const EntryPicker = ({
1773
1661
  } else if (!isChecked) {
1774
1662
  valArr = valArr.filter(valItem => valItem !== value);
1775
1663
  }
1776
-
1777
1664
  setValue(formId, id, valArr);
1778
1665
  } else {
1779
1666
  setValue(formId, id, value);
1780
1667
  }
1781
1668
  };
1782
-
1783
1669
  return /*#__PURE__*/React.createElement(EntryPickerStyled, {
1784
1670
  className: `${type}-container`,
1785
1671
  useDefaultTheme: useDefaultTheme
@@ -1806,7 +1692,6 @@ const EntryPicker = ({
1806
1692
  }));
1807
1693
  }));
1808
1694
  };
1809
-
1810
1695
  EntryPicker.propTypes = {
1811
1696
  className: PropTypes.string,
1812
1697
  results: PropTypes.array,
@@ -1819,6 +1704,1352 @@ EntryPicker.propTypes = {
1819
1704
  formId: PropTypes.string
1820
1705
  };
1821
1706
 
1707
+ function _extends() {
1708
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
1709
+ for (var i = 1; i < arguments.length; i++) {
1710
+ var source = arguments[i];
1711
+ for (var key in source) {
1712
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1713
+ target[key] = source[key];
1714
+ }
1715
+ }
1716
+ }
1717
+ return target;
1718
+ };
1719
+ return _extends.apply(this, arguments);
1720
+ }
1721
+
1722
+ const countries = [{
1723
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1e8.svg",
1724
+ "country": "Ascension Island",
1725
+ "code": "ac"
1726
+ }, {
1727
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1e9.svg",
1728
+ "country": "Andorra",
1729
+ "code": "ad"
1730
+ }, {
1731
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1ea.svg",
1732
+ "country": "United Arab Emirates",
1733
+ "code": "ae"
1734
+ }, {
1735
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1eb.svg",
1736
+ "country": "Afghanistan",
1737
+ "code": "af"
1738
+ }, {
1739
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1ec.svg",
1740
+ "country": "Antigua & Barbuda",
1741
+ "code": "ag"
1742
+ }, {
1743
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1ee.svg",
1744
+ "country": "Anguilla",
1745
+ "code": "ai"
1746
+ }, {
1747
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1f1.svg",
1748
+ "country": "Albania",
1749
+ "code": "al"
1750
+ }, {
1751
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1f2.svg",
1752
+ "country": "Armenia",
1753
+ "code": "am"
1754
+ }, {
1755
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1f4.svg",
1756
+ "country": "Angola",
1757
+ "code": "ad"
1758
+ }, {
1759
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1f6.svg",
1760
+ "country": "Antarctica",
1761
+ "code": "aq"
1762
+ }, {
1763
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1f7.svg",
1764
+ "country": "Argentina",
1765
+ "code": "ar"
1766
+ }, {
1767
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1f8.svg",
1768
+ "country": "American Samoa",
1769
+ "code": "as"
1770
+ }, {
1771
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1f9.svg",
1772
+ "country": "Austria",
1773
+ "code": "at"
1774
+ }, {
1775
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1fa.svg",
1776
+ "country": "Australia",
1777
+ "code": "au"
1778
+ }, {
1779
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1fc.svg",
1780
+ "country": "Aruba",
1781
+ "code": "aw"
1782
+ }, {
1783
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1fd.svg",
1784
+ "country": "Åland Islands",
1785
+ "code": "ax"
1786
+ }, {
1787
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e6-1f1ff.svg",
1788
+ "country": "Azerbaijan",
1789
+ "code": "az"
1790
+ }, {
1791
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1e6.svg",
1792
+ "country": "Bosnia & Herzegovina",
1793
+ "code": "ba"
1794
+ }, {
1795
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1e7.svg",
1796
+ "country": "Barbados",
1797
+ "code": "bb"
1798
+ }, {
1799
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1e9.svg",
1800
+ "country": "Bangladesh",
1801
+ "code": "bd"
1802
+ }, {
1803
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1ea.svg",
1804
+ "country": "Belgium",
1805
+ "code": "be"
1806
+ }, {
1807
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1eb.svg",
1808
+ "country": "Burkina Faso",
1809
+ "code": "bf"
1810
+ }, {
1811
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1ec.svg",
1812
+ "country": "Bulgaria",
1813
+ "code": "bg"
1814
+ }, {
1815
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1ed.svg",
1816
+ "country": "Bahrain",
1817
+ "code": "bh"
1818
+ }, {
1819
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1ee.svg",
1820
+ "country": "Burundi",
1821
+ "code": "bi"
1822
+ }, {
1823
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1ef.svg",
1824
+ "country": "Benin",
1825
+ "code": "bj"
1826
+ }, {
1827
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1f1.svg",
1828
+ "country": "St. Barthélemy",
1829
+ "code": "bl"
1830
+ }, {
1831
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1f2.svg",
1832
+ "country": "Bermuda",
1833
+ "code": "bm"
1834
+ }, {
1835
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1f3.svg",
1836
+ "country": "Brunei",
1837
+ "code": "bn"
1838
+ }, {
1839
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1f4.svg",
1840
+ "country": "Bolivia",
1841
+ "code": "bo"
1842
+ }, {
1843
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1f6.svg",
1844
+ "country": "Caribbean Netherlands"
1845
+ }, {
1846
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1f7.svg",
1847
+ "country": "Brazil",
1848
+ "code": "br"
1849
+ }, {
1850
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1f8.svg",
1851
+ "country": "Bahamas",
1852
+ "code": "bs"
1853
+ }, {
1854
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1f9.svg",
1855
+ "country": "Bhutan",
1856
+ "code": "bt"
1857
+ }, {
1858
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1fb.svg",
1859
+ "country": "Bouvet Island",
1860
+ "code": "bv"
1861
+ }, {
1862
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1fc.svg",
1863
+ "country": "Botswana",
1864
+ "code": "bw"
1865
+ }, {
1866
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1fe.svg",
1867
+ "country": "Belarus",
1868
+ "code": "by"
1869
+ }, {
1870
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e7-1f1ff.svg",
1871
+ "country": "Belize",
1872
+ "code": "bz"
1873
+ }, {
1874
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1e6.svg",
1875
+ "country": "Canada",
1876
+ "code": "ca"
1877
+ }, {
1878
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1e8.svg",
1879
+ "country": "Cocos (Keeling) Islands",
1880
+ "code": "cc"
1881
+ }, {
1882
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1e9.svg",
1883
+ "country": "Congo - Kinshasa",
1884
+ "code": "cg"
1885
+ }, {
1886
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1eb.svg",
1887
+ "country": "Central African Republic",
1888
+ "code": "cf"
1889
+ }, {
1890
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1ec.svg",
1891
+ "country": "Congo - Brazzaville",
1892
+ "code": "cd"
1893
+ }, {
1894
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1ed.svg",
1895
+ "country": "Switzerland",
1896
+ "code": "ch"
1897
+ }, {
1898
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1ee.svg",
1899
+ "country": "Côte d’Ivoire",
1900
+ "code": "ci"
1901
+ }, {
1902
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1f0.svg",
1903
+ "country": "Cook Islands",
1904
+ "code": "ck"
1905
+ }, {
1906
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1f1.svg",
1907
+ "country": "Chile",
1908
+ "code": "cl"
1909
+ }, {
1910
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1f2.svg",
1911
+ "country": "Cameroon",
1912
+ "code": "cm"
1913
+ }, {
1914
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1f3.svg",
1915
+ "country": "China",
1916
+ "code": "cn"
1917
+ }, {
1918
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1f4.svg",
1919
+ "country": "Colombia",
1920
+ "code": "co"
1921
+ }, {
1922
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1f5.svg",
1923
+ "country": "Clipperton Island",
1924
+ "code": "cp"
1925
+ }, {
1926
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1f7.svg",
1927
+ "country": "Costa Rica",
1928
+ "code": "cr"
1929
+ }, {
1930
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1fa.svg",
1931
+ "country": "Cuba",
1932
+ "code": "cu"
1933
+ }, {
1934
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1fb.svg",
1935
+ "country": "Cape Verde",
1936
+ "code": "cv"
1937
+ }, {
1938
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1fc.svg",
1939
+ "country": "Curaçao",
1940
+ "code": "cw"
1941
+ }, {
1942
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1fd.svg",
1943
+ "country": "Christmas Island",
1944
+ "code": "cx"
1945
+ }, {
1946
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1fe.svg",
1947
+ "country": "Cyprus",
1948
+ "code": "cy"
1949
+ }, {
1950
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e8-1f1ff.svg",
1951
+ "country": "Czechia",
1952
+ "code": "cz"
1953
+ }, {
1954
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e9-1f1ea.svg",
1955
+ "country": "Germany",
1956
+ "code": "de"
1957
+ }, {
1958
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e9-1f1ec.svg",
1959
+ "country": "Diego Garcia",
1960
+ "code": "dg"
1961
+ }, {
1962
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e9-1f1ef.svg",
1963
+ "country": "Djibouti",
1964
+ "code": "dj"
1965
+ }, {
1966
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e9-1f1f0.svg",
1967
+ "country": "Denmark",
1968
+ "code": "dk"
1969
+ }, {
1970
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e9-1f1f2.svg",
1971
+ "country": "Dominica",
1972
+ "code": "dm"
1973
+ }, {
1974
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e9-1f1f4.svg",
1975
+ "country": "Dominican Republic",
1976
+ "code": "do"
1977
+ }, {
1978
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1e9-1f1ff.svg",
1979
+ "country": "Algeria",
1980
+ "code": "dz"
1981
+ }, {
1982
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ea-1f1e6.svg",
1983
+ "country": "Ceuta & Melilla",
1984
+ "code": "ea"
1985
+ }, {
1986
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ea-1f1e8.svg",
1987
+ "country": "Ecuador",
1988
+ "code": "ec"
1989
+ }, {
1990
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ea-1f1ea.svg",
1991
+ "country": "Estonia",
1992
+ "code": "ee"
1993
+ }, {
1994
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ea-1f1ec.svg",
1995
+ "country": "Egypt",
1996
+ "code": "eg"
1997
+ }, {
1998
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ea-1f1ed.svg",
1999
+ "country": "Western Sahara",
2000
+ "code": "eh"
2001
+ }, {
2002
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ea-1f1f7.svg",
2003
+ "country": "Eritrea",
2004
+ "code": "er"
2005
+ }, {
2006
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ea-1f1f8.svg",
2007
+ "country": "Spain",
2008
+ "code": "es"
2009
+ }, {
2010
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ea-1f1f9.svg",
2011
+ "country": "Ethiopia",
2012
+ "code": "et"
2013
+ }, {
2014
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ea-1f1fa.svg",
2015
+ "country": "European Union",
2016
+ "code": "eu"
2017
+ }, {
2018
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1eb-1f1ee.svg",
2019
+ "country": "Finland",
2020
+ "code": "fi"
2021
+ }, {
2022
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1eb-1f1ef.svg",
2023
+ "country": "Fiji",
2024
+ "code": "fj"
2025
+ }, {
2026
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1eb-1f1f0.svg",
2027
+ "country": "Falkland Islands",
2028
+ "code": "fk"
2029
+ }, {
2030
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1eb-1f1f2.svg",
2031
+ "country": "Micronesia",
2032
+ "code": "fm"
2033
+ }, {
2034
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1eb-1f1f4.svg",
2035
+ "country": "Faroe Islands",
2036
+ "code": "fo"
2037
+ }, {
2038
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1eb-1f1f7.svg",
2039
+ "country": "France",
2040
+ "code": "fr"
2041
+ }, {
2042
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1e6.svg",
2043
+ "country": "Gabon",
2044
+ "code": "ga"
2045
+ }, {
2046
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1e7.svg",
2047
+ "country": "United Kingdom",
2048
+ "code": "gb"
2049
+ }, {
2050
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1e9.svg",
2051
+ "country": "Grenada",
2052
+ "code": "gd"
2053
+ }, {
2054
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1ea.svg",
2055
+ "country": "Georgia",
2056
+ "code": "ge"
2057
+ }, {
2058
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1eb.svg",
2059
+ "country": "French Guiana",
2060
+ "code": "gf"
2061
+ }, {
2062
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1ec.svg",
2063
+ "country": "Guernsey",
2064
+ "code": "gg"
2065
+ }, {
2066
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1ed.svg",
2067
+ "country": "Ghana",
2068
+ "code": "gh"
2069
+ }, {
2070
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1ee.svg",
2071
+ "country": "Gibraltar",
2072
+ "code": "gi"
2073
+ }, {
2074
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1f1.svg",
2075
+ "country": "Greenland",
2076
+ "code": "gl"
2077
+ }, {
2078
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1f2.svg",
2079
+ "country": "Gambia",
2080
+ "code": "gm"
2081
+ }, {
2082
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1f3.svg",
2083
+ "country": "Guinea",
2084
+ "code": "gn"
2085
+ }, {
2086
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1f5.svg",
2087
+ "country": "Guadeloupe",
2088
+ "code": "gp"
2089
+ }, {
2090
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1f6.svg",
2091
+ "country": "Equatorial Guinea",
2092
+ "code": "gq"
2093
+ }, {
2094
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1f7.svg",
2095
+ "country": "Greece",
2096
+ "code": "gr"
2097
+ }, {
2098
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1f8.svg",
2099
+ "country": "South Georgia & South', Sandwich Islands",
2100
+ "code": "gs"
2101
+ }, {
2102
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1f9.svg",
2103
+ "country": "Guatemala",
2104
+ "code": "gt"
2105
+ }, {
2106
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1fa.svg",
2107
+ "country": "Guam",
2108
+ "code": "gu"
2109
+ }, {
2110
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1fc.svg",
2111
+ "country": "Guinea-Bissau",
2112
+ "code": "gw"
2113
+ }, {
2114
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ec-1f1fe.svg",
2115
+ "country": "Guyana",
2116
+ "code": "gy"
2117
+ }, {
2118
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ed-1f1f0.svg",
2119
+ "country": "Hong Kong SAR China",
2120
+ "code": "hk"
2121
+ }, {
2122
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ed-1f1f2.svg",
2123
+ "country": "Heard & McDonald Islands",
2124
+ "code": "hm"
2125
+ }, {
2126
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ed-1f1f3.svg",
2127
+ "country": "Honduras",
2128
+ "code": "hn"
2129
+ }, {
2130
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ed-1f1f7.svg",
2131
+ "country": "Croatia",
2132
+ "code": "hr"
2133
+ }, {
2134
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ed-1f1f9.svg",
2135
+ "country": "Haiti",
2136
+ "code": "ht"
2137
+ }, {
2138
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ed-1f1fa.svg",
2139
+ "country": "Hungary",
2140
+ "code": "hu"
2141
+ }, {
2142
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1e8.svg",
2143
+ "country": "Canary Islands",
2144
+ "code": "ic"
2145
+ }, {
2146
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1e9.svg",
2147
+ "country": "Indonesia",
2148
+ "code": "id"
2149
+ }, {
2150
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1ea.svg",
2151
+ "country": "Ireland",
2152
+ "code": "ie"
2153
+ }, {
2154
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1f1.svg",
2155
+ "country": "Israel",
2156
+ "code": "il"
2157
+ }, {
2158
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1f2.svg",
2159
+ "country": "Isle of Man",
2160
+ "code": "im"
2161
+ }, {
2162
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1f3.svg",
2163
+ "country": "India",
2164
+ "code": "in"
2165
+ }, {
2166
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1f4.svg",
2167
+ "country": "British Indian Ocean Territory",
2168
+ "code": "io"
2169
+ }, {
2170
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1f6.svg",
2171
+ "country": "Iraq",
2172
+ "code": "iq"
2173
+ }, {
2174
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1f7.svg",
2175
+ "country": "Iran"
2176
+ }, {
2177
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1f8.svg",
2178
+ "country": "Iceland",
2179
+ "code": "is"
2180
+ }, {
2181
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ee-1f1f9.svg",
2182
+ "country": "Italy",
2183
+ "code": "it"
2184
+ }, {
2185
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ef-1f1ea.svg",
2186
+ "country": "Jersey",
2187
+ "code": "je"
2188
+ }, {
2189
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ef-1f1f2.svg",
2190
+ "country": "Jamaica",
2191
+ "code": "jm"
2192
+ }, {
2193
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ef-1f1f4.svg",
2194
+ "country": "Jordan",
2195
+ "code": "jo"
2196
+ }, {
2197
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ef-1f1f5.svg",
2198
+ "country": "Japan",
2199
+ "code": "jp"
2200
+ }, {
2201
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1ea.svg",
2202
+ "country": "Kenya",
2203
+ "code": "ke"
2204
+ }, {
2205
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1ec.svg",
2206
+ "country": "Kyrgyzstan",
2207
+ "code": "kg"
2208
+ }, {
2209
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1ed.svg",
2210
+ "country": "Cambodia",
2211
+ "code": "kh"
2212
+ }, {
2213
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1ee.svg",
2214
+ "country": "Kiribati",
2215
+ "code": "ki"
2216
+ }, {
2217
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1f2.svg",
2218
+ "country": "Comoros",
2219
+ "code": "km"
2220
+ }, {
2221
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1f3.svg",
2222
+ "country": "St. Kitts & Nevis",
2223
+ "code": "kn"
2224
+ }, {
2225
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1f5.svg",
2226
+ "country": "North Korea",
2227
+ "code": "kp"
2228
+ }, {
2229
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1f7.svg",
2230
+ "country": "South Korea",
2231
+ "code": "kr"
2232
+ }, {
2233
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1fc.svg",
2234
+ "country": "Kuwait",
2235
+ "code": "kw"
2236
+ }, {
2237
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1fe.svg",
2238
+ "country": "Cayman Islands",
2239
+ "code": "ky"
2240
+ }, {
2241
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f0-1f1ff.svg",
2242
+ "country": "Kazakhstan",
2243
+ "code": "kz"
2244
+ }, {
2245
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1e6.svg",
2246
+ "country": "Laos",
2247
+ "code": "la"
2248
+ }, {
2249
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1e7.svg",
2250
+ "country": "Lebanon",
2251
+ "code": "lb"
2252
+ }, {
2253
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1e8.svg",
2254
+ "country": "St. Lucia",
2255
+ "code": "lc"
2256
+ }, {
2257
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1ee.svg",
2258
+ "country": "Liechtenstein",
2259
+ "code": "li"
2260
+ }, {
2261
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1f0.svg",
2262
+ "country": "Sri Lanka",
2263
+ "code": "lk"
2264
+ }, {
2265
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1f7.svg",
2266
+ "country": "Liberia",
2267
+ "code": "lr"
2268
+ }, {
2269
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1f8.svg",
2270
+ "country": "Lesotho",
2271
+ "code": "ls"
2272
+ }, {
2273
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1f9.svg",
2274
+ "country": "Lithuania",
2275
+ "code": "lt"
2276
+ }, {
2277
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1fa.svg",
2278
+ "country": "Luxembourg",
2279
+ "code": "lu"
2280
+ }, {
2281
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1fb.svg",
2282
+ "country": "Latvia",
2283
+ "code": "lv"
2284
+ }, {
2285
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f1-1f1fe.svg",
2286
+ "country": "Libya",
2287
+ "code": "ly"
2288
+ }, {
2289
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1e6.svg",
2290
+ "country": "Morocco",
2291
+ "code": "ma"
2292
+ }, {
2293
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1e8.svg",
2294
+ "country": "Monaco",
2295
+ "code": "mc"
2296
+ }, {
2297
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1e9.svg",
2298
+ "country": "Moldova",
2299
+ "code": "md"
2300
+ }, {
2301
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1ea.svg",
2302
+ "country": "Montenegro",
2303
+ "code": "me"
2304
+ }, {
2305
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1eb.svg",
2306
+ "country": "St. Martin",
2307
+ "code": "mf"
2308
+ }, {
2309
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1ec.svg",
2310
+ "country": "Madagascar",
2311
+ "code": "mg"
2312
+ }, {
2313
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1ed.svg",
2314
+ "country": "Marshall Islands",
2315
+ "code": "mh"
2316
+ }, {
2317
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1f0.svg",
2318
+ "country": "North Macedonia",
2319
+ "code": "mk"
2320
+ }, {
2321
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1f1.svg",
2322
+ "country": "Mali",
2323
+ "code": "ml"
2324
+ }, {
2325
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1f2.svg",
2326
+ "country": "Myanmar (Burma)",
2327
+ "code": "mm"
2328
+ }, {
2329
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1f3.svg",
2330
+ "country": "Mongolia",
2331
+ "code": "mn"
2332
+ }, {
2333
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1f4.svg",
2334
+ "country": "Macao Sar China",
2335
+ "code": "mo"
2336
+ }, {
2337
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1f5.svg",
2338
+ "country": "Northern Mariana Islands",
2339
+ "code": "mp"
2340
+ }, {
2341
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1f6.svg",
2342
+ "country": "Martinique",
2343
+ "code": "mq"
2344
+ }, {
2345
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1f7.svg",
2346
+ "country": "Mauritania",
2347
+ "code": "mr"
2348
+ }, {
2349
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1f8.svg",
2350
+ "country": "Montserrat",
2351
+ "code": "ms"
2352
+ }, {
2353
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1f9.svg",
2354
+ "country": "Malta",
2355
+ "code": "mt"
2356
+ }, {
2357
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1fa.svg",
2358
+ "country": "Mauritius",
2359
+ "code": "mu"
2360
+ }, {
2361
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1fb.svg",
2362
+ "country": "Maldives",
2363
+ "code": "mv"
2364
+ }, {
2365
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1fc.svg",
2366
+ "country": "Malawi",
2367
+ "code": "mw"
2368
+ }, {
2369
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1fd.svg",
2370
+ "country": "Mexico",
2371
+ "code": "mx"
2372
+ }, {
2373
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1fe.svg",
2374
+ "country": "Malaysia",
2375
+ "code": "my"
2376
+ }, {
2377
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f2-1f1ff.svg",
2378
+ "country": "Mozambique",
2379
+ "code": "mz"
2380
+ }, {
2381
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1e6.svg",
2382
+ "country": "Namibia",
2383
+ "code": "na"
2384
+ }, {
2385
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1e8.svg",
2386
+ "country": "New Caledonia",
2387
+ "code": "nc"
2388
+ }, {
2389
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1ea.svg",
2390
+ "country": "Niger",
2391
+ "code": "ne"
2392
+ }, {
2393
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1eb.svg",
2394
+ "country": "Norfolk Island",
2395
+ "code": "nf"
2396
+ }, {
2397
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1ec.svg",
2398
+ "country": "Nigeria",
2399
+ "code": "ng"
2400
+ }, {
2401
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1ee.svg",
2402
+ "country": "Nicaragua",
2403
+ "code": "ni"
2404
+ }, {
2405
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1f1.svg",
2406
+ "country": "Netherlands",
2407
+ "code": "nl"
2408
+ }, {
2409
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1f4.svg",
2410
+ "country": "Norway",
2411
+ "code": "no"
2412
+ }, {
2413
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1f5.svg",
2414
+ "country": "Nepal",
2415
+ "code": "np"
2416
+ }, {
2417
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1f7.svg",
2418
+ "country": "Nauru",
2419
+ "code": "nr"
2420
+ }, {
2421
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1fa.svg",
2422
+ "country": "Niue",
2423
+ "code": "nu"
2424
+ }, {
2425
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f3-1f1ff.svg",
2426
+ "country": "New Zealand",
2427
+ "code": "nz"
2428
+ }, {
2429
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f4-1f1f2.svg",
2430
+ "country": "Oman",
2431
+ "code": "om"
2432
+ }, {
2433
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1e6.svg",
2434
+ "country": "Panama",
2435
+ "code": "pa"
2436
+ }, {
2437
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1ea.svg",
2438
+ "country": "Peru",
2439
+ "code": "pe"
2440
+ }, {
2441
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1eb.svg",
2442
+ "country": "French Polynesia",
2443
+ "code": "pf"
2444
+ }, {
2445
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1ec.svg",
2446
+ "country": "Papua New Guinea",
2447
+ "code": "pg"
2448
+ }, {
2449
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1ed.svg",
2450
+ "country": "Philippines",
2451
+ "code": "ph"
2452
+ }, {
2453
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1f0.svg",
2454
+ "country": "Pakistan",
2455
+ "code": "pk"
2456
+ }, {
2457
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1f1.svg",
2458
+ "country": "Poland",
2459
+ "code": "pl"
2460
+ }, {
2461
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1f2.svg",
2462
+ "country": "St. Pierre & Miquelon",
2463
+ "code": "pm"
2464
+ }, {
2465
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1f3.svg",
2466
+ "country": "Pitcairn Islands",
2467
+ "code": "pn"
2468
+ }, {
2469
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1f7.svg",
2470
+ "country": "Puerto Rico",
2471
+ "code": "pr"
2472
+ }, {
2473
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1f8.svg",
2474
+ "country": "Palestinian Territories",
2475
+ "code": "ps"
2476
+ }, {
2477
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1f9.svg",
2478
+ "country": "Portugal",
2479
+ "code": "pt"
2480
+ }, {
2481
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1fc.svg",
2482
+ "country": "Palau",
2483
+ "code": "pw"
2484
+ }, {
2485
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f5-1f1fe.svg",
2486
+ "country": "Paraguay",
2487
+ "code": "py"
2488
+ }, {
2489
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f6-1f1e6.svg",
2490
+ "country": "Qatar",
2491
+ "code": "qa"
2492
+ }, {
2493
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f7-1f1ea.svg",
2494
+ "country": "Réunion",
2495
+ "code": "re"
2496
+ }, {
2497
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f7-1f1f4.svg",
2498
+ "country": "Romania",
2499
+ "code": "ro"
2500
+ }, {
2501
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f7-1f1f8.svg",
2502
+ "country": "Serbia",
2503
+ "code": "yu"
2504
+ }, {
2505
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f7-1f1fa.svg",
2506
+ "country": "Russia",
2507
+ "code": "ru"
2508
+ }, {
2509
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f7-1f1fc.svg",
2510
+ "country": "Rwanda",
2511
+ "code": "rw"
2512
+ }, {
2513
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1e6.svg",
2514
+ "country": "Saudi Arabia",
2515
+ "code": "sa"
2516
+ }, {
2517
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1e7.svg",
2518
+ "country": "Solomon Islands",
2519
+ "code": "sb"
2520
+ }, {
2521
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1e8.svg",
2522
+ "country": "Seychelles",
2523
+ "code": "sc"
2524
+ }, {
2525
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1e9.svg",
2526
+ "country": "Sudan",
2527
+ "code": "sd"
2528
+ }, {
2529
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1ea.svg",
2530
+ "country": "Sweden",
2531
+ "code": "se"
2532
+ }, {
2533
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1ec.svg",
2534
+ "country": "Singapore",
2535
+ "code": "sg"
2536
+ }, {
2537
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1ed.svg",
2538
+ "country": "St. Helena",
2539
+ "code": "sh"
2540
+ }, {
2541
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1ee.svg",
2542
+ "country": "Slovenia",
2543
+ "code": "si"
2544
+ }, {
2545
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1ef.svg",
2546
+ "country": "Svalbard & Jan Mayen",
2547
+ "code": "sj"
2548
+ }, {
2549
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1f0.svg",
2550
+ "country": "Slovakia",
2551
+ "code": "sk"
2552
+ }, {
2553
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1f1.svg",
2554
+ "country": "Sierra Leone",
2555
+ "code": "sl"
2556
+ }, {
2557
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1f2.svg",
2558
+ "country": "San Marino",
2559
+ "code": "sm"
2560
+ }, {
2561
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1f3.svg",
2562
+ "country": "Senegal",
2563
+ "code": "sn"
2564
+ }, {
2565
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1f4.svg",
2566
+ "country": "Somalia",
2567
+ "code": "so"
2568
+ }, {
2569
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1f7.svg",
2570
+ "country": "Suriname",
2571
+ "code": "sr"
2572
+ }, {
2573
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1f8.svg",
2574
+ "country": "South Sudan",
2575
+ "code": "ss"
2576
+ }, {
2577
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1f9.svg",
2578
+ "country": "São Tomé & Príncipe",
2579
+ "code": "st"
2580
+ }, {
2581
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1fb.svg",
2582
+ "country": "El Salvador",
2583
+ "code": "sv"
2584
+ }, {
2585
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1fd.svg",
2586
+ "country": "Sint Maarten",
2587
+ "code": "sx"
2588
+ }, {
2589
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1fe.svg",
2590
+ "country": "Syria",
2591
+ "code": "sy"
2592
+ }, {
2593
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f8-1f1ff.svg",
2594
+ "country": "Eswatini",
2595
+ "code": "sz"
2596
+ }, {
2597
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1e6.svg",
2598
+ "country": "Tristan Da Cunha",
2599
+ "code": "sh"
2600
+ }, {
2601
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1e8.svg",
2602
+ "country": "Turks & Caicos Islands",
2603
+ "code": "tc"
2604
+ }, {
2605
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1e9.svg",
2606
+ "country": "Chad",
2607
+ "code": "td"
2608
+ }, {
2609
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1eb.svg",
2610
+ "country": "French Southern Territories",
2611
+ "code": "tf"
2612
+ }, {
2613
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1ec.svg",
2614
+ "country": "Togo",
2615
+ "code": "tg"
2616
+ }, {
2617
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1ed.svg",
2618
+ "country": "Thailand",
2619
+ "code": "th"
2620
+ }, {
2621
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1ef.svg",
2622
+ "country": "Tajikistan",
2623
+ "code": "tj"
2624
+ }, {
2625
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1f0.svg",
2626
+ "country": "Tokelau",
2627
+ "code": "tk"
2628
+ }, {
2629
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1f1.svg",
2630
+ "country": "Timor-Leste",
2631
+ "code": "tl"
2632
+ }, {
2633
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1f2.svg",
2634
+ "country": "Turkmenistan",
2635
+ "code": "tm"
2636
+ }, {
2637
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1f3.svg",
2638
+ "country": "Tunisia",
2639
+ "code": "tn"
2640
+ }, {
2641
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1f4.svg",
2642
+ "country": "Tonga",
2643
+ "code": "to"
2644
+ }, {
2645
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1f7.svg",
2646
+ "country": "Turkey",
2647
+ "code": "tr"
2648
+ }, {
2649
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1f9.svg",
2650
+ "country": "Trinidad & Tobago",
2651
+ "code": "tt"
2652
+ }, {
2653
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1fb.svg",
2654
+ "country": "Tuvalu",
2655
+ "code": "tv"
2656
+ }, {
2657
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1fc.svg",
2658
+ "country": "Taiwan",
2659
+ "code": "tw"
2660
+ }, {
2661
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1f9-1f1ff.svg",
2662
+ "country": "Tanzania",
2663
+ "code": "tz"
2664
+ }, {
2665
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fa-1f1e6.svg",
2666
+ "country": "Ukraine",
2667
+ "code": "ua"
2668
+ }, {
2669
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fa-1f1ec.svg",
2670
+ "country": "Uganda",
2671
+ "code": "ug"
2672
+ }, {
2673
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fa-1f1f2.svg",
2674
+ "country": "U.S. Outlying Islands",
2675
+ "code": "um"
2676
+ }, {
2677
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fa-1f1f3.svg",
2678
+ "country": "United Nations",
2679
+ "code": "un"
2680
+ }, {
2681
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fa-1f1f8.svg",
2682
+ "country": "United States",
2683
+ "code": "us"
2684
+ }, {
2685
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fa-1f1fe.svg",
2686
+ "country": "Uruguay",
2687
+ "code": "uy"
2688
+ }, {
2689
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fa-1f1ff.svg",
2690
+ "country": "Uzbekistan",
2691
+ "code": "uz"
2692
+ }, {
2693
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fb-1f1e6.svg",
2694
+ "country": "Vatican City",
2695
+ "code": "va"
2696
+ }, {
2697
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fb-1f1e8.svg",
2698
+ "country": "St. Vincent & Grenadines",
2699
+ "code": "vc"
2700
+ }, {
2701
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fb-1f1ea.svg",
2702
+ "country": "Venezuela",
2703
+ "code": "ve"
2704
+ }, {
2705
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fb-1f1ec.svg",
2706
+ "country": "British Virgin Islands",
2707
+ "code": "vg"
2708
+ }, {
2709
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fb-1f1ee.svg",
2710
+ "country": "U.S. Virgin Islands",
2711
+ "code": "vi"
2712
+ }, {
2713
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fb-1f1f3.svg",
2714
+ "country": "Vietnam",
2715
+ "code": "vn"
2716
+ }, {
2717
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fb-1f1fa.svg",
2718
+ "country": "Vanuatu",
2719
+ "code": "vu"
2720
+ }, {
2721
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fc-1f1eb.svg",
2722
+ "country": "Wallis & Futuna",
2723
+ "code": "wf"
2724
+ }, {
2725
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fc-1f1f8.svg",
2726
+ "country": "Samoa",
2727
+ "code": "ws"
2728
+ }, {
2729
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fd-1f1f0.svg",
2730
+ "country": "Kosovo",
2731
+ "code": "xk"
2732
+ }, {
2733
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fe-1f1ea.svg",
2734
+ "country": "Yemen",
2735
+ "code": "ye"
2736
+ }, {
2737
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1fe-1f1f9.svg",
2738
+ "country": "Mayotte",
2739
+ "code": "yt"
2740
+ }, {
2741
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ff-1f1e6.svg",
2742
+ "country": "South Africa",
2743
+ "code": "za"
2744
+ }, {
2745
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ff-1f1f2.svg",
2746
+ "country": "Zambia",
2747
+ "code": "zm"
2748
+ }, {
2749
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f1ff-1f1fc.svg",
2750
+ "country": "Zimbabwe",
2751
+ "code": "zw"
2752
+ }, {
2753
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f3f4-e0067-e0062-e0065-e006e-e0067-e007f.svg",
2754
+ "country": "England",
2755
+ "code": "uk"
2756
+ }, {
2757
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f3f4-e0067-e0062-e0073-e0063-e0074-e007f.svg",
2758
+ "country": "Scotland",
2759
+ "code": "uk"
2760
+ }, {
2761
+ "flag": "https://twemoji.maxcdn.com/2/svg/1f3f4-e0067-e0062-e0077-e006c-e0073-e007f.svg",
2762
+ "country": "Wales",
2763
+ "code": "uk"
2764
+ }];
2765
+
2766
+ const useClickOutside = (ref, callback) => {
2767
+ useEffect(() => {
2768
+ const element = ref === null || ref === void 0 ? void 0 : ref.current;
2769
+ const listener = evt => {
2770
+ if (!element || element.contains(evt.target)) return;
2771
+ callback(evt);
2772
+ };
2773
+ document.addEventListener('mousedown', listener);
2774
+ document.addEventListener('touchstart', listener);
2775
+ return () => {
2776
+ document.removeEventListener('mousedown', listener);
2777
+ document.removeEventListener('touchstart', listener);
2778
+ };
2779
+ }, [ref, callback]);
2780
+ };
2781
+ const useKeyPress = targetKey => {
2782
+ const [pressed, setPressed] = useState(false);
2783
+ useEffect(() => {
2784
+ const onKeydown = e => {
2785
+ const keyPressed = e.key;
2786
+ if (keyPressed === targetKey) setPressed(true);
2787
+ };
2788
+ const onKeyup = e => {
2789
+ const keyPressed = e.key;
2790
+ if (keyPressed === targetKey) setPressed(false);
2791
+ };
2792
+ window.addEventListener('keydown', onKeydown);
2793
+ window.addEventListener('keyup', onKeyup);
2794
+ return () => {
2795
+ window.removeEventListener('keydown', onKeydown);
2796
+ window.removeEventListener('keyup', onKeyup);
2797
+ };
2798
+ }, [targetKey]);
2799
+ return pressed;
2800
+ };
2801
+ const CountrySelectStyled = styled.div.withConfig({
2802
+ displayName: "country__CountrySelectStyled",
2803
+ componentId: "sc-93yqgk-0"
2804
+ })(["", ";"], ({
2805
+ theme
2806
+ }) => {
2807
+ return css(["div[aria-hidden=\"true\"]{display:none;}[aria-invalid='true']{background:#F9D7D7!important;border:1px solid #ca2121 !important;}[aria-invalid='false']{background:#D5FCE9 !important;border:1px solid #008A48 !important;}.country-select__label{display:block;margin:0 0 8px;}.country-select__wrapper{padding:16px 8px;margin:8px 0 0;}.country-select__btn--toggle{padding:8px;display:flex;align-items:center;justify-content:space-between;cursor:pointer;font-family:inherit;background:#fff;border-radius:3px;border:1px solid #949494;height:40px;width:100%;max-width:100%;padding:8px;.country-select__icons{margin-left:auto;display:flex;align-items:center;}}.country-select__input{margin:0 8px 16px;font-family:inherit;background-color:#fff;border-radius:3px;border:1px solid #949494;height:40px;width:100%;max-width:calc(100% - 16px);padding:8px;}.country-select__options{overflow-y:scroll;height:247px;list-style:none;padding:0;margin:0;}.country-select__option{padding:8px;display:flex;align-items:center;cursor:pointer;background:transparent;border:none;width:100%;svg{margin-right:4px;}}img{margin-left:4px;width:16px;height:16px;}.required{color:", ";}"], theme.colors.red_darker);
2808
+ });
2809
+ const CountrySelect = ({
2810
+ formId,
2811
+ id,
2812
+ field,
2813
+ validations,
2814
+ defaultValue
2815
+ }) => {
2816
+ var _options$filter, _options$filter$;
2817
+ const [options, setOptions] = useState(countries);
2818
+ const [selected, setSelected] = useState(defaultValue || '');
2819
+ const [toggled, toggleDropdown] = useState(false);
2820
+ useEffect(() => {
2821
+ if (defaultValue) {
2822
+ var _countries$filter, _countries$filter$;
2823
+ const defaultCountry = ((_countries$filter = countries.filter(({
2824
+ country
2825
+ }) => country === defaultValue)) === null || _countries$filter === void 0 ? void 0 : (_countries$filter$ = _countries$filter[0]) === null || _countries$filter$ === void 0 ? void 0 : _countries$filter$.country) || '';
2826
+ if (defaultCountry) setSelected(defaultCountry);
2827
+ }
2828
+ }, [defaultValue]);
2829
+ const isRequired = validations && validations.required ? true : false;
2830
+ const onChange = value => {
2831
+ if (value && value.length >= 1) {
2832
+ const opts = countries;
2833
+ const optsfiltered = opts.filter(({
2834
+ country
2835
+ }) => country.toLowerCase().includes(value.toLowerCase()));
2836
+ setOptions(optsfiltered);
2837
+ } else setOptions(countries);
2838
+ };
2839
+
2840
+ // Validation
2841
+ const dispatch = useDispatch();
2842
+ const selectFormValidationSent = makeSelectFormValidationSent(formId);
2843
+ const formValidationSent = useSelector(selectFormValidationSent);
2844
+ const [a11yInvalid, setA11yInvalid] = useState('');
2845
+ useEffect(() => {
2846
+ if (formValidationSent) setA11yInvalid(doA11yValidation(selected, field, true));
2847
+ }, [formValidationSent]);
2848
+ const elOptionRef = useRef();
2849
+ const elContainerRef = useRef();
2850
+ const close = () => toggleDropdown(false);
2851
+ useClickOutside(elContainerRef, close);
2852
+
2853
+ // Keyboard Navigation
2854
+ const isArrowUpPressed = useKeyPress('ArrowUp');
2855
+ const isArrowDownPressed = useKeyPress('ArrowDown');
2856
+ const isEscapePressed = useKeyPress('Escape');
2857
+ const [initState, setInitState] = useState({
2858
+ selectedIndex: -1
2859
+ });
2860
+ const updateState = (type, i) => {
2861
+ const max = options.length - 1;
2862
+ if (type === 'ARROW_UP') {
2863
+ let updatedState = {
2864
+ ...initState
2865
+ };
2866
+ const updatedIndex = updatedState.selectedIndex !== 0 ? updatedState.selectedIndex - 1 : max;
2867
+ updatedState.selectedIndex = updatedIndex;
2868
+ setInitState(updatedState);
2869
+ }
2870
+ if (type === 'ARROW_DOWN') {
2871
+ let updatedState = {
2872
+ ...initState
2873
+ };
2874
+ const updatedIndex = updatedState.selectedIndex !== max ? updatedState.selectedIndex + 1 : 0;
2875
+ updatedState.selectedIndex = updatedIndex;
2876
+ setInitState(updatedState);
2877
+ }
2878
+ if (type === 'SELECT') {
2879
+ let updatedState = {
2880
+ ...initState
2881
+ };
2882
+ updatedState.selectedIndex = i;
2883
+ setInitState(updatedState);
2884
+ }
2885
+ };
2886
+ useEffect(() => {
2887
+ if (toggled) {
2888
+ if (isArrowDownPressed) updateState('ARROW_DOWN');
2889
+ if (isArrowUpPressed) updateState('ARROW_UP');
2890
+ if (isEscapePressed) toggleDropdown(false);
2891
+ doFocus();
2892
+ }
2893
+ }, [toggled, isArrowDownPressed, isArrowUpPressed, isEscapePressed]);
2894
+ const doFocus = () => {
2895
+ var _element$;
2896
+ const attr = `[aria-pressed="true"]`;
2897
+ const element = document.querySelectorAll(attr);
2898
+ if (element && element.length >= 1) (_element$ = element[0]) === null || _element$ === void 0 ? void 0 : _element$.focus();
2899
+ };
2900
+ return /*#__PURE__*/React.createElement(CountrySelectStyled, {
2901
+ ref: elContainerRef,
2902
+ role: "region",
2903
+ id: "country",
2904
+ "aria-live": "polite"
2905
+ }, /*#__PURE__*/React.createElement("span", {
2906
+ className: "country-select__label",
2907
+ role: "label",
2908
+ "aria-label": `Select a country ${isRequired ? 'required' : 'optional'} ${selected}`,
2909
+ htmlFor: "country"
2910
+ }, "Select a country", isRequired ? /*#__PURE__*/React.createElement("span", {
2911
+ className: "label__required"
2912
+ }, "(required)") : /*#__PURE__*/React.createElement("span", {
2913
+ className: "label__optional"
2914
+ }, "(optional)")), /*#__PURE__*/React.createElement("button", {
2915
+ className: "country-select__btn--toggle",
2916
+ "aria-controls": "country",
2917
+ "aria-invalid": a11yInvalid,
2918
+ "aria-expanded": toggled,
2919
+ onClick: e => {
2920
+ e.preventDefault();
2921
+ toggleDropdown(!toggled);
2922
+ }
2923
+ }, selected, selected && /*#__PURE__*/React.createElement("img", {
2924
+ src: (_options$filter = options.filter(opt => opt.country === selected)) === null || _options$filter === void 0 ? void 0 : (_options$filter$ = _options$filter[0]) === null || _options$filter$ === void 0 ? void 0 : _options$filter$.flag,
2925
+ alt: ""
2926
+ }), /*#__PURE__*/React.createElement("span", {
2927
+ className: "sr-only"
2928
+ }, "Open the Country select searchable dropdown"), /*#__PURE__*/React.createElement("div", {
2929
+ className: "country-select__icons"
2930
+ }, toggled ? /*#__PURE__*/React.createElement("svg", {
2931
+ xmlns: "http://www.w3.org/2000/svg",
2932
+ width: "24",
2933
+ height: "24",
2934
+ fill: "none",
2935
+ focusable: "false",
2936
+ "aria-hidden": "true",
2937
+ role: "presentation"
2938
+ }, /*#__PURE__*/React.createElement("path", {
2939
+ fill: "#333",
2940
+ d: "m7 15 4.293-4.293L15.586 15 17 13.586l-5.707-5.707-5.707 5.707L7 15Z"
2941
+ })) : /*#__PURE__*/React.createElement("svg", {
2942
+ xmlns: "http://www.w3.org/2000/svg",
2943
+ width: "24",
2944
+ height: "24",
2945
+ fill: "none",
2946
+ focusable: "false",
2947
+ "aria-hidden": "true",
2948
+ role: "presentation"
2949
+ }, /*#__PURE__*/React.createElement("path", {
2950
+ fill: "#333",
2951
+ d: "m16 8-4.293 4.293L7.414 8 6 9.414l5.707 5.707 5.707-5.707L16 8Z"
2952
+ })), a11yInvalid == 'true' && /*#__PURE__*/React.createElement("svg", {
2953
+ className: "svg",
2954
+ xmlns: "http://www.w3.org/2000/svg",
2955
+ focusable: "false",
2956
+ "aria-hidden": "true",
2957
+ role: "presentation",
2958
+ width: "16",
2959
+ height: "16",
2960
+ fill: "none"
2961
+ }, /*#__PURE__*/React.createElement("path", {
2962
+ fill: "#333",
2963
+ d: "M12.2 3.807a.664.664 0 0 0-.94 0L8 7.06 4.74 3.8a.665.665 0 0 0-.94.94L7.06 8 3.8 11.26a.664.664 0 1 0 .94.94L8 8.94l3.26 3.26a.665.665 0 0 0 .94-.94L8.94 8l3.26-3.26a.668.668 0 0 0 0-.933Z"
2964
+ })), a11yInvalid == 'false' && /*#__PURE__*/React.createElement("svg", {
2965
+ className: "svg",
2966
+ xmlns: "http://www.w3.org/2000/svg",
2967
+ focusable: "false",
2968
+ "aria-hidden": "true",
2969
+ role: "presentation",
2970
+ width: "16",
2971
+ height: "16",
2972
+ fill: "none"
2973
+ }, /*#__PURE__*/React.createElement("path", {
2974
+ fill: "#333",
2975
+ d: "m2 8 4.418 4.667L14 4.659l-1.246-1.326-6.336 6.692-3.18-3.332L2 8Z"
2976
+ })))), /*#__PURE__*/React.createElement("div", {
2977
+ className: "country-select__wrapper",
2978
+ "aria-hidden": !toggled
2979
+ }, /*#__PURE__*/React.createElement("label", {
2980
+ htmlFor: "search-country-name",
2981
+ className: "sr-only"
2982
+ }, "Search country name"), /*#__PURE__*/React.createElement("input", {
2983
+ id: "search-country-name",
2984
+ className: "country-select__input",
2985
+ placeholder: "Search country name",
2986
+ onChange: e => {
2987
+ e.preventDefault();
2988
+ onChange(e.target.value);
2989
+ }
2990
+ }), /*#__PURE__*/React.createElement("ul", {
2991
+ id: "contry",
2992
+ role: "select",
2993
+ name: "country",
2994
+ className: "country-select__options"
2995
+ }, options.map((option, i) => {
2996
+ const isSelected = selected === option.country;
2997
+ return /*#__PURE__*/React.createElement("li", {
2998
+ key: i,
2999
+ "aria-hidden": isSelected,
3000
+ "aria-selected": isSelected,
3001
+ role: "option"
3002
+ }, /*#__PURE__*/React.createElement(CountryOption, {
3003
+ onClick: e => {
3004
+ e.preventDefault();
3005
+ setSelected(option.country);
3006
+ dispatch(setValue(formId, id, e.target.value));
3007
+ setA11yInvalid(doA11yValidation(e.target.value, field, formValidationSent));
3008
+ },
3009
+ onKeyDown: e => {
3010
+ if (e.key === 'Enter' || e.key === ' ') {
3011
+ setSelected(option.country);
3012
+ dispatch(setValue(formId, id, e.target.value));
3013
+ setA11yInvalid(doA11yValidation(e.target.value, field, formValidationSent));
3014
+ updateState('SELECT', i);
3015
+ e.target.blur();
3016
+ }
3017
+ },
3018
+ ref: elOptionRef,
3019
+ value: option.country,
3020
+ "aria-pressed": i === initState.selectedIndex,
3021
+ tabIndex: 0
3022
+ }, isSelected && /*#__PURE__*/React.createElement("svg", {
3023
+ focusable: "false",
3024
+ "aria-hidden": "true",
3025
+ role: "presentation",
3026
+ xmlns: "http://www.w3.org/2000/svg",
3027
+ width: "16px",
3028
+ height: "16px",
3029
+ viewBox: "0 0 24 24",
3030
+ fill: "none"
3031
+ }, /*#__PURE__*/React.createElement("path", {
3032
+ fill: "#333",
3033
+ d: "m3 12 6.627 7L21 6.988 19.131 5 9.627 15.038 4.856 10.04 3 12Z"
3034
+ })), option.country, /*#__PURE__*/React.createElement("img", {
3035
+ src: option.flag,
3036
+ alt: ""
3037
+ })));
3038
+ }))));
3039
+ };
3040
+ const CountryOption = /*#__PURE__*/forwardRef(function SelectItem(props, ref = null) {
3041
+ const {
3042
+ className,
3043
+ children,
3044
+ ...rest
3045
+ } = props;
3046
+ return /*#__PURE__*/React.createElement("button", _extends({
3047
+ className: "country-select__option",
3048
+ role: "option",
3049
+ ref: ref
3050
+ }, rest), children);
3051
+ });
3052
+
1822
3053
  const FormComposer = ({
1823
3054
  fields,
1824
3055
  formData,
@@ -1829,13 +3060,11 @@ const FormComposer = ({
1829
3060
  defaultLanguage,
1830
3061
  errors,
1831
3062
  useDefaultTheme,
1832
- entries,
1833
- setCheckboxValue
3063
+ entries
1834
3064
  }) => {
1835
3065
  if (!fields || fields.length < 1) return null;
1836
3066
  return fields.map((field, idx) => {
1837
3067
  if (!field) return null;
1838
-
1839
3068
  switch (field.type) {
1840
3069
  case 'number':
1841
3070
  case 'textfield':
@@ -1857,7 +3086,6 @@ const FormComposer = ({
1857
3086
  useDefaultTheme: useDefaultTheme
1858
3087
  });
1859
3088
  }
1860
-
1861
3089
  case 'textarea':
1862
3090
  {
1863
3091
  return /*#__PURE__*/React.createElement(Textarea, {
@@ -1877,7 +3105,6 @@ const FormComposer = ({
1877
3105
  errors: errors
1878
3106
  });
1879
3107
  }
1880
-
1881
3108
  case 'dropdown':
1882
3109
  {
1883
3110
  return /*#__PURE__*/React.createElement(Dropdown, {
@@ -1892,7 +3119,6 @@ const FormComposer = ({
1892
3119
  useDefaultTheme: useDefaultTheme
1893
3120
  });
1894
3121
  }
1895
-
1896
3122
  case 'checkbox':
1897
3123
  {
1898
3124
  return /*#__PURE__*/React.createElement(Checkbox, {
@@ -1906,11 +3132,9 @@ const FormComposer = ({
1906
3132
  formId: formId,
1907
3133
  defaultValue: formData && formData[field.id] || field.default,
1908
3134
  type: field.dataType === 'boolean' ? 'single' : 'multiple',
1909
- useDefaultTheme: useDefaultTheme,
1910
- setCheckboxValue: setCheckboxValue
3135
+ useDefaultTheme: useDefaultTheme
1911
3136
  });
1912
3137
  }
1913
-
1914
3138
  case 'radio':
1915
3139
  {
1916
3140
  return /*#__PURE__*/React.createElement(RadioButton, {
@@ -1925,7 +3149,6 @@ const FormComposer = ({
1925
3149
  useDefaultTheme: useDefaultTheme
1926
3150
  });
1927
3151
  }
1928
-
1929
3152
  case 'entryPicker':
1930
3153
  {
1931
3154
  const type = field.dataType === 'objectArray' ? 'checkbox' : 'radio';
@@ -1942,7 +3165,6 @@ const FormComposer = ({
1942
3165
  formId: formId
1943
3166
  });
1944
3167
  }
1945
-
1946
3168
  case 'date':
1947
3169
  {
1948
3170
  return /*#__PURE__*/React.createElement(SingleDate, {
@@ -1956,7 +3178,6 @@ const FormComposer = ({
1956
3178
  useDefaultTheme: useDefaultTheme
1957
3179
  });
1958
3180
  }
1959
-
1960
3181
  case 'dateRange':
1961
3182
  {
1962
3183
  return /*#__PURE__*/React.createElement(DateRange, {
@@ -1969,7 +3190,6 @@ const FormComposer = ({
1969
3190
  useDefaultTheme: useDefaultTheme
1970
3191
  });
1971
3192
  }
1972
-
1973
3193
  case 'hidden':
1974
3194
  {
1975
3195
  return /*#__PURE__*/React.createElement(HiddenField, {
@@ -1982,10 +3202,21 @@ const FormComposer = ({
1982
3202
  placeholder: field.editor
1983
3203
  });
1984
3204
  }
3205
+ case 'country':
3206
+ {
3207
+ var _field$default;
3208
+ return /*#__PURE__*/React.createElement(CountrySelect, {
3209
+ key: `${field.id}-${idx}`,
3210
+ formId: formId,
3211
+ field: field,
3212
+ id: field.id,
3213
+ validations: field.validations,
3214
+ defaultValue: field === null || field === void 0 ? void 0 : (_field$default = field.default) === null || _field$default === void 0 ? void 0 : _field$default[defaultLanguage]
3215
+ });
3216
+ }
1985
3217
  }
1986
3218
  });
1987
3219
  };
1988
-
1989
3220
  FormComposer.propTypes = {
1990
3221
  fields: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
1991
3222
  formData: PropTypes.object,
@@ -1996,8 +3227,7 @@ FormComposer.propTypes = {
1996
3227
  setDateRangeValues: PropTypes.func,
1997
3228
  defaultLanguage: PropTypes.string,
1998
3229
  errors: PropTypes.array,
1999
- useDefaultTheme: PropTypes.bool,
2000
- setCheckboxValue: PropTypes.func
3230
+ useDefaultTheme: PropTypes.bool
2001
3231
  };
2002
3232
 
2003
3233
  const Loader = ({
@@ -2058,7 +3288,7 @@ const Button = ({
2058
3288
  useDefaultTheme
2059
3289
  }) => {
2060
3290
  return /*#__PURE__*/React.createElement(ButtonStyled, {
2061
- className: `${className ? className : ''} btnSubmit`,
3291
+ className: className,
2062
3292
  type: type,
2063
3293
  onClick: () => action(),
2064
3294
  disabled: loading,
@@ -2106,23 +3336,13 @@ const Form = ({
2106
3336
  onCustomSubmit
2107
3337
  }) => {
2108
3338
  const dispatch = useDispatch();
2109
-
2110
3339
  const _setFormId = formId => dispatch(setFormId(formId));
2111
-
2112
3340
  const _setValue = (formId, id, value) => dispatch(setValue(formId, id, value));
2113
-
2114
- const _setCheckboxValue = (formId, id, value, isChecked) => dispatch(setCheckboxValue(formId, id, value, isChecked));
2115
-
2116
3341
  const _setDateRangeValues = (formId, id, dateType, value) => dispatch(setDateRangeValues(formId, id, dateType, value));
2117
-
2118
3342
  const _onValidateField = (formId, id, value) => dispatch(onValidateField(formId, id, value));
2119
-
2120
3343
  const _doTogglePageForward = (formId, pageIndex) => dispatch(doTogglePageForward(formId, pageIndex));
2121
-
2122
3344
  const _doTogglePageBack = (formId, pageIndex) => dispatch(doTogglePageBack(formId, pageIndex));
2123
-
2124
3345
  const _onSubmit = formId => dispatch(onSubmit(formId));
2125
-
2126
3346
  useEffect(() => {
2127
3347
  if (formId) _setFormId(formId);
2128
3348
  }, [formId]);
@@ -2134,7 +3354,6 @@ const Form = ({
2134
3354
  const selectFormFieldErrors = makeSelectFormFieldErrors(formId);
2135
3355
  const selectFormEntries = makeSelectFormEntries(formId);
2136
3356
  const selectFormPostData = makeSelectFormPostData(formId);
2137
- const selectFormValidationSent = makeSelectFormValidationSent(formId);
2138
3357
  const status = useSelector(selectFormStatus);
2139
3358
  const fields = useSelector(selectFormFields);
2140
3359
  const pagingInfo = useSelector(selectPagingInfo);
@@ -2143,8 +3362,6 @@ const Form = ({
2143
3362
  const errors = useSelector(selectFormFieldErrors);
2144
3363
  const entries = useSelector(selectFormEntries);
2145
3364
  const formData = useSelector(selectFormPostData);
2146
- const validate = useSelector(selectFormValidationSent);
2147
-
2148
3365
  if (pagingInfo && pagingInfo.pageCount > 1) {
2149
3366
  const isLastPage = pagingInfo.pageCount == pagingInfo.pageIndex + 1;
2150
3367
  return /*#__PURE__*/React.createElement(ThemeProvider, {
@@ -2153,12 +3370,7 @@ const Form = ({
2153
3370
  className: className,
2154
3371
  id: formId,
2155
3372
  useDefaultTheme: useDefaultTheme
2156
- }, !(status !== null && status !== void 0 && status.hasSuccess) && !(status !== null && status !== void 0 && status.isLoading) && /*#__PURE__*/React.createElement(React.Fragment, null, pagingInfo.pageIndex > 0 && /*#__PURE__*/React.createElement(Button, {
2157
- type: "button",
2158
- text: "Go Back",
2159
- action: () => _doTogglePageBack(formId, pagingInfo.pageIndex - 1),
2160
- useDefaultTheme: useDefaultTheme
2161
- }), /*#__PURE__*/React.createElement(FormComposer, {
3373
+ }, !(status !== null && status !== void 0 && status.hasSuccess) && !(status !== null && status !== void 0 && status.isLoading) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormComposer, {
2162
3374
  fields: fields,
2163
3375
  formData: formData,
2164
3376
  formId: formId,
@@ -2169,20 +3381,26 @@ const Form = ({
2169
3381
  pagingInfo: pagingInfo,
2170
3382
  useDefaultTheme: useDefaultTheme,
2171
3383
  entries: entries,
2172
- setDateRangeValues: _setDateRangeValues,
2173
- setCheckboxValue: _setCheckboxValue
3384
+ setDateRangeValues: _setDateRangeValues
3385
+ }), pagingInfo.pageIndex > 0 && /*#__PURE__*/React.createElement(Button, {
3386
+ className: "form__btn--prev",
3387
+ type: "button",
3388
+ text: "Go Back",
3389
+ action: () => _doTogglePageBack(formId, pagingInfo.pageIndex - 1),
3390
+ useDefaultTheme: useDefaultTheme
2174
3391
  }), !isLastPage && /*#__PURE__*/React.createElement(Button, {
3392
+ className: "form__btn--next",
2175
3393
  type: "button",
2176
3394
  text: "Next",
2177
3395
  action: () => _doTogglePageForward(formId, pagingInfo.pageIndex + 1),
2178
3396
  useDefaultTheme: useDefaultTheme
2179
3397
  }), isLastPage && /*#__PURE__*/React.createElement(Button, {
3398
+ className: "form__btn--submit",
2180
3399
  text: (settings === null || settings === void 0 ? void 0 : settings.submitButtonText) || "Submit",
2181
3400
  type: "button",
2182
- loading: status === null || status === void 0 ? void 0 : status.isLoading,
3401
+ loading: status === null || status === void 0 ? void 0 : status.isSubmitting,
2183
3402
  action: () => {
2184
3403
  _onSubmit(formId);
2185
-
2186
3404
  if (onCustomSubmit) onCustomSubmit();
2187
3405
  },
2188
3406
  useDefaultTheme: useDefaultTheme
@@ -2193,7 +3411,7 @@ const Form = ({
2193
3411
  color: "#333"
2194
3412
  }), (status === null || status === void 0 ? void 0 : status.hasSuccess) && (status === null || status === void 0 ? void 0 : status.messages.success) && /*#__PURE__*/React.createElement("p", {
2195
3413
  className: "success-message"
2196
- }, status.messages.success), (errors === null || errors === void 0 ? void 0 : errors.length) >= 1 && validate && /*#__PURE__*/React.createElement("div", {
3414
+ }, status.messages.success), (errors === null || errors === void 0 ? void 0 : errors.length) >= 1 && /*#__PURE__*/React.createElement("div", {
2197
3415
  className: "form__errors",
2198
3416
  role: "alert"
2199
3417
  }, errors === null || errors === void 0 ? void 0 : errors.map(({
@@ -2221,15 +3439,14 @@ const Form = ({
2221
3439
  defaultLanguage: defaultLanguage,
2222
3440
  errors: errors,
2223
3441
  useDefaultTheme: useDefaultTheme,
2224
- entries: entries,
2225
- setCheckboxValue: _setCheckboxValue
3442
+ entries: entries
2226
3443
  }), /*#__PURE__*/React.createElement(Button, {
3444
+ className: "form__btn--submit",
2227
3445
  loading: status === null || status === void 0 ? void 0 : status.isSubmitting,
2228
3446
  text: (settings === null || settings === void 0 ? void 0 : settings.submitButtonText) || "Submit",
2229
3447
  type: "button",
2230
3448
  action: () => {
2231
3449
  _onSubmit(formId);
2232
-
2233
3450
  if (onCustomSubmit) onCustomSubmit();
2234
3451
  },
2235
3452
  useDefaultTheme: useDefaultTheme
@@ -2240,7 +3457,7 @@ const Form = ({
2240
3457
  color: "#333"
2241
3458
  }), (status === null || status === void 0 ? void 0 : status.hasSuccess) && (status === null || status === void 0 ? void 0 : status.messages.success) && /*#__PURE__*/React.createElement("p", {
2242
3459
  className: "success-message"
2243
- }, status.messages.success), (errors === null || errors === void 0 ? void 0 : errors.length) >= 1 && validate && /*#__PURE__*/React.createElement("div", {
3460
+ }, status.messages.success), (errors === null || errors === void 0 ? void 0 : errors.length) >= 1 && /*#__PURE__*/React.createElement("div", {
2244
3461
  className: "form__errors",
2245
3462
  role: "alert"
2246
3463
  }, errors === null || errors === void 0 ? void 0 : errors.map(({
@@ -2254,7 +3471,6 @@ const Form = ({
2254
3471
  }))));
2255
3472
  }
2256
3473
  };
2257
-
2258
3474
  Form.propTypes = {
2259
3475
  className: PropTypes.string,
2260
3476
  formId: PropTypes.string,