UNPKG

@maherunlocker/custom-react-table

Version:
295 lines 10.1 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx } from "react/jsx-runtime"; import { Checkbox, styled } from '@mui/material'; import MuiTableBody from '@mui/material/TableBody'; import MuiTableCell from '@mui/material/TableCell'; import MuiTableHead from '@mui/material/TableHead'; import MuiTableRow from '@mui/material/TableRow'; import MuiTableTable from '@mui/material/Table'; import React from 'react'; import cx from 'classnames'; import { makeStyles } from '@mui/styles'; import { important } from '../utils/important'; export const useStyles = makeStyles({ rawTable: { borderSpacing: 0, border: '1px solid rgba(224, 224, 224, 1)', maxWidth: '100%', borderTop: '0', fontFamily: `"Segoe UI", "-apple-system", "Helvetica Neue", "Arial"`, // minHeight: '100vh', // marginTop: 5, }, tableHead: { position: 'sticky', top: '0px', zIndex: 200, borderTop: '0', marginTop: '0', marginBottom: '2', paddingTop: '0', }, stickyCol: { position: important('sticky'), right: important('45px'), background: 'white', //boxShadow: '5px 2px 5px grey', }, hide_colomns_sticky: { position: important('sticky'), right: important(0), background: 'white', //boxShadow: '5px 2px 5px grey', }, tableHeadRow: { // backgroundColor: 'red', backgroundColor: '#F8F8FB ', color: '#000', border: '0px', // borderBottom: '1px solid rgba(224, 224, 224, 1)', // '&:hover $resizeHandle': { // opacity: 1, // }, }, tableHeadCell: { padding: '16px 1px 16px 16px', fontSize: '0.875rem', textAlign: 'center', maxHeight: 45, verticalAlign: 'inherit', justifyContent: 'center !important', display: 'flex', fontFamily: `"Segoe UI", "-apple-system", "Helvetica Neue", "Arial"`, fontWeight: '700 !important', lineHeight: '1.5rem', borderRight: '1px solid rgba(224, 224, 224, 1)', '&:last-child': { borderRight: 'none', }, // borderBottom: '1px solid #555B6D', }, tableBody: { fontFamily: `"Segoe UI", "-apple-system", "Helvetica Neue", "Arial"`, }, tableRow: { color: 'inherit', maxHeight: 50, outline: 0, fontFamily: `"Segoe UI", "-apple-system", "Helvetica Neue", "Arial"`, verticalAlign: 'middle', backgroundColor: 'white', border: 'none', '&:hover': { backgroundColor: 'rgba(0, 0, 0, 0.07)', }, '&:nth-child(even)': { backgroundColor: 'hsl(0, 0%, 98%,1)', }, borderBottom: '1px rgb(239, 239, 239)', '&:last-child': { borderBottom: 'none', }, '&.rowSelected': { backgroundColor: 'rgba(195, 55, 55, 0.04)', // backgroundColor: 'rgba(0, 0, 0, 0.04)', '&:hover': { backgroundColor: 'rgba(0, 0, 0, 0.07)', }, }, '&.clickable': { cursor: 'pointer', }, }, tableLabel: {}, tableCell: { padding: '8px 16px', fontFamily: `"Segoe UI", "-apple-system", "Helvetica Neue", "Arial"`, fontSize: '0.875rem', textAlign: 'center', fontWeight: 300, lineHeight: 1.3, verticalAlign: 'inherit', color: 'rgba(0, 0, 0, 0.87)', display: 'flex', justifyContent: 'center', alignItems: 'center', // borderRight: '1px solid rgba(224, 224, 224, 1)', // '&:last-child': { // borderRight: 'none', // }, }, resizeHandle: { position: 'absolute', cursor: 'col-resize', zIndex: 100, opacity: 0, borderLeft: '1px solid #42a5f5', borderRight: '1px solid #42a5f5', height: '50%', top: '25%', transition: 'all linear 100ms', right: -2, width: 3, '&.handleActive': { opacity: 1, border: 'none', backgroundColor: '#42a5f5', height: 'calc(100% - 4px)', top: '2px', right: -1, width: 1, }, }, tableSortLabel: { '& svg': { width: 16, height: 16, marginTop: 0, marginLeft: 2, }, }, tableFilterAltOutlinedIcon: { width: ' 21px !important', height: '23px !important', marginTop: 0, marginRight: 2, }, headerIcon: { '& svg': { width: 16, height: 16, marginTop: 4, marginRight: 0, }, }, iconDirectionAsc: { transform: 'rotate(90deg)', }, iconDirectionDesc: { transform: 'rotate(180deg)', }, iconDirectionRight: { transform: 'rotate(180deg)', }, cellIcon: { '& svg': { width: 16, height: 16, marginTop: 3, }, }, FiltersCss: { border: '1px solid rgba(224, 224, 224, 1)', borderSpacing: 0, paddingLeft: '0 !important', paddingTop: '0 !important', height: '45px !important', backgroundColor: ' var(--unnamed-color-ffffff) 0% 0% no-repeat padding-box ', alignItems: 'center', minHeight: '64px', }, DividerCss: { background: '#F7F7FA 0% 0% no-repeat padding-box', // border: '1px solid #F1F1F1', height: '2px', }, SvgNoDataCss: { display: 'flex !important', justifyContent: 'center !important', alignContent: 'center!important', alignItems: 'center!important', border: '0', height: '60%', }, cardHeaderCss: { padding: '0 ', backgroundColor: 'white', marginBottom: '4px !important', border: '1px solid rgba(0,0,0,.125)', }, cell_short: { lineHeight: '1.5rem', fontWeight: '700!important', // width: 100, border: '0 !important', }, }); const areEqual = (prevProps, nextProps) => prevProps.checked === nextProps.checked && prevProps.indeterminate === nextProps.indeterminate; export const RawTable = (_a) => { var { children, className } = _a, rest = __rest(_a, ["children", "className"]); const classes = useStyles(); return (_jsx(MuiTableTable, Object.assign({ className: cx(className, classes.rawTable) }, rest, { children: children }))); }; export const TableBody = (_a) => { var { children, className } = _a, rest = __rest(_a, ["children", "className"]); const classes = useStyles(); return (_jsx(MuiTableBody, Object.assign({ className: cx(className, classes.tableBody) }, rest, { children: children }))); }; export const TableHead = (_a) => { var { children, className } = _a, rest = __rest(_a, ["children", "className"]); const classes = useStyles(); return (_jsx(MuiTableHead, Object.assign({ className: cx(className, classes.tableHead) }, rest, { children: children }))); }; export const TableHeadRow = (_a) => { var { children, className } = _a, rest = __rest(_a, ["children", "className"]); const classes = useStyles(); return (_jsx(MuiTableRow, Object.assign({ className: cx(className, classes.tableHeadRow) }, rest, { children: children }))); }; export const TableHeadCell = (_a) => { var { children, className } = _a, rest = __rest(_a, ["children", "className"]); const classes = useStyles(); return (_jsx(MuiTableCell, Object.assign({ className: cx(className, classes.tableHeadCell) }, rest, { children: children }))); }; export const TableRow = (_a) => { var { children, className } = _a, rest = __rest(_a, ["children", "className"]); const classes = useStyles(); return (_jsx(MuiTableRow, Object.assign({ className: cx(className, classes.tableRow) }, rest, { children: children }))); }; // export const TableRow = React.memo(TableRow_, areEqual); export const TableCell = (_a) => { var { children, className } = _a, rest = __rest(_a, ["children", "className"]); const classes = useStyles(); return (_jsx(MuiTableCell, Object.assign({ className: cx(className, classes.tableCell) }, rest, { children: children }))); }; // export const TableCell = React.memo(TableCell_, areEqual); export const TableLabel = (_a) => { var { children, className } = _a, rest = __rest(_a, ["children", "className"]); const classes = useStyles(); return (_jsx("div", Object.assign({ className: cx(className, classes.tableLabel) }, rest, { children: children }))); }; export const HeaderCheckbox = React.memo(styled(Checkbox)({ fontSize: '1rem', margin: '-8px 0 -8px -15px', padding: '8px 9px', '& svg': { width: '24px', height: '24px', }, '&:hover': { backgroundColor: 'transparent', }, }), areEqual); export const RowCheckbox = React.memo(styled(Checkbox)({ fontSize: '14px', margin: '-9px 0 -8px -15px', padding: '5px 9px', '&:hover': { backgroundColor: 'transparent', }, '& svg': { width: 24, height: 24, }, }), areEqual); //# sourceMappingURL=TableStyle.js.map