@kilivi/payloadcms-theme-management 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ServerThemeInjector.d.ts +1 -1
- package/dist/components/ServerThemeInjector.d.ts.map +1 -1
- package/dist/components/{ServerThemeInjector.jsx → ServerThemeInjector.js} +47 -34
- package/dist/components/ServerThemeInjector.js.map +1 -0
- package/dist/components/ThemePreview.js +318 -0
- package/dist/components/ThemePreview.js.map +1 -0
- package/dist/components/typographyPreviewUtils.js +12 -17
- package/dist/components/typographyPreviewUtils.js.map +1 -1
- package/dist/constants/themeFonts.js +94 -24
- package/dist/constants/themeFonts.js.map +1 -1
- package/dist/fields/ColorPickerField.js +332 -0
- package/dist/fields/ColorPickerField.js.map +1 -0
- package/dist/fields/RadiusField.js +174 -0
- package/dist/fields/RadiusField.js.map +1 -0
- package/dist/fields/ThemeColorPickerField.js +163 -0
- package/dist/fields/ThemeColorPickerField.js.map +1 -0
- package/dist/fields/ThemePreviewField.js +558 -0
- package/dist/fields/ThemePreviewField.js.map +1 -0
- package/dist/fields/ThemeTokenSelectField.js +209 -0
- package/dist/fields/ThemeTokenSelectField.js.map +1 -0
- package/dist/fields/colorModeFields.js +167 -73
- package/dist/fields/colorModeFields.js.map +1 -1
- package/dist/fields/themeConfigurationField.d.ts +1 -1
- package/dist/fields/themeConfigurationField.d.ts.map +1 -1
- package/dist/fields/themeConfigurationField.js +224 -131
- package/dist/fields/themeConfigurationField.js.map +1 -1
- package/dist/index.d.ts +17 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -52
- package/dist/index.js.map +1 -1
- package/dist/payload-types.js +2 -2
- package/dist/payload-types.js.map +1 -1
- package/dist/plugin.d.ts +1 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +2 -1
- package/dist/plugin.js.map +1 -1
- package/dist/presets.js +66 -65
- package/dist/presets.js.map +1 -1
- package/dist/providers/Theme/index.d.ts +1 -1
- package/dist/providers/Theme/index.d.ts.map +1 -1
- package/dist/providers/Theme/{index.jsx → index.js} +61 -31
- package/dist/providers/Theme/index.js.map +1 -0
- package/dist/providers/Theme/shared.d.ts +1 -1
- package/dist/providers/Theme/shared.d.ts.map +1 -1
- package/dist/providers/Theme/shared.js +34 -9
- package/dist/providers/Theme/shared.js.map +1 -1
- package/dist/providers/Theme/themeConfig.d.ts +1 -1
- package/dist/providers/Theme/themeConfig.d.ts.map +1 -1
- package/dist/providers/Theme/themeConfig.js +37 -36
- package/dist/providers/Theme/themeConfig.js.map +1 -1
- package/dist/providers/Theme/types.js +15 -13
- package/dist/providers/Theme/types.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -2
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/resolveThemeConfiguration.d.ts +3 -3
- package/dist/utils/resolveThemeConfiguration.d.ts.map +1 -1
- package/dist/utils/resolveThemeConfiguration.js +53 -34
- package/dist/utils/resolveThemeConfiguration.js.map +1 -1
- package/dist/utils/themeAssets.d.ts +1 -1
- package/dist/utils/themeAssets.d.ts.map +1 -1
- package/dist/utils/themeAssets.js +4 -4
- package/dist/utils/themeAssets.js.map +1 -1
- package/dist/utils/themeColors.js +95 -41
- package/dist/utils/themeColors.js.map +1 -1
- package/dist/utils/themeUtils.d.ts +2 -2
- package/dist/utils/themeUtils.d.ts.map +1 -1
- package/dist/utils/themeUtils.js +32 -47
- package/dist/utils/themeUtils.js.map +1 -1
- package/package.json +13 -5
- package/dist/components/ServerThemeInjector.jsx.map +0 -1
- package/dist/components/ThemePreview.jsx +0 -231
- package/dist/components/ThemePreview.jsx.map +0 -1
- package/dist/fields/ColorPickerField.jsx +0 -205
- package/dist/fields/ColorPickerField.jsx.map +0 -1
- package/dist/fields/RadiusField.jsx +0 -123
- package/dist/fields/RadiusField.jsx.map +0 -1
- package/dist/fields/ThemeColorPickerField.jsx +0 -110
- package/dist/fields/ThemeColorPickerField.jsx.map +0 -1
- package/dist/fields/ThemePreviewField.jsx +0 -420
- package/dist/fields/ThemePreviewField.jsx.map +0 -1
- package/dist/fields/ThemeTokenSelectField.jsx +0 -151
- package/dist/fields/ThemeTokenSelectField.jsx.map +0 -1
- package/dist/providers/Theme/index.jsx.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import type { Plugin } from 'payload';
|
|
2
|
-
import type { SiteThemeConfiguration } from './payload-types';
|
|
3
|
-
import type { ThemePreset } from './presets';
|
|
4
|
-
import type { FetchThemeConfigurationOptions,
|
|
5
|
-
export declare const
|
|
2
|
+
import type { SiteThemeConfiguration } from './payload-types.js';
|
|
3
|
+
import type { ThemePreset } from './presets.js';
|
|
4
|
+
import type { FetchThemeConfigurationOptions, ThemeManagementPluginOptions } from './types.js';
|
|
5
|
+
export declare const themeManagementPlugin: (options?: ThemeManagementPluginOptions) => Plugin;
|
|
6
6
|
type FetchOptionsInput = string | FetchThemeConfigurationOptions;
|
|
7
7
|
export declare const fetchThemeConfiguration: (options?: FetchOptionsInput) => Promise<SiteThemeConfiguration | null>;
|
|
8
8
|
export declare const getThemePreset: (themeName: string) => ThemePreset | null;
|
|
9
9
|
export declare const getAvailableThemePresets: () => ThemePreset[];
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export {
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
export
|
|
10
|
+
export { defaultThemePresets } from './presets.js';
|
|
11
|
+
export type { ThemePreset, ThemeTypographyPreset } from './presets.js';
|
|
12
|
+
export type { ThemeManagementPluginOptions, FetchThemeConfigurationOptions } from './types.js';
|
|
13
|
+
export { DEFAULT_THEME_CONFIGURATION, resolveThemeConfiguration, } from './utils/resolveThemeConfiguration.js';
|
|
14
|
+
export { generateThemeColorsCss, hexToHsl } from './utils/themeColors.js';
|
|
15
|
+
export { generateThemeCSS, getThemeStyles } from './utils/themeUtils.js';
|
|
16
|
+
export { ServerThemeInjector } from './components/ServerThemeInjector.js';
|
|
17
|
+
export type { Mode, ThemeDefaults } from './providers/Theme/types.js';
|
|
18
|
+
export { ThemeProvider } from './providers/Theme/index.js';
|
|
19
|
+
export declare const ThemeManagementPlugin: (options?: ThemeManagementPluginOptions) => Plugin;
|
|
20
|
+
/** @deprecated use {@link themeManagementPlugin} */
|
|
21
|
+
export declare const themeConfigurationPlugin: (options?: ThemeManagementPluginOptions) => Plugin;
|
|
22
|
+
export default themeManagementPlugin;
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,MAAM,EAAE,MAAM,SAAS,CAAA;AAEtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,MAAM,EAAE,MAAM,SAAS,CAAA;AAEtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EACV,8BAA8B,EAC9B,4BAA4B,EAC7B,MAAM,YAAY,CAAA;AA2BnB,eAAO,MAAM,qBAAqB,GAAI,UAAS,4BAAiC,KAAG,MAqElF,CAAA;AAED,KAAK,iBAAiB,GAAG,MAAM,GAAG,8BAA8B,CAAA;AAEhE,eAAO,MAAM,uBAAuB,GAClC,UAAU,iBAAiB,KAC1B,OAAO,CAAC,sBAAsB,GAAG,IAAI,CA8CvC,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,WAAW,MAAM,KAAG,WAAW,GAAG,IAEhE,CAAA;AAED,eAAO,MAAM,wBAAwB,QAAO,WAAW,EAEtD,CAAA;AAID,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACtE,YAAY,EAAE,4BAA4B,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAA;AAC9F,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACzE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAEzE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE1D,eAAO,MAAM,qBAAqB,aAnJa,4BAA4B,KAAQ,MAmJzB,CAAA;AAC1D,oDAAoD;AACpD,eAAO,MAAM,wBAAwB,aArJU,4BAA4B,KAAQ,MAqJtB,CAAA;AAE7D,eAAe,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import { createThemeConfigurationField } from './fields/themeConfigurationField';
|
|
2
|
-
import { defaultThemePresets } from './presets';
|
|
1
|
+
import { createThemeConfigurationField } from './fields/themeConfigurationField.js';
|
|
2
|
+
import { defaultThemePresets } from './presets.js';
|
|
3
3
|
const THEME_FIELD_NAME = 'themeConfiguration';
|
|
4
|
-
const removeExistingThemeField = (fields = [])
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
const upsertThemeField = (fields, themeField, enableLogging)
|
|
4
|
+
const removeExistingThemeField = (fields = [])=>fields.filter((field)=>{
|
|
5
|
+
const candidate = field;
|
|
6
|
+
return candidate?.name !== THEME_FIELD_NAME;
|
|
7
|
+
});
|
|
8
|
+
const upsertThemeField = (fields, themeField, enableLogging)=>{
|
|
9
9
|
const sanitized = removeExistingThemeField(fields ?? []);
|
|
10
10
|
if (enableLogging) {
|
|
11
|
-
console.log('🎨 Theme
|
|
11
|
+
console.log('🎨 Theme Management Plugin: injecting theme configuration field');
|
|
12
12
|
}
|
|
13
|
-
return [
|
|
13
|
+
return [
|
|
14
|
+
...sanitized,
|
|
15
|
+
themeField
|
|
16
|
+
];
|
|
14
17
|
};
|
|
15
|
-
const ensureCollectionsArray = (collections)
|
|
16
|
-
export const
|
|
17
|
-
return (config)
|
|
18
|
-
const { enabled = true, targetCollection = 'site-settings', themePresets = defaultThemePresets, defaultTheme = 'cool', includeColorModeToggle = true, includeCustomCSS = true, includeBrandIdentity = false, enableAdvancedFeatures = true, enableLogging = false
|
|
18
|
+
const ensureCollectionsArray = (collections)=>Array.isArray(collections) ? collections : [];
|
|
19
|
+
export const themeManagementPlugin = (options = {})=>{
|
|
20
|
+
return (config)=>{
|
|
21
|
+
const { enabled = true, targetCollection = 'site-settings', themePresets = defaultThemePresets, defaultTheme = 'cool', includeColorModeToggle = true, includeCustomCSS = true, includeBrandIdentity = false, enableAdvancedFeatures = true, enableLogging = false } = options;
|
|
19
22
|
if (!enabled) {
|
|
20
23
|
if (enableLogging) {
|
|
21
|
-
console.log('🎨 Theme
|
|
24
|
+
console.log('🎨 Theme Management Plugin: disabled via options, skipping.');
|
|
22
25
|
}
|
|
23
26
|
return config;
|
|
24
27
|
}
|
|
@@ -28,53 +31,50 @@ export const themeConfigurationPlugin = (options = {}) => {
|
|
|
28
31
|
includeColorModeToggle,
|
|
29
32
|
includeCustomCSS,
|
|
30
33
|
includeBrandIdentity: includeBrandIdentity ?? false,
|
|
31
|
-
enableAdvancedFeatures
|
|
34
|
+
enableAdvancedFeatures
|
|
32
35
|
});
|
|
33
36
|
let collectionTouched = false;
|
|
34
|
-
const collections = ensureCollectionsArray(config.collections).map((collection)
|
|
37
|
+
const collections = ensureCollectionsArray(config.collections).map((collection)=>{
|
|
35
38
|
if (collection.slug !== targetCollection) {
|
|
36
39
|
return collection;
|
|
37
40
|
}
|
|
38
41
|
collectionTouched = true;
|
|
39
42
|
if (enableLogging) {
|
|
40
|
-
console.log(`🎨 Theme
|
|
43
|
+
console.log(`🎨 Theme Management Plugin: enhancing collection "${collection.slug}"`);
|
|
41
44
|
}
|
|
42
45
|
const existingFields = Array.isArray(collection.fields) ? collection.fields : [];
|
|
43
46
|
const fields = upsertThemeField(existingFields, themeField, enableLogging);
|
|
44
47
|
return {
|
|
45
48
|
...collection,
|
|
46
|
-
fields
|
|
49
|
+
fields
|
|
47
50
|
};
|
|
48
51
|
});
|
|
49
52
|
if (!collectionTouched) {
|
|
50
53
|
if (enableLogging) {
|
|
51
|
-
console.warn(`🎨 Theme
|
|
54
|
+
console.warn(`🎨 Theme Management Plugin: collection "${targetCollection}" was not found, leaving config untouched.`);
|
|
52
55
|
}
|
|
53
56
|
return config;
|
|
54
57
|
}
|
|
55
58
|
return {
|
|
56
59
|
...config,
|
|
57
|
-
collections
|
|
60
|
+
collections
|
|
58
61
|
};
|
|
59
62
|
};
|
|
60
63
|
};
|
|
61
|
-
export const fetchThemeConfiguration = async (options)
|
|
62
|
-
const normalizedOptions = typeof options === 'string'
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const { tenantSlug, collectionSlug = 'site-settings', depth, locale, draft, queryParams = {}
|
|
66
|
-
const params = new URLSearchParams({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
if (locale)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Object.entries(queryParams).forEach(([key, value]) => {
|
|
76
|
-
if (value === undefined)
|
|
77
|
-
return;
|
|
64
|
+
export const fetchThemeConfiguration = async (options)=>{
|
|
65
|
+
const normalizedOptions = typeof options === 'string' ? {
|
|
66
|
+
tenantSlug: options
|
|
67
|
+
} : options ?? {};
|
|
68
|
+
const { tenantSlug, collectionSlug = 'site-settings', depth, locale, draft, queryParams = {} } = normalizedOptions;
|
|
69
|
+
const params = new URLSearchParams({
|
|
70
|
+
limit: '1'
|
|
71
|
+
});
|
|
72
|
+
if (typeof depth === 'number') params.set('depth', String(depth));
|
|
73
|
+
if (tenantSlug) params.set('tenant', tenantSlug);
|
|
74
|
+
if (locale) params.set('locale', locale);
|
|
75
|
+
if (draft) params.set('draft', 'true');
|
|
76
|
+
Object.entries(queryParams).forEach(([key, value])=>{
|
|
77
|
+
if (value === undefined) return;
|
|
78
78
|
params.set(key, String(value));
|
|
79
79
|
});
|
|
80
80
|
const url = `/api/${collectionSlug}?${params.toString()}`;
|
|
@@ -83,28 +83,28 @@ export const fetchThemeConfiguration = async (options) => {
|
|
|
83
83
|
if (!response.ok) {
|
|
84
84
|
throw new Error(`Failed to fetch theme configuration (status ${response.status})`);
|
|
85
85
|
}
|
|
86
|
-
const data =
|
|
86
|
+
const data = await response.json();
|
|
87
87
|
const doc = data.docs?.[0];
|
|
88
88
|
return doc?.themeConfiguration ?? null;
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
89
|
+
} catch (error) {
|
|
91
90
|
console.warn('Failed to fetch theme configuration:', error);
|
|
92
91
|
return null;
|
|
93
92
|
}
|
|
94
93
|
};
|
|
95
|
-
export const getThemePreset = (themeName)
|
|
96
|
-
return defaultThemePresets.find((preset)
|
|
94
|
+
export const getThemePreset = (themeName)=>{
|
|
95
|
+
return defaultThemePresets.find((preset)=>preset.name === themeName) || null;
|
|
97
96
|
};
|
|
98
|
-
export const getAvailableThemePresets = ()
|
|
97
|
+
export const getAvailableThemePresets = ()=>{
|
|
99
98
|
return defaultThemePresets;
|
|
100
99
|
};
|
|
101
|
-
export
|
|
102
|
-
export
|
|
103
|
-
export
|
|
104
|
-
export {
|
|
105
|
-
export {
|
|
106
|
-
export {
|
|
107
|
-
export
|
|
108
|
-
|
|
109
|
-
export
|
|
100
|
+
export { defaultThemePresets } from './presets.js';
|
|
101
|
+
export { DEFAULT_THEME_CONFIGURATION, resolveThemeConfiguration } from './utils/resolveThemeConfiguration.js';
|
|
102
|
+
export { generateThemeColorsCss, hexToHsl } from './utils/themeColors.js';
|
|
103
|
+
export { generateThemeCSS, getThemeStyles } from './utils/themeUtils.js';
|
|
104
|
+
export { ServerThemeInjector } from './components/ServerThemeInjector.js';
|
|
105
|
+
export { ThemeProvider } from './providers/Theme/index.js';
|
|
106
|
+
export const ThemeManagementPlugin = themeManagementPlugin;
|
|
107
|
+
/** @deprecated use {@link themeManagementPlugin} */ export const themeConfigurationPlugin = themeManagementPlugin;
|
|
108
|
+
export default themeManagementPlugin;
|
|
109
|
+
|
|
110
110
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config, Field, Plugin } from 'payload'\nimport { createThemeConfigurationField } from './fields/themeConfigurationField.js'\nimport type { SiteThemeConfiguration } from './payload-types.js'\nimport type { ThemePreset } from './presets.js'\nimport { defaultThemePresets } from './presets.js'\nimport type {\n FetchThemeConfigurationOptions,\n ThemeManagementPluginOptions,\n} from './types.js'\n\nconst THEME_FIELD_NAME = 'themeConfiguration'\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\nconst upsertThemeField = (\n fields: Field[] | undefined,\n themeField: Field,\n enableLogging: boolean,\n): Field[] => {\n const sanitized = removeExistingThemeField(fields ?? [])\n\n if (enableLogging) {\n console.log('🎨 Theme Management Plugin: injecting theme configuration field')\n }\n\n return [...sanitized, themeField]\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 themePresets = defaultThemePresets,\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 themeField = createThemeConfigurationField({\n themePresets,\n defaultTheme,\n includeColorModeToggle,\n includeCustomCSS,\n includeBrandIdentity: includeBrandIdentity ?? false,\n enableAdvancedFeatures,\n })\n\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(\n `🎨 Theme Management Plugin: enhancing collection \"${collection.slug}\"`,\n )\n }\n\n const existingFields = Array.isArray(collection.fields) ? collection.fields : []\n\n const fields = upsertThemeField(existingFields, themeField, 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 =\n typeof options === 'string'\n ? { tenantSlug: options }\n : options ?? {}\n\n const {\n tenantSlug,\n collectionSlug = 'site-settings',\n depth,\n locale,\n draft,\n queryParams = {},\n } = normalizedOptions\n\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 try {\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 } 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 defaultThemePresets.find((preset) => preset.name === themeName) || null\n}\n\nexport const getAvailableThemePresets = (): ThemePreset[] => {\n return defaultThemePresets\n}\n\n\n\nexport { defaultThemePresets } from './presets.js'\nexport type { ThemePreset, ThemeTypographyPreset } from './presets.js'\nexport type { ThemeManagementPluginOptions, FetchThemeConfigurationOptions } from './types.js'\nexport {\n DEFAULT_THEME_CONFIGURATION,\n resolveThemeConfiguration,\n} from './utils/resolveThemeConfiguration.js'\nexport { generateThemeColorsCss, hexToHsl } from './utils/themeColors.js'\nexport { generateThemeCSS, getThemeStyles } from './utils/themeUtils.js'\nexport { ServerThemeInjector } from './components/ServerThemeInjector.js'\n\nexport type { Mode, ThemeDefaults } from './providers/Theme/types.js'\nexport { ThemeProvider } from './providers/Theme/index.js'\n\nexport const ThemeManagementPlugin = themeManagementPlugin\n/** @deprecated use {@link themeManagementPlugin} */\nexport const themeConfigurationPlugin = themeManagementPlugin\n\nexport default themeManagementPlugin"],"names":["createThemeConfigurationField","defaultThemePresets","THEME_FIELD_NAME","removeExistingThemeField","fields","filter","field","candidate","name","upsertThemeField","themeField","enableLogging","sanitized","console","log","ensureCollectionsArray","collections","Array","isArray","themeManagementPlugin","options","config","enabled","targetCollection","themePresets","defaultTheme","includeColorModeToggle","includeCustomCSS","includeBrandIdentity","enableAdvancedFeatures","collectionTouched","map","collection","slug","existingFields","warn","fetchThemeConfiguration","normalizedOptions","tenantSlug","collectionSlug","depth","locale","draft","queryParams","params","URLSearchParams","limit","set","String","Object","entries","forEach","key","value","undefined","url","toString","response","fetch","ok","Error","status","data","json","doc","docs","themeConfiguration","error","getThemePreset","themeName","find","preset","getAvailableThemePresets","DEFAULT_THEME_CONFIGURATION","resolveThemeConfiguration","generateThemeColorsCss","hexToHsl","generateThemeCSS","getThemeStyles","ServerThemeInjector","ThemeProvider","ThemeManagementPlugin","themeConfigurationPlugin"],"mappings":"AACA,SAASA,6BAA6B,QAAQ,sCAAqC;AAGnF,SAASC,mBAAmB,QAAQ,eAAc;AAMlD,MAAMC,mBAAmB;AAEzB,MAAMC,2BAA2B,CAACC,SAAkB,EAAE,GACpDA,OAAOC,MAAM,CAAC,CAACC;QACb,MAAMC,YAAYD;QAClB,OAAOC,WAAWC,SAASN;IAC7B;AAEF,MAAMO,mBAAmB,CACvBL,QACAM,YACAC;IAEA,MAAMC,YAAYT,yBAAyBC,UAAU,EAAE;IAEvD,IAAIO,eAAe;QACnBE,QAAQC,GAAG,CAAC;IACZ;IAEA,OAAO;WAAIF;QAAWF;KAAW;AACnC;AAEA,MAAMK,yBAAyB,CAACC,cAC9BC,MAAMC,OAAO,CAACF,eAAeA,cAAc,EAAE;AAE/C,OAAO,MAAMG,wBAAwB,CAACC,UAAwC,CAAC,CAAC;IAC9E,OAAO,CAACC;QACN,MAAM,EACJC,UAAU,IAAI,EACdC,mBAAmB,eAAe,EAClCC,eAAevB,mBAAmB,EAClCwB,eAAe,MAAM,EACrBC,yBAAyB,IAAI,EAC7BC,mBAAmB,IAAI,EACvBC,uBAAuB,KAAK,EAC5BC,yBAAyB,IAAI,EAC7BlB,gBAAgB,KAAK,EACtB,GAAGS;QAEJ,IAAI,CAACE,SAAS;YACZ,IAAIX,eAAe;gBACvBE,QAAQC,GAAG,CAAC;YACR;YACA,OAAOO;QACT;QAEA,MAAMX,aAAaV,8BAA8B;YAC/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1
|
+
{"version":3,"sources":["../src/payload-types.ts"],"sourcesContent":["/**\n * Payload types for theme configuration\n * These are placeholder types that will be extended in the consuming application\n */\n\nexport interface ThemeColorOverride {\n [token: string]: string | null | undefined;\n primary?: string | null;\n secondary?: string | null;\n accent?: string | null;\n background?: string | null;\n surface?: string | null;\n surfaceVariant?: string | null;\n text?: string | null;\n textSecondary?: string | null;\n border?: string | null;\n success?: string | null;\n warning?: string | null;\n error?: string | null;\n info?: string | null;\n foreground?: string | null;\n card?: string | null;\n cardForeground?: string | null;\n popover?: string | null;\n popoverForeground?: string | null;\n primaryForeground?: string | null;\n secondaryForeground?: string | null;\n muted?: string | null;\n mutedForeground?: string | null;\n accentForeground?: string | null;\n destructive?: string | null;\n destructiveForeground?: string | null;\n input?: string | null;\n ring?: string | null;\n}\n\nexport interface ThemeTypographyOverride {\n bodyFont?:\n | (\n | 'preset'\n | 'system'\n | 'geist-sans'\n | 'inter'\n | 'manrope'\n | 'urbanist'\n | 'outfit'\n | 'lora'\n | 'custom'\n )\n | null;\n headingFont?:\n | (\n | 'preset'\n | 'geist-sans'\n | 'geist-mono'\n | 'outfit'\n | 'playfair'\n | 'lora'\n | 'serif-classic'\n | 'custom'\n )\n | null;\n bodyFontCustom?: string | null;\n headingFontCustom?: string | null;\n baseFontSize?: ('preset' | '14px' | '16px' | '18px' | '20px') | null;\n lineHeight?: ('preset' | '1.4' | '1.5' | '1.6' | '1.75' | '1.9') | null;\n fontWeights?: Partial<\n Record<'light' | 'normal' | 'medium' | 'semibold' | 'bold' | 'black', string | null>\n > | null;\n letterSpacing?: Partial<Record<'tight' | 'normal' | 'wide' | 'wider', string | null>> | null;\n}\n\nexport interface ThemeCustomization {\n primaryColor?: string | null;\n accentColor?: string | null;\n backgroundColor?: string | null;\n textColor?: string | null;\n customCSS?: string | null;\n}\n\nexport interface SiteThemeConfiguration {\n theme?: string | null;\n preset?: string | null;\n colorMode?: 'auto' | 'light' | 'dark' | null;\n allowColorModeToggle?: boolean | null;\n lightMode?: ThemeColorOverride | null;\n darkMode?: ThemeColorOverride | null;\n colors?: ThemeColorOverride | null;\n typography?: ThemeTypographyOverride | null;\n borderRadius?: 'none' | 'small' | 'medium' | 'large' | 'xl' | null;\n fontScale?: 'small' | 'medium' | 'large' | 'xl' | null;\n spacing?: 'compact' | 'medium' | 'spacious' | null;\n animationLevel?: 'none' | 'reduced' | 'medium' | 'high' | null;\n customCSS?: string | null;\n customization?: ThemeCustomization | null;\n radius?: string | null;\n}\n\nexport interface SiteSetting {\n id: string;\n title?: string | null;\n slug?: string | null;\n themeConfiguration: SiteThemeConfiguration | null;\n updatedAt: string;\n createdAt: string;\n}\n\nexport interface Config {\n collections: {\n 'site-settings': SiteSetting;\n };\n globals: Record<string, unknown>;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAwGD,WAKC"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type { ThemeConfigurationPluginOptions } from './types';
|
|
1
|
+
export type { ThemeManagementPluginOptions } from './types.js';
|
|
3
2
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/plugin.js
CHANGED
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["export type { ThemeManagementPluginOptions } from './types.js';\n"],"names":[],"mappings":"AAAA,WAA+D"}
|