@medipass/utils 11.73.2 → 11.73.3-chore-update-react-18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/abn.js +40 -45
  2. package/{billable-items-f8291b1e.js → billable-items-5e559447.js} +1 -1
  3. package/build-validation-schema.js +81 -123
  4. package/{businesses-2633ab9b.js → businesses-94ec0280.js} +1 -1
  5. package/chart.js +7 -14
  6. package/claim-payment-status-formatted.js +5 -2
  7. package/claim-payment-status-icons.js +13 -2
  8. package/claim-payment-status-text-classes.js +14 -2
  9. package/constants.js +82 -69
  10. package/countries.js +6 -8
  11. package/datetime.js +6 -13
  12. package/document-types-formatted.js +8 -3
  13. package/document-types-icons.js +4 -2
  14. package/document-types-text-classes.js +5 -2
  15. package/documents/workflow-state-formatted-text-classes.js +13 -4
  16. package/documents/workflow-state-formatted.js +13 -4
  17. package/documents/workflow-state-icons.js +11 -2
  18. package/form-applications/assign-values-to-sections.js +10 -16
  19. package/{forms-e1c51a53.js → forms-646810f2.js} +1 -1
  20. package/funders.js +21 -56
  21. package/get-env.js +38 -75
  22. package/get-select-options.js +21 -40
  23. package/get-staff-type-display-name.js +2 -4
  24. package/google-addresses.js +46 -91
  25. package/{health-fund-accounts-88eac93c.js → health-fund-accounts-8eda8621.js} +1 -1
  26. package/{health-fund-settings-e7a0f2ec.js → health-fund-settings-6d803913.js} +1 -1
  27. package/{health-funds-7fea63a0.js → health-funds-5e838942.js} +2 -2
  28. package/i18n/index.js +15 -18
  29. package/i18n/translations.js +1 -1
  30. package/index.js +1 -3
  31. package/intercom.js +24 -69
  32. package/{members-8eb8d8d0.js → members-e1797829.js} +1 -1
  33. package/{modalities-2dfbea63.js → modalities-d9979fa4.js} +1 -1
  34. package/package.json +4 -4
  35. package/parse-health-fund-card-fields.js +4 -6
  36. package/{patients-dd3709c1.js → patients-aba388c0.js} +1 -1
  37. package/{payment-methods-d36bc018.js → payment-methods-4010f9e5.js} +1 -1
  38. package/payment-options.js +11 -33
  39. package/{practices-d6c480f1.js → practices-17c06e6c.js} +3 -3
  40. package/{products-0a392564.js → products-7054c705.js} +2 -2
  41. package/products.js +5 -12
  42. package/{professional-categories-157d1767.js → professional-categories-0927144e.js} +1 -1
  43. package/redux-actions.js +69 -108
  44. package/redux-reducer.js +53 -69
  45. package/sanitise-url.js +1 -1
  46. package/scroll.js +1 -3
  47. package/sensitive-keys.js +2 -2
  48. package/sentry.js +35 -59
  49. package/service-items.js +70 -111
  50. package/{services-f8480eba.js → services-a81b505c.js} +3 -3
  51. package/{specialties-25fbb171.js → specialties-c29f2f67.js} +1 -1
  52. package/{staff-646053b7.js → staff-fedb5a08.js} +4 -4
  53. package/status-icons.js +12 -2
  54. package/status-text-classes.js +12 -2
  55. package/{subscriptions-aef302aa.js → subscriptions-25d86dab.js} +5 -5
  56. package/test-framework/fixtures/accounts.js +1 -1
  57. package/test-framework/fixtures/billable-items.js +1 -1
  58. package/test-framework/fixtures/businesses.js +1 -1
  59. package/test-framework/fixtures/documents.js +3 -3
  60. package/test-framework/fixtures/form-application-templates.js +1 -1
  61. package/test-framework/fixtures/form-applications.js +1 -1
  62. package/test-framework/fixtures/forms.js +1 -1
  63. package/test-framework/fixtures/health-fund-accounts.js +1 -1
  64. package/test-framework/fixtures/health-fund-settings.js +1 -1
  65. package/test-framework/fixtures/health-funds.js +1 -1
  66. package/test-framework/fixtures/index.js +18 -18
  67. package/test-framework/fixtures/members.js +1 -1
  68. package/test-framework/fixtures/message-mappings.js +1 -1
  69. package/test-framework/fixtures/modalities.js +1 -1
  70. package/test-framework/fixtures/patients.js +1 -1
  71. package/test-framework/fixtures/payment-methods.js +1 -1
  72. package/test-framework/fixtures/practices.js +1 -1
  73. package/test-framework/fixtures/products.js +1 -1
  74. package/test-framework/fixtures/professional-categories.js +1 -1
  75. package/test-framework/fixtures/services.js +1 -1
  76. package/test-framework/fixtures/specialties.js +1 -1
  77. package/test-framework/fixtures/staff.js +1 -1
  78. package/test-framework/fixtures/subscriptions.js +1 -1
  79. package/test-framework/fixtures/transaction-reports.js +6 -6
  80. package/test-framework/fixtures/transactions.js +1 -1
  81. package/test-framework/fixtures/workflow-exceptions.js +2 -2
  82. package/test-framework/react.js +10 -12
  83. package/transaction-details-by-funder.js +20 -21
  84. package/transaction-status-formatted.js +13 -3
  85. package/transaction-status-helpers.js +21 -27
  86. package/transaction-status-icons.js +9 -2
  87. package/transaction-status-text-classes.js +16 -2
  88. package/transaction-status.js +7 -15
  89. package/{transactions-4a08e450.js → transactions-de63fd15.js} +14 -14
  90. package/validate-form.js +79 -269
  91. package/validate.js +16 -28
  92. package/webpack-config.js +6 -13
  93. package/workflow-state-formatted-text-classes.js +12 -4
  94. package/workflow-state-formatted.js +11 -2
package/validate-form.js CHANGED
@@ -9,8 +9,6 @@ require('core-js/es6/promise');
9
9
  require('core-js/es6/set');
10
10
  require('google-libphonenumber');
11
11
  var validate = require('./validate.js');
12
- var _regeneratorRuntime = _interopDefault(require('@babel/runtime/regenerator'));
13
- var _asyncToGenerator = _interopDefault(require('@babel/runtime/helpers/asyncToGenerator'));
14
12
  var _isArray = _interopDefault(require('lodash/isArray'));
15
13
  var _get = _interopDefault(require('lodash/get'));
16
14
  var format = _interopDefault(require('date-fns/format'));
@@ -20,356 +18,168 @@ var isValid = _interopDefault(require('date-fns/isValid'));
20
18
  var parse = _interopDefault(require('date-fns/parse'));
21
19
  var abn = require('./abn.js');
22
20
 
23
- var isRequired = function isRequired(value) {
24
- return !value || value.trim && !value.trim() || _isArray(value) && value.length === 0 ? 'This field is required' : undefined;
25
- };
26
- var isNumber = function isNumber(value) {
27
- return value && value.match(/[^0-9]/) ? 'This field must only contain numbers' : undefined;
28
- };
29
- var isEqualTo = function isEqualTo(target, message) {
21
+ const isRequired = value => !value || value.trim && !value.trim() || _isArray(value) && value.length === 0 ? 'This field is required' : undefined;
22
+ const isNumber = value => value && value.match(/[^0-9]/) ? 'This field must only contain numbers' : undefined;
23
+ const isEqualTo = function (target, message) {
30
24
  if (message === void 0) {
31
- message = "This field must be equal to " + target;
25
+ message = `This field must be equal to ${target}`;
32
26
  }
33
-
34
- return function (value) {
35
- return target === value ? undefined : message;
36
- };
27
+ return value => target === value ? undefined : message;
37
28
  };
38
- var isSameValueAsField = function isSameValueAsField(targetField, message) {
29
+ const isSameValueAsField = function (targetField, message) {
39
30
  if (message === void 0) {
40
31
  message = 'Fields must be the same';
41
32
  }
42
-
43
- return function (value, values) {
44
- return value === values[targetField] ? undefined : message;
45
- };
33
+ return (value, values) => value === values[targetField] ? undefined : message;
46
34
  };
47
- var isLengthEqualTo = function isLengthEqualTo(length, message) {
35
+ const isLengthEqualTo = function (length, message) {
48
36
  if (message === void 0) {
49
- message = "Field must contain " + length + " characters";
37
+ message = `Field must contain ${length} characters`;
50
38
  }
51
-
52
- return function (value) {
53
- return !value || value.length === length ? undefined : message;
54
- };
55
- };
56
- var isLengthGreaterThanOrEqualTo = function isLengthGreaterThanOrEqualTo(length) {
57
- return function (value) {
58
- return !value || value.split(' ').join('').length >= length ? undefined : "Must be greater than or equal to " + length + " characters";
59
- };
60
- };
61
- var isLengthLessThanOrEqualTo = function isLengthLessThanOrEqualTo(length) {
62
- return function (value) {
63
- return !value || value.split(' ').join('').length <= length ? undefined : "Must be less than or equal to " + length + " characters";
64
- };
65
- };
66
- var isLengthWithSpacesLessThanOrEqualTo = function isLengthWithSpacesLessThanOrEqualTo(length) {
67
- return function (value) {
68
- return !value || value.length <= length ? undefined : "Must be less than or equal to " + length + " characters";
69
- };
70
- };
71
- var isLengthWithSpacesGreaterThanOrEqualTo = function isLengthWithSpacesGreaterThanOrEqualTo(length) {
72
- return function (value) {
73
- return !value || value.length >= length ? undefined : "Must be greater than or equal to " + length + " characters";
74
- };
75
- };
76
- var isGreaterThanOrEqualTo = function isGreaterThanOrEqualTo(length) {
77
- return function (value) {
78
- return !value || parseFloat(value) >= length ? undefined : "Must be greater than or equal to " + length;
79
- };
80
- };
81
- var isGreaterThan = function isGreaterThan(length) {
82
- return function (value) {
83
- return !value || parseFloat(value) > length ? undefined : "Must be greater than " + length;
84
- };
85
- };
86
- var isLessThanOrEqualTo = function isLessThanOrEqualTo(length) {
87
- return function (value) {
88
- return !value || parseFloat(value) <= length ? undefined : "Must be less than or equal to " + length;
89
- };
90
- };
91
- var hasUppercaseLetter = function hasUppercaseLetter(value) {
92
- return /[A-Z]/.test(value) ? undefined : 'Field must contain an uppercase letter';
93
- };
94
- var hasNumber = function hasNumber(value) {
95
- return /[0-9]/.test(value) ? undefined : 'Field must contain a number';
96
- }; // Adheres to the 'BECS EBCDIC' character set.
97
-
98
- var isValidBankAccountName = function isValidBankAccountName(value) {
99
- return /^[A-Za-z0-9^_[\]',?;:=#\/.*()&%!$ @+-]+$/.test(value) ? undefined : 'Bank account name must not contain any special characters';
100
- };
101
- var hasSpecialChar = function hasSpecialChar(value) {
102
- return /[!@?#\$%\^\&*\)\(+=._-]/.test(value) ? undefined : 'Field must contain a special character (e.g. !@#)';
103
- }; // eslint-disable-line no-useless-escape
104
-
105
- var isValidEmailAsync = /*#__PURE__*/function () {
106
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
107
- return _regeneratorRuntime.wrap(function _callee$(_context) {
108
- while (1) {
109
- switch (_context.prev = _context.next) {
110
- case 0:
111
- _context.t0 = !value;
112
-
113
- if (_context.t0) {
114
- _context.next = 5;
115
- break;
116
- }
117
-
118
- _context.next = 4;
119
- return validate.isEmail(value);
120
-
121
- case 4:
122
- _context.t0 = _context.sent;
123
-
124
- case 5:
125
- if (!_context.t0) {
126
- _context.next = 9;
127
- break;
128
- }
129
-
130
- _context.t1 = undefined;
131
- _context.next = 10;
132
- break;
133
-
134
- case 9:
135
- _context.t1 = 'Please enter a valid email';
136
-
137
- case 10:
138
- return _context.abrupt("return", _context.t1);
139
-
140
- case 11:
141
- case "end":
142
- return _context.stop();
143
- }
144
- }
145
- }, _callee);
146
- }));
147
-
148
- return function isValidEmailAsync(_x) {
149
- return _ref.apply(this, arguments);
150
- };
151
- }();
152
- var isValidEmail = function isValidEmail(value) {
153
- return !value || /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+$/i.test(value) ? undefined : 'Please enter a valid email';
154
- };
155
- var isValidMobile = function isValidMobile(value) {
156
- return !value || validate.isMobileNumber(value, 'AU') ? undefined : 'Please enter a valid mobile number';
157
- };
158
- var isValidDatePatterns = function isValidDatePatterns(_ref2) {
159
- var day = _ref2.day,
160
- month = _ref2.month,
161
- year = _ref2.year;
162
- return function (value) {
39
+ return value => !value || value.length === length ? undefined : message;
40
+ };
41
+ const isLengthGreaterThanOrEqualTo = length => value => !value || value.split(' ').join('').length >= length ? undefined : `Must be greater than or equal to ${length} characters`;
42
+ const isLengthLessThanOrEqualTo = length => value => !value || value.split(' ').join('').length <= length ? undefined : `Must be less than or equal to ${length} characters`;
43
+ const isLengthWithSpacesLessThanOrEqualTo = length => value => !value || value.length <= length ? undefined : `Must be less than or equal to ${length} characters`;
44
+ const isLengthWithSpacesGreaterThanOrEqualTo = length => value => !value || value.length >= length ? undefined : `Must be greater than or equal to ${length} characters`;
45
+ const isGreaterThanOrEqualTo = length => value => !value || parseFloat(value) >= length ? undefined : `Must be greater than or equal to ${length}`;
46
+ const isGreaterThan = length => value => !value || parseFloat(value) > length ? undefined : `Must be greater than ${length}`;
47
+ const isLessThanOrEqualTo = length => value => !value || parseFloat(value) <= length ? undefined : `Must be less than or equal to ${length}`;
48
+ const hasUppercaseLetter = value => /[A-Z]/.test(value) ? undefined : 'Field must contain an uppercase letter';
49
+ const hasNumber = value => /[0-9]/.test(value) ? undefined : 'Field must contain a number';
50
+ // Adheres to the 'BECS EBCDIC' character set.
51
+ const isValidBankAccountName = value => /^[A-Za-z0-9^_[\]',?;:=#\/.*()&%!$ @+-]+$/.test(value) ? undefined : 'Bank account name must not contain any special characters';
52
+ const hasSpecialChar = value => /[!@?#\$%\^\&*\)\(+=._-]/.test(value) ? undefined : 'Field must contain a special character (e.g. !@#)';
53
+ // eslint-disable-line no-useless-escape
54
+ const isValidEmailAsync = async value => !value || (await validate.isEmail(value)) ? undefined : 'Please enter a valid email';
55
+ const isValidEmail = value => !value || /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+$/i.test(value) ? undefined : 'Please enter a valid email';
56
+ const isValidMobile = value => !value || validate.isMobileNumber(value, 'AU') ? undefined : 'Please enter a valid mobile number';
57
+ const isValidDatePatterns = _ref => {
58
+ let {
59
+ day,
60
+ month,
61
+ year
62
+ } = _ref;
63
+ return value => {
163
64
  if (!value) {
164
65
  return undefined;
165
66
  }
166
-
167
67
  if (day) {
168
- var valueArray = value.split('/');
169
-
170
- var dayValue = _get(valueArray, "[" + day.index + "]", '').split(' ').join('');
171
-
68
+ const valueArray = value.split('/');
69
+ const dayValue = _get(valueArray, `[${day.index}]`, '').split(' ').join('');
172
70
  if (!new RegExp(day.regex).test(dayValue)) {
173
71
  return day.message;
174
72
  }
175
73
  }
176
-
177
74
  if (month) {
178
- var _valueArray = value.split('/');
179
-
180
- var monthValue = _get(_valueArray, "[" + month.index + "]", '').split(' ').join('');
181
-
75
+ const valueArray = value.split('/');
76
+ const monthValue = _get(valueArray, `[${month.index}]`, '').split(' ').join('');
182
77
  if (!new RegExp(month.regex).test(monthValue)) {
183
78
  return month.message;
184
79
  }
185
80
  }
186
-
187
81
  if (year) {
188
- var _valueArray2 = value.split('/');
189
-
190
- var yearValue = _get(_valueArray2, "[" + year.index + "]", '').split(' ').join('');
191
-
82
+ const valueArray = value.split('/');
83
+ const yearValue = _get(valueArray, `[${year.index}]`, '').split(' ').join('');
192
84
  if (!new RegExp(year.regex).test(yearValue)) {
193
85
  return year.message;
194
86
  }
195
87
  }
196
-
197
88
  return undefined;
198
89
  };
199
90
  };
200
- var isValidDate = function isValidDate(value) {
201
- return value && !isValid(parse(value, 'dd/MM/yyyy', new Date())) ? 'Date is invalid' : undefined;
202
- };
203
- var isValidUrlAsync = /*#__PURE__*/function () {
204
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(value) {
205
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
206
- while (1) {
207
- switch (_context2.prev = _context2.next) {
208
- case 0:
209
- _context2.t0 = !value;
210
-
211
- if (_context2.t0) {
212
- _context2.next = 5;
213
- break;
214
- }
215
-
216
- _context2.next = 4;
217
- return validate.isUrl(value);
218
-
219
- case 4:
220
- _context2.t0 = _context2.sent;
221
-
222
- case 5:
223
- if (!_context2.t0) {
224
- _context2.next = 9;
225
- break;
226
- }
227
-
228
- _context2.t1 = undefined;
229
- _context2.next = 10;
230
- break;
231
-
232
- case 9:
233
- _context2.t1 = 'Please enter a valid URL (starting with http:// or https://).';
234
-
235
- case 10:
236
- return _context2.abrupt("return", _context2.t1);
237
-
238
- case 11:
239
- case "end":
240
- return _context2.stop();
241
- }
242
- }
243
- }, _callee2);
244
- }));
245
-
246
- return function isValidUrlAsync(_x2) {
247
- return _ref3.apply(this, arguments);
248
- };
249
- }();
250
- var isYearInRange = function isYearInRange(_ref4) {
251
- var index = _ref4.index,
252
- isShortYearFormat = _ref4.isShortYearFormat,
253
- lessThanCurrentYear = _ref4.lessThanCurrentYear;
91
+ const isValidDate = value => value && !isValid(parse(value, 'dd/MM/yyyy', new Date())) ? 'Date is invalid' : undefined;
92
+ const isValidUrlAsync = async value => !value || (await validate.isUrl(value)) ? undefined : 'Please enter a valid URL (starting with http:// or https://).';
93
+ const isYearInRange = _ref2 => {
94
+ let {
95
+ index,
96
+ isShortYearFormat,
97
+ lessThanCurrentYear
98
+ } = _ref2;
254
99
  return function (value) {
255
100
  if (value === void 0) {
256
101
  value = '';
257
102
  }
258
-
259
- var year = value.split('/')[index];
260
- var currentYear = format(new Date(), isShortYearFormat ? 'yy' : 'yyyy');
261
-
103
+ const year = value.split('/')[index];
104
+ const currentYear = format(new Date(), isShortYearFormat ? 'yy' : 'yyyy');
262
105
  if (!lessThanCurrentYear && (parseInt(year, 10) < parseInt(currentYear, 10) || parseInt(year, 10) > parseInt(currentYear, 10) + 15)) {
263
106
  if (parseInt(year, 10) < parseInt(currentYear, 10)) {
264
- return "Year must be a year equal or greater than " + parseInt(currentYear, 10);
107
+ return `Year must be a year equal or greater than ${parseInt(currentYear, 10)}`;
265
108
  }
266
-
267
109
  if (parseInt(year, 10) > parseInt(currentYear, 10) + 15) {
268
- return "Year must be a year less than " + (parseInt(currentYear, 10) + 15);
110
+ return `Year must be a year less than ${parseInt(currentYear, 10) + 15}`;
269
111
  }
270
-
271
112
  return 'Please enter a valid year';
272
113
  }
273
-
274
114
  if (lessThanCurrentYear && parseInt(year, 10) > parseInt(currentYear, 10)) {
275
- return "Year must be a year equal or less than " + parseInt(currentYear, 10);
115
+ return `Year must be a year equal or less than ${parseInt(currentYear, 10)}`;
276
116
  }
277
-
278
117
  return undefined;
279
118
  };
280
119
  };
281
- var isValidDOB = function isValidDOB(value) {
282
- var invalidDate = isValidDate(value);
120
+ const isValidDOB = value => {
121
+ const invalidDate = isValidDate(value);
283
122
  if (invalidDate) return invalidDate;
284
- var year = value.split('/')[2];
285
- var currentYear = format(new Date(), 'yyyy');
286
-
123
+ const year = value.split('/')[2];
124
+ const currentYear = format(new Date(), 'yyyy');
287
125
  if (parseInt(year, 10) > parseInt(currentYear, 10)) {
288
126
  return 'Year must be before current year.';
289
127
  }
290
-
291
128
  if (parseInt(year, 10) < 1900) {
292
129
  return 'Year must be greater than 1900';
293
130
  }
294
-
295
131
  return undefined;
296
132
  };
297
- var matchesRegex = function matchesRegex(pattern, message) {
298
- return function (value) {
299
- return !value || new RegExp(pattern).test(value) ? undefined : message;
300
- };
301
- };
302
- var isFutureDate = function isFutureDate(value) {
303
- var date = value && new Date(value.split('/')[2], value.split('/')[1] - 1, value.split('/')[0]);
133
+ const matchesRegex = (pattern, message) => value => !value || new RegExp(pattern).test(value) ? undefined : message;
134
+ const isFutureDate = value => {
135
+ const date = value && new Date(value.split('/')[2], value.split('/')[1] - 1, value.split('/')[0]);
304
136
  return isFuture(date) ? 'Date must not be in the future.' : undefined;
305
137
  };
306
- var isMoreThanThreeYears = function isMoreThanThreeYears(value) {
307
- var dateToValidate = new Date(value.split('/')[2], value.split('/')[1] - 1, value.split('/')[0]);
308
- var dateThreeYearsAgo = new Date(new Date().getFullYear() - 3, new Date().getMonth(), new Date().getDate() - 1);
138
+ const isMoreThanThreeYears = value => {
139
+ const dateToValidate = new Date(value.split('/')[2], value.split('/')[1] - 1, value.split('/')[0]);
140
+ const dateThreeYearsAgo = new Date(new Date().getFullYear() - 3, new Date().getMonth(), new Date().getDate() - 1);
309
141
  return isBefore(dateToValidate, dateThreeYearsAgo) ? 'Date must not be more than 3 years ago.' : undefined;
310
142
  };
311
- var hasInvalidCharacters = function hasInvalidCharacters(value) {
312
- return value && /[()]/.test(value) ? 'This field cannot contain ( or )' : undefined;
313
- };
314
- var hasStrictInvalidCharacters = function hasStrictInvalidCharacters(value) {
315
- return value && /[^A-Za-z0-9-' ]/.test(value) ? 'This field cannot contain any special characters except for space, hyphen and apostrophe under certain conditions' : undefined;
316
- };
317
- var hasDoubleSpaces = function hasDoubleSpaces(value) {
143
+ const hasInvalidCharacters = value => value && /[()]/.test(value) ? 'This field cannot contain ( or )' : undefined;
144
+ const hasStrictInvalidCharacters = value => value && /[^A-Za-z0-9-' ]/.test(value) ? 'This field cannot contain any special characters except for space, hyphen and apostrophe under certain conditions' : undefined;
145
+ const hasDoubleSpaces = value => {
318
146
  return value && /\s\s+/g.test(value) ? 'There can be no double spaces in the supplied value' : undefined;
319
147
  };
320
- var hasWhitespaceAtStartOrEnd = function hasWhitespaceAtStartOrEnd(value) {
148
+ const hasWhitespaceAtStartOrEnd = value => {
321
149
  return value && /(^\s+)|(\s+$)/.test(value) ? 'There can be no spaces at the start or end of the supplied value' : undefined;
322
150
  };
323
- var hasSpaceAfterHyphen = function hasSpaceAfterHyphen(value) {
324
- return value && /([-]\s)/.test(value) ? 'Name cannot have a space after a hyphen (-)' : undefined;
325
- };
326
- var hasSpaceBeforeHyphen = function hasSpaceBeforeHyphen(value) {
327
- return value && /(\s[-])/.test(value) ? 'Name cannot have a space before a hyphen (-)' : undefined;
328
- };
329
- var hasSpaceAfterApostrophe = function hasSpaceAfterApostrophe(value) {
330
- return value && /([']\s)/.test(value) ? "Name cannot have a space after an apostrophe (')" : undefined;
331
- };
332
- var hasSpaceBeforeApostrophe = function hasSpaceBeforeApostrophe(value) {
333
- return value && /(\s['])/.test(value) ? "Name cannot have a space before an apostrophe (')" : undefined;
334
- };
335
- var isValidAbn = function isValidAbn(value) {
336
- var isValid = abn.isValidAbn(value);
337
-
151
+ const hasSpaceAfterHyphen = value => value && /([-]\s)/.test(value) ? 'Name cannot have a space after a hyphen (-)' : undefined;
152
+ const hasSpaceBeforeHyphen = value => value && /(\s[-])/.test(value) ? 'Name cannot have a space before a hyphen (-)' : undefined;
153
+ const hasSpaceAfterApostrophe = value => value && /([']\s)/.test(value) ? "Name cannot have a space after an apostrophe (')" : undefined;
154
+ const hasSpaceBeforeApostrophe = value => value && /(\s['])/.test(value) ? "Name cannot have a space before an apostrophe (')" : undefined;
155
+ const isValidAbn = value => {
156
+ const isValid = abn.isValidAbn(value);
338
157
  if (isValid) return undefined;
339
158
  return 'Invalid ABN';
340
159
  };
341
- var isValidAcn = function isValidAcn(value) {
342
- var isValid = abn.isValidAcn(value);
343
-
160
+ const isValidAcn = value => {
161
+ const isValid = abn.isValidAcn(value);
344
162
  if (isValid) return undefined;
345
163
  return 'Invalid ACN';
346
164
  };
347
- var isValidAbnOrAcn = function isValidAbnOrAcn(value) {
165
+ const isValidAbnOrAcn = value => {
348
166
  if (abn.isValidAbn(value)) {
349
167
  return undefined;
350
168
  }
351
-
352
169
  if (abn.isValidAcn(value)) {
353
170
  return undefined;
354
171
  }
355
-
356
172
  return 'Invalid ABN or ACN';
357
173
  };
358
-
359
- var combineValidators = function combineValidators() {
174
+ const combineValidators = function () {
360
175
  for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
361
176
  fns[_key] = arguments[_key];
362
177
  }
363
-
364
- return function (value) {
365
- var validator = fns.find(function (fn) {
366
- return fn(value);
367
- });
368
-
178
+ return value => {
179
+ const validator = fns.find(fn => fn(value));
369
180
  if (validator) {
370
181
  return validator(value);
371
182
  }
372
-
373
183
  return undefined;
374
184
  };
375
185
  };
package/validate.js CHANGED
@@ -9,46 +9,34 @@ require('core-js/es6/promise');
9
9
  require('core-js/es6/set');
10
10
  var googleLibPhoneNumber = _interopDefault(require('google-libphonenumber'));
11
11
 
12
- var isNotEmpty = function isNotEmpty(value) {
13
- return yup.mixed().required().isValid(value);
14
- };
15
- var isEmail = function isEmail(email) {
16
- return yup.string().email().isValid(email);
17
- };
18
- var isNumber = function isNumber(number) {
19
- return yup.number().isValid(number);
20
- };
21
- var isStringLength = function isStringLength(length, value) {
22
- return yup.string().min(length).max(length).isValid(value);
23
- };
24
- var isUrl = function isUrl(value) {
25
- return yup.string().url().isValid(value);
26
- };
27
- var phoneUtil = googleLibPhoneNumber.PhoneNumberUtil.getInstance();
28
- var phoneType = googleLibPhoneNumber.PhoneNumberType;
29
- var isMobileNumber = function isMobileNumber(phoneNumber, countryCode) {
12
+ const isNotEmpty = value => yup.mixed().required().isValid(value);
13
+ const isEmail = email => yup.string().email().isValid(email);
14
+ const isNumber = number => yup.number().isValid(number);
15
+ const isStringLength = (length, value) => yup.string().min(length).max(length).isValid(value);
16
+ const isUrl = value => yup.string().url().isValid(value);
17
+ const phoneUtil = googleLibPhoneNumber.PhoneNumberUtil.getInstance();
18
+ const phoneType = googleLibPhoneNumber.PhoneNumberType;
19
+ const isMobileNumber = (phoneNumber, countryCode) => {
30
20
  if (!countryCode) {
31
21
  throw new Error('`countryCode` not given.');
32
22
  }
33
-
34
23
  if (!phoneNumber) {
35
24
  return false;
36
25
  }
37
-
38
26
  try {
39
- var parsedPhoneNumber = phoneUtil.parse(phoneNumber, countryCode);
27
+ const parsedPhoneNumber = phoneUtil.parse(phoneNumber, countryCode);
40
28
  return phoneUtil.getNumberType(parsedPhoneNumber) === phoneType.MOBILE;
41
29
  } catch (err) {
42
30
  return false;
43
31
  }
44
32
  };
45
- var validate = {
46
- isEmail: isEmail,
47
- isNotEmpty: isNotEmpty,
48
- isNumber: isNumber,
49
- isStringLength: isStringLength,
50
- isUrl: isUrl,
51
- isMobileNumber: isMobileNumber
33
+ const validate = {
34
+ isEmail,
35
+ isNotEmpty,
36
+ isNumber,
37
+ isStringLength,
38
+ isUrl,
39
+ isMobileNumber
52
40
  };
53
41
 
54
42
  exports.default = validate;
package/webpack-config.js CHANGED
@@ -7,20 +7,13 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
7
7
  var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
8
8
 
9
9
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
-
11
10
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
-
13
- var path = require('path');
14
-
15
- var buildAliases = function buildAliases(modules, dirname) {
16
- return modules.reduce(function (alias, m) {
17
- var _objectSpread2;
18
-
19
- return _objectSpread({}, alias, (_objectSpread2 = {}, _objectSpread2[m] = path.resolve(dirname, "node_modules/" + m), _objectSpread2));
20
- }, {});
21
- };
22
- var resolveConfig = {
23
- extensions: [process.env.REACT_APP_REGION ? "." + process.env.REACT_APP_REGION.toLowerCase() + ".js" : undefined, '.js', '.jsx', '.json'].filter(Boolean)
11
+ const path = require('path');
12
+ const buildAliases = (modules, dirname) => modules.reduce((alias, m) => _objectSpread({}, alias, {
13
+ [m]: path.resolve(dirname, `node_modules/${m}`)
14
+ }), {});
15
+ const resolveConfig = {
16
+ extensions: [process.env.REACT_APP_REGION ? `.${process.env.REACT_APP_REGION.toLowerCase()}.js` : undefined, '.js', '.jsx', '.json'].filter(Boolean)
24
17
  };
25
18
 
26
19
  exports.buildAliases = buildAliases;
@@ -4,9 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var constants = require('./constants.js');
6
6
 
7
- var _default$WORKFLOW_STA;
8
- var workflowStateFormattedTextClasses = (_default$WORKFLOW_STA = {
9
- _default: 'primary'
10
- }, _default$WORKFLOW_STA[constants.WORKFLOW_STATES.ARCHIVED] = 'danger', _default$WORKFLOW_STA[constants.WORKFLOW_STATES.ASSIGNED] = 'warning', _default$WORKFLOW_STA[constants.WORKFLOW_STATES.CANCELLED] = 'danger', _default$WORKFLOW_STA[constants.WORKFLOW_STATES.COMPLETED] = 'success', _default$WORKFLOW_STA[constants.WORKFLOW_STATES.ERRORED] = 'danger', _default$WORKFLOW_STA[constants.WORKFLOW_STATES.INBOX] = 'warning', _default$WORKFLOW_STA[constants.WORKFLOW_STATES.PARKED] = 'warning', _default$WORKFLOW_STA[constants.WORKFLOW_STATES.POSTED] = 'warning', _default$WORKFLOW_STA[constants.WORKFLOW_STATES.SUBMITTED] = 'warning', _default$WORKFLOW_STA);
7
+ var workflowStateFormattedTextClasses = {
8
+ _default: 'primary',
9
+ [constants.WORKFLOW_STATES.ARCHIVED]: 'danger',
10
+ [constants.WORKFLOW_STATES.ASSIGNED]: 'warning',
11
+ [constants.WORKFLOW_STATES.CANCELLED]: 'danger',
12
+ [constants.WORKFLOW_STATES.COMPLETED]: 'success',
13
+ [constants.WORKFLOW_STATES.ERRORED]: 'danger',
14
+ [constants.WORKFLOW_STATES.INBOX]: 'warning',
15
+ [constants.WORKFLOW_STATES.PARKED]: 'warning',
16
+ [constants.WORKFLOW_STATES.POSTED]: 'warning',
17
+ [constants.WORKFLOW_STATES.SUBMITTED]: 'warning'
18
+ };
11
19
 
12
20
  exports.default = workflowStateFormattedTextClasses;
@@ -7,7 +7,16 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
7
7
  var constants = require('./constants.js');
8
8
  var _capitalize = _interopDefault(require('lodash/capitalize'));
9
9
 
10
- var _workflowStateFormatt;
11
- var workflowStateFormatted = (_workflowStateFormatt = {}, _workflowStateFormatt[constants.WORKFLOW_STATES.INBOX] = constants.GARRISON_WORKFLOW_STATES_HUMANIZED.SUBMITTED, _workflowStateFormatt[constants.WORKFLOW_STATES.ASSIGNED] = constants.GARRISON_WORKFLOW_STATES_HUMANIZED.UNDER_REVIEW, _workflowStateFormatt[constants.WORKFLOW_STATES.PARKED] = constants.GARRISON_WORKFLOW_STATES_HUMANIZED.UNDER_REVIEW, _workflowStateFormatt[constants.WORKFLOW_STATES.SUBMITTED] = constants.GARRISON_WORKFLOW_STATES_HUMANIZED.UNDER_REVIEW, _workflowStateFormatt[constants.WORKFLOW_STATES.POSTED] = constants.GARRISON_WORKFLOW_STATES_HUMANIZED.UNDER_REVIEW, _workflowStateFormatt[constants.WORKFLOW_STATES.COMPLETED] = constants.GARRISON_WORKFLOW_STATES_HUMANIZED.COMPLETED, _workflowStateFormatt[constants.WORKFLOW_STATES.ERRORED] = _capitalize(constants.WORKFLOW_STATES.ERRORED), _workflowStateFormatt[constants.WORKFLOW_STATES.ARCHIVED] = _capitalize(constants.WORKFLOW_STATES.ARCHIVED), _workflowStateFormatt[constants.WORKFLOW_STATES.CANCELLED] = _capitalize(constants.WORKFLOW_STATES.CANCELLED), _workflowStateFormatt);
10
+ const workflowStateFormatted = {
11
+ [constants.WORKFLOW_STATES.INBOX]: constants.GARRISON_WORKFLOW_STATES_HUMANIZED.SUBMITTED,
12
+ [constants.WORKFLOW_STATES.ASSIGNED]: constants.GARRISON_WORKFLOW_STATES_HUMANIZED.UNDER_REVIEW,
13
+ [constants.WORKFLOW_STATES.PARKED]: constants.GARRISON_WORKFLOW_STATES_HUMANIZED.UNDER_REVIEW,
14
+ [constants.WORKFLOW_STATES.SUBMITTED]: constants.GARRISON_WORKFLOW_STATES_HUMANIZED.UNDER_REVIEW,
15
+ [constants.WORKFLOW_STATES.POSTED]: constants.GARRISON_WORKFLOW_STATES_HUMANIZED.UNDER_REVIEW,
16
+ [constants.WORKFLOW_STATES.COMPLETED]: constants.GARRISON_WORKFLOW_STATES_HUMANIZED.COMPLETED,
17
+ [constants.WORKFLOW_STATES.ERRORED]: _capitalize(constants.WORKFLOW_STATES.ERRORED),
18
+ [constants.WORKFLOW_STATES.ARCHIVED]: _capitalize(constants.WORKFLOW_STATES.ARCHIVED),
19
+ [constants.WORKFLOW_STATES.CANCELLED]: _capitalize(constants.WORKFLOW_STATES.CANCELLED)
20
+ };
12
21
 
13
22
  exports.default = workflowStateFormatted;