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

lkt-table

v1.3.19

Published

![ts](https://img.shields.io/badge/Typescript-3178c6?style=for-the-badge) ![js](https://img.shields.io/badge/Javascript-f68333?style=for-the-badge) ![vue](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Flekrat%2Flkt

Downloads

331

Readme

LKT Table

ts js vue node

Vue component (Vue.js 3.0) allowing a simple yet powerful table component.

Features

  • Custom slots per column
  • Hide columns by config
  • Automatically hide empty columns
  • Full support of Sortable.js features:
    • Supports touch devices
    • Supports drag handles and selectable text
    • Smart auto-scrolling
    • No jQuery dependency
  • Keeps in sync HTML and view model list

Installation

With npm

npm i -S lkt-table

Typical use:

In your main.js

import LktTable from 'lkt-table';
  
app.use(LktTable);

In your component:

<lkt-table v-model="myArray" v-bind:columns="columns"></lkt-table>
import {createColumn} from 'lkt-table';


export default {
    data() {
        return {
            columns: [
                createColumn({key: 'name', label: 'Name'}),
                createColumn({key: 'surname', label: 'Surname', sortable: false}),
            ],
            items: [
                {name: 'a', surname: 'n'},
                {name: 'b', surname: 'n1'},
            ]
        }
    }
}

With custom column slots:

<lkt-table v-model:value="myArray" v-bind:columns="columns">
    <template v-slot:name="{item}">{{item.name}}</template
</lkt-table>

Usage of createColumn:

const column = createColumn({
  key: '', // Element property
  label: '', // Column text,
  sortable: true,
  hidden: false,
  formatter: undefined,
  emptyChecker: undefined,
  colspan: undefined
})

Props

value

Type: Array Required: true Default: []

Input data array to display.

<lkt-table v-model:value="myArray"></lkt-table>

columns

Type: Array Required: true Default: []

Columns configuration (data to be shown, order, ...)

<lkt-table v-bind:columns="columns"></lkt-table>

sorter

Type: Function Required: false Default: undefined

Sorting function which will be triggered each time a th is clicked (if column is sortable)

<lkt-table v-bind:sorter="sorter"></lkt-table>
export default {
    methods: {
        sorter(datum1, datum2, column, sortDirection) {
            return 1;
        }
    },
    ...
}

sortable

Type: Boolean Required: false Default: false

Enables drag and drop

<lkt-table v-bind:sortable="true"></lkt-table>

hideEmptyColumns

Type: Boolean Required: false Default: false

Enables automatic hide empty columns

<lkt-table v-bind:hide-empty-columns="true"></lkt-table>

draggableChecker

Type: Function Required: false Default: (evt) => true

A function to determine if an item can be dragged

<lkt-table v-bind:draggable-checker="fn"></lkt-table>

checkValidDrag

Type: Function Required: false Default: (evt) => true

A function to determine if an item can be dropped in a certain position

<lkt-table v-bind:check-valid-drag="fn"></lkt-table>

Events

  • LktTable emits these events:

    • update:modelValue (for value v-model)
    • sort (same as input, but after sorting)

HTML:

<lkt-table v-on:sort="doSomething"></lkt-table>

Slots

custom column slot

LktTable generates one slot per column, so you can always control how a column will be shown.

The custom column slot will be named with the column key.

Slot props:

  • value the element value for that column
  • item the element itself
  • column the column config
  • i the row index
<lkt-table v-model:value="myArray" v-bind:columns="columns">
    <template v-slot:name="{item, value}">
        <div>{{value}}, {{item.surname}}</div>
    </template
</lkt-table>