1.1.0 • Published 6 years ago

power-search v1.1.0

Weekly downloads
5
License
MIT
Repository
-
Last release
6 years ago

power-search

Installation & Usage

npm install curio-power-search --save
import React from 'react';
import ReactDOM from 'react-dom';
import PowerSearch from "curio-power-search";

const filterListExample:Array<Filter> = [
    {
        key:"subscribe",
        label:"User Status",
        active:true,
        op_type:"binary",
        value_type:"select",
        value_option_list:[
            {value:0, label:"Unsubscribed"},
            {value:1, label:"Subscribed"}
        ],
        value_default:1
    },{
        key:"username",
        label:"Username",
        active:false,
        op_type:"all",
        value_type:"input"
    }
];

ReactDOM.render(
    <PowerSearch filterList={filterListExample} url="" />,
    document.getElementById("app"));

Configuration

PowerSearch

PropNameTypeDescriptionDefault value
filterListArray<Filter>Array of Filtersrequired
urlstringSearch request URLrequired
onChange(filterList:Array<Filter>) => anyReturn the changes applied to filterList

Filter

PropertyTypeDescriptionDefault value
keystringFilter keyrequired
labelstringFilter Labelrequired
activebooleanSet if the filter is active or notfalse
op_typestringDefine the OperationType (unique/binary/all/date/custom)required
op_type_customArray<Option>Set the custom OperationType if op_type === "custom"
value_typestringDefine the type of the value input (text/select/search/datepicker/custom)required
value_type_custom(value:any) => JSX.ElementDefine the custom value render if value_type === "custom"required
value_option_listArray<Option>Define the list of options if value_type === ("selectsearch")
value_defaultanyDefine the default value
listArray<Option>Define the list of filter items

Option

PropertyTypeDescriptionDefault value
valueanyOption valuerequired
labelstringOption labelrequired

OperationType

{
    unique: [
        { label: 'is', value: 'eq'}
    ],
    binary: [
        { label: 'is', value: 'eq'},
        { label: 'is not', value: 'ne'}
    ],
    all: [
        { label: 'is', value: 'eq'},
        { label: 'is not', value: 'ne'},
        { label: 'starts with', value: 'starts with'},
        { label: 'ends with', value: 'ends with'},
        { label: 'contains', value: 'contains'},
        { label: 'does not contain', value: 'does not contain'}
    ],
    date: [
        { label: 'is', value: 'day'},
        { label: 'greater than', value: 'gt'},
        { label: 'less than', value: 'lt'}
    ]
};