advanced-filter-system 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +446 -208
- package/dist/AFS.esm.js +4484 -759
- package/dist/AFS.esm.js.map +1 -1
- package/dist/AFS.js +4486 -760
- package/dist/AFS.js.map +1 -1
- package/dist/AFS.min.js +1 -1
- package/dist/AFS.min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,324 +1,562 @@
|
|
|
1
|
-
# Advanced Filter System
|
|
2
|
-
|
|
3
|
-
A powerful and flexible JavaScript
|
|
1
|
+
# Advanced Filter System (AFS)
|
|
2
|
+
|
|
3
|
+
A powerful and flexible vanilla JavaScript filtering system that provides advanced filtering, searching, sorting, and pagination capabilities for DOM elements. Zero dependencies, lightweight, and highly customizable.
|
|
4
|
+
|
|
5
|
+
[Live Demo](https://misits.github.io/advanced-filter-system) | [NPM Package](https://www.npmjs.com/package/advanced-filter-system)
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Advanced Filter System (AFS)](#advanced-filter-system-afs)
|
|
10
|
+
- [Table of Contents](#table-of-contents)
|
|
11
|
+
- [Features](#features)
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [Quick Start](#quick-start)
|
|
14
|
+
- [HTML Structure](#html-structure)
|
|
15
|
+
- [JavaScript Initialization](#javascript-initialization)
|
|
16
|
+
- [Basic Usage](#basic-usage)
|
|
17
|
+
- [Filtering](#filtering)
|
|
18
|
+
- [Searching](#searching)
|
|
19
|
+
- [Sorting](#sorting)
|
|
20
|
+
- [Pagination](#pagination)
|
|
21
|
+
- [Advanced Usage](#advanced-usage)
|
|
22
|
+
- [Custom Animation](#custom-animation)
|
|
23
|
+
- [Filter Groups](#filter-groups)
|
|
24
|
+
- [Custom Sorting](#custom-sorting)
|
|
25
|
+
- [URL State Management](#url-state-management)
|
|
26
|
+
- [Components](#components)
|
|
27
|
+
- [Filter System](#filter-system)
|
|
28
|
+
- [Range Filter](#range-filter)
|
|
29
|
+
- [Date Filter](#date-filter)
|
|
30
|
+
- [Search System](#search-system)
|
|
31
|
+
- [Sort System](#sort-system)
|
|
32
|
+
- [Pagination](#pagination-1)
|
|
33
|
+
- [URL Manager](#url-manager)
|
|
34
|
+
- [Styling \& Theming](#styling--theming)
|
|
35
|
+
- [Built-in Themes](#built-in-themes)
|
|
36
|
+
- [Custom Themes](#custom-themes)
|
|
37
|
+
- [Animations](#animations)
|
|
38
|
+
- [Browser Support](#browser-support)
|
|
39
|
+
- [TypeScript Support](#typescript-support)
|
|
40
|
+
- [Contributing](#contributing)
|
|
41
|
+
- [License](#license)
|
|
4
42
|
|
|
5
43
|
## Features
|
|
6
44
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
45
|
+
- 🔍 **Advanced Filtering**
|
|
46
|
+
- Multiple filter types (text, range, date)
|
|
47
|
+
- AND/OR logic
|
|
48
|
+
- Filter groups
|
|
49
|
+
- Dynamic filters
|
|
50
|
+
- 🔎 **Smart Search**
|
|
51
|
+
- Real-time search
|
|
52
|
+
- Multiple fields
|
|
53
|
+
- Highlight matches
|
|
54
|
+
- Minimum character threshold
|
|
55
|
+
- ↕️ **Flexible Sorting**
|
|
56
|
+
- Multi-column sort
|
|
57
|
+
- Custom comparators
|
|
58
|
+
- Auto-detect data types
|
|
59
|
+
- 📄 **Pagination**
|
|
60
|
+
- Dynamic page size
|
|
61
|
+
- Custom controls
|
|
62
|
+
- Scroll to top
|
|
63
|
+
- 🔗 **URL Management**
|
|
64
|
+
- State persistence
|
|
65
|
+
- Browser history support
|
|
66
|
+
- Shareable URLs
|
|
67
|
+
- ⚡ **Performance**
|
|
68
|
+
- Debounced updates
|
|
69
|
+
- Efficient DOM manipulation
|
|
70
|
+
- Minimal reflows
|
|
71
|
+
- 🎨 **Rich Animation**
|
|
72
|
+
- 15+ built-in animations
|
|
73
|
+
- Custom transitions
|
|
74
|
+
- Hardware acceleration
|
|
75
|
+
- 💾 **State Management**
|
|
76
|
+
- Centralized state
|
|
77
|
+
- Import/Export
|
|
78
|
+
- Undo/Redo support
|
|
79
|
+
- 🎯 **Event System**
|
|
80
|
+
- Rich event API
|
|
81
|
+
- Custom events
|
|
82
|
+
- Event debugging
|
|
31
83
|
|
|
32
84
|
## Installation
|
|
33
85
|
|
|
34
|
-
### Via npm
|
|
35
|
-
|
|
36
86
|
```bash
|
|
87
|
+
# NPM
|
|
37
88
|
npm install advanced-filter-system
|
|
38
|
-
```
|
|
39
89
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```bash
|
|
90
|
+
# Yarn
|
|
43
91
|
yarn add advanced-filter-system
|
|
92
|
+
|
|
93
|
+
# PNPM
|
|
94
|
+
pnpm add advanced-filter-system
|
|
44
95
|
```
|
|
45
96
|
|
|
46
|
-
|
|
97
|
+
Or include via CDN:
|
|
47
98
|
|
|
48
|
-
|
|
99
|
+
```html
|
|
100
|
+
<script src="https://unpkg.com/advanced-filter-system@1.0.6/dist/afs.min.js"></script>
|
|
101
|
+
<link rel="stylesheet" href="https://unpkg.com/advanced-filter-system@1.0.6/dist/afs.min.css">
|
|
102
|
+
```
|
|
49
103
|
|
|
50
|
-
##
|
|
104
|
+
## Quick Start
|
|
51
105
|
|
|
52
|
-
###
|
|
106
|
+
### HTML Structure
|
|
53
107
|
|
|
54
108
|
```html
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
109
|
+
<!DOCTYPE html>
|
|
110
|
+
<html>
|
|
111
|
+
<head>
|
|
112
|
+
<title>AFS Demo</title>
|
|
113
|
+
<link rel="stylesheet" href="https://unpkg.com/advanced-filter-system@1.0.6/dist/afs.min.css">
|
|
114
|
+
</head>
|
|
115
|
+
<body>
|
|
116
|
+
<!-- Counter -->
|
|
117
|
+
<div class="filter-counter"></div>
|
|
62
118
|
|
|
63
|
-
<!--
|
|
119
|
+
<!-- Search -->
|
|
64
120
|
<input type="text" class="filter-search" placeholder="Search...">
|
|
65
|
-
|
|
121
|
+
|
|
122
|
+
<!-- Filter Buttons -->
|
|
123
|
+
<div class="filter-buttons">
|
|
124
|
+
<button class="btn-filter" data-filter="all">All</button>
|
|
125
|
+
<button class="btn-filter" data-filter="category1">Category 1</button>
|
|
126
|
+
<button class="btn-filter" data-filter="category2">Category 2</button>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<!-- Sort Buttons -->
|
|
130
|
+
<div class="sort-buttons">
|
|
131
|
+
<button class="btn-sort" data-sort-key="price">
|
|
132
|
+
Price <span class="sort-direction">↑</span>
|
|
133
|
+
</button>
|
|
134
|
+
<button class="btn-sort" data-sort-key="date">
|
|
135
|
+
Date <span class="sort-direction">↑</span>
|
|
136
|
+
</button>
|
|
137
|
+
</div>
|
|
66
138
|
|
|
67
|
-
<!--
|
|
68
|
-
<div
|
|
139
|
+
<!-- Range Filter -->
|
|
140
|
+
<div id="price-range"></div>
|
|
141
|
+
|
|
142
|
+
<!-- Date Filter -->
|
|
143
|
+
<div id="date-filter"></div>
|
|
144
|
+
|
|
145
|
+
<!-- Items Container -->
|
|
146
|
+
<div id="items-container">
|
|
69
147
|
<div class="filter-item"
|
|
70
|
-
data-categories="
|
|
71
|
-
data-
|
|
72
|
-
data-
|
|
73
|
-
data-
|
|
74
|
-
|
|
148
|
+
data-categories="category1"
|
|
149
|
+
data-price="99.99"
|
|
150
|
+
data-date="2024-03-15"
|
|
151
|
+
data-title="Item 1"
|
|
152
|
+
data-description="Description for item 1">
|
|
153
|
+
<h3>Item 1</h3>
|
|
154
|
+
<p>$99.99</p>
|
|
155
|
+
<p>March 15, 2024</p>
|
|
75
156
|
</div>
|
|
157
|
+
<!-- More items... -->
|
|
76
158
|
</div>
|
|
77
|
-
|
|
159
|
+
|
|
160
|
+
<!-- Pagination -->
|
|
161
|
+
<div class="pagination-container"></div>
|
|
162
|
+
|
|
163
|
+
<!-- Scripts -->
|
|
164
|
+
<script src="https://unpkg.com/advanced-filter-system@1.0.6/dist/afs.min.js"></script>
|
|
165
|
+
<script>
|
|
166
|
+
const afs = AFS.createAFS({
|
|
167
|
+
containerSelector: '#items-container',
|
|
168
|
+
itemSelector: '.filter-item',
|
|
169
|
+
searchInputSelector: '.filter-search',
|
|
170
|
+
filterButtonSelector: '.btn-filter',
|
|
171
|
+
sortButtonSelector: '.btn-sort',
|
|
172
|
+
counterSelector: '.filter-counter',
|
|
173
|
+
debug: true,
|
|
174
|
+
responsive: true,
|
|
175
|
+
preserveState: true,
|
|
176
|
+
animation: {
|
|
177
|
+
type: 'fade',
|
|
178
|
+
duration: 300
|
|
179
|
+
},
|
|
180
|
+
pagination: {
|
|
181
|
+
enabled: true,
|
|
182
|
+
itemsPerPage: 10
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// Add range filter
|
|
187
|
+
afs.rangeFilter.addRangeSlider({
|
|
188
|
+
key: 'price',
|
|
189
|
+
container: document.querySelector('#price-range'),
|
|
190
|
+
min: 0,
|
|
191
|
+
max: 1000,
|
|
192
|
+
step: 10
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Add date filter
|
|
196
|
+
afs.dateFilter.addDateRange({
|
|
197
|
+
key: 'date',
|
|
198
|
+
container: document.querySelector('#date-filter')
|
|
199
|
+
});
|
|
200
|
+
</script>
|
|
201
|
+
</body>
|
|
202
|
+
</html>
|
|
78
203
|
```
|
|
79
204
|
|
|
80
|
-
###
|
|
205
|
+
### JavaScript Initialization
|
|
206
|
+
|
|
207
|
+
Using ES modules:
|
|
81
208
|
|
|
82
209
|
```javascript
|
|
83
|
-
import {
|
|
210
|
+
import { createAFS } from 'advanced-filter-system';
|
|
84
211
|
|
|
85
|
-
const
|
|
86
|
-
containerSelector: '
|
|
212
|
+
const afs = createAFS({
|
|
213
|
+
containerSelector: '#items-container',
|
|
87
214
|
itemSelector: '.filter-item',
|
|
88
|
-
|
|
215
|
+
debug: true,
|
|
216
|
+
animation: {
|
|
217
|
+
type: 'fade',
|
|
218
|
+
duration: 300
|
|
219
|
+
}
|
|
89
220
|
});
|
|
90
221
|
```
|
|
91
222
|
|
|
92
|
-
##
|
|
223
|
+
## Basic Usage
|
|
93
224
|
|
|
94
|
-
###
|
|
225
|
+
### Filtering
|
|
95
226
|
|
|
96
227
|
```javascript
|
|
97
|
-
//
|
|
98
|
-
filter
|
|
99
|
-
filter
|
|
228
|
+
// HTML
|
|
229
|
+
<button class="btn-filter" data-filter="category1">Category 1</button>
|
|
230
|
+
<button class="btn-filter" data-filter="category2">Category 2</button>
|
|
100
231
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 2. Filter Groups
|
|
232
|
+
<div class="filter-item" data-categories="category1,category2">
|
|
233
|
+
Item content
|
|
234
|
+
</div>
|
|
107
235
|
|
|
108
|
-
|
|
236
|
+
// JavaScript
|
|
237
|
+
// Set filter mode
|
|
238
|
+
afs.filter.setFilterMode('AND'); // or 'OR'
|
|
109
239
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
filter.addFilterGroup('categories', ['category:tech', 'category:web'], 'OR');
|
|
113
|
-
filter.addFilterGroup('price', ['price:low', 'price:medium'], 'AND');
|
|
240
|
+
// Add filter programmatically
|
|
241
|
+
afs.filter.addFilter('category1');
|
|
114
242
|
|
|
115
|
-
//
|
|
116
|
-
filter.
|
|
117
|
-
filter.setGroupMode('OR'); // Items must match any group
|
|
243
|
+
// Remove filter
|
|
244
|
+
afs.filter.removeFilter('category1');
|
|
118
245
|
|
|
119
|
-
//
|
|
120
|
-
filter.
|
|
246
|
+
// Clear all filters
|
|
247
|
+
afs.filter.clearAllFilters();
|
|
121
248
|
```
|
|
122
249
|
|
|
123
|
-
###
|
|
250
|
+
### Searching
|
|
124
251
|
|
|
125
252
|
```javascript
|
|
253
|
+
// HTML
|
|
254
|
+
<input type="text" class="filter-search">
|
|
255
|
+
<div class="filter-item"
|
|
256
|
+
data-title="Product Name"
|
|
257
|
+
data-description="Product description">
|
|
258
|
+
Item content
|
|
259
|
+
</div>
|
|
260
|
+
|
|
261
|
+
// JavaScript
|
|
126
262
|
// Configure search
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
263
|
+
afs.search.updateConfig({
|
|
264
|
+
searchKeys: ['title', 'description'],
|
|
265
|
+
minSearchLength: 2,
|
|
266
|
+
highlightMatches: true,
|
|
267
|
+
debounceTime: 300
|
|
131
268
|
});
|
|
132
269
|
|
|
133
|
-
//
|
|
134
|
-
|
|
270
|
+
// Perform search programmatically
|
|
271
|
+
afs.search.search('query');
|
|
272
|
+
|
|
273
|
+
// Clear search
|
|
274
|
+
afs.search.clearSearch();
|
|
135
275
|
```
|
|
136
276
|
|
|
137
|
-
###
|
|
277
|
+
### Sorting
|
|
138
278
|
|
|
139
279
|
```javascript
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
{ key: 'title', direction: 'asc' }
|
|
144
|
-
]);
|
|
280
|
+
// HTML
|
|
281
|
+
<button class="btn-sort" data-sort-key="price">Sort by Price</button>
|
|
282
|
+
<button class="btn-sort" data-sort-key="date">Sort by Date</button>
|
|
145
283
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
### 5. Range Filtering
|
|
284
|
+
<div class="filter-item" data-price="99.99" data-date="2024-03-15">
|
|
285
|
+
Item content
|
|
286
|
+
</div>
|
|
151
287
|
|
|
152
|
-
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
```
|
|
288
|
+
// JavaScript
|
|
289
|
+
// Basic sort
|
|
290
|
+
afs.sort.sort('price', 'asc');
|
|
156
291
|
|
|
157
|
-
|
|
292
|
+
// Multiple criteria sort
|
|
293
|
+
afs.sort.sortMultiple([
|
|
294
|
+
{ key: 'category', direction: 'asc' },
|
|
295
|
+
{ key: 'price', direction: 'desc' }
|
|
296
|
+
]);
|
|
158
297
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
filter.setPagination(12); // 12 items per page
|
|
298
|
+
// Reset sort
|
|
299
|
+
afs.sort.reset();
|
|
162
300
|
```
|
|
163
301
|
|
|
164
|
-
###
|
|
302
|
+
### Pagination
|
|
165
303
|
|
|
166
304
|
```javascript
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
|
|
305
|
+
// HTML
|
|
306
|
+
<div class="pagination-container"></div>
|
|
307
|
+
|
|
308
|
+
// JavaScript
|
|
309
|
+
// Configure pagination
|
|
310
|
+
const afs = createAFS({
|
|
311
|
+
pagination: {
|
|
312
|
+
enabled: true,
|
|
313
|
+
itemsPerPage: 10,
|
|
314
|
+
maxButtons: 7,
|
|
315
|
+
showPrevNext: true,
|
|
316
|
+
scrollToTop: true
|
|
317
|
+
}
|
|
318
|
+
});
|
|
170
319
|
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
filter.importState(state);
|
|
320
|
+
// Navigate pages
|
|
321
|
+
afs.pagination.goToPage(2);
|
|
174
322
|
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
|
|
323
|
+
// Change items per page
|
|
324
|
+
afs.pagination.setItemsPerPage(20);
|
|
325
|
+
|
|
326
|
+
// Get pagination info
|
|
327
|
+
const info = afs.pagination.getPageInfo();
|
|
178
328
|
```
|
|
179
329
|
|
|
180
|
-
|
|
330
|
+
## Advanced Usage
|
|
331
|
+
|
|
332
|
+
### Custom Animation
|
|
181
333
|
|
|
182
334
|
```javascript
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
335
|
+
// Custom animation configuration
|
|
336
|
+
const afs = createAFS({
|
|
337
|
+
animation: {
|
|
338
|
+
type: 'custom',
|
|
339
|
+
duration: 500,
|
|
340
|
+
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
341
|
+
inClass: 'my-enter',
|
|
342
|
+
outClass: 'my-leave'
|
|
343
|
+
}
|
|
186
344
|
});
|
|
345
|
+
|
|
346
|
+
// CSS
|
|
347
|
+
.my-enter {
|
|
348
|
+
opacity: 0;
|
|
349
|
+
transform: scale(0.9);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.my-enter.my-enter-active {
|
|
353
|
+
opacity: 1;
|
|
354
|
+
transform: scale(1);
|
|
355
|
+
transition: opacity 500ms cubic-bezier(0.4, 0, 0.2, 1),
|
|
356
|
+
transform 500ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.my-leave {
|
|
360
|
+
opacity: 1;
|
|
361
|
+
transform: scale(1);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.my-leave.my-leave-active {
|
|
365
|
+
opacity: 0;
|
|
366
|
+
transform: scale(0.9);
|
|
367
|
+
transition: opacity 500ms cubic-bezier(0.4, 0, 0.2, 1),
|
|
368
|
+
transform 500ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
369
|
+
}
|
|
187
370
|
```
|
|
188
371
|
|
|
189
|
-
###
|
|
372
|
+
### Filter Groups
|
|
190
373
|
|
|
191
374
|
```javascript
|
|
192
|
-
filter
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
375
|
+
// Create filter groups with different operators
|
|
376
|
+
afs.filter.addFilterGroup('price', {
|
|
377
|
+
ranges: [[0, 100], [101, 500], [501, 1000]],
|
|
378
|
+
operator: 'OR'
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
afs.filter.addFilterGroup('categories', {
|
|
382
|
+
filters: ['electronics', 'books'],
|
|
383
|
+
operator: 'AND'
|
|
201
384
|
});
|
|
385
|
+
|
|
386
|
+
// Set group mode
|
|
387
|
+
afs.filter.setGroupMode('AND');
|
|
388
|
+
|
|
389
|
+
// Remove group
|
|
390
|
+
afs.filter.removeFilterGroup('price');
|
|
202
391
|
```
|
|
203
392
|
|
|
204
|
-
###
|
|
393
|
+
### Custom Sorting
|
|
205
394
|
|
|
206
395
|
```javascript
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
396
|
+
// Custom comparator for special sorting needs
|
|
397
|
+
afs.sort.sortWithComparator('title', (a, b) => {
|
|
398
|
+
// Sort by last word
|
|
399
|
+
const getLastWord = str => str.split(' ').pop();
|
|
400
|
+
const lastA = getLastWord(a);
|
|
401
|
+
const lastB = getLastWord(b);
|
|
402
|
+
return lastA.localeCompare(lastB);
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// Sort with multiple languages
|
|
406
|
+
afs.sort.sortWithComparator('title', (a, b) => {
|
|
407
|
+
return a.localeCompare(b, 'es', {
|
|
408
|
+
sensitivity: 'base',
|
|
409
|
+
numeric: true
|
|
410
|
+
});
|
|
210
411
|
});
|
|
211
412
|
```
|
|
212
413
|
|
|
213
|
-
###
|
|
414
|
+
### URL State Management
|
|
214
415
|
|
|
215
416
|
```javascript
|
|
216
|
-
|
|
217
|
-
|
|
417
|
+
// Enable URL state
|
|
418
|
+
const afs = createAFS({
|
|
419
|
+
urlStateEnabled: true,
|
|
420
|
+
urlStateKey: 'filter'
|
|
218
421
|
});
|
|
219
|
-
```
|
|
220
422
|
|
|
221
|
-
|
|
423
|
+
// Handle state changes
|
|
424
|
+
afs.on('urlStateLoaded', (state) => {
|
|
425
|
+
console.log('State loaded:', state);
|
|
426
|
+
});
|
|
222
427
|
|
|
223
|
-
|
|
224
|
-
|
|
428
|
+
// Manual control
|
|
429
|
+
afs.urlManager.updateURL();
|
|
430
|
+
afs.urlManager.loadFromURL();
|
|
431
|
+
afs.urlManager.clearURL();
|
|
432
|
+
|
|
433
|
+
// Get specific parameter
|
|
434
|
+
const searchQuery = afs.urlManager.getParam('search');
|
|
225
435
|
```
|
|
226
436
|
|
|
227
|
-
|
|
437
|
+
## Components
|
|
228
438
|
|
|
229
|
-
|
|
230
|
-
filter.sortWithComparator('price', (a, b) => parseFloat(a) - parseFloat(b), 'asc');
|
|
439
|
+
Each component can be used independently or as part of the AFS system.
|
|
231
440
|
|
|
232
|
-
|
|
441
|
+
### Filter System
|
|
442
|
+
See [Filter Documentation](docs/filter.md)
|
|
233
443
|
|
|
234
|
-
|
|
235
|
-
|
|
444
|
+
### Range Filter
|
|
445
|
+
See [Range Filter Documentation](docs/range-filter.md)
|
|
236
446
|
|
|
237
|
-
###
|
|
447
|
+
### Date Filter
|
|
448
|
+
See [Date Filter Documentation](docs/date-filter.md)
|
|
238
449
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
450
|
+
### Search System
|
|
451
|
+
See [Search Documentation](docs/search.md)
|
|
452
|
+
|
|
453
|
+
### Sort System
|
|
454
|
+
See [Sort Documentation](docs/sort.md)
|
|
455
|
+
|
|
456
|
+
### Pagination
|
|
457
|
+
See [Pagination Documentation](docs/pagination.md)
|
|
242
458
|
|
|
243
|
-
|
|
459
|
+
### URL Manager
|
|
460
|
+
See [URL Manager Documentation](docs/url-manager.md)
|
|
244
461
|
|
|
245
|
-
|
|
246
|
-
- ✅ Firefox
|
|
247
|
-
- ✅ Safari
|
|
248
|
-
- ✅ Edge
|
|
249
|
-
- ✅ IE11 (with polyfills)
|
|
462
|
+
## Styling & Theming
|
|
250
463
|
|
|
251
|
-
|
|
464
|
+
### Built-in Themes
|
|
252
465
|
|
|
253
466
|
```javascript
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
counterSelector: '.filter-counter',
|
|
263
|
-
activeClass: 'active',
|
|
264
|
-
hiddenClass: 'hidden',
|
|
265
|
-
animationDuration: 300,
|
|
266
|
-
filterMode: 'OR',
|
|
267
|
-
searchKeys: ['title'],
|
|
268
|
-
debounceTime: 300,
|
|
269
|
-
debug: false, // Enable console logs
|
|
270
|
-
logLevel: 'info', // 'info', 'warn', 'error', 'debug'
|
|
467
|
+
const afs = createAFS({
|
|
468
|
+
styles: {
|
|
469
|
+
colors: {
|
|
470
|
+
primary: '#3b82f6',
|
|
471
|
+
background: '#f3f4f6',
|
|
472
|
+
text: '#1f2937'
|
|
473
|
+
}
|
|
474
|
+
}
|
|
271
475
|
});
|
|
272
476
|
```
|
|
273
477
|
|
|
274
|
-
|
|
478
|
+
### Custom Themes
|
|
275
479
|
|
|
276
|
-
|
|
480
|
+
```javascript
|
|
481
|
+
const afs = createAFS({
|
|
482
|
+
styles: {
|
|
483
|
+
colors: {
|
|
484
|
+
primary: '#custom-color',
|
|
485
|
+
background: '#custom-bg',
|
|
486
|
+
text: '#custom-text'
|
|
487
|
+
},
|
|
488
|
+
components: {
|
|
489
|
+
button: {
|
|
490
|
+
borderRadius: '8px',
|
|
491
|
+
padding: '8px 16px'
|
|
492
|
+
},
|
|
493
|
+
input: {
|
|
494
|
+
borderWidth: '2px',
|
|
495
|
+
focusRing: '3px'
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
```
|
|
277
501
|
|
|
278
|
-
|
|
279
|
-
- `removeFilter(type, value)`
|
|
280
|
-
- `getActiveFiltersByType(type)`
|
|
281
|
-
- `setFilterMode(mode)`
|
|
282
|
-
- `resetFilters()`
|
|
502
|
+
### Animations
|
|
283
503
|
|
|
284
|
-
|
|
504
|
+
```javascript
|
|
505
|
+
const afs = createAFS({
|
|
506
|
+
animation: {
|
|
507
|
+
type: 'fade', // or 'slide', 'scale', etc.
|
|
508
|
+
duration: 300,
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
```
|
|
285
512
|
|
|
286
|
-
|
|
287
|
-
- `removeFilterGroup(groupId)`
|
|
288
|
-
- `setGroupMode(mode)`
|
|
513
|
+
## Browser Support
|
|
289
514
|
|
|
290
|
-
|
|
515
|
+
- Chrome (last 2 versions)
|
|
516
|
+
- Firefox (last 2 versions)
|
|
517
|
+
- Safari (last 2 versions)
|
|
518
|
+
- Edge (last 2 versions)
|
|
519
|
+
- iOS Safari (last 2 versions)
|
|
520
|
+
- Android Chrome (last 2 versions)
|
|
291
521
|
|
|
292
|
-
|
|
293
|
-
- `sortMultiple(criteria)`
|
|
294
|
-
- `sortWithComparator(key, comparator)`
|
|
295
|
-
- `addRangeFilter(key, min, max)`
|
|
296
|
-
- `shuffle()`
|
|
297
|
-
- `sortWithOrder(key)`
|
|
522
|
+
Required browser features:
|
|
298
523
|
|
|
299
|
-
|
|
524
|
+
- CSS Transitions
|
|
525
|
+
- Flexbox
|
|
526
|
+
- CSS Grid (optional)
|
|
527
|
+
- History API
|
|
528
|
+
- localStorage
|
|
529
|
+
- MutationObserver
|
|
300
530
|
|
|
301
|
-
|
|
302
|
-
- `importState(state)`
|
|
303
|
-
- `savePreset(presetName)`
|
|
304
|
-
- `loadPreset(presetName)`
|
|
531
|
+
## TypeScript Support
|
|
305
532
|
|
|
306
|
-
|
|
533
|
+
Full TypeScript support with type definitions included:
|
|
307
534
|
|
|
308
|
-
|
|
309
|
-
-
|
|
310
|
-
- `setResponsiveOptions(breakpoints)`
|
|
311
|
-
- `enableKeyboardNavigation()`
|
|
535
|
+
```typescript
|
|
536
|
+
import { createAFS, AFSOptions } from 'advanced-filter-system';
|
|
312
537
|
|
|
313
|
-
|
|
538
|
+
const options: AFSOptions = {
|
|
539
|
+
containerSelector: '#items-container',
|
|
540
|
+
itemSelector: '.filter-item'
|
|
541
|
+
};
|
|
314
542
|
|
|
315
|
-
|
|
316
|
-
|
|
543
|
+
const afs = createAFS(options);
|
|
544
|
+
```
|
|
317
545
|
|
|
318
546
|
## Contributing
|
|
319
547
|
|
|
320
|
-
|
|
548
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on:
|
|
549
|
+
|
|
550
|
+
1. Setting up the development environment
|
|
551
|
+
2. Coding standards
|
|
552
|
+
3. Pull request process
|
|
553
|
+
4. Bug reporting
|
|
554
|
+
5. Feature requests
|
|
321
555
|
|
|
322
556
|
## License
|
|
323
557
|
|
|
324
|
-
MIT License -
|
|
558
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
559
|
+
|
|
560
|
+
---
|
|
561
|
+
|
|
562
|
+
Made with ♥ by [misits](https://github.com/misits)
|