@marvalt/dstyler 0.1.3 → 0.1.6

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/README.md CHANGED
@@ -9,6 +9,7 @@ Design system package for styling WordPress content with zero-config templates.
9
9
  - Maps parsed WordPress sections → React templates
10
10
  - Ensures consistent responsive styling across the site
11
11
  - Renders blocks (text, images, buttons, forms) inside sections
12
+ - Provides utilities to bridge design tokens with WordPress color mapping
12
13
 
13
14
  ## Installation
14
15
 
@@ -18,6 +19,8 @@ npm install @marvalt/dstyler
18
19
 
19
20
  ## Usage
20
21
 
22
+ ### Basic Usage
23
+
21
24
  ```tsx
22
25
  import { ThemeProvider, StyledPage } from '@marvalt/dstyler';
23
26
  import { getThemeStyles } from '@marvalt/wadapter';
@@ -27,8 +30,47 @@ import { getThemeStyles } from '@marvalt/wadapter';
27
30
  </ThemeProvider>
28
31
  ```
29
32
 
33
+ ### Creating Color Mapper from Design Tokens
34
+
35
+ Bridge dstyler design tokens with wparser's color mapping system:
36
+
37
+ ```tsx
38
+ import { createColorMapperFromTokens } from '@marvalt/dstyler';
39
+ import { createEnhancedRegistry } from '@marvalt/wparser';
40
+ import { loadTheme } from '@/config/themes';
41
+
42
+ // Get your design tokens
43
+ const tokens = await loadTheme();
44
+
45
+ // Generate colorMapper from tokens
46
+ const colorMapper = createColorMapperFromTokens(tokens, {
47
+ // Optional overrides for specific WordPress color names
48
+ 'accent-6': 'bg-[#4a90a4] text-white',
49
+ });
50
+
51
+ // Use with wparser registry
52
+ const registry = createEnhancedRegistry(mappings, undefined, colorMapper);
53
+ ```
54
+
55
+ ### Using Semantic Tailwind Classes
56
+
57
+ If your Tailwind config has semantic colors defined (primary, secondary, etc.):
58
+
59
+ ```tsx
60
+ import { createColorMapperWithSemanticClasses } from '@marvalt/dstyler';
61
+
62
+ const colorMapper = createColorMapperWithSemanticClasses(tokens, {
63
+ 'accent-1': 'bg-primary text-primary-foreground',
64
+ 'accent-2': 'bg-secondary text-secondary-foreground',
65
+ });
66
+ ```
67
+
30
68
  ## License
31
69
 
32
70
  GPL-3.0-or-later
33
71
 
34
72
 
73
+
74
+
75
+
76
+
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { ComponentType } from 'react';
2
- import { WordPressBlock, ComponentRegistry } from '@marvalt/wparser';
2
+ import { WordPressBlock, ComponentRegistry, ColorMapper } from '@marvalt/wparser';
3
3
 
4
4
  /**
5
5
  * @license GPL-3.0-or-later
@@ -67,9 +67,18 @@ interface ThemeStyles {
67
67
  */
68
68
 
69
69
  interface ThemeProviderProps {
70
- children: React.ReactNode;
70
+ children?: React.ReactNode;
71
71
  wpStyles?: ThemeStyles;
72
+ customTokens?: DesignTokens;
72
73
  }
74
+ /**
75
+ * ThemeProvider - Provides design tokens to the application
76
+ *
77
+ * Priority order:
78
+ * 1. customTokens (highest priority - overrides everything)
79
+ * 2. WordPress styles (converted to tokens)
80
+ * 3. Default tokens (fallback)
81
+ */
73
82
  declare const ThemeProvider: React.FC<ThemeProviderProps>;
74
83
 
75
84
  /**
@@ -284,5 +293,66 @@ interface FooterMinimalProps {
284
293
  }
285
294
  declare const FooterMinimal: React.FC<FooterMinimalProps>;
286
295
 
287
- export { AutoBlock, AutoSection, FooterMinimal, HeroDefault, SectionBase, SectionWave, StyledPage, ThemeProvider, convertWordPressToTokens, defaultTokens, detectSections, determineSectionStyle, injectCSSVariables, selectBlockRenderer, selectTemplate };
296
+ /**
297
+ * @license GPL-3.0-or-later
298
+ *
299
+ * This file is part of the MarVAlt Open SDK.
300
+ * Copyright (c) 2025 Vibune Pty Ltd.
301
+ */
302
+ /**
303
+ * Responsive utility functions
304
+ */
305
+ declare function getResponsiveValue(mobile: string | number, tablet?: string | number, desktop?: string | number): string;
306
+
307
+ /**
308
+ * @license GPL-3.0-or-later
309
+ *
310
+ * This file is part of the MarVAlt Open SDK.
311
+ * Copyright (c) 2025 Vibune Pty Ltd.
312
+ */
313
+
314
+ /**
315
+ * Create a colorMapper from design tokens
316
+ *
317
+ * This utility helps bridge dstyler design tokens with wparser's color mapping system.
318
+ * It generates a ColorMapper function that maps WordPress theme color names to CSS classes
319
+ * based on your design tokens.
320
+ *
321
+ * @param tokens - Design tokens containing color definitions
322
+ * @param overrides - Optional overrides for specific WordPress color names
323
+ * @returns A ColorMapper function compatible with wparser
324
+ *
325
+ * @example
326
+ * ```typescript
327
+ * import { createColorMapperFromTokens } from '@marvalt/dstyler';
328
+ * import { loadTheme } from '@/config/themes';
329
+ *
330
+ * const tokens = await loadTheme();
331
+ * const colorMapper = createColorMapperFromTokens(tokens, {
332
+ * 'accent-6': 'bg-[#4a90a4] text-white', // Custom override
333
+ * });
334
+ * ```
335
+ */
336
+ declare function createColorMapperFromTokens(tokens: DesignTokens, overrides?: Record<string, string>): ColorMapper;
337
+ /**
338
+ * Create a colorMapper with semantic Tailwind classes
339
+ *
340
+ * Alternative version that uses semantic Tailwind classes (bg-primary, bg-secondary, etc.)
341
+ * instead of arbitrary values. Use this if your Tailwind config has these colors defined.
342
+ *
343
+ * @param tokens - Design tokens (used for reference, but classes are semantic)
344
+ * @param overrides - Optional overrides for specific WordPress color names
345
+ * @returns A ColorMapper function compatible with wparser
346
+ *
347
+ * @example
348
+ * ```typescript
349
+ * const colorMapper = createColorMapperWithSemanticClasses(tokens, {
350
+ * 'accent-1': 'bg-primary text-primary-foreground',
351
+ * 'accent-2': 'bg-secondary text-secondary-foreground',
352
+ * });
353
+ * ```
354
+ */
355
+ declare function createColorMapperWithSemanticClasses(tokens: DesignTokens, overrides?: Record<string, string>): ColorMapper;
356
+
357
+ export { AutoBlock, AutoSection, FooterMinimal, HeroDefault, SectionBase, SectionWave, StyledPage, ThemeProvider, convertWordPressToTokens, createColorMapperFromTokens, createColorMapperWithSemanticClasses, defaultTokens, detectSections, determineSectionStyle, getResponsiveValue, injectCSSVariables, selectBlockRenderer, selectTemplate };
288
358
  export type { AutoBlockProps, AutoSectionProps, BlockRenderer, BlockRendererProps, DesignTokens, FooterMinimalProps, HeroDefaultProps, Section, SectionBaseProps, SectionStyle, SectionWaveProps, StyledPageProps, TemplateComponent, ThemeProviderProps, ThemeStyles, WordPressPage };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/index.esm.js CHANGED
@@ -1,4 +1,170 @@
1
- import require$$0, { useEffect } from 'react';
1
+ import React, { useEffect } from 'react';
2
+
3
+ /**
4
+ * @license GPL-3.0-or-later
5
+ *
6
+ * This file is part of the MarVAlt Open SDK.
7
+ * Copyright (c) 2025 Vibune Pty Ltd.
8
+ */
9
+ const defaultTokens = {
10
+ colors: {
11
+ primary: '#1a73e8',
12
+ secondary: '#34a853',
13
+ background: '#ffffff',
14
+ text: '#222222',
15
+ default: '#ffffff',
16
+ alternate: '#f5f5f5',
17
+ highlight: '#e8f0fe',
18
+ },
19
+ spacing: {
20
+ sm: 8,
21
+ md: 16,
22
+ lg: 32,
23
+ xl: 64,
24
+ },
25
+ typography: {
26
+ body: 'Inter, sans-serif',
27
+ heading: 'Inter, sans-serif',
28
+ scale: 1.2,
29
+ },
30
+ };
31
+
32
+ /**
33
+ * @license GPL-3.0-or-later
34
+ *
35
+ * This file is part of the MarVAlt Open SDK.
36
+ * Copyright (c) 2025 Vibune Pty Ltd.
37
+ */
38
+ /**
39
+ * Convert WordPress theme styles to design tokens
40
+ */
41
+ function convertWordPressToTokens(wpStyles) {
42
+ if (!wpStyles) {
43
+ return defaultTokens;
44
+ }
45
+ const tokens = {
46
+ ...defaultTokens,
47
+ colors: {
48
+ ...defaultTokens.colors,
49
+ ...(wpStyles.colors?.primary && { primary: wpStyles.colors.primary }),
50
+ ...(wpStyles.colors?.secondary && { secondary: wpStyles.colors.secondary }),
51
+ ...(wpStyles.colors?.text && { text: wpStyles.colors.text }),
52
+ ...(wpStyles.colors?.background && {
53
+ background: wpStyles.colors.background,
54
+ default: wpStyles.colors.background,
55
+ }),
56
+ },
57
+ typography: {
58
+ ...defaultTokens.typography,
59
+ ...(wpStyles.typography?.heading_font_family && {
60
+ heading: wpStyles.typography.heading_font_family
61
+ }),
62
+ ...(wpStyles.typography?.body_font_family && {
63
+ body: wpStyles.typography.body_font_family
64
+ }),
65
+ },
66
+ };
67
+ // Generate alternate and highlight colors from primary/background
68
+ if (tokens.colors.primary && tokens.colors.background) {
69
+ // Alternate: slightly darker/lighter than background
70
+ tokens.colors.alternate = adjustBrightness(tokens.colors.background, -0.05);
71
+ // Highlight: tinted with primary color
72
+ tokens.colors.highlight = blendColors(tokens.colors.background, tokens.colors.primary, 0.1);
73
+ }
74
+ return tokens;
75
+ }
76
+ /**
77
+ * Adjust brightness of a hex color
78
+ */
79
+ function adjustBrightness(hex, amount) {
80
+ const num = parseInt(hex.replace('#', ''), 16);
81
+ const r = Math.max(0, Math.min(255, ((num >> 16) & 0xff) + (amount * 255)));
82
+ const g = Math.max(0, Math.min(255, ((num >> 8) & 0xff) + (amount * 255)));
83
+ const b = Math.max(0, Math.min(255, (num & 0xff) + (amount * 255)));
84
+ return `#${((r << 16) | (g << 8) | b).toString(16).padStart(6, '0')}`;
85
+ }
86
+ /**
87
+ * Blend two colors
88
+ */
89
+ function blendColors(color1, color2, ratio) {
90
+ const c1 = hexToRgb(color1);
91
+ const c2 = hexToRgb(color2);
92
+ if (!c1 || !c2)
93
+ return color1;
94
+ const r = Math.round(c1.r + (c2.r - c1.r) * ratio);
95
+ const g = Math.round(c1.g + (c2.g - c1.g) * ratio);
96
+ const b = Math.round(c1.b + (c2.b - c1.b) * ratio);
97
+ return `rgb(${r}, ${g}, ${b})`;
98
+ }
99
+ function hexToRgb(hex) {
100
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
101
+ return result
102
+ ? {
103
+ r: parseInt(result[1], 16),
104
+ g: parseInt(result[2], 16),
105
+ b: parseInt(result[3], 16),
106
+ }
107
+ : null;
108
+ }
109
+
110
+ /**
111
+ * @license GPL-3.0-or-later
112
+ *
113
+ * This file is part of the MarVAlt Open SDK.
114
+ * Copyright (c) 2025 Vibune Pty Ltd.
115
+ */
116
+ /**
117
+ * Inject CSS variables from design tokens into the document
118
+ */
119
+ function injectCSSVariables(tokens) {
120
+ if (typeof document === 'undefined')
121
+ return;
122
+ const root = document.documentElement;
123
+ // Colors
124
+ root.style.setProperty('--dstyler-color-primary', tokens.colors.primary);
125
+ root.style.setProperty('--dstyler-color-secondary', tokens.colors.secondary);
126
+ root.style.setProperty('--dstyler-color-background', tokens.colors.background);
127
+ root.style.setProperty('--dstyler-color-text', tokens.colors.text);
128
+ root.style.setProperty('--dstyler-color-default', tokens.colors.default);
129
+ root.style.setProperty('--dstyler-color-alternate', tokens.colors.alternate);
130
+ root.style.setProperty('--dstyler-color-highlight', tokens.colors.highlight);
131
+ // Spacing
132
+ root.style.setProperty('--dstyler-spacing-sm', `${tokens.spacing.sm}px`);
133
+ root.style.setProperty('--dstyler-spacing-md', `${tokens.spacing.md}px`);
134
+ root.style.setProperty('--dstyler-spacing-lg', `${tokens.spacing.lg}px`);
135
+ root.style.setProperty('--dstyler-spacing-xl', `${tokens.spacing.xl}px`);
136
+ // Typography
137
+ root.style.setProperty('--dstyler-font-body', tokens.typography.body);
138
+ root.style.setProperty('--dstyler-font-heading', tokens.typography.heading);
139
+ root.style.setProperty('--dstyler-font-scale', tokens.typography.scale.toString());
140
+ }
141
+
142
+ /**
143
+ * @license GPL-3.0-or-later
144
+ *
145
+ * This file is part of the MarVAlt Open SDK.
146
+ * Copyright (c) 2025 Vibune Pty Ltd.
147
+ */
148
+ /**
149
+ * ThemeProvider - Provides design tokens to the application
150
+ *
151
+ * Priority order:
152
+ * 1. customTokens (highest priority - overrides everything)
153
+ * 2. WordPress styles (converted to tokens)
154
+ * 3. Default tokens (fallback)
155
+ */
156
+ const ThemeProvider = ({ children, wpStyles, customTokens }) => {
157
+ useEffect(() => {
158
+ // Use custom tokens if provided, otherwise convert WordPress styles
159
+ const tokens = customTokens || convertWordPressToTokens(wpStyles);
160
+ injectCSSVariables(tokens);
161
+ }, [wpStyles, customTokens]);
162
+ // Return children if provided, otherwise return null (theme still applies via useEffect)
163
+ if (children === undefined || children === null) {
164
+ return null;
165
+ }
166
+ return React.createElement(React.Fragment, null, children);
167
+ };
2
168
 
3
169
  var jsxRuntime = {exports: {}};
4
170
 
@@ -336,7 +502,7 @@ function requireReactJsxRuntime_development () {
336
502
  object.$$typeof === REACT_ELEMENT_TYPE
337
503
  );
338
504
  }
339
- var React = require$$0,
505
+ var React$1 = React,
340
506
  REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
341
507
  REACT_PORTAL_TYPE = Symbol.for("react.portal"),
342
508
  REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
@@ -352,7 +518,7 @@ function requireReactJsxRuntime_development () {
352
518
  REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
353
519
  REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
354
520
  ReactSharedInternals =
355
- React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
521
+ React$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
356
522
  hasOwnProperty = Object.prototype.hasOwnProperty,
357
523
  isArrayImpl = Array.isArray,
358
524
  createTask = console.createTask
@@ -360,15 +526,15 @@ function requireReactJsxRuntime_development () {
360
526
  : function () {
361
527
  return null;
362
528
  };
363
- React = {
529
+ React$1 = {
364
530
  react_stack_bottom_frame: function (callStackForError) {
365
531
  return callStackForError();
366
532
  }
367
533
  };
368
534
  var specialPropKeyWarningShown;
369
535
  var didWarnAboutElementRef = {};
370
- var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
371
- React,
536
+ var unknownOwnerDebugStack = React$1.react_stack_bottom_frame.bind(
537
+ React$1,
372
538
  UnknownOwner
373
539
  )();
374
540
  var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
@@ -414,153 +580,6 @@ if (process.env.NODE_ENV === 'production') {
414
580
 
415
581
  var jsxRuntimeExports = jsxRuntime.exports;
416
582
 
417
- /**
418
- * @license GPL-3.0-or-later
419
- *
420
- * This file is part of the MarVAlt Open SDK.
421
- * Copyright (c) 2025 Vibune Pty Ltd.
422
- */
423
- const defaultTokens = {
424
- colors: {
425
- primary: '#1a73e8',
426
- secondary: '#34a853',
427
- background: '#ffffff',
428
- text: '#222222',
429
- default: '#ffffff',
430
- alternate: '#f5f5f5',
431
- highlight: '#e8f0fe',
432
- },
433
- spacing: {
434
- sm: 8,
435
- md: 16,
436
- lg: 32,
437
- xl: 64,
438
- },
439
- typography: {
440
- body: 'Inter, sans-serif',
441
- heading: 'Inter, sans-serif',
442
- scale: 1.2,
443
- },
444
- };
445
-
446
- /**
447
- * @license GPL-3.0-or-later
448
- *
449
- * This file is part of the MarVAlt Open SDK.
450
- * Copyright (c) 2025 Vibune Pty Ltd.
451
- */
452
- /**
453
- * Convert WordPress theme styles to design tokens
454
- */
455
- function convertWordPressToTokens(wpStyles) {
456
- if (!wpStyles) {
457
- return defaultTokens;
458
- }
459
- const tokens = {
460
- ...defaultTokens,
461
- colors: {
462
- ...defaultTokens.colors,
463
- ...(wpStyles.colors?.primary && { primary: wpStyles.colors.primary }),
464
- ...(wpStyles.colors?.secondary && { secondary: wpStyles.colors.secondary }),
465
- ...(wpStyles.colors?.text && { text: wpStyles.colors.text }),
466
- ...(wpStyles.colors?.background && {
467
- background: wpStyles.colors.background,
468
- default: wpStyles.colors.background,
469
- }),
470
- },
471
- typography: {
472
- ...defaultTokens.typography,
473
- ...(wpStyles.typography?.heading_font_family && {
474
- heading: wpStyles.typography.heading_font_family
475
- }),
476
- ...(wpStyles.typography?.body_font_family && {
477
- body: wpStyles.typography.body_font_family
478
- }),
479
- },
480
- };
481
- // Generate alternate and highlight colors from primary/background
482
- if (tokens.colors.primary && tokens.colors.background) {
483
- // Alternate: slightly darker/lighter than background
484
- tokens.colors.alternate = adjustBrightness(tokens.colors.background, -0.05);
485
- // Highlight: tinted with primary color
486
- tokens.colors.highlight = blendColors(tokens.colors.background, tokens.colors.primary, 0.1);
487
- }
488
- return tokens;
489
- }
490
- /**
491
- * Adjust brightness of a hex color
492
- */
493
- function adjustBrightness(hex, amount) {
494
- const num = parseInt(hex.replace('#', ''), 16);
495
- const r = Math.max(0, Math.min(255, ((num >> 16) & 0xff) + (amount * 255)));
496
- const g = Math.max(0, Math.min(255, ((num >> 8) & 0xff) + (amount * 255)));
497
- const b = Math.max(0, Math.min(255, (num & 0xff) + (amount * 255)));
498
- return `#${((r << 16) | (g << 8) | b).toString(16).padStart(6, '0')}`;
499
- }
500
- /**
501
- * Blend two colors
502
- */
503
- function blendColors(color1, color2, ratio) {
504
- const c1 = hexToRgb(color1);
505
- const c2 = hexToRgb(color2);
506
- if (!c1 || !c2)
507
- return color1;
508
- const r = Math.round(c1.r + (c2.r - c1.r) * ratio);
509
- const g = Math.round(c1.g + (c2.g - c1.g) * ratio);
510
- const b = Math.round(c1.b + (c2.b - c1.b) * ratio);
511
- return `rgb(${r}, ${g}, ${b})`;
512
- }
513
- function hexToRgb(hex) {
514
- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
515
- return result
516
- ? {
517
- r: parseInt(result[1], 16),
518
- g: parseInt(result[2], 16),
519
- b: parseInt(result[3], 16),
520
- }
521
- : null;
522
- }
523
-
524
- /**
525
- * @license GPL-3.0-or-later
526
- *
527
- * This file is part of the MarVAlt Open SDK.
528
- * Copyright (c) 2025 Vibune Pty Ltd.
529
- */
530
- /**
531
- * Inject CSS variables from design tokens into the document
532
- */
533
- function injectCSSVariables(tokens) {
534
- if (typeof document === 'undefined')
535
- return;
536
- const root = document.documentElement;
537
- // Colors
538
- root.style.setProperty('--dstyler-color-primary', tokens.colors.primary);
539
- root.style.setProperty('--dstyler-color-secondary', tokens.colors.secondary);
540
- root.style.setProperty('--dstyler-color-background', tokens.colors.background);
541
- root.style.setProperty('--dstyler-color-text', tokens.colors.text);
542
- root.style.setProperty('--dstyler-color-default', tokens.colors.default);
543
- root.style.setProperty('--dstyler-color-alternate', tokens.colors.alternate);
544
- root.style.setProperty('--dstyler-color-highlight', tokens.colors.highlight);
545
- // Spacing
546
- root.style.setProperty('--dstyler-spacing-sm', `${tokens.spacing.sm}px`);
547
- root.style.setProperty('--dstyler-spacing-md', `${tokens.spacing.md}px`);
548
- root.style.setProperty('--dstyler-spacing-lg', `${tokens.spacing.lg}px`);
549
- root.style.setProperty('--dstyler-spacing-xl', `${tokens.spacing.xl}px`);
550
- // Typography
551
- root.style.setProperty('--dstyler-font-body', tokens.typography.body);
552
- root.style.setProperty('--dstyler-font-heading', tokens.typography.heading);
553
- root.style.setProperty('--dstyler-font-scale', tokens.typography.scale.toString());
554
- }
555
-
556
- const ThemeProvider = ({ children, wpStyles }) => {
557
- useEffect(() => {
558
- const tokens = convertWordPressToTokens(wpStyles);
559
- injectCSSVariables(tokens);
560
- }, [wpStyles]);
561
- return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
562
- };
563
-
564
583
  /**
565
584
  * @license GPL-3.0-or-later
566
585
  *
@@ -927,5 +946,114 @@ const StyledPage = ({ page, registry }) => {
927
946
  return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: styledSections.map((section) => (jsxRuntimeExports.jsx(AutoSection, { section: section, registry: registry }, section.id))) }));
928
947
  };
929
948
 
930
- export { AutoBlock, AutoSection, FooterMinimal, HeroDefault, SectionBase, SectionWave, StyledPage, ThemeProvider, convertWordPressToTokens, defaultTokens, detectSections, determineSectionStyle, injectCSSVariables, selectBlockRenderer, selectTemplate };
949
+ /**
950
+ * @license GPL-3.0-or-later
951
+ *
952
+ * This file is part of the MarVAlt Open SDK.
953
+ * Copyright (c) 2025 Vibune Pty Ltd.
954
+ */
955
+ /**
956
+ * Responsive utility functions
957
+ */
958
+ function getResponsiveValue(mobile, tablet, desktop) {
959
+ if (!tablet && !desktop) {
960
+ return typeof mobile === 'number' ? `${mobile}px` : mobile;
961
+ }
962
+ // For now, return mobile value
963
+ // In the future, this could use CSS custom properties with media queries
964
+ return typeof mobile === 'number' ? `${mobile}px` : mobile;
965
+ }
966
+
967
+ /**
968
+ * @license GPL-3.0-or-later
969
+ *
970
+ * This file is part of the MarVAlt Open SDK.
971
+ * Copyright (c) 2025 Vibune Pty Ltd.
972
+ */
973
+ /**
974
+ * Create a colorMapper from design tokens
975
+ *
976
+ * This utility helps bridge dstyler design tokens with wparser's color mapping system.
977
+ * It generates a ColorMapper function that maps WordPress theme color names to CSS classes
978
+ * based on your design tokens.
979
+ *
980
+ * @param tokens - Design tokens containing color definitions
981
+ * @param overrides - Optional overrides for specific WordPress color names
982
+ * @returns A ColorMapper function compatible with wparser
983
+ *
984
+ * @example
985
+ * ```typescript
986
+ * import { createColorMapperFromTokens } from '@marvalt/dstyler';
987
+ * import { loadTheme } from '@/config/themes';
988
+ *
989
+ * const tokens = await loadTheme();
990
+ * const colorMapper = createColorMapperFromTokens(tokens, {
991
+ * 'accent-6': 'bg-[#4a90a4] text-white', // Custom override
992
+ * });
993
+ * ```
994
+ */
995
+ function createColorMapperFromTokens(tokens, overrides) {
996
+ return (wpColorName) => {
997
+ // Use overrides first if provided
998
+ if (wpColorName && overrides?.[wpColorName]) {
999
+ return overrides[wpColorName];
1000
+ }
1001
+ // Map WordPress theme colors to design tokens
1002
+ // Using Tailwind's arbitrary value syntax for hex colors
1003
+ const defaultMap = {
1004
+ 'base': `bg-[${tokens.colors.background}]`,
1005
+ 'contrast': `bg-[${tokens.colors.text}] text-[${tokens.colors.background}]`,
1006
+ 'transparent': 'bg-transparent',
1007
+ 'accent-1': `bg-[${tokens.colors.primary}] text-white`,
1008
+ 'accent-2': `bg-[${tokens.colors.secondary}] text-white`,
1009
+ 'accent-3': `bg-[${tokens.colors.highlight}] text-[${tokens.colors.text}]`,
1010
+ 'accent-4': `bg-[${tokens.colors.alternate}] text-[${tokens.colors.text}]`,
1011
+ 'accent-5': `bg-[${tokens.colors.default}] text-[${tokens.colors.text}]`,
1012
+ 'accent-6': `bg-[${tokens.colors.primary}] text-white`, // Fallback to primary if accent-6 not defined
1013
+ };
1014
+ return wpColorName ? defaultMap[wpColorName] || null : null;
1015
+ };
1016
+ }
1017
+ /**
1018
+ * Create a colorMapper with semantic Tailwind classes
1019
+ *
1020
+ * Alternative version that uses semantic Tailwind classes (bg-primary, bg-secondary, etc.)
1021
+ * instead of arbitrary values. Use this if your Tailwind config has these colors defined.
1022
+ *
1023
+ * @param tokens - Design tokens (used for reference, but classes are semantic)
1024
+ * @param overrides - Optional overrides for specific WordPress color names
1025
+ * @returns A ColorMapper function compatible with wparser
1026
+ *
1027
+ * @example
1028
+ * ```typescript
1029
+ * const colorMapper = createColorMapperWithSemanticClasses(tokens, {
1030
+ * 'accent-1': 'bg-primary text-primary-foreground',
1031
+ * 'accent-2': 'bg-secondary text-secondary-foreground',
1032
+ * });
1033
+ * ```
1034
+ */
1035
+ function createColorMapperWithSemanticClasses(tokens, overrides) {
1036
+ return (wpColorName) => {
1037
+ // Use overrides first if provided
1038
+ if (wpColorName && overrides?.[wpColorName]) {
1039
+ return overrides[wpColorName];
1040
+ }
1041
+ // Map WordPress theme colors to semantic Tailwind classes
1042
+ // Assumes your Tailwind config has primary, secondary, muted, etc. defined
1043
+ const defaultMap = {
1044
+ 'base': 'bg-white',
1045
+ 'contrast': 'bg-gray-900 text-white',
1046
+ 'transparent': 'bg-transparent',
1047
+ 'accent-1': 'bg-primary text-primary-foreground',
1048
+ 'accent-2': 'bg-secondary text-secondary-foreground',
1049
+ 'accent-3': 'bg-muted text-muted-foreground',
1050
+ 'accent-4': 'bg-gray-200 text-gray-900',
1051
+ 'accent-5': 'bg-gray-100 text-gray-900',
1052
+ 'accent-6': 'bg-primary text-primary-foreground', // Fallback
1053
+ };
1054
+ return wpColorName ? defaultMap[wpColorName] || null : null;
1055
+ };
1056
+ }
1057
+
1058
+ export { AutoBlock, AutoSection, FooterMinimal, HeroDefault, SectionBase, SectionWave, StyledPage, ThemeProvider, convertWordPressToTokens, createColorMapperFromTokens, createColorMapperWithSemanticClasses, defaultTokens, detectSections, determineSectionStyle, getResponsiveValue, injectCSSVariables, selectBlockRenderer, selectTemplate };
931
1059
  //# sourceMappingURL=index.esm.js.map