nhsuk-tools-chart-components-react 1.2.0-beta.0 → 2.0.0-nhsuk-react-beta

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.
@@ -15,6 +15,21 @@
15
15
  margin-bottom: 3px;
16
16
  }
17
17
 
18
+
19
+ .nhsuk-bar-slider-graph {
20
+ position: relative;
21
+ outline: 1px solid black;
22
+ margin-top: 20px;
23
+ display: flex;
24
+ height: 28px;
25
+ }
26
+ @media (min-width: 320px) and (max-width: 641px) {
27
+ .nhsuk-bar-slider-graph {
28
+ height: 24px;
29
+ }
30
+ }
31
+
32
+
18
33
  .nhsuk-bmi-legend-key-classification-underweight, .nhsuk-bmi-classification-underweight {
19
34
  background: #330072;
20
35
  }
@@ -44,18 +59,6 @@
44
59
  }
45
60
  }
46
61
 
47
- .nhsuk-bar-slider-graph {
48
- position: relative;
49
- outline: 1px solid black;
50
- margin-top: 20px;
51
- display: flex;
52
- height: 28px;
53
- }
54
- @media (min-width: 320px) and (max-width: 641px) {
55
- .nhsuk-bar-slider-graph {
56
- height: 24px;
57
- }
58
- }
59
62
 
60
63
  .nhsuk-bar-slider-arrow-marker {
61
64
  position: absolute;
@@ -101,6 +104,7 @@
101
104
  margin-right: 2px;
102
105
  }
103
106
 
107
+
104
108
  .nhsuk-bmi-chart-marker {
105
109
  position: absolute;
106
110
  z-index: 4;
@@ -116,6 +120,7 @@
116
120
  }
117
121
  }
118
122
 
123
+
119
124
  .nhsuk-bmi-legend-key-classification-underweight, .nhsuk-bmi-classification-underweight {
120
125
  background: #330072;
121
126
  }
@@ -163,48 +168,6 @@
163
168
  box-shadow: none;
164
169
  }
165
170
 
166
- .nhsuk-bp-classification-low, .nhsuk-bp-legend-key-classification-low {
167
- background: #330072;
168
- }
169
-
170
- .nhsuk-bp-classification-healthy, .nhsuk-bp-legend-key-classification-healthy {
171
- background: repeating-linear-gradient(-45deg, #59c3bc, #59c3bc 4.5px, #33b6ad 4.5px, #33b6ad 9px);
172
- }
173
-
174
- .nhsuk-bp-classification-slightlyraised, .nhsuk-bp-legend-key-classification-slightlyraised {
175
- background: #ffb81c;
176
- }
177
-
178
- .nhsuk-bp-classification-high, .nhsuk-bp-legend-key-classification-high {
179
- background: repeating-linear-gradient(45deg, #e1746b, #e1746b 4.5px, #dd5349 4.5px, #dd5349 9px);
180
- }
181
-
182
- #nhsuk-bp-chart > figure {
183
- margin: 0;
184
- }
185
-
186
- .nhsuk-bp-legend-key-wrapper {
187
- display: flex;
188
- }
189
- .nhsuk-bp-legend-key-wrapper:last-child {
190
- margin-top: 5px;
191
- }
192
-
193
- .nhsuk-bp-legend-display-card {
194
- margin-top: 50px;
195
- max-width: 300px;
196
- }
197
-
198
- .nhsuk-bp-legend-key-classification-low {
199
- border-bottom: none;
200
- box-shadow: none;
201
- }
202
-
203
- .nhsuk-bp-legend-key-marker {
204
- border-bottom: none;
205
- box-shadow: none;
206
- }
207
-
208
171
  .nhsuk-bmi-legend-key-classification-underweight, .nhsuk-bmi-classification-underweight {
209
172
  background: #330072;
210
173
  }
@@ -231,75 +194,64 @@
231
194
  box-shadow: none;
232
195
  }
233
196
 
234
- .nhsuk-bp-graph {
235
- position: relative;
236
- margin-left: 20px;
237
- margin-right: 20px;
238
- outline: 2px solid black;
239
- display: flex;
240
- flex-direction: column;
241
- height: 350px;
197
+ .nhsuk-bmi-axis-marker {
198
+ position: absolute;
199
+ outline: 0.5px solid black;
200
+ height: 5px;
201
+ bottom: -5px;
242
202
  }
243
- @media (max-width: 320px) {
244
- .nhsuk-bp-graph {
245
- height: 225px;
246
- }
203
+
204
+ .nhsuk-bmi-axis-marker-label {
205
+ position: absolute;
206
+ bottom: -25px;
207
+ left: -10px;
208
+ width: 20px;
209
+ text-align: center;
247
210
  }
248
- @media (min-width: 320px) and (max-width: 641px) {
249
- .nhsuk-bp-graph {
250
- height: 275px;
251
- }
211
+
212
+ .nhsuk-bp-classification-low, .nhsuk-bp-legend-key-classification-low {
213
+ background: #330072;
252
214
  }
253
215
 
254
- .nhsuk-bp-graph-row {
255
- flex-grow: 1;
256
- display: flex;
216
+ .nhsuk-bp-classification-healthy, .nhsuk-bp-legend-key-classification-healthy {
217
+ background: repeating-linear-gradient(-45deg, #59c3bc, #59c3bc 4.5px, #33b6ad 4.5px, #33b6ad 9px);
257
218
  }
258
219
 
259
- .nhsuk-bp-systolic-legend-wrapper {
260
- display: flex;
261
- align-items: flex-end;
262
- margin-bottom: 10px;
220
+ .nhsuk-bp-classification-slightlyraised, .nhsuk-bp-legend-key-classification-slightlyraised {
221
+ background: #ffb81c;
263
222
  }
264
223
 
265
- .nhsuk-bp-diastolic-legend-wrapper {
266
- display: flex;
267
- align-items: flex-start;
268
- margin-top: 30px;
269
- padding-left: 18px;
224
+ .nhsuk-bp-classification-high, .nhsuk-bp-legend-key-classification-high {
225
+ background: repeating-linear-gradient(45deg, #e1746b, #e1746b 4.5px, #dd5349 4.5px, #dd5349 9px);
270
226
  }
271
227
 
272
- .nhsuk-bp-diastolic-legend-marker, .nhsuk-bp-systolic-legend-marker {
273
- height: 16px;
274
- margin-right: 5px;
275
- border-left: 2px solid black;
228
+ #nhsuk-bp-chart > figure {
229
+ margin: 0;
276
230
  }
277
231
 
278
- .nhsuk-bp-systolic-legend-marker {
279
- width: 40px;
280
- border-top: 2px solid black;
232
+ .nhsuk-bp-legend-key-wrapper {
233
+ display: flex;
234
+ }
235
+ .nhsuk-bp-legend-key-wrapper:last-child {
236
+ margin-top: 5px;
281
237
  }
282
238
 
283
- .nhsuk-bp-diastolic-legend-marker {
284
- width: 20px;
285
- border-bottom: 2px solid black;
239
+ .nhsuk-bp-legend-display-card {
240
+ margin-top: 50px;
241
+ max-width: 300px;
286
242
  }
287
243
 
288
- .nhsuk-bmi-axis-marker {
289
- position: absolute;
290
- outline: 0.5px solid black;
291
- height: 5px;
292
- bottom: -5px;
244
+ .nhsuk-bp-legend-key-classification-low {
245
+ border-bottom: none;
246
+ box-shadow: none;
293
247
  }
294
248
 
295
- .nhsuk-bmi-axis-marker-label {
296
- position: absolute;
297
- bottom: -25px;
298
- left: -10px;
299
- width: 20px;
300
- text-align: center;
249
+ .nhsuk-bp-legend-key-marker {
250
+ border-bottom: none;
251
+ box-shadow: none;
301
252
  }
302
253
 
254
+
303
255
  .nhsuk-bp-graph-marker {
304
256
  position: absolute;
305
257
  z-index: 6;
@@ -322,6 +274,7 @@
322
274
  }
323
275
  }
324
276
 
277
+
325
278
  .nhsuk-bp-diastolic-axis-marker, .nhsuk-bp-systolic-axis-marker {
326
279
  position: absolute;
327
280
  outline: 0.5px solid black;
@@ -382,6 +335,61 @@
382
335
  text-align: center;
383
336
  }
384
337
 
338
+
339
+ .nhsuk-bp-graph {
340
+ position: relative;
341
+ margin-left: 20px;
342
+ margin-right: 20px;
343
+ outline: 2px solid black;
344
+ display: flex;
345
+ flex-direction: column;
346
+ height: 350px;
347
+ }
348
+ @media (max-width: 320px) {
349
+ .nhsuk-bp-graph {
350
+ height: 225px;
351
+ }
352
+ }
353
+ @media (min-width: 320px) and (max-width: 641px) {
354
+ .nhsuk-bp-graph {
355
+ height: 275px;
356
+ }
357
+ }
358
+
359
+ .nhsuk-bp-graph-row {
360
+ flex-grow: 1;
361
+ display: flex;
362
+ }
363
+
364
+ .nhsuk-bp-systolic-legend-wrapper {
365
+ display: flex;
366
+ align-items: flex-end;
367
+ margin-bottom: 10px;
368
+ }
369
+
370
+ .nhsuk-bp-diastolic-legend-wrapper {
371
+ display: flex;
372
+ align-items: flex-start;
373
+ margin-top: 30px;
374
+ padding-left: 18px;
375
+ }
376
+
377
+ .nhsuk-bp-diastolic-legend-marker, .nhsuk-bp-systolic-legend-marker {
378
+ height: 16px;
379
+ margin-right: 5px;
380
+ border-left: 2px solid black;
381
+ }
382
+
383
+ .nhsuk-bp-systolic-legend-marker {
384
+ width: 40px;
385
+ border-top: 2px solid black;
386
+ }
387
+
388
+ .nhsuk-bp-diastolic-legend-marker {
389
+ width: 20px;
390
+ border-bottom: 2px solid black;
391
+ }
392
+
385
393
  .nhsuk-cbmi-classification-healthy, .nhsuk-cbmi-legend-key-classification-healthy {
386
394
  background: repeating-linear-gradient(-45deg, #30b4ab, #30b4ab 4.5px, #00a499 4.5px, #00a499 9px);
387
395
  }
@@ -394,17 +402,30 @@
394
402
  background: #330072;
395
403
  }
396
404
 
397
- .nhsuk-cbmi-graph {
398
- position: relative;
399
- outline: 1px solid black;
400
- margin-top: 20px;
401
- display: flex;
402
- height: 28px;
405
+ .nhsuk-cbmi-legend-key-classification-overweight {
406
+ border-bottom: none;
407
+ box-shadow: none;
403
408
  }
404
- @media (min-width: 320px) and (max-width: 641px) {
405
- .nhsuk-cbmi-graph {
406
- height: 24px;
407
- }
409
+
410
+ .nhsuk-cbmi-legend-key, .nhsuk-cbmi-legend-key-classification-underweight, .nhsuk-cbmi-legend-key-classification-healthy, .nhsuk-cbmi-legend-key-classification-overweight {
411
+ border-bottom: 2px solid white;
412
+ margin-bottom: 2px;
413
+ }
414
+
415
+ .nhsuk-cbmi-legend-marker {
416
+ margin-bottom: 2px;
417
+ }
418
+
419
+ .nhsuk-cbmi-classification-underweight-heading {
420
+ border-left: 8px solid #330072;
421
+ }
422
+
423
+ .nhsuk-cbmi-classification-healthy-heading {
424
+ border-left: 8px solid #30b4ab;
425
+ }
426
+
427
+ .nhsuk-cbmi-classification-overweight-heading {
428
+ border-left: 8px solid #ffb81c;
408
429
  }
409
430
 
410
431
  .nhsuk-bp-classification-low, .nhsuk-bp-legend-key-classification-low {
@@ -458,6 +479,32 @@
458
479
  z-index: 0;
459
480
  }
460
481
 
482
+
483
+ .nhsuk-cbmi-classification-healthy, .nhsuk-cbmi-legend-key-classification-healthy {
484
+ background: repeating-linear-gradient(-45deg, #30b4ab, #30b4ab 4.5px, #00a499 4.5px, #00a499 9px);
485
+ }
486
+
487
+ .nhsuk-cbmi-classification-overweight, .nhsuk-cbmi-legend-key-classification-overweight {
488
+ background: #ffb81c;
489
+ }
490
+
491
+ .nhsuk-cbmi-classification-underweight, .nhsuk-cbmi-legend-key-classification-underweight {
492
+ background: #330072;
493
+ }
494
+
495
+ .nhsuk-cbmi-graph {
496
+ position: relative;
497
+ outline: 1px solid black;
498
+ margin-top: 20px;
499
+ display: flex;
500
+ height: 28px;
501
+ }
502
+ @media (min-width: 320px) and (max-width: 641px) {
503
+ .nhsuk-cbmi-graph {
504
+ height: 24px;
505
+ }
506
+ }
507
+
461
508
  .nhsuk-bp-graph-cell {
462
509
  flex-grow: 1;
463
510
  border-bottom: 1px solid white;
@@ -474,6 +521,7 @@
474
521
  border-left: none;
475
522
  }
476
523
 
524
+
477
525
  .nhsuk-cbmi-classification-healthy, .nhsuk-cbmi-legend-key-classification-healthy {
478
526
  background: repeating-linear-gradient(-45deg, #30b4ab, #30b4ab 4.5px, #00a499 4.5px, #00a499 9px);
479
527
  }
@@ -486,44 +534,43 @@
486
534
  background: #330072;
487
535
  }
488
536
 
489
- .nhsuk-cbmi-legend-key-classification-overweight {
490
- border-bottom: none;
491
- box-shadow: none;
492
- }
493
-
494
- .nhsuk-cbmi-legend-key, .nhsuk-cbmi-legend-key-classification-underweight, .nhsuk-cbmi-legend-key-classification-healthy, .nhsuk-cbmi-legend-key-classification-overweight {
495
- border-bottom: 2px solid white;
496
- margin-bottom: 2px;
537
+ .nhsuk-cbmi-classification-overweight, .nhsuk-cbmi-classification-healthy, .nhsuk-cbmi-classification-underweight {
538
+ position: absolute;
539
+ bottom: 0%;
540
+ outline: 1px solid black;
541
+ height: 28px;
497
542
  }
498
-
499
- .nhsuk-cbmi-legend-marker {
500
- margin-bottom: 2px;
543
+ @media (min-width: 320px) and (max-width: 641px) {
544
+ .nhsuk-cbmi-classification-overweight, .nhsuk-cbmi-classification-healthy, .nhsuk-cbmi-classification-underweight {
545
+ height: 24px;
546
+ }
501
547
  }
502
548
 
503
- .nhsuk-cbmi-classification-underweight-heading {
504
- border-left: 8px solid #330072;
549
+ .nhsuk-cbmi-classification-underweight {
550
+ z-index: 3;
505
551
  }
506
552
 
507
- .nhsuk-cbmi-classification-healthy-heading {
508
- border-left: 8px solid #30b4ab;
553
+ .nhsuk-cbmi-classification-healthy {
554
+ z-index: 2;
509
555
  }
510
556
 
511
- .nhsuk-cbmi-classification-overweight-heading {
512
- border-left: 8px solid #ffb81c;
557
+ .nhsuk-cbmi-classification-overweight {
558
+ z-index: 1;
513
559
  }
514
560
 
515
- .nhsuk-cbmi-classification-healthy, .nhsuk-cbmi-legend-key-classification-healthy {
561
+ .nhsuk-cbmi-legend-key-classification-healthy, .nhsuk-cbmi-classification-healthy {
516
562
  background: repeating-linear-gradient(-45deg, #30b4ab, #30b4ab 4.5px, #00a499 4.5px, #00a499 9px);
517
563
  }
518
564
 
519
- .nhsuk-cbmi-classification-overweight, .nhsuk-cbmi-legend-key-classification-overweight {
565
+ .nhsuk-cbmi-legend-key-classification-overweight, .nhsuk-cbmi-classification-overweight {
520
566
  background: #ffb81c;
521
567
  }
522
568
 
523
- .nhsuk-cbmi-classification-underweight, .nhsuk-cbmi-legend-key-classification-underweight {
569
+ .nhsuk-cbmi-legend-key-classification-underweight, .nhsuk-cbmi-classification-underweight {
524
570
  background: #330072;
525
571
  }
526
572
 
573
+
527
574
  .nhsuk-cbmi-axis-marker {
528
575
  border: 1px solid black;
529
576
  position: absolute;
@@ -547,15 +594,16 @@
547
594
  text-align: center;
548
595
  }
549
596
 
550
- .nhsuk-cbmi-classification-healthy, .nhsuk-cbmi-legend-key-classification-healthy {
597
+
598
+ .nhsuk-cbmi-legend-key-classification-healthy, .nhsuk-cbmi-classification-healthy {
551
599
  background: repeating-linear-gradient(-45deg, #30b4ab, #30b4ab 4.5px, #00a499 4.5px, #00a499 9px);
552
600
  }
553
601
 
554
- .nhsuk-cbmi-classification-overweight, .nhsuk-cbmi-legend-key-classification-overweight {
602
+ .nhsuk-cbmi-legend-key-classification-overweight, .nhsuk-cbmi-classification-overweight {
555
603
  background: #ffb81c;
556
604
  }
557
605
 
558
- .nhsuk-cbmi-classification-underweight, .nhsuk-cbmi-legend-key-classification-underweight {
606
+ .nhsuk-cbmi-legend-key-classification-underweight, .nhsuk-cbmi-classification-underweight {
559
607
  background: #330072;
560
608
  }
561
609
 
@@ -616,40 +664,4 @@
616
664
  .nhsuk-cbmi-chart-axis-marker {
617
665
  height: 24px;
618
666
  }
619
- }
620
-
621
- .nhsuk-cbmi-classification-healthy, .nhsuk-cbmi-legend-key-classification-healthy {
622
- background: repeating-linear-gradient(-45deg, #30b4ab, #30b4ab 4.5px, #00a499 4.5px, #00a499 9px);
623
- }
624
-
625
- .nhsuk-cbmi-classification-overweight, .nhsuk-cbmi-legend-key-classification-overweight {
626
- background: #ffb81c;
627
- }
628
-
629
- .nhsuk-cbmi-classification-underweight, .nhsuk-cbmi-legend-key-classification-underweight {
630
- background: #330072;
631
- }
632
-
633
- .nhsuk-cbmi-classification-overweight, .nhsuk-cbmi-classification-healthy, .nhsuk-cbmi-classification-underweight {
634
- position: absolute;
635
- bottom: 0%;
636
- outline: 1px solid black;
637
- height: 28px;
638
- }
639
- @media (min-width: 320px) and (max-width: 641px) {
640
- .nhsuk-cbmi-classification-overweight, .nhsuk-cbmi-classification-healthy, .nhsuk-cbmi-classification-underweight {
641
- height: 24px;
642
- }
643
- }
644
-
645
- .nhsuk-cbmi-classification-underweight {
646
- z-index: 3;
647
- }
648
-
649
- .nhsuk-cbmi-classification-healthy {
650
- z-index: 2;
651
- }
652
-
653
- .nhsuk-cbmi-classification-overweight {
654
- z-index: 1;
655
667
  }
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react"),t=require("nhsuk-react-components"),a=require("big.js");function n(e){const t=function(e){if(e.axis.ticks.length<=2)throw Error("invalid number of axis ticks");const t=[...e.axis.ticks].sort(((e,t)=>e.value-t.value));return e.segments.map(((e,a)=>{var n,s;const r=null!==(n=e.start)&&void 0!==n?n:t[a].value,l=null!==(s=e.end)&&void 0!==s?s:t[a+1].value;return Object.assign(Object.assign({},e),{start:r,end:l})}))}(e),a=t.reduce(((e,t)=>{var a;return e+(null!==(a=t.weight)&&void 0!==a?a:0)}),0),n=t.filter((e=>void 0===e.weight)).reduce(((e,t)=>e+(t.end-t.start)),0),s=100-a;if(s<0)throw new Error("Invalid segment weight.");return t.map((e=>{if(void 0!==e.weight)return e;const t=(e.end-e.start)/n*s;return Object.assign(Object.assign({},e),{weight:t})}))}class s{constructor(e,t){this.chartWidth=t,this.chartName=e.name,this.axis=e.axis,this.constraints=e.constraints,this.segments=n(e)}get name(){return this.chartName}getAxisTicks(){return Object.values(this.axis.ticks).map((e=>{var t;const a=null===(t=e.isVisible)||void 0===t||t;return{label:e.value.toString(),value:this.calculateRawPosition(e.value),isVisible:a}}))}getChartRegions(){return Object.values(this.axis.ticks).slice(1).map((e=>({value:this.calculateRawPosition(e.value),styleClass:this.segmentstyleSuffix(e.value)})))}segmentstyleSuffix(e){const t=this.getSegmentByTick(e);return(null==t?void 0:t.styleSuffix)?`${this.chartName}-${t.styleSuffix}`:""}getSegmentByTick(e){for(const t of this.segments)if(e>=t.start&&e<=t.end)return t;return null}calculatePosition(e){if(this.constraints){const{value:t,position:a}=this.constraints.max;if(e>=t)return a}return this.calculateRawPosition(e)}calculateRawPosition(e){let t=0;const a=this.clampValue(e),{totalSegmentsWidth:n}=this;for(const e of this.segments){if(a>=e.start&&a<=e.end){return t+(a-e.start)/(e.end-e.start)*(e.weight/n)*this.chartWidth}t+=e.weight/n*this.chartWidth}return 0}clampValue(e){return Math.min(Math.max(e,this.axis.ticks[0].value),this.axis.ticks[this.axis.ticks.length-1].value)}get totalSegmentsWidth(){return this.segments.reduce(((e,t)=>e+t.weight),0)}}const r=(e,t)=>t>0?`${e}-axis-marker-label`:`${e}-start-axis-marker-label`,l=(e,t)=>t>0?`${e}-axis-marker`:`${e}-start-axis-marker`;function i({chartName:t,markerText:a,offsetPercent:n}){return e.createElement("div",{className:`${l(t,n)}`,style:{left:`${n}%`}},e.createElement("div",{className:`nhsuk-font-size-16 nhsuk-u-secondary-text-color ${r(t,n)}`},a))}function c({model:t}){return e.createElement(e.Fragment,null,t.getAxisTicks().map((({label:a,value:n,isVisible:s})=>s&&e.createElement(i,{chartName:t.name,markerText:a,offsetPercent:n,key:a}))))}function o(){return e.createElement("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M6 9L0.803849 -9.78799e-07L11.1962 -7.02746e-08L6 9Z",fill:"black"}))}const u=(e,t)=>t<=20?`${e}-label-align-left`:t<=80?`${e}-label-align-center`:`${e}-label-align-right`;function m({chartName:t,value:a,offset:n,markerText:s}){return e.createElement("div",{className:`${t}-label-marker`},e.createElement("div",{className:`nhsuk-font-size-16 ${u(t,n)}`},s,e.createElement("span",{className:`${t}-value-marker`},a)))}function d({value:t,model:a,markerText:n}){const s=a.calculatePosition(t),r=Math.pow(10,1),l=Math.round(s*r)/r;return e.createElement(e.Fragment,null,e.createElement("div",{className:`${a.name}-arrow-marker`,style:{left:`${l}%`}},e.createElement(m,{chartName:a.name,value:t,markerText:n,offset:l}),e.createElement(o,null)),e.createElement("div",{className:`${a.name}-value-axis-marker`,style:{left:`${l}%`}}))}function h({value:t,styleClass:a}){return e.createElement("div",{className:a,style:{width:`${t}%`}})}function g({model:t}){return e.createElement(e.Fragment,null,t.getChartRegions().map((({value:t,styleClass:a})=>e.createElement(h,{value:t,styleClass:a,key:t}))))}const f=100;function p({config:t,value:a,markerText:n}){const r=new s(t,f);return e.createElement("div",{className:`${t.name}-graph nhsuk-u-margin-bottom-9`,"aria-hidden":"true"},e.createElement(c,{model:r}),e.createElement(d,{value:a,markerText:n,model:r}),e.createElement(g,{model:r}))}function b({element:t,text:a,className:n,wrapperClassName:s}){return e.createElement("div",{className:`nhsuk-chart-legend-key-wrapper ${null!=s?s:""}`},e.createElement("div",{className:`nhsuk-chart-legend-key ${null!=n?n:""}`},t),a)}function k({legendKeys:a,className:n}){return e.createElement(t.Card,{className:`${n} nhsuk-u-padding-3 nhsuk-chart-legend-card`},a.map((t=>e.createElement(b,Object.assign({key:t.text},t)))))}function y({legendKeys:t,className:a}){return e.createElement("div",{className:a},t.map((t=>e.createElement(b,Object.assign({key:t.text},t)))))}function v({legendKeys:t,borderWrapper:a=!0}){const n="nhsuk-u-margin-top-6 nhsuk-u-margin-bottom-3 nhsuk-u-secondary-text-color nhsuk-body-s";return e.createElement("div",{"aria-hidden":"true"},a?e.createElement(k,{legendKeys:t,className:n}):e.createElement(y,{legendKeys:t,className:n}))}const E={Underweight:"underweight",Healthy:"healthy",Overweight:"overweight"},w=Object.assign(Object.assign({},E),{Obese:"obese"}),x=Object.assign(Object.assign({},E),{Obese1:"obese1",Obese2:"obese2",Obese3:"obese3"});x.Underweight,x.Healthy,x.Underweight,x.Overweight,x.Healthy;class L{constructor(e){this.bounds={lowerBound:17.5,upperBounds:{[w.Underweight]:e.upper[x.Underweight].value,[w.Healthy]:e.upper[x.Healthy].value,[w.Overweight]:e.upper[x.Overweight].value,[w.Obese]:e.upper[x.Obese2].value}}}get chartRange(){return this.bounds.upperBounds[w.Obese]-this.bounds.lowerBound}classificationPercentage(e){return this.offsetPercentage(this.bounds.upperBounds[e])}offsetPercentage(e){return(e-this.bounds.lowerBound)/this.chartRange*100}}function N(){return e.createElement("svg",{viewBox:"1 1 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("g",{clipPath:"url(#clip0_1346_102759)"},e.createElement("path",{xmlns:"http://www.w3.org/2000/svg",d:"M1.93209 4.05025L1.57854 4.40381L1.93209 4.75736L6.17473 9L1.93209 13.2426L1.57854 13.5962L1.93209 13.9497L4.05341 16.0711L4.40697 16.4246L4.76052 16.0711L9.00316 11.8284L13.2458 16.0711L13.5994 16.4246L13.9529 16.0711L16.0742 13.9497L16.4278 13.5962L16.0742 13.2426L11.8316 9L16.0742 4.75736L16.4278 4.40381L16.0742 4.05025L13.9529 1.92893L13.5994 1.57538L13.2458 1.92893L9.00316 6.17157L4.76052 1.92893L4.40697 1.57538L4.05341 1.92893L1.93209 4.05025Z",fill:"black",stroke:"white"})))}function B({bmi:t,model:a}){const n=a.offsetPercentage(t);let s=0;if(n>0){const e=1,t=Math.pow(10,e);s=Math.round(n*t)/t}return e.createElement("div",{className:"nhsuk-bmi-chart-marker",style:{left:`${s}%`}},e.createElement(N,null))}function $({classification:t,model:a}){const n=a.classificationPercentage(t);return e.createElement("div",{className:`nhsuk-bmi-classification-${t}`,style:{width:`${n}%`}})}function T({model:t}){return e.createElement(e.Fragment,null,e.createElement($,{classification:w.Underweight,model:t}),e.createElement($,{classification:w.Healthy,model:t}),e.createElement($,{classification:w.Overweight,model:t}),e.createElement($,{classification:w.Obese,model:t}))}function O({markerText:t,offsetPercent:a}){return e.createElement("div",{className:"nhsuk-bmi-axis-marker",style:{left:`${a}%`}},e.createElement("div",{className:"nhsuk-bmi-axis-marker-label"},t))}function P({model:t}){return e.createElement(e.Fragment,null,e.createElement(O,{markerText:t.bounds.upperBounds[w.Underweight].toString(),offsetPercent:t.classificationPercentage(w.Underweight)}),e.createElement(O,{markerText:t.bounds.upperBounds[w.Healthy].toString(),offsetPercent:t.classificationPercentage(w.Healthy)}),e.createElement(O,{markerText:t.bounds.upperBounds[w.Overweight].toString(),offsetPercent:t.classificationPercentage(w.Overweight)}))}function S({classificationBounds:t,bmi:a}){const n=new L(t);return e.createElement("div",{className:"nhsuk-bmi-graph","aria-hidden":"true"},e.createElement(P,{model:n}),e.createElement(B,{bmi:a,model:n}),e.createElement(T,{model:n}))}const R={Low:"low",Healthy:"healthy",SlightlyRaised:"slightlyRaised",High:"high"};var C;function H({axisType:t,labelText:a,offsetPercent:n,applyLabelSpecificStyles:s=!0}){const r=`${C[t].toLowerCase()}-axis`,l=`nhsuk-bp-${r}-marker`,i=`nhsuk-bp-${r}-marker-${a}`;return e.createElement("div",{className:s?`${l} ${i}`:`${l}`,style:t===C.Systolic?{bottom:`${n}%`}:{left:`${n}%`}},e.createElement("div",{className:`nhsuk-bp-${r}-label`},a))}function j(e,t,a){return(e-a)/(t-a)*100}function U(e,t,a){return j(t[e].value,t[R.High].value,a)}function M({axisType:t,upperBounds:a,lowerBound:n}){const s={slightlyRaisedValueToCheck:85,slightlyRaisedValueToAdd:90};return e.createElement("div",null,e.createElement(H,{labelText:n.toString(),offsetPercent:0,axisType:t}),e.createElement(H,{labelText:a[R.Low].value.toString(),offsetPercent:U(R.Low,a,n),axisType:t}),e.createElement(H,{labelText:a[R.Healthy].value.toString(),offsetPercent:U(R.Healthy,a,n),axisType:t}),e.createElement(H,{labelText:a[R.SlightlyRaised].value.toString(),offsetPercent:U(R.SlightlyRaised,a,n),axisType:t,applyLabelSpecificStyles:a[R.SlightlyRaised].value===s.slightlyRaisedValueToCheck}),t===C.Diastolic&&a[R.SlightlyRaised].value===s.slightlyRaisedValueToCheck&&e.createElement(H,{labelText:s.slightlyRaisedValueToAdd.toString(),offsetPercent:j(s.slightlyRaisedValueToAdd,a[R.High].value,n),axisType:t}),e.createElement(H,{labelText:a[R.High].value.toString(),offsetPercent:100,axisType:t}))}function F({bounds:t}){return e.createElement(e.Fragment,null,e.createElement(M,{axisType:C.Systolic,upperBounds:t.systolic.upper,lowerBound:t.systolic.lower}),e.createElement(M,{axisType:C.Diastolic,upperBounds:t.diastolic.upper,lowerBound:t.diastolic.lower}))}function A(){return e.createElement("svg",{viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("g",{clipPath:"url(#clip0_1346_102759)"},e.createElement("path",{d:"M5.18718 8.36931L4.48008 9.07641L5.18718 9.78352L11.3744 15.9707L5.18718 22.1579L4.48008 22.865L5.18718 23.5721L8.36916 26.7541L9.07627 27.4612L9.78338 26.7541L15.9706 20.5669L22.1577 26.7541L22.8649 27.4612L23.572 26.7541L26.7539 23.5721L27.461 22.865L26.7539 22.1579L20.5668 15.9707L26.7539 9.78352L27.461 9.07641L26.7539 8.36931L23.572 5.18732L22.8649 4.48022L22.1577 5.18732L15.9706 11.3745L9.78338 5.18732L9.07627 4.48022L8.36916 5.18732L5.18718 8.36931Z",fill:"black",stroke:"white",strokeWidth:"2"})))}function K({systolicReading:t,diastolicReading:n,systolicLowerBound:s,systolicUpperBound:r,diastolicLowerBound:l,diastolicUpperBound:i}){const c=i-l,o=new a((t-s)/(r-s)).times(100),u=new a((n-l)/c).times(100),m=o.round(1),d=u.round(1);return e.createElement("div",{className:"nhsuk-bp-graph-marker",style:{left:`${d}%`,bottom:`${m}%`}},e.createElement(A,null))}function V(e,t,a){return(t[a].value-e)/(t.high.value-e)*100}function W(e){return`nhsuk-bp-classification-${e.toLowerCase()}`}function z({classification:t,bounds:a,renderAsBoundary:n=!1}){const s=V(a.diastolic.lower,a.diastolic.upper,t),r=V(a.systolic.lower,a.systolic.upper,t);return e.createElement("div",{className:n?"nhsuk-bp-region-boundary":W(t),style:{width:`${s}%`,height:`${r}%`}})}function D({bounds:t,renderAsBoundary:a=!1}){return e.createElement(e.Fragment,null,e.createElement(z,Object.assign({classification:R.Low},{bounds:t,renderAsBoundary:a})),e.createElement(z,Object.assign({classification:R.Healthy},{bounds:t,renderAsBoundary:a})),e.createElement(z,Object.assign({classification:R.SlightlyRaised},{bounds:t,renderAsBoundary:a})),!a&&e.createElement(z,Object.assign({classification:R.High},{bounds:t,renderAsBoundary:a})))}function _({firstInRow:t=!1,firstInColumn:a=!1}){let n="nhsuk-bp-graph-cell";return t&&(n+=" nhsuk-bp-first-in-row"),a&&(n+=" nhsuk-bp-first-in-column"),e.createElement("div",{className:n})}function q({bounds:t,graphLayout:a,reading:n}){const{systolic:s,diastolic:r}=n,{systolicLabel:l,diastolicLabel:i}=a;return e.createElement("div",{className:"nhsuk-body-s"},e.createElement("div",{className:"nhsuk-bp-systolic-legend-wrapper","aria-hidden":"true"},e.createElement("div",{className:"nhsuk-bp-systolic-legend-marker"}),e.createElement("span",null,l)),e.createElement("div",{className:"nhsuk-bp-graph","aria-hidden":"true"},e.createElement(F,{bounds:t}),e.createElement(K,{systolicReading:s,diastolicReading:r,systolicLowerBound:t.systolic.lower,systolicUpperBound:t.systolic.upper.high.value,diastolicLowerBound:t.diastolic.lower,diastolicUpperBound:t.diastolic.upper.high.value}),e.createElement(D,{bounds:t}),a.rows.map((t=>e.createElement("div",{key:t.id,className:"nhsuk-bp-graph-row"},t.cells.map((t=>e.createElement(_,Object.assign({key:t.id},t))))))),e.createElement(D,{bounds:t,renderAsBoundary:!0})),e.createElement("div",{className:"nhsuk-bp-diastolic-legend-wrapper","aria-hidden":"true"},e.createElement("div",{className:"nhsuk-bp-diastolic-legend-marker"}),e.createElement("span",null,i)))}!function(e){e[e.Systolic=0]="Systolic",e[e.Diastolic=1]="Diastolic"}(C||(C={})),a.RM=a.roundHalfEven;const I={[x.Underweight]:null,[x.Healthy]:x.Underweight,[x.Overweight]:x.Healthy};class Z{constructor(e){this.bounds={lowerBound:0,upperBounds:{[w.Underweight]:e.upper[x.Underweight].value,[w.Healthy]:e.upper[x.Healthy].value,[w.Overweight]:e.upper[x.Overweight].value}}}get chartRange(){return this.bounds.upperBounds[x.Overweight]-this.bounds.lowerBound}classificationPercentage(e){return this.offsetPercentage(this.bounds.upperBounds[e])}offsetPercentage(e){const t=this.chartRange;if(e<=2){const a=.08*t;return this.calculateOffset(e,E.Underweight,a)}if(e<=91){const a=.72*t,n=.08*t;return this.calculateOffset(e,E.Healthy,a)+n}const a=.2*t,n=.8*t;return this.calculateOffset(e,E.Overweight,a)+n}calculateOffset(e,t,a){const n=I[t]?this.bounds.upperBounds[I[t]]:0;return(e-n)/(this.bounds.upperBounds[t]-n)*a}clampedOffsetPercentage(e){const t=Math.max(1,Math.min(e,99));return this.offsetPercentage(t)}}function G({markerText:t,offsetPercent:a}){return e.createElement("div",{className:"nhsuk-cbmi-axis-marker",style:{left:`${a}%`}},e.createElement("div",{className:"nhsuk-font-size-16 nhsuk-cbmi-axis-marker-label"},t))}function J({model:t}){return e.createElement(e.Fragment,null,e.createElement(G,{markerText:t.bounds.upperBounds[E.Underweight].toString(),offsetPercent:t.classificationPercentage(E.Underweight)}),e.createElement(G,{markerText:t.bounds.upperBounds[E.Healthy].toString(),offsetPercent:t.classificationPercentage(E.Healthy)}))}const Q=e=>e<=20?"nhsuk-cbmi-chart-label-align-left":e<=80?"nhsuk-cbmi-chart-label-align-center":"nhsuk-cbmi-chart-label-align-right";function X({centile:t,markerText:a}){return e.createElement("div",{className:"nhsuk-cbmi-chart-label-marker"},e.createElement("div",{className:`nhsuk-u-font-size-19 ${Q(t.value)}`},a,e.createElement("span",{className:"nhsuk-cbmi-chart-centile-marker"},t.label)))}function Y({centile:t,model:a,markerText:n}){const s=a.clampedOffsetPercentage(t.value);let r=0;if(s>0){const e=1,t=Math.pow(10,e);r=Math.round(s*t)/t}return e.createElement("div",null,e.createElement("div",{className:"nhsuk-cbmi-chart-arrow-marker",style:{left:`${r}%`}},e.createElement(X,{centile:t,markerText:n}),e.createElement(o,null)),e.createElement("div",{className:"nhsuk-cbmi-chart-axis-marker",style:{left:`${r}%`}}))}function ee({classification:t,model:a}){const n=a.classificationPercentage(t);return e.createElement("div",{className:`nhsuk-cbmi-classification-${t}`,style:{width:`${n}%`}})}function te({model:t}){return e.createElement(e.Fragment,null,e.createElement(ee,{classification:E.Underweight,model:t}),e.createElement(ee,{classification:E.Healthy,model:t}),e.createElement(ee,{classification:E.Overweight,model:t}))}function ae({classificationBounds:t,centile:a,markerText:n}){const s=new Z(t);return e.createElement("div",{className:"nhsuk-cbmi-graph nhsuk-u-margin-bottom-9 ","aria-hidden":"true"},e.createElement(J,{model:s}),e.createElement(Y,{centile:a,markerText:n,model:s}),e.createElement(te,{model:s}))}exports.BarSliderChart=p,exports.BarSliderChartFigure=function({config:t,value:a,ariaLabel:n,markerText:s}){const r=Object.values(t.segments).filter((e=>null!=e.legend)).map((e=>({text:e.legend,className:`${t.name}-legend-key-${e.styleSuffix}`,wrapperClassName:`${t.name}-legend-marker`})));return e.createElement("figure",{className:"nhsuk-u-margin-0"},e.createElement("figcaption",{className:"nhsuk-u-visually-hidden"},n),e.createElement(p,{config:t,value:a,markerText:s}),e.createElement(v,{legendKeys:r,borderWrapper:!1}))},exports.BmiChart=S,exports.BmiChartFigure=function({classificationBounds:t,bmi:a,ariaLabel:n,legendKeys:s,legendMarkerText:r}){const l=((t,a)=>Object.entries(t).map((([e,t])=>({text:t,className:`nhsuk-bmi-legend-key-classification-${e}`}))).concat({text:a,className:"nhsuk-bmi-legend-key-marker",element:e.createElement(N,null)}))(s,r);return e.createElement("figure",{className:"nhsuk-u-margin-0"},e.createElement("figcaption",{className:"nhsuk-u-visually-hidden"},n),e.createElement(S,{classificationBounds:t,bmi:a}),e.createElement(v,{legendKeys:l,borderWrapper:!0}))},exports.BpChart=q,exports.BpChartFigure=function({bounds:t,graphLayout:a,reading:n,ariaLabel:s,legendKeys:r,legendMarkerText:l}){const i=((t,a)=>Object.entries(t).map((([e,t])=>({text:t,className:`nhsuk-bp-legend-key-classification-${e}`}))).concat({text:a,className:"nhsuk-bp-legend-key-marker",element:e.createElement(A,null)}))(r,l);return e.createElement("figure",{className:"nhsuk-u-margin-0"},e.createElement("figcaption",{className:"nhsuk-u-visually-hidden"},s),e.createElement(q,{bounds:t,reading:n,graphLayout:a}),e.createElement(v,{legendKeys:i}))},exports.ChartLegend=v,exports.ChildBmiChart=ae,exports.ChildBmiChartFigure=function({classificationBounds:t,centile:a,centileMarkerText:n,ariaLabel:s,legendKeys:r}){const l=Object.entries(r).map((([e,t])=>({text:t,className:`nhsuk-cbmi-legend-key-classification-${e}`,wrapperClassName:"nhsuk-cbmi-legend-marker"})));return e.createElement("figure",{className:"nhsuk-u-margin-0"},e.createElement("figcaption",{className:"nhsuk-u-visually-hidden"},s),e.createElement(ae,{classificationBounds:t,centile:a,markerText:n}),e.createElement(v,{legendKeys:l,borderWrapper:!1}))};
1
+ "use strict";var e=require("react"),t=require("nhsuk-react-components"),a=require("big.js");function n(e){const t=function(e){if(e.axis.ticks.length<=2)throw Error("invalid number of axis ticks");const t=[...e.axis.ticks].sort(((e,t)=>e.value-t.value));return e.segments.map(((e,a)=>{var n,r;const s=null!==(n=e.start)&&void 0!==n?n:t[a].value,l=null!==(r=e.end)&&void 0!==r?r:t[a+1].value;return Object.assign(Object.assign({},e),{start:s,end:l})}))}(e),a=t.reduce(((e,t)=>{var a;return e+(null!==(a=t.weight)&&void 0!==a?a:0)}),0),n=t.filter((e=>void 0===e.weight)).reduce(((e,t)=>e+(t.end-t.start)),0),r=100-a;if(r<0)throw new Error("Invalid segment weight.");return t.map((e=>{if(void 0!==e.weight)return e;const t=(e.end-e.start)/n*r;return Object.assign(Object.assign({},e),{weight:t})}))}class r{constructor(e,t){this.chartWidth=t,this.chartName=e.name,this.axis=e.axis,this.constraints=e.constraints,this.segments=n(e)}get name(){return this.chartName}getAxisTicks(){return Object.values(this.axis.ticks).map((e=>{var t;const a=null===(t=e.isVisible)||void 0===t||t;return{label:e.value.toString(),value:this.calculateRawPosition(e.value),isVisible:a}}))}getChartRegions(){return Object.values(this.axis.ticks).slice(1).map((e=>({value:this.calculateRawPosition(e.value),styleClass:this.segmentstyleSuffix(e.value)})))}segmentstyleSuffix(e){const t=this.getSegmentByTick(e);return(null==t?void 0:t.styleSuffix)?`${this.chartName}-${t.styleSuffix}`:""}getSegmentByTick(e){for(const t of this.segments)if(e>=t.start&&e<=t.end)return t;return null}calculatePosition(e){if(this.constraints){const{value:t,position:a}=this.constraints.max;if(e>=t)return a}return this.calculateRawPosition(e)}calculateRawPosition(e){let t=0;const a=this.clampValue(e),{totalSegmentsWidth:n}=this;for(const e of this.segments){if(a>=e.start&&a<=e.end){return t+(a-e.start)/(e.end-e.start)*(e.weight/n)*this.chartWidth}t+=e.weight/n*this.chartWidth}return 0}clampValue(e){return Math.min(Math.max(e,this.axis.ticks[0].value),this.axis.ticks[this.axis.ticks.length-1].value)}get totalSegmentsWidth(){return this.segments.reduce(((e,t)=>e+t.weight),0)}}const s=(e,t)=>t>0?`${e}-axis-marker-label`:`${e}-start-axis-marker-label`,l=(e,t)=>t>0?`${e}-axis-marker`:`${e}-start-axis-marker`;function i({chartName:t,markerText:a,offsetPercent:n}){return e.createElement("div",{className:`${l(t,n)}`,style:{left:`${n}%`}},e.createElement("div",{className:`nhsuk-font-size-16 nhsuk-u-secondary-text-color ${s(t,n)}`},a))}function c({model:t}){return e.createElement(e.Fragment,null,t.getAxisTicks().map((({label:a,value:n,isVisible:r})=>r&&e.createElement(i,{chartName:t.name,markerText:a,offsetPercent:n,key:a}))))}function o(){return e.createElement("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M6 9L0.803849 -9.78799e-07L11.1962 -7.02746e-08L6 9Z",fill:"black"}))}const u=(e,t)=>t<=20?`${e}-label-align-left`:t<=80?`${e}-label-align-center`:`${e}-label-align-right`;function m({chartName:t,value:a,offset:n,markerText:r}){return e.createElement("div",{className:`${t}-label-marker`},e.createElement("div",{className:`nhsuk-font-size-16 ${u(t,n)}`},r,e.createElement("span",{className:`${t}-value-marker`},a)))}function d({value:t,model:a,markerText:n}){const r=a.calculatePosition(t),s=Math.pow(10,1),l=Math.round(r*s)/s;return e.createElement(e.Fragment,null,e.createElement("div",{className:`${a.name}-arrow-marker`,style:{left:`${l}%`}},e.createElement(m,{chartName:a.name,value:t,markerText:n,offset:l}),e.createElement(o,null)),e.createElement("div",{className:`${a.name}-value-axis-marker`,style:{left:`${l}%`}}))}function h({value:t,styleClass:a}){return e.createElement("div",{className:a,style:{width:`${t}%`}})}function g({model:t}){return e.createElement(e.Fragment,null,t.getChartRegions().map((({value:t,styleClass:a})=>e.createElement(h,{value:t,styleClass:a,key:t}))))}const f=100;function p({config:t,value:a,markerText:n}){const s=new r(t,f);return e.createElement("div",{className:`${t.name}-graph nhsuk-u-margin-bottom-9`,"aria-hidden":"true"},e.createElement(c,{model:s}),e.createElement(d,{value:a,markerText:n,model:s}),e.createElement(g,{model:s}))}function b({element:t,text:a,className:n,wrapperClassName:r}){return e.createElement("div",{className:`nhsuk-chart-legend-key-wrapper ${null!=r?r:""}`},e.createElement("div",{className:`nhsuk-chart-legend-key ${null!=n?n:""}`},t),a)}function k({legendKeys:a,className:n}){return e.createElement(t.Card,{className:`${n} nhsuk-u-padding-3 nhsuk-chart-legend-card`},a.map((t=>e.createElement(b,Object.assign({key:t.text},t)))))}function y({legendKeys:t,className:a}){return e.createElement("div",{className:a},t.map((t=>e.createElement(b,Object.assign({key:t.text},t)))))}function v({legendKeys:t,borderWrapper:a=!0}){const n="nhsuk-u-margin-top-6 nhsuk-u-margin-bottom-3 nhsuk-u-secondary-text-color nhsuk-body-s";return e.createElement("div",{"aria-hidden":"true"},a?e.createElement(k,{legendKeys:t,className:n}):e.createElement(y,{legendKeys:t,className:n}))}const E={Underweight:"underweight",Healthy:"healthy",Overweight:"overweight"},w=Object.assign(Object.assign({},E),{Obese:"obese"}),x=Object.assign(Object.assign({},E),{Obese1:"obese1",Obese2:"obese2",Obese3:"obese3"});x.Underweight,x.Healthy,x.Underweight,x.Overweight,x.Healthy;class L{constructor(e){this.bounds={lowerBound:17.5,upperBounds:{[w.Underweight]:e.upper[x.Underweight].value,[w.Healthy]:e.upper[x.Healthy].value,[w.Overweight]:e.upper[x.Overweight].value,[w.Obese]:e.upper[x.Obese2].value}}}get chartRange(){return this.bounds.upperBounds[w.Obese]-this.bounds.lowerBound}classificationPercentage(e){return this.offsetPercentage(this.bounds.upperBounds[e])}offsetPercentage(e){return(e-this.bounds.lowerBound)/this.chartRange*100}}function N(){return e.createElement("svg",{viewBox:"1 1 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("g",{clipPath:"url(#clip0_1346_102759)"},e.createElement("path",{xmlns:"http://www.w3.org/2000/svg",d:"M1.93209 4.05025L1.57854 4.40381L1.93209 4.75736L6.17473 9L1.93209 13.2426L1.57854 13.5962L1.93209 13.9497L4.05341 16.0711L4.40697 16.4246L4.76052 16.0711L9.00316 11.8284L13.2458 16.0711L13.5994 16.4246L13.9529 16.0711L16.0742 13.9497L16.4278 13.5962L16.0742 13.2426L11.8316 9L16.0742 4.75736L16.4278 4.40381L16.0742 4.05025L13.9529 1.92893L13.5994 1.57538L13.2458 1.92893L9.00316 6.17157L4.76052 1.92893L4.40697 1.57538L4.05341 1.92893L1.93209 4.05025Z",fill:"black",stroke:"white"})))}function B({bmi:t,model:a}){const n=a.offsetPercentage(t);let r=0;if(n>0){const e=1,t=Math.pow(10,e);r=Math.round(n*t)/t}return e.createElement("div",{className:"nhsuk-bmi-chart-marker",style:{left:`${r}%`}},e.createElement(N,null))}function $({classification:t,model:a}){const n=a.classificationPercentage(t);return e.createElement("div",{className:`nhsuk-bmi-classification-${t}`,style:{width:`${n}%`}})}function T({model:t}){return e.createElement(e.Fragment,null,e.createElement($,{classification:w.Underweight,model:t}),e.createElement($,{classification:w.Healthy,model:t}),e.createElement($,{classification:w.Overweight,model:t}),e.createElement($,{classification:w.Obese,model:t}))}function O({markerText:t,offsetPercent:a}){return e.createElement("div",{className:"nhsuk-bmi-axis-marker",style:{left:`${a}%`}},e.createElement("div",{className:"nhsuk-bmi-axis-marker-label"},t))}function P({model:t}){return e.createElement(e.Fragment,null,e.createElement(O,{markerText:t.bounds.upperBounds[w.Underweight].toString(),offsetPercent:t.classificationPercentage(w.Underweight)}),e.createElement(O,{markerText:t.bounds.upperBounds[w.Healthy].toString(),offsetPercent:t.classificationPercentage(w.Healthy)}),e.createElement(O,{markerText:t.bounds.upperBounds[w.Overweight].toString(),offsetPercent:t.classificationPercentage(w.Overweight)}))}function S({classificationBounds:t,bmi:a}){const n=new L(t);return e.createElement("div",{className:"nhsuk-bmi-graph","aria-hidden":"true"},e.createElement(P,{model:n}),e.createElement(B,{bmi:a,model:n}),e.createElement(T,{model:n}))}const R={Low:"low",Healthy:"healthy",SlightlyRaised:"slightlyRaised",High:"high"};var C;function H({axisType:t,labelText:a,offsetPercent:n,applyLabelSpecificStyles:r=!0}){const s=`${C[t].toLowerCase()}-axis`,l=`nhsuk-bp-${s}-marker`,i=`nhsuk-bp-${s}-marker-${a}`;return e.createElement("div",{className:r?`${l} ${i}`:`${l}`,style:t===C.Systolic?{bottom:`${n}%`}:{left:`${n}%`}},e.createElement("div",{className:`nhsuk-bp-${s}-label`},a))}function U(e,t,a){return(e-a)/(t-a)*100}function j(e,t,a){return U(t[e].value,t[R.High].value,a)}function M({axisType:t,upperBounds:a,lowerBound:n}){const r={slightlyRaisedValueToCheck:85,slightlyRaisedValueToAdd:90};return e.createElement("div",null,e.createElement(H,{labelText:n.toString(),offsetPercent:0,axisType:t}),e.createElement(H,{labelText:a[R.Low].value.toString(),offsetPercent:j(R.Low,a,n),axisType:t}),e.createElement(H,{labelText:a[R.Healthy].value.toString(),offsetPercent:j(R.Healthy,a,n),axisType:t}),e.createElement(H,{labelText:a[R.SlightlyRaised].value.toString(),offsetPercent:j(R.SlightlyRaised,a,n),axisType:t,applyLabelSpecificStyles:a[R.SlightlyRaised].value===r.slightlyRaisedValueToCheck}),t===C.Diastolic&&a[R.SlightlyRaised].value===r.slightlyRaisedValueToCheck&&e.createElement(H,{labelText:r.slightlyRaisedValueToAdd.toString(),offsetPercent:U(r.slightlyRaisedValueToAdd,a[R.High].value,n),axisType:t}),e.createElement(H,{labelText:a[R.High].value.toString(),offsetPercent:100,axisType:t}))}function F({bounds:t}){return e.createElement(e.Fragment,null,e.createElement(M,{axisType:C.Systolic,upperBounds:t.systolic.upper,lowerBound:t.systolic.lower}),e.createElement(M,{axisType:C.Diastolic,upperBounds:t.diastolic.upper,lowerBound:t.diastolic.lower}))}function A(){return e.createElement("svg",{viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("g",{clipPath:"url(#clip0_1346_102759)"},e.createElement("path",{d:"M5.18718 8.36931L4.48008 9.07641L5.18718 9.78352L11.3744 15.9707L5.18718 22.1579L4.48008 22.865L5.18718 23.5721L8.36916 26.7541L9.07627 27.4612L9.78338 26.7541L15.9706 20.5669L22.1577 26.7541L22.8649 27.4612L23.572 26.7541L26.7539 23.5721L27.461 22.865L26.7539 22.1579L20.5668 15.9707L26.7539 9.78352L27.461 9.07641L26.7539 8.36931L23.572 5.18732L22.8649 4.48022L22.1577 5.18732L15.9706 11.3745L9.78338 5.18732L9.07627 4.48022L8.36916 5.18732L5.18718 8.36931Z",fill:"black",stroke:"white",strokeWidth:"2"})))}function K({systolicReading:t,diastolicReading:n,systolicLowerBound:r,systolicUpperBound:s,diastolicLowerBound:l,diastolicUpperBound:i}){const c=i-l,o=new a((t-r)/(s-r)).times(100),u=new a((n-l)/c).times(100),m=o.round(1),d=u.round(1);return e.createElement("div",{className:"nhsuk-bp-graph-marker",style:{left:`${d}%`,bottom:`${m}%`}},e.createElement(A,null))}function V(e,t,a){return(t[a].value-e)/(t.high.value-e)*100}function W(e){return`nhsuk-bp-classification-${e.toLowerCase()}`}function z({classification:t,bounds:a,renderAsBoundary:n=!1}){const r=V(a.diastolic.lower,a.diastolic.upper,t),s=V(a.systolic.lower,a.systolic.upper,t);return e.createElement("div",{className:n?"nhsuk-bp-region-boundary":W(t),style:{width:`${r}%`,height:`${s}%`}})}function D({bounds:t,renderAsBoundary:a=!1}){return e.createElement(e.Fragment,null,e.createElement(z,{classification:R.Low,bounds:t,renderAsBoundary:a}),e.createElement(z,{classification:R.Healthy,bounds:t,renderAsBoundary:a}),e.createElement(z,{classification:R.SlightlyRaised,bounds:t,renderAsBoundary:a}),!a&&e.createElement(z,{classification:R.High,bounds:t,renderAsBoundary:a}))}function _({firstInRow:t=!1,firstInColumn:a=!1}){let n="nhsuk-bp-graph-cell";return t&&(n+=" nhsuk-bp-first-in-row"),a&&(n+=" nhsuk-bp-first-in-column"),e.createElement("div",{className:n})}function q({bounds:t,graphLayout:a,reading:n}){const{systolic:r,diastolic:s}=n,{systolicLabel:l,diastolicLabel:i}=a;return e.createElement("div",{className:"nhsuk-body-s"},e.createElement("div",{className:"nhsuk-bp-systolic-legend-wrapper","aria-hidden":"true"},e.createElement("div",{className:"nhsuk-bp-systolic-legend-marker"}),e.createElement("span",null,l)),e.createElement("div",{className:"nhsuk-bp-graph","aria-hidden":"true"},e.createElement(F,{bounds:t}),e.createElement(K,{systolicReading:r,diastolicReading:s,systolicLowerBound:t.systolic.lower,systolicUpperBound:t.systolic.upper.high.value,diastolicLowerBound:t.diastolic.lower,diastolicUpperBound:t.diastolic.upper.high.value}),e.createElement(D,{bounds:t}),a.rows.map((t=>e.createElement("div",{key:t.id,className:"nhsuk-bp-graph-row"},t.cells.map((t=>e.createElement(_,Object.assign({key:t.id},t))))))),e.createElement(D,{bounds:t,renderAsBoundary:!0})),e.createElement("div",{className:"nhsuk-bp-diastolic-legend-wrapper","aria-hidden":"true"},e.createElement("div",{className:"nhsuk-bp-diastolic-legend-marker"}),e.createElement("span",null,i)))}!function(e){e[e.Systolic=0]="Systolic",e[e.Diastolic=1]="Diastolic"}(C||(C={})),a.RM=a.roundHalfEven;const I={[x.Underweight]:null,[x.Healthy]:x.Underweight,[x.Overweight]:x.Healthy};class Z{constructor(e){this.bounds={lowerBound:0,upperBounds:{[w.Underweight]:e.upper[x.Underweight].value,[w.Healthy]:e.upper[x.Healthy].value,[w.Overweight]:e.upper[x.Overweight].value}}}get chartRange(){return this.bounds.upperBounds[x.Overweight]-this.bounds.lowerBound}classificationPercentage(e){return this.offsetPercentage(this.bounds.upperBounds[e])}offsetPercentage(e){const t=this.chartRange;if(e<=2){const a=.08*t;return this.calculateOffset(e,E.Underweight,a)}if(e<=91){const a=.72*t,n=.08*t;return this.calculateOffset(e,E.Healthy,a)+n}const a=.2*t,n=.8*t;return this.calculateOffset(e,E.Overweight,a)+n}calculateOffset(e,t,a){const n=I[t]?this.bounds.upperBounds[I[t]]:0;return(e-n)/(this.bounds.upperBounds[t]-n)*a}clampedOffsetPercentage(e){const t=Math.max(1,Math.min(e,99));return this.offsetPercentage(t)}}function G({markerText:t,offsetPercent:a}){return e.createElement("div",{className:"nhsuk-cbmi-axis-marker",style:{left:`${a}%`}},e.createElement("div",{className:"nhsuk-font-size-16 nhsuk-cbmi-axis-marker-label"},t))}function J({model:t}){return e.createElement(e.Fragment,null,e.createElement(G,{markerText:t.bounds.upperBounds[E.Underweight].toString(),offsetPercent:t.classificationPercentage(E.Underweight)}),e.createElement(G,{markerText:t.bounds.upperBounds[E.Healthy].toString(),offsetPercent:t.classificationPercentage(E.Healthy)}))}const Q=e=>e<=20?"nhsuk-cbmi-chart-label-align-left":e<=80?"nhsuk-cbmi-chart-label-align-center":"nhsuk-cbmi-chart-label-align-right";function X({centile:t,markerText:a}){return e.createElement("div",{className:"nhsuk-cbmi-chart-label-marker"},e.createElement("div",{className:`nhsuk-u-font-size-19 ${Q(t.value)}`},a,e.createElement("span",{className:"nhsuk-cbmi-chart-centile-marker"},t.label)))}function Y({centile:t,model:a,markerText:n}){const r=a.clampedOffsetPercentage(t.value);let s=0;if(r>0){const e=1,t=Math.pow(10,e);s=Math.round(r*t)/t}return e.createElement("div",null,e.createElement("div",{className:"nhsuk-cbmi-chart-arrow-marker",style:{left:`${s}%`}},e.createElement(X,{centile:t,markerText:n}),e.createElement(o,null)),e.createElement("div",{className:"nhsuk-cbmi-chart-axis-marker",style:{left:`${s}%`}}))}function ee({classification:t,model:a}){const n=a.classificationPercentage(t);return e.createElement("div",{className:`nhsuk-cbmi-classification-${t}`,style:{width:`${n}%`}})}function te({model:t}){return e.createElement(e.Fragment,null,e.createElement(ee,{classification:E.Underweight,model:t}),e.createElement(ee,{classification:E.Healthy,model:t}),e.createElement(ee,{classification:E.Overweight,model:t}))}function ae({classificationBounds:t,centile:a,markerText:n}){const r=new Z(t);return e.createElement("div",{className:"nhsuk-cbmi-graph nhsuk-u-margin-bottom-9 ","aria-hidden":"true"},e.createElement(J,{model:r}),e.createElement(Y,{centile:a,markerText:n,model:r}),e.createElement(te,{model:r}))}exports.BarSliderChart=p,exports.BarSliderChartFigure=function({config:t,value:a,ariaLabel:n,markerText:r}){const s=Object.values(t.segments).filter((e=>null!=e.legend)).map((e=>({text:e.legend,className:`${t.name}-legend-key-${e.styleSuffix}`,wrapperClassName:`${t.name}-legend-marker`})));return e.createElement("figure",{className:"nhsuk-u-margin-0"},e.createElement("figcaption",{className:"nhsuk-u-visually-hidden"},n),e.createElement(p,{config:t,value:a,markerText:r}),e.createElement(v,{legendKeys:s,borderWrapper:!1}))},exports.BmiChart=S,exports.BmiChartFigure=function({classificationBounds:t,bmi:a,ariaLabel:n,legendKeys:r,legendMarkerText:s}){const l=((t,a)=>Object.entries(t).map((([e,t])=>({text:t,className:`nhsuk-bmi-legend-key-classification-${e}`}))).concat({text:a,className:"nhsuk-bmi-legend-key-marker",element:e.createElement(N,null)}))(r,s);return e.createElement("figure",{className:"nhsuk-u-margin-0"},e.createElement("figcaption",{className:"nhsuk-u-visually-hidden"},n),e.createElement(S,{classificationBounds:t,bmi:a}),e.createElement(v,{legendKeys:l,borderWrapper:!0}))},exports.BpChart=q,exports.BpChartFigure=function({bounds:t,graphLayout:a,reading:n,ariaLabel:r,legendKeys:s,legendMarkerText:l}){const i=((t,a)=>Object.entries(t).map((([e,t])=>({text:t,className:`nhsuk-bp-legend-key-classification-${e}`}))).concat({text:a,className:"nhsuk-bp-legend-key-marker",element:e.createElement(A,null)}))(s,l);return e.createElement("figure",{className:"nhsuk-u-margin-0"},e.createElement("figcaption",{className:"nhsuk-u-visually-hidden"},r),e.createElement(q,{bounds:t,reading:n,graphLayout:a}),e.createElement(v,{legendKeys:i}))},exports.ChartLegend=v,exports.ChildBmiChart=ae,exports.ChildBmiChartFigure=function({classificationBounds:t,centile:a,centileMarkerText:n,ariaLabel:r,legendKeys:s}){const l=Object.entries(s).map((([e,t])=>({text:t,className:`nhsuk-cbmi-legend-key-classification-${e}`,wrapperClassName:"nhsuk-cbmi-legend-marker"})));return e.createElement("figure",{className:"nhsuk-u-margin-0"},e.createElement("figcaption",{className:"nhsuk-u-visually-hidden"},r),e.createElement(ae,{classificationBounds:t,centile:a,markerText:n}),e.createElement(v,{legendKeys:l,borderWrapper:!1}))};
2
2
  //# sourceMappingURL=index.js.map