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

@anomalyce/data-table

v1.0.0-alpha.5

Published

Vue 3 based data-table component.

Downloads

8

Readme

Data-Table

A Vue 3 component based on the Composition API for easily presenting data in a table-esque manner.

npm install @anomalyce/data-table

Feature Support

  • [x] Dynamic headings
  • [x] Custom column appearance
  • [ ] Sorting
  • [ ] Filtering
  • [ ] Pagination

Usage

The data-table component consists of the main component, <data-table.table /> and two sub-components;

  • <data-table.heading />
  • <data-table.item />

The heading and item components must be immediate children of the data-table component itself. The number of heading components dictate the amount of columns your table will end up with, and their names dictate the respective slot names of all the item components. Below is an example of how to use the component, any component options can be found further down.

<script setup>
  import { ref } from 'vue'
  import DataTable from '@anomalyce/data-table'

  const data = ref([
    {
      city: 'Gothenburg',
      country: 'Sweden',
    },
    {
      city: 'London',
      country: 'England',
    },
    {
      city: 'Turin',
      country: 'Italy',
    },
  ])
</script>

<template>
  <h1>Example Data-Table</h1>

  <data-table.table>
    <data-table.heading name="city">
      <strong>City</strong>
    </data-table.heading>

    <data-table.heading name="country">
      Country
    </data-table.heading>

    <data-table.item v-for="(item, index) in data" :key="index">
      <template #city>
        <span style="color: blue;">
          {{ item.city }}
        </span>
      </template>

      <template #default="{ column }">
        <span v-if="item[column]">
          {{ item[column] }}
        </span>

        <span v-else>
          &mdash;
        </span>
      </template>
    </data-table.item>
  </data-table.table>
</template>

Configuration

Table Component

CSS

The <data-table.table /> component has a base class of data-table.

Parameters

Property|Type|Required|Default Value|Description :----|:----|:----|:----|:---- css|boolean|false|true|Whether to add a very limited amount of CSS for the grid layout or not.

Heading Component

CSS

The <data-table.heading /> component has a base class of data-table-heading. All headings get wrapped inside of a container with the data-table-row & data-table-headings classes.

Parameters

Property|Type|Required|Default Value|Description :----|:----|:----|:----|:---- name|string|true||The name of the column, used for customising the apperance of an item column

Item Component

CSS

The <data-table.item /> component has a base class of data-table-column and receives the data-table-column--default class whenever no custom slot has been declared for it. All item components get wrapped in a row container with the data-table-row class.

HTML Attributes

In addition to the classes, the [data-table-column="<name>"] attribute is added with the name of the relevant column heading.

Column Appearance

If you would like to customise the appearance of a specific column, you may create a custom vue template slot for it, based on the column heading name.

<data-table.item>
  <template #country>
    <a :href="`https://wikipedia.org/${item.country}`" target="_blank" rel="noopener noreferrer">
      {{ item.country }}
    </a>
  </template>

  <template #default="{ column }">
    {{ item[column] }}
  </template>
</data-table.item>