@shefing/quickfilter 1.0.74 → 1.0.76
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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionSlug, Config } from 'payload';
|
|
1
|
+
import type { CollectionConfig, CollectionSlug, Config } from 'payload';
|
|
2
2
|
export type CollectionFilterPluginConfig = {
|
|
3
3
|
/**
|
|
4
4
|
* List of collections to add filters to
|
|
@@ -7,6 +7,7 @@ export type CollectionFilterPluginConfig = {
|
|
|
7
7
|
excludedCollections?: CollectionSlug[];
|
|
8
8
|
includedCollections?: CollectionSlug[];
|
|
9
9
|
};
|
|
10
|
+
export declare function addQuickFilterToCollection(newCollection: CollectionConfig): void;
|
|
10
11
|
export declare const CollectionQuickFilterPlugin: (pluginOptions?: CollectionFilterPluginConfig) => (config: Config) => Config;
|
|
11
12
|
export default CollectionQuickFilterPlugin;
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGxE,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,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,gBAAgB,QA2BzE;AAED,eAAO,MAAM,2BAA2B,mBACtB,4BAA4B,cACnC,MAAM,KAAG,MAoCjB,CAAC;AAEJ,eAAe,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
export function addQuickFilterToCollection(newCollection) {
|
|
2
|
+
// Initialize components if not exists
|
|
3
|
+
if (!newCollection.admin) {
|
|
4
|
+
newCollection.admin = {};
|
|
5
|
+
}
|
|
6
|
+
if (!newCollection.admin.components) {
|
|
7
|
+
newCollection.admin.components = {};
|
|
8
|
+
}
|
|
9
|
+
if (!newCollection.admin.components.beforeListTable) {
|
|
10
|
+
newCollection.admin.components.beforeListTable = [];
|
|
11
|
+
} else if (!Array.isArray(newCollection.admin.components.beforeListTable)) {
|
|
12
|
+
// If it's not an array, convert it to an array
|
|
13
|
+
newCollection.admin.components.beforeListTable = [
|
|
14
|
+
newCollection.admin.components.beforeListTable
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
// Add the QuickFilter component
|
|
18
|
+
newCollection.admin.components.beforeListTable.push({
|
|
19
|
+
path: '@shefing/quickfilter/QuickFilter',
|
|
20
|
+
clientProps: {
|
|
21
|
+
filterList: newCollection.custom.filterList,
|
|
22
|
+
slug: newCollection.slug
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
1
26
|
export const CollectionQuickFilterPlugin = (pluginOptions = {})=>(config)=>{
|
|
2
27
|
if (!config.collections) {
|
|
3
28
|
config.collections = [];
|
|
@@ -13,29 +38,7 @@ export const CollectionQuickFilterPlugin = (pluginOptions = {})=>(config)=>{
|
|
|
13
38
|
const newCollection = {
|
|
14
39
|
...collection
|
|
15
40
|
};
|
|
16
|
-
|
|
17
|
-
if (!newCollection.admin) {
|
|
18
|
-
newCollection.admin = {};
|
|
19
|
-
}
|
|
20
|
-
if (!newCollection.admin.components) {
|
|
21
|
-
newCollection.admin.components = {};
|
|
22
|
-
}
|
|
23
|
-
if (!newCollection.admin.components.beforeListTable) {
|
|
24
|
-
newCollection.admin.components.beforeListTable = [];
|
|
25
|
-
} else if (!Array.isArray(newCollection.admin.components.beforeListTable)) {
|
|
26
|
-
// If it's not an array, convert it to an array
|
|
27
|
-
newCollection.admin.components.beforeListTable = [
|
|
28
|
-
newCollection.admin.components.beforeListTable
|
|
29
|
-
];
|
|
30
|
-
}
|
|
31
|
-
// Add the QuickFilter component
|
|
32
|
-
newCollection.admin.components.beforeListTable.push({
|
|
33
|
-
path: '@shefing/quickfilter/QuickFilter',
|
|
34
|
-
clientProps: {
|
|
35
|
-
filterList: collection.custom.filterList,
|
|
36
|
-
slug: collection.slug
|
|
37
|
-
}
|
|
38
|
-
});
|
|
41
|
+
addQuickFilterToCollection(newCollection);
|
|
39
42
|
return newCollection;
|
|
40
43
|
}
|
|
41
44
|
return collection;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionSlug, Config } from 'payload';\n\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 as CollectionSlug)\n : pluginOptions.excludedCollections \n ? !pluginOptions.excludedCollections.includes(collection.slug as CollectionSlug)\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
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, CollectionSlug, Config } from 'payload';\n\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 function addQuickFilterToCollection(newCollection: CollectionConfig) {\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: newCollection.custom.filterList,\n slug: newCollection.slug,\n },\n });\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 as CollectionSlug)\n : pluginOptions.excludedCollections \n ? !pluginOptions.excludedCollections.includes(collection.slug as CollectionSlug)\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 addQuickFilterToCollection(newCollection);\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":["addQuickFilterToCollection","newCollection","admin","components","beforeListTable","Array","isArray","push","path","clientProps","filterList","custom","slug","CollectionQuickFilterPlugin","pluginOptions","config","collections","map","collection","shouldProcessCollection","includedCollections","includes","excludedCollections","disabled"],"mappings":"AAYA,OAAO,SAASA,2BAA2BC,aAA+B;IACxE,sCAAsC;IACtC,IAAI,CAACA,cAAcC,KAAK,EAAE;QACxBD,cAAcC,KAAK,GAAG,CAAC;IACzB;IAEA,IAAI,CAACD,cAAcC,KAAK,CAACC,UAAU,EAAE;QACnCF,cAAcC,KAAK,CAACC,UAAU,GAAG,CAAC;IACpC;IAEA,IAAI,CAACF,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe,EAAE;QACnDH,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe,GAAG,EAAE;IACrD,OAAO,IAAI,CAACC,MAAMC,OAAO,CAACL,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe,GAAG;QACzE,+CAA+C;QAC/CH,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe,GAAG;YAC/CH,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe;SAC/C;IACH;IAEA,gCAAgC;IAChCH,cAAcC,KAAK,CAACC,UAAU,CAACC,eAAe,CAACG,IAAI,CAAC;QAClDC,MAAM;QACNC,aAAa;YACXC,YAAYT,cAAcU,MAAM,CAACD,UAAU;YAC3CE,MAAMX,cAAcW,IAAI;QAC1B;IACF;AACF;AAEA,OAAO,MAAMC,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,WAAWN,IAAI,IAC1DE,cAAcQ,mBAAmB,GAC/B,CAACR,cAAcQ,mBAAmB,CAACD,QAAQ,CAACH,WAAWN,IAAI,IAC3D;YAEN,yDAAyD;YACzD,6CAA6C;YAC7C,IAAIO,2BAA2BD,WAAWP,MAAM,EAAED,cAAcL,MAAMC,OAAO,CAACY,WAAWP,MAAM,CAACD,UAAU,GAAG;gBAC3G,sDAAsD;gBACtD,MAAMT,gBAAgB;oBAAE,GAAGiB,UAAU;gBAAC;gBACtClB,2BAA2BC;gBAE3B,OAAOA;YACT;YAEA,OAAOiB;QACT;QAEA;;;KAGC,GACD,IAAIJ,cAAcS,QAAQ,EAAE;YAC1B,OAAOR;QACT;QAEA,OAAOA;IACT,EAAE;AAEJ,eAAeF,4BAA4B"}
|