@shefing/quickfilter 1.0.46 → 1.0.52

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.
@@ -1 +1 @@
1
- {"version":3,"file":"FilterField.d.ts","sourceRoot":"","sources":["../src/FilterField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAS3C,QAAA,MAAM,WAAW,uDAId;IACD,KAAK,EAAE,GAAG,CAAC;IACX,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACxD,KAAK,EAAE,GAAG,CAAC;CACZ,sBAsFA,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"FilterField.d.ts","sourceRoot":"","sources":["../src/FilterField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAS3C,QAAA,MAAM,WAAW,uDAId;IACD,KAAK,EAAE,GAAG,CAAC;IACX,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACxD,KAAK,EAAE,GAAG,CAAC;CACZ,sBAkGA,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,4 +1,3 @@
1
- // FilterField.tsx (הקובץ המתוקן)
2
1
  'use client';
3
2
  import { jsx as _jsx } from "react/jsx-runtime";
4
3
  import React, { useCallback } from 'react';
@@ -18,22 +17,37 @@ const FilterField = ({ field, onFilterChange, value: controlledValue })=>{
18
17
  direction
19
18
  };
20
19
  const handleDateFilterChange = useCallback((value)=>{
21
- onFilterChange(field.name, value);
20
+ let fieldName = field.name;
21
+ if (typeof field.virtual === 'string') {
22
+ fieldName = field.virtual;
23
+ }
24
+ onFilterChange(fieldName, value);
22
25
  }, [
23
26
  onFilterChange,
24
- field.name
27
+ field.name,
28
+ field.virtual
25
29
  ]);
26
30
  const handleSelectFilterChange = useCallback((value)=>{
27
- onFilterChange(field.name, value);
31
+ let fieldName = field.name;
32
+ if (typeof field.virtual === 'string') {
33
+ fieldName = field.virtual;
34
+ }
35
+ onFilterChange(fieldName, value);
28
36
  }, [
29
37
  onFilterChange,
30
- field.name
38
+ field.name,
39
+ field.virtual
31
40
  ]);
32
41
  const handleCheckboxFilterChange = useCallback((state)=>{
33
- onFilterChange(field.name, state);
42
+ let fieldName = field.name;
43
+ if (typeof field.virtual === 'string') {
44
+ fieldName = field.virtual;
45
+ }
46
+ onFilterChange(fieldName, state);
34
47
  }, [
35
48
  onFilterChange,
36
- field.name
49
+ field.name,
50
+ field.virtual
37
51
  ]);
38
52
  switch(field.type){
39
53
  case 'date':
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/FilterField.tsx"],"sourcesContent":["// FilterField.tsx (הקובץ המתוקן)\n\n'use client';\nimport React, { useCallback } from 'react';\nimport { useTranslation } from '@payloadcms/ui';\nimport { getTranslation, rtlLanguages } from '@payloadcms/translations';\nimport { Locale } from './filters/types/filters-type';\nimport { DateFilter } from './filters/components/date-filter';\nimport { SmallSelectFilter } from './filters/components/small-select-filter';\nimport { SelectFilter } from './filters/components/select-filter';\nimport { CheckboxFilter } from './filters/components/checkbox-filter';\n\nconst FilterField = ({\n field,\n onFilterChange,\n value: controlledValue,\n}: {\n field: any;\n onFilterChange: (fieldName: string, value: any) => void;\n value: any;\n}) => {\n const { i18n } = useTranslation();\n const localeLang = i18n.language;\n const isRTL = (rtlLanguages as readonly string[]).includes(localeLang);\n const direction = isRTL ? 'rtl' : 'ltr';\n const locale = { code: localeLang, direction } as Locale;\n\n const handleDateFilterChange = useCallback(\n (value: any) => {\n onFilterChange(field.name, value);\n },\n [onFilterChange, field.name],\n );\n\n const handleSelectFilterChange = useCallback(\n (value: any) => {\n onFilterChange(field.name, value);\n },\n [onFilterChange, field.name],\n );\n\n const handleCheckboxFilterChange = useCallback(\n (state: any) => {\n onFilterChange(field.name, state);\n },\n [onFilterChange, field.name],\n );\n\n switch (field.type) {\n case 'date':\n return (\n <DateFilter\n label={field.label}\n value={controlledValue}\n key={field.name}\n onChange={handleDateFilterChange}\n locale={locale}\n style={{ width: field.width || '230px' }}\n />\n );\n case 'select':\n if (field.options.length <= 3) {\n return (\n <SmallSelectFilter\n label={field.label}\n key={field.name}\n options={(field.options || []).map((option: any) => ({\n label: getTranslation(option.label, i18n),\n value: option.value,\n }))}\n onChange={handleSelectFilterChange}\n value={controlledValue}\n locale={locale}\n style={{ width: field.width || '230px' }}\n />\n );\n }\n return (\n <SelectFilter\n label={field.label}\n key={field.name}\n options={(field.options || []).map((option: any) => ({\n label: getTranslation(option.label, i18n),\n value: option.value,\n }))}\n onChange={handleSelectFilterChange}\n value={controlledValue}\n locale={locale}\n style={{ width: field.width || '230px' }}\n />\n );\n case 'checkbox':\n return (\n <CheckboxFilter\n label={field.label}\n key={field.name}\n onChange={handleCheckboxFilterChange}\n value={controlledValue}\n checkboxLabel={''}\n locale={locale}\n style={{ width: field.width || '230px' }}\n />\n );\n default:\n return null;\n }\n};\n\nexport default FilterField;\n"],"names":["React","useCallback","useTranslation","getTranslation","rtlLanguages","DateFilter","SmallSelectFilter","SelectFilter","CheckboxFilter","FilterField","field","onFilterChange","value","controlledValue","i18n","localeLang","language","isRTL","includes","direction","locale","code","handleDateFilterChange","name","handleSelectFilterChange","handleCheckboxFilterChange","state","type","label","onChange","style","width","options","length","map","option","checkboxLabel"],"mappings":"AAAA,iCAAiC;AAEjC;;AACA,OAAOA,SAASC,WAAW,QAAQ,QAAQ;AAC3C,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,cAAc,EAAEC,YAAY,QAAQ,2BAA2B;AAExE,SAASC,UAAU,QAAQ,mCAAmC;AAC9D,SAASC,iBAAiB,QAAQ,2CAA2C;AAC7E,SAASC,YAAY,QAAQ,qCAAqC;AAClE,SAASC,cAAc,QAAQ,uCAAuC;AAEtE,MAAMC,cAAc,CAAC,EACnBC,KAAK,EACLC,cAAc,EACdC,OAAOC,eAAe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qBACE,KAAChB;gBACCqB,OAAOlB,MAAMkB,KAAK;gBAElBI,SAAS,AAACtB,CAAAA,MAAMsB,OAAO,IAAI,EAAE,AAAD,EAAGE,GAAG,CAAC,CAACC,SAAiB,CAAA;wBACnDP,OAAOzB,eAAegC,OAAOP,KAAK,EAAEd;wBACpCF,OAAOuB,OAAOvB,KAAK;oBACrB,CAAA;gBACAiB,UAAUL;gBACVZ,OAAOC;gBACPO,QAAQA;gBACRU,OAAO;oBAAEC,OAAOrB,MAAMqB,KAAK,IAAI;gBAAQ;eARlCrB,MAAMa,IAAI;QAWrB,KAAK;YACH,qBACE,KAACf;gBACCoB,OAAOlB,MAAMkB,KAAK;gBAElBC,UAAUJ;gBACVb,OAAOC;gBACPuB,eAAe;gBACfhB,QAAQA;gBACRU,OAAO;oBAAEC,OAAOrB,MAAMqB,KAAK,IAAI;gBAAQ;eALlCrB,MAAMa,IAAI;QAQrB;YACE,OAAO;IACX;AACF;AAEA,eAAed,YAAY"}
1
+ {"version":3,"sources":["../src/FilterField.tsx"],"sourcesContent":["'use client';\nimport React, { useCallback } from 'react';\nimport { useTranslation } from '@payloadcms/ui';\nimport { getTranslation, rtlLanguages } from '@payloadcms/translations';\nimport { Locale } from './filters/types/filters-type';\nimport { DateFilter } from './filters/components/date-filter';\nimport { SmallSelectFilter } from './filters/components/small-select-filter';\nimport { SelectFilter } from './filters/components/select-filter';\nimport { CheckboxFilter } from './filters/components/checkbox-filter';\n\nconst FilterField = ({\n field,\n onFilterChange,\n value: controlledValue,\n}: {\n field: any;\n onFilterChange: (fieldName: string, value: any) => void;\n value: any;\n}) => {\n const { i18n } = useTranslation();\n const localeLang = i18n.language;\n const isRTL = (rtlLanguages as readonly string[]).includes(localeLang);\n const direction = isRTL ? 'rtl' : 'ltr';\n const locale = { code: localeLang, direction } as Locale;\n\n const handleDateFilterChange = useCallback(\n (value: any) => {\n let fieldName = field.name;\n if (typeof field.virtual === 'string') {\n fieldName = field.virtual;\n }\n onFilterChange(fieldName, value);\n },\n [onFilterChange, field.name, field.virtual],\n );\n\n const handleSelectFilterChange = useCallback(\n (value: any) => {\n let fieldName = field.name;\n if (typeof field.virtual === 'string') {\n fieldName = field.virtual;\n }\n onFilterChange(fieldName, value);\n },\n [onFilterChange, field.name, field.virtual],\n );\n\n const handleCheckboxFilterChange = useCallback(\n (state: any) => {\n let fieldName = field.name;\n if (typeof field.virtual === 'string') {\n fieldName = field.virtual;\n }\n onFilterChange(fieldName, state);\n },\n [onFilterChange, field.name, field.virtual],\n );\n\n switch (field.type) {\n case 'date':\n return (\n <DateFilter\n label={field.label}\n value={controlledValue}\n key={field.name}\n onChange={handleDateFilterChange}\n locale={locale}\n style={{ width: field.width || '230px' }}\n />\n );\n case 'select':\n if (field.options.length <= 3) {\n return (\n <SmallSelectFilter\n label={field.label}\n key={field.name}\n options={(field.options || []).map((option: any) => ({\n label: getTranslation(option.label, i18n),\n value: option.value,\n }))}\n onChange={handleSelectFilterChange}\n value={controlledValue}\n locale={locale}\n style={{ width: field.width || '230px' }}\n />\n );\n }\n return (\n <SelectFilter\n label={field.label}\n key={field.name}\n options={(field.options || []).map((option: any) => ({\n label: getTranslation(option.label, i18n),\n value: option.value,\n }))}\n onChange={handleSelectFilterChange}\n value={controlledValue}\n locale={locale}\n style={{ width: field.width || '230px' }}\n />\n );\n case 'checkbox':\n return (\n <CheckboxFilter\n label={field.label}\n key={field.name}\n onChange={handleCheckboxFilterChange}\n value={controlledValue}\n checkboxLabel={''}\n locale={locale}\n style={{ width: field.width || '230px' }}\n />\n );\n default:\n return null;\n }\n};\n\nexport default FilterField;\n"],"names":["React","useCallback","useTranslation","getTranslation","rtlLanguages","DateFilter","SmallSelectFilter","SelectFilter","CheckboxFilter","FilterField","field","onFilterChange","value","controlledValue","i18n","localeLang","language","isRTL","includes","direction","locale","code","handleDateFilterChange","fieldName","name","virtual","handleSelectFilterChange","handleCheckboxFilterChange","state","type","label","onChange","style","width","options","length","map","option","checkboxLabel"],"mappings":"AAAA;;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;eALlCvB,MAAMc,IAAI;QAQrB;YACE,OAAO;IACX;AACF;AAEA,eAAef,YAAY"}
@@ -1 +1 @@
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,gCA2RA,CAAA;AAED,eAAe,WAAW,CAAA"}
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,gCA+SA,CAAA;AAED,eAAe,WAAW,CAAA"}
@@ -142,7 +142,13 @@ const QuickFilter = ({ slug, filterList })=>{
142
142
  return;
143
143
  }
144
144
  const quickFilterConditions = buildQuickFilterConditions(filterValues, fields, locale);
145
- const quickFilterFieldNames = new Set(fields.map((f)=>f.name));
145
+ const quickFilterFieldNames = new Set(fields.map((f)=>{
146
+ let name = f.name;
147
+ if (typeof f.virtual === 'string') {
148
+ name = f.virtual;
149
+ }
150
+ return name;
151
+ }));
146
152
  const otherFilters = cleanWhereClause(query.where, quickFilterFieldNames);
147
153
  const allConditions = [
148
154
  ...quickFilterConditions
@@ -195,7 +201,13 @@ const QuickFilter = ({ slug, filterList })=>{
195
201
  const activeFilters = [];
196
202
  const locale = i18n.language;
197
203
  Object.entries(filterValues).forEach(([fieldName, value])=>{
198
- const field = fields.find((f)=>f.name === fieldName);
204
+ const field = fields.find((f)=>{
205
+ let name = f.name;
206
+ if (typeof f.virtual === 'string') {
207
+ name = f.virtual;
208
+ }
209
+ return name === fieldName;
210
+ });
199
211
  if (!field) return;
200
212
  switch(field.type){
201
213
  case 'date':
@@ -257,11 +269,17 @@ const QuickFilter = ({ slug, filterList })=>{
257
269
  return filterRows.map((row)=>/*#__PURE__*/ _jsx("div", {
258
270
  children: /*#__PURE__*/ _jsx("div", {
259
271
  className: "flex flex-wrap gap-6 mb-4",
260
- children: row.filters.map((field)=>/*#__PURE__*/ _jsx(FilterField, {
272
+ children: row.filters.map((field)=>{
273
+ let fieldName = field.name;
274
+ if (typeof field.virtual === 'string') {
275
+ fieldName = field.virtual;
276
+ }
277
+ return /*#__PURE__*/ _jsx(FilterField, {
261
278
  field: field,
262
279
  onFilterChange: handleFilterChange,
263
- value: filterValues[field.name]
264
- }, field.name))
280
+ value: filterValues[fieldName]
281
+ }, field.name);
282
+ })
265
283
  })
266
284
  }, row.rowNumber));
267
285
  }, [
@@ -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 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 virtual: 'virtual' in field ? (field.virtual as string | boolean) : undefined,\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","virtual","undefined","width","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;AAChC,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,MAAM,QAAQ,cAAa;AACpC,SACEC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MAAM4B,mBAAmBD,qBAAqBpF,MAAM,GAAG;IAEvD,IAAI,CAAC7B,OAAO6B,MAAM,EAAE,OAAO;IAE3B,qBACE,MAAC8E;QAAIC,WAAU;;0BACb,KAACD;gBAAIQ,OAAO;oBAAEC,UAAU;oBAAYC,KAAK;oBAASC,QAAQ;gBAAM;0BAC9D,cAAA,MAAC/H;oBACCgI,SAAQ;oBACRC,MAAK;oBACLC,SAAST;oBACTJ,WAAW,CAAC,wEAAwE,EAClFM,mBAAmB,qBAAqB,IACxC;;sCAEF,KAAChI;4BAAO0H,WAAW,CAAC,QAAQ,EAAEM,mBAAmB,iBAAiB,IAAI;;wBAErEA,iCACC;;8CACE,MAACQ;oCAAKd,WAAU;;sDACd,KAACe;sDACE,GAAGV,qBAAqBpF,MAAM,KAAK,IAAI/C,SAAS,wBAAwBc,UAAUd,SAAS,sBAAsBc,QAAQ,EAAE,CAAC;;wCACrH;wCACTqH,qBAAqBW,IAAI,CAAC;;;8CAG7B,KAACF;oCACCD,SAAS,CAACI;wCACRA,EAAEC,eAAe;wCACjBtB;oCACF;oCACAI,WAAU;8CAEV,cAAA,KAACxH;wCAAEwH,WAAU;;;8CAEf,KAACc;oCACCD,SAAS,CAACI;wCACRA,EAAEC,eAAe;wCACjBrB;oCACF;oCACAG,WAAU;8CAEV,cAAA,KAACzH;wCAAUyH,WAAU;;;;2CAIzB,KAACc;4BAAKd,WAAU;sCAAoB9H,SAAS,gBAAgBc;;wBAG9D4C,4BAAc,KAACvD;4BAAU2H,WAAU;2CAAe,KAAC5H;4BAAY4H,WAAU;;;;;YAG7EpE,6BAAe,KAACmE;gBAAIC,WAAW;0BAAsBF;;;;AAG5D;AAEA,eAAexE,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 virtual: 'virtual' in field ? (field.virtual as string | boolean) : undefined,\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(\n fields.map((f) => {\n let name = f.name\n if (typeof f.virtual === 'string') {\n name = f.virtual\n }\n return name\n }),\n )\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) => {\n let name = f.name\n if (typeof f.virtual === 'string') {\n name = f.virtual\n }\n return name === fieldName\n })\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 let fieldName = field.name\n if (typeof field.virtual === 'string') {\n fieldName = field.virtual\n }\n return (\n <FilterField\n key={field.name}\n field={field}\n onFilterChange={handleFilterChange}\n value={filterValues[fieldName]}\n />\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","virtual","undefined","width","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;AAChC,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,MAAM,QAAQ,cAAa;AACpC,SACEC,0BAA0B,EAC1BC,8BAA8B,QACzB,cAAa;AAEpB,yCAAyC;AACzC,MAAMC,oBAAoB,CAACC,OAAYC;IACrC,IAAI,OAAOD,UAAU,YAAYA,UAAU,MAAM;QAC/C,OAAOA,KAAK,CAACC,OAAO,IAAID,KAAK,CAAC,KAAK,IAAIE,OAAOC,MAAM,CAACH,MAAM,CAAC,EAAE,IAAI;IACpE;IACA,OAAOA,SAAS;AAClB;AAEA,4CAA4C;AAC5C,SAASI,iBAAiBC,MAAqB,EAAEC,UAAoB;IACnE,MAAMC,UAAyB,EAAE;IACjC,SAASC,gBAAgBC,aAA4B;QACnD,MAAMC,iBAAiBD,cAAcE,MAAM,CACzC,CAACC,QAAU,UAAUA,SAASN,WAAWO,QAAQ,CAACD,MAAME,IAAI;QAE9DP,QAAQQ,IAAI,IAAIL;QAChBD,cAAcO,OAAO,CAAC,CAACC;YACrB,IACE,AAACA,CAAAA,KAAKC,IAAI,KAAK,WAAWD,KAAKC,IAAI,KAAK,SA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,SAAST;oBACTJ,WAAW,CAAC,wEAAwE,EAClFM,mBAAmB,qBAAqB,IACxC;;sCAEF,KAAChI;4BAAO0H,WAAW,CAAC,QAAQ,EAAEM,mBAAmB,iBAAiB,IAAI;;wBAErEA,iCACC;;8CACE,MAACQ;oCAAKd,WAAU;;sDACd,KAACe;sDACE,GAAGV,qBAAqBpF,MAAM,KAAK,IAAI/C,SAAS,wBAAwBc,UAAUd,SAAS,sBAAsBc,QAAQ,EAAE,CAAC;;wCACrH;wCACTqH,qBAAqBW,IAAI,CAAC;;;8CAG7B,KAACF;oCACCD,SAAS,CAACI;wCACRA,EAAEC,eAAe;wCACjBtB;oCACF;oCACAI,WAAU;8CAEV,cAAA,KAACxH;wCAAEwH,WAAU;;;8CAEf,KAACc;oCACCD,SAAS,CAACI;wCACRA,EAAEC,eAAe;wCACjBrB;oCACF;oCACAG,WAAU;8CAEV,cAAA,KAACzH;wCAAUyH,WAAU;;;;2CAIzB,KAACc;4BAAKd,WAAU;sCAAoB9H,SAAS,gBAAgBc;;wBAG9D4C,4BAAc,KAACvD;4BAAU2H,WAAU;2CAAe,KAAC5H;4BAAY4H,WAAU;;;;;YAG7EpE,6BAAe,KAACmE;gBAAIC,WAAW;0BAAsBF;;;;AAG5D;AAEA,eAAexE,YAAW"}
@@ -79,7 +79,7 @@ export function SmallSelectFilter({ label, options, value, onChange, locale = {
79
79
  return colors[index] || 'bg-accent text-accent-foreground hover:bg-accent/80';
80
80
  };
81
81
  return /*#__PURE__*/ _jsxs("div", {
82
- className: cn('space-y-2', className),
82
+ className: cn('space-y-1', className),
83
83
  dir: locale.direction,
84
84
  style: style,
85
85
  children: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/filters/components/small-select-filter.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\nimport { X } from 'lucide-react';\nimport { Locale, SelectFilterValue } from '../types/filters-type';\nimport { Label } from '../../ui/label';\nimport { cn } from '../../lib/utils';\nimport { Button } from '../../ui/button';\nimport { SupportedLocale } from '../../labels';\n\ninterface SmallSelectOption {\n value: string;\n label: string;\n}\n\ninterface SmallSelectFilterProps {\n label?: string;\n options: SmallSelectOption[];\n value?: SelectFilterValue;\n onChange: (value: SelectFilterValue) => void;\n locale?: Locale;\n className?: string;\n multiSelect?: boolean;\n maxOptions?: number;\n style?: React.CSSProperties;\n}\n\nexport function SmallSelectFilter({\n label,\n options,\n value,\n onChange,\n locale = { code: 'he', direction: 'rtl' },\n className,\n multiSelect = true,\n maxOptions = 3,\n style,\n}: SmallSelectFilterProps) {\n const [internalValue, setInternalValue] = useState<SelectFilterValue>(\n value || { type: 'none', selectedValues: [] },\n );\n\n const isRtl = locale?.direction === 'rtl';\n\n // Limit options to maxOptions\n const limitedOptions = options.slice(0, maxOptions);\n\n // Sync internal state with external value prop\n useEffect(() => {\n setInternalValue(value || { type: 'none', selectedValues: [] });\n }, [value]);\n\n const handleOptionToggle = (optionValue: string) => {\n let newSelectedValues: string[];\n\n if (multiSelect) {\n // Multiple selection mode - allow multiple choices\n if (internalValue.selectedValues.includes(optionValue)) {\n newSelectedValues = internalValue.selectedValues.filter((val) => val !== optionValue);\n } else {\n newSelectedValues = [...internalValue.selectedValues, optionValue];\n }\n } else {\n // Single selection mode\n if (internalValue.selectedValues.includes(optionValue)) {\n newSelectedValues = []; // Deselect if already selected\n } else {\n newSelectedValues = [optionValue]; // Select only this option\n }\n }\n\n const newValue: SelectFilterValue = {\n type:\n newSelectedValues.length === 0\n ? 'none'\n : newSelectedValues.length === options.length\n ? 'all'\n : 'some',\n selectedValues: newSelectedValues,\n };\n setInternalValue(newValue);\n onChange(newValue);\n };\n\n const handleClear = () => {\n const newValue: SelectFilterValue = { type: 'none', selectedValues: [] };\n setInternalValue(newValue);\n onChange(newValue);\n };\n\n const hasSelection = internalValue.selectedValues.length > 0;\n\n const isOptionSelected = (optionValue: string) => {\n return internalValue.selectedValues.includes(optionValue);\n };\n\n const getButtonColor = (optionValue: string, index: number) => {\n if (!isOptionSelected(optionValue)) {\n return 'useTw bg-background text-muted-foreground hover:bg-muted';\n }\n\n // Different colors for different options when selected\n const colors = [\n 'bg-blue-600 text-white hover:bg-blue-700', // First option - blue\n 'bg-green-600 text-white hover:bg-green-700', // Second option - green\n 'bg-purple-600 text-white hover:bg-purple-700', // Third option - purple\n ];\n return colors[index] || 'bg-accent text-accent-foreground hover:bg-accent/80';\n };\n\n return (\n <div className={cn('space-y-2', className)} dir={locale.direction} style={style}>\n {label && (\n <Label className={cn('useTw text-sm font-medium', isRtl && 'text-right block')}>\n {label}\n </Label>\n )}\n\n <div\n className={cn(\n 'flex items-center gap-3 transition-colors py-0.5',\n locale.direction === 'rtl' && 'justify-start',\n )}\n >\n <div className={cn('flex items-center', locale.direction === 'rtl' && 'order-first')}>\n {/* Toggle Options */}\n <div className='flex rounded-md border overflow-hidden'>\n {limitedOptions.map((option, index) => (\n <Button\n key={option.value}\n variant='ghost'\n size='sm'\n className={cn(\n 'px-3 py-1 text-xs rounded-none border-0',\n index > 0 && 'border-l',\n getButtonColor(option.value, index),\n )}\n onClick={() => handleOptionToggle(option.value)}\n >\n {option.label}\n </Button>\n ))}\n </div>\n </div>\n\n {hasSelection && (\n <Button\n variant='ghost'\n size='sm'\n className={cn(\n 'h-5 w-5 p-0 hover:bg-muted rounded-full -mt-1 -ml-1',\n locale.direction === 'rtl' ? 'order-last' : 'order-last',\n )}\n onClick={handleClear}\n >\n <X className='useTw h-3 w-3' />\n </Button>\n )}\n </div>\n </div>\n );\n}\n"],"names":["useEffect","useState","X","Label","cn","Button","SmallSelectFilter","label","options","value","onChange","locale","code","direction","className","multiSelect","maxOptions","style","internalValue","setInternalValue","type","selectedValues","isRtl","limitedOptions","slice","handleOptionToggle","optionValue","newSelectedValues","includes","filter","val","newValue","length","handleClear","hasSelection","isOptionSelected","getButtonColor","index","colors","div","dir","map","option","variant","size","onClick"],"mappings":"AAAA;;AAEA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE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A,KAAC/B;4BAAEY,WAAU;;;;;;;AAMzB"}
1
+ {"version":3,"sources":["../../../src/filters/components/small-select-filter.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\nimport { X } from 'lucide-react';\nimport { Locale, SelectFilterValue } from '../types/filters-type';\nimport { Label } from '../../ui/label';\nimport { cn } from '../../lib/utils';\nimport { Button } from '../../ui/button';\nimport { SupportedLocale } from '../../labels';\n\ninterface SmallSelectOption {\n value: string;\n label: string;\n}\n\ninterface SmallSelectFilterProps {\n label?: string;\n options: SmallSelectOption[];\n value?: SelectFilterValue;\n onChange: (value: SelectFilterValue) => void;\n locale?: Locale;\n className?: string;\n multiSelect?: boolean;\n maxOptions?: number;\n style?: React.CSSProperties;\n}\n\nexport function SmallSelectFilter({\n label,\n options,\n value,\n onChange,\n locale = { code: 'he', direction: 'rtl' },\n className,\n multiSelect = true,\n maxOptions = 3,\n style,\n}: SmallSelectFilterProps) {\n const [internalValue, setInternalValue] = useState<SelectFilterValue>(\n value || { type: 'none', selectedValues: [] },\n );\n\n const isRtl = locale?.direction === 'rtl';\n\n // Limit options to maxOptions\n const limitedOptions = options.slice(0, maxOptions);\n\n // Sync internal state with external value prop\n useEffect(() => {\n setInternalValue(value || { type: 'none', selectedValues: [] });\n }, [value]);\n\n const handleOptionToggle = (optionValue: string) => {\n let newSelectedValues: string[];\n\n if (multiSelect) {\n // Multiple selection mode - allow multiple choices\n if (internalValue.selectedValues.includes(optionValue)) {\n newSelectedValues = internalValue.selectedValues.filter((val) => val !== optionValue);\n } else {\n newSelectedValues = [...internalValue.selectedValues, optionValue];\n }\n } else {\n // Single selection mode\n if (internalValue.selectedValues.includes(optionValue)) {\n newSelectedValues = []; // Deselect if already selected\n } else {\n newSelectedValues = [optionValue]; // Select only this option\n }\n }\n\n const newValue: SelectFilterValue = {\n type:\n newSelectedValues.length === 0\n ? 'none'\n : newSelectedValues.length === options.length\n ? 'all'\n : 'some',\n selectedValues: newSelectedValues,\n };\n setInternalValue(newValue);\n onChange(newValue);\n };\n\n const handleClear = () => {\n const newValue: SelectFilterValue = { type: 'none', selectedValues: [] };\n setInternalValue(newValue);\n onChange(newValue);\n };\n\n const hasSelection = internalValue.selectedValues.length > 0;\n\n const isOptionSelected = (optionValue: string) => {\n return internalValue.selectedValues.includes(optionValue);\n };\n\n const getButtonColor = (optionValue: string, index: number) => {\n if (!isOptionSelected(optionValue)) {\n return 'useTw bg-background text-muted-foreground hover:bg-muted';\n }\n\n // Different colors for different options when selected\n const colors = [\n 'bg-blue-600 text-white hover:bg-blue-700', // First option - blue\n 'bg-green-600 text-white hover:bg-green-700', // Second option - green\n 'bg-purple-600 text-white hover:bg-purple-700', // Third option - purple\n ];\n return colors[index] || 'bg-accent text-accent-foreground hover:bg-accent/80';\n };\n\n return (\n <div className={cn('space-y-1', className)} dir={locale.direction} style={style}>\n {label && (\n <Label className={cn('useTw text-sm font-medium', isRtl && 'text-right block')}>\n {label}\n </Label>\n )}\n\n <div\n className={cn(\n 'flex items-center gap-3 transition-colors py-0.5',\n locale.direction === 'rtl' && 'justify-start',\n )}\n >\n <div className={cn('flex items-center', locale.direction === 'rtl' && 'order-first')}>\n {/* Toggle Options */}\n <div className='flex rounded-md border overflow-hidden'>\n {limitedOptions.map((option, index) => (\n <Button\n key={option.value}\n variant='ghost'\n size='sm'\n className={cn(\n 'px-3 py-1 text-xs rounded-none border-0',\n index > 0 && 'border-l',\n getButtonColor(option.value, index),\n )}\n onClick={() => handleOptionToggle(option.value)}\n >\n {option.label}\n </Button>\n ))}\n </div>\n </div>\n\n {hasSelection && (\n <Button\n variant='ghost'\n size='sm'\n className={cn(\n 'h-5 w-5 p-0 hover:bg-muted rounded-full -mt-1 -ml-1',\n locale.direction === 'rtl' ? 'order-last' : 'order-last',\n )}\n onClick={handleClear}\n >\n <X className='useTw h-3 w-3' />\n </Button>\n )}\n </div>\n </div>\n );\n}\n"],"names":["useEffect","useState","X","Label","cn","Button","SmallSelectFilter","label","options","value","onChange","locale","code","direction","className","multiSelect","maxOptions","style","internalValue","setInternalValue","type","selectedValues","isRtl","limitedOptions","slice","handleOptionToggle","optionValue","newSelectedValues","includes","filter","val","newValue","length","handleClear","hasSelection","isOptionSelected","getButtonColor","index","colors","div","dir","map","option","variant","size","onClick"],"mappings":"AAAA;;AAEA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C,SAASC,CAAC,QAAQ,eAAe;AAEjC,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,EAAE,QAAQ,kBAAkB;AACrC,SAASC,MAAM,QAAQ,kBAAkB;AAoBzC,OAAO,SAASC,kBAAkB,EAChCC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,QAAQ,EACRC,SAAS;IAAEC,MAAM;IAAMC,WAAW;AAAM,CAAC,EACzCC,SAAS,EACTC,cAAc,IAAI,EAClBC,aAAa,CAAC,EACdC,KAAK,EACkB;IACvB,MAAM,CAACC,eAAeC,iBAAiB,GAAGlB,SACxCQ,SAAS;QAAEW,MAAM;QAAQC,gBAAgB,EAAE;IAAC;IAG9C,MAAMC,QAAQX,QAAQE,cAAc;IAEpC,8BAA8B;IAC9B,MAAMU,iBAAiBf,QAAQgB,KAAK,CAAC,GAAGR;IAExC,+CAA+C;IAC/ChB,UAAU;QACRmB,iBAAiBV,SAAS;YAAEW,MAAM;YAAQC,gBAAgB,EAAE;QAAC;IAC/D,GAAG;QAACZ;KAAM;IAEV,MAAMgB,qBAAqB,CAACC;QAC1B,IAAIC;QAEJ,IAAIZ,aAAa;YACf,mDAAmD;YACnD,IAAIG,cAAcG,cAAc,CAACO,QAAQ,CAACF,cAAc;gBACtDC,oBAAoBT,cAAcG,cAAc,CAACQ,MAAM,CAAC,CAACC,MAAQA,QAAQJ;YAC3E,OAAO;gBACLC,oBAAoB;uBAAIT,cAAcG,cAAc;oBAAEK;iBAAY;YACpE;QACF,OAAO;YACL,wBAAwB;YACxB,IAAIR,cAAcG,cAAc,CAACO,QAAQ,CAACF,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BQ,SAAS,IAAMpB,mBAAmBiB,OAAOjC,KAAK;8CAE7CiC,OAAOnC,KAAK;mCAVRmC,OAAOjC,KAAK;;;oBAgBxByB,8BACC,KAAC7B;wBACCsC,SAAQ;wBACRC,MAAK;wBACL9B,WAAWV,GACT,uDACAO,OAAOE,SAAS,KAAK,QAAQ,eAAe;wBAE9CgC,SAASZ;kCAET,cAAA,KAAC/B;4BAAEY,WAAU;;;;;;;AAMzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAA;AAE5C,OAAO,KAAK,EAGV,aAAa,EAEd,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAM3C,OAAO,KAAK,EAAC,KAAK,EAA4C,MAAM,SAAS,CAAA;AAK7E,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAGD,eAAO,MAAM,8BAA8B,UAClC,GAAG,UACF,aAAa,EAAE,UACf,eAAe,KACtB,MAAM,CAAC,MAAM,EAAE,GAAG,CAqGpB,CAAA;AAED,eAAO,MAAM,0BAA0B,WAC7B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,aAChB,aAAa,EAAE,UAClB,eAAe,KACtB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAgErB,CAAA;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAuCzE;AAGD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,GAAG,EAAE,EACb,WAAW,EAAE,GAAG,EAAE,EAClB,OAAO,EAAE,GAAG,EACZ,IAAI,EAAE,GAAG,GACR,GAAG,EAAE,CAgEP"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAA;AAE5C,OAAO,KAAK,EAGV,aAAa,EAEd,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAM3C,OAAO,KAAK,EAAC,KAAK,EAA4C,MAAM,SAAS,CAAA;AAK7E,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAGD,eAAO,MAAM,8BAA8B,UAClC,GAAG,UACF,aAAa,EAAE,UACf,eAAe,KACtB,MAAM,CAAC,MAAM,EAAE,GAAG,CAiHpB,CAAA;AAED,eAAO,MAAM,0BAA0B,WAC7B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,aAChB,aAAa,EAAE,UAClB,eAAe,KACtB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAmErB,CAAA;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAuCzE;AAGD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,GAAG,EAAE,EACb,WAAW,EAAE,GAAG,EAAE,EAClB,OAAO,EAAE,GAAG,EACZ,IAAI,EAAE,GAAG,GACR,GAAG,EAAE,CAuEP"}
package/dist/lib/utils.js CHANGED
@@ -11,7 +11,17 @@ export function cn(...inputs) {
11
11
  // Translates URL query conditions to the quick filter's internal state
12
12
  export const parseWhereClauseToFilterValues = (where, fields, locale)=>{
13
13
  const values = {};
14
- const fieldNames = new Set(fields.map((f)=>f.name));
14
+ const fieldNames = new Set(fields.flatMap((f)=>{
15
+ if (typeof f.virtual === 'string') {
16
+ return [
17
+ f.virtual,
18
+ f.name
19
+ ];
20
+ }
21
+ return [
22
+ f.name
23
+ ];
24
+ }));
15
25
  const recursiveParse = (clause)=>{
16
26
  if (!clause || typeof clause !== 'object') return;
17
27
  if (clause.and) {
@@ -27,7 +37,13 @@ export const parseWhereClauseToFilterValues = (where, fields, locale)=>{
27
37
  }
28
38
  for(const fieldName in clause){
29
39
  if (fieldNames.has(fieldName)) {
30
- const fieldDef = fields.find((f)=>f.name === fieldName);
40
+ const fieldDef = fields.find((f)=>{
41
+ let name = f.name;
42
+ if (typeof f.virtual === 'string') {
43
+ name = f.virtual;
44
+ }
45
+ return name === fieldName;
46
+ });
31
47
  const condition = clause[fieldName];
32
48
  // Handle string values for date fields (e.g., 'todayAndFuture')
33
49
  if (fieldDef && fieldDef.type === 'date' && typeof condition === 'string') {
@@ -118,11 +134,14 @@ export const buildQuickFilterConditions = (values, fieldDefs, locale)=>{
118
134
  const conditions = [];
119
135
  Object.entries(values).forEach(([fieldName, value])=>{
120
136
  if (!value) return;
121
- const fieldDef = fieldDefs.find((f)=>f.name === fieldName);
137
+ const fieldDef = fieldDefs.find((f)=>{
138
+ let name = f.name;
139
+ if (typeof f.virtual === 'string') {
140
+ name = f.virtual;
141
+ }
142
+ return name === fieldName;
143
+ });
122
144
  if (!fieldDef) return;
123
- if (typeof fieldDef.virtual == 'string') {
124
- fieldName = fieldDef.virtual;
125
- }
126
145
  let condition = null;
127
146
  switch(fieldDef.type){
128
147
  case 'date':
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type ClassValue, clsx } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\nimport type {\n CheckboxFilterState,\n DateFilterValue,\n FilterDetaild,\n SelectFilterValue,\n} from '../filters/types/filters-type'\nimport { SupportedLocale } from '../labels'\nimport {\n futureOptionKeys,\n pastOptionKeys,\n} from '../filters/constants/date-filter-options'\nimport { getDateRangeForOption } from '../filters/utils/date-helpers'\nimport type {Field, FieldAffectingData, SelectField, UIField} from 'payload'\nimport { formatAdminURL } from 'payload/shared'\nimport { stringify } from 'qs-esm'\nimport { EntityType } from '@payloadcms/ui/shared'\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\n// Translates URL query conditions to the quick filter's internal state\nexport const 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 // Handle string values for date fields (e.g., 'todayAndFuture')\n if (fieldDef && fieldDef.type === 'date' && typeof condition === 'string') {\n const predefinedValue = condition\n if ([...pastOptionKeys, ...futureOptionKeys].includes(predefinedValue as any)) {\n values[fieldName] = {\n type: 'predefined',\n predefinedValue,\n }\n continue\n }\n }\n\n if (fieldDef && condition && typeof condition === 'object') {\n if ('equals' in condition) {\n if (fieldDef.type === 'checkbox') {\n values[fieldName] = (condition.equals == 'true' || 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 : boolean\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: boolean\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// Builds an array of condition objects from the quick filter values\nexport const 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 if (typeof fieldDef.virtual == 'string'){\n fieldName = fieldDef.virtual\n }\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// Recursive function to find a field by name\nexport function findFieldByName(fields: Field[], fieldName: string): Field {\n // First check at the current level\n const directMatch = fields.find(\n (f) => (f as FieldAffectingData).name === fieldName,\n )\n if (directMatch) return directMatch\n\n // If not found, search recursively in nested structures\n for (const item of fields) {\n // Check in array, row, or collapsible fields\n if (\n (item.type === 'array' || item.type === 'row' || item.type === 'collapsible') &&\n 'fields' in item &&\n Array.isArray(item.fields)\n ) {\n const nestedMatch = findFieldByName(item.fields, fieldName)\n if (nestedMatch) return nestedMatch\n } \n // Check in tabs\n else if (item.type === 'tabs' && Array.isArray(item.tabs)) {\n for (const tab of item.tabs) {\n if ('fields' in tab && Array.isArray(tab.fields)) {\n const tabMatch = findFieldByName(tab.fields, fieldName)\n if (tabMatch) return tabMatch\n }\n }\n } \n // Check in blocks\n else if (item.type === 'blocks' && Array.isArray(item.blocks)) {\n for (const block of item.blocks) {\n if ('fields' in block && Array.isArray(block.fields)) {\n const blockMatch = findFieldByName(block.fields, fieldName)\n if (blockMatch) return blockMatch\n }\n }\n }\n }\n\n return null\n}\n\n// Process nav groups to add href with defaultFilter query parameters\nexport function processNavGroups(\n groups: any[], \n collections: any[], \n payload: any, \n i18n: any\n): any[] {\n return groups.map(group => {\n const processedEntities = group.entities.map(entity => {\n if (entity.type === EntityType.collection) {\n const collection = collections.find(c => c.slug === entity.slug);\n\n // Check if collection has defaultFilter in custom props\n if (collection?.custom?.defaultFilter) {\n // Base URL without query parameters\n const baseHref = formatAdminURL({ \n adminRoute: payload.config.routes.admin, \n path: `/collections/${entity.slug}` \n });\n\n // Get the fields from the collection for parsing the where clause\n const fields: FilterDetaild[] =\n Object.keys(collection.custom.defaultFilter)\n ?.flat()\n .map((fieldName: string) => {\n const fieldConfig = findFieldByName(collection.fields, fieldName)\n return {\n name: fieldName,\n type: fieldConfig?.type,\n options: (fieldConfig as SelectField)?.options,\n label: (fieldConfig as UIField)?.label || fieldName,\n row: 0,\n virtual: 'virtual' in fieldConfig && fieldConfig.virtual\n } as FilterDetaild\n })\n .filter(Boolean) || []\n\n // If we have fields and a defaultFilter, calculate the URL with where clause\n if (fields.length > 0) {\n // Parse the defaultFilter to get filter values\n const filterValues = parseWhereClauseToFilterValues(\n collection.custom.defaultFilter,\n fields,\n i18n.language as SupportedLocale\n );\n // If we have filter values, add them to the URL\n if (Object.keys(filterValues).length > 0) {\n const quickFilterConditions = buildQuickFilterConditions(filterValues, fields, i18n.language as SupportedLocale)\n\n const whereCondition = quickFilterConditions.length === 1 ? quickFilterConditions[0] : { and: quickFilterConditions };\n const query = {\n where: whereCondition,\n };\n const stringifiedQuery = stringify(query, { addQueryPrefix: true });\n return {\n ...entity,\n href: `${baseHref}${stringifiedQuery}`\n };\n }\n }\n }\n }\n return entity;\n });\n\n return {\n ...group,\n entities: processedEntities\n };\n });\n}\n"],"names":["clsx","twMerge","futureOptionKeys","pastOptionKeys","getDateRangeForOption","formatAdminURL","stringify","EntityType","cn","inputs","parseWhereClauseToFilterValues","where","fields","locale","values","fieldNames","Set","map","f","name","recursiveParse","clause","and","forEach","or","length","fieldName","has","fieldDef","find","condition","type","predefinedValue","includes","equals","selectedValues","Array","isArray","in","fromDate","greater_than_equal","Date","toDate","less_than_equal","allDateOptions","matchedOption","option","range","isFromMatch","from","toDateString","to","undefined","isToMatch","customRange","buildQuickFilterConditions","fieldDefs","conditions","Object","entries","value","virtual","dateValue","dateQuery","keys","selectValue","checkboxState","push","findFieldByName","directMatch","item","nestedMatch","tabs","tab","tabMatch","blocks","block","blockMatch","processNavGroups","groups","collections","payload","i18n","group","processedEntities","entities","entity","collection","c","slug","custom","defaultFilter","baseHref","adminRoute","config","routes","admin","path","flat","fieldConfig","options","label","row","filter","Boolean","filterValues","language","quickFilterConditions","whereCondition","query","stringifiedQuery","addQueryPrefix","href"],"mappings":"AAAA,qDAAqD,GACrD,SAA0BA,IAAI,QAAQ,OAAM;AAC5C,SAASC,OAAO,QAAQ,iBAAgB;AAQxC,SACEC,gBAAgB,EAChBC,cAAc,QACT,2CAA0C;AACjD,SAASC,qBAAqB,QAAQ,gCAA+B;AAErE,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,SAAS,QAAQ,SAAQ;AAClC,SAASC,UAAU,QAAQ,wBAAuB;AAElD,OAAO,SAASC,GAAG,GAAGC,MAAoB;IACxC,OAAOR,QAAQD,KAAKS;AACtB;AAEA,uEAAuE;AACvE,OAAO,MAAMC,iCAAiC,CAC5CC,OACAC,QACAC;IAEA,MAAMC,SAA8B,CAAC;IACrC,MAAMC,aAAa,IAAIC,IAAIJ,OAAOK,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI;IAEnD,MAAMC,iBAAiB,CAACC;QACtB,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU;QAE3C,IAAIA,OAAOC,GAAG,EAAE;YACdD,OAAOC,GAAG,CAACC,OAAO,CAACH;YACnB;QACF;QACA,IAAIC,OAAOG,EAAE,EAAE;YACb,IAAIH,OAAOG,EAAE,CAACC,MAAM,GAAG,GAAG;gBACxB;YACF;YACAJ,OAAOG,EAAE,CAACD,OAAO,CAACH;YAClB;QACF;QACA,IAAK,MAAMM,aAAaL,OAAQ;YAC9B,IAAIN,WAAWY,GAAG,CAACD,YAAY;gBAC7B,MAAME,WAAWhB,OAAOiB,IAAI,CAAC,CAACX,IAAMA,EAAEC,IAAI,KAAKO;gBAC/C,MAAMI,YAAYT,MAAM,CAACK,UAAU;gBAEnC,gEAAgE;gBAChE,IAAIE,YAAYA,SAASG,IAAI,KAAK,UAAU,OAAOD,cAAc,UAAU;oBACzE,MAAME,kBAAkBF;oBACxB,IAAI;2BAAI3B;2BAAmBD;qBAAiB,CAAC+B,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gCAAErF,KAAKqF;4BAAsB;4BACpH,MAAME,QAAQ;gCACZlG,OAAOiG;4BACT;4BACA,MAAME,mBAAmBxG,UAAUuG,OAAO;gCAAEE,gBAAgB;4BAAK;4BACjE,OAAO;gCACL,GAAGzB,MAAM;gCACT0B,MAAM,GAAGpB,WAAWkB,kBAAkB;4BACxC;wBACF;oBACF;gBACF;YACF;YACA,OAAOxB;QACT;QAEA,OAAO;YACL,GAAGH,KAAK;YACRE,UAAUD;QACZ;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/lib/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type ClassValue, clsx } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\nimport type {\n CheckboxFilterState,\n DateFilterValue,\n FilterDetaild,\n SelectFilterValue,\n} from '../filters/types/filters-type'\nimport { SupportedLocale } from '../labels'\nimport {\n futureOptionKeys,\n pastOptionKeys,\n} from '../filters/constants/date-filter-options'\nimport { getDateRangeForOption } from '../filters/utils/date-helpers'\nimport type {Field, FieldAffectingData, SelectField, UIField} from 'payload'\nimport { formatAdminURL } from 'payload/shared'\nimport { stringify } from 'qs-esm'\nimport { EntityType } from '@payloadcms/ui/shared'\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\n// Translates URL query conditions to the quick filter's internal state\nexport const 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(\n fields.flatMap((f) => {\n if (typeof f.virtual === 'string') {\n return [f.virtual, f.name]\n }\n return [f.name]\n }),\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) => {\n let name = f.name\n if (typeof f.virtual === 'string') {\n name = f.virtual\n }\n return name === fieldName\n })\n const condition = clause[fieldName]\n\n // Handle string values for date fields (e.g., 'todayAndFuture')\n if (fieldDef && fieldDef.type === 'date' && typeof condition === 'string') {\n const predefinedValue = condition\n if ([...pastOptionKeys, ...futureOptionKeys].includes(predefinedValue as any)) {\n values[fieldName] = {\n type: 'predefined',\n predefinedValue,\n }\n continue\n }\n }\n\n if (fieldDef && condition && typeof condition === 'object') {\n if ('equals' in condition) {\n if (fieldDef.type === 'checkbox') {\n values[fieldName] = (condition.equals == 'true' || 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 : boolean\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: boolean\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// Builds an array of condition objects from the quick filter values\nexport const 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) => {\n let name = f.name\n if (typeof f.virtual === 'string') {\n name = f.virtual\n }\n return name === fieldName\n })\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// Recursive function to find a field by name\nexport function findFieldByName(fields: Field[], fieldName: string): Field {\n // First check at the current level\n const directMatch = fields.find(\n (f) => (f as FieldAffectingData).name === fieldName,\n )\n if (directMatch) return directMatch\n\n // If not found, search recursively in nested structures\n for (const item of fields) {\n // Check in array, row, or collapsible fields\n if (\n (item.type === 'array' || item.type === 'row' || item.type === 'collapsible') &&\n 'fields' in item &&\n Array.isArray(item.fields)\n ) {\n const nestedMatch = findFieldByName(item.fields, fieldName)\n if (nestedMatch) return nestedMatch\n } \n // Check in tabs\n else if (item.type === 'tabs' && Array.isArray(item.tabs)) {\n for (const tab of item.tabs) {\n if ('fields' in tab && Array.isArray(tab.fields)) {\n const tabMatch = findFieldByName(tab.fields, fieldName)\n if (tabMatch) return tabMatch\n }\n }\n } \n // Check in blocks\n else if (item.type === 'blocks' && Array.isArray(item.blocks)) {\n for (const block of item.blocks) {\n if ('fields' in block && Array.isArray(block.fields)) {\n const blockMatch = findFieldByName(block.fields, fieldName)\n if (blockMatch) return blockMatch\n }\n }\n }\n }\n\n return null\n}\n\n// Process nav groups to add href with defaultFilter query parameters\nexport function processNavGroups(\n groups: any[], \n collections: any[], \n payload: any, \n i18n: any\n): any[] {\n return groups.map(group => {\n const processedEntities = group.entities.map(entity => {\n if (entity.type === EntityType.collection) {\n const collection = collections.find(c => c.slug === entity.slug);\n\n // Check if collection has defaultFilter in custom props\n if (collection?.custom?.defaultFilter) {\n // Base URL without query parameters\n const baseHref = formatAdminURL({ \n adminRoute: payload.config.routes.admin, \n path: `/collections/${entity.slug}` \n });\n\n // Get the fields from the collection for parsing the where clause\n const fields: FilterDetaild[] =\n Object.keys(collection.custom.defaultFilter)\n ?.flat()\n .map((fieldName: string) => {\n const fieldConfig = findFieldByName(collection.fields, fieldName)\n return {\n name: fieldName,\n type: fieldConfig?.type,\n options: (fieldConfig as SelectField)?.options,\n label: (fieldConfig as UIField)?.label || fieldName,\n row: 0,\n virtual: 'virtual' in fieldConfig && fieldConfig.virtual,\n } as FilterDetaild\n })\n .filter(Boolean) || []\n\n // If we have fields and a defaultFilter, calculate the URL with where clause\n if (fields.length > 0) {\n // Parse the defaultFilter to get filter values\n const filterValues = parseWhereClauseToFilterValues(\n collection.custom.defaultFilter,\n fields,\n i18n.language as SupportedLocale,\n )\n // If we have filter values, add them to the URL\n if (Object.keys(filterValues).length > 0) {\n const quickFilterConditions = buildQuickFilterConditions(\n filterValues,\n fields,\n i18n.language as SupportedLocale,\n )\n\n const whereCondition =\n quickFilterConditions.length === 1\n ? quickFilterConditions[0]\n : { and: quickFilterConditions }\n const query = {\n where: whereCondition,\n }\n const stringifiedQuery = stringify(query, { addQueryPrefix: true })\n return {\n ...entity,\n href: `${baseHref}${stringifiedQuery}`,\n }\n }\n }\n }\n }\n return entity\n })\n\n return {\n ...group,\n entities: processedEntities,\n }\n })\n}\n"],"names":["clsx","twMerge","futureOptionKeys","pastOptionKeys","getDateRangeForOption","formatAdminURL","stringify","EntityType","cn","inputs","parseWhereClauseToFilterValues","where","fields","locale","values","fieldNames","Set","flatMap","f","virtual","name","recursiveParse","clause","and","forEach","or","length","fieldName","has","fieldDef","find","condition","type","predefinedValue","includes","equals","selectedValues","Array","isArray","in","fromDate","greater_than_equal","Date","toDate","less_than_equal","allDateOptions","matchedOption","option","range","isFromMatch","from","toDateString","to","undefined","isToMatch","customRange","buildQuickFilterConditions","fieldDefs","conditions","Object","entries","value","dateValue","dateQuery","keys","selectValue","checkboxState","push","findFieldByName","directMatch","item","nestedMatch","tabs","tab","tabMatch","blocks","block","blockMatch","processNavGroups","groups","collections","payload","i18n","map","group","processedEntities","entities","entity","collection","c","slug","custom","defaultFilter","baseHref","adminRoute","config","routes","admin","path","flat","fieldConfig","options","label","row","filter","Boolean","filterValues","language","quickFilterConditions","whereCondition","query","stringifiedQuery","addQueryPrefix","href"],"mappings":"AAAA,qDAAqD,GACrD,SAA0BA,IAAI,QAAQ,OAAM;AAC5C,SAASC,OAAO,QAAQ,iBAAgB;AAQxC,SACEC,gBAAgB,EAChBC,cAAc,QACT,2CAA0C;AACjD,SAASC,qBAAqB,QAAQ,gCAA+B;AAErE,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,SAAS,QA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QAAQ;gCACZnG,OAAOkG;4BACT;4BACA,MAAME,mBAAmBzG,UAAUwG,OAAO;gCAAEE,gBAAgB;4BAAK;4BACjE,OAAO;gCACL,GAAGzB,MAAM;gCACT0B,MAAM,GAAGpB,WAAWkB,kBAAkB;4BACxC;wBACF;oBACF;gBACF;YACF;YACA,OAAOxB;QACT;QAEA,OAAO;YACL,GAAGH,KAAK;YACRE,UAAUD;QACZ;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shefing/quickfilter",
3
- "version": "1.0.46",
3
+ "version": "1.0.52",
4
4
  "private": false,
5
5
  "bugs": "https://github.com/shefing/payload-tools/issues",
6
6
  "repository": "https://github.com/shefing/payload-tools",