@medipass/utils 11.80.6-chore-update-react-places-autocomplete.0 → 11.80.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abn.d.ts +0 -1
- package/abn.js +0 -40
- package/google-addresses.d.ts +8 -13
- package/google-addresses.js +25 -13
- package/i18n/translations.js +1 -1
- package/package.json +3 -4
- package/validate-form.d.ts +1 -3
- package/validate-form.js +1 -20
package/abn.d.ts
CHANGED
package/abn.js
CHANGED
|
@@ -3,17 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var ABN_LENGTH = 11;
|
|
6
|
-
var ACN_LENGTH = 9;
|
|
7
6
|
var normaliseAbn = function normaliseAbn(abn) {
|
|
8
7
|
var trimmedABN = abn == null ? void 0 : abn.replace(/\s/g, ''); // The input is an ABN, in which case the format should be 99 999 999 999
|
|
9
8
|
|
|
10
9
|
if (trimmedABN.length === ABN_LENGTH) {
|
|
11
10
|
return trimmedABN.substring(0, 2) + ' ' + trimmedABN.substring(2, 5) + ' ' + trimmedABN.substring(5, 8) + ' ' + trimmedABN.substring(8);
|
|
12
|
-
} //The input is an ACN, in which case the format should be 999 999 999
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (trimmedABN.length === ACN_LENGTH) {
|
|
16
|
-
return trimmedABN.substring(0, 3) + ' ' + trimmedABN.substring(3, 6) + ' ' + trimmedABN.substring(6);
|
|
17
11
|
}
|
|
18
12
|
|
|
19
13
|
return abn;
|
|
@@ -53,40 +47,6 @@ var isValidAbn = function isValidAbn(abn) {
|
|
|
53
47
|
return false;
|
|
54
48
|
}
|
|
55
49
|
};
|
|
56
|
-
var isValidAcn = function isValidAcn(acn) {
|
|
57
|
-
var VALID_ACN_LENGTH = 9; // strip whitespace from value
|
|
58
|
-
|
|
59
|
-
acn = String(acn).replace(/\s+/g, '');
|
|
60
|
-
|
|
61
|
-
if (acn.length === VALID_ACN_LENGTH) {
|
|
62
|
-
var weights = [8, 7, 6, 5, 4, 3, 2, 1];
|
|
63
|
-
var acnArray = [];
|
|
64
|
-
|
|
65
|
-
for (var i = 0; i < acn.length; i++) {
|
|
66
|
-
acnArray[i] = parseInt(acn.charAt(i));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
var acnSum = 0; // sum the digits 1-8
|
|
70
|
-
|
|
71
|
-
for (var _i3 = 0; _i3 < weights.length; _i3++) {
|
|
72
|
-
acnSum = acnSum + acnArray[_i3] * weights[_i3];
|
|
73
|
-
} // divide by 10 and take remainder
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var remainder = acnSum % 10; // complement the remainder to 10
|
|
77
|
-
|
|
78
|
-
var complement = 10 - remainder; // if the complement equals 10, set it to 0
|
|
79
|
-
|
|
80
|
-
if (complement === 10) {
|
|
81
|
-
complement = 0;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return acnArray[8] === complement;
|
|
85
|
-
} else {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
50
|
|
|
90
51
|
exports.isValidAbn = isValidAbn;
|
|
91
|
-
exports.isValidAcn = isValidAcn;
|
|
92
52
|
exports.normaliseAbn = normaliseAbn;
|
package/google-addresses.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export declare function geocodeAddress(address: any): Promise<{
|
|
2
|
+
results: any[];
|
|
3
|
+
latLng: {
|
|
4
|
+
lng: number;
|
|
5
|
+
lat: number;
|
|
6
|
+
};
|
|
5
7
|
}>;
|
|
6
|
-
export declare const mapAddressComponents: (addressComponents:
|
|
7
|
-
export declare const parseAddress: (addressComponents:
|
|
8
|
-
address?: string | undefined;
|
|
9
|
-
countryCode?: string | undefined;
|
|
10
|
-
country?: string | undefined;
|
|
11
|
-
state?: string | undefined;
|
|
12
|
-
city?: string | undefined;
|
|
13
|
-
postcode?: string | undefined;
|
|
14
|
-
};
|
|
8
|
+
export declare const mapAddressComponents: (addressComponents: any) => {};
|
|
9
|
+
export declare const parseAddress: (addressComponents: any) => {};
|
package/google-addresses.js
CHANGED
|
@@ -18,7 +18,8 @@ var ADDRESS_COMPONENT_MAPPINGS = {
|
|
|
18
18
|
state: 'administrative_area_level_1',
|
|
19
19
|
city: 'locality',
|
|
20
20
|
postcode: 'postal_code'
|
|
21
|
-
};
|
|
21
|
+
}; // @ts-expect-error TS(7006): Parameter 'address' implicitly has an 'any' type.
|
|
22
|
+
|
|
22
23
|
function geocodeAddress(address) {
|
|
23
24
|
return new Promise( /*#__PURE__*/function () {
|
|
24
25
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(res, rej) {
|
|
@@ -82,15 +83,15 @@ function geocodeAddress(address) {
|
|
|
82
83
|
return _ref.apply(this, arguments);
|
|
83
84
|
};
|
|
84
85
|
}());
|
|
85
|
-
}
|
|
86
|
+
} // @ts-expect-error TS(7006): Parameter 'addressComponents' implicitly has an 'a... Remove this comment to see the full error message
|
|
87
|
+
|
|
86
88
|
var mapAddressComponents = function mapAddressComponents(addressComponents) {
|
|
87
89
|
var components = {};
|
|
88
90
|
|
|
89
91
|
_forEach(addressComponents, function (component) {
|
|
90
92
|
_forOwn(ADDRESS_COMPONENT_MAPPINGS, function (mapping, key) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if ((component == null ? void 0 : (_component$types = component.types) == null ? void 0 : _component$types[0]) === mapping) {
|
|
93
|
+
if (component.types[0] === mapping) {
|
|
94
|
+
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
94
95
|
components[key] = {
|
|
95
96
|
longName: component.long_name,
|
|
96
97
|
shortName: component.short_name
|
|
@@ -100,24 +101,35 @@ var mapAddressComponents = function mapAddressComponents(addressComponents) {
|
|
|
100
101
|
});
|
|
101
102
|
|
|
102
103
|
return components;
|
|
103
|
-
};
|
|
104
|
+
}; // @ts-expect-error TS(7006): Parameter 'addressComponents' implicitly has an 'a... Remove this comment to see the full error message
|
|
105
|
+
|
|
104
106
|
var parseAddress = function parseAddress(addressComponents) {
|
|
105
107
|
var requestData = {};
|
|
106
108
|
|
|
107
109
|
if (addressComponents) {
|
|
108
|
-
var address = mapAddressComponents(addressComponents);
|
|
110
|
+
var address = mapAddressComponents(addressComponents); // @ts-expect-error TS(2339): Property 'route' does not exist on type '{}'.
|
|
109
111
|
|
|
110
112
|
if (address.route) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
// @ts-expect-error TS(2339): Property 'address' does not exist on type '{}'.
|
|
114
|
+
requestData.address = // @ts-expect-error
|
|
115
|
+
"" + (address.subpremise ? address.subpremise.longName + "/" : '') + ( // @ts-expect-error
|
|
116
|
+
(address.streetNumber ? address.streetNumber.longName : '') + " ") + ( // @ts-expect-error
|
|
117
|
+
"" + address.route.longName);
|
|
118
|
+
} // @ts-expect-error TS(2339): Property 'country' does not exist on type '{}'.
|
|
119
|
+
|
|
113
120
|
|
|
114
121
|
if (address.country) {
|
|
115
|
-
|
|
122
|
+
// @ts-expect-error TS(2339): Property 'countryCode' does not exist on type '{}'... Remove this comment to see the full error message
|
|
123
|
+
requestData.countryCode = address.country.shortName; // @ts-expect-error TS(2339): Property 'country' does not exist on type '{}'.
|
|
124
|
+
|
|
116
125
|
requestData.country = address.country.longName;
|
|
117
|
-
}
|
|
126
|
+
} // @ts-expect-error TS(2339): Property 'state' does not exist on type '{}'.
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
requestData.state = address.state ? address.state.longName : null; // @ts-expect-error TS(2339): Property 'city' does not exist on type '{}'.
|
|
130
|
+
|
|
131
|
+
requestData.city = address.city ? address.city.longName : null; // @ts-expect-error TS(2339): Property 'postcode' does not exist on type '{}'.
|
|
118
132
|
|
|
119
|
-
requestData.state = address.state ? address.state.longName : null;
|
|
120
|
-
requestData.city = address.city ? address.city.longName : null;
|
|
121
133
|
requestData.postcode = address.postcode ? address.postcode.longName : null;
|
|
122
134
|
}
|
|
123
135
|
|
package/i18n/translations.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medipass/utils",
|
|
3
|
-
"version": "11.80.6
|
|
3
|
+
"version": "11.80.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"masked": "1.1.0",
|
|
39
39
|
"moment": "2.22.2",
|
|
40
40
|
"react-i18next": "11.7.0",
|
|
41
|
-
"react-places-autocomplete": "
|
|
41
|
+
"react-places-autocomplete": "5.4.3",
|
|
42
42
|
"react-redux": "8.0.5",
|
|
43
43
|
"redux": "4.2.1",
|
|
44
44
|
"redux-sentry-middleware": "0.1.3",
|
|
@@ -47,11 +47,10 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@babel/plugin-transform-runtime": "7.8.3",
|
|
49
49
|
"@types/jest": "29.1.2",
|
|
50
|
-
"@types/react-places-autocomplete": "7.2.9",
|
|
51
50
|
"redux-mock-store": "^1.3.0",
|
|
52
51
|
"redux-thunk": "^2.2.0",
|
|
53
52
|
"rimraf": "^2.6.2",
|
|
54
53
|
"typescript": "4.8.4"
|
|
55
54
|
},
|
|
56
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "2b8de9cd4967dbff51540eddf8dd89cf64961df2"
|
|
57
56
|
}
|
package/validate-form.d.ts
CHANGED
|
@@ -59,8 +59,6 @@ export declare const hasSpaceAfterHyphen: (value: any) => "Name cannot have a sp
|
|
|
59
59
|
export declare const hasSpaceBeforeHyphen: (value: any) => "Name cannot have a space before a hyphen (-)" | undefined;
|
|
60
60
|
export declare const hasSpaceAfterApostrophe: (value: any) => "Name cannot have a space after an apostrophe (')" | undefined;
|
|
61
61
|
export declare const hasSpaceBeforeApostrophe: (value: any) => "Name cannot have a space before an apostrophe (')" | undefined;
|
|
62
|
-
export declare const isValidAbn: (value: string) => "
|
|
63
|
-
export declare const isValidAcn: (value: string) => "Invalid ACN" | undefined;
|
|
64
|
-
export declare const isValidAbnOrAcn: (value: string) => "Invalid ABN or ACN" | undefined;
|
|
62
|
+
export declare const isValidAbn: (value: string) => "Please enter a valid 11 digit ABN" | undefined;
|
|
65
63
|
declare const combineValidators: (...fns: any[]) => (value: any) => any;
|
|
66
64
|
export default combineValidators;
|
package/validate-form.js
CHANGED
|
@@ -383,24 +383,7 @@ var isValidAbn = function isValidAbn(value) {
|
|
|
383
383
|
var isValid = abn.isValidAbn(value);
|
|
384
384
|
|
|
385
385
|
if (isValid) return undefined;
|
|
386
|
-
return '
|
|
387
|
-
};
|
|
388
|
-
var isValidAcn = function isValidAcn(value) {
|
|
389
|
-
var isValid = abn.isValidAcn(value);
|
|
390
|
-
|
|
391
|
-
if (isValid) return undefined;
|
|
392
|
-
return 'Invalid ACN';
|
|
393
|
-
};
|
|
394
|
-
var isValidAbnOrAcn = function isValidAbnOrAcn(value) {
|
|
395
|
-
if (abn.isValidAbn(value)) {
|
|
396
|
-
return undefined;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if (abn.isValidAcn(value)) {
|
|
400
|
-
return undefined;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
return 'Invalid ABN or ACN';
|
|
386
|
+
return 'Please enter a valid 11 digit ABN';
|
|
404
387
|
};
|
|
405
388
|
|
|
406
389
|
var combineValidators = // @ts-expect-error TS(7019): Rest parameter 'fns' implicitly has an 'any[]' typ... Remove this comment to see the full error message
|
|
@@ -456,8 +439,6 @@ exports.isNumber = isNumber;
|
|
|
456
439
|
exports.isRequired = isRequired;
|
|
457
440
|
exports.isSameValueAsField = isSameValueAsField;
|
|
458
441
|
exports.isValidAbn = isValidAbn;
|
|
459
|
-
exports.isValidAbnOrAcn = isValidAbnOrAcn;
|
|
460
|
-
exports.isValidAcn = isValidAcn;
|
|
461
442
|
exports.isValidBankAccountName = isValidBankAccountName;
|
|
462
443
|
exports.isValidDOB = isValidDOB;
|
|
463
444
|
exports.isValidDate = isValidDate;
|