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

mui-query-builder-bugfix

v1.0.2

Published

Material-UI Query Builder. https://www.npmjs.com/package/mui-querybuilder, Author: Tiago Fernandez, homepage: https://github.com/tiagofernandez/mui-querybuilder#readme

Downloads

1

Readme

This version was updated to correctly install with npm i. Original package: https://www.npmjs.com/package/mui-querybuilder, Author: Tiago Fernandez, Homepage: https://github.com/tiagofernandez/mui-querybuilder#readme

MUI-QueryBuilder

Query builder for React applications based on Material-UI.

npm package npm downloads

Installation

MUI-QueryBuilder is available as an npm package.

yarn add --exact mui-querybuilder \
    @date-io/[email protected] \
    @date-io/[email protected] \
    @material-ui/core \
    @material-ui/icons \
    @material-ui/lab \
    @material-ui/pickers \
    date-fns \
    prop-types

Usage

Here is a quick example to get you started:

import MuiQueryBuilder from "mui-querybuilder";

import React, { useState } from "react";
import ReactDOM from "react-dom";

const filters = [
    {
        label: "Article",
        options: [
            {
                label: "Title",
                value: "title",
                type: "text",
            },
            {
                label: "URL",
                value: "url",
                type: "text",
            },
        ],
    },
];

function App() {
    const [query, setQuery] = useState({
        combinator: "and",
        rules: [
            {
                field: "title",
                operator: "contains",
                value: "France",
            },
        ],
    });
    return (
        <MuiQueryBuilder
            filters={filters}
            query={query}
            onChange={(query, valid) => {
                setQuery(query);
            }}
        />
    );
}

ReactDOM.render(<App />, document.querySelector('#app'));

Examples

Check out some examples in here!

API

Types

  • date: renders a date picker, date only.
  • integer: renders a text field that only accepts numbers.
  • number: renders a text field that only accepts fractional numbers.
  • multiselect: renders an autocomplete input for multiple items.
  • radio: renders radio buttons with true and false values.
  • select: renders an autocomplete input for a single item.
  • switch: renders an on/off switch input.
  • text: renders a text field.

Filters

The filters object is a list of grouped objects with label (string) and options (list) properties. Each option is an object with label (string), value (string), and type (string). The label can be anything, but the value must be an unique key, used by each field in a ruleset. In case an option's type is select or multiselect, it will require a nested options (list) property with label & value items.

Operators

In order to relate operators to their corresponding types, we rely on this data structure. Each operator must have a label (string), unique value (string), and the types (list) it supports.

Query

The query object is a recursive data structure composed of combinator (string) and rules (list) properties. Each rule is an object with field (string), operator (string), and value (anything, depending on the field's type). In case the rule contains a combinator property, it's considered a nested group.

Properties

|Property|Type|Default|Description |-|-|-|-| |customOperators|object|{}|Additional operators to be used by the query builder. |debug|bool|false|Dev mode helper that renders the generated query directly in the screen. |filters|array|[]|The filters the query builder framework will rely to create rules. |maxLevels|number|1|The max nesting level, with 0 meaning no nesting at all. |operators|array|[...operators]|The operators to be used, in case you want to change or translate the default ones. |onChange|func|null|Function (query: object, valid: bool) => void with the current query and its validity (true if all rules have values). |query|object|{ combinator: "and", rules: [{ field: null, operator: null, value: null }] }|The initial query to be rendered. |sortFilters|bool|true|Option to disable sorting filters within their groups.

Utility functions

import MuiQueryBuilder from "mui-querybuilder";

// Formats a query by deleting IDs from all nodes.
const formattedQuery = MuiQueryBuilder.formatQuery(query);

// Verifies if a query is valid, i.e. all rules and nested groups are filled.
const valid = MuiQueryBuilder.isQueryValid(query);

License

This project is licensed under the terms of the MIT license.