@balena/ui-shared-components 12.2.0-build-add-horizontal-bar-chart-dae1f4cd0a78d7632496dbca8ebc3bd03fc9ee30-1 → 12.2.0-build-add-horizontal-bar-chart-0e478eeab27b27c6c8f2f14649da6ca7d3a74c14-1
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.
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Stack, styled, Tooltip, Typography } from '@mui/material';
|
|
3
3
|
import { token } from '../../utils/token';
|
|
4
|
+
import { useTranslation } from '../../hooks/useTranslations';
|
|
4
5
|
const Bar = styled('div', {
|
|
5
6
|
name: 'Bar',
|
|
6
7
|
slot: 'bar',
|
|
7
8
|
})({
|
|
8
9
|
width: '100%',
|
|
9
|
-
height:
|
|
10
|
+
height: 24,
|
|
10
11
|
display: 'flex',
|
|
11
12
|
borderRadius: token('shape.borderRadius.sm'),
|
|
12
13
|
overflow: 'hidden',
|
|
@@ -37,9 +38,17 @@ const LegendItem = styled('li')({
|
|
|
37
38
|
},
|
|
38
39
|
});
|
|
39
40
|
export const HorizontalBarChart = ({ items }) => {
|
|
41
|
+
const { t } = useTranslation();
|
|
40
42
|
const total = items.reduce((partialSum, a) => partialSum + a.count, 0);
|
|
41
|
-
|
|
43
|
+
const getTotalDevicesLabel = (count) => count > 1
|
|
44
|
+
? t('labels.total_devices_other', { count })
|
|
45
|
+
: t('labels.total_devices_one', { count });
|
|
46
|
+
return (_jsxs(Stack, { sx: { gap: token('spacing.2') }, children: [_jsx(Bar, { children: items
|
|
47
|
+
.filter((item) => item.count > 0)
|
|
48
|
+
.map((item) => (_jsx(Tooltip, { title: `${item.title}: ${getTotalDevicesLabel(item.count)}`, children: _jsx(BarItem, { sx: {
|
|
42
49
|
backgroundColor: item.color,
|
|
43
50
|
width: `${(item.count / total) * 100}%`,
|
|
44
|
-
} }) }, item.title))) }), _jsx(Legend, { children: items
|
|
51
|
+
} }) }, item.title))) }), _jsx(Legend, { children: items
|
|
52
|
+
.filter((item) => item.count > 0)
|
|
53
|
+
.map((item) => (_jsx(Tooltip, { title: getTotalDevicesLabel(item.count), children: _jsx(LegendItem, { style: { color: item.color }, children: _jsx(Typography, { variant: "bodySm", color: token('color.text.subtle'), children: item.title }) }) }, item.title))) })] }));
|
|
45
54
|
};
|
|
@@ -59,6 +59,8 @@ const translationMap = {
|
|
|
59
59
|
'labels.views': 'Views',
|
|
60
60
|
'labels.filter_one': 'Filter',
|
|
61
61
|
'labels.filter_other': 'Filters',
|
|
62
|
+
'labels.total_devices_one': '{{count}} device',
|
|
63
|
+
'labels.total_devices_other': '{{count}} devices',
|
|
62
64
|
'labels.save_current_view': 'Save current view',
|
|
63
65
|
'aria_labels.remove_view': 'Delete the selected view',
|
|
64
66
|
'aria_labels.create_view': 'Create named view',
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { FileWidget } from './components/Form/Widgets/FileWidget';
|
|
|
17
17
|
export type { OnFileReadParams } from './components/Form/Widgets/FileWidget';
|
|
18
18
|
export { PasswordWidget } from './components/Form/Widgets/PasswordWidget';
|
|
19
19
|
export { SelectWidget } from './components/Form/Widgets/SelectWidget';
|
|
20
|
+
export { HorizontalBarChart } from './components/HorizontalBarChart';
|
|
20
21
|
export { Code } from './components/Code';
|
|
21
22
|
export { CookiesBanner } from './components/CookiesBanner';
|
|
22
23
|
export type { CollapsedListProps } from './components/CollapsedList';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { RJSForm, Templates as RjsfTemplates } from './components/Form';
|
|
|
7
7
|
export { FileWidget } from './components/Form/Widgets/FileWidget';
|
|
8
8
|
export { PasswordWidget } from './components/Form/Widgets/PasswordWidget';
|
|
9
9
|
export { SelectWidget } from './components/Form/Widgets/SelectWidget';
|
|
10
|
+
export { HorizontalBarChart } from './components/HorizontalBarChart';
|
|
10
11
|
export { Code } from './components/Code';
|
|
11
12
|
export { CookiesBanner } from './components/CookiesBanner';
|
|
12
13
|
export { CollapsedList } from './components/CollapsedList';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/ui-shared-components",
|
|
3
|
-
"version": "12.2.0-build-add-horizontal-bar-chart-
|
|
3
|
+
"version": "12.2.0-build-add-horizontal-bar-chart-0e478eeab27b27c6c8f2f14649da6ca7d3a74c14-1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -138,6 +138,6 @@
|
|
|
138
138
|
},
|
|
139
139
|
"homepage": "https://github.com/balena-io/ui-shared-components#readme",
|
|
140
140
|
"versionist": {
|
|
141
|
-
"publishedAt": "2025-04-
|
|
141
|
+
"publishedAt": "2025-04-10T20:19:18.265Z"
|
|
142
142
|
}
|
|
143
143
|
}
|