Skip to content

Commit

Permalink
Merge pull request #233 from icflorescu/next
Browse files Browse the repository at this point in the history
Extract DataTableHeaderSelectorCell component, update turbo, bump version
  • Loading branch information
icflorescu committed Mar 30, 2023
2 parents ef9ac4d + 1e8b0cf commit 1d40bb8
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 105 deletions.
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mantine-datatable-docs",
"version": "2.2.8",
"version": "2.2.9",
"description": "Docs website for mantine-datatable; see ../package/package.json for more info",
"private": true,
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mantine-datatable-turborepo",
"version": "2.2.8",
"version": "2.2.9",
"description": "This is a monorepo; see package/package.json for more info",
"private": true,
"workspaces": [
Expand Down Expand Up @@ -36,7 +36,7 @@
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"prettier": "^2.8.7",
"turbo": "^1.8.6",
"turbo": "^1.8.8",
"typescript": "^5.0.2"
},
"engines": {
Expand Down
80 changes: 19 additions & 61 deletions package/DataTableHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,20 @@
import { Checkbox, createStyles, px, type CSSObject } from '@mantine/core';
import { createStyles, type CSSObject } from '@mantine/core';
import { forwardRef, type CSSProperties, type ForwardedRef } from 'react';
import DataTableHeaderCell from './DataTableHeaderCell';
import DataTableHeaderSelectorCell from './DataTableHeaderSelectorCell';
import type { DataTableColumn, DataTableSortStatus } from './types';

const useStyles = createStyles((theme) => {
const shadowGradientAlpha = theme.colorScheme === 'dark' ? 0.5 : 0.05;
return {
root: {
zIndex: 2,
position: 'sticky',
top: 0,
background: theme.colorScheme === 'dark' ? theme.colors.dark[7] : theme.white,
},
textSelectionDisabled: {
userSelect: 'none',
},
selectorColumnHeader: {
position: 'sticky',
width: 0,
left: 0,
background: 'inherit',
'&::after': {
content: '""',
position: 'absolute',
top: 0,
right: -px(theme.spacing.sm),
bottom: 0,
borderLeft: `1px solid ${theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`,
width: theme.spacing.sm,
background: `linear-gradient(to right, ${theme.fn.rgba(theme.black, shadowGradientAlpha)}, ${theme.fn.rgba(
theme.black,
0
)}), linear-gradient(to right, ${theme.fn.rgba(theme.black, shadowGradientAlpha)}, ${theme.fn.rgba(
theme.black,
0
)} 30%)`,
pointerEvents: 'none',
opacity: 0,
transition: 'opacity .15s ease',
},
},
selectorColumnHeaderWithRightShadow: {
'&::after': {
opacity: 1,
},
},
selectionCheckboxInput: {
cursor: 'pointer',
},
};
});
const useStyles = createStyles((theme) => ({
root: {
zIndex: 2,
position: 'sticky',
top: 0,
background: theme.colorScheme === 'dark' ? theme.colors.dark[7] : theme.white,
},
textSelectionDisabled: {
userSelect: 'none',
},
}));

type DataTableHeaderProps<T> = {
className?: string;
Expand Down Expand Up @@ -85,19 +50,12 @@ export default forwardRef(function DataTableHeader<T>(
<thead className={cx(classes.root, className)} style={style as CSSProperties} ref={ref}>
<tr>
{selectionVisible && (
<th
className={cx(classes.selectorColumnHeader, {
[classes.selectorColumnHeaderWithRightShadow]: leftShadowVisible,
})}
>
<Checkbox
classNames={{ input: classes.selectionCheckboxInput }}
checked={selectionChecked}
indeterminate={selectionIndeterminate}
disabled={!onSelectionChange}
onChange={onSelectionChange}
/>
</th>
<DataTableHeaderSelectorCell
shadowVisible={leftShadowVisible}
checked={selectionChecked}
indeterminate={selectionIndeterminate}
onChange={onSelectionChange}
/>
)}
{columns.map(
({
Expand Down
67 changes: 67 additions & 0 deletions package/DataTableHeaderSelectorCell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Checkbox, createStyles, px } from '@mantine/core';

const useStyles = createStyles((theme) => {
const shadowGradientAlpha = theme.colorScheme === 'dark' ? 0.5 : 0.05;
return {
root: {
position: 'sticky',
width: 0,
left: 0,
background: 'inherit',
'&::after': {
content: '""',
position: 'absolute',
top: 0,
right: -px(theme.spacing.sm),
bottom: 0,
borderLeft: `1px solid ${theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`,
width: theme.spacing.sm,
background: `linear-gradient(to right, ${theme.fn.rgba(theme.black, shadowGradientAlpha)}, ${theme.fn.rgba(
theme.black,
0
)}), linear-gradient(to right, ${theme.fn.rgba(theme.black, shadowGradientAlpha)}, ${theme.fn.rgba(
theme.black,
0
)} 30%)`,
pointerEvents: 'none',
opacity: 0,
transition: 'opacity .15s ease',
},
},
shadowVisible: {
'&::after': {
opacity: 1,
},
},
checkboxInput: {
cursor: 'pointer',
},
};
});

type DataTableHeaderSelectorCellProps = {
shadowVisible: boolean;
checked: boolean;
indeterminate: boolean;
onChange: (() => void) | undefined;
};

export default function DataTableHeaderSelectorCell({
shadowVisible,
checked,
indeterminate,
onChange,
}: DataTableHeaderSelectorCellProps) {
const { cx, classes } = useStyles();
return (
<th className={cx(classes.root, { [classes.shadowVisible]: shadowVisible })}>
<Checkbox
classNames={{ input: classes.checkboxInput }}
checked={checked}
indeterminate={indeterminate}
disabled={!onChange}
onChange={onChange}
/>
</th>
);
}
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mantine-datatable",
"version": "2.2.8",
"version": "2.2.9",
"description": "Datatable component for Mantine UI, featuring asynchronous data loading support, pagination, multple rows selection, column sorting, custom cell data rendering, row context menu, row expansion and more",
"keywords": [
"ui",
Expand Down
80 changes: 40 additions & 40 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6574,47 +6574,47 @@ tsutils@^3.21.0:
dependencies:
tslib "^1.8.1"

turbo-darwin-64@1.8.6:
version "1.8.6"
resolved "https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-1.8.6.tgz#0aa99b8e6e48667648ad5bb9b2c29d734821cd11"
integrity sha512-VlXkQR0TEBAEyBRsvAXBax+fj1EdPKPliwBaCnRLiDUcA/8wYlKte/Kk6ubmj9E0n7U/B4keCxxHiJZqW/5Rqg==

turbo-darwin-arm64@1.8.6:
version "1.8.6"
resolved "https://registry.yarnpkg.com/turbo-darwin-arm64/-/turbo-darwin-arm64-1.8.6.tgz#359a80bd9ae4ffc7091a2b7dbd260920c5fb37b6"
integrity sha512-w4L2QLj90ex68UXxTPoqtZPl8mWzc6a1RtPjQhoxAWtZf9T2WXi813dCzYEbVUVC09/DOW/VxZRN7sb2r0KP9A==

turbo-linux-64@1.8.6:
version "1.8.6"
resolved "https://registry.yarnpkg.com/turbo-linux-64/-/turbo-linux-64-1.8.6.tgz#432d6b569bbcf64bdc3f6b3ec898f210d3ff4b1c"
integrity sha512-eV245jefIhMAZskqQKalFwreC5UEdQcuHcBiWcgUk0py76fbwB7+1HfH5cmeJlb3a1sB6f3H0HHmGPmb34feCA==

turbo-linux-arm64@1.8.6:
version "1.8.6"
resolved "https://registry.yarnpkg.com/turbo-linux-arm64/-/turbo-linux-arm64-1.8.6.tgz#5a75828bdaf6894f04510bedf4d6c7fb97117e74"
integrity sha512-Kiw3nyEvNU6Bpil4zE5FwhasPAOi59R4YdCmjJp0Sen6V9u+/Jij6SWwaoUdATORJLiYQBbhontWBH55B53VDw==

turbo-windows-64@1.8.6:
version "1.8.6"
resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.8.6.tgz#0ade09c84581539aab075d1adf03dce78bcfd378"
integrity sha512-34BkAG9r4nE00xeMeVahaF82h8R6SO+IIOcD60fNr2p+Ch+YcQa+DbEWA/KUj3coUTIiNP5XnRCLRUYADdlxjQ==

turbo-windows-arm64@1.8.6:
version "1.8.6"
resolved "https://registry.yarnpkg.com/turbo-windows-arm64/-/turbo-windows-arm64-1.8.6.tgz#a675c0443e068e49bc64db679880282601756a8a"
integrity sha512-4jWUaI7Lmonp2I3x81GruiCYd0aQsG/xDOYhuv9+j2yIgB/UHJFz/P8PWp/nziwPtGpRd/AheDlPzzyd9lWoqw==

turbo@^1.8.6:
version "1.8.6"
resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.8.6.tgz#35a14872de5bf00ba6062cf90dd2692a95e5f6e2"
integrity sha512-6IOOaa8ytgjnSCTnp3LKAd2uGBZ/Kmx8ZPlI/YMWuKMUqvkXKLbh+w76ApMgMm+faUqti+QujVWovCu2kY6KuQ==
turbo-darwin-64@1.8.8:
version "1.8.8"
resolved "https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-1.8.8.tgz#f72b1b6275415b17238f450032c8ef5e5fc71777"
integrity sha512-18cSeIm7aeEvIxGyq7PVoFyEnPpWDM/0CpZvXKHpQ6qMTkfNt517qVqUTAwsIYqNS8xazcKAqkNbvU1V49n65Q==

turbo-darwin-arm64@1.8.8:
version "1.8.8"
resolved "https://registry.yarnpkg.com/turbo-darwin-arm64/-/turbo-darwin-arm64-1.8.8.tgz#8ec78848e0d5978fd732b3588a1b406fdb978839"
integrity sha512-ruGRI9nHxojIGLQv1TPgN7ud4HO4V8mFBwSgO6oDoZTNuk5ybWybItGR+yu6fni5vJoyMHXOYA2srnxvOc7hjQ==

turbo-linux-64@1.8.8:
version "1.8.8"
resolved "https://registry.yarnpkg.com/turbo-linux-64/-/turbo-linux-64-1.8.8.tgz#b1f707b23bc6e22b2894dd8063fc2fa4dbb6ffb9"
integrity sha512-N/GkHTHeIQogXB1/6ZWfxHx+ubYeb8Jlq3b/3jnU4zLucpZzTQ8XkXIAfJG/TL3Q7ON7xQ8yGOyGLhHL7MpFRg==

turbo-linux-arm64@1.8.8:
version "1.8.8"
resolved "https://registry.yarnpkg.com/turbo-linux-arm64/-/turbo-linux-arm64-1.8.8.tgz#34575bdffd2af8c835d9ba3dd9e3a83e0d31dac9"
integrity sha512-hKqLbBHgUkYf2Ww8uBL9UYdBFQ5677a7QXdsFhONXoACbDUPvpK4BKlz3NN7G4NZ+g9dGju+OJJjQP0VXRHb5w==

turbo-windows-64@1.8.8:
version "1.8.8"
resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.8.8.tgz#73f67969d54269c95cbf7f082e22c20368aedddc"
integrity sha512-2ndjDJyzkNslXxLt+PQuU21AHJWc8f6MnLypXy3KsN4EyX/uKKGZS0QJWz27PeHg0JS75PVvhfFV+L9t9i+Yyg==

turbo-windows-arm64@1.8.8:
version "1.8.8"
resolved "https://registry.yarnpkg.com/turbo-windows-arm64/-/turbo-windows-arm64-1.8.8.tgz#c80b9a170adf6ee028e9dcae45b07755af83f3f2"
integrity sha512-xCA3oxgmW9OMqpI34AAmKfOVsfDljhD5YBwgs0ZDsn5h3kCHhC4x9W5dDk1oyQ4F5EXSH3xVym5/xl1J6WRpUg==

turbo@^1.8.8:
version "1.8.8"
resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.8.8.tgz#8bb331e3f0bd9656b20321339e91e899ad499012"
integrity sha512-qYJ5NjoTX+591/x09KgsDOPVDUJfU9GoS+6jszQQlLp1AHrf1wRFA3Yps8U+/HTG03q0M4qouOfOLtRQP4QypA==
optionalDependencies:
turbo-darwin-64 "1.8.6"
turbo-darwin-arm64 "1.8.6"
turbo-linux-64 "1.8.6"
turbo-linux-arm64 "1.8.6"
turbo-windows-64 "1.8.6"
turbo-windows-arm64 "1.8.6"
turbo-darwin-64 "1.8.8"
turbo-darwin-arm64 "1.8.8"
turbo-linux-64 "1.8.8"
turbo-linux-arm64 "1.8.8"
turbo-windows-64 "1.8.8"
turbo-windows-arm64 "1.8.8"

type-check@^0.4.0, type-check@~0.4.0:
version "0.4.0"
Expand Down

0 comments on commit 1d40bb8

Please sign in to comment.