@kilivi/payloadcms-theme-management 2.0.0 → 2.2.0

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 (235) hide show
  1. package/README.md +346 -845
  2. package/dist/components/AppearanceSessionControls.d.ts +15 -0
  3. package/dist/components/AppearanceSessionControls.d.ts.map +1 -0
  4. package/dist/components/AppearanceSessionControls.js +152 -0
  5. package/dist/components/AppearanceSessionControls.js.map +1 -0
  6. package/dist/components/ColorModeToggle.css +42 -0
  7. package/dist/components/ColorModeToggle.d.ts +40 -0
  8. package/dist/components/ColorModeToggle.d.ts.map +1 -0
  9. package/dist/components/ColorModeToggle.js +111 -0
  10. package/dist/components/ColorModeToggle.js.map +1 -0
  11. package/dist/components/ServerThemeInjector.d.ts +13 -1
  12. package/dist/components/ServerThemeInjector.d.ts.map +1 -1
  13. package/dist/components/ServerThemeInjector.js +65 -15
  14. package/dist/components/ServerThemeInjector.js.map +1 -1
  15. package/dist/components/ThemeLivePreviewSync.d.ts +4 -0
  16. package/dist/components/ThemeLivePreviewSync.d.ts.map +1 -1
  17. package/dist/components/ThemeLivePreviewSync.js +28 -4
  18. package/dist/components/ThemeLivePreviewSync.js.map +1 -1
  19. package/dist/components/ThemeSwitcher.d.ts +36 -0
  20. package/dist/components/ThemeSwitcher.d.ts.map +1 -0
  21. package/dist/components/ThemeSwitcher.js +89 -0
  22. package/dist/components/ThemeSwitcher.js.map +1 -0
  23. package/dist/components/typographyPreviewUtils.d.ts +5 -0
  24. package/dist/components/typographyPreviewUtils.d.ts.map +1 -1
  25. package/dist/components/typographyPreviewUtils.js +24 -11
  26. package/dist/components/typographyPreviewUtils.js.map +1 -1
  27. package/dist/constants/devicePreviews.d.ts +35 -0
  28. package/dist/constants/devicePreviews.d.ts.map +1 -0
  29. package/dist/constants/devicePreviews.js +43 -0
  30. package/dist/constants/devicePreviews.js.map +1 -0
  31. package/dist/constants/themeFonts.d.ts +94 -168
  32. package/dist/constants/themeFonts.d.ts.map +1 -1
  33. package/dist/constants/themeFonts.js +260 -140
  34. package/dist/constants/themeFonts.js.map +1 -1
  35. package/dist/endpoints/themeFonts.d.ts +5 -0
  36. package/dist/endpoints/themeFonts.d.ts.map +1 -0
  37. package/dist/endpoints/themeFonts.js +138 -0
  38. package/dist/endpoints/themeFonts.js.map +1 -0
  39. package/dist/extended-presets.d.ts +0 -4
  40. package/dist/extended-presets.d.ts.map +1 -1
  41. package/dist/extended-presets.js +1 -18
  42. package/dist/extended-presets.js.map +1 -1
  43. package/dist/extended-themes.d.ts.map +1 -1
  44. package/dist/extended-themes.js +428 -0
  45. package/dist/extended-themes.js.map +1 -1
  46. package/dist/fields/AccessibilityAuditField.d.ts +2 -0
  47. package/dist/fields/AccessibilityAuditField.d.ts.map +1 -0
  48. package/dist/fields/AccessibilityAuditField.js +303 -0
  49. package/dist/fields/AccessibilityAuditField.js.map +1 -0
  50. package/dist/fields/AppearancePreviewField.d.ts +2 -0
  51. package/dist/fields/AppearancePreviewField.d.ts.map +1 -0
  52. package/dist/fields/AppearancePreviewField.js +826 -0
  53. package/dist/fields/AppearancePreviewField.js.map +1 -0
  54. package/dist/fields/ColorPickerField.d.ts.map +1 -1
  55. package/dist/fields/ColorPickerField.js +89 -85
  56. package/dist/fields/ColorPickerField.js.map +1 -1
  57. package/dist/fields/FontSelectField.css +155 -0
  58. package/dist/fields/FontSelectField.d.ts +8 -0
  59. package/dist/fields/FontSelectField.d.ts.map +1 -1
  60. package/dist/fields/FontSelectField.js +223 -188
  61. package/dist/fields/FontSelectField.js.map +1 -1
  62. package/dist/fields/PaletteGeneratorField.d.ts +7 -0
  63. package/dist/fields/PaletteGeneratorField.d.ts.map +1 -0
  64. package/dist/fields/PaletteGeneratorField.js +327 -0
  65. package/dist/fields/PaletteGeneratorField.js.map +1 -0
  66. package/dist/fields/StylePresetField.d.ts +3 -0
  67. package/dist/fields/StylePresetField.d.ts.map +1 -0
  68. package/dist/fields/StylePresetField.js +463 -0
  69. package/dist/fields/StylePresetField.js.map +1 -0
  70. package/dist/fields/ThemeColorPickerField.css +115 -35
  71. package/dist/fields/ThemeColorPickerField.d.ts.map +1 -1
  72. package/dist/fields/ThemeColorPickerField.js +204 -70
  73. package/dist/fields/ThemeColorPickerField.js.map +1 -1
  74. package/dist/fields/ThemeExportField.d.ts +6 -0
  75. package/dist/fields/ThemeExportField.d.ts.map +1 -0
  76. package/dist/fields/ThemeExportField.js +202 -0
  77. package/dist/fields/ThemeExportField.js.map +1 -0
  78. package/dist/fields/ThemePresetImportField.d.ts.map +1 -1
  79. package/dist/fields/ThemePresetImportField.js +56 -25
  80. package/dist/fields/ThemePresetImportField.js.map +1 -1
  81. package/dist/fields/ThemePreviewField.css +444 -5
  82. package/dist/fields/ThemePreviewField.d.ts.map +1 -1
  83. package/dist/fields/ThemePreviewField.js +265 -170
  84. package/dist/fields/ThemePreviewField.js.map +1 -1
  85. package/dist/fields/ThemeTokenSelectField.d.ts.map +1 -1
  86. package/dist/fields/ThemeTokenSelectField.js +278 -80
  87. package/dist/fields/ThemeTokenSelectField.js.map +1 -1
  88. package/dist/fields/colorFieldHelpers.d.ts +90 -0
  89. package/dist/fields/colorFieldHelpers.d.ts.map +1 -0
  90. package/dist/fields/colorFieldHelpers.js +133 -0
  91. package/dist/fields/colorFieldHelpers.js.map +1 -0
  92. package/dist/fields/colorModeFields.d.ts +1 -1
  93. package/dist/fields/colorModeFields.d.ts.map +1 -1
  94. package/dist/fields/colorModeFields.js +49 -7
  95. package/dist/fields/colorModeFields.js.map +1 -1
  96. package/dist/fields/themeConfigurationField.d.ts +8 -1
  97. package/dist/fields/themeConfigurationField.d.ts.map +1 -1
  98. package/dist/fields/themeConfigurationField.js +1209 -228
  99. package/dist/fields/themeConfigurationField.js.map +1 -1
  100. package/dist/globals/ThemeSettings/FontPicker/FontPreview.d.ts.map +1 -1
  101. package/dist/globals/ThemeSettings/FontPicker/FontPreview.js +8 -4
  102. package/dist/globals/ThemeSettings/FontPicker/FontPreview.js.map +1 -1
  103. package/dist/globals/ThemeSettings/FontPicker/index.d.ts.map +1 -1
  104. package/dist/globals/ThemeSettings/FontPicker/index.js +81 -26
  105. package/dist/globals/ThemeSettings/FontPicker/index.js.map +1 -1
  106. package/dist/globals/ThemeSettings/FontPicker/styles.css +98 -41
  107. package/dist/globals/ThemeSettings/FontPicker/translations.d.ts +6 -0
  108. package/dist/globals/ThemeSettings/FontPicker/translations.d.ts.map +1 -1
  109. package/dist/globals/ThemeSettings/FontPicker/translations.js +14 -2
  110. package/dist/globals/ThemeSettings/FontPicker/translations.js.map +1 -1
  111. package/dist/globals/ThemeSettings/config.d.ts.map +1 -1
  112. package/dist/globals/ThemeSettings/config.js +76 -79
  113. package/dist/globals/ThemeSettings/config.js.map +1 -1
  114. package/dist/globals/ThemeSettings/fields/FontLoadingGuideField.d.ts.map +1 -1
  115. package/dist/globals/ThemeSettings/fields/FontLoadingGuideField.js +63 -62
  116. package/dist/globals/ThemeSettings/fields/FontLoadingGuideField.js.map +1 -1
  117. package/dist/globals/ThemeSettings/fields/TypographyInfoField.d.ts.map +1 -1
  118. package/dist/globals/ThemeSettings/fields/TypographyInfoField.js +22 -25
  119. package/dist/globals/ThemeSettings/fields/TypographyInfoField.js.map +1 -1
  120. package/dist/hooks/useAppearanceSession.d.ts +50 -0
  121. package/dist/hooks/useAppearanceSession.d.ts.map +1 -0
  122. package/dist/hooks/useAppearanceSession.js +91 -0
  123. package/dist/hooks/useAppearanceSession.js.map +1 -0
  124. package/dist/hooks/useNativeLivePreview.d.ts +15 -0
  125. package/dist/hooks/useNativeLivePreview.d.ts.map +1 -0
  126. package/dist/hooks/useNativeLivePreview.js +18 -0
  127. package/dist/hooks/useNativeLivePreview.js.map +1 -0
  128. package/dist/hooks/useThemeFonts.d.ts +10 -0
  129. package/dist/hooks/useThemeFonts.d.ts.map +1 -0
  130. package/dist/hooks/useThemeFonts.js +36 -0
  131. package/dist/hooks/useThemeFonts.js.map +1 -0
  132. package/dist/hooks/useThemeTranslations.d.ts +13 -0
  133. package/dist/hooks/useThemeTranslations.d.ts.map +1 -0
  134. package/dist/hooks/useThemeTranslations.js +22 -0
  135. package/dist/hooks/useThemeTranslations.js.map +1 -0
  136. package/dist/i18n.d.ts +53 -0
  137. package/dist/i18n.d.ts.map +1 -0
  138. package/dist/i18n.js +53 -0
  139. package/dist/i18n.js.map +1 -0
  140. package/dist/index.d.ts +13 -4
  141. package/dist/index.d.ts.map +1 -1
  142. package/dist/index.js +59 -29
  143. package/dist/index.js.map +1 -1
  144. package/dist/next-fonts.d.ts +3 -0
  145. package/dist/next-fonts.d.ts.map +1 -0
  146. package/dist/next-fonts.js +360 -0
  147. package/dist/next-fonts.js.map +1 -0
  148. package/dist/payload-types.d.ts +34 -6
  149. package/dist/payload-types.d.ts.map +1 -1
  150. package/dist/payload-types.js.map +1 -1
  151. package/dist/presets.d.ts +14 -0
  152. package/dist/presets.d.ts.map +1 -1
  153. package/dist/presets.js.map +1 -1
  154. package/dist/providers/Theme/index.d.ts.map +1 -1
  155. package/dist/providers/Theme/index.js +75 -11
  156. package/dist/providers/Theme/index.js.map +1 -1
  157. package/dist/providers/Theme/themeConfig.d.ts.map +1 -1
  158. package/dist/providers/Theme/themeConfig.js +104 -0
  159. package/dist/providers/Theme/themeConfig.js.map +1 -1
  160. package/dist/providers/Theme/types.d.ts +1 -1
  161. package/dist/providers/Theme/types.d.ts.map +1 -1
  162. package/dist/providers/Theme/types.js +10 -1
  163. package/dist/providers/Theme/types.js.map +1 -1
  164. package/dist/style-presets.d.ts +75 -0
  165. package/dist/style-presets.d.ts.map +1 -0
  166. package/dist/style-presets.js +738 -0
  167. package/dist/style-presets.js.map +1 -0
  168. package/dist/translations.d.ts +164 -1
  169. package/dist/translations.d.ts.map +1 -1
  170. package/dist/translations.js +320 -9
  171. package/dist/translations.js.map +1 -1
  172. package/dist/tweakcn-special-themes.d.ts.map +1 -1
  173. package/dist/tweakcn-special-themes.js +585 -9
  174. package/dist/tweakcn-special-themes.js.map +1 -1
  175. package/dist/types/css.d.js +3 -0
  176. package/dist/types/css.d.js.map +1 -0
  177. package/dist/types.d.ts +26 -0
  178. package/dist/types.d.ts.map +1 -1
  179. package/dist/types.js +1 -1
  180. package/dist/types.js.map +1 -1
  181. package/dist/utilities/getThemeSettings.d.ts.map +1 -1
  182. package/dist/utilities/getThemeSettings.js +2 -14
  183. package/dist/utilities/getThemeSettings.js.map +1 -1
  184. package/dist/utils/contrast.d.ts +63 -0
  185. package/dist/utils/contrast.d.ts.map +1 -0
  186. package/dist/utils/contrast.js +158 -0
  187. package/dist/utils/contrast.js.map +1 -0
  188. package/dist/utils/exportTokens.d.ts +30 -0
  189. package/dist/utils/exportTokens.d.ts.map +1 -0
  190. package/dist/utils/exportTokens.js +183 -0
  191. package/dist/utils/exportTokens.js.map +1 -0
  192. package/dist/utils/generatePalette.d.ts +46 -0
  193. package/dist/utils/generatePalette.d.ts.map +1 -0
  194. package/dist/utils/generatePalette.js +127 -0
  195. package/dist/utils/generatePalette.js.map +1 -0
  196. package/dist/utils/generateThemeCSS.d.ts.map +1 -1
  197. package/dist/utils/generateThemeCSS.js +2 -40
  198. package/dist/utils/generateThemeCSS.js.map +1 -1
  199. package/dist/utils/livePreviewThemeRuntime.d.ts +22 -3
  200. package/dist/utils/livePreviewThemeRuntime.d.ts.map +1 -1
  201. package/dist/utils/livePreviewThemeRuntime.js +48 -15
  202. package/dist/utils/livePreviewThemeRuntime.js.map +1 -1
  203. package/dist/utils/localizedText.d.ts +8 -0
  204. package/dist/utils/localizedText.d.ts.map +1 -0
  205. package/dist/utils/localizedText.js +21 -0
  206. package/dist/utils/localizedText.js.map +1 -0
  207. package/dist/utils/resolveThemeConfiguration.d.ts +60 -1
  208. package/dist/utils/resolveThemeConfiguration.d.ts.map +1 -1
  209. package/dist/utils/resolveThemeConfiguration.js +53 -13
  210. package/dist/utils/resolveThemeConfiguration.js.map +1 -1
  211. package/dist/utils/themeColors.d.ts +3 -0
  212. package/dist/utils/themeColors.d.ts.map +1 -1
  213. package/dist/utils/themeColors.js +30 -1
  214. package/dist/utils/themeColors.js.map +1 -1
  215. package/dist/utils/themeHtmlAttributes.d.ts +32 -12
  216. package/dist/utils/themeHtmlAttributes.d.ts.map +1 -1
  217. package/dist/utils/themeHtmlAttributes.js +38 -5
  218. package/dist/utils/themeHtmlAttributes.js.map +1 -1
  219. package/dist/utils/themeUtils.d.ts +3 -5
  220. package/dist/utils/themeUtils.d.ts.map +1 -1
  221. package/dist/utils/themeUtils.js +474 -6
  222. package/dist/utils/themeUtils.js.map +1 -1
  223. package/dist/utils/tweakcnConverter.d.ts +1 -3
  224. package/dist/utils/tweakcnConverter.d.ts.map +1 -1
  225. package/dist/utils/tweakcnConverter.js +1 -3
  226. package/dist/utils/tweakcnConverter.js.map +1 -1
  227. package/package.json +15 -5
  228. package/dist/components/ThemePreview.d.ts +0 -3
  229. package/dist/components/ThemePreview.d.ts.map +0 -1
  230. package/dist/components/ThemePreview.js +0 -321
  231. package/dist/components/ThemePreview.js.map +0 -1
  232. package/dist/plugin.d.ts +0 -2
  233. package/dist/plugin.d.ts.map +0 -1
  234. package/dist/plugin.js +0 -3
  235. package/dist/plugin.js.map +0 -1
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import * as PayloadUI from '@payloadcms/ui';
3
+ import { useEffect } from 'react';
4
+ import { buildThemeFontsHref } from '../constants/themeFonts.js';
5
+ // Tolerate a missing export (older Payload, unit-test mocks): fall back to '/api'.
6
+ const useConfigSafe = PayloadUI.useConfig ?? (()=>undefined);
7
+ /** Payload's REST API route (`routes.api`), '/api' by default. */ export function useApiRoute() {
8
+ return useConfigSafe()?.config?.routes?.api ?? '/api';
9
+ }
10
+ /**
11
+ * Load catalog fonts into the admin document through the plugin's self-hosted
12
+ * font endpoint, so previews render in the real faces without the editor's
13
+ * browser contacting Google. One `<link>` per distinct font set, shared by every
14
+ * field that asks for the same set.
15
+ */ export function useThemeFonts(values) {
16
+ const apiRoute = useApiRoute();
17
+ const href = buildThemeFontsHref(values, {
18
+ apiRoute
19
+ });
20
+ useEffect(()=>{
21
+ if (!href || typeof document === 'undefined') return;
22
+ const exists = [
23
+ ...document.querySelectorAll('link[data-tm-fonts]')
24
+ ].some((link)=>link.getAttribute('href') === href);
25
+ if (exists) return;
26
+ const link = document.createElement('link');
27
+ link.rel = 'stylesheet';
28
+ link.href = href;
29
+ link.dataset.tmFonts = '';
30
+ document.head.appendChild(link);
31
+ }, [
32
+ href
33
+ ]);
34
+ }
35
+
36
+ //# sourceMappingURL=useThemeFonts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useThemeFonts.ts"],"sourcesContent":["'use client'\n\nimport * as PayloadUI from '@payloadcms/ui'\nimport { useEffect } from 'react'\nimport { buildThemeFontsHref } from '../constants/themeFonts.js'\n\ntype UseConfig = () => { config?: { routes?: { api?: string } } } | undefined\n\n// Tolerate a missing export (older Payload, unit-test mocks): fall back to '/api'.\nconst useConfigSafe: UseConfig =\n (PayloadUI as unknown as { useConfig?: UseConfig }).useConfig ?? (() => undefined)\n\n/** Payload's REST API route (`routes.api`), '/api' by default. */\nexport function useApiRoute(): string {\n return useConfigSafe()?.config?.routes?.api ?? '/api'\n}\n\n/**\n * Load catalog fonts into the admin document through the plugin's self-hosted\n * font endpoint, so previews render in the real faces without the editor's\n * browser contacting Google. One `<link>` per distinct font set, shared by every\n * field that asks for the same set.\n */\nexport function useThemeFonts(values: Array<string | null | undefined>): void {\n const apiRoute = useApiRoute()\n const href = buildThemeFontsHref(values, { apiRoute })\n\n useEffect(() => {\n if (!href || typeof document === 'undefined') return\n const exists = [...document.querySelectorAll<HTMLLinkElement>('link[data-tm-fonts]')].some(\n (link) => link.getAttribute('href') === href,\n )\n if (exists) return\n const link = document.createElement('link')\n link.rel = 'stylesheet'\n link.href = href\n link.dataset.tmFonts = ''\n document.head.appendChild(link)\n }, [href])\n}\n"],"names":["PayloadUI","useEffect","buildThemeFontsHref","useConfigSafe","useConfig","undefined","useApiRoute","config","routes","api","useThemeFonts","values","apiRoute","href","document","exists","querySelectorAll","some","link","getAttribute","createElement","rel","dataset","tmFonts","head","appendChild"],"mappings":"AAAA;AAEA,YAAYA,eAAe,iBAAgB;AAC3C,SAASC,SAAS,QAAQ,QAAO;AACjC,SAASC,mBAAmB,QAAQ,6BAA4B;AAIhE,mFAAmF;AACnF,MAAMC,gBACJ,AAACH,UAAmDI,SAAS,IAAK,CAAA,IAAMC,SAAQ;AAElF,gEAAgE,GAChE,OAAO,SAASC;IACd,OAAOH,iBAAiBI,QAAQC,QAAQC,OAAO;AACjD;AAEA;;;;;CAKC,GACD,OAAO,SAASC,cAAcC,MAAwC;IACpE,MAAMC,WAAWN;IACjB,MAAMO,OAAOX,oBAAoBS,QAAQ;QAAEC;IAAS;IAEpDX,UAAU;QACR,IAAI,CAACY,QAAQ,OAAOC,aAAa,aAAa;QAC9C,MAAMC,SAAS;eAAID,SAASE,gBAAgB,CAAkB;SAAuB,CAACC,IAAI,CACxF,CAACC,OAASA,KAAKC,YAAY,CAAC,YAAYN;QAE1C,IAAIE,QAAQ;QACZ,MAAMG,OAAOJ,SAASM,aAAa,CAAC;QACpCF,KAAKG,GAAG,GAAG;QACXH,KAAKL,IAAI,GAAGA;QACZK,KAAKI,OAAO,CAACC,OAAO,GAAG;QACvBT,SAASU,IAAI,CAACC,WAAW,CAACP;IAC5B,GAAG;QAACL;KAAK;AACX"}
@@ -0,0 +1,13 @@
1
+ import { type PluginTranslations } from '../translations.js';
2
+ /**
3
+ * Resolve the current Payload admin language using Payload's native i18n context
4
+ * (instead of sniffing `navigator.language`). Falls back to English.
5
+ */
6
+ export declare function useThemeLanguage(): string;
7
+ /**
8
+ * Return the plugin's translations for the active admin language, with English
9
+ * used as the fallback for any missing key. Use this in client field components
10
+ * so the strings follow the admin's selected locale natively.
11
+ */
12
+ export declare function useThemeTranslations(): PluginTranslations;
13
+ //# sourceMappingURL=useThemeTranslations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useThemeTranslations.d.ts","sourceRoot":"","sources":["../../src/hooks/useThemeTranslations.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAE7E;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,kBAAkB,CAEzD"}
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+ import { useTranslation } from '@payloadcms/ui';
3
+ import { getTranslations } from '../translations.js';
4
+ /**
5
+ * Resolve the current Payload admin language using Payload's native i18n context
6
+ * (instead of sniffing `navigator.language`). Falls back to English.
7
+ */ export function useThemeLanguage() {
8
+ // Tolerate `useTranslation()` returning undefined (e.g. outside an i18n provider
9
+ // or in unit tests with reset mocks) by falling back to English.
10
+ const result = useTranslation();
11
+ const language = result?.i18n?.language;
12
+ return typeof language === 'string' && language.length >= 2 ? language : 'en';
13
+ }
14
+ /**
15
+ * Return the plugin's translations for the active admin language, with English
16
+ * used as the fallback for any missing key. Use this in client field components
17
+ * so the strings follow the admin's selected locale natively.
18
+ */ export function useThemeTranslations() {
19
+ return getTranslations(useThemeLanguage());
20
+ }
21
+
22
+ //# sourceMappingURL=useThemeTranslations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useThemeTranslations.ts"],"sourcesContent":["'use client'\n\nimport { useTranslation } from '@payloadcms/ui'\nimport { getTranslations, type PluginTranslations } from '../translations.js'\n\n/**\n * Resolve the current Payload admin language using Payload's native i18n context\n * (instead of sniffing `navigator.language`). Falls back to English.\n */\nexport function useThemeLanguage(): string {\n // Tolerate `useTranslation()` returning undefined (e.g. outside an i18n provider\n // or in unit tests with reset mocks) by falling back to English.\n const result = useTranslation() as { i18n?: { language?: string } } | undefined\n const language = result?.i18n?.language\n return typeof language === 'string' && language.length >= 2 ? language : 'en'\n}\n\n/**\n * Return the plugin's translations for the active admin language, with English\n * used as the fallback for any missing key. Use this in client field components\n * so the strings follow the admin's selected locale natively.\n */\nexport function useThemeTranslations(): PluginTranslations {\n return getTranslations(useThemeLanguage())\n}\n"],"names":["useTranslation","getTranslations","useThemeLanguage","result","language","i18n","length","useThemeTranslations"],"mappings":"AAAA;AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,eAAe,QAAiC,qBAAoB;AAE7E;;;CAGC,GACD,OAAO,SAASC;IACd,iFAAiF;IACjF,iEAAiE;IACjE,MAAMC,SAASH;IACf,MAAMI,WAAWD,QAAQE,MAAMD;IAC/B,OAAO,OAAOA,aAAa,YAAYA,SAASE,MAAM,IAAI,IAAIF,WAAW;AAC3E;AAEA;;;;CAIC,GACD,OAAO,SAASG;IACd,OAAON,gBAAgBC;AACzB"}
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import type { Config } from 'payload';
2
+ import { type DeepPartial, type PluginTranslations } from './translations.js';
3
+ /**
4
+ * Additional or overriding translations, keyed by language code.
5
+ * Each entry is deep-merged over the built-in English/Czech translations, so you
6
+ * only need to provide the keys you want to add or change.
7
+ */
8
+ export type ThemeManagementI18nTranslations = Record<string, DeepPartial<PluginTranslations>>;
9
+ export interface ThemeManagementI18nOptions {
10
+ /**
11
+ * Extra languages or per-key overrides for the plugin admin UI strings.
12
+ *
13
+ * @example
14
+ * i18n: {
15
+ * translations: {
16
+ * de: { tabLabel: 'Darstellung', ui: { lightMode: 'Heller Modus' } },
17
+ * en: { tabLabel: 'Theme' }, // override a built-in string
18
+ * },
19
+ * }
20
+ */
21
+ translations?: ThemeManagementI18nTranslations;
22
+ /**
23
+ * Pass-through to `config.i18n.supportedLanguages`. Provide language objects from
24
+ * `@payloadcms/translations/languages/*` when you want the Payload admin to offer a
25
+ * brand-new admin language (beyond the project defaults).
26
+ *
27
+ * @example
28
+ * import { de } from '@payloadcms/translations/languages/de'
29
+ * i18n: { supportedLanguages: { de } }
30
+ */
31
+ supportedLanguages?: Record<string, unknown>;
32
+ }
33
+ type PayloadTranslationsByLang = Record<string, Record<string, unknown>>;
34
+ /**
35
+ * Build the plugin's translations in Payload's native `config.i18n.translations`
36
+ * shape: `{ [lang]: { 'theme-management': { ...keys } } }`.
37
+ *
38
+ * Every language is filled out via `getTranslations`, so English acts as the
39
+ * fallback for any missing key in another language.
40
+ */
41
+ export declare function getThemeManagementI18nTranslations(): PayloadTranslationsByLang;
42
+ /**
43
+ * Merge the plugin's translations into an existing `config.i18n`, following the
44
+ * official Payload plugin i18n pattern. Translations already present on the
45
+ * incoming config win over the plugin defaults, so apps can freely override.
46
+ *
47
+ * Any `options.translations` are registered first so they participate in the
48
+ * merge (and are visible to `getTranslations` at runtime), and any
49
+ * `options.supportedLanguages` are passed straight through.
50
+ */
51
+ export declare function mergeThemeManagementI18n(existing: Config['i18n'], options?: ThemeManagementI18nOptions): NonNullable<Config['i18n']>;
52
+ export {};
53
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAA;AAE1B;;;;GAIG;AACH,MAAM,MAAM,+BAA+B,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAE7F,MAAM,WAAW,0BAA0B;IACzC;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE,+BAA+B,CAAA;IAC9C;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7C;AAED,KAAK,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAExE;;;;;;GAMG;AACH,wBAAgB,kCAAkC,IAAI,yBAAyB,CAM9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EACxB,OAAO,CAAC,EAAE,0BAA0B,GACnC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAgC7B"}
package/dist/i18n.js ADDED
@@ -0,0 +1,53 @@
1
+ import { THEME_MANAGEMENT_I18N_NAMESPACE, availableLanguages, deepMerge, getTranslations, registerTranslations } from './translations.js';
2
+ /**
3
+ * Build the plugin's translations in Payload's native `config.i18n.translations`
4
+ * shape: `{ [lang]: { 'theme-management': { ...keys } } }`.
5
+ *
6
+ * Every language is filled out via `getTranslations`, so English acts as the
7
+ * fallback for any missing key in another language.
8
+ */ export function getThemeManagementI18nTranslations() {
9
+ const out = {};
10
+ for (const lang of availableLanguages()){
11
+ out[lang] = {
12
+ [THEME_MANAGEMENT_I18N_NAMESPACE]: getTranslations(lang)
13
+ };
14
+ }
15
+ return out;
16
+ }
17
+ /**
18
+ * Merge the plugin's translations into an existing `config.i18n`, following the
19
+ * official Payload plugin i18n pattern. Translations already present on the
20
+ * incoming config win over the plugin defaults, so apps can freely override.
21
+ *
22
+ * Any `options.translations` are registered first so they participate in the
23
+ * merge (and are visible to `getTranslations` at runtime), and any
24
+ * `options.supportedLanguages` are passed straight through.
25
+ */ export function mergeThemeManagementI18n(existing, options) {
26
+ if (options?.translations) {
27
+ registerTranslations(options.translations);
28
+ }
29
+ const pluginTranslations = getThemeManagementI18nTranslations();
30
+ const existingTranslations = existing?.translations ?? {};
31
+ // Start from existing translations to preserve every other namespace/language,
32
+ // then layer the plugin namespace underneath the app's own values.
33
+ const mergedTranslations = {
34
+ ...existingTranslations
35
+ };
36
+ for (const lang of Object.keys(pluginTranslations)){
37
+ mergedTranslations[lang] = deepMerge(pluginTranslations[lang], existingTranslations[lang] ?? {});
38
+ }
39
+ const merged = {
40
+ ...existing ?? {},
41
+ translations: mergedTranslations
42
+ };
43
+ if (options?.supportedLanguages) {
44
+ ;
45
+ merged.supportedLanguages = {
46
+ ...existing?.supportedLanguages ?? {},
47
+ ...options.supportedLanguages
48
+ };
49
+ }
50
+ return merged;
51
+ }
52
+
53
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/i18n.ts"],"sourcesContent":["import type { Config } from 'payload'\nimport {\n THEME_MANAGEMENT_I18N_NAMESPACE,\n availableLanguages,\n deepMerge,\n getTranslations,\n registerTranslations,\n type DeepPartial,\n type PluginTranslations,\n} from './translations.js'\n\n/**\n * Additional or overriding translations, keyed by language code.\n * Each entry is deep-merged over the built-in English/Czech translations, so you\n * only need to provide the keys you want to add or change.\n */\nexport type ThemeManagementI18nTranslations = Record<string, DeepPartial<PluginTranslations>>\n\nexport interface ThemeManagementI18nOptions {\n /**\n * Extra languages or per-key overrides for the plugin admin UI strings.\n *\n * @example\n * i18n: {\n * translations: {\n * de: { tabLabel: 'Darstellung', ui: { lightMode: 'Heller Modus' } },\n * en: { tabLabel: 'Theme' }, // override a built-in string\n * },\n * }\n */\n translations?: ThemeManagementI18nTranslations\n /**\n * Pass-through to `config.i18n.supportedLanguages`. Provide language objects from\n * `@payloadcms/translations/languages/*` when you want the Payload admin to offer a\n * brand-new admin language (beyond the project defaults).\n *\n * @example\n * import { de } from '@payloadcms/translations/languages/de'\n * i18n: { supportedLanguages: { de } }\n */\n supportedLanguages?: Record<string, unknown>\n}\n\ntype PayloadTranslationsByLang = Record<string, Record<string, unknown>>\n\n/**\n * Build the plugin's translations in Payload's native `config.i18n.translations`\n * shape: `{ [lang]: { 'theme-management': { ...keys } } }`.\n *\n * Every language is filled out via `getTranslations`, so English acts as the\n * fallback for any missing key in another language.\n */\nexport function getThemeManagementI18nTranslations(): PayloadTranslationsByLang {\n const out: PayloadTranslationsByLang = {}\n for (const lang of availableLanguages()) {\n out[lang] = { [THEME_MANAGEMENT_I18N_NAMESPACE]: getTranslations(lang) }\n }\n return out\n}\n\n/**\n * Merge the plugin's translations into an existing `config.i18n`, following the\n * official Payload plugin i18n pattern. Translations already present on the\n * incoming config win over the plugin defaults, so apps can freely override.\n *\n * Any `options.translations` are registered first so they participate in the\n * merge (and are visible to `getTranslations` at runtime), and any\n * `options.supportedLanguages` are passed straight through.\n */\nexport function mergeThemeManagementI18n(\n existing: Config['i18n'],\n options?: ThemeManagementI18nOptions,\n): NonNullable<Config['i18n']> {\n if (options?.translations) {\n registerTranslations(options.translations)\n }\n\n const pluginTranslations = getThemeManagementI18nTranslations()\n const existingTranslations = (existing?.translations ?? {}) as PayloadTranslationsByLang\n\n // Start from existing translations to preserve every other namespace/language,\n // then layer the plugin namespace underneath the app's own values.\n const mergedTranslations: PayloadTranslationsByLang = { ...existingTranslations }\n for (const lang of Object.keys(pluginTranslations)) {\n mergedTranslations[lang] = deepMerge(\n pluginTranslations[lang] as Record<string, unknown>,\n (existingTranslations[lang] ?? {}) as Record<string, unknown>,\n )\n }\n\n const merged = {\n ...(existing ?? {}),\n translations: mergedTranslations,\n } as NonNullable<Config['i18n']>\n\n if (options?.supportedLanguages) {\n ;(merged as { supportedLanguages?: Record<string, unknown> }).supportedLanguages = {\n ...((existing as { supportedLanguages?: Record<string, unknown> } | undefined)\n ?.supportedLanguages ?? {}),\n ...options.supportedLanguages,\n }\n }\n\n return merged\n}\n"],"names":["THEME_MANAGEMENT_I18N_NAMESPACE","availableLanguages","deepMerge","getTranslations","registerTranslations","getThemeManagementI18nTranslations","out","lang","mergeThemeManagementI18n","existing","options","translations","pluginTranslations","existingTranslations","mergedTranslations","Object","keys","merged","supportedLanguages"],"mappings":"AACA,SACEA,+BAA+B,EAC/BC,kBAAkB,EAClBC,SAAS,EACTC,eAAe,EACfC,oBAAoB,QAGf,oBAAmB;AAoC1B;;;;;;CAMC,GACD,OAAO,SAASC;IACd,MAAMC,MAAiC,CAAC;IACxC,KAAK,MAAMC,QAAQN,qBAAsB;QACvCK,GAAG,CAACC,KAAK,GAAG;YAAE,CAACP,gCAAgC,EAAEG,gBAAgBI;QAAM;IACzE;IACA,OAAOD;AACT;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASE,yBACdC,QAAwB,EACxBC,OAAoC;IAEpC,IAAIA,SAASC,cAAc;QACzBP,qBAAqBM,QAAQC,YAAY;IAC3C;IAEA,MAAMC,qBAAqBP;IAC3B,MAAMQ,uBAAwBJ,UAAUE,gBAAgB,CAAC;IAEzD,+EAA+E;IAC/E,mEAAmE;IACnE,MAAMG,qBAAgD;QAAE,GAAGD,oBAAoB;IAAC;IAChF,KAAK,MAAMN,QAAQQ,OAAOC,IAAI,CAACJ,oBAAqB;QAClDE,kBAAkB,CAACP,KAAK,GAAGL,UACzBU,kBAAkB,CAACL,KAAK,EACvBM,oBAAoB,CAACN,KAAK,IAAI,CAAC;IAEpC;IAEA,MAAMU,SAAS;QACb,GAAIR,YAAY,CAAC,CAAC;QAClBE,cAAcG;IAChB;IAEA,IAAIJ,SAASQ,oBAAoB;;QAC7BD,OAA4DC,kBAAkB,GAAG;YACjF,GAAI,AAACT,UACDS,sBAAsB,CAAC,CAAC;YAC5B,GAAGR,QAAQQ,kBAAkB;QAC/B;IACF;IAEA,OAAOD;AACT"}
package/dist/index.d.ts CHANGED
@@ -13,20 +13,29 @@ export type { ThemeTab } from './fields/themeConfigurationField.js';
13
13
  export { extendedThemePresets, allExtendedThemePresets, extendedThemeToCSSVariables, } from './extended-presets.js';
14
14
  export type { ExtendedThemePreset, ShadcnColorTokens } from './extended-presets.js';
15
15
  export { applyExtendedTheme, generateExtendedThemeCSS, resetExtendedTheme, getExtendedThemeTokens, createUseExtendedTheme, getTailwindVarReferences, } from './utils/extendedThemeHelpers.js';
16
- export type { ThemeManagementPluginOptions, ThemeManagementCacheRevalidationOptions, FetchThemeConfigurationOptions, ThemeManagementLivePreviewOptions, ThemeManagementLivePreviewUrlArgs, } from './types.js';
16
+ export type { ThemeManagementPluginOptions, ThemeManagementCacheRevalidationOptions, FetchThemeConfigurationOptions, ThemeManagementLivePreviewOptions, ThemeManagementLivePreviewUrlArgs, PluginLogger, } from './types.js';
17
+ export type { SiteThemeConfiguration, ThemeColorOverride, ThemeTypographyOverride, ThemeCustomization, ThemeVisualEffects, ThemeComponentStyles, } from './payload-types.js';
17
18
  export { DEFAULT_THEME_CONFIGURATION, resolveThemeConfiguration, } from './utils/resolveThemeConfiguration.js';
18
- export type { ResolvedThemeConfiguration } from './utils/resolveThemeConfiguration.js';
19
+ export type { ResolvedThemeConfiguration, ResolvedVisualEffects, ResolvedComponentStyles, } from './utils/resolveThemeConfiguration.js';
20
+ export { allStylePresets, stylePresetCategories } from './style-presets.js';
21
+ export type { StylePreset } from './style-presets.js';
19
22
  export { generateThemeColorsCss, hexToHsl } from './utils/themeColors.js';
20
23
  export { generateThemeCSS, getThemeStyles } from './utils/themeUtils.js';
21
24
  export { getThemeHtmlAttributes } from './utils/themeHtmlAttributes.js';
25
+ export { FONT_CATALOG, buildThemeFontsHref, getFontCatalogEntry, } from './constants/themeFonts.js';
26
+ export type { FontCatalogEntry, ThemeFontLoading } from './constants/themeFonts.js';
27
+ export { themeFontEndpoints } from './endpoints/themeFonts.js';
22
28
  export { generateThemeCSS as generatePresetCSS, generateAllThemesCSS, } from './utils/generateThemeCSS.js';
23
29
  export { getThemeDynamicCSS, getAllDynamicThemesCSS } from './utils/themeCSS.js';
24
30
  export type { Mode, ThemeDefaults } from './providers/Theme/types.js';
25
- export { ThemeProvider } from './providers/Theme/index.js';
31
+ export { ThemeProvider, useTheme } from './providers/Theme/index.js';
26
32
  export { getFontLoaderCode, getThemeFontFamilies, ThemeFontProvider, useThemeFonts, FONT_IMPORT_MAP, } from './providers/font-loader.js';
27
33
  export declare const ThemeManagementPlugin: (options?: ThemeManagementPluginOptions) => Plugin;
28
34
  /** @deprecated use {@link themeManagementPlugin} */
29
35
  export declare const themeConfigurationPlugin: (options?: ThemeManagementPluginOptions) => Plugin;
30
- export { translations, getTranslations, registerTranslations, availableLanguages, } from './translations.js';
36
+ export { translations, getTranslations, registerTranslations, availableLanguages, THEME_MANAGEMENT_I18N_NAMESPACE, } from './translations.js';
37
+ export type { PluginTranslations, Language, DeepPartial } from './translations.js';
38
+ export { mergeThemeManagementI18n, getThemeManagementI18nTranslations, } from './i18n.js';
39
+ export type { ThemeManagementI18nOptions, ThemeManagementI18nTranslations, } from './i18n.js';
31
40
  export default themeManagementPlugin;
32
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiD,MAAM,EAAa,MAAM,SAAS,CAAA;AAG/F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAG/C,OAAO,KAAK,EACV,8BAA8B,EAG9B,4BAA4B,EAC7B,MAAM,YAAY,CAAA;AA0nBnB,eAAO,MAAM,qBAAqB,GAAI,UAAS,4BAAiC,KAAG,MAyOlF,CAAA;AAED,KAAK,iBAAiB,GAAG,MAAM,GAAG,8BAA8B,CAAA;AAEhE,eAAO,MAAM,uBAAuB,GAClC,UAAU,iBAAiB,KAC1B,OAAO,CAAC,sBAAsB,GAAG,IAAI,CA6EvC,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,KAAG,WAAW,GAAG,IAEhE,CAAA;AAED,eAAO,MAAM,wBAAwB,QAAO,WAAW,EAEtD,CAAA;AAED,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnE,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACtE,YAAY,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EAAE,mBAAmB,EAAE,iBAA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5aU,4BAA4B,KAAQ,MA4atB,CAAA;AAG7D,OAAO,EACL,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,+BAA+B,GAChC,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAGlF,OAAO,EACL,wBAAwB,EACxB,kCAAkC,GACnC,MAAM,WAAW,CAAA;AAClB,YAAY,EACV,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,WAAW,CAAA;AAElB,eAAe,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -1,5 +1,8 @@
1
+ import { themeFontEndpoints } from './endpoints/themeFonts.js';
2
+ import { DEFAULT_LIVE_PREVIEW_BREAKPOINTS } from './constants/devicePreviews.js';
1
3
  import { createThemeConfigurationField } from './fields/themeConfigurationField.js';
2
4
  import { allThemePresets } from './presets.js';
5
+ import { mergeThemeManagementI18n } from './i18n.js';
3
6
  import { getTranslations, translations } from './translations.js';
4
7
  const THEME_FIELD_NAME = 'themeConfiguration';
5
8
  /**
@@ -46,7 +49,7 @@ const THEME_FIELD_NAME = 'themeConfiguration';
46
49
  const tabsField = findTabsField(sanitizedFields);
47
50
  if (!tabsField || !tabsField.tabs) {
48
51
  if (enableLogging) {
49
- console.warn('🎨 Theme Management Plugin: No tabs field found. Creating a new tabs structure.');
52
+ console.warn('Theme Management Plugin: No tabs field found. Creating a new tabs structure.');
50
53
  }
51
54
  // If no tabs exist, create a basic tabs structure with just the theme tab
52
55
  const newTabsField = {
@@ -68,7 +71,7 @@ const THEME_FIELD_NAME = 'themeConfiguration';
68
71
  themeTab
69
72
  ];
70
73
  if (enableLogging) {
71
- console.log('🎨 Theme Management Plugin: injecting Appearance Settings tab');
74
+ console.log('Theme Management Plugin: injecting Appearance Settings tab');
72
75
  }
73
76
  // Update the tabs field
74
77
  const updatedTabsField = {
@@ -81,7 +84,8 @@ const THEME_FIELD_NAME = 'themeConfiguration';
81
84
  const ensureCollectionsArray = (collections)=>Array.isArray(collections) ? collections : [];
82
85
  const ensureEndpointsArray = (endpoints)=>Array.isArray(endpoints) ? endpoints : [];
83
86
  const normalizeLivePreviewOptions = (livePreview)=>{
84
- if (livePreview === false) {
87
+ if (!livePreview) {
88
+ // undefined or false → live preview not configured; show ThemePreviewField instead
85
89
  return {
86
90
  enabled: false,
87
91
  injectRoute: false,
@@ -94,7 +98,7 @@ const normalizeLivePreviewOptions = (livePreview)=>{
94
98
  breakpoints: undefined
95
99
  };
96
100
  }
97
- const raw = typeof livePreview === 'object' && livePreview ? livePreview : {};
101
+ const raw = typeof livePreview === 'object' ? livePreview : {};
98
102
  return {
99
103
  enabled: raw.enabled ?? true,
100
104
  injectRoute: raw.injectRoute ?? false,
@@ -104,7 +108,7 @@ const normalizeLivePreviewOptions = (livePreview)=>{
104
108
  fallbackToFirstPage: raw.fallbackToFirstPage ?? true,
105
109
  tenantField: raw.tenantField ?? 'tenant',
106
110
  tenantQueryParam: raw.tenantQueryParam ?? 'tenant',
107
- breakpoints: raw.breakpoints,
111
+ breakpoints: raw.breakpoints ?? DEFAULT_LIVE_PREVIEW_BREAKPOINTS,
108
112
  url: raw.url
109
113
  };
110
114
  };
@@ -244,7 +248,7 @@ const resolveLivePreviewUrl = async (args)=>{
244
248
  return buildDefaultPreviewPath(resolvedPageSlug, tenantSlug, livePreview.tenantQueryParam);
245
249
  } catch (error) {
246
250
  if (enableLogging) {
247
- req.payload.logger?.warn?.('🎨 Theme Management Plugin: live preview URL fallback used', error);
251
+ req.payload.logger?.warn?.('Theme Management Plugin: live preview URL fallback used', error);
248
252
  }
249
253
  return buildDefaultPreviewPath(livePreview.pageSlug, tenantSlug, livePreview.tenantQueryParam);
250
254
  }
@@ -303,11 +307,11 @@ const executeThemeRevalidation = async (options)=>{
303
307
  tags.forEach((tag)=>revalidateTag(tag));
304
308
  paths.forEach((path)=>revalidatePath(path));
305
309
  if (enableLogging) {
306
- logger?.info?.(`🎨 Theme Management Plugin: revalidated cache tags=[${tags.join(', ')}] paths=[${paths.join(', ')}]`);
310
+ logger?.info?.(`Theme Management Plugin: revalidated cache tags=[${tags.join(', ')}] paths=[${paths.join(', ')}]`);
307
311
  }
308
312
  } catch (error) {
309
313
  if (enableLogging) {
310
- logger?.error?.('🎨 Theme Management Plugin: cache invalidation failed:', error);
314
+ logger?.error?.('Theme Management Plugin: cache invalidation failed:', error);
311
315
  }
312
316
  throw error;
313
317
  }
@@ -367,7 +371,7 @@ const createLivePreviewEndpoint = (options)=>{
367
371
  // Redirect to the actual client page (standard Payload live preview behavior)
368
372
  const destination = buildDefaultPreviewPath(pageSlug, tenantSlug, livePreview.tenantQueryParam);
369
373
  if (enableLogging) {
370
- console.log('🎨 Theme Management Plugin: live preview redirect', destination);
374
+ console.log('Theme Management Plugin: live preview redirect', destination);
371
375
  }
372
376
  return {
373
377
  status: 307,
@@ -446,7 +450,7 @@ const jsonResponse = (body, status = 200)=>{
446
450
  export const themeManagementPlugin = (options = {})=>{
447
451
  return (config)=>{
448
452
  const { enabled = true, targetCollection = 'site-settings', useStandaloneCollection = false, standaloneCollectionSlug = 'appearance-settings', // Allow either string or localized object; default comes from plugin translations
449
- standaloneCollectionLabel = getTranslations().standaloneCollectionLabel, themePresets = allThemePresets, defaultTheme = 'cool', includeColorModeToggle = true, includeCustomCSS = true, includeBrandIdentity = false, enableAdvancedFeatures = true, enableLogging = false, livePreview = true, cacheRevalidation } = options;
453
+ standaloneCollectionLabel = getTranslations().standaloneCollectionLabel, themePresets = allThemePresets, defaultTheme = 'cool', includeColorModeToggle = true, includeCustomCSS = true, customThemeConfigurationFields, customThemeConfigurationSections, includeBrandIdentity = false, enableAdvancedFeatures = true, enableLogging = false, livePreview = true, cacheRevalidation, i18n } = options;
450
454
  const normalizedLivePreview = normalizeLivePreviewOptions(livePreview);
451
455
  const normalizedCacheRevalidation = normalizeCacheRevalidationOptions({
452
456
  cacheRevalidation,
@@ -455,23 +459,34 @@ export const themeManagementPlugin = (options = {})=>{
455
459
  });
456
460
  if (!enabled) {
457
461
  if (enableLogging) {
458
- console.log('🎨 Theme Management Plugin: disabled via options, skipping.');
462
+ console.log('Theme Management Plugin: disabled via options, skipping.');
459
463
  }
460
464
  return config;
461
465
  }
466
+ // Register the plugin's translations into Payload's native i18n
467
+ // (`theme-management` namespace), merging in any user-provided extensions or
468
+ // overrides. This config is used as the base for every return path below.
469
+ const configWithI18n = {
470
+ ...config,
471
+ i18n: mergeThemeManagementI18n(config.i18n, i18n)
472
+ };
462
473
  const themeTab = createThemeConfigurationField({
463
474
  themePresets,
464
475
  defaultTheme,
465
476
  includeColorModeToggle,
466
477
  includeCustomCSS,
478
+ customThemeConfigurationFields,
479
+ customThemeConfigurationSections,
467
480
  includeBrandIdentity: includeBrandIdentity ?? false,
468
481
  enableAdvancedFeatures,
469
- useThemePreviewField: !normalizedLivePreview.enabled
482
+ // Always show the static ModePreview panel; it hides at runtime when the user
483
+ // actively enters livePreview mode (isLivePreviewing = true in context).
484
+ useThemePreviewField: true
470
485
  });
471
486
  // If using standalone collection, create a new global
472
487
  if (useStandaloneCollection) {
473
488
  if (enableLogging) {
474
- console.log(`🎨 Theme Management Plugin: creating standalone global "${standaloneCollectionSlug}"`);
489
+ console.log(`Theme Management Plugin: creating standalone global "${standaloneCollectionSlug}"`);
475
490
  }
476
491
  // Extract the fields from the tab directly (no wrapping in group)
477
492
  const tabFields = themeTab.fields ?? [];
@@ -548,16 +563,16 @@ export const themeManagementPlugin = (options = {})=>{
548
563
  ]
549
564
  }
550
565
  };
551
- const globals = Array.isArray(config.globals) ? config.globals : [];
566
+ const globals = Array.isArray(configWithI18n.globals) ? configWithI18n.globals : [];
552
567
  // Check if global already exists
553
568
  const existingIndex = globals.findIndex((g)=>g.slug === standaloneCollectionSlug);
554
569
  if (existingIndex !== -1) {
555
570
  if (enableLogging) {
556
- console.warn(`🎨 Theme Management Plugin: global "${standaloneCollectionSlug}" already exists, skipping creation.`);
571
+ console.warn(`Theme Management Plugin: global "${standaloneCollectionSlug}" already exists, skipping creation.`);
557
572
  }
558
- return config;
573
+ return configWithI18n;
559
574
  }
560
- const currentEndpoints = ensureEndpointsArray(config.endpoints);
575
+ const currentEndpoints = ensureEndpointsArray(configWithI18n.endpoints);
561
576
  const livePreviewEndpoint = createLivePreviewEndpoint({
562
577
  livePreview: normalizedLivePreview,
563
578
  enableLogging
@@ -568,8 +583,11 @@ export const themeManagementPlugin = (options = {})=>{
568
583
  enableLogging
569
584
  });
570
585
  endpoints = mergeEndpoint(endpoints, cacheEndpoint);
586
+ themeFontEndpoints.forEach((endpoint)=>{
587
+ endpoints = mergeEndpoint(endpoints, endpoint);
588
+ });
571
589
  return {
572
- ...config,
590
+ ...configWithI18n,
573
591
  endpoints,
574
592
  globals: [
575
593
  ...globals,
@@ -579,13 +597,13 @@ export const themeManagementPlugin = (options = {})=>{
579
597
  }
580
598
  // Otherwise, add as tab to existing collection
581
599
  let collectionTouched = false;
582
- const collections = ensureCollectionsArray(config.collections).map((collection)=>{
600
+ const collections = ensureCollectionsArray(configWithI18n.collections).map((collection)=>{
583
601
  if (collection.slug !== targetCollection) {
584
602
  return collection;
585
603
  }
586
604
  collectionTouched = true;
587
605
  if (enableLogging) {
588
- console.log(`🎨 Theme Management Plugin: enhancing collection "${collection.slug}"`);
606
+ console.log(`Theme Management Plugin: enhancing collection "${collection.slug}"`);
589
607
  }
590
608
  const existingFields = Array.isArray(collection.fields) ? collection.fields : [];
591
609
  const fields = injectThemeTab(existingFields, themeTab, enableLogging);
@@ -601,11 +619,11 @@ export const themeManagementPlugin = (options = {})=>{
601
619
  });
602
620
  if (!collectionTouched) {
603
621
  if (enableLogging) {
604
- console.warn(`🎨 Theme Management Plugin: collection "${targetCollection}" was not found, leaving config untouched.`);
622
+ console.warn(`Theme Management Plugin: collection "${targetCollection}" was not found, leaving config untouched.`);
605
623
  }
606
- return config;
624
+ return configWithI18n;
607
625
  }
608
- const currentEndpoints = ensureEndpointsArray(config.endpoints);
626
+ const currentEndpoints = ensureEndpointsArray(configWithI18n.endpoints);
609
627
  const livePreviewEndpoint = createLivePreviewEndpoint({
610
628
  livePreview: normalizedLivePreview,
611
629
  enableLogging
@@ -616,8 +634,11 @@ export const themeManagementPlugin = (options = {})=>{
616
634
  enableLogging
617
635
  });
618
636
  endpoints = mergeEndpoint(endpoints, cacheEndpoint);
637
+ themeFontEndpoints.forEach((endpoint)=>{
638
+ endpoints = mergeEndpoint(endpoints, endpoint);
639
+ });
619
640
  return {
620
- ...config,
641
+ ...configWithI18n,
621
642
  endpoints,
622
643
  collections
623
644
  };
@@ -627,7 +648,7 @@ export const fetchThemeConfiguration = async (options)=>{
627
648
  const normalizedOptions = typeof options === 'string' ? {
628
649
  tenantSlug: options
629
650
  } : options ?? {};
630
- const { tenantSlug, collectionSlug = 'site-settings', depth, locale, draft, queryParams = {}, useGlobal = false } = normalizedOptions;
651
+ const { tenantSlug, collectionSlug = 'site-settings', depth, locale, draft, queryParams = {}, useGlobal = false, signal } = normalizedOptions;
631
652
  try {
632
653
  if (useGlobal) {
633
654
  // Fetch from global endpoint
@@ -644,7 +665,9 @@ export const fetchThemeConfiguration = async (options)=>{
644
665
  });
645
666
  const queryString = params.toString();
646
667
  const url = `/api/globals/${collectionSlug}${queryString ? `?${queryString}` : ''}`;
647
- const response = await fetch(url);
668
+ const response = await fetch(url, {
669
+ signal
670
+ });
648
671
  if (!response.ok) {
649
672
  throw new Error(`Failed to fetch theme global (status ${response.status})`);
650
673
  }
@@ -665,7 +688,9 @@ export const fetchThemeConfiguration = async (options)=>{
665
688
  params.set(key, String(value));
666
689
  });
667
690
  const url = `/api/${collectionSlug}?${params.toString()}`;
668
- const response = await fetch(url);
691
+ const response = await fetch(url, {
692
+ signal
693
+ });
669
694
  if (!response.ok) {
670
695
  throw new Error(`Failed to fetch theme configuration (status ${response.status})`);
671
696
  }
@@ -688,13 +713,16 @@ export { defaultThemePresets, allThemePresets } from './presets.js';
688
713
  export { extendedThemePresets, allExtendedThemePresets, extendedThemeToCSSVariables } from './extended-presets.js';
689
714
  export { applyExtendedTheme, generateExtendedThemeCSS, resetExtendedTheme, getExtendedThemeTokens, createUseExtendedTheme, getTailwindVarReferences } from './utils/extendedThemeHelpers.js';
690
715
  export { DEFAULT_THEME_CONFIGURATION, resolveThemeConfiguration } from './utils/resolveThemeConfiguration.js';
716
+ export { allStylePresets, stylePresetCategories } from './style-presets.js';
691
717
  export { generateThemeColorsCss, hexToHsl } from './utils/themeColors.js';
692
718
  export { generateThemeCSS, getThemeStyles } from './utils/themeUtils.js';
693
719
  export { getThemeHtmlAttributes } from './utils/themeHtmlAttributes.js';
720
+ export { FONT_CATALOG, buildThemeFontsHref, getFontCatalogEntry } from './constants/themeFonts.js';
721
+ export { themeFontEndpoints } from './endpoints/themeFonts.js';
694
722
  // Dynamic theme CSS generation
695
723
  export { generateThemeCSS as generatePresetCSS, generateAllThemesCSS } from './utils/generateThemeCSS.js';
696
724
  export { getThemeDynamicCSS, getAllDynamicThemesCSS } from './utils/themeCSS.js';
697
- export { ThemeProvider } from './providers/Theme/index.js';
725
+ export { ThemeProvider, useTheme } from './providers/Theme/index.js';
698
726
  // Font loading utilities for Next.js integration
699
727
  export { getFontLoaderCode, getThemeFontFamilies, ThemeFontProvider, useThemeFonts, FONT_IMPORT_MAP } from './providers/font-loader.js';
700
728
  // Note: Do NOT re-export client components from the root entry to avoid
@@ -703,7 +731,9 @@ export { getFontLoaderCode, getThemeFontFamilies, ThemeFontProvider, useThemeFon
703
731
  export const ThemeManagementPlugin = themeManagementPlugin;
704
732
  /** @deprecated use {@link themeManagementPlugin} */ export const themeConfigurationPlugin = themeManagementPlugin;
705
733
  // Export plugin translations for consumers to merge into their payload translations
706
- export { translations, getTranslations, registerTranslations, availableLanguages } from './translations.js';
734
+ export { translations, getTranslations, registerTranslations, availableLanguages, THEME_MANAGEMENT_I18N_NAMESPACE } from './translations.js';
735
+ // Native Payload i18n helpers (theme-management namespace)
736
+ export { mergeThemeManagementI18n, getThemeManagementI18nTranslations } from './i18n.js';
707
737
  export default themeManagementPlugin;
708
738
 
709
739
  //# sourceMappingURL=index.js.map