├── lib
├── src
│ ├── utilities
│ │ ├── index.ts
│ │ ├── clsx.ts
│ │ ├── useReachUI.ts
│ │ ├── useStylesheet.ts
│ │ ├── deepMerge.ts
│ │ ├── styled.ts
│ │ ├── theme.ts
│ │ ├── systemColumns.ts
│ │ └── generateStatus.ts
│ ├── index.ts
│ ├── context.ts
│ ├── typings.d.ts
│ ├── types
│ │ ├── TableOptions.ts
│ │ ├── DataType.ts
│ │ ├── OtherOptions.ts
│ │ ├── index.ts
│ │ ├── RowStateOptions.ts
│ │ ├── RowSelectOptions.ts
│ │ ├── LocaleOptions.ts
│ │ ├── ExpandedOptions.ts
│ │ ├── ActionOptions.ts
│ │ ├── StyleOptions.ts
│ │ ├── ColumnOptions.ts
│ │ ├── GlobalFilterOptions.ts
│ │ ├── FiltersOptions.ts
│ │ ├── ReactTable.ts
│ │ ├── PaginationOptions.ts
│ │ ├── SortingOptions.ts
│ │ └── ReactTableUIProps.ts
│ ├── styles
│ │ ├── index.ts
│ │ ├── StatusBarStyle.ts
│ │ ├── menuStyle.ts
│ │ ├── commonStyle.ts
│ │ ├── containerStyle.ts
│ │ ├── TitleBarStyle.ts
│ │ └── TableStyle.ts
│ ├── logic
│ │ ├── useCreateDefaultColumns.ts
│ │ ├── useManualPagination.ts
│ │ ├── useScrollPosition.ts
│ │ ├── generateUseExpandedColumn.tsx
│ │ ├── useModal.tsx
│ │ ├── generateUseRowActionColumn.tsx
│ │ ├── generateUseRowSelectColumn.tsx
│ │ ├── useFullscreenAction.tsx
│ │ ├── useTheme.ts
│ │ ├── useVisibleFilters.tsx
│ │ ├── useHandleStateChange.ts
│ │ └── useReactTableUI.tsx
│ ├── common
│ │ ├── Cell.tsx
│ │ ├── Button.tsx
│ │ ├── Icon.tsx
│ │ └── FocusTrap.tsx
│ ├── components
│ │ ├── TitleBar
│ │ │ ├── index.tsx
│ │ │ ├── VisibleFilterAction.tsx
│ │ │ ├── userDefinedActions.tsx
│ │ │ ├── PreferencesAction.tsx
│ │ │ └── GlobalFilter.tsx
│ │ ├── Modal.tsx
│ │ ├── ReactTableUI.tsx
│ │ ├── Foot.tsx
│ │ ├── Table.tsx
│ │ ├── Body.tsx
│ │ ├── StatusBar.tsx
│ │ ├── Filters.tsx
│ │ └── Head.tsx
│ └── react-table-config.d.ts
├── tsconfig.json
├── scripts
│ ├── build.js
│ ├── postInstall.js
│ └── publish.js
├── package.json
└── README.md
├── example
├── src
│ ├── vite-env.d.ts
│ ├── routes
│ │ ├── _router.tsx
│ │ ├── Basic.tsx
│ │ └── Pagination.tsx
│ ├── index.tsx
│ ├── index.css
│ ├── App.tsx
│ └── react-table-config.d.ts
├── vite.config.ts
├── tsconfig.node.json
├── .gitignore
├── index.html
├── package.json
└── tsconfig.json
├── .vscode
└── settings.json
├── assets
├── Logo.png
├── RTUI.jpg
└── hero.png
├── .prettierrc
├── .gitignore
├── README.md
├── typedoc.json
├── tsconfig.json
├── .eslintrc
├── LICENSE
├── .github
└── workflows
│ └── publish.yml
└── package.json
/lib/src/utilities/index.ts:
--------------------------------------------------------------------------------
1 | export const NOOP = () => {}
2 |
--------------------------------------------------------------------------------
/example/src/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "cSpell.words": [
3 | "rtui"
4 | ]
5 | }
--------------------------------------------------------------------------------
/assets/Logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuptaSiddhant/react-table-ui/HEAD/assets/Logo.png
--------------------------------------------------------------------------------
/assets/RTUI.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuptaSiddhant/react-table-ui/HEAD/assets/RTUI.jpg
--------------------------------------------------------------------------------
/assets/hero.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuptaSiddhant/react-table-ui/HEAD/assets/hero.png
--------------------------------------------------------------------------------
/example/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import react from '@vitejs/plugin-react'
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | plugins: [react()]
7 | })
8 |
--------------------------------------------------------------------------------
/lib/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "dist"
5 | },
6 | "include": ["src"],
7 | "exclude": ["node_modules", "dist", "docs", "example"]
8 | }
9 |
--------------------------------------------------------------------------------
/example/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "module": "ESNext",
5 | "moduleResolution": "Node",
6 | "allowSyntheticDefaultImports": true
7 | },
8 | "include": ["vite.config.ts"]
9 | }
10 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "jsxSingleQuote": true,
4 | "semi": false,
5 | "tabWidth": 2,
6 | "bracketSpacing": true,
7 | "jsxBracketSameLine": false,
8 | "arrowParens": "always",
9 | "trailingComma": "none"
10 | }
11 |
--------------------------------------------------------------------------------
/lib/src/index.ts:
--------------------------------------------------------------------------------
1 | // Import components
2 | import ReactTableUI from './components/ReactTableUI'
3 |
4 | // -----------------
5 |
6 | // Export components
7 |
8 | export default ReactTableUI
9 |
10 | // Export types
11 | export * from './types'
12 |
13 | // -----------------
14 |
--------------------------------------------------------------------------------
/example/src/routes/_router.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 |
3 | const Basic = React.lazy(() => import('./Basic'))
4 | const Pagination = React.lazy(() => import('./Pagination'))
5 |
6 | const router = {
7 | Basic: ,
8 | Pagination:
9 | }
10 |
11 | export default router
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | node_modules
5 |
6 | # builds
7 | build
8 | dist
9 | .rpt2_cache
10 | docs/.generated-docs
11 | docs
12 |
13 | # misc
14 | .DS_Store
15 | .env
16 | .env.*
17 |
18 | npm-debug.log*
19 | yarn-debug.log*
20 | yarn-error.log*
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React-Table UI Monorepo
2 |
3 | [](https://www.npmjs.com/package/react-table-ui)
4 | [](https://github.com/GuptaSiddhant/react-table-ui)
5 |
6 | Out-of-the-box UI for [React-Table 7](https://react-table-v7.tanstack.com).
7 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/example/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom/client'
3 | import { BrowserRouter } from 'react-router-dom'
4 |
5 | import App from './App'
6 | import './index.css'
7 |
8 | ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
9 |
10 |
11 |
12 |
13 |
14 | )
15 |
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Vite + React + TS
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://typedoc.org/schema.json",
3 | "name": "React-Table UI Docs",
4 | "includeVersion": false,
5 | "excludeExternals": false,
6 | "excludeInternal": true,
7 | "categoryOrder": ["Important", "Component", "Options", "State", "*"],
8 | "includes": "./lib",
9 |
10 | "entryPoints": ["./lib/src/index.ts"],
11 | "readme": "./lib/README.md",
12 | "skipErrorChecking": true
13 | }
14 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "esnext",
4 | "lib": ["dom", "esnext"],
5 | "moduleResolution": "node",
6 | "jsx": "react",
7 | "strict": true,
8 | "sourceMap": true,
9 | "declaration": true,
10 | "esModuleInterop": true,
11 | "allowSyntheticDefaultImports": true,
12 | "emitDeclarationOnly": true
13 | },
14 | "exclude": ["node_modules", "dist", "docs", "examples/*"]
15 | }
16 |
--------------------------------------------------------------------------------
/lib/src/context.ts:
--------------------------------------------------------------------------------
1 | import * as React from 'react'
2 | import type { DataType, TableContext } from './types'
3 |
4 | export const tableContext = React.createContext | undefined>(
5 | undefined
6 | )
7 |
8 | export default function useTableContext<
9 | Data extends DataType
10 | >(): TableContext {
11 | const ctx = React.useContext(tableContext)
12 | if (!ctx)
13 | throw new Error(
14 | 'useTableContext cannot be used outside ReactTableUI component.'
15 | )
16 |
17 | return ctx
18 | }
19 |
--------------------------------------------------------------------------------
/lib/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Default CSS definition for typescript,
3 | * will be overridden with file-specific definitions by rollup
4 | */
5 | declare module '*.css' {
6 | const content: { [className: string]: string }
7 | export default content
8 | }
9 |
10 | interface SvgrComponent
11 | extends React.FunctionComponent> {}
12 |
13 | declare module '*.svg' {
14 | const svgUrl: string
15 | const svgComponent: SvgrComponent
16 | export default svgUrl
17 | export { svgComponent as ReactComponent }
18 | }
19 |
--------------------------------------------------------------------------------
/lib/src/types/TableOptions.ts:
--------------------------------------------------------------------------------
1 | import type { UseTableOptions, TableState } from './ReactTable'
2 |
3 | import type { DataType, StateChangeHandler } from './DataType'
4 |
5 | /** Type interface of Table specific options.
6 | * @category Options */
7 | export interface TableOptions
8 | extends Omit, 'columns' | 'data'> {
9 | /** Callback executed when table's state is updated.
10 | * The function must be wrapped in useCallback hook. */
11 | onStateChange?: StateChangeHandler>
12 | }
13 |
14 | export default TableOptions
15 |
--------------------------------------------------------------------------------
/lib/src/styles/index.ts:
--------------------------------------------------------------------------------
1 | import styled from '../utilities/styled'
2 |
3 | import { ButtonStyle } from '../common/Button'
4 | import { CellStyle } from '../common/Cell'
5 |
6 | import commonStyle from './commonStyle'
7 | import containerStyle from './containerStyle'
8 | import TableStyle from './TableStyle'
9 | import TitleBarStyle from './TitleBarStyle'
10 | import menuStyle from './menuStyle'
11 |
12 | const styles = styled.rtui`
13 | ${containerStyle}
14 | ${commonStyle}
15 | ${menuStyle}
16 | ${ButtonStyle}
17 | ${TitleBarStyle}
18 | ${TableStyle}
19 | ${CellStyle}
20 | `
21 |
22 | export default styles
23 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-table-ui-example",
3 | "private": true,
4 | "version": "0.0.0",
5 | "type": "module",
6 | "scripts": {
7 | "dev": "vite",
8 | "build": "tsc && vite build",
9 | "preview": "vite preview"
10 | },
11 | "dependencies": {
12 | "namor": "^2.0.4",
13 | "react": "*",
14 | "react-dom": "*",
15 | "react-router-dom": "^6.3.0",
16 | "react-table-ui": "*"
17 | },
18 | "devDependencies": {
19 | "@types/react": "*",
20 | "@types/react-dom": "*",
21 | "@vitejs/plugin-react": "^2.1.0",
22 | "typescript": "*",
23 | "vite": "^3.1.0"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/example/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "useDefineForClassFields": true,
5 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
6 | "allowJs": false,
7 | "skipLibCheck": true,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true,
17 | "jsx": "react-jsx"
18 | },
19 | "include": ["src"],
20 | "references": [{ "path": "./tsconfig.node.json" }]
21 | }
22 |
--------------------------------------------------------------------------------
/lib/src/types/DataType.ts:
--------------------------------------------------------------------------------
1 | import type { ReactNode } from 'react'
2 |
3 | export interface DataType extends Record {
4 | /** Select data-row by default. */
5 | isSelected?: boolean
6 |
7 | /** Always expanded data-row, regardless of state. */
8 | expanded?: boolean
9 |
10 | /** Sub rows visible when expanded. */
11 | subRows?: DataType[]
12 |
13 | /** Custom component shown when row is expanded.
14 | * @category Custom Component */
15 | subComponent?: ReactNode
16 | }
17 |
18 | /** Type for Callback to handle state changes. */
19 | export type StateChangeHandler = (state: State) => void
20 |
21 | export default DataType
22 |
--------------------------------------------------------------------------------
/lib/src/utilities/clsx.ts:
--------------------------------------------------------------------------------
1 | export const commonClassName = 'RTUI'
2 |
3 | type FalsyValue = undefined | null | false | 0 | ''
4 | type ClassName = string | FalsyValue | ClassName[] | Record
5 |
6 | export default function clsx(...classNames: ClassName[]): string {
7 | return classNames
8 | .map((name) => {
9 | if (!name) return null
10 | if (typeof name !== 'object') return name
11 | if (Array.isArray(name)) return clsx(name)
12 | return Object.entries(name)
13 | .filter(([, v]) => Boolean(v))
14 | .map(([k]) => k)
15 | .join(' ')
16 | })
17 | .filter(Boolean)
18 | .join(' ')
19 | }
20 |
--------------------------------------------------------------------------------
/lib/src/logic/useCreateDefaultColumns.ts:
--------------------------------------------------------------------------------
1 | import { useMemo } from 'react'
2 | import type { DataType, Column } from '../types'
3 |
4 | const toTitleCase = (str: string) =>
5 | str.slice(0, 1).toUpperCase() + str.slice(1)
6 |
7 | const useCreateDefaultColumns = (
8 | data: Data[]
9 | ): Column[] =>
10 | useMemo(() => {
11 | const uniqueKeys = Object.keys(Object.assign({}, ...data))
12 | return uniqueKeys
13 | .filter((key) => !['subRows', 'subComponent'].includes(key))
14 | .map((key) => ({
15 | accessor: key,
16 | Header: toTitleCase(key)
17 | }))
18 | }, [data])
19 |
20 | export default useCreateDefaultColumns
21 |
--------------------------------------------------------------------------------
/lib/src/common/Cell.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react'
2 | import { color, spacing } from '../utilities/theme'
3 | import clsx from '../utilities/clsx'
4 | import styled from '../utilities/styled'
5 |
6 | export const CellStyle = styled('td')`
7 | &,
8 | .th {
9 | padding: ${spacing.sm} ${spacing.md};
10 | background: ${color.background.primary};
11 | overflow: hidden;
12 | }
13 | `
14 |
15 | const Cell = React.forwardRef<
16 | HTMLDivElement,
17 | React.HTMLAttributes
18 | >(({ className, ...props }, ref) => {
19 | return (
20 |
26 | )
27 | })
28 |
29 | export default Cell
30 |
--------------------------------------------------------------------------------
/lib/src/utilities/useReachUI.ts:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react'
2 |
3 | const useReachUI = (type: 'menu') => {
4 | const [reach, setReach] = useState