northants-design-system 0.2.22 → 0.2.23

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.
@@ -132,39 +132,36 @@ const ErrorText = styled.p`
132
132
  `;
133
133
 
134
134
  const StyledTextInput = styled.input`
135
- display: block;
136
-
137
- /* 100% of container minus padding and borders */
138
- width: calc(100% - ${props => props.isLarge? props.theme.theme_vars.spacingSizes.small : props.theme.theme_vars.spacingSizes.extra_small}
139
- - ${props => props.isLarge? props.theme.theme_vars.spacingSizes.small : props.theme.theme_vars.spacingSizes.extra_small}
140
- - ${props => props.theme.theme_vars.border_width}
141
- - ${props => props.theme.theme_vars.border_width});
142
-
143
- ${props => props.theme.fontStyles}
144
- margin-top: 0 !important;
145
- margin-bottom: 0;
146
- padding: ${props => props.isLarge ? props.theme.theme_vars.spacingSizes.small : props.theme.theme_vars.spacingSizes.extra_small};
147
- border: solid ${props => props.isErrored ? props.theme.theme_vars.colours.negative : props.theme.theme_vars.colours.black};
148
- border-width: ${props => props.isErrored ? props.theme.theme_vars.border_width_error : props.theme.theme_vars.border_width};
149
- border-radius: ${props => props.isLarge ? props.theme.theme_vars.border_radius_large : props.theme.theme_vars.border_radius};
150
-
151
- &:focus {
152
- outline: none;
153
- box-shadow: ${props => props.theme.theme_vars.colours.focus} 0 0 0 3px;
154
- transition: box-shadow 0.3s ease 0s;
155
- }
135
+ display: block;
136
+ width: 100%;
137
+ ${(props) => props.theme.fontStyles}
138
+ margin-top: 0 !important;
139
+ margin-bottom: 0;
140
+ padding: ${(props) =>
141
+ props.isLarge ? props.theme.theme_vars.spacingSizes.small : props.theme.theme_vars.spacingSizes.extra_small};
142
+ border: solid
143
+ ${(props) => (props.isErrored ? props.theme.theme_vars.colours.negative : props.theme.theme_vars.colours.black)};
144
+ border-width: ${(props) =>
145
+ props.isErrored ? props.theme.theme_vars.border_width_error : props.theme.theme_vars.border_width};
146
+ border-radius: ${(props) =>
147
+ props.isLarge ? props.theme.theme_vars.border_radius_large : props.theme.theme_vars.border_radius};
156
148
 
157
- &::placeholder {
158
- color: ${props => props.theme.theme_vars.colours.placeholder};
159
- opacity: 1;
160
- }
161
- &:-ms-input-placeholder {
162
- color: ${props => props.theme.theme_vars.colours.placeholder};
163
- }
164
- &::-ms-input-placeholder {
165
- color: ${props => props.theme.theme_vars.colours.placeholder};
166
- }
149
+ &:focus {
150
+ outline: none;
151
+ box-shadow: ${(props) => props.theme.theme_vars.colours.focus} 0 0 0 3px;
152
+ transition: box-shadow 0.3s ease 0s;
153
+ }
167
154
 
155
+ &::placeholder {
156
+ color: ${(props) => props.theme.theme_vars.colours.placeholder};
157
+ opacity: 1;
158
+ }
159
+ &:-ms-input-placeholder {
160
+ color: ${(props) => props.theme.theme_vars.colours.placeholder};
161
+ }
162
+ &::-ms-input-placeholder {
163
+ color: ${(props) => props.theme.theme_vars.colours.placeholder};
164
+ }
168
165
  `;
169
166
 
170
167
  const VisuallyHidden$2 = css`
@@ -246,6 +243,7 @@ const AutocompleteSuggestionList = styled.ul`
246
243
  const AutocompleteSuggestionItem = styled.li`
247
244
  display: block;
248
245
  width: auto;
246
+ left: 0;
249
247
  padding: calc(
250
248
  ${(props) =>
251
249
  props.isLarge ? props.theme.theme_vars.spacingSizes.small : props.theme.theme_vars.spacingSizes.extra_small} +
@@ -3782,7 +3780,7 @@ process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
3782
3780
  * click on to select. If viewing in Storybook, try typing the name of a fruit in the story examples.
3783
3781
  */
3784
3782
  var Autocomplete = function (_a) {
3785
- var _b = _a.id, id = _b === void 0 ? "autocomplete" : _b, _c = _a.name, name = _c === void 0 ? "autocomplete" : _c, labelText = _a.labelText, _d = _a.hasHiddenLabel, hasHiddenLabel = _d === void 0 ? false : _d, value = _a.value, size = _a.size, placeholder = _a.placeholder, _e = _a.isErrored, isErrored = _e === void 0 ? false : _e, errorText = _a.errorText, _f = _a.suggestions, suggestions = _f === void 0 ? [] : _f, _g = _a.showSuggestions, showSuggestions = _g === void 0 ? false : _g, _h = _a.minimumMatchLength, minimumMatchLength = _h === void 0 ? 2 : _h, _j = _a.maximumMatchesShown, maximumMatchesShown = _j === void 0 ? 5 : _j, _k = _a.isLarge, isLarge = _k === void 0 ? false : _k, _l = _a.hasAdjacentButton, hasAdjacentButton = _l === void 0 ? false : _l, onSelect = _a.onSelect, onChange = _a.onChange;
3783
+ var _b = _a.id, id = _b === void 0 ? 'autocomplete' : _b, _c = _a.name, name = _c === void 0 ? 'autocomplete' : _c, labelText = _a.labelText, _d = _a.hasHiddenLabel, hasHiddenLabel = _d === void 0 ? false : _d, value = _a.value, size = _a.size, placeholder = _a.placeholder, _e = _a.isErrored, isErrored = _e === void 0 ? false : _e, errorText = _a.errorText, _f = _a.suggestions, suggestions = _f === void 0 ? [] : _f, _g = _a.showSuggestions, showSuggestions = _g === void 0 ? false : _g, _h = _a.minimumMatchLength, minimumMatchLength = _h === void 0 ? 2 : _h, _j = _a.maximumMatchesShown, maximumMatchesShown = _j === void 0 ? 5 : _j, _k = _a.isLarge, isLarge = _k === void 0 ? false : _k, _l = _a.hasAdjacentButton, hasAdjacentButton = _l === void 0 ? false : _l, onSelect = _a.onSelect, onChange = _a.onChange;
3786
3784
  /**
3787
3785
  * We save the input value in state or we can't cope with leaving the input
3788
3786
  * without selecting a matching suggestion.
@@ -3812,12 +3810,13 @@ var Autocomplete = function (_a) {
3812
3810
  * don't, so we can apply different styling to highlight the match(es).
3813
3811
  */
3814
3812
  function getItemTextChunks(item, input) {
3815
- var regex = new RegExp("(" + input + ")", "ig");
3813
+ var escapedInput = input.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
3814
+ var regex = new RegExp('(' + escapedInput + ')', 'ig');
3816
3815
  var chunks = item.split(regex);
3817
3816
  var results = [];
3818
3817
  var key = 1;
3819
3818
  chunks.forEach(function (chunk) {
3820
- if (chunk !== "") {
3819
+ if (chunk !== '') {
3821
3820
  if (chunk.toLowerCase() === input.toLowerCase()) {
3822
3821
  results.push(React.createElement(AutocompleteSuggestionTextMatch, { key: key++ }, chunk));
3823
3822
  }
@@ -3856,11 +3855,11 @@ var Autocomplete = function (_a) {
3856
3855
  * a suggestion.
3857
3856
  */
3858
3857
  return (React.createElement(React.Fragment, null,
3859
- React.createElement(Downshift$1, { id: id, labelId: id + "-label", inputId: id + "-input", menuId: id + "-menu", onStateChange: handleStateChange, selectedItem: inputvalue ? inputvalue : "", initialIsOpen: showSuggestions }, function (_a) {
3858
+ React.createElement(Downshift$1, { id: id, labelId: id + '-label', inputId: id + '-input', menuId: id + '-menu', onStateChange: handleStateChange, selectedItem: inputvalue ? inputvalue : '', initialIsOpen: showSuggestions }, function (_a) {
3860
3859
  var getInputProps = _a.getInputProps, getItemProps = _a.getItemProps, getLabelProps = _a.getLabelProps, getMenuProps = _a.getMenuProps, isOpen = _a.isOpen, inputValue = _a.inputValue, getRootProps = _a.getRootProps;
3861
3860
  return (React.createElement("div", null,
3862
3861
  React.createElement(AutocompleteLabel, __assign$2({}, getLabelProps(), { hasHiddenLabel: hasHiddenLabel }), labelText ? labelText : placeholder),
3863
- isErrored && errorText ? React.createElement(ErrorText, null, errorText) : "",
3862
+ isErrored && errorText ? React.createElement(ErrorText, null, errorText) : '',
3864
3863
  React.createElement("div", __assign$2({}, getRootProps(undefined, { suppressRefError: true })),
3865
3864
  React.createElement(AutocompleteTextInput, __assign$2({}, getInputProps({
3866
3865
  name: name,
@@ -3870,24 +3869,22 @@ var Autocomplete = function (_a) {
3870
3869
  isOpen: isOpen && filteredsuggestions.length > 0,
3871
3870
  isLarge: isLarge,
3872
3871
  hasAdjacentButton: hasAdjacentButton,
3873
- size: size
3872
+ size: size,
3874
3873
  })))),
3875
3874
  // can't rely just on isOpen or we can end up displaying an empty suggestions list
3876
- isOpen && filteredsuggestions.length > 0 ?
3877
- React.createElement(AutocompleteSuggestionList, __assign$2({}, getMenuProps({
3878
- 'aria-labelledby': null,
3879
- 'aria-label': "Suggestion",
3880
- title: "Suggestion"
3881
- }), { isLarge: isLarge }),
3882
- // Here we are turning our filtered suggestions into list items
3883
- filteredsuggestions.map(function (item, index) {
3884
- return (React.createElement(AutocompleteSuggestionItem, __assign$2({}, getItemProps({
3885
- key: item,
3886
- index: index,
3887
- item: item
3888
- }), { isLarge: isLarge }), getItemTextChunks(item, inputValue)));
3889
- }))
3890
- : ''));
3875
+ isOpen && filteredsuggestions.length > 0 ? (React.createElement(AutocompleteSuggestionList, __assign$2({}, getMenuProps({
3876
+ 'aria-labelledby': null,
3877
+ 'aria-label': 'Suggestion',
3878
+ title: 'Suggestion',
3879
+ }), { isLarge: isLarge }),
3880
+ // Here we are turning our filtered suggestions into list items
3881
+ filteredsuggestions.map(function (item, index) {
3882
+ return (React.createElement(AutocompleteSuggestionItem, __assign$2({}, getItemProps({
3883
+ key: item,
3884
+ index: index,
3885
+ item: item,
3886
+ }), { isLarge: isLarge }), getItemTextChunks(item, inputValue)));
3887
+ }))) : ('')));
3891
3888
  })));
3892
3889
  };
3893
3890
 
@@ -5561,10 +5558,10 @@ var HeadingWithIcon = function (_a) {
5561
5558
  };
5562
5559
 
5563
5560
  const Container$T = styled.div`
5564
- ${props => props.theme.fontStyles};
5561
+ ${(props) => props.theme.fontStyles};
5565
5562
  display: block;
5566
- border-top: 1px solid ${props => props.theme.theme_vars.colours.grey};
5567
- padding-top: ${props => props.theme.theme_vars.spacingSizes.small};
5563
+ border-top: 1px solid ${(props) => props.theme.theme_vars.colours.grey};
5564
+ padding-top: ${(props) => props.theme.theme_vars.spacingSizes.small};
5568
5565
  `;
5569
5566
 
5570
5567
  const resetButtonStyles = `
@@ -5576,33 +5573,33 @@ const resetButtonStyles = `
5576
5573
 
5577
5574
  const Previous = styled.button`
5578
5575
  ${resetButtonStyles}
5579
- ${props => props.theme.fontStyles}
5580
- ${props => props.theme.linkStyles}
5576
+ ${(props) => props.theme.fontStyles}
5577
+ ${(props) => props.theme.linkStyles}
5581
5578
 
5582
5579
  &:hover {
5583
- ${props => props.theme.linkStylesHover}
5580
+ ${(props) => props.theme.linkStylesHover}
5584
5581
  }
5585
5582
  &:focus {
5586
- ${props => props.theme.linkStylesFocus}
5583
+ ${(props) => props.theme.linkStylesFocus}
5587
5584
  }
5588
5585
  &:active {
5589
- ${props => props.theme.linkStylesActive}
5586
+ ${(props) => props.theme.linkStylesActive}
5590
5587
  }
5591
5588
  `;
5592
5589
 
5593
5590
  const Next = styled.button`
5594
5591
  ${resetButtonStyles}
5595
- ${props => props.theme.fontStyles}
5596
- ${props => props.theme.linkStyles}
5592
+ ${(props) => props.theme.fontStyles}
5593
+ ${(props) => props.theme.linkStyles}
5597
5594
 
5598
5595
  &:hover {
5599
- ${props => props.theme.linkStylesHover}
5596
+ ${(props) => props.theme.linkStylesHover}
5600
5597
  }
5601
5598
  &:focus {
5602
- ${props => props.theme.linkStylesFocus}
5599
+ ${(props) => props.theme.linkStylesFocus}
5603
5600
  }
5604
5601
  &:active {
5605
- ${props => props.theme.linkStylesActive}
5602
+ ${(props) => props.theme.linkStylesActive}
5606
5603
  }
5607
5604
  `;
5608
5605
 
@@ -5622,27 +5619,28 @@ const NumberContainer = styled.li`
5622
5619
  }
5623
5620
  `;
5624
5621
 
5625
-
5626
5622
  const Number$1 = styled.button`
5627
5623
  ${resetButtonStyles}
5628
5624
  padding: 8px 12px;
5629
- ${props => props.theme.fontStyles}
5630
- ${props => props.theme.linkStyles}
5625
+ ${(props) => props.theme.fontStyles}
5626
+ ${(props) => props.theme.linkStyles}
5631
5627
 
5632
5628
  &:hover {
5633
- ${props => props.theme.linkStylesHover}
5629
+ ${(props) => props.theme.linkStylesHover}
5634
5630
  }
5635
5631
  &:focus {
5636
- ${props => props.theme.linkStylesFocus}
5632
+ ${(props) => props.theme.linkStylesFocus}
5637
5633
  }
5638
5634
  &:active {
5639
- ${props => props.theme.linkStylesActive}
5635
+ ${(props) => props.theme.linkStylesActive}
5640
5636
  }
5641
5637
 
5642
- text-decoration: ${props => props.isCurrent ? 'none' : 'underline'};
5643
- font-weight: ${props => props.isCurrent ? 'normal' : '700'};
5638
+ text-decoration: ${(props) => (props.isCurrent ? 'none' : 'underline')};
5639
+ font-weight: ${(props) => (props.isCurrent ? 'normal' : '700')};
5644
5640
  `;
5645
5641
 
5642
+ const Ellipsis = styled.span``;
5643
+
5646
5644
  const VisuallyHidden$1 = styled.span`
5647
5645
  position: absolute !important;
5648
5646
  width: 1px !important;
@@ -6285,12 +6283,19 @@ var Uri = Uri$1.exports;
6285
6283
  };
6286
6284
 
6287
6285
  var Pagination = function (_a) {
6288
- var currentPage = _a.currentPage, totalResults = _a.totalResults, resultsPerPage = _a.resultsPerPage, _b = _a.postTo, postTo = _b === void 0 ? "search" : _b;
6289
- // support for ...
6290
- var pagination = function (c, m) {
6291
- var current = c, last = m, delta = 2, left = current - delta, right = current + delta + 1, range = [], rangeWithDots = [], l;
6286
+ var currentPage = _a.currentPage, totalResults = _a.totalResults, resultsPerPage = _a.resultsPerPage, _b = _a.postTo, postTo = _b === void 0 ? 'search' : _b;
6287
+ // given current page number and max page number, return list of numbers to display with ... to reduce range visible
6288
+ var pagination = function (currentPage, maxPage) {
6289
+ var current = currentPage;
6290
+ var last = maxPage;
6291
+ var delta = 2;
6292
+ var left = current - delta;
6293
+ var right = current + delta + 1;
6294
+ var range = [];
6295
+ var rangeWithDots = [];
6296
+ var l;
6292
6297
  for (var i = 1; i <= last; i++) {
6293
- if (i == 1 || i == last || i >= left && i < right) {
6298
+ if (i == 1 || i == last || (i >= left && i < right)) {
6294
6299
  range.push(i);
6295
6300
  }
6296
6301
  }
@@ -6309,27 +6314,29 @@ var Pagination = function (_a) {
6309
6314
  }
6310
6315
  return rangeWithDots;
6311
6316
  };
6312
- if (resultsPerPage === undefined)
6317
+ if (resultsPerPage === undefined) {
6313
6318
  resultsPerPage = 10;
6319
+ }
6314
6320
  var numberOfNumbers = Math.ceil(totalResults / resultsPerPage);
6315
- Array.from({ length: numberOfNumbers }, function (v, i) { return i + 1; });
6321
+ if (currentPage < 1) {
6322
+ currentPage = 1;
6323
+ }
6324
+ else if (currentPage > numberOfNumbers) {
6325
+ currentPage = numberOfNumbers;
6326
+ }
6316
6327
  var numbers = pagination(currentPage, numberOfNumbers);
6317
- // const numbers = allNumbers;
6318
6328
  var buttonClick = function (pageNo) {
6319
6329
  handleParams(postTo, [{ key: 'page', value: pageNo }]);
6320
6330
  };
6321
6331
  if (numbers.length > 1) {
6322
6332
  return (React.createElement(Container$T, { "data-testid": "Pagination", role: "navigation", "aria-label": "Pagination" },
6323
- currentPage !== 1 &&
6324
- React.createElement(Previous, { onClick: function () { return buttonClick(currentPage - 1); }, title: "Go back a page" }, "Previous"),
6325
- React.createElement(NumbersContainer, null, numbers.map(function (v, i) {
6326
- return React.createElement(NumberContainer, { key: i },
6327
- React.createElement(Number$1, { onClick: function () { return buttonClick(v); }, isCurrent: currentPage === v, title: currentPage === v ? "This is the current page" : v === "..." ? "See more pages" : ("Go to page " + v) },
6328
- React.createElement(VisuallyHidden$1, null, "Page "),
6329
- v));
6330
- })),
6331
- currentPage < numberOfNumbers &&
6332
- React.createElement(Next, { onClick: function () { return buttonClick(currentPage + 1); }, title: "Go forward a page" }, "Next")));
6333
+ currentPage > 1 && (React.createElement(Previous, { onClick: function () { return buttonClick(currentPage - 1); }, title: "Go back a page" }, "Previous")),
6334
+ React.createElement(NumbersContainer, null, numbers.map(function (v, i) { return (React.createElement(NumberContainer, { key: i },
6335
+ v === '...' && (React.createElement(Ellipsis, null, "...")),
6336
+ 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 },
6337
+ React.createElement(VisuallyHidden$1, null, "Page "),
6338
+ v)))); })),
6339
+ currentPage < numberOfNumbers && (React.createElement(Next, { onClick: function () { return buttonClick(currentPage + 1); }, title: "Go forward a page" }, "Next"))));
6333
6340
  }
6334
6341
  return null;
6335
6342
  };
@@ -7082,10 +7089,21 @@ const Container$M = styled.div`
7082
7089
  const Content$3 = styled.div`
7083
7090
  padding: ${(props) => props.theme.theme_vars.spacingSizes.medium};
7084
7091
  flex-grow: 1;
7092
+
7093
+ p:last-of-type {
7094
+ margin-bottom: 0;
7095
+ }
7085
7096
  `;
7086
7097
 
7087
7098
  const Image$4 = styled.img`
7088
7099
  width: 100%;
7100
+ vertical-align: bottom;
7101
+ `;
7102
+
7103
+ const ImageLink$1 = styled.a`
7104
+ &:hover {
7105
+ box-shadow: 1px 1px 5px 1px rgba(0, 0, 0, 0.2);
7106
+ }
7089
7107
  `;
7090
7108
 
7091
7109
  const Header$1 = styled.div`
@@ -7095,7 +7113,7 @@ const Header$1 = styled.div`
7095
7113
  `;
7096
7114
 
7097
7115
  const Footer$1 = styled.div`
7098
- margin-top: ${(props) => props.theme.theme_vars.spacingSizes.small};
7116
+ margin-top: 0;
7099
7117
  padding: ${(props) => props.theme.theme_vars.spacingSizes.small}
7100
7118
  ${(props) => props.theme.theme_vars.spacingSizes.medium} ${(props) => props.theme.theme_vars.spacingSizes.medium};
7101
7119
 
@@ -19912,7 +19930,8 @@ var Card = function (_a) {
19912
19930
  var header = _a.header, content = _a.content, footerLink = _a.footerLink, imageLarge = _a.imageLarge, imageSmall = _a.imageSmall, imageAltText = _a.imageAltText;
19913
19931
  var showContent = content || header;
19914
19932
  return (React.createElement(Container$M, { "data-testid": "Card" },
19915
- imageLarge && imageSmall && (React.createElement(Image$4, { src: imageLarge, alt: imageAltText, srcSet: "".concat(imageSmall, " 400w, ").concat(imageLarge, " 800w"), sizes: "(max-width: 550px) 400px, 800px", loading: "lazy" })),
19933
+ imageLarge && imageSmall && (React.createElement(React.Fragment, null, footerLink ? (React.createElement(ImageLink$1, { href: footerLink.url },
19934
+ React.createElement(Image$4, { src: imageLarge, alt: imageAltText, srcSet: "".concat(imageSmall, " 400w, ").concat(imageLarge, " 800w"), sizes: "(max-width: 550px) 400px, 800px", loading: "lazy" }))) : (React.createElement(Image$4, { src: imageLarge, alt: imageAltText, srcSet: "".concat(imageSmall, " 400w, ").concat(imageLarge, " 800w"), sizes: "(max-width: 550px) 400px, 800px", loading: "lazy" })))),
19916
19935
  showContent && (React.createElement(Content$3, null,
19917
19936
  header && (React.createElement(Header$1, null,
19918
19937
  React.createElement(Heading, { text: header, level: 3 }))),
@@ -22342,6 +22361,8 @@ const FooterList = styled.ul`
22342
22361
 
22343
22362
  const FooterListItem = styled.li`
22344
22363
  display: inline-block;
22364
+ left: 0;
22365
+ padding-right: 0;
22345
22366
  margin-right: 25px;
22346
22367
  margin-bottom: 15px;
22347
22368
  `;
@@ -23088,7 +23109,7 @@ var HeroImage = function (_a) {
23088
23109
  return (React.createElement(React.Fragment, null,
23089
23110
  React.createElement(LazyImage, { src: imageLarge, placeholder: imageSmall, visibilitySensorProps: {
23090
23111
  partialVisibility: true,
23091
- } }, function (src, loading) { return (React.createElement(Container$o, { image: src, loading: loading.toString(), backgroundBox: backgroundBox, "data-testid": "HeroImage" },
23112
+ } }, function (src) { return (React.createElement(Container$o, { image: src, backgroundBox: backgroundBox, "data-testid": "HeroImage" },
23092
23113
  React.createElement(InnerContainer, null,
23093
23114
  React.createElement(Overlay, { backgroundBox: backgroundBox, "data-testid": "HeroImageOverlay" },
23094
23115
  breadcrumb && (React.createElement(BreadcrumbLink, { href: breadcrumb.url, backgroundBox: backgroundBox }, breadcrumb.title)),