@kilivi/payloadcms-theme-management 1.0.2 → 1.0.4

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.
Files changed (46) hide show
  1. package/README.md +4 -0
  2. package/dist/components/ThemePreview.d.ts.map +1 -1
  3. package/dist/components/ThemePreview.js +15 -12
  4. package/dist/components/ThemePreview.js.map +1 -1
  5. package/dist/constants/themeFonts.d.ts +68 -17
  6. package/dist/constants/themeFonts.d.ts.map +1 -1
  7. package/dist/constants/themeFonts.js +68 -17
  8. package/dist/constants/themeFonts.js.map +1 -1
  9. package/dist/fields/FontSelectField.d.ts.map +1 -1
  10. package/dist/fields/FontSelectField.js +44 -7
  11. package/dist/fields/FontSelectField.js.map +1 -1
  12. package/dist/fields/ThemePreviewField.d.ts.map +1 -1
  13. package/dist/fields/ThemePreviewField.js +35 -29
  14. package/dist/fields/ThemePreviewField.js.map +1 -1
  15. package/dist/fields/ThemeTokenSelectField.d.ts.map +1 -1
  16. package/dist/fields/ThemeTokenSelectField.js +0 -1
  17. package/dist/fields/ThemeTokenSelectField.js.map +1 -1
  18. package/dist/globals/ThemeSettings/FontPicker/FontPreview.d.ts.map +1 -1
  19. package/dist/globals/ThemeSettings/FontPicker/FontPreview.js +7 -4
  20. package/dist/globals/ThemeSettings/FontPicker/FontPreview.js.map +1 -1
  21. package/dist/globals/ThemeSettings/config.d.ts.map +1 -1
  22. package/dist/globals/ThemeSettings/config.js +32 -8
  23. package/dist/globals/ThemeSettings/config.js.map +1 -1
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +29 -12
  27. package/dist/index.js.map +1 -1
  28. package/dist/providers/font-loader.d.ts +1 -1
  29. package/dist/providers/font-loader.d.ts.map +1 -1
  30. package/dist/providers/font-loader.js.map +1 -1
  31. package/dist/translations.d.ts +49 -0
  32. package/dist/translations.d.ts.map +1 -0
  33. package/dist/translations.js +121 -0
  34. package/dist/translations.js.map +1 -0
  35. package/dist/types/jest-axe.d.js +2 -0
  36. package/dist/types/jest-axe.d.js.map +1 -0
  37. package/dist/types/payload-ui.d.js +2 -0
  38. package/dist/types/payload-ui.d.js.map +1 -0
  39. package/dist/utilities/getThemeSettings.d.ts.map +1 -1
  40. package/dist/utilities/getThemeSettings.js +8 -2
  41. package/dist/utilities/getThemeSettings.js.map +1 -1
  42. package/dist/utils/getAdminLanguage.d.ts +2 -0
  43. package/dist/utils/getAdminLanguage.d.ts.map +1 -0
  44. package/dist/utils/getAdminLanguage.js +21 -0
  45. package/dist/utils/getAdminLanguage.js.map +1 -0
  46. package/package.json +22 -4
@@ -1,6 +1,8 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import React, { useEffect, useRef } from 'react';
4
+ import { getTranslations } from '../../../translations.js';
5
+ import { getAdminLanguage } from '../../../utils/getAdminLanguage.js';
4
6
  /**
5
7
  * FontPreview component with Shadow DOM isolation
6
8
  *
@@ -54,6 +56,7 @@ import React, { useEffect, useRef } from 'react';
54
56
  padding: 0;
55
57
  `;
56
58
  let content;
59
+ const t = getTranslations(getAdminLanguage());
57
60
  switch(variant){
58
61
  case 'h1':
59
62
  content = document.createElement('h1');
@@ -127,7 +130,7 @@ import React, { useEffect, useRef } from 'react';
127
130
  line-height: 1.8;
128
131
  margin: 4px 0;
129
132
  `;
130
- line.textContent = `${weight} - The quick brown fox jumps over the lazy dog`;
133
+ line.textContent = `${weight} - ${t.ui.sampleSentence}`;
131
134
  content.appendChild(line);
132
135
  });
133
136
  break;
@@ -153,9 +156,9 @@ import React, { useEffect, useRef } from 'react';
153
156
  font-weight: 400;
154
157
  line-height: 1.5;
155
158
  margin: 0;
156
- color: var(--theme-text-secondary, #6b7280);
159
+ color: var(--theme-text-secondary, #6b7280); // visual only (no text change)
157
160
  `;
158
- description.textContent = text || 'The quick brown fox jumps over the lazy dog';
161
+ description.textContent = text || t.ui.sampleSentence;
159
162
  content.appendChild(title);
160
163
  content.appendChild(description);
161
164
  break;
@@ -182,7 +185,7 @@ import React, { useEffect, useRef } from 'react';
182
185
  flex: 1;
183
186
  opacity: 0.7;
184
187
  `;
185
- sampleSpan.textContent = text || 'The quick brown fox jumps over the lazy dog';
188
+ sampleSpan.textContent = text || t.ui.sampleSentence;
186
189
  content.appendChild(nameSpan);
187
190
  content.appendChild(sampleSpan);
188
191
  break;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/globals/ThemeSettings/FontPicker/FontPreview.tsx"],"sourcesContent":["'use client'\n\nimport React, { useEffect, useRef } from 'react'\nimport type { GoogleFont } from '../../../app/api/google-fonts/route'\n\nexport type PreviewVariant =\n | 'h1'\n | 'h2'\n | 'h3'\n | 'body'\n | 'small'\n | 'chars'\n | 'weights'\n | 'card'\n | 'row'\n | 'name'\n\nexport interface FontPreviewProps {\n font: GoogleFont\n variant: PreviewVariant\n text?: string\n onLoad?: () => void\n}\n\n/**\n * FontPreview component with Shadow DOM isolation\n *\n * This component renders font previews in an isolated Shadow DOM\n * to prevent Payload CMS admin styles from affecting the preview.\n */\nexport const FontPreview: React.FC<FontPreviewProps> = ({ font, variant, text, onLoad }) => {\n const shadowHostRef = useRef<HTMLDivElement>(null)\n const shadowRootRef = useRef<ShadowRoot | null>(null)\n const fontLoadedRef = useRef(false)\n\n useEffect(() => {\n if (!shadowHostRef.current) return\n\n // Create Shadow DOM if not already created\n if (!shadowRootRef.current) {\n shadowRootRef.current = shadowHostRef.current.attachShadow({ mode: 'open' })\n }\n\n const shadowRoot = shadowRootRef.current\n\n // Get font weights\n const weights = font.variants.filter((v) => !v.includes('italic')).join(';')\n const fontFamily = font.family\n\n // Load font CSS\n const loadFont = async () => {\n if (fontLoadedRef.current) return\n\n try {\n // Create font face CSS\n const fontUrl = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(\n fontFamily,\n )}:wght@${weights}&display=swap`\n\n // Check if font is already loaded\n const link = document.createElement('link')\n link.rel = 'stylesheet'\n link.href = fontUrl\n\n // Wait for font to load\n link.onload = () => {\n fontLoadedRef.current = true\n onLoad?.()\n }\n\n // Add link to shadow root\n shadowRoot.appendChild(link)\n } catch (error) {\n console.error('Error loading font:', error)\n }\n }\n\n loadFont()\n\n // Render preview based on variant\n const renderPreview = () => {\n const container = document.createElement('div')\n container.style.cssText = `\n font-family: '${fontFamily}', sans-serif;\n color: inherit;\n margin: 0;\n padding: 0;\n `\n\n let content: HTMLElement\n\n switch (variant) {\n case 'h1':\n content = document.createElement('h1')\n content.style.cssText = `\n font-size: 48px;\n font-weight: 700;\n line-height: 1.2;\n margin: 0;\n `\n content.textContent = text || font.family\n break\n\n case 'h2':\n content = document.createElement('h2')\n content.style.cssText = `\n font-size: 36px;\n font-weight: 600;\n line-height: 1.3;\n margin: 0;\n `\n content.textContent = text || font.family\n break\n\n case 'h3':\n content = document.createElement('h3')\n content.style.cssText = `\n font-size: 24px;\n font-weight: 500;\n line-height: 1.4;\n margin: 0;\n `\n content.textContent = text || font.family\n break\n\n case 'body':\n content = document.createElement('p')\n content.style.cssText = `\n font-size: 16px;\n font-weight: 400;\n line-height: 1.6;\n margin: 0;\n `\n content.textContent = text || font.family\n break\n\n case 'small':\n content = document.createElement('p')\n content.style.cssText = `\n font-size: 14px;\n font-weight: 400;\n line-height: 1.5;\n margin: 0;\n `\n content.textContent = text || font.family\n break\n\n case 'chars':\n content = document.createElement('div')\n content.style.cssText = `\n font-size: 18px;\n font-weight: 400;\n line-height: 1.5;\n margin: 0;\n `\n content.textContent = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz 0123456789'\n break\n\n case 'weights':\n content = document.createElement('div')\n content.style.cssText = `margin: 0;`\n const availableWeights = font.variants\n .filter((v) => !v.includes('italic'))\n .map((v) => parseInt(v))\n .filter((w) => !isNaN(w))\n .sort((a, b) => a - b)\n\n availableWeights.forEach((weight) => {\n const line = document.createElement('div')\n line.style.cssText = `\n font-size: 16px;\n font-weight: ${weight};\n line-height: 1.8;\n margin: 4px 0;\n `\n line.textContent = `${weight} - The quick brown fox jumps over the lazy dog`\n content.appendChild(line)\n })\n break\n\n case 'card':\n content = document.createElement('div')\n content.style.cssText = `\n padding: 16px;\n background: var(--theme-bg, #ffffff);\n border: 1px solid var(--theme-border, #e5e7eb);\n border-radius: 8px;\n margin: 0;\n `\n const title = document.createElement('h3')\n title.style.cssText = `\n font-size: 20px;\n font-weight: 600;\n margin: 0 0 8px 0;\n `\n title.textContent = font.family\n const description = document.createElement('p')\n description.style.cssText = `\n font-size: 14px;\n font-weight: 400;\n line-height: 1.5;\n margin: 0;\n color: var(--theme-text-secondary, #6b7280);\n `\n description.textContent = text || 'The quick brown fox jumps over the lazy dog'\n content.appendChild(title)\n content.appendChild(description)\n break\n\n case 'row':\n content = document.createElement('div')\n content.style.cssText = `\n display: flex;\n align-items: center;\n gap: 16px;\n padding: 12px 16px;\n margin: 0;\n `\n const nameSpan = document.createElement('span')\n nameSpan.style.cssText = `\n font-size: 16px;\n font-weight: 500;\n min-width: 150px;\n `\n nameSpan.textContent = font.family\n const sampleSpan = document.createElement('span')\n sampleSpan.style.cssText = `\n font-size: 16px;\n font-weight: 400;\n flex: 1;\n opacity: 0.7;\n `\n sampleSpan.textContent = text || 'The quick brown fox jumps over the lazy dog'\n content.appendChild(nameSpan)\n content.appendChild(sampleSpan)\n break\n\n case 'name':\n default:\n content = document.createElement('span')\n content.style.cssText = `\n font-size: 16px;\n font-weight: 500;\n margin: 0;\n `\n content.textContent = font.family\n break\n }\n\n container.appendChild(content)\n return container\n }\n\n // Clear previous content\n shadowRoot.innerHTML = ''\n\n // Render preview\n const preview = renderPreview()\n shadowRoot.appendChild(preview)\n\n // Cleanup\n return () => {\n if (shadowRoot) {\n shadowRoot.innerHTML = ''\n }\n }\n }, [font, variant, text, onLoad])\n\n return <div ref={shadowHostRef} style={{ width: '100%', minHeight: '20px' }} />\n}\n"],"names":["React","useEffect","useRef","FontPreview","font","variant","text","onLoad","shadowHostRef","shadowRootRef","fontLoadedRef","current","attachShadow","mode","shadowRoot","weights","variants","filter","v","includes","join","fontFamily","family","loadFont","fontUrl","encodeURIComponent","link","document","createElement","rel","href","onload","appendChild","error","console","renderPreview","container","style","cssText","content","textContent","availableWeights","map","parseInt","w","isNaN","sort","a","b","forEach","weight","line","title","description","nameSpan","sampleSpan","innerHTML","preview","div","ref","width","minHeight"],"mappings":"AAAA;;AAEA,OAAOA,SAASC,SAAS,EAAEC,MAAM,QAAQ,QAAO;AAsBhD;;;;;CAKC,GACD,OAAO,MAAMC,cAA0C,CAAC,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,EAAEC,MAAM,EAAE;IACrF,MAAMC,gBAAgBN,OAAuB;IAC7C,MAAMO,gBAAgBP,OAA0B;IAChD,MAAMQ,gBAAgBR,OAAO;IAE7BD,UAAU;QACR,IAAI,CAACO,cAAcG,OAAO,EAAE;QAE5B,2CAA2C;QAC3C,IAAI,CAACF,cAAcE,OAAO,EAAE;YAC1BF,cAAcE,OAAO,GAAGH,cAAcG,OAAO,CAACC,YAAY,CAAC;gBAAEC,MAAM;YAAO;QAC5E;QAEA,MAAMC,aAAaL,cAAcE,OAAO;QAExC,mBAAmB;QACnB,MAAMI,UAAUX,KAAKY,QAAQ,CAACC,MAAM,CAAC,CAACC,IAAM,CAACA,EAAEC,QAAQ,CAAC,WAAWC,IAAI,CAAC;QACxE,MAAMC,aAAajB,KAAKkB,MAAM;QAE9B,gBAAgB;QAChB,MAAMC,WAAW;YACf,IAAIb,cAAcC,OAAO,EAAE;YAE3B,IAAI;gBACF,uBAAuB;gBACvB,MAAMa,UAAU,CAAC,yCAAyC,EAAEC,mBAC1DJ,YACA,MAAM,EAAEN,QAAQ,aAAa,CAAC;gBAEhC,kCAAkC;gBAClC,MAAMW,OAAOC,SAASC,aAAa,CAAC;gBACpCF,KAAKG,GAAG,GAAG;gBACXH,KAAKI,IAAI,GAAGN;gBAEZ,wBAAwB;gBACxBE,KAAKK,MAAM,GAAG;oBAC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AC;oBACjCW,QAAQF,KAAK,CAACC,OAAO,GAAG,CAAC;;;;;;UAMzB,CAAC;oBACD,MAAMgB,WAAW3B,SAASC,aAAa,CAAC;oBACxC0B,SAASjB,KAAK,CAACC,OAAO,GAAG,CAAC;;;;UAI1B,CAAC;oBACDgB,SAASd,WAAW,GAAGpC,KAAKkB,MAAM;oBAClC,MAAMiC,aAAa5B,SAASC,aAAa,CAAC;oBAC1C2B,WAAWlB,KAAK,CAACC,OAAO,GAAG,CAAC;;;;;UAK5B,CAAC;oBACDiB,WAAWf,WAAW,GAAGlC,QAAQ;oBACjCiC,QAAQP,WAAW,CAACsB;oBACpBf,QAAQP,WAAW,CAACuB;oBACpB;gBAEF,KAAK;gBACL;oBACEhB,UAAUZ,SAASC,aAAa,CAAC;oBACjCW,QAAQF,KAAK,CAACC,OAAO,GAAG,CAAC;;;;UAIzB,CAAC;oBACDC,QAAQC,WAAW,GAAGpC,KAAKkB,MAAM;oBACjC;YACJ;YAEAc,UAAUJ,WAAW,CAACO;YACtB,OAAOH;QACT;QAEA,yBAAyB;QACzBtB,WAAW0C,SAAS,GAAG;QAEvB,iBAAiB;QACjB,MAAMC,UAAUtB;QAChBrB,WAAWkB,WAAW,CAACyB;QAEvB,UAAU;QACV,OAAO;YACL,IAAI3C,YAAY;gBACdA,WAAW0C,SAAS,GAAG;YACzB;QACF;IACF,GAAG;QAACpD;QAAMC;QAASC;QAAMC;KAAO;IAEhC,qBAAO,KAACmD;QAAIC,KAAKnD;QAAe6B,OAAO;YAAEuB,OAAO;YAAQC,WAAW;QAAO;;AAC5E,EAAC"}
1
+ {"version":3,"sources":["../../../../src/globals/ThemeSettings/FontPicker/FontPreview.tsx"],"sourcesContent":["'use client'\n\nimport React, { useEffect, useRef } from 'react'\nimport type { GoogleFont } from '../../../app/api/google-fonts/route'\nimport { getTranslations } from '../../../translations.js'\nimport { getAdminLanguage } from '../../../utils/getAdminLanguage.js'\n\nexport type PreviewVariant =\n | 'h1'\n | 'h2'\n | 'h3'\n | 'body'\n | 'small'\n | 'chars'\n | 'weights'\n | 'card'\n | 'row'\n | 'name'\n\nexport interface FontPreviewProps {\n font: GoogleFont\n variant: PreviewVariant\n text?: string\n onLoad?: () => void\n}\n\n/**\n * FontPreview component with Shadow DOM isolation\n *\n * This component renders font previews in an isolated Shadow DOM\n * to prevent Payload CMS admin styles from affecting the preview.\n */\nexport const FontPreview: React.FC<FontPreviewProps> = ({ font, variant, text, onLoad }) => {\n const shadowHostRef = useRef<HTMLDivElement>(null)\n const shadowRootRef = useRef<ShadowRoot | null>(null)\n const fontLoadedRef = useRef(false)\n\n useEffect(() => {\n if (!shadowHostRef.current) return\n\n // Create Shadow DOM if not already created\n if (!shadowRootRef.current) {\n shadowRootRef.current = shadowHostRef.current.attachShadow({ mode: 'open' })\n }\n\n const shadowRoot = shadowRootRef.current\n\n // Get font weights\n const weights = font.variants.filter((v) => !v.includes('italic')).join(';')\n const fontFamily = font.family\n\n // Load font CSS\n const loadFont = async () => {\n if (fontLoadedRef.current) return\n\n try {\n // Create font face CSS\n const fontUrl = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(\n fontFamily,\n )}:wght@${weights}&display=swap`\n\n // Check if font is already loaded\n const link = document.createElement('link')\n link.rel = 'stylesheet'\n link.href = fontUrl\n\n // Wait for font to load\n link.onload = () => {\n fontLoadedRef.current = true\n onLoad?.()\n }\n\n // Add link to shadow root\n shadowRoot.appendChild(link)\n } catch (error) {\n console.error('Error loading font:', error)\n }\n }\n\n loadFont()\n\n // Render preview based on variant\n const renderPreview = () => {\n const container = document.createElement('div')\n container.style.cssText = `\n font-family: '${fontFamily}', sans-serif;\n color: inherit;\n margin: 0;\n padding: 0;\n `\n\n let content: HTMLElement\n const t = getTranslations(getAdminLanguage())\n\n switch (variant) {\n case 'h1':\n content = document.createElement('h1')\n content.style.cssText = `\n font-size: 48px;\n font-weight: 700;\n line-height: 1.2;\n margin: 0;\n `\n content.textContent = text || font.family\n break\n\n case 'h2':\n content = document.createElement('h2')\n content.style.cssText = `\n font-size: 36px;\n font-weight: 600;\n line-height: 1.3;\n margin: 0;\n `\n content.textContent = text || font.family\n break\n\n case 'h3':\n content = document.createElement('h3')\n content.style.cssText = `\n font-size: 24px;\n font-weight: 500;\n line-height: 1.4;\n margin: 0;\n `\n content.textContent = text || font.family\n break\n\n case 'body':\n content = document.createElement('p')\n content.style.cssText = `\n font-size: 16px;\n font-weight: 400;\n line-height: 1.6;\n margin: 0;\n `\n content.textContent = text || font.family\n break\n\n case 'small':\n content = document.createElement('p')\n content.style.cssText = `\n font-size: 14px;\n font-weight: 400;\n line-height: 1.5;\n margin: 0;\n `\n content.textContent = text || font.family\n break\n\n case 'chars':\n content = document.createElement('div')\n content.style.cssText = `\n font-size: 18px;\n font-weight: 400;\n line-height: 1.5;\n margin: 0;\n `\n content.textContent = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz 0123456789'\n break\n\n case 'weights':\n content = document.createElement('div')\n content.style.cssText = `margin: 0;`\n const availableWeights = font.variants\n .filter((v) => !v.includes('italic'))\n .map((v) => parseInt(v))\n .filter((w) => !isNaN(w))\n .sort((a, b) => a - b)\n\n availableWeights.forEach((weight) => {\n const line = document.createElement('div')\n line.style.cssText = `\n font-size: 16px;\n font-weight: ${weight};\n line-height: 1.8;\n margin: 4px 0;\n `\n line.textContent = `${weight} - ${t.ui.sampleSentence}`\n content.appendChild(line)\n })\n break\n\n case 'card':\n content = document.createElement('div')\n content.style.cssText = `\n padding: 16px;\n background: var(--theme-bg, #ffffff);\n border: 1px solid var(--theme-border, #e5e7eb);\n border-radius: 8px;\n margin: 0;\n `\n const title = document.createElement('h3')\n title.style.cssText = `\n font-size: 20px;\n font-weight: 600;\n margin: 0 0 8px 0;\n `\n title.textContent = font.family\n const description = document.createElement('p')\n description.style.cssText = `\n font-size: 14px;\n font-weight: 400;\n line-height: 1.5;\n margin: 0;\n color: var(--theme-text-secondary, #6b7280); // visual only (no text change)\n `\n description.textContent = text || t.ui.sampleSentence\n content.appendChild(title)\n content.appendChild(description)\n break\n\n case 'row':\n content = document.createElement('div')\n content.style.cssText = `\n display: flex;\n align-items: center;\n gap: 16px;\n padding: 12px 16px;\n margin: 0;\n `\n const nameSpan = document.createElement('span')\n nameSpan.style.cssText = `\n font-size: 16px;\n font-weight: 500;\n min-width: 150px;\n `\n nameSpan.textContent = font.family\n const sampleSpan = document.createElement('span')\n sampleSpan.style.cssText = `\n font-size: 16px;\n font-weight: 400;\n flex: 1;\n opacity: 0.7;\n `\n sampleSpan.textContent = text || t.ui.sampleSentence\n content.appendChild(nameSpan)\n content.appendChild(sampleSpan)\n break\n\n case 'name':\n default:\n content = document.createElement('span')\n content.style.cssText = `\n font-size: 16px;\n font-weight: 500;\n margin: 0;\n `\n content.textContent = font.family\n break\n }\n\n container.appendChild(content)\n return container\n }\n\n // Clear previous content\n shadowRoot.innerHTML = ''\n\n // Render preview\n const preview = renderPreview()\n shadowRoot.appendChild(preview)\n\n // Cleanup\n return () => {\n if (shadowRoot) {\n shadowRoot.innerHTML = ''\n }\n }\n }, [font, variant, text, onLoad])\n\n return <div ref={shadowHostRef} style={{ width: '100%', minHeight: '20px' }} />\n}\n"],"names":["React","useEffect","useRef","getTranslations","getAdminLanguage","FontPreview","font","variant","text","onLoad","shadowHostRef","shadowRootRef","fontLoadedRef","current","attachShadow","mode","shadowRoot","weights","variants","filter","v","includes","join","fontFamily","family","loadFont","fontUrl","encodeURIComponent","link","document","createElement","rel","href","onload","appendChild","error","console","renderPreview","container","style","cssText","content","t","textContent","availableWeights","map","parseInt","w","isNaN","sort","a","b","forEach","weight","line","ui","sampleSentence","title","description","nameSpan","sampleSpan","innerHTML","preview","div","ref","width","minHeight"],"mappings":"AAAA;;AAEA,OAAOA,SAASC,SAAS,EAAEC,MAAM,QAAQ,QAAO;AAEhD,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,gBAAgB,QAAQ,qCAAoC;AAqBrE;;;;;CAKC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MoC,aAAa/B,SAASC,aAAa,CAAC;oBAC1C8B,WAAWrB,KAAK,CAACC,OAAO,GAAG,CAAC;;;;;UAK5B,CAAC;oBACDoB,WAAWjB,WAAW,GAAGnC,QAAQkC,EAAEa,EAAE,CAACC,cAAc;oBACpDf,QAAQP,WAAW,CAACyB;oBACpBlB,QAAQP,WAAW,CAAC0B;oBACpB;gBAEF,KAAK;gBACL;oBACEnB,UAAUZ,SAASC,aAAa,CAAC;oBACjCW,QAAQF,KAAK,CAACC,OAAO,GAAG,CAAC;;;;UAIzB,CAAC;oBACDC,QAAQE,WAAW,GAAGrC,KAAKkB,MAAM;oBACjC;YACJ;YAEAc,UAAUJ,WAAW,CAACO;YACtB,OAAOH;QACT;QAEA,yBAAyB;QACzBtB,WAAW6C,SAAS,GAAG;QAEvB,iBAAiB;QACjB,MAAMC,UAAUzB;QAChBrB,WAAWkB,WAAW,CAAC4B;QAEvB,UAAU;QACV,OAAO;YACL,IAAI9C,YAAY;gBACdA,WAAW6C,SAAS,GAAG;YACzB;QACF;IACF,GAAG;QAACvD;QAAMC;QAASC;QAAMC;KAAO;IAEhC,qBAAO,KAACsD;QAAIC,KAAKtD;QAAe6B,OAAO;YAAE0B,OAAO;YAAQC,WAAW;QAAO;;AAC5E,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/globals/ThemeSettings/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,YA+G3B,CAAA"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/globals/ThemeSettings/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,YAqH3B,CAAA"}
@@ -6,9 +6,15 @@
6
6
  * - Google Fonts API key (optional, for extended font library)
7
7
  */ export const ThemeSettings = {
8
8
  slug: 'themeSettings',
9
- label: 'Theme Settings',
9
+ label: {
10
+ en: 'Theme Settings',
11
+ cs: 'Nastavení témat'
12
+ },
10
13
  admin: {
11
- group: 'Settings'
14
+ group: {
15
+ en: 'Settings',
16
+ cs: 'Nastavení'
17
+ }
12
18
  },
13
19
  access: {
14
20
  read: ()=>true,
@@ -22,15 +28,24 @@
22
28
  type: 'tabs',
23
29
  tabs: [
24
30
  {
25
- label: 'Typography',
31
+ label: {
32
+ en: 'Typography',
33
+ cs: 'Typografie'
34
+ },
26
35
  fields: [
27
36
  {
28
37
  name: 'activeFont',
29
38
  type: 'text',
30
- label: 'Active Font Family',
39
+ label: {
40
+ en: 'Active Font Family',
41
+ cs: 'Aktivní rodina písem'
42
+ },
31
43
  defaultValue: 'Inter',
32
44
  admin: {
33
- description: 'The currently active font family for your website',
45
+ description: {
46
+ en: 'The currently active font family for your website',
47
+ cs: 'Aktuální rodina písem pro váš web'
48
+ },
34
49
  components: {
35
50
  Field: '@kilivi/payloadcms-theme-management/globals/ThemeSettings/FontPicker'
36
51
  }
@@ -39,9 +54,15 @@
39
54
  {
40
55
  name: 'googleFontsApiKey',
41
56
  type: 'text',
42
- label: 'Google Fonts API Key',
57
+ label: {
58
+ en: 'Google Fonts API Key',
59
+ cs: 'Google Fonts API klíč'
60
+ },
43
61
  admin: {
44
- description: "Optional: Add your Google Fonts API key to access the full library of 1400+ fonts. Without this, you'll have access to 35 popular fonts.",
62
+ description: {
63
+ en: "Optional: Add your Google Fonts API key to access the full library of 1400+ fonts. Without this, you'll have access to 35 popular fonts.",
64
+ cs: 'Volitelné: přidejte svůj Google Fonts API klíč pro přístup k plné knihovně 1400+ písem. Bez něj máte k dispozici 35 populárních písem.'
65
+ },
45
66
  placeholder: 'AIzaSy...'
46
67
  }
47
68
  },
@@ -150,7 +171,10 @@
150
171
  ]
151
172
  },
152
173
  {
153
- label: 'Font Loading',
174
+ label: {
175
+ en: 'Font Loading',
176
+ cs: 'Načítání písem'
177
+ },
154
178
  fields: [
155
179
  {
156
180
  type: 'ui',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/globals/ThemeSettings/config.ts"],"sourcesContent":["import type { GlobalConfig } from 'payload'\n\n/**\n * ThemeSettings Global Configuration\n *\n * This global stores theme-related settings including:\n * - Active font family (selected via FontPicker)\n * - Google Fonts API key (optional, for extended font library)\n */\nexport const ThemeSettings: GlobalConfig = {\n slug: 'themeSettings',\n label: 'Theme Settings',\n admin: {\n group: 'Settings',\n },\n access: {\n read: () => true,\n update: ({ req }) => {\n // Only admins can update theme settings\n return req.user?.roles?.includes('admin') || false\n },\n },\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n label: 'Typography',\n fields: [\n {\n name: 'activeFont',\n type: 'text',\n label: 'Active Font Family',\n defaultValue: 'Inter',\n admin: {\n description: 'The currently active font family for your website',\n components: {\n Field: '@kilivi/payloadcms-theme-management/globals/ThemeSettings/FontPicker',\n },\n },\n },\n {\n name: 'googleFontsApiKey',\n type: 'text',\n label: 'Google Fonts API Key',\n admin: {\n description:\n \"Optional: Add your Google Fonts API key to access the full library of 1400+ fonts. Without this, you'll have access to 35 popular fonts.\",\n placeholder: 'AIzaSy...',\n },\n },\n {\n type: 'row',\n fields: [\n {\n name: 'fontWeightHeading',\n type: 'select',\n label: 'Heading Font Weight',\n defaultValue: '700',\n options: [\n { label: '100 - Thin', value: '100' },\n { label: '200 - Extra Light', value: '200' },\n { label: '300 - Light', value: '300' },\n { label: '400 - Regular', value: '400' },\n { label: '500 - Medium', value: '500' },\n { label: '600 - Semi Bold', value: '600' },\n { label: '700 - Bold', value: '700' },\n { label: '800 - Extra Bold', value: '800' },\n { label: '900 - Black', value: '900' },\n ],\n },\n {\n name: 'fontWeightBody',\n type: 'select',\n label: 'Body Font Weight',\n defaultValue: '400',\n options: [\n { label: '100 - Thin', value: '100' },\n { label: '200 - Extra Light', value: '200' },\n { label: '300 - Light', value: '300' },\n { label: '400 - Regular', value: '400' },\n { label: '500 - Medium', value: '500' },\n { label: '600 - Semi Bold', value: '600' },\n { label: '700 - Bold', value: '700' },\n { label: '800 - Extra Bold', value: '800' },\n { label: '900 - Black', value: '900' },\n ],\n },\n ],\n },\n {\n type: 'ui',\n name: 'typographyInfo',\n admin: {\n components: {\n Field:\n '@kilivi/payloadcms-theme-management/globals/ThemeSettings/fields/TypographyInfoField',\n },\n },\n },\n ],\n },\n {\n label: 'Font Loading',\n fields: [\n {\n type: 'ui',\n name: 'fontLoadingGuide',\n admin: {\n components: {\n Field:\n '@kilivi/payloadcms-theme-management/globals/ThemeSettings/fields/FontLoadingGuideField',\n },\n },\n },\n ],\n },\n ],\n },\n ],\n}\n"],"names":["ThemeSettings","slug","label","admin","group","access","read","update","req","user","roles","includes","fields","type","tabs","name","defaultValue","description","components","Field","placeholder","options","value"],"mappings":"AAEA;;;;;;CAMC,GACD,OAAO,MAAMA,gBAA8B;IACzCC,MAAM;IACNC,OAAO;IACPC,OAAO;QACLC,OAAO;IACT;IACAC,QAAQ;QACNC,MAAM,IAAM;QACZC,QAAQ,CAAC,EAAEC,GAAG,EAAE;YACd,wCAAwC;YACxC,OAAOA,IAAIC,IAAI,EAAEC,OAAOC,SAAS,YAAY;QAC/C;IACF;IACAC,QAAQ;QACN;YACEC,MAAM;YACNC,MAAM;gBACJ;oBACEZ,OAAO;oBACPU,QAAQ;wBACN;4BACEG,MAAM;4BACNF,MAAM;4BACNX,OAAO;4BACPc,cAAc;4BACdb,OAAO;gCACLc,aAAa;gCACbC,YAAY;oCACVC,OAAO;gCACT;4BACF;wBACF;wBACA;4BACEJ,MAAM;4BACNF,MAAM;4BACNX,OAAO;4BACPC,OAAO;gCACLc,aACE;gCACFG,aAAa;4BACf;wBACF;wBACA;4BACEP,MAAM;4BACND,QAAQ;gCACN;oCACEG,MAAM;oCACNF,MAAM;oCACNX,OAAO;oCACPc,cAAc;oCACdK,SAAS;wCACP;4CAAEnB,OAAO;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config.ts"],"sourcesContent":["import type { GlobalConfig } from 'payload'\n\n/**\n * ThemeSettings Global Configuration\n *\n * This global stores theme-related settings including:\n * - Active font family (selected via FontPicker)\n * - Google Fonts API key (optional, for extended font library)\n */\nexport const ThemeSettings: GlobalConfig = {\n slug: 'themeSettings',\n label: { en: 'Theme Settings', cs: 'Nastavení témat' },\n admin: {\n group: { en: 'Settings', cs: 'Nastavení' },\n },\n access: {\n read: () => true,\n update: ({ req }) => {\n // Only admins can update theme settings\n return req.user?.roles?.includes('admin') || false\n },\n },\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n label: { en: 'Typography', cs: 'Typografie' },\n fields: [\n {\n name: 'activeFont',\n type: 'text',\n label: { en: 'Active Font Family', cs: 'Aktivní rodina písem' },\n defaultValue: 'Inter',\n admin: {\n description: {\n en: 'The currently active font family for your website',\n cs: 'Aktuální rodina písem pro váš web',\n },\n components: {\n Field: '@kilivi/payloadcms-theme-management/globals/ThemeSettings/FontPicker',\n },\n },\n },\n {\n name: 'googleFontsApiKey',\n type: 'text',\n label: { en: 'Google Fonts API Key', cs: 'Google Fonts API klíč' },\n admin: {\n description: {\n en: \"Optional: Add your Google Fonts API key to access the full library of 1400+ fonts. Without this, you'll have access to 35 popular fonts.\",\n cs: 'Volitelné: přidejte svůj Google Fonts API klíč pro přístup k plné knihovně 1400+ písem. Bez něj máte k dispozici 35 populárních písem.',\n },\n placeholder: 'AIzaSy...',\n },\n },\n\n {\n type: 'row',\n fields: [\n {\n name: 'fontWeightHeading',\n type: 'select',\n label: 'Heading Font Weight',\n defaultValue: '700',\n options: [\n { label: '100 - Thin', value: '100' },\n { label: '200 - Extra Light', value: '200' },\n { label: '300 - Light', value: '300' },\n { label: '400 - Regular', value: '400' },\n { label: '500 - Medium', value: '500' },\n { label: '600 - Semi Bold', value: '600' },\n { label: '700 - Bold', value: '700' },\n { label: '800 - Extra Bold', value: '800' },\n { label: '900 - Black', value: '900' },\n ],\n },\n {\n name: 'fontWeightBody',\n type: 'select',\n label: 'Body Font Weight',\n defaultValue: '400',\n options: [\n { label: '100 - Thin', value: '100' },\n { label: '200 - Extra Light', value: '200' },\n { label: '300 - Light', value: '300' },\n { label: '400 - Regular', value: '400' },\n { label: '500 - Medium', value: '500' },\n { label: '600 - Semi Bold', value: '600' },\n { label: '700 - Bold', value: '700' },\n { label: '800 - Extra Bold', value: '800' },\n { label: '900 - Black', value: '900' },\n ],\n },\n ],\n },\n {\n type: 'ui',\n name: 'typographyInfo',\n admin: {\n components: {\n Field:\n '@kilivi/payloadcms-theme-management/globals/ThemeSettings/fields/TypographyInfoField',\n },\n },\n },\n ],\n },\n {\n label: { en: 'Font Loading', cs: 'Načítání písem' },\n fields: [\n {\n type: 'ui',\n name: 'fontLoadingGuide',\n admin: {\n components: {\n Field:\n '@kilivi/payloadcms-theme-management/globals/ThemeSettings/fields/FontLoadingGuideField',\n },\n },\n },\n ],\n },\n ],\n },\n ],\n}\n"],"names":["ThemeSettings","slug","label","en","cs","admin","group","access","read","update","req","user","roles","includes","fields","type","tabs","name","defaultValue","description","components","Field","placeholder","options","value"],"mappings":"AAEA;;;;;;CAMC,GACD,OAAO,MAAMA,gBAA8B;IACzCC,MAAM;IACNC,OAAO;QAAEC,IAAI;QAAkBC,IAAI;IAAkB;IACrDC,OAAO;QACLC,OAAO;YAAEH,IAAI;YAAYC,IAAI;QAAY;IAC3C;IACAG,QAAQ;QACNC,MAAM,IAAM;QACZC,QAAQ,CAAC,EAAEC,GAAG,EAAE;YACd,wCAAwC;YACxC,OAAOA,IAAIC,IAAI,EAAEC,OAAOC,SAAS,YAAY;QAC/C;IACF;IACAC,QAAQ;QACN;YACEC,MAAM;YACNC,MAAM;gBACJ;oBACEd,OAAO;wBAAEC,IAAI;wBAAcC,IAAI;oBAAa;oBAC5CU,QAAQ;wBACN;4BACEG,MAAM;4BACNF,MAAM;4BACNb,OAAO;gCAAEC,IAAI;gCAAsBC,IAAI;4BAAuB;4BAC9Dc,cAAc;4BACdb,OAAO;gC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O;wCAAM;wCAC1C;4CAAEtB,OAAO;4CAAesB,OAAO;wCAAM;qCACtC;gCACH;6BACD;wBACH;wBACA;4BACET,MAAM;4BACNE,MAAM;4BACNZ,OAAO;gCACLe,YAAY;oCACVC,OACE;gCACJ;4BACF;wBACF;qBACD;gBACH;gBACA;oBACEnB,OAAO;wBAAEC,IAAI;wBAAgBC,IAAI;oBAAiB;oBAClDU,QAAQ;wBACN;4BACEC,MAAM;4BACNE,MAAM;4BACNZ,OAAO;gCACLe,YAAY;oCACVC,OACE;gCACJ;4BACF;wBACF;qBACD;gBACH;aACD;QACH;KACD;AACH,EAAC"}
package/dist/index.d.ts CHANGED
@@ -27,5 +27,6 @@ export { getFontLoaderCode, getThemeFontFamilies, ThemeFontProvider, useThemeFon
27
27
  export declare const ThemeManagementPlugin: (options?: ThemeManagementPluginOptions) => Plugin;
28
28
  /** @deprecated use {@link themeManagementPlugin} */
29
29
  export declare const themeConfigurationPlugin: (options?: ThemeManagementPluginOptions) => Plugin;
30
+ export { translations, getTranslations, registerTranslations, availableLanguages, } from './translations.js';
30
31
  export default themeManagementPlugin;
31
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,MAAM,EAAa,MAAM,SAAS,CAAA;AAGjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAA;AA6F9F,eAAO,MAAM,qBAAqB,GAAI,UAAS,4BAAiC,KAAG,MA6JlF,CAAA;AAED,KAAK,iBAAiB,GAAG,MAAM,GAAG,8BAA8B,CAAA;AAEhE,eAAO,MAAM,uBAAuB,GAClC,UAAU,iBAAiB,KAC1B,OAAO,CAAC,sBAA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ationField.js';
2
2
  import { allThemePresets } from './presets.js';
3
+ import { getTranslations, translations } from './translations.js';
3
4
  const THEME_FIELD_NAME = 'themeConfiguration';
4
5
  /**
5
6
  * Removes existing theme configuration from a group field (legacy)
@@ -20,9 +21,20 @@ const THEME_FIELD_NAME = 'themeConfiguration';
20
21
  /**
21
22
  * Removes existing Appearance Settings tab if it exists
22
23
  */ const removeExistingThemeTab = (tabs)=>{
24
+ const knownLabels = Object.values(translations).map((t)=>t.tabLabel);
23
25
  return tabs.filter((tab)=>{
24
- const labelEn = typeof tab.label === 'object' && tab.label !== null ? tab.label.en : tab.label;
25
- return labelEn !== '🎨 Appearance Settings' && labelEn !== 'Appearance Settings';
26
+ // Normalize label to string (support localized object or plain string)
27
+ let labelValues = [];
28
+ if (typeof tab.label === 'object' && tab.label !== null) {
29
+ labelValues = Object.values(tab.label);
30
+ } else if (typeof tab.label === 'string') {
31
+ labelValues = [
32
+ tab.label
33
+ ];
34
+ }
35
+ // If any of the label values match a known plugin tab label, remove it
36
+ const matchesKnown = labelValues.some((v)=>knownLabels.includes(v));
37
+ return !matchesKnown;
26
38
  });
27
39
  };
28
40
  /**
@@ -69,7 +81,8 @@ const THEME_FIELD_NAME = 'themeConfiguration';
69
81
  const ensureCollectionsArray = (collections)=>Array.isArray(collections) ? collections : [];
70
82
  export const themeManagementPlugin = (options = {})=>{
71
83
  return (config)=>{
72
- const { enabled = true, targetCollection = 'site-settings', useStandaloneCollection = false, standaloneCollectionSlug = 'appearance-settings', standaloneCollectionLabel = 'Appearance Settings', themePresets = allThemePresets, defaultTheme = 'cool', includeColorModeToggle = true, includeCustomCSS = true, includeBrandIdentity = false, enableAdvancedFeatures = true, enableLogging = false } = options;
84
+ const { enabled = true, targetCollection = 'site-settings', useStandaloneCollection = false, standaloneCollectionSlug = 'appearance-settings', // Allow either string or localized object; default comes from plugin translations
85
+ standaloneCollectionLabel = getTranslations().standaloneCollectionLabel, themePresets = allThemePresets, defaultTheme = 'cool', includeColorModeToggle = true, includeCustomCSS = true, includeBrandIdentity = false, enableAdvancedFeatures = true, enableLogging = false } = options;
73
86
  if (!enabled) {
74
87
  if (enableLogging) {
75
88
  console.log('🎨 Theme Management Plugin: disabled via options, skipping.');
@@ -91,9 +104,7 @@ export const themeManagementPlugin = (options = {})=>{
91
104
  }
92
105
  // Extract the fields from the tab directly (no wrapping in group)
93
106
  const tabFields = themeTab.fields ?? [];
94
- /**
95
- * Hook to auto-populate lightMode and darkMode colors when theme changes
96
- */ const beforeChangeHook = async (args)=>{
107
+ const beforeChangeHook = async (args)=>{
97
108
  const { data } = args;
98
109
  // If theme is being changed, auto-populate color modes
99
110
  if (data?.themeConfiguration?.theme) {
@@ -130,12 +141,16 @@ export const themeManagementPlugin = (options = {})=>{
130
141
  admin: {
131
142
  group: 'Settings'
132
143
  },
133
- access: {
134
- read: ()=>true,
135
- create: ({ req })=>!!req?.user,
136
- update: ({ req })=>!!req?.user,
137
- delete: ({ req })=>!!req?.user
138
- },
144
+ // Provide a broad access object but cast to GlobalConfig['access'] to satisfy types
145
+ access: (()=>{
146
+ const accessObj = {
147
+ read: ()=>true,
148
+ create: ({ req })=>!!req?.user,
149
+ update: ({ req })=>!!req?.user,
150
+ delete: ({ req })=>!!req?.user
151
+ };
152
+ return accessObj;
153
+ })(),
139
154
  fields: tabFields,
140
155
  hooks: {
141
156
  beforeChange: [
@@ -265,6 +280,8 @@ export { getFontLoaderCode, getThemeFontFamilies, ThemeFontProvider, useThemeFon
265
280
  // If needed, import directly from subpath: `@kilivi/payloadcms-theme-management/fields/ThemeLivePreview`
266
281
  export const ThemeManagementPlugin = themeManagementPlugin;
267
282
  /** @deprecated use {@link themeManagementPlugin} */ export const themeConfigurationPlugin = themeManagementPlugin;
283
+ // Export plugin translations for consumers to merge into their payload translations
284
+ export { translations, getTranslations, registerTranslations, availableLanguages } from './translations.js';
268
285
  export default themeManagementPlugin;
269
286
 
270
287
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config, Field, Plugin, TabsField } from 'payload'\nimport { createThemeConfigurationField } from './fields/themeConfigurationField.js'\nimport type { ThemeTab } from './fields/themeConfigurationField.js'\nimport type { SiteThemeConfiguration } from './payload-types.js'\nimport type { ThemePreset } from './presets.js'\nimport { allThemePresets } from './presets.js'\nimport type { FetchThemeConfigurationOptions, ThemeManagementPluginOptions } from './types.js'\n\nconst THEME_FIELD_NAME = 'themeConfiguration'\n\n/**\n * Removes existing theme configuration from a group field (legacy)\n */\nconst removeExistingThemeField = (fields: Field[] = []): Field[] =>\n fields.filter((field) => {\n const candidate = field as { name?: unknown }\n return candidate?.name !== THEME_FIELD_NAME\n })\n\n/**\n * Finds the tabs field in the collection fields array\n */\nconst findTabsField = (fields: Field[] = []): TabsField | null => {\n for (const field of fields) {\n if (field.type === 'tabs') {\n return field as TabsField\n }\n }\n return null\n}\n\n/**\n * Removes existing Appearance Settings tab if it exists\n */\nconst removeExistingThemeTab = (\n tabs: NonNullable<TabsField['tabs']>,\n): NonNullable<TabsField['tabs']> => {\n return tabs.filter((tab) => {\n const labelEn =\n typeof tab.label === 'object' && tab.label !== null\n ? (tab.label as { en?: string }).en\n : tab.label\n return labelEn !== '🎨 Appearance Settings' && labelEn !== 'Appearance Settings'\n })\n}\n\n/**\n * Injects theme tab into existing tabs field\n */\nconst injectThemeTab = (\n fields: Field[] | undefined,\n themeTab: ThemeTab,\n enableLogging: boolean,\n): Field[] => {\n // First, remove any legacy theme field (group-based)\n const sanitizedFields = removeExistingThemeField(fields ?? [])\n\n // Find the tabs field\n const tabsField = findTabsField(sanitizedFields)\n\n if (!tabsField || !tabsField.tabs) {\n if (enableLogging) {\n console.warn(\n '🎨 Theme Management Plugin: No tabs field found. Creating a new tabs structure.',\n )\n }\n\n // If no tabs exist, create a basic tabs structure with just the theme tab\n const newTabsField: TabsField = {\n type: 'tabs',\n tabs: [themeTab],\n }\n\n return [...sanitizedFields, newTabsField]\n }\n\n // Remove existing theme tab if present\n const sanitizedTabs = removeExistingThemeTab(tabsField.tabs)\n\n // Add theme tab to the end\n const updatedTabs = [...sanitizedTabs, themeTab]\n\n if (enableLogging) {\n console.log('🎨 Theme Management Plugin: injecting Appearance Settings tab')\n }\n\n // Update the tabs field\n const updatedTabsField: TabsField = {\n ...tabsField,\n tabs: updatedTabs,\n }\n\n // Replace the old tabs field with the updated one\n return sanitizedFields.map((field) => (field.type === 'tabs' ? updatedTabsField : field))\n}\n\nconst ensureCollectionsArray = (collections: Config['collections']): CollectionConfig[] =>\n Array.isArray(collections) ? collections : []\n\nexport const themeManagementPlugin = (options: ThemeManagementPluginOptions = {}): Plugin => {\n return (config: Config): Config => {\n const {\n enabled = true,\n targetCollection = 'site-settings',\n useStandaloneCollection = false,\n standaloneCollectionSlug = 'appearance-settings',\n standaloneCollectionLabel = 'Appearance Settings',\n themePresets = allThemePresets,\n defaultTheme = 'cool',\n includeColorModeToggle = true,\n includeCustomCSS = true,\n includeBrandIdentity = false,\n enableAdvancedFeatures = true,\n enableLogging = false,\n } = options\n\n if (!enabled) {\n if (enableLogging) {\n console.log('🎨 Theme Management Plugin: disabled via options, skipping.')\n }\n return config\n }\n\n const themeTab = createThemeConfigurationField({\n themePresets,\n defaultTheme,\n includeColorModeToggle,\n includeCustomCSS,\n includeBrandIdentity: includeBrandIdentity ?? false,\n enableAdvancedFeatures,\n })\n\n // If using standalone collection, create a new global\n if (useStandaloneCollection) {\n if (enableLogging) {\n console.log(\n `🎨 Theme Management Plugin: creating standalone global \"${standaloneCollectionSlug}\"`,\n )\n }\n\n // Extract the fields from the tab directly (no wrapping in group)\n const tabFields = (themeTab.fields ?? []) as Field[]\n\n /**\n * Hook to auto-populate lightMode and darkMode colors when theme changes\n */\n const beforeChangeHook = async (args: any) => {\n const { data } = args\n\n // If theme is being changed, auto-populate color modes\n if (data?.themeConfiguration?.theme) {\n const themeName = data.themeConfiguration.theme\n const selectedPreset = themePresets.find((p) => p.name === themeName)\n\n if (selectedPreset) {\n // Initialize light and dark mode colors from preset if not already set\n if (!data.themeConfiguration.lightMode) {\n data.themeConfiguration.lightMode = {}\n }\n if (!data.themeConfiguration.darkMode) {\n data.themeConfiguration.darkMode = {}\n }\n\n // Only populate if not manually edited (first time or empty)\n const isLightModeEmpty = !data.themeConfiguration.lightMode?.background\n const isDarkModeEmpty = !data.themeConfiguration.darkMode?.background\n\n if (isLightModeEmpty && selectedPreset.lightMode) {\n data.themeConfiguration.lightMode = { ...selectedPreset.lightMode }\n }\n\n if (isDarkModeEmpty && selectedPreset.darkMode) {\n data.themeConfiguration.darkMode = { ...selectedPreset.darkMode }\n }\n }\n }\n\n return data\n }\n\n const standaloneGlobal: any = {\n slug: standaloneCollectionSlug,\n label: standaloneCollectionLabel,\n admin: {\n group: 'Settings',\n },\n access: {\n read: () => true,\n create: ({ req }: { req?: any }) => !!req?.user,\n update: ({ req }: { req?: any }) => !!req?.user,\n delete: ({ req }: { req?: any }) => !!req?.user,\n },\n fields: tabFields,\n hooks: {\n beforeChange: [beforeChangeHook],\n },\n }\n\n const globals = Array.isArray(config.globals) ? config.globals : []\n\n // Check if global already exists\n const existingIndex = globals.findIndex((g) => g.slug === standaloneCollectionSlug)\n\n if (existingIndex !== -1) {\n if (enableLogging) {\n console.warn(\n `🎨 Theme Management Plugin: global \"${standaloneCollectionSlug}\" already exists, skipping creation.`,\n )\n }\n return config\n }\n\n return {\n ...config,\n globals: [...globals, standaloneGlobal],\n }\n }\n\n // Otherwise, add as tab to existing collection\n let collectionTouched = false\n\n const collections = ensureCollectionsArray(config.collections).map((collection) => {\n if (collection.slug !== targetCollection) {\n return collection\n }\n\n collectionTouched = true\n\n if (enableLogging) {\n console.log(`🎨 Theme Management Plugin: enhancing collection \"${collection.slug}\"`)\n }\n\n const existingFields = Array.isArray(collection.fields) ? collection.fields : []\n\n const fields = injectThemeTab(existingFields, themeTab, enableLogging)\n\n return {\n ...collection,\n fields,\n }\n })\n\n if (!collectionTouched) {\n if (enableLogging) {\n console.warn(\n `🎨 Theme Management Plugin: collection \"${targetCollection}\" was not found, leaving config untouched.`,\n )\n }\n return config\n }\n\n return {\n ...config,\n collections,\n }\n }\n}\n\ntype FetchOptionsInput = string | FetchThemeConfigurationOptions\n\nexport const fetchThemeConfiguration = async (\n options?: FetchOptionsInput,\n): Promise<SiteThemeConfiguration | null> => {\n const normalizedOptions = typeof options === 'string' ? { tenantSlug: options } : (options ?? {})\n\n const {\n tenantSlug,\n collectionSlug = 'site-settings', // Can be overridden to 'appearance-settings' if using standalone\n depth,\n locale,\n draft,\n queryParams = {},\n useGlobal = false, // Set to true if using standalone global instead of collection\n } = normalizedOptions\n\n try {\n if (useGlobal) {\n // Fetch from global endpoint\n const params = new URLSearchParams()\n\n if (typeof depth === 'number') params.set('depth', String(depth))\n if (tenantSlug) params.set('tenant', tenantSlug)\n if (locale) params.set('locale', locale)\n if (draft) params.set('draft', 'true')\n\n Object.entries(queryParams).forEach(([key, value]) => {\n if (value === undefined) return\n params.set(key, String(value))\n })\n\n const queryString = params.toString()\n const url = `/api/globals/${collectionSlug}${queryString ? `?${queryString}` : ''}`\n\n const response = await fetch(url)\n if (!response.ok) {\n throw new Error(`Failed to fetch theme global (status ${response.status})`)\n }\n\n const data = (await response.json()) as {\n themeConfiguration?: SiteThemeConfiguration\n }\n\n return data?.themeConfiguration ?? null\n } else {\n // Fetch from collection endpoint (legacy/default behavior)\n const params = new URLSearchParams({ limit: '1' })\n\n if (typeof depth === 'number') params.set('depth', String(depth))\n if (tenantSlug) params.set('tenant', tenantSlug)\n if (locale) params.set('locale', locale)\n if (draft) params.set('draft', 'true')\n\n Object.entries(queryParams).forEach(([key, value]) => {\n if (value === undefined) return\n params.set(key, String(value))\n })\n\n const url = `/api/${collectionSlug}?${params.toString()}`\n\n const response = await fetch(url)\n if (!response.ok) {\n throw new Error(`Failed to fetch theme configuration (status ${response.status})`)\n }\n\n const data = (await response.json()) as {\n docs?: Array<{ themeConfiguration?: SiteThemeConfiguration }>\n }\n\n const doc = data.docs?.[0]\n\n return doc?.themeConfiguration ?? null\n }\n } catch (error) {\n console.warn('Failed to fetch theme configuration:', error)\n return null\n }\n}\n\nexport const getThemePreset = (themeName: string): ThemePreset | null => {\n return allThemePresets.find((preset) => preset.name === themeName) || null\n}\n\nexport const getAvailableThemePresets = (): ThemePreset[] => {\n return allThemePresets\n}\n\nexport { defaultThemePresets, allThemePresets } from './presets.js'\nexport type { ThemePreset, ThemeTypographyPreset } from './presets.js'\nexport type { ThemeTab } from './fields/themeConfigurationField.js'\nexport {\n extendedThemePresets,\n allExtendedThemePresets,\n extendedThemeToCSSVariables,\n} from './extended-presets.js'\nexport type { ExtendedThemePreset, ShadcnColorTokens } from './extended-presets.js'\nexport {\n applyExtendedTheme,\n generateExtendedThemeCSS,\n resetExtendedTheme,\n getExtendedThemeTokens,\n createUseExtendedTheme,\n getTailwindVarReferences,\n} from './utils/extendedThemeHelpers.js'\nexport type { ThemeManagementPluginOptions, FetchThemeConfigurationOptions } from './types.js'\nexport {\n DEFAULT_THEME_CONFIGURATION,\n resolveThemeConfiguration,\n} from './utils/resolveThemeConfiguration.js'\nexport type { ResolvedThemeConfiguration } from './utils/resolveThemeConfiguration.js'\nexport { generateThemeColorsCss, hexToHsl } from './utils/themeColors.js'\nexport { generateThemeCSS, getThemeStyles } from './utils/themeUtils.js'\nexport { getThemeHtmlAttributes } from './utils/themeHtmlAttributes.js'\n\n// Dynamic theme CSS generation\nexport {\n generateThemeCSS as generatePresetCSS,\n generateAllThemesCSS,\n} from './utils/generateThemeCSS.js'\nexport { getThemeDynamicCSS, getAllDynamicThemesCSS } from './utils/themeCSS.js'\n\nexport type { Mode, ThemeDefaults } from './providers/Theme/types.js'\nexport { ThemeProvider } from './providers/Theme/index.js'\n\n// Font loading utilities for Next.js integration\nexport {\n getFontLoaderCode,\n getThemeFontFamilies,\n ThemeFontProvider,\n useThemeFonts,\n FONT_IMPORT_MAP,\n} from './providers/font-loader.js'\n\n// Note: Do NOT re-export client components from the root entry to avoid\n// server-side evaluation during `payload generate:importmap`.\n// If needed, import directly from subpath: `@kilivi/payloadcms-theme-management/fields/ThemeLivePreview`\n\nexport const ThemeManagementPlugin = themeManagementPlugin\n/** @deprecated use {@link themeManagementPlugin} */\nexport const themeConfigurationPlugin = themeManagementPlugin\n\nexport default themeManagementPlugin\n"],"names":["createThemeConfigurationField","allThemePresets","THEME_FIELD_NAME","removeExistingThemeField","fields","filter","field","candidate","name","findTabsField","type","removeExistingThemeTab","tabs","tab","labelEn","label","en","injectThemeTab","themeTab","enableLogging","sanitizedFields","tabsField","console","warn","newTabsField","sanitizedTabs","updatedTabs","log","updatedTabsField","map","ensureCollectionsArray","collections","Array","isArray","themeManagementPlugin","options","config","enabled","targetCollection","useStandaloneCollection","standaloneCollectionSlug","standaloneCollectionLabel","themePresets","defaultTheme","includeColorModeToggle","includeCustomCSS","includeBrandIdentity","enableAdvancedFeatures","tabFields","beforeChangeHook","args","data","themeConfiguration","theme","themeName","selectedPreset","find","p","lightMode","darkMode","isLightModeEmpty","background","isDarkModeEmpty","standaloneGlobal","slug","admin","group","access","read","create","req","user","update","delete","hooks","beforeChange","globals","existingIndex","findIndex","g","collectionTouched","collection","existingFields","fetchThemeConfiguration","normalizedOptions","tenantSlug","collectionSlug","depth","locale","draft","queryParams","useGlobal","params","URLSearchParams","set","String","Object","entries","forEach","key","value","undefined","queryString","toString","url","response","fetch","ok","Error","status","json","limit","doc","docs","error","getThemePreset","preset","getAvailableThemePresets","defaultThemePresets","extendedThemePresets","allExtendedThemePresets","extendedThemeToCSSVariables","applyExtendedTheme","generateExtendedThemeCSS","resetExtendedTheme","getExtendedThemeTokens","createUseExtendedTheme","getTailwindVarReferences","DEFAULT_THEME_CONFIGURATION","resolveThemeConfiguration","generateThemeColorsCss","hexToHsl","generateThemeCSS","getThemeStyles","getThemeHtmlAttributes","generatePresetCSS","generateAllThemesCSS","getThemeDynamicCSS","getAllDynamicThemesCSS","ThemeProvider","getFontLoaderCode","getThemeFontFamilies","ThemeFontProvider","useThemeFonts","FONT_IMPORT_MAP","ThemeManagementPlugin","themeConfigurationPlugin"],"mappings":"AACA,SAASA,6BAA6B,QAAQ,sCAAqC;AAInF,SAASC,eAAe,QAAQ,eAAc;AAG9C,MAAMC,mBAAmB;AAEzB;;CAEC,GACD,MAAMC,2BAA2B,CAACC,SAAkB,EAAE,GACpDA,OAAOC,MAAM,CAAC,CAACC;QACb,MAAMC,YAAYD;QAClB,OAAOC,WAAWC,SAASN;IAC7B;AAEF;;CAEC,GACD,MAAMO,gBAAgB,CAACL,SAAkB,EAAE;IACzC,KAAK,MAAME,SAASF,OAAQ;QAC1B,IAAIE,MAAMI,IAAI,KAAK,QAAQ;YACzB,OAAOJ;QACT;IACF;IACA,OAAO;AACT;AAEA;;CAEC,GACD,MAAMK,yBAAyB,CAC7BC;IAEA,OAAOA,KAAKP,MAAM,CAAC,CAACQ;QAClB,MAAMC,UACJ,OAAOD,IAAIE,KAAK,KAAK,YAAYF,IAAIE,KAAK,KAAK,OAC3C,AAACF,IAAIE,KAAK,CAAqBC,EAAE,GACjCH,IAAIE,KAAK;QACf,OAAOD,YAAY,4BAA4BA,YAAY;IAC7D;AACF;AAEA;;CAEC,GACD,MAAMG,iBAAiB,CACrBb,QACAc,UACAC;IAEA,qDAAqD;IACrD,MAAMC,kBAAkBjB,yBAAyBC,UAAU,EAAE;IAE7D,sBAAsB;IACtB,MAAMiB,YAAYZ,cAAcW;IAEhC,IAAI,CAACC,aAAa,CAACA,UAAUT,IAAI,EAAE;QACjC,IAAIO,eAAe;YACjBG,QAAQC,IAAI,CACV;QAEJ;QAEA,0EAA0E;QAC1E,MAAMC,eAA0B;YAC9Bd,MAAM;YACNE,MAAM;gBAACM;aAAS;QAClB;QAEA,OAAO;eAAIE;YAAiBI;SAAa;IAC3C;IAEA,uCAAuC;IACvC,MAAMC,gBAAgBd,uBAAuBU,UAAUT,IAAI;IAE3D,2BAA2B;IAC3B,MAAM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BG,iBAAiB,EACrCC,oBAAoB,QACf,8BAA6B;AACpC,SAASC,kBAAkB,EAAEC,sBAAsB,QAAQ,sBAAqB;AAGhF,SAASC,aAAa,QAAQ,6BAA4B;AAE1D,iDAAiD;AACjD,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,iBAAiB,EACjBC,aAAa,EACbC,eAAe,QACV,6BAA4B;AAEnC,wEAAwE;AACxE,8DAA8D;AAC9D,yGAAyG;AAEzG,OAAO,MAAMC,wBAAwB/G,sBAAqB;AAC1D,kDAAkD,GAClD,OAAO,MAAMgH,2BAA2BhH,sBAAqB;AAE7D,eAAeA,sBAAqB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config, Field, GlobalConfig, Plugin, TabsField } from 'payload'\nimport { createThemeConfigurationField } from './fields/themeConfigurationField.js'\nimport type { ThemeTab } from './fields/themeConfigurationField.js'\nimport type { SiteThemeConfiguration } from './payload-types.js'\nimport type { ThemePreset } from './presets.js'\nimport { allThemePresets } from './presets.js'\nimport { getTranslations, translations } from './translations.js'\nimport type { FetchThemeConfigurationOptions, ThemeManagementPluginOptions } from './types.js'\n\nconst THEME_FIELD_NAME = 'themeConfiguration'\n\n/**\n * Removes existing theme configuration from a group field (legacy)\n */\nconst removeExistingThemeField = (fields: Field[] = []): Field[] =>\n fields.filter((field) => {\n const candidate = field as { name?: unknown }\n return candidate?.name !== THEME_FIELD_NAME\n })\n\n/**\n * Finds the tabs field in the collection fields array\n */\nconst findTabsField = (fields: Field[] = []): TabsField | null => {\n for (const field of fields) {\n if (field.type === 'tabs') {\n return field as TabsField\n }\n }\n return null\n}\n\n/**\n * Removes existing Appearance Settings tab if it exists\n */\nconst removeExistingThemeTab = (\n tabs: NonNullable<TabsField['tabs']>,\n): NonNullable<TabsField['tabs']> => {\n const knownLabels = Object.values(translations).map((t) => t.tabLabel)\n return tabs.filter((tab) => {\n // Normalize label to string (support localized object or plain string)\n let labelValues: string[] = []\n if (typeof tab.label === 'object' && tab.label !== null) {\n labelValues = Object.values(tab.label as Record<string, string>)\n } else if (typeof tab.label === 'string') {\n labelValues = [tab.label]\n }\n\n // If any of the label values match a known plugin tab label, remove it\n const matchesKnown = labelValues.some((v) => knownLabels.includes(v))\n\n return !matchesKnown\n })\n}\n\n/**\n * Injects theme tab into existing tabs field\n */\nconst injectThemeTab = (\n fields: Field[] | undefined,\n themeTab: ThemeTab,\n enableLogging: boolean,\n): Field[] => {\n // First, remove any legacy theme field (group-based)\n const sanitizedFields = removeExistingThemeField(fields ?? [])\n\n // Find the tabs field\n const tabsField = findTabsField(sanitizedFields)\n\n if (!tabsField || !tabsField.tabs) {\n if (enableLogging) {\n console.warn(\n '🎨 Theme Management Plugin: No tabs field found. Creating a new tabs structure.',\n )\n }\n\n // If no tabs exist, create a basic tabs structure with just the theme tab\n const newTabsField: TabsField = {\n type: 'tabs',\n tabs: [themeTab],\n }\n\n return [...sanitizedFields, newTabsField]\n }\n\n // Remove existing theme tab if present\n const sanitizedTabs = removeExistingThemeTab(tabsField.tabs)\n\n // Add theme tab to the end\n const updatedTabs = [...sanitizedTabs, themeTab]\n\n if (enableLogging) {\n console.log('🎨 Theme Management Plugin: injecting Appearance Settings tab')\n }\n\n // Update the tabs field\n const updatedTabsField: TabsField = {\n ...tabsField,\n tabs: updatedTabs,\n }\n\n // Replace the old tabs field with the updated one\n return sanitizedFields.map((field) => (field.type === 'tabs' ? updatedTabsField : field))\n}\n\nconst ensureCollectionsArray = (collections: Config['collections']): CollectionConfig[] =>\n Array.isArray(collections) ? collections : []\n\nexport const themeManagementPlugin = (options: ThemeManagementPluginOptions = {}): Plugin => {\n return (config: Config): Config => {\n const {\n enabled = true,\n targetCollection = 'site-settings',\n useStandaloneCollection = false,\n standaloneCollectionSlug = 'appearance-settings',\n // Allow either string or localized object; default comes from plugin translations\n standaloneCollectionLabel = getTranslations().standaloneCollectionLabel,\n themePresets = allThemePresets,\n defaultTheme = 'cool',\n includeColorModeToggle = true,\n includeCustomCSS = true,\n includeBrandIdentity = false,\n enableAdvancedFeatures = true,\n enableLogging = false,\n } = options\n\n if (!enabled) {\n if (enableLogging) {\n console.log('🎨 Theme Management Plugin: disabled via options, skipping.')\n }\n return config\n }\n\n const themeTab = createThemeConfigurationField({\n themePresets,\n defaultTheme,\n includeColorModeToggle,\n includeCustomCSS,\n includeBrandIdentity: includeBrandIdentity ?? false,\n enableAdvancedFeatures,\n })\n\n // If using standalone collection, create a new global\n if (useStandaloneCollection) {\n if (enableLogging) {\n console.log(\n `🎨 Theme Management Plugin: creating standalone global \"${standaloneCollectionSlug}\"`,\n )\n }\n\n // Extract the fields from the tab directly (no wrapping in group)\n const tabFields = (themeTab.fields ?? []) as Field[]\n\n /**\n * Hook to auto-populate lightMode and darkMode colors when theme changes\n */\n type BeforeChangeArgs = {\n data?: {\n themeConfiguration?: {\n theme?: string\n lightMode?: Record<string, unknown>\n darkMode?: Record<string, unknown>\n }\n }\n }\n\n const beforeChangeHook = async (args: BeforeChangeArgs) => {\n const { data } = args\n\n // If theme is being changed, auto-populate color modes\n if (data?.themeConfiguration?.theme) {\n const themeName = data.themeConfiguration.theme\n const selectedPreset = themePresets.find((p) => p.name === themeName)\n\n if (selectedPreset) {\n // Initialize light and dark mode colors from preset if not already set\n if (!data.themeConfiguration.lightMode) {\n data.themeConfiguration.lightMode = {}\n }\n if (!data.themeConfiguration.darkMode) {\n data.themeConfiguration.darkMode = {}\n }\n\n // Only populate if not manually edited (first time or empty)\n const isLightModeEmpty = !data.themeConfiguration.lightMode?.background\n const isDarkModeEmpty = !data.themeConfiguration.darkMode?.background\n\n if (isLightModeEmpty && selectedPreset.lightMode) {\n data.themeConfiguration.lightMode = { ...selectedPreset.lightMode }\n }\n\n if (isDarkModeEmpty && selectedPreset.darkMode) {\n data.themeConfiguration.darkMode = { ...selectedPreset.darkMode }\n }\n }\n }\n\n return data\n }\n\n const standaloneGlobal: GlobalConfig = {\n slug: standaloneCollectionSlug,\n label: standaloneCollectionLabel,\n admin: {\n group: 'Settings',\n },\n // Provide a broad access object but cast to GlobalConfig['access'] to satisfy types\n access: ((): GlobalConfig['access'] => {\n const accessObj = {\n read: () => true,\n create: ({ req }: { req?: { user?: unknown } }) => !!req?.user,\n update: ({ req }: { req?: { user?: unknown } }) => !!req?.user,\n delete: ({ req }: { req?: { user?: unknown } }) => !!req?.user,\n } as unknown as GlobalConfig['access']\n return accessObj\n })(),\n fields: tabFields,\n hooks: {\n beforeChange: [beforeChangeHook],\n },\n }\n\n const globals = Array.isArray(config.globals) ? config.globals : []\n\n // Check if global already exists\n const existingIndex = globals.findIndex((g) => g.slug === standaloneCollectionSlug)\n\n if (existingIndex !== -1) {\n if (enableLogging) {\n console.warn(\n `🎨 Theme Management Plugin: global \"${standaloneCollectionSlug}\" already exists, skipping creation.`,\n )\n }\n return config\n }\n\n return {\n ...config,\n globals: [...globals, standaloneGlobal],\n }\n }\n\n // Otherwise, add as tab to existing collection\n let collectionTouched = false\n\n const collections = ensureCollectionsArray(config.collections).map((collection) => {\n if (collection.slug !== targetCollection) {\n return collection\n }\n\n collectionTouched = true\n\n if (enableLogging) {\n console.log(`🎨 Theme Management Plugin: enhancing collection \"${collection.slug}\"`)\n }\n\n const existingFields = Array.isArray(collection.fields) ? collection.fields : []\n\n const fields = injectThemeTab(existingFields, themeTab, enableLogging)\n\n return {\n ...collection,\n fields,\n }\n })\n\n if (!collectionTouched) {\n if (enableLogging) {\n console.warn(\n `🎨 Theme Management Plugin: collection \"${targetCollection}\" was not found, leaving config untouched.`,\n )\n }\n return config\n }\n\n return {\n ...config,\n collections,\n }\n }\n}\n\ntype FetchOptionsInput = string | FetchThemeConfigurationOptions\n\nexport const fetchThemeConfiguration = async (\n options?: FetchOptionsInput,\n): Promise<SiteThemeConfiguration | null> => {\n const normalizedOptions = typeof options === 'string' ? { tenantSlug: options } : (options ?? {})\n\n const {\n tenantSlug,\n collectionSlug = 'site-settings', // Can be overridden to 'appearance-settings' if using standalone\n depth,\n locale,\n draft,\n queryParams = {},\n useGlobal = false, // Set to true if using standalone global instead of collection\n } = normalizedOptions\n\n try {\n if (useGlobal) {\n // Fetch from global endpoint\n const params = new URLSearchParams()\n\n if (typeof depth === 'number') params.set('depth', String(depth))\n if (tenantSlug) params.set('tenant', tenantSlug)\n if (locale) params.set('locale', locale)\n if (draft) params.set('draft', 'true')\n\n Object.entries(queryParams).forEach(([key, value]) => {\n if (value === undefined) return\n params.set(key, String(value))\n })\n\n const queryString = params.toString()\n const url = `/api/globals/${collectionSlug}${queryString ? `?${queryString}` : ''}`\n\n const response = await fetch(url)\n if (!response.ok) {\n throw new Error(`Failed to fetch theme global (status ${response.status})`)\n }\n\n const data = (await response.json()) as {\n themeConfiguration?: SiteThemeConfiguration\n }\n\n return data?.themeConfiguration ?? null\n } else {\n // Fetch from collection endpoint (legacy/default behavior)\n const params = new URLSearchParams({ limit: '1' })\n\n if (typeof depth === 'number') params.set('depth', String(depth))\n if (tenantSlug) params.set('tenant', tenantSlug)\n if (locale) params.set('locale', locale)\n if (draft) params.set('draft', 'true')\n\n Object.entries(queryParams).forEach(([key, value]) => {\n if (value === undefined) return\n params.set(key, String(value))\n })\n\n const url = `/api/${collectionSlug}?${params.toString()}`\n\n const response = await fetch(url)\n if (!response.ok) {\n throw new Error(`Failed to fetch theme configuration (status ${response.status})`)\n }\n\n const data = (await response.json()) as {\n docs?: Array<{ themeConfiguration?: SiteThemeConfiguration }>\n }\n\n const doc = data.docs?.[0]\n\n return doc?.themeConfiguration ?? null\n }\n } catch (error) {\n console.warn('Failed to fetch theme configuration:', error)\n return null\n }\n}\n\nexport const getThemePreset = (themeName: string): ThemePreset | null => {\n return allThemePresets.find((preset) => preset.name === themeName) || null\n}\n\nexport const getAvailableThemePresets = (): ThemePreset[] => {\n return allThemePresets\n}\n\nexport { defaultThemePresets, allThemePresets } from './presets.js'\nexport type { ThemePreset, ThemeTypographyPreset } from './presets.js'\nexport type { ThemeTab } from './fields/themeConfigurationField.js'\nexport {\n extendedThemePresets,\n allExtendedThemePresets,\n extendedThemeToCSSVariables,\n} from './extended-presets.js'\nexport type { ExtendedThemePreset, ShadcnColorTokens } from './extended-presets.js'\nexport {\n applyExtendedTheme,\n generateExtendedThemeCSS,\n resetExtendedTheme,\n getExtendedThemeTokens,\n createUseExtendedTheme,\n getTailwindVarReferences,\n} from './utils/extendedThemeHelpers.js'\nexport type { ThemeManagementPluginOptions, FetchThemeConfigurationOptions } from './types.js'\nexport {\n DEFAULT_THEME_CONFIGURATION,\n resolveThemeConfiguration,\n} from './utils/resolveThemeConfiguration.js'\nexport type { ResolvedThemeConfiguration } from './utils/resolveThemeConfiguration.js'\nexport { generateThemeColorsCss, hexToHsl } from './utils/themeColors.js'\nexport { generateThemeCSS, getThemeStyles } from './utils/themeUtils.js'\nexport { getThemeHtmlAttributes } from './utils/themeHtmlAttributes.js'\n\n// Dynamic theme CSS generation\nexport {\n generateThemeCSS as generatePresetCSS,\n generateAllThemesCSS,\n} from './utils/generateThemeCSS.js'\nexport { getThemeDynamicCSS, getAllDynamicThemesCSS } from './utils/themeCSS.js'\n\nexport type { Mode, ThemeDefaults } from './providers/Theme/types.js'\nexport { ThemeProvider } from './providers/Theme/index.js'\n\n// Font loading utilities for Next.js integration\nexport {\n getFontLoaderCode,\n getThemeFontFamilies,\n ThemeFontProvider,\n useThemeFonts,\n FONT_IMPORT_MAP,\n} from './providers/font-loader.js'\n\n// Note: Do NOT re-export client components from the root entry to avoid\n// server-side evaluation during `payload generate:importmap`.\n// If needed, import directly from subpath: `@kilivi/payloadcms-theme-management/fields/ThemeLivePreview`\n\nexport const ThemeManagementPlugin = themeManagementPlugin\n/** @deprecated use {@link themeManagementPlugin} */\nexport const themeConfigurationPlugin = themeManagementPlugin\n\n// Export plugin translations for consumers to merge into their payload translations\nexport {\n translations,\n getTranslations,\n registerTranslations,\n availableLanguages,\n} from './translations.js'\n\nexport default themeManagementPlugin\n"],"names":["createThemeConfigurationField","allThemePresets","getTranslations","translations","THEME_FIELD_NAME","removeExistingThemeField","fields","filter","field","candidate","name","findTabsField","type","removeExistingThemeTab","tabs","knownLabels","Object","values","map","t","tabLabel","tab","labelValues","label","matchesKnown","some","v","includes","injectThemeTab","themeTab","enableLogging","sanitizedFields","tabsField","console","warn","newTabsField","sanitizedTabs","updatedTabs","log","updatedTabsField","ensureCollectionsArray","collections","Array","isArray","themeManagementPlugin","options","config","enabled","targetCollection","useStandaloneCollection","standaloneCollectionSlug","standaloneCollectionLabel","themePresets","defaultTheme","includeColorModeToggle","includeCustomCSS","includeBrandIdentity","enableAdvancedFeatures","tabFields","beforeChangeHook","args","data","themeConfiguration","theme","themeName","selectedPreset","find","p","lightMode","darkMode","isLightModeEmpty","background","isDarkModeEmpty","standaloneGlobal","slug","admin","group","access","accessObj","read","create","req","user","update","delete","hooks","beforeChange","globals","existingIndex","findIndex","g","collectionTouched","collection","existingFields","fetchThemeConfiguration","normalizedOptions","tenantSlug","collectionSlug","depth","locale","draft","queryParams","useGlobal","params","URLSearchParams","set","String","entries","forEach","key","value","undefined","queryString","toString","url","response","fetch","ok","Error","status","json","limit","doc","docs","error","getThemePreset","preset","getAvailableThemePresets","defaultThemePresets","extendedThemePresets","allExtendedThemePresets","extendedThemeToCSSVariables","applyExtendedTheme","generateExtendedThemeCSS","resetExtendedTheme","getExtendedThemeTokens","createUseExtendedTheme","getTailwindVarReferences","DEFAULT_THEME_CONFIGURATION","resolveThemeConfiguration","generateThemeColorsCss","hexToHsl","generateThemeCSS","getThemeStyles","getThemeHtmlAttributes","generatePresetCSS","generateAllThemesCSS","getThemeDynamicCSS","getAllDynamicThemesCSS","ThemeProvider","getFontLoaderCode","getThemeFontFamilies","ThemeFontProvider","useThemeFonts","FONT_IMPORT_MAP","ThemeManagementPlugin","themeConfigurationPlugin","registerTranslations","availableLanguages"],"mappings":"AACA,SAASA,6BAA6B,QAAQ,sCAAqC;AAInF,SAASC,eAAe,QAAQ,eAAc;AAC9C,SAASC,eAAe,EAAEC,YAAY,QAAQ,oBAAmB;A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C,2BAA2B,EAC3BC,yBAAyB,QACpB,uCAAsC;AAE7C,SAASC,sBAAsB,EAAEC,QAAQ,QAAQ,yBAAwB;AACzE,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,wBAAuB;AACxE,SAASC,sBAAsB,QAAQ,iCAAgC;AAEvE,+BAA+B;AAC/B,SACEF,oBAAoBG,iBAAiB,EACrCC,oBAAoB,QACf,8BAA6B;AACpC,SAASC,kBAAkB,EAAEC,sBAAsB,QAAQ,sBAAqB;AAGhF,SAASC,aAAa,QAAQ,6BAA4B;AAE1D,iDAAiD;AACjD,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,iBAAiB,EACjBC,aAAa,EACbC,eAAe,QACV,6BAA4B;AAEnC,wEAAwE;AACxE,8DAA8D;AAC9D,yGAAyG;AAEzG,OAAO,MAAMC,wBAAwB/G,sBAAqB;AAC1D,kDAAkD,GAClD,OAAO,MAAMgH,2BAA2BhH,sBAAqB;AAE7D,oFAAoF;AACpF,SACEzC,YAAY,EACZD,eAAe,EACf2J,oBAAoB,EACpBC,kBAAkB,QACb,oBAAmB;AAE1B,eAAelH,sBAAqB"}
@@ -109,7 +109,7 @@ export declare function getThemeFontFamilies(config: ThemeConfig): {
109
109
  * Use this to inject font CSS variables into your app
110
110
  */
111
111
  export declare function ThemeFontProvider({ children, bodyFont, headingFont, bodyFontCustom, headingFontCustom, }: {
112
- children: React.ReactNode;
112
+ children: React.ReactNode | any;
113
113
  bodyFont?: string;
114
114
  headingFont?: string;
115
115
  bodyFontCustom?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"font-loader.d.ts","sourceRoot":"","sources":["../../src/providers/font-loader.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,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,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAyChF,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CA+B7D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAkBA;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,cAAc,EACd,iBAAiB,GAClB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,GAAG,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,+BAeA;AAED;;;GAGG;AACH,wBAAgB,aAAa;;;EAY5B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/providers/font-loader.tsx"],"sourcesContent":["/**\n * Next.js Font Loader Utilities\n *\n * This file provides utilities for loading Google Fonts in Next.js applications\n * based on theme configuration from the CMS.\n *\n * ## Usage Guide\n *\n * ### 1. Static Font Loading (Recommended)\n *\n * In your Next.js app's root layout:\n *\n * ```tsx\n * // app/layout.tsx\n * import { Inter, Playfair_Display } from 'next/font/google'\n *\n * const inter = Inter({\n * subsets: ['latin'],\n * variable: '--font-body',\n * display: 'swap',\n * })\n *\n * const playfair = Playfair_Display({\n * subsets: ['latin'],\n * variable: '--font-heading',\n * display: 'swap',\n * })\n *\n * export default function RootLayout({ children }: { children: React.ReactNode }) {\n * return (\n * <html lang=\"en\" className={`${inter.variable} ${playfair.variable}`}>\n * <body>{children}</body>\n * </html>\n * )\n * }\n * ```\n *\n * ### 2. CSS Variables Usage\n *\n * In your global CSS:\n *\n * ```css\n * :root {\n * --font-body: var(--font-inter), system-ui, sans-serif;\n * --font-heading: var(--font-playfair), Georgia, serif;\n * }\n *\n * body {\n * font-family: var(--font-body);\n * }\n *\n * h1, h2, h3, h4, h5, h6 {\n * font-family: var(--font-heading);\n * }\n * ```\n *\n * ### 3. Dynamic Font Loading\n *\n * Use the helper functions below to generate font loader code:\n *\n * ```tsx\n * import { getFontLoaderCode } from '@kilivi/payloadcms-theme-management/providers/font-loader'\n *\n * const themeConfig = await getThemeConfig()\n * const fontCode = getFontLoaderCode(themeConfig)\n * console.log(fontCode) // Copy this to your layout.tsx\n * ```\n */\n\ninterface ThemeConfig {\n bodyFont?: string\n headingFont?: string\n bodyFontCustom?: string\n headingFontCustom?: string\n}\n\n/**\n * Font mapping for next/font/google imports\n * Maps theme font values to Next.js font imports\n */\nexport const FONT_IMPORT_MAP: Record<string, { import: string; variable: string }> = {\n Inter: {\n import: `import { Inter } from 'next/font/google'\\nconst inter = Inter({ subsets: ['latin'], variable: '--font-body' })`,\n variable: 'inter.variable',\n },\n Roboto: {\n import: `import { Roboto } from 'next/font/google'\\nconst roboto = Roboto({ weight: ['400', '500', '700'], subsets: ['latin'], variable: '--font-body' })`,\n variable: 'roboto.variable',\n },\n 'Open Sans': {\n import: `import { Open_Sans } from 'next/font/google'\\nconst openSans = Open_Sans({ subsets: ['latin'], variable: '--font-body' })`,\n variable: 'openSans.variable',\n },\n Lato: {\n import: `import { Lato } from 'next/font/google'\\nconst lato = Lato({ weight: ['400', '700'], subsets: ['latin'], variable: '--font-body' })`,\n variable: 'lato.variable',\n },\n Montserrat: {\n import: `import { Montserrat } from 'next/font/google'\\nconst montserrat = Montserrat({ subsets: ['latin'], variable: '--font-body' })`,\n variable: 'montserrat.variable',\n },\n Poppins: {\n import: `import { Poppins } from 'next/font/google'\\nconst poppins = Poppins({ weight: ['400', '500', '600', '700'], subsets: ['latin'], variable: '--font-body' })`,\n variable: 'poppins.variable',\n },\n 'Playfair Display': {\n import: `import { Playfair_Display } from 'next/font/google'\\nconst playfair = Playfair_Display({ subsets: ['latin'], variable: '--font-heading' })`,\n variable: 'playfair.variable',\n },\n Merriweather: {\n import: `import { Merriweather } from 'next/font/google'\\nconst merriweather = Merriweather({ weight: ['400', '700'], subsets: ['latin'], variable: '--font-heading' })`,\n variable: 'merriweather.variable',\n },\n Lora: {\n import: `import { Lora } from 'next/font/google'\\nconst lora = Lora({ subsets: ['latin'], variable: '--font-heading' })`,\n variable: 'lora.variable',\n },\n 'Crimson Text': {\n import: `import { Crimson_Text } from 'next/font/google'\\nconst crimsonText = Crimson_Text({ weight: ['400', '600', '700'], subsets: ['latin'], variable: '--font-heading' })`,\n variable: 'crimsonText.variable',\n },\n}\n\n/**\n * Generate Next.js font loader code for your layout\n *\n * @param config - Theme configuration from CMS\n * @returns String with complete Next.js font loading code\n *\n * @example\n * ```tsx\n * const code = getFontLoaderCode({ bodyFont: 'Inter', headingFont: 'Playfair Display' })\n * console.log(code)\n * // Copy the output to your app/layout.tsx file\n * ```\n */\nexport function getFontLoaderCode(config: ThemeConfig): string {\n const imports: string[] = []\n const variables: string[] = []\n\n if (config.bodyFont && config.bodyFont !== 'preset' && config.bodyFont !== 'custom') {\n const fontConfig = FONT_IMPORT_MAP[config.bodyFont]\n if (fontConfig) {\n imports.push(fontConfig.import)\n variables.push(fontConfig.variable)\n }\n }\n\n if (config.headingFont && config.headingFont !== 'preset' && config.headingFont !== 'custom') {\n const fontConfig = FONT_IMPORT_MAP[config.headingFont]\n if (fontConfig) {\n imports.push(fontConfig.import)\n variables.push(fontConfig.variable)\n }\n }\n\n return `// app/layout.tsx\n${imports.join('\\n\\n')}\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\" className={\\`${variables.join(' ')}\\`}>\n <body>{children}</body>\n </html>\n )\n}\n`\n}\n\n/**\n * Get font family CSS strings for inline styles\n *\n * @param config - Theme configuration\n * @returns Object with bodyFont and headingFont CSS font-family strings\n */\nexport function getThemeFontFamilies(config: ThemeConfig): {\n bodyFont?: string\n headingFont?: string\n} {\n const result: { bodyFont?: string; headingFont?: string } = {}\n\n // Body font\n if (config.bodyFont === 'custom' && config.bodyFontCustom) {\n result.bodyFont = config.bodyFontCustom\n } else if (config.bodyFont && config.bodyFont !== 'preset') {\n result.bodyFont = `var(--font-body), ${config.bodyFont}, sans-serif`\n }\n\n // Heading font\n if (config.headingFont === 'custom' && config.headingFontCustom) {\n result.headingFont = config.headingFontCustom\n } else if (config.headingFont && config.headingFont !== 'preset') {\n result.headingFont = `var(--font-heading), ${config.headingFont}, serif`\n }\n\n return result\n}\n\n/**\n * React component wrapper for font variables\n * Use this to inject font CSS variables into your app\n */\nexport function ThemeFontProvider({\n children,\n bodyFont,\n headingFont,\n bodyFontCustom,\n headingFontCustom,\n}: {\n children: React.ReactNode\n bodyFont?: string\n headingFont?: string\n bodyFontCustom?: string\n headingFontCustom?: string\n}) {\n const fonts = getThemeFontFamilies({ bodyFont, headingFont, bodyFontCustom, headingFontCustom })\n\n return (\n <div\n style={\n {\n '--font-body': fonts.bodyFont,\n '--font-heading': fonts.headingFont,\n } as React.CSSProperties\n }\n >\n {children}\n </div>\n )\n}\n\n/**\n * Client-side hook for accessing theme fonts\n * Use this in client components to read font CSS variables\n */\nexport function useThemeFonts() {\n if (typeof window === 'undefined') {\n return { bodyFont: undefined, headingFont: undefined }\n }\n\n const bodyFont = getComputedStyle(document.documentElement).getPropertyValue('--font-body')\n const headingFont = getComputedStyle(document.documentElement).getPropertyValue('--font-heading')\n\n return {\n bodyFont: bodyFont || undefined,\n headingFont: headingFont || undefined,\n }\n}\n"],"names":["FONT_IMPORT_MAP","Inter","import","variable","Roboto","Lato","Montserrat","Poppins","Merriweather","Lora","getFontLoaderCode","config","imports","variables","bodyFont","fontConfig","push","headingFont","join","getThemeFontFamilies","result","bodyFontCustom","headingFontCustom","ThemeFontProvider","children","fonts","div","style","useThemeFonts","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BAAkBW,MAAMR,WAAW;QACrC;kBAGDO;;AAGP;AAEA;;;CAGC,GACD,OAAO,SAASI;IACd,IAAI,OAAOC,WAAW,aAAa;QACjC,OAAO;YAAEf,UAAUgB;YAAWb,aAAaa;QAAU;IACvD;IAEA,MAAMhB,WAAWiB,iBAAiBC,SAASC,eAAe,EAAEC,gBAAgB,CAAC;IAC7E,MAAMjB,cAAcc,iBAAiBC,SAASC,eAAe,EAAEC,gBAAgB,CAAC;IAEhF,OAAO;QACLpB,UAAUA,YAAYgB;QACtBb,aAAaA,eAAea;IAC9B;AACF"}
1
+ {"version":3,"sources":["../../src/providers/font-loader.tsx"],"sourcesContent":["/**\n * Next.js Font Loader Utilities\n *\n * This file provides utilities for loading Google Fonts in Next.js applications\n * based on theme configuration from the CMS.\n *\n * ## Usage Guide\n *\n * ### 1. Static Font Loading (Recommended)\n *\n * In your Next.js app's root layout:\n *\n * ```tsx\n * // app/layout.tsx\n * import { Inter, Playfair_Display } from 'next/font/google'\n *\n * const inter = Inter({\n * subsets: ['latin'],\n * variable: '--font-body',\n * display: 'swap',\n * })\n *\n * const playfair = Playfair_Display({\n * subsets: ['latin'],\n * variable: '--font-heading',\n * display: 'swap',\n * })\n *\n * export default function RootLayout({ children }: { children: React.ReactNode }) {\n * return (\n * <html lang=\"en\" className={`${inter.variable} ${playfair.variable}`}>\n * <body>{children}</body>\n * </html>\n * )\n * }\n * ```\n *\n * ### 2. CSS Variables Usage\n *\n * In your global CSS:\n *\n * ```css\n * :root {\n * --font-body: var(--font-inter), system-ui, sans-serif;\n * --font-heading: var(--font-playfair), Georgia, serif;\n * }\n *\n * body {\n * font-family: var(--font-body);\n * }\n *\n * h1, h2, h3, h4, h5, h6 {\n * font-family: var(--font-heading);\n * }\n * ```\n *\n * ### 3. Dynamic Font Loading\n *\n * Use the helper functions below to generate font loader code:\n *\n * ```tsx\n * import { getFontLoaderCode } from '@kilivi/payloadcms-theme-management/providers/font-loader'\n *\n * const themeConfig = await getThemeConfig()\n * const fontCode = getFontLoaderCode(themeConfig)\n * console.log(fontCode) // Copy this to your layout.tsx\n * ```\n */\n\ninterface ThemeConfig {\n bodyFont?: string\n headingFont?: string\n bodyFontCustom?: string\n headingFontCustom?: string\n}\n\n/**\n * Font mapping for next/font/google imports\n * Maps theme font values to Next.js font imports\n */\nexport const FONT_IMPORT_MAP: Record<string, { import: string; variable: string }> = {\n Inter: {\n import: `import { Inter } from 'next/font/google'\\nconst inter = Inter({ subsets: ['latin'], variable: '--font-body' })`,\n variable: 'inter.variable',\n },\n Roboto: {\n import: `import { Roboto } from 'next/font/google'\\nconst roboto = Roboto({ weight: ['400', '500', '700'], subsets: ['latin'], variable: '--font-body' })`,\n variable: 'roboto.variable',\n },\n 'Open Sans': {\n import: `import { Open_Sans } from 'next/font/google'\\nconst openSans = Open_Sans({ subsets: ['latin'], variable: '--font-body' })`,\n variable: 'openSans.variable',\n },\n Lato: {\n import: `import { Lato } from 'next/font/google'\\nconst lato = Lato({ weight: ['400', '700'], subsets: ['latin'], variable: '--font-body' })`,\n variable: 'lato.variable',\n },\n Montserrat: {\n import: `import { Montserrat } from 'next/font/google'\\nconst montserrat = Montserrat({ subsets: ['latin'], variable: '--font-body' })`,\n variable: 'montserrat.variable',\n },\n Poppins: {\n import: `import { Poppins } from 'next/font/google'\\nconst poppins = Poppins({ weight: ['400', '500', '600', '700'], subsets: ['latin'], variable: '--font-body' })`,\n variable: 'poppins.variable',\n },\n 'Playfair Display': {\n import: `import { Playfair_Display } from 'next/font/google'\\nconst playfair = Playfair_Display({ subsets: ['latin'], variable: '--font-heading' })`,\n variable: 'playfair.variable',\n },\n Merriweather: {\n import: `import { Merriweather } from 'next/font/google'\\nconst merriweather = Merriweather({ weight: ['400', '700'], subsets: ['latin'], variable: '--font-heading' })`,\n variable: 'merriweather.variable',\n },\n Lora: {\n import: `import { Lora } from 'next/font/google'\\nconst lora = Lora({ subsets: ['latin'], variable: '--font-heading' })`,\n variable: 'lora.variable',\n },\n 'Crimson Text': {\n import: `import { Crimson_Text } from 'next/font/google'\\nconst crimsonText = Crimson_Text({ weight: ['400', '600', '700'], subsets: ['latin'], variable: '--font-heading' })`,\n variable: 'crimsonText.variable',\n },\n}\n\n/**\n * Generate Next.js font loader code for your layout\n *\n * @param config - Theme configuration from CMS\n * @returns String with complete Next.js font loading code\n *\n * @example\n * ```tsx\n * const code = getFontLoaderCode({ bodyFont: 'Inter', headingFont: 'Playfair Display' })\n * console.log(code)\n * // Copy the output to your app/layout.tsx file\n * ```\n */\nexport function getFontLoaderCode(config: ThemeConfig): string {\n const imports: string[] = []\n const variables: string[] = []\n\n if (config.bodyFont && config.bodyFont !== 'preset' && config.bodyFont !== 'custom') {\n const fontConfig = FONT_IMPORT_MAP[config.bodyFont]\n if (fontConfig) {\n imports.push(fontConfig.import)\n variables.push(fontConfig.variable)\n }\n }\n\n if (config.headingFont && config.headingFont !== 'preset' && config.headingFont !== 'custom') {\n const fontConfig = FONT_IMPORT_MAP[config.headingFont]\n if (fontConfig) {\n imports.push(fontConfig.import)\n variables.push(fontConfig.variable)\n }\n }\n\n return `// app/layout.tsx\n${imports.join('\\n\\n')}\n\nexport default function RootLayout({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\" className={\\`${variables.join(' ')}\\`}>\n <body>{children}</body>\n </html>\n )\n}\n`\n}\n\n/**\n * Get font family CSS strings for inline styles\n *\n * @param config - Theme configuration\n * @returns Object with bodyFont and headingFont CSS font-family strings\n */\nexport function getThemeFontFamilies(config: ThemeConfig): {\n bodyFont?: string\n headingFont?: string\n} {\n const result: { bodyFont?: string; headingFont?: string } = {}\n\n // Body font\n if (config.bodyFont === 'custom' && config.bodyFontCustom) {\n result.bodyFont = config.bodyFontCustom\n } else if (config.bodyFont && config.bodyFont !== 'preset') {\n result.bodyFont = `var(--font-body), ${config.bodyFont}, sans-serif`\n }\n\n // Heading font\n if (config.headingFont === 'custom' && config.headingFontCustom) {\n result.headingFont = config.headingFontCustom\n } else if (config.headingFont && config.headingFont !== 'preset') {\n result.headingFont = `var(--font-heading), ${config.headingFont}, serif`\n }\n\n return result\n}\n\n/**\n * React component wrapper for font variables\n * Use this to inject font CSS variables into your app\n */\nexport function ThemeFontProvider({\n children,\n bodyFont,\n headingFont,\n bodyFontCustom,\n headingFontCustom,\n}: {\n children: React.ReactNode | any\n bodyFont?: string\n headingFont?: string\n bodyFontCustom?: string\n headingFontCustom?: string\n}) {\n const fonts = getThemeFontFamilies({ bodyFont, headingFont, bodyFontCustom, headingFontCustom })\n\n return (\n <div\n style={\n {\n '--font-body': fonts.bodyFont,\n '--font-heading': fonts.headingFont,\n } as React.CSSProperties\n }\n >\n {children}\n </div>\n )\n}\n\n/**\n * Client-side hook for accessing theme fonts\n * Use this in client components to read font CSS variables\n */\nexport function useThemeFonts() {\n if (typeof window === 'undefined') {\n return { bodyFont: undefined, headingFont: undefined }\n }\n\n const bodyFont = getComputedStyle(document.documentElement).getPropertyValue('--font-body')\n const headingFont = getComputedStyle(document.documentElement).getPropertyValue('--font-heading')\n\n return {\n bodyFont: bodyFont || undefined,\n headingFont: headingFont || undefined,\n }\n}\n"],"names":["FONT_IMPORT_MAP","Inter","import","variable","Roboto","Lato","Montserrat","Poppins","Merriweather","Lora","getFontLoaderCode","config","imports","variables","bodyFont","fontConfig","push","headingFont","join","getThemeFontFamilies","result","bodyFontCustom","headingFontCustom","ThemeFontProvider","children","fonts","div","style","useThemeFonts","window","undefined","getComputedStyle","document","documentElement","getPropertyValue"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEC;AASD;;;CAGC,GACD,OAAO,MAAMA,kBAAwE;IACnFC,OAAO;QACLC,QAAQ,CAAC,8GAA8G,CAAC;QACxHC,UAAU;IACZ;IACAC,QAAQ;QACNF,QAAQ,CAAC,gJAAgJ,CAAC;QAC1JC,UAAU;IACZ;IACA,aAAa;QACXD,QAAQ,CAAC,yHAAyH,CAAC;Q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ACF"}
@@ -0,0 +1,49 @@
1
+ export type Language = string;
2
+ export interface PluginTranslations {
3
+ tabLabel: string;
4
+ standaloneCollectionLabel: string;
5
+ livePreview: {
6
+ smallTitle: string;
7
+ largeTitle: string;
8
+ };
9
+ ui: {
10
+ primaryAction: string;
11
+ secondaryAction: string;
12
+ lightMode: string;
13
+ darkMode: string;
14
+ selectFontPlaceholder: string;
15
+ usePreset: string;
16
+ specifyCustom: string;
17
+ sampleSentence: string;
18
+ };
19
+ colors: {
20
+ primary: string;
21
+ secondary: string;
22
+ accent: string;
23
+ background: string;
24
+ foreground: string;
25
+ muted: string;
26
+ card: string;
27
+ popover: string;
28
+ };
29
+ preview: {
30
+ siteTitle: string;
31
+ nav: {
32
+ home: string;
33
+ about: string;
34
+ services: string;
35
+ contact: string;
36
+ };
37
+ welcomeTitle: string;
38
+ welcomeCopy: string;
39
+ sampleCardTitle: string;
40
+ customPalette: string;
41
+ footer: string;
42
+ };
43
+ }
44
+ declare const translations: Record<Language, PluginTranslations>;
45
+ export declare function getTranslations(lang?: Language): PluginTranslations;
46
+ export declare function registerTranslations(newTranslations: Record<Language, Partial<PluginTranslations>>): void;
47
+ export declare function availableLanguages(): string[];
48
+ export { translations };
49
+ //# sourceMappingURL=translations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../src/translations.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAA;AAE7B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,yBAAyB,EAAE,MAAM,CAAA;IACjC,WAAW,EAAE;QACX,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,EAAE,EAAE;QACF,aAAa,EAAE,MAAM,CAAA;QACrB,eAAe,EAAE,MAAM,CAAA;QACvB,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;QA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