npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@radar-azdelta/svelte-datatable

v0.0.80

Published

Why yet another datatable component? During the development of [Keun](https://github.com/RADar-AZDelta/Keun), we needed a datatable component that could handle CSV's with more than 100.000 rows. We didn't find anything that suited our needs, so we develop

Downloads

563

Readme

@radar-azdelta/svelte-datatable

Why yet another datatable component? During the development of Keun, we needed a datatable component that could handle CSV's with more than 100.000 rows. We didn't find anything that suited our needs, so we developed our own.

Features

  • Supports multiple data sources: array of object, matrix of values, Function (remote data source) and File (CSV datasource)
  • Sorting (multi column)
  • Filtering (multi column)
  • Reposition columns
  • Resize columns
  • Store column settings in localStorage
  • Show/hide columns
  • Fast for very large CSV files (more than 100.000 rows)
  • Uses Arquero in a web worker for File (CSV) data source

Usage

install the package

pnpm install @radar-azdelta/svelte-datatable

add the component to a svelte page

<script lang="ts">
  import DataTable from '@radar-azdelta/svelte-datatable'

  const data = [
    {
      name: 'Rory',
      age: 35,
      country: 'Belgium',
      telephone: '0800-123-524-634',
      address: 'Rue des Taillis 221,Gijzelbrechtegem,West Flanders,8570,',
    },
    {
      name: 'Amethyst',
      age: 35,
      country: 'Belgium',
      telephone: '0800-123-524-634',
      address: 'Eikstraat 450,Belgrade,Namur,5001,',
    },
  ]
</script>

<DataTable {data} />

Also add the folowing config to your vite.config.ts, otherwise @radar-azdelta/svelte-datatable worker can't be downloaded.

export default defineConfig({
  ...
  optimizeDeps: {
    exclude: ['@radar-azdelta/svelte-datatable'],
  }
  ...
})

Example

see demo site

Manual

Properties

The DataTable component accepts 3 properties: options, columns, and data.

<DataTable {options} {columns} {data} />

Options property

global options for the DataTable

interface ITableOptions {
  id?: string
  currentPage?: number
  rowsPerPage?: number
  rowsPerPageOptions?: number[]
  actionColumn?: boolean
}

| Value | Description | Required | Default | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | -------------------- | | id | identifier for the datatable, so that it settings can be stored in localStorage | no | | | currentPage | the current page to display | no | 1 | | rowsPerPage | number of rows visible in a page | no | 20 | | rowsPerPageOptions | number of rows visible in a page | no | [5, 10, 20, 50, 100] | | actionColumn | Adds an action column as first column. This can be used to add aditional functionality, for example 'selecting multiple columns', or 'add custom action buttoms', etc... | no | false |

Columns property

The columns can be extracted from the data property (except when the data is a matrix). But you can also manually define the columns.

interface IColumnMetaData {
  id: string
  label?: string
  visible?: boolean
  sortable?: boolean
  filterable?: boolean
  resizable?: boolean
  repositionable?: boolean
  sortDirection?: SortDirection
  sortOrder?: number
  filter?: any
  position?: number
  width?: number
}

| Value | Description | Required | Default | | ------------------ | --------------------------------------------------------------------------- | -------- | ------- | | id | id or name of the column | yes | | | label | id or name of the column | no | | | visible | is the column visible | no | yes | | sortable | is the column sortable | no | yes | | filterable | is the column filterable | no | yes | | resizable | FUTURE FUNCTIONALITY: can the column width be adjusted | no | yes | | repositionable | can the column be repositioned | no | yes | | sortDirection | do not sort (undefined), sort the column 'asc' or 'desc' | no | | | sortOrder | if multiple columns are sorted, this prop defines the sequence of the order | no | | | filter | filter the column values | no | | | position | the visual position (sequence) of the column | no | | | width | FUTURE FUNCTIONALITY: the width of the column | no | |

Data property

  • Array of Objects
const data = [
  {
    name: 'Rory',
    age: 35,
    country: 'Belgium',
    telephone: '0800-123-524-634',
    address: 'Rue des Taillis 221,Gijzelbrechtegem,West Flanders,8570,',
  },
  {
    name: 'Amethyst',
    age: 35,
    country: 'Belgium',
    telephone: '0800-123-524-634',
    address: 'Eikstraat 450,Belgrade,Namur,5001,',
  },
]
  • Matrix (requires the columns property)
const data = [
  ['Rory', 35, 'Belgium', '0800-123-524-634', 'Rue des Taillis 221,Gijzelbrechtegem,West Flanders,8570,'],
  ['Amethyst', 35, 'Belgium', '0800-123-524-634', 'Eikstraat 450,Belgrade,Namur,5001,'],
]
  • Function (fetch from webservice)
async function fetchData(
  filteredColumns: Map<string, TFilter>,
  sortedColumns: Map<string, SortDirection>,
  pagination: IPagination
): Promise<{ totalRows: number; data: any[][] | any[] }> {
  const response = await fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ filteredColumns: [...filteredColumns], sortedColumns: [...sortedColumns], pagination }),
  })
  const result = response.json()
  return { totalRows: result.totalRows, data: result.data }
}
  • File (CSV)
const response = await fetch('https://raw.githubusercontent.com/RADar-AZDelta/AZDelta-OMOP-CDM/main/drug_exposure/drug_concept_id/medicatie_usagi.csv')
const blob = await response.blob()
const metadata = {
  type: 'text/csv',
}
const data = new File([data], 'medicatie_usagi.csv', metadata)

Setup for development

Run these commands to get started:

git clone [email protected]:RADar-AZDelta/svelte-datatable.git
cd svelte-datatable
pnpm install

To run the example app, run pnpm run dev --open from the project root.

Reorder Column

reorderColumn

Resize Column

ResizeColumn

Visible Columns

VisibleColumns

Edit cell

Als EditableCell is toegevoegd in het Datatable component dan kan u doubel klikken op de tekst om die aan te passen.
escape key kan gebruikt worden om uit de input te gaan zonder aanpassing op te slaan.
enter key kan gebruikt worden of check button om de aanpassing op te slaan.

EditCell