0.4.6-0 • Published 4 years ago

react-wseditor v0.4.6-0

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

react-wseditor

react worksheet like editor

NPM JavaScript Style Guide


Limitations

NEWS : improved version of this control available here react-ws-canvas

  • design : each component row, cell should have data and other informations in their prop in order to take advantage of React PureComponent or useMemo ( functional component ) to allow automatic avoid of rendering when props doesn't change. This implementation make use of direct access to editor information through object preventing this practice.
  • performance : when rows x count = cells count is big there are problem during cell change using keys ( arrow up/down )
  • alternatives :

Quickstart

yarn create react-app my-app --typescript
cd my-app
yarn add react-wseditor
code .

from vscode terminal issue a yarn start this will open browser for application debug

follow an example of react functional component ( requires yarn add chance @types/chance in order to work )

import React, { useState, useEffect } from "react";
import Chance from 'chance';

import { WSEditor, WSEditorColumn } from 'react-wseditor';

interface MyData {
    name: string;
    value1: number;
    value2: number;
    value3: number;
}

export default function MyComponent() {
    const [rows, setRows] = useState<MyData[]>([]);
    const [cols, setCols] = useState<WSEditorColumn<MyData>[]>([]);

    const SIZE_TEST = 10000;

    useEffect(() => {
        setCols([
            { header: "name", field: "name", defaultEditor: "text" },
            { header: 'value1', field: 'value1', defaultEditor: "number" },
            { header: 'value2', field: 'value2', defaultEditor: "number" },
            { header: 'value3', field: 'value3', defaultEditor: "number" },
        ]);

        const r: MyData[] = [];
        const chance = new Chance();
        for (let i = 0; i < SIZE_TEST; ++i) {
            r.push({
                name: chance.word(),
                value1: chance.minute(),
                value2: chance.floating({ min: 0, max: 1e6, fixed: 4 }),
                value3: chance.floating({ min: 0, max: 1e9, fixed: 2 })
            });
        }
        setRows(r);
    }, []);

    return <WSEditor
        debug={true}
        viewRowCount={6}
        rows={rows} setRows={setRows}
        cols={cols} setCols={setCols} />
}

Examples

npm.io

Features

How to contribute (quickstart)

to establish development environment to contribute with PR see here

development keynotes

to allow grid manage tons of rows was required by design to react only for view cells ( virtualized grid ) and manage mapping between rows data and cell views by pointing and converting view cell row index to data cell row index by a scroll offset information stored in editor state.

how this project was built

npm create react-library react-wseditor --typescript
0.4.6-0

4 years ago

0.4.4-0

5 years ago

0.4.3-0

5 years ago

0.4.2-0

5 years ago

0.4.1-0

5 years ago

0.4.0-0

5 years ago

0.3.26-0

5 years ago

0.3.25-0

5 years ago

0.3.24-0

5 years ago

0.3.22-0

5 years ago

0.3.21-0

5 years ago

0.3.20-0

5 years ago

0.3.17-0

5 years ago

0.3.16-0

5 years ago

0.3.15-0

5 years ago

0.3.14-0

5 years ago

0.3.12-0

5 years ago

0.3.11-0

5 years ago

0.3.10-0

5 years ago

0.3.9-0

5 years ago

0.3.8-0

5 years ago

0.3.7-0

5 years ago

0.3.6-0

5 years ago

0.3.5-0

5 years ago

0.3.3-0

5 years ago

0.3.2-0

5 years ago

0.3.1-0

5 years ago

0.3.0-0

5 years ago

0.2.7-0

5 years ago

0.2.5-0

5 years ago

0.2.4-0

5 years ago

0.2.3-0

5 years ago

0.2.2-0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago