@shefing/quickfilter 1.0.13 → 1.0.17
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/LICENSE +201 -0
- package/README.md +53 -421
- package/dist/QuickFilter.d.ts.map +1 -1
- package/dist/QuickFilter.js +8 -1
- package/dist/QuickFilter.js.map +1 -1
- package/dist/filters/constants/date-filter-options.d.ts +2 -2
- package/dist/filters/constants/date-filter-options.d.ts.map +1 -1
- package/dist/filters/constants/date-filter-options.js +6 -2
- package/dist/filters/constants/date-filter-options.js.map +1 -1
- package/dist/filters/utils/date-helpers.d.ts.map +1 -1
- package/dist/filters/utils/date-helpers.js +30 -2
- package/dist/filters/utils/date-helpers.js.map +1 -1
- package/dist/labels.d.ts +72 -24
- package/dist/labels.d.ts.map +1 -1
- package/dist/labels.js +36 -12
- package/dist/labels.js.map +1 -1
- package/package.json +42 -35
package/README.md
CHANGED
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
Transform your PayloadCMS admin experience with instant, intuitive filters that appear right where you need them. Say goodbye to clunky filter forms and hello to seamless data exploration!
|
|
6
6
|
|
|
7
|
-

|
|
8
|
-
_See QuickFilter in action - filtering happens instantly as you click!_
|
|
9
|
-
|
|
10
7
|
## ✨ Features
|
|
11
8
|
|
|
12
9
|
| Feature | Description | Icon |
|
|
@@ -17,49 +14,50 @@ _See QuickFilter in action - filtering happens instantly as you click!_
|
|
|
17
14
|
| **🌍 Internationalization** | Full i18n support with RTL language compatibility |  |
|
|
18
15
|
| **💾 Persistent State** | Filters persist in localStorage and URL parameters |  |
|
|
19
16
|
| **📅 Smart Date Filtering** | Predefined ranges + custom date picker |  |
|
|
20
|
-
| **♿ Accessibility** | Full keyboard navigation and screen reader support |  |
|
|
21
17
|
|
|
22
18
|
### 🎥 See It In Action
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
<summary>📸 Click to view screenshots</summary>
|
|
26
|
-
|
|
27
|
-
#### Collapsed State
|
|
28
|
-
|
|
29
|
-

|
|
30
|
-
_Clean, minimal button that shows active filter count_
|
|
31
|
-
|
|
32
|
-
#### Expanded State
|
|
33
|
-
|
|
34
|
-

|
|
35
|
-
_All your filters laid out beautifully in customizable rows_
|
|
36
|
-
|
|
37
|
-
#### Date Filter Options
|
|
20
|
+
[Video placeholder]
|
|
38
21
|
|
|
39
|
-
|
|
40
|
-
_Smart date presets + custom range picker_
|
|
22
|
+
---
|
|
41
23
|
|
|
42
|
-
|
|
24
|
+
### 📋 Requirements
|
|
43
25
|
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
- ✅ PayloadCMS 3.0+
|
|
27
|
+
- ✅ React 18+
|
|
28
|
+
- ✅ TypeScript (recommended)
|
|
29
|
+
- ✅ Tailwind CSS (for styling)
|
|
46
30
|
|
|
47
|
-
|
|
31
|
+
> 🚨 **Important**: Make sure your project has Tailwind CSS configured, as the plugin uses Tailwind classes for styling.
|
|
32
|
+
> Add the following path to your tailwind.config.js under the content array:
|
|
48
33
|
|
|
49
|
-
|
|
34
|
+
```ts
|
|
35
|
+
// tailwind.config.js
|
|
50
36
|
|
|
51
|
-
|
|
37
|
+
module.exports = {
|
|
38
|
+
content: [
|
|
39
|
+
'./src/**/*.{js,ts,jsx,tsx}', // your app paths
|
|
40
|
+
'./node_modules/@shefing/quickfilter/**/*.{js,ts,jsx,tsx}', // ✅ required for QuickFilter
|
|
41
|
+
],
|
|
42
|
+
// ...rest of your config
|
|
43
|
+
// Here we scope the Tailwind not to intefere with the Admin UI
|
|
44
|
+
plugins: [
|
|
45
|
+
scopedPreflightStyles({
|
|
46
|
+
isolationStrategy: isolateInsideOfContainer(['.useTw']),
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
```
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
---
|
|
54
53
|
|
|
55
|
-
### Quick Start (2 minutes!)
|
|
54
|
+
### ⚡ Quick Start (2 minutes!)
|
|
56
55
|
|
|
57
56
|
<details>
|
|
58
|
-
<summary>📦 Step 1:
|
|
57
|
+
<summary>📦 Step 1: Install the Package</summary>
|
|
59
58
|
|
|
60
59
|
```bash
|
|
61
|
-
|
|
62
|
-
cp -r quickfilter/ your-project/src/plugins/
|
|
60
|
+
pnpm add @shefing/quickfilter
|
|
63
61
|
```
|
|
64
62
|
|
|
65
63
|
</details>
|
|
@@ -67,47 +65,45 @@ cp -r quickfilter/ your-project/src/plugins/
|
|
|
67
65
|
<details>
|
|
68
66
|
<summary>⚙️ Step 2: Configure PayloadCMS</summary>
|
|
69
67
|
|
|
70
|
-
```
|
|
71
|
-
|
|
68
|
+
```ts
|
|
69
|
+
// payload.config.ts
|
|
70
|
+
|
|
71
|
+
import { CollectionQuickFilterPlugin } from '@shefing/quickfilter';
|
|
72
72
|
|
|
73
73
|
export default buildConfig({
|
|
74
|
-
plugins: [
|
|
75
|
-
CollectionQuickFilterPlugin({
|
|
76
|
-
disabled: false, // 🎛️ Optional: disable the plugin
|
|
77
|
-
}),
|
|
78
|
-
],
|
|
79
|
-
// ... rest of your config
|
|
74
|
+
plugins: [CollectionQuickFilterPlugin({})],
|
|
80
75
|
});
|
|
81
76
|
```
|
|
82
77
|
|
|
83
78
|
</details>
|
|
84
79
|
|
|
85
80
|
<details>
|
|
86
|
-
<summary
|
|
81
|
+
<summary>⚙️ Step 3: Configure Collections</summary>
|
|
87
82
|
|
|
88
83
|
```typescript
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
[
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
export const Users: CollectionConfig = {
|
|
85
|
+
slug: 'users',
|
|
86
|
+
custom: {
|
|
87
|
+
filterList: [
|
|
88
|
+
['status', 'role'], // First row with two filters
|
|
89
|
+
['createdAt'], // Second row with one filter
|
|
90
|
+
[
|
|
91
|
+
{ name: 'department', width: '300px' }, // Custom width
|
|
92
|
+
'isActive',
|
|
93
|
+
],
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
// ... rest of your collection config
|
|
97
|
+
};
|
|
95
98
|
```
|
|
96
99
|
|
|
97
100
|
</details>
|
|
98
101
|
|
|
99
|
-
|
|
102
|
+
---
|
|
100
103
|
|
|
101
|
-
- ✅ PayloadCMS 2.0+
|
|
102
|
-
- ✅ React 18+
|
|
103
|
-
- ✅ TypeScript (recommended)
|
|
104
|
-
- ✅ Tailwind CSS (for styling)
|
|
105
104
|
|
|
106
|
-
> 🚨 **Important**: Make sure your project has Tailwind CSS configured, as the plugin uses Tailwind classes for styling.
|
|
107
105
|
|
|
108
|
-
## ⚙️ Configuration
|
|
109
|
-
|
|
110
|
-
### 🎯 Basic Setup
|
|
106
|
+
## ⚙️ Collections Configuration
|
|
111
107
|
|
|
112
108
|
Transform any collection into a filtering powerhouse! Just add a `filterList` to your collection's `custom` property:
|
|
113
109
|
|
|
@@ -294,34 +290,6 @@ The magic happens right above your collection table! Here's what your users will
|
|
|
294
290
|
|
|
295
291
|
### 🎯 Filter Types in Detail
|
|
296
292
|
|
|
297
|
-
<details>
|
|
298
|
-
<summary>📅 <strong>Date Filter</strong> - Time travel made easy!</summary>
|
|
299
|
-
|
|
300
|
-
**🚀 Predefined Magic:**
|
|
301
|
-
|
|
302
|
-
```typescript
|
|
303
|
-
🕐 Past Options:
|
|
304
|
-
├── Yesterday
|
|
305
|
-
├── Last Week
|
|
306
|
-
├── Last Month
|
|
307
|
-
└── All Past
|
|
308
|
-
|
|
309
|
-
🔮 Future Options:
|
|
310
|
-
├── Today
|
|
311
|
-
├── Next Week
|
|
312
|
-
├── Next Month
|
|
313
|
-
└── All Future
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
**🎯 Custom Range Power:**
|
|
317
|
-
|
|
318
|
-
- 📅 **From/To picker**: Select any date range
|
|
319
|
-
- 🌍 **Localized**: Dates display in user's format
|
|
320
|
-
- ⚡ **Smart defaults**: Common ranges are just one click away
|
|
321
|
-
|
|
322
|
-

|
|
323
|
-
|
|
324
|
-
</details>
|
|
325
293
|
|
|
326
294
|
<details>
|
|
327
295
|
<summary>📋 <strong>Select Filter</strong> - Intelligence that adapts</summary>
|
|
@@ -343,14 +311,6 @@ The magic happens right above your collection table! Here's what your users will
|
|
|
343
311
|
└─────────────────────────┘
|
|
344
312
|
```
|
|
345
313
|
|
|
346
|
-
**💪 Multi-select Support:**
|
|
347
|
-
|
|
348
|
-
```typescript
|
|
349
|
-
{
|
|
350
|
-
selectedValues: ['published', 'draft'],
|
|
351
|
-
type: 'some' // Shows items matching ANY selected value
|
|
352
|
-
}
|
|
353
|
-
```
|
|
354
314
|
|
|
355
315
|

|
|
356
316
|
|
|
@@ -378,20 +338,6 @@ Perfect for boolean fields like:
|
|
|
378
338
|
|
|
379
339
|
## 🆚 Why Choose QuickFilter Over Regular PayloadCMS Filters?
|
|
380
340
|
|
|
381
|
-
<details>
|
|
382
|
-
<summary>🎯 <strong>Side-by-Side Comparison</strong></summary>
|
|
383
|
-
|
|
384
|
-
| Feature | 🔥 QuickFilter | 😐 Regular Filters |
|
|
385
|
-
| ------------------- | --------------------------------- | ------------------------------ |
|
|
386
|
-
| **Speed** | ⚡ Instant filtering | 🐌 Page reload required |
|
|
387
|
-
| **UX** | 🎨 Beautiful, intuitive UI | 📝 Complex form interface |
|
|
388
|
-
| **Persistence** | 💾 Remembers your filters | 🔄 Resets on refresh |
|
|
389
|
-
| **Visual Feedback** | 👀 Clear active filter indicators | ❓ Hard to see what's filtered |
|
|
390
|
-
| **Mobile** | 📱 Fully responsive | 📱 Limited mobile support |
|
|
391
|
-
| **Accessibility** | ♿ Full keyboard + screen reader | ⚠️ Basic accessibility |
|
|
392
|
-
|
|
393
|
-
</details>
|
|
394
|
-
|
|
395
341
|
### 🚀 **1. User Experience Revolution**
|
|
396
342
|
|
|
397
343
|
<details>
|
|
@@ -404,42 +350,11 @@ Perfect for boolean fields like:
|
|
|
404
350
|
| **💾 Memory** | Filters persist across sessions | Start over every time |
|
|
405
351
|
| **🎯 Simplicity** | Click and filter | Navigate to filter page, fill form, submit |
|
|
406
352
|
|
|
407
|
-

|
|
408
353
|
|
|
409
354
|
</details>
|
|
410
355
|
|
|
411
356
|
### ⚡ **2. Performance That Scales**
|
|
412
357
|
|
|
413
|
-
<details>
|
|
414
|
-
<summary>Technical performance benefits</summary>
|
|
415
|
-
|
|
416
|
-
```typescript
|
|
417
|
-
// 🔥 QuickFilter generates optimized queries
|
|
418
|
-
{
|
|
419
|
-
and: [
|
|
420
|
-
{ status: { in: ['published', 'draft'] } },
|
|
421
|
-
{ createdAt: { greater_than_equal: '2024-01-01' } },
|
|
422
|
-
];
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// 😐 vs manual filter complexity
|
|
426
|
-
// Users struggle with query syntax
|
|
427
|
-
// Multiple server round-trips
|
|
428
|
-
// No client-side optimization
|
|
429
|
-
```
|
|
430
|
-
|
|
431
|
-
**📊 Performance Metrics:**
|
|
432
|
-
|
|
433
|
-
- 🚀 **90% faster** filter application
|
|
434
|
-
- 💾 **50% fewer** server requests
|
|
435
|
-
- 🧠 **Zero learning curve** for end users
|
|
436
|
-
|
|
437
|
-
</details>
|
|
438
|
-
|
|
439
|
-
### ♿ **3. Accessibility First**
|
|
440
|
-
|
|
441
|
-
<details>
|
|
442
|
-
<summary>Built for everyone</summary>
|
|
443
358
|
|
|
444
359
|
**🎯 What we support:**
|
|
445
360
|
|
|
@@ -449,77 +364,9 @@ Perfect for boolean fields like:
|
|
|
449
364
|
- 🎨 **High contrast**: Works with accessibility themes
|
|
450
365
|
- 📱 **Touch friendly**: Perfect for mobile and tablet users
|
|
451
366
|
|
|
452
|
-
**🏆 Compliance:**
|
|
453
|
-
|
|
454
|
-
- ✅ WCAG 2.1 AA compliant
|
|
455
|
-
- ✅ Section 508 compliant
|
|
456
|
-
- ✅ Keyboard-only navigation
|
|
457
|
-
- ✅ Screen reader tested
|
|
458
|
-
|
|
459
|
-
</details>
|
|
460
|
-
|
|
461
|
-
### 👨💻 **4. Developer Experience**
|
|
462
|
-
|
|
463
|
-
<details>
|
|
464
|
-
<summary>Built by developers, for developers</summary>
|
|
465
|
-
|
|
466
|
-
**🔥 What you'll love:**
|
|
467
|
-
|
|
468
|
-
```typescript
|
|
469
|
-
// ✨ Simple configuration
|
|
470
|
-
custom: {
|
|
471
|
-
filterList: [
|
|
472
|
-
['status', 'role'], // That's it!
|
|
473
|
-
];
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// 🚀 vs complex filter setup
|
|
477
|
-
// No custom components needed
|
|
478
|
-
// No backend modifications
|
|
479
|
-
// Full TypeScript support
|
|
480
|
-
// Zero learning curve
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
**🛠️ Developer Benefits:**
|
|
484
|
-
|
|
485
|
-
- 📝 **5-minute setup**: Copy, paste, configure
|
|
486
|
-
- 🔧 **Zero maintenance**: Works with existing fields
|
|
487
|
-
- 🎯 **Type safe**: Full TypeScript integration
|
|
488
|
-
- 🔌 **Extensible**: Easy to add custom filter types
|
|
489
|
-
|
|
490
367
|
</details>
|
|
491
368
|
|
|
492
|
-
### 🌟 **5. Advanced Features**
|
|
493
369
|
|
|
494
|
-
<details>
|
|
495
|
-
<summary>Features that make the difference</summary>
|
|
496
|
-
|
|
497
|
-
**🌍 Multi-language Support:**
|
|
498
|
-
|
|
499
|
-
```typescript
|
|
500
|
-
// Built-in translations for 6 languages
|
|
501
|
-
'en' | 'ar' | 'fr' | 'es' | 'zh' | 'he';
|
|
502
|
-
// RTL support for Arabic and Hebrew
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
**🎨 Custom Layouts:**
|
|
506
|
-
|
|
507
|
-
```typescript
|
|
508
|
-
// Flexible row-based arrangement
|
|
509
|
-
filterList: [
|
|
510
|
-
['status', 'role', 'department'], // 3 in a row
|
|
511
|
-
[{ name: 'tags', width: '400px' }], // Custom width
|
|
512
|
-
['isActive', 'isVerified'], // Side by side
|
|
513
|
-
];
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
**🔗 URL Integration:**
|
|
517
|
-
|
|
518
|
-
- 📋 **Bookmarkable**: Share filtered views via URL
|
|
519
|
-
- 🔄 **Browser history**: Back/forward button support
|
|
520
|
-
- 🔗 **Deep linking**: Direct links to filtered data
|
|
521
|
-
|
|
522
|
-
</details>
|
|
523
370
|
|
|
524
371
|
## 🌍 Internationalization
|
|
525
372
|
|
|
@@ -540,6 +387,7 @@ The plugin speaks your users' language! Full translations included for:
|
|
|
540
387
|
|
|
541
388
|
<details>
|
|
542
389
|
<summary>🌐 <strong>Extend language support</strong></summary>
|
|
390
|
+
PRs are welcomed
|
|
543
391
|
|
|
544
392
|
```typescript
|
|
545
393
|
// In labels.ts, add your language
|
|
@@ -564,30 +412,8 @@ export const PLUGIN_LABELS = {
|
|
|
564
412
|
};
|
|
565
413
|
```
|
|
566
414
|
|
|
567
|
-
**🎯 Pro Tips:**
|
|
568
|
-
|
|
569
|
-
- 🔄 **Auto-detection**: Plugin automatically uses user's browser language
|
|
570
|
-
- 🛡️ **Fallback**: Falls back to English if translation missing
|
|
571
|
-
- 🎨 **RTL Support**: Add `rtlLanguages` array for right-to-left languages
|
|
572
|
-
|
|
573
415
|
</details>
|
|
574
416
|
|
|
575
|
-
### 🎨 RTL Language Demo
|
|
576
|
-
|
|
577
|
-
<details>
|
|
578
|
-
<summary>📸 See RTL support in action</summary>
|
|
579
|
-
|
|
580
|
-

|
|
581
|
-
_Arabic and Hebrew interfaces with proper right-to-left layout_
|
|
582
|
-
|
|
583
|
-
**✨ RTL Features:**
|
|
584
|
-
|
|
585
|
-
- 🔄 **Auto-detection**: Automatically switches to RTL layout
|
|
586
|
-
- 🎯 **Proper alignment**: Text, buttons, and dropdowns align correctly
|
|
587
|
-
- 📱 **Mobile optimized**: RTL works perfectly on mobile devices
|
|
588
|
-
- 🎨 **Icon positioning**: Icons flip to match reading direction
|
|
589
|
-
|
|
590
|
-
</details>
|
|
591
417
|
|
|
592
418
|
## 🔧 Advanced Configuration
|
|
593
419
|
|
|
@@ -649,201 +475,7 @@ CollectionQuickFilterPlugin({
|
|
|
649
475
|
|
|
650
476
|
</details>
|
|
651
477
|
|
|
652
|
-
### 🎨 Custom Styling
|
|
653
|
-
|
|
654
|
-
<details>
|
|
655
|
-
<summary>🎨 <strong>Make it match your brand</strong></summary>
|
|
656
|
-
|
|
657
|
-
```css
|
|
658
|
-
/* Override default styles in your CSS */
|
|
659
|
-
.filter-container {
|
|
660
|
-
--filter-bg: #f8f9fa;
|
|
661
|
-
--filter-border: #e9ecef;
|
|
662
|
-
--filter-text: #495057;
|
|
663
|
-
--filter-active: #007bff;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
/* Custom button styles */
|
|
667
|
-
.filter-container .useTw button {
|
|
668
|
-
border-radius: 8px;
|
|
669
|
-
font-weight: 500;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
/* Active filter highlighting */
|
|
673
|
-
.filter-container .fill-current {
|
|
674
|
-
color: var(--filter-active);
|
|
675
|
-
}
|
|
676
|
-
```
|
|
677
|
-
|
|
678
|
-
**🎨 Customization Options:**
|
|
679
|
-
|
|
680
|
-
- 🎨 **Colors**: Match your admin theme
|
|
681
|
-
- 📐 **Spacing**: Adjust padding and margins
|
|
682
|
-
- 🔤 **Typography**: Custom fonts and sizes
|
|
683
|
-
- 🎯 **Animations**: Add hover effects
|
|
684
|
-
|
|
685
|
-
</details>
|
|
686
|
-
|
|
687
|
-
## 🔧 Troubleshooting
|
|
688
|
-
|
|
689
|
-
### 🚨 Common Issues & Quick Fixes
|
|
690
478
|
|
|
691
|
-
<details>
|
|
692
|
-
<summary>🔍 <strong>Filters not appearing</strong></summary>
|
|
693
|
-
|
|
694
|
-
**❌ Problem:** QuickFilter button doesn't show up
|
|
695
|
-
|
|
696
|
-
**✅ Solutions:**
|
|
697
|
-
|
|
698
|
-
```typescript
|
|
699
|
-
// ✅ Make sure filterList is in custom property
|
|
700
|
-
export const MyCollection = {
|
|
701
|
-
slug: 'my-collection',
|
|
702
|
-
custom: {
|
|
703
|
-
filterList: [['status']], // ← Must be here!
|
|
704
|
-
},
|
|
705
|
-
};
|
|
706
|
-
|
|
707
|
-
// ❌ Wrong - this won't work
|
|
708
|
-
export const MyCollection = {
|
|
709
|
-
slug: 'my-collection',
|
|
710
|
-
filterList: [['status']], // ← Wrong location
|
|
711
|
-
};
|
|
712
|
-
```
|
|
713
|
-
|
|
714
|
-
**🔍 Debug checklist:**
|
|
715
|
-
|
|
716
|
-
- ✅ Plugin is imported and added to config
|
|
717
|
-
- ✅ `filterList` is in `custom` property
|
|
718
|
-
- ✅ Field names match your collection fields
|
|
719
|
-
- ✅ Collection has the fields you're trying to filter
|
|
720
|
-
|
|
721
|
-
</details>
|
|
722
|
-
|
|
723
|
-
<details>
|
|
724
|
-
<summary>📅 <strong>Date filters not working</strong></summary>
|
|
725
|
-
|
|
726
|
-
**❌ Problem:** Date filter shows but doesn't filter results
|
|
727
|
-
|
|
728
|
-
**✅ Solutions:**
|
|
729
|
-
|
|
730
|
-
```typescript
|
|
731
|
-
// ✅ Correct date field configuration
|
|
732
|
-
{
|
|
733
|
-
name: 'createdAt',
|
|
734
|
-
type: 'date' // ← Must be exactly 'date'
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
// ❌ These won't work with date filters
|
|
738
|
-
{
|
|
739
|
-
name: 'createdAt',
|
|
740
|
-
type: 'text' // ← Wrong type
|
|
741
|
-
}
|
|
742
|
-
```
|
|
743
|
-
|
|
744
|
-
**🎯 Pro tip:** Use browser dev tools to check the generated query in Network tab
|
|
745
|
-
|
|
746
|
-
</details>
|
|
747
|
-
|
|
748
|
-
<details>
|
|
749
|
-
<summary>📋 <strong>Select options missing</strong></summary>
|
|
750
|
-
|
|
751
|
-
**❌ Problem:** Select filter is empty or shows no options
|
|
752
|
-
|
|
753
|
-
**✅ Solutions:**
|
|
754
|
-
|
|
755
|
-
```typescript
|
|
756
|
-
// ✅ Correct select field with options
|
|
757
|
-
{
|
|
758
|
-
name: 'status',
|
|
759
|
-
type: 'select',
|
|
760
|
-
options: [ // ← Must have options array
|
|
761
|
-
{ label: 'Active', value: 'active' },
|
|
762
|
-
{ label: 'Inactive', value: 'inactive' }
|
|
763
|
-
]
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
// ❌ Missing options won't work
|
|
767
|
-
{
|
|
768
|
-
name: 'status',
|
|
769
|
-
type: 'select'
|
|
770
|
-
// ← No options array
|
|
771
|
-
}
|
|
772
|
-
```
|
|
773
|
-
|
|
774
|
-
</details>
|
|
775
|
-
|
|
776
|
-
<details>
|
|
777
|
-
<summary>🎨 <strong>Styling issues</strong></summary>
|
|
778
|
-
|
|
779
|
-
**❌ Problem:** Filters look broken or unstyled
|
|
780
|
-
|
|
781
|
-
**✅ Solutions:**
|
|
782
|
-
|
|
783
|
-
1. **Ensure Tailwind CSS is configured:**
|
|
784
|
-
|
|
785
|
-
```javascript
|
|
786
|
-
// tailwind.config.js
|
|
787
|
-
module.exports = {
|
|
788
|
-
content: [
|
|
789
|
-
'./src/**/*.{js,ts,jsx,tsx}',
|
|
790
|
-
'./src/plugins/**/*.{js,ts,jsx,tsx}', // ← Include plugins
|
|
791
|
-
],
|
|
792
|
-
};
|
|
793
|
-
```
|
|
794
|
-
|
|
795
|
-
2. **Check CSS imports:**
|
|
796
|
-
|
|
797
|
-
```typescript
|
|
798
|
-
// Make sure Tailwind is imported in your app
|
|
799
|
-
import 'tailwindcss/tailwind.css';
|
|
800
|
-
```
|
|
801
|
-
|
|
802
|
-
3. **Custom styling conflicts:**
|
|
803
|
-
|
|
804
|
-
```css
|
|
805
|
-
/* If you have custom styles, make sure they don't override */
|
|
806
|
-
.filter-container .useTw {
|
|
807
|
-
/* Plugin styles have priority here */
|
|
808
|
-
}
|
|
809
|
-
```
|
|
810
|
-
|
|
811
|
-
</details>
|
|
812
|
-
|
|
813
|
-
### 🐛 Debug Mode
|
|
814
|
-
|
|
815
|
-
<details>
|
|
816
|
-
<summary>🔍 <strong>Enable detailed logging</strong></summary>
|
|
817
|
-
|
|
818
|
-
**🎯 What to look for in console:**
|
|
819
|
-
|
|
820
|
-
- `[QuickFilter] Loading filters for collection: users`
|
|
821
|
-
- `[QuickFilter] Generated query:` + query object
|
|
822
|
-
- `[QuickFilter] Filter state updated:` + state object
|
|
823
|
-
|
|
824
|
-
</details>
|
|
825
|
-
|
|
826
|
-
### 🆘 Still Having Issues?
|
|
827
|
-
|
|
828
|
-
<details>
|
|
829
|
-
<summary>📞 <strong>Get help</strong></summary>
|
|
830
|
-
|
|
831
|
-
**Before asking for help, please:**
|
|
832
|
-
|
|
833
|
-
1. ✅ **Check the console** for error messages
|
|
834
|
-
2. ✅ **Enable debug mode** and share the logs
|
|
835
|
-
3. ✅ **Verify your configuration** matches the examples
|
|
836
|
-
4. ✅ **Test with a simple setup** first
|
|
837
|
-
|
|
838
|
-
**When reporting issues, include:**
|
|
839
|
-
|
|
840
|
-
- 🔧 Your PayloadCMS version
|
|
841
|
-
- 📋 Your collection configuration
|
|
842
|
-
- 🎯 Your filterList configuration
|
|
843
|
-
- 🐛 Console error messages
|
|
844
|
-
- 📸 Screenshots of the issue
|
|
845
|
-
|
|
846
|
-
</details>
|
|
847
479
|
|
|
848
480
|
## Contributing
|
|
849
481
|
|
|
@@ -856,4 +488,4 @@ The plugin is designed to be extensible. To add new filter types:
|
|
|
856
488
|
|
|
857
489
|
## License
|
|
858
490
|
|
|
859
|
-
This plugin is
|
|
491
|
+
This plugin is licensed under the Apache License, Version 2.0.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickFilter.d.ts","sourceRoot":"","sources":["../src/QuickFilter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"QuickFilter.d.ts","sourceRoot":"","sources":["../src/QuickFilter.tsx"],"names":[],"mappings":"AA2QA,QAAA,MAAM,WAAW,0BAGd;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,CAAC,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,EAAE,CAAC;CAC5D,gCA0SA,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/dist/QuickFilter.js
CHANGED
|
@@ -11,6 +11,13 @@ import { getDateRangeForOption } from './filters/utils/date-helpers';
|
|
|
11
11
|
import { isEqual } from 'lodash';
|
|
12
12
|
import { futureOptionKeys, getDateFilterOptions, pastOptionKeys } from './filters/constants/date-filter-options';
|
|
13
13
|
import { Button } from './ui/button';
|
|
14
|
+
// Helper function to get localized label
|
|
15
|
+
const getLocalizedLabel = (label, locale)=>{
|
|
16
|
+
if (typeof label === 'object' && label !== null) {
|
|
17
|
+
return label[locale] || label['en'] || Object.values(label)[0] || '';
|
|
18
|
+
}
|
|
19
|
+
return label || '';
|
|
20
|
+
};
|
|
14
21
|
// Recursive function to find fields by name
|
|
15
22
|
function findFieldsByName(fields, fieldNames) {
|
|
16
23
|
const results = [];
|
|
@@ -425,7 +432,7 @@ const QuickFilter = ({ slug, filterList })=>{
|
|
|
425
432
|
} else if (selectValue.selectedValues.length === 1) {
|
|
426
433
|
// Show the actual option name when only one is selected
|
|
427
434
|
const selectedOption = field.options?.find((opt)=>opt.value === selectValue.selectedValues[0]);
|
|
428
|
-
const optionLabel = selectedOption ? selectedOption.label : selectValue.selectedValues[0];
|
|
435
|
+
const optionLabel = selectedOption ? getLocalizedLabel(selectedOption.label, locale) : selectValue.selectedValues[0];
|
|
429
436
|
activeFilters.push(`${field.label} (${optionLabel})`);
|
|
430
437
|
} else {
|
|
431
438
|
// Show count for multiple selections
|