@ainsleydev/payload-helper 0.0.39 → 0.0.40

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 CHANGED
@@ -4,6 +4,93 @@ Payload Helper is a project designed to extend and enhance functionality for Pay
4
4
  project includes custom configurations, scripts, and utilities to streamline development and content
5
5
  management processes.
6
6
 
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @ainsleydev/payload-helper
11
+ # or
12
+ pnpm add @ainsleydev/payload-helper
13
+ # or
14
+ yarn add @ainsleydev/payload-helper
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Add the plugin to your Payload configuration:
20
+
21
+ ```typescript
22
+ import { payloadHelper } from '@ainsleydev/payload-helper'
23
+
24
+ export default buildConfig({
25
+ plugins: [
26
+ payloadHelper({
27
+ siteName: 'My Site',
28
+ admin: {
29
+ logo: {
30
+ path: '/images/logo-light.svg',
31
+ darkModePath: '/images/logo-dark.svg',
32
+ width: 150,
33
+ height: 40,
34
+ alt: 'My Site Logo',
35
+ className: 'custom-logo-class',
36
+ },
37
+ icon: {
38
+ path: '/images/icon-light.svg',
39
+ darkModePath: '/images/icon-dark.svg',
40
+ width: 120,
41
+ height: 120,
42
+ alt: 'My Site Icon',
43
+ className: 'custom-icon-class',
44
+ },
45
+ },
46
+ }),
47
+ ],
48
+ })
49
+ ```
50
+
51
+ ## Configuration
52
+
53
+ ### Admin configuration
54
+
55
+ The `admin` object contains configuration for admin UI customisation:
56
+
57
+ #### Logo configuration
58
+
59
+ The logo appears in the navigation area of the Payload admin dashboard.
60
+
61
+ - `path` (required): Path to the logo image file
62
+ - `darkModePath` (optional): Path to the logo for dark mode
63
+ - `width` (optional): Logo width in pixels (default: 150)
64
+ - `height` (optional): Logo height in pixels (default: 40)
65
+ - `alt` (optional): Alt text for the logo (defaults to siteName)
66
+ - `className` (optional): Custom CSS class name
67
+
68
+ #### Icon configuration
69
+
70
+ The icon appears in the top left corner of the Payload admin dashboard.
71
+
72
+ - `path` (required): Path to the icon image file
73
+ - `darkModePath` (optional): Path to the icon for dark mode
74
+ - `width` (optional): Icon width in pixels (default: 120)
75
+ - `height` (optional): Icon height in pixels (default: 120)
76
+ - `alt` (optional): Alt text for the icon (defaults to siteName)
77
+ - `className` (optional): Custom CSS class name
78
+
79
+ ### Web server configuration
80
+
81
+ Configure cache invalidation for your web server:
82
+
83
+ ```typescript
84
+ payloadHelper({
85
+ siteName: 'My Site',
86
+ webServer: {
87
+ apiKey: 'your-api-key',
88
+ baseURL: 'https://your-site.com',
89
+ cacheEndpoint: '/api/cache/purge',
90
+ },
91
+ })
92
+ ```
93
+
7
94
  ## Open Source
8
95
 
9
96
  ainsley.dev permits the use of any HTML, SCSS and Javascript found within the repository for use
@@ -0,0 +1,16 @@
1
+ import type React from 'react';
2
+ import type { AdminIconConfig } from '../../types.js';
3
+ /**
4
+ * Props for the Icon component.
5
+ */
6
+ export type IconProps = {
7
+ config: AdminIconConfig;
8
+ };
9
+ /**
10
+ * Icon component that displays a configurable icon with theme support.
11
+ * The icon appears in the top left corner of the Payload dashboard.
12
+ *
13
+ * @param {IconProps} props - Component props containing icon configuration
14
+ * @returns {React.ReactElement} Icon component
15
+ */
16
+ export declare const Icon: React.FC<IconProps>;
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useTheme } from '@payloadcms/ui';
4
+ // @ts-expect-error - next/image is a peer dependency and will be available in consumer projects
5
+ import Image from 'next/image';
6
+ /**
7
+ * Icon component that displays a configurable icon with theme support.
8
+ * The icon appears in the top left corner of the Payload dashboard.
9
+ *
10
+ * @param {IconProps} props - Component props containing icon configuration
11
+ * @returns {React.ReactElement} Icon component
12
+ */ export const Icon = ({ config })=>{
13
+ const { theme } = useTheme();
14
+ const imagePath = theme === 'light' || !config.darkModePath ? config.path : config.darkModePath;
15
+ return /*#__PURE__*/ _jsx("figure", {
16
+ className: config.className ? config.className : undefined,
17
+ children: /*#__PURE__*/ _jsx(Image, {
18
+ src: imagePath,
19
+ alt: config.alt || 'Icon',
20
+ width: config.width || 120,
21
+ height: config.height || 120
22
+ })
23
+ });
24
+ };
25
+
26
+ //# sourceMappingURL=Icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/admin/components/Icon.tsx"],"sourcesContent":["'use client';\n\nimport { useTheme } from '@payloadcms/ui';\n// @ts-expect-error - next/image is a peer dependency and will be available in consumer projects\nimport Image from 'next/image';\nimport type React from 'react';\nimport type { AdminIconConfig } from '../../types.js';\n\n/**\n * Props for the Icon component.\n */\nexport type IconProps = {\n\tconfig: AdminIconConfig;\n};\n\n/**\n * Icon component that displays a configurable icon with theme support.\n * The icon appears in the top left corner of the Payload dashboard.\n *\n * @param {IconProps} props - Component props containing icon configuration\n * @returns {React.ReactElement} Icon component\n */\nexport const Icon: React.FC<IconProps> = ({ config }) => {\n\tconst { theme } = useTheme();\n\tconst imagePath = theme === 'light' || !config.darkModePath ? config.path : config.darkModePath;\n\n\treturn (\n\t\t<figure className={config.className ? config.className : undefined}>\n\t\t\t<Image\n\t\t\t\tsrc={imagePath}\n\t\t\t\talt={config.alt || 'Icon'}\n\t\t\t\twidth={config.width || 120}\n\t\t\t\theight={config.height || 120}\n\t\t\t/>\n\t\t</figure>\n\t);\n};\n"],"names":["useTheme","Image","Icon","config","theme","imagePath","darkModePath","path","figure","className","undefined","src","alt","width","height"],"mappings":"AAAA;;AAEA,SAASA,QAAQ,QAAQ,iBAAiB;AAC1C,gGAAgG;AAChG,OAAOC,WAAW,aAAa;AAW/B;;;;;;CAMC,GACD,OAAO,MAAMC,OAA4B,CAAC,EAAEC,MAAM,EAAE;IACnD,MAAM,EAAEC,KAAK,EAAE,GAAGJ;IAClB,MAAMK,YAAYD,UAAU,WAAW,CAACD,OAAOG,YAAY,GAAGH,OAAOI,IAAI,GAAGJ,OAAOG,YAAY;IAE/F,qBACC,KAACE;QAAOC,WAAWN,OAAOM,SAAS,GAAGN,OAAOM,SAAS,GAAGC;kBACxD,cAAA,KAACT;YACAU,KAAKN;YACLO,KAAKT,OAAOS,GAAG,IAAI;YACnBC,OAAOV,OAAOU,KAAK,IAAI;YACvBC,QAAQX,OAAOW,MAAM,IAAI;;;AAI7B,EAAE"}
package/dist/index.d.ts CHANGED
@@ -7,5 +7,6 @@ import type { PayloadHelperPluginConfig } from './types.js';
7
7
  * @param pluginOptions
8
8
  */
9
9
  export declare const payloadHelper: (pluginOptions: PayloadHelperPluginConfig) => (incomingConfig: Config) => Config;
10
+ export type { IconProps } from './admin/components/Icon.js';
10
11
  export type { LogoProps } from './admin/components/Logo.js';
11
- export type { AdminLogoConfig, PayloadHelperPluginConfig } from './types.js';
12
+ export type { AdminConfig, AdminIconConfig, AdminLogoConfig, PayloadHelperPluginConfig, } from './types.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
+ import { injectAdminIcon, injectAdminLogo } from './plugin/admin.js';
1
2
  import { cacheHookCollections, cacheHookGlobals } from './plugin/hooks.js';
2
- import { injectAdminLogo } from './plugin/logo.js';
3
3
  /**
4
4
  * Payload Helper Plugin for websites at ainsley.dev
5
5
  *
@@ -11,9 +11,13 @@ import { injectAdminLogo } from './plugin/logo.js';
11
11
  // Update typescript generation file
12
12
  config.typescript = config.typescript || {};
13
13
  config.typescript.outputFile = './src/types/payload.ts';
14
- // Inject admin Logo component if adminLogo config is provided
15
- if (pluginOptions.adminLogo) {
16
- config = injectAdminLogo(config, pluginOptions.adminLogo, pluginOptions.siteName);
14
+ // Inject admin Logo component if logo config is provided
15
+ if (pluginOptions.admin?.logo) {
16
+ config = injectAdminLogo(config, pluginOptions.admin.logo, pluginOptions.siteName);
17
+ }
18
+ // Inject admin Icon component if icon config is provided
19
+ if (pluginOptions.admin?.icon) {
20
+ config = injectAdminIcon(config, pluginOptions.admin.icon, pluginOptions.siteName);
17
21
  }
18
22
  // Map collections & add hooks
19
23
  config.collections = (config.collections || []).map((collection)=>{
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config } from 'payload';\nimport { cacheHookCollections, cacheHookGlobals } from './plugin/hooks.js';\nimport { injectAdminLogo } from './plugin/logo.js';\nimport type { PayloadHelperPluginConfig } from './types.js';\n\n/**\n * Payload Helper Plugin for websites at ainsley.dev\n *\n * @constructor\n * @param pluginOptions\n */\nexport const payloadHelper =\n\t(pluginOptions: PayloadHelperPluginConfig) =>\n\t(incomingConfig: Config): Config => {\n\t\t// TODO: Validate Config\n\n\t\tlet config = incomingConfig;\n\n\t\t// Update typescript generation file\n\t\tconfig.typescript = config.typescript || {};\n\t\tconfig.typescript.outputFile = './src/types/payload.ts';\n\n\t\t// Inject admin Logo component if adminLogo config is provided\n\t\tif (pluginOptions.adminLogo) {\n\t\t\tconfig = injectAdminLogo(config, pluginOptions.adminLogo, pluginOptions.siteName);\n\t\t}\n\n\t\t// Map collections & add hooks\n\t\tconfig.collections = (config.collections || []).map((collection): CollectionConfig => {\n\t\t\tif (collection.upload !== undefined && collection.upload !== true) {\n\t\t\t\treturn collection;\n\t\t\t}\n\n\t\t\tconst hooks = collection.hooks || {};\n\n\t\t\t// Add afterChange hook only if webServer is defined\n\t\t\tif (pluginOptions.webServer) {\n\t\t\t\thooks.afterChange = [\n\t\t\t\t\t...(hooks.afterChange || []),\n\t\t\t\t\tcacheHookCollections({\n\t\t\t\t\t\tserver: pluginOptions.webServer,\n\t\t\t\t\t\tslug: collection.slug,\n\t\t\t\t\t\tfields: collection.fields,\n\t\t\t\t\t\tisCollection: true,\n\t\t\t\t\t}),\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...collection,\n\t\t\t\thooks,\n\t\t\t};\n\t\t});\n\n\t\t// Map globals & add hooks\n\t\tconfig.globals = (config.globals || []).map((global) => {\n\t\t\tconst hooks = global.hooks || {};\n\n\t\t\t// Add afterChange hook only if webServer is defined\n\t\t\tif (pluginOptions.webServer) {\n\t\t\t\thooks.afterChange = [\n\t\t\t\t\t...(hooks.afterChange || []),\n\t\t\t\t\tcacheHookGlobals({\n\t\t\t\t\t\tserver: pluginOptions.webServer,\n\t\t\t\t\t\tslug: global.slug,\n\t\t\t\t\t\tfields: global.fields,\n\t\t\t\t\t\tisCollection: true,\n\t\t\t\t\t}),\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...global,\n\t\t\t\thooks,\n\t\t\t};\n\t\t});\n\n\t\treturn config;\n\t};\n\nexport type { LogoProps } from './admin/components/Logo.js';\nexport type { AdminLogoConfig, PayloadHelperPluginConfig } from './types.js';\n"],"names":["cacheHookCollections","cacheHookGlobals","injectAdminLogo","payloadHelper","pluginOptions","incomingConfig","config","typescript","outputFile","adminLogo","siteName","collections","map","collection","upload","undefined","hooks","webServer","afterChange","server","slug","fields","isCollection","globals","global"],"mappings":"AACA,SAASA,oBAAoB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAC3E,SAASC,eAAe,QAAQ,mBAAmB;AAGnD;;;;;CAKC,GACD,OAAO,MAAMC,gBACZ,CAACC,gBACD,CAACC;QACA,wBAAwB;QAExB,IAAIC,SAASD;QAEb,oCAAoC;QACpCC,OAAOC,UAAU,GAAGD,OAAOC,UAAU,IAAI,CAAC;QAC1CD,OAAOC,UAAU,CAACC,UAAU,GAAG;QAE/B,8DAA8D;QAC9D,IAAIJ,cAAcK,SAAS,EAAE;YAC5BH,SAASJ,gBAAgBI,QAAQF,cAAcK,SAAS,EAAEL,cAAcM,QAAQ;QACjF;QAEA,8BAA8B;QAC9BJ,OAAOK,WAAW,GAAG,AAACL,CAAAA,OAAOK,WAAW,IAAI,EAAE,AAAD,EAAGC,GAAG,CAAC,CAACC;YACpD,IAAIA,WAAWC,MAAM,KAAKC,aAAaF,WAAWC,MAAM,KAAK,MAAM;gBAClE,OAAOD;YACR;YAEA,MAAMG,QAAQH,WAAWG,KAAK,IAAI,CAAC;YAEnC,oDAAoD;YACpD,IAAIZ,cAAca,SAAS,EAAE;gBAC5BD,MAAME,WAAW,GAAG;uBACfF,MAAME,WAAW,IAAI,EAAE;oBAC3BlB,qBAAqB;wBACpBmB,QAAQf,cAAca,SAAS;wBAC/BG,MAAMP,WAAWO,IAAI;wBACrBC,QAAQR,WAAWQ,MAAM;wBACzBC,cAAc;oBACf;iBACA;YACF;YAEA,OAAO;gBACN,GAAGT,UAAU;gBACbG;YACD;QACD;QAEA,0BAA0B;QAC1BV,OAAOiB,OAAO,GAAG,AAACjB,CAAAA,OAAOiB,OAAO,IAAI,EAAE,AAAD,EAAGX,GAAG,CAAC,CAACY;YAC5C,MAAMR,QAAQQ,OAAOR,KAAK,IAAI,CAAC;YAE/B,oDAAoD;YACpD,IAAIZ,cAAca,SAAS,EAAE;gBAC5BD,MAAME,WAAW,GAAG;uBACfF,MAAME,WAAW,IAAI,EAAE;oBAC3BjB,iBAAiB;wBAChBkB,QAAQf,cAAca,SAAS;wBAC/BG,MAAMI,OAAOJ,IAAI;wBACjBC,QAAQG,OAAOH,MAAM;wBACrBC,cAAc;oBACf;iBACA;YACF;YAEA,OAAO;gBACN,GAAGE,MAAM;gBACTR;YACD;QACD;QAEA,OAAOV;IACR,EAAE"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config } from 'payload';\nimport { injectAdminIcon, injectAdminLogo } from './plugin/admin.js';\nimport { cacheHookCollections, cacheHookGlobals } from './plugin/hooks.js';\nimport type { PayloadHelperPluginConfig } from './types.js';\n\n/**\n * Payload Helper Plugin for websites at ainsley.dev\n *\n * @constructor\n * @param pluginOptions\n */\nexport const payloadHelper =\n\t(pluginOptions: PayloadHelperPluginConfig) =>\n\t(incomingConfig: Config): Config => {\n\t\t// TODO: Validate Config\n\n\t\tlet config = incomingConfig;\n\n\t\t// Update typescript generation file\n\t\tconfig.typescript = config.typescript || {};\n\t\tconfig.typescript.outputFile = './src/types/payload.ts';\n\n\t\t// Inject admin Logo component if logo config is provided\n\t\tif (pluginOptions.admin?.logo) {\n\t\t\tconfig = injectAdminLogo(config, pluginOptions.admin.logo, pluginOptions.siteName);\n\t\t}\n\n\t\t// Inject admin Icon component if icon config is provided\n\t\tif (pluginOptions.admin?.icon) {\n\t\t\tconfig = injectAdminIcon(config, pluginOptions.admin.icon, pluginOptions.siteName);\n\t\t}\n\n\t\t// Map collections & add hooks\n\t\tconfig.collections = (config.collections || []).map((collection): CollectionConfig => {\n\t\t\tif (collection.upload !== undefined && collection.upload !== true) {\n\t\t\t\treturn collection;\n\t\t\t}\n\n\t\t\tconst hooks = collection.hooks || {};\n\n\t\t\t// Add afterChange hook only if webServer is defined\n\t\t\tif (pluginOptions.webServer) {\n\t\t\t\thooks.afterChange = [\n\t\t\t\t\t...(hooks.afterChange || []),\n\t\t\t\t\tcacheHookCollections({\n\t\t\t\t\t\tserver: pluginOptions.webServer,\n\t\t\t\t\t\tslug: collection.slug,\n\t\t\t\t\t\tfields: collection.fields,\n\t\t\t\t\t\tisCollection: true,\n\t\t\t\t\t}),\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...collection,\n\t\t\t\thooks,\n\t\t\t};\n\t\t});\n\n\t\t// Map globals & add hooks\n\t\tconfig.globals = (config.globals || []).map((global) => {\n\t\t\tconst hooks = global.hooks || {};\n\n\t\t\t// Add afterChange hook only if webServer is defined\n\t\t\tif (pluginOptions.webServer) {\n\t\t\t\thooks.afterChange = [\n\t\t\t\t\t...(hooks.afterChange || []),\n\t\t\t\t\tcacheHookGlobals({\n\t\t\t\t\t\tserver: pluginOptions.webServer,\n\t\t\t\t\t\tslug: global.slug,\n\t\t\t\t\t\tfields: global.fields,\n\t\t\t\t\t\tisCollection: true,\n\t\t\t\t\t}),\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...global,\n\t\t\t\thooks,\n\t\t\t};\n\t\t});\n\n\t\treturn config;\n\t};\n\nexport type { IconProps } from './admin/components/Icon.js';\nexport type { LogoProps } from './admin/components/Logo.js';\nexport type {\n\tAdminConfig,\n\tAdminIconConfig,\n\tAdminLogoConfig,\n\tPayloadHelperPluginConfig,\n} from './types.js';\n"],"names":["injectAdminIcon","injectAdminLogo","cacheHookCollections","cacheHookGlobals","payloadHelper","pluginOptions","incomingConfig","config","typescript","outputFile","admin","logo","siteName","icon","collections","map","collection","upload","undefined","hooks","webServer","afterChange","server","slug","fields","isCollection","globals","global"],"mappings":"AACA,SAASA,eAAe,EAAEC,eAAe,QAAQ,oBAAoB;AACrE,SAASC,oBAAoB,EAAEC,gBAAgB,QAAQ,oBAAoB;AAG3E;;;;;CAKC,GACD,OAAO,MAAMC,gBACZ,CAACC,gBACD,CAACC;QACA,wBAAwB;QAExB,IAAIC,SAASD;QAEb,oCAAoC;QACpCC,OAAOC,UAAU,GAAGD,OAAOC,UAAU,IAAI,CAAC;QAC1CD,OAAOC,UAAU,CAACC,UAAU,GAAG;QAE/B,yDAAyD;QACzD,IAAIJ,cAAcK,KAAK,EAAEC,MAAM;YAC9BJ,SAASN,gBAAgBM,QAAQF,cAAcK,KAAK,CAACC,IAAI,EAAEN,cAAcO,QAAQ;QAClF;QAEA,yDAAyD;QACzD,IAAIP,cAAcK,KAAK,EAAEG,MAAM;YAC9BN,SAASP,gBAAgBO,QAAQF,cAAcK,KAAK,CAACG,IAAI,EAAER,cAAcO,QAAQ;QAClF;QAEA,8BAA8B;QAC9BL,OAAOO,WAAW,GAAG,AAACP,CAAAA,OAAOO,WAAW,IAAI,EAAE,AAAD,EAAGC,GAAG,CAAC,CAACC;YACpD,IAAIA,WAAWC,MAAM,KAAKC,aAAaF,WAAWC,MAAM,KAAK,MAAM;gBAClE,OAAOD;YACR;YAEA,MAAMG,QAAQH,WAAWG,KAAK,IAAI,CAAC;YAEnC,oDAAoD;YACpD,IAAId,cAAce,SAAS,EAAE;gBAC5BD,MAAME,WAAW,GAAG;uBACfF,MAAME,WAAW,IAAI,EAAE;oBAC3BnB,qBAAqB;wBACpBoB,QAAQjB,cAAce,SAAS;wBAC/BG,MAAMP,WAAWO,IAAI;wBACrBC,QAAQR,WAAWQ,MAAM;wBACzBC,cAAc;oBACf;iBACA;YACF;YAEA,OAAO;gBACN,GAAGT,UAAU;gBACbG;YACD;QACD;QAEA,0BAA0B;QAC1BZ,OAAOmB,OAAO,GAAG,AAACnB,CAAAA,OAAOmB,OAAO,IAAI,EAAE,AAAD,EAAGX,GAAG,CAAC,CAACY;YAC5C,MAAMR,QAAQQ,OAAOR,KAAK,IAAI,CAAC;YAE/B,oDAAoD;YACpD,IAAId,cAAce,SAAS,EAAE;gBAC5BD,MAAME,WAAW,GAAG;uBACfF,MAAME,WAAW,IAAI,EAAE;oBAC3BlB,iBAAiB;wBAChBmB,QAAQjB,cAAce,SAAS;wBAC/BG,MAAMI,OAAOJ,IAAI;wBACjBC,QAAQG,OAAOH,MAAM;wBACrBC,cAAc;oBACf;iBACA;YACF;YAEA,OAAO;gBACN,GAAGE,MAAM;gBACTR;YACD;QACD;QAEA,OAAOZ;IACR,EAAE"}
@@ -0,0 +1,10 @@
1
+ import type { Config } from 'payload';
2
+ import type { AdminIconConfig, AdminLogoConfig } from '../types.js';
3
+ /**
4
+ * Injects the admin Logo component into the Payload config.
5
+ */
6
+ export declare const injectAdminLogo: (config: Config, logoConfig: AdminLogoConfig, siteName: string) => Config;
7
+ /**
8
+ * Injects the admin Icon component into the Payload config.
9
+ */
10
+ export declare const injectAdminIcon: (config: Config, iconConfig: AdminIconConfig, siteName: string) => Config;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Injects the admin Logo component into the Payload config.
3
+ */ export const injectAdminLogo = (config, logoConfig, siteName)=>({
4
+ ...config,
5
+ admin: {
6
+ ...config.admin,
7
+ components: {
8
+ ...config.admin?.components,
9
+ graphics: {
10
+ ...config.admin?.components?.graphics,
11
+ Logo: {
12
+ path: '@ainsleydev/payload-helper/dist/admin/components/Logo',
13
+ exportName: 'Logo',
14
+ clientProps: {
15
+ config: {
16
+ ...logoConfig,
17
+ alt: logoConfig.alt || siteName
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ }
24
+ });
25
+ /**
26
+ * Injects the admin Icon component into the Payload config.
27
+ */ export const injectAdminIcon = (config, iconConfig, siteName)=>({
28
+ ...config,
29
+ admin: {
30
+ ...config.admin,
31
+ components: {
32
+ ...config.admin?.components,
33
+ graphics: {
34
+ ...config.admin?.components?.graphics,
35
+ Icon: {
36
+ path: '@ainsleydev/payload-helper/dist/admin/components/Icon',
37
+ exportName: 'Icon',
38
+ clientProps: {
39
+ config: {
40
+ ...iconConfig,
41
+ alt: iconConfig.alt || siteName
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ });
49
+
50
+ //# sourceMappingURL=admin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugin/admin.ts"],"sourcesContent":["import type { Config } from 'payload';\nimport type { AdminIconConfig, AdminLogoConfig } from '../types.js';\n\n/**\n * Injects the admin Logo component into the Payload config.\n */\nexport const injectAdminLogo = (\n\tconfig: Config,\n\tlogoConfig: AdminLogoConfig,\n\tsiteName: string,\n): Config => ({\n\t...config,\n\tadmin: {\n\t\t...config.admin,\n\t\tcomponents: {\n\t\t\t...config.admin?.components,\n\t\t\tgraphics: {\n\t\t\t\t...config.admin?.components?.graphics,\n\t\t\t\tLogo: {\n\t\t\t\t\tpath: '@ainsleydev/payload-helper/dist/admin/components/Logo',\n\t\t\t\t\texportName: 'Logo',\n\t\t\t\t\tclientProps: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t...logoConfig,\n\t\t\t\t\t\t\talt: logoConfig.alt || siteName,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n});\n\n/**\n * Injects the admin Icon component into the Payload config.\n */\nexport const injectAdminIcon = (\n\tconfig: Config,\n\ticonConfig: AdminIconConfig,\n\tsiteName: string,\n): Config => ({\n\t...config,\n\tadmin: {\n\t\t...config.admin,\n\t\tcomponents: {\n\t\t\t...config.admin?.components,\n\t\t\tgraphics: {\n\t\t\t\t...config.admin?.components?.graphics,\n\t\t\t\tIcon: {\n\t\t\t\t\tpath: '@ainsleydev/payload-helper/dist/admin/components/Icon',\n\t\t\t\t\texportName: 'Icon',\n\t\t\t\t\tclientProps: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t...iconConfig,\n\t\t\t\t\t\t\talt: iconConfig.alt || siteName,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n});\n"],"names":["injectAdminLogo","config","logoConfig","siteName","admin","components","graphics","Logo","path","exportName","clientProps","alt","injectAdminIcon","iconConfig","Icon"],"mappings":"AAGA;;CAEC,GACD,OAAO,MAAMA,kBAAkB,CAC9BC,QACAC,YACAC,WACa,CAAA;QACb,GAAGF,MAAM;QACTG,OAAO;YACN,GAAGH,OAAOG,KAAK;YACfC,YAAY;gBACX,GAAGJ,OAAOG,KAAK,EAAEC,UAAU;gBAC3BC,UAAU;oBACT,GAAGL,OAAOG,KAAK,EAAEC,YAAYC,QAAQ;oBACrCC,MAAM;wBACLC,MAAM;wBACNC,YAAY;wBACZC,aAAa;4BACZT,QAAQ;gCACP,GAAGC,UAAU;gCACbS,KAAKT,WAAWS,GAAG,IAAIR;4BACxB;wBACD;oBACD;gBACD;YACD;QACD;IACD,CAAA,EAAG;AAEH;;CAEC,GACD,OAAO,MAAMS,kBAAkB,CAC9BX,QACAY,YACAV,WACa,CAAA;QACb,GAAGF,MAAM;QACTG,OAAO;YACN,GAAGH,OAAOG,KAAK;YACfC,YAAY;gBACX,GAAGJ,OAAOG,KAAK,EAAEC,UAAU;gBAC3BC,UAAU;oBACT,GAAGL,OAAOG,KAAK,EAAEC,YAAYC,QAAQ;oBACrCQ,MAAM;wBACLN,MAAM;wBACNC,YAAY;wBACZC,aAAa;4BACZT,QAAQ;gCACP,GAAGY,UAAU;gCACbF,KAAKE,WAAWF,GAAG,IAAIR;4BACxB;wBACD;oBACD;gBACD;YACD;QACD;IACD,CAAA,EAAG"}
@@ -0,0 +1,6 @@
1
+ import type { Config } from 'payload';
2
+ import type { AdminIconConfig } from '../types.js';
3
+ /**
4
+ * Injects the admin Icon component into the Payload config.
5
+ */
6
+ export declare const injectAdminIcon: (config: Config, iconConfig: AdminIconConfig, siteName: string) => Config;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Injects the admin Icon component into the Payload config.
3
+ */ export const injectAdminIcon = (config, iconConfig, siteName)=>({
4
+ ...config,
5
+ admin: {
6
+ ...config.admin,
7
+ components: {
8
+ ...config.admin?.components,
9
+ graphics: {
10
+ ...config.admin?.components?.graphics,
11
+ Icon: {
12
+ path: '@ainsleydev/payload-helper/dist/admin/components/Icon',
13
+ exportName: 'Icon',
14
+ clientProps: {
15
+ config: {
16
+ ...iconConfig,
17
+ alt: iconConfig.alt || siteName
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ }
24
+ });
25
+
26
+ //# sourceMappingURL=icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugin/icon.ts"],"sourcesContent":["import type { Config } from 'payload';\nimport type { AdminIconConfig } from '../types.js';\n\n/**\n * Injects the admin Icon component into the Payload config.\n */\nexport const injectAdminIcon = (\n\tconfig: Config,\n\ticonConfig: AdminIconConfig,\n\tsiteName: string,\n): Config => ({\n\t...config,\n\tadmin: {\n\t\t...config.admin,\n\t\tcomponents: {\n\t\t\t...config.admin?.components,\n\t\t\tgraphics: {\n\t\t\t\t...config.admin?.components?.graphics,\n\t\t\t\tIcon: {\n\t\t\t\t\tpath: '@ainsleydev/payload-helper/dist/admin/components/Icon',\n\t\t\t\t\texportName: 'Icon',\n\t\t\t\t\tclientProps: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t...iconConfig,\n\t\t\t\t\t\t\talt: iconConfig.alt || siteName,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n});\n"],"names":["injectAdminIcon","config","iconConfig","siteName","admin","components","graphics","Icon","path","exportName","clientProps","alt"],"mappings":"AAGA;;CAEC,GACD,OAAO,MAAMA,kBAAkB,CAC9BC,QACAC,YACAC,WACa,CAAA;QACb,GAAGF,MAAM;QACTG,OAAO;YACN,GAAGH,OAAOG,KAAK;YACfC,YAAY;gBACX,GAAGJ,OAAOG,KAAK,EAAEC,UAAU;gBAC3BC,UAAU;oBACT,GAAGL,OAAOG,KAAK,EAAEC,YAAYC,QAAQ;oBACrCC,MAAM;wBACLC,MAAM;wBACNC,YAAY;wBACZC,aAAa;4BACZT,QAAQ;gCACP,GAAGC,UAAU;gCACbS,KAAKT,WAAWS,GAAG,IAAIR;4BACxB;wBACD;oBACD;gBACD;YACD;QACD;IACD,CAAA,EAAG"}
package/dist/types.d.ts CHANGED
@@ -18,9 +18,21 @@ export type AdminLogoConfig = {
18
18
  alt?: string;
19
19
  className?: string;
20
20
  };
21
+ export type AdminIconConfig = {
22
+ path: string;
23
+ darkModePath?: string;
24
+ width?: number;
25
+ height?: number;
26
+ alt?: string;
27
+ className?: string;
28
+ };
29
+ export type AdminConfig = {
30
+ logo?: AdminLogoConfig;
31
+ icon?: AdminIconConfig;
32
+ };
21
33
  export type PayloadHelperPluginConfig = {
22
34
  siteName: string;
23
35
  settings?: SettingsConfig;
24
36
  webServer?: WebServerConfig;
25
- adminLogo?: AdminLogoConfig;
37
+ admin?: AdminConfig;
26
38
  };
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["// import type { SEOPluginConfig } from \"@payloadcms/plugin-seo/types\";\nimport type { GlobalConfig, Tab, TextField, TextareaField, UploadField } from 'payload';\n// import type {SEOPluginConfig} from \"@payloadcms/plugin-seo/dist/types.js\";\n\nexport type SettingsConfig = {\n\tadditionalTabs?: Tab[];\n\toverride: (args: {\n\t\tconfig: GlobalConfig;\n\t}) => GlobalConfig;\n};\n\nexport type WebServerConfig = {\n\tapiKey?: string;\n\tbaseURL: string;\n\tcacheEndpoint: string;\n};\n\n// export type SEOConfig = Omit<SEOPluginConfig, 'uploadsCollection' | 'tabbedUI'>;\n//\n// export type S3Config = {\n// \tenabled: boolean;\n// \tbucket: string\n// \tconfig: AWS.S3ClientConfig;\n// }\n\nexport type AdminLogoConfig = {\n\tpath: string;\n\tdarkModePath?: string;\n\twidth?: number;\n\theight?: number;\n\talt?: string;\n\tclassName?: string;\n};\n\nexport type PayloadHelperPluginConfig = {\n\tsiteName: string;\n\tsettings?: SettingsConfig;\n\t// seo?: SEOConfig;\n\twebServer?: WebServerConfig;\n\tadminLogo?: AdminLogoConfig;\n};\n"],"names":[],"mappings":"AAAA,uEAAuE;AAkCvE,WAME"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["// import type { SEOPluginConfig } from \"@payloadcms/plugin-seo/types\";\nimport type { GlobalConfig, Tab, TextField, TextareaField, UploadField } from 'payload';\n// import type {SEOPluginConfig} from \"@payloadcms/plugin-seo/dist/types.js\";\n\nexport type SettingsConfig = {\n\tadditionalTabs?: Tab[];\n\toverride: (args: {\n\t\tconfig: GlobalConfig;\n\t}) => GlobalConfig;\n};\n\nexport type WebServerConfig = {\n\tapiKey?: string;\n\tbaseURL: string;\n\tcacheEndpoint: string;\n};\n\n// export type SEOConfig = Omit<SEOPluginConfig, 'uploadsCollection' | 'tabbedUI'>;\n//\n// export type S3Config = {\n// \tenabled: boolean;\n// \tbucket: string\n// \tconfig: AWS.S3ClientConfig;\n// }\n\nexport type AdminLogoConfig = {\n\tpath: string;\n\tdarkModePath?: string;\n\twidth?: number;\n\theight?: number;\n\talt?: string;\n\tclassName?: string;\n};\n\nexport type AdminIconConfig = {\n\tpath: string;\n\tdarkModePath?: string;\n\twidth?: number;\n\theight?: number;\n\talt?: string;\n\tclassName?: string;\n};\n\nexport type AdminConfig = {\n\tlogo?: AdminLogoConfig;\n\ticon?: AdminIconConfig;\n};\n\nexport type PayloadHelperPluginConfig = {\n\tsiteName: string;\n\tsettings?: SettingsConfig;\n\t// seo?: SEOConfig;\n\twebServer?: WebServerConfig;\n\tadmin?: AdminConfig;\n};\n"],"names":[],"mappings":"AAAA,uEAAuE;AAgDvE,WAME"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ainsleydev/payload-helper",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "description": "Payload CMS utilities, collections and global types for ainsley.dev builds",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -86,7 +86,7 @@
86
86
  "build": "pnpm clean && pnpm build:types && pnpm build:swc",
87
87
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
88
88
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
89
- "format": "biome format --write . --apply-unsafe --organise-imports",
89
+ "format": "biome check --write --unsafe .",
90
90
  "lint": "biome lint --write .",
91
91
  "clean": "rimraf {dist,*.tsbuildinfo}",
92
92
  "test": "jest --passWithNoTests"