Skip to content

Commit 1f09988

Browse files
authored
Merge branch 'main' into clarity
2 parents d5f94fa + 26c96ee commit 1f09988

File tree

11 files changed

+94
-22
lines changed

11 files changed

+94
-22
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ The DataGrid supports the following CSS variables for customization:
187187
--rdg-summary-border-width: calc(var(--rdg-border-width) * 2);
188188
--rdg-summary-border-color: light-dark(#aaa, #555);
189189

190-
/* Frozen columns */
191-
--rdg-cell-frozen-box-shadow: 2px 0 5px -2px rgba(136, 136, 136, 0.3);
192-
193190
/* Checkboxes */
194191
--rdg-checkbox-focus-color: hsl(207deg 100% 69%);
195192
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"typecheck": "tsc --build"
4848
},
4949
"devDependencies": {
50-
"@eslint-react/eslint-plugin": "3.0.0-beta.53",
50+
"@eslint-react/eslint-plugin": "3.0.0-beta.68",
5151
"@eslint/markdown": "^7.5.1",
5252
"@faker-js/faker": "^10.0.0",
5353
"@tanstack/react-router": "^1.132.31",
@@ -60,15 +60,15 @@
6060
"@vitest/coverage-istanbul": "^4.0.16",
6161
"@vitest/eslint-plugin": "^1.6.4",
6262
"clsx": "^2.1.1",
63-
"ecij": "^0.3.0",
63+
"ecij": "^0.4.1",
6464
"eslint": "^10.0.1",
6565
"eslint-plugin-jest-dom": "^5.5.0",
6666
"eslint-plugin-react-hooks": "^7.0.1",
6767
"eslint-plugin-sonarjs": "^4.0.0",
6868
"eslint-plugin-testing-library": "^7.13.5",
6969
"jspdf": "^4.0.0",
7070
"jspdf-autotable": "^5.0.2",
71-
"oxfmt": "0.35.0",
71+
"oxfmt": "0.36.0",
7272
"playwright": "~1.58.0",
7373
"postcss": "^8.5.2",
7474
"react": "^19.2.1",
@@ -77,7 +77,7 @@
7777
"rolldown-plugin-dts": "^0.22.1",
7878
"typescript": "~5.9.2",
7979
"typescript-eslint": "^8.56.0",
80-
"vite": "^8.0.0-beta.13",
80+
"vite": "^8.0.0-beta.16",
8181
"vitest": "^4.0.17",
8282
"vitest-browser-react": "^2.0.2"
8383
},

src/DataGrid.tsx

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ import type { PartialPosition } from './ScrollToCell';
6969
import ScrollToCell from './ScrollToCell';
7070
import { default as defaultRenderSortStatus } from './sortStatus';
7171
import { cellDragHandleClassname, cellDragHandleFrozenClassname } from './style/cell';
72-
import { rootClassname, viewportDraggingClassname } from './style/core';
72+
import {
73+
rootClassname,
74+
frozenColumnShadowClassname,
75+
viewportDraggingClassname,
76+
frozenColumnShadowTopClassname
77+
} from './style/core';
7378
import SummaryRow from './SummaryRow';
7479

7580
export interface SelectCellState extends Position {
@@ -368,6 +373,10 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
368373
const minRowIdx = -headerAndTopSummaryRowsCount;
369374
const mainHeaderRowIdx = minRowIdx + groupedColumnHeaderRowsCount;
370375
const maxRowIdx = rows.length + bottomSummaryRowsCount - 1;
376+
const frozenShadowStyles: React.CSSProperties = {
377+
gridColumnStart: lastFrozenColumnIndex + 2,
378+
insetInlineStart: totalFrozenColumnWidth
379+
};
371380

372381
const [selectedPosition, setSelectedPosition] = useState(
373382
(): SelectCellState | EditCellState<R> => ({ idx: -1, rowIdx: minRowIdx - 1, mode: 'SELECT' })
@@ -1270,11 +1279,11 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
12701279
const isSummaryRowSelected = selectedPosition.rowIdx === summaryRowIdx;
12711280
const top =
12721281
clientHeight > totalRowHeight
1273-
? gridHeight - summaryRowHeight * (bottomSummaryRows.length - rowIdx)
1282+
? gridHeight - summaryRowHeight * (bottomSummaryRowsCount - rowIdx)
12741283
: undefined;
12751284
const bottom =
12761285
top === undefined
1277-
? summaryRowHeight * (bottomSummaryRows.length - 1 - rowIdx)
1286+
? summaryRowHeight * (bottomSummaryRowsCount - 1 - rowIdx)
12781287
: undefined;
12791288

12801289
return (
@@ -1299,6 +1308,47 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
12991308
)}
13001309
</DataGridDefaultRenderersContext>
13011310

1311+
{lastFrozenColumnIndex > -1 && (
1312+
<>
1313+
<div
1314+
className={frozenColumnShadowTopClassname}
1315+
style={{
1316+
...frozenShadowStyles,
1317+
gridRowStart: 1,
1318+
gridRowEnd: headerRowsCount + 1 + topSummaryRowsCount,
1319+
insetBlockStart: 0
1320+
}}
1321+
/>
1322+
1323+
{rows.length > 0 && (
1324+
<div
1325+
className={frozenColumnShadowClassname}
1326+
style={{
1327+
...frozenShadowStyles,
1328+
gridRowStart: headerAndTopSummaryRowsCount + rowOverscanStartIdx + 1,
1329+
gridRowEnd: headerAndTopSummaryRowsCount + rowOverscanEndIdx + 2
1330+
}}
1331+
/>
1332+
)}
1333+
1334+
{bottomSummaryRows != null && bottomSummaryRowsCount > 0 && (
1335+
<div
1336+
className={frozenColumnShadowTopClassname}
1337+
style={{
1338+
...frozenShadowStyles,
1339+
gridRowStart: headerAndTopSummaryRowsCount + rows.length + 1,
1340+
gridRowEnd: headerAndTopSummaryRowsCount + rows.length + 1 + bottomSummaryRowsCount,
1341+
insetBlockStart:
1342+
clientHeight > totalRowHeight
1343+
? gridHeight - summaryRowHeight * bottomSummaryRowsCount
1344+
: undefined,
1345+
insetBlockEnd: clientHeight > totalRowHeight ? undefined : 0
1346+
}}
1347+
/>
1348+
)}
1349+
</>
1350+
)}
1351+
13021352
{getDragHandle()}
13031353

13041354
{/* render empty cells that span only 1 column so we can safely measure column widths, regardless of colSpan */}

src/style/cell.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ export const cellFrozen = css`
3535
position: sticky;
3636
/* Should have a higher value than 0 to show up above unfrozen cells */
3737
z-index: 1;
38-
39-
/* Add box-shadow on the last frozen cell */
40-
&:nth-last-child(1 of &) {
41-
box-shadow: var(--rdg-cell-frozen-box-shadow);
42-
}
4338
}
4439
`;
4540

src/style/core.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const root = css`
1616
--rdg-selection-width: 2px;
1717
--rdg-selection-color: hsl(207, 75%, 66%);
1818
--rdg-font-size: 14px;
19-
--rdg-cell-frozen-box-shadow: 2px 0 5px -2px rgba(136, 136, 136, 0.3);
2019
--rdg-border-width: 1px;
2120
--rdg-summary-border-width: calc(var(--rdg-border-width) * 2);
2221
--rdg-color: light-dark(#000, #ddd);
@@ -38,10 +37,6 @@ const root = css`
3837
color-scheme: light;
3938
}
4039
41-
&:dir(rtl) {
42-
--rdg-cell-frozen-box-shadow: -2px 0 5px -2px rgba(136, 136, 136, 0.3);
43-
}
44-
4540
display: grid;
4641
4742
accent-color: light-dark(hsl(207deg 100% 29%), hsl(207deg 100% 79%));
@@ -59,6 +54,9 @@ const root = css`
5954
color: var(--rdg-color);
6055
font-size: var(--rdg-font-size);
6156
57+
container-name: rdg-root;
58+
container-type: scroll-state;
59+
6260
/* needed on Firefox to fix scrollbars */
6361
&::before {
6462
content: '';
@@ -92,3 +90,35 @@ const viewportDragging = css`
9290
`;
9391

9492
export const viewportDraggingClassname = `rdg-viewport-dragging ${viewportDragging}`;
93+
94+
// Add shadow after the last frozen cell
95+
export const frozenColumnShadowClassname = css`
96+
position: sticky;
97+
width: 10px;
98+
background-image: linear-gradient(
99+
to right,
100+
light-dark(rgb(0 0 0 / 15%), rgb(0 0 0 / 40%)),
101+
transparent
102+
);
103+
pointer-events: none;
104+
z-index: 1;
105+
106+
opacity: 1;
107+
transition: opacity 0.1s;
108+
109+
/* TODO: reverse 'opacity' and remove 'not' */
110+
@container rdg-root not scroll-state(scrollable: inline-start) {
111+
opacity: 0;
112+
}
113+
114+
&:dir(rtl) {
115+
transform: scaleX(-1);
116+
}
117+
`;
118+
119+
const topShadowClassname = css`
120+
/* render above header and summary rows */
121+
z-index: 2;
122+
`;
123+
124+
export const frozenColumnShadowTopClassname = `${frozenColumnShadowClassname} ${topShadowClassname}`;
-2.26 KB
Loading
-1.26 KB
Loading
-2.38 KB
Loading
-1.65 KB
Loading

website/routes/CommonFeatures.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const dialogContainerClassname = css`
3434
inset: 0;
3535
display: flex;
3636
place-items: center;
37-
background: rgba(0, 0, 0, 0.1);
37+
background: rgb(0 0 0 / 10%);
3838
3939
> dialog {
4040
width: 300px;

0 commit comments

Comments
 (0)