Skip to content

Commit 35af9c2

Browse files
update readme
1 parent 43b5cfe commit 35af9c2

File tree

3 files changed

+149
-22
lines changed

3 files changed

+149
-22
lines changed

README.md

Lines changed: 147 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,162 @@
1-
# React-Filter-Editor 🔎
2-
### Documentation
3-
[React Filter Editor Docs ](https://storybook--hilarious-dieffenbachia-334eae.netlify.app/?path=/story/installation--page)
41

5-
## Getting Started 🚀
2+
3+
4+
# React-Filter-Editor 🔎
5+
6+
7+
8+
### Documentation
9+
10+
11+
12+
[React Filter Editor Docs V1.3.3 ](https://storybook--hilarious-dieffenbachia-334eae.netlify.app/?path=/story/installation--page)
13+
14+
15+
16+
17+
18+
## Getting Started 🚀
19+
20+
21+
622
```
723
$ npm install react-filter-editor
8-
$ yarn add react-filter-editor
924
```
10-
## Integration
11-
```
12-
import React, { useState } from 'react';
13-
import FilterEditor from 'react-filter-editor';
25+
1426

15-
const options = [{ name:"name", label:"Name", fieldType: "text" }];
27+
28+
## Integration
29+
1630

17-
const App = () => {
31+
32+
```
33+
import React, { useState } from 'react';
34+
import FilterEditor from 'react-filter-editor';
35+
36+
37+
const options = [{ name:"name", label:"Name", fieldType: "text" }];
38+
39+
const App = () => {
1840
const [values, setValues] = useState({name: ""});
19-
return (
20-
<FilterEditor options={options} values={values} onChangeValues={setValues}/>
21-
);
22-
}
41+
42+
return (
43+
<FilterEditor options={options} values={values} onChangeValues={setValues}/>
44+
);
45+
}
2346
```
24-
## Import component for Bootstrap v5
47+
48+
## Import component for Bootstrap v5
49+
50+
51+
2552
```
26-
import FilterEditor from 'react-filter-editor/lib/bootstrap';
53+
import FilterEditor from 'react-filter-editor/lib/bootstrap';
2754
```
28-
## Contributors 👽
29-
### Code Contributors
55+
56+
## Documentation V2.0
57+
58+
| attributes | type | description |
59+
|--|--|--|
60+
| values | object |
61+
| options | Array object |
62+
| onChangeValues | Function | function to return select value (data) => void; |
63+
| getData | Function | function to query all data |
64+
| setVisibleValue | Function Callback | function options to return tag value |
65+
| configButtons | Object |
66+
| className | String | parent ClassName |
67+
| optionsComponent | JSX Element | render options in dropdown |
68+
69+
70+
71+
### values
72+
73+
{name: "", age: 30, pets: ["Firulais", "Toby", "Martita"]}
74+
75+
### options
76+
77+
[
78+
{
79+
label:"Person Name",
80+
styles: {color: "red"},
81+
value:"name",
82+
icon: "fas fa-user",
83+
fieldType?: select || text || number || date,
84+
fieldComponent?:({onChange, data, onEditField, onDisabledEditMode}) => JSX.Element
85+
}
86+
]
87+
88+
### setVisibleValue
89+
function callback
90+
91+
({label, name, value, fieldType}) => return string;
92+
93+
### configButtons
94+
95+
icons work with [fontAwesome](https://fontawesome.com/icons)
96+
97+
98+
{
99+
add: {
100+
icon: string
101+
text: string
102+
},
103+
remove: {
104+
icon?: string,
105+
text?: string,
106+
removeComponent?: ({onAction}) => return JXS.Element
107+
},
108+
filterActive: {
109+
icon?: string
110+
filterActiveComponent?: ({onAction}) => return JXS.Element
111+
},
112+
filterDisabled: {
113+
icon?: string
114+
filterDisabledComponent?: ({onAction}) => return JXS.Element
115+
}
116+
}
117+
118+
### optionsComponent
119+
render options in dropdown
120+
the component brings the following properties: onAddFilter and options,
121+
to the **onAddFilter** function you have to pass the name as an attribute
122+
123+
124+
const OptionsRender = ({onAddFilter, options}) => {
125+
return (....)
126+
}
127+
128+
129+
130+
## Contributors 👽
131+
132+
133+
134+
### Code Contributors
135+
136+
137+
30138
![jpprogrammer](https://avatars.githubusercontent.com/u/52465504?s=56&)
139+
140+
141+
31142
![andresceccoli](https://avatars.githubusercontent.com/u/7004266?s=56&)
32-
### Financial Contributors
33-
<img src="https://app.sitrack.io/static/media/sitrack_color.22c61360.svg" alt="drawing" style="width:200px;"/>
34143

35-
## License
144+
145+
146+
### Financial Contributors
147+
148+
149+
150+
<img src="https://app.sitrack.io/static/media/sitrack_color.22c61360.svg" alt="drawing" style="width:200px;"/>
151+
152+
153+
154+
155+
156+
## License
157+
158+
159+
160+
36161

37162
Licensed under MIT

lib/hooks/useFilter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ exports.useFilter = useFilter;
134134
//@ts-ignore
135135
const objectsEqual = (o1, o2) => (typeof o1 === 'object' && Object.keys(o1).length > 0
136136
? Object.keys(o1).length === Object.keys(o2).length
137+
//@ts-ignore
137138
&& Object.keys(o1).every(p => objectsEqual(o1[p], o2[p]))
138139
: o1 === o2);
139140
const arraysEqual = (a1, a2) => a1.length === a2.length && a1.every((o, idx) => objectsEqual(o, a2[idx]));

src/hooks/useFilter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export const useFilter = ({ data, options, onChangeCallback, setVisibleValue }:
141141
const objectsEqual = (o1: any, o2: any) => (
142142
typeof o1 === 'object' && Object.keys(o1).length > 0
143143
? Object.keys(o1).length === Object.keys(o2).length
144+
//@ts-ignore
144145
&& Object.keys(o1).every(p => objectsEqual(o1[p], o2[p]))
145146
: o1 === o2
146147
);

0 commit comments

Comments
 (0)