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

structured-query

v0.0.2

Published

## Overview

Downloads

1

Readme

Structured Query

Overview

Structured Query is a library that can be used to filter data. Is used in conjunction with kyle tables.

Features

Structured query renders UI elements called tokens. The tokens are used to represent data that has been filtered out. Each token keeps track of four different values:

  • id: Each token has an id associated with it. The id should be what you need to query; i.e. a database table field, a client side table column name, etc
  • category: displayed to the user and indicates the field being queried.
  • operation: operation to apply to the data with value and is based on the data type of the category
  • value: value to filter against the category with the operation selected

Structured query can generate enumerable lists for values, generate different operations based on the data type of the category, and has typeahead with fuzzy matching for all lists. Space, tab, and enter will autocomplete as well.

Styling

CSS styles can be found in structured-filter.css Datepicker styles can be found in input-moment.css

Props

options

A list of opjects describing the options that are available in lists for categories, operations, and values(optional).

An example options prop:

[ { id: '123', category: 'Display123', type: 'enumoptions', options: ['foo', 'bar'] },
{ id: 'baz', category: 'Another category', type: 'integer' } ]

Id ( string )

Identifier for the token. Attached to the token when user selects a category.

Category ( string )

Display name to show to the user.

Type ( string )

Type says what kind of operations are allowed on the category.

The following operations are allowed based on what data type is equal to:

Data Types
  • string, email
    • ==
    • !=
    • contains
    • !contains
    • like
    • !like
    • startsWith
    • !startsWith
    • endsWith
    • !endsWith
  • integer, float, datetime
    • ==
    • !=
    • <
    • <=
    • >
    • >=
  • enumoptions, boolean
    • ==
    • !=

Options ( [string] )

A list of options that will generate if the value is supposed to be an enumerable list. Used with enumoptions data type.

Note: Boolean data type does not generate a default list and you should pass in an on options object describing the true/false for it.

OptionObjs ( [object] )

A list of options that will generate if the value is supposed to be an enumerable list. This one will take objects that must an id and name field in them. Structured query will generate a list based on the name field. Used with enumoptions data type.

Note: If an options object passes both an options and optionObjs prop, only the options prop will be used and optionObjs prop will be ignored.

customClasses

Custom CSS classes to apply to structured query. The following fields in an object will be used as classes to change the appearance of structured query:

  • input: Changes the input box
  • results: Changes the list container of options
  • listItem: Changes each list option in the list container
  • listAnchor: Changes each list link in the list container
customClasses={{
	input: '123',
	results: 'foo',
	listItem: 'bar',
	listAnchor: 'baz'
}}

initTokens

Initial tokens is a list of objects that can be passed in to generate predefined tokens in structured query.

Objects passed in need to have the following fields: * id ( string ): token identifier * category ( string ): the field being searched * operator ( string ): operation being applied to the field * value ( string ): value to look for

onTokenAdd

A callback function that is called when the user finishes generating a new token. This function will receive a list of objects with each object being a token.

onTokenRemove

A callback function that is called when the user removes a token. This function will receive a list of objects with each object being a token.

queryDisabled

Toggle if querying is disabled on the table. Sometimes, you may want to allow the current query to be viewable but not modifiable. Set this to true to show query tokens, but it does not allow the user to change the query in the filter.

enableQueryOnClick

Toggle to allow the user to enable querying if it is disabled. Set if the querying is to be initially disabled, but then want to allow the user to enable it on click.