0.0.2 • Published 8 months ago

@licuido-ui/ui_filter v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Filter

The Filter component is a flexible and customizable filtering tool. It allows users to apply filters and refine their data based on various criteria. The component provides a user-friendly interface with options like search functionality, chip display, and more. Users can select from a list of custom data items and use buttons to trigger specific actions based on their selected filters. With its configurable styles and options, the Filter component offers a powerful solution for creating interactive and dynamic filtering experiences in web applications.

Author

Link

Story Book Link ButtonGroup

PlayGround

Try it have a fun codeBox

Installation

npm i @licuido-ui/ui_filter

Import component

import { Filter } from '@licuido-ui/ui_filter';

Usage

<Filter customData={[]} buttons={[]} />

Image

alt text

Sample code

    <Filter
      icon={<FunnelIcon color='#fff' width='16px' height='16px' />,}
    customData={[
      {
        listName: 'Category',
        selected: false,
        subList: [
          {
            list: 'Category1',
            selected: false,
            listStyle: {},
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
          {
            list: 'Category2',
            selected: false,
            listStyle: {},
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
          {
            list: 'Category3',
            selected: false,
            listStyle: {},
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
          {
            list: 'Category4',
            selected: false,
            listStyle: {},
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
          {
            list: 'Category5',
            selected: false,
            listStyle: {},
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
          {
            list: 'Category6',
            selected: false,
            listStyle: {},
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
        ],
        listNameStyle: {},
        subListType: 'checkbox',
      }
      {
        listName: 'product',
        selected: false,
        subList: [
          {
            list: 'Product1',
            selected: false,
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
          {
            list: 'product2',
            selected: false,
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
          {
            list: 'product3',
            selected: false,
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
          {
            list: 'product4',
            selected: false,
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
        ],
        subListType: 'chip',
      },
      {
        listName: 'Price',
        selected: false,
        subList: [
          {
            list: '100',
            selected: false,
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
          {
            list: '200',
            selected: false,
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
          {
            list: '300',
            selected: false,
            LabelbgColor: '#E9E9E9',
            LabelColor: '#666666',
          },
        ],
        subListType: 'checkbox',
      },
    ]}

    buttons={[
      {
        label: 'Clear all',
        onClick: (data, getClearState) => {
          getClearState();
        },
        btnstyle: {
          backgroundColor: '#FFE8E9',
          padding: '4px',
          color: '#F44F5A',
          width: '121px',
          height: '36px',
        },
      },
      {
        label: 'Apply',
        onClick: (data: any) => {
          const selectedData: any = [];

          data.forEach((item: any) => {
            const { listName, subList } = item;
            const selectedSubList = subList?.filter((subItem: any) => subItem.selected);
            if (selectedSubList && selectedSubList.length > 0) {
              selectedData.push({ listName, subList: selectedSubList });
            }
          });
          console.log(selectedData);
        },
        btnstyle: {
          backgroundColor: '#665CD7',
          padding: '4px',
          color: '#fff',
          width: '121px',
          height: '36px',
        },
      },
    ]}
    rootStyle={{}}
    anchorOrigin={{
     vertical: 'bottom',
      horizontal: 'left',
    }}

    filterTitle={'Filter'}
    filterTitleStyle={{
      fontSize: '16px',
      textalign: 'left',
      color: '#262626',
      fontWeight: 'bold',
    }}
    listIconStyle={{}}
    subListContainerStyle={{}}
    buttonContainerStyle={{}}
    PopoverStyle={{}}
    contentWrapStyle={{}}
    searchBarStyle={{}}
    showSearchBar={true}
    filterButtonStyle={{ height: '36px', width: '10px' }}
    labelStyle={{}}
    listItemStyle={{}}
    maxLabelShow={}
    moreLabelStyle={{
     backgroundColor: '#E9E9E9',
      fontSize: '10px',
      m: 0,
      borderRadius: '4px',
    }}
    titleWrapperStyle={{}}
    btnWrapperStyle={{}}
    selectedchipConStyle={{}}
    searchPlaceHolder={'Search'}
    searchVariant={'outlined'}
    searchbarSize={'small'}
    checkboxStyle={{}}
    chipStyle={{}}
    chipVariant={'outlined'}
    visibleSubList={3}
    badgeColor={'secondary'}
    moreLabelcolor={'#666666'}
  />

Props

NameTypeDefault ValueDescription
filterIdstringstringstring
classNamestring''Additional CSS class for styling the component.
sxSxProps{}Custom style prop for using MUI's sx prop.
iconJSX.Element<FunnelIcon />The icon element to display as the filter button.
customDataCustomData[][]An array of objects representing custom data for the filter.
buttonsButtonItem[][]An array of objects representing buttons in the filter.
rootStyleSxProps{}Additional custom style for the root container.
filterButtonStyleSxProps{}Additional custom style for the filter button.
anchorOrigin{ vertical: 'top' | 'bottom', horizontal: 'left' | 'center' | 'right' }{ vertical: 'bottom', horizontal: 'left' }The anchor origin for the Popover component.
transformOrigin{ vertical: 'top' | 'bottom', horizontal: 'left' | 'center' | 'right' }{ vertical: 'top', horizontal: 'left' }The transform origin for the Popover component.
filterTitlestring''The title to display at the top of the filter.
filterTitleStyleSxProps{}Additional custom style for the filter title.
listContainerStyleSxProps{}Additional custom style for the list container.
listIconStyleSxProps{}Additional custom style for the list icon.
subListContainerStyleSxProps{}Additional custom style for the sublist container.
buttonContainerStyleSxProps{}Additional custom style for the button container.
PopoverStyleSxProps{}Additional custom style for the Popover component.
contentWrapStyleSxProps{}Additional custom style for the content wrapper.
searchBarStyleSxProps{}Additional custom style for the search bar.
showSearchBartrue | falsetrueWhether to show the search bar in the filter.
chipStyleSxProps{}Additional custom style for the chip.
labelStyleSxProps{}Additional custom style for the label.
listItemStyleSxProps{}Additional custom style for each list item.
maxLabelShownumber2The maximum number of labels to show before displaying the "more" label.
visibleSubListnumber3The maximum number of sublist items to display before showing a "more" label.
moreLabelStyleSxProps{}Additional custom style for the "more" label.
titleWrapperStyleSxProps{}Additional custom style for the title wrapper.
btnWrapperStyleSxProps{}Additional custom style for the button wrapper.
selectedchipConStyleSxProps{}Additional custom style for the selected chip container.
searchPlaceHolderstring''The placeholder text for the search bar.
searchVariant'standard' | 'filled' | 'outlined''outlined'The variant of the search bar.
searchbarSize'small' | 'medium''small'The size of the search bar.
checkboxStyleSxProps{}Additional custom style for the checkbox (if sublistType is 'checkbox').
chipVariant'filled' | 'outlined''outlined'The variant of the chip (if sublistType is 'chip').
badgeColor'success' | 'primary' | 'secondary' | 'error''primary'The color of the badge on the filter button.
moreLabelcolorstring'#666666'The color of the text for the "more" label.
moreLabelbgColorstring'#E9E9E9'The background color of the "more" label.