@kilivi/payloadcms-theme-management 0.2.18 → 0.3.2

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 (47) hide show
  1. package/dist/fields/ColorPickerField.js +1 -1
  2. package/dist/fields/ColorPickerField.js.map +1 -1
  3. package/dist/fields/ThemeTokenSelectField.d.ts.map +1 -1
  4. package/dist/fields/ThemeTokenSelectField.js +1 -1
  5. package/dist/fields/ThemeTokenSelectField.js.map +1 -1
  6. package/dist/fields/themeConfigurationField.d.ts +3 -14
  7. package/dist/fields/themeConfigurationField.d.ts.map +1 -1
  8. package/dist/fields/themeConfigurationField.js +233 -297
  9. package/dist/fields/themeConfigurationField.js.map +1 -1
  10. package/dist/index.d.ts +0 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +17 -77
  13. package/dist/index.js.map +1 -1
  14. package/package.json +1 -1
  15. package/dist/fields/ExtendedThemeAutoPopulateField.d.ts +0 -12
  16. package/dist/fields/ExtendedThemeAutoPopulateField.d.ts.map +0 -1
  17. package/dist/fields/ExtendedThemeAutoPopulateField.js +0 -176
  18. package/dist/fields/ExtendedThemeAutoPopulateField.js.map +0 -1
  19. package/dist/fields/RadiusField.d.ts +0 -3
  20. package/dist/fields/RadiusField.d.ts.map +0 -1
  21. package/dist/fields/RadiusField.js +0 -174
  22. package/dist/fields/RadiusField.js.map +0 -1
  23. package/dist/fields/ThemeLivePreview.css +0 -190
  24. package/dist/fields/ThemeLivePreview.d.ts +0 -3
  25. package/dist/fields/ThemeLivePreview.d.ts.map +0 -1
  26. package/dist/fields/ThemeLivePreview.js +0 -195
  27. package/dist/fields/ThemeLivePreview.js.map +0 -1
  28. package/dist/fields/VISUAL_EXAMPLES.d.ts +0 -153
  29. package/dist/fields/VISUAL_EXAMPLES.d.ts.map +0 -1
  30. package/dist/fields/VISUAL_EXAMPLES.js +0 -148
  31. package/dist/fields/VISUAL_EXAMPLES.js.map +0 -1
  32. package/dist/fields/extendedThemeFields.d.ts +0 -139
  33. package/dist/fields/extendedThemeFields.d.ts.map +0 -1
  34. package/dist/fields/extendedThemeFields.js +0 -489
  35. package/dist/fields/extendedThemeFields.js.map +0 -1
  36. package/dist/views/ThemePreviewLoader.d.ts +0 -7
  37. package/dist/views/ThemePreviewLoader.d.ts.map +0 -1
  38. package/dist/views/ThemePreviewLoader.js +0 -43
  39. package/dist/views/ThemePreviewLoader.js.map +0 -1
  40. package/dist/views/ThemePreviewView.d.ts +0 -10
  41. package/dist/views/ThemePreviewView.d.ts.map +0 -1
  42. package/dist/views/ThemePreviewView.js +0 -43
  43. package/dist/views/ThemePreviewView.js.map +0 -1
  44. package/dist/views/ThemePreviewViewClient.d.ts +0 -7
  45. package/dist/views/ThemePreviewViewClient.d.ts.map +0 -1
  46. package/dist/views/ThemePreviewViewClient.js +0 -12
  47. package/dist/views/ThemePreviewViewClient.js.map +0 -1
@@ -1,174 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useField } from '@payloadcms/ui';
4
- import { useMemo } from 'react';
5
- import { borderRadiusPresets } from '../providers/Theme/themeConfig.js';
6
- export default function RadiusField({ field, ...props }) {
7
- const { value, setValue } = useField({
8
- path: props.path
9
- });
10
- const label = typeof field.label === 'string' ? field.label : '';
11
- const radiusOptions = useMemo(()=>{
12
- const entries = Object.entries(borderRadiusPresets);
13
- return entries.map(([key, preset])=>({
14
- key,
15
- label: preset.label,
16
- css: preset.css
17
- }));
18
- }, []);
19
- const fallbackKey = radiusOptions[2]?.key ?? radiusOptions[0]?.key ?? 'medium';
20
- const currentKey = typeof value === 'string' && value in borderRadiusPresets ? value : fallbackKey;
21
- const description = typeof field.admin?.description === 'string' ? field.admin.description : field.admin?.description?.en || field.admin?.description?.cs || null;
22
- return /*#__PURE__*/ _jsxs("div", {
23
- className: "field-type",
24
- children: [
25
- /*#__PURE__*/ _jsxs("label", {
26
- className: "field-label",
27
- htmlFor: props.path,
28
- children: [
29
- label,
30
- field.required && /*#__PURE__*/ _jsx("span", {
31
- className: "required",
32
- children: "*"
33
- })
34
- ]
35
- }),
36
- description && /*#__PURE__*/ _jsx("p", {
37
- style: {
38
- marginTop: '4px',
39
- fontSize: '12px',
40
- lineHeight: 1.5,
41
- color: 'var(--theme-elevation-600)'
42
- },
43
- children: description
44
- }),
45
- /*#__PURE__*/ _jsx("div", {
46
- style: {
47
- display: 'grid',
48
- gridTemplateColumns: 'repeat(auto-fit, minmax(160px, 1fr))',
49
- gap: '16px',
50
- marginTop: '16px'
51
- },
52
- children: radiusOptions.map((option)=>{
53
- const isSelected = option.key === currentKey;
54
- const cardRadius = option.css['--radius-large'] ?? option.css['--radius-default'] ?? option.css['--radius-medium'];
55
- const chipRadius = option.css['--radius-default'] ?? option.css['--radius-small'];
56
- const pillRadius = option.css['--radius-xl'] ?? option.css['--radius-large'] ?? '999px';
57
- return /*#__PURE__*/ _jsxs("button", {
58
- type: "button",
59
- onClick: ()=>setValue(option.key),
60
- "aria-pressed": isSelected,
61
- style: {
62
- border: isSelected ? '2px solid var(--theme-success-500)' : '1px solid var(--theme-elevation-150)',
63
- borderRadius: '14px',
64
- backgroundColor: 'var(--theme-elevation-25)',
65
- padding: '16px',
66
- display: 'grid',
67
- gap: '10px',
68
- textAlign: 'left',
69
- cursor: 'pointer',
70
- transition: 'border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease',
71
- boxShadow: isSelected ? '0 10px 20px rgba(34, 197, 94, 0.18)' : '0 6px 18px rgba(15, 23, 42, 0.08)',
72
- transform: isSelected ? 'translateY(-2px)' : 'translateY(0)'
73
- },
74
- children: [
75
- /*#__PURE__*/ _jsxs("div", {
76
- style: {
77
- display: 'flex',
78
- alignItems: 'center',
79
- justifyContent: 'space-between',
80
- fontWeight: 600,
81
- fontSize: '13px',
82
- color: 'var(--theme-elevation-800)'
83
- },
84
- children: [
85
- /*#__PURE__*/ _jsx("span", {
86
- children: option.label
87
- }),
88
- /*#__PURE__*/ _jsx("span", {
89
- style: {
90
- fontSize: '11px',
91
- opacity: 0.7
92
- },
93
- children: option.key
94
- })
95
- ]
96
- }),
97
- /*#__PURE__*/ _jsxs("div", {
98
- style: {
99
- display: 'grid',
100
- gap: '10px'
101
- },
102
- children: [
103
- /*#__PURE__*/ _jsxs("div", {
104
- style: {
105
- display: 'flex',
106
- gap: '8px',
107
- alignItems: 'center'
108
- },
109
- children: [
110
- /*#__PURE__*/ _jsx("div", {
111
- style: {
112
- width: '50px',
113
- height: '34px',
114
- backgroundColor: 'var(--theme-elevation-100)',
115
- border: '1px solid var(--theme-elevation-200)',
116
- borderRadius: cardRadius ?? '0'
117
- }
118
- }),
119
- /*#__PURE__*/ _jsx("div", {
120
- style: {
121
- flex: 1,
122
- height: '14px',
123
- backgroundColor: 'var(--theme-primary-500)',
124
- borderRadius: pillRadius
125
- }
126
- })
127
- ]
128
- }),
129
- /*#__PURE__*/ _jsxs("div", {
130
- style: {
131
- display: 'flex',
132
- gap: '6px',
133
- flexWrap: 'wrap',
134
- fontSize: '11px',
135
- color: 'var(--theme-elevation-600)'
136
- },
137
- children: [
138
- /*#__PURE__*/ _jsxs("span", {
139
- children: [
140
- "Card ",
141
- cardRadius ?? '—'
142
- ]
143
- }),
144
- /*#__PURE__*/ _jsxs("span", {
145
- children: [
146
- "Chip ",
147
- chipRadius ?? '—'
148
- ]
149
- }),
150
- /*#__PURE__*/ _jsxs("span", {
151
- children: [
152
- "Pill ",
153
- pillRadius
154
- ]
155
- })
156
- ]
157
- })
158
- ]
159
- })
160
- ]
161
- }, option.key);
162
- })
163
- }),
164
- /*#__PURE__*/ _jsx("input", {
165
- type: "hidden",
166
- id: props.path,
167
- value: currentKey,
168
- readOnly: true
169
- })
170
- ]
171
- });
172
- }
173
-
174
- //# sourceMappingURL=RadiusField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/fields/RadiusField.tsx"],"sourcesContent":["'use client'\n\nimport { useField } from '@payloadcms/ui'\nimport type { SelectFieldClientProps } from 'payload'\nimport { useMemo } from 'react'\nimport { borderRadiusPresets } from '../providers/Theme/themeConfig.js'\n\ntype RadiusPresetKey = Extract<keyof typeof borderRadiusPresets, string>\n\ninterface RadiusOptionCard {\n key: RadiusPresetKey\n label: string\n css: Record<string, string>\n}\n\nexport default function RadiusField({ field, ...props }: SelectFieldClientProps) {\n const { value, setValue } = useField<string>({ path: props.path })\n const label = typeof field.label === 'string' ? field.label : ''\n\n const radiusOptions = useMemo<RadiusOptionCard[]>(() => {\n const entries = Object.entries(borderRadiusPresets) as Array<\n [RadiusPresetKey, (typeof borderRadiusPresets)[RadiusPresetKey]]\n >\n return entries.map(([key, preset]) => ({\n key,\n label: preset.label,\n css: preset.css,\n }))\n }, [])\n\n const fallbackKey: RadiusPresetKey = radiusOptions[2]?.key ?? radiusOptions[0]?.key ?? 'medium'\n const currentKey =\n typeof value === 'string' && value in borderRadiusPresets\n ? (value as RadiusPresetKey)\n : fallbackKey\n\n const description =\n typeof field.admin?.description === 'string'\n ? field.admin.description\n : field.admin?.description?.en || field.admin?.description?.cs || null\n\n return (\n <div className=\"field-type\">\n <label className=\"field-label\" htmlFor={props.path}>\n {label}\n {field.required && <span className=\"required\">*</span>}\n </label>\n\n {description && (\n <p\n style={{\n marginTop: '4px',\n fontSize: '12px',\n lineHeight: 1.5,\n color: 'var(--theme-elevation-600)',\n }}\n >\n {description}\n </p>\n )}\n\n <div\n style={{\n display: 'grid',\n gridTemplateColumns: 'repeat(auto-fit, minmax(160px, 1fr))',\n gap: '16px',\n marginTop: '16px',\n }}\n >\n {radiusOptions.map((option) => {\n const isSelected = option.key === currentKey\n const cardRadius =\n option.css['--radius-large'] ??\n option.css['--radius-default'] ??\n option.css['--radius-medium']\n const chipRadius = option.css['--radius-default'] ?? option.css['--radius-small']\n const pillRadius = option.css['--radius-xl'] ?? option.css['--radius-large'] ?? '999px'\n\n return (\n <button\n key={option.key}\n type=\"button\"\n onClick={() => setValue(option.key)}\n aria-pressed={isSelected}\n style={{\n border: isSelected\n ? '2px solid var(--theme-success-500)'\n : '1px solid var(--theme-elevation-150)',\n borderRadius: '14px',\n backgroundColor: 'var(--theme-elevation-25)',\n padding: '16px',\n display: 'grid',\n gap: '10px',\n textAlign: 'left',\n cursor: 'pointer',\n transition: 'border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease',\n boxShadow: isSelected\n ? '0 10px 20px rgba(34, 197, 94, 0.18)'\n : '0 6px 18px rgba(15, 23, 42, 0.08)',\n transform: isSelected ? 'translateY(-2px)' : 'translateY(0)',\n }}\n >\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n fontWeight: 600,\n fontSize: '13px',\n color: 'var(--theme-elevation-800)',\n }}\n >\n <span>{option.label}</span>\n <span style={{ fontSize: '11px', opacity: 0.7 }}>{option.key}</span>\n </div>\n\n <div\n style={{\n display: 'grid',\n gap: '10px',\n }}\n >\n <div\n style={{\n display: 'flex',\n gap: '8px',\n alignItems: 'center',\n }}\n >\n <div\n style={{\n width: '50px',\n height: '34px',\n backgroundColor: 'var(--theme-elevation-100)',\n border: '1px solid var(--theme-elevation-200)',\n borderRadius: cardRadius ?? '0',\n }}\n />\n <div\n style={{\n flex: 1,\n height: '14px',\n backgroundColor: 'var(--theme-primary-500)',\n borderRadius: pillRadius,\n }}\n />\n </div>\n\n <div\n style={{\n display: 'flex',\n gap: '6px',\n flexWrap: 'wrap',\n fontSize: '11px',\n color: 'var(--theme-elevation-600)',\n }}\n >\n <span>Card {cardRadius ?? '—'}</span>\n <span>Chip {chipRadius ?? '—'}</span>\n <span>Pill {pillRadius}</span>\n </div>\n </div>\n </button>\n )\n })}\n </div>\n\n <input type=\"hidden\" id={props.path} value={currentKey} readOnly />\n </div>\n )\n}\n"],"names":["useField","useMemo","borderRadiusPresets","RadiusField","field","props","value","setValue","path","label","radiusOptions","entries","Object","map","key","preset","css","fallbackKey","currentKey","description","admin","en","cs","div","className","htmlFor","required","span","p","style","marginTop","fontSize","lineHeight","color","display","gridTemplateColumns","gap","option","isSelected","cardRadius","chipRadius","pillRadius","button","type","onClick","aria-pressed","border","borderRadius","backgroundColor","padding","textAlign","cursor","transition","boxShadow","transform","alignItems","justifyContent","fontWeight","opacity","width","height","flex","flexWrap","input","id","readOnly"],"mappings":"AAAA;;AAEA,SAASA,QAAQ,QAAQ,iBAAgB;AAEzC,SAASC,OAAO,QAAQ,QAAO;AAC/B,SAASC,mBAAmB,QAAQ,oCAAmC;AAUvE,eAAe,SAASC,YAAY,EAAEC,KAAK,EAAE,GAAGC,OAA+B;IAC7E,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGP,SAAiB;QAAEQ,MAAMH,MAAMG,IAAI;IAAC;IAChE,MAAMC,QAAQ,OAAOL,MAAMK,KAAK,KAAK,WAAWL,MAAMK,KAAK,GAAG;IAE9D,MAAMC,gBAAgBT,QAA4B;QAChD,MAAMU,UAAUC,OAAOD,OAAO,CAACT;QAG/B,OAAOS,QAAQE,GAAG,CAAC,CAAC,CAACC,KAAKC,OAAO,GAAM,CAAA;gBACrCD;gBACAL,OAAOM,OAAON,KAAK;gBACnBO,KAAKD,OAAOC,GAAG;YACjB,CAAA;IACF,GAAG,EAAE;IAEL,MAAMC,cAA+BP,aAAa,CAAC,EAAE,EAAEI,OAAOJ,aAAa,CAAC,EAAE,EAAEI,OAAO;IACvF,MAAMI,aACJ,OAAOZ,UAAU,YAAYA,SAASJ,sBACjCI,QACDW;IAEN,MAAME,cACJ,OAAOf,MAAMgB,KAAK,EAAED,gBAAgB,WAChCf,MAAMgB,KAAK,CAACD,WAAW,GACvBf,MAAMgB,KAAK,EAAED,aAAaE,MAAMjB,MAAMgB,KAAK,EAAED,aAAaG,MAAM;IAEtE,qBACE,MAACC;QAAIC,WAAU;;0BACb,MAACf;gBAAMe,WAAU;gBAAcC,SAASpB,MAAMG,IAAI;;oBAC/CC;oBACAL,MAAMsB,QAAQ,kBAAI,KAACC;wBAAKH,WAAU;k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;wCACCM,OAAO;4CACLK,SAAS;4CACTE,KAAK;4CACLmB,YAAY;wCACd;;0DAEA,KAAChC;gDACCM,OAAO;oDACL8B,OAAO;oDACPC,QAAQ;oDACRZ,iBAAiB;oDACjBF,QAAQ;oDACRC,cAAcR,cAAc;gDAC9B;;0DAEF,KAAChB;gDACCM,OAAO;oDACLgC,MAAM;oDACND,QAAQ;oDACRZ,iBAAiB;oDACjBD,cAAcN;gDAChB;;;;kDAIJ,MAAClB;wCACCM,OAAO;4CACLK,SAAS;4CACTE,KAAK;4CACL0B,UAAU;4CACV/B,UAAU;4CACVE,OAAO;wCACT;;0DAEA,MAACN;;oDAAK;oDAAMY,cAAc;;;0DAC1B,MAACZ;;oDAAK;oDAAMa,cAAc;;;0DAC1B,MAACb;;oDAAK;oDAAMc;;;;;;;;uBA/EXJ,OAAOvB,GAAG;gBAoFrB;;0BAGN,KAACiD;gBAAMpB,MAAK;gBAASqB,IAAI3D,MAAMG,IAAI;gBAAEF,OAAOY;gBAAY+C,QAAQ;;;;AAGlE"}
@@ -1,190 +0,0 @@
1
- /* Theme Live Preview Styles */
2
- .theme-live-preview-container {
3
- position: sticky;
4
- top: 0;
5
- height: 100vh;
6
- overflow-y: auto;
7
- background: var(--theme-elevation-50);
8
- border-left: 1px solid var(--theme-elevation-200);
9
- }
10
-
11
- .theme-live-preview-empty {
12
- display: flex;
13
- align-items: center;
14
- justify-content: center;
15
- height: 100%;
16
- padding: 2rem;
17
- color: var(--theme-elevation-400);
18
- font-size: 0.875rem;
19
- text-align: center;
20
- }
21
-
22
- .preview-header {
23
- position: sticky;
24
- top: 0;
25
- z-index: 10;
26
- background: var(--theme-elevation-0);
27
- border-bottom: 1px solid var(--theme-elevation-200);
28
- padding: 1rem;
29
- display: flex;
30
- justify-content: space-between;
31
- align-items: center;
32
- }
33
-
34
- .preview-header h3 {
35
- margin: 0;
36
- font-size: 1rem;
37
- font-weight: 600;
38
- color: var(--theme-text);
39
- }
40
-
41
- .mode-toggle {
42
- display: flex;
43
- gap: 0.5rem;
44
- background: var(--theme-elevation-100);
45
- padding: 0.25rem;
46
- border-radius: 8px;
47
- }
48
-
49
- .mode-toggle button {
50
- padding: 0.5rem 1rem;
51
- border: none;
52
- background: transparent;
53
- color: var(--theme-text);
54
- font-size: 0.875rem;
55
- font-weight: 500;
56
- cursor: pointer;
57
- border-radius: 6px;
58
- transition: all 0.2s;
59
- }
60
-
61
- .mode-toggle button.active {
62
- background: white;
63
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
64
- }
65
-
66
- .preview-content {
67
- padding: 2rem;
68
- min-height: calc(100vh - 80px);
69
- transition: all 0.3s;
70
- }
71
-
72
- .preview-section {
73
- margin-bottom: 2rem;
74
- }
75
-
76
- .preview-section h1 {
77
- font-size: 2rem;
78
- font-weight: 700;
79
- margin: 0 0 0.5rem 0;
80
- }
81
-
82
- .preview-section p {
83
- font-size: 1rem;
84
- margin: 0;
85
- }
86
-
87
- .preview-cards {
88
- display: grid;
89
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
90
- gap: 1.5rem;
91
- margin-bottom: 2rem;
92
- }
93
-
94
- .preview-card {
95
- padding: 1.5rem;
96
- border-radius: 12px;
97
- border: 2px solid;
98
- transition: all 0.2s;
99
- }
100
-
101
- .preview-card:hover {
102
- transform: translateY(-2px);
103
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
104
- }
105
-
106
- .preview-card h3 {
107
- margin: 0 0 0.5rem 0;
108
- font-size: 1.25rem;
109
- font-weight: 600;
110
- }
111
-
112
- .preview-card p {
113
- margin: 0 0 1rem 0;
114
- font-size: 0.875rem;
115
- }
116
-
117
- .preview-btn-primary,
118
- .preview-btn-secondary,
119
- .preview-btn-destructive {
120
- padding: 0.625rem 1.25rem;
121
- border: none;
122
- border-radius: 8px;
123
- font-weight: 600;
124
- font-size: 0.875rem;
125
- cursor: pointer;
126
- transition: all 0.2s;
127
- }
128
-
129
- .preview-btn-primary:hover,
130
- .preview-btn-secondary:hover,
131
- .preview-btn-destructive:hover {
132
- opacity: 0.9;
133
- transform: translateY(-1px);
134
- }
135
-
136
- .preview-ui-elements {
137
- display: flex;
138
- gap: 1rem;
139
- align-items: center;
140
- flex-wrap: wrap;
141
- margin-bottom: 2rem;
142
- }
143
-
144
- .preview-input {
145
- padding: 0.625rem 1rem;
146
- border: 2px solid;
147
- border-radius: 8px;
148
- font-size: 0.875rem;
149
- min-width: 200px;
150
- transition: all 0.2s;
151
- }
152
-
153
- .preview-input:focus {
154
- outline: none;
155
- border-color: var(--preview-ring, #3b82f6);
156
- box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
157
- }
158
-
159
- .preview-badge {
160
- padding: 0.375rem 0.875rem;
161
- border-radius: 6px;
162
- font-size: 0.75rem;
163
- font-weight: 600;
164
- text-transform: uppercase;
165
- letter-spacing: 0.05em;
166
- }
167
-
168
- .preview-muted {
169
- padding: 1.5rem;
170
- border-radius: 8px;
171
- margin-bottom: 2rem;
172
- }
173
-
174
- .preview-muted p {
175
- margin: 0;
176
- font-size: 0.875rem;
177
- }
178
-
179
- /* Dark mode adjustments */
180
- .theme-live-preview-container[data-mode="dark"] .preview-content {
181
- background: #1a1a1a;
182
- }
183
-
184
- .theme-live-preview-container[data-mode="dark"] .preview-card {
185
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
186
- }
187
-
188
- .theme-live-preview-container[data-mode="dark"] .preview-card:hover {
189
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
190
- }
@@ -1,3 +0,0 @@
1
- export declare const ThemeLivePreview: () => import("react").JSX.Element;
2
- export default ThemeLivePreview;
3
- //# sourceMappingURL=ThemeLivePreview.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThemeLivePreview.d.ts","sourceRoot":"","sources":["../../src/fields/ThemeLivePreview.tsx"],"names":[],"mappings":"AAoBA,eAAO,MAAM,gBAAgB,mCA6J5B,CAAA;AAED,eAAe,gBAAgB,CAAA"}
@@ -1,195 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- /**
4
- * Theme Live Preview Component
5
- * Real-time preview of theme configuration
6
- * Inspired by Payload CMS 3 Live Preview
7
- */ import { useFormFields } from '@payloadcms/ui';
8
- import { useState } from 'react';
9
- // Import CSS only in browser environment
10
- // This prevents Node.js from trying to import CSS directly
11
- // which causes ERR_UNKNOWN_FILE_EXTENSION error
12
- if (typeof window !== 'undefined') {
13
- // @ts-expect-error - Dynamic import of CSS is not recognized by TypeScript
14
- import('./ThemeLivePreview.css').catch((err)=>{
15
- console.warn('Failed to load CSS file:', err);
16
- });
17
- }
18
- export const ThemeLivePreview = ()=>{
19
- const allFields = useFormFields(([fields])=>fields);
20
- const [previewMode, setPreviewMode] = useState('light');
21
- const themeConfig = allFields?.themeConfiguration?.value;
22
- // Extract colors from theme configuration
23
- // Support both basic (lightMode/darkMode) and extended (extendedLightMode/extendedDarkMode)
24
- const lightMode = themeConfig?.extendedLightMode || themeConfig?.lightMode;
25
- const darkMode = themeConfig?.extendedDarkMode || themeConfig?.darkMode;
26
- const activeMode = previewMode === 'light' ? lightMode : darkMode;
27
- if (!themeConfig) {
28
- return /*#__PURE__*/ _jsx("div", {
29
- className: "theme-live-preview-empty",
30
- children: /*#__PURE__*/ _jsx("p", {
31
- children: "Configure your theme to see live preview"
32
- })
33
- });
34
- }
35
- return /*#__PURE__*/ _jsxs("div", {
36
- className: "theme-live-preview-container",
37
- "data-mode": previewMode,
38
- children: [
39
- /*#__PURE__*/ _jsxs("div", {
40
- className: "preview-header",
41
- children: [
42
- /*#__PURE__*/ _jsx("h3", {
43
- children: "Live Theme Preview"
44
- }),
45
- /*#__PURE__*/ _jsxs("div", {
46
- className: "mode-toggle",
47
- children: [
48
- /*#__PURE__*/ _jsx("button", {
49
- type: "button",
50
- className: previewMode === 'light' ? 'active' : '',
51
- onClick: ()=>setPreviewMode('light'),
52
- children: "☀️ Light"
53
- }),
54
- /*#__PURE__*/ _jsx("button", {
55
- type: "button",
56
- className: previewMode === 'dark' ? 'active' : '',
57
- onClick: ()=>setPreviewMode('dark'),
58
- children: "🌙 Dark"
59
- })
60
- ]
61
- })
62
- ]
63
- }),
64
- /*#__PURE__*/ _jsxs("div", {
65
- className: "preview-content",
66
- style: {
67
- backgroundColor: activeMode?.background || '#ffffff',
68
- color: activeMode?.foreground || '#000000'
69
- },
70
- children: [
71
- /*#__PURE__*/ _jsxs("div", {
72
- className: "preview-section",
73
- children: [
74
- /*#__PURE__*/ _jsx("h1", {
75
- style: {
76
- color: activeMode?.foreground
77
- },
78
- children: "Welcome to Your Site"
79
- }),
80
- /*#__PURE__*/ _jsx("p", {
81
- style: {
82
- color: activeMode?.mutedForeground
83
- },
84
- children: "This is a live preview of your theme configuration"
85
- })
86
- ]
87
- }),
88
- /*#__PURE__*/ _jsxs("div", {
89
- className: "preview-cards",
90
- children: [
91
- /*#__PURE__*/ _jsxs("div", {
92
- className: "preview-card",
93
- style: {
94
- backgroundColor: activeMode?.card || '#ffffff',
95
- color: activeMode?.cardForeground || '#000000',
96
- borderColor: activeMode?.border || '#e2e8f0'
97
- },
98
- children: [
99
- /*#__PURE__*/ _jsx("h3", {
100
- children: "Featured Content"
101
- }),
102
- /*#__PURE__*/ _jsx("p", {
103
- style: {
104
- color: activeMode?.mutedForeground
105
- },
106
- children: "Card component with theme colors"
107
- }),
108
- /*#__PURE__*/ _jsx("button", {
109
- className: "preview-btn-primary",
110
- style: {
111
- backgroundColor: activeMode?.primary || '#0070f3',
112
- color: activeMode?.primaryForeground || '#ffffff'
113
- },
114
- children: "Primary Action"
115
- })
116
- ]
117
- }),
118
- /*#__PURE__*/ _jsxs("div", {
119
- className: "preview-card",
120
- style: {
121
- backgroundColor: activeMode?.card || '#ffffff',
122
- color: activeMode?.cardForeground || '#000000',
123
- borderColor: activeMode?.border || '#e2e8f0'
124
- },
125
- children: [
126
- /*#__PURE__*/ _jsx("h3", {
127
- children: "Secondary Card"
128
- }),
129
- /*#__PURE__*/ _jsx("p", {
130
- style: {
131
- color: activeMode?.mutedForeground
132
- },
133
- children: "Another card to showcase your theme"
134
- }),
135
- /*#__PURE__*/ _jsx("button", {
136
- className: "preview-btn-secondary",
137
- style: {
138
- backgroundColor: activeMode?.secondary || '#f1f5f9',
139
- color: activeMode?.secondaryForeground || '#0f172a'
140
- },
141
- children: "Secondary"
142
- })
143
- ]
144
- })
145
- ]
146
- }),
147
- /*#__PURE__*/ _jsxs("div", {
148
- className: "preview-ui-elements",
149
- children: [
150
- /*#__PURE__*/ _jsx("input", {
151
- type: "text",
152
- placeholder: "Input field",
153
- className: "preview-input",
154
- style: {
155
- backgroundColor: activeMode?.background,
156
- color: activeMode?.foreground,
157
- borderColor: activeMode?.input || activeMode?.border
158
- }
159
- }),
160
- /*#__PURE__*/ _jsx("div", {
161
- className: "preview-badge",
162
- style: {
163
- backgroundColor: activeMode?.accent || '#f1f5f9',
164
- color: activeMode?.accentForeground || '#0f172a'
165
- },
166
- children: "Accent Badge"
167
- }),
168
- /*#__PURE__*/ _jsx("button", {
169
- className: "preview-btn-destructive",
170
- style: {
171
- backgroundColor: activeMode?.destructive || '#ef4444',
172
- color: activeMode?.destructiveForeground || '#ffffff'
173
- },
174
- children: "Destructive"
175
- })
176
- ]
177
- }),
178
- /*#__PURE__*/ _jsx("div", {
179
- className: "preview-muted",
180
- style: {
181
- backgroundColor: activeMode?.muted || '#f1f5f9',
182
- color: activeMode?.mutedForeground || '#64748b'
183
- },
184
- children: /*#__PURE__*/ _jsx("p", {
185
- children: "Muted background section for less prominent content"
186
- })
187
- })
188
- ]
189
- })
190
- ]
191
- });
192
- };
193
- export default ThemeLivePreview;
194
-
195
- //# sourceMappingURL=ThemeLivePreview.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/fields/ThemeLivePreview.tsx"],"sourcesContent":["'use client'\n\n/**\n * Theme Live Preview Component\n * Real-time preview of theme configuration\n * Inspired by Payload CMS 3 Live Preview\n */\nimport { useFormFields } from '@payloadcms/ui'\nimport { useState } from 'react'\n\n// Import CSS only in browser environment\n// This prevents Node.js from trying to import CSS directly\n// which causes ERR_UNKNOWN_FILE_EXTENSION error\nif (typeof window !== 'undefined') {\n // @ts-expect-error - Dynamic import of CSS is not recognized by TypeScript\n import('./ThemeLivePreview.css').catch((err) => {\n console.warn('Failed to load CSS file:', err)\n })\n}\n\nexport const ThemeLivePreview = () => {\n const allFields = useFormFields(([fields]) => fields)\n const [previewMode, setPreviewMode] = useState<'light' | 'dark'>('light')\n\n const themeConfig = allFields?.themeConfiguration?.value as Record<string, unknown> | undefined\n\n // Extract colors from theme configuration\n // Support both basic (lightMode/darkMode) and extended (extendedLightMode/extendedDarkMode)\n const lightMode = (themeConfig?.extendedLightMode || themeConfig?.lightMode) as\n | Record<string, string>\n | undefined\n const darkMode = (themeConfig?.extendedDarkMode || themeConfig?.darkMode) as\n | Record<string, string>\n | undefined\n const activeMode = previewMode === 'light' ? lightMode : darkMode\n\n if (!themeConfig) {\n return (\n <div className=\"theme-live-preview-empty\">\n <p>Configure your theme to see live preview</p>\n </div>\n )\n }\n\n return (\n <div className=\"theme-live-preview-container\" data-mode={previewMode}>\n {/* Mode Toggle */}\n <div className=\"preview-header\">\n <h3>Live Theme Preview</h3>\n <div className=\"mode-toggle\">\n <button\n type=\"button\"\n className={previewMode === 'light' ? 'active' : ''}\n onClick={() => setPreviewMode('light')}\n >\n ☀️ Light\n </button>\n <button\n type=\"button\"\n className={previewMode === 'dark' ? 'active' : ''}\n onClick={() => setPreviewMode('dark')}\n >\n 🌙 Dark\n </button>\n </div>\n </div>\n\n {/* Preview Content */}\n <div\n className=\"preview-content\"\n style={{\n backgroundColor: activeMode?.background || '#ffffff',\n color: activeMode?.foreground || '#000000',\n }}\n >\n {/* Header Section */}\n <div className=\"preview-section\">\n <h1 style={{ color: activeMode?.foreground }}>Welcome to Your Site</h1>\n <p style={{ color: activeMode?.mutedForeground }}>\n This is a live preview of your theme configuration\n </p>\n </div>\n\n {/* Card Section */}\n <div className=\"preview-cards\">\n <div\n className=\"preview-card\"\n style={{\n backgroundColor: activeMode?.card || '#ffffff',\n color: activeMode?.cardForeground || '#000000',\n borderColor: activeMode?.border || '#e2e8f0',\n }}\n >\n <h3>Featured Content</h3>\n <p style={{ color: activeMode?.mutedForeground }}>Card component with theme colors</p>\n <button\n className=\"preview-btn-primary\"\n style={{\n backgroundColor: activeMode?.primary || '#0070f3',\n color: activeMode?.primaryForeground || '#ffffff',\n }}\n >\n Primary Action\n </button>\n </div>\n\n <div\n className=\"preview-card\"\n style={{\n backgroundColor: activeMode?.card || '#ffffff',\n color: activeMode?.cardForeground || '#000000',\n borderColor: activeMode?.border || '#e2e8f0',\n }}\n >\n <h3>Secondary Card</h3>\n <p style={{ color: activeMode?.mutedForeground }}>\n Another card to showcase your theme\n </p>\n <button\n className=\"preview-btn-secondary\"\n style={{\n backgroundColor: activeMode?.secondary || '#f1f5f9',\n color: activeMode?.secondaryForeground || '#0f172a',\n }}\n >\n Secondary\n </button>\n </div>\n </div>\n\n {/* UI Elements */}\n <div className=\"preview-ui-elements\">\n <input\n type=\"text\"\n placeholder=\"Input field\"\n className=\"preview-input\"\n style={{\n backgroundColor: activeMode?.background,\n color: activeMode?.foreground,\n borderColor: activeMode?.input || activeMode?.border,\n }}\n />\n\n <div\n className=\"preview-badge\"\n style={{\n backgroundColor: activeMode?.accent || '#f1f5f9',\n color: activeMode?.accentForeground || '#0f172a',\n }}\n >\n Accent Badge\n </div>\n\n <button\n className=\"preview-btn-destructive\"\n style={{\n backgroundColor: activeMode?.destructive || '#ef4444',\n color: activeMode?.destructiveForeground || '#ffffff',\n }}\n >\n Destructive\n </button>\n </div>\n\n {/* Muted Section */}\n <div\n className=\"preview-muted\"\n style={{\n backgroundColor: activeMode?.muted || '#f1f5f9',\n color: activeMode?.mutedForeground || '#64748b',\n }}\n >\n <p>Muted background section for less prominent content</p>\n </div>\n </div>\n </div>\n )\n}\n\nexport default ThemeLivePreview\n"],"names":["useFormFields","useState","window","catch","err","console","warn","ThemeLivePreview","allFields","fields","previewMode","setPreviewMode","themeConfig","themeConfiguration","value","lightMode","extendedLightMode","darkMode","extendedDarkMode","activeMode","div","className","p","data-mode","h3","button","type","onClick","style","backgroundColor","background","color","foreground","h1","mutedForeground","card","cardForeground","borderColor","border","primary","primaryForeground","secondary","secondaryForeground","input","placeholder","accent","accentForeground","destructive","destructiveForeground","muted"],"mappings":"AAAA;;AAEA;;;;CAIC,GACD,SAASA,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,QAAQ,QAAQ,QAAO;AAEhC,yCAAyC;AACzC,2DAA2D;AAC3D,gDAAgD;AAChD,IAAI,OAAOC,WAAW,aAAa;IACjC,2EAA2E;IAC3E,MAAM,CAAC,0BAA0BC,KAAK,CAAC,CAACC;QACtCC,QAAQC,IAAI,CAAC,4BAA4BF;IAC3C;AACF;AAEA,OAAO,MAAMG,mBAAmB;IAC9B,MAAMC,YAAYR,cAAc,CAAC,CAACS,OAAO,GAAKA;IAC9C,MAAM,CAACC,aAAaC,eAAe,GAAGV,SAA2B;IAEjE,MAAMW,cAAcJ,WAAWK,oBAAoBC;IAEnD,0CAA0C;IAC1C,4FAA4F;IAC5F,MAAMC,YAAaH,aAAaI,qBAAqBJ,aAAaG;IAGlE,MAAME,WAAYL,aAAaM,oBAAoBN,aAAaK;IAGhE,MAAME,aAAaT,gBAAgB,UAAUK,YAAYE;IAEzD,IAAI,CAACL,aAAa;QAChB,qBACE,KAACQ;YAAIC,WAAU;sBACb,cAAA,KAACC;0BAAE;;;IAGT;IAEA,qBACE,MAACF;QAAIC,WAAU;QAA+BE,aAAWb;;0BAEvD,MAACU;gBAAIC,WAAU;;kCACb,KAACG;kCAAG;;kCACJ,MAACJ;wBAAIC,WAAU;;0CACb,KAACI;gCACCC,MAAK;gCACLL,WAAWX,gBAAgB,UAAU,WAAW;gCAChDiB,SAAS,IAAMhB,eAAe;0CAC/B;;0CAGD,KAACc;gCACCC,MAAK;gCAC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