northants-design-system 0.4.0-alpha.6 → 0.4.0-alpha.7

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.
@@ -165,7 +165,7 @@ const StyledTextInput = styled.input`
165
165
  }
166
166
  `;
167
167
 
168
- const VisuallyHidden$2 = css`
168
+ const VisuallyHidden$3 = css`
169
169
  position: absolute !important;
170
170
  width: 1px !important;
171
171
  height: 1px !important;
@@ -218,7 +218,7 @@ const AutocompleteTextInput = styled(StyledTextInput)`
218
218
 
219
219
  const AutocompleteLabel = styled.label`
220
220
  font-family: ${(props) => props.theme.theme_vars.fontstack};
221
- ${(props) => (props.hasHiddenLabel ? VisuallyHidden$2 : 'display: inline-block; padding-bottom: 10px')}
221
+ ${(props) => (props.hasHiddenLabel ? VisuallyHidden$3 : 'display: inline-block; padding-bottom: 10px')}
222
222
  `;
223
223
 
224
224
  /**
@@ -5953,7 +5953,7 @@ const Number$1 = styled.button`
5953
5953
 
5954
5954
  const Ellipsis = styled.span``;
5955
5955
 
5956
- const VisuallyHidden$1 = styled.span`
5956
+ const VisuallyHidden$2 = styled.span`
5957
5957
  position: absolute !important;
5958
5958
  width: 1px !important;
5959
5959
  height: 1px !important;
@@ -6651,7 +6651,7 @@ var Pagination = function (_a) {
6651
6651
  React.createElement(NumbersContainer, null, numbers.map(function (v, i) { return (React.createElement(NumberContainer, { key: i },
6652
6652
  v === '...' && React.createElement(Ellipsis, null, "..."),
6653
6653
  v !== '...' && (React.createElement(Number$1, { onClick: function () { return buttonClick(v); }, isCurrent: currentPage === v, title: currentPage === v ? 'This is the current page' : 'Go to page ' + v },
6654
- React.createElement(VisuallyHidden$1, null, "Page "),
6654
+ React.createElement(VisuallyHidden$2, null, "Page "),
6655
6655
  v)))); })),
6656
6656
  currentPage < numberOfNumbers && (React.createElement(Next, { onClick: function () { return buttonClick(currentPage + 1); }, title: "Go forward a page" }, "Next"))));
6657
6657
  }
@@ -6678,7 +6678,7 @@ const Fieldset$1 = styled.fieldset`
6678
6678
 
6679
6679
  const hideLabel$1 = (props) => {
6680
6680
  if (props.labelHidden) {
6681
- return VisuallyHidden$2;
6681
+ return VisuallyHidden$3;
6682
6682
  }
6683
6683
  };
6684
6684
 
@@ -6696,7 +6696,7 @@ const Legend$1 = styled.legend`
6696
6696
 
6697
6697
  const hideHint = (props) => {
6698
6698
  if (props.hintHidden) {
6699
- return VisuallyHidden$2;
6699
+ return VisuallyHidden$3;
6700
6700
  }
6701
6701
  };
6702
6702
 
@@ -6844,7 +6844,7 @@ const Container$_ = styled.div`
6844
6844
 
6845
6845
  const hideLabel = props => {
6846
6846
  if(props.hideLabel === true) {
6847
- return VisuallyHidden$2;
6847
+ return VisuallyHidden$3;
6848
6848
  }
6849
6849
  };
6850
6850
 
@@ -7150,11 +7150,11 @@ const Container$W = styled.div`
7150
7150
  }
7151
7151
  `;
7152
7152
 
7153
- const AccordionControls = styled.div`
7153
+ const AccordionControls$1 = styled.div`
7154
7154
  text-align: right;
7155
7155
  `;
7156
7156
 
7157
- const OpenAllButton = styled.button`
7157
+ const OpenAllButton$1 = styled.button`
7158
7158
  font-size: ${(props) => props.theme.theme_vars.fontSizes.extra_small};
7159
7159
  position: relative;
7160
7160
  z-index: 1;
@@ -7176,7 +7176,7 @@ const OpenAllButton = styled.button`
7176
7176
  }
7177
7177
  `;
7178
7178
 
7179
- const VisuallyHidden = styled.span`
7179
+ const VisuallyHidden$1 = styled.span`
7180
7180
  ${(props) => props.theme.visuallyHidden}
7181
7181
  `;
7182
7182
 
@@ -7423,10 +7423,10 @@ var Accordion$1 = function (_a) {
7423
7423
  };
7424
7424
  var accordionId = "accordion".concat(uniqueID());
7425
7425
  return (React.createElement(Container$W, { "data-testid": "Accordion", id: accordionId },
7426
- showControls && sections.length > 1 && (React.createElement(AccordionControls, null,
7427
- React.createElement(OpenAllButton, { onClick: toggleAll, type: "button", "aria-expanded": !openAll },
7426
+ showControls && sections.length > 1 && (React.createElement(AccordionControls$1, null,
7427
+ React.createElement(OpenAllButton$1, { onClick: toggleAll, type: "button", "aria-expanded": !openAll },
7428
7428
  openAll ? 'Open all' : 'Close all',
7429
- React.createElement(VisuallyHidden, null, " sections")))),
7429
+ React.createElement(VisuallyHidden$1, null, " sections")))),
7430
7430
  accordionStates.map(function (section, i) { return (React.createElement(AccordionSection, __assign$2({}, section, { key: i, onToggle: updateAccordionState, isFilter: isFilter, withReadMore: withReadMore }))); })));
7431
7431
  };
7432
7432
 
@@ -21043,7 +21043,7 @@ var FileDownload = function (_a) {
21043
21043
  React.createElement(Title$7, { className: "file-title" }, title),
21044
21044
  React.createElement(Type, null, type == 'Microsoft Office - OOXML - Word Document'
21045
21045
  ? 'Word Document'
21046
- : type == 'Adobe Portable Document Format'
21046
+ : type == 'Adobe Portable Document Format' || type == 'application/pdf'
21047
21047
  ? 'PDF'
21048
21048
  : type),
21049
21049
  React.createElement(Size, null, size)))));
@@ -22329,7 +22329,7 @@ const Label$2 = styled.label`
22329
22329
  font-family: ${(props) => props.theme.theme_vars.fontstack};
22330
22330
  ${(props) =>
22331
22331
  props.hasHiddenLabel
22332
- ? VisuallyHidden$2
22332
+ ? VisuallyHidden$3
22333
22333
  : `display: inline-block; padding-bottom: ${props.theme.theme_vars.spacingSizes.small}`}
22334
22334
  `;
22335
22335
 
@@ -24286,7 +24286,7 @@ const StyledMaxWidthContainer$1 = styled.div`
24286
24286
  }
24287
24287
  `;
24288
24288
  const HiddenH1$1 = styled.h1`
24289
- ${(props) => VisuallyHidden$2};
24289
+ ${(props) => VisuallyHidden$3};
24290
24290
  `;
24291
24291
 
24292
24292
  const MainBox = styled.div`
@@ -34341,7 +34341,7 @@ var ServiceContact = function (_a) {
34341
34341
  if (phones.length > 0) {
34342
34342
  terms.push({
34343
34343
  term: 'Phone',
34344
- detail: phones.flatMap(function (phone) { return phone.number; }).join('<br /> '),
34344
+ detail: phones.flatMap(function (phone) { return "<p><a href=\"tel:".concat(phone.number, "\">").concat(phone.number, "</a></p>"); }).join(''),
34345
34345
  });
34346
34346
  }
34347
34347
  return (React.createElement(Container$3, { "data-testid": "ServiceContact" },
@@ -34353,7 +34353,7 @@ var transformService = function (email, url) {
34353
34353
  if (email) {
34354
34354
  service.push({
34355
34355
  term: 'Email',
34356
- detail: email,
34356
+ detail: "<a href=\"mailto:".concat(email, "\">").concat(email, "</a>"),
34357
34357
  });
34358
34358
  }
34359
34359
  if (url) {
@@ -34501,13 +34501,13 @@ var DirectoryAddToShortList = function (_a) {
34501
34501
 
34502
34502
  var getSnippet = function (description, extractLength) {
34503
34503
  if (extractLength === void 0) { extractLength = 190; }
34504
- return sanitizeHtml$1(description, {
34504
+ return (sanitizeHtml$1(description, {
34505
34505
  allowedTags: [],
34506
34506
  allowedAttributes: {},
34507
- }).substr(0, extractLength) + String.fromCharCode(8230);
34507
+ }).substr(0, extractLength) + String.fromCharCode(8230));
34508
34508
  };
34509
34509
  var DirectoryService = function (_a) {
34510
- 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, regular_schedules = _a.regular_schedules, contacts = _a.contacts, service_areas = _a.service_areas, service_at_locations = _a.service_at_locations, url = _a.url;
34510
+ 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, regular_schedules = _a.regular_schedules, contacts = _a.contacts, service_areas = _a.service_areas, service_at_locations = _a.service_at_locations, url = _a.url, uploads = _a.uploads;
34511
34511
  var labelLetters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'];
34512
34512
  var _b = useState(false), notServer = _b[0], setNotServer = _b[1];
34513
34513
  useEffect(function () {
@@ -34525,7 +34525,7 @@ var DirectoryService = function (_a) {
34525
34525
  React.createElement(Column, { small: "full", medium: "full", large: "one-half" },
34526
34526
  location.physical_addresses.map(function (address) { return (React.createElement("p", { key: address.id, dangerouslySetInnerHTML: {
34527
34527
  __html: Object.values(address)
34528
- .filter(function (item) { return item !== ''; })
34528
+ .filter(function (item) { return item !== '' && item !== address.id; })
34529
34529
  .join(' <br />'),
34530
34530
  } })); }),
34531
34531
  (location === null || location === void 0 ? void 0 : location.accessibility_for_disabilities.length) > 0 && (React.createElement(React.Fragment, null,
@@ -34568,7 +34568,10 @@ var DirectoryService = function (_a) {
34568
34568
  React.createElement(Column, { small: "full", medium: "full", large: "full" },
34569
34569
  React.createElement(Heading, { level: 2, text: "Contact details" }),
34570
34570
  React.createElement(SummaryList, { terms: transformService(email, url), hasMargin: false }), contacts === null || contacts === void 0 ? void 0 :
34571
- contacts.map(function (contact, contactIndex) { return (React.createElement(ServiceContact, __assign$2({}, contact, { key: contactIndex }))); })))));
34571
+ contacts.map(function (contact, contactIndex) { return (React.createElement(ServiceContact, __assign$2({}, contact, { key: contactIndex }))); })),
34572
+ uploads && (React.createElement(Column, { small: "full", medium: "full", large: "full" },
34573
+ React.createElement(Heading, { level: 2, text: "Resources" }),
34574
+ React.createElement(DownloadableFiles, { files: uploads }))))));
34572
34575
  };
34573
34576
 
34574
34577
  const Container$1 = styled.div`
@@ -34859,6 +34862,36 @@ const Accordion = styled.div`
34859
34862
  display: ${(props) => (props.isOpen ? 'block' : 'none')};
34860
34863
  `;
34861
34864
 
34865
+ const AccordionControls = styled.div`
34866
+ text-align: right;
34867
+ `;
34868
+
34869
+ const OpenAllButton = styled.button`
34870
+ font-size: ${(props) => props.theme.theme_vars.fontSizes.extra_small};
34871
+ position: relative;
34872
+ z-index: 1;
34873
+ margin: 0;
34874
+ margin-bottom: 15px;
34875
+ padding: 0;
34876
+ border-width: 0;
34877
+ color: ${(props) => props.theme.theme_vars.colours.action};
34878
+ background: none;
34879
+ cursor: pointer;
34880
+ &:hover {
34881
+ ${(props) => props.theme.linkStylesHover};
34882
+ }
34883
+ &:focus {
34884
+ ${(props) => props.theme.linkStylesFocus};
34885
+ }
34886
+ &:active {
34887
+ ${(props) => props.theme.linkStylesActive};
34888
+ }
34889
+ `;
34890
+
34891
+ const VisuallyHidden = styled.span`
34892
+ ${(props) => props.theme.visuallyHidden}
34893
+ `;
34894
+
34862
34895
  const FavouritesContainer = styled.div`
34863
34896
  display: flex;
34864
34897
  flex-direction: row;
@@ -34966,14 +34999,15 @@ const LoadingContainer = styled.div`
34966
34999
  `;
34967
35000
 
34968
35001
  var DirectoryServiceList = function (_a) {
34969
- var directoryPath = _a.directoryPath, shortListPath = _a.shortListPath, services = _a.services, _b = _a.search, search = _b === void 0 ? '' : _b, setSearch = _a.setSearch, _c = _a.postcode, postcode = _c === void 0 ? '' : _c, setPostcode = _a.setPostcode, _d = _a.totalResults, totalResults = _d === void 0 ? 0 : _d, _e = _a.pageNumber, pageNumber = _e === void 0 ? 1 : _e, setPageNumber = _a.setPageNumber, _f = _a.perPage, perPage = _f === void 0 ? 5 : _f, _g = _a.extractLength, extractLength = _g === void 0 ? 190 : _g, _h = _a.categories, categories = _h === void 0 ? [] : _h, setCategories = _a.setCategories, _j = _a.minimumAge, minimumAge = _j === void 0 ? '' : _j, setMinimumAge = _a.setMinimumAge, _k = _a.maximumAge, maximumAge = _k === void 0 ? '' : _k, setMaximumAge = _a.setMaximumAge, _l = _a.mapCenter, mapCenter = _l === void 0 ? '52.23555414368587,-0.8957390701320571' : _l, _m = _a.mapZoom, mapZoom = _m === void 0 ? 9 : _m, _o = _a.isLoading, isLoading = _o === void 0 ? false : _o;
34970
- var _p = useLocalStorage("".concat(directoryPath.replace(/\//g, ''), "-accordion"), []), accordions = _p[0], setAccordions = _p[1];
34971
- var _q = useLocalStorage("".concat(directoryPath.replace(/\//g, ''), "-show-map"), false), showMap = _q[0], setShowMap = _q[1];
34972
- var _r = useState(false), showFilters = _r[0], setShowFilters = _r[1];
34973
- var _s = useDirectoryShortListContext(), _t = _s.favourites, favourites = _t.favourites; _t.setFavourites; _s.toggleFavourites; _s.isFavourite;
34974
- var _u = useState(false), notServer = _u[0], setNotServer = _u[1];
34975
- var _v = useState(search), searchTerm = _v[0], setSearchTerm = _v[1];
34976
- var _w = useState(postcode), postcodeSearch = _w[0], setPostcodeSearch = _w[1];
35002
+ var directoryPath = _a.directoryPath, shortListPath = _a.shortListPath, services = _a.services, _b = _a.search, search = _b === void 0 ? '' : _b, setSearch = _a.setSearch, _c = _a.postcode, postcode = _c === void 0 ? '' : _c, setPostcode = _a.setPostcode, _d = _a.totalResults, totalResults = _d === void 0 ? 0 : _d, _e = _a.pageNumber, pageNumber = _e === void 0 ? 1 : _e, setPageNumber = _a.setPageNumber, _f = _a.perPage, perPage = _f === void 0 ? 5 : _f, _g = _a.extractLength, extractLength = _g === void 0 ? 190 : _g, _h = _a.categories, categories = _h === void 0 ? [] : _h, setCategories = _a.setCategories, _j = _a.minimumAge, minimumAge = _j === void 0 ? undefined : _j, setMinimumAge = _a.setMinimumAge, _k = _a.maximumAge, maximumAge = _k === void 0 ? undefined : _k, setMaximumAge = _a.setMaximumAge, _l = _a.mapCenter, mapCenter = _l === void 0 ? '52.23555414368587,-0.8957390701320571' : _l, _m = _a.mapZoom, mapZoom = _m === void 0 ? 9 : _m, _o = _a.isLoading, isLoading = _o === void 0 ? false : _o, _p = _a.ageInMonths, ageInMonths = _p === void 0 ? false : _p;
35003
+ var _q = useLocalStorage("".concat(directoryPath.replace(/\//g, ''), "-accordion"), []), accordions = _q[0], setAccordions = _q[1];
35004
+ var _r = useLocalStorage("".concat(directoryPath.replace(/\//g, ''), "-accordion-all"), true), openAll = _r[0], setOpenAll = _r[1];
35005
+ var _s = useLocalStorage("".concat(directoryPath.replace(/\//g, ''), "-show-map"), false), showMap = _s[0], setShowMap = _s[1];
35006
+ var _t = useState(false), showFilters = _t[0], setShowFilters = _t[1];
35007
+ var _u = useDirectoryShortListContext(), _v = _u.favourites, favourites = _v.favourites; _v.setFavourites; _u.toggleFavourites; _u.isFavourite;
35008
+ var _w = useState(false), notServer = _w[0], setNotServer = _w[1];
35009
+ var _x = useState(search), searchTerm = _x[0], setSearchTerm = _x[1];
35010
+ var _y = useState(postcode), postcodeSearch = _y[0], setPostcodeSearch = _y[1];
34977
35011
  useEffect(function () {
34978
35012
  setNotServer(true);
34979
35013
  }, []);
@@ -35009,6 +35043,13 @@ var DirectoryServiceList = function (_a) {
35009
35043
  updatedAccordions[index] = !updatedAccordions[index];
35010
35044
  setAccordions(updatedAccordions);
35011
35045
  };
35046
+ var toggleAll = function () {
35047
+ setOpenAll(!openAll);
35048
+ var updatedAccordions = accordions.map(function () {
35049
+ return openAll;
35050
+ });
35051
+ setAccordions(updatedAccordions);
35052
+ };
35012
35053
  var submitSearch = function (e) {
35013
35054
  e.preventDefault();
35014
35055
  setSearch(searchTerm);
@@ -35031,6 +35072,30 @@ var DirectoryServiceList = function (_a) {
35031
35072
  };
35032
35073
  }),
35033
35074
  };
35075
+ var formatAge = function (age) {
35076
+ if (age === 0) {
35077
+ return age;
35078
+ }
35079
+ if (ageInMonths) {
35080
+ if (age > 36) {
35081
+ return Math.ceil(age / 12) + ' years';
35082
+ }
35083
+ return "".concat(age, " months");
35084
+ }
35085
+ return "".concat(age, " years");
35086
+ };
35087
+ var handleAgeChange = function (e, field) {
35088
+ var age = e.target.value ? parseInt(e.target.value, 10) : undefined;
35089
+ if (ageInMonths && age) {
35090
+ age = age * 12;
35091
+ }
35092
+ if (field === 'maximumAge') {
35093
+ setMaximumAge(age);
35094
+ }
35095
+ else {
35096
+ setMinimumAge(age);
35097
+ }
35098
+ };
35034
35099
  return (React.createElement(Container$1, { "data-testid": "DirectoryServiceList" },
35035
35100
  React.createElement(Row$1, null,
35036
35101
  React.createElement(Column, { small: "full", medium: "full", large: "full" },
@@ -35061,7 +35126,12 @@ var DirectoryServiceList = function (_a) {
35061
35126
  React.createElement(Row$1, null,
35062
35127
  React.createElement(Column, { small: "full", medium: "full", large: "full" },
35063
35128
  React.createElement(ResultInfo, null, "Refine your search")),
35064
- notServer && (React.createElement(React.Fragment, null, categories === null || categories === void 0 ? void 0 :
35129
+ notServer && (React.createElement(React.Fragment, null,
35130
+ React.createElement(Column, { small: "full", medium: "full", large: "full" },
35131
+ React.createElement(AccordionControls, null,
35132
+ React.createElement(OpenAllButton, { onClick: toggleAll, type: "button", "aria-expanded": !openAll },
35133
+ openAll ? 'Open all' : 'Close all',
35134
+ React.createElement(VisuallyHidden, null, " sections")))), categories === null || categories === void 0 ? void 0 :
35065
35135
  categories.map(function (category, categoryIndex) { return (React.createElement(Column, { small: "full", medium: "full", large: "full", key: category.label },
35066
35136
  React.createElement(Fieldset, null,
35067
35137
  React.createElement(Legend, null,
@@ -35081,10 +35151,10 @@ var DirectoryServiceList = function (_a) {
35081
35151
  React.createElement(Row$1, null,
35082
35152
  React.createElement(Column, { small: "full", medium: "one-half", large: "one-half" },
35083
35153
  React.createElement(Label, { htmlFor: "minimum_age" }, "From"),
35084
- React.createElement(Input, { name: "minimum_age", onChange: function (e) { var _a; return setMinimumAge((_a = e.target.value) !== null && _a !== void 0 ? _a : ''); }, defaultValue: minimumAge, id: "minimum_age" })),
35154
+ React.createElement(Input, { name: "minimum_age", onChange: function (e) { return handleAgeChange(e, 'minimumAge'); }, defaultValue: ageInMonths && minimumAge ? minimumAge / 12 : minimumAge, id: "minimum_age", type: "number" })),
35085
35155
  React.createElement(Column, { small: "full", medium: "one-half", large: "one-half" },
35086
35156
  React.createElement(Label, { htmlFor: "maximum_age" }, "To"),
35087
- React.createElement(Input, { name: "maximum_age", onChange: function (e) { var _a; return setMaximumAge((_a = e.target.value) !== null && _a !== void 0 ? _a : ''); }, defaultValue: maximumAge, id: "maximum_age" }))))))))))),
35157
+ React.createElement(Input, { name: "maximum_age", onChange: function (e) { return handleAgeChange(e, 'maximumAge'); }, defaultValue: ageInMonths && maximumAge ? maximumAge / 12 : maximumAge, id: "maximum_age", type: "number" }))))))))))),
35088
35158
  React.createElement(Column, { small: "full", medium: "two-thirds", large: "two-thirds" },
35089
35159
  React.createElement(Row$1, null,
35090
35160
  isLoading ? (React.createElement(LoadingContainer, null,
@@ -35126,9 +35196,10 @@ var DirectoryServiceList = function (_a) {
35126
35196
  React.createElement("div", null, snippet),
35127
35197
  service.eligibilitys && (React.createElement(React.Fragment, null, service.eligibilitys.map(function (eligibility) { return (React.createElement(Age, { key: eligibility.id },
35128
35198
  "Suitable for ages from ",
35129
- eligibility.minimum_age,
35130
- " to ",
35131
- eligibility.maximum_age)); })))),
35199
+ formatAge(eligibility.minimum_age),
35200
+ " to",
35201
+ ' ',
35202
+ formatAge(eligibility.maximum_age))); })))),
35132
35203
  React.createElement(Column, { small: "full", medium: "full", large: "full" },
35133
35204
  React.createElement(DirectoryAddToShortList, { id: service.id, name: service.name, snippet: snippet }))))));
35134
35205
  }))),