Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 153 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,154 @@
# Bright-table
# Bright Table

A table library released by and for Brightsoftware. It is open for everyone to use and contribute.


![Example screenshot from the example/react](https://github.com/user-attachments/assets/74116377-e84f-43e1-ac88-b71876f18803)


## ✨ Features

### 🔧 Core Functionality
- **Virtual Scrolling** - High performance rendering for large datasets ( probably in future ).
- **Server-side Pagination** - Laravel-compatible pagination support
- **Sorting** - Built-in column sorting with custom sort indicators ( requires manual sorting by the way. )
- **Row Selection** - Single and multi-row selection with checkboxes
- **Tree Tables** - Hierarchical data display with expandable rows

### 🎨 UI/UX Features
- **RTL Support** - Right-to-left language compatibility
- **Striped Rows** - Alternating row colors for better readability
- **Hover Effects** - Interactive row highlighting
- **Loading States** - Built-in loading indicators and empty states

### 📱 Layout & Styling
- **Fixed Columns** - Pin columns to left or right
- **Column Groups** - Group related columns with headers
- **Auto Height** - Dynamic table height based on content
- **Custom Cell Rendering** - Flexible cell content with custom components
- **Cell and Row span** - Span cells across rows and columns
- **CSS Variables** - Easy theming and customization

## 📦 Installation

```bash
npm install @brightsoftware/table
# or
yarn add @brightsoftware/table
# or
bun add @brightsoftware/table
```

## 🚀 Example
> [!NOTE]
> This is the code for above displayed table.

```tsx
import { Cell, Column, ColumnGroup, HeaderCell, Table } from "@brightsoftware/table"
import { data, mockNestedData, } from "./faker";
import { useEffect, useState } from "react";
import { larvelPaginationObject } from "@brightsoftware/table/types/src/Pagination.d.ts";

function App() {
const [data, setData] = useState<data[]>([]);

useEffect(() => {
const data = mockNestedData(101);
setData(data);
}, []);

const [sort, setSort] = useState<"asc" | "desc" | undefined>();

return (
<Table
name="MP"
rowSelection
headerHeight={80}
isTree
rowKey={"id"}
rowBordered
pagination={{
// laravel pagination serverResponse,
onRowsPerPageChange(newRowPerPage) {
console.log(newRowPerPage)
},
linkComponent: {
element: <a />,
urlProp: "href"
}
}}
shouldUpdateScroll={false}
stripeRows
data={data}
cellBordered
autoHeight
>
<Column width={200} customizable id="sn">
<HeaderCell>
sn
</HeaderCell>
<Cell>
{(_, i) => {
return (i || 0 + 1);
}}
</Cell>
</Column>

<ColumnGroup header="User Name">
<Column width={250} customizable id="firstname">
<HeaderCell>First Name</HeaderCell>
<Cell >
{(rd) => {
return rd.firstname;
}}
</Cell>
</Column>

<Column width={150} customizable id="lastname">
<HeaderCell>Last Name</HeaderCell>
<Cell dataKey="lastname" />
</Column>

</ColumnGroup>

<Column
width={300}
minWidth={300}
flexGrow={1}
align="left"
customizable
id="email"
sort={sort}
onHeaderClick={() => {
// your actions
}}
>
<HeaderCell>Email</HeaderCell>
<Cell dataKey="email" />
</Column>

<Column width={100} align="center">
<HeaderCell>...</HeaderCell>
<Cell style={{ padding: '6px' }}>
{rowData => (
<button onClick={() => alert(`id:${rowData.id}`)}>
Edit
</button>
)}
</Cell>
</Column>
</Table>
)
}

export default App
```

## 🏢 About

Developed by [Bright Office System](https://brightit.com.np/) - A leading software development company focused on creating modern, efficient web solutions.

---

For more examples, please visit the example/react folder for now.

Binary file modified bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions example/.docusaurus/DONT-EDIT-THIS-FOLDER
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This folder stores temp files that Docusaurus' client bundler accesses.

DO NOT hand-modify files in this folder because they will be overwritten in the
next build. You can clear all build artifacts (including this folder) with the
`docusaurus clear` command.
6 changes: 6 additions & 0 deletions example/.docusaurus/client-modules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default [
require("/Users/sakunpanthi/Desktop/table/example/node_modules/infima/dist/css/default/default.css"),
require("/Users/sakunpanthi/Desktop/table/example/node_modules/@docusaurus/theme-classic/lib/prism-include-languages"),
require("/Users/sakunpanthi/Desktop/table/example/node_modules/@docusaurus/theme-classic/lib/nprogress"),
require("/Users/sakunpanthi/Desktop/table/example/src/css/custom.css"),
];
1 change: 1 addition & 0 deletions example/.docusaurus/codeTranslations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "docusaurus-plugin-content-blog",
"id": "default"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Recent posts",
"items": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"blogBasePath": "/blog",
"blogTitle": "Blog",
"authorsListPath": "/blog/authors"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "docusaurus-plugin-content-docs",
"id": "default"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"tutorialSidebar":[{"type":"link","label":"Tutorial","href":"/docs/intro","docId":"intro","unlisted":false},{"type":"category","label":"examples","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"normal-table","href":"/docs/examples/normal-table","docId":"examples/normal-table","unlisted":false}]}]},"docs":{"examples/normal-table":{"id":"examples/normal-table","title":"normal-table","description":"This is a example table","sidebar":"tutorialSidebar"},"intro":{"id":"intro","title":"Tutorial","description":"Let's discover Bright Table in less than 10 minutes.","sidebar":"tutorialSidebar"}}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"id": "examples/normal-table",
"title": "normal-table",
"description": "This is a example table",
"source": "@site/docs/examples/normal-table.mdx",
"sourceDirName": "examples",
"slug": "/examples/normal-table",
"permalink": "/docs/examples/normal-table",
"draft": false,
"unlisted": false,
"editUrl": "https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/examples/normal-table.mdx",
"tags": [],
"version": "current",
"frontMatter": {},
"sidebar": "tutorialSidebar",
"previous": {
"title": "Tutorial",
"permalink": "/docs/intro"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "intro",
"title": "Tutorial",
"description": "Let's discover Bright Table in less than 10 minutes.",
"source": "@site/docs/intro.md",
"sourceDirName": ".",
"slug": "/intro",
"permalink": "/docs/intro",
"draft": false,
"unlisted": false,
"editUrl": "https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/intro.md",
"tags": [],
"version": "current",
"sidebarPosition": 1,
"frontMatter": {
"sidebar_position": 1
},
"sidebar": "tutorialSidebar",
"next": {
"title": "normal-table",
"permalink": "/docs/examples/normal-table"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "docusaurus-plugin-content-pages",
"id": "default"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "mdx",
"permalink": "/markdown-page",
"source": "@site/src/pages/markdown-page.md",
"title": "Markdown page example",
"description": "You don't need React to write simple standalone pages.",
"frontMatter": {
"title": "Markdown page example"
},
"unlisted": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "docusaurus-plugin-debug",
"id": "default"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"allContent":{"docusaurus-plugin-content-docs":{"default":{"loadedVersions":[{"versionName":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","path":"/docs","tagsPath":"/docs/tags","editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs","editUrlLocalized":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/i18n/en/docusaurus-plugin-content-docs/current","isLast":true,"routePriority":-1,"sidebarFilePath":"/Users/sakunpanthi/Desktop/table/example/sidebars.ts","contentPath":"/Users/sakunpanthi/Desktop/table/example/docs","contentPathLocalized":"/Users/sakunpanthi/Desktop/table/example/i18n/en/docusaurus-plugin-content-docs/current","docs":[{"id":"examples/normal-table","title":"normal-table","description":"This is a example table","source":"@site/docs/examples/normal-table.mdx","sourceDirName":"examples","slug":"/examples/normal-table","permalink":"/docs/examples/normal-table","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/examples/normal-table.mdx","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Tutorial","permalink":"/docs/intro"}},{"id":"intro","title":"Tutorial","description":"Let's discover Bright Table in less than 10 minutes.","source":"@site/docs/intro.md","sourceDirName":".","slug":"/intro","permalink":"/docs/intro","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/intro.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"sidebar_position":1},"sidebar":"tutorialSidebar","next":{"title":"normal-table","permalink":"/docs/examples/normal-table"}}],"drafts":[],"sidebars":{"tutorialSidebar":[{"type":"doc","id":"intro"},{"type":"category","label":"examples","collapsible":true,"collapsed":true,"items":[{"type":"doc","id":"examples/normal-table"}]}]}}]}},"docusaurus-plugin-content-blog":{"default":{"blogSidebarTitle":"Recent posts","blogPosts":[],"blogListPaginated":[],"blogTags":{},"blogTagsListPath":"/blog/tags"}},"docusaurus-plugin-content-pages":{"default":null},"docusaurus-plugin-debug":{},"docusaurus-plugin-svgr":{},"docusaurus-theme-classic":{},"docusaurus-bootstrap-plugin":{},"docusaurus-mdx-fallback-plugin":{}}}
Loading