@shefing/quickfilter 1.0.32 → 1.0.34
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 +62 -4
- package/dist/QuickFilter.d.ts.map +1 -1
- package/dist/QuickFilter.js +2 -172
- 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 +4 -1
- 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 +26 -0
- package/dist/filters/utils/date-helpers.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/labels.d.ts +38 -2
- package/dist/labels.d.ts.map +1 -1
- package/dist/labels.js +19 -1
- package/dist/labels.js.map +1 -1
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +186 -0
- package/dist/lib/utils.js.map +1 -1
- package/dist/nav/NavHamburger/index.d.ts +5 -0
- package/dist/nav/NavHamburger/index.d.ts.map +1 -0
- package/dist/nav/NavHamburger/index.js +20 -0
- package/dist/nav/NavHamburger/index.js.map +1 -0
- package/dist/nav/NavWrapper/index.d.ts +7 -0
- package/dist/nav/NavWrapper/index.d.ts.map +1 -0
- package/dist/nav/NavWrapper/index.js +25 -0
- package/dist/nav/NavWrapper/index.js.map +1 -0
- package/dist/nav/NavWrapper/index.scss +27 -0
- package/dist/nav/getNavPrefs.d.ts +3 -0
- package/dist/nav/getNavPrefs.d.ts.map +1 -0
- package/dist/nav/getNavPrefs.js +31 -0
- package/dist/nav/getNavPrefs.js.map +1 -0
- package/dist/nav/index.client.d.ts +8 -0
- package/dist/nav/index.client.d.ts.map +1 -0
- package/dist/nav/index.client.js +93 -0
- package/dist/nav/index.client.js.map +1 -0
- package/dist/nav/index.d.ts +8 -0
- package/dist/nav/index.d.ts.map +1 -0
- package/dist/nav/index.js +208 -0
- package/dist/nav/index.js.map +1 -0
- package/dist/nav/index.scss +163 -0
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/command.d.ts +7 -7
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -12,7 +12,6 @@ Transform your PayloadCMS admin experience with instant, intuitive filters that
|
|
|
12
12
|
| **🎛️ Multiple Filter Types** | Date, select, checkbox, and small select filters |  |
|
|
13
13
|
| **📱 Responsive Layout** | Configurable row-based layout with custom widths |  |
|
|
14
14
|
| **🌍 Internationalization** | Full i18n support with RTL language compatibility |  |
|
|
15
|
-
| **💾 Persistent State** | Filters persist in localStorage and URL parameters |  |
|
|
16
15
|
| **📅 Smart Date Filtering** | Predefined ranges + custom date picker |  |
|
|
17
16
|
|
|
18
17
|
### 🎥 See It In Action
|
|
@@ -188,8 +187,8 @@ filterList: [
|
|
|
188
187
|
|
|
189
188
|
**✨ What you get:**
|
|
190
189
|
|
|
191
|
-
- 🕐 **Predefined time ranges**: Yesterday, Last Week, Last Month, All Past
|
|
192
|
-
- 🔮 **Future options**: Today,
|
|
190
|
+
- 🕐 **Predefined time ranges**: Yesterday, Last Week, Last Month, Last 7 Days, Last 30 Days, Last Year, Last 2 Years, All Past
|
|
191
|
+
- 🔮 **Future options**: Today, This Week, This Month, Next 7 Days, Next 30 Days, Today And Future, All Future
|
|
193
192
|
- 🎯 **Custom range**: Pick any from/to dates
|
|
194
193
|
- 🌍 **Localized**: Date formats adapt to user's language
|
|
195
194
|
|
|
@@ -352,7 +351,6 @@ Perfect for boolean fields like:
|
|
|
352
351
|
| **🎯 Simplicity** | Click and filter | Navigate to filter page, fill form, submit |
|
|
353
352
|
| **⚡ Speed** | Instant results as you click | Wait for page reload every time |
|
|
354
353
|
| **👀 Clarity** | `🔍 3 Active filters: Status • Role • Date` | Guess what filters are active |
|
|
355
|
-
| **💾 Persistent** | Filters persist across sessions | Start over every time |
|
|
356
354
|
|
|
357
355
|
|
|
358
356
|
</details>
|
|
@@ -479,6 +477,66 @@ CollectionQuickFilterPlugin({
|
|
|
479
477
|
|
|
480
478
|
</details>
|
|
481
479
|
|
|
480
|
+
### 🧭 NavDefaultFilter Component
|
|
481
|
+
|
|
482
|
+
<details>
|
|
483
|
+
<summary>⚙️ <strong>Using NavDefaultFilter in your admin UI</strong></summary>
|
|
484
|
+
|
|
485
|
+
The NavDefaultFilter component allows you to apply default filters to collection views directly from the navigation menu. This means users will see filtered data immediately when they click on a collection.
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
// payload.config.ts
|
|
489
|
+
export default buildConfig({
|
|
490
|
+
admin: {
|
|
491
|
+
components: {
|
|
492
|
+
Nav: '@shefing/quickfilter/nav',
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
// ... rest of your config
|
|
496
|
+
});
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
**🎯 Collection Configuration Examples:**
|
|
500
|
+
|
|
501
|
+
1. Filter to show only today's and future meetings:
|
|
502
|
+
|
|
503
|
+
```typescript
|
|
504
|
+
export const Meetings: CollectionConfig = {
|
|
505
|
+
slug: 'meetings',
|
|
506
|
+
custom: {
|
|
507
|
+
defaultFilter: {
|
|
508
|
+
'meetingDate': 'todayAndFuture'
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
// ... rest of your collection config
|
|
512
|
+
};
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
2. Filter to show only unhandled items:
|
|
516
|
+
|
|
517
|
+
```typescript
|
|
518
|
+
export const Tasks: CollectionConfig = {
|
|
519
|
+
slug: 'tasks',
|
|
520
|
+
custom: {
|
|
521
|
+
filterList: [['type', 'createdAt', 'meetingDate', 'holdingsLimit', 'handled', 'acquireTask']],
|
|
522
|
+
defaultFilter: {
|
|
523
|
+
'handled': {
|
|
524
|
+
equals: false
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
// ... rest of your collection config
|
|
529
|
+
};
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
**✨ Benefits:**
|
|
533
|
+
|
|
534
|
+
- 🎯 **Context-aware navigation**: Users see the most relevant data immediately
|
|
535
|
+
- ⏱️ **Time-saving**: No need to manually apply filters after navigation
|
|
536
|
+
- 🧠 **Smart defaults**: Configure different default views for different collections
|
|
537
|
+
|
|
538
|
+
</details>
|
|
539
|
+
|
|
482
540
|
|
|
483
541
|
|
|
484
542
|
## Contributing
|
|
@@ -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":"AAsGA,QAAA,MAAM,WAAW,0BAGd;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,CAAC,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,EAAE,CAAA;CAC3D,gCA0RA,CAAA;AAED,eAAe,WAAW,CAAA"}
|
package/dist/QuickFilter.js
CHANGED
|
@@ -7,10 +7,10 @@ import FilterField from './FilterField';
|
|
|
7
7
|
import { getLabel } from './labels';
|
|
8
8
|
import { groupFiltersByRow } from './filters/utils/layout-helpers';
|
|
9
9
|
import { ChevronDown, ChevronUp, Filter, RefreshCw, X } from 'lucide-react';
|
|
10
|
-
import { getDateRangeForOption } from './filters/utils/date-helpers';
|
|
11
10
|
import { isEqual } from 'lodash';
|
|
12
|
-
import {
|
|
11
|
+
import { getDateFilterOptions } from './filters/constants/date-filter-options';
|
|
13
12
|
import { Button } from './ui/button';
|
|
13
|
+
import { buildQuickFilterConditions, parseWhereClauseToFilterValues } from './lib/utils';
|
|
14
14
|
// Helper function to get localized label
|
|
15
15
|
const getLocalizedLabel = (label, locale)=>{
|
|
16
16
|
if (typeof label === 'object' && label !== null) {
|
|
@@ -45,85 +45,6 @@ function findFieldsByName(fields, fieldNames) {
|
|
|
45
45
|
recursiveSearch(fields);
|
|
46
46
|
return results;
|
|
47
47
|
}
|
|
48
|
-
// Builds an array of condition objects from the quick filter values
|
|
49
|
-
const buildQuickFilterConditions = (values, fieldDefs, locale)=>{
|
|
50
|
-
const conditions = [];
|
|
51
|
-
Object.entries(values).forEach(([fieldName, value])=>{
|
|
52
|
-
if (!value) return;
|
|
53
|
-
const fieldDef = fieldDefs.find((f)=>f.name === fieldName);
|
|
54
|
-
if (!fieldDef) return;
|
|
55
|
-
let condition = null;
|
|
56
|
-
switch(fieldDef.type){
|
|
57
|
-
case 'date':
|
|
58
|
-
{
|
|
59
|
-
const dateValue = value;
|
|
60
|
-
let from;
|
|
61
|
-
let to;
|
|
62
|
-
if (dateValue.predefinedValue) {
|
|
63
|
-
const range = getDateRangeForOption(dateValue.predefinedValue, locale);
|
|
64
|
-
from = range.from;
|
|
65
|
-
to = range.to;
|
|
66
|
-
} else if (dateValue.customRange) {
|
|
67
|
-
if (dateValue.customRange.from) from = new Date(dateValue.customRange.from);
|
|
68
|
-
if (dateValue.customRange.to) to = new Date(dateValue.customRange.to);
|
|
69
|
-
}
|
|
70
|
-
if (from || to) {
|
|
71
|
-
const dateQuery = {};
|
|
72
|
-
if (from) dateQuery.greater_than_equal = from;
|
|
73
|
-
if (to) dateQuery.less_than_equal = to;
|
|
74
|
-
if (Object.keys(dateQuery).length > 0) {
|
|
75
|
-
condition = {
|
|
76
|
-
[fieldName]: dateQuery
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
case 'select':
|
|
83
|
-
{
|
|
84
|
-
const selectValue = value;
|
|
85
|
-
if (selectValue.selectedValues && selectValue.selectedValues.length > 0) {
|
|
86
|
-
if (selectValue.selectedValues.length === 1) {
|
|
87
|
-
condition = {
|
|
88
|
-
[fieldName]: {
|
|
89
|
-
equals: selectValue.selectedValues[0]
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
} else {
|
|
93
|
-
condition = {
|
|
94
|
-
[fieldName]: {
|
|
95
|
-
in: selectValue.selectedValues
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
case 'checkbox':
|
|
103
|
-
{
|
|
104
|
-
const checkboxState = value;
|
|
105
|
-
if (checkboxState === 'checked') {
|
|
106
|
-
condition = {
|
|
107
|
-
[fieldName]: {
|
|
108
|
-
equals: 'true'
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
} else if (checkboxState === 'unchecked') {
|
|
112
|
-
condition = {
|
|
113
|
-
[fieldName]: {
|
|
114
|
-
equals: 'false'
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (condition) {
|
|
122
|
-
conditions.push(condition);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
return conditions;
|
|
126
|
-
};
|
|
127
48
|
// Helper function to remove quick filter conditions from a 'where' clause
|
|
128
49
|
const cleanWhereClause = (clause, fieldsToClean)=>{
|
|
129
50
|
if (!clause || typeof clause !== 'object' || Array.isArray(clause)) {
|
|
@@ -151,97 +72,6 @@ const cleanWhereClause = (clause, fieldsToClean)=>{
|
|
|
151
72
|
}
|
|
152
73
|
return newClause;
|
|
153
74
|
};
|
|
154
|
-
// Translates URL query conditions to the quick filter's internal state
|
|
155
|
-
const parseWhereClauseToFilterValues = (where, fields, locale)=>{
|
|
156
|
-
const values = {};
|
|
157
|
-
const fieldNames = new Set(fields.map((f)=>f.name));
|
|
158
|
-
const recursiveParse = (clause)=>{
|
|
159
|
-
if (!clause || typeof clause !== 'object') return;
|
|
160
|
-
if (clause.and) {
|
|
161
|
-
clause.and.forEach(recursiveParse);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
if (clause.or) {
|
|
165
|
-
if (clause.or.length > 1) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
clause.or.forEach(recursiveParse);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
for(const fieldName in clause){
|
|
172
|
-
if (fieldNames.has(fieldName)) {
|
|
173
|
-
const fieldDef = fields.find((f)=>f.name === fieldName);
|
|
174
|
-
const condition = clause[fieldName];
|
|
175
|
-
if (fieldDef && condition && typeof condition === 'object') {
|
|
176
|
-
if ('equals' in condition) {
|
|
177
|
-
if (fieldDef.type === 'checkbox') {
|
|
178
|
-
values[fieldName] = condition.equals == 'true' ? 'checked' : 'unchecked';
|
|
179
|
-
} else if (fieldDef.type === 'select') {
|
|
180
|
-
values[fieldName] = {
|
|
181
|
-
selectedValues: [
|
|
182
|
-
condition.equals
|
|
183
|
-
]
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
} else if ('in' in condition && Array.isArray(condition.in)) {
|
|
187
|
-
if (fieldDef.type === 'select') {
|
|
188
|
-
values[fieldName] = {
|
|
189
|
-
selectedValues: condition.in
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
} else if ('greater_than_equal' in condition || 'less_than_equal' in condition) {
|
|
193
|
-
if (fieldDef.type === 'date') {
|
|
194
|
-
const fromDate = condition.greater_than_equal ? new Date(condition.greater_than_equal) : null;
|
|
195
|
-
const toDate = condition.less_than_equal ? new Date(condition.less_than_equal) : null;
|
|
196
|
-
const allDateOptions = [
|
|
197
|
-
...pastOptionKeys,
|
|
198
|
-
...futureOptionKeys
|
|
199
|
-
];
|
|
200
|
-
let matchedOption = null;
|
|
201
|
-
for (const option of allDateOptions){
|
|
202
|
-
const range = getDateRangeForOption(option, locale);
|
|
203
|
-
let isFromMatch;
|
|
204
|
-
if (fromDate) {
|
|
205
|
-
isFromMatch = range.from?.toDateString() === fromDate.toDateString();
|
|
206
|
-
} else if (fromDate == null && range.to == undefined) {
|
|
207
|
-
// all future: fromDate == null & range.to == undefined
|
|
208
|
-
isFromMatch = true;
|
|
209
|
-
}
|
|
210
|
-
let isToMatch;
|
|
211
|
-
if (toDate) {
|
|
212
|
-
isToMatch = range.to?.toDateString() === toDate.toDateString();
|
|
213
|
-
} else if (toDate == null && range.to == undefined) {
|
|
214
|
-
// all future: fromDate == null & range.to == undefined
|
|
215
|
-
isToMatch = true;
|
|
216
|
-
}
|
|
217
|
-
if (isFromMatch && isToMatch) {
|
|
218
|
-
matchedOption = option;
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
if (matchedOption) {
|
|
223
|
-
values[fieldName] = {
|
|
224
|
-
type: 'predefined',
|
|
225
|
-
predefinedValue: matchedOption
|
|
226
|
-
};
|
|
227
|
-
} else {
|
|
228
|
-
values[fieldName] = {
|
|
229
|
-
type: 'custom',
|
|
230
|
-
customRange: {
|
|
231
|
-
from: fromDate,
|
|
232
|
-
to: toDate
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
recursiveParse(where);
|
|
243
|
-
return values;
|
|
244
|
-
};
|
|
245
75
|
const QuickFilter = ({ slug, filterList })=>{
|
|
246
76
|
const [fields, setFields] = useState([]);
|
|
247
77
|
const [filterRows, setFilterRows] = useState([]);
|
package/dist/QuickFilter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/QuickFilter.tsx"],"sourcesContent":["'use client'\n\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useConfig, useListQuery, useTranslation } from '@payloadcms/ui'\nimport type { ClientField, FieldAffectingData, ListQuery, OptionObject, SelectField } from 'payload'\nimport { getTranslation } from '@payloadcms/translations'\nimport FilterField from './FilterField'\nimport { getLabel, SupportedLocale } from './labels'\nimport type {\n CheckboxFilterState,\n DateFilterValue,\n FilterDetaild,\n FilterRow,\n SelectFilterValue,\n} from './filters/types/filters-type'\nimport { groupFiltersByRow } from './filters/utils/layout-helpers'\nimport { ChevronDown, ChevronUp, Filter, RefreshCw, X } from 'lucide-react'\n\nimport { getDateRangeForOption } from './filters/utils/date-helpers'\nimport { isEqual } from 'lodash'\nimport {\n futureOptionKeys,\n getDateFilterOptions,\n pastOptionKeys,\n} from './filters/constants/date-filter-options'\nimport { Button } from './ui/button'\n\n// Helper function to get localized label\nconst getLocalizedLabel = (label: any, locale: SupportedLocale): string => {\n if (typeof label === 'object' && label !== null) {\n return label[locale] || label['en'] || Object.values(label)[0] || ''\n }\n return label || ''\n}\n\n// Recursive function to find fields by name\nfunction findFieldsByName(fields: ClientField[], fieldNames: string[]): ClientField[] {\n const results: ClientField[] = []\n function recursiveSearch(currentFields: ClientField[]) {\n const filteredFields = currentFields.filter(\n (field) => 'name' in field && fieldNames.includes(field.name as string),\n )\n results.push(...filteredFields)\n currentFields.forEach((item) => {\n if (\n (item.type === 'array' || item.type === 'row' || item.type === 'collapsible') &&\n 'fields' in item &&\n Array.isArray(item.fields)\n ) {\n recursiveSearch(item.fields)\n } else if (item.type === 'tabs' && Array.isArray(item.tabs)) {\n item.tabs.forEach((tab) => {\n if ('fields' in tab && Array.isArray(tab.fields)) {\n recursiveSearch(tab.fields)\n }\n })\n } else if (item.type === 'blocks' && Array.isArray(item.blocks)) {\n item.blocks.forEach((block) => {\n if ('fields' in block && Array.isArray(block.fields)) {\n recursiveSearch(block.fields)\n }\n })\n }\n })\n }\n recursiveSearch(fields)\n return results\n}\n\n// Builds an array of condition objects from the quick filter values\nconst buildQuickFilterConditions = (\n values: Record<string, any>,\n fieldDefs: FilterDetaild[],\n locale: SupportedLocale,\n): Record<string, any>[] => {\n const conditions: Record<string, any>[] = []\n\n Object.entries(values).forEach(([fieldName, value]) => {\n if (!value) return\n const fieldDef = fieldDefs.find((f) => f.name === fieldName)\n if (!fieldDef) return\n\n let condition: Record<string, any> | null = null\n\n switch (fieldDef.type) {\n case 'date': {\n const dateValue = value as DateFilterValue\n let from: Date | undefined\n let to: Date | undefined\n\n if (dateValue.predefinedValue) {\n const range = getDateRangeForOption(dateValue.predefinedValue, locale)\n from = range.from\n to = range.to\n } else if (dateValue.customRange) {\n if (dateValue.customRange.from) from = new Date(dateValue.customRange.from)\n if (dateValue.customRange.to) to = new Date(dateValue.customRange.to)\n }\n\n if (from || to) {\n const dateQuery: any = {}\n if (from) dateQuery.greater_than_equal = from\n if (to) dateQuery.less_than_equal = to\n if (Object.keys(dateQuery).length > 0) {\n condition = { [fieldName]: dateQuery }\n }\n }\n break\n }\n case 'select': {\n const selectValue = value as SelectFilterValue\n if (selectValue.selectedValues && selectValue.selectedValues.length > 0) {\n if (selectValue.selectedValues.length === 1) {\n condition = { [fieldName]: { equals: selectValue.selectedValues[0] } }\n } else {\n condition = { [fieldName]: { in: selectValue.selectedValues } }\n }\n }\n break\n }\n case 'checkbox': {\n const checkboxState = value as CheckboxFilterState\n if (checkboxState === 'checked') {\n condition = { [fieldName]: { equals: 'true' } }\n } else if (checkboxState === 'unchecked') {\n condition = { [fieldName]: { equals: 'false' } }\n }\n break\n }\n }\n if (condition) {\n conditions.push(condition)\n }\n })\n return conditions\n}\n\n// Helper function to remove quick filter conditions from a 'where' clause\nconst cleanWhereClause = (clause: any, fieldsToClean: Set<string>): any => {\n if (!clause || typeof clause !== 'object' || Array.isArray(clause)) {\n return clause\n }\n\n const newClause: Record<string, any> = {}\n\n for (const key in clause) {\n if (key === 'and' || key === 'or') {\n const cleanedSubClauses = clause[key]\n .map((subClause: any) => cleanWhereClause(subClause, fieldsToClean))\n .filter(Boolean)\n\n if (cleanedSubClauses.length > 0) {\n newClause[key] = cleanedSubClauses\n }\n } else if (!fieldsToClean.has(key)) {\n newClause[key] = clause[key]\n }\n }\n\n if (Object.keys(newClause).length === 0) {\n return null\n }\n\n if (newClause.and?.length === 1 && Object.keys(newClause).length === 1) {\n return newClause.and[0]\n }\n if (newClause.or?.length === 1 && Object.keys(newClause).length === 1) {\n return newClause.or[0]\n }\n\n return newClause\n}\n\n// Translates URL query conditions to the quick filter's internal state\nconst parseWhereClauseToFilterValues = (\n where: any,\n fields: FilterDetaild[],\n locale: SupportedLocale,\n): Record<string, any> => {\n const values: Record<string, any> = {}\n const fieldNames = new Set(fields.map((f) => f.name))\n\n const recursiveParse = (clause: any) => {\n if (!clause || typeof clause !== 'object') return\n\n if (clause.and) {\n clause.and.forEach(recursiveParse)\n return\n }\n if (clause.or) {\n if (clause.or.length > 1) {\n return\n }\n clause.or.forEach(recursiveParse)\n return\n }\n for (const fieldName in clause) {\n if (fieldNames.has(fieldName)) {\n const fieldDef = fields.find((f) => f.name === fieldName)\n const condition = clause[fieldName]\n\n if (fieldDef && condition && typeof condition === 'object') {\n if ('equals' in condition) {\n if (fieldDef.type === 'checkbox') {\n values[fieldName] = condition.equals == 'true' ? 'checked' : 'unchecked'\n } else if (fieldDef.type === 'select') {\n values[fieldName] = { selectedValues: [condition.equals] }\n }\n } else if ('in' in condition && Array.isArray(condition.in)) {\n if (fieldDef.type === 'select') {\n values[fieldName] = { selectedValues: condition.in }\n }\n } else if ('greater_than_equal' in condition || 'less_than_equal' in condition) {\n if (fieldDef.type === 'date') {\n const fromDate = condition.greater_than_equal\n ? new Date(condition.greater_than_equal)\n : null\n const toDate = condition.less_than_equal ? new Date(condition.less_than_equal) : null\n const allDateOptions = [...pastOptionKeys, ...futureOptionKeys]\n let matchedOption = null\n\n for (const option of allDateOptions) {\n const range = getDateRangeForOption(option, locale)\n let isFromMatch\n if (fromDate) {\n isFromMatch = range.from?.toDateString() === fromDate.toDateString()\n } else if (fromDate == null && range.to == undefined) {\n // all future: fromDate == null & range.to == undefined\n isFromMatch = true\n }\n let isToMatch\n if (toDate) {\n isToMatch = range.to?.toDateString() === toDate.toDateString()\n } else if (toDate == null && range.to == undefined) {\n // all future: fromDate == null & range.to == undefined\n isToMatch = true\n }\n\n if (isFromMatch && isToMatch) {\n matchedOption = option\n break\n }\n }\n\n if (matchedOption) {\n values[fieldName] = {\n type: 'predefined',\n predefinedValue: matchedOption,\n }\n } else {\n values[fieldName] = {\n type: 'custom',\n customRange: {\n from: fromDate,\n to: toDate,\n },\n }\n }\n }\n }\n }\n }\n }\n }\n\n recursiveParse(where)\n return values\n}\n\nconst QuickFilter = ({\n slug,\n filterList,\n}: {\n slug: string\n filterList: (string | { name: string; width: string })[][]\n}) => {\n const [fields, setFields] = useState<FilterDetaild[]>([])\n const [filterRows, setFilterRows] = useState<FilterRow[]>([])\n const [showFilters, setShowFilters] = useState(false)\n const { refineListData, query } = useListQuery()\n const { getEntityConfig } = useConfig()\n const { i18n } = useTranslation()\n const locale = i18n.language as SupportedLocale\n\n const [filterValues, setFilterValues] = useState<Record<string, any>>({})\n\n // Build the list of filter fields from config\n useEffect(() => {\n const collection = getEntityConfig({ collectionSlug: slug })\n const flattenedFieldConfigs = filterList.flatMap((row, rowIndex) =>\n row.map((field, fieldIndex) => ({\n field,\n rowIndex,\n fieldIndex,\n })),\n )\n const fieldNames = flattenedFieldConfigs.map(({ field }) =>\n typeof field === 'string' ? field : field.name,\n )\n const matchedFields = findFieldsByName(collection?.fields || [], fieldNames)\n const simplifiedFields: FilterDetaild[] = matchedFields.map((field) => {\n const label = (field as FieldAffectingData).label\n const translatedLabel = getTranslation(label as string, i18n)\n const fieldName = (field as FieldAffectingData).name as string\n const fieldConfig = flattenedFieldConfigs.find(({ field: f }) =>\n typeof f === 'string' ? f === fieldName : f.name === fieldName,\n )\n return {\n name: fieldName,\n label: translatedLabel as string,\n type: field.type,\n options: (field as SelectField).options as OptionObject[],\n row: fieldConfig ? fieldConfig.rowIndex : 0,\n width:\n typeof fieldConfig?.field === 'object' && 'width' in fieldConfig.field\n ? fieldConfig.field.width\n : undefined,\n }\n })\n const sortedFields = flattenedFieldConfigs\n .map(({ field }) => {\n const fieldName = typeof field === 'string' ? field : field.name\n return simplifiedFields.find((f) => f.name === fieldName)\n })\n .filter((f): f is FilterDetaild => !!f)\n setFields(sortedFields)\n setFilterRows(groupFiltersByRow(sortedFields))\n }, [slug, filterList, getEntityConfig, i18n])\n // Sync from URL (query.where) into internal state\n useEffect(() => {\n if (fields.length === 0) return\n const valuesFromQuery: Record<string, any> = parseWhereClauseToFilterValues(\n query.where,\n fields,\n locale,\n )\n if (!isEqual(filterValues, valuesFromQuery)) {\n // Lock to prevent feedback loop when internal state changes\n setFilterValues(valuesFromQuery)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [query.where, fields])\n\n // Sync internal state (filterValues) back into the URL\n useEffect(() => {\n if (fields.length === 0) return\n const valuesFromQuery: Record<string, any> = parseWhereClauseToFilterValues(\n query.where,\n fields,\n locale,\n )\n if (Object.keys(filterValues).length == 0 && !query.where) {\n }\n if (isEqual(filterValues, valuesFromQuery)) {\n return\n }\n const quickFilterConditions = buildQuickFilterConditions(filterValues, fields, locale)\n const quickFilterFieldNames = new Set(fields.map((f) => f.name))\n const otherFilters = cleanWhereClause(query.where, quickFilterFieldNames)\n\n const allConditions = [...quickFilterConditions]\n if (otherFilters) {\n if (otherFilters.and && Array.isArray(otherFilters.and)) {\n allConditions.push(...otherFilters.and)\n } else if (Object.keys(otherFilters).length > 0) {\n allConditions.push(otherFilters)\n }\n }\n\n let newWhere: Record<string, any> = {}\n if (allConditions.length > 1) {\n newWhere = { and: allConditions }\n } else if (allConditions.length === 1) {\n newWhere = allConditions[0]\n }\n\n // Only update if the query has actually changed to avoid unnecessary updates\n if (!(isEqual(newWhere, query.where) || (Object.keys(newWhere).length == 0 && !query.where))) {\n const refinedData = {\n where: newWhere,\n page: 1,\n } as ListQuery\n\n refineListData(refinedData).then((r) => {\n console.log('Query refreshed', refinedData)\n })\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [filterValues])\n\n // Updates only the internal state\n const handleFilterChange = useCallback((fieldName: string, value: any) => {\n setFilterValues((prev) => {\n const newValues = { ...prev }\n if (\n value === undefined ||\n value === null ||\n value === 'indeterminate' ||\n (value && value.type === 'none')\n ) {\n delete newValues[fieldName]\n } else {\n newValues[fieldName] = value\n }\n return newValues\n })\n }, [])\n\n // This function remains largely the same.\n const getActiveFiltersDetails = () => {\n const activeFilters: string[] = []\n const locale = i18n.language as SupportedLocale\n Object.entries(filterValues).forEach(([fieldName, value]) => {\n const field = fields.find((f) => f.name === fieldName)\n if (!field) return\n\n switch (field.type) {\n case 'date':\n if (value !== undefined) {\n const dateValue = value as DateFilterValue\n let dateDescription = ''\n\n if (dateValue.type === 'predefined' && dateValue.predefinedValue) {\n const { pastOptions, futureOptions } = getDateFilterOptions(locale)\n const allOptions = [...pastOptions, ...futureOptions]\n const option = allOptions.find((opt) => opt.value === dateValue.predefinedValue)\n dateDescription = option ? option.label : getLabel('custom', locale)\n } else if (dateValue.type === 'custom' || dateValue.customRange) {\n dateDescription = getLabel('custom', locale)\n }\n\n if (dateDescription) {\n activeFilters.push(`${field.label} (${dateDescription})`)\n }\n }\n break\n case 'select': {\n const selectValue = value as SelectFilterValue\n if (selectValue && selectValue.selectedValues && selectValue.selectedValues.length > 0) {\n const totalOptions = field.options?.length || 0\n\n if (selectValue.selectedValues.length === totalOptions) {\n activeFilters.push(`${field.label} (${getLabel('all', locale)})`)\n } else if (selectValue.selectedValues.length === 1) {\n // Show the actual option name when only one is selected\n const selectedOption = field.options?.find(\n (opt: any) => opt.value === selectValue.selectedValues[0],\n )\n const optionLabel = selectedOption\n ? getLocalizedLabel(selectedOption.label, locale)\n : selectValue.selectedValues[0]\n activeFilters.push(`${field.label} (${optionLabel})`)\n } else {\n // Show count for multiple selections\n activeFilters.push(`${field.label} (${selectValue.selectedValues.length})`)\n }\n }\n break\n }\n case 'checkbox':\n if (value !== 'indeterminate') {\n const checkboxValue =\n value === 'checked' ? getLabel('yes', locale) : getLabel('no', locale)\n activeFilters.push(`${field.label} (${checkboxValue})`)\n }\n break\n }\n })\n\n return activeFilters\n }\n\n const clearAllFilters = () => {\n setFilterValues({})\n }\n\n const refreshFilters = () => {\n refineListData(query)\n }\n\n const memoizedFilterRows = useMemo(() => {\n return filterRows.map((row) => (\n <div key={row.rowNumber}>\n <div className=\"flex flex-wrap gap-6 mb-4\">\n {row.filters.map((field) => (\n <FilterField\n key={field.name}\n field={field}\n onFilterChange={handleFilterChange}\n value={filterValues[field.name]}\n />\n ))}\n </div>\n </div>\n ))\n }, [filterRows, handleFilterChange, filterValues])\n\n const toggleFilters = () => {\n setShowFilters((prev) => !prev)\n }\n\n const activeFiltersDetails = getActiveFiltersDetails()\n const hasActiveFilters = activeFiltersDetails.length > 0\n\n if (!fields.length) return null\n\n return (\n <div className=\"filter-container useTw\">\n <div style={{ position: 'relative', top: '-24px', height: '0px' }}>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={toggleFilters}\n className={`flex items-center gap-2 bg-background border-muted-muted hover:bg-muted ${\n hasActiveFilters ? 'w-auto min-w-fit' : ''\n }`}\n >\n <Filter className={`h-4 w-4 ${hasActiveFilters ? 'fill-current' : ''}`} />\n\n {hasActiveFilters ? (\n <>\n <span className=\"text-sm truncate\">\n <strong>\n {`${activeFiltersDetails.length === 1 ? getLabel('activeFilterSingular', locale) : getLabel('activeFilterPlural', locale)}: `}\n </strong>{' '}\n {activeFiltersDetails.join(' • ')}\n </span>\n\n <span\n onClick={(e) => {\n e.stopPropagation()\n clearAllFilters()\n }}\n className=\"ml-1 p-0.5 hover:bg-muted rounded-sm transition-colors flex-shrink-0\"\n >\n <X className=\"h-3 w-3 text-gray-500\" />\n </span>\n <span\n onClick={(e) => {\n e.stopPropagation()\n refreshFilters()\n }}\n className=\"ml-1 p-0.5 hover:bg-muted rounded-sm transition-colors flex-shrink-0\"\n >\n <RefreshCw className=\"h-3 w-3 text-gray-500\" />\n </span>\n </>\n ) : (\n <span className=\"text-sm truncate\">{getLabel('quickFilters', locale)}</span>\n )}\n\n {showFilters ? <ChevronUp className=\"h-4 w-4\" /> : <ChevronDown className=\"h-4 w-4\" />}\n </Button>\n </div>\n {showFilters && <div className={'p-4 pb-2 bg-muted'}>{memoizedFilterRows}</div>}\n </div>\n )\n}\n\nexport default QuickFilter\n"],"names":["useCallback","useEffect","useMemo","useState","useConfig","useListQuery","useTranslation","getTranslation","FilterField","getLabel","groupFiltersByRow","ChevronDown","ChevronUp","Filter","RefreshCw","X","getDateRangeForOption","isEqual","futureOptionKeys","getDateFilterOptions","pastOptionKeys","Button","getLocalizedLabel","label","locale","Object","values","findFieldsByName","fields","fieldNames","results","recursiveSearch","currentFields","filteredFields","filter","field","includes","name","push","forEach","item","type","Array","isArray","tabs","tab","blocks","block","buildQuickFilterConditions","fieldDefs","conditions","entries","fieldName","value","fieldDef","find","f","condition","dateValue","from","to","predefinedValue","range","customRange","Date","dateQuery","greater_than_equal","less_than_equal","keys","length","selectValue","selectedValues","equals","in","checkboxState","cleanWhereClause","clause","fieldsToClean","newClause","key","cleanedSubClauses","map","subClause","Boolean","has","and","or","parseWhereClauseToFilterValues","where","Set","recursiveParse","fromDate","toDate","allDateOptions","matchedOption","option","isFromMatch","toDateString","undefined","isToMatch","QuickFilter","slug","filterList","setFields","filterRows","setFilterRows","showFilters","setShowFilters","refineListData","query","getEntityConfig","i18n","language","filterValues","setFilterValues","collection","collectionSlug","flattenedFieldConfigs","flatMap","row","rowIndex","fieldIndex","matchedFields","simplifiedFields","translatedLabel","fieldConfig","options","width","sortedFields","valuesFromQuery","quickFilterConditions","quickFilterFieldNames","otherFilters","allConditions","newWhere","refinedData","page","then","r","console","log","handleFilterChange","prev","newValues","getActiveFiltersDetails","activeFilters","dateDescription","pastOptions","futureOptions","allOptions","opt","totalOptions","selectedOption","optionLabel","checkboxValue","clearAllFilters","refreshFilters","memoizedFilterRows","div","className","filters","onFilterChange","rowNumber","toggleFilters","activeFiltersDetails","hasActiveFilters","style","position","top","height","variant","size","onClick","span","strong","join","e","stopPropagation"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAE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xJ;4BAAOkJ,WAAW,CAAC,QAAQ,EAAEM,mBAAmB,iBAAiB,IAAI;;wBAErEA,iCACC;;8CACE,MAACQ;oCAAKd,WAAU;;sDACd,KAACe;sDACE,GAAGV,qBAAqB/F,MAAM,KAAK,IAAI5D,SAAS,wBAAwBe,UAAUf,SAAS,sBAAsBe,QAAQ,EAAE,CAAC;;wCACrH;wCACT4I,qBAAqBW,IAAI,CAAC;;;8CAG7B,KAACF;oCACCD,SAAS,CAACI;wCACRA,EAAEC,eAAe;wCACjBtB;oCACF;oCACAI,WAAU;8CAEV,cAAA,KAAChJ;wCAAEgJ,WAAU;;;8CAEf,KAACc;oCACCD,SAAS,CAACI;wCACRA,EAAEC,eAAe;wCACjBrB;oCACF;oCACAG,WAAU;8CAEV,cAAA,KAACjJ;wCAAUiJ,WAAU;;;;2CAIzB,KAACc;4BAAKd,WAAU;sCAAoBtJ,SAAS,gBAAgBe;;wBAG9DkF,4BAAc,KAAC9F;4BAAUmJ,WAAU;2CAAe,KAACpJ;4BAAYoJ,WAAU;;;;;YAG7ErD,6BAAe,KAACoD;gBAAIC,WAAW;0BAAsBF;;;;AAG5D;AAEA,eAAezD,YAAW"}
|
|
1
|
+
{"version":3,"sources":["../src/QuickFilter.tsx"],"sourcesContent":["'use client'\n\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useConfig, useListQuery, useTranslation } from '@payloadcms/ui'\nimport type { ClientField, FieldAffectingData, ListQuery, OptionObject, SelectField } from 'payload'\nimport { getTranslation } from '@payloadcms/translations'\nimport FilterField from './FilterField'\nimport { getLabel, SupportedLocale } from './labels'\nimport type {\n DateFilterValue,\n FilterDetaild,\n FilterRow,\n SelectFilterValue,\n} from './filters/types/filters-type'\nimport { groupFiltersByRow } from './filters/utils/layout-helpers'\nimport { ChevronDown, ChevronUp, Filter, RefreshCw, X } from 'lucide-react'\nimport { isEqual } from 'lodash'\nimport { getDateFilterOptions } from './filters/constants/date-filter-options'\nimport { Button } from './ui/button'\nimport {\n buildQuickFilterConditions,\n parseWhereClauseToFilterValues,\n} from './lib/utils'\n\n// Helper function to get localized label\nconst getLocalizedLabel = (label: any, locale: SupportedLocale): string => {\n if (typeof label === 'object' && label !== null) {\n return label[locale] || label['en'] || Object.values(label)[0] || ''\n }\n return label || ''\n}\n\n// Recursive function to find fields by name\nfunction findFieldsByName(fields: ClientField[], fieldNames: string[]): ClientField[] {\n const results: ClientField[] = []\n function recursiveSearch(currentFields: ClientField[]) {\n const filteredFields = currentFields.filter(\n (field) => 'name' in field && fieldNames.includes(field.name as string),\n )\n results.push(...filteredFields)\n currentFields.forEach((item) => {\n if (\n (item.type === 'array' || item.type === 'row' || item.type === 'collapsible') &&\n 'fields' in item &&\n Array.isArray(item.fields)\n ) {\n recursiveSearch(item.fields)\n } else if (item.type === 'tabs' && Array.isArray(item.tabs)) {\n item.tabs.forEach((tab) => {\n if ('fields' in tab && Array.isArray(tab.fields)) {\n recursiveSearch(tab.fields)\n }\n })\n } else if (item.type === 'blocks' && Array.isArray(item.blocks)) {\n item.blocks.forEach((block) => {\n if ('fields' in block && Array.isArray(block.fields)) {\n recursiveSearch(block.fields)\n }\n })\n }\n })\n }\n recursiveSearch(fields)\n return results\n}\n\n// Helper function to remove quick filter conditions from a 'where' clause\nconst cleanWhereClause = (clause: any, fieldsToClean: Set<string>): any => {\n if (!clause || typeof clause !== 'object' || Array.isArray(clause)) {\n return clause\n }\n\n const newClause: Record<string, any> = {}\n\n for (const key in clause) {\n if (key === 'and' || key === 'or') {\n const cleanedSubClauses = clause[key]\n .map((subClause: any) => cleanWhereClause(subClause, fieldsToClean))\n .filter(Boolean)\n\n if (cleanedSubClauses.length > 0) {\n newClause[key] = cleanedSubClauses\n }\n } else if (!fieldsToClean.has(key)) {\n newClause[key] = clause[key]\n }\n }\n\n if (Object.keys(newClause).length === 0) {\n return null\n }\n\n if (newClause.and?.length === 1 && Object.keys(newClause).length === 1) {\n return newClause.and[0]\n }\n if (newClause.or?.length === 1 && Object.keys(newClause).length === 1) {\n return newClause.or[0]\n }\n\n return newClause\n}\n\nconst QuickFilter = ({\n slug,\n filterList,\n}: {\n slug: string\n filterList: (string | { name: string; width: string })[][]\n}) => {\n const [fields, setFields] = useState<FilterDetaild[]>([])\n const [filterRows, setFilterRows] = useState<FilterRow[]>([])\n const [showFilters, setShowFilters] = useState(false)\n const { refineListData, query } = useListQuery()\n const { getEntityConfig } = useConfig()\n const { i18n } = useTranslation()\n const locale = i18n.language as SupportedLocale\n\n const [filterValues, setFilterValues] = useState<Record<string, any>>({})\n\n // Build the list of filter fields from config\n useEffect(() => {\n const collection = getEntityConfig({ collectionSlug: slug })\n const flattenedFieldConfigs = filterList.flatMap((row, rowIndex) =>\n row.map((field, fieldIndex) => ({\n field,\n rowIndex,\n fieldIndex,\n })),\n )\n const fieldNames = flattenedFieldConfigs.map(({ field }) =>\n typeof field === 'string' ? field : field.name,\n )\n const matchedFields = findFieldsByName(collection?.fields || [], fieldNames)\n const simplifiedFields: FilterDetaild[] = matchedFields.map((field) => {\n const label = (field as FieldAffectingData).label\n const translatedLabel = getTranslation(label as string, i18n)\n const fieldName = (field as FieldAffectingData).name as string\n const fieldConfig = flattenedFieldConfigs.find(({ field: f }) =>\n typeof f === 'string' ? f === fieldName : f.name === fieldName,\n )\n return {\n name: fieldName,\n label: translatedLabel as string,\n type: field.type,\n options: (field as SelectField).options as OptionObject[],\n row: fieldConfig ? fieldConfig.rowIndex : 0,\n width:\n typeof fieldConfig?.field === 'object' && 'width' in fieldConfig.field\n ? fieldConfig.field.width\n : undefined,\n }\n })\n const sortedFields = flattenedFieldConfigs\n .map(({ field }) => {\n const fieldName = typeof field === 'string' ? field : field.name\n return simplifiedFields.find((f) => f.name === fieldName)\n })\n .filter((f): f is FilterDetaild => !!f)\n setFields(sortedFields)\n setFilterRows(groupFiltersByRow(sortedFields))\n }, [slug, filterList, getEntityConfig, i18n])\n // Sync from URL (query.where) into internal state\n useEffect(() => {\n if (fields.length === 0) return\n const valuesFromQuery: Record<string, any> = parseWhereClauseToFilterValues(\n query.where,\n fields,\n locale,\n )\n if (!isEqual(filterValues, valuesFromQuery)) {\n // Lock to prevent feedback loop when internal state changes\n setFilterValues(valuesFromQuery)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [query.where, fields])\n\n // Sync internal state (filterValues) back into the URL\n useEffect(() => {\n if (fields.length === 0) return\n const valuesFromQuery: Record<string, any> = parseWhereClauseToFilterValues(\n query.where,\n fields,\n locale,\n )\n if (Object.keys(filterValues).length == 0 && !query.where) {\n }\n if (isEqual(filterValues, valuesFromQuery)) {\n return\n }\n const quickFilterConditions = buildQuickFilterConditions(filterValues, fields, locale)\n const quickFilterFieldNames = new Set(fields.map((f) => f.name))\n const otherFilters = cleanWhereClause(query.where, quickFilterFieldNames)\n\n const allConditions = [...quickFilterConditions]\n if (otherFilters) {\n if (otherFilters.and && Array.isArray(otherFilters.and)) {\n allConditions.push(...otherFilters.and)\n } else if (Object.keys(otherFilters).length > 0) {\n allConditions.push(otherFilters)\n }\n }\n\n let newWhere: Record<string, any> = {}\n if (allConditions.length > 1) {\n newWhere = { and: allConditions }\n } else if (allConditions.length === 1) {\n newWhere = allConditions[0]\n }\n\n // Only update if the query has actually changed to avoid unnecessary updates\n if (!(isEqual(newWhere, query.where) || (Object.keys(newWhere).length == 0 && !query.where))) {\n const refinedData = {\n where: newWhere,\n page: 1,\n } as ListQuery\n\n refineListData(refinedData).then((r) => {\n console.log('Query refreshed', refinedData)\n })\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [filterValues])\n\n // Updates only the internal state\n const handleFilterChange = useCallback((fieldName: string, value: any) => {\n setFilterValues((prev) => {\n const newValues = { ...prev }\n if (\n value === undefined ||\n value === null ||\n value === 'indeterminate' ||\n (value && value.type === 'none')\n ) {\n delete newValues[fieldName]\n } else {\n newValues[fieldName] = value\n }\n return newValues\n })\n }, [])\n\n // This function remains largely the same.\n const getActiveFiltersDetails = () => {\n const activeFilters: string[] = []\n const locale = i18n.language as SupportedLocale\n Object.entries(filterValues).forEach(([fieldName, value]) => {\n const field = fields.find((f) => f.name === fieldName)\n if (!field) return\n\n switch (field.type) {\n case 'date':\n if (value !== undefined) {\n const dateValue = value as DateFilterValue\n let dateDescription = ''\n\n if (dateValue.type === 'predefined' && dateValue.predefinedValue) {\n const { pastOptions, futureOptions } = getDateFilterOptions(locale)\n const allOptions = [...pastOptions, ...futureOptions]\n const option = allOptions.find((opt) => opt.value === dateValue.predefinedValue)\n dateDescription = option ? option.label : getLabel('custom', locale)\n } else if (dateValue.type === 'custom' || dateValue.customRange) {\n dateDescription = getLabel('custom', locale)\n }\n\n if (dateDescription) {\n activeFilters.push(`${field.label} (${dateDescription})`)\n }\n }\n break\n case 'select': {\n const selectValue = value as SelectFilterValue\n if (selectValue && selectValue.selectedValues && selectValue.selectedValues.length > 0) {\n const totalOptions = field.options?.length || 0\n\n if (selectValue.selectedValues.length === totalOptions) {\n activeFilters.push(`${field.label} (${getLabel('all', locale)})`)\n } else if (selectValue.selectedValues.length === 1) {\n // Show the actual option name when only one is selected\n const selectedOption = field.options?.find(\n (opt: any) => opt.value === selectValue.selectedValues[0],\n )\n const optionLabel = selectedOption\n ? getLocalizedLabel(selectedOption.label, locale)\n : selectValue.selectedValues[0]\n activeFilters.push(`${field.label} (${optionLabel})`)\n } else {\n // Show count for multiple selections\n activeFilters.push(`${field.label} (${selectValue.selectedValues.length})`)\n }\n }\n break\n }\n case 'checkbox':\n if (value !== 'indeterminate') {\n const checkboxValue =\n value === 'checked' ? getLabel('yes', locale) : getLabel('no', locale)\n activeFilters.push(`${field.label} (${checkboxValue})`)\n }\n break\n }\n })\n\n return activeFilters\n }\n\n const clearAllFilters = () => {\n setFilterValues({})\n }\n\n const refreshFilters = () => {\n refineListData(query)\n }\n\n const memoizedFilterRows = useMemo(() => {\n return filterRows.map((row) => (\n <div key={row.rowNumber}>\n <div className=\"flex flex-wrap gap-6 mb-4\">\n {row.filters.map((field) => (\n <FilterField\n key={field.name}\n field={field}\n onFilterChange={handleFilterChange}\n value={filterValues[field.name]}\n />\n ))}\n </div>\n </div>\n ))\n }, [filterRows, handleFilterChange, filterValues])\n\n const toggleFilters = () => {\n setShowFilters((prev) => !prev)\n }\n\n const activeFiltersDetails = getActiveFiltersDetails()\n const hasActiveFilters = activeFiltersDetails.length > 0\n\n if (!fields.length) return null\n\n return (\n <div className=\"filter-container useTw\">\n <div style={{ position: 'relative', top: '-24px', height: '0px' }}>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={toggleFilters}\n className={`flex items-center gap-2 bg-background border-muted-muted hover:bg-muted ${\n hasActiveFilters ? 'w-auto min-w-fit' : ''\n }`}\n >\n <Filter className={`h-4 w-4 ${hasActiveFilters ? 'fill-current' : ''}`} />\n\n {hasActiveFilters ? (\n <>\n <span className=\"text-sm truncate\">\n <strong>\n {`${activeFiltersDetails.length === 1 ? getLabel('activeFilterSingular', locale) : getLabel('activeFilterPlural', locale)}: `}\n </strong>{' '}\n {activeFiltersDetails.join(' • ')}\n </span>\n\n <span\n onClick={(e) => {\n e.stopPropagation()\n clearAllFilters()\n }}\n className=\"ml-1 p-0.5 hover:bg-muted rounded-sm transition-colors flex-shrink-0\"\n >\n <X className=\"h-3 w-3 text-gray-500\" />\n </span>\n <span\n onClick={(e) => {\n e.stopPropagation()\n refreshFilters()\n }}\n className=\"ml-1 p-0.5 hover:bg-muted rounded-sm transition-colors flex-shrink-0\"\n >\n <RefreshCw className=\"h-3 w-3 text-gray-500\" />\n </span>\n </>\n ) : (\n <span className=\"text-sm truncate\">{getLabel('quickFilters', locale)}</span>\n )}\n\n {showFilters ? <ChevronUp className=\"h-4 w-4\" /> : <ChevronDown className=\"h-4 w-4\" />}\n </Button>\n </div>\n {showFilters && <div className={'p-4 pb-2 bg-muted'}>{memoizedFilterRows}</div>}\n </div>\n )\n}\n\nexport default QuickFilter\n"],"names":["useCallback","useEffect","useMemo","useState","useConfig","useListQuery","useTranslation","getTranslation","FilterField","getLabel","groupFiltersByRow","ChevronDown","ChevronUp","Filter","RefreshCw","X","isEqual","getDateFilterOptions","Button","buildQuickFilterConditions","parseWhereClauseToFilterValues","getLocalizedLabel","label","locale","Object","values","findFieldsByName","fields","fieldNames","results","recursiveSearch","currentFields","filteredFields","filter","field","includes","name","push","forEach","item","type","Array","isArray","tabs","tab","blocks","block","cleanWhereClause","clause","fieldsToClean","newClause","key","cleanedSubClauses","map","subClause","Boolean","length","has","keys","and","or","QuickFilter","slug","filterList","setFields","filterRows","setFilterRows","showFilters","setShowFilters","refineListData","query","getEntityConfig","i18n","language","filterValues","setFilterValues","collection","collectionSlug","flattenedFieldConfigs","flatMap","row","rowIndex","fieldIndex","matchedFields","simplifiedFields","translatedLabel","fieldName","fieldConfig","find","f","options","width","undefined","sortedFields","valuesFromQuery","where","quickFilterConditions","quickFilterFieldNames","Set","otherFilters","allConditions","newWhere","refinedData","page","then","r","console","log","handleFilterChange","value","prev","newValues","getActiveFiltersDetails","activeFilters","entries","dateValue","dateDescription","predefinedValue","pastOptions","futureOptions","allOptions","option","opt","customRange","selectValue","selectedValues","totalOptions","selectedOption","optionLabel","checkboxValue","clearAllFilters","refreshFilters","memoizedFilterRows","div","className","filters","onFilterChange","rowNumber","toggleFilters","activeFiltersDetails","hasActiveFilters","style","position","top","height","variant","size","onClick","span","strong","join","e","stopPropagation"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACjE,SAASC,SAAS,EAAEC,YAAY,EAAEC,cAAc,QAAQ,iBAAgB;AAExE,SAASC,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,iBAAiB,gBAAe;AACvC,SAASC,QAAQ,QAAyB,WAAU;AAOpD,SAASC,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,SAAS,EAAEC,CAAC,QAAQ,eAAc;AAC3E,SAASC,OAAO,QAAQ,SAAQ;AA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AEA,MAAM6B,uBAAuB3B;IAC7B,MAAM4B,mBAAmBD,qBAAqBnF,MAAM,GAAG;IAEvD,IAAI,CAAC7B,OAAO6B,MAAM,EAAE,OAAO;IAE3B,qBACE,MAAC6E;QAAIC,WAAU;;0BACb,KAACD;gBAAIQ,OAAO;oBAAEC,UAAU;oBAAYC,KAAK;oBAASC,QAAQ;gBAAM;0BAC9D,cAAA,MAAC9H;oBACC+H,SAAQ;oBACRC,MAAK;oBACLC,SAAST;oBACTJ,WAAW,CAAC,wEAAwE,EAClFM,mBAAmB,qBAAqB,IACxC;;sCAEF,KAAC/H;4BAAOyH,WAAW,CAAC,QAAQ,EAAEM,mBAAmB,iBAAiB,IAAI;;wBAErEA,iCACC;;8CACE,MAACQ;oCAAKd,WAAU;;sDACd,KAACe;sDACE,GAAGV,qBAAqBnF,MAAM,KAAK,IAAI/C,SAAS,wBAAwBc,UAAUd,SAAS,sBAAsBc,QAAQ,EAAE,CAAC;;wCACrH;wCACToH,qBAAqBW,IAAI,CAAC;;;8CAG7B,KAACF;oCACCD,SAAS,CAACI;wCACRA,EAAEC,eAAe;wCACjBtB;oCACF;oCACAI,WAAU;8CAEV,cAAA,KAACvH;wCAAEuH,WAAU;;;8CAEf,KAACc;oCACCD,SAAS,CAACI;wCACRA,EAAEC,eAAe;wCACjBrB;oCACF;oCACAG,WAAU;8CAEV,cAAA,KAACxH;wCAAUwH,WAAU;;;;2CAIzB,KAACc;4BAAKd,WAAU;sCAAoB7H,SAAS,gBAAgBc;;wBAG9D4C,4BAAc,KAACvD;4BAAU0H,WAAU;2CAAe,KAAC3H;4BAAY2H,WAAU;;;;;YAG7EnE,6BAAe,KAACkE;gBAAIC,WAAW;0BAAsBF;;;;AAG5D;AAEA,eAAevE,YAAW"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SupportedLocale } from '../../labels';
|
|
2
2
|
import { DateFilterOption } from '../types/filters-type';
|
|
3
|
-
export declare const pastOptionKeys: readonly ["yesterday", "lastWeek", "lastMonth", "last7Days", "last30Days", "
|
|
4
|
-
export declare const futureOptionKeys: readonly ["today", "thisWeek", "thisMonth", "next7Days", "next30Days", "allFuture"];
|
|
3
|
+
export declare const pastOptionKeys: readonly ["allPast", "yesterday", "lastWeek", "lastMonth", "last7Days", "last30Days", "lastYear", "last2Years"];
|
|
4
|
+
export declare const futureOptionKeys: readonly ["todayAndFuture", "today", "thisWeek", "thisMonth", "next7Days", "next30Days", "allFuture"];
|
|
5
5
|
export declare const getDateFilterOptions: (locale: SupportedLocale | string) => {
|
|
6
6
|
pastOptions: DateFilterOption[];
|
|
7
7
|
futureOptions: DateFilterOption[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-filter-options.d.ts","sourceRoot":"","sources":["../../../src/filters/constants/date-filter-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"date-filter-options.d.ts","sourceRoot":"","sources":["../../../src/filters/constants/date-filter-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,eAAO,MAAM,cAAc,iHASjB,CAAC;AACX,eAAO,MAAM,gBAAgB,uGAQnB,CAAC;AAaX,eAAO,MAAM,oBAAoB,WAAY,eAAe,GAAG,MAAM;;;CAKpE,CAAC"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { getLabel } from '../../labels';
|
|
2
2
|
// Define the option keys for past and future date filters
|
|
3
3
|
export const pastOptionKeys = [
|
|
4
|
+
'allPast',
|
|
4
5
|
'yesterday',
|
|
5
6
|
'lastWeek',
|
|
6
7
|
'lastMonth',
|
|
7
8
|
'last7Days',
|
|
8
9
|
'last30Days',
|
|
9
|
-
'
|
|
10
|
+
'lastYear',
|
|
11
|
+
'last2Years'
|
|
10
12
|
];
|
|
11
13
|
export const futureOptionKeys = [
|
|
14
|
+
'todayAndFuture',
|
|
12
15
|
'today',
|
|
13
16
|
'thisWeek',
|
|
14
17
|
'thisMonth',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/filters/constants/date-filter-options.ts"],"sourcesContent":["import type { LabelKey, SupportedLocale } from '../../labels';\nimport { getLabel } from '../../labels';\nimport { DateFilterOption } from '../types/filters-type'; // Define the option keys for past and future date filters\n\n// Define the option keys for past and future date filters\nexport const pastOptionKeys = [\n 'yesterday',\n 'lastWeek',\n 'lastMonth',\n 'last7Days',\n 'last30Days',\n '
|
|
1
|
+
{"version":3,"sources":["../../../src/filters/constants/date-filter-options.ts"],"sourcesContent":["import type { LabelKey, SupportedLocale } from '../../labels';\nimport { getLabel } from '../../labels';\nimport { DateFilterOption } from '../types/filters-type'; // Define the option keys for past and future date filters\n\n// Define the option keys for past and future date filters\nexport const pastOptionKeys = [\n 'allPast',\n 'yesterday',\n 'lastWeek',\n 'lastMonth',\n 'last7Days',\n 'last30Days',\n 'lastYear',\n 'last2Years',\n] as const;\nexport const futureOptionKeys = [\n 'todayAndFuture',\n 'today',\n 'thisWeek',\n 'thisMonth',\n 'next7Days',\n 'next30Days',\n 'allFuture',\n] as const;\n\n// Create date filter options dynamically based on locale\nconst createDateFilterOptions = (\n keys: readonly string[],\n locale: SupportedLocale | string,\n): DateFilterOption[] => {\n return keys.map((key) => ({\n value: key,\n label: getLabel(key as LabelKey, locale as SupportedLocale),\n }));\n};\n\nexport const getDateFilterOptions = (locale: SupportedLocale | string) => {\n return {\n pastOptions: createDateFilterOptions(pastOptionKeys, locale),\n futureOptions: createDateFilterOptions(futureOptionKeys, locale),\n };\n};\n"],"names":["getLabel","pastOptionKeys","futureOptionKeys","createDateFilterOptions","keys","locale","map","key","value","label","getDateFilterOptions","pastOptions","futureOptions"],"mappings":"AACA,SAASA,QAAQ,QAAQ,eAAe;AAGxC,0DAA0D;AAC1D,OAAO,MAAMC,iBAAiB;IAC5B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAU;AACX,OAAO,MAAMC,mBAAmB;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAU;AAEX,yDAAyD;AACzD,MAAMC,0BAA0B,CAC9BC,MACAC;IAEA,OAAOD,KAAKE,GAAG,CAAC,CAACC,MAAS,CAAA;YACxBC,OAAOD;YACPE,OAAOT,SAASO,KAAiBF;QACnC,CAAA;AACF;AAEA,OAAO,MAAMK,uBAAuB,CAACL;IACnC,OAAO;QACLM,aAAaR,wBAAwBF,gBAAgBI;QACrDO,eAAeT,wBAAwBD,kBAAkBG;IAC3D;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-helpers.d.ts","sourceRoot":"","sources":["../../../src/filters/utils/date-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAY,MAAM,cAAc,CAAC;AAEzD,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAItD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAExD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAExD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAI1D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAE1D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,G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BAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAI1D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAE1D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAI3C;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAIzC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,IAAI,CAOrF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,IAAI,CAKnF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAI7C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAI3C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAqBhE;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,eAAsB,GAC7B;IAAE,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IAAC,EAAE,EAAE,IAAI,GAAG,SAAS,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAyIvE"}
|
|
@@ -123,6 +123,26 @@ export function getDateRangeForOption(option, locale = 'he') {
|
|
|
123
123
|
to: endOfDay(now),
|
|
124
124
|
description: `(${formatDate(last30DaysStart, 'dd/MM')}-${formatDate(now, 'dd/MM/yyyy')})`
|
|
125
125
|
};
|
|
126
|
+
case 'lastYear':
|
|
127
|
+
{
|
|
128
|
+
const lastYearStart = new Date(now.getFullYear() - 1, 0, 1); // Jan 1 of last year
|
|
129
|
+
const lastYearEnd = new Date(now.getFullYear() - 1, 11, 31, 23, 59, 59, 999); // Dec 31 of last year
|
|
130
|
+
return {
|
|
131
|
+
from: lastYearStart,
|
|
132
|
+
to: lastYearEnd,
|
|
133
|
+
description: `(${formatDate(lastYearStart, 'yyyy')})`
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
case 'last2Years':
|
|
137
|
+
{
|
|
138
|
+
const twoYearsAgoStart = new Date(now.getFullYear() - 2, 0, 1); // Jan 1 of two years ago
|
|
139
|
+
const lastYearEnd = new Date(now.getFullYear() - 1, 11, 31, 23, 59, 59, 999); // Dec 31 of last year
|
|
140
|
+
return {
|
|
141
|
+
from: twoYearsAgoStart,
|
|
142
|
+
to: lastYearEnd,
|
|
143
|
+
description: `(${formatDate(twoYearsAgoStart, 'yyyy')}-${formatDate(lastYearEnd, 'yyyy')})`
|
|
144
|
+
};
|
|
145
|
+
}
|
|
126
146
|
case 'allPast':
|
|
127
147
|
{
|
|
128
148
|
const yesterday = subDays(now, 1);
|
|
@@ -172,6 +192,12 @@ export function getDateRangeForOption(option, locale = 'he') {
|
|
|
172
192
|
to: next30DaysEnd,
|
|
173
193
|
description: `(${formatDate(now, 'dd/MM')}-${formatDate(next30DaysEnd, 'dd/MM/yyyy')})`
|
|
174
194
|
};
|
|
195
|
+
case 'todayAndFuture':
|
|
196
|
+
return {
|
|
197
|
+
from: startOfDay(now),
|
|
198
|
+
to: undefined,
|
|
199
|
+
description: `(${getLabel('presentFuture', locale)})`
|
|
200
|
+
};
|
|
175
201
|
case 'allFuture':
|
|
176
202
|
return {
|
|
177
203
|
from: startOfDay(now),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/filters/utils/date-helpers.ts"],"sourcesContent":["// Custom date utilities to replace date-fns\n\nimport { SupportedLocale, getLabel } from '../../labels';\n\nexport function addDays(date: Date, days: number): Date {\n const result = new Date(date);\n result.setDate(result.getDate() + days);\n return result;\n}\n\nexport function subDays(date: Date, days: number): Date {\n return addDays(date, -days);\n}\n\nexport function addWeeks(date: Date, weeks: number): Date {\n return addDays(date, weeks * 7);\n}\n\nexport function subWeeks(date: Date, weeks: number): Date {\n return addWeeks(date, -weeks);\n}\n\nexport function addMonths(date: Date, months: number): Date {\n const result = new Date(date);\n result.setMonth(result.getMonth() + months);\n return result;\n}\n\nexport function subMonths(date: Date, months: number): Date {\n return addMonths(date, -months);\n}\n\nexport function startOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\nexport function endOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(23, 59, 59, 999);\n return result;\n}\n\nexport function startOfWeek(date: Date, options: { weekStartsOn?: number } = {}): Date {\n const { weekStartsOn = 0 } = options;\n const result = new Date(date);\n const day = result.getDay();\n const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;\n result.setDate(result.getDate() - diff);\n return startOfDay(result);\n}\n\nexport function endOfWeek(date: Date, options: { weekStartsOn?: number } = {}): Date {\n const { weekStartsOn = 0 } = options;\n const result = startOfWeek(date, { weekStartsOn });\n result.setDate(result.getDate() + 6);\n return endOfDay(result);\n}\n\nexport function startOfMonth(date: Date): Date {\n const result = new Date(date);\n result.setDate(1);\n return startOfDay(result);\n}\n\nexport function endOfMonth(date: Date): Date {\n const result = new Date(date);\n result.setMonth(result.getMonth() + 1, 0);\n return endOfDay(result);\n}\n\nexport function formatDate(date: Date, formatStr: string): string {\n const day = date.getDate().toString().padStart(2, '0');\n const month = (date.getMonth() + 1).toString().padStart(2, '0');\n const year = date.getFullYear().toString();\n\n switch (formatStr) {\n case 'dd/MM/yyyy':\n return `${day}/${month}/${year}`;\n case 'dd/MM':\n return `${day}/${month}`;\n case 'MM/yyyy':\n return `${month}/${year}`;\n case 'PPP':\n return date.toLocaleDateString('en-US', {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n });\n default:\n return date.toLocaleDateString();\n }\n}\n\nexport function getDateRangeForOption(\n option: string,\n locale: SupportedLocale = 'he',\n): { from: Date | undefined; to: Date | undefined; description: string } {\n const now = new Date();\n\n switch (option) {\n case 'yesterday':\n const yesterday = subDays(now, 1);\n return {\n from: startOfDay(yesterday),\n to: endOfDay(yesterday),\n description: `(${formatDate(yesterday, 'dd/MM/yyyy')})`,\n };\n\n case 'lastWeek':\n const lastWeekStart = startOfWeek(subWeeks(now, 1), { weekStartsOn: 0 });\n const lastWeekEnd = endOfWeek(subWeeks(now, 1), { weekStartsOn: 0 });\n return {\n from: lastWeekStart,\n to: lastWeekEnd,\n description: `(${formatDate(lastWeekStart, 'dd/MM')}-${formatDate(lastWeekEnd, 'dd/MM/yyyy')})`,\n };\n\n case 'lastMonth':\n const lastMonthStart = startOfMonth(subMonths(now, 1));\n const lastMonthEnd = endOfMonth(subMonths(now, 1));\n return {\n from: lastMonthStart,\n to: lastMonthEnd,\n description: `(${formatDate(lastMonthStart, 'MM/yyyy')})`,\n };\n\n case 'last7Days':\n const last7DaysStart = startOfDay(subDays(now, 6));\n return {\n from: last7DaysStart,\n to: endOfDay(now),\n description: `(${formatDate(last7DaysStart, 'dd/MM')}-${formatDate(now, 'dd/MM/yyyy')})`,\n };\n\n case 'last30Days':\n const last30DaysStart = startOfDay(subDays(now, 29));\n return {\n from: last30DaysStart,\n to: endOfDay(now),\n description: `(${formatDate(last30DaysStart, 'dd/MM')}-${formatDate(now, 'dd/MM/yyyy')})`,\n };\n\n case 'allPast': {\n const yesterday = subDays(now, 1);\n return {\n from: undefined,\n to: endOfDay(yesterday),\n description: `(${getLabel('allPast', locale)})`,\n };\n }\n\n case 'today':\n return {\n from: startOfDay(now),\n to: endOfDay(now),\n description: `(${formatDate(now, 'dd/MM/yyyy')})`,\n };\n\n case 'thisWeek':\n const thisWeekStart = startOfWeek(now, { weekStartsOn: 0 });\n const thisWeekEnd = endOfWeek(now, { weekStartsOn: 0 });\n return {\n from: thisWeekStart,\n to: thisWeekEnd,\n description: `(${formatDate(thisWeekStart, 'dd/MM')}-${formatDate(thisWeekEnd, 'dd/MM/yyyy')})`,\n };\n\n case 'thisMonth':\n const thisMonthStart = startOfMonth(now);\n const thisMonthEnd = endOfMonth(now);\n return {\n from: thisMonthStart,\n to: thisMonthEnd,\n description: `(${formatDate(thisMonthStart, 'MM/yyyy')})`,\n };\n\n case 'next7Days':\n const next7DaysEnd = endOfDay(addDays(now, 6));\n return {\n from: startOfDay(now),\n to: next7DaysEnd,\n description: `(${formatDate(now, 'dd/MM')}-${formatDate(next7DaysEnd, 'dd/MM/yyyy')})`,\n };\n\n case 'next30Days':\n const next30DaysEnd = endOfDay(addDays(now, 29));\n return {\n from: startOfDay(now),\n to: next30DaysEnd,\n description: `(${formatDate(now, 'dd/MM')}-${formatDate(next30DaysEnd, 'dd/MM/yyyy')})`,\n };\n\n case 'allFuture':\n return {\n from: startOfDay(now),\n to: undefined,\n description: `(${getLabel('allFuture', locale)})`,\n };\n\n default:\n return {\n from: startOfDay(now),\n to: endOfDay(now),\n description: '',\n };\n }\n}\n"],"names":["getLabel","addDays","date","days","result","Date","setDate","getDate","subDays","addWeeks","weeks","subWeeks","addMonths","months","setMonth","getMonth","subMonths","startOfDay","setHours","endOfDay","startOfWeek","options","weekStartsOn","day","getDay","diff","endOfWeek","startOfMonth","endOfMonth","formatDate","formatStr","toString","padStart","month","year","getFullYear","toLocaleDateString","getDateRangeForOption","option","locale","now","yesterday","from","to","description","lastWeekStart","lastWeekEnd","lastMonthStart","lastMonthEnd","last7DaysStart","last30DaysStart","undefined","thisWeekStart","thisWeekEnd","thisMonthStart","thisMonthEnd","next7DaysEnd","next30DaysEnd"],"mappings":"AAAA,4CAA4C;AAE5C,SAA0BA,QAAQ,QAAQ,eAAe;AAEzD,OAAO,SAASC,QAAQC,IAAU,EAAEC,IAAY;IAC9C,MAAMC,SAAS,IAAIC,KAAKH;IACxBE,OAAOE,OAAO,CAACF,OAAOG,OAAO,KAAKJ;IAClC,OAAOC;AACT;AAEA,OAAO,SAASI,QAAQN,IAAU,EA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;YACnD;QAEF,KAAK;YACH,MAAMY,gBAAgBhC,YAAYoB,KAAK;gBAAElB,cAAc;YAAE;YACzD,MAAM+B,cAAc3B,UAAUc,KAAK;gBAAElB,cAAc;YAAE;YACrD,OAAO;gBACLoB,MAAMU;gBACNT,IAAIU;gBACJT,aAAa,CAAC,CAAC,EAAEf,WAAWuB,eAAe,SAAS,CAAC,EAAEvB,WAAWwB,aAAa,cAAc,CAAC,CAAC;YACjG;QAEF,KAAK;YACH,MAAMC,iBAAiB3B,aAAaa;YACpC,MAAMe,eAAe3B,WAAWY;YAChC,OAAO;gBACLE,MAAMY;gBACNX,IAAIY;gBACJX,aAAa,CAAC,CAAC,EAAEf,WAAWyB,gBAAgB,WAAW,CAAC,CAAC;YAC3D;QAEF,KAAK;YACH,MAAME,eAAerC,SAASlB,QAAQuC,KAAK;YAC3C,OAAO;gBACLE,MAAMzB,WAAWuB;gBACjBG,IAAIa;gBACJZ,aAAa,CAAC,CAAC,EAAEf,WAAWW,KAAK,SAAS,CAAC,EAAEX,WAAW2B,cAAc,cAAc,CAAC,CAAC;YACxF;QAEF,KAAK;YACH,MAAMC,gBAAgBtC,SAASlB,QAAQuC,KAAK;YAC5C,OAAO;gBACLE,MAAMzB,WAAWuB;gBACjBG,IAAIc;gBACJb,aAAa,CAAC,CAAC,EAAEf,WAAWW,KAAK,SAAS,CAAC,EAAEX,WAAW4B,eAAe,cAAc,CAAC,CAAC;YACzF;QAEF,KAAK;YACH,OAAO;gBACLf,MAAMzB,WAAWuB;gBACjBG,IAAIQ;gBACJP,aAAa,CAAC,CAAC,EAAE5C,SAAS,aAAauC,QAAQ,CAAC,CAAC;YACnD;QAEF;YACE,OAAO;gBACLG,MAAMzB,WAAWuB;gBACjBG,IAAIxB,SAASqB;gBACbI,aAAa;YACf;IACJ;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/filters/utils/date-helpers.ts"],"sourcesContent":["// Custom date utilities to replace date-fns\n\nimport { SupportedLocale, getLabel } from '../../labels';\n\nexport function addDays(date: Date, days: number): Date {\n const result = new Date(date);\n result.setDate(result.getDate() + days);\n return result;\n}\n\nexport function subDays(date: Date, days: number): Date {\n return addDays(date, -days);\n}\n\nexport function addWeeks(date: Date, weeks: number): Date {\n return addDays(date, weeks * 7);\n}\n\nexport function subWeeks(date: Date, weeks: number): Date {\n return addWeeks(date, -weeks);\n}\n\nexport function addMonths(date: Date, months: number): Date {\n const result = new Date(date);\n result.setMonth(result.getMonth() + months);\n return result;\n}\n\nexport function subMonths(date: Date, months: number): Date {\n return addMonths(date, -months);\n}\n\nexport function startOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\nexport function endOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(23, 59, 59, 999);\n return result;\n}\n\nexport function startOfWeek(date: Date, options: { weekStartsOn?: number } = {}): Date {\n const { weekStartsOn = 0 } = options;\n const result = new Date(date);\n const day = result.getDay();\n const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;\n result.setDate(result.getDate() - diff);\n return startOfDay(result);\n}\n\nexport function endOfWeek(date: Date, options: { weekStartsOn?: number } = {}): Date {\n const { weekStartsOn = 0 } = options;\n const result = startOfWeek(date, { weekStartsOn });\n result.setDate(result.getDate() + 6);\n return endOfDay(result);\n}\n\nexport function startOfMonth(date: Date): Date {\n const result = new Date(date);\n result.setDate(1);\n return startOfDay(result);\n}\n\nexport function endOfMonth(date: Date): Date {\n const result = new Date(date);\n result.setMonth(result.getMonth() + 1, 0);\n return endOfDay(result);\n}\n\nexport function formatDate(date: Date, formatStr: string): string {\n const day = date.getDate().toString().padStart(2, '0');\n const month = (date.getMonth() + 1).toString().padStart(2, '0');\n const year = date.getFullYear().toString();\n\n switch (formatStr) {\n case 'dd/MM/yyyy':\n return `${day}/${month}/${year}`;\n case 'dd/MM':\n return `${day}/${month}`;\n case 'MM/yyyy':\n return `${month}/${year}`;\n case 'PPP':\n return date.toLocaleDateString('en-US', {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n });\n default:\n return date.toLocaleDateString();\n }\n}\n\nexport function getDateRangeForOption(\n option: string,\n locale: SupportedLocale = 'he',\n): { from: Date | undefined; to: Date | undefined; description: string } {\n const now = new Date();\n\n switch (option) {\n case 'yesterday':\n const yesterday = subDays(now, 1);\n return {\n from: startOfDay(yesterday),\n to: endOfDay(yesterday),\n description: `(${formatDate(yesterday, 'dd/MM/yyyy')})`,\n };\n\n case 'lastWeek':\n const lastWeekStart = startOfWeek(subWeeks(now, 1), { weekStartsOn: 0 });\n const lastWeekEnd = endOfWeek(subWeeks(now, 1), { weekStartsOn: 0 });\n return {\n from: lastWeekStart,\n to: lastWeekEnd,\n description: `(${formatDate(lastWeekStart, 'dd/MM')}-${formatDate(lastWeekEnd, 'dd/MM/yyyy')})`,\n };\n\n case 'lastMonth':\n const lastMonthStart = startOfMonth(subMonths(now, 1));\n const lastMonthEnd = endOfMonth(subMonths(now, 1));\n return {\n from: lastMonthStart,\n to: lastMonthEnd,\n description: `(${formatDate(lastMonthStart, 'MM/yyyy')})`,\n };\n\n case 'last7Days':\n const last7DaysStart = startOfDay(subDays(now, 6));\n return {\n from: last7DaysStart,\n to: endOfDay(now),\n description: `(${formatDate(last7DaysStart, 'dd/MM')}-${formatDate(now, 'dd/MM/yyyy')})`,\n };\n\n case 'last30Days':\n const last30DaysStart = startOfDay(subDays(now, 29));\n return {\n from: last30DaysStart,\n to: endOfDay(now),\n description: `(${formatDate(last30DaysStart, 'dd/MM')}-${formatDate(now, 'dd/MM/yyyy')})`,\n };\n\n case 'lastYear': {\n const lastYearStart = new Date(now.getFullYear() - 1, 0, 1); // Jan 1 of last year\n const lastYearEnd = new Date(now.getFullYear() - 1, 11, 31, 23, 59, 59, 999); // Dec 31 of last year\n return {\n from: lastYearStart,\n to: lastYearEnd,\n description: `(${formatDate(lastYearStart, 'yyyy')})`,\n };\n }\n\n case 'last2Years': {\n const twoYearsAgoStart = new Date(now.getFullYear() - 2, 0, 1); // Jan 1 of two years ago\n const lastYearEnd = new Date(now.getFullYear() - 1, 11, 31, 23, 59, 59, 999); // Dec 31 of last year\n return {\n from: twoYearsAgoStart,\n to: lastYearEnd,\n description: `(${formatDate(twoYearsAgoStart, 'yyyy')}-${formatDate(lastYearEnd, 'yyyy')})`,\n };\n }\n\n case 'allPast': {\n const yesterday = subDays(now, 1);\n return {\n from: undefined,\n to: endOfDay(yesterday),\n description: `(${getLabel('allPast', locale)})`,\n };\n }\n\n case 'today':\n return {\n from: startOfDay(now),\n to: endOfDay(now),\n description: `(${formatDate(now, 'dd/MM/yyyy')})`,\n };\n\n case 'thisWeek':\n const thisWeekStart = startOfWeek(now, { weekStartsOn: 0 });\n const thisWeekEnd = endOfWeek(now, { weekStartsOn: 0 });\n return {\n from: thisWeekStart,\n to: thisWeekEnd,\n description: `(${formatDate(thisWeekStart, 'dd/MM')}-${formatDate(thisWeekEnd, 'dd/MM/yyyy')})`,\n };\n\n case 'thisMonth':\n const thisMonthStart = startOfMonth(now);\n const thisMonthEnd = endOfMonth(now);\n return {\n from: thisMonthStart,\n to: thisMonthEnd,\n description: `(${formatDate(thisMonthStart, 'MM/yyyy')})`,\n };\n\n case 'next7Days':\n const next7DaysEnd = endOfDay(addDays(now, 6));\n return {\n from: startOfDay(now),\n to: next7DaysEnd,\n description: `(${formatDate(now, 'dd/MM')}-${formatDate(next7DaysEnd, 'dd/MM/yyyy')})`,\n };\n\n case 'next30Days':\n const next30DaysEnd = endOfDay(addDays(now, 29));\n return {\n from: startOfDay(now),\n to: next30DaysEnd,\n description: `(${formatDate(now, 'dd/MM')}-${formatDate(next30DaysEnd, 'dd/MM/yyyy')})`,\n };\n\n case 'todayAndFuture':\n return {\n from: startOfDay(now),\n to: undefined,\n description: `(${getLabel('presentFuture', locale)})`,\n };\n\n case 'allFuture':\n return {\n from: startOfDay(now),\n to: undefined,\n description: `(${getLabel('allFuture', locale)})`,\n };\n\n default:\n return {\n from: startOfDay(now),\n to: endOfDay(now),\n description: '',\n };\n }\n}\n"],"names":["getLabel","addDays","date","days","result","Date","setDate","getDate","subDays","addWeeks","weeks","subWeeks","addMonths","months","setMonth","getMonth","subMonths","startOfDay","setHours","endOfDay","startOfWeek","options","weekStartsOn","day","getDay","diff","endOfWeek","startOfMonth","endOfMonth","formatDate","formatStr","toString","padStart","month","year","getFullYear","toLocaleDateString","getDateRangeForOption","option","locale","now","yesterday","from","to","description","lastWeekStart","lastWeekEnd","lastMonthStart","lastMonthEnd","last7DaysStart","last30DaysStart","lastYearStart","lastYearEnd","twoYearsAgoStart","undefined","thisWeekStart","thisWeekEnd","thisMonthStart","thisMonthEnd","next7DaysEnd","next30DaysEnd"],"mappings":"AAAA,4CAA4C;AAE5C,SAA0BA,QAAQ,QAAQ,eAAe;AAEzD,OAAO,SAASC,QAAQC,IAAU,EAAEC,IAAY;IAC9C,MAAMC,SAAS,IAAIC,KAAKH;IACxBE,OAAOE,OAAO,CAACF,OAAOG,OAAO,KAAKJ;IAClC,OAAOC;AACT;AAEA,OAAO,SAASI,QAAQN,IAAU,EAAEC,IAAY;IAC9C,OAAOF,QAAQC,MAAM,CAACC;AACxB;AAEA,OAAO,SAASM,SAASP,IAAU,EAAEQ,KAAa;IAChD,OAAOT,QAAQC,MAAMQ,QAAQ;AAC/B;AAEA,OAAO,SAASC,SAAST,IAAU,EAAEQ,KAAa;IAChD,OAAOD,SAASP,MAAM,CAACQ;AACzB;AAEA,OAAO,SAASE,UAAUV,IAAU,EAAEW,MAAc;IAClD,MAAMT,SAAS,IAAIC,KAAKH;IACxBE,OAAOU,QAAQ,CAACV,OAAOW,QAAQ,KAAKF;IACpC,OAAOT;AACT;AAEA,OAAO,SAASY,UAAUd,IAAU,EAAEW,MAAc;IAClD,OAAOD,UAAUV,MAAM,CAACW;AAC1B;AAEA,OAAO,SAASI,WAAWf,IAAU;IACnC,MAAME,SAAS,IAAIC,KAAKH;IACxBE,OAAOc,QAAQ,CAAC,GAAG,GAAG,GAAG;IACzB,OAAOd;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aAAa,CAAC,CAAC,EAAE5C,SAAS,aAAauC,QAAQ,CAAC,CAAC;YACnD;QAEF;YACE,OAAO;gBACLG,MAAMzB,WAAWuB;gBACjBG,IAAIxB,SAASqB;gBACbI,aAAa;YACf;IACJ;AACF"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,MAAM,4BAA4B,GAAG;IACzC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAC;IACvC,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,2BAA2B,mBACtB,4BAA4B,cACnC,MAAM,KAAG,MA8DjB,CAAC;AAEJ,eAAe,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtD,cAAc,aAAa,CAAC;AAE5B,MAAM,MAAM,4BAA4B,GAAG;IACzC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAC;IACvC,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,2BAA2B,mBACtB,4BAA4B,cACnC,MAAM,KAAG,MA8DjB,CAAC;AAEJ,eAAe,2BAA2B,CAAC"}
|