@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.js
CHANGED
|
@@ -4049,7 +4049,7 @@ var FormContainer$1 = styled__default["default"].div(templateObject_4 || (templa
|
|
|
4049
4049
|
return props.isLoading && "\n opacity: 0.5; \n pointer-events: none;\n ";
|
|
4050
4050
|
});
|
|
4051
4051
|
var ErrorTextWrapper = styled__default["default"].div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: block;\n width: 100%;\n"], ["\n display: block;\n width: 100%;\n"])));
|
|
4052
|
-
var DropDownSelectContainer = styled__default["default"].div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-bottom: 20px;\n"], ["\n padding-bottom: 20px;\n"])));
|
|
4052
|
+
var DropDownSelectContainer = styled__default["default"].div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-bottom: 20px;\n width: 90%;\n"], ["\n padding-bottom: 20px;\n width: 90%;\n"])));
|
|
4053
4053
|
var FormInnerContainer = styled__default["default"].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"])));
|
|
4054
4054
|
styled__default["default"].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; });
|
|
4055
4055
|
styled__default["default"].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"])));
|
|
@@ -4342,14 +4342,23 @@ var BinCollection = function (_a) {
|
|
|
4342
4342
|
fetchAddresses(enteredPostcode);
|
|
4343
4343
|
}
|
|
4344
4344
|
};
|
|
4345
|
+
var formatUKPostcode = function (postcode) {
|
|
4346
|
+
// Remove existing spaces and convert to uppercase
|
|
4347
|
+
var cleaned = postcode.replace(/\s/g, '').toUpperCase();
|
|
4348
|
+
// Add space before the last 3 characters
|
|
4349
|
+
var formatted = cleaned.slice(0, -3) + " " + cleaned.slice(-3);
|
|
4350
|
+
return formatted;
|
|
4351
|
+
};
|
|
4345
4352
|
/**
|
|
4346
4353
|
* Returns an array of address options based on the entered postcode.
|
|
4347
4354
|
*/
|
|
4348
4355
|
var fetchAddresses = function (postcode) { return __awaiter(void 0, void 0, void 0, function () {
|
|
4349
4356
|
return __generator(this, function (_a) {
|
|
4357
|
+
setCalendarEvents({});
|
|
4350
4358
|
setError(false);
|
|
4351
4359
|
setErrorText('');
|
|
4352
4360
|
setIsLoading(true);
|
|
4361
|
+
postcode = formatUKPostcode(postcode);
|
|
4353
4362
|
axios__default["default"].get("".concat(BinCollectionApiUrl).concat(postcode))
|
|
4354
4363
|
.then(function (response) {
|
|
4355
4364
|
setIsLoading(false);
|
|
@@ -4434,15 +4443,49 @@ var BinCollection = function (_a) {
|
|
|
4434
4443
|
};
|
|
4435
4444
|
var formatTitle = function (apiTitle) {
|
|
4436
4445
|
var mappings = [
|
|
4437
|
-
{
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4446
|
+
{
|
|
4447
|
+
keyword: 'Refuse',
|
|
4448
|
+
replacement: 'General refuse bin',
|
|
4449
|
+
allowedValues: [
|
|
4450
|
+
'Refuse bin 1100l', 'Refuse bin 140l', 'Refuse bin 180l',
|
|
4451
|
+
'Refuse bin 240l', 'Refuse bin 360l', 'Refuse bin 660l',
|
|
4452
|
+
'Refuse Chamberlain', 'Refuse Palladin', 'Authorised bin (larger h/hold) 120l',
|
|
4453
|
+
'Authorised bin (larger h/hold) 140l', 'Authorised bin (larger h/hold) 180l',
|
|
4454
|
+
'Authorised bin (offensive) 140l', 'Authorised bin (offensive) 180l', 'Authorised bin (offensive) 240l',
|
|
4455
|
+
]
|
|
4456
|
+
},
|
|
4457
|
+
{
|
|
4458
|
+
keyword: 'Recycling',
|
|
4459
|
+
replacement: 'Recycling bin',
|
|
4460
|
+
allowedValues: [
|
|
4461
|
+
'Recycling 1100l', 'Recycling 140l', 'Recycling 180l',
|
|
4462
|
+
'Recycling 240l', 'Recycling bin 1100l'
|
|
4463
|
+
]
|
|
4464
|
+
},
|
|
4465
|
+
{
|
|
4466
|
+
keyword: 'Garden',
|
|
4467
|
+
replacement: 'Garden bin',
|
|
4468
|
+
allowedValues: [
|
|
4469
|
+
'Garden 140l', 'Garden 180l', 'Garden 240l'
|
|
4470
|
+
]
|
|
4471
|
+
},
|
|
4472
|
+
{
|
|
4473
|
+
keyword: 'Food',
|
|
4474
|
+
replacement: 'Food caddy',
|
|
4475
|
+
allowedValues: [
|
|
4476
|
+
'Communal food bin (exterior) 180L',
|
|
4477
|
+
'Food Caddy (exterior) 23l',
|
|
4478
|
+
'Food Caddy (indoor) 5l'
|
|
4479
|
+
]
|
|
4480
|
+
},
|
|
4441
4481
|
];
|
|
4442
4482
|
for (var _i = 0, mappings_1 = mappings; _i < mappings_1.length; _i++) {
|
|
4443
4483
|
var mapping = mappings_1[_i];
|
|
4444
|
-
|
|
4445
|
-
|
|
4484
|
+
for (var _a = 0, _b = mapping.allowedValues; _a < _b.length; _a++) {
|
|
4485
|
+
var value = _b[_a];
|
|
4486
|
+
if (apiTitle.includes(value)) {
|
|
4487
|
+
return mapping.replacement;
|
|
4488
|
+
}
|
|
4446
4489
|
}
|
|
4447
4490
|
}
|
|
4448
4491
|
return null;
|
|
@@ -4462,21 +4505,19 @@ var BinCollection = function (_a) {
|
|
|
4462
4505
|
addressOptions.length > 0 && (React__default["default"].createElement(DropDownSelectContainer, null,
|
|
4463
4506
|
React__default["default"].createElement(DropDownSelect, { onChange: handleAddressChange, id: "address", label: "Select your address", options: __spreadArray([{ title: 'Select an address', value: '' }], addressOptions, true) }))),
|
|
4464
4507
|
noResultsFound && React__default["default"].createElement("p", null, "No results found."),
|
|
4465
|
-
React__default["default"].createElement("div", null,
|
|
4466
|
-
var
|
|
4467
|
-
var
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
return
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
.map(function (date) { return (React__default["default"].createElement("p", null, date.toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }))); })));
|
|
4479
|
-
})),
|
|
4508
|
+
React__default["default"].createElement("div", null, (function () {
|
|
4509
|
+
var order = ['General refuse bin', 'Recycling bin', 'Garden bin', 'Food caddy'];
|
|
4510
|
+
var uniqueTitles = Array.from(new Set(Object.keys(calendarEvents).map(function (apiTitle) { return formatTitle(apiTitle); }).filter(function (title) { return title !== null; })));
|
|
4511
|
+
var sortedTitles = uniqueTitles.sort(function (a, b) { return order.indexOf(a) - order.indexOf(b); });
|
|
4512
|
+
return sortedTitles.map(function (title, index) {
|
|
4513
|
+
var apiTitlesForThisType = Object.keys(calendarEvents).filter(function (apiTitle) { return formatTitle(apiTitle) === title; });
|
|
4514
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, { key: "".concat(title, "-").concat(index) },
|
|
4515
|
+
React__default["default"].createElement(Heading, { level: 3, text: title }),
|
|
4516
|
+
apiTitlesForThisType.flatMap(function (apiTitle) { return calendarEvents[apiTitle]; })
|
|
4517
|
+
.sort(function (a, b) { return new Date(a).getTime() - new Date(b).getTime(); })
|
|
4518
|
+
.map(function (date) { return (React__default["default"].createElement("p", null, date.toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }))); })));
|
|
4519
|
+
});
|
|
4520
|
+
})()),
|
|
4480
4521
|
Object.keys(calendarEvents).length > 0 && (React__default["default"].createElement(FormButton, { size: "small", type: "button", "aria-label": "Reset", text: "Find a different address", onClick: resetForm }))));
|
|
4481
4522
|
};
|
|
4482
4523
|
|