grep-components 1.25.0 → 1.26.0-GREPF-2165.2
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/GrepTable/index.d.ts +3 -1
- package/dist/index.js +21 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ export interface GrepTableProps<T> extends Pick<TableProps, 'size' | 'stickyHead
|
|
|
20
20
|
header?: boolean;
|
|
21
21
|
outlined?: boolean;
|
|
22
22
|
rowsPerPage?: number;
|
|
23
|
+
rowsPerPageOptions?: number[];
|
|
23
24
|
pagination?: boolean;
|
|
24
25
|
/**
|
|
25
26
|
* @deprecated No longer in use.
|
|
@@ -42,6 +43,7 @@ export interface GrepTableProps<T> extends Pick<TableProps, 'size' | 'stickyHead
|
|
|
42
43
|
* @deprecated No longer in use.
|
|
43
44
|
*/
|
|
44
45
|
rowHeight?: number;
|
|
46
|
+
rowStyle?: React.CSSProperties | ((data: any, index: number) => React.CSSProperties);
|
|
45
47
|
disableSelectOnClick?: boolean;
|
|
46
48
|
underlineOnFocus?: boolean;
|
|
47
49
|
rowTabIndex?: number;
|
|
@@ -68,6 +70,6 @@ export declare const useStyles: (params: StyleProps, styleOverrides?: {
|
|
|
68
70
|
* @todo enhance page handling
|
|
69
71
|
*
|
|
70
72
|
*/
|
|
71
|
-
export declare const GrepTable: <T>({ placeholderText, dropdownItems, isRowDisabled, pagination, outlined, columns, header, data, onSelectedRowChange, sortBy, sortDirection, onSortBy, onRowClick, size, caption, stickyHeader, padding, disableSelectOnClick, menuButtonLabel, underlineOnFocus, rowTabIndex, ...props }: GrepTableProps<T>) => JSX.Element;
|
|
73
|
+
export declare const GrepTable: <T>({ placeholderText, dropdownItems, isRowDisabled, pagination, outlined, columns, header, data, onSelectedRowChange, sortBy, sortDirection, onSortBy, onRowClick, size, caption, stickyHeader, padding, disableSelectOnClick, menuButtonLabel, underlineOnFocus, rowTabIndex, rowStyle, rowsPerPageOptions, ...props }: GrepTableProps<T>) => JSX.Element;
|
|
72
74
|
export { GrepTableRow };
|
|
73
75
|
export default GrepTable;
|
package/dist/index.js
CHANGED
|
@@ -3612,7 +3612,7 @@ var PaginationActions = function (_a) {
|
|
|
3612
3612
|
|
|
3613
3613
|
var GrepTablePagination = function (props) {
|
|
3614
3614
|
var classes = usePaginationStyles().classes;
|
|
3615
|
-
return (React__default.createElement(TablePagination, __assign({ classes: classes, rowsPerPageOptions: props.rowsPerPageOptions
|
|
3615
|
+
return (React__default.createElement(TablePagination, __assign({ classes: classes, rowsPerPageOptions: props.rowsPerPageOptions, SelectProps: {
|
|
3616
3616
|
inputProps: {
|
|
3617
3617
|
title: 'Velg antall elementer',
|
|
3618
3618
|
},
|
|
@@ -3662,13 +3662,13 @@ var getElementIndex = function (el) {
|
|
|
3662
3662
|
*
|
|
3663
3663
|
*/
|
|
3664
3664
|
var GrepTable = function (_a) {
|
|
3665
|
-
var placeholderText = _a.placeholderText, dropdownItems = _a.dropdownItems, isRowDisabled = _a.isRowDisabled, pagination = _a.pagination, outlined = _a.outlined, columns = _a.columns, header = _a.header, data = _a.data, onSelectedRowChange = _a.onSelectedRowChange, sortBy = _a.sortBy, sortDirection = _a.sortDirection, onSortBy = _a.onSortBy, onRowClick = _a.onRowClick, size = _a.size, caption = _a.caption, stickyHeader = _a.stickyHeader, padding = _a.padding, _b = _a.disableSelectOnClick, disableSelectOnClick = _b === void 0 ? false : _b, menuButtonLabel = _a.menuButtonLabel, underlineOnFocus = _a.underlineOnFocus, rowTabIndex = _a.rowTabIndex, props = __rest$1(_a, ["placeholderText", "dropdownItems", "isRowDisabled", "pagination", "outlined", "columns", "header", "data", "onSelectedRowChange", "sortBy", "sortDirection", "onSortBy", "onRowClick", "size", "caption", "stickyHeader", "padding", "disableSelectOnClick", "menuButtonLabel", "underlineOnFocus", "rowTabIndex"]);
|
|
3666
|
-
var
|
|
3667
|
-
var
|
|
3668
|
-
var
|
|
3669
|
-
var
|
|
3670
|
-
var
|
|
3671
|
-
var
|
|
3665
|
+
var placeholderText = _a.placeholderText, dropdownItems = _a.dropdownItems, isRowDisabled = _a.isRowDisabled, pagination = _a.pagination, outlined = _a.outlined, columns = _a.columns, header = _a.header, data = _a.data, onSelectedRowChange = _a.onSelectedRowChange, sortBy = _a.sortBy, sortDirection = _a.sortDirection, onSortBy = _a.onSortBy, onRowClick = _a.onRowClick, size = _a.size, caption = _a.caption, stickyHeader = _a.stickyHeader, padding = _a.padding, _b = _a.disableSelectOnClick, disableSelectOnClick = _b === void 0 ? false : _b, menuButtonLabel = _a.menuButtonLabel, underlineOnFocus = _a.underlineOnFocus, rowTabIndex = _a.rowTabIndex, rowStyle = _a.rowStyle, _c = _a.rowsPerPageOptions, rowsPerPageOptions = _c === void 0 ? [5, 10, 25, 50] : _c, props = __rest$1(_a, ["placeholderText", "dropdownItems", "isRowDisabled", "pagination", "outlined", "columns", "header", "data", "onSelectedRowChange", "sortBy", "sortDirection", "onSortBy", "onRowClick", "size", "caption", "stickyHeader", "padding", "disableSelectOnClick", "menuButtonLabel", "underlineOnFocus", "rowTabIndex", "rowStyle", "rowsPerPageOptions"]);
|
|
3666
|
+
var _d = __read(React__default.useState(props.rowsPerPage || 10), 2), rowsPerPage = _d[0], setRowsPerPage = _d[1];
|
|
3667
|
+
var _e = __read(React__default.useState(null), 2), menuAnchor = _e[0], setMenuAnchor = _e[1];
|
|
3668
|
+
var _f = __read(React__default.useState(0), 2), currentPage = _f[0], _setCurrentPage = _f[1];
|
|
3669
|
+
var _g = __read(React__default.useState(), 2), selectedRowIndex = _g[0], _setSelectedRowIndex = _g[1];
|
|
3670
|
+
var _h = __read(React__default.useState(), 2), expandedRowIndex = _h[0], _setExpandedRowIndex = _h[1];
|
|
3671
|
+
var _j = __read(React__default.useState(), 2), dropdownContext = _j[0], setDropdownContext = _j[1];
|
|
3672
3672
|
var selectedRow = data[selectedRowIndex] || null;
|
|
3673
3673
|
var setCurrentPage = useCallback$1(function (index, rowIndex, shouldExpand) {
|
|
3674
3674
|
index = pagination && index >= 0 ? index : 0;
|
|
@@ -3756,6 +3756,16 @@ var GrepTable = function (_a) {
|
|
|
3756
3756
|
}, tabIndex: 0, size: "large", "aria-label": menuButtonLabel !== null && menuButtonLabel !== void 0 ? menuButtonLabel : 'Åpne meny' },
|
|
3757
3757
|
React__default.createElement(MoreVert, null)))));
|
|
3758
3758
|
};
|
|
3759
|
+
var getRowStyle = function (row, index, clickableRows, disabled) {
|
|
3760
|
+
var style = { cursor: clickableRows && !disabled ? 'pointer' : '' };
|
|
3761
|
+
if (typeof rowStyle === "function") {
|
|
3762
|
+
style = __assign(__assign({}, style), rowStyle(row, index));
|
|
3763
|
+
}
|
|
3764
|
+
else if (rowStyle) {
|
|
3765
|
+
style = __assign(__assign({}, style), rowStyle);
|
|
3766
|
+
}
|
|
3767
|
+
return style;
|
|
3768
|
+
};
|
|
3759
3769
|
var _renderRow = function (row, index) {
|
|
3760
3770
|
var rowColumns = dropdownItems
|
|
3761
3771
|
? columns.concat([{ getCell: _renderCellButton, padding: 'none' }])
|
|
@@ -3775,7 +3785,7 @@ var GrepTable = function (_a) {
|
|
|
3775
3785
|
_handleRowClick(row);
|
|
3776
3786
|
}
|
|
3777
3787
|
}
|
|
3778
|
-
}, columns: rowColumns, row: row, style:
|
|
3788
|
+
}, columns: rowColumns, row: row, style: getRowStyle(row, index, clickableRows, disabled), onFocus: function (e) {
|
|
3779
3789
|
if (selectedRowIndex !== rowIndex) {
|
|
3780
3790
|
setSelectedElement(e.currentTarget);
|
|
3781
3791
|
}
|
|
@@ -3831,7 +3841,7 @@ var GrepTable = function (_a) {
|
|
|
3831
3841
|
React__default.createElement(TableHeader, { className: classes.header, columns: columns, sortBy: sortBy, sortDirection: sortDirection, onSortBy: onSortBy, dropdownItems: dropdownItems }),
|
|
3832
3842
|
React__default.createElement(TableBody, { ref: tableRef, className: classes.body, onKeyDown: onKey }, data.length ? (rows.map(_renderRow)) : (React__default.createElement(GrepTablePlaceholder, { padding: padding, columns: columns, text: placeholderText }))),
|
|
3833
3843
|
React__default.createElement(TableFooter, null, pagination && (React__default.createElement(TableRow, null,
|
|
3834
|
-
React__default.createElement(GrepTablePagination, { page: currentPage, count: data.length, rowsPerPage: rowsPerPage, onPageChange: _handlePageChange, onRowsPerPageChange: _handleChangeRowsPerPage, labelRowsPerPage: '', labelDisplayedRows: function (_a) {
|
|
3844
|
+
React__default.createElement(GrepTablePagination, { page: currentPage, count: data.length, rowsPerPage: rowsPerPage, onPageChange: _handlePageChange, rowsPerPageOptions: rowsPerPageOptions, onRowsPerPageChange: _handleChangeRowsPerPage, labelRowsPerPage: '', labelDisplayedRows: function (_a) {
|
|
3835
3845
|
var from = _a.from, to = _a.to, count = _a.count;
|
|
3836
3846
|
return "Viser ".concat(from, "-").concat(to, " av ").concat(count);
|
|
3837
3847
|
} }))))),
|
|
@@ -4609,7 +4619,7 @@ var DatePicker = function (_a) {
|
|
|
4609
4619
|
var _c = __read(useState(), 2), error = _c[0], setError = _c[1];
|
|
4610
4620
|
var helperText = errorMessage || error || props.helperText;
|
|
4611
4621
|
useEffect(function () { return onChange(date); }, [String(date)]);
|
|
4612
|
-
return (React__default.createElement(LocalizationProvider, { dateAdapter: AdapterDayjs,
|
|
4622
|
+
return (React__default.createElement(LocalizationProvider, { dateAdapter: AdapterDayjs, adapterLocale: 'nb' },
|
|
4613
4623
|
React__default.createElement(DesktopDatePicker
|
|
4614
4624
|
// clearable @todo
|
|
4615
4625
|
, __assign({
|