@balena/ui-shared-components 12.2.0-build-add-horizontal-bar-chart-db8d21032600e1691b782f35738d157b23185b6e-1 → 12.2.0-build-add-manage-columns-tracking-57187862023acb4b29b7aad932ba7521b790a439-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.
@@ -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 : [] })), showAddTagDialog && (tagKeys === null || tagKeys === void 0 ? void 0 : tagKeys.length) && (_jsx(AddTagHandler, { columns: columns, tagKeys: tagKeys, onClose: handleAddTagClose }))] }));
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-build-add-horizontal-bar-chart-db8d21032600e1691b782f35738d157b23185b6e-1",
3
+ "version": "12.2.0-build-add-manage-columns-tracking-57187862023acb4b29b7aad932ba7521b790a439-1",
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": "^6.0.0-beta.22",
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-10T20:45:27.362Z"
141
+ "publishedAt": "2025-04-15T13:56:03.369Z"
142
142
  }
143
143
  }
@@ -1,8 +0,0 @@
1
- export interface HorizontalBarChartProps {
2
- items: Array<{
3
- color: string;
4
- title: string;
5
- count: number;
6
- }>;
7
- }
8
- export declare const HorizontalBarChart: ({ items }: HorizontalBarChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,54 +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
- const Bar = styled('div', {
6
- name: 'Bar',
7
- slot: 'bar',
8
- })({
9
- width: '100%',
10
- height: 24,
11
- display: 'flex',
12
- borderRadius: token('shape.borderRadius.sm'),
13
- overflow: 'hidden',
14
- gap: 2,
15
- });
16
- const BarItem = styled('span', {
17
- name: 'BarItem',
18
- slot: 'bar-item',
19
- })({});
20
- const Legend = styled('ul')({
21
- display: 'inline',
22
- listStyle: 'none',
23
- padding: 0,
24
- margin: 0,
25
- });
26
- const LegendItem = styled('li')({
27
- display: 'inline-flex',
28
- marginRight: token('spacing.2'),
29
- alignItems: 'center',
30
- '&:before': {
31
- content: '""',
32
- backgroundColor: 'currentColor',
33
- borderRadius: '50%',
34
- width: '10px',
35
- height: '10px',
36
- display: 'inline-block',
37
- marginRight: token('spacing.1'),
38
- },
39
- });
40
- export const HorizontalBarChart = ({ items }) => {
41
- const { t } = useTranslation();
42
- const total = items.reduce((partialSum, a) => partialSum + a.count, 0);
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: {
49
- backgroundColor: item.color,
50
- width: `${(item.count / total) * 100}%`,
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))) })] }));
54
- };