@shefing/quickfilter 1.0.27 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# 🚀 QuickFilter Plugin for PayloadCMS
|
|
2
2
|
|
|
3
|
-
#!!! Payload 3.49 breaks the plugin - https://github.com/payloadcms/payload/pull/13200 We are working to fix that
|
|
4
|
-
|
|
5
3
|
⚡ **Lightning-fast and intuitive filtering that your users will love!**
|
|
6
4
|
|
|
7
5
|
Transform your PayloadCMS admin experience with instant, intuitive filters that appear right where you need them. Say goodbye to clunky filter forms and welcome to seamless data exploration!
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { Config } from 'payload';
|
|
1
|
+
import type { CollectionSlug, Config } from 'payload';
|
|
2
2
|
export type CollectionFilterPluginConfig = {
|
|
3
3
|
/**
|
|
4
4
|
* List of collections to add filters to
|
|
5
5
|
*/
|
|
6
6
|
disabled?: boolean;
|
|
7
|
+
excludedCollections?: CollectionSlug[];
|
|
8
|
+
includedCollections?: CollectionSlug[];
|
|
7
9
|
};
|
|
8
10
|
export declare const CollectionQuickFilterPlugin: (pluginOptions?: CollectionFilterPluginConfig) => (config: Config) => Config;
|
|
9
11
|
export default CollectionQuickFilterPlugin;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,MAAM,4BAA4B,GAAG;IACzC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAC;IACvC,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,2BAA2B,mBACtB,4BAA4B,cACnC,MAAM,KAAG,MA8DjB,CAAC;AAEJ,eAAe,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,11 @@ export const CollectionQuickFilterPlugin = (pluginOptions = {})=>(config)=>{
|
|
|
4
4
|
}
|
|
5
5
|
// Process each collection to add the QuickFilter component
|
|
6
6
|
config.collections = config.collections.map((collection)=>{
|
|
7
|
+
// Check if this collection should be processed based on includedCollections/excludedCollections
|
|
8
|
+
const shouldProcessCollection = pluginOptions.includedCollections ? pluginOptions.includedCollections.includes(collection.slug) : pluginOptions.excludedCollections ? !pluginOptions.excludedCollections.includes(collection.slug) : true;
|
|
7
9
|
// Check if the collection has a filterList configuration
|
|
8
10
|
// or if it's specified in the plugin options
|
|
9
|
-
if (collection.custom?.filterList && Array.isArray(collection.custom.filterList)) {
|
|
11
|
+
if (shouldProcessCollection && collection.custom?.filterList && Array.isArray(collection.custom.filterList)) {
|
|
10
12
|
// Clone the collection to avoid mutating the original
|
|
11
13
|
const newCollection = {
|
|
12
14
|
...collection
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload';\n\nexport type CollectionFilterPluginConfig = {\n /**\n * List of collections to add filters to\n */\n disabled?: boolean;\n};\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","
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionSlug, Config } from 'payload';\n\nexport type CollectionFilterPluginConfig = {\n /**\n * List of collections to add filters to\n */\n disabled?: boolean;\n excludedCollections?: CollectionSlug[];\n includedCollections?: CollectionSlug[];\n};\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 this collection should be processed based on includedCollections/excludedCollections\n const shouldProcessCollection = pluginOptions.includedCollections \n ? pluginOptions.includedCollections.includes(collection.slug) \n : pluginOptions.excludedCollections \n ? !pluginOptions.excludedCollections.includes(collection.slug) \n : true;\n\n // Check if the collection has a filterList configuration\n // or if it's specified in the plugin options\n if (shouldProcessCollection && 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","shouldProcessCollection","includedCollections","includes","slug","excludedCollections","custom","filterList","Array","isArray","newCollection","admin","components","beforeListTable","push","path","clientProps","disabled"],"mappings":"AAWA,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,gGAAgG;YAChG,MAAMC,0BAA0BL,cAAcM,mBAAmB,GAC7DN,cAAcM,mBAAmB,CAACC,QAAQ,CAACH,WAAWI,IAAI,IAC1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