1.0.0-alpha.45 • Published 5 years ago

vue-data-component v1.0.0-alpha.45

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

A straightforward Vue component to filter, sort and paginate data.

Latest Version on NPM Less than 6.5kb Software License Build Status npm

Work in progress!

vue-data-component is a renderless component to build data-driven interfaces. Especially interfaces that contain filterable, sortable, or paginated data. We wanted to build something that takes care of pesky little problems like loading indicators, debouncing, or mapping your interface's filters to an AJAX request.

A brief overview of what vue-data-component has to offer:

  • Filter, sort, and paginate data via AJAX or from any other data source
  • Sync the component state with the current URL's query string
  • Debounce asynchronous requests
  • Handle loading indicators. No unnecessary flashes, only display them if the request is taking too long
  • Pass initial data for the component's first render when fetching data asynchronously, avoids layout jumps on first render when the data isn't loaded yet
  • Renderless: build your own interface, we don't make any assumptions
  • Additional helper components for sorting, pagination, and facet filters

On their own, none of these features are super impressive, but together they enable you to build better interfaces in a uniform approach.

Changelog

Please see CHANGELOG for more information what has changed recently.

Installation

With npm:

npm install vue-data-component

With yarn:

yarn add vue-data-component

This package contains a few components. You can register them all globally by installing this package as a plugin.

import Vue from 'vue';
import VueDataComponent from 'vue-data-component';

Vue.use(VueDataComponent);

Alternatively, you can import the ones you need separately.

import {
    DataComponent,
    QueryComponent,
    DataSortToggle,
    DataFilter,
    DataPaginator,
} from 'vue-data-component';

Polyfills

vue-data-component expects the following browser API's to be available. If you expect wider browser support, you'll need to add a polyfill.

Usage

The main component exposed by this package is the

PropTypeDefaultDescription
source*Function(required)This function will be called to fetch data. It receives an object parameter: { query, queryString }. The function should return a response object. The response object mayb be wrapped in a promise.
queryObject{}A query object. A deep watcher will be registered on the query object to determine when new data should be fetched.
initialObject or nullnullAn initial response object so the component can render as soon as possible.
debounceMsNumber0Data wont be subsequently fetched until the debounce time has passed.
slowRequestMsNumber0Requests that take longer than slowRequestMs will be considered slow. See Handling slow requests.
useQueryStringBooleanfalseWhen true, the browser's query string will be updated based on the current query. See Query strings. This prop is currently not supported with SSR.
queryStringDefaultsObject or nullnullThe default values for the query string. When these values match the current query values, they will be omitted from the query string. For example, you generally don't want page=1 in your URL's, since it has the same effect as no page parameter.

Query objects

Todo

Query strings

Response objects

Todo

Handling slow requests

Slow initial loads

Todo

Slow subsequent requests

Todo

Testing

yarn test

Contributing

Please see CONTRIBUTING for details.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards on our company website.

Security

If you discover any security related issues, please contact freek@spatie.be instead of using the issue tracker.

Credits

Support us

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License

The MIT License (MIT). Please see License File for more information.

1.0.0-alpha.45

5 years ago

1.0.0-alpha.44

5 years ago

1.0.0-alpha.43

5 years ago

1.0.0-alpha.42

5 years ago

1.0.0-alpha.41

5 years ago

1.0.0-alpha.40

5 years ago

1.0.0-alpha.39

5 years ago

1.0.0-alpha.38

5 years ago

1.0.0-alpha.37

5 years ago

1.0.0-alpha.36

5 years ago

1.0.0-alpha.35

5 years ago

1.0.0-alpha.34

5 years ago

1.0.0-alpha.33

5 years ago

1.0.0-alpha.32

6 years ago

1.0.0-alpha.31

6 years ago

1.0.0-alpha.30

6 years ago

1.0.0-alpha.29

6 years ago

1.0.0-alpha.28

6 years ago

1.0.0-alpha.27

6 years ago

1.0.0-alpha.26

6 years ago

1.0.0-alpha.25

6 years ago

1.0.0-alpha.24

6 years ago

1.0.0-alpha.23

6 years ago

1.0.0-alpha.22

6 years ago

1.0.0-alpha.21

6 years ago

1.0.0-alpha.20

6 years ago

1.0.0-alpha.19

6 years ago

1.0.0-alpha.18

6 years ago

1.0.0-alpha.17

6 years ago

1.0.0-alpha.16

6 years ago

1.0.0-alpha.15

6 years ago

1.0.0-alpha.14

6 years ago

1.0.0-alpha.13

6 years ago

1.0.0-alpha.12

6 years ago

1.0.0-alpha.11

6 years ago

1.0.0-alpha.10

6 years ago

1.0.0-alpha.9

6 years ago

1.0.0-alpha.8

6 years ago

1.0.0-alpha.7

6 years ago

1.0.0-alpha.6

6 years ago

1.0.0-alpha.5

6 years ago

1.0.0-alpha.4

6 years ago

1.0.0-alpha.3

6 years ago

1.0.0-alpha.2

6 years ago

1.0.0-alpha.1

6 years ago