@astral/ui 0.37.0 → 0.38.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/ActionCell/ActionCell.js +1 -1
- package/ContentState/ContentState.js +2 -1
- package/ContentState/styles.d.ts +5 -0
- package/ContentState/styles.js +10 -0
- package/DataGrid/DataGrid.d.ts +1 -1
- package/DataGrid/DataGrid.js +2 -2
- package/DataGrid/DataGridBody/DataGridBody.d.ts +1 -1
- package/DataGrid/DataGridBody/DataGridBody.js +8 -3
- package/DataGrid/DataGridBody/types.d.ts +1 -0
- package/DataGrid/types.d.ts +1 -0
- package/IconDropdownButton/IconDropdownButton.js +1 -1
- package/esm/ActionCell/ActionCell.js +1 -1
- package/esm/ContentState/ContentState.js +2 -1
- package/esm/ContentState/styles.d.ts +5 -0
- package/esm/ContentState/styles.js +7 -0
- package/esm/DataGrid/DataGrid.d.ts +1 -1
- package/esm/DataGrid/DataGrid.js +2 -2
- package/esm/DataGrid/DataGridBody/DataGridBody.d.ts +1 -1
- package/esm/DataGrid/DataGridBody/DataGridBody.js +8 -3
- package/esm/DataGrid/DataGridBody/types.d.ts +1 -0
- package/esm/DataGrid/types.d.ts +1 -0
- package/esm/IconDropdownButton/IconDropdownButton.js +1 -1
- package/esm/theme/components/MuiOutlinedInput.js +1 -2
- package/esm/theme/components/MuiTableRow.d.ts +3 -0
- package/esm/theme/components/MuiTableRow.js +13 -0
- package/esm/theme/components/components.js +2 -0
- package/esm/theme/palette/palette.js +1 -1
- package/package.json +2 -2
- package/theme/components/MuiOutlinedInput.js +1 -2
- package/theme/components/MuiTableRow.d.ts +3 -0
- package/theme/components/MuiTableRow.js +16 -0
- package/theme/components/components.js +2 -0
- package/theme/palette/palette.js +1 -1
package/ActionCell/ActionCell.js
CHANGED
|
@@ -46,6 +46,6 @@ function ActionCell(_a) {
|
|
|
46
46
|
return ((0, jsx_runtime_1.jsx)(MenuItem_1.MenuItem, __assign({ onClick: handleActionClick(onClick) }, { children: name }), name));
|
|
47
47
|
}) }), void 0));
|
|
48
48
|
}, [secondary, handleActionClick]);
|
|
49
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.ActionCellWrapper, { children: [main.map(function (action) { return renderMainAction(action); }), renderSecondaryActions] }, void 0));
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.ActionCellWrapper, __assign({ onClick: function (event) { return event.stopPropagation(); } }, { children: [main.map(function (action) { return renderMainAction(action); }), renderSecondaryActions] }), void 0));
|
|
50
50
|
}
|
|
51
51
|
exports.ActionCell = ActionCell;
|
|
@@ -15,10 +15,11 @@ exports.ContentState = void 0;
|
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
var react_1 = require("react");
|
|
17
17
|
var __1 = require("..");
|
|
18
|
+
var styles_1 = require("./styles");
|
|
18
19
|
var ContentState = function (props) {
|
|
19
20
|
var isLoading = props.isLoading, _a = props.loadingContent, LoadingContent = _a === void 0 ? (0, jsx_runtime_1.jsx)(__1.CircularProgress, { color: "primary" }, void 0) : _a, isError = props.isError, errorState = props.errorState, isCustom = props.isCustom, customState = props.customState, children = props.children;
|
|
20
21
|
if (isLoading)
|
|
21
|
-
return (0, jsx_runtime_1.jsx)(
|
|
22
|
+
return (0, jsx_runtime_1.jsx)(styles_1.LoadingContainer, { children: LoadingContent }, void 0);
|
|
22
23
|
if (isCustom && customState) {
|
|
23
24
|
return (0, jsx_runtime_1.jsx)(__1.Placeholder, __assign({}, customState), void 0);
|
|
24
25
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const LoadingContainer: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.LoadingContainer = void 0;
|
|
8
|
+
var styles_1 = require("../styles");
|
|
9
|
+
exports.LoadingContainer = styles_1.styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n"], ["\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n"])));
|
|
10
|
+
var templateObject_1;
|
package/DataGrid/DataGrid.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DataGridProps } from './types';
|
|
3
|
-
export declare function DataGrid<T>({ columns, rows, selectedRows, sorting, maxHeight, minDisplayRows, onSelectRow, Footer, loading, onSort, keyId, }: DataGridProps<T>): JSX.Element;
|
|
3
|
+
export declare function DataGrid<T>({ columns, rows, selectedRows, sorting, maxHeight, minDisplayRows, onRowClick, onSelectRow, Footer, loading, onSort, keyId, }: DataGridProps<T>): JSX.Element;
|
package/DataGrid/DataGrid.js
CHANGED
|
@@ -32,7 +32,7 @@ var DataGridBody_1 = require("./DataGridBody");
|
|
|
32
32
|
var DataGridLoader_1 = __importDefault(require("./DataGridLoader/DataGridLoader"));
|
|
33
33
|
var styled_1 = require("./styled");
|
|
34
34
|
function DataGrid(_a) {
|
|
35
|
-
var columns = _a.columns, _b = _a.rows, rows = _b === void 0 ? [] : _b, _c = _a.selectedRows, selectedRows = _c === void 0 ? [] : _c, _d = _a.sorting, sorting = _d === void 0 ? [] : _d, maxHeight = _a.maxHeight, _e = _a.minDisplayRows, minDisplayRows = _e === void 0 ? 10 : _e, onSelectRow = _a.onSelectRow, Footer = _a.Footer, loading = _a.loading, onSort = _a.onSort, keyId = _a.keyId;
|
|
35
|
+
var columns = _a.columns, _b = _a.rows, rows = _b === void 0 ? [] : _b, _c = _a.selectedRows, selectedRows = _c === void 0 ? [] : _c, _d = _a.sorting, sorting = _d === void 0 ? [] : _d, maxHeight = _a.maxHeight, _e = _a.minDisplayRows, minDisplayRows = _e === void 0 ? 10 : _e, onRowClick = _a.onRowClick, onSelectRow = _a.onSelectRow, Footer = _a.Footer, loading = _a.loading, onSort = _a.onSort, keyId = _a.keyId;
|
|
36
36
|
var selectable = Boolean(onSelectRow);
|
|
37
37
|
var handleSelectAllRows = function (event) {
|
|
38
38
|
if (!onSelectRow)
|
|
@@ -59,6 +59,6 @@ function DataGrid(_a) {
|
|
|
59
59
|
return !selectedRows.find(function (selectedRow) { return selectedRow[keyId] === row[keyId]; });
|
|
60
60
|
}).length;
|
|
61
61
|
}, [rows, selectedRows, keyId]);
|
|
62
|
-
return ((0, jsx_runtime_1.jsxs)(styled_1.DataGridContainer, { children: [(0, jsx_runtime_1.jsxs)(styled_1.StyledTableContainer, __assign({ maxHeight: maxHeight }, { children: [(0, jsx_runtime_1.jsxs)(Table_1.Table, __assign({ stickyHeader: true }, { children: [(0, jsx_runtime_1.jsx)(DataGridHead_1.DataGridHead, { onSort: onSort, rowsCount: rows.length, uncheckedRowsCount: uncheckedRowsCount, onSelectAllRows: handleSelectAllRows, selectable: selectable, sorting: sorting, columns: columns }, void 0), (0, jsx_runtime_1.jsx)(DataGridBody_1.DataGridBody, { keyId: keyId, selectedRows: selectedRows, minDisplayRows: minDisplayRows, onSelectRow: handleSelectRow, selectable: selectable, rows: rows, columns: columns }, void 0)] }), void 0), (0, jsx_runtime_1.jsx)(DataGridLoader_1.default, { loading: loading }, void 0)] }), void 0), Footer] }, void 0));
|
|
62
|
+
return ((0, jsx_runtime_1.jsxs)(styled_1.DataGridContainer, { children: [(0, jsx_runtime_1.jsxs)(styled_1.StyledTableContainer, __assign({ maxHeight: maxHeight }, { children: [(0, jsx_runtime_1.jsxs)(Table_1.Table, __assign({ stickyHeader: true }, { children: [(0, jsx_runtime_1.jsx)(DataGridHead_1.DataGridHead, { onSort: onSort, rowsCount: rows.length, uncheckedRowsCount: uncheckedRowsCount, onSelectAllRows: handleSelectAllRows, selectable: selectable, sorting: sorting, columns: columns }, void 0), (0, jsx_runtime_1.jsx)(DataGridBody_1.DataGridBody, { keyId: keyId, selectedRows: selectedRows, minDisplayRows: minDisplayRows, onRowClick: onRowClick, onSelectRow: handleSelectRow, selectable: selectable, rows: rows, columns: columns }, void 0)] }), void 0), (0, jsx_runtime_1.jsx)(DataGridLoader_1.default, { loading: loading }, void 0)] }), void 0), Footer] }, void 0));
|
|
63
63
|
}
|
|
64
64
|
exports.DataGrid = DataGrid;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DataGridBodyProps } from './types';
|
|
3
|
-
export declare function DataGridBody<T>({ rows, columns, selectable, onSelectRow, selectedRows, minDisplayRows, keyId, }: DataGridBodyProps<T>): JSX.Element;
|
|
3
|
+
export declare function DataGridBody<T>({ rows, columns, selectable, onRowClick, onSelectRow, selectedRows, minDisplayRows, keyId, }: DataGridBodyProps<T>): JSX.Element;
|
|
@@ -19,21 +19,26 @@ var DataGridCell_1 = require("../DataGridCell");
|
|
|
19
19
|
var Checkbox_1 = require("../../Checkbox");
|
|
20
20
|
var styled_1 = require("./styled");
|
|
21
21
|
function DataGridBody(_a) {
|
|
22
|
-
var rows = _a.rows, columns = _a.columns, selectable = _a.selectable, onSelectRow = _a.onSelectRow, _b = _a.selectedRows, selectedRows = _b === void 0 ? [] : _b, minDisplayRows = _a.minDisplayRows, keyId = _a.keyId;
|
|
22
|
+
var rows = _a.rows, columns = _a.columns, selectable = _a.selectable, onRowClick = _a.onRowClick, onSelectRow = _a.onSelectRow, _b = _a.selectedRows, selectedRows = _b === void 0 ? [] : _b, minDisplayRows = _a.minDisplayRows, keyId = _a.keyId;
|
|
23
23
|
var renderCells = (0, react_1.useCallback)(function (row, rowId) {
|
|
24
24
|
return columns.map(function (cell, index) {
|
|
25
25
|
var cellId = "".concat(rowId, "-").concat(index);
|
|
26
26
|
return (0, jsx_runtime_1.jsx)(DataGridCell_1.DataGridCell, { row: row, cell: cell }, cellId);
|
|
27
27
|
});
|
|
28
28
|
}, [columns]);
|
|
29
|
+
var handleRowClick = function (row) { return function () {
|
|
30
|
+
if (onRowClick) {
|
|
31
|
+
onRowClick(row);
|
|
32
|
+
}
|
|
33
|
+
}; };
|
|
29
34
|
var renderedRows = (0, react_1.useMemo)(function () {
|
|
30
35
|
return rows.map(function (row) {
|
|
31
36
|
var rowId = row[keyId];
|
|
32
37
|
var checked = selectable &&
|
|
33
38
|
Boolean(selectedRows.find(function (selectedRow) { return selectedRow[keyId] === rowId; }));
|
|
34
|
-
return ((0, jsx_runtime_1.jsxs)(Table_1.TableRow, { children: [selectable && ((0, jsx_runtime_1.jsx)(Table_1.TableCell, __assign({ padding: "checkbox" }, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: checked, onChange: onSelectRow(row) }, void 0) }), void 0)), renderCells(row, rowId)] }, rowId));
|
|
39
|
+
return ((0, jsx_runtime_1.jsxs)(Table_1.TableRow, __assign({ hover: Boolean(onRowClick), onClick: handleRowClick(row) }, { children: [selectable && ((0, jsx_runtime_1.jsx)(Table_1.TableCell, __assign({ padding: "checkbox", onClick: function (event) { return event.stopPropagation(); } }, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: checked, onChange: onSelectRow(row) }, void 0) }), void 0)), renderCells(row, rowId)] }), rowId));
|
|
35
40
|
});
|
|
36
|
-
}, [rows, keyId, selectable, selectedRows, onSelectRow, columns]);
|
|
41
|
+
}, [rows, keyId, selectable, selectedRows, onSelectRow, onRowClick, columns]);
|
|
37
42
|
return ((0, jsx_runtime_1.jsx)(styled_1.StyledTableBody, __assign({ empty: !rows.length, minDisplayRows: minDisplayRows }, { children: renderedRows }), void 0));
|
|
38
43
|
}
|
|
39
44
|
exports.DataGridBody = DataGridBody;
|
|
@@ -3,6 +3,7 @@ import { DataGridColumns, DataGridRow } from '../types';
|
|
|
3
3
|
export declare type DataGridBodyProps<T = DataGridRow> = {
|
|
4
4
|
columns: DataGridColumns<T>[];
|
|
5
5
|
keyId: keyof DataGridRow;
|
|
6
|
+
onRowClick?: (row: T) => void;
|
|
6
7
|
selectable?: boolean;
|
|
7
8
|
selectedRows?: Array<T>;
|
|
8
9
|
rows: T[];
|
package/DataGrid/types.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare type DataGridProps<T = DataGridRow> = {
|
|
|
12
12
|
rows: T[];
|
|
13
13
|
columns: DataGridColumns<T>[];
|
|
14
14
|
keyId: keyof DataGridRow;
|
|
15
|
+
onRowClick?: (row: T) => void;
|
|
15
16
|
selectedRows?: Array<T>;
|
|
16
17
|
onSelectRow?: (row: T[]) => void;
|
|
17
18
|
sorting?: DataGridSort<T>[];
|
|
@@ -32,5 +32,5 @@ var Menu_1 = require("../Menu");
|
|
|
32
32
|
exports.IconDropdownButton = (0, react_1.forwardRef)(function (_a, ref) {
|
|
33
33
|
var children = _a.children, icon = _a.icon, props = __rest(_a, ["children", "icon"]);
|
|
34
34
|
var _b = (0, hooks_1.useMenu)(ref), open = _b.open, anchorRef = _b.anchorRef, handleOpenMenu = _b.handleOpenMenu, handleCloseMenu = _b.handleCloseMenu;
|
|
35
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.ClickAwayListener, __assign({ onClickAway: handleCloseMenu }, { children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, __assign({}, props, { ref: anchorRef, onClick: handleOpenMenu, selected: open }, { children: icon }), void 0) }), void 0), (0, jsx_runtime_1.jsx)(Menu_1.Menu, __assign({ open: open, anchorEl: anchorRef.current }, { children: children }), void 0)] }, void 0));
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.ClickAwayListener, __assign({ onClickAway: handleCloseMenu, mouseEvent: "onMouseDown" }, { children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, __assign({}, props, { ref: anchorRef, onClick: handleOpenMenu, selected: open }, { children: icon }), void 0) }), void 0), (0, jsx_runtime_1.jsx)(Menu_1.Menu, __assign({ open: open, anchorEl: anchorRef.current }, { children: children }), void 0)] }, void 0));
|
|
36
36
|
});
|
|
@@ -43,5 +43,5 @@ export function ActionCell(_a) {
|
|
|
43
43
|
return (_jsx(MenuItem, __assign({ onClick: handleActionClick(onClick) }, { children: name }), name));
|
|
44
44
|
}) }), void 0));
|
|
45
45
|
}, [secondary, handleActionClick]);
|
|
46
|
-
return (_jsxs(ActionCellWrapper, { children: [main.map(function (action) { return renderMainAction(action); }), renderSecondaryActions] }, void 0));
|
|
46
|
+
return (_jsxs(ActionCellWrapper, __assign({ onClick: function (event) { return event.stopPropagation(); } }, { children: [main.map(function (action) { return renderMainAction(action); }), renderSecondaryActions] }), void 0));
|
|
47
47
|
}
|
|
@@ -12,10 +12,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { Fragment } from 'react';
|
|
14
14
|
import { Button, CircularProgress, Placeholder, Typography } from '..';
|
|
15
|
+
import { LoadingContainer } from './styles';
|
|
15
16
|
export var ContentState = function (props) {
|
|
16
17
|
var isLoading = props.isLoading, _a = props.loadingContent, LoadingContent = _a === void 0 ? _jsx(CircularProgress, { color: "primary" }, void 0) : _a, isError = props.isError, errorState = props.errorState, isCustom = props.isCustom, customState = props.customState, children = props.children;
|
|
17
18
|
if (isLoading)
|
|
18
|
-
return _jsx(
|
|
19
|
+
return _jsx(LoadingContainer, { children: LoadingContent }, void 0);
|
|
19
20
|
if (isCustom && customState) {
|
|
20
21
|
return _jsx(Placeholder, __assign({}, customState), void 0);
|
|
21
22
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const LoadingContainer: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { styled } from '../styles';
|
|
6
|
+
export var LoadingContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n"], ["\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n"])));
|
|
7
|
+
var templateObject_1;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DataGridProps } from './types';
|
|
3
|
-
export declare function DataGrid<T>({ columns, rows, selectedRows, sorting, maxHeight, minDisplayRows, onSelectRow, Footer, loading, onSort, keyId, }: DataGridProps<T>): JSX.Element;
|
|
3
|
+
export declare function DataGrid<T>({ columns, rows, selectedRows, sorting, maxHeight, minDisplayRows, onRowClick, onSelectRow, Footer, loading, onSort, keyId, }: DataGridProps<T>): JSX.Element;
|
package/esm/DataGrid/DataGrid.js
CHANGED
|
@@ -26,7 +26,7 @@ import { DataGridBody } from './DataGridBody';
|
|
|
26
26
|
import DataGridLoader from './DataGridLoader/DataGridLoader';
|
|
27
27
|
import { DataGridContainer, StyledTableContainer } from './styled';
|
|
28
28
|
export function DataGrid(_a) {
|
|
29
|
-
var columns = _a.columns, _b = _a.rows, rows = _b === void 0 ? [] : _b, _c = _a.selectedRows, selectedRows = _c === void 0 ? [] : _c, _d = _a.sorting, sorting = _d === void 0 ? [] : _d, maxHeight = _a.maxHeight, _e = _a.minDisplayRows, minDisplayRows = _e === void 0 ? 10 : _e, onSelectRow = _a.onSelectRow, Footer = _a.Footer, loading = _a.loading, onSort = _a.onSort, keyId = _a.keyId;
|
|
29
|
+
var columns = _a.columns, _b = _a.rows, rows = _b === void 0 ? [] : _b, _c = _a.selectedRows, selectedRows = _c === void 0 ? [] : _c, _d = _a.sorting, sorting = _d === void 0 ? [] : _d, maxHeight = _a.maxHeight, _e = _a.minDisplayRows, minDisplayRows = _e === void 0 ? 10 : _e, onRowClick = _a.onRowClick, onSelectRow = _a.onSelectRow, Footer = _a.Footer, loading = _a.loading, onSort = _a.onSort, keyId = _a.keyId;
|
|
30
30
|
var selectable = Boolean(onSelectRow);
|
|
31
31
|
var handleSelectAllRows = function (event) {
|
|
32
32
|
if (!onSelectRow)
|
|
@@ -53,5 +53,5 @@ export function DataGrid(_a) {
|
|
|
53
53
|
return !selectedRows.find(function (selectedRow) { return selectedRow[keyId] === row[keyId]; });
|
|
54
54
|
}).length;
|
|
55
55
|
}, [rows, selectedRows, keyId]);
|
|
56
|
-
return (_jsxs(DataGridContainer, { children: [_jsxs(StyledTableContainer, __assign({ maxHeight: maxHeight }, { children: [_jsxs(Table, __assign({ stickyHeader: true }, { children: [_jsx(DataGridHead, { onSort: onSort, rowsCount: rows.length, uncheckedRowsCount: uncheckedRowsCount, onSelectAllRows: handleSelectAllRows, selectable: selectable, sorting: sorting, columns: columns }, void 0), _jsx(DataGridBody, { keyId: keyId, selectedRows: selectedRows, minDisplayRows: minDisplayRows, onSelectRow: handleSelectRow, selectable: selectable, rows: rows, columns: columns }, void 0)] }), void 0), _jsx(DataGridLoader, { loading: loading }, void 0)] }), void 0), Footer] }, void 0));
|
|
56
|
+
return (_jsxs(DataGridContainer, { children: [_jsxs(StyledTableContainer, __assign({ maxHeight: maxHeight }, { children: [_jsxs(Table, __assign({ stickyHeader: true }, { children: [_jsx(DataGridHead, { onSort: onSort, rowsCount: rows.length, uncheckedRowsCount: uncheckedRowsCount, onSelectAllRows: handleSelectAllRows, selectable: selectable, sorting: sorting, columns: columns }, void 0), _jsx(DataGridBody, { keyId: keyId, selectedRows: selectedRows, minDisplayRows: minDisplayRows, onRowClick: onRowClick, onSelectRow: handleSelectRow, selectable: selectable, rows: rows, columns: columns }, void 0)] }), void 0), _jsx(DataGridLoader, { loading: loading }, void 0)] }), void 0), Footer] }, void 0));
|
|
57
57
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DataGridBodyProps } from './types';
|
|
3
|
-
export declare function DataGridBody<T>({ rows, columns, selectable, onSelectRow, selectedRows, minDisplayRows, keyId, }: DataGridBodyProps<T>): JSX.Element;
|
|
3
|
+
export declare function DataGridBody<T>({ rows, columns, selectable, onRowClick, onSelectRow, selectedRows, minDisplayRows, keyId, }: DataGridBodyProps<T>): JSX.Element;
|
|
@@ -16,20 +16,25 @@ import { DataGridCell } from '../DataGridCell';
|
|
|
16
16
|
import { Checkbox } from '../../Checkbox';
|
|
17
17
|
import { StyledTableBody } from './styled';
|
|
18
18
|
export function DataGridBody(_a) {
|
|
19
|
-
var rows = _a.rows, columns = _a.columns, selectable = _a.selectable, onSelectRow = _a.onSelectRow, _b = _a.selectedRows, selectedRows = _b === void 0 ? [] : _b, minDisplayRows = _a.minDisplayRows, keyId = _a.keyId;
|
|
19
|
+
var rows = _a.rows, columns = _a.columns, selectable = _a.selectable, onRowClick = _a.onRowClick, onSelectRow = _a.onSelectRow, _b = _a.selectedRows, selectedRows = _b === void 0 ? [] : _b, minDisplayRows = _a.minDisplayRows, keyId = _a.keyId;
|
|
20
20
|
var renderCells = useCallback(function (row, rowId) {
|
|
21
21
|
return columns.map(function (cell, index) {
|
|
22
22
|
var cellId = "".concat(rowId, "-").concat(index);
|
|
23
23
|
return _jsx(DataGridCell, { row: row, cell: cell }, cellId);
|
|
24
24
|
});
|
|
25
25
|
}, [columns]);
|
|
26
|
+
var handleRowClick = function (row) { return function () {
|
|
27
|
+
if (onRowClick) {
|
|
28
|
+
onRowClick(row);
|
|
29
|
+
}
|
|
30
|
+
}; };
|
|
26
31
|
var renderedRows = useMemo(function () {
|
|
27
32
|
return rows.map(function (row) {
|
|
28
33
|
var rowId = row[keyId];
|
|
29
34
|
var checked = selectable &&
|
|
30
35
|
Boolean(selectedRows.find(function (selectedRow) { return selectedRow[keyId] === rowId; }));
|
|
31
|
-
return (_jsxs(TableRow, { children: [selectable && (_jsx(TableCell, __assign({ padding: "checkbox" }, { children: _jsx(Checkbox, { checked: checked, onChange: onSelectRow(row) }, void 0) }), void 0)), renderCells(row, rowId)] }, rowId));
|
|
36
|
+
return (_jsxs(TableRow, __assign({ hover: Boolean(onRowClick), onClick: handleRowClick(row) }, { children: [selectable && (_jsx(TableCell, __assign({ padding: "checkbox", onClick: function (event) { return event.stopPropagation(); } }, { children: _jsx(Checkbox, { checked: checked, onChange: onSelectRow(row) }, void 0) }), void 0)), renderCells(row, rowId)] }), rowId));
|
|
32
37
|
});
|
|
33
|
-
}, [rows, keyId, selectable, selectedRows, onSelectRow, columns]);
|
|
38
|
+
}, [rows, keyId, selectable, selectedRows, onSelectRow, onRowClick, columns]);
|
|
34
39
|
return (_jsx(StyledTableBody, __assign({ empty: !rows.length, minDisplayRows: minDisplayRows }, { children: renderedRows }), void 0));
|
|
35
40
|
}
|
|
@@ -3,6 +3,7 @@ import { DataGridColumns, DataGridRow } from '../types';
|
|
|
3
3
|
export declare type DataGridBodyProps<T = DataGridRow> = {
|
|
4
4
|
columns: DataGridColumns<T>[];
|
|
5
5
|
keyId: keyof DataGridRow;
|
|
6
|
+
onRowClick?: (row: T) => void;
|
|
6
7
|
selectable?: boolean;
|
|
7
8
|
selectedRows?: Array<T>;
|
|
8
9
|
rows: T[];
|
package/esm/DataGrid/types.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare type DataGridProps<T = DataGridRow> = {
|
|
|
12
12
|
rows: T[];
|
|
13
13
|
columns: DataGridColumns<T>[];
|
|
14
14
|
keyId: keyof DataGridRow;
|
|
15
|
+
onRowClick?: (row: T) => void;
|
|
15
16
|
selectedRows?: Array<T>;
|
|
16
17
|
onSelectRow?: (row: T[]) => void;
|
|
17
18
|
sorting?: DataGridSort<T>[];
|
|
@@ -29,5 +29,5 @@ import { Menu } from '../Menu';
|
|
|
29
29
|
export var IconDropdownButton = forwardRef(function (_a, ref) {
|
|
30
30
|
var children = _a.children, icon = _a.icon, props = __rest(_a, ["children", "icon"]);
|
|
31
31
|
var _b = useMenu(ref), open = _b.open, anchorRef = _b.anchorRef, handleOpenMenu = _b.handleOpenMenu, handleCloseMenu = _b.handleCloseMenu;
|
|
32
|
-
return (_jsxs(_Fragment, { children: [_jsx(ClickAwayListener, __assign({ onClickAway: handleCloseMenu }, { children: _jsx(IconButton, __assign({}, props, { ref: anchorRef, onClick: handleOpenMenu, selected: open }, { children: icon }), void 0) }), void 0), _jsx(Menu, __assign({ open: open, anchorEl: anchorRef.current }, { children: children }), void 0)] }, void 0));
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsx(ClickAwayListener, __assign({ onClickAway: handleCloseMenu, mouseEvent: "onMouseDown" }, { children: _jsx(IconButton, __assign({}, props, { ref: anchorRef, onClick: handleOpenMenu, selected: open }, { children: icon }), void 0) }), void 0), _jsx(Menu, __assign({ open: open, anchorEl: anchorRef.current }, { children: children }), void 0)] }, void 0));
|
|
33
33
|
});
|
|
@@ -11,8 +11,7 @@ export var MuiOutlinedInput = {
|
|
|
11
11
|
color: theme.palette.grey[900],
|
|
12
12
|
background: theme.palette.background.element,
|
|
13
13
|
'&:hover': {
|
|
14
|
-
|
|
15
|
-
background: '#EEF1F4',
|
|
14
|
+
background: theme.palette.background.elementHover,
|
|
16
15
|
'&.Mui-disabled': {
|
|
17
16
|
background: theme.palette.background.element,
|
|
18
17
|
},
|
|
@@ -15,6 +15,7 @@ import { MuiDialogContent } from './MuiDialogContent';
|
|
|
15
15
|
import { MuiDialogActions } from './MuiDialogActions';
|
|
16
16
|
import { MuiTableCell } from './MuiTableCell';
|
|
17
17
|
import { MuiTableHead } from './MuiTableHead';
|
|
18
|
+
import { MuiTableRow } from './MuiTableRow';
|
|
18
19
|
import { MuiPickersDay } from './MuiPickersDay';
|
|
19
20
|
import { MuiCalendarPicker } from './MuiCalendarPicker';
|
|
20
21
|
import { MuiYearPicker } from './MuiYearPicker';
|
|
@@ -56,6 +57,7 @@ export var getComponents = function (fontUrls) { return ({
|
|
|
56
57
|
MuiDialogActions: MuiDialogActions,
|
|
57
58
|
MuiTableCell: MuiTableCell,
|
|
58
59
|
MuiTableHead: MuiTableHead,
|
|
60
|
+
MuiTableRow: MuiTableRow,
|
|
59
61
|
MuiPaginationItem: MuiPaginationItem,
|
|
60
62
|
MuiPickersDay: MuiPickersDay,
|
|
61
63
|
MuiCalendarPicker: MuiCalendarPicker,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astral/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"browser": "./src/index.ts",
|
|
5
5
|
"jest": {
|
|
6
6
|
"moduleNameMapper": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
}
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@astral/icons": "^0.
|
|
11
|
+
"@astral/icons": "^0.38.0",
|
|
12
12
|
"@emotion/cache": "11.7.1",
|
|
13
13
|
"@emotion/react": "11.9.0",
|
|
14
14
|
"@emotion/server": "11.4.0",
|
|
@@ -14,8 +14,7 @@ exports.MuiOutlinedInput = {
|
|
|
14
14
|
color: theme.palette.grey[900],
|
|
15
15
|
background: theme.palette.background.element,
|
|
16
16
|
'&:hover': {
|
|
17
|
-
|
|
18
|
-
background: '#EEF1F4',
|
|
17
|
+
background: theme.palette.background.elementHover,
|
|
19
18
|
'&.Mui-disabled': {
|
|
20
19
|
background: theme.palette.background.element,
|
|
21
20
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MuiTableRow = void 0;
|
|
4
|
+
exports.MuiTableRow = {
|
|
5
|
+
styleOverrides: {
|
|
6
|
+
root: function (_a) {
|
|
7
|
+
var theme = _a.theme;
|
|
8
|
+
return {
|
|
9
|
+
'&.MuiTableRow-hover:hover': {
|
|
10
|
+
backgroundColor: theme.palette.background.elementHover,
|
|
11
|
+
cursor: 'pointer',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -18,6 +18,7 @@ var MuiDialogContent_1 = require("./MuiDialogContent");
|
|
|
18
18
|
var MuiDialogActions_1 = require("./MuiDialogActions");
|
|
19
19
|
var MuiTableCell_1 = require("./MuiTableCell");
|
|
20
20
|
var MuiTableHead_1 = require("./MuiTableHead");
|
|
21
|
+
var MuiTableRow_1 = require("./MuiTableRow");
|
|
21
22
|
var MuiPickersDay_1 = require("./MuiPickersDay");
|
|
22
23
|
var MuiCalendarPicker_1 = require("./MuiCalendarPicker");
|
|
23
24
|
var MuiYearPicker_1 = require("./MuiYearPicker");
|
|
@@ -59,6 +60,7 @@ var getComponents = function (fontUrls) { return ({
|
|
|
59
60
|
MuiDialogActions: MuiDialogActions_1.MuiDialogActions,
|
|
60
61
|
MuiTableCell: MuiTableCell_1.MuiTableCell,
|
|
61
62
|
MuiTableHead: MuiTableHead_1.MuiTableHead,
|
|
63
|
+
MuiTableRow: MuiTableRow_1.MuiTableRow,
|
|
62
64
|
MuiPaginationItem: MuiPaginationItem_1.MuiPaginationItem,
|
|
63
65
|
MuiPickersDay: MuiPickersDay_1.MuiPickersDay,
|
|
64
66
|
MuiCalendarPicker: MuiCalendarPicker_1.MuiCalendarPicker,
|