advanced-filter-system 1.3.2 → 1.3.4

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 CHANGED
@@ -47,6 +47,7 @@ A powerful and flexible vanilla JavaScript filtering system that provides advanc
47
47
  - AND/OR logic
48
48
  - Filter groups
49
49
  - Dynamic filters
50
+ - Multiple categories per item
50
51
  - 🔎 **Smart Search**
51
52
  - Real-time search
52
53
  - Multiple fields
@@ -69,8 +70,8 @@ A powerful and flexible vanilla JavaScript filtering system that provides advanc
69
70
  - Efficient DOM manipulation
70
71
  - Minimal reflows
71
72
  - 🎨 **Rich Animation**
72
- - 15+ built-in animations
73
- - Custom transitions
73
+ - Smooth transitions
74
+ - Custom animations
74
75
  - Hardware acceleration
75
76
  - 💾 **State Management**
76
77
  - Centralized state
@@ -97,7 +98,7 @@ pnpm add advanced-filter-system
97
98
  Or include via CDN:
98
99
 
99
100
  ```html
100
- <script src="https://unpkg.com/advanced-filter-system@1.3.2/dist/afs.modern.js"></script>
101
+ <script src="https://unpkg.com/advanced-filter-system@latest/dist/afs.modern.js"></script>
101
102
  ```
102
103
 
103
104
  ## Quick Start
@@ -143,7 +144,7 @@ Or include via CDN:
143
144
  <!-- Items Container -->
144
145
  <div id="items-container">
145
146
  <div class="afs-filter-item"
146
- data-categories="category:category1"
147
+ data-categories="category:category1 category:category2"
147
148
  data-price="99.99"
148
149
  data-date="2024-03-15"
149
150
  data-title="Item 1"
@@ -159,7 +160,7 @@ Or include via CDN:
159
160
  <div class="pagination-container"></div>
160
161
 
161
162
  <!-- Scripts -->
162
- <script src="https://unpkg.com/advanced-filter-system@1.3.2/dist/afs.modern.js"></script>
163
+ <script src="https://unpkg.com/advanced-filter-system@latest/dist/afs.modern.js"></script>
163
164
  <script>
164
165
  const afs = AFS.createAFS({
165
166
  containerSelector: '#items-container',
@@ -222,16 +223,28 @@ const afs = createAFS({
222
223
 
223
224
  ### Filtering
224
225
 
225
- ```javascript
226
- // HTML
227
- <button class="afs-btn-filter" data-filter="category:category1">Category 1</button>
228
- <button class="afs-btn-filter" data-filter="category:category2">Category 2</button>
226
+ Multiple categories can be specified using space-separated values in the `data-categories` attribute:
227
+
228
+ ```html
229
+ <!-- Single category -->
230
+ <div class="afs-filter-item" data-categories="category:category1">
231
+ Item content
232
+ </div>
229
233
 
230
- <div class="afs-filter-item" data-categories="category:category1 category:category2">
234
+ <!-- Multiple categories -->
235
+ <div class="afs-filter-item" data-categories="category:category1 category:category2 category:category3">
231
236
  Item content
232
237
  </div>
233
238
 
234
- // JavaScript
239
+ <!-- Multiple filter types -->
240
+ <div class="afs-filter-item" data-categories="category:category1 month:january season:2024">
241
+ Item content
242
+ </div>
243
+ ```
244
+
245
+ JavaScript API:
246
+
247
+ ```javascript
235
248
  // Set filter mode
236
249
  afs.filter.setFilterMode('AND'); // or 'OR'
237
250
 
@@ -248,81 +261,48 @@ afs.filter.clearAllFilters();
248
261
  ### Searching
249
262
 
250
263
  ```javascript
251
- // HTML
252
- <input type="text" class="filter-search">
253
- <div class="afs-filter-item"
254
- data-title="Product Name"
255
- data-description="Product description">
256
- Item content
257
- </div>
258
-
259
- // JavaScript
260
264
  // Configure search
261
- afs.search.updateConfig({
262
- searchKeys: ['title', 'description'],
263
- minSearchLength: 2,
264
- highlightMatches: true,
265
- debounceTime: 300
265
+ afs.search.configure({
266
+ keys: ['title', 'description'],
267
+ minLength: 2,
268
+ debounce: 300
266
269
  });
267
270
 
268
- // Perform search programmatically
271
+ // Search programmatically
269
272
  afs.search.search('query');
270
-
271
- // Clear search
272
- afs.search.clearSearch();
273
273
  ```
274
274
 
275
275
  ### Sorting
276
276
 
277
277
  ```javascript
278
- // HTML
279
- <button class="afs-btn-sort" data-filter="price">Sort by Price</button>
280
- <button class="afs-btn-sort" data-filter="date">Sort by Date</button>
281
-
282
- <div class="afs-filter-item" data-price="99.99" data-date="2024-03-15">
283
- Item content
284
- </div>
285
-
286
- // JavaScript
287
- // Basic sort
278
+ // Single column sort
288
279
  afs.sort.sort('price', 'asc');
289
280
 
290
- // Multiple criteria sort
281
+ // Multiple column sort
291
282
  afs.sort.sortMultiple([
292
283
  { key: 'category', direction: 'asc' },
293
284
  { key: 'price', direction: 'desc' }
294
285
  ]);
295
286
 
296
- // Reset sort
297
- afs.sort.reset();
287
+ // Custom sort
288
+ afs.sort.sortWithComparator('title', (a, b) => {
289
+ return a.localeCompare(b);
290
+ });
298
291
  ```
299
292
 
300
293
  ### Pagination
301
294
 
302
295
  ```javascript
303
- // HTML
304
- <div class="afs-pagination-container"></div>
305
-
306
- // JavaScript
307
296
  // Configure pagination
308
- const afs = createAFS({
309
- pagination: {
310
- enabled: true,
311
- itemsPerPage: 10,
312
- maxButtons: 7,
313
- showPrevNext: true,
314
- scrollToTop: true
315
- }
297
+ afs.pagination.configure({
298
+ itemsPerPage: 10,
299
+ showControls: true
316
300
  });
317
301
 
318
302
  // Navigate pages
319
303
  afs.pagination.goToPage(2);
320
-
321
- // Change items per page
322
- afs.pagination.setItemsPerPage(20);
323
-
324
- // Get pagination info
325
- const info = afs.pagination.getPageInfo();
304
+ afs.pagination.nextPage();
305
+ afs.pagination.previousPage();
326
306
  ```
327
307
 
328
308
  ## Advanced Usage
@@ -330,42 +310,22 @@ const info = afs.pagination.getPageInfo();
330
310
  ### Filter Groups
331
311
 
332
312
  ```javascript
333
- // Create filter groups with different operators
334
- afs.filter.addFilterGroup('price', {
335
- ranges: [[0, 100], [101, 500], [501, 1000]],
313
+ // Create filter group
314
+ afs.filter.createGroup('group1', {
315
+ filters: ['category:category1', 'category:category2'],
336
316
  operator: 'OR'
337
317
  });
338
318
 
339
- afs.filter.addFilterGroup('categories', {
340
- filters: ['electronics', 'books'],
341
- operator: 'AND'
342
- });
343
-
344
319
  // Set group mode
345
- afs.filter.setGroupMode('AND');
346
-
347
- // Remove group
348
- afs.filter.removeFilterGroup('price');
320
+ afs.filter.setGroupMode('AND'); // or 'OR'
349
321
  ```
350
322
 
351
323
  ### Custom Sorting
352
324
 
353
325
  ```javascript
354
- // Custom comparator for special sorting needs
355
- afs.sort.sortWithComparator('title', (a, b) => {
356
- // Sort by last word
357
- const getLastWord = str => str.split(' ').pop();
358
- const lastA = getLastWord(a);
359
- const lastB = getLastWord(b);
360
- return lastA.localeCompare(lastB);
361
- });
362
-
363
- // Sort with multiple languages
364
- afs.sort.sortWithComparator('title', (a, b) => {
365
- return a.localeCompare(b, 'es', {
366
- sensitivity: 'base',
367
- numeric: true
368
- });
326
+ // Custom sort function
327
+ afs.sort.sortWithComparator('price', (a, b) => {
328
+ return parseFloat(a) - parseFloat(b);
369
329
  });
370
330
  ```
371
331
 
@@ -373,23 +333,13 @@ afs.sort.sortWithComparator('title', (a, b) => {
373
333
 
374
334
  ```javascript
375
335
  // Enable URL state
376
- const afs = createAFS({
377
- urlStateEnabled: true,
378
- urlStateKey: 'filter'
379
- });
380
-
381
- // Handle state changes
382
- afs.on('urlStateLoaded', (state) => {
383
- console.log('State loaded:', state);
384
- });
336
+ afs.urlManager.enable();
385
337
 
386
- // Manual control
387
- afs.urlManager.updateURL();
388
- afs.urlManager.loadFromURL();
389
- afs.urlManager.clearURL();
338
+ // Get current state
339
+ const state = afs.urlManager.getState();
390
340
 
391
- // Get specific parameter
392
- const searchQuery = afs.urlManager.getParam('search');
341
+ // Set state
342
+ afs.urlManager.setState(state);
393
343
  ```
394
344
 
395
345
  ## Components
@@ -472,21 +422,11 @@ const afs = createAFS({
472
422
 
473
423
  ## Browser Support
474
424
 
475
- - Chrome (last 2 versions)
476
- - Firefox (last 2 versions)
477
- - Safari (last 2 versions)
478
- - Edge (last 2 versions)
479
- - iOS Safari (last 2 versions)
480
- - Android Chrome (last 2 versions)
481
-
482
- Required browser features:
483
-
484
- - CSS Transitions
485
- - Flexbox
486
- - CSS Grid (optional)
487
- - History API
488
- - localStorage
489
- - MutationObserver
425
+ - Chrome (latest)
426
+ - Firefox (latest)
427
+ - Safari (latest)
428
+ - Edge (latest)
429
+ - Opera (latest)
490
430
 
491
431
  ## TypeScript Support
492
432