0.1.3 • Published 4 years ago

gridchen v0.1.3

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

About

Very lightweight and fast editable web grid with strict MS-Excel adherence to user experience. Modern as of year 2020 (web components, es6 modules) with no dependencies.

If you need to edit mixed hierarchical and grid data, please visit sister project form-chen.

Demos, PlayGrounds and Documentation

See grid-chen at github.io

Releases

All stable releases are tagged.

You either git-clone a release, copy the grid-chen module folder, reference the modules at https://decatur.github.io/grid-chen/gridchen, or install the gridchen Python package.

:warning: gridchen is not (yet) registered at npmjs.

Basic Usage

<!DOCTYPE html>
<grid-chen></grid-chen>
<script type="module">
    import "https://decatur.github.io/grid-chen/gridchen/webcomponent.js"
    import {createView} from "https://decatur.github.io/grid-chen/gridchen/matrixview.js"
    import {createTransactionManager} from "https://decatur.github.io/grid-chen/gridchen/utils.js";

    // The JSON schema defines the data structure of the matrix.
    const schema = {
        title: 'Array of Row Arrays',
        type: 'array',
        items: {
            type: 'array',
            items: [
                {title: 'SomeDate', type: 'string', format:'full-date'},
                {title: 'SomeNumber', type: 'number'}
            ]
        }
    };
    
    const rows = [['2019-01-01', 1], ['2020-01-01', 2], ['2021-01-01', 3]];
    const view = createView(schema, rows);
    const tm = createTransactionManager();
    document.querySelector('grid-chen').resetFromView(view, tm);
</script>

Expected Behaviour

We try to mimic MS-Excel as close as possible.

Supported Keyboard Shortcuts

See also Keyboard shortcuts in Excel

KeyAction
Ctrl+ZUndo last transaction
Ctrl+YRedo, reverse last undo
ArrowsMove active cell up/down/left/right (not in edit mode)
TabMove active cell right (non-rolling)
EnterMove active cell down (non-rolling)
Shift+EnterMove active cell up (non-rolling)
Shift+TabMove active cell left (non-rolling)
SHIFT+ArrowsSelect a range of cells
Ctrl+SpaceSelect entire column
Shift+SpaceSelect entire row
Shift+MouseClickExpand selection
Ctrl+MouseClickMulti-select cells
Ctrl+'-'Delete selected row
Ctrl+'+'Insert row before selection
Alt + EnterIn edit mode, insert newline
Page DownMove one page down
Page UpMove one page up
Ctrl+ASelect all grid cells (same as Ctrl+A in an Excel List Object)
Ctrl+A Ctrl+ASelect the entire grid including header (same as Ctrl+A Ctrl+A in an Excel List Object)
ESCCancel edit or input mode
DeleteRemove selected cells contents
Ctrl+CCopy selected cells to clipboard
Ctrl+VPaste clipboard into selected cells
Ctrl+XCut
F2Enter edit mode; In input or edit mode, toggle between input and edit.
Alt+F1Open a modal chart of the selection.
BackspaceIn input or edit mode, deletes one character to the left
DeleteIn input or edit mode, deletes one character to the right
EndIn input or edit mode, move to the end of the text
HomeIn input or edit mode, move to the beginning of the text

Light / Dark Mode

grid-chen has a light and dark mode. The desired mode is sniffed through the background color intensity of the body element. There are currently no other explicit CSS hooks, such as CSS custom properties.

⚠ Some dark reader (for example Dark Reader) extensions may show inferior results when converting light to dark mode than grid-chen's native dark mode.

Undo & Redo

tm

TODOs

  • Do not use JSON Patch replace for a remove operation!
  • TransactionManager: Do not add properties cell to patch array.
  • Handle clipboard not permitted errors
  • Improve encapsulation of JavaScript API
  • Show 1 empty row at end (Slider issue)
  • Avoid refreshing complete viewport on cell change
  • Handling of Infinity and NaN (#NV in de-de)

Alternatives