New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

blb-table

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blb-table

An empty base template for publishing a React TS package to npmjs library.

1.0.6
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

BlackLightBurn Table

BlackLightBurn table component

Installation

npm install --save blb-table

Import styles and use react-query

Import styles in app.js and use QueryClientProvider.

import  'blb-table/dist/variables.css';
import  'bootstrap/dist/css/bootstrap.min.css';

import { QueryClient, QueryClientProvider } from 'react-query';
const queryClient = new QueryClient();

export default function App({ Component, pageProps }: any) {
	return (
		<QueryClientProvider client={queryClient}>
			<Component {...pageProps} />
		</QueryClientProvider>
	);
}

Usage

import { Table } from 'blb-table';
import { useQuery } from 'react-query';
import { influencersQuery } from  '@/queries/influencersQuery';

interface QueryParams {
	limit: number;
	filter?: {
		[key: string]: string | number | Array<number | null> | boolean;
	};
	search?: string;
	skip: number;
	sort: {
		id: string;
		desc: boolean;
	}[];
}

export  default  function  Home() {
	const [queryParams, setQueryParams] = useState<QueryParams>({
		limit: 10,
	});

	const { data, isFetching } = useQuery(influencersQuery(queryParams));

	const columns: = [
		{
			accessorKey: 'title',
			header: () => <span>Influencer</span>,
			cell: (info) => info.getValue(),
			enableSorting: false,
		}
	];

	return (
		<Table
			data={data}
			columns={columns}
			isLoading={isFetching}
			onChange={setQueryParams}
			limit={queryParams.limit}
		/>
	)
}

API

  • data: { data: Array<object>; count: number; }

    Count is a total count of elements

  • isLoading: boolean
  • onChange: Dispatch<SetStateAction<QueryParams>>
  • limit: number

    Limit for pagination page size and for number of elements to display

  • columns: any[]
  • search?: string
  • components?: { components API }

    For your custom components

Components API

  • Pagination?: (props: { pageCount: number; pageIndex: number; setPageIndex: ({ selected }: { selected: number }) => void; }) => React.ReactElement;

    pageCount - total page count pageIndex - current index of page setPageIndex - function for set the page number

  • EmptyData?: (props: { isLoading: boolean; isEmpty: boolean }) => React.ReactElement;
  • Search?: (props: { resetPagination: () => void; openFilters: () => void; }) => React.ReactElement;

    resetPagination - for reset pagination on first page openFilter - open/close filters

  • Filters?: (props: { resetPagination: () => void }) => React.ReactElement;

Contributing

This project is open for improvements and maintenance. Feel free to fork and make your own modifications.

License

MIT

Keywords

react

FAQs

Package last updated on 04 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts