Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lawvs/fn-sphere
⌛ Filter Sphere is a powerful and flexible library for creating dynamic filtering interfaces in your web applications.
https://github.com/lawvs/fn-sphere
advanced-filter filter filter-builder query query-builder zod
Last synced: 8 days ago
JSON representation
⌛ Filter Sphere is a powerful and flexible library for creating dynamic filtering interfaces in your web applications.
- Host: GitHub
- URL: https://github.com/lawvs/fn-sphere
- Owner: lawvs
- Created: 2024-03-20T08:22:17.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-10-28T03:34:26.000Z (9 days ago)
- Last Synced: 2024-10-28T07:07:15.226Z (8 days ago)
- Topics: advanced-filter, filter, filter-builder, query, query-builder, zod
- Language: TypeScript
- Homepage: http://www.waterwater.moe/fn-sphere/
- Size: 1.89 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fn Sphere
[![Build](https://github.com/lawvs/fn-sphere/actions/workflows/build.yml/badge.svg)](https://github.com/lawvs/fn-sphere/actions/workflows/build.yml)
[![npm](https://img.shields.io/npm/v/@fn-sphere/filter)](https://www.npmjs.com/package/@fn-sphere/filter)Fn Sphere contains a set of libraries for filtering, sorting, and transforming data. Use it, you can easily integrate advanced filters, sorters, and transform functions to handle your data.
## Filter Sphere
With Filter Sphere, you can easily integrate a filter system into your application.
![demo](https://github.com/user-attachments/assets/5a5b9ebe-f37e-4944-8bf2-e29555dff138)
![demo ui](https://github.com/user-attachments/assets/cbf689fd-029d-4f2b-8993-0363f2667e74)
## Usage
Visit [Filter Sphere Docs](https://lawvs.github.io/fn-sphere) to learn more.
```sh
npm add @fn-sphere/filter
``````tsx
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[] = [
{ name: "Jack", age: 18 },
];const Filter = () => {
const { filterRule, predicate, context } = useFilterSphere({
schema: YOUR_DATA_SCHEMA,
onRuleChange: ({ predicate }) => {
const filteredData = YOUR_DATA.filter(predicate);
console.log(filteredData);
},
});return (
);
};
```## Acknowledgements
- This project is inspired by the filter system in [toeverything/AFFiNE](https://github.com/toeverything/AFFiNE/tree/3e810eb043e62811ba3ab2e021c6f4b92fb4fe70/packages/frontend/core/src/components/page-list/filter)