northants-design-system 0.2.25 → 0.2.28

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.
@@ -7065,23 +7065,11 @@ const Container$P = styled.div`
7065
7065
  const Row$1 = styled.div`
7066
7066
  margin-bottom: 15px;
7067
7067
  border-bottom: 1px solid ${(props) => props.theme.theme_vars.colours.grey};
7068
- display: grid;
7069
- grid-template-columns: minmax(80px, min-content) 1fr;
7070
- grid-template-rows: 1fr;
7071
- gap: 0px 1em;
7072
- grid-template-areas: 'letter data';
7073
7068
  `;
7074
7069
 
7075
7070
  const Letter = styled.div`
7076
7071
  text-transform: uppercase;
7077
7072
  ${(props) => props.theme.theme_vars.h1}
7078
- grid-area: letter;
7079
- `;
7080
-
7081
- const Data = styled.div`
7082
- padding: 15px;
7083
- column-count: 2;
7084
- column-gap: 15px;
7085
7073
  `;
7086
7074
 
7087
7075
  const Link$4 = styled.a`
@@ -7170,6 +7158,78 @@ const ErrorText = styled.p`
7170
7158
  }
7171
7159
  `;
7172
7160
 
7161
+ const calculateWidth = (size) => {
7162
+ switch (size) {
7163
+ case 'full':
7164
+ return css`
7165
+ width: 100%;
7166
+ `;
7167
+ case 'one-half':
7168
+ return css`
7169
+ width: 50%;
7170
+ `;
7171
+ case 'one-third':
7172
+ return css`
7173
+ width: 33.333%;
7174
+ `;
7175
+ case 'two-thirds':
7176
+ return css`
7177
+ width: 66.666%;
7178
+ `;
7179
+ case 'one-quarter':
7180
+ return css`
7181
+ width: 25%;
7182
+ `;
7183
+ case 'three-quarters':
7184
+ return css`
7185
+ width: 75%;
7186
+ `;
7187
+ }
7188
+ };
7189
+
7190
+ const widths = (props) => {
7191
+ return css`
7192
+ ${calculateWidth(props.small)};
7193
+
7194
+ @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
7195
+ ${calculateWidth(props.medium)};
7196
+ }
7197
+
7198
+ @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.l}) {
7199
+ ${calculateWidth(props.large)};
7200
+ }
7201
+ `;
7202
+ };
7203
+
7204
+ const Container$O = styled.div`
7205
+ box-sizing: border-box;
7206
+ display: block;
7207
+ padding: ${(props) => (props.hasPadding ? props.theme.theme_vars.spacingSizes.small : `0`)};
7208
+ border: ${(props) => (props.hasBorder ? `1px solid ${props.theme.theme_vars.colours.negative}` : 'none')};
7209
+ ${widths};
7210
+ `;
7211
+
7212
+ var Column = function (_a) {
7213
+ var _b = _a.small, small = _b === void 0 ? 'full' : _b, _c = _a.medium, medium = _c === void 0 ? 'one-half' : _c, _d = _a.large, large = _d === void 0 ? 'one-third' : _d, _e = _a.hasPadding, hasPadding = _e === void 0 ? true : _e, _f = _a.hasBorder, hasBorder = _f === void 0 ? false : _f, children = _a.children;
7214
+ return (React.createElement(Container$O, { "data-testid": "Column", small: small, medium: medium, large: large, hasPadding: hasPadding, hasBorder: hasBorder }, children));
7215
+ };
7216
+
7217
+ const Container$N = styled.div`
7218
+ box-sizing: border-box;
7219
+ display: flex;
7220
+ flex-wrap: wrap;
7221
+ flex-direction: row;
7222
+ justify-content: start;
7223
+ align-items: stretch;
7224
+ margin: 0;
7225
+ border: ${(props) => (props.hasBorder ? `1px solid ${props.theme.theme_vars.colours.grey}` : 'none')};
7226
+ `;
7227
+
7228
+ var Row = function (_a) {
7229
+ var _b = _a.hasBorder, hasBorder = _b === void 0 ? false : _b, children = _a.children;
7230
+ return (React.createElement(Container$N, { "data-testid": "Row", hasBorder: hasBorder }, children));
7231
+ };
7232
+
7173
7233
  /**
7174
7234
  * An list of parishes, sorted alphabetically, containing parish council tax bands
7175
7235
  */
@@ -7177,9 +7237,26 @@ var CouncilTaxAlphabeticalDirectory = function (_a) {
7177
7237
  var financialYear = _a.financialYear, parishes = _a.parishes;
7178
7238
  var _b = useState([]), data = _b[0], setData = _b[1];
7179
7239
  var _c = useState(null), parish = _c[0], setCurrentParish = _c[1];
7240
+ var directoryRef = useRef(null);
7180
7241
  useEffect(function () {
7181
7242
  setData(formatParishData(parishes));
7182
7243
  }, []);
7244
+ var showParish = function (sortedParish) {
7245
+ setCurrentParish(sortedParish);
7246
+ directoryRef.current.scrollIntoView();
7247
+ };
7248
+ /**
7249
+ * Trim NCP or CP from the end of the parish name
7250
+ */
7251
+ var trimParishName = function (officialParish) {
7252
+ if (officialParish.endsWith('NCP')) {
7253
+ return officialParish.slice(0, -4);
7254
+ }
7255
+ if (officialParish.endsWith('CP')) {
7256
+ return officialParish.slice(0, -3);
7257
+ }
7258
+ return officialParish;
7259
+ };
7183
7260
  /**
7184
7261
  * take the data we get from the API and make it how we want it
7185
7262
  * @param data
@@ -7188,14 +7265,17 @@ var CouncilTaxAlphabeticalDirectory = function (_a) {
7188
7265
  var formatParishData = function (data) {
7189
7266
  var sortData = data.reduce(function (r, e) {
7190
7267
  // get first letter of name of current element
7191
- var group = e.banding_parish[0];
7268
+ var group = e.official_parish[0];
7192
7269
  if (!r[group]) {
7193
7270
  // there is no property in accumulator with this letter so create it
7194
- r[group] = { group: group, children: [{ title: e.banding_parish, values: e.bands }] };
7271
+ r[group] = {
7272
+ group: group,
7273
+ children: [{ title: trimParishName(e.official_parish), values: e.bands }],
7274
+ };
7195
7275
  }
7196
7276
  else {
7197
7277
  // push current element to children array for that letter
7198
- r[group].children.push({ title: e.banding_parish, values: e.bands });
7278
+ r[group].children.push({ title: trimParishName(e.official_parish), values: e.bands });
7199
7279
  }
7200
7280
  return r;
7201
7281
  }, {});
@@ -7225,12 +7305,16 @@ var CouncilTaxAlphabeticalDirectory = function (_a) {
7225
7305
  });
7226
7306
  return letterData;
7227
7307
  });
7228
- return (React.createElement(Container$P, { "data-testid": "AlphabeticalDirectory" },
7308
+ return (React.createElement(Container$P, { "data-testid": "AlphabeticalDirectory", ref: directoryRef },
7229
7309
  React.createElement(React.Fragment, null,
7230
7310
  parishes.length === 0 && (React.createElement(ErrorText, null, "There was an issue fetching the parish data. Please try again later.")),
7231
7311
  parish === null ? (React.createElement(React.Fragment, null, sortedData.map(function (letter, i) { return (React.createElement(Row$1, { key: i },
7232
- React.createElement(Letter, null, letter.group),
7233
- React.createElement(Data, null, letter.children.map(function (letterData, i) { return (React.createElement(Link$4, { onClick: function () { return setCurrentParish(letterData); }, key: i }, letterData.title)); })))); }))) : (React.createElement(React.Fragment, null,
7312
+ React.createElement(Row, null,
7313
+ React.createElement(Column, { small: "full", medium: "one-quarter", large: "one-quarter" },
7314
+ React.createElement(Letter, null, letter.group)),
7315
+ React.createElement(Column, { small: "full", medium: "three-quarters", large: "three-quarters" },
7316
+ React.createElement(Row, null, letter.children.map(function (letterData, i) { return (React.createElement(Column, { small: "one-half", medium: "one-half", large: "one-half", key: i },
7317
+ React.createElement(Link$4, { onClick: function () { return showParish(letterData); } }, letterData.title))); })))))); }))) : (React.createElement(React.Fragment, null,
7234
7318
  React.createElement(BackButton, { onClick: function () { return setCurrentParish(null); } }, "Back"),
7235
7319
  React.createElement("div", { className: "table-container" },
7236
7320
  React.createElement("table", null,
@@ -7247,25 +7331,9 @@ var CouncilTaxAlphabeticalDirectory = function (_a) {
7247
7331
  React.createElement("td", null, Number(parish.values[band]).toLocaleString('en-GB', { style: 'currency', currency: 'GBP' })))); })))))))));
7248
7332
  };
7249
7333
 
7250
- const Container$O = styled.div``;
7251
-
7252
- const Container$N = styled.div`
7253
- box-sizing: border-box;
7254
- display: flex;
7255
- flex-wrap: wrap;
7256
- flex-direction: row;
7257
- justify-content: start;
7258
- align-items: stretch;
7259
- margin: 0;
7260
- border: ${(props) => (props.hasBorder ? `1px solid ${props.theme.theme_vars.colours.grey}` : 'none')};
7261
- `;
7334
+ const Container$M = styled.div``;
7262
7335
 
7263
- var Row = function (_a) {
7264
- var _b = _a.hasBorder, hasBorder = _b === void 0 ? false : _b, children = _a.children;
7265
- return (React.createElement(Container$N, { "data-testid": "Row", hasBorder: hasBorder }, children));
7266
- };
7267
-
7268
- const Container$M = styled.div`
7336
+ const Container$L = styled.div`
7269
7337
  display: flex;
7270
7338
  flex-direction: column;
7271
7339
  justify-content: flex-start;
@@ -17061,7 +17129,7 @@ function markDirtyUp(node) {
17061
17129
  }
17062
17130
  }
17063
17131
 
17064
- class Container$L extends Node$1 {
17132
+ class Container$K extends Node$1 {
17065
17133
  push(child) {
17066
17134
  child.parent = this;
17067
17135
  this.proxyOf.nodes.push(child);
@@ -17354,7 +17422,7 @@ class Container$L extends Node$1 {
17354
17422
 
17355
17423
  let processed = nodes.map(i => {
17356
17424
  /* c8 ignore next */
17357
- if (!i[my$1]) Container$L.rebuild(i);
17425
+ if (!i[my$1]) Container$K.rebuild(i);
17358
17426
  i = i.proxyOf;
17359
17427
  if (i.parent) i.parent.removeChild(i);
17360
17428
  if (i[isClean$1]) markDirtyUp(i);
@@ -17432,23 +17500,23 @@ class Container$L extends Node$1 {
17432
17500
  }
17433
17501
  }
17434
17502
 
17435
- Container$L.registerParse = dependant => {
17503
+ Container$K.registerParse = dependant => {
17436
17504
  parse$4 = dependant;
17437
17505
  };
17438
17506
 
17439
- Container$L.registerRule = dependant => {
17507
+ Container$K.registerRule = dependant => {
17440
17508
  Rule$4 = dependant;
17441
17509
  };
17442
17510
 
17443
- Container$L.registerAtRule = dependant => {
17511
+ Container$K.registerAtRule = dependant => {
17444
17512
  AtRule$4 = dependant;
17445
17513
  };
17446
17514
 
17447
- var container = Container$L;
17448
- Container$L.default = Container$L;
17515
+ var container = Container$K;
17516
+ Container$K.default = Container$K;
17449
17517
 
17450
17518
  /* c8 ignore start */
17451
- Container$L.rebuild = node => {
17519
+ Container$K.rebuild = node => {
17452
17520
  if (node.type === 'atrule') {
17453
17521
  Object.setPrototypeOf(node, AtRule$4.prototype);
17454
17522
  } else if (node.type === 'rule') {
@@ -17463,16 +17531,16 @@ Container$L.rebuild = node => {
17463
17531
 
17464
17532
  if (node.nodes) {
17465
17533
  node.nodes.forEach(child => {
17466
- Container$L.rebuild(child);
17534
+ Container$K.rebuild(child);
17467
17535
  });
17468
17536
  }
17469
17537
  };
17470
17538
 
17471
- let Container$K = container;
17539
+ let Container$J = container;
17472
17540
 
17473
17541
  let LazyResult$4, Processor$3;
17474
17542
 
17475
- class Document$3 extends Container$K {
17543
+ class Document$3 extends Container$J {
17476
17544
  constructor(defaults) {
17477
17545
  // type needs to be passed to super, otherwise child roots won't be normalized correctly
17478
17546
  super({ type: 'document', ...defaults });
@@ -17590,9 +17658,9 @@ class Result$4 {
17590
17658
  var result = Result$4;
17591
17659
  Result$4.default = Result$4;
17592
17660
 
17593
- let Container$J = container;
17661
+ let Container$I = container;
17594
17662
 
17595
- class AtRule$3 extends Container$J {
17663
+ class AtRule$3 extends Container$I {
17596
17664
  constructor(defaults) {
17597
17665
  super(defaults);
17598
17666
  this.type = 'atrule';
@@ -17612,13 +17680,13 @@ class AtRule$3 extends Container$J {
17612
17680
  var atRule = AtRule$3;
17613
17681
  AtRule$3.default = AtRule$3;
17614
17682
 
17615
- Container$J.registerAtRule(AtRule$3);
17683
+ Container$I.registerAtRule(AtRule$3);
17616
17684
 
17617
- let Container$I = container;
17685
+ let Container$H = container;
17618
17686
 
17619
17687
  let LazyResult$3, Processor$2;
17620
17688
 
17621
- class Root$5 extends Container$I {
17689
+ class Root$5 extends Container$H {
17622
17690
  constructor(defaults) {
17623
17691
  super(defaults);
17624
17692
  this.type = 'root';
@@ -17727,10 +17795,10 @@ let list$2 = {
17727
17795
  var list_1 = list$2;
17728
17796
  list$2.default = list$2;
17729
17797
 
17730
- let Container$H = container;
17798
+ let Container$G = container;
17731
17799
  let list$1 = list_1;
17732
17800
 
17733
- class Rule$3 extends Container$H {
17801
+ class Rule$3 extends Container$G {
17734
17802
  constructor(defaults) {
17735
17803
  super(defaults);
17736
17804
  this.type = 'rule';
@@ -17751,7 +17819,7 @@ class Rule$3 extends Container$H {
17751
17819
  var rule = Rule$3;
17752
17820
  Rule$3.default = Rule$3;
17753
17821
 
17754
- Container$H.registerRule(Rule$3);
17822
+ Container$G.registerRule(Rule$3);
17755
17823
 
17756
17824
  let Declaration$2 = declaration;
17757
17825
  let tokenizer = tokenize;
@@ -18355,7 +18423,7 @@ class Parser$1 {
18355
18423
 
18356
18424
  var parser = Parser$1;
18357
18425
 
18358
- let Container$G = container;
18426
+ let Container$F = container;
18359
18427
  let Parser = parser;
18360
18428
  let Input$3 = input;
18361
18429
 
@@ -18394,12 +18462,12 @@ function parse$3(css, opts) {
18394
18462
  var parse_1 = parse$3;
18395
18463
  parse$3.default = parse$3;
18396
18464
 
18397
- Container$G.registerParse(parse$3);
18465
+ Container$F.registerParse(parse$3);
18398
18466
 
18399
18467
  let { isClean, my } = symbols;
18400
18468
  let MapGenerator$1 = mapGenerator;
18401
18469
  let stringify$2 = stringify_1;
18402
- let Container$F = container;
18470
+ let Container$E = container;
18403
18471
  let Document$2 = document$1;
18404
18472
  let warnOnce$1 = warnOnce$2;
18405
18473
  let Result$3 = result;
@@ -18534,7 +18602,7 @@ class LazyResult$2 {
18534
18602
 
18535
18603
  if (root && !root[my]) {
18536
18604
  /* c8 ignore next 2 */
18537
- Container$F.rebuild(root);
18605
+ Container$E.rebuild(root);
18538
18606
  }
18539
18607
  }
18540
18608
 
@@ -19201,7 +19269,7 @@ fromJSON$1.default = fromJSON$1;
19201
19269
  let CssSyntaxError = cssSyntaxError;
19202
19270
  let Declaration = declaration;
19203
19271
  let LazyResult = lazyResult;
19204
- let Container$E = container;
19272
+ let Container$D = container;
19205
19273
  let Processor = processor;
19206
19274
  let stringify = stringify_1;
19207
19275
  let fromJSON = fromJSON_1;
@@ -19281,7 +19349,7 @@ postcss.document = defaults => new Document(defaults);
19281
19349
 
19282
19350
  postcss.CssSyntaxError = CssSyntaxError;
19283
19351
  postcss.Declaration = Declaration;
19284
- postcss.Container = Container$E;
19352
+ postcss.Container = Container$D;
19285
19353
  postcss.Processor = Processor;
19286
19354
  postcss.Document = Document;
19287
19355
  postcss.Comment = Comment;
@@ -20121,7 +20189,7 @@ sanitizeHtml.simpleTransform = function(newTagName, newAttribs, merge) {
20121
20189
  var Card = function (_a) {
20122
20190
  var header = _a.header, content = _a.content, footerLink = _a.footerLink, imageLarge = _a.imageLarge, imageSmall = _a.imageSmall, imageAltText = _a.imageAltText;
20123
20191
  var showContent = content || header;
20124
- return (React.createElement(Container$M, { "data-testid": "Card" },
20192
+ return (React.createElement(Container$L, { "data-testid": "Card" },
20125
20193
  imageLarge && imageSmall && (React.createElement(React.Fragment, null, footerLink ? (React.createElement(ImageLink$1, { href: footerLink.url },
20126
20194
  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" })))),
20127
20195
  showContent && (React.createElement(Content$4, null,
@@ -20132,68 +20200,12 @@ var Card = function (_a) {
20132
20200
  React.createElement(FooterLink$1, { href: footerLink.url }, footerLink.title)))));
20133
20201
  };
20134
20202
 
20135
- const calculateWidth = (size) => {
20136
- switch (size) {
20137
- case 'full':
20138
- return css`
20139
- width: 100%;
20140
- `;
20141
- case 'one-half':
20142
- return css`
20143
- width: 50%;
20144
- `;
20145
- case 'one-third':
20146
- return css`
20147
- width: 33.333%;
20148
- `;
20149
- case 'two-thirds':
20150
- return css`
20151
- width: 66.666%;
20152
- `;
20153
- case 'one-quarter':
20154
- return css`
20155
- width: 25%;
20156
- `;
20157
- case 'three-quarters':
20158
- return css`
20159
- width: 75%;
20160
- `;
20161
- }
20162
- };
20163
-
20164
- const widths = (props) => {
20165
- return css`
20166
- ${calculateWidth(props.small)};
20167
-
20168
- @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
20169
- ${calculateWidth(props.medium)};
20170
- }
20171
-
20172
- @media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.l}) {
20173
- ${calculateWidth(props.large)};
20174
- }
20175
- `;
20176
- };
20177
-
20178
- const Container$D = styled.div`
20179
- box-sizing: border-box;
20180
- display: block;
20181
- padding: ${(props) => (props.hasPadding ? props.theme.theme_vars.spacingSizes.small : `0`)};
20182
- border: ${(props) => (props.hasBorder ? `1px solid ${props.theme.theme_vars.colours.negative}` : 'none')};
20183
- ${widths};
20184
- `;
20185
-
20186
- var Column = function (_a) {
20187
- var _b = _a.small, small = _b === void 0 ? 'full' : _b, _c = _a.medium, medium = _c === void 0 ? 'one-half' : _c, _d = _a.large, large = _d === void 0 ? 'one-third' : _d, _e = _a.hasPadding, hasPadding = _e === void 0 ? true : _e, _f = _a.hasBorder, hasBorder = _f === void 0 ? false : _f, children = _a.children;
20188
- return (React.createElement(Container$D, { "data-testid": "Column", small: small, medium: medium, large: large, hasPadding: hasPadding, hasBorder: hasBorder }, children));
20189
- };
20190
-
20191
20203
  /**
20192
20204
  * Multiple cards in a responsive grid
20193
20205
  */
20194
20206
  var Cards = function (_a) {
20195
20207
  var cards = _a.cards;
20196
- return (React.createElement(Container$O, { "data-testid": "Cards" },
20208
+ return (React.createElement(Container$M, { "data-testid": "Cards" },
20197
20209
  React.createElement(Row, null, cards.map(function (card, index) { return (React.createElement(Column, { small: "full", medium: "one-half", large: "one-third", key: index },
20198
20210
  React.createElement(Card, __assign$2({}, card)))); }))));
20199
20211
  };
@@ -21199,7 +21211,7 @@ var LazyImage = /*@__PURE__*/getDefaultExportFromCjs(lib);
21199
21211
  * with an optional caption.
21200
21212
  */
21201
21213
  var Image$2 = function (_a) {
21202
- var imageSmall = _a.imageSmall, imageLarge = _a.imageLarge, imageAltText = _a.imageAltText, _b = _a.ratio, ratio = _b === void 0 ? '4by3' : _b, caption = _a.caption, _c = _a.wrapText, wrapText = _c === void 0 ? false : _c;
21214
+ var imageSmall = _a.imageSmall, imageLarge = _a.imageLarge, imageAltText = _a.imageAltText, _b = _a.ratio, ratio = _b === void 0 ? '4by3' : _b, caption = _a.caption, wrapText = _a.wrapText;
21203
21215
  return (React.createElement(Container$A, { "data-testid": "Image", wrapText: wrapText },
21204
21216
  React.createElement(ImageContainer$4, { "data-testid": "ImageContainer", ratio: ratio },
21205
21217
  React.createElement(LazyImage, { placeholder: imageSmall, src: imageLarge, visibilitySensorProps: {
@@ -21232,10 +21244,12 @@ var ImageAndText = function (_a) {
21232
21244
  heading && (React.createElement(Column, { small: "full", medium: "full", large: "full" },
21233
21245
  React.createElement(HeadingContainer, null,
21234
21246
  React.createElement(Heading, { text: heading, level: 3 })))),
21235
- React.createElement(Column, { small: "full", medium: "one-third", large: "one-third" },
21236
- React.createElement(Image$2, __assign$2({}, image))),
21237
- React.createElement(Column, { small: "full", medium: "two-thirds", large: "two-thirds" },
21238
- React.createElement(Content$3, { dangerouslySetInnerHTML: { __html: sanitizeHtml_1(textContent) } })))));
21247
+ image ? (React.createElement(React.Fragment, null,
21248
+ React.createElement(Column, { small: "full", medium: "one-third", large: "one-third" },
21249
+ React.createElement(Image$2, __assign$2({}, image))),
21250
+ React.createElement(Column, { small: "full", medium: "two-thirds", large: "two-thirds" },
21251
+ React.createElement(Content$3, { dangerouslySetInnerHTML: { __html: sanitizeHtml_1(textContent) } })))) : (React.createElement(Column, { small: "full", medium: "full", large: "full" },
21252
+ React.createElement(Content$3, { dangerouslySetInnerHTML: { __html: sanitizeHtml_1(textContent) } }))))));
21239
21253
  };
21240
21254
 
21241
21255
  const Container$y = styled.div`