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

@tillhub/datatable

v1.1.5

Published

Handle data with uniform UX

Downloads

15

Readme

th-datatable

Handle data with uniform UX

  • author - Tillhub
  • license - UNLICENSED

slots

  • actions

  • actions-post

  • tools

  • expanding-row

  • no-data

props

  • resource String (required)

    Define which SDK resource is allowed and will be built.

  • custom-resource Object (optional) default: undefined

  • resource-limit Number (optional) default: undefined

    The limit of API items and hence size of an API page.

  • resource-query Object (optional) default: undefined

    The options object that will be passed to the SDK

  • meta-options Object (optional) default: undefined

    The options object that will be passed to SDK when calling .meta functions

  • height String (optional) default: '100%'

    Height in DOM

  • width String (optional) default: '100%'

    Width in DOM

  • color String (optional) default: 'black'

    Font color in DOM (not in use)

  • table-data Array (optional) default: null

    Injectable data. This will lead to API calls not being made (not in use)

  • headers Array (required)

    ElTable header configuration

  • show-tools Boolean (optional) default: true

    Toggle visibility of the toolbar.

  • show-actions Boolean (optional) default: true

    Toggle visibility of the action bar.

  • show-operations Boolean (optional) default: true

    Toggle visibility of the operations bar.

  • headers-filterable Boolean (optional) default: undefined

    Toggle filterability of the headers

  • show-search-filter Boolean (optional) default: undefined

    Toggle visibilty of the search filter (ot in use).

  • search-filters Array (optional) default: [object Object]

    Toggle visibilty of the search filters.

  • multiple-select Boolean (optional) default: false

    Allow multiple select and multi actions in the item list.

  • show-tool-header Boolean (optional) default: true

    Toggle visibilty of the tool header.

  • operations Object (optional) default: [object Object]

    Configure customisable operations.

  • paging Boolean (optional) default: true

    Define whether to page or not (not in use)

  • no-meta-check Boolean (optional) default: false

    Allow or disallow meta checks. If disallowed, pages will rely on the local data count

  • show-loading Boolean (optional) default: true

    Toggle loading indicator

  • do-route Boolean (optional) default: false

    Define whether to route, e.g. on click events

  • do-route-filters Boolean (optional) default: undefined

    Define whether to route on filters being set. This e.g. triggers query parameters in the browser

  • route-base String (optional) default: [object Object]

    Define a base for routing, e.g. if you do not wish to route on the current URL.

  • page-size Number (optional) default: 20

    Define a page size

  • page-sizes Array (optional) default: [object Object]

    Define available page sizes the user can choose from

  • transform-fetched-data Function (optional) default: undefined

    Transform data the after it arrives from the SDK.

  • transform-table-data Function (optional) default: undefined

    Transform data the before it will be injected into the DOM.

  • expanding-row Boolean (optional) default: false

    Toggle expandable rows.

  • log-exception Function (optional) default: [object Object]

    General error handler. Will be called with no-op if not set.

  • headers-config Object (optional) default: undefined

  • message String (optional) default: ''

  • show-message Boolean (optional) default: false

  • headers-default-hide Array (optional) default: [object Object]

  • buttons Array (optional) default: [object Object]

  • fuzzy-search Boolean (optional) default: true

  • search-filter-config Object (optional) default: [object Object]

  • sortable Boolean (optional) default: false

    Toggle sortability

  • locale String (optional) default: 'en'

    Set locale to be used downstream (not in use)

  • row-menu-options Array (optional) default: [object Object]

    Configure ElTable row menus

  • handle-row-menu-click Function (optional) default: [object Object]

    Function that will be called on row menu click

data

  • localData

initial value: [object Object]

  • isLoading

initial value: false

  • currentPage

initial value: 1

  • page

initial value: [object Object]

  • totalCount

initial value: null

  • next

initial value: null

  • localPageSize

initial value: [object Object]

  • show

initial value: [object Object]

  • defaultFallback

initial value: '--'

computed properties

  • initialHeaders

    dependencies: headersDefaultHide, headersConfig

  • filterHeaders

    dependencies: headers, initialHeaders, initialHeaders

  • loading

    dependencies: isLoading, showLoading

  • apiPageCount

    dependencies: localData

  • totalPages

    dependencies: totalCount, pageSize, totalCount, pageSize

  • parsedFilter

    dependencies: $route, $route, $route

  • hasFilters

    dependencies: parsedFilter

  • isSearch

    dependencies: hasFilters, parsedFilter, fuzzySearch

  • doMetaCheck

    dependencies: noMetaCheck, hasFilters

  • showNoData

    dependencies: localData, isLoading

events

  • loading

  • loaded

  • delete-requested

  • edit-requested

  • size-changed

    order of execution might be important here, as we allow outside pageSize changes

  • will-handle-page-change

  • current-page-changed

  • will-handle-page

  • page-handled

  • handled-count

  • loading-error

  • row-click

  • row-dblclick

  • selection-change

  • headers-config

  • search-filter

  • search-filter-submit

  • search-filter-submit-route

methods

  • fetch()

    Simultaneously fetch the total count and first page of a resource's data. Fetching requires a uniform layout of the Tillhub SDK, hence the availability of a resource as an instance class and that having a .meta and .getAll call that behavior exactly the same across pageable resources. That is also that a second API page will be returned as next cursor from the SDK.

    This function propagetes some usage mistage as exceptions. It also handles some unexpected errors based on it's surroundings, e.g. throwing if no error listener is attached.

  • getResourceOptions()

  • handleIncomingData(data)

  • handleSearchData(data)

  • handleNext(bound)

    handle an available next cursor. If a user jumps to any arbitrary page, we need to page until that data becomes available

    parameters:

    • bound Number - defines when to stop fetch recursively
  • deleteRow(index)

    let the caller handle deletion events

  • edit(index)

    the caller will be notified about edit requests, which usually will have routing to an edit page as a consequence. Since this is common we offer a convenience options to route based on the resource

  • extendedFormatter(item, formatter, field, index)

    apply a user defined formatter. If none is defined we expect the passed formatter to be the field value. TODO: review.

  • handleSizeChange(val)

    will be emitted from the pagination component. Any size change will cause the table to return to page 1

    parameters:

    • val Number - page size that was defined in the page size options
  • handleCurrentChange(val)

    any page control will trigger this event, e.g. a paging number or a goto input

    parameters:

    • val Any - page index
  • handlePage()

    Slice local data based on current page and the page size. This function also handles boundaries and behaviors when one is overstepped.

  • handleMeta(metadata)

    Handle incoming metadata by setting total items etc.

    parameters:

    • metadata Object - the result of a TH SDK .meta call
  • refresh()

    Refresh the data, triggering re-render if data is available

  • maybeHandleError(err)

    Emit an error to the caller if a listener is set. Otherwise throw.

    parameters:

    • err Error - upstream error
  • handleRowClick(row, column, event)

    Simple row click handler. Routes if doRoute is set.

  • handleRowDblClick(row, column, event)

    Simple row double click handler. Routes if doRoute is set or routing on double click is specifically requested.

    Migh not be fired when click triggers first and has an action that will choke the second click.

    parameters:

    • row Object - EltableRowData
    • column Object - EltableColumnData
    • event Object - EltableColumnEvent
  • handleSelectionChange(val)

    Emit selection change to the implementor

    parameters:

    • val Object - value of selected item
  • changeTotalCount(count)

  • updateHeadersConfig(activeHeaders)

  • injectFilter()

  • handleSearchFilterInput(v)

  • handleSearchFilterSubmit(v)

  • toggleShow()

  • getResourceInstance()

  • isNull(value, fallback)

  • sortChange(info)

  • compareRow(a, b, info)

  • isRowMenu(column, event)