@shefing/quickfilter 1.0.1 → 1.0.3
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/dist/FilterField.d.ts.map +1 -1
- package/dist/FilterField.js +0 -1
- package/dist/FilterField.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterField.d.ts","sourceRoot":"","sources":["../src/FilterField.tsx"],"names":[],"mappings":"
|
|
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,sBAsFA,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/dist/FilterField.js
CHANGED
package/dist/FilterField.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/FilterField.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/FilterField.tsx"],"sourcesContent":["'use client';\nimport React, { useCallback } from 'react';\nimport { useTranslation } from '@payloadcms/ui';\nimport { rtlLanguages } from '@payloadcms/translations';\nimport { DateFilter } from './filters/components/date-filter';\nimport { Locale } from './filters/types/filters-type';\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 userLocale = { code: localeLang, direction };\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={userLocale as Locale}\n className={` w-[${field.width || '250px'}]`}\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: option.label,\n value: option.value,\n }))}\n onChange={handleSelectFilterChange}\n value={controlledValue}\n locale={userLocale as Locale}\n className={` w-[${field.width || '250px'}]`}\n />\n );\n }\n return (\n <SelectFilter\n label={field.label}\n key={field.name}\n options={(field.options || []).map((option: any) => ({\n label: option.label,\n value: option.value,\n }))}\n onChange={handleSelectFilterChange}\n value={controlledValue}\n locale={userLocale as Locale}\n className={` w-[${field.width || '250px'}]`}\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={userLocale as Locale}\n className={` w-[${field.width || '250px'}]`}\n />\n );\n default:\n return null;\n }\n};\n\nexport default FilterField;\n"],"names":["React","useCallback","useTranslation","rtlLanguages","DateFilter","SmallSelectFilter","SelectFilter","CheckboxFilter","FilterField","field","onFilterChange","value","controlledValue","i18n","localeLang","language","isRTL","includes","direction","userLocale","code","handleDateFilterChange","name","handleSelectFilterChange","handleCheckboxFilterChange","state","type","label","onChange","locale","className","width","options","length","map","option","checkboxLabel"],"mappings":"AAAA;;A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oBAElBK,SAAS,AAACvB,CAAAA,MAAMuB,OAAO,IAAI,EAAE,AAAD,EAAGE,GAAG,CAAC,CAACC,SAAiB,CAAA;4BACnDR,OAAOQ,OAAOR,KAAK;4BACnBhB,OAAOwB,OAAOxB,KAAK;wBACrB,CAAA;oBACAiB,UAAUL;oBACVZ,OAAOC;oBACPiB,QAAQV;oBACRW,WAAW,CAAC,IAAI,EAAErB,MAAMsB,KAAK,IAAI,QAAQ,CAAC,CAAC;mBARtCtB,MAAMa,IAAI;YAWrB;YACA,qBACE,KAAChB;gBACCqB,OAAOlB,MAAMkB,KAAK;gBAElBK,SAAS,AAACvB,CAAAA,MAAMuB,OAAO,IAAI,EAAE,AAAD,EAAGE,GAAG,CAAC,CAACC,SAAiB,CAAA;wBACnDR,OAAOQ,OAAOR,KAAK;wBACnBhB,OAAOwB,OAAOxB,KAAK;oBACrB,CAAA;gBACAiB,UAAUL;gBACVZ,OAAOC;gBACPiB,QAAQV;gBACRW,WAAW,CAAC,IAAI,EAAErB,MAAMsB,KAAK,IAAI,QAAQ,CAAC,CAAC;eARtCtB,MAAMa,IAAI;QAWrB,KAAK;YACH,qBACE,KAACf;gBACCoB,OAAOlB,MAAMkB,KAAK;gBAElBC,UAAUJ;gBACVb,OAAOC;gBACPwB,eAAe;gBACfP,QAAQV;gBACRW,WAAW,CAAC,IAAI,EAAErB,MAAMsB,KAAK,IAAI,QAAQ,CAAC,CAAC;eALtCtB,MAAMa,IAAI;QAQrB;YACE,OAAO;IACX;AACF;AAEA,eAAed,YAAY"}
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ export const CollectionQuickFilterPlugin = (pluginOptions = {})=>(config)=>{
|
|
|
28
28
|
}
|
|
29
29
|
// Add the QuickFilter component
|
|
30
30
|
newCollection.admin.components.beforeListTable.push({
|
|
31
|
-
path: '/
|
|
31
|
+
path: '@shefing/quickfilter/QuickFilter',
|
|
32
32
|
clientProps: {
|
|
33
33
|
filterList: collection.custom.filterList,
|
|
34
34
|
slug: collection.slug
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload';\nimport { CollectionFilterPluginConfig } from './types';\n\nexport const CollectionQuickFilterPlugin =\n (pluginOptions: CollectionFilterPluginConfig = {}) =>\n (config: Config): Config => {\n if (!config.collections) {\n config.collections = [];\n }\n\n // Process each collection to add the QuickFilter component\n config.collections = config.collections.map((collection) => {\n // Check if the collection has a filterList configuration\n // or if it's specified in the plugin options\n if (collection.custom?.filterList && Array.isArray(collection.custom.filterList)) {\n // Clone the collection to avoid mutating the original\n const newCollection = { ...collection };\n\n // Initialize components if not exists\n if (!newCollection.admin) {\n newCollection.admin = {};\n }\n\n if (!newCollection.admin.components) {\n newCollection.admin.components = {};\n }\n\n if (!newCollection.admin.components.beforeListTable) {\n newCollection.admin.components.beforeListTable = [];\n } else if (!Array.isArray(newCollection.admin.components.beforeListTable)) {\n // If it's not an array, convert it to an array\n newCollection.admin.components.beforeListTable = [\n newCollection.admin.components.beforeListTable,\n ];\n }\n\n // Add the QuickFilter component\n newCollection.admin.components.beforeListTable.push({\n path: '/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload';\nimport { CollectionFilterPluginConfig } from './types';\n\nexport const CollectionQuickFilterPlugin =\n (pluginOptions: CollectionFilterPluginConfig = {}) =>\n (config: Config): Config => {\n if (!config.collections) {\n config.collections = [];\n }\n\n // Process each collection to add the QuickFilter component\n config.collections = config.collections.map((collection) => {\n // Check if the collection has a filterList configuration\n // or if it's specified in the plugin options\n if (collection.custom?.filterList && Array.isArray(collection.custom.filterList)) {\n // Clone the collection to avoid mutating the original\n const newCollection = { ...collection };\n\n // Initialize components if not exists\n if (!newCollection.admin) {\n newCollection.admin = {};\n }\n\n if (!newCollection.admin.components) {\n newCollection.admin.components = {};\n }\n\n if (!newCollection.admin.components.beforeListTable) {\n newCollection.admin.components.beforeListTable = [];\n } else if (!Array.isArray(newCollection.admin.components.beforeListTable)) {\n // If it's not an array, convert it to an array\n newCollection.admin.components.beforeListTable = [\n newCollection.admin.components.beforeListTable,\n ];\n }\n\n // Add the QuickFilter component\n newCollection.admin.components.beforeListTable.push({\n path: '@shefing/quickfilter/QuickFilter',\n clientProps: {\n filterList: collection.custom.filterList,\n slug: collection.slug,\n },\n });\n\n return newCollection;\n }\n\n return collection;\n });\n\n /**\n * If the plugin is disabled, we still want to keep added collections/fields so the database schema is consistent which is important for migrations.\n * If your plugin heavily modifies the database schema, you may want to remove this property.\n */\n if (pluginOptions.disabled) {\n return config;\n }\n\n return config;\n };\n\nexport default CollectionQuickFilterPlugin;\n"],"names":["CollectionQuickFilterPlugin","pluginOptions","config","collections","map","collection","custom","filterList","Array","isArray","newCollection","admin","components","beforeListTable","push","path","clientProps","slug","disabled"],"mappings":"AAGA,OAAO,MAAMA,8BACX,CAACC,gBAA8C,CAAC,CAAC,GACjD,CAACC;QACC,IAAI,CAACA,OAAOC,WAAW,EAAE;YACvBD,OAAOC,WAAW,GAAG,EAAE;QACzB;QAEA,2DAA2D;QAC3DD,OAAOC,WAAW,GAAGD,OAAOC,WAAW,CAACC,GAAG,CAAC,CAACC;YAC3C,yDAAyD;YACzD,6CAA6C;YAC7C,IAAIA,WAAWC,MAAM,EAAEC,cAAcC,MAAMC,OAAO,CAACJ,WAAWC,MAAM,CAACC,UAAU,GAAG;gBAChF,sDAAsD;gBACtD,MAAMG,gBAAgB;oBAAE,GAAGL,UAAU;gBAAC;gBAEtC,sCAAsC;gBACtC,IAAI,CAACK,cAAcC,KAAK,EAAE;oBACxBD,cAAcC,KAAK,GAAG,CAAC;gBACzB;gBAEA,IAAI,CAACD,cAAcC,KAAK,CAACC,UAAU,EAAE;oBACnCF,cAAcC,KAAK,CAACC,UAAU,GAAG,CAAC;gBACpC;gBAEA,IAAI,CAACF,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe,EAAE;oBACnDH,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe,GAAG,EAAE;gBACrD,OAAO,IAAI,CAACL,MAAMC,OAAO,CAACC,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe,GAAG;oBACzE,+CAA+C;oBAC/CH,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe,GAAG;wBAC/CH,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe;qBAC/C;gBACH;gBAEA,gCAAgC;gBAChCH,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe,CAACC,IAAI,CAAC;oBAClDC,MAAM;oBACNC,aAAa;wBACXT,YAAYF,WAAWC,MAAM,CAACC,UAAU;wBACxCU,MAAMZ,WAAWY,IAAI;oBACvB;gBACF;gBAEA,OAAOP;YACT;YAEA,OAAOL;QACT;QAEA;;;KAGC,GACD,IAAIJ,cAAciB,QAAQ,EAAE;YAC1B,OAAOhB;QACT;QAEA,OAAOA;IACT,EAAE;AAEJ,eAAeF,4BAA4B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shefing/quickfilter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bugs": "https://github.com/shefing/payload-tools/issues",
|
|
6
6
|
"repository": "https://github.com/shefing/payload-tools",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"import": "./dist/index.js",
|
|
19
19
|
"require": "./dist/index.js"
|
|
20
20
|
},
|
|
21
|
-
"./
|
|
21
|
+
"./QuickFilter": {
|
|
22
22
|
"import": "./dist/QuickFilter.js",
|
|
23
23
|
"require": "./dist/QuickFilter.js"
|
|
24
24
|
}
|
|
@@ -65,7 +65,10 @@
|
|
|
65
65
|
"@radix-ui/react-separator": "^1.1.2",
|
|
66
66
|
"cmdk": "^1.0.4",
|
|
67
67
|
"@radix-ui/react-dialog": "^1.1.6",
|
|
68
|
-
"@radix-ui/react-checkbox": "^1.1.4"
|
|
68
|
+
"@radix-ui/react-checkbox": "^1.1.4",
|
|
69
|
+
"tailwindcss-animate": "^1.0.7",
|
|
70
|
+
"tailwindcss-scoped-preflight": "^3.4.10",
|
|
71
|
+
"tailwindcss": "3.4.17"
|
|
69
72
|
},
|
|
70
73
|
"publishConfig": {
|
|
71
74
|
"access": "public"
|