JSPM

  • Created
  • Published
  • Downloads 20724
  • Score
    100M100P100Q143710F
  • License MIT

Custom MUI (Material Design) components for react-querybuilder

Package Exports

  • @react-querybuilder/material
  • @react-querybuilder/material/dist/index.cjs.js
  • @react-querybuilder/material/dist/index.es.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@react-querybuilder/material) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@react-querybuilder/material

Official MUI/Material Design components for react-querybuilder.

To see them in action, check out the react-querybuilder demo and choose "Material" from the Style drop-down.

Installation

npm i --save react-querybuilder @react-querybuilder/material @mui/icons-material @mui/material
# OR
yarn add react-querybuilder @react-querybuilder/material @mui/icons-material @mui/material

Usage

import QueryBuilder, { RuleGroupType } from 'react-querybuilder';
import {
  MaterialActionElement,
  MaterialDragHandle,
  MaterialNotToggle,
  MaterialValueEditor,
  MaterialValueSelector
} from '@react-querybuilder/material';

const fields = [
  { name: 'firstName', label: 'First Name' },
  { name: 'lastName', label: 'Last Name' }
];

const App = () => {
  const [query, setQuery] = useState<RuleGroupType>({ combinator: 'and', rules: [] });

  return (
    <QueryBuilder
      fields={fields}
      query={query}
      onQueryChange={(q) => setQuery(q)}
      controlElements={{
        addGroupAction: MaterialActionElement,
        addRuleAction: MaterialActionElement,
        cloneGroupAction: MaterialActionElement,
        cloneRuleAction: MaterialActionElement,
        combinatorSelector: MaterialValueSelector,
        fieldSelector: MaterialValueSelector,
        notToggle: MaterialNotToggle,
        operatorSelector: MaterialValueSelector,
        removeGroupAction: MaterialActionElement,
        removeRuleAction: MaterialActionElement,
        valueEditor: MaterialValueEditor,
        dragHandle: MaterialDragHandle
      }}
    />
  );
};