@nnc-digital/nnc-design-system 0.4.33 → 0.4.34

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.
@@ -299,6 +299,21 @@ const AutocompleteSuggestionTextMatch = styled.span`
299
299
  font-weight: bold;
300
300
  `;
301
301
 
302
+ const LightErrorText = styled.p`
303
+ ${(props) => props.theme.fontStyles}
304
+ color: ${(props) => props.theme.theme_vars.colours.white};
305
+ font-weight: bold;
306
+ margin-bottom: 5px;
307
+ font-size: 14px;
308
+ font-size: 0.8rem;
309
+ line-height: 1.1;
310
+ @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
311
+ font-size: 18px;
312
+ font-size: 1rem;
313
+ line-height: 1.25;
314
+ }
315
+ `;
316
+
302
317
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
303
318
 
304
319
  function getDefaultExportFromCjs (x) {
@@ -3732,12 +3747,12 @@ process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
3732
3747
  * click on to select. If viewing in Storybook, try typing the name of a fruit in the story examples.
3733
3748
  */
3734
3749
  var Autocomplete = function (_a) {
3735
- 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;
3750
+ 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, _m = _a.required, required = _m === void 0 ? false : _m, _o = _a.hasLightBackground, hasLightBackground = _o === void 0 ? true : _o;
3736
3751
  /**
3737
3752
  * We save the input value in state or we can't cope with leaving the input
3738
3753
  * without selecting a matching suggestion.
3739
3754
  */
3740
- var _m = useState(value), inputvalue = _m[0], setInputValue = _m[1];
3755
+ var _p = useState(value), inputvalue = _p[0], setInputValue = _p[1];
3741
3756
  /**
3742
3757
  * For component state changes that affect the input value, we copy the
3743
3758
  * value into our saved state, and fire the onSelect handler if the change
@@ -3811,7 +3826,7 @@ var Autocomplete = function (_a) {
3811
3826
  var getInputProps = _a.getInputProps, getItemProps = _a.getItemProps, getLabelProps = _a.getLabelProps, getMenuProps = _a.getMenuProps, isOpen = _a.isOpen, inputValue = _a.inputValue, getRootProps = _a.getRootProps;
3812
3827
  return (React.createElement("div", null,
3813
3828
  React.createElement(AutocompleteLabel, __assign$2({}, getLabelProps(), { hasHiddenLabel: hasHiddenLabel }), labelText ? labelText : placeholder),
3814
- isErrored && errorText ? React.createElement(ErrorText$1, null, errorText) : '',
3829
+ isErrored && errorText && (React.createElement(React.Fragment, null, hasLightBackground ? (React.createElement(ErrorText$1, null, errorText)) : (React.createElement(LightErrorText, null, errorText)))),
3815
3830
  React.createElement("div", __assign$2({}, getRootProps(undefined, { suppressRefError: true })),
3816
3831
  React.createElement(AutocompleteTextInput, __assign$2({}, getInputProps({
3817
3832
  name: name,
@@ -3822,7 +3837,7 @@ var Autocomplete = function (_a) {
3822
3837
  isLarge: isLarge,
3823
3838
  hasAdjacentButton: hasAdjacentButton,
3824
3839
  size: size,
3825
- })))),
3840
+ }), { "aria-required": required ? 'true' : 'false', "aria-invalid": isErrored ? 'true' : 'false' }))),
3826
3841
  // can't rely just on isOpen or we can end up displaying an empty suggestions list
3827
3842
  isOpen && filteredsuggestions.length > 0 ? (React.createElement(AutocompleteSuggestionList, __assign$2({}, getMenuProps({
3828
3843
  'aria-labelledby': null,
@@ -4152,9 +4167,9 @@ const StyledButton = styled.button`
4152
4167
  * Primary UI component for user interaction
4153
4168
  */
4154
4169
  var FormButton = function (_a) {
4155
- var _b = _a.primary, primary = _b === void 0 ? true : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, text = _a.text; _a.type; _a.isDisabled; var props = __rest(_a, ["primary", "size", "text", "type", "isDisabled"]);
4170
+ var _b = _a.primary, primary = _b === void 0 ? true : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, text = _a.text, _d = _a.type, type = _d === void 0 ? "submit" : _d; _a.isDisabled; var props = __rest(_a, ["primary", "size", "text", "type", "isDisabled"]);
4156
4171
  var mode = primary ? 'button--primary' : 'button--secondary';
4157
- return (React.createElement(StyledButton, __assign$2({ className: ["button--".concat(size), mode].join(' ') }, props), text));
4172
+ return (React.createElement(StyledButton, __assign$2({ type: type, className: ["button--".concat(size), mode].join(' ') }, props), text));
4158
4173
  };
4159
4174
 
4160
4175
  const Container$15 = styled.div`
@@ -4497,7 +4512,7 @@ var BinCollection = function (_a) {
4497
4512
  React.createElement(VisuallyHiddenLabel, { id: "postcode-label", htmlFor: "postcode-input" }, "Enter a postcode"),
4498
4513
  React.createElement(StyledTextInput, { type: "text", placeholder: "Enter a postcode", name: "postcode", id: "postcode-input", isErrored: isError, "aria-labelledby": "postcode-label", autoComplete: "postal-code" }),
4499
4514
  React.createElement(BinCollectionButtonStyles, null,
4500
- React.createElement(FormButton, { size: "large", type: "submit", "aria-label": "Submit", text: "Find" }))))),
4515
+ React.createElement(FormButton, { size: "large", "aria-label": "Submit", text: "Find" }))))),
4501
4516
  addressOptions.length > 0 && (React.createElement(DropDownSelectContainer, null,
4502
4517
  React.createElement(DropDownSelect, { onChange: handleAddressChange, id: "address", label: "Select your address", options: __spreadArray([{ title: 'Select an address', value: '' }], addressOptions, true) }))),
4503
4518
  noResultsFound && React.createElement("p", null, "No results found."),
@@ -24119,7 +24134,7 @@ var BackLink = function (_a) {
24119
24134
  };
24120
24135
 
24121
24136
  const Container$B = styled.div`
24122
- padding-top: 20px;
24137
+ padding-top: 15px;
24123
24138
  border-bottom: 1px solid ${(props) => props.theme.theme_vars.colours.grey}80;
24124
24139
  margin-bottom: ${(props) => (props.hasMargin ? props.theme.theme_vars.spacingSizes.large : 0)};
24125
24140
  `;
@@ -24135,7 +24150,7 @@ const List$2 = styled.ol`
24135
24150
 
24136
24151
  const Crumb = styled.li`
24137
24152
  margin-right: ${(props) => props.theme.theme_vars.spacingSizes.small};
24138
- margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.small};
24153
+ margin-bottom: 0;
24139
24154
  display: none;
24140
24155
  left: 0;
24141
24156
  padding-right: 0;
@@ -24164,6 +24179,7 @@ const BreadcrumbLink$1 = styled.a`
24164
24179
  ${(props) => props.theme.linkStyles}
24165
24180
  font-weight: 400;
24166
24181
  display: inline-block;
24182
+ padding: ${(props) => props.theme.theme_vars.spacingSizes.small} 0;
24167
24183
 
24168
24184
  svg {
24169
24185
  fill: ${(props) => props.theme.theme_vars.colours.action};
@@ -24186,7 +24202,7 @@ const BreadcrumbLink$1 = styled.a`
24186
24202
  var Breadcrumbs = function (_a) {
24187
24203
  var breadcrumbsArray = _a.breadcrumbsArray, _b = _a.hasMargin, hasMargin = _b === void 0 ? false : _b;
24188
24204
  return (React.createElement(Container$B, { hasMargin: hasMargin, "data-testid": "Breadcrumbs" },
24189
- React.createElement(List$2, null, breadcrumbsArray.map(function (crumb) { return (React.createElement(Crumb, { key: crumb.title }, React.createElement(React.Fragment, null,
24205
+ React.createElement(List$2, { as: breadcrumbsArray.length === 1 ? 'div' : 'ol' }, breadcrumbsArray.map(function (crumb) { return (React.createElement(Crumb, { key: crumb.title, as: breadcrumbsArray.length === 1 ? 'span' : 'li' }, React.createElement(React.Fragment, null,
24190
24206
  React.createElement(BreadcrumbLink$1, { href: crumb.url, title: crumb.title }, crumb.title),
24191
24207
  React.createElement(IconWrapper$4, null,
24192
24208
  React.createElement(ChevronIcon, { direction: 'right', colourFill: "#C6C6C6" }))))); }))));
@@ -24365,10 +24381,6 @@ const FooterList = styled.ul`
24365
24381
  margin-bottom: 25px;
24366
24382
  list-style-type: none;
24367
24383
 
24368
- li:last-of-type {
24369
- margin-bottom: 0;
24370
- }
24371
-
24372
24384
  @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.s}) {
24373
24385
  margin-bottom: 0px;
24374
24386
  }
@@ -24378,8 +24390,15 @@ const FooterListItem = styled.li`
24378
24390
  display: inline-block;
24379
24391
  left: 0;
24380
24392
  padding-right: 0;
24381
- margin-right: 25px;
24382
- margin-bottom: 15px;
24393
+ margin-right: 0;
24394
+ margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.small};
24395
+ width: 100%;
24396
+
24397
+ @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
24398
+ width: auto;
24399
+ margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.medium};
24400
+ margin-right: ${(props) => props.theme.theme_vars.spacingSizes.small};
24401
+ }
24383
24402
  `;
24384
24403
 
24385
24404
  const SocialLinks = styled.ul`
@@ -24393,8 +24412,8 @@ const SocialLinkItem = styled.li`
24393
24412
  `;
24394
24413
 
24395
24414
  const SocialLinkSingle = styled.a`
24396
- display: inline-block;
24397
- height: 36px;
24415
+ display: block;
24416
+ padding: ${(props) => props.theme.theme_vars.spacingSizes.extra_small};
24398
24417
 
24399
24418
  &:hover {
24400
24419
  opacity: 0.8;
@@ -24426,9 +24445,16 @@ const SocialLinkSingle = styled.a`
24426
24445
  `;
24427
24446
 
24428
24447
  const FooterLink = styled.a`
24448
+ display: block;
24429
24449
  ${(props) => props.theme.linkStyles}
24430
24450
  color: ${(props) => props.theme.theme_vars.colours.white};
24431
24451
  font-weight: 400;
24452
+ padding: ${(props) =>
24453
+ `${props.theme.theme_vars.spacingSizes.small} ${props.theme.theme_vars.spacingSizes.extra_small}`};
24454
+
24455
+ @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
24456
+ display: inline-block;
24457
+ }
24432
24458
 
24433
24459
  &:hover {
24434
24460
  ${(props) => props.theme.linkStylesHover}
@@ -24766,8 +24792,8 @@ var NorthColouredLogo = function () {
24766
24792
  };
24767
24793
 
24768
24794
  const Container$v = styled.div`
24769
- ${props => props.theme.fontStyles}
24770
- width: calc(100% - ${ props => props.isLarge ? "5rem" : "3rem"});
24795
+ ${(props) => props.theme.fontStyles}
24796
+ width: calc(100% - ${(props) => (props.isLarge ? '5rem' : '3rem')});
24771
24797
  `;
24772
24798
 
24773
24799
  styled.label`
@@ -24792,41 +24818,44 @@ const InputWrapper = styled.div`
24792
24818
  const Button$3 = styled.button`
24793
24819
  position: absolute;
24794
24820
  top: 0;
24795
- right: ${ props => props.isLarge ? "-5rem" : "-3rem"};
24821
+ right: ${(props) => (props.isLarge ? '-5rem' : '-3rem')};
24796
24822
  cursor: pointer;
24797
24823
  margin: 0;
24798
- padding: ${props => props.theme.theme_vars.spacingSizes.small};
24799
- background: ${props => props.isLight ? props.theme.theme_vars.colours.action : props.theme.theme_vars.colours.grey_darkest};
24800
- color: ${props => props.theme.theme_vars.colours.white};
24824
+ margin-top: ${(props) => (props.isErrored ? '25px' : 0)};
24825
+ padding: ${(props) => props.theme.theme_vars.spacingSizes.small};
24826
+ background: ${(props) =>
24827
+ props.isLight ? props.theme.theme_vars.colours.action : props.theme.theme_vars.colours.grey_darkest};
24828
+ color: ${(props) => props.theme.theme_vars.colours.white};
24801
24829
  border: 1px solid transparent;
24802
- border-top-right-radius: calc(${props => props.theme.theme_vars.border_radius} * 2);
24803
- border-bottom-right-radius: calc(${props => props.theme.theme_vars.border_radius} * 2);
24804
- width: ${props => props.isLarge ? "5rem" : "3rem"};
24830
+ border-top-right-radius: calc(${(props) => props.theme.theme_vars.border_radius} * 2);
24831
+ border-bottom-right-radius: calc(${(props) => props.theme.theme_vars.border_radius} * 2);
24832
+ width: ${(props) => (props.isLarge ? '5rem' : '3rem')};
24805
24833
  text-align: center;
24806
- height: ${ props => props.isLarge ? "2.9rem" : "2.28rem"};
24807
- @media screen and (min-width: ${ props => props.theme.theme_vars.breakpoints.m}) {
24808
- height: ${ props => props.isLarge ? "3.22rem" : "2.6rem"};
24834
+ height: ${(props) => (props.isLarge ? '2.9rem' : '2.28rem')};
24835
+ @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
24836
+ height: ${(props) => (props.isLarge ? '3.22rem' : '2.6rem')};
24809
24837
  }
24810
24838
 
24811
24839
  &:hover {
24812
- background: ${props => props.isLight? props.theme.theme_vars.colours.action_dark : props.theme.theme_vars.colours.black};
24840
+ background: ${(props) =>
24841
+ props.isLight ? props.theme.theme_vars.colours.action_dark : props.theme.theme_vars.colours.black};
24813
24842
  }
24814
24843
 
24815
24844
  &:focus {
24816
24845
  outline: none;
24817
- background: ${props => props.theme.theme_vars.colours.focus};
24846
+ background: ${(props) => props.theme.theme_vars.colours.focus};
24818
24847
  svg {
24819
- path{
24820
- fill: ${props => props.theme.theme_vars.colours.black};
24848
+ path {
24849
+ fill: ${(props) => props.theme.theme_vars.colours.black};
24821
24850
  }
24822
24851
  }
24823
24852
  }
24824
24853
 
24825
24854
  &:active {
24826
24855
  transform: translateY(1px);
24827
- background-color: ${props => props.theme.theme_vars.colours.focus};
24828
- box-shadow: 0px -1px 0px 0px ${props => props.theme.theme_vars.colours.black};
24829
- border-top-color: ${props => props.theme.theme_vars.colours.black};
24856
+ background-color: ${(props) => props.theme.theme_vars.colours.focus};
24857
+ box-shadow: 0px -1px 0px 0px ${(props) => props.theme.theme_vars.colours.black};
24858
+ border-top-color: ${(props) => props.theme.theme_vars.colours.black};
24830
24859
  border-bottom-color: transparent;
24831
24860
  }
24832
24861
  `;
@@ -24851,7 +24880,7 @@ var IconDownload = function (_a) {
24851
24880
  };
24852
24881
 
24853
24882
  var Searchbar = function (_a) {
24854
- var _b = _a.placeholder, placeholder = _b === void 0 ? "Search" : _b, isLight = _a.isLight, isLarge = _a.isLarge, _c = _a.searchTerm, searchTerm = _c === void 0 ? "" : _c, submitInfo = _a.submitInfo, _d = _a.id, id = _d === void 0 ? "search" : _d, _e = _a.suggestions, suggestions = _e === void 0 ? [] : _e, _f = _a.minimumMatchLength, minimumMatchLength = _f === void 0 ? 2 : _f, _g = _a.maximumMatchesShown, maximumMatchesShown = _g === void 0 ? 5 : _g;
24883
+ var _b = _a.placeholder, placeholder = _b === void 0 ? 'Search' : _b, isLight = _a.isLight, isLarge = _a.isLarge, _c = _a.searchTerm, searchTerm = _c === void 0 ? '' : _c, submitInfo = _a.submitInfo, _d = _a.id, id = _d === void 0 ? 'search' : _d, _e = _a.suggestions, suggestions = _e === void 0 ? [] : _e, _f = _a.minimumMatchLength, minimumMatchLength = _f === void 0 ? 2 : _f, _g = _a.maximumMatchesShown, maximumMatchesShown = _g === void 0 ? 5 : _g;
24855
24884
  var initialSearchTerm = searchTerm;
24856
24885
  var _h = useState(initialSearchTerm), inputSearchTerm = _h[0], setInputSearchTerm = _h[1];
24857
24886
  var _j = useState(false), submit = _j[0], setSubmit = _j[1];
@@ -24883,13 +24912,12 @@ var Searchbar = function (_a) {
24883
24912
  return;
24884
24913
  setSubmit(false);
24885
24914
  var submitParams = submitInfo.params;
24886
- if (initialSearchTerm !== inputSearchTerm ||
24887
- !(NewsArticleFilterFields.search.queryParamKey in submitParams)) {
24915
+ if (initialSearchTerm !== inputSearchTerm || !(NewsArticleFilterFields.search.queryParamKey in submitParams)) {
24888
24916
  submitParams = __assign$2(__assign$2({}, submitParams), { searchTerm: inputSearchTerm });
24889
24917
  var keyValueFormat = Object.keys(submitParams).map(function (key) {
24890
24918
  return { key: key, value: submitParams[key] };
24891
24919
  });
24892
- handleParams(submitInfo.postTo, keyValueFormat, ["page"]);
24920
+ handleParams(submitInfo.postTo, keyValueFormat, ['page']);
24893
24921
  }
24894
24922
  }, [submit, submitInfo, initialSearchTerm, inputSearchTerm, handleParams] // dependencies that this function relies upon
24895
24923
  );
@@ -24900,7 +24928,7 @@ var Searchbar = function (_a) {
24900
24928
  var handleSubmit = function (event) {
24901
24929
  if (event)
24902
24930
  event.preventDefault();
24903
- if (inputSearchTerm == "") {
24931
+ if (inputSearchTerm == '') {
24904
24932
  if (!isErrored) {
24905
24933
  setIsErrored(true);
24906
24934
  }
@@ -24915,8 +24943,8 @@ var Searchbar = function (_a) {
24915
24943
  React.createElement("form", { onSubmit: handleSubmit },
24916
24944
  React.createElement("div", { role: "search" },
24917
24945
  React.createElement(InputWrapper, null,
24918
- React.createElement(Autocomplete, { id: id, name: NewsArticleFilterFields.search.queryParamKey, placeholder: placeholder, onSelect: handleSelect, onChange: handleChange, value: inputSearchTerm, suggestions: suggestions, minimumMatchLength: minimumMatchLength, maximumMatchesShown: maximumMatchesShown, isLarge: isLarge, hasAdjacentButton: true, isErrored: isErrored, hasHiddenLabel: true }),
24919
- React.createElement(Button$3, { type: "submit", value: "Search", isLarge: isLarge, isLight: isLight, "data-testid": "SearchButton" },
24946
+ React.createElement(Autocomplete, { id: id, name: NewsArticleFilterFields.search.queryParamKey, placeholder: placeholder, onSelect: handleSelect, onChange: handleChange, value: inputSearchTerm, suggestions: suggestions, minimumMatchLength: minimumMatchLength, maximumMatchesShown: maximumMatchesShown, isLarge: isLarge, hasAdjacentButton: true, isErrored: isErrored, hasHiddenLabel: true, required: true, errorText: "The search field is required.", hasLightBackground: isLight }),
24947
+ React.createElement(Button$3, { type: "submit", value: "Search", isLarge: isLarge, isLight: isLight, isErrored: isErrored, "data-testid": "SearchButton" },
24920
24948
  React.createElement(IconDownload, { colourFill: "#fff" }),
24921
24949
  React.createElement(ButtonText$2, null, "Search")))))));
24922
24950
  };
@@ -24974,7 +25002,7 @@ var Header = function (_a) {
24974
25002
  hasNewsLink && (React.createElement(Link$1, { href: "/news" }, "News")),
24975
25003
  allServicesLink && (React.createElement(Link$1, { href: isHomepage ? '#all-services' : allServicesLink + '#all-services' }, "All services")))),
24976
25004
  !hideSearchBar && (React.createElement(SearchWrapper, null,
24977
- React.createElement(Searchbar, { isLight: themeContext.cardinal_name === 'north' ? true : false, submitInfo: {
25005
+ React.createElement(Searchbar, { isLight: themeContext.cardinal_name === 'north' ? true : false, isLarge: true, submitInfo: {
24978
25006
  postTo: '/search',
24979
25007
  params: {
24980
25008
  type: 'search',