nhsuk-tools-chart-components-react 1.0.0

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.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -0
  3. package/dist/cjs/bundle.css +598 -0
  4. package/dist/cjs/index.js +2 -0
  5. package/dist/cjs/index.js.map +1 -0
  6. package/dist/esm/bundle.css +598 -0
  7. package/dist/esm/components/blood-pressure/bp-chart-axes.js +2 -0
  8. package/dist/esm/components/blood-pressure/bp-chart-axes.js.map +1 -0
  9. package/dist/esm/components/blood-pressure/bp-chart-cell.js +2 -0
  10. package/dist/esm/components/blood-pressure/bp-chart-cell.js.map +1 -0
  11. package/dist/esm/components/blood-pressure/bp-chart-marker-icon.js +2 -0
  12. package/dist/esm/components/blood-pressure/bp-chart-marker-icon.js.map +1 -0
  13. package/dist/esm/components/blood-pressure/bp-chart-marker.js +2 -0
  14. package/dist/esm/components/blood-pressure/bp-chart-marker.js.map +1 -0
  15. package/dist/esm/components/blood-pressure/bp-chart-regions.js +2 -0
  16. package/dist/esm/components/blood-pressure/bp-chart-regions.js.map +1 -0
  17. package/dist/esm/components/blood-pressure/bp-chart.js +2 -0
  18. package/dist/esm/components/blood-pressure/bp-chart.js.map +1 -0
  19. package/dist/esm/components/blood-pressure/bp-figure-chart.js +2 -0
  20. package/dist/esm/components/blood-pressure/bp-figure-chart.js.map +1 -0
  21. package/dist/esm/components/bmi/bmi-chart-axes.js +2 -0
  22. package/dist/esm/components/bmi/bmi-chart-axes.js.map +1 -0
  23. package/dist/esm/components/bmi/bmi-chart-marker-icon.js +2 -0
  24. package/dist/esm/components/bmi/bmi-chart-marker-icon.js.map +1 -0
  25. package/dist/esm/components/bmi/bmi-chart-marker.js +2 -0
  26. package/dist/esm/components/bmi/bmi-chart-marker.js.map +1 -0
  27. package/dist/esm/components/bmi/bmi-chart-regions.js +2 -0
  28. package/dist/esm/components/bmi/bmi-chart-regions.js.map +1 -0
  29. package/dist/esm/components/bmi/bmi-chart.js +2 -0
  30. package/dist/esm/components/bmi/bmi-chart.js.map +1 -0
  31. package/dist/esm/components/bmi/bmi-figure-chart.js +2 -0
  32. package/dist/esm/components/bmi/bmi-figure-chart.js.map +1 -0
  33. package/dist/esm/components/chart-legend.js +2 -0
  34. package/dist/esm/components/chart-legend.js.map +1 -0
  35. package/dist/esm/components/child-bmi/cbmi-chart-axes.js +2 -0
  36. package/dist/esm/components/child-bmi/cbmi-chart-axes.js.map +1 -0
  37. package/dist/esm/components/child-bmi/cbmi-chart-marker-icon.js +2 -0
  38. package/dist/esm/components/child-bmi/cbmi-chart-marker-icon.js.map +1 -0
  39. package/dist/esm/components/child-bmi/cbmi-chart-marker.js +2 -0
  40. package/dist/esm/components/child-bmi/cbmi-chart-marker.js.map +1 -0
  41. package/dist/esm/components/child-bmi/cbmi-chart-regions.js +2 -0
  42. package/dist/esm/components/child-bmi/cbmi-chart-regions.js.map +1 -0
  43. package/dist/esm/components/child-bmi/cbmi-chart.js +2 -0
  44. package/dist/esm/components/child-bmi/cbmi-chart.js.map +1 -0
  45. package/dist/esm/components/child-bmi/cbmi-figure-chart.js +2 -0
  46. package/dist/esm/components/child-bmi/cbmi-figure-chart.js.map +1 -0
  47. package/dist/esm/custom-types/blood-pressure.types.js +2 -0
  48. package/dist/esm/custom-types/blood-pressure.types.js.map +1 -0
  49. package/dist/esm/custom-types/bmi.types.js +2 -0
  50. package/dist/esm/custom-types/bmi.types.js.map +1 -0
  51. package/dist/esm/custom-types/classifications.types.js +2 -0
  52. package/dist/esm/custom-types/classifications.types.js.map +1 -0
  53. package/dist/esm/index.js +2 -0
  54. package/dist/esm/index.js.map +1 -0
  55. package/dist/esm/models/bmi-chart.model.js +2 -0
  56. package/dist/esm/models/bmi-chart.model.js.map +1 -0
  57. package/dist/esm/models/cbmi-chart.model.js +2 -0
  58. package/dist/esm/models/cbmi-chart.model.js.map +1 -0
  59. package/dist/esm/src/__tests__/__helpers__/mocks/bmi-results.d.ts +29 -0
  60. package/dist/esm/src/__tests__/__helpers__/mocks/bp-results.d.ts +5 -0
  61. package/dist/esm/src/__tests__/__helpers__/mocks/cbmi-results.d.ts +21 -0
  62. package/dist/esm/src/__tests__/components/blood-pressure/bp-chart-figure.test.d.ts +1 -0
  63. package/dist/esm/src/__tests__/components/blood-pressure/bp-chart.test.d.ts +1 -0
  64. package/dist/esm/src/__tests__/components/bmi/bmi-chart-figure.test.d.ts +1 -0
  65. package/dist/esm/src/__tests__/components/bmi/bmi-chart.test.d.ts +1 -0
  66. package/dist/esm/src/__tests__/components/chart-legend.test.d.ts +1 -0
  67. package/dist/esm/src/__tests__/components/child-bmi/cbmi-chart-figure.test.d.ts +1 -0
  68. package/dist/esm/src/__tests__/components/child-bmi/cbmi-chart.test.d.ts +1 -0
  69. package/dist/esm/src/components/blood-pressure/bp-chart-axes.d.ts +18 -0
  70. package/dist/esm/src/components/blood-pressure/bp-chart-cell.d.ts +3 -0
  71. package/dist/esm/src/components/blood-pressure/bp-chart-marker-icon.d.ts +2 -0
  72. package/dist/esm/src/components/blood-pressure/bp-chart-marker.d.ts +12 -0
  73. package/dist/esm/src/components/blood-pressure/bp-chart-regions.d.ts +11 -0
  74. package/dist/esm/src/components/blood-pressure/bp-chart.d.ts +27 -0
  75. package/dist/esm/src/components/blood-pressure/bp-figure-chart.d.ts +37 -0
  76. package/dist/esm/src/components/bmi/bmi-chart-axes.d.ts +8 -0
  77. package/dist/esm/src/components/bmi/bmi-chart-marker-icon.d.ts +2 -0
  78. package/dist/esm/src/components/bmi/bmi-chart-marker.d.ts +7 -0
  79. package/dist/esm/src/components/bmi/bmi-chart-regions.d.ts +6 -0
  80. package/dist/esm/src/components/bmi/bmi-chart.d.ts +24 -0
  81. package/dist/esm/src/components/bmi/bmi-figure-chart.d.ts +33 -0
  82. package/dist/esm/src/components/chart-legend.d.ts +37 -0
  83. package/dist/esm/src/components/child-bmi/cbmi-chart-axes.d.ts +8 -0
  84. package/dist/esm/src/components/child-bmi/cbmi-chart-marker-icon.d.ts +1 -0
  85. package/dist/esm/src/components/child-bmi/cbmi-chart-marker.d.ts +9 -0
  86. package/dist/esm/src/components/child-bmi/cbmi-chart-regions.d.ts +6 -0
  87. package/dist/esm/src/components/child-bmi/cbmi-chart.d.ts +27 -0
  88. package/dist/esm/src/components/child-bmi/cbmi-figure-chart.d.ts +33 -0
  89. package/dist/esm/src/custom-types/blood-pressure.types.d.ts +29 -0
  90. package/dist/esm/src/custom-types/bmi.types.d.ts +41 -0
  91. package/dist/esm/src/custom-types/chart.types.d.ts +8 -0
  92. package/dist/esm/src/custom-types/classifications.types.d.ts +19 -0
  93. package/dist/esm/src/custom-types/threshold.types.d.ts +13 -0
  94. package/dist/esm/src/index.d.ts +14 -0
  95. package/dist/esm/src/models/bmi-chart.model.d.ts +16 -0
  96. package/dist/esm/src/models/cbmi-chart.model.d.ts +26 -0
  97. package/dist/esm/stories/Charts/Adult Bmi/Chart.stories.d.ts +56 -0
  98. package/dist/esm/stories/Charts/Adult Bmi/Figure.stories.d.ts +79 -0
  99. package/dist/esm/stories/Charts/Blood Pressure/Chart.stories.d.ts +122 -0
  100. package/dist/esm/stories/Charts/Blood Pressure/Figure.stories.d.ts +143 -0
  101. package/dist/esm/stories/Charts/Child Bmi/Chart.stories.d.ts +53 -0
  102. package/dist/esm/stories/Charts/Child Bmi/Figure.stories.d.ts +71 -0
  103. package/dist/esm/stories/Legend/ChartLegend.stories.d.ts +51 -0
  104. package/dist/index.d.ts +290 -0
  105. package/package.json +96 -0
@@ -0,0 +1,53 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { ChildBmiChart } from '@components/child-bmi/cbmi-chart';
3
+ declare const meta: Meta<typeof ChildBmiChart>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof ChildBmiChart>;
6
+ /**
7
+ *
8
+ * This component can be found in the `nhsuk-tools-chart-components` repository <a href="https://github.com/NHSDigital/nhsuk-tools-chart-components/tree/main/src/components/child-bmi" target="_blank" rel="noopener noreferrer">here</a>.
9
+ *
10
+ * It visualizes a Child's Body Mass Index (BMI) on a chart.
11
+ *
12
+ * ## Usage
13
+ *
14
+ * ```jsx
15
+ * <ChildBmiChart
16
+ * classificationBounds={classificationBounds}
17
+ * centile={{ value: 1, label: 'Below 2' }}
18
+ * markerText="The centile:"
19
+ * />
20
+ * ```
21
+ *
22
+ * ## Properties
23
+ *
24
+ * ### classificationBounds
25
+ * Defines the boundaries for different BMI classifications.
26
+ *
27
+ * This property provides a structured way to define the ranges for different BMI classifications, including both the numerical values and the corresponding labels for display.
28
+ *
29
+ * ```
30
+ * {
31
+ * lower: 0,
32
+ * upper: {
33
+ * [BaseClassifications.Underweight]: {
34
+ * value: 2,
35
+ * label: '2',
36
+ * },
37
+ * [BaseClassifications.Healthy]: {
38
+ * value: 91,
39
+ * label: '91',
40
+ * },
41
+ * [BaseClassifications.Overweight]: {
42
+ * value: 100,
43
+ * label: '100',
44
+ * },
45
+ * },
46
+ * };
47
+ * ```
48
+ * ### centile
49
+ * Represents the child BMI centile score.
50
+ *
51
+ * It consists of the numerical value and a textual description of the percentile score
52
+ */
53
+ export declare const Chart: Story;
@@ -0,0 +1,71 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { ChildBmiChartFigure } from '@components/child-bmi/cbmi-figure-chart';
3
+ declare const meta: Meta<typeof ChildBmiChartFigure>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof ChildBmiChartFigure>;
6
+ /**
7
+ *
8
+ * This component can be found in the `nhsuk-tools-chart-components` repository <a href="https://github.com/NHSDigital/nhsuk-tools-chart-components/tree/main/src/components/child-bmi" target="_blank" rel="noopener noreferrer">here</a>.
9
+ *
10
+ * Display a visual representation of a Child's BMI, including a chart, markers, and labels.
11
+ *
12
+ * ## Usage
13
+ *
14
+ * ```jsx
15
+ * <ChildBmiChartFigure
16
+ * ariaLabel="Your child's body mass index result is shown on a chart here. A full description can be found in the text below it"
17
+ * classificationBounds={classificationBounds}
18
+ * centile={{ value: 1, label: 'Below 2' }}
19
+ * centileMarkerText="The centile:"
20
+ * legendKeys={{
21
+ * underweight: 'Underweight range',
22
+ * healthy: 'Healthy weight range',
23
+ * overweight: 'Overweight range',
24
+ * }}
25
+ * />
26
+ * ```
27
+ *
28
+ * ## Properties
29
+ *
30
+ * ### classificationBounds
31
+ * Defines the boundaries for different BMI classifications.
32
+ *
33
+ * This property provides a structured way to define the ranges for different BMI classifications, including both the numerical values and the corresponding labels for display.
34
+ *
35
+ * ```
36
+ * {
37
+ * lower: 0,
38
+ * upper: {
39
+ * [BaseClassifications.Underweight]: {
40
+ * value: 2,
41
+ * label: '2',
42
+ * },
43
+ * [BaseClassifications.Healthy]: {
44
+ * value: 91,
45
+ * label: '91',
46
+ * },
47
+ * [BaseClassifications.Overweight]: {
48
+ * value: 100,
49
+ * label: '100',
50
+ * },
51
+ * },
52
+ * };
53
+ * ```
54
+ * ### ariaLabel
55
+ * This property provides a textual description of the figure for screen readers.
56
+ *
57
+ * ### centileMarkerText
58
+ * This label is used to identify the marker that represents the child's BMI percentile on the chart.
59
+ *
60
+ * ### centile
61
+ * Represents the child BMI centile score.
62
+ *
63
+ * It consists of the numerical value and a textual description of the percentile score
64
+ *
65
+ * ### legendKeys
66
+ * Defines the labels for different BMI categories.
67
+ *
68
+ * This property maps BMI categories to their corresponding labels, which will be displayed in the chart's legend.
69
+ *
70
+ */
71
+ export declare const Figure: Story;
@@ -0,0 +1,51 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { ChartLegend } from '@components/chart-legend';
3
+ /**
4
+ * This component can be found in the `nhsuk-tools-chart-components` repository <a href="https://github.com/NHSDigital/nhsuk-tools-chart-components/tree/main/src/components/" target="_blank" rel="noopener noreferrer">here</a>.
5
+ *
6
+ * Chart legend with styles for each legend key
7
+ * ## Usage
8
+ *
9
+ * ```jsx
10
+ * <ChartLegend
11
+ * borderWrapper
12
+ * legendKeys={[
13
+ * {
14
+ * text: 'First item',
15
+ * className: `nhsuk-cbmi-legend-key-classification-underweight`,
16
+ * },
17
+ * {
18
+ * text: 'Second item',
19
+ * className: `nhsuk-cbmi-legend-key-classification-healthy`,
20
+ * },
21
+ * {
22
+ * text: 'Third item',
23
+ * className: `nhsuk-cbmi-legend-key-classification-overweight`,
24
+ * }
25
+ * ]}
26
+ * />
27
+ * ```
28
+ * ## Properties
29
+ *
30
+ * ### borderWrapper
31
+ *
32
+ * Controls whether a border wrapper is applied around the legend items.
33
+ *
34
+ * ### legendKeys
35
+ * Defines the items that will be displayed in the legend.
36
+ *
37
+ * Each object in the array represents a legend item and has the following properties:
38
+ *
39
+ * - `text`: The text label that will be displayed for the legend item.
40
+ *
41
+ * - `className`: A CSS class that can be used to style the legend item. In this example, the classes are used to indicate different BMI classifications (underweight, healthy, overweight).
42
+ *
43
+ * - `element`: (Optional) A React component that can be rendered instead of the default text label.
44
+ *
45
+ */
46
+ declare const meta: Meta<typeof ChartLegend>;
47
+ export default meta;
48
+ type Story = StoryObj<typeof ChartLegend>;
49
+ export declare const WithBorder: Story;
50
+ export declare const Borderless: Story;
51
+ export declare const KeyWithElement: Story;
@@ -0,0 +1,290 @@
1
+ import { JSX as JSX$1 } from 'react';
2
+
3
+ type UpperBoundInequalityMethod = (a: number, b: number) => boolean;
4
+ type UpperBoundValue = {
5
+ value?: number;
6
+ label?: string;
7
+ inequalityMethod?: UpperBoundInequalityMethod;
8
+ };
9
+ type UpperBounds<TClassificationLevel extends string> = {
10
+ [key in TClassificationLevel]: UpperBoundValue;
11
+ };
12
+ type Bounds<TClassificationLevel extends string> = {
13
+ lower: number;
14
+ upper: UpperBounds<TClassificationLevel>;
15
+ };
16
+
17
+ declare const BaseClassifications: {
18
+ readonly Underweight: "underweight";
19
+ readonly Healthy: "healthy";
20
+ readonly Overweight: "overweight";
21
+ };
22
+ declare const BmiClassificationLabel: {
23
+ readonly Obese: "obese";
24
+ readonly Underweight: "underweight";
25
+ readonly Healthy: "healthy";
26
+ readonly Overweight: "overweight";
27
+ };
28
+ declare const BmiClassification: {
29
+ readonly Obese1: "obese1";
30
+ readonly Obese2: "obese2";
31
+ readonly Obese3: "obese3";
32
+ readonly Underweight: "underweight";
33
+ readonly Healthy: "healthy";
34
+ readonly Overweight: "overweight";
35
+ };
36
+ type BaseClassificationLevel = (typeof BaseClassifications)[keyof typeof BaseClassifications];
37
+ type BaseClassificationBounds = Bounds<BaseClassificationLevel>;
38
+ type BmiClassificationBounds = Bounds<BmiClassificationLevel>;
39
+ type BmiClassificationLevel = (typeof BmiClassification)[keyof typeof BmiClassification];
40
+ type BmiClassificationLevelLabel = (typeof BmiClassificationLabel)[keyof typeof BmiClassificationLabel];
41
+ type CentileValue = {
42
+ value: number;
43
+ label: string;
44
+ };
45
+ type ChildBmiLegendKeys = {
46
+ [key in BaseClassificationLevel]: string;
47
+ };
48
+ type BmiLegendKeys = {
49
+ [key in BmiClassificationLevelLabel]?: string;
50
+ };
51
+
52
+ /**
53
+ * The properties for @ChildBmiChart component
54
+ *
55
+ * @param {BaseClassificationBounds} classificationBounds - The child body mass index classification ranges
56
+ * @param {CentileValue} centile - The centile value and label
57
+ * @param {string} markerText - Marker text for the centile value
58
+ */
59
+ type ChildBmiChartProps = {
60
+ classificationBounds: BaseClassificationBounds;
61
+ centile: CentileValue;
62
+ markerText: string;
63
+ };
64
+ /**
65
+ * A component to display the child body mass index chart
66
+ *
67
+ * @typedef {object} ChildBmiChartProps
68
+ * @property {BaseClassificationBounds} classificationBounds - The child body mass index classification ranges
69
+ * @property {CentileValue} centile - The centile value and label
70
+ * @property {string} markerText - Marker text for the centile value
71
+ *
72
+ * @param {ChildBmiChartProps} props
73
+ * @returns {JSX.Element}
74
+ */
75
+ declare function ChildBmiChart({ classificationBounds, centile, markerText, }: Readonly<ChildBmiChartProps>): JSX$1.Element;
76
+
77
+ /**
78
+ * The properties for @ChildBmiChartFigure component
79
+ *
80
+ * @param {BaseClassificationBounds} classificationBounds - The child body mass index classification ranges
81
+ * @param {CentileValue} centile - The centile value and label
82
+ * @param {string} ariaLabel - The aria label for the chart figure
83
+ * @param {string} centileMarkerText - The marker text for the centile value
84
+ * @param {ChildBmiLegendKeys} legendKeys - The chart legend items
85
+ */
86
+ type ChildBmiChartFigureProps = {
87
+ classificationBounds: BaseClassificationBounds;
88
+ centile: CentileValue;
89
+ ariaLabel: string;
90
+ centileMarkerText: string;
91
+ legendKeys: ChildBmiLegendKeys;
92
+ };
93
+ /**
94
+ * A component to display the child body mass index chart figure
95
+ *
96
+ * @typedef {object} ChildBmiChartFigureProps
97
+ * @property {BaseClassificationBounds} classificationBounds - The child body mass index classification ranges
98
+ * @property {CentileValue} centile - The centile value and label
99
+ * @property {string} centileMarkerText - The marker text for the centile value
100
+ * @property {string} ariaLabel - The aria label for the chart figure
101
+ * @property {ChildBmiLegendKeys} legendKeys - The chart legend items
102
+ *
103
+ * @param {ChildBmiChartFigureProps} props
104
+ * @returns {JSX.Element}
105
+ */
106
+ declare function ChildBmiChartFigure({ classificationBounds, centile, centileMarkerText, ariaLabel, legendKeys, }: Readonly<ChildBmiChartFigureProps>): JSX$1.Element;
107
+
108
+ /**
109
+ * The properties for @BmiChart component
110
+ *
111
+ * @param {classificationBounds} classificationBounds - The body mass index classification ranges
112
+ * @param {number} bmi - The body mass index value
113
+ */
114
+ type BmiChartProps = {
115
+ classificationBounds: BmiClassificationBounds;
116
+ bmi: number;
117
+ };
118
+ /**
119
+ * A component to display the body mass index chart
120
+ *
121
+ * @typedef {object} BmiChartProps
122
+ * @property {classificationBounds} classificationBounds - The body mass index classification ranges
123
+ * @property {number} bmi - The body mass index value
124
+ *
125
+ * @param {BmiChartProps} props
126
+ * @returns {JSX.Element}
127
+ */
128
+ declare function BmiChart({ classificationBounds, bmi, }: Readonly<BmiChartProps>): JSX$1.Element;
129
+
130
+ /**
131
+ * The properties for @BmiChartFigure component
132
+ *
133
+ * @param {classificationBounds} classificationBounds - The body mass index classification ranges
134
+ * @param {number} bmi - The body mass index value
135
+ * @param {string} ariaLabel - The aria label for the chart figure
136
+ * @param {BmiLegendKeys} legendKeys - The chart legend items
137
+ * @param {string} legendMarkerText The chart legend marker text
138
+ */
139
+ type BmiChartFigureProps = {
140
+ classificationBounds: BmiClassificationBounds;
141
+ bmi: number;
142
+ ariaLabel: string;
143
+ legendKeys: BmiLegendKeys;
144
+ legendMarkerText: string;
145
+ };
146
+ /**
147
+ * A component to display the body mass index chart figure
148
+ *
149
+ * @typedef {object} BmiChartFigureProps
150
+ * @property {classificationBounds} classificationBounds - The body mass index classification ranges
151
+ * @property {number} bmi - The body mass index value
152
+ * @property {string} ariaLabel - The aria label for the chart figure
153
+ * @property {BmiLegendKeys} legendKeys - The chart legend items
154
+ * @property {string} legendMarkerText The chart legend marker text
155
+ *
156
+ * @param {BmiChartFigureProps} props
157
+ * @returns {JSX.Element}
158
+ */
159
+ declare function BmiChartFigure({ classificationBounds, bmi, ariaLabel, legendKeys, legendMarkerText, }: Readonly<BmiChartFigureProps>): JSX$1.Element;
160
+
161
+ declare const BpClassificationLevel: {
162
+ readonly Low: "0";
163
+ readonly Healthy: "1";
164
+ readonly SlightlyRaised: "2";
165
+ readonly High: "3";
166
+ readonly VeryHigh: "4";
167
+ };
168
+ type BpClassificationLevelType = (typeof BpClassificationLevel)[keyof typeof BpClassificationLevel];
169
+ type BpLegendKeys = {
170
+ [key in keyof typeof BpClassificationLevel as Lowercase<string>]: string;
171
+ };
172
+ type BpReadingValue = {
173
+ systolic: number;
174
+ diastolic: number;
175
+ };
176
+ type BpCellConfiguration = {
177
+ id: string;
178
+ firstInRow?: boolean;
179
+ firstInColumn?: boolean;
180
+ };
181
+ type BpRowConfiguration = {
182
+ id: string;
183
+ cells: BpCellConfiguration[];
184
+ };
185
+ type BpGraphLayout = {
186
+ systolicLabel: string;
187
+ diastolicLabel: string;
188
+ rows: BpRowConfiguration[];
189
+ };
190
+
191
+ type BpBounds = {
192
+ [key in keyof BpReadingValue]: Bounds<BpClassificationLevelType>;
193
+ };
194
+
195
+ /**
196
+ * The properties for @BpChart component
197
+ *
198
+ * @param {BpBounds} bounds - The blood pressure classification ranges
199
+ * @param {BpGraphLayout} graphLayout - The graph layout contains rows configuration and systolic/diastolic chart labels
200
+ * @param {BpReadingValue} readings - The systolic and diastolic blood pressure readings
201
+ */
202
+ type BpChartProps = {
203
+ bounds: BpBounds;
204
+ graphLayout: BpGraphLayout;
205
+ reading: BpReadingValue;
206
+ };
207
+ /**
208
+ * A component to display the blood pressure chart
209
+ *
210
+ * @typedef {object} BpChartProps
211
+ * @property {BpBounds} bounds - The blood pressure classification ranges
212
+ * @property {BpGraphLayout} graphLayout - The graph layout contains rows configuration and systolic/diastolic chart labels
213
+ * @property {BpReadingValue} readings - The systolic and diastolic blood pressure readings
214
+ *
215
+ * @param {BpChartProps} props
216
+ * @returns {JSX.Element}
217
+ */
218
+ declare function BpChart({ bounds, graphLayout, reading, }: Readonly<BpChartProps>): JSX.Element;
219
+
220
+ /**
221
+ * The properties for @BpChartFigure component
222
+ *
223
+ * @param {BpBounds} bounds - The blood pressure classification ranges
224
+ * @param {BpGraphLayout} graphLayout - The graph layout with row configuration and systolic/diastolic chart labels
225
+ * @param {BpReadingValue} readings - The systolic and diastolic blood pressure readings
226
+ * @param {string }ariaLabel - The aria label for the chart figure
227
+ * @param {BpLegendKeys} legendKeys - The legend keys for the chart figure
228
+ * @param {string } legendMarkerText - The legend marker text
229
+ */
230
+ type BpChartFigureProps = {
231
+ bounds: BpBounds;
232
+ graphLayout: BpGraphLayout;
233
+ reading: BpReadingValue;
234
+ ariaLabel: string;
235
+ legendKeys: BpLegendKeys;
236
+ legendMarkerText: string;
237
+ };
238
+ /**
239
+ * A component to display the blood pressure chart figure
240
+ *
241
+ * @typedef {object} BpChartFigureProps
242
+ * @property {BpBounds} bounds - The blood pressure classification ranges
243
+ * @property {BpGraphLayout} graphLayout - The graph layout with row configuration and systolic/diastolic chart labels
244
+ * @property {BpReadingValue} readings - The systolic and diastolic blood pressure readings
245
+ * @property {string }ariaLabel - The aria label for the chart figure
246
+ * @property {BpLegendKeys} legendKeys - The legend keys for the chart figure
247
+ * @property {string } legendMarkerText - The legend marker text
248
+ *
249
+ * @param {BpChartFigureProps} props
250
+ * @returns {JSX.Element}
251
+ */
252
+ declare function BpChartFigure({ bounds, graphLayout, reading, ariaLabel, legendKeys, legendMarkerText, }: Readonly<BpChartFigureProps>): JSX$1.Element;
253
+
254
+ /**
255
+ * The ChartLegendKey type
256
+ *
257
+ * @param {string} className - Optional: The classname of the legend key
258
+ * @param {string} wrapperClassName - Optional: The wrapper classname for the card component
259
+ * @param {string} text - The text of the legend key
260
+ * @param {BmiLegendKeys} JSX.Element - Optional: A JSX.Element of the legend key
261
+ */
262
+ type ChartLegendKey = {
263
+ className?: string;
264
+ wrapperClassName?: string;
265
+ text: string;
266
+ element?: JSX$1.Element;
267
+ };
268
+ /**
269
+ * The properties for @ChartLegend component
270
+ *
271
+ * @param {ChartLegendKey[]} legendKeys - The list of legend keys
272
+ * @param {boolean} borderWrapper - Optional: A boolean value to enable or disable a border around the legend items with a set max width of 250px
273
+ */
274
+ type ChartLegendProps = {
275
+ legendKeys: ChartLegendKey[];
276
+ borderWrapper?: boolean;
277
+ };
278
+ /**
279
+ * A component to display a legend associated with a chart, consisting of a card which wraps a set of legend keys.
280
+ *
281
+ * @typedef {object} ChartLegendProps
282
+ * @property {ChartLegendKey[]} legendKeys - The list of legend keys
283
+ * @property {boolean} borderWrapper - Optional: A boolean value to enable or disable a border around the legend items with a set max width of 250px
284
+ *
285
+ * @param {ChartLegendProps} props
286
+ * @returns {JSX.Element}
287
+ */
288
+ declare function ChartLegend({ legendKeys, borderWrapper, }: Readonly<ChartLegendProps>): JSX$1.Element;
289
+
290
+ export { BmiChart, BmiChartFigure, type BmiChartFigureProps, type BmiChartProps, BpChart, BpChartFigure, type BpChartFigureProps, type BpChartProps, ChartLegend, type ChartLegendKey, type ChartLegendProps, ChildBmiChart, ChildBmiChartFigure, type ChildBmiChartFigureProps, type ChildBmiChartProps };
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "nhsuk-tools-chart-components-react",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "rimraf dist && rollup -c rollup.config.mjs",
10
+ "build-storybook": "storybook build",
11
+ "storybook": "storybook dev -p 6006",
12
+ "watch": "npm run build -- --watch",
13
+ "lint": "eslint ./src",
14
+ "test": "jest",
15
+ "test:watch": "jest --watch",
16
+ "test:ci": "jest --ci",
17
+ "prepare": "is-ci || husky install && npm run build"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/NHSDigital/nhsuk-tools-chart-components.git"
25
+ },
26
+ "author": {
27
+ "name": "NHS England"
28
+ },
29
+ "license": "MIT",
30
+ "devDependencies": {
31
+ "@chromatic-com/storybook": "^1.9.0",
32
+ "@rollup/plugin-commonjs": "^25.0.7",
33
+ "@rollup/plugin-node-resolve": "^15.2.3",
34
+ "@rollup/plugin-terser": "^0.4.4",
35
+ "@rollup/plugin-typescript": "^11.1.6",
36
+ "@storybook/addon-actions": "^8.0.5",
37
+ "@storybook/addon-essentials": "^8.0.5",
38
+ "@storybook/addon-interactions": "^8.3.2",
39
+ "@storybook/addon-links": "^8.0.5",
40
+ "@storybook/addon-onboarding": "^8.3.2",
41
+ "@storybook/addon-styling": "^1.3.7",
42
+ "@storybook/addon-styling-webpack": "^1.0.0",
43
+ "@storybook/blocks": "^8.0.5",
44
+ "@storybook/manager-api": "^8.0.5",
45
+ "@storybook/preview-api": "^8.0.5",
46
+ "@storybook/react-vite": "^8.0.5",
47
+ "@storybook/test": "^8.3.2",
48
+ "@storybook/theming": "^8.0.5",
49
+ "@testing-library/dom": "^8.20.1",
50
+ "@testing-library/jest-dom": "^5.17.0",
51
+ "@testing-library/react": "^15.0.7",
52
+ "@testing-library/user-event": "^13.5.0",
53
+ "@types/big.js": "^6.2.2",
54
+ "@types/jest": "^29.5.12",
55
+ "@types/react": "^18.2.0",
56
+ "@types/react-dom": "^18.2.0",
57
+ "@types/rollup-plugin-peer-deps-external": "^2.2.5",
58
+ "eslint": "^8.27.0",
59
+ "eslint-config-airbnb": "^19.0.4",
60
+ "eslint-config-airbnb-typescript": "^17.0.0",
61
+ "eslint-config-prettier": "^8.5.0",
62
+ "eslint-plugin-sonarjs": "^0.16.0",
63
+ "eslint-plugin-storybook": "^0.8.0",
64
+ "husky": "^8.0.0",
65
+ "is-ci": "^3.0.1",
66
+ "jest": "^29.7.0",
67
+ "jest-environment-jsdom": "^29.3.1",
68
+ "jest-junit": "^14.0.1",
69
+ "jest-sonar-reporter": "^2.0.0",
70
+ "@storybook/react": "^8.0.5",
71
+ "lint-staged": "^13.1.0",
72
+ "prettier": "^2.7.1",
73
+ "rimraf": "^3.0.2",
74
+ "rollup": "^4.13.0",
75
+ "rollup-plugin-dts": "^6.1.0",
76
+ "rollup-plugin-peer-deps-external": "^2.2.4",
77
+ "rollup-plugin-preserve-directives": "^0.4.0",
78
+ "rollup-plugin-scss": "^4.0.0",
79
+ "rollup-plugin-tsconfig-paths": "^1.5.2",
80
+ "sass": "^1.77.4",
81
+ "storybook": "^8.0.5",
82
+ "ts-jest": "^29.0.3",
83
+ "ts-node": "^10.9.2",
84
+ "tsconfig-paths": "^4.2.0",
85
+ "typescript": "^4.9.5",
86
+ "vite": "^4.5.3",
87
+ "vite-tsconfig-paths": "^4.3.2"
88
+ },
89
+ "peerDependencies": {
90
+ "big.js": "^6.2.2",
91
+ "nhsuk-frontend": ">=8.0.0 <9.0.0",
92
+ "nhsuk-react-components": ">=4.0.0 <5.0.0",
93
+ "react": ">=16.8.0",
94
+ "react-dom": ">=16.8.0"
95
+ }
96
+ }