4.3.12 • Published 10 days ago

bear-react-table v4.3.12

Weekly downloads
-
License
MIT
Repository
github
Last release
10 days ago

bear-react-table

Datepicker library based for Reactjs

NPM npm

Support Version Map

ReactReact ScriptsBear React Table
185.0.12.0.0

Install

yarn add bear-react-table

Usage

add in your index.tsx

import "bear-react-table/dist/index.css";

then in your page

import {Table} from 'bear-react-table';


const getPageData = (currentPage: number, pageLimit: number) => {
    const pageStart = (currentPage -1) * pageLimit;
    return data.slice(pageStart, pageStart + pageLimit );
}


const BaseUsed = () => {

    const [isFetching, setIsFetching] = useState(false);
    const [paginateMeta, setPaginateMeta] = useState<IPaginateMeta>({
        currentPage: 1,
        pageLimit: 8,
        sort: {field: 'name', orderBy: 'DESC'},
    });
    const [paginateData, setPaginateData] = useState<IPaginateData[]>(getPageData(paginateMeta.currentPage, paginateMeta.pageLimit));
    const [paginateInfo, setPaginateInfo] = useState<IPaginateInfo>({
        totalItems: data.length,
        totalPages: Math.ceil(data.length / paginateMeta.pageLimit),
    });



    /**
     * 查詢分頁
     */
    const handleFetchPaginate = useCallback((meta: IPaginateMeta) => {
        // 取得查詢項目
        setIsFetching(true);
        setPaginateMeta(meta);

        setTimeout(() => {
            setPaginateData(getPageData(meta.currentPage, meta.pageLimit));
            setIsFetching(false);
        }, 400);
    }, []);



    return <div className="d-flex flex-row my-2">
        <Table
            isFetching={isFetching}
            title={[
                {text: '#',          field: 'avatar',      col: 60, titleAlign: 'center', dataAlign: 'center'},
                {text: 'Name',       field: 'name',        col: true, isEnableSort: true},
                {text: 'Role',       field: 'role',        col: 120},
                {text: 'Crated',     field: 'createdAt',   col: 110, isEnableSort: true},
                {text: 'Joined',     field: 'isApplyJoin', col: 80},
            ]}
            data={paginateData.map(row => {
                const createdAt = dayjs(row.createdAt);

                return {
                    id: row.id,
                    disabled: !row.isJoined,
                    field: {
                        avatar: <Avatar style={{backgroundImage: `url(${row.avatar})`}}/>,
                        name: <div className="d-flex flex-column">
                            <div>{row.name}</div>
                            <div>{row.email}</div>
                        </div>,
                        isApplyJoin: row.isJoined ? '已加入':'等待同意',
                        createdAt: <div style={{fontSize: 12}}>
                            {createdAt.format('YYYY-MM-DD')}<br/>
                            {createdAt.format('HH:mm:ss')}
                        </div>,
                    }
                    
                };
            })}
            onChangePage={handleFetchPaginate}
            paginateMeta={paginateMeta}
            paginateInfo={paginateInfo}
        />

    </div>

};

There is also a codesandbox template that you can fork and play with it:

Edit react-editext-template

License

MIT © imagine10255

4.3.13-alpha.1

10 days ago

4.3.13-alpha.0

11 days ago

4.3.12

3 months ago

4.3.11

3 months ago

4.3.10

3 months ago

4.3.9

4 months ago

4.3.8

4 months ago

4.3.8-alpha.1

4 months ago

4.3.8-alpha.0

4 months ago

4.3.8-alpha.2

4 months ago

4.3.7

5 months ago

4.3.6

5 months ago

4.3.6-alpha.4

5 months ago

4.3.6-alpha.1

5 months ago

4.3.6-alpha.3

5 months ago

4.3.6-alpha.2

5 months ago

4.3.4-alpha.4

7 months ago

4.0.2-alpha.0

8 months ago

4.3.4-alpha.5

7 months ago

4.3.4-alpha.2

7 months ago

4.0.2-alpha.1

8 months ago

4.3.4-alpha.1

7 months ago

4.2.1-alpha.0

8 months ago

4.2.1-alpha.1

8 months ago

4.3.4-alpha.8

7 months ago

4.3.5

6 months ago

4.3.4-alpha.9

7 months ago

4.3.4-alpha.6

7 months ago

4.3.4-alpha.7

7 months ago

4.2.1-alpha.2

8 months ago

4.3.6-alpha.0

5 months ago

4.0.0-alpha.0

8 months ago

4.2.3

8 months ago

4.2.2

8 months ago

4.2.5

8 months ago

4.0.1

8 months ago

4.0.0

8 months ago

4.2.1

8 months ago

4.2.0

8 months ago

4.3.4-alpha.10

7 months ago

4.3.4-alpha.12

7 months ago

4.3.4-alpha.11

7 months ago

4.3.4-alpha.14

7 months ago

4.3.5-alpha.0

7 months ago

4.3.4-alpha.13

7 months ago

4.3.5-alpha.3

6 months ago

4.3.5-alpha.4

6 months ago

4.3.5-alpha.1

7 months ago

3.0.1-alpha.8

10 months ago

4.3.5-alpha.2

6 months ago

4.3.5-alpha.5

6 months ago

4.3.5-alpha.6

6 months ago

4.2.7

8 months ago

4.2.6

8 months ago

4.3.1

7 months ago

4.3.4

7 months ago

4.3.3

7 months ago

4.1.0

8 months ago

4.3.0

7 months ago

4.1.0-alpha.0

8 months ago

3.0.1-alpha.6

11 months ago

3.0.1-alpha.5

11 months ago

3.0.1-alpha.7

11 months ago

3.0.1-aplha.0

11 months ago

3.0.1-aplha.3

11 months ago

3.0.1-aplha.4

11 months ago

3.0.1-aplha.1

11 months ago

3.0.1-aplha.2

11 months ago

3.0.0

1 year ago

2.2.0-alpha.4

1 year ago

2.2.0-alpha.0

1 year ago

2.2.0-alpha.2

1 year ago

2.2.0-alpha.1

1 year ago

2.1.2

2 years ago

2.1.2-alpha.0

2 years ago

2.1.1

2 years ago

2.1.1-alpha.1

2 years ago

2.1.1-alpha.0

2 years ago

2.1.0

2 years ago

2.1.0-alpha.2

2 years ago

2.1.0-alpha.1

2 years ago

2.1.0-alpha.0

2 years ago

2.0.9-alpha.0

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.3-alpha.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago