@k-int/address-plugins 1.0.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.
- package/README.md +249 -0
- package/es/address-plugin-british-isles/index.js +13 -0
- package/es/address-plugin-british-isles/src/AddressFieldsGBR.js +110 -0
- package/es/address-plugin-british-isles/src/backendToFields.js +45 -0
- package/es/address-plugin-british-isles/src/fieldOrder.js +16 -0
- package/es/address-plugin-british-isles/src/fieldsToBackend.js +101 -0
- package/es/address-plugin-british-isles/src/index.js +21 -0
- package/es/address-plugin-british-isles/src/listOfSupportedCountries.js +8 -0
- package/es/address-plugin-generic/index.js +13 -0
- package/es/address-plugin-generic/src/AddressFieldsGeneric.js +140 -0
- package/es/address-plugin-generic/src/backendToFields.js +53 -0
- package/es/address-plugin-generic/src/fieldOrder.js +19 -0
- package/es/address-plugin-generic/src/fieldsToBackend.js +140 -0
- package/es/address-plugin-generic/src/index.js +21 -0
- package/es/address-plugin-generic/src/listOfSupportedCountries.js +8 -0
- package/es/address-plugin-north-america/index.js +13 -0
- package/es/address-plugin-north-america/src/AddressFieldsUSA.js +106 -0
- package/es/address-plugin-north-america/src/backendToFields.js +41 -0
- package/es/address-plugin-north-america/src/fieldOrder.js +15 -0
- package/es/address-plugin-north-america/src/fieldsToBackend.js +98 -0
- package/es/address-plugin-north-america/src/index.js +21 -0
- package/es/address-plugin-north-america/src/listOfSupportedCountries.js +8 -0
- package/es/address-utils/index.js +16 -0
- package/es/address-utils/src/deleteFieldIfExists.js +17 -0
- package/es/address-utils/src/getExistingLineField.js +14 -0
- package/es/address-utils/src/index.js +27 -0
- package/es/address-utils/src/requiredValidator.js +20 -0
- package/es/index.js +31 -0
- package/package.json +65 -0
- package/src/address-plugin-british-isles/README.md +31 -0
- package/src/address-plugin-british-isles/index.js +1 -0
- package/src/address-plugin-british-isles/src/AddressFieldsGBR.js +88 -0
- package/src/address-plugin-british-isles/src/backendToFields.js +43 -0
- package/src/address-plugin-british-isles/src/fieldOrder.js +11 -0
- package/src/address-plugin-british-isles/src/fieldsToBackend.js +51 -0
- package/src/address-plugin-british-isles/src/index.js +9 -0
- package/src/address-plugin-british-isles/src/listOfSupportedCountries.js +3 -0
- package/src/address-plugin-generic/README.md +6 -0
- package/src/address-plugin-generic/index.js +1 -0
- package/src/address-plugin-generic/src/AddressFieldsGeneric.js +112 -0
- package/src/address-plugin-generic/src/backendToFields.js +51 -0
- package/src/address-plugin-generic/src/fieldOrder.js +14 -0
- package/src/address-plugin-generic/src/fieldsToBackend.js +68 -0
- package/src/address-plugin-generic/src/index.js +9 -0
- package/src/address-plugin-generic/src/listOfSupportedCountries.js +3 -0
- package/src/address-plugin-north-america/README.md +33 -0
- package/src/address-plugin-north-america/index.js +1 -0
- package/src/address-plugin-north-america/src/AddressFieldsUSA.js +85 -0
- package/src/address-plugin-north-america/src/backendToFields.js +40 -0
- package/src/address-plugin-north-america/src/fieldOrder.js +10 -0
- package/src/address-plugin-north-america/src/fieldsToBackend.js +50 -0
- package/src/address-plugin-north-america/src/index.js +8 -0
- package/src/address-plugin-north-america/src/listOfSupportedCountries.js +2 -0
- package/src/address-utils/README.md +40 -0
- package/src/address-utils/index.js +1 -0
- package/src/address-utils/src/deleteFieldIfExists.js +8 -0
- package/src/address-utils/src/getExistingLineField.js +8 -0
- package/src/address-utils/src/index.js +5 -0
- package/src/address-utils/src/requiredValidator.js +12 -0
- package/src/index.js +4 -0
- package/translations/ui-address-plugins/ar.json +38 -0
- package/translations/ui-address-plugins/ca.json +1 -0
- package/translations/ui-address-plugins/cs_CZ.json +38 -0
- package/translations/ui-address-plugins/da.json +38 -0
- package/translations/ui-address-plugins/de.json +38 -0
- package/translations/ui-address-plugins/en.json +44 -0
- package/translations/ui-address-plugins/en_US.json +1 -0
- package/translations/ui-address-plugins/es.json +38 -0
- package/translations/ui-address-plugins/fr.json +38 -0
- package/translations/ui-address-plugins/hi_IN.json +38 -0
- package/translations/ui-address-plugins/hu.json +38 -0
- package/translations/ui-address-plugins/it_IT.json +38 -0
- package/translations/ui-address-plugins/ja.json +38 -0
- package/translations/ui-address-plugins/ko.json +1 -0
- package/translations/ui-address-plugins/nb.json +1 -0
- package/translations/ui-address-plugins/nn.json +1 -0
- package/translations/ui-address-plugins/pl.json +38 -0
- package/translations/ui-address-plugins/pt_PT.json +38 -0
- package/translations/ui-address-plugins/ru.json +38 -0
- package/translations/ui-address-plugins/sv.json +38 -0
- package/translations/ui-address-plugins/ur.json +1 -0
- package/translations/ui-address-plugins/zh_CN.json +38 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _reactIntl = require("react-intl");
|
|
9
|
+
var _reactFlexboxGrid = require("react-flexbox-grid");
|
|
10
|
+
var _addressUtils = require("../../address-utils");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const AddressFieldsGeneric = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
AddressTextField,
|
|
16
|
+
name
|
|
17
|
+
} = _ref;
|
|
18
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
19
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactFlexboxGrid.Row, {
|
|
20
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
21
|
+
xs: 6,
|
|
22
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
23
|
+
name: name ? "".concat(name, ".department") : 'department',
|
|
24
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
25
|
+
id: "ui-address-plugins.generic.department"
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
29
|
+
xs: 6,
|
|
30
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
31
|
+
name: name ? "".concat(name, ".premise") : 'premise',
|
|
32
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
33
|
+
id: "ui-address-plugins.generic.premise"
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
})]
|
|
37
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactFlexboxGrid.Row, {
|
|
38
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
39
|
+
xs: 6,
|
|
40
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
41
|
+
name: name ? "".concat(name, ".thoroughfare") : 'thoroughfare',
|
|
42
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
43
|
+
id: "ui-address-plugins.generic.thoroughfare"
|
|
44
|
+
}),
|
|
45
|
+
required: true,
|
|
46
|
+
validator: _addressUtils.requiredValidator
|
|
47
|
+
})
|
|
48
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
49
|
+
xs: 6,
|
|
50
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
51
|
+
name: name ? "".concat(name, ".postalCodeOrTown") : 'postalCodeOrTown',
|
|
52
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
53
|
+
id: "ui-address-plugins.generic.postalCodeOrTown"
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
})]
|
|
57
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactFlexboxGrid.Row, {
|
|
58
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
59
|
+
xs: 6,
|
|
60
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
61
|
+
name: name ? "".concat(name, ".locality") : 'locality',
|
|
62
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
63
|
+
id: "ui-address-plugins.generic.locality"
|
|
64
|
+
}),
|
|
65
|
+
required: true,
|
|
66
|
+
validator: _addressUtils.requiredValidator
|
|
67
|
+
})
|
|
68
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
69
|
+
xs: 6,
|
|
70
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
71
|
+
name: name ? "".concat(name, ".administrativeArea") : 'administrativeArea',
|
|
72
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
73
|
+
id: "ui-address-plugins.generic.administrativeArea"
|
|
74
|
+
}),
|
|
75
|
+
required: true,
|
|
76
|
+
validator: _addressUtils.requiredValidator
|
|
77
|
+
})
|
|
78
|
+
})]
|
|
79
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactFlexboxGrid.Row, {
|
|
80
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
81
|
+
xs: 4,
|
|
82
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
83
|
+
name: name ? "".concat(name, ".postalCode") : 'postalCode',
|
|
84
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
85
|
+
id: "ui-address-plugins.generic.postalCode"
|
|
86
|
+
}),
|
|
87
|
+
required: true,
|
|
88
|
+
validator: _addressUtils.requiredValidator
|
|
89
|
+
})
|
|
90
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
91
|
+
xs: 4,
|
|
92
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
93
|
+
name: name ? "".concat(name, ".postBox") : 'postBox',
|
|
94
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
95
|
+
id: "ui-address-plugins.generic.postBox"
|
|
96
|
+
}),
|
|
97
|
+
required: false
|
|
98
|
+
})
|
|
99
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
100
|
+
xs: 4,
|
|
101
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
102
|
+
name: name ? "".concat(name, ".postOffice") : 'postOffice',
|
|
103
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
104
|
+
id: "ui-address-plugins.generic.postOffice"
|
|
105
|
+
}),
|
|
106
|
+
required: false
|
|
107
|
+
})
|
|
108
|
+
})]
|
|
109
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Row, {
|
|
110
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
111
|
+
xs: 12,
|
|
112
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
113
|
+
name: name ? "".concat(name, ".country") : 'country',
|
|
114
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
115
|
+
id: "ui-address-plugins.generic.country"
|
|
116
|
+
}),
|
|
117
|
+
required: true,
|
|
118
|
+
validator: _addressUtils.requiredValidator
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
})]
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
AddressFieldsGeneric.propTypes = {
|
|
125
|
+
AddressTextField: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
126
|
+
name: _propTypes.default.string,
|
|
127
|
+
savedAddress: _propTypes.default.shape({
|
|
128
|
+
addressLabel: _propTypes.default.string,
|
|
129
|
+
countryCode: _propTypes.default.string,
|
|
130
|
+
id: _propTypes.default.string,
|
|
131
|
+
lines: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
132
|
+
id: _propTypes.default.string.isRequired,
|
|
133
|
+
type: _propTypes.default.shape({
|
|
134
|
+
value: _propTypes.default.string.isRequired
|
|
135
|
+
}).isRequired,
|
|
136
|
+
value: _propTypes.default.string.isRequired
|
|
137
|
+
}))
|
|
138
|
+
})
|
|
139
|
+
};
|
|
140
|
+
var _default = exports.default = AddressFieldsGeneric;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _addressUtils = require("../../address-utils");
|
|
8
|
+
const backendToFields = address => {
|
|
9
|
+
var _getExistingLineField, _getExistingLineField2, _getExistingLineField3, _getExistingLineField4, _getExistingLineField5, _getExistingLineField6, _getExistingLineField7, _getExistingLineField8, _getExistingLineField9, _getExistingLineField0;
|
|
10
|
+
const addressFields = {};
|
|
11
|
+
const department = (_getExistingLineField = (0, _addressUtils.getExistingLineField)(address.lines, 'department')) === null || _getExistingLineField === void 0 ? void 0 : _getExistingLineField.value;
|
|
12
|
+
const premise = (_getExistingLineField2 = (0, _addressUtils.getExistingLineField)(address.lines, 'premise')) === null || _getExistingLineField2 === void 0 ? void 0 : _getExistingLineField2.value;
|
|
13
|
+
const thoroughfare = (_getExistingLineField3 = (0, _addressUtils.getExistingLineField)(address.lines, 'thoroughfare')) === null || _getExistingLineField3 === void 0 ? void 0 : _getExistingLineField3.value;
|
|
14
|
+
const postalCodeOrTown = (_getExistingLineField4 = (0, _addressUtils.getExistingLineField)(address.lines, 'postalcodeortown')) === null || _getExistingLineField4 === void 0 ? void 0 : _getExistingLineField4.value;
|
|
15
|
+
const locality = (_getExistingLineField5 = (0, _addressUtils.getExistingLineField)(address.lines, 'locality')) === null || _getExistingLineField5 === void 0 ? void 0 : _getExistingLineField5.value;
|
|
16
|
+
const administrativeArea = (_getExistingLineField6 = (0, _addressUtils.getExistingLineField)(address.lines, 'administrativearea')) === null || _getExistingLineField6 === void 0 ? void 0 : _getExistingLineField6.value;
|
|
17
|
+
const postalCode = (_getExistingLineField7 = (0, _addressUtils.getExistingLineField)(address.lines, 'postalcode')) === null || _getExistingLineField7 === void 0 ? void 0 : _getExistingLineField7.value;
|
|
18
|
+
const postBox = (_getExistingLineField8 = (0, _addressUtils.getExistingLineField)(address.lines, 'postbox')) === null || _getExistingLineField8 === void 0 ? void 0 : _getExistingLineField8.value;
|
|
19
|
+
const postOffice = (_getExistingLineField9 = (0, _addressUtils.getExistingLineField)(address.lines, 'postoffice')) === null || _getExistingLineField9 === void 0 ? void 0 : _getExistingLineField9.value;
|
|
20
|
+
const country = (_getExistingLineField0 = (0, _addressUtils.getExistingLineField)(address.lines, 'country')) === null || _getExistingLineField0 === void 0 ? void 0 : _getExistingLineField0.value;
|
|
21
|
+
if (department) {
|
|
22
|
+
addressFields.department = department;
|
|
23
|
+
}
|
|
24
|
+
if (premise) {
|
|
25
|
+
addressFields.premise = premise;
|
|
26
|
+
}
|
|
27
|
+
if (thoroughfare) {
|
|
28
|
+
addressFields.thoroughfare = thoroughfare;
|
|
29
|
+
}
|
|
30
|
+
if (postalCodeOrTown) {
|
|
31
|
+
addressFields.postalCodeOrTown = postalCodeOrTown;
|
|
32
|
+
}
|
|
33
|
+
if (locality) {
|
|
34
|
+
addressFields.locality = locality;
|
|
35
|
+
}
|
|
36
|
+
if (administrativeArea) {
|
|
37
|
+
addressFields.administrativeArea = administrativeArea;
|
|
38
|
+
}
|
|
39
|
+
if (postalCode) {
|
|
40
|
+
addressFields.postalCode = postalCode;
|
|
41
|
+
}
|
|
42
|
+
if (postBox) {
|
|
43
|
+
addressFields.postBox = postBox;
|
|
44
|
+
}
|
|
45
|
+
if (postOffice) {
|
|
46
|
+
addressFields.postOffice = postOffice;
|
|
47
|
+
}
|
|
48
|
+
if (country) {
|
|
49
|
+
addressFields.country = country;
|
|
50
|
+
}
|
|
51
|
+
return addressFields;
|
|
52
|
+
};
|
|
53
|
+
var _default = exports.default = backendToFields;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const fieldOrder = {
|
|
8
|
+
'Department': 0,
|
|
9
|
+
'Premise': 1,
|
|
10
|
+
'Thoroughfare': 2,
|
|
11
|
+
'PostalCodeOrTown': 3,
|
|
12
|
+
'Locality': 4,
|
|
13
|
+
'AdministrativeArea': 5,
|
|
14
|
+
'PostalCode': 6,
|
|
15
|
+
'PostBox': 7,
|
|
16
|
+
'PostOffice': 8,
|
|
17
|
+
'Country': 9
|
|
18
|
+
};
|
|
19
|
+
var _default = exports.default = fieldOrder;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _addressUtils = require("../../address-utils");
|
|
8
|
+
const fieldsToBackend = address => {
|
|
9
|
+
const addressId = address.id || null;
|
|
10
|
+
const countryCode = address.countryCode || null;
|
|
11
|
+
const newAddress = {};
|
|
12
|
+
let lines = [];
|
|
13
|
+
if (address.department) {
|
|
14
|
+
var _getExistingLineField;
|
|
15
|
+
const id = (_getExistingLineField = (0, _addressUtils.getExistingLineField)(address.lines, 'department')) === null || _getExistingLineField === void 0 ? void 0 : _getExistingLineField.id;
|
|
16
|
+
lines.push({
|
|
17
|
+
type: {
|
|
18
|
+
value: 'Department'
|
|
19
|
+
},
|
|
20
|
+
value: address.department,
|
|
21
|
+
id
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
lines.push((0, _addressUtils.deleteFieldIfExists)(address.lines, 'department'));
|
|
25
|
+
}
|
|
26
|
+
if (address.premise) {
|
|
27
|
+
var _getExistingLineField2;
|
|
28
|
+
const id = (_getExistingLineField2 = (0, _addressUtils.getExistingLineField)(address.lines, 'premise')) === null || _getExistingLineField2 === void 0 ? void 0 : _getExistingLineField2.id;
|
|
29
|
+
lines.push({
|
|
30
|
+
type: {
|
|
31
|
+
value: 'Premise'
|
|
32
|
+
},
|
|
33
|
+
value: address.premise,
|
|
34
|
+
id
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
lines.push((0, _addressUtils.deleteFieldIfExists)(address.lines, 'premise'));
|
|
38
|
+
}
|
|
39
|
+
if (address.thoroughfare) {
|
|
40
|
+
var _getExistingLineField3;
|
|
41
|
+
const id = (_getExistingLineField3 = (0, _addressUtils.getExistingLineField)(address.lines, 'thoroughfare')) === null || _getExistingLineField3 === void 0 ? void 0 : _getExistingLineField3.id;
|
|
42
|
+
lines.push({
|
|
43
|
+
type: {
|
|
44
|
+
value: 'Thoroughfare'
|
|
45
|
+
},
|
|
46
|
+
value: address.thoroughfare,
|
|
47
|
+
id
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (address.postalCodeOrTown) {
|
|
51
|
+
var _getExistingLineField4;
|
|
52
|
+
const id = (_getExistingLineField4 = (0, _addressUtils.getExistingLineField)(address.lines, 'postalcodeortown')) === null || _getExistingLineField4 === void 0 ? void 0 : _getExistingLineField4.id;
|
|
53
|
+
lines.push({
|
|
54
|
+
type: {
|
|
55
|
+
value: 'PostalCodeOrTown'
|
|
56
|
+
},
|
|
57
|
+
value: address.postalCodeOrTown,
|
|
58
|
+
id
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
lines.push((0, _addressUtils.deleteFieldIfExists)(address.lines, 'postalcodeortown'));
|
|
62
|
+
}
|
|
63
|
+
if (address.locality) {
|
|
64
|
+
var _getExistingLineField5;
|
|
65
|
+
const id = (_getExistingLineField5 = (0, _addressUtils.getExistingLineField)(address.lines, 'locality')) === null || _getExistingLineField5 === void 0 ? void 0 : _getExistingLineField5.id;
|
|
66
|
+
lines.push({
|
|
67
|
+
type: {
|
|
68
|
+
value: 'Locality'
|
|
69
|
+
},
|
|
70
|
+
value: address.locality,
|
|
71
|
+
id
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (address.administrativeArea) {
|
|
75
|
+
var _getExistingLineField6;
|
|
76
|
+
const id = (_getExistingLineField6 = (0, _addressUtils.getExistingLineField)(address.lines, 'administrativearea')) === null || _getExistingLineField6 === void 0 ? void 0 : _getExistingLineField6.id;
|
|
77
|
+
lines.push({
|
|
78
|
+
type: {
|
|
79
|
+
value: 'AdministrativeArea'
|
|
80
|
+
},
|
|
81
|
+
value: address.administrativeArea,
|
|
82
|
+
id
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (address.postalCode) {
|
|
86
|
+
var _getExistingLineField7;
|
|
87
|
+
const id = (_getExistingLineField7 = (0, _addressUtils.getExistingLineField)(address.lines, 'postalcode')) === null || _getExistingLineField7 === void 0 ? void 0 : _getExistingLineField7.id;
|
|
88
|
+
lines.push({
|
|
89
|
+
type: {
|
|
90
|
+
value: 'PostalCode'
|
|
91
|
+
},
|
|
92
|
+
value: address.postalCode,
|
|
93
|
+
id
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (address.postBox) {
|
|
97
|
+
var _getExistingLineField8;
|
|
98
|
+
const id = (_getExistingLineField8 = (0, _addressUtils.getExistingLineField)(address.lines, 'postbox')) === null || _getExistingLineField8 === void 0 ? void 0 : _getExistingLineField8.id;
|
|
99
|
+
lines.push({
|
|
100
|
+
type: {
|
|
101
|
+
value: 'PostBox'
|
|
102
|
+
},
|
|
103
|
+
value: address.postBox,
|
|
104
|
+
id
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
lines.push((0, _addressUtils.deleteFieldIfExists)(address.lines, 'postbox'));
|
|
108
|
+
}
|
|
109
|
+
if (address.postOffice) {
|
|
110
|
+
var _getExistingLineField9;
|
|
111
|
+
const id = (_getExistingLineField9 = (0, _addressUtils.getExistingLineField)(address.lines, 'postoffice')) === null || _getExistingLineField9 === void 0 ? void 0 : _getExistingLineField9.id;
|
|
112
|
+
lines.push({
|
|
113
|
+
type: {
|
|
114
|
+
value: 'PostOffice'
|
|
115
|
+
},
|
|
116
|
+
value: address.postOffice,
|
|
117
|
+
id
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
lines.push((0, _addressUtils.deleteFieldIfExists)(address.lines, 'postoffice'));
|
|
121
|
+
}
|
|
122
|
+
if (address.country) {
|
|
123
|
+
var _getExistingLineField0;
|
|
124
|
+
const id = (_getExistingLineField0 = (0, _addressUtils.getExistingLineField)(address.lines, 'country')) === null || _getExistingLineField0 === void 0 ? void 0 : _getExistingLineField0.id;
|
|
125
|
+
lines.push({
|
|
126
|
+
type: {
|
|
127
|
+
value: 'Country'
|
|
128
|
+
},
|
|
129
|
+
value: address.country,
|
|
130
|
+
id
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
lines = lines.filter(line => line !== null);
|
|
134
|
+
newAddress.addressLabel = address.addressLabel;
|
|
135
|
+
newAddress.lines = lines;
|
|
136
|
+
newAddress.id = addressId;
|
|
137
|
+
newAddress.countryCode = countryCode;
|
|
138
|
+
return newAddress;
|
|
139
|
+
};
|
|
140
|
+
var _default = exports.default = fieldsToBackend;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _AddressFieldsGeneric = _interopRequireDefault(require("./AddressFieldsGeneric"));
|
|
8
|
+
var _fieldsToBackend = _interopRequireDefault(require("./fieldsToBackend"));
|
|
9
|
+
var _backendToFields = _interopRequireDefault(require("./backendToFields"));
|
|
10
|
+
var _listOfSupportedCountries = _interopRequireDefault(require("./listOfSupportedCountries"));
|
|
11
|
+
var _fieldOrder = _interopRequireDefault(require("./fieldOrder"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const pluginName = 'address-plugin-generic';
|
|
14
|
+
var _default = exports.default = {
|
|
15
|
+
addressFields: _AddressFieldsGeneric.default,
|
|
16
|
+
fieldsToBackend: _fieldsToBackend.default,
|
|
17
|
+
backendToFields: _backendToFields.default,
|
|
18
|
+
listOfSupportedCountries: _listOfSupportedCountries.default,
|
|
19
|
+
fieldOrder: _fieldOrder.default,
|
|
20
|
+
pluginName
|
|
21
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _src.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _src = _interopRequireDefault(require("./src"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _reactIntl = require("react-intl");
|
|
9
|
+
var _reactFlexboxGrid = require("react-flexbox-grid");
|
|
10
|
+
var _addressUtils = require("../../address-utils");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const AddressFieldsUSA = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
AddressTextField,
|
|
16
|
+
country,
|
|
17
|
+
name
|
|
18
|
+
} = _ref;
|
|
19
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
20
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactFlexboxGrid.Row, {
|
|
21
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
22
|
+
xs: 6,
|
|
23
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
24
|
+
name: name ? "".concat(name, ".addressLineOne") : 'addressLineOne',
|
|
25
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
26
|
+
id: "ui-address-plugins.NA.".concat(country, ".addressLineOne")
|
|
27
|
+
}),
|
|
28
|
+
required: true,
|
|
29
|
+
validator: _addressUtils.requiredValidator
|
|
30
|
+
})
|
|
31
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
32
|
+
xs: 6,
|
|
33
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
34
|
+
name: name ? "".concat(name, ".addressLineTwo") : 'addressLineTwo',
|
|
35
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
36
|
+
id: "ui-address-plugins.NA.".concat(country, ".addressLineTwo")
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})]
|
|
40
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Row, {
|
|
41
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
42
|
+
xs: 12,
|
|
43
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
44
|
+
name: name ? "".concat(name, ".locality") : 'locality',
|
|
45
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
46
|
+
id: "ui-address-plugins.NA.".concat(country, ".locality")
|
|
47
|
+
}),
|
|
48
|
+
required: true,
|
|
49
|
+
validator: _addressUtils.requiredValidator
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactFlexboxGrid.Row, {
|
|
53
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
54
|
+
xs: 6,
|
|
55
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
56
|
+
name: name ? "".concat(name, ".administrativeArea") : 'administrativeArea',
|
|
57
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
58
|
+
id: "ui-address-plugins.NA.".concat(country, ".administrativeArea")
|
|
59
|
+
}),
|
|
60
|
+
required: true,
|
|
61
|
+
validator: _addressUtils.requiredValidator
|
|
62
|
+
})
|
|
63
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
64
|
+
xs: 6,
|
|
65
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
66
|
+
name: name ? "".concat(name, ".postalCode") : 'postalCode',
|
|
67
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
68
|
+
id: "ui-address-plugins.NA.".concat(country, ".postalCode")
|
|
69
|
+
}),
|
|
70
|
+
required: true,
|
|
71
|
+
validator: _addressUtils.requiredValidator
|
|
72
|
+
})
|
|
73
|
+
})]
|
|
74
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Row, {
|
|
75
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFlexboxGrid.Col, {
|
|
76
|
+
xs: 12,
|
|
77
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(AddressTextField, {
|
|
78
|
+
name: name ? "".concat(name, ".country") : 'country',
|
|
79
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
80
|
+
id: "ui-address-plugins.NA.".concat(country, ".country")
|
|
81
|
+
}),
|
|
82
|
+
required: true,
|
|
83
|
+
validator: _addressUtils.requiredValidator
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
})]
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
AddressFieldsUSA.propTypes = {
|
|
90
|
+
AddressTextField: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
91
|
+
country: _propTypes.default.string,
|
|
92
|
+
name: _propTypes.default.string,
|
|
93
|
+
savedAddress: _propTypes.default.shape({
|
|
94
|
+
addressLabel: _propTypes.default.string,
|
|
95
|
+
countryCode: _propTypes.default.string,
|
|
96
|
+
id: _propTypes.default.string,
|
|
97
|
+
lines: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
98
|
+
id: _propTypes.default.string.isRequired,
|
|
99
|
+
type: _propTypes.default.shape({
|
|
100
|
+
value: _propTypes.default.string.isRequired
|
|
101
|
+
}).isRequired,
|
|
102
|
+
value: _propTypes.default.string.isRequired
|
|
103
|
+
}))
|
|
104
|
+
})
|
|
105
|
+
};
|
|
106
|
+
var _default = exports.default = AddressFieldsUSA;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _addressUtils = require("../../address-utils");
|
|
8
|
+
const backendToFields = address => {
|
|
9
|
+
var _getExistingLineField, _getExistingLineField2, _getExistingLineField3, _getExistingLineField4, _getExistingLineField5, _getExistingLineField6;
|
|
10
|
+
const addressFields = {};
|
|
11
|
+
const premise = (_getExistingLineField = (0, _addressUtils.getExistingLineField)(address.lines, 'premise')) === null || _getExistingLineField === void 0 ? void 0 : _getExistingLineField.value;
|
|
12
|
+
const thoroughfare = (_getExistingLineField2 = (0, _addressUtils.getExistingLineField)(address.lines, 'thoroughfare')) === null || _getExistingLineField2 === void 0 ? void 0 : _getExistingLineField2.value;
|
|
13
|
+
const locality = (_getExistingLineField3 = (0, _addressUtils.getExistingLineField)(address.lines, 'locality')) === null || _getExistingLineField3 === void 0 ? void 0 : _getExistingLineField3.value;
|
|
14
|
+
const postalCode = (_getExistingLineField4 = (0, _addressUtils.getExistingLineField)(address.lines, 'postalcode')) === null || _getExistingLineField4 === void 0 ? void 0 : _getExistingLineField4.value;
|
|
15
|
+
const administrativeArea = (_getExistingLineField5 = (0, _addressUtils.getExistingLineField)(address.lines, 'administrativearea')) === null || _getExistingLineField5 === void 0 ? void 0 : _getExistingLineField5.value;
|
|
16
|
+
const country = (_getExistingLineField6 = (0, _addressUtils.getExistingLineField)(address.lines, 'country')) === null || _getExistingLineField6 === void 0 ? void 0 : _getExistingLineField6.value;
|
|
17
|
+
const countryCode = address === null || address === void 0 ? void 0 : address.countryCode;
|
|
18
|
+
if (premise && thoroughfare) {
|
|
19
|
+
addressFields.addressLineOne = premise;
|
|
20
|
+
addressFields.addressLineTwo = thoroughfare;
|
|
21
|
+
} else {
|
|
22
|
+
addressFields.addressLineOne = thoroughfare;
|
|
23
|
+
}
|
|
24
|
+
if (locality) {
|
|
25
|
+
addressFields.locality = locality;
|
|
26
|
+
}
|
|
27
|
+
if (postalCode) {
|
|
28
|
+
addressFields.postalCode = postalCode;
|
|
29
|
+
}
|
|
30
|
+
if (administrativeArea) {
|
|
31
|
+
addressFields.administrativeArea = administrativeArea;
|
|
32
|
+
}
|
|
33
|
+
if (country) {
|
|
34
|
+
addressFields.country = country;
|
|
35
|
+
}
|
|
36
|
+
if (countryCode) {
|
|
37
|
+
addressFields.countryCode = countryCode;
|
|
38
|
+
}
|
|
39
|
+
return addressFields;
|
|
40
|
+
};
|
|
41
|
+
var _default = exports.default = backendToFields;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const fieldOrder = {
|
|
8
|
+
'Premise': 0,
|
|
9
|
+
'Thoroughfare': 1,
|
|
10
|
+
'Locality': 2,
|
|
11
|
+
'AdministrativeArea': 3,
|
|
12
|
+
'PostalCode': 4,
|
|
13
|
+
'Country': 5
|
|
14
|
+
};
|
|
15
|
+
var _default = exports.default = fieldOrder;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _addressUtils = require("../../address-utils");
|
|
8
|
+
const fieldsToBackend = address => {
|
|
9
|
+
const addressId = address.id || null;
|
|
10
|
+
const countryCode = address.countryCode || null;
|
|
11
|
+
const newAddress = {};
|
|
12
|
+
let lines = [];
|
|
13
|
+
if (address.addressLineOne && address.addressLineTwo) {
|
|
14
|
+
var _getExistingLineField, _getExistingLineField2;
|
|
15
|
+
// In this case we assume the first line is a premise, and the second is a thoroughfare
|
|
16
|
+
const premiseId = (_getExistingLineField = (0, _addressUtils.getExistingLineField)(address.lines, 'premise')) === null || _getExistingLineField === void 0 ? void 0 : _getExistingLineField.id;
|
|
17
|
+
const thoroughfareId = (_getExistingLineField2 = (0, _addressUtils.getExistingLineField)(address.lines, 'thoroughfare')) === null || _getExistingLineField2 === void 0 ? void 0 : _getExistingLineField2.id;
|
|
18
|
+
lines.push({
|
|
19
|
+
type: {
|
|
20
|
+
value: 'Premise'
|
|
21
|
+
},
|
|
22
|
+
value: address.addressLineOne,
|
|
23
|
+
id: premiseId
|
|
24
|
+
});
|
|
25
|
+
lines.push({
|
|
26
|
+
type: {
|
|
27
|
+
value: 'Thoroughfare'
|
|
28
|
+
},
|
|
29
|
+
value: address.addressLineTwo,
|
|
30
|
+
id: thoroughfareId
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
33
|
+
var _getExistingLineField3;
|
|
34
|
+
// The only other scenario that should happen is a blank address line 2,
|
|
35
|
+
// in which case we assume that address line 1 was the thoroughfare.
|
|
36
|
+
const thoroughfareId = (_getExistingLineField3 = (0, _addressUtils.getExistingLineField)(address.lines, 'thoroughfare')) === null || _getExistingLineField3 === void 0 ? void 0 : _getExistingLineField3.id;
|
|
37
|
+
lines.push({
|
|
38
|
+
type: {
|
|
39
|
+
value: 'Thoroughfare'
|
|
40
|
+
},
|
|
41
|
+
value: address.addressLineOne,
|
|
42
|
+
id: thoroughfareId
|
|
43
|
+
});
|
|
44
|
+
// In this case we can also check if there used to be a premise, and delete it if so
|
|
45
|
+
lines.push((0, _addressUtils.deleteFieldIfExists)(address.lines, 'premise'));
|
|
46
|
+
}
|
|
47
|
+
if (address.locality) {
|
|
48
|
+
var _getExistingLineField4;
|
|
49
|
+
const id = (_getExistingLineField4 = (0, _addressUtils.getExistingLineField)(address.lines, 'locality')) === null || _getExistingLineField4 === void 0 ? void 0 : _getExistingLineField4.id;
|
|
50
|
+
lines.push({
|
|
51
|
+
type: {
|
|
52
|
+
value: 'Locality'
|
|
53
|
+
},
|
|
54
|
+
value: address.locality,
|
|
55
|
+
id
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (address.administrativeArea) {
|
|
59
|
+
var _getExistingLineField5;
|
|
60
|
+
const id = (_getExistingLineField5 = (0, _addressUtils.getExistingLineField)(address.lines, 'administrativearea')) === null || _getExistingLineField5 === void 0 ? void 0 : _getExistingLineField5.id;
|
|
61
|
+
lines.push({
|
|
62
|
+
type: {
|
|
63
|
+
value: 'AdministrativeArea'
|
|
64
|
+
},
|
|
65
|
+
value: address.administrativeArea,
|
|
66
|
+
id
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (address.postalCode) {
|
|
70
|
+
var _getExistingLineField6;
|
|
71
|
+
const id = (_getExistingLineField6 = (0, _addressUtils.getExistingLineField)(address.lines, 'postalcode')) === null || _getExistingLineField6 === void 0 ? void 0 : _getExistingLineField6.id;
|
|
72
|
+
lines.push({
|
|
73
|
+
type: {
|
|
74
|
+
value: 'PostalCode'
|
|
75
|
+
},
|
|
76
|
+
value: address.postalCode,
|
|
77
|
+
id
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (address.country) {
|
|
81
|
+
var _getExistingLineField7;
|
|
82
|
+
const id = (_getExistingLineField7 = (0, _addressUtils.getExistingLineField)(address.lines, 'country')) === null || _getExistingLineField7 === void 0 ? void 0 : _getExistingLineField7.id;
|
|
83
|
+
lines.push({
|
|
84
|
+
type: {
|
|
85
|
+
value: 'Country'
|
|
86
|
+
},
|
|
87
|
+
value: address.country,
|
|
88
|
+
id
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
lines = lines.filter(line => line !== null);
|
|
92
|
+
newAddress.addressLabel = address.addressLabel;
|
|
93
|
+
newAddress.lines = lines;
|
|
94
|
+
newAddress.id = addressId;
|
|
95
|
+
newAddress.countryCode = countryCode;
|
|
96
|
+
return newAddress;
|
|
97
|
+
};
|
|
98
|
+
var _default = exports.default = fieldsToBackend;
|