@balena/ui-shared-components 12.2.2-build-renovate-major-7-react-router-dom-6a1be028886aeeefaed345cf0c1cc563fe73b1ba-1 → 12.3.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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface HorizontalBarChartProps {
|
|
2
|
+
items: Array<{
|
|
3
|
+
color: string;
|
|
4
|
+
title: string;
|
|
5
|
+
count: number;
|
|
6
|
+
}>;
|
|
7
|
+
resourceLabel?: string;
|
|
8
|
+
resourceLabelPlural?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const HorizontalBarChart: ({ items, resourceLabel, resourceLabelPlural, }: HorizontalBarChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Stack, styled, Tooltip, Typography } from '@mui/material';
|
|
3
|
+
import { token } from '../../utils/token';
|
|
4
|
+
import { useTranslation } from '../../hooks/useTranslations';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
const Bar = styled('div')({
|
|
7
|
+
width: '100%',
|
|
8
|
+
height: 24,
|
|
9
|
+
display: 'flex',
|
|
10
|
+
borderRadius: token('shape.borderRadius.sm'),
|
|
11
|
+
overflow: 'hidden',
|
|
12
|
+
gap: 2,
|
|
13
|
+
});
|
|
14
|
+
const BarItem = styled('span')({
|
|
15
|
+
minWidth: 3,
|
|
16
|
+
});
|
|
17
|
+
const Legend = styled('ul')({
|
|
18
|
+
display: 'inline',
|
|
19
|
+
listStyle: 'none',
|
|
20
|
+
padding: 0,
|
|
21
|
+
margin: 0,
|
|
22
|
+
});
|
|
23
|
+
const LegendItem = styled('li')({
|
|
24
|
+
display: 'inline-flex',
|
|
25
|
+
marginRight: token('spacing.2'),
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
'&:before': {
|
|
28
|
+
content: '""',
|
|
29
|
+
backgroundColor: 'currentColor',
|
|
30
|
+
borderRadius: '50%',
|
|
31
|
+
width: '10px',
|
|
32
|
+
height: '10px',
|
|
33
|
+
display: 'inline-block',
|
|
34
|
+
marginRight: token('spacing.1'),
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
export const HorizontalBarChart = ({ items, resourceLabel, resourceLabelPlural, }) => {
|
|
38
|
+
const { t } = useTranslation();
|
|
39
|
+
const totalItems = useMemo(() => items.reduce((sum, item) => sum + item.count, 0), [items]);
|
|
40
|
+
const filteredItems = useMemo(() => items.filter((item) => item.count > 0), [items]);
|
|
41
|
+
const getTotalResourcesLabel = (count) => {
|
|
42
|
+
if (resourceLabel && resourceLabelPlural) {
|
|
43
|
+
return t('labels.total_resources', {
|
|
44
|
+
count,
|
|
45
|
+
resource: count > 1 ? resourceLabelPlural : resourceLabel,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return count;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return (_jsxs(Stack, { sx: { gap: token('spacing.2') }, children: [_jsx(Bar, { children: filteredItems.map((item) => (_jsx(Tooltip, { title: `${item.title}: ${getTotalResourcesLabel(item.count)}`, children: _jsx(BarItem, { sx: {
|
|
53
|
+
backgroundColor: item.color,
|
|
54
|
+
width: `${Math.floor((item.count / totalItems) * 100)}%`,
|
|
55
|
+
} }) }, item.title))) }), _jsx(Legend, { children: filteredItems.map((item) => (_jsx(Tooltip, { title: getTotalResourcesLabel(item.count), children: _jsx(LegendItem, { style: { color: item.color }, children: _jsx(Typography, { variant: "bodySm", color: token('color.text.subtle'), children: item.title }) }) }, item.title))) })] }));
|
|
56
|
+
};
|
|
@@ -59,6 +59,7 @@ const translationMap = {
|
|
|
59
59
|
'labels.views': 'Views',
|
|
60
60
|
'labels.filter_one': 'Filter',
|
|
61
61
|
'labels.filter_other': 'Filters',
|
|
62
|
+
'labels.total_resources': '{{count}} {{resource}}',
|
|
62
63
|
'labels.save_current_view': 'Save current view',
|
|
63
64
|
'aria_labels.remove_view': 'Delete the selected view',
|
|
64
65
|
'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.
|
|
3
|
+
"version": "12.3.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"react-dropzone": "^14.2.3",
|
|
45
45
|
"react-helmet": "^6.1.0",
|
|
46
46
|
"react-markdown": "^10.0.0",
|
|
47
|
-
"react-router-dom": "^
|
|
47
|
+
"react-router-dom": "^6.28.0",
|
|
48
48
|
"remark-breaks": "^4.0.0",
|
|
49
49
|
"remark-gfm": "^4.0.0",
|
|
50
50
|
"rimraf": "^6.0.0",
|
|
@@ -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-16T08:30:07.754Z"
|
|
142
142
|
}
|
|
143
143
|
}
|