@nnc-digital/nnc-design-system 0.4.15 → 0.4.16
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/build/index.esm.js +63 -22
- package/build/index.esm.js.map +1 -1
- package/build/index.js +63 -22
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.esm.js
CHANGED
|
@@ -4034,7 +4034,7 @@ var FormContainer$1 = styled.div(templateObject_4 || (templateObject_4 = __makeT
|
|
|
4034
4034
|
return props.isLoading && "\n opacity: 0.5; \n pointer-events: none;\n ";
|
|
4035
4035
|
});
|
|
4036
4036
|
var ErrorTextWrapper = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: block;\n width: 100%;\n"], ["\n display: block;\n width: 100%;\n"])));
|
|
4037
|
-
var DropDownSelectContainer = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-bottom: 20px;\n"], ["\n padding-bottom: 20px;\n"])));
|
|
4037
|
+
var DropDownSelectContainer = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-bottom: 20px;\n width: 90%;\n"], ["\n padding-bottom: 20px;\n width: 90%;\n"])));
|
|
4038
4038
|
var FormInnerContainer = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n"], ["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n"])));
|
|
4039
4039
|
styled.label(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin-right: ", ";\n"], ["\n display: flex;\n align-items: center;\n margin-right: ", ";\n"])), function (props) { return props.theme.theme_vars.spacingSizes.small; });
|
|
4040
4040
|
styled.div(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: flex;\n justify-content: left;\n margin-bottom: .5em;\n width: 100%;\n"], ["\n display: flex;\n justify-content: left;\n margin-bottom: .5em;\n width: 100%;\n"])));
|
|
@@ -4327,14 +4327,23 @@ var BinCollection = function (_a) {
|
|
|
4327
4327
|
fetchAddresses(enteredPostcode);
|
|
4328
4328
|
}
|
|
4329
4329
|
};
|
|
4330
|
+
var formatUKPostcode = function (postcode) {
|
|
4331
|
+
// Remove existing spaces and convert to uppercase
|
|
4332
|
+
var cleaned = postcode.replace(/\s/g, '').toUpperCase();
|
|
4333
|
+
// Add space before the last 3 characters
|
|
4334
|
+
var formatted = cleaned.slice(0, -3) + " " + cleaned.slice(-3);
|
|
4335
|
+
return formatted;
|
|
4336
|
+
};
|
|
4330
4337
|
/**
|
|
4331
4338
|
* Returns an array of address options based on the entered postcode.
|
|
4332
4339
|
*/
|
|
4333
4340
|
var fetchAddresses = function (postcode) { return __awaiter(void 0, void 0, void 0, function () {
|
|
4334
4341
|
return __generator(this, function (_a) {
|
|
4342
|
+
setCalendarEvents({});
|
|
4335
4343
|
setError(false);
|
|
4336
4344
|
setErrorText('');
|
|
4337
4345
|
setIsLoading(true);
|
|
4346
|
+
postcode = formatUKPostcode(postcode);
|
|
4338
4347
|
axios.get("".concat(BinCollectionApiUrl).concat(postcode))
|
|
4339
4348
|
.then(function (response) {
|
|
4340
4349
|
setIsLoading(false);
|
|
@@ -4419,15 +4428,49 @@ var BinCollection = function (_a) {
|
|
|
4419
4428
|
};
|
|
4420
4429
|
var formatTitle = function (apiTitle) {
|
|
4421
4430
|
var mappings = [
|
|
4422
|
-
{
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4431
|
+
{
|
|
4432
|
+
keyword: 'Refuse',
|
|
4433
|
+
replacement: 'General refuse bin',
|
|
4434
|
+
allowedValues: [
|
|
4435
|
+
'Refuse bin 1100l', 'Refuse bin 140l', 'Refuse bin 180l',
|
|
4436
|
+
'Refuse bin 240l', 'Refuse bin 360l', 'Refuse bin 660l',
|
|
4437
|
+
'Refuse Chamberlain', 'Refuse Palladin', 'Authorised bin (larger h/hold) 120l',
|
|
4438
|
+
'Authorised bin (larger h/hold) 140l', 'Authorised bin (larger h/hold) 180l',
|
|
4439
|
+
'Authorised bin (offensive) 140l', 'Authorised bin (offensive) 180l', 'Authorised bin (offensive) 240l',
|
|
4440
|
+
]
|
|
4441
|
+
},
|
|
4442
|
+
{
|
|
4443
|
+
keyword: 'Recycling',
|
|
4444
|
+
replacement: 'Recycling bin',
|
|
4445
|
+
allowedValues: [
|
|
4446
|
+
'Recycling 1100l', 'Recycling 140l', 'Recycling 180l',
|
|
4447
|
+
'Recycling 240l', 'Recycling bin 1100l'
|
|
4448
|
+
]
|
|
4449
|
+
},
|
|
4450
|
+
{
|
|
4451
|
+
keyword: 'Garden',
|
|
4452
|
+
replacement: 'Garden bin',
|
|
4453
|
+
allowedValues: [
|
|
4454
|
+
'Garden 140l', 'Garden 180l', 'Garden 240l'
|
|
4455
|
+
]
|
|
4456
|
+
},
|
|
4457
|
+
{
|
|
4458
|
+
keyword: 'Food',
|
|
4459
|
+
replacement: 'Food caddy',
|
|
4460
|
+
allowedValues: [
|
|
4461
|
+
'Communal food bin (exterior) 180L',
|
|
4462
|
+
'Food Caddy (exterior) 23l',
|
|
4463
|
+
'Food Caddy (indoor) 5l'
|
|
4464
|
+
]
|
|
4465
|
+
},
|
|
4426
4466
|
];
|
|
4427
4467
|
for (var _i = 0, mappings_1 = mappings; _i < mappings_1.length; _i++) {
|
|
4428
4468
|
var mapping = mappings_1[_i];
|
|
4429
|
-
|
|
4430
|
-
|
|
4469
|
+
for (var _a = 0, _b = mapping.allowedValues; _a < _b.length; _a++) {
|
|
4470
|
+
var value = _b[_a];
|
|
4471
|
+
if (apiTitle.includes(value)) {
|
|
4472
|
+
return mapping.replacement;
|
|
4473
|
+
}
|
|
4431
4474
|
}
|
|
4432
4475
|
}
|
|
4433
4476
|
return null;
|
|
@@ -4447,21 +4490,19 @@ var BinCollection = function (_a) {
|
|
|
4447
4490
|
addressOptions.length > 0 && (React.createElement(DropDownSelectContainer, null,
|
|
4448
4491
|
React.createElement(DropDownSelect, { onChange: handleAddressChange, id: "address", label: "Select your address", options: __spreadArray([{ title: 'Select an address', value: '' }], addressOptions, true) }))),
|
|
4449
4492
|
noResultsFound && React.createElement("p", null, "No results found."),
|
|
4450
|
-
React.createElement("div", null,
|
|
4451
|
-
var
|
|
4452
|
-
var
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
return
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
.map(function (date) { return (React.createElement("p", null, date.toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }))); })));
|
|
4464
|
-
})),
|
|
4493
|
+
React.createElement("div", null, (function () {
|
|
4494
|
+
var order = ['General refuse bin', 'Recycling bin', 'Garden bin', 'Food caddy'];
|
|
4495
|
+
var uniqueTitles = Array.from(new Set(Object.keys(calendarEvents).map(function (apiTitle) { return formatTitle(apiTitle); }).filter(function (title) { return title !== null; })));
|
|
4496
|
+
var sortedTitles = uniqueTitles.sort(function (a, b) { return order.indexOf(a) - order.indexOf(b); });
|
|
4497
|
+
return sortedTitles.map(function (title, index) {
|
|
4498
|
+
var apiTitlesForThisType = Object.keys(calendarEvents).filter(function (apiTitle) { return formatTitle(apiTitle) === title; });
|
|
4499
|
+
return (React.createElement(React.Fragment, { key: "".concat(title, "-").concat(index) },
|
|
4500
|
+
React.createElement(Heading, { level: 3, text: title }),
|
|
4501
|
+
apiTitlesForThisType.flatMap(function (apiTitle) { return calendarEvents[apiTitle]; })
|
|
4502
|
+
.sort(function (a, b) { return new Date(a).getTime() - new Date(b).getTime(); })
|
|
4503
|
+
.map(function (date) { return (React.createElement("p", null, date.toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }))); })));
|
|
4504
|
+
});
|
|
4505
|
+
})()),
|
|
4465
4506
|
Object.keys(calendarEvents).length > 0 && (React.createElement(FormButton, { size: "small", type: "button", "aria-label": "Reset", text: "Find a different address", onClick: resetForm }))));
|
|
4466
4507
|
};
|
|
4467
4508
|
|