3.1.0 • Published 5 months ago

filter-material-ui v3.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 months ago

filter-material-ui Weekly downloads

A material-ui component which allows to edit a user defined set of fields representing a filter and display it as a text or a form


Demo

You can access the storybook for this component here.

Props

The component accepts the props defined bellow in the table.

Props accepted by FilterMaterialUi

NameTypeRequiredDefaultDescription
idstringnoundefinedThe id of the field
fieldsFilterField[]yes-The fields of the filter
dataDictionary<string | string[]>no{}The initial values for the filter's fields
onChange(data: Dictionary<string | string[]>) => voidyes-The callback function called when the data is changed
textPrefixstringno""The text displayed before the fields in text mode
textSuffixstringno""The text displayed after the fields in text mode

Fields defined by FilterField

NameTypeRequiredDefaultDescription
labelstringyes-The text used as label for the field
namestringyes-The name associated to the field and in the data object
optionsstring[]no[]The options used in a select
textTEXTyes-The texts displayed in the text mode
typeTYPEyes-The type of the field

Fields defined by TEXT

NameTypeRequiredDescription
allstringyesThe text displayed when there is no value selected
noOptionsAvailablestringnoThe text when there are no longer options selectable
noOptionsMatchFilterstringnoThe text when there are no options matching the filter in select
pluralstringyesThe text displayed when there is one value selected
singularstringyesThe text displayed when there is more then one value selected

Values valid for type

EnumType of the field
INPUTInput
COLORS_SELECTMultiple Select with preview for colors
MULTIPLE_SELECTMultiple Select
SINGLE_SELECTSingle Select

Versions

FilterMaterialUi usesMaterial-uiReact
1.0.x3.2.016.5.2
1.1.x3.6.016.6.3
1.2.x3.9.216.8.1
1.3.x3.9.316.8.6
2.0.x4.0.216.8.6
2.1.x4.2.016.8.6
2.2.x4.3.316.9.0
2.3.x4.9.016.9.0
2.4.x4.9.716.9.0
2.5.x4.10.216.9.0
2.6.x4.11.016.9.0
2.7.x4.11.316.9.0 or 17.0.0
2.8.x4.12.316.9.0 or 17.0.0
2.9.x5.0.416.9.0 or 17.0.0
3.0.x5.10.17>=18.0.0

About versioning schema used for FilterMaterialUi

  • Major - it will be increased if the major version of the dependat package changes or there are breaking changes in the code of FilterMaterialUi
  • Minor - it will be increased if no major version of the dependat package changes, but there are changes of the minor or patch versions of it
  • Patch - it will be increased if there are no changes of the dependat packages, but there are non breaking changes in the code of FilterMaterialUi

Example

The base component which allows to create read-only or creatable select components for selecting only one or more values:

import React from "react";

import FilterMaterialUi, { FilterField, TYPE } from "filter-material-ui";

class App extends React.Component<any, AppState> {
  public state: AppState = {
    data: {
      name: "Green-Field",
      categories: "Open-Source",
      colors: ["red", "yellow"]
    }
  };

  private fields: FilterField[] = [
    {
      label: "App types",
      name: "types",
      options: ["JS", "JAVA", "C#"],
      text: {
        all: "of any type",
        singular: "having the type",
        plural: "having the types"
      },
      type: TYPE.MULTIPLE_SELECT
    },
    {
      label: "Name",
      name: "name",
      text: {
        all: "having any name",
        singular: "having names containing",
        plural: "having names containing"
      },
      type: TYPE.INPUT
    },
    {
      label: "Category",
      name: "categories",
      options: ["Open-Source", "Commercial", "Educational"],
      text: {
        all: "ignoring categories",
        singular: "having the category",
        plural: "having the categories"
      },
      type: TYPE.SINGLE_SELECT
    },
    {
      label: "Colors",
      name: "colors",
      options: ["red", "green", "blue", "white", "black", "gray", "yellow"],
      text: {
        all: "ignoring colors",
        singular: "having the color",
        plural: "having the colors"
      },
      type: TYPE.COLORS_SELECT
    }
  ];

  public render() {
    return (
      <div className="App">
        <h3>App</h3>
        <FilterMaterialUi
          textPrefix="Display apps "
          textSuffix="."
          data={this.state.data}
          fields={fields}
          onChange={this.handleChange}
        />
      </div>
    );
  }

  private handleChange = (data: Dictionary) => {
    console.log({
      data
    });

    this.setState({
      data
    });
  };
}

interface AppState {
  data: Dictionary;
}

interface Dictionary {
  [key: string]: string | string[];
}

export default App;

Changelog

1.0.0

  • filter-material-ui is made publicly available

1.0.2

  • Added texts for select fields for the case when there are no longer selectable options or no option matches the filter in select

1.0.3

  • Made the icon fo edit button scale with the text

1.0.4

  • Reduced number of re-renders

1.1.0

  • Updated the react and material-ui packages

1.1.1

  • Fixed the line height when the text is wrapped

1.2.0

  • Updated packages

1.3.0

  • Updated packages

1.3.1

  • Updated packages
  • Fixed display of the pencil button at different font sizes

2.0.0

  • Updated packages

2.0.1

  • Fixed the selects to use defaultValue(s) instead of value(s)
  • Added a storybook for this component
  • Updated packages

2.1.0

  • Updated packages

2.2.0

  • Updated packages

2.3.0

  • Updated packages

2.3.1

  • Updated packages

2.4.0

  • Updated packages
  • Moved from npm to yarn
  • Made SingleSelect clearable
  • Fixed the crash when there are no options selected in dropdown
  • Made stories for both not pre-filled and pre-filled filters

2.5.0

  • Updated packages

2.6.0

  • Updated packages

2.6.1

  • Fixed crash produced by "export * from"

2.7.0

  • Accepting React 17 as peerDependencies
  • Fixed security warnings

2.8.0

  • Updated the packages

2.9.0

  • Updated the packages

3.0.0

  • Migrated to material-ui 5
  • Supports minimum React 18
3.1.0

5 months ago

3.0.0

1 year ago

2.9.0

3 years ago

2.8.0

3 years ago

2.7.0

3 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.0

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago