@balena/ui-shared-components 12.2.0-build-add-horizontal-bar-chart-6ee5a259ba1b19526e22819624d07c39f1e8b246-1 → 12.2.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.
- package/dist/components/RJST/Lenses/types/table.js +6 -1
- package/dist/components/RJST/components/Table/TableActions.d.ts +2 -1
- package/dist/components/RJST/components/Table/TableActions.js +2 -1
- package/dist/components/RJST/components/Table/TableToolbar.d.ts +2 -1
- package/dist/components/RJST/components/Table/TableToolbar.js +2 -2
- package/dist/components/RJST/components/Table/index.d.ts +2 -1
- package/dist/components/RJST/components/Table/index.js +2 -2
- package/dist/hooks/useTranslations.js +0 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +3 -3
- package/dist/components/HorizontalBarChart/index.d.ts +0 -8
- package/dist/components/HorizontalBarChart/index.js +0 -51
|
@@ -161,7 +161,12 @@ const TableRenderer = ({ filtered, selected, properties, hasUpdateActions, check
|
|
|
161
161
|
columns: columnsAnalyticsObject,
|
|
162
162
|
changeType,
|
|
163
163
|
});
|
|
164
|
-
}, actions: actions !== null && actions !== void 0 ? actions : []
|
|
164
|
+
}, actions: actions !== null && actions !== void 0 ? actions : [], onManageColumnsOpen: () => {
|
|
165
|
+
var _a;
|
|
166
|
+
(_a = analytics.webTracker) === null || _a === void 0 ? void 0 : _a.track('Open manage columns', {
|
|
167
|
+
resource: model.resource,
|
|
168
|
+
});
|
|
169
|
+
} })), showAddTagDialog && (tagKeys === null || tagKeys === void 0 ? void 0 : tagKeys.length) && (_jsx(AddTagHandler, { columns: columns, tagKeys: tagKeys, onClose: handleAddTagClose }))] }));
|
|
165
170
|
};
|
|
166
171
|
export const table = {
|
|
167
172
|
slug: 'table',
|
|
@@ -5,6 +5,7 @@ interface TableActionsProps<T> {
|
|
|
5
5
|
columns: Array<RJSTEntityPropertyDefinition<T>>;
|
|
6
6
|
actions?: MenuItemProps[];
|
|
7
7
|
onColumnPreferencesChange?: ColumnPreferencesChangeProp<T>;
|
|
8
|
+
onManageColumnsOpen?: () => void;
|
|
8
9
|
}
|
|
9
|
-
export declare const TableActions: <T extends object>({ columns, actions, onColumnPreferencesChange, }: TableActionsProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const TableActions: <T extends object>({ columns, actions, onColumnPreferencesChange, onManageColumnsOpen, }: TableActionsProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -22,7 +22,7 @@ const SortableItem = ({ column, handleColumnSelection, }) => {
|
|
|
22
22
|
handleColumnSelection(column);
|
|
23
23
|
}, checked: column.selected }), label: typeof column.label === 'string' ? column.label : column.title })] })));
|
|
24
24
|
};
|
|
25
|
-
export const TableActions = ({ columns, actions, onColumnPreferencesChange, }) => {
|
|
25
|
+
export const TableActions = ({ columns, actions, onColumnPreferencesChange, onManageColumnsOpen, }) => {
|
|
26
26
|
const [anchorEl, setAnchorEl] = React.useState();
|
|
27
27
|
const theme = useTheme();
|
|
28
28
|
const { state: analyticsState } = useAnalyticsContext();
|
|
@@ -30,6 +30,7 @@ export const TableActions = ({ columns, actions, onColumnPreferencesChange, }) =
|
|
|
30
30
|
const open = Boolean(anchorEl);
|
|
31
31
|
const handleClick = (event) => {
|
|
32
32
|
setAnchorEl(event.currentTarget);
|
|
33
|
+
onManageColumnsOpen === null || onManageColumnsOpen === void 0 ? void 0 : onManageColumnsOpen();
|
|
33
34
|
};
|
|
34
35
|
const handleClose = () => {
|
|
35
36
|
setAnchorEl(undefined);
|
|
@@ -5,7 +5,8 @@ interface TableToolbarProps<T> {
|
|
|
5
5
|
numSelected?: number;
|
|
6
6
|
columns: Array<RJSTEntityPropertyDefinition<T>>;
|
|
7
7
|
actions?: MenuItemProps[];
|
|
8
|
+
onManageColumnsOpen?: () => void;
|
|
8
9
|
onColumnPreferencesChange?: ColumnPreferencesChangeProp<T>;
|
|
9
10
|
}
|
|
10
|
-
export declare const TableToolbar: <T extends object>({ numSelected, columns, actions, onColumnPreferencesChange, }: TableToolbarProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const TableToolbar: <T extends object>({ numSelected, columns, actions, onManageColumnsOpen, onColumnPreferencesChange, }: TableToolbarProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Stack, Typography } from '@mui/material';
|
|
3
3
|
import { TableActions } from './TableActions';
|
|
4
4
|
import { token } from '../../../../utils/token';
|
|
5
|
-
export const TableToolbar = ({ numSelected = 0, columns, actions, onColumnPreferencesChange, }) => {
|
|
5
|
+
export const TableToolbar = ({ numSelected = 0, columns, actions, onManageColumnsOpen, onColumnPreferencesChange, }) => {
|
|
6
6
|
return (_jsxs(Stack, { direction: "row", children: [numSelected > 0 && (_jsxs(Typography, { color: "inherit", variant: "bodySm", component: "div", sx: (theme) => ({
|
|
7
7
|
alignSelf: 'flex-end',
|
|
8
8
|
px: theme.spacing(2),
|
|
@@ -10,5 +10,5 @@ export const TableToolbar = ({ numSelected = 0, columns, actions, onColumnPrefer
|
|
|
10
10
|
borderRadius: `${token('shape.borderRadius.sm')} ${token('shape.borderRadius.sm')} 0 0`,
|
|
11
11
|
background: token('color.bg.subtle'),
|
|
12
12
|
boxShadow: 'inset 0px -1px 1px rgba(0,0,0,0.05)',
|
|
13
|
-
}), children: [_jsx("strong", { children: numSelected }), " selected"] })), _jsx(TableActions, { columns: columns, actions: actions, onColumnPreferencesChange: onColumnPreferencesChange })] }));
|
|
13
|
+
}), children: [_jsx("strong", { children: numSelected }), " selected"] })), _jsx(TableActions, { columns: columns, actions: actions, onColumnPreferencesChange: onColumnPreferencesChange, onManageColumnsOpen: onManageColumnsOpen })] }));
|
|
14
14
|
};
|
|
@@ -18,6 +18,7 @@ interface TableProps<T> {
|
|
|
18
18
|
onRowClick?: (entity: T, event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
19
19
|
onPageChange?: (page: number, itemsPerPage: number) => void;
|
|
20
20
|
onColumnPreferencesChange?: ColumnPreferencesChangeProp<T>;
|
|
21
|
+
onManageColumnsOpen?: () => void;
|
|
21
22
|
}
|
|
22
|
-
export declare const Table: <T extends object>({ rowKey, data, checkedItems, checkedState, columns, pagination, sort, actions, onCheck, onSort, onRowClick, getRowHref, onPageChange, onColumnPreferencesChange, }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const Table: <T extends object>({ rowKey, data, checkedItems, checkedState, columns, pagination, onManageColumnsOpen, sort, actions, onCheck, onSort, onRowClick, getRowHref, onPageChange, onColumnPreferencesChange, }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
23
24
|
export {};
|
|
@@ -20,7 +20,7 @@ const StyledMaterialTable = styled(MaterialTable)(() => ({
|
|
|
20
20
|
zIndex: 10,
|
|
21
21
|
},
|
|
22
22
|
}));
|
|
23
|
-
export const Table = ({ rowKey, data, checkedItems = [], checkedState, columns, pagination, sort, actions, onCheck, onSort, onRowClick, getRowHref, onPageChange, onColumnPreferencesChange, }) => {
|
|
23
|
+
export const Table = ({ rowKey, data, checkedItems = [], checkedState, columns, pagination, onManageColumnsOpen, sort, actions, onCheck, onSort, onRowClick, getRowHref, onPageChange, onColumnPreferencesChange, }) => {
|
|
24
24
|
var _a;
|
|
25
25
|
const { state: analytics } = useAnalyticsContext();
|
|
26
26
|
const lastSelected = React.useRef();
|
|
@@ -122,7 +122,7 @@ export const Table = ({ rowKey, data, checkedItems = [], checkedState, columns,
|
|
|
122
122
|
onCheck === null || onCheck === void 0 ? void 0 : onCheck(filteredArray, filteredArray.length > 0 ? 'some' : 'none');
|
|
123
123
|
};
|
|
124
124
|
}, [visibleRowsMap, checkedRowsMap, rowKey, checkedState, onCheck]);
|
|
125
|
-
return (_jsxs(Box, { sx: { width: '100%' }, children: [_jsx(TableToolbar, { numSelected: numSelected, columns: columns, actions: actions, onColumnPreferencesChange: onColumnPreferencesChange }), _jsx(TableContainer, { sx: { maxHeight: '70vh' }, children: _jsxs(StyledMaterialTable, { stickyHeader: true, children: [_jsx(TableHeader, { "data-display": "table-head", columns: columns, data: data, isServerSide: pagination === null || pagination === void 0 ? void 0 : pagination.serverSide, numSelected: numSelected, checkedState: checkedState, order: sort.direction, orderBy: sort.key, onSelectAllClick: onCheck, onRequestSort: handleOnSort, rowCount: totalItems }), _jsx(TableBody, { "data-display": "table-body", children: visibleRows.map((row, rowIndex) => {
|
|
125
|
+
return (_jsxs(Box, { sx: { width: '100%' }, children: [_jsx(TableToolbar, { numSelected: numSelected, columns: columns, actions: actions, onColumnPreferencesChange: onColumnPreferencesChange, onManageColumnsOpen: onManageColumnsOpen }), _jsx(TableContainer, { sx: { maxHeight: '70vh' }, children: _jsxs(StyledMaterialTable, { stickyHeader: true, children: [_jsx(TableHeader, { "data-display": "table-head", columns: columns, data: data, isServerSide: pagination === null || pagination === void 0 ? void 0 : pagination.serverSide, numSelected: numSelected, checkedState: checkedState, order: sort.direction, orderBy: sort.key, onSelectAllClick: onCheck, onRequestSort: handleOnSort, rowCount: totalItems }), _jsx(TableBody, { "data-display": "table-body", children: visibleRows.map((row, rowIndex) => {
|
|
126
126
|
const labelId = `enhanced-table-checkbox-${rowIndex}`;
|
|
127
127
|
const checked = isChecked(row);
|
|
128
128
|
const href = getRowHref === null || getRowHref === void 0 ? void 0 : getRowHref(row);
|
|
@@ -59,8 +59,6 @@ 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',
|
|
64
62
|
'labels.save_current_view': 'Save current view',
|
|
65
63
|
'aria_labels.remove_view': 'Delete the selected view',
|
|
66
64
|
'aria_labels.create_view': 'Create named view',
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ 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';
|
|
21
20
|
export { Code } from './components/Code';
|
|
22
21
|
export { CookiesBanner } from './components/CookiesBanner';
|
|
23
22
|
export type { CollapsedListProps } from './components/CollapsedList';
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,6 @@ 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';
|
|
11
10
|
export { Code } from './components/Code';
|
|
12
11
|
export { CookiesBanner } from './components/CookiesBanner';
|
|
13
12
|
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
|
|
3
|
+
"version": "12.2.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
|
19
19
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
20
20
|
"@mui/icons-material": "^6.3.1",
|
|
21
|
-
"@mui/lab": "
|
|
21
|
+
"@mui/lab": "6.0.0-beta.24",
|
|
22
22
|
"@mui/material": "^6.3.1",
|
|
23
23
|
"@mui/styled-engine-sc": "^6.3.1",
|
|
24
24
|
"@mui/x-data-grid": "^7.23.5",
|
|
@@ -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-15T13:56:03.369Z"
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -1,51 +0,0 @@
|
|
|
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 }) => {
|
|
38
|
-
const { t } = useTranslation();
|
|
39
|
-
const totalItems = useMemo(() => items.reduce((sum, item) => sum + item.count, 0), [items]);
|
|
40
|
-
const getTotalDevicesLabel = (count) => count > 1
|
|
41
|
-
? t('labels.total_devices_other', { count })
|
|
42
|
-
: t('labels.total_devices_one', { count });
|
|
43
|
-
return (_jsxs(Stack, { sx: { gap: token('spacing.2') }, children: [_jsx(Bar, { children: items
|
|
44
|
-
.filter((item) => item.count > 0)
|
|
45
|
-
.map((item) => (_jsx(Tooltip, { title: `${item.title}: ${getTotalDevicesLabel(item.count)}`, children: _jsx(BarItem, { sx: {
|
|
46
|
-
backgroundColor: item.color,
|
|
47
|
-
width: `${(item.count / totalItems) * 100}%`,
|
|
48
|
-
} }) }, item.title))) }), _jsx(Legend, { children: items
|
|
49
|
-
.filter((item) => item.count > 0)
|
|
50
|
-
.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))) })] }));
|
|
51
|
-
};
|