0.7.2 • Published 11 months ago
@fn-sphere/filter v0.7.2
Filter Sphere
Filter Sphere is meant to generate advanced filters based on a zod schema. It is designed to work seamlessly with React, allowing you to create dynamic and complex filter interfaces in your applications.
Installation
Install the package:
npm install @fn-sphere/filter
yarn add @fn-sphere/filter
pnpm add @fn-sphere/filterFilter Sphere uses zod as its schema engine. You can install it by running:
npm install zodUsage
You can use the useFilterSphere hook to create a filter:
import { useFilterSphere } from "@fn-sphere/filter";
import { z } from "zod";
const YOUR_DATA_SCHEMA = z.object({
name: z.string(),
age: z.number(),
});
const YOUR_DATA: z.infer<typeof YOUR_DATA_SCHEMA>[] = [
{
name: "John",
age: 30,
},
];
const Filter = () => {
const { rule, predicate, context } = useFilterSphere({
schema: YOUR_DATA_SCHEMA,
});
const filteredData = YOUR_DATA.filter(predicate);
console.log(filteredData);
return (
<FilterSphereProvider context={context}>
<FilterBuilder />
</FilterSphereProvider>
);
};Custom Styles
You can provide custom styles for the filter styles by using the FilterThemeProvider component:
import { FilterThemeProvider, FilterTheme } from "@fn-sphere/filter";
const theme: FilterTheme = {};
const App = () => {
return (
<FilterThemeProvider theme={theme}>
<FlattenFilterDialog />
</FilterThemeProvider>
);
};0.7.2
11 months ago
0.7.1
11 months ago
0.7.0
11 months ago
0.6.0
1 year ago
0.5.0
1 year ago
0.4.0
1 year ago
0.3.8
1 year ago
0.3.7
1 year ago
0.3.6
1 year ago
0.3.5
1 year ago
0.3.4
1 year ago
0.3.3
1 year ago
0.3.2
1 year ago
0.3.1
1 year ago
0.3.0
1 year ago
0.2.0
1 year ago
0.1.3
1 year ago
0.1.2
1 year ago
0.1.1
1 year ago
0.1.0
1 year ago