@shefing/quickfilter 1.0.11 → 1.0.12
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 +873 -0
- package/dist/FilterField.d.ts.map +1 -1
- package/dist/FilterField.js +18 -9
- package/dist/FilterField.js.map +1 -1
- package/dist/QuickFilter.d.ts.map +1 -1
- package/dist/QuickFilter.js +227 -55
- package/dist/QuickFilter.js.map +1 -1
- package/dist/filters/components/checkbox-filter.d.ts +2 -1
- package/dist/filters/components/checkbox-filter.d.ts.map +1 -1
- package/dist/filters/components/checkbox-filter.js +9 -7
- package/dist/filters/components/checkbox-filter.js.map +1 -1
- package/dist/filters/components/date-filter.d.ts +2 -1
- package/dist/filters/components/date-filter.d.ts.map +1 -1
- package/dist/filters/components/date-filter.js +26 -24
- package/dist/filters/components/date-filter.js.map +1 -1
- package/dist/filters/components/select-filter.d.ts +2 -1
- package/dist/filters/components/select-filter.d.ts.map +1 -1
- package/dist/filters/components/select-filter.js +20 -18
- package/dist/filters/components/select-filter.js.map +1 -1
- package/dist/filters/components/small-select-filter.d.ts +2 -1
- package/dist/filters/components/small-select-filter.d.ts.map +1 -1
- package/dist/filters/components/small-select-filter.js +4 -3
- package/dist/filters/components/small-select-filter.js.map +1 -1
- package/dist/filters/constants/date-filter-options.d.ts +7 -4
- package/dist/filters/constants/date-filter-options.d.ts.map +1 -1
- package/dist/filters/constants/date-filter-options.js +25 -70
- package/dist/filters/constants/date-filter-options.js.map +1 -1
- package/dist/filters/types/filters-type.d.ts.map +1 -1
- package/dist/filters/types/filters-type.js.map +1 -1
- package/dist/filters/utils/date-helpers.d.ts +4 -3
- package/dist/filters/utils/date-helpers.d.ts.map +1 -1
- package/dist/filters/utils/date-helpers.js +14 -11
- package/dist/filters/utils/date-helpers.js.map +1 -1
- package/dist/filters/utils/layout-helpers.d.ts.map +1 -1
- package/dist/filters/utils/layout-helpers.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/labels.d.ts +326 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +192 -0
- package/dist/labels.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,873 @@
|
|
|
1
|
+
# 🚀 QuickFilter Plugin for PayloadCMS
|
|
2
|
+
|
|
3
|
+
> ⚡ **Lightning-fast filtering that your users will love!**
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+

|
|
8
|
+
_See QuickFilter in action - filtering happens instantly as you click!_
|
|
9
|
+
|
|
10
|
+
## ✨ Features
|
|
11
|
+
|
|
12
|
+
| Feature | Description | Icon |
|
|
13
|
+
| ---------------------------- | -------------------------------------------------- | -------------------------------------------------------------------- |
|
|
14
|
+
| **⚡ Instant Filtering** | Apply filters immediately without page reloads |  |
|
|
15
|
+
| **🎛️ Multiple Filter Types** | Date, select, checkbox, and small select filters |  |
|
|
16
|
+
| **📱 Responsive Layout** | Configurable row-based layout with custom widths |  |
|
|
17
|
+
| **🌍 Internationalization** | Full i18n support with RTL language compatibility |  |
|
|
18
|
+
| **💾 Persistent State** | Filters persist in localStorage and URL parameters |  |
|
|
19
|
+
| **📅 Smart Date Filtering** | Predefined ranges + custom date picker |  |
|
|
20
|
+
| **♿ Accessibility** | Full keyboard navigation and screen reader support |  |
|
|
21
|
+
|
|
22
|
+
### 🎥 See It In Action
|
|
23
|
+
|
|
24
|
+
<details>
|
|
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
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
_Smart date presets + custom range picker_
|
|
41
|
+
|
|
42
|
+
#### Multi-Select in Action
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
_Powerful multi-select with search for large datasets_
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
### 🎬 Video Demos
|
|
50
|
+
|
|
51
|
+
> 💡 **Pro Tip**: Record a quick screen capture showing the filters in action and save as `quickfilter-demo.mp4` in the screenshots folder!
|
|
52
|
+
|
|
53
|
+
## 🛠️ Installation
|
|
54
|
+
|
|
55
|
+
### Quick Start (2 minutes!)
|
|
56
|
+
|
|
57
|
+
<details>
|
|
58
|
+
<summary>📦 Step 1: Copy Plugin Files</summary>
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Copy the entire quickfilter directory to your plugins folder
|
|
62
|
+
cp -r quickfilter/ your-project/src/plugins/
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
</details>
|
|
66
|
+
|
|
67
|
+
<details>
|
|
68
|
+
<summary>⚙️ Step 2: Configure PayloadCMS</summary>
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { CollectionQuickFilterPlugin } from './src/plugins/quickfilter/CollectionQuickFilterPlugin';
|
|
72
|
+
|
|
73
|
+
export default buildConfig({
|
|
74
|
+
plugins: [
|
|
75
|
+
CollectionQuickFilterPlugin({
|
|
76
|
+
disabled: false, // 🎛️ Optional: disable the plugin
|
|
77
|
+
}),
|
|
78
|
+
],
|
|
79
|
+
// ... rest of your config
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
</details>
|
|
84
|
+
|
|
85
|
+
<details>
|
|
86
|
+
<summary>🎯 Step 3: Add Filters to Collections</summary>
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// Add this to any collection where you want quick filters
|
|
90
|
+
custom: {
|
|
91
|
+
filterList: [
|
|
92
|
+
['status', 'role'], // 🔥 That's it! Filters are ready
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
</details>
|
|
98
|
+
|
|
99
|
+
### 📋 Requirements
|
|
100
|
+
|
|
101
|
+
- ✅ PayloadCMS 2.0+
|
|
102
|
+
- ✅ React 18+
|
|
103
|
+
- ✅ TypeScript (recommended)
|
|
104
|
+
- ✅ Tailwind CSS (for styling)
|
|
105
|
+
|
|
106
|
+
> 🚨 **Important**: Make sure your project has Tailwind CSS configured, as the plugin uses Tailwind classes for styling.
|
|
107
|
+
|
|
108
|
+
## ⚙️ Configuration
|
|
109
|
+
|
|
110
|
+
### 🎯 Basic Setup
|
|
111
|
+
|
|
112
|
+
Transform any collection into a filtering powerhouse! Just add a `filterList` to your collection's `custom` property:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
export const Users: CollectionConfig = {
|
|
116
|
+
slug: 'users',
|
|
117
|
+
custom: {
|
|
118
|
+
filterList: [
|
|
119
|
+
['status', 'role'], // First row with two filters
|
|
120
|
+
['createdAt'], // Second row with one filter
|
|
121
|
+
[
|
|
122
|
+
{ name: 'department', width: '300px' }, // Custom width
|
|
123
|
+
'isActive',
|
|
124
|
+
],
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
fields: [
|
|
128
|
+
{
|
|
129
|
+
name: 'status',
|
|
130
|
+
type: 'select',
|
|
131
|
+
options: [
|
|
132
|
+
{ label: 'Active', value: 'active' },
|
|
133
|
+
{ label: 'Inactive', value: 'inactive' },
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'role',
|
|
138
|
+
type: 'select',
|
|
139
|
+
options: [
|
|
140
|
+
{ label: 'Admin', value: 'admin' },
|
|
141
|
+
{ label: 'User', value: 'user' },
|
|
142
|
+
{ label: 'Editor', value: 'editor' },
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'createdAt',
|
|
147
|
+
type: 'date',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'isActive',
|
|
151
|
+
type: 'checkbox',
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
};
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 🎨 Filter Configuration Options
|
|
158
|
+
|
|
159
|
+
#### 📐 Row Layout Magic
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
filterList: [
|
|
163
|
+
// 🔥 Mix and match however you want!
|
|
164
|
+
['status', 'role', 'department'], // 3 filters in one row
|
|
165
|
+
['createdAt'], // Single filter gets full width
|
|
166
|
+
[{ name: 'tags', width: '400px' }], // Custom width for long lists
|
|
167
|
+
['isActive', 'isVerified'], // Two checkboxes side by side
|
|
168
|
+
];
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
| Format | Example | Result |
|
|
172
|
+
| ---------------- | ------------------------------------------------ | ---------------------------- |
|
|
173
|
+
| 📝 **String** | `'fieldName'` | Default width (230px) |
|
|
174
|
+
| 🎛️ **Object** | `{ name: 'field', width: '300px' }` | Custom width |
|
|
175
|
+
| 📊 **Mixed Row** | `['field1', { name: 'field2', width: '400px' }]` | Different widths in same row |
|
|
176
|
+
|
|
177
|
+
#### 🎯 Supported Field Types
|
|
178
|
+
|
|
179
|
+
<details>
|
|
180
|
+
<summary>📅 <strong>Date Fields</strong> - Smart date filtering made easy</summary>
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
{
|
|
184
|
+
name: 'createdAt',
|
|
185
|
+
type: 'date'
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**✨ What you get:**
|
|
190
|
+
|
|
191
|
+
- 🕐 **Predefined ranges**: Yesterday, Last Week, Last Month, All Past
|
|
192
|
+
- 🔮 **Future options**: Today, Next Week, Next Month, All Future
|
|
193
|
+
- 🎯 **Custom range**: Pick any from/to dates
|
|
194
|
+
- 🌍 **Localized**: Date formats adapt to user's language
|
|
195
|
+
|
|
196
|
+

|
|
197
|
+
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
<details>
|
|
201
|
+
<summary>📋 <strong>Select Fields</strong> - Powerful multi-select with intelligence</summary>
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
{
|
|
205
|
+
name: 'status',
|
|
206
|
+
type: 'select',
|
|
207
|
+
options: [
|
|
208
|
+
{ label: 'Published', value: 'published' },
|
|
209
|
+
{ label: 'Draft', value: 'draft' },
|
|
210
|
+
{ label: 'Archived', value: 'archived' }
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**🧠 Smart behavior:**
|
|
216
|
+
|
|
217
|
+
- 🔘 **≤3 options**: Compact button-style selector
|
|
218
|
+
- 📝 **>3 options**: Full dropdown with search
|
|
219
|
+
- ✅ **Multi-select**: Choose multiple values
|
|
220
|
+
- 🔍 **Search**: Find options in large lists quickly
|
|
221
|
+
|
|
222
|
+

|
|
223
|
+
|
|
224
|
+
</details>
|
|
225
|
+
|
|
226
|
+
<details>
|
|
227
|
+
<summary>☑️ <strong>Checkbox Fields</strong> - Three-state filtering</summary>
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
{
|
|
231
|
+
name: 'isActive',
|
|
232
|
+
type: 'checkbox'
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**🎛️ Three states:**
|
|
237
|
+
|
|
238
|
+
- ✅ **Checked**: Show only `true` values
|
|
239
|
+
- ❌ **Unchecked**: Show only `false` values
|
|
240
|
+
- ➖ **Indeterminate**: Show all (default)
|
|
241
|
+
|
|
242
|
+
Perfect for boolean fields like active/inactive, published/unpublished, etc.
|
|
243
|
+
|
|
244
|
+
</details>
|
|
245
|
+
|
|
246
|
+
## 🎮 Usage
|
|
247
|
+
|
|
248
|
+
### 🖥️ User Interface
|
|
249
|
+
|
|
250
|
+
The magic happens right above your collection table! Here's what your users will see:
|
|
251
|
+
|
|
252
|
+
<details>
|
|
253
|
+
<summary>🔽 <strong>Collapsed State</strong> - Clean and minimal</summary>
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
┌─────────────────────────────────────┐
|
|
257
|
+
│ 🔍 Quick Filters │ ← Clean button when no filters active
|
|
258
|
+
└─────────────────────────────────────┘
|
|
259
|
+
|
|
260
|
+
┌─────────────────────────────────────┐
|
|
261
|
+
│ 🔍 2 Active filters: Status • Role │ ← Shows count and field names
|
|
262
|
+
└─────────────────────────────────────┘
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+

|
|
266
|
+
|
|
267
|
+
</details>
|
|
268
|
+
|
|
269
|
+
<details>
|
|
270
|
+
<summary>🔽 <strong>Expanded State</strong> - All your filters beautifully laid out</summary>
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
274
|
+
│ 🔍 2 Active filters: Status • Role ❌ │
|
|
275
|
+
├─────────────────────────────────────────────────────────────┤
|
|
276
|
+
│ │
|
|
277
|
+
│ Status ▼ Role ▼ Department ▼ │
|
|
278
|
+
│ [Published] [Admin ] [Engineering ] │
|
|
279
|
+
│ │
|
|
280
|
+
│ Created Date ▼ │
|
|
281
|
+
│ [Last Week ▼] │
|
|
282
|
+
│ │
|
|
283
|
+
└─────────────────────────────────────────────────────────────┘
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**✨ What users love:**
|
|
287
|
+
|
|
288
|
+
- 👀 **Visual feedback**: See exactly which filters are active
|
|
289
|
+
- 🧹 **One-click clear**: Remove all filters instantly with the ❌ button
|
|
290
|
+
- 💾 **Persistent**: Filters stay active when you refresh or navigate back
|
|
291
|
+
- ⚡ **Instant results**: Table updates immediately as you change filters
|
|
292
|
+
|
|
293
|
+
</details>
|
|
294
|
+
|
|
295
|
+
### 🎯 Filter Types in Detail
|
|
296
|
+
|
|
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
|
+
|
|
326
|
+
<details>
|
|
327
|
+
<summary>📋 <strong>Select Filter</strong> - Intelligence that adapts</summary>
|
|
328
|
+
|
|
329
|
+
**🧠 Smart Behavior:**
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
// 🔘 Small lists (≤3 options) = Button style
|
|
333
|
+
[Active] [Inactive] [Pending]
|
|
334
|
+
|
|
335
|
+
// 📝 Large lists (>3 options) = Dropdown with search
|
|
336
|
+
┌─────────────────────────┐
|
|
337
|
+
│ 🔍 Search options... │
|
|
338
|
+
├─────────────────────────┤
|
|
339
|
+
│ ✅ Published │
|
|
340
|
+
│ ✅ Draft │
|
|
341
|
+
│ ⬜ Archived │
|
|
342
|
+
│ ⬜ Under Review │
|
|
343
|
+
└─────────────────────────┘
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**💪 Multi-select Support:**
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
{
|
|
350
|
+
selectedValues: ['published', 'draft'],
|
|
351
|
+
type: 'some' // Shows items matching ANY selected value
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+

|
|
356
|
+
|
|
357
|
+
</details>
|
|
358
|
+
|
|
359
|
+
<details>
|
|
360
|
+
<summary>☑️ <strong>Checkbox Filter</strong> - Three-state perfection</summary>
|
|
361
|
+
|
|
362
|
+
**🎛️ The Three States:**
|
|
363
|
+
|
|
364
|
+
| State | Visual | Behavior | Use Case |
|
|
365
|
+
| -------------------- | ------ | ------------------------ | -------------------------- |
|
|
366
|
+
| ✅ **Checked** | `[✓]` | Show only `true` values | "Show only active users" |
|
|
367
|
+
| ❌ **Unchecked** | `[ ]` | Show only `false` values | "Show only inactive users" |
|
|
368
|
+
| ➖ **Indeterminate** | `[-]` | Show all values | "Show everyone" (default) |
|
|
369
|
+
|
|
370
|
+
Perfect for boolean fields like:
|
|
371
|
+
|
|
372
|
+
- 🟢 Active/Inactive
|
|
373
|
+
- 📝 Published/Unpublished
|
|
374
|
+
- ✅ Verified/Unverified
|
|
375
|
+
- 🔒 Public/Private
|
|
376
|
+
|
|
377
|
+
</details>
|
|
378
|
+
|
|
379
|
+
## 🆚 Why Choose QuickFilter Over Regular PayloadCMS Filters?
|
|
380
|
+
|
|
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
|
+
### 🚀 **1. User Experience Revolution**
|
|
396
|
+
|
|
397
|
+
<details>
|
|
398
|
+
<summary>Click to see the UX improvements</summary>
|
|
399
|
+
|
|
400
|
+
| Aspect | QuickFilter Experience | Regular Filter Experience |
|
|
401
|
+
| ----------------- | ------------------------------------------- | ------------------------------------------ |
|
|
402
|
+
| **⚡ Speed** | Instant results as you click | Wait for page reload every time |
|
|
403
|
+
| **👀 Clarity** | `🔍 3 Active filters: Status • Role • Date` | Guess what filters are active |
|
|
404
|
+
| **💾 Memory** | Filters persist across sessions | Start over every time |
|
|
405
|
+
| **🎯 Simplicity** | Click and filter | Navigate to filter page, fill form, submit |
|
|
406
|
+
|
|
407
|
+

|
|
408
|
+
|
|
409
|
+
</details>
|
|
410
|
+
|
|
411
|
+
### ⚡ **2. Performance That Scales**
|
|
412
|
+
|
|
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
|
+
|
|
444
|
+
**🎯 What we support:**
|
|
445
|
+
|
|
446
|
+
- ⌨️ **Full keyboard navigation**: Tab through all filters
|
|
447
|
+
- 🔊 **Screen reader friendly**: Proper ARIA labels and descriptions
|
|
448
|
+
- 🌍 **RTL languages**: Native Hebrew/Arabic support
|
|
449
|
+
- 🎨 **High contrast**: Works with accessibility themes
|
|
450
|
+
- 📱 **Touch friendly**: Perfect for mobile and tablet users
|
|
451
|
+
|
|
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
|
+
</details>
|
|
491
|
+
|
|
492
|
+
### 🌟 **5. Advanced Features**
|
|
493
|
+
|
|
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
|
+
|
|
524
|
+
## 🌍 Internationalization
|
|
525
|
+
|
|
526
|
+
### 🗣️ Built-in Language Support
|
|
527
|
+
|
|
528
|
+
The plugin speaks your users' language! Full translations included for:
|
|
529
|
+
|
|
530
|
+
| Language | Code | RTL Support | Status |
|
|
531
|
+
| -------------- | ---- | ----------- | ----------- |
|
|
532
|
+
| 🇺🇸 **English** | `en` | - | ✅ Complete |
|
|
533
|
+
| 🇸🇦 **Arabic** | `ar` | ✅ Yes | ✅ Complete |
|
|
534
|
+
| 🇫🇷 **French** | `fr` | - | ✅ Complete |
|
|
535
|
+
| 🇪🇸 **Spanish** | `es` | - | ✅ Complete |
|
|
536
|
+
| 🇨🇳 **Chinese** | `zh` | - | ✅ Complete |
|
|
537
|
+
| 🇮🇱 **Hebrew** | `he` | ✅ Yes | ✅ Complete |
|
|
538
|
+
|
|
539
|
+
### 🔧 Adding Custom Languages
|
|
540
|
+
|
|
541
|
+
<details>
|
|
542
|
+
<summary>🌐 <strong>Extend language support</strong></summary>
|
|
543
|
+
|
|
544
|
+
```typescript
|
|
545
|
+
// In labels.ts, add your language
|
|
546
|
+
export const PLUGIN_LABELS = {
|
|
547
|
+
// ... existing languages
|
|
548
|
+
de: {
|
|
549
|
+
quickFilters: 'Schnellfilter',
|
|
550
|
+
clearFilters: 'Filter löschen',
|
|
551
|
+
activeFilterSingular: 'Aktiver Filter auf Spalte',
|
|
552
|
+
activeFilterPlural: 'Aktive Filter auf Spalten',
|
|
553
|
+
custom: 'Benutzerdefiniert',
|
|
554
|
+
all: 'Alle',
|
|
555
|
+
yes: 'Ja',
|
|
556
|
+
no: 'Nein',
|
|
557
|
+
// ... add all other translations
|
|
558
|
+
},
|
|
559
|
+
ja: {
|
|
560
|
+
quickFilters: 'クイックフィルター',
|
|
561
|
+
clearFilters: 'フィルターをクリア',
|
|
562
|
+
// ... Japanese translations
|
|
563
|
+
},
|
|
564
|
+
};
|
|
565
|
+
```
|
|
566
|
+
|
|
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
|
+
</details>
|
|
574
|
+
|
|
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
|
+
|
|
592
|
+
## 🔧 Advanced Configuration
|
|
593
|
+
|
|
594
|
+
### 🎨 Custom Filter Widths
|
|
595
|
+
|
|
596
|
+
<details>
|
|
597
|
+
<summary>🎯 <strong>Perfect your layout</strong></summary>
|
|
598
|
+
|
|
599
|
+
```typescript
|
|
600
|
+
filterList: [
|
|
601
|
+
[
|
|
602
|
+
{ name: 'longFieldName', width: '400px' }, // Wide for long option lists
|
|
603
|
+
{ name: 'shortField', width: '150px' }, // Narrow for simple fields
|
|
604
|
+
],
|
|
605
|
+
[
|
|
606
|
+
{ name: 'description', width: '100%' }, // Full width for text fields
|
|
607
|
+
'status', // Default width (230px)
|
|
608
|
+
],
|
|
609
|
+
];
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
**📏 Width Options:**
|
|
613
|
+
|
|
614
|
+
- `'150px'` - Compact for simple fields
|
|
615
|
+
- `'230px'` - Default width (when not specified)
|
|
616
|
+
- `'400px'` - Wide for complex selects
|
|
617
|
+
- `'100%'` - Full row width
|
|
618
|
+
- `'50%'` - Half row width
|
|
619
|
+
|
|
620
|
+
</details>
|
|
621
|
+
|
|
622
|
+
### 🎛️ Conditional Plugin Loading
|
|
623
|
+
|
|
624
|
+
<details>
|
|
625
|
+
<summary>⚙️ <strong>Environment-based configuration</strong></summary>
|
|
626
|
+
|
|
627
|
+
```typescript
|
|
628
|
+
// Disable in development
|
|
629
|
+
CollectionQuickFilterPlugin({
|
|
630
|
+
disabled: process.env.NODE_ENV === 'development',
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
// Enable only for specific environments
|
|
634
|
+
CollectionQuickFilterPlugin({
|
|
635
|
+
disabled: !['production', 'staging'].includes(process.env.NODE_ENV),
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
// Feature flag support
|
|
639
|
+
CollectionQuickFilterPlugin({
|
|
640
|
+
disabled: !process.env.ENABLE_QUICK_FILTERS,
|
|
641
|
+
});
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
**🎯 Use Cases:**
|
|
645
|
+
|
|
646
|
+
- 🧪 **Testing**: Disable during development
|
|
647
|
+
- 🚀 **Gradual rollout**: Enable for specific environments
|
|
648
|
+
- 🎚️ **Feature flags**: Toggle via environment variables
|
|
649
|
+
|
|
650
|
+
</details>
|
|
651
|
+
|
|
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
|
+
|
|
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
|
+
```typescript
|
|
819
|
+
// In your browser console
|
|
820
|
+
localStorage.setItem('quickfilter-debug', 'true');
|
|
821
|
+
|
|
822
|
+
// Then refresh the page and check console for:
|
|
823
|
+
// ✅ Filter configuration loading
|
|
824
|
+
// ✅ Query generation details
|
|
825
|
+
// ✅ State management logs
|
|
826
|
+
// ✅ Error details
|
|
827
|
+
|
|
828
|
+
// To disable debug mode:
|
|
829
|
+
localStorage.removeItem('quickfilter-debug');
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
**🎯 What to look for in console:**
|
|
833
|
+
|
|
834
|
+
- `[QuickFilter] Loading filters for collection: users`
|
|
835
|
+
- `[QuickFilter] Generated query:` + query object
|
|
836
|
+
- `[QuickFilter] Filter state updated:` + state object
|
|
837
|
+
|
|
838
|
+
</details>
|
|
839
|
+
|
|
840
|
+
### 🆘 Still Having Issues?
|
|
841
|
+
|
|
842
|
+
<details>
|
|
843
|
+
<summary>📞 <strong>Get help</strong></summary>
|
|
844
|
+
|
|
845
|
+
**Before asking for help, please:**
|
|
846
|
+
|
|
847
|
+
1. ✅ **Check the console** for error messages
|
|
848
|
+
2. ✅ **Enable debug mode** and share the logs
|
|
849
|
+
3. ✅ **Verify your configuration** matches the examples
|
|
850
|
+
4. ✅ **Test with a simple setup** first
|
|
851
|
+
|
|
852
|
+
**When reporting issues, include:**
|
|
853
|
+
|
|
854
|
+
- 🔧 Your PayloadCMS version
|
|
855
|
+
- 📋 Your collection configuration
|
|
856
|
+
- 🎯 Your filterList configuration
|
|
857
|
+
- 🐛 Console error messages
|
|
858
|
+
- 📸 Screenshots of the issue
|
|
859
|
+
|
|
860
|
+
</details>
|
|
861
|
+
|
|
862
|
+
## Contributing
|
|
863
|
+
|
|
864
|
+
The plugin is designed to be extensible. To add new filter types:
|
|
865
|
+
|
|
866
|
+
1. Create a new component in `filters/components/`
|
|
867
|
+
2. Add type definitions in `filters/types/filters-type.ts`
|
|
868
|
+
3. Update `FilterField.tsx` to handle the new type
|
|
869
|
+
4. Add translations in `labels.ts`
|
|
870
|
+
|
|
871
|
+
## License
|
|
872
|
+
|
|
873
|
+
This plugin is part of your PayloadCMS project and follows the same licensing terms.
|