Skip to content

Commit ce553cd

Browse files
jassmithivoelbertvtrlx
authored
DataGrid 3.0 (#74)
* Theme storybook * Fix everything having the same image * Massively improve column performance * 100k cols is better than 2k * Cancel images * More aggressive image cache clearing * Fix testcases * More beautiful stories * Draw row selection in blank area * Prevent dragging columns when they should not be draggable * More stories * Try not to make out of bounds getCellValue calls when adding a new row * Fix crashes * More crash fixes * Links in markdown should open in blank target * Improve codespace * Add more expressive abilities for trailing row * Progress on new add styles * WIP * Improve handling of new row cell * Back to parity * Start breaking out rendering into smaller chunks * Use title instead of company because company is slow in faker and the mocks shouldn't slow down the demos * Build fixes * Update TS version * More faster with 100k cols * Re-enable blitting * Fix blitting * New story with all cell kinds * Fix all data types * Remove allow resize from public API as it can be inferred by onColumnResized * Improve images * Auto-redraw when editing a cell * Fix shift+click on last sticky row * Improve shift click onto last sticky row * Don't allow selection of add row * Add hover animations * Well if wasn't going to be a 3.0 before it definitely is now * Don't allow drag select on trailing row * Fix hook deps * Scroll to end when appending rows * Don't commit every branch back to storybook... * Prevent NaN in number editor * Bump version * New marker cells * DRY * Normal folks dont zero index * Support large numbers of selected rows efficiently * Fix hook * Greately improve standard multi-select behavior * More selection edge cases * Fix lint errors * Update linter * Fix drag selections starting from last sticky row * Optimize animation amnager * Fix jello scrolls * Make a class out of CompactSelection * Rework theme to be much simpler * Fix a few type errors * Remove dead code * Fix build * Pass a slightly less too big number * Scroll by 1000 vs 100 to make sure massive rows are well accounted for * Remove references to cellOffsetX/Y * Swap images column * Naming * Make sure icons work correctly in data grid with custom themed columns * WIP: New sticky row behavior * Single line border focus ring * Clean up bounds calculation * Fix text overlay editor sizing * Improve overlay editor layouting * Minor theme ugprades * Add multi-column select from the get go * Delete dead code * Don't search millions of rows. Get 1000's and stop * More string changes * update story * One more global gone * Don't respond to clicks outside of event region * Try to track down blitting issue * Prevent subpixel scroll as it screws up blitting * Rapidly fade in overlay editor * More edge cases handled in keyboard * Disable diagonal blitting as it causes issues * Faster but we will need to start adapting rendering to deal with clipping hurting performance too much very soon * Diagnol scrolling still too glitchy * Major drawing refactor * Fix hidpi * More perf work * improve damage performance * Eliminate middle buffer as it really hurts performance even though it cleans up the code a lot * Better handling of touch events * Fix issue when scrolling left in non smooth scroll * Fix sticky footer rendering without tint * Turn tint back on * Make sure overdraws are used correctly * WIP * Minor cleanup to event handling * Remove dep * Fix build * remove another dep * update docs * Add API for replacing icons * Add support for custom icons * errant console statement * Fix build * Hopefully fix safari events * Clipping works on safari now * Fix some focus scrolling behavior issues * Improve docs * Final column can resize in dead zone * Hopefully don't commit to main just to deploy page * More actions work * Remove cruft * remove testing code * Tag beta1 * Give ourselves a tiny amount of wiggle room to prevent scrollbars * beta 2 * Make sure not to highlight newly typed strings * Fix build * 3.0.0-beta3 * More theme tweaks * Add header click event * Remove shit parsing colors * Implement animations for headers * 3.0.0-beta4 * Add API to get first item from CompactSelection * Might as well have last too * Allocate image space only after image loads (#76) Previously, the space was allocated so long as the image was specified, and in the event that an image failed to load or specified an invalid URL, would leave an empty space to the right of the text. This fixes that issue. * Testing delayed handling of row append * 3.0.0-beta5 * Add exponential backoff to focus behavior * Don't show highlight on trailing row * Add right element * Minor fix * 3.0.0-beta7 * Fix height of right element * Fix missing line * 3.0.0-beta8 * Fix under-draw of grid lines * 3.0.0-beta9 * More diverse images with better optimization for big/small * 3.0.0-beta10 * Fix issue where sometimes you could not type to edit a cell * Draw blanks under lines as well * Fix minor themeing issue * Fix performance issues and clean up a couple more minor theming issues * Shrink sprite map * Improve handling of header border line * 3.0.0-rc4 * Add comments explaining future areas of improvement * Prevent invalid text measure cache results * Add rapid update support * Don't set a react state in rAF * Better numbers * Speed up random numbers slightly to try to stop bottlenecking streaming updates * Crush default svg's * Unused exports * Better error * Add copy story * Story cleanup * 3.0.0-rc5 * Add experimental padding support * Fix positioning bug with non-sticky scroll Y and new cells * Remove dead code * Deps * 3.0.0-rc7 * Fix overscroll and rendering issues * 3.0.0-rc8 * Dumb math error * 3.0.0-rc9 * Increase margin for error * Fix copy * 3.0 Co-authored-by: ivoelbert <ivo.elbert1@gmail.com> Co-authored-by: Victoria Lacroix <victoria@vlacroix.ca>
1 parent 6c465e2 commit ce553cd

51 files changed

Lines changed: 5187 additions & 1922 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# [Choice] Node.js version: 14, 12, 10
44
ARG VARIANT="14-buster"
55
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
6-
#Install google-cloud
7-
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && apt-get update -y && apt-get install google-cloud-sdk -y
8-
RUN rm -f ~/.config/gcloud/application_default_credentials.json
6+
7+
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg
8+
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
9+
10+
RUN apt-get update && DEBIAN_FRONTEND=non-interactive apt-get install gh -y

.devcontainer/devcontainer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
// Add the IDs of extensions you want installed when the container is created.
1919
"extensions": [
2020
"dbaeumer.vscode-eslint",
21-
"esbenp.prettier-vscode"
21+
"esbenp.prettier-vscode",
22+
"jpoissonnier.vscode-styled-components"
2223
],
2324

2425
// Use 'forwardPorts' to make a list of ports inside the container available locally.
25-
"forwardPorts": [3000, 9009],
26+
"forwardPorts": [9009],
2627

2728
// Use 'postCreateCommand' to run commands after the container is created.
2829
"postCreateCommand": "./.devcontainer/run.sh",

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"no-console": "warn",
1717
"guard-for-in": "error",
1818
"no-empty": "error",
19-
"no-shadow": "error",
19+
"no-shadow": "off",
2020
"import/no-cycle": "off",
2121
"import/namespace": "off",
2222
"import/named": "off",
@@ -30,6 +30,7 @@
3030
"@typescript-eslint/camelcase": "off",
3131
"@typescript-eslint/interface-name-prefix": "off",
3232
"@typescript-eslint/no-floating-promises": "error",
33+
"@typescript-eslint/no-shadow": "error",
3334
"@typescript-eslint/no-misused-promises": [
3435
"error",
3536
{

.storybook/main.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
const path = require('path');
1+
const path = require("path");
22

33
module.exports = {
44
stories: ["../src/**/*.stories.tsx"],
5-
addons: [
6-
"@storybook/addon-actions",
7-
"@storybook/addon-links",
8-
"@storybook/addon-controls",
9-
],
5+
addons: ["@storybook/addon-links", "@storybook/addon-controls"],
106
webpackFinal: async (config, { configType }) => {
117
// config.module.rules.push({
128
// test: /\.scss$/,
@@ -24,12 +20,12 @@ module.exports = {
2420
test: /\.(ts|tsx)$/,
2521
use: [
2622
{
27-
loader: require.resolve('babel-loader'),
23+
loader: require.resolve("babel-loader"),
2824
},
2925
],
3026
});
3127

32-
config.resolve.extensions.push('.ts', '.tsx');
28+
config.resolve.extensions.push(".ts", ".tsx");
3329

3430
config.performance.hints = false;
3531

.storybook/manager.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { addons } from "@storybook/addons";
2+
import { themes, create } from "@storybook/theming";
3+
4+
const glideTheme = create({
5+
base: "dark",
6+
brandTitle: "Glide Data Grid",
7+
brandUrl: "https://grid.glideapps.com",
8+
brandImage: "https://res.cloudinary.com/glide/image/upload/c_scale,w_45/v1634058004/glidehq/glide-transparent.png",
9+
});
10+
11+
addons.setConfig({
12+
isFullscreen: false,
13+
showNav: true,
14+
showPanel: false,
15+
panelPosition: "bottom",
16+
enableShortcuts: true,
17+
isToolshown: false,
18+
theme: glideTheme,
19+
selectedPanel: undefined,
20+
initialActive: "sidebar",
21+
sidebar: {
22+
showRoots: true,
23+
collapsedRoots: ["Subcomponents"],
24+
},
25+
toolbar: {
26+
title: { hidden: false },
27+
zoom: { hidden: false },
28+
eject: { hidden: false },
29+
copy: { hidden: false },
30+
fullscreen: { hidden: false },
31+
},
32+
});

.storybook/preview-body.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div id="portal" style="position: absolute; left: 0; top: 0; z-index: 9999;"></div>
1+
<div id="portal" style="position: fixed; left: 0; top: 0; z-index: 9999;"></div>

.storybook/preview-head.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<link rel="preconnect" href="https://fonts.googleapis.com">
2+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
3+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
14
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono|Roboto:400,500,700,900&display=swap" rel="stylesheet" />
25
<style>
36
html {

API.md

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Currently the Grid depends on there being a root level "portal" div in your HTML. Insert this snippet as the last child of your `<body>` tag:
66

77
```HTML
8-
<div id="portal" />
8+
<div id="portal" style="position: fixed; left: 0; top: 0; z-index: 9999;" />
99
```
1010

1111
Once you've got that done, the easiest way to use the Data Grid is to wrap it inside a `DataEditorContainer` component:
@@ -65,24 +65,11 @@ getCellContent: (cell: readonly [number, number]) => GridCell;
6565

6666
### Optional
6767

68-
```ts
69-
cellXOffset?: number;
70-
cellYOffset?: number;
71-
```
72-
73-
`cellXOffset` and `cellYOffset` are the zero-based indexes of the leftmost column, and topmost row to display, respectively. Both should be provided if one is.
74-
75-
```ts
76-
allowResize?: boolean;
77-
```
78-
79-
`allowResize` is a boolean indicating whether to allow resizing the widths of columns. Default is `false`.
80-
8168
```ts
8269
onVisibleRegionChanged?: (range: Rectangle) => void;
8370
```
8471

85-
`onVisibleRegionChanged` is called whenever the visible region changed. The new visible region is passed as a `Rectangle`. Note that you have to keep track of at least the `cellXOffset` and `cellYOffset`, for which the rectangle provides new values in `.x` and `.y`, respectively, and pass them back in as properties, otherwise your Grid will not scroll.
72+
`onVisibleRegionChanged` is called whenever the visible region changed. The new visible region is passed as a `Rectangle`.
8673

8774
```ts
8875
headerHeight: number;
@@ -97,10 +84,10 @@ rowHeight: number | ((index: number) => number);
9784
`rowHeight` is the height of a row in the table. It defaults to `34`. By passing a function instead of a number you can give different heights to each row. The `index` is the zero-based absolute row index.
9885

9986
```ts
100-
rowMarkers?: boolean;
87+
rowMarkers?: "checkbox" | "number" | "both" | "none";
10188
```
10289

103-
`rowMarkers` determines whether to display the marker column on the very left. It defaults to `true`. Note that this column doesn't count as a table column, i.e. it has no index, and doesn't change column indexes.
90+
`rowMarkers` determines whether to display the marker column on the very left. It defaults to `none`. Note that this column doesn't count as a table column, i.e. it has no index, and doesn't change column indexes.
10491

10592
```ts
10693
rowMarkerWidth?: number;
@@ -145,13 +132,15 @@ onItemHovered?: (args: GridMouseEventArgs) => void;
145132
`onItemHovered` is called when the user hovers over a cell, a header, or outside the grid.
146133

147134
```ts
148-
showTrailingBlankRow?: boolean;
149-
onRowAppended?: (cell: readonly [number, number], newValue: EditableGridCell) => void;
135+
trailingRowOptions?: {
136+
readonly tint?: boolean;
137+
readonly hint?: string;
138+
readonly sticky?: boolean;
139+
}
140+
onRowAppended?: (cell?: readonly [number, number], newValue?: EditableGridCell) => void;
150141
```
151142

152-
`showTrailingBlankRow` and `onRowAppended` control adding new rows at the bottom of the Grid. If `showTrailingBlankRow` is `true`, an empty, editable row will display at the bottom. If the user enters a value in one of its cells, `onRowAppended` is called, which is responsible for appending the new row.
153-
154-
`showTrailingBlankRow` is `true` by default.
143+
`onRowAppended` controls adding new rows at the bottom of the Grid. If `onRowAppended` is defined, an empty, editable row will display at the bottom. If the user enters a value in one of its cells, `onRowAppended` is called, which is responsible for appending the new row. The appearance of the blank row can be configured using `trailingRowOptions`.
155144

156145
```ts
157146
getCellsForSelection?: (selection: GridSelection) => readonly (readonly GridCell[])[];
@@ -212,7 +201,7 @@ If the value is less than 50, it will be increased to 50. If it isn't set, the d
212201

213202
### Cell coordinates
214203

215-
Many function properties take cell coordinates. Those are arrays of two numbers, namely the column index and the row index. Both are zero-based, and are absolute, i.e. independent of the region of cells currently displayed in the grid. For example, if `cellOffsetX` is `3` and `cellOffsetY` is `5`, then the coordinates of the cell displayed at the top left would be `[3, 5]`.
204+
Many function properties take cell coordinates. Those are arrays of two numbers, namely the column index and the row index. Both are zero-based, and are absolute, i.e. independent of the region of cells currently displayed in the grid.
216205

217206
### Rectangle
218207

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ We built [Data Grid](https://grid.glideapps.com) as the basis for the [Glide Dat
1515
- **Cell rendering can be customized**.
1616

1717
### Setting Up Codespaces
18+
1819
If you'd like to set up glide data grid locally and contribute, the easiest way to get up and running
1920
is to use Codespaces if you have access to it. If you do not, simply cloning the repo and running `npm install` also works!
21+
2022
#### Steps
21-
- Cick the green dropdown labeled code, there should be two tabs: local and codespaces.
22-
- Click on codespaces.
23-
- If this is your first time, then create a new codespace. It will open a new browser tab and build the docker container for it - there will be a button to open the environment in VSCode if you'd prefer to run it that way
24-
- You should see a screen that says `Setting up your codespace` As soon as that's done, you should see a VSCode like UI with files on the left.
25-
- Open a terminal window (you should find it at the top under terminal) and run
26-
`.devcontainer/install.sh`
23+
24+
- Cick the green dropdown labeled code, there should be two tabs: local and codespaces.
25+
- Click on codespaces.
26+
- If this is your first time, then create a new codespace. It will open a new browser tab and build the docker container for it - there will be a button to open the environment in VSCode if you'd prefer to run it that way
27+
- You should see a screen that says `Setting up your codespace` As soon as that's done, you should see a VSCode like UI with files on the left.
28+
- Open a terminal window (you should find it at the top under terminal) and run
29+
`.devcontainer/install.sh`
2730

2831
## Installation
2932

@@ -91,7 +94,7 @@ Please read the [Prerequisites section in the docs](API.md).
9194

9295
**Does it work with screen readers and other a11y tools?**
9396

94-
Not yet unfortunately. This is on our todo list.
97+
Yes. Unfortunately none of the primary developers are accessibility users so there are likely flaws in the implementation we are not aware of. Bug reports welcome!
9598

9699
**Does it support my data source?**
97100

babel.config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010
"@babel/preset-react",
1111
"@babel/preset-typescript"
1212
],
13-
"plugins": ["@babel/plugin-proposal-class-properties"]
13+
"plugins": ["@babel/plugin-proposal-class-properties"],
14+
"comments": false,
15+
"sourceMaps": true
1416
}

0 commit comments

Comments
 (0)