northants-design-system 0.4.0 → 0.4.2

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.
@@ -22675,12 +22675,13 @@ const SubmitButton = styled.input`
22675
22675
 
22676
22676
  /**
22677
22677
  * Primary UI component for user interaction
22678
+ * If value is set then treat as controlled component
22678
22679
  */
22679
22680
  var Input = function (_a) {
22680
- var _b = _a.type, type = _b === void 0 ? 'text' : _b, _c = _a.placeholder, placeholder = _c === void 0 ? '' : _c, _d = _a.isErrored, isErrored = _d === void 0 ? false : _d, errorText = _a.errorText, name = _a.name, maxLength = _a.maxLength, defaultValue = _a.defaultValue, onChange = _a.onChange, id = _a.id;
22681
+ var _b = _a.type, type = _b === void 0 ? 'text' : _b, _c = _a.placeholder, placeholder = _c === void 0 ? '' : _c, _d = _a.isErrored, isErrored = _d === void 0 ? false : _d, errorText = _a.errorText, name = _a.name, maxLength = _a.maxLength, defaultValue = _a.defaultValue, onChange = _a.onChange, id = _a.id, value = _a.value;
22681
22682
  return (React.createElement(React.Fragment, null,
22682
22683
  errorText && React.createElement(ErrorText$1, null, errorText),
22683
- React.createElement(StyledInput, { onChange: onChange, type: type, placeholder: placeholder, name: name, isErrored: isErrored, maxLength: maxLength, defaultValue: defaultValue, id: id })));
22684
+ typeof value !== 'undefined' ? (React.createElement(StyledInput, { onChange: onChange, type: type, placeholder: placeholder, name: name, isErrored: isErrored, maxLength: maxLength, value: value, id: id })) : (React.createElement(StyledInput, { onChange: onChange, type: type, placeholder: placeholder, name: name, isErrored: isErrored, maxLength: maxLength, defaultValue: defaultValue, id: id }))));
22684
22685
  };
22685
22686
 
22686
22687
  var CustomSearch = function (_a) {
@@ -28840,12 +28841,16 @@ var transformService = function (email, url, phone) {
28840
28841
  }
28841
28842
  return service;
28842
28843
  };
28843
- var transformDescriptionDetails = function (accreditations, fees, service_areas, languages) {
28844
+ var transformDescriptionDetails = function (accreditations, fees, service_areas, languages, eligibilities, ageInMonths) {
28845
+ if (ageInMonths === void 0) { ageInMonths = false; }
28844
28846
  var details = [];
28845
28847
  if (accreditations) {
28846
28848
  details.push({
28847
28849
  term: 'Accreditations',
28848
- detail: accreditations,
28850
+ detail: sanitizeHtml$1(accreditations, {
28851
+ allowedTags: ['p', 'b', 'i', 'em', 'strong', 'a', 'ul', 'li', 'ol'],
28852
+ allowedStyles: {},
28853
+ }),
28849
28854
  });
28850
28855
  }
28851
28856
  if (fees) {
@@ -28854,7 +28859,13 @@ var transformDescriptionDetails = function (accreditations, fees, service_areas,
28854
28859
  detail: fees,
28855
28860
  });
28856
28861
  }
28857
- if ((service_areas === null || service_areas === void 0 ? void 0 : service_areas.length) > 0) {
28862
+ if ((service_areas === null || service_areas === void 0 ? void 0 : service_areas.length) === 1) {
28863
+ details.push({
28864
+ term: 'Locality',
28865
+ detail: "<span>".concat(service_areas[0].service_area, "</span>"),
28866
+ });
28867
+ }
28868
+ else if ((service_areas === null || service_areas === void 0 ? void 0 : service_areas.length) > 1) {
28858
28869
  details.push({
28859
28870
  term: 'Locality',
28860
28871
  detail: '<ul>' +
@@ -28866,7 +28877,13 @@ var transformDescriptionDetails = function (accreditations, fees, service_areas,
28866
28877
  '</ul>',
28867
28878
  });
28868
28879
  }
28869
- if ((languages === null || languages === void 0 ? void 0 : languages.length) > 0) {
28880
+ if ((languages === null || languages === void 0 ? void 0 : languages.length) === 1) {
28881
+ details.push({
28882
+ term: 'Additional languages',
28883
+ detail: "<span>".concat(languages[0].language, "</span>"),
28884
+ });
28885
+ }
28886
+ else if ((languages === null || languages === void 0 ? void 0 : languages.length) > 1) {
28870
28887
  details.push({
28871
28888
  term: 'Additional languages',
28872
28889
  detail: '<ul>' +
@@ -28878,6 +28895,24 @@ var transformDescriptionDetails = function (accreditations, fees, service_areas,
28878
28895
  '</ul>',
28879
28896
  });
28880
28897
  }
28898
+ if ((eligibilities === null || eligibilities === void 0 ? void 0 : eligibilities.length) === 1) {
28899
+ details.push({
28900
+ term: 'Age range',
28901
+ detail: "<span>Suitable for ages from ".concat(transformAge(eligibilities[0].minimum_age, ageInMonths), " to\n ").concat(transformAge(eligibilities[0].maximum_age, ageInMonths), "</span>"),
28902
+ });
28903
+ }
28904
+ else if ((eligibilities === null || eligibilities === void 0 ? void 0 : eligibilities.length) > 1) {
28905
+ details.push({
28906
+ term: 'Age range',
28907
+ detail: '<ul>' +
28908
+ eligibilities
28909
+ .map(function (eligibility) {
28910
+ return "<li>Suitable for ages from ".concat(transformAge(eligibility.minimum_age, ageInMonths), " to \n ").concat(transformAge(eligibility.maximum_age, ageInMonths), "</li>");
28911
+ })
28912
+ .join('') +
28913
+ '</ul>',
28914
+ });
28915
+ }
28881
28916
  return details;
28882
28917
  };
28883
28918
  var transformSnippet = function (description, extractLength) {
@@ -28893,19 +28928,40 @@ var transformTaxonomies = function (service_taxonomys, taxonomiesToShow) {
28893
28928
  var groupedTaxonomies = groupBy(service_taxonomys, 'vocabulary');
28894
28929
  taxonomiesToShow.forEach(function (taxonomy, taxonomyIndex) {
28895
28930
  if (groupedTaxonomies.hasOwnProperty(taxonomy.vocabulary)) {
28896
- details.push({
28897
- term: taxonomy.label,
28898
- detail: '<ul>' +
28899
- groupedTaxonomies[taxonomy.vocabulary]
28900
- .map(function (item) {
28901
- return "<li>".concat(item.name, "</li>");
28902
- })
28903
- .join('') +
28904
- '</ul>',
28905
- });
28931
+ if (groupedTaxonomies[taxonomy.vocabulary].length === 1) {
28932
+ details.push({
28933
+ term: taxonomy.label,
28934
+ detail: '<span>' + groupedTaxonomies[taxonomy.vocabulary][0].name + '</span>',
28935
+ });
28936
+ }
28937
+ else {
28938
+ details.push({
28939
+ term: taxonomy.label,
28940
+ detail: '<ul>' +
28941
+ groupedTaxonomies[taxonomy.vocabulary]
28942
+ .map(function (item) {
28943
+ return "<li>".concat(item.name, "</li>");
28944
+ })
28945
+ .join('') +
28946
+ '</ul>',
28947
+ });
28948
+ }
28906
28949
  }
28907
28950
  });
28908
28951
  return details;
28952
+ };
28953
+ var transformAge = function (age, ageInMonths) {
28954
+ if (ageInMonths === void 0) { ageInMonths = false; }
28955
+ if (age === 0) {
28956
+ return age;
28957
+ }
28958
+ if (ageInMonths) {
28959
+ if (age > 36) {
28960
+ return Math.ceil(age / 12) + ' years';
28961
+ }
28962
+ return "".concat(age, " months");
28963
+ }
28964
+ return "".concat(age, " years");
28909
28965
  };
28910
28966
 
28911
28967
  const Container$5 = styled.div`
@@ -29085,9 +29141,9 @@ var getIcon = function (profile) {
29085
29141
 
29086
29142
  var DirectoryService = function (_a) {
29087
29143
  var _b, _c, _d, _e;
29088
- var id = _a.id, name = _a.name, accreditations = _a.accreditations, description = _a.description, descriptionElement = _a.descriptionElement, email = _a.email, fees = _a.fees, languages = _a.languages, organization = _a.organization, regular_schedules = _a.regular_schedules, contacts = _a.contacts, service_areas = _a.service_areas, service_at_locations = _a.service_at_locations, service_social_profiles = _a.service_social_profiles, service_taxonomys = _a.service_taxonomys, taxonomiesToShow = _a.taxonomiesToShow, url = _a.url, uploads = _a.uploads, shortListPath = _a.shortListPath;
29144
+ var id = _a.id, name = _a.name, accreditations = _a.accreditations, _f = _a.ageInMonths, ageInMonths = _f === void 0 ? false : _f, description = _a.description, descriptionElement = _a.descriptionElement, eligibilitys = _a.eligibilitys, email = _a.email, fees = _a.fees, languages = _a.languages, organization = _a.organization, regular_schedules = _a.regular_schedules, contacts = _a.contacts, service_areas = _a.service_areas, service_at_locations = _a.service_at_locations, service_social_profiles = _a.service_social_profiles, service_taxonomys = _a.service_taxonomys, taxonomiesToShow = _a.taxonomiesToShow, url = _a.url, uploads = _a.uploads, shortListPath = _a.shortListPath;
29089
29145
  var labelLetters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'];
29090
- var _f = useState(false), notServer = _f[0], setNotServer = _f[1];
29146
+ var _g = useState(false), notServer = _g[0], setNotServer = _g[1];
29091
29147
  var themeContext = useContext(ThemeContext);
29092
29148
  var favourites = useDirectoryShortListContext().favourites.favourites;
29093
29149
  useEffect(function () {
@@ -29154,14 +29210,14 @@ var DirectoryService = function (_a) {
29154
29210
  }),
29155
29211
  } })),
29156
29212
  React.createElement(MapLink, { href: "https://www.google.com/maps/search/?api=1&query=".concat(service_at_locations[0].latitude, "%2C").concat(service_at_locations[0].longitude) }, "View in Google Maps"))))))),
29157
- (email || url || contacts) && (React.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
29213
+ (email || url || (contacts === null || contacts === void 0 ? void 0 : contacts.length) > 0) && (React.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
29158
29214
  React.createElement(Heading, { level: 2, text: "How to contact this service" }),
29159
29215
  React.createElement(ServiceContact, { email: email, website: url, contacts: contacts }))),
29160
29216
  React.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
29161
- React.createElement(Heading, { level: 2, text: "How this service can help" }),
29217
+ React.createElement(Heading, { level: 2, text: "Description" }),
29162
29218
  React.createElement("div", null,
29163
29219
  React.createElement(React.Fragment, null, descriptionElement)),
29164
- React.createElement(SummaryList, { terms: transformDescriptionDetails(accreditations, fees, service_areas, languages), hasMargin: false }),
29220
+ React.createElement(SummaryList, { terms: transformDescriptionDetails(accreditations, fees, service_areas, languages, eligibilitys, ageInMonths), hasMargin: false }),
29165
29221
  React.createElement(SummaryList, { terms: transformTaxonomies(service_taxonomys, taxonomiesToShow), hasMargin: false })),
29166
29222
  regular_schedules.length > 0 && (React.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
29167
29223
  React.createElement(Heading, { level: 2, text: "Service hours" }),
@@ -29173,7 +29229,7 @@ var DirectoryService = function (_a) {
29173
29229
  React.createElement("th", { scope: "col" }, "Opens"),
29174
29230
  React.createElement("th", { scope: "col" }, "Closes"))),
29175
29231
  React.createElement("tbody", null, regular_schedules === null || regular_schedules === void 0 ? void 0 : regular_schedules.map(function (schedule, scheduleIndex) { return (React.createElement("tr", { key: scheduleIndex },
29176
- React.createElement("th", null, schedule.weekday),
29232
+ React.createElement("td", null, schedule.weekday),
29177
29233
  React.createElement("td", null, schedule.opens_at),
29178
29234
  React.createElement("td", null, schedule.closes_at))); })))))),
29179
29235
  (uploads === null || uploads === void 0 ? void 0 : uploads.length) > 0 && (React.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
@@ -29188,7 +29244,7 @@ var DirectoryService = function (_a) {
29188
29244
  .filter(function (location) {
29189
29245
  return location.is_visitable == false;
29190
29246
  })
29191
- .map(function (location) { return (React.createElement(Row$1, null,
29247
+ .map(function (location) { return (React.createElement(Row$1, { key: location.id },
29192
29248
  React.createElement(Column, { small: "full", medium: "one-half", large: "one-third", key: location.id },
29193
29249
  React.createElement(Heading, { level: 2, text: location.name }),
29194
29250
  location.physical_addresses.map(function (address) { return (React.createElement(PhysicalAddress, { key: address.id },
@@ -29199,10 +29255,7 @@ var DirectoryService = function (_a) {
29199
29255
  } }))); }),
29200
29256
  (location === null || location === void 0 ? void 0 : location.accessibility_for_disabilities.length) > 0 && (React.createElement(React.Fragment, null,
29201
29257
  React.createElement(Heading, { level: 3, text: "Other facilities on site" }),
29202
- React.createElement("ul", null, location.accessibility_for_disabilities.map(function (accessibility) { return (React.createElement("li", { key: accessibility.id }, accessibility.accessibility)); }))))),
29203
- React.createElement(Column, { small: "full", medium: "one-half", large: "two-thirds" },
29204
- React.createElement(WarningText, { title: "Please note", isWarning: true },
29205
- React.createElement("p", null, "This address is not open to visitors."))))); }))))));
29258
+ React.createElement("ul", null, location.accessibility_for_disabilities.map(function (accessibility) { return (React.createElement("li", { key: accessibility.id }, accessibility.accessibility)); }))))))); }))))));
29206
29259
  };
29207
29260
 
29208
29261
  const Container$3 = styled.div`
@@ -29405,7 +29458,13 @@ const AccordionControls = styled.div`
29405
29458
  justify-content: space-between;
29406
29459
  `;
29407
29460
 
29408
- const TextLink = styled.button`
29461
+ const ClearFilter$1 = styled.div`
29462
+ display: flex;
29463
+ justify-content: flex-end;
29464
+ padding-top: ${(props) => props.theme.theme_vars.spacingSizes.small};
29465
+ `;
29466
+
29467
+ const TextLink$1 = styled.button`
29409
29468
  font-size: ${(props) => props.theme.theme_vars.fontSizes.extra_small};
29410
29469
  position: relative;
29411
29470
  z-index: 1;
@@ -29661,7 +29720,7 @@ var RadioCheckboxInput = function (_a) {
29661
29720
  var id = useId();
29662
29721
  return (React.createElement(Container$2, { "data-testid": "RadioCheckboxInput" },
29663
29722
  React.createElement(Category$1, null,
29664
- React.createElement(CategoryInput, { type: singleSelection ? 'radio' : 'checkbox', value: value, id: id, name: name, onChange: onChange, defaultChecked: checked }),
29723
+ React.createElement(CategoryInput, { type: singleSelection ? 'radio' : 'checkbox', value: value, id: id, name: name, onClick: onChange, defaultChecked: checked }),
29665
29724
  React.createElement(CategoryInputLabel, { isChecked: checked, htmlFor: id, singleSelection: singleSelection }, label))));
29666
29725
  };
29667
29726
 
@@ -29681,6 +29740,9 @@ var DirectoryServiceList = function (_a) {
29681
29740
  setNotServer(true);
29682
29741
  setFiltersActive(hasActiveFilters());
29683
29742
  }, []);
29743
+ useEffect(function () {
29744
+ setFiltersActive(hasActiveFilters());
29745
+ }, [minimumAge, maximumAge, categories]);
29684
29746
  if (accordions.length === 0) {
29685
29747
  var tempAccordions_1 = [];
29686
29748
  categories === null || categories === void 0 ? void 0 : categories.forEach(function () {
@@ -29702,7 +29764,21 @@ var DirectoryServiceList = function (_a) {
29702
29764
  }
29703
29765
  });
29704
29766
  setCategories(newCategories);
29705
- setFiltersActive(hasActiveFilters());
29767
+ };
29768
+ /**
29769
+ * Uncheck all the options for a specific category
29770
+ */
29771
+ var clearCategory = function (categoryIndex) {
29772
+ var newCategories = __spreadArray([], categories, true);
29773
+ newCategories[categoryIndex].options.forEach(function (option) {
29774
+ option.checked = false;
29775
+ });
29776
+ setCategories(newCategories);
29777
+ };
29778
+ var clearAges = function (e) {
29779
+ e.target.value = '';
29780
+ handleAgeChange(e, 'minimumAge');
29781
+ handleAgeChange(e, 'maximumAge');
29706
29782
  };
29707
29783
  var from = pageNumber * perPage - (perPage - 1);
29708
29784
  var to = from + ((services === null || services === void 0 ? void 0 : services.length) ? services.length - 1 : 0);
@@ -29748,21 +29824,9 @@ var DirectoryServiceList = function (_a) {
29748
29824
  };
29749
29825
  }),
29750
29826
  };
29751
- var formatAge = function (age) {
29752
- if (age === 0) {
29753
- return age;
29754
- }
29755
- if (ageInMonths) {
29756
- if (age > 36) {
29757
- return Math.ceil(age / 12) + ' years';
29758
- }
29759
- return "".concat(age, " months");
29760
- }
29761
- return "".concat(age, " years");
29762
- };
29763
29827
  var handleAgeChange = function (e, field) {
29764
- var age = e.target.value ? parseInt(e.target.value, 10) : undefined;
29765
- if (ageInMonths && age) {
29828
+ var age = e.target.value ? parseInt(e.target.value, 10) : '';
29829
+ if (typeof age === 'number' && ageInMonths) {
29766
29830
  age = age * 12;
29767
29831
  }
29768
29832
  if (field === 'maximumAge') {
@@ -29773,13 +29837,14 @@ var DirectoryServiceList = function (_a) {
29773
29837
  }
29774
29838
  };
29775
29839
  var hasActiveFilters = function () {
29776
- return categories.some(function (category) {
29777
- return category.options.some(function (option) {
29778
- return option.checked == true;
29779
- });
29780
- });
29840
+ return (maximumAge !== '' ||
29841
+ minimumAge !== '' ||
29842
+ categories.some(function (category) {
29843
+ return category.options.some(function (option) {
29844
+ return option.checked == true;
29845
+ });
29846
+ }));
29781
29847
  };
29782
- hasActiveFilters();
29783
29848
  return (React.createElement(Container$3, { "data-testid": "DirectoryServiceList" },
29784
29849
  React.createElement(Row$1, null,
29785
29850
  React.createElement(Column, { small: "full", medium: "full", large: "full" },
@@ -29812,9 +29877,9 @@ var DirectoryServiceList = function (_a) {
29812
29877
  notServer && (React.createElement(React.Fragment, null,
29813
29878
  React.createElement(Column, { small: "full", medium: "full", large: "full" },
29814
29879
  React.createElement(AccordionControls, null,
29815
- filtersActive ? (React.createElement(TextLink, { onClick: clearSearch, type: "button" },
29880
+ filtersActive ? (React.createElement(TextLink$1, { onClick: clearSearch, type: "button" },
29816
29881
  React.createElement(ButtonText$1, null, "Clear all filters"))) : (React.createElement("div", null)),
29817
- React.createElement(TextLink, { onClick: toggleAll, type: "button", "aria-expanded": !openAll },
29882
+ React.createElement(TextLink$1, { onClick: toggleAll, type: "button", "aria-expanded": !openAll },
29818
29883
  openAll ? 'Open all' : 'Close all',
29819
29884
  React.createElement(VisuallyHidden, null, " sections")))),
29820
29885
  React.createElement(Column, { small: "full", medium: "full", large: "full" },
@@ -29824,69 +29889,76 @@ var DirectoryServiceList = function (_a) {
29824
29889
  "Select age group (years)",
29825
29890
  React.createElement(AccordionIcon, { isOpen: accordions[0] }))),
29826
29891
  React.createElement(Accordion, { isOpen: accordions[0] },
29892
+ React.createElement(ClearFilter$1, null,
29893
+ React.createElement(TextLink$1, { onClick: function (e) { return clearAges(e); } }, "Clear filter")),
29827
29894
  React.createElement(Row$1, null,
29828
29895
  React.createElement(Column, { small: "full", medium: "one-half", large: "one-half" },
29829
29896
  React.createElement(Label$1, { htmlFor: "minimum_age" }, "From"),
29830
- React.createElement(Input, { name: "minimum_age", onChange: function (e) { return handleAgeChange(e, 'minimumAge'); }, defaultValue: ageInMonths && minimumAge ? minimumAge / 12 : minimumAge, id: "minimum_age", type: "number" })),
29897
+ React.createElement(Input, { name: "minimum_age", onChange: function (e) { return handleAgeChange(e, 'minimumAge'); }, value: ageInMonths && typeof minimumAge === 'number' ? minimumAge / 12 : minimumAge, id: "minimum_age", type: "number" })),
29831
29898
  React.createElement(Column, { small: "full", medium: "one-half", large: "one-half" },
29832
29899
  React.createElement(Label$1, { htmlFor: "maximum_age" }, "To"),
29833
- React.createElement(Input, { name: "maximum_age", onChange: function (e) { return handleAgeChange(e, 'maximumAge'); }, defaultValue: ageInMonths && maximumAge ? maximumAge / 12 : maximumAge, id: "maximum_age", type: "number" })))))), categories === null || categories === void 0 ? void 0 :
29900
+ React.createElement(Input, { name: "maximum_age", onChange: function (e) { return handleAgeChange(e, 'maximumAge'); }, value: ageInMonths && typeof maximumAge === 'number' ? maximumAge / 12 : maximumAge, id: "maximum_age", type: "number" })))))), categories === null || categories === void 0 ? void 0 :
29834
29901
  categories.map(function (category, categoryIndex) { return (React.createElement(Column, { small: "full", medium: "full", large: "full", key: category.label },
29835
29902
  React.createElement(Fieldset$1, null,
29836
29903
  React.createElement(Legend$1, null,
29837
29904
  React.createElement(LegendButton, { onClick: function (e) { return toggleAccordion(categoryIndex + 1); }, type: "button" },
29838
29905
  category.label,
29839
29906
  React.createElement(AccordionIcon, { isOpen: accordions[categoryIndex + 1] }))),
29840
- React.createElement(Accordion, { isOpen: accordions[categoryIndex + 1] }, category.options.map(function (taxonomy) { return (React.createElement(Category$2, { key: taxonomy.id },
29841
- React.createElement(RadioCheckboxInput, { name: taxonomy.vocabulary, value: taxonomy.id, label: taxonomy.name, singleSelection: category.singleSelection, checked: taxonomy.checked, onChange: function (e) { return optionChecked(e, categoryIndex, category.singleSelection); } }))); }))))); })))))),
29907
+ React.createElement(Accordion, { isOpen: accordions[categoryIndex + 1] },
29908
+ React.createElement(ClearFilter$1, null,
29909
+ React.createElement(TextLink$1, { onClick: function (e) { return clearCategory(categoryIndex); } }, "Clear filter")),
29910
+ category.options.map(function (taxonomy) { return (React.createElement(Category$2, { key: taxonomy.id },
29911
+ React.createElement(RadioCheckboxInput, { name: taxonomy.vocabulary, value: taxonomy.id, label: taxonomy.name, singleSelection: category.singleSelection, checked: taxonomy.checked, onChange: function (e) { return optionChecked(e, categoryIndex, category.singleSelection); } }))); }))))); })))))),
29842
29912
  React.createElement(Column, { small: "full", medium: "two-thirds", large: "two-thirds" },
29843
- React.createElement(Row$1, null,
29844
- isLoading ? (React.createElement(LoadingContainer$1, null,
29845
- React.createElement(LoadingSpinner, null),
29846
- React.createElement("p", null, "Loading"))) : (React.createElement(React.Fragment, null,
29847
- React.createElement(Column, { small: "full", medium: "full", large: "full" },
29848
- (services === null || services === void 0 ? void 0 : services.length) > 0 ? (React.createElement(ResultInfo$1, null,
29849
- "Showing ",
29850
- from,
29851
- " to ",
29852
- to,
29853
- " out of ",
29854
- totalResults.toLocaleString())) : (React.createElement(ResultInfo$1, null, "No results found")),
29855
- React.createElement(FavouritesContainer, null,
29856
- (services === null || services === void 0 ? void 0 : services.length) > 0 && (React.createElement(MapToggle, { type: "button", onClick: function (e) { return setShowMap(!showMap); } }, showMap ? "Hide Map" : "Show Map")),
29857
- React.createElement(Favourites, { href: shortListPath },
29858
- React.createElement(HeartIcon, { colourFill: themeContext.theme_vars.colours.action }),
29859
- " Shortlist (",
29860
- favourites.length,
29861
- ")"))),
29862
- React.createElement(Column, { small: "full", medium: "full", large: "full" }, notServer && React.createElement(React.Fragment, null, (services === null || services === void 0 ? void 0 : services.length) > 0 && showMap && React.createElement(DirectoryMap, { mapProps: mapProps }))),
29863
- services.map(function (service, index) {
29864
- var _a, _b, _c, _d, _e, _f;
29865
- var snippet = transformSnippet(service.description, extractLength);
29866
- return (React.createElement(Column, { small: "full", medium: "full", large: "full", key: service.id },
29867
- React.createElement(ServiceContainer, { resultNumber: index },
29868
- React.createElement(Row$1, null,
29869
- React.createElement(Column, { small: "full", medium: "full", large: "full" },
29870
- React.createElement(ServiceHeader, null,
29871
- React.createElement(ServiceLink$1, { href: "".concat(directoryPath, "/").concat(service.id) }, service.name),
29872
- showMap && (React.createElement(MarkerContainer, null,
29873
- React.createElement("span", null, labelLetters[index]),
29874
- React.createElement(PinIcon, { colourFill: themeContext.theme_vars.colours.action_dark }))))),
29875
- React.createElement(Column, { small: "full", medium: ((_a = service.organization) === null || _a === void 0 ? void 0 : _a.logo) ? 'two-thirds' : 'full', large: ((_b = service.organization) === null || _b === void 0 ? void 0 : _b.logo) ? 'two-thirds' : 'full' },
29876
- React.createElement("div", null, snippet)),
29877
- ((_c = service.organization) === null || _c === void 0 ? void 0 : _c.logo) && (React.createElement(Column, { small: "full", medium: "one-third", large: "one-third" },
29878
- React.createElement(ServiceImageContainer, null,
29879
- React.createElement(ServiceImage, { src: service.organization.logo, alt: service.name + ' logo', loading: "lazy" })))),
29880
- React.createElement(Column, { small: "full", medium: "full", large: "full" }, service.eligibilitys && (React.createElement(React.Fragment, null, service.eligibilitys.map(function (eligibility) { return (React.createElement(Age, { key: eligibility.id },
29881
- "Suitable for ages from ",
29882
- formatAge(eligibility.minimum_age),
29883
- " to",
29884
- ' ',
29885
- formatAge(eligibility.maximum_age))); })))),
29886
- React.createElement(Column, { small: "full", medium: "full", large: "full" },
29887
- React.createElement(DirectoryAddToShortList, { id: service.id, name: service.name, snippet: snippet, email: service.email, website: service.url, phone: (_f = (_e = (_d = service.contacts) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.phones) === null || _f === void 0 ? void 0 : _f.flatMap(function (phone) { return phone.number; }).join(', ') }))))));
29888
- }))),
29889
- React.createElement(Column, { small: "full", medium: "full", large: "full" }, !isLoading && (React.createElement(Pagination, { currentPage: pageNumber, totalResults: totalResults, resultsPerPage: perPage, postTo: directoryPath, buttonClickOverride: setPageNumber }))))))));
29913
+ React.createElement(Row$1, null, isLoading ? (React.createElement(LoadingContainer$1, null,
29914
+ React.createElement(LoadingSpinner, null),
29915
+ React.createElement("p", null, "Loading"))) : (React.createElement(React.Fragment, null,
29916
+ React.createElement(Column, { small: "full", medium: "full", large: "full" },
29917
+ (services === null || services === void 0 ? void 0 : services.length) > 0 ? (React.createElement(ResultInfo$1, null,
29918
+ "Showing ",
29919
+ from,
29920
+ " to ",
29921
+ to,
29922
+ " out of ",
29923
+ totalResults.toLocaleString())) : (React.createElement(ResultInfo$1, null, "No results found")),
29924
+ React.createElement(FavouritesContainer, null,
29925
+ (services === null || services === void 0 ? void 0 : services.length) > 0 && (React.createElement(MapToggle, { type: "button", onClick: function (e) { return setShowMap(!showMap); } }, showMap ? "Hide Map" : "Show Map")),
29926
+ React.createElement(Favourites, { href: shortListPath },
29927
+ React.createElement(HeartIcon, { colourFill: themeContext.theme_vars.colours.action }),
29928
+ " Shortlist (",
29929
+ favourites.length,
29930
+ ")"))),
29931
+ React.createElement(Column, { small: "full", medium: "full", large: "full" },
29932
+ React.createElement(Pagination, { currentPage: pageNumber, totalResults: totalResults, resultsPerPage: perPage, postTo: directoryPath, buttonClickOverride: setPageNumber })),
29933
+ React.createElement(Column, { small: "full", medium: "full", large: "full" }, notServer && React.createElement(React.Fragment, null, (services === null || services === void 0 ? void 0 : services.length) > 0 && showMap && React.createElement(DirectoryMap, { mapProps: mapProps }))),
29934
+ services.map(function (service, index) {
29935
+ var _a, _b, _c, _d, _e, _f;
29936
+ var snippet = transformSnippet(service.description, extractLength);
29937
+ return (React.createElement(Column, { small: "full", medium: "full", large: "full", key: service.id },
29938
+ React.createElement(ServiceContainer, { resultNumber: index },
29939
+ React.createElement(Row$1, null,
29940
+ React.createElement(Column, { small: "full", medium: "full", large: "full" },
29941
+ React.createElement(ServiceHeader, null,
29942
+ React.createElement(ServiceLink$1, { href: "".concat(directoryPath, "/").concat(service.id) }, service.name),
29943
+ showMap && (React.createElement(MarkerContainer, null,
29944
+ React.createElement("span", null, labelLetters[index]),
29945
+ React.createElement(PinIcon, { colourFill: themeContext.theme_vars.colours.action_dark }))))),
29946
+ React.createElement(Column, { small: "full", medium: ((_a = service.organization) === null || _a === void 0 ? void 0 : _a.logo) ? 'two-thirds' : 'full', large: ((_b = service.organization) === null || _b === void 0 ? void 0 : _b.logo) ? 'two-thirds' : 'full' },
29947
+ React.createElement("div", null, snippet)),
29948
+ ((_c = service.organization) === null || _c === void 0 ? void 0 : _c.logo) && (React.createElement(Column, { small: "full", medium: "one-third", large: "one-third" },
29949
+ React.createElement(ServiceImageContainer, null,
29950
+ React.createElement(ServiceImage, { src: service.organization.logo, alt: service.name + ' logo', loading: "lazy" })))),
29951
+ React.createElement(Column, { small: "full", medium: "full", large: "full" }, service.eligibilitys && (React.createElement(React.Fragment, null, service.eligibilitys.map(function (eligibility) { return (React.createElement(Age, { key: eligibility.id },
29952
+ "Suitable for ages from ",
29953
+ transformAge(eligibility.minimum_age, ageInMonths),
29954
+ " to",
29955
+ ' ',
29956
+ transformAge(eligibility.maximum_age, ageInMonths))); })))),
29957
+ React.createElement(Column, { small: "full", medium: "full", large: "full" },
29958
+ React.createElement(DirectoryAddToShortList, { id: service.id, name: service.name, snippet: snippet, email: service.email, website: service.url, phone: (_f = (_e = (_d = service.contacts) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.phones) === null || _f === void 0 ? void 0 : _f.flatMap(function (phone) { return phone.number; }).join(', ') }))))));
29959
+ }),
29960
+ React.createElement(Column, { small: "full", medium: "full", large: "full" },
29961
+ React.createElement(Pagination, { currentPage: pageNumber, totalResults: totalResults, resultsPerPage: perPage, postTo: directoryPath, buttonClickOverride: setPageNumber })))))))));
29890
29962
  };
29891
29963
 
29892
29964
  const Container$1 = styled.div`
@@ -31449,6 +31521,34 @@ const ResultInfo = styled.div`
31449
31521
  color: ${(props) => props.theme.theme_vars.colours.grey_dark};
31450
31522
  `;
31451
31523
 
31524
+ const ClearFilter = styled.div`
31525
+ display: flex;
31526
+ justify-content: flex-end;
31527
+ padding-top: ${(props) => props.theme.theme_vars.spacingSizes.small};
31528
+ `;
31529
+
31530
+ const TextLink = styled.button`
31531
+ font-size: ${(props) => props.theme.theme_vars.fontSizes.extra_small};
31532
+ position: relative;
31533
+ z-index: 1;
31534
+ margin: 0;
31535
+ margin-bottom: 15px;
31536
+ padding: 0;
31537
+ border-width: 0;
31538
+ color: ${(props) => props.theme.theme_vars.colours.action};
31539
+ background: none;
31540
+ cursor: pointer;
31541
+ &:hover {
31542
+ ${(props) => props.theme.linkStylesHover};
31543
+ }
31544
+ &:focus {
31545
+ ${(props) => props.theme.linkStylesFocus};
31546
+ }
31547
+ &:active {
31548
+ ${(props) => props.theme.linkStylesActive};
31549
+ }
31550
+ `;
31551
+
31452
31552
  const Fieldset = styled.fieldset`
31453
31553
  display: block;
31454
31554
  border-bottom: 1px solid ${(props) => props.theme.theme_vars.colours.grey};
@@ -31509,6 +31609,16 @@ var DirectoryDocumentList = function (_a) {
31509
31609
  });
31510
31610
  setCategories(newCategories);
31511
31611
  };
31612
+ /**
31613
+ * Uncheck all the options for a specific category
31614
+ */
31615
+ var clearCategory = function (categoryIndex) {
31616
+ var newCategories = __spreadArray([], categories, true);
31617
+ newCategories[categoryIndex].options.forEach(function (option) {
31618
+ option.checked = false;
31619
+ });
31620
+ setCategories(newCategories);
31621
+ };
31512
31622
  var from = pageNumber * perPage - (perPage - 1);
31513
31623
  var to = from + ((documents === null || documents === void 0 ? void 0 : documents.length) ? documents.length - 1 : 0);
31514
31624
  return (React.createElement(Container, { "data-testid": "DirectoryDocumentList" },
@@ -31527,7 +31637,9 @@ var DirectoryDocumentList = function (_a) {
31527
31637
  React.createElement(ButtonContainer, null,
31528
31638
  React.createElement(Button, { onClick: submitSearch, type: "submit" },
31529
31639
  React.createElement(ButtonText, null, "Search"),
31530
- React.createElement(IconDownload, { colourFill: "#fff" })))))))),
31640
+ React.createElement(IconDownload, { colourFill: "#fff" })))),
31641
+ React.createElement(Column, { small: "full", medium: "full", large: "full" },
31642
+ React.createElement(Button$4, { url: "".concat(directoryPath, "?search=").concat(searchTerm), text: "View directory", primary: false })))))),
31531
31643
  React.createElement(Column, { small: "full", medium: "one-third", large: "one-third" },
31532
31644
  React.createElement(Row$1, null,
31533
31645
  React.createElement(Column, { small: "full", medium: "full", large: "full" },
@@ -31535,6 +31647,8 @@ var DirectoryDocumentList = function (_a) {
31535
31647
  categories.map(function (category, categoryIndex) { return (React.createElement(Column, { small: "full", medium: "full", large: "full", key: category.label },
31536
31648
  React.createElement(Fieldset, null,
31537
31649
  React.createElement(Legend, null, category.label),
31650
+ React.createElement(ClearFilter, null,
31651
+ React.createElement(TextLink, { onClick: function (e) { return clearCategory(categoryIndex); } }, "Clear filter")),
31538
31652
  category.options.map(function (taxonomy) { return (React.createElement(Category, { key: taxonomy.id },
31539
31653
  React.createElement(RadioCheckboxInput, { name: taxonomy.vocabulary, value: taxonomy.id, label: taxonomy.name, singleSelection: category.singleSelection, checked: taxonomy.checked, onChange: function (e) { return optionChecked(e, categoryIndex, category.singleSelection); } }))); })))); }))),
31540
31654
  React.createElement(Column, { small: "full", medium: "two-thirds", large: "two-thirds" },