grep-components 2.24.0 → 2.25.0-GREPF-2906.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.
|
@@ -6,10 +6,15 @@ export interface SelectItem {
|
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
lang?: string;
|
|
8
8
|
}
|
|
9
|
+
export interface ErrorOptions {
|
|
10
|
+
text: string;
|
|
11
|
+
color?: string;
|
|
12
|
+
}
|
|
9
13
|
export type GrepSelectProps = SelectProps & {
|
|
10
14
|
label: string;
|
|
11
15
|
outlined?: boolean;
|
|
12
16
|
helperText?: string;
|
|
17
|
+
errorOptions?: ErrorOptions;
|
|
13
18
|
errorMessage?: string;
|
|
14
19
|
selectItems: SelectItem[];
|
|
15
20
|
unselectOption?: boolean;
|
|
@@ -3,6 +3,7 @@ import { TableProps } from '@mui/material/Table';
|
|
|
3
3
|
import { TableCellProps } from '@mui/material/TableCell';
|
|
4
4
|
import GrepTableRow from './components/grep-table-row';
|
|
5
5
|
import { DropdownMenuItem } from '../DropdownMenu';
|
|
6
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
6
7
|
export interface TableColumn<T> extends Pick<TableCellProps, 'padding' | 'sx'> {
|
|
7
8
|
label?: string | JSX.Element;
|
|
8
9
|
width?: number | string;
|
|
@@ -44,6 +45,7 @@ export interface GrepTableProps<T> extends Pick<TableProps, 'size' | 'stickyHead
|
|
|
44
45
|
* @deprecated No longer in use.
|
|
45
46
|
*/
|
|
46
47
|
rowHeight?: number;
|
|
48
|
+
tableHeaderSx?: SxProps<Theme>;
|
|
47
49
|
rowStyle?: React.CSSProperties | ((data: T, index: number) => React.CSSProperties);
|
|
48
50
|
disableSelectOnClick?: boolean;
|
|
49
51
|
underlineOnFocus?: boolean;
|
|
@@ -58,7 +60,7 @@ export declare const useStyles: (params: StyleProps, muiStyleOverridesParams?: {
|
|
|
58
60
|
ownerState?: Record<string, unknown> | undefined;
|
|
59
61
|
} | undefined) => {
|
|
60
62
|
classes: Record<"body" | "header" | "table", string>;
|
|
61
|
-
theme:
|
|
63
|
+
theme: Theme;
|
|
62
64
|
css: import("tss-react").Css;
|
|
63
65
|
cx: import("tss-react").Cx;
|
|
64
66
|
};
|
|
@@ -69,6 +71,6 @@ export declare const useStyles: (params: StyleProps, muiStyleOverridesParams?: {
|
|
|
69
71
|
* @todo enhance page handling
|
|
70
72
|
*
|
|
71
73
|
*/
|
|
72
|
-
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;
|
|
74
|
+
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, tableHeaderSx, rowStyle, rowsPerPageOptions, ...props }: GrepTableProps<T>) => JSX.Element;
|
|
73
75
|
export { GrepTableRow };
|
|
74
76
|
export default GrepTable;
|
package/dist/index.js
CHANGED
|
@@ -2152,7 +2152,7 @@ const getElementIndex = (el) => Number(el.getAttribute('data-index') || -1);
|
|
|
2152
2152
|
* @todo enhance page handling
|
|
2153
2153
|
*
|
|
2154
2154
|
*/
|
|
2155
|
-
const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination, outlined, columns, header, data, onSelectedRowChange, sortBy, sortDirection, onSortBy, onRowClick, size, caption, stickyHeader, padding, disableSelectOnClick = false, menuButtonLabel, underlineOnFocus, rowTabIndex, rowStyle, rowsPerPageOptions = [5, 10, 25, 50], ...props }) => {
|
|
2155
|
+
const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination, outlined, columns, header, data, onSelectedRowChange, sortBy, sortDirection, onSortBy, onRowClick, size, caption, stickyHeader, padding, disableSelectOnClick = false, menuButtonLabel, underlineOnFocus, rowTabIndex, tableHeaderSx, rowStyle, rowsPerPageOptions = [5, 10, 25, 50], ...props }) => {
|
|
2156
2156
|
const [rowsPerPage, setRowsPerPage] = React__default.useState(props.rowsPerPage || 10);
|
|
2157
2157
|
const [menuAnchor, setMenuAnchor] = React__default.useState(null);
|
|
2158
2158
|
const [currentPage, _setCurrentPage] = React__default.useState(0);
|
|
@@ -2336,7 +2336,7 @@ const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination,
|
|
|
2336
2336
|
return (React__default.createElement(TableContainer, { sx: props.style },
|
|
2337
2337
|
React__default.createElement(Table, { className: classes.table, size: size, stickyHeader: stickyHeader, padding: padding },
|
|
2338
2338
|
caption && React__default.createElement("caption", null, caption),
|
|
2339
|
-
React__default.createElement(TableHeader, { className: classes.header, columns: columns, sortBy: sortBy, sortDirection: sortDirection, onSortBy: onSortBy, dropdownItems: dropdownItems }),
|
|
2339
|
+
React__default.createElement(TableHeader, { className: classes.header, columns: columns, sortBy: sortBy, sortDirection: sortDirection, onSortBy: onSortBy, dropdownItems: dropdownItems, sx: tableHeaderSx }),
|
|
2340
2340
|
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 }))),
|
|
2341
2341
|
React__default.createElement(TableFooter, null, pagination && (React__default.createElement(TableRow, null,
|
|
2342
2342
|
React__default.createElement(GrepTablePagination, { page: currentPage, count: data.length, rowsPerPage: rowsPerPage, onPageChange: _handlePageChange, rowsPerPageOptions: rowsPerPageOptions, onRowsPerPageChange: _handleChangeRowsPerPage, labelRowsPerPage: '', labelDisplayedRows: ({ from, to, count }) => `Viser ${from}-${to} av ${count}` }))))),
|
|
@@ -2613,10 +2613,36 @@ const GrepSelect = (props) => {
|
|
|
2613
2613
|
React.useEffect(() => {
|
|
2614
2614
|
setLabelWidth(inputLabel.current.offsetWidth);
|
|
2615
2615
|
}, []);
|
|
2616
|
-
const { unselectOption = true,
|
|
2617
|
-
const error =
|
|
2616
|
+
const { unselectOption = true, errorOptions, selectItems, helperText, fullWidth, outlined, disabled, required, label, labelProps, inputProps, value, size, id, useCheckedSelect, ...rest } = props;
|
|
2617
|
+
const error = errorOptions?.text ? errorOptions?.text.length > 0 : false;
|
|
2618
2618
|
const selected = value;
|
|
2619
|
-
|
|
2619
|
+
const errorColor = errorOptions?.color
|
|
2620
|
+
? {
|
|
2621
|
+
'& .MuiFormLabel-root.Mui-error': {
|
|
2622
|
+
color: errorOptions?.color,
|
|
2623
|
+
},
|
|
2624
|
+
'& .MuiInputBase-root.Mui-error': {
|
|
2625
|
+
':after': {
|
|
2626
|
+
borderBottomColor: errorOptions?.color,
|
|
2627
|
+
},
|
|
2628
|
+
':before': {
|
|
2629
|
+
borderBottomColor: errorOptions?.color,
|
|
2630
|
+
},
|
|
2631
|
+
},
|
|
2632
|
+
'& .MuiFormHelperText-root.Mui-error': {
|
|
2633
|
+
color: errorOptions?.color,
|
|
2634
|
+
},
|
|
2635
|
+
'& .MuiFormLabel-asterisk.Mui-error': {
|
|
2636
|
+
color: errorOptions?.color,
|
|
2637
|
+
},
|
|
2638
|
+
'& .MuiOutlinedInput-root.Mui-error': {
|
|
2639
|
+
'& fieldset': {
|
|
2640
|
+
borderColor: errorOptions?.color,
|
|
2641
|
+
},
|
|
2642
|
+
},
|
|
2643
|
+
}
|
|
2644
|
+
: null;
|
|
2645
|
+
return (React.createElement(FormControl, { variant: outlined ? 'outlined' : 'standard', className: props.className, fullWidth: fullWidth, required: required, style: props.style, error: error, size: size, disabled: disabled, sx: errorColor },
|
|
2620
2646
|
React.createElement(InputLabel, { htmlFor: id, ref: inputLabel, style: {
|
|
2621
2647
|
minWidth: 'max-content',
|
|
2622
2648
|
overflow: 'visible',
|
|
@@ -2639,7 +2665,7 @@ const GrepSelect = (props) => {
|
|
|
2639
2665
|
selectItems.map(({ label, value, disabled, lang }, i) => (React.createElement(MenuItem$1, { key: i, value: value, disabled: disabled, lang: lang },
|
|
2640
2666
|
useCheckedSelect && (React.createElement(Checkbox, { checked: selected?.indexOf(value) > -1 })),
|
|
2641
2667
|
React.createElement(ListItemText, { sx: { margin: '0px', span: { lineHeight: '1.4375em' } }, primary: label ? label : value }))))),
|
|
2642
|
-
React.createElement(FormHelperText, null,
|
|
2668
|
+
React.createElement(FormHelperText, null, errorOptions?.text || helperText)));
|
|
2643
2669
|
};
|
|
2644
2670
|
|
|
2645
2671
|
const defaultOptions$2 = {
|