frontend/.pnpm-store/v3/files/ac/d7c320fdb1f5f9ae28c61c8c098f4e5e34e8c06989515ef2529227439537561aac454b143ba3a53d72244479ecf5d33d9bffe1386f8a0a21c4b4554fdc6c25

100 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div align="center">
<img align="center" src="./static/logo.svg" alt="logo" width="172"/>
<p align="center">
<h1 align="center" style="font-size:32px;margin:0;border:none;">svelte simple datatables</h1>
<p style="color:#eee">A toolkit for creating datatable components with Svelte</p>
<img src="https://img.shields.io/npm/v/@vincjo/datatables?color=%23b71540" alt="npm version"/>
<img src="https://img.shields.io/github/license/vincjo/datatables?color=b71540" alt="last commit"/>
</p>
</div>
# Presentation
This package provides an API to handle data and related events : rows, filters, pagination, search, sort...
- **Headless** by design <br>
- **Typescript** support <br>
- **SSR** compatibility
Also provides some sample components, which you can grab and customize in your own project.
<br>
:globe_with_meridians: **[Live examples](https://vincjo.fr/datatables/examples)**
<br>
# Install
````apache
npm i -D @vincjo/datatables
````
# Sample code
````svelte
<script lang="ts">
import { DataHandler } from '@vincjo/datatables'
import { someData } from './data'
const handler = new DataHandler(someData, { rowsPerPage: 50 })
const rows = handler.getRows()
</script>
<table>
<thead>
<tr>
<th>First name</th>
<th>Last name</th>
</tr>
</thead>
<tbody>
{#each $rows as row}
<tr>
<td>{row.first_name}</td>
<td>{row.last_name}</td>
</tr>
{/each}
</tbody>
</table>
````
### :globe_with_meridians: [See full documentation](https://vincjo.fr/datatables)
<br>
# DataHandler methods
````ts
getRows(): Readable<any[]>
setRows( data: any[] ): void
````
````ts
sort( orderBy: Function | string ): void
sortAsc( orderBy: Function | string ): void
sortDesc( orderBy: Function | string ): void
getSorted(): Writable<{ identifier?: string; direction?: 'asc' | 'desc'; }>
````
````ts
filter( value: string, filterBy: Function | string ): void
````
````ts
search( value: string, scope?: string[] ): void
clearSearch(): void
````
````ts
getRowsPerPage(): Writable<number | null>
````
````ts
getRowCount(): Readable<{ total: number; start: number; end: number; }>
````
````ts
getPages( param: { ellipsis: boolean } ): Readable<number[]>
getPageCount(): Readable<number>
getPageNumber(): Readable<number>
setPage( value: number | previous | next ): void
````
````ts
getTriggerChange(): Writable<number>
````