@kilivi/payloadcms-theme-management 0.1.5 → 0.1.7

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 (93) hide show
  1. package/README.md +97 -97
  2. package/dist/components/ServerThemeInjector.d.ts +1 -1
  3. package/dist/components/ServerThemeInjector.d.ts.map +1 -1
  4. package/dist/components/{ServerThemeInjector.jsx → ServerThemeInjector.js} +50 -37
  5. package/dist/components/ServerThemeInjector.js.map +1 -0
  6. package/dist/components/ThemePreview.js +318 -0
  7. package/dist/components/ThemePreview.js.map +1 -0
  8. package/dist/components/typographyPreviewUtils.js +12 -17
  9. package/dist/components/typographyPreviewUtils.js.map +1 -1
  10. package/dist/constants/themeFonts.js +94 -24
  11. package/dist/constants/themeFonts.js.map +1 -1
  12. package/dist/fields/ColorPickerField.js +332 -0
  13. package/dist/fields/ColorPickerField.js.map +1 -0
  14. package/dist/fields/RadiusField.js +174 -0
  15. package/dist/fields/RadiusField.js.map +1 -0
  16. package/dist/fields/ThemeColorPickerField.css +138 -138
  17. package/dist/fields/ThemeColorPickerField.js +163 -0
  18. package/dist/fields/ThemeColorPickerField.js.map +1 -0
  19. package/dist/fields/ThemePreviewField.js +558 -0
  20. package/dist/fields/ThemePreviewField.js.map +1 -0
  21. package/dist/fields/ThemeTokenSelectField.js +209 -0
  22. package/dist/fields/ThemeTokenSelectField.js.map +1 -0
  23. package/dist/fields/colorModeFields.js +167 -73
  24. package/dist/fields/colorModeFields.js.map +1 -1
  25. package/dist/fields/themeConfigurationField.d.ts +1 -1
  26. package/dist/fields/themeConfigurationField.d.ts.map +1 -1
  27. package/dist/fields/themeConfigurationField.js +227 -134
  28. package/dist/fields/themeConfigurationField.js.map +1 -1
  29. package/dist/index.d.ts +17 -16
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +52 -52
  32. package/dist/index.js.map +1 -1
  33. package/dist/payload-types.js +5 -5
  34. package/dist/payload-types.js.map +1 -1
  35. package/dist/plugin.d.ts +1 -2
  36. package/dist/plugin.d.ts.map +1 -1
  37. package/dist/plugin.js +2 -1
  38. package/dist/plugin.js.map +1 -1
  39. package/dist/presets.js +66 -65
  40. package/dist/presets.js.map +1 -1
  41. package/dist/providers/Theme/index.d.ts +1 -1
  42. package/dist/providers/Theme/index.d.ts.map +1 -1
  43. package/dist/providers/Theme/{index.jsx → index.js} +61 -31
  44. package/dist/providers/Theme/index.js.map +1 -0
  45. package/dist/providers/Theme/shared.d.ts +1 -1
  46. package/dist/providers/Theme/shared.d.ts.map +1 -1
  47. package/dist/providers/Theme/shared.js +34 -9
  48. package/dist/providers/Theme/shared.js.map +1 -1
  49. package/dist/providers/Theme/themeConfig.d.ts +1 -1
  50. package/dist/providers/Theme/themeConfig.d.ts.map +1 -1
  51. package/dist/providers/Theme/themeConfig.js +37 -36
  52. package/dist/providers/Theme/themeConfig.js.map +1 -1
  53. package/dist/providers/Theme/types.js +15 -13
  54. package/dist/providers/Theme/types.js.map +1 -1
  55. package/dist/server.d.ts +2 -2
  56. package/dist/server.d.ts.map +1 -1
  57. package/dist/server.js +3 -2
  58. package/dist/server.js.map +1 -1
  59. package/dist/src/--verbose/dist/fields/ThemeColorPickerField.scss +138 -0
  60. package/dist/src/dist/fields/ThemeColorPickerField.scss +138 -0
  61. package/dist/types.d.ts +2 -2
  62. package/dist/types.d.ts.map +1 -1
  63. package/dist/types.js +2 -1
  64. package/dist/types.js.map +1 -1
  65. package/dist/utils/resolveThemeConfiguration.d.ts +3 -3
  66. package/dist/utils/resolveThemeConfiguration.d.ts.map +1 -1
  67. package/dist/utils/resolveThemeConfiguration.js +53 -34
  68. package/dist/utils/resolveThemeConfiguration.js.map +1 -1
  69. package/dist/utils/themeAssets.d.ts +1 -1
  70. package/dist/utils/themeAssets.d.ts.map +1 -1
  71. package/dist/utils/themeAssets.js +4 -4
  72. package/dist/utils/themeAssets.js.map +1 -1
  73. package/dist/utils/themeColors.js +95 -41
  74. package/dist/utils/themeColors.js.map +1 -1
  75. package/dist/utils/themeUtils.d.ts +2 -2
  76. package/dist/utils/themeUtils.d.ts.map +1 -1
  77. package/dist/utils/themeUtils.js +38 -53
  78. package/dist/utils/themeUtils.js.map +1 -1
  79. package/package.json +13 -5
  80. package/dist/components/ServerThemeInjector.jsx.map +0 -1
  81. package/dist/components/ThemePreview.jsx +0 -231
  82. package/dist/components/ThemePreview.jsx.map +0 -1
  83. package/dist/fields/ColorPickerField.jsx +0 -205
  84. package/dist/fields/ColorPickerField.jsx.map +0 -1
  85. package/dist/fields/RadiusField.jsx +0 -123
  86. package/dist/fields/RadiusField.jsx.map +0 -1
  87. package/dist/fields/ThemeColorPickerField.jsx +0 -110
  88. package/dist/fields/ThemeColorPickerField.jsx.map +0 -1
  89. package/dist/fields/ThemePreviewField.jsx +0 -420
  90. package/dist/fields/ThemePreviewField.jsx.map +0 -1
  91. package/dist/fields/ThemeTokenSelectField.jsx +0 -151
  92. package/dist/fields/ThemeTokenSelectField.jsx.map +0 -1
  93. package/dist/providers/Theme/index.jsx.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/ThemePreview.tsx"],"sourcesContent":["'use client'\r\n\r\nimport { useField } from '@payloadcms/ui'\r\nimport React, { useMemo } from 'react'\r\nimport { themeIsValid } from '../providers/Theme/types.js'\r\nimport { defaultThemePresets } from '../presets.js'\r\n\r\nconst DEFAULT_THEME_KEY = 'cool'\r\nconst basePresetMap = defaultThemePresets.reduce<\r\n Record<string, (typeof defaultThemePresets)[number]>\r\n>((accumulator, preset) => {\r\n accumulator[preset.name] = preset\r\n return accumulator\r\n}, {})\r\n\r\nconst fallbackPreset = basePresetMap[DEFAULT_THEME_KEY] ?? defaultThemePresets[0]\r\nconst fallbackLightMode = fallbackPreset?.lightMode ?? {\r\n primary: '#3b82f6',\r\n accent: '#06b6d4',\r\n background: '#ffffff',\r\n foreground: '#1f2937',\r\n}\r\n\r\nexport default function ThemePreview() {\r\n // Get individual field values using useField hooks\r\n const { value: selectedTheme } = useField<string>({ path: 'themeConfiguration.theme' })\r\n const { value: primaryColor } = useField<string>({\r\n path: 'themeConfiguration.customization.primaryColor',\r\n })\r\n const { value: accentColor } = useField<string>({\r\n path: 'themeConfiguration.customization.accentColor',\r\n })\r\n const { value: backgroundColor } = useField<string>({\r\n path: 'themeConfiguration.customization.backgroundColor',\r\n })\r\n const { value: textColor } = useField<string>({\r\n path: 'themeConfiguration.customization.textColor',\r\n })\r\n\r\n // Determine current theme and if overrides are active\r\n const currentTheme = themeIsValid(selectedTheme)\r\n ? selectedTheme\r\n : (fallbackPreset?.name ?? 'cool')\r\n const hasOverrides = Boolean(primaryColor || accentColor || backgroundColor || textColor)\r\n\r\n const themeColors = useMemo(() => {\r\n const preset = basePresetMap[currentTheme] ?? fallbackPreset\r\n const lightMode = preset?.lightMode ?? fallbackLightMode\r\n\r\n return {\r\n primary: lightMode?.primary ?? fallbackLightMode.primary,\r\n accent:\r\n lightMode?.accent ??\r\n lightMode?.secondary ??\r\n fallbackLightMode.accent ??\r\n fallbackLightMode.primary,\r\n background: lightMode?.background ?? fallbackLightMode.background,\r\n text: lightMode?.foreground ?? fallbackLightMode.foreground,\r\n }\r\n }, [currentTheme])\r\n\r\n const currentColors = useMemo(\r\n () => ({\r\n primary: primaryColor || themeColors.primary,\r\n accent: accentColor || themeColors.accent,\r\n background: backgroundColor || themeColors.background,\r\n text: textColor || themeColors.text,\r\n }),\r\n [primaryColor, accentColor, backgroundColor, textColor, themeColors],\r\n )\r\n\r\n return (\r\n <div className=\"theme-preview\" style={{ marginTop: '20px' }}>\r\n <div\r\n style={{\r\n fontSize: '16px',\r\n fontWeight: '600',\r\n marginBottom: '16px',\r\n color: '#374151',\r\n }}\r\n >\r\n 🎨 Live Theme Preview\r\n </div>\r\n\r\n <div\r\n className=\"preview-container\"\r\n style={{\r\n border: '2px solid #e5e7eb',\r\n borderRadius: '12px',\r\n overflow: 'hidden',\r\n backgroundColor: currentColors.background,\r\n color: currentColors.text,\r\n minHeight: '300px',\r\n }}\r\n >\r\n {/* Header */}\r\n <div\r\n style={{\r\n backgroundColor: currentColors.primary,\r\n color: currentColors.background,\r\n padding: '16px 24px',\r\n display: 'flex',\r\n justifyContent: 'space-between',\r\n alignItems: 'center',\r\n }}\r\n >\r\n <div style={{ fontSize: '20px', fontWeight: '700' }}>Your Website</div>\r\n <nav style={{ display: 'flex', gap: '24px', fontSize: '14px' }}>\r\n <span>Home</span>\r\n <span>About</span>\r\n <span>Services</span>\r\n <span>Contact</span>\r\n </nav>\r\n </div>\r\n\r\n {/* Content */}\r\n <div style={{ padding: '32px 24px' }}>\r\n <h1\r\n style={{\r\n fontSize: '32px',\r\n fontWeight: '800',\r\n marginBottom: '16px',\r\n color: currentColors.text,\r\n }}\r\n >\r\n Welcome to Your Site\r\n </h1>\r\n\r\n <p\r\n style={{\r\n fontSize: '16px',\r\n lineHeight: '1.6',\r\n marginBottom: '24px',\r\n color: currentColors.text,\r\n opacity: 0.8,\r\n }}\r\n >\r\n This is how your content will look with the selected theme. The colors and styling will\r\n be applied across your entire website.\r\n </p>\r\n\r\n {/* Buttons */}\r\n <div style={{ display: 'flex', gap: '12px', marginBottom: '32px' }}>\r\n <button\r\n style={{\r\n backgroundColor: currentColors.primary,\r\n color: currentColors.background,\r\n border: 'none',\r\n padding: '12px 24px',\r\n borderRadius: '6px',\r\n fontSize: '14px',\r\n fontWeight: '600',\r\n cursor: 'pointer',\r\n }}\r\n >\r\n Primary Button\r\n </button>\r\n <button\r\n style={{\r\n backgroundColor: 'transparent',\r\n color: currentColors.primary,\r\n border: `2px solid ${currentColors.primary}`,\r\n padding: '10px 24px',\r\n borderRadius: '6px',\r\n fontSize: '14px',\r\n fontWeight: '600',\r\n cursor: 'pointer',\r\n }}\r\n >\r\n Secondary Button\r\n </button>\r\n </div>\r\n\r\n {/* Card */}\r\n <div\r\n style={{\r\n backgroundColor: currentColors.text,\r\n color: currentColors.background,\r\n padding: '24px',\r\n borderRadius: '8px',\r\n opacity: 0.05,\r\n marginBottom: '16px',\r\n }}\r\n />\r\n <div\r\n style={{\r\n border: `1px solid ${currentColors.text}`,\r\n padding: '20px',\r\n borderRadius: '8px',\r\n opacity: 0.1,\r\n }}\r\n >\r\n <h3\r\n style={{\r\n fontSize: '18px',\r\n fontWeight: '600',\r\n marginBottom: '12px',\r\n color: currentColors.text,\r\n }}\r\n >\r\n Sample Card\r\n </h3>\r\n <p\r\n style={{\r\n fontSize: '14px',\r\n color: currentColors.text,\r\n opacity: 0.7,\r\n }}\r\n >\r\n This shows how cards and content blocks will appear.\r\n </p>\r\n </div>\r\n </div>\r\n\r\n {/* Footer */}\r\n <div\r\n style={{\r\n backgroundColor: currentColors.accent,\r\n color: currentColors.background,\r\n padding: '16px 24px',\r\n textAlign: 'center',\r\n fontSize: '14px',\r\n marginTop: 'auto',\r\n }}\r\n >\r\n © 2025 Your Website. Powered by PayloadCMS.\r\n </div>\r\n </div>\r\n\r\n {/* Theme info */}\r\n <div\r\n style={{\r\n marginTop: '12px',\r\n fontSize: '12px',\r\n color: '#6b7280',\r\n display: 'grid',\r\n gridTemplateColumns: 'repeat(2, 1fr)',\r\n gap: '8px',\r\n }}\r\n >\r\n <div>\r\n <strong>Active Theme:</strong> {currentTheme}\r\n </div>\r\n <div>\r\n <strong>Primary:</strong> {currentColors.primary}\r\n </div>\r\n <div>\r\n <strong>Accent:</strong> {currentColors.accent}\r\n </div>\r\n <div>\r\n <strong>Background:</strong> {currentColors.background}\r\n </div>\r\n </div>\r\n\r\n {/* Customization indicator */}\r\n {hasOverrides && (\r\n <div\r\n style={{\r\n marginTop: '8px',\r\n padding: '8px 12px',\r\n backgroundColor: '#fef3c7',\r\n borderRadius: '6px',\r\n fontSize: '11px',\r\n color: '#92400e',\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '6px',\r\n }}\r\n >\r\n <span>⚡</span>\r\n <span>\r\n <strong>Custom colors applied</strong> - overriding theme defaults\r\n </span>\r\n </div>\r\n )}\r\n </div>\r\n )\r\n}\r\n"],"names":["useField","React","useMemo","themeIsValid","defaultThemePresets","DEFAULT_THEME_KEY","basePresetMap","reduce","accumulator","preset","name","fallbackPreset","fallbackLightMode","lightMode","primary","accent","background","foreground","ThemePreview","value","selectedTheme","path","primaryColor","accentColor","backgroundColor","textColor","currentTheme","hasOverrides","Boolean","themeColors","secondary","text","currentColors","div","className","style","marginTop","fontSize","fontWeight","marginBottom","color","border","borderRadius","overflow","minHeight","padding","display","justifyContent","alignItems","nav","gap","span","h1","p","lineHeight","opacity","button","cursor","h3","textAlign","gridTemplateColumns","strong"],"mappings":"AAAA;;AAEA,SAASA,QAAQ,QAAQ,iBAAgB;AACzC,OAAOC,SAASC,OAAO,QAAQ,QAAO;AACtC,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,mBAAmB,QAAQ,gBAAe;AAEnD,MAAMC,oBAAoB;AAC1B,MAAMC,gBAAgBF,oBAAoBG,MAAM,CAE9C,CAACC,aAAaC;IACdD,WAAW,CAACC,OAAOC,IAAI,CAAC,GAAGD;IAC3B,OAAOD;AACT,GAAG,CAAC;AAEJ,MAAMG,iBAAiBL,aAAa,CAACD,kBAAkB,IAAID,mBAAmB,CAAC,EAAE;AACjF,MAAMQ,oBAAoBD,gBAAgBE,aAAa;IACrDC,SAAS;IACTC,QAAQ;IACRC,YAAY;IACZC,YAAY;AACd;AAEA,eAAe,SAASC;IACtB,mDAAmD;IACnD,MAAM,EAAEC,OAAOC,aAAa,EAAE,GAAGpB,SAAiB;QAAEqB,MAAM;IAA2B;IACrF,MAAM,EAAEF,OAAOG,YAAY,EAAE,GAAGtB,SAAiB;QAC/CqB,MAAM;IACR;IACA,MAAM,EAAEF,OAAOI,WAAW,EAAE,GAAGvB,SAAiB;QAC9CqB,MAAM;IACR;IACA,MAAM,EAAEF,OAAOK,eAAe,EAAE,GAAGxB,SAAiB;QAClDqB,MAAM;IACR;IACA,MAAM,EAAEF,OAAOM,SAAS,EAAE,GAAGzB,SAAiB;QAC5CqB,M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ET,cAAcD,IAAI,EAAE;oCACzCc,SAAS;oCACTH,cAAc;oCACda,SAAS;gCACX;;kDAEA,KAACG;wCACCvB,OAAO;4CACLE,UAAU;4CACVC,YAAY;4CACZC,cAAc;4CACdC,OAAOR,cAAcD,IAAI;wCAC3B;kDACD;;kDAGD,KAACsB;wCACClB,OAAO;4CACLE,UAAU;4CACVG,OAAOR,cAAcD,IAAI;4CACzBwB,SAAS;wCACX;kDACD;;;;;;kCAOL,KAACtB;wBACCE,OAAO;4BACLX,iBAAiBQ,cAAcjB,MAAM;4BACrCyB,OAAOR,cAAchB,UAAU;4BAC/B6B,SAAS;4BACTc,WAAW;4BACXtB,UAAU;4BACVD,WAAW;wBACb;kCACD;;;;0BAMH,MAACH;gBACCE,OAAO;oBACLC,WAAW;oBACXC,UAAU;oBACVG,OAAO;oBACPM,SAAS;oBACTc,qBAAqB;oBACrBV,KAAK;gBACP;;kCAEA,MAACjB;;0CACC,KAAC4B;0CAAO;;4BAAsB;4BAAEnC;;;kCAElC,MAACO;;0CACC,KAAC4B;0CAAO;;4BAAiB;4BAAE7B,cAAclB,OAAO;;;kCAElD,MAACmB;;0CACC,KAAC4B;0CAAO;;4BAAgB;4BAAE7B,cAAcjB,MAAM;;;kCAEhD,MAACkB;;0CACC,KAAC4B;0CAAO;;4BAAoB;4BAAE7B,cAAchB,UAAU;;;;;YAKzDW,8BACC,MAACM;gBACCE,OAAO;oBACLC,WAAW;oBACXS,SAAS;oBACTrB,iBAAiB;oBACjBkB,cAAc;oBACdL,UAAU;oBACVG,OAAO;oBACPM,SAAS;oBACTE,YAAY;oBACZE,KAAK;gBACP;;kCAEA,KAACC;kCAAK;;kCACN,MAACA;;0CACC,KAACU;0CAAO;;4BAA8B;;;;;;;AAMlD"}
@@ -1,7 +1,7 @@
1
- import { BODY_FONT_OPTIONS, FONT_VALUE_TO_CSS, HEADING_FONT_OPTIONS } from '@/constants/themeFonts';
2
- import { defaultThemePresets } from '../presets';
1
+ import { BODY_FONT_OPTIONS, FONT_VALUE_TO_CSS, HEADING_FONT_OPTIONS } from '../constants/themeFonts.js';
2
+ import { defaultThemePresets } from '../presets.js';
3
3
  const FALLBACK_THEME = defaultThemePresets[0]?.name ?? 'cool';
4
- const fallbackPreset = defaultThemePresets.find((preset) => preset.name === FALLBACK_THEME) ?? defaultThemePresets[0];
4
+ const fallbackPreset = defaultThemePresets.find((preset)=>preset.name === FALLBACK_THEME) ?? defaultThemePresets[0];
5
5
  const FONT_VAR_FALLBACK = {
6
6
  'var(--font-geist-sans)': '"Geist Sans", system-ui, sans-serif',
7
7
  'var(--font-geist-mono)': '"Geist Mono", SFMono-Regular, ui-monospace, monospace',
@@ -10,11 +10,10 @@ const FONT_VAR_FALLBACK = {
10
10
  'var(--font-playfair)': '"Playfair Display", "Times New Roman", serif',
11
11
  'var(--font-lora)': '"Lora", "Times New Roman", serif',
12
12
  'var(--font-manrope)': '"Manrope", system-ui, sans-serif',
13
- 'var(--font-urbanist)': '"Urbanist", system-ui, sans-serif',
13
+ 'var(--font-urbanist)': '"Urbanist", system-ui, sans-serif'
14
14
  };
15
15
  function withFallback(fontFamily, fallback) {
16
- if (!fontFamily)
17
- return fallback;
16
+ if (!fontFamily) return fallback;
18
17
  if (fontFamily.startsWith('var(')) {
19
18
  const mappedFallback = FONT_VAR_FALLBACK[fontFamily] ?? fallback;
20
19
  return `${fontFamily}, ${mappedFallback}`;
@@ -22,7 +21,7 @@ function withFallback(fontFamily, fallback) {
22
21
  return fontFamily;
23
22
  }
24
23
  function getPresetTypography(themeName) {
25
- const preset = defaultThemePresets.find((item) => item.name === themeName) ?? fallbackPreset;
24
+ const preset = defaultThemePresets.find((item)=>item.name === themeName) ?? fallbackPreset;
26
25
  return preset?.typography;
27
26
  }
28
27
  function resolveFontFamily(value, customValue, fallback) {
@@ -42,9 +41,8 @@ function resolveFontFamily(value, customValue, fallback) {
42
41
  return withFallback(fallback, fallbackPreset?.typography?.fontFamily ?? 'system-ui, sans-serif');
43
42
  }
44
43
  function resolveOptionLabel(options, value, locale = 'en') {
45
- const option = options.find((item) => item.value === value);
46
- if (!option)
47
- return value ?? '';
44
+ const option = options.find((item)=>item.value === value);
45
+ if (!option) return value ?? '';
48
46
  if (typeof option.label === 'string') {
49
47
  return option.label;
50
48
  }
@@ -62,19 +60,16 @@ export function resolveTypographyPreview(selection, themeName) {
62
60
  const headingFontCustom = selection?.headingFontCustom ?? undefined;
63
61
  const resolvedBodyFont = resolveFontFamily(bodyFontValue, bodyFontCustom, fallbackBody);
64
62
  const resolvedHeadingFont = resolveFontFamily(headingFontValue, headingFontCustom, fallbackHeading);
65
- const baseFontSize = selection?.baseFontSize && selection.baseFontSize !== 'preset'
66
- ? selection.baseFontSize
67
- : fallbackSize;
68
- const lineHeight = selection?.lineHeight && selection.lineHeight !== 'preset'
69
- ? selection.lineHeight
70
- : fallbackLineHeight;
63
+ const baseFontSize = selection?.baseFontSize && selection.baseFontSize !== 'preset' ? selection.baseFontSize : fallbackSize;
64
+ const lineHeight = selection?.lineHeight && selection.lineHeight !== 'preset' ? selection.lineHeight : fallbackLineHeight;
71
65
  return {
72
66
  bodyFont: resolvedBodyFont,
73
67
  headingFont: resolvedHeadingFont,
74
68
  baseFontSize,
75
69
  lineHeight,
76
70
  bodyLabel: resolveOptionLabel(BODY_FONT_OPTIONS, bodyFontValue),
77
- headingLabel: resolveOptionLabel(HEADING_FONT_OPTIONS, headingFontValue),
71
+ headingLabel: resolveOptionLabel(HEADING_FONT_OPTIONS, headingFontValue)
78
72
  };
79
73
  }
74
+
80
75
  //# sourceMappingURL=typographyPreviewUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typographyPreviewUtils.js","sourceRoot":"","sources":["../../src/components/typographyPreviewUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AACnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAoBhD,MAAM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1
+ {"version":3,"sources":["../../src/components/typographyPreviewUtils.ts"],"sourcesContent":["import { BODY_FONT_OPTIONS, FONT_VALUE_TO_CSS, HEADING_FONT_OPTIONS } from '../constants/themeFonts.js'\r\nimport { defaultThemePresets } from '../presets.js'\r\n\r\nexport interface TypographySelection {\r\n bodyFont?: string | null\r\n headingFont?: string | null\r\n bodyFontCustom?: string | null\r\n headingFontCustom?: string | null\r\n baseFontSize?: string | null\r\n lineHeight?: string | null\r\n}\r\n\r\nexport interface ResolvedTypographyPreview {\r\n bodyFont: string\r\n headingFont: string\r\n baseFontSize: string\r\n lineHeight: string\r\n bodyLabel: string\r\n headingLabel: string\r\n}\r\n\r\nconst FALLBACK_THEME = defaultThemePresets[0]?.name ?? 'cool'\r\nconst fallbackPreset =\r\n defaultThemePresets.find((preset) => preset.name === FALLBACK_THEME) ?? defaultThemePresets[0]\r\n\r\nconst FONT_VAR_FALLBACK: Record<string, string> = {\r\n 'var(--font-geist-sans)': '\"Geist Sans\", system-ui, sans-serif',\r\n 'var(--font-geist-mono)': '\"Geist Mono\", SFMono-Regular, ui-monospace, monospace',\r\n 'var(--font-inter)': '\"Inter\", system-ui, sans-serif',\r\n 'var(--font-outfit)': '\"Outfit\", system-ui, sans-serif',\r\n 'var(--font-playfair)': '\"Playfair Display\", \"Times New Roman\", serif',\r\n 'var(--font-lora)': '\"Lora\", \"Times New Roman\", serif',\r\n 'var(--font-manrope)': '\"Manrope\", system-ui, sans-serif',\r\n 'var(--font-urbanist)': '\"Urbanist\", system-ui, sans-serif',\r\n}\r\n\r\nfunction withFallback(fontFamily: string, fallback: string): string {\r\n if (!fontFamily) return fallback\r\n\r\n if (fontFamily.startsWith('var(')) {\r\n const mappedFallback = FONT_VAR_FALLBACK[fontFamily] ?? fallback\r\n return `${fontFamily}, ${mappedFallback}`\r\n }\r\n\r\n return fontFamily\r\n}\r\n\r\nfunction getPresetTypography(themeName?: string) {\r\n const preset = defaultThemePresets.find((item) => item.name === themeName) ?? fallbackPreset\r\n return preset?.typography\r\n}\r\n\r\nfunction resolveFontFamily(\r\n value: string | null | undefined,\r\n customValue: string | null | undefined,\r\n fallback: string,\r\n): string {\r\n if (!value || value === 'preset') {\r\n return withFallback(fallback, fallbackPreset?.typography?.fontFamily ?? 'system-ui, sans-serif')\r\n }\r\n\r\n if (value === 'custom') {\r\n if (customValue && customValue.trim().length > 0) {\r\n return customValue.trim()\r\n }\r\n return withFallback(fallback, fallbackPreset?.typography?.fontFamily ?? 'system-ui, sans-serif')\r\n }\r\n\r\n const preconfigured = FONT_VALUE_TO_CSS[value]\r\n if (preconfigured) {\r\n return withFallback(\r\n preconfigured,\r\n fallbackPreset?.typography?.fontFamily ?? 'system-ui, sans-serif',\r\n )\r\n }\r\n\r\n return withFallback(fallback, fallbackPreset?.typography?.fontFamily ?? 'system-ui, sans-serif')\r\n}\r\n\r\nfunction resolveOptionLabel(\r\n options: ReadonlyArray<{ label: string | Record<string, string>; value: string }>,\r\n value?: string | null,\r\n locale: 'en' | 'cs' = 'en',\r\n): string {\r\n const option = options.find((item) => item.value === value)\r\n if (!option) return value ?? ''\r\n if (typeof option.label === 'string') {\r\n return option.label\r\n }\r\n return option.label?.[locale] ?? Object.values(option.label)[0] ?? option.value\r\n}\r\n\r\nexport function resolveTypographyPreview(\r\n selection: TypographySelection | null | undefined,\r\n themeName?: string,\r\n): ResolvedTypographyPreview {\r\n const presetTypography = getPresetTypography(themeName)\r\n const fallbackBody = presetTypography?.fontFamily ?? 'system-ui, sans-serif'\r\n const fallbackHeading = presetTypography?.headingFamily ?? fallbackBody\r\n const fallbackSize = presetTypography?.baseFontSize ?? '16px'\r\n const fallbackLineHeight = presetTypography?.lineHeight ?? '1.6'\r\n\r\n const bodyFontValue = selection?.bodyFont ?? 'preset'\r\n const headingFontValue = selection?.headingFont ?? 'preset'\r\n const bodyFontCustom = selection?.bodyFontCustom ?? undefined\r\n const headingFontCustom = selection?.headingFontCustom ?? undefined\r\n const resolvedBodyFont = resolveFontFamily(bodyFontValue, bodyFontCustom, fallbackBody)\r\n const resolvedHeadingFont = resolveFontFamily(\r\n headingFontValue,\r\n headingFontCustom,\r\n fallbackHeading,\r\n )\r\n\r\n const baseFontSize =\r\n selection?.baseFontSize && selection.baseFontSize !== 'preset'\r\n ? selection.baseFontSize\r\n : fallbackSize\r\n const lineHeight =\r\n selection?.lineHeight && selection.lineHeight !== 'preset'\r\n ? selection.lineHeight\r\n : fallbackLineHeight\r\n\r\n return {\r\n bodyFont: resolvedBodyFont,\r\n headingFont: resolvedHeadingFont,\r\n baseFontSize,\r\n lineHeight,\r\n bodyLabel: resolveOptionLabel(BODY_FONT_OPTIONS, bodyFontValue),\r\n headingLabel: resolveOptionLabel(HEADING_FONT_OPTIONS, headingFontValue),\r\n }\r\n}\r\n"],"names":["BODY_FONT_OPTIONS","FONT_VALUE_TO_CSS","HEADING_FONT_OPTIONS","defaultThemePresets","FALLBACK_THEME","name","fallbackPreset","find","preset","FONT_VAR_FALLBACK","withFallback","fontFamily","fallback","startsWith","mappedFallback","getPresetTypography","themeName","item","typography","resolveFontFamily","value","customValue","trim","length","preconfigured","resolveOptionLabel","options","locale","option","label","Object","values","resolveTypographyPreview","selection","presetTypography","fallbackBody","fallbackHeading","headingFamily","fallbackSize","baseFontSize","fallbackLineHeight","lineHeight","bodyFontValue","bodyFont","headingFontValue","headingFont","bodyFontCustom","undefined","headingFontCustom","resolvedBodyFont","resolvedHeadingFont","bodyLabel","headingLabel"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,iBAAiB,EAAEC,oBAAoB,QAAQ,6BAA4B;AACvG,SAASC,mBAAmB,QAAQ,gBAAe;AAoBnD,MAAMC,iBAAiBD,mBAAmB,CAAC,EAAE,EAAEE,QAAQ;AACvD,MAAMC,iBACJH,oBAAoBI,IAAI,CAAC,CAACC,SAAWA,OAAOH,IAAI,KAAKD,mBAAmBD,mBAAmB,CAAC,EAAE;AAEhG,MAAMM,oBAA4C;IAChD,0BAA0B;IAC1B,0BAA0B;I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AOD,OAAOC,KAAK,EAAE,CAACF,OAAO,IAAIG,OAAOC,MAAM,CAACH,OAAOC,KAAK,CAAC,CAAC,EAAE,IAAID,OAAOR,KAAK;AACjF;AAEA,OAAO,SAASY,yBACdC,SAAiD,EACjDjB,SAAkB;IAElB,MAAMkB,mBAAmBnB,oBAAoBC;IAC7C,MAAMmB,eAAeD,kBAAkBvB,cAAc;IACrD,MAAMyB,kBAAkBF,kBAAkBG,iBAAiBF;IAC3D,MAAMG,eAAeJ,kBAAkBK,gBAAgB;IACvD,MAAMC,qBAAqBN,kBAAkBO,cAAc;IAE3D,MAAMC,gBAAgBT,WAAWU,YAAY;IAC7C,MAAMC,mBAAmBX,WAAWY,eAAe;IACnD,MAAMC,iBAAiBb,WAAWa,kBAAkBC;IACpD,MAAMC,oBAAoBf,WAAWe,qBAAqBD;IAC1D,MAAME,mBAAmB9B,kBAAkBuB,eAAeI,gBAAgBX;IAC1E,MAAMe,sBAAsB/B,kBAC1ByB,kBACAI,mBACAZ;IAGF,MAAMG,eACJN,WAAWM,gBAAgBN,UAAUM,YAAY,KAAK,WAClDN,UAAUM,YAAY,GACtBD;IACN,MAAMG,aACJR,WAAWQ,cAAcR,UAAUQ,UAAU,KAAK,WAC9CR,UAAUQ,UAAU,GACpBD;IAEN,OAAO;QACLG,UAAUM;QACVJ,aAAaK;QACbX;QACAE;QACAU,WAAW1B,mBAAmBzB,mBAAmB0C;QACjDU,cAAc3B,mBAAmBvB,sBAAsB0C;IACzD;AACF"}
@@ -1,34 +1,103 @@
1
1
  // Theme font constants for the plugin
2
2
  export const BODY_FONT_OPTIONS = [
3
- { label: 'System', value: 'system-ui' },
4
- { label: 'Inter', value: 'Inter' },
5
- { label: 'Roboto', value: 'Roboto' },
6
- { label: 'Open Sans', value: 'Open Sans' },
7
- { label: 'Lato', value: 'Lato' },
8
- { label: 'Montserrat', value: 'Montserrat' },
9
- { label: 'Poppins', value: 'Poppins' },
3
+ {
4
+ label: 'System',
5
+ value: 'system-ui'
6
+ },
7
+ {
8
+ label: 'Inter',
9
+ value: 'Inter'
10
+ },
11
+ {
12
+ label: 'Roboto',
13
+ value: 'Roboto'
14
+ },
15
+ {
16
+ label: 'Open Sans',
17
+ value: 'Open Sans'
18
+ },
19
+ {
20
+ label: 'Lato',
21
+ value: 'Lato'
22
+ },
23
+ {
24
+ label: 'Montserrat',
25
+ value: 'Montserrat'
26
+ },
27
+ {
28
+ label: 'Poppins',
29
+ value: 'Poppins'
30
+ }
10
31
  ];
11
32
  export const HEADING_FONT_OPTIONS = [
12
- { label: 'System', value: 'system-ui' },
13
- { label: 'Inter', value: 'Inter' },
14
- { label: 'Playfair Display', value: 'Playfair Display' },
15
- { label: 'Merriweather', value: 'Merriweather' },
16
- { label: 'Montserrat', value: 'Montserrat' },
17
- { label: 'Raleway', value: 'Raleway' },
33
+ {
34
+ label: 'System',
35
+ value: 'system-ui'
36
+ },
37
+ {
38
+ label: 'Inter',
39
+ value: 'Inter'
40
+ },
41
+ {
42
+ label: 'Playfair Display',
43
+ value: 'Playfair Display'
44
+ },
45
+ {
46
+ label: 'Merriweather',
47
+ value: 'Merriweather'
48
+ },
49
+ {
50
+ label: 'Montserrat',
51
+ value: 'Montserrat'
52
+ },
53
+ {
54
+ label: 'Raleway',
55
+ value: 'Raleway'
56
+ }
18
57
  ];
19
58
  export const BASE_FONT_SIZE_OPTIONS = [
20
- { label: '14px', value: '14' },
21
- { label: '15px', value: '15' },
22
- { label: '16px', value: '16' },
23
- { label: '17px', value: '17' },
24
- { label: '18px', value: '18' },
59
+ {
60
+ label: '14px',
61
+ value: '14'
62
+ },
63
+ {
64
+ label: '15px',
65
+ value: '15'
66
+ },
67
+ {
68
+ label: '16px',
69
+ value: '16'
70
+ },
71
+ {
72
+ label: '17px',
73
+ value: '17'
74
+ },
75
+ {
76
+ label: '18px',
77
+ value: '18'
78
+ }
25
79
  ];
26
80
  export const LINE_HEIGHT_OPTIONS = [
27
- { label: '1.4', value: '1.4' },
28
- { label: '1.5', value: '1.5' },
29
- { label: '1.6', value: '1.6' },
30
- { label: '1.7', value: '1.7' },
31
- { label: '1.8', value: '1.8' },
81
+ {
82
+ label: '1.4',
83
+ value: '1.4'
84
+ },
85
+ {
86
+ label: '1.5',
87
+ value: '1.5'
88
+ },
89
+ {
90
+ label: '1.6',
91
+ value: '1.6'
92
+ },
93
+ {
94
+ label: '1.7',
95
+ value: '1.7'
96
+ },
97
+ {
98
+ label: '1.8',
99
+ value: '1.8'
100
+ }
32
101
  ];
33
102
  export const FONT_VALUE_TO_CSS = {
34
103
  'system-ui': 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
@@ -40,6 +109,7 @@ export const FONT_VALUE_TO_CSS = {
40
109
  'Poppins': '"Poppins", sans-serif',
41
110
  'Playfair Display': '"Playfair Display", serif',
42
111
  'Merriweather': '"Merriweather", serif',
43
- 'Raleway': '"Raleway", sans-serif',
112
+ 'Raleway': '"Raleway", sans-serif'
44
113
  };
114
+
45
115
  //# sourceMappingURL=themeFonts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"themeFonts.js","sourceRoot":"","sources":["../../src/constants/themeFonts.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE;IACvC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IAClC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;IAC1C,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAChC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAC5C,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;CAC9B,CAAC;AAEX,MAAM,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,sBAAsB;IAChC,WAAW,EAAE,yBAAyB;IACtC,MAAM,EAAE,oBAAoB;IAC5B,YAAY,EAAE,0BAA0B;IACxC,SAAS,EAAE,uBAAuB;IAClC,kBAAkB,EAAE,2BAA2B;IAC/C,cAAc,EAAE,uBAAuB;IACvC,SAAS,EAAE,uBAAuB;CACnC,CAAC"}
1
+ {"version":3,"sources":["../../src/constants/themeFonts.ts"],"sourcesContent":["// Theme font constants for the plugin\r\nexport const BODY_FONT_OPTIONS = [\r\n { label: 'System', value: 'system-ui' },\r\n { label: 'Inter', value: 'Inter' },\r\n { label: 'Roboto', value: 'Roboto' },\r\n { label: 'Open Sans', value: 'Open Sans' },\r\n { label: 'Lato', value: 'Lato' },\r\n { label: 'Montserrat', value: 'Montserrat' },\r\n { label: 'Poppins', value: 'Poppins' },\r\n] as const;\r\n\r\nexport const HEADING_FONT_OPTIONS = [\r\n { label: 'System', value: 'system-ui' },\r\n { label: 'Inter', value: 'Inter' },\r\n { label: 'Playfair Display', value: 'Playfair Display' },\r\n { label: 'Merriweather', value: 'Merriweather' },\r\n { label: 'Montserrat', value: 'Montserrat' },\r\n { label: 'Raleway', value: 'Raleway' },\r\n] as const;\r\n\r\nexport const BASE_FONT_SIZE_OPTIONS = [\r\n { label: '14px', value: '14' },\r\n { label: '15px', value: '15' },\r\n { label: '16px', value: '16' },\r\n { label: '17px', value: '17' },\r\n { label: '18px', value: '18' },\r\n] as const;\r\n\r\nexport const LINE_HEIGHT_OPTIONS = [\r\n { label: '1.4', value: '1.4' },\r\n { label: '1.5', value: '1.5' },\r\n { label: '1.6', value: '1.6' },\r\n { label: '1.7', value: '1.7' },\r\n { label: '1.8', value: '1.8' },\r\n] as const;\r\n\r\nexport const FONT_VALUE_TO_CSS: Record<string, string> = {\r\n 'system-ui': 'system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif',\r\n 'Inter': '\"Inter\", sans-serif',\r\n 'Roboto': '\"Roboto\", sans-serif',\r\n 'Open Sans': '\"Open Sans\", sans-serif',\r\n 'Lato': '\"Lato\", sans-serif',\r\n 'Montserrat': '\"Montserrat\", sans-serif',\r\n 'Poppins': '\"Poppins\", sans-serif',\r\n 'Playfair Display': '\"Playfair Display\", serif',\r\n 'Merriweather': '\"Merriweather\", serif',\r\n 'Raleway': '\"Raleway\", sans-serif',\r\n};\r\n"],"names":["BODY_FONT_OPTIONS","label","value","HEADING_FONT_OPTIONS","BASE_FONT_SIZE_OPTIONS","LINE_HEIGHT_OPTIONS","FONT_VALUE_TO_CSS"],"mappings":"AAAA,sCAAsC;AACtC,OAAO,MAAMA,oBAAoB;IAC/B;QAAEC,OAAO;QAAUC,OAAO;IAAY;IACtC;QAAED,OAAO;QAASC,OAAO;IAAQ;IACjC;QAAED,OAAO;QAAUC,OAAO;IAAS;IACnC;QAAED,OAAO;QAAaC,OAAO;IAAY;IACzC;QAAED,OAAO;QAAQC,OAAO;IAAO;IAC/B;QAAED,OAAO;QAAcC,OAAO;IAAa;IAC3C;QAAED,OAAO;QAAWC,OAAO;IAAU;CACtC,CAAU;AAEX,OAAO,MAAMC,uBAAuB;IAClC;QAAEF,OAAO;QAAUC,OAAO;IAAY;IACtC;QAAED,OAAO;QAASC,OAAO;IAAQ;IACjC;QAAED,OAAO;QAAoBC,OAAO;IAAmB;IACvD;QAAED,OAAO;QAAgBC,OAAO;IAAe;IAC/C;QAAED,OAAO;QAAcC,OAAO;IAAa;IAC3C;QAAED,OAAO;QAAWC,OAAO;IAAU;CACtC,CAAU;AAEX,OAAO,MAAME,yBAAyB;IACpC;QAAEH,OAAO;QAAQC,OAAO;IAAK;IAC7B;QAAED,OAAO;QAAQC,OAAO;IAAK;IAC7B;QAAED,OAAO;QAAQC,OAAO;IAAK;IAC7B;QAAED,OAAO;QAAQC,OAAO;IAAK;IAC7B;QAAED,OAAO;QAAQC,OAAO;IAAK;CAC9B,CAAU;AAEX,OAAO,MAAMG,sBAAsB;IACjC;QAAEJ,OAAO;QAAOC,OAAO;IAAM;IAC7B;QAAED,OAAO;QAAOC,OAAO;IAAM;IAC7B;QAAED,OAAO;QAAOC,OAAO;IAAM;IAC7B;QAAED,OAAO;QAAOC,OAAO;IAAM;IAC7B;QAAED,OAAO;QAAOC,OAAO;IAAM;CAC9B,CAAU;AAEX,OAAO,MAAMI,oBAA4C;IACvD,aAAa;IACb,SAAS;IACT,UAAU;IACV,aAAa;IACb,QAAQ;IACR,cAAc;IACd,WAAW;IACX,oBAAoB;IACpB,gBAAgB;IAChB,WAAW;AACb,EAAE"}
@@ -0,0 +1,332 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useField } from '@payloadcms/ui';
4
+ import { useCallback, useEffect, useRef, useState } from 'react';
5
+ const colorPresets = {
6
+ 'Theme Colors': [
7
+ '#3b82f6',
8
+ '#1e40af',
9
+ '#b45309',
10
+ '#78716c',
11
+ '#8b5cf6',
12
+ '#f97316'
13
+ ],
14
+ 'Common Colors': [
15
+ '#ef4444',
16
+ '#10b981',
17
+ '#f59e0b',
18
+ '#06b6d4',
19
+ '#ec4899',
20
+ '#6b7280'
21
+ ],
22
+ 'Neutral Tones': [
23
+ '#000000',
24
+ '#1f2937',
25
+ '#6b7280',
26
+ '#d1d5db',
27
+ '#f3f4f6',
28
+ '#ffffff'
29
+ ]
30
+ };
31
+ function resolveLocalizedValue(value) {
32
+ if (typeof value === 'string') {
33
+ return value;
34
+ }
35
+ if (typeof value === 'object' && value !== null) {
36
+ const localized = value;
37
+ const fallback = localized.en ?? localized.cs ?? localized[''];
38
+ return typeof fallback === 'string' ? fallback : '';
39
+ }
40
+ return '';
41
+ }
42
+ export default function ColorPickerField(props) {
43
+ const { field, path } = props;
44
+ const { value = '#000000', setValue } = useField({
45
+ path
46
+ });
47
+ const [isPickerOpen, setIsPickerOpen] = useState(false);
48
+ const pickerRef = useRef(null);
49
+ const fieldLabel = resolveLocalizedValue(field.label);
50
+ const fieldDescription = resolveLocalizedValue(field.admin?.description);
51
+ const placeholder = resolveLocalizedValue(field.admin?.placeholder) || 'e.g., #3b82f6, hsl(...)';
52
+ const handleColorChange = useCallback((color)=>{
53
+ setValue(color);
54
+ }, [
55
+ setValue
56
+ ]);
57
+ const handleInputChange = useCallback((event)=>{
58
+ handleColorChange(event.target.value);
59
+ }, [
60
+ handleColorChange
61
+ ]);
62
+ const togglePicker = useCallback(()=>{
63
+ setIsPickerOpen((previous)=>!previous);
64
+ }, []);
65
+ useEffect(()=>{
66
+ if (!isPickerOpen) {
67
+ return;
68
+ }
69
+ function handleClickOutside(event) {
70
+ if (!pickerRef.current) {
71
+ return;
72
+ }
73
+ if (!pickerRef.current.contains(event.target)) {
74
+ setIsPickerOpen(false);
75
+ }
76
+ }
77
+ document.addEventListener('mousedown', handleClickOutside);
78
+ return ()=>{
79
+ document.removeEventListener('mousedown', handleClickOutside);
80
+ };
81
+ }, [
82
+ isPickerOpen
83
+ ]);
84
+ return /*#__PURE__*/ _jsxs("div", {
85
+ className: "field-type color-picker-field",
86
+ style: {
87
+ position: 'relative'
88
+ },
89
+ children: [
90
+ fieldLabel && /*#__PURE__*/ _jsxs("label", {
91
+ htmlFor: path,
92
+ className: "field-label",
93
+ style: {
94
+ display: 'block',
95
+ marginBottom: '8px',
96
+ fontSize: '13px',
97
+ fontWeight: 600
98
+ },
99
+ children: [
100
+ fieldLabel,
101
+ field.required && /*#__PURE__*/ _jsx("span", {
102
+ className: "required",
103
+ style: {
104
+ color: 'var(--theme-error-500)',
105
+ marginLeft: '4px'
106
+ },
107
+ children: "*"
108
+ })
109
+ ]
110
+ }),
111
+ fieldDescription && /*#__PURE__*/ _jsx("div", {
112
+ className: "field-description",
113
+ style: {
114
+ marginBottom: '8px',
115
+ fontSize: '13px',
116
+ color: 'var(--theme-elevation-500)',
117
+ lineHeight: 1.5
118
+ },
119
+ children: fieldDescription
120
+ }),
121
+ /*#__PURE__*/ _jsxs("div", {
122
+ className: "color-picker-input-group",
123
+ style: {
124
+ display: 'flex',
125
+ alignItems: 'center',
126
+ gap: '8px'
127
+ },
128
+ children: [
129
+ /*#__PURE__*/ _jsx("button", {
130
+ type: "button",
131
+ onClick: togglePicker,
132
+ className: "color-preview-button",
133
+ style: {
134
+ width: '40px',
135
+ height: '40px',
136
+ borderRadius: '6px',
137
+ border: '2px solid #e5e7eb',
138
+ backgroundColor: value || '#ffffff',
139
+ cursor: 'pointer',
140
+ position: 'relative',
141
+ display: 'flex',
142
+ alignItems: 'center',
143
+ justifyContent: 'center'
144
+ },
145
+ title: value ? `Current color: ${value}` : 'Select a color',
146
+ children: !value && /*#__PURE__*/ _jsx("span", {
147
+ style: {
148
+ fontSize: '20px',
149
+ color: '#9ca3af'
150
+ },
151
+ children: "?"
152
+ })
153
+ }),
154
+ /*#__PURE__*/ _jsx("input", {
155
+ id: path,
156
+ type: "text",
157
+ value: value || '',
158
+ onChange: handleInputChange,
159
+ placeholder: placeholder,
160
+ style: {
161
+ flex: 1,
162
+ padding: '8px 12px',
163
+ border: '1px solid var(--theme-elevation-150)',
164
+ borderRadius: '6px',
165
+ fontSize: '14px',
166
+ fontFamily: 'monospace',
167
+ backgroundColor: 'var(--theme-elevation-0)',
168
+ color: 'var(--theme-elevation-1000)'
169
+ }
170
+ }),
171
+ /*#__PURE__*/ _jsx("input", {
172
+ type: "color",
173
+ value: value?.startsWith('#') ? value : '#3b82f6',
174
+ onChange: handleInputChange,
175
+ title: "Pick a color",
176
+ style: {
177
+ width: '40px',
178
+ height: '40px',
179
+ border: 'none',
180
+ borderRadius: '6px',
181
+ cursor: 'pointer'
182
+ }
183
+ })
184
+ ]
185
+ }),
186
+ isPickerOpen && /*#__PURE__*/ _jsxs("div", {
187
+ ref: pickerRef,
188
+ className: "color-presets",
189
+ style: {
190
+ position: 'absolute',
191
+ top: '100%',
192
+ left: 0,
193
+ right: 0,
194
+ zIndex: 1000,
195
+ marginTop: '4px',
196
+ padding: '16px',
197
+ border: '1px solid var(--theme-elevation-150)',
198
+ borderRadius: '8px',
199
+ backgroundColor: 'var(--theme-elevation-0)',
200
+ boxShadow: '0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
201
+ maxHeight: '300px',
202
+ overflowY: 'auto'
203
+ },
204
+ children: [
205
+ /*#__PURE__*/ _jsx("div", {
206
+ style: {
207
+ marginBottom: '16px',
208
+ fontSize: '14px',
209
+ fontWeight: 600,
210
+ color: 'var(--theme-elevation-800)'
211
+ },
212
+ children: "🎨 Professional Color Picker"
213
+ }),
214
+ Object.entries(colorPresets).map(([groupName, colors])=>/*#__PURE__*/ _jsxs("div", {
215
+ style: {
216
+ marginBottom: '16px'
217
+ },
218
+ children: [
219
+ /*#__PURE__*/ _jsx("div", {
220
+ style: {
221
+ marginBottom: '8px',
222
+ fontSize: '12px',
223
+ fontWeight: 500,
224
+ color: 'var(--theme-elevation-600)',
225
+ textTransform: 'uppercase',
226
+ letterSpacing: '0.05em'
227
+ },
228
+ children: groupName
229
+ }),
230
+ /*#__PURE__*/ _jsx("div", {
231
+ style: {
232
+ display: 'grid',
233
+ gridTemplateColumns: 'repeat(6, 1fr)',
234
+ gap: '6px'
235
+ },
236
+ children: colors.map((color)=>/*#__PURE__*/ _jsx("button", {
237
+ type: "button",
238
+ onClick: ()=>handleColorChange(color),
239
+ style: {
240
+ width: '36px',
241
+ height: '36px',
242
+ borderRadius: '6px',
243
+ border: value === color ? '3px solid var(--theme-primary-500)' : '1px solid var(--theme-elevation-150)',
244
+ backgroundColor: color,
245
+ cursor: 'pointer',
246
+ transition: 'all 0.2s ease',
247
+ position: 'relative',
248
+ overflow: 'hidden',
249
+ boxShadow: value === color ? '0 0 0 2px var(--theme-primary-200)' : '0 1px 3px rgba(0, 0, 0, 0.1)'
250
+ },
251
+ title: `${color} - Click to select`,
252
+ onMouseEnter: (event)=>{
253
+ event.currentTarget.style.transform = 'scale(1.1)';
254
+ },
255
+ onMouseLeave: (event)=>{
256
+ event.currentTarget.style.transform = 'scale(1)';
257
+ },
258
+ children: color === '#ffffff' && /*#__PURE__*/ _jsx("div", {
259
+ style: {
260
+ position: 'absolute',
261
+ inset: 0,
262
+ border: '1px solid var(--theme-elevation-150)',
263
+ borderRadius: 'inherit'
264
+ }
265
+ })
266
+ }, color))
267
+ })
268
+ ]
269
+ }, groupName)),
270
+ /*#__PURE__*/ _jsxs("div", {
271
+ style: {
272
+ marginTop: '16px',
273
+ paddingTop: '16px',
274
+ borderTop: '1px solid var(--theme-elevation-100)'
275
+ },
276
+ children: [
277
+ /*#__PURE__*/ _jsx("div", {
278
+ style: {
279
+ marginBottom: '8px',
280
+ fontSize: '12px',
281
+ fontWeight: 500,
282
+ color: 'var(--theme-elevation-600)'
283
+ },
284
+ children: "CUSTOM COLOR"
285
+ }),
286
+ /*#__PURE__*/ _jsxs("div", {
287
+ style: {
288
+ display: 'flex',
289
+ gap: '8px',
290
+ alignItems: 'center'
291
+ },
292
+ children: [
293
+ /*#__PURE__*/ _jsx("input", {
294
+ type: "color",
295
+ value: value?.startsWith('#') ? value : '#3b82f6',
296
+ onChange: handleInputChange,
297
+ style: {
298
+ width: '36px',
299
+ height: '36px',
300
+ border: 'none',
301
+ borderRadius: '6px',
302
+ cursor: 'pointer'
303
+ }
304
+ }),
305
+ /*#__PURE__*/ _jsxs("div", {
306
+ style: {
307
+ fontSize: '11px',
308
+ color: '#9ca3af',
309
+ lineHeight: 1.3
310
+ },
311
+ children: [
312
+ /*#__PURE__*/ _jsx("div", {
313
+ children: /*#__PURE__*/ _jsx("strong", {
314
+ children: "Formats:"
315
+ })
316
+ }),
317
+ /*#__PURE__*/ _jsx("div", {
318
+ children: "Hex, RGB, HSL, CSS vars"
319
+ })
320
+ ]
321
+ })
322
+ ]
323
+ })
324
+ ]
325
+ })
326
+ ]
327
+ })
328
+ ]
329
+ });
330
+ }
331
+
332
+ //# sourceMappingURL=ColorPickerField.js.map