@foundrykit/media-plugin 0.3.1 → 0.3.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/activePlugins.d.ts +10 -0
- package/dist/activePlugins.js +27 -0
- package/dist/activePlugins.js.map +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +12 -11
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Config } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Records this plugin as active in `config.custom.foundrykit.activePlugins`, the list
|
|
4
|
+
* `@foundrykit/guides-plugin` sends to the guides hub so the site gets this plugin's guides.
|
|
5
|
+
* Only call it on the enabled path: installed-but-disabled doesn't count.
|
|
6
|
+
*
|
|
7
|
+
* Every FoundryKit Payload plugin carries its own copy of this file (it's too small for a package);
|
|
8
|
+
* keep them identical.
|
|
9
|
+
*/
|
|
10
|
+
export declare const recordActivePlugin: (config: Config, name: string) => Config;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records this plugin as active in `config.custom.foundrykit.activePlugins`, the list
|
|
3
|
+
* `@foundrykit/guides-plugin` sends to the guides hub so the site gets this plugin's guides.
|
|
4
|
+
* Only call it on the enabled path: installed-but-disabled doesn't count.
|
|
5
|
+
*
|
|
6
|
+
* Every FoundryKit Payload plugin carries its own copy of this file (it's too small for a package);
|
|
7
|
+
* keep them identical.
|
|
8
|
+
*/ export const recordActivePlugin = (config, name)=>{
|
|
9
|
+
const foundrykit = config.custom?.foundrykit ?? {};
|
|
10
|
+
return {
|
|
11
|
+
...config,
|
|
12
|
+
custom: {
|
|
13
|
+
...config.custom,
|
|
14
|
+
foundrykit: {
|
|
15
|
+
...foundrykit,
|
|
16
|
+
activePlugins: [
|
|
17
|
+
...new Set([
|
|
18
|
+
...foundrykit.activePlugins ?? [],
|
|
19
|
+
name
|
|
20
|
+
])
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=activePlugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/activePlugins.ts"],"sourcesContent":["import type { Config } from 'payload';\n\n/**\n * Records this plugin as active in `config.custom.foundrykit.activePlugins`, the list\n * `@foundrykit/guides-plugin` sends to the guides hub so the site gets this plugin's guides.\n * Only call it on the enabled path: installed-but-disabled doesn't count.\n *\n * Every FoundryKit Payload plugin carries its own copy of this file (it's too small for a package);\n * keep them identical.\n */\nexport const recordActivePlugin = (config: Config, name: string): Config => {\n const foundrykit = (config.custom?.foundrykit ?? {}) as {\n activePlugins?: string[];\n };\n return {\n ...config,\n custom: {\n ...config.custom,\n foundrykit: {\n ...foundrykit,\n activePlugins: [\n ...new Set([...(foundrykit.activePlugins ?? []), name]),\n ],\n },\n },\n };\n};\n"],"names":["recordActivePlugin","config","name","foundrykit","custom","activePlugins","Set"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,MAAMA,qBAAqB,CAACC,QAAgBC;IACjD,MAAMC,aAAcF,OAAOG,MAAM,EAAED,cAAc,CAAC;IAGlD,OAAO;QACL,GAAGF,MAAM;QACTG,QAAQ;YACN,GAAGH,OAAOG,MAAM;YAChBD,YAAY;gBACV,GAAGA,UAAU;gBACbE,eAAe;uBACV,IAAIC,IAAI;2BAAKH,WAAWE,aAAa,IAAI,EAAE;wBAAGH;qBAAK;iBACvD;YACH;QACF;IACF;AACF,EAAE"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { recordActivePlugin } from './activePlugins.js';
|
|
1
2
|
import { folderPreviewsEndpoint } from './endpoints/folderPreviews.js';
|
|
2
3
|
const LIST_VIEW = '@foundrykit/media-plugin/client#MediaListView';
|
|
3
4
|
const MEDIA_VIEWS = '@foundrykit/media-plugin/client#MediaViews';
|
|
@@ -6,7 +7,7 @@ const FOLDER_PREVIEWS = '@foundrykit/media-plugin/client#FolderPreviewsProvider'
|
|
|
6
7
|
* A List / Grid switch on upload collection lists, and a Folders tab in the picker drawer so
|
|
7
8
|
* editors can choose images from inside folders. A collection that already has its own list
|
|
8
9
|
* view keeps it.
|
|
9
|
-
*/ export const mediaPlugin = ({ collections, folderPicker = true, folderPreviews = true, gridView = true } = {})=>(config)=>({
|
|
10
|
+
*/ export const mediaPlugin = ({ collections, folderPicker = true, folderPreviews = true, gridView = true } = {})=>(config)=>recordActivePlugin({
|
|
10
11
|
...config,
|
|
11
12
|
collections: config.collections?.map((collection)=>{
|
|
12
13
|
const wanted = collections ? collections.includes(collection.slug) : Boolean(collection.upload);
|
|
@@ -31,7 +32,7 @@ const FOLDER_PREVIEWS = '@foundrykit/media-plugin/client#FolderPreviewsProvider'
|
|
|
31
32
|
...config.endpoints ?? [],
|
|
32
33
|
folderPreviewsEndpoint
|
|
33
34
|
] : config.endpoints
|
|
34
|
-
});
|
|
35
|
+
}, '@foundrykit/media-plugin');
|
|
35
36
|
function enhance(collection, { folderPicker, gridView }) {
|
|
36
37
|
const components = collection.admin?.components ?? {};
|
|
37
38
|
const views = components.views ?? {};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config } from 'payload';\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config } from 'payload';\nimport { recordActivePlugin } from './activePlugins.js';\nimport { folderPreviewsEndpoint } from './endpoints/folderPreviews.js';\n\nexport type { FolderPreview } from './endpoints/folderPreviews.js';\n\nexport type MediaPluginConfig = {\n /** Upload collections to enhance. Defaults to every upload collection. */\n collections?: string[];\n /** Folders tab inside the image picker drawer. Needs `folders: true` on the collection. Default true. */\n folderPicker?: boolean;\n /** First few thumbnails and a \"what's inside\" count on folder cards. Default true. */\n folderPreviews?: boolean;\n /** List / Grid switch on the list, full page and picker drawer. Default true. */\n gridView?: boolean;\n};\n\nconst LIST_VIEW = '@foundrykit/media-plugin/client#MediaListView';\nconst MEDIA_VIEWS = '@foundrykit/media-plugin/client#MediaViews';\nconst FOLDER_PREVIEWS =\n '@foundrykit/media-plugin/client#FolderPreviewsProvider';\n\n/**\n * A List / Grid switch on upload collection lists, and a Folders tab in the picker drawer so\n * editors can choose images from inside folders. A collection that already has its own list\n * view keeps it.\n */\nexport const mediaPlugin =\n ({\n collections,\n folderPicker = true,\n folderPreviews = true,\n gridView = true,\n }: MediaPluginConfig = {}) =>\n (config: Config): Config =>\n recordActivePlugin(\n {\n ...config,\n collections: config.collections?.map(collection => {\n const wanted = collections\n ? collections.includes(collection.slug)\n : Boolean(collection.upload);\n return wanted\n ? enhance(collection, { folderPicker, gridView })\n : collection;\n }),\n // By Folder renders no plugin components inside it (Payload 3.90), so the card previews\n // there come from a provider that wraps the whole admin. The picker renders its own.\n admin: folderPreviews\n ? {\n ...config.admin,\n components: {\n ...config.admin?.components,\n providers: [\n ...(config.admin?.components?.providers ?? []),\n FOLDER_PREVIEWS,\n ],\n },\n }\n : config.admin,\n endpoints: folderPreviews\n ? [...(config.endpoints ?? []), folderPreviewsEndpoint]\n : config.endpoints,\n },\n '@foundrykit/media-plugin'\n );\n\nfunction enhance(\n collection: CollectionConfig,\n { folderPicker, gridView }: { folderPicker: boolean; gridView: boolean }\n): CollectionConfig {\n const components = collection.admin?.components ?? {};\n const views = components.views ?? {};\n const beforeListTable = components.beforeListTable ?? [];\n\n return {\n ...collection,\n admin: {\n ...collection.admin,\n components: {\n ...components,\n beforeListTable: gridView\n ? [...beforeListTable, MEDIA_VIEWS]\n : beforeListTable,\n views: {\n ...views,\n list:\n folderPicker && !views.list ? { Component: LIST_VIEW } : views.list,\n },\n },\n },\n };\n}\n"],"names":["recordActivePlugin","folderPreviewsEndpoint","LIST_VIEW","MEDIA_VIEWS","FOLDER_PREVIEWS","mediaPlugin","collections","folderPicker","folderPreviews","gridView","config","map","collection","wanted","includes","slug","Boolean","upload","enhance","admin","components","providers","endpoints","views","beforeListTable","list","Component"],"mappings":"AACA,SAASA,kBAAkB,QAAQ,qBAAqB;AACxD,SAASC,sBAAsB,QAAQ,gCAAgC;AAevE,MAAMC,YAAY;AAClB,MAAMC,cAAc;AACpB,MAAMC,kBACJ;AAEF;;;;CAIC,GACD,OAAO,MAAMC,cACX,CAAC,EACCC,WAAW,EACXC,eAAe,IAAI,EACnBC,iBAAiB,IAAI,EACrBC,WAAW,IAAI,EACG,GAAG,CAAC,CAAC,GACzB,CAACC,SACCV,mBACE;YACE,GAAGU,MAAM;YACTJ,aAAaI,OAAOJ,WAAW,EAAEK,IAAIC,CAAAA;gBACnC,MAAMC,SAASP,cACXA,YAAYQ,QAAQ,CAACF,WAAWG,IAAI,IACpCC,QAAQJ,WAAWK,MAAM;gBAC7B,OAAOJ,SACHK,QAAQN,YAAY;oBAAEL;oBAAcE;gBAAS,KAC7CG;YACN;YACA,wFAAwF;YACxF,qFAAqF;YACrFO,OAAOX,iBACH;gBACE,GAAGE,OAAOS,KAAK;gBACfC,YAAY;oBACV,GAAGV,OAAOS,KAAK,EAAEC,UAAU;oBAC3BC,WAAW;2BACLX,OAAOS,KAAK,EAAEC,YAAYC,aAAa,EAAE;wBAC7CjB;qBACD;gBACH;YACF,IACAM,OAAOS,KAAK;YAChBG,WAAWd,iBACP;mBAAKE,OAAOY,SAAS,IAAI,EAAE;gBAAGrB;aAAuB,GACrDS,OAAOY,SAAS;QACtB,GACA,4BACA;AAEN,SAASJ,QACPN,UAA4B,EAC5B,EAAEL,YAAY,EAAEE,QAAQ,EAAgD;IAExE,MAAMW,aAAaR,WAAWO,KAAK,EAAEC,cAAc,CAAC;IACpD,MAAMG,QAAQH,WAAWG,KAAK,IAAI,CAAC;IACnC,MAAMC,kBAAkBJ,WAAWI,eAAe,IAAI,EAAE;IAExD,OAAO;QACL,GAAGZ,UAAU;QACbO,OAAO;YACL,GAAGP,WAAWO,KAAK;YACnBC,YAAY;gBACV,GAAGA,UAAU;gBACbI,iBAAiBf,WACb;uBAAIe;oBAAiBrB;iBAAY,GACjCqB;gBACJD,OAAO;oBACL,GAAGA,KAAK;oBACRE,MACElB,gBAAgB,CAACgB,MAAME,IAAI,GAAG;wBAAEC,WAAWxB;oBAAU,IAAIqB,MAAME,IAAI;gBACvE;YACF;QACF;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foundrykit/media-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Media library for Payload CMS 3: a List / Grid switch on upload lists and a Folders tab in the image picker",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
"screenshots"
|
|
29
29
|
],
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@payloadcms/db-mongodb": "3.
|
|
32
|
-
"@payloadcms/
|
|
33
|
-
"@payloadcms/
|
|
31
|
+
"@payloadcms/db-mongodb": "3.90.0",
|
|
32
|
+
"@payloadcms/db-postgres": "3.90.0",
|
|
33
|
+
"@payloadcms/next": "3.90.0",
|
|
34
|
+
"@payloadcms/ui": "3.90.0",
|
|
34
35
|
"@playwright/test": "1.58.2",
|
|
35
36
|
"@swc-node/register": "1.10.9",
|
|
36
37
|
"@swc/cli": "0.6.0",
|
|
@@ -44,10 +45,10 @@
|
|
|
44
45
|
"graphql": "^16.8.1",
|
|
45
46
|
"jsdom": "^26.1.0",
|
|
46
47
|
"mongodb-memory-server": "10.1.4",
|
|
47
|
-
"next": "16.
|
|
48
|
-
"payload": "3.
|
|
49
|
-
"react": "19.2.
|
|
50
|
-
"react-dom": "19.2.
|
|
48
|
+
"next": "16.3.8",
|
|
49
|
+
"payload": "3.90.0",
|
|
50
|
+
"react": "19.2.8",
|
|
51
|
+
"react-dom": "19.2.8",
|
|
51
52
|
"rimraf": "3.0.2",
|
|
52
53
|
"sharp": "0.34.2",
|
|
53
54
|
"typescript": "5.9.2",
|
|
@@ -55,10 +56,10 @@
|
|
|
55
56
|
"vitest": "4.1.10"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
58
|
-
"@payloadcms/next": "^3.84.
|
|
59
|
-
"@payloadcms/ui": "^3.84.
|
|
59
|
+
"@payloadcms/next": "^3.84.0",
|
|
60
|
+
"@payloadcms/ui": "^3.84.0",
|
|
60
61
|
"next": ">=15",
|
|
61
|
-
"payload": "^3.84.
|
|
62
|
+
"payload": "^3.84.0",
|
|
62
63
|
"react": "^19",
|
|
63
64
|
"react-dom": "^19"
|
|
64
65
|
},
|