8000 GitHub - Level0r0s/filter: Svelte filter component for building data queries.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Level0r0s/filter

 
 

Repository files navigation

SVAR Svelte Filter | Query Builder

npm License

🔗 Website • 📚 Documentation • 👀 Demos

SVAR Svelte Filter helps you add flexible filtering features to your Svelte apps: from simple filter bars to advanced query builders. It provides an intuitive UI to create and edit filtering rules, group filters, define conditions, and choose combining logic (AND/OR).

SVAR Filter - Svelte Query Builder Component

🧩 Included Components

The package includes 3 widgets:

  • FilterBuilder - the main component that provides an interactive interface for building complex queries and filtering large datasets.
  • FilterEditor - allows you to create a filtering rule for a single field, and can be used as a standalone component.
  • FilterBar - a simplified filter bar UI with inputs and select controls. It allows building filtering rules for several fields and combining them with logical operators.

✨ Key features:

  • Complex filter queries: multi-field rules, groups of filters, nested filters, AND/OR logic.
  • Multiple data types: text, number, and date filtering with type-specific operators.
  • Configurable layouts: vertical, horizontal, or minimal filter bar layouts.
  • Localization: labels and date formats can be customized to match users' locale.
  • Dynamic loading: filter options can be loaded on demand when a new filter is added.
  • JSON output: the component outputs structured JSON that can be transformed into SQL or other query formats.
  • Intuitive, straightforward API: easily set and retrieve values, customize filters, and track changes.

Check out the demos to see all SVAR Filter features in action.

🛠️ How to Use

You can install SVAR Svelte Filter as follows:

npm install wx-svelte-filter

To use SVAR Filter, simply import the package and include the component in your Svelte file:

<script>
    import { FilterBuilder }  from 'wx-svelte-filter';

    const fields = [
        { id: "first_name", label: "Name", type: "text" },
        { id: "age", label: "Age", type: "number" }
    ];
    const options = [
        first_name: ["Alex", "Marta", "Claire", "David"],
        age: [21, 25, 28, 35, 42, 51, 53]
    ];
</script>

<FilterBuilder {fields} {options} />

For further instructions, see the detailed how-to-start guide.

💻 How to Modify

Typically, you don't need to modify the code. However, if you wish to do so, follow these steps:

  1. Run yarn to install dependencies. Note that this project is a monorepo using yarn workspaces, so npm will not work
  2. Start the project in development mode with yarn start

✅ Run Tests

To run the test:

  1. Start the test examples with:
    yarn start:tests
  2. In a separate console, run the end-to-end tests with:
    yarn test:cypress

💬 Need Help?

Post an Issue or use our community forum.

About

Svelte filter component for building data queries.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 52.8%
  • Svelte 39.5%
  • TypeScript 7.2%
  • Other 0.5%
0