@kilivi/payloadcms-theme-management 2.1.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 (81) hide show
  1. package/README.md +37 -7
  2. package/dist/components/ServerThemeInjector.d.ts +13 -1
  3. package/dist/components/ServerThemeInjector.d.ts.map +1 -1
  4. package/dist/components/ServerThemeInjector.js +24 -1
  5. package/dist/components/ServerThemeInjector.js.map +1 -1
  6. package/dist/components/ThemeLivePreviewSync.d.ts +3 -0
  7. package/dist/components/ThemeLivePreviewSync.d.ts.map +1 -1
  8. package/dist/components/ThemeLivePreviewSync.js +28 -4
  9. package/dist/components/ThemeLivePreviewSync.js.map +1 -1
  10. package/dist/components/typographyPreviewUtils.d.ts +5 -0
  11. package/dist/components/typographyPreviewUtils.d.ts.map +1 -1
  12. package/dist/components/typographyPreviewUtils.js +16 -10
  13. package/dist/components/typographyPreviewUtils.js.map +1 -1
  14. package/dist/constants/themeFonts.d.ts +94 -168
  15. package/dist/constants/themeFonts.d.ts.map +1 -1
  16. package/dist/constants/themeFonts.js +260 -140
  17. package/dist/constants/themeFonts.js.map +1 -1
  18. package/dist/endpoints/themeFonts.d.ts +5 -0
  19. package/dist/endpoints/themeFonts.d.ts.map +1 -0
  20. package/dist/endpoints/themeFonts.js +138 -0
  21. package/dist/endpoints/themeFonts.js.map +1 -0
  22. package/dist/fields/AppearancePreviewField.d.ts.map +1 -1
  23. package/dist/fields/AppearancePreviewField.js +196 -133
  24. package/dist/fields/AppearancePreviewField.js.map +1 -1
  25. package/dist/fields/FontSelectField.css +155 -0
  26. package/dist/fields/FontSelectField.d.ts +4 -2
  27. package/dist/fields/FontSelectField.d.ts.map +1 -1
  28. package/dist/fields/FontSelectField.js +80 -118
  29. package/dist/fields/FontSelectField.js.map +1 -1
  30. package/dist/fields/StylePresetField.d.ts.map +1 -1
  31. package/dist/fields/StylePresetField.js +31 -30
  32. package/dist/fields/StylePresetField.js.map +1 -1
  33. package/dist/fields/ThemePreviewField.css +63 -1
  34. package/dist/fields/ThemePreviewField.d.ts.map +1 -1
  35. package/dist/fields/ThemePreviewField.js +2 -5
  36. package/dist/fields/ThemePreviewField.js.map +1 -1
  37. package/dist/fields/themeConfigurationField.d.ts.map +1 -1
  38. package/dist/fields/themeConfigurationField.js +320 -271
  39. package/dist/fields/themeConfigurationField.js.map +1 -1
  40. package/dist/hooks/useNativeLivePreview.d.ts +15 -0
  41. package/dist/hooks/useNativeLivePreview.d.ts.map +1 -0
  42. package/dist/hooks/useNativeLivePreview.js +18 -0
  43. package/dist/hooks/useNativeLivePreview.js.map +1 -0
  44. package/dist/hooks/useThemeFonts.d.ts +10 -0
  45. package/dist/hooks/useThemeFonts.d.ts.map +1 -0
  46. package/dist/hooks/useThemeFonts.js +36 -0
  47. package/dist/hooks/useThemeFonts.js.map +1 -0
  48. package/dist/index.d.ts +3 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +9 -0
  51. package/dist/index.js.map +1 -1
  52. package/dist/next-fonts.d.ts +3 -0
  53. package/dist/next-fonts.d.ts.map +1 -0
  54. package/dist/next-fonts.js +360 -0
  55. package/dist/next-fonts.js.map +1 -0
  56. package/dist/payload-types.d.ts +10 -6
  57. package/dist/payload-types.d.ts.map +1 -1
  58. package/dist/payload-types.js.map +1 -1
  59. package/dist/presets.d.ts +6 -0
  60. package/dist/presets.d.ts.map +1 -1
  61. package/dist/presets.js.map +1 -1
  62. package/dist/style-presets.d.ts +27 -18
  63. package/dist/style-presets.d.ts.map +1 -1
  64. package/dist/style-presets.js +399 -217
  65. package/dist/style-presets.js.map +1 -1
  66. package/dist/translations.d.ts +5 -0
  67. package/dist/translations.d.ts.map +1 -1
  68. package/dist/translations.js +10 -0
  69. package/dist/translations.js.map +1 -1
  70. package/dist/utils/livePreviewThemeRuntime.d.ts +6 -1
  71. package/dist/utils/livePreviewThemeRuntime.d.ts.map +1 -1
  72. package/dist/utils/livePreviewThemeRuntime.js +11 -1
  73. package/dist/utils/livePreviewThemeRuntime.js.map +1 -1
  74. package/dist/utils/resolveThemeConfiguration.d.ts +15 -0
  75. package/dist/utils/resolveThemeConfiguration.d.ts.map +1 -1
  76. package/dist/utils/resolveThemeConfiguration.js +41 -8
  77. package/dist/utils/resolveThemeConfiguration.js.map +1 -1
  78. package/dist/utils/themeUtils.d.ts.map +1 -1
  79. package/dist/utils/themeUtils.js +60 -2
  80. package/dist/utils/themeUtils.js.map +1 -1
  81. package/package.json +5 -1
@@ -1,170 +1,96 @@
1
- export declare const BODY_FONT_OPTIONS: readonly [{
2
- readonly label: {
3
- readonly en: "Use theme preset";
4
- readonly cs: "Použít výchozí";
5
- };
6
- readonly value: "preset";
7
- }, {
8
- readonly label: {
9
- readonly en: "System";
10
- readonly cs: "Systémové";
11
- };
12
- readonly value: "system-ui";
13
- readonly fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif";
14
- readonly category: "sans-serif";
15
- }, {
16
- readonly label: {
17
- readonly en: "Inter";
18
- readonly cs: "Inter";
19
- };
20
- readonly value: "Inter";
21
- readonly fontFamily: "\"Inter\", sans-serif";
22
- readonly category: "sans-serif";
23
- }, {
24
- readonly label: {
25
- readonly en: "Roboto";
26
- readonly cs: "Roboto";
27
- };
28
- readonly value: "Roboto";
29
- readonly fontFamily: "\"Roboto\", sans-serif";
30
- readonly category: "sans-serif";
31
- }, {
32
- readonly label: {
33
- readonly en: "Open Sans";
34
- readonly cs: "Open Sans";
35
- };
36
- readonly value: "Open Sans";
37
- readonly fontFamily: "\"Open Sans\", sans-serif";
38
- readonly category: "sans-serif";
39
- }, {
40
- readonly label: {
41
- readonly en: "Lato";
42
- readonly cs: "Lato";
43
- };
44
- readonly value: "Lato";
45
- readonly fontFamily: "\"Lato\", sans-serif";
46
- readonly category: "sans-serif";
47
- }, {
48
- readonly label: {
49
- readonly en: "Montserrat";
50
- readonly cs: "Montserrat";
51
- };
52
- readonly value: "Montserrat";
53
- readonly fontFamily: "\"Montserrat\", sans-serif";
54
- readonly category: "sans-serif";
55
- }, {
56
- readonly label: {
57
- readonly en: "Poppins";
58
- readonly cs: "Poppins";
59
- };
60
- readonly value: "Poppins";
61
- readonly fontFamily: "\"Poppins\", sans-serif";
62
- readonly category: "sans-serif";
63
- }, {
64
- readonly label: {
65
- readonly en: "Custom font...";
66
- readonly cs: "Vlastní písmo...";
67
- };
68
- readonly value: "custom";
69
- }];
70
- export declare const HEADING_FONT_OPTIONS: readonly [{
71
- readonly label: {
72
- readonly en: "Use theme preset";
73
- readonly cs: "Použít výchozí";
74
- };
75
- readonly value: "preset";
76
- }, {
77
- readonly label: {
78
- readonly en: "System";
79
- readonly cs: "Systémové";
80
- };
81
- readonly value: "system-ui";
82
- readonly fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif";
83
- readonly category: "sans-serif";
84
- }, {
85
- readonly label: {
86
- readonly en: "Inter";
87
- readonly cs: "Inter";
88
- };
89
- readonly value: "Inter";
90
- readonly fontFamily: "\"Inter\", sans-serif";
91
- readonly category: "sans-serif";
92
- }, {
93
- readonly label: {
94
- readonly en: "Playfair Display";
95
- readonly cs: "Playfair Display";
96
- };
97
- readonly value: "Playfair Display";
98
- readonly fontFamily: "\"Playfair Display\", serif";
99
- readonly category: "serif";
100
- }, {
101
- readonly label: {
102
- readonly en: "Merriweather";
103
- readonly cs: "Merriweather";
104
- };
105
- readonly value: "Merriweather";
106
- readonly fontFamily: "\"Merriweather\", serif";
107
- readonly category: "serif";
108
- }, {
109
- readonly label: {
110
- readonly en: "Montserrat";
111
- readonly cs: "Montserrat";
112
- };
113
- readonly value: "Montserrat";
114
- readonly fontFamily: "\"Montserrat\", sans-serif";
115
- readonly category: "sans-serif";
116
- }, {
117
- readonly label: {
118
- readonly en: "Raleway";
119
- readonly cs: "Raleway";
120
- };
121
- readonly value: "Raleway";
122
- readonly fontFamily: "\"Raleway\", sans-serif";
123
- readonly category: "sans-serif";
124
- }, {
125
- readonly label: {
126
- readonly en: "Custom font...";
127
- readonly cs: "Vlastní písmo...";
128
- };
129
- readonly value: "custom";
130
- }];
131
- export declare const BASE_FONT_SIZE_OPTIONS: readonly [{
132
- readonly label: "preset";
133
- readonly value: "preset";
134
- }, {
135
- readonly label: "14px";
136
- readonly value: "14";
137
- }, {
138
- readonly label: "15px";
139
- readonly value: "15";
140
- }, {
141
- readonly label: "16px";
142
- readonly value: "16";
143
- }, {
144
- readonly label: "17px";
145
- readonly value: "17";
146
- }, {
147
- readonly label: "18px";
148
- readonly value: "18";
149
- }];
150
- export declare const LINE_HEIGHT_OPTIONS: readonly [{
151
- readonly label: "preset";
152
- readonly value: "preset";
153
- }, {
154
- readonly label: "1.4";
155
- readonly value: "1.4";
156
- }, {
157
- readonly label: "1.5";
158
- readonly value: "1.5";
159
- }, {
160
- readonly label: "1.6";
161
- readonly value: "1.6";
162
- }, {
163
- readonly label: "1.7";
164
- readonly value: "1.7";
165
- }, {
166
- readonly label: "1.8";
167
- readonly value: "1.8";
168
- }];
1
+ export type FontCategory = 'sans-serif' | 'serif' | 'display' | 'monospace';
2
+ export interface FontCatalogEntry {
3
+ /** Stored value (the Google Fonts family name, or a system keyword). */
4
+ value: string;
5
+ category: FontCategory;
6
+ /** Full CSS font-family stack. A `--font-*` variable is honoured first so a
7
+ * site that self-hosts the face with `next/font` keeps using that copy. */
8
+ fontFamily: string;
9
+ /** Weights requested from Google Fonts (`null` for system stacks). */
10
+ googleWeights: string | null;
11
+ /** Display faces only make sense for headings. */
12
+ headingOnly?: boolean;
13
+ }
14
+ export declare const FONT_CATALOG: readonly FontCatalogEntry[];
15
+ export declare function getFontCatalogEntry(value?: string | null): FontCatalogEntry | undefined;
16
+ export declare const FONT_CATEGORY_LABELS: Record<FontCategory, {
17
+ en: string;
18
+ cs: string;
19
+ }>;
20
+ export declare const BODY_FONT_OPTIONS: {
21
+ label: {
22
+ en: string;
23
+ cs: string;
24
+ };
25
+ value: string;
26
+ }[];
27
+ export declare const HEADING_FONT_OPTIONS: {
28
+ label: {
29
+ en: string;
30
+ cs: string;
31
+ };
32
+ value: string;
33
+ }[];
34
+ export declare const BASE_FONT_SIZE_OPTIONS: ({
35
+ label: {
36
+ en: string;
37
+ cs: string;
38
+ };
39
+ value: string;
40
+ } | {
41
+ label: string;
42
+ value: string;
43
+ })[];
44
+ export declare const LINE_HEIGHT_OPTIONS: ({
45
+ label: {
46
+ en: string;
47
+ cs: string;
48
+ };
49
+ value: string;
50
+ } | {
51
+ label: string;
52
+ value: string;
53
+ })[];
54
+ export declare const HEADING_WEIGHT_OPTIONS: {
55
+ label: {
56
+ en: string;
57
+ cs: string;
58
+ };
59
+ value: string;
60
+ }[];
61
+ export declare const LETTER_SPACING_OPTIONS: {
62
+ label: {
63
+ en: string;
64
+ cs: string;
65
+ };
66
+ value: string;
67
+ }[];
68
+ /** Heading tracking for each letter-spacing token. `wider` also sets headings in caps. */
69
+ export declare const LETTER_SPACING_TO_CSS: Record<string, string>;
70
+ /** Stored base-font-size values are bare pixel numbers ('16'); CSS needs a unit. */
71
+ export declare function toFontSizeCss(value?: string | null): string | undefined;
169
72
  export declare const FONT_VALUE_TO_CSS: Record<string, string>;
73
+ /**
74
+ * Google Fonts stylesheet URL for the given font values (catalog entries only;
75
+ * system stacks and custom stacks are skipped). Returns null when nothing needs loading.
76
+ */
77
+ export declare function buildGoogleFontsHref(values: Array<string | null | undefined>): string | null;
78
+ /** Payload endpoints (under `routes.api`) that serve the catalog fonts from the site's own origin. */
79
+ export declare const THEME_FONTS_CSS_PATH = "/theme-fonts/css";
80
+ export declare const THEME_FONTS_FILE_PATH = "/theme-fonts/file";
81
+ /** Catalog font values hosted by Google, de-duplicated and sorted (stable cache key). */
82
+ export declare function parseFontFamilies(raw: string | null | undefined): string[];
83
+ export type ThemeFontLoading = 'self-hosted' | 'google' | 'none';
84
+ /**
85
+ * Stylesheet URL that loads the given fonts.
86
+ *
87
+ * - `self-hosted` (default): same-origin URL served by the plugin's font
88
+ * endpoints; the visitor's browser never contacts Google (GDPR-friendly).
89
+ * - `google`: the Google Fonts CDN directly.
90
+ * - `none`: nothing; the site loads the faces itself (e.g. `next/font`).
91
+ */
92
+ export declare function buildThemeFontsHref(values: Array<string | null | undefined>, options?: {
93
+ mode?: ThemeFontLoading;
94
+ apiRoute?: string;
95
+ }): string | null;
170
96
  //# sourceMappingURL=themeFonts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"themeFonts.d.ts","sourceRoot":"","sources":["../../src/constants/themeFonts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CpB,CAAA;AAEV,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCvB,CAAA;AAEV,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;EAOzB,CAAA;AAEV,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;EAOtB,CAAA;AAEV,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAWpD,CAAA"}
1
+ {"version":3,"file":"themeFonts.d.ts","sourceRoot":"","sources":["../../src/constants/themeFonts.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAA;AAE3E,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,YAAY,CAAA;IACtB;gFAC4E;IAC5E,UAAU,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,kDAAkD;IAClD,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAqBD,eAAO,MAAM,YAAY,EAAE,SAAS,gBAAgB,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