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

vye-teible

v0.1.29

Published

Table component for Vue.js

Downloads

7

Readme

Vue Teible

Introduction

Teible is yet another table component. I know we have enough of them but it is something else.

Features

  • Column definition using template
  • Filtering, ordering and pagination
  • Synchronous and asynchronous data (Promise)
  • Customizable headers & cells using slot and formatter
  • Customizable styling & attributes
  • Dot-notation support for column fields

Teible is heavily inspired by vue-table-component. The way columns are defined totally got me at the first sight. But it's deprecated in favor of the "traditional" way, no longer in maintenance and has a lot of fancy features you may never need: data type, date format, caching, etc. So if you're looking for a simple but flexible component, take a look at the below example, you may fall in love with teible.

Demo

See https://hiendv.github.io/teible/ or the fiddle

Installation & Usage

CDN

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vue-teible@latest/dist/vueteible.css" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/vue-teible@latest/dist/vueteible.iife.js" crossorigin="anonymous"></script>

Note: We recommend linking to a specific version number that you can update manually

Vue.component('data-table', vueteible.DataTable)
Vue.component('data-column', vueteible.DataColumn)

NPM

npm install --save vue-teible
# yarn add vue-teible
<script>
import Vue from 'vue'
import { DataTable, DataColumn } from 'vue-teible'

new Vue({
  el: '#app',
  components: { DataTable, DataColumn },
  data: {
    items: [{
      id: 'id-1',
      name: 'foo'
    }, {
      id: 'id-2',
      name: 'bar'
    }, {
      id: 'id-3',
      name: 'qux'
    }]
  },
  methods: {
    destroy (x) {
      this.items = this.items.filter(item => item.id !== x.id)
    }
  }
})
</script>

// write your table
<template>
  <data-table :items="items">
    <data-column field="id" label="ID"/>
    <data-column field="name" label="Name" width="50%"/>
    <data-column label="Action" :sortable="false">
      <template slot-scope="props">
        <button @click.prevent="destroy(props.item)">Delete</button>
      </template>
    </data-column>
  </data-table>
</template>

If you're looking for a more complicated use-case, see vue-teible-example.

Documentation

DataTable

Props

{
  items: { // Array of objects or Function (filtering, sorting, paging)
    type: [Array, Function],
    required: true
  },
  page: { // Two-way binding with .sync
    type: Number,
    default: 1
  },
  perPage: {
    type: Number,
    default: 10
  },
  sortBy: { // Two-way binding with .sync
    type: String,
    default: ''
  },
  sortDesc: { // Two-way binding with .sync
    type: Boolean,
    default: false
  },
  filter: { // Two-way binding with .sync
    type: String,
    default: ''
  },
  theme: {
    type: Object,
    default: themeDefault
  },
  disableFiltering: {
    type: Boolean,
    default: false
  },
  disableLoader: {
    type: Boolean,
    default: false
  },
  pagination: { // Positions of paginations (top, bottom)
    type: Array,
    default () {
      return ['top']
    }
  },
  paginationSide: { // The number of pages for each side of paginations
    type: Number,
    default: 2
  },
  rowClick: { // Callback for row click events
    type: Function,
    default: (event, item, index) => {}
  },
  rowHover: { // Callback for row hover events
    type: Function,
    default: (event, item, index) => {} // event.type could be "mouseenter" or "mouseleave"
  }
}

Methods

  • loadSlots (): reload columns manually
  • loadClass (): reload class name manually
  • loadItems (): reload data manually
  • reloadItems (): set current page to 1 and loadItems

Events

  • loaded (items): fired when items are loaded

DataColumn

Props

{
  label: {
    type: String,
    required: true
  },
  field: {
    type: String,
    default: ''
  },
  sortable: {
    type: Boolean,
    default: true
  },
  filterable: {
    type: Boolean,
    default: true
  },
  render: { // Function (value, item). Format the column with the original value reserved at $_[field]
    type: Function
  }
}

Loader

You can custom the loader with slot loader

<template>
  <data-table :items="items">
    <div slot="loader">
      Loading...
    </div>
    <data-column field="id" label="ID"/>
    <data-column field="name" label="Name" width="50%"/>
  </data-table>
</template>

Localization

Teible could be integrated perfectly with vue-i18n. It comes with English by default but you can localize it easily.

const messages = {
  en: {
    teible: {
      showing: 'Showing',
      total: 'of {count} records',
      last: 'the last record',
      empty: 'No records',
      filter: 'Filter records'
    }
  },
  vi: {
    teible: {
      showing: 'Hiển thị',
      total: 'trên tổng số {count} bản ghi',
      last: 'bản ghi cuối cùng',
      empty: 'Không có dữ liệu',
      filter: 'Lọc các bản ghi'
    }
  }
}

const i18n = new VueI18n({
  locale: 'vi',
  messages
})

Development & Testing

Please check the Contributing Guidelines.

Contribution

Issues and PRs are welcome !