@brunoalz/smartgesti-site-editor 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor/BlockSelector.js +5 -2
- package/dist/editor/BlockSelector.js.map +1 -1
- package/dist/editor/LandingPageEditor.d.ts.map +1 -1
- package/dist/editor/LandingPageEditor.js +199 -173
- package/dist/editor/LandingPageEditor.js.map +1 -1
- package/dist/editor/PaletteSelector.d.ts +3 -0
- package/dist/editor/PaletteSelector.d.ts.map +1 -1
- package/dist/editor/PaletteSelector.js +114 -25
- package/dist/editor/PaletteSelector.js.map +1 -1
- package/dist/editor/PropertyEditor/BlockPropertyEditor.d.ts.map +1 -1
- package/dist/editor/PropertyEditor/BlockPropertyEditor.js +86 -48
- package/dist/editor/PropertyEditor/BlockPropertyEditor.js.map +1 -1
- package/dist/editor/components/RightPanel.d.ts +2 -0
- package/dist/editor/components/RightPanel.d.ts.map +1 -1
- package/dist/editor/components/RightPanel.js +23 -22
- package/dist/editor/components/RightPanel.js.map +1 -1
- package/dist/engine/export/exporters/content/AvatarExporter.js +2 -2
- package/dist/engine/export/exporters/content/AvatarExporter.js.map +1 -1
- package/dist/engine/export/exporters/content/BadgeExporter.js +11 -11
- package/dist/engine/export/exporters/content/BadgeExporter.js.map +1 -1
- package/dist/engine/export/exporters/sections/AdminSectionExporters.d.ts +6 -0
- package/dist/engine/export/exporters/sections/AdminSectionExporters.d.ts.map +1 -0
- package/dist/engine/export/exporters/sections/AdminSectionExporters.js +157 -0
- package/dist/engine/export/exporters/sections/AdminSectionExporters.js.map +1 -0
- package/dist/engine/export/exporters/sections/BlogPostExporters.js +34 -34
- package/dist/engine/export/exporters/sections/BlogPostExporters.js.map +1 -1
- package/dist/engine/export/exporters/sections/ContentGridExporters.js +16 -16
- package/dist/engine/export/exporters/sections/ContentGridExporters.js.map +1 -1
- package/dist/engine/export/exporters/sections/MarketingExporters.js +4 -4
- package/dist/engine/export/exporters/sections/MarketingExporters.js.map +1 -1
- package/dist/engine/export/exporters/sections/index.d.ts.map +1 -1
- package/dist/engine/export/exporters/sections/index.js +37 -33
- package/dist/engine/export/exporters/sections/index.js.map +1 -1
- package/dist/engine/index.js +98 -95
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/preview/Preview.d.ts.map +1 -1
- package/dist/engine/preview/Preview.js +165 -160
- package/dist/engine/preview/Preview.js.map +1 -1
- package/dist/engine/registry/blocks/sections/aboutSection.d.ts +3 -0
- package/dist/engine/registry/blocks/sections/aboutSection.d.ts.map +1 -0
- package/dist/engine/registry/blocks/sections/aboutSection.js +117 -0
- package/dist/engine/registry/blocks/sections/aboutSection.js.map +1 -0
- package/dist/engine/registry/blocks/sections/contactSection.d.ts +3 -0
- package/dist/engine/registry/blocks/sections/contactSection.d.ts.map +1 -0
- package/dist/engine/registry/blocks/sections/contactSection.js +118 -0
- package/dist/engine/registry/blocks/sections/contactSection.js.map +1 -0
- package/dist/engine/registry/blocks/sections/index.d.ts +3 -0
- package/dist/engine/registry/blocks/sections/index.d.ts.map +1 -1
- package/dist/engine/registry/blocks/sections/productShowcase.d.ts +3 -0
- package/dist/engine/registry/blocks/sections/productShowcase.d.ts.map +1 -0
- package/dist/engine/registry/blocks/sections/productShowcase.js +108 -0
- package/dist/engine/registry/blocks/sections/productShowcase.js.map +1 -0
- package/dist/engine/render/renderers/content/BadgeRenderer.js +12 -12
- package/dist/engine/render/renderers/content/BadgeRenderer.js.map +1 -1
- package/dist/engine/render/renderers/sections/AboutSectionRenderer.d.ts +3 -0
- package/dist/engine/render/renderers/sections/AboutSectionRenderer.d.ts.map +1 -0
- package/dist/engine/render/renderers/sections/AboutSectionRenderer.js +246 -0
- package/dist/engine/render/renderers/sections/AboutSectionRenderer.js.map +1 -0
- package/dist/engine/render/renderers/sections/ContactSectionRenderer.d.ts +3 -0
- package/dist/engine/render/renderers/sections/ContactSectionRenderer.d.ts.map +1 -0
- package/dist/engine/render/renderers/sections/ContactSectionRenderer.js +287 -0
- package/dist/engine/render/renderers/sections/ContactSectionRenderer.js.map +1 -0
- package/dist/engine/render/renderers/sections/FeatureGridRenderer.js +5 -5
- package/dist/engine/render/renderers/sections/FeatureGridRenderer.js.map +1 -1
- package/dist/engine/render/renderers/sections/FeatureRenderer.js +9 -9
- package/dist/engine/render/renderers/sections/FeatureRenderer.js.map +1 -1
- package/dist/engine/render/renderers/sections/PricingCardRenderer.js +5 -5
- package/dist/engine/render/renderers/sections/PricingCardRenderer.js.map +1 -1
- package/dist/engine/render/renderers/sections/ProductShowcaseRenderer.d.ts +3 -0
- package/dist/engine/render/renderers/sections/ProductShowcaseRenderer.d.ts.map +1 -0
- package/dist/engine/render/renderers/sections/ProductShowcaseRenderer.js +287 -0
- package/dist/engine/render/renderers/sections/ProductShowcaseRenderer.js.map +1 -0
- package/dist/engine/render/renderers/sections/index.js +26 -20
- package/dist/engine/render/renderers/sections/index.js.map +1 -1
- package/dist/engine/schema/siteDocument.d.ts +96 -2
- package/dist/engine/schema/siteDocument.d.ts.map +1 -1
- package/dist/engine/schema/siteDocument.js.map +1 -1
- package/dist/hooks/useEditorState.d.ts +2 -0
- package/dist/hooks/useEditorState.d.ts.map +1 -1
- package/dist/hooks/useEditorState.js +82 -77
- package/dist/hooks/useEditorState.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +109 -106
- package/dist/index.js.map +1 -1
- package/dist/shared/schema.d.ts +1 -1
- package/dist/shared/schema.d.ts.map +1 -1
- package/dist/shared/schema.js +7 -4
- package/dist/shared/schema.js.map +1 -1
- package/dist/shared/templates/index.d.ts +6 -0
- package/dist/shared/templates/index.d.ts.map +1 -1
- package/dist/shared/templates/index.js +49 -23
- package/dist/shared/templates/index.js.map +1 -1
- package/dist/shared/templates/smartgesti-admin.d.ts +3 -0
- package/dist/shared/templates/smartgesti-admin.d.ts.map +1 -0
- package/dist/shared/templates/smartgesti-admin.js +423 -0
- package/dist/shared/templates/smartgesti-admin.js.map +1 -0
- package/dist/utils/blockIcons.d.ts.map +1 -1
- package/dist/utils/blockIcons.js +3 -0
- package/dist/utils/blockIcons.js.map +1 -1
- package/dist/utils/colorUtils.d.ts +73 -16
- package/dist/utils/colorUtils.d.ts.map +1 -1
- package/dist/utils/colorUtils.js +95 -9
- package/dist/utils/colorUtils.js.map +1 -1
- package/dist/viewer/LandingPageViewer.d.ts.map +1 -1
- package/dist/viewer/LandingPageViewer.js +66 -65
- package/dist/viewer/LandingPageViewer.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,29 +1,86 @@
|
|
|
1
|
+
import { ColorPalette } from '../editor/PaletteSelector';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Utilitários para manipulação de cores
|
|
3
|
+
* Converte hex para RGB
|
|
4
4
|
*/
|
|
5
|
+
export declare function hexToRgb(hex: string): {
|
|
6
|
+
r: number;
|
|
7
|
+
g: number;
|
|
8
|
+
b: number;
|
|
9
|
+
} | null;
|
|
5
10
|
/**
|
|
6
|
-
*
|
|
7
|
-
|
|
11
|
+
* Converte hex para HSL
|
|
12
|
+
*/
|
|
13
|
+
export declare function hexToHSL(hex: string): {
|
|
14
|
+
h: number;
|
|
15
|
+
s: number;
|
|
16
|
+
l: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Converte HSL para hex
|
|
20
|
+
*/
|
|
21
|
+
export declare function hslToHex(h: number, s: number, l: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* Calcula luminancia relativa (WCAG 2.1)
|
|
24
|
+
* Retorna valor entre 0 (preto) e 1 (branco)
|
|
25
|
+
*/
|
|
26
|
+
export declare function getLuminance(hex: string): number;
|
|
27
|
+
/**
|
|
28
|
+
* Detecta se uma cor e clara (luminancia > 0.5)
|
|
8
29
|
*/
|
|
9
30
|
export declare function isLightColor(hex: string): boolean;
|
|
10
31
|
/**
|
|
11
|
-
* Detecta se uma cor
|
|
12
|
-
* Retorna true se a cor for escura (luminância <= 0.5)
|
|
32
|
+
* Detecta se uma cor e escura (luminancia <= 0.5)
|
|
13
33
|
*/
|
|
14
34
|
export declare function isDarkColor(hex: string): boolean;
|
|
15
35
|
/**
|
|
16
|
-
*
|
|
36
|
+
* Calcula contrast ratio entre duas cores (WCAG 2.1)
|
|
37
|
+
* Retorna valor entre 1 (sem contraste) e 21 (maximo)
|
|
38
|
+
*/
|
|
39
|
+
export declare function contrastRatio(fg: string, bg: string): number;
|
|
40
|
+
/**
|
|
41
|
+
* Escurece uma cor por amount (0-100, reduz lightness)
|
|
42
|
+
*/
|
|
43
|
+
export declare function darken(hex: string, amount: number): string;
|
|
44
|
+
/**
|
|
45
|
+
* Clareia uma cor por amount (0-100, aumenta lightness)
|
|
46
|
+
*/
|
|
47
|
+
export declare function lighten(hex: string, amount: number): string;
|
|
48
|
+
/**
|
|
49
|
+
* Ajusta foreground (clareia ou escurece) ate atingir minRatio de contraste com bg
|
|
50
|
+
* Default minRatio = 4.5 (WCAG AA para texto normal)
|
|
17
51
|
*/
|
|
18
|
-
export declare function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
52
|
+
export declare function ensureContrast(fg: string, bg: string, minRatio?: number): string;
|
|
53
|
+
export interface DerivedPaletteColors {
|
|
54
|
+
/** Theme color tokens (patch em /theme/colors/*) */
|
|
55
|
+
themeColors: {
|
|
56
|
+
primary: string;
|
|
57
|
+
secondary: string;
|
|
58
|
+
accent: string;
|
|
59
|
+
bg: string;
|
|
60
|
+
surface: string;
|
|
61
|
+
text: string;
|
|
62
|
+
primaryHover: string;
|
|
63
|
+
primaryText: string;
|
|
64
|
+
secondaryHover: string;
|
|
65
|
+
mutedText: string;
|
|
66
|
+
border: string;
|
|
67
|
+
linkColor: string;
|
|
68
|
+
menuLinkColor: string;
|
|
69
|
+
ring: string;
|
|
70
|
+
};
|
|
71
|
+
/** Hero gradient colors */
|
|
72
|
+
heroGradientStart: string;
|
|
73
|
+
heroGradientEnd: string;
|
|
74
|
+
heroTitleColor: string;
|
|
75
|
+
heroSubtitleColor: string;
|
|
76
|
+
heroDescColor: string;
|
|
77
|
+
/** Navbar */
|
|
78
|
+
navbarBg: string;
|
|
79
|
+
/** Footer */
|
|
80
|
+
footerLinkHover: string;
|
|
81
|
+
}
|
|
25
82
|
/**
|
|
26
|
-
*
|
|
83
|
+
* Deriva todas as cores da paleta a partir dos seeds
|
|
27
84
|
*/
|
|
28
|
-
export declare function
|
|
85
|
+
export declare function derivePaletteColors(palette: ColorPalette): DerivedPaletteColors;
|
|
29
86
|
//# sourceMappingURL=colorUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorUtils.d.ts","sourceRoot":"","sources":["../../src/utils/colorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"colorUtils.d.ts","sourceRoot":"","sources":["../../src/utils/colorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM9D;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAShF;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAuBzE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAsBhE;AAMD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAShD;AAED;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B,aAAa;IACb,QAAQ,EAAE,MAAM,CAAC;IAEjB,aAAa;IACb,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,oBAAoB,CAmD/E"}
|
package/dist/utils/colorUtils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C(r) {
|
|
2
2
|
const n = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);
|
|
3
3
|
return n ? {
|
|
4
4
|
r: parseInt(n[1], 16),
|
|
@@ -6,16 +6,102 @@ function s(r) {
|
|
|
6
6
|
b: parseInt(n[3], 16)
|
|
7
7
|
} : null;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
const n =
|
|
11
|
-
if (!n) return
|
|
12
|
-
const
|
|
13
|
-
|
|
9
|
+
function y(r) {
|
|
10
|
+
const n = C(r);
|
|
11
|
+
if (!n) return { h: 0, s: 0, l: 50 };
|
|
12
|
+
const o = n.r / 255, c = n.g / 255, i = n.b / 255, t = Math.max(o, c, i), f = Math.min(o, c, i), u = (t + f) / 2;
|
|
13
|
+
if (t === f) return { h: 0, s: 0, l: u * 100 };
|
|
14
|
+
const s = t - f, a = u > 0.5 ? s / (2 - t - f) : s / (t + f);
|
|
15
|
+
let e = 0;
|
|
16
|
+
return t === o ? e = ((c - i) / s + (c < i ? 6 : 0)) / 6 : t === c ? e = ((i - o) / s + 2) / 6 : e = ((o - c) / s + 4) / 6, { h: e * 360, s: a * 100, l: u * 100 };
|
|
14
17
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
18
|
+
function k(r, n, o) {
|
|
19
|
+
const c = n / 100, i = o / 100, t = (1 - Math.abs(2 * i - 1)) * c, f = t * (1 - Math.abs(r / 60 % 2 - 1)), u = i - t / 2;
|
|
20
|
+
let s = 0, a = 0, e = 0;
|
|
21
|
+
r < 60 ? (s = t, a = f, e = 0) : r < 120 ? (s = f, a = t, e = 0) : r < 180 ? (s = 0, a = t, e = f) : r < 240 ? (s = 0, a = f, e = t) : r < 300 ? (s = f, a = 0, e = t) : (s = t, a = 0, e = f);
|
|
22
|
+
const h = (M) => {
|
|
23
|
+
const g = Math.round((M + u) * 255).toString(16);
|
|
24
|
+
return g.length === 1 ? "0" + g : g;
|
|
25
|
+
};
|
|
26
|
+
return `#${h(s)}${h(a)}${h(e)}`;
|
|
27
|
+
}
|
|
28
|
+
function l(r) {
|
|
29
|
+
const n = C(r);
|
|
30
|
+
if (!n) return 0.5;
|
|
31
|
+
const [o, c, i] = [n.r / 255, n.g / 255, n.b / 255].map((t) => t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4));
|
|
32
|
+
return 0.2126 * o + 0.7152 * c + 0.0722 * i;
|
|
33
|
+
}
|
|
34
|
+
function L(r) {
|
|
35
|
+
return l(r) > 0.5;
|
|
36
|
+
}
|
|
37
|
+
function x(r, n) {
|
|
38
|
+
const o = l(r), c = l(n), i = Math.max(o, c), t = Math.min(o, c);
|
|
39
|
+
return (i + 0.05) / (t + 0.05);
|
|
40
|
+
}
|
|
41
|
+
function d(r, n) {
|
|
42
|
+
const o = y(r);
|
|
43
|
+
return k(o.h, o.s, Math.max(0, o.l - n));
|
|
44
|
+
}
|
|
45
|
+
function m(r, n) {
|
|
46
|
+
const o = y(r);
|
|
47
|
+
return k(o.h, o.s, Math.min(100, o.l + n));
|
|
48
|
+
}
|
|
49
|
+
function b(r, n, o = 4.5) {
|
|
50
|
+
if (x(r, n) >= o) return r;
|
|
51
|
+
const c = l(n), i = y(r), t = c < 0.5 ? 1 : -1;
|
|
52
|
+
let f = r, u = x(r, n);
|
|
53
|
+
for (let s = 5; s <= 100; s += 5) {
|
|
54
|
+
const a = Math.max(0, Math.min(100, i.l + t * s)), e = k(i.h, i.s, a), h = x(e, n);
|
|
55
|
+
if (h > u && (f = e, u = h), h >= o) return e;
|
|
56
|
+
}
|
|
57
|
+
return u < o ? c < 0.5 ? "#ffffff" : "#000000" : f;
|
|
58
|
+
}
|
|
59
|
+
function H(r) {
|
|
60
|
+
const n = L(r.background), o = b("#ffffff", r.primary), c = n ? "#6b7280" : "#9ca3af", i = n ? d(r.background, 12) : m(r.background, 15), t = r.menuLinkColor || r.primary, f = r.linkColor || r.primary, u = r.heroGradientStart || d(r.primary, 35), s = r.heroGradientEnd || d(r.secondary, 25), a = b("#ffffff", u, 7), e = b(
|
|
61
|
+
m(a, 10),
|
|
62
|
+
u,
|
|
63
|
+
4.5
|
|
64
|
+
), h = b(
|
|
65
|
+
m(a, 20),
|
|
66
|
+
u,
|
|
67
|
+
4.5
|
|
68
|
+
);
|
|
69
|
+
return {
|
|
70
|
+
themeColors: {
|
|
71
|
+
primary: r.primary,
|
|
72
|
+
secondary: r.secondary,
|
|
73
|
+
accent: r.accent,
|
|
74
|
+
bg: r.background,
|
|
75
|
+
surface: r.surface || (n ? "#f8fafc" : m(r.background, 5)),
|
|
76
|
+
text: r.text,
|
|
77
|
+
primaryHover: d(r.primary, 10),
|
|
78
|
+
primaryText: o,
|
|
79
|
+
secondaryHover: d(r.secondary, 10),
|
|
80
|
+
mutedText: c,
|
|
81
|
+
border: i,
|
|
82
|
+
linkColor: f,
|
|
83
|
+
menuLinkColor: t,
|
|
84
|
+
ring: r.primary
|
|
85
|
+
},
|
|
86
|
+
heroGradientStart: u,
|
|
87
|
+
heroGradientEnd: s,
|
|
88
|
+
heroTitleColor: a,
|
|
89
|
+
heroSubtitleColor: e,
|
|
90
|
+
heroDescColor: h,
|
|
91
|
+
navbarBg: r.background,
|
|
92
|
+
footerLinkHover: m(r.primary, 20)
|
|
93
|
+
};
|
|
17
94
|
}
|
|
18
95
|
export {
|
|
19
|
-
|
|
96
|
+
x as contrastRatio,
|
|
97
|
+
d as darken,
|
|
98
|
+
H as derivePaletteColors,
|
|
99
|
+
b as ensureContrast,
|
|
100
|
+
l as getLuminance,
|
|
101
|
+
y as hexToHSL,
|
|
102
|
+
C as hexToRgb,
|
|
103
|
+
k as hslToHex,
|
|
104
|
+
L as isLightColor,
|
|
105
|
+
m as lighten
|
|
20
106
|
};
|
|
21
107
|
//# sourceMappingURL=colorUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorUtils.js","sources":["../../src/utils/colorUtils.ts"],"sourcesContent":["/**\n * Color Utilities\n * Utilitários para manipulação de cores\n */\n\n/**\n * Converte hex para RGB\n */\nfunction hexToRgb(hex: string): { r: number; g: number; b: number } | null {\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex)\n return result\n ? {\n r: parseInt(result[1], 16),\n g: parseInt(result[2], 16),\n b: parseInt(result[3], 16),\n }\n : null\n}\n\n/**\n * Calcula o brilho relativo de uma cor (0-255)\n * Usa a fórmula de luminância relativa\n */\nfunction getLuminance(hex: string): number {\n const rgb = hexToRgb(hex)\n if (!rgb) return 128 // Default para cinza médio\n\n // Normalizar valores RGB para 0-1\n const [r, g, b] = [rgb.r / 255, rgb.g / 255, rgb.b / 255]\n\n // Aplicar gamma correction\n const [rLinear, gLinear, bLinear] = [r, g, b].map((val) => {\n return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4)\n })\n\n // Calcular luminância relativa\n return 0.2126 * rLinear + 0.7152 * gLinear + 0.0722 * bLinear\n}\n\n/**\n * Detecta se uma cor é clara ou escura\n * Retorna true se a cor for clara (luminância > 0.5)\n */\nexport function isLightColor(hex: string): boolean {\n return getLuminance(hex) > 0.5\n}\n\n/**\n * Detecta se uma cor é escura\n * Retorna true se a cor for escura (luminância <= 0.5)\n */\nexport function isDarkColor(hex: string): boolean {\n return !isLightColor(hex)\n}\n\n/**\n * Aplica cores customizadas à landing page usando CSS variables\n */\nexport function applyLandingPageColors(colors: {\n primary?: string\n secondary?: string\n background?: string\n text?: string\n accent?: string\n}): void {\n const root = document.documentElement\n\n if (colors.primary) {\n root.style.setProperty('--lp-primary-color', colors.primary)\n }\n if (colors.secondary) {\n root.style.setProperty('--lp-secondary-color', colors.secondary)\n }\n if (colors.background) {\n root.style.setProperty('--lp-background-color', colors.background)\n }\n if (colors.text) {\n root.style.setProperty('--lp-text-color', colors.text)\n }\n if (colors.accent) {\n root.style.setProperty('--lp-accent-color', colors.accent)\n }\n}\n\n/**\n * Remove cores customizadas\n */\nexport function removeLandingPageColors(): void {\n const root = document.documentElement\n root.style.removeProperty('--lp-primary-color')\n root.style.removeProperty('--lp-secondary-color')\n root.style.removeProperty('--lp-background-color')\n root.style.removeProperty('--lp-text-color')\n root.style.removeProperty('--lp-accent-color')\n}\n"],"names":["hexToRgb","hex","result","getLuminance","rgb","r","g","b","rLinear","gLinear","bLinear","val","isLightColor"],"mappings":"AAQA,SAASA,EAASC,GAAyD;AACzE,QAAMC,IAAS,4CAA4C,KAAKD,CAAG;AACnE,SAAOC,IACH;AAAA,IACE,GAAG,SAASA,EAAO,CAAC,GAAG,EAAE;AAAA,IACzB,GAAG,SAASA,EAAO,CAAC,GAAG,EAAE;AAAA,IACzB,GAAG,SAASA,EAAO,CAAC,GAAG,EAAE;AAAA,EAAA,IAE3B;AACN;AAMA,SAASC,EAAaF,GAAqB;AACzC,QAAMG,IAAMJ,EAASC,CAAG;AACxB,MAAI,CAACG,EAAK,QAAO;AAGjB,QAAM,CAACC,GAAGC,GAAGC,CAAC,IAAI,CAACH,EAAI,IAAI,KAAKA,EAAI,IAAI,KAAKA,EAAI,IAAI,GAAG,GAGlD,CAACI,GAASC,GAASC,CAAO,IAAI,CAACL,GAAGC,GAAGC,CAAC,EAAE,IAAI,CAACI,MAC1CA,KAAO,UAAUA,IAAM,QAAQ,KAAK,KAAKA,IAAM,SAAS,OAAO,GAAG,CAC1E;AAGD,SAAO,SAASH,IAAU,SAASC,IAAU,SAASC;AACxD;AAMO,SAASE,EAAaX,GAAsB;AACjD,SAAOE,EAAaF,CAAG,IAAI;AAC7B;"}
|
|
1
|
+
{"version":3,"file":"colorUtils.js","sources":["../../src/utils/colorUtils.ts"],"sourcesContent":["/**\n * Color Utilities\n * Utilitarios para manipulacao de cores, contraste WCAG e derivacao de paleta\n */\n\nimport type { ColorPalette } from \"../editor/PaletteSelector\";\n\n// ============================================================================\n// Core Conversions\n// ============================================================================\n\n/**\n * Converte hex para RGB\n */\nexport function hexToRgb(hex: string): { r: number; g: number; b: number } | null {\n const result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex)\n return result\n ? {\n r: parseInt(result[1], 16),\n g: parseInt(result[2], 16),\n b: parseInt(result[3], 16),\n }\n : null\n}\n\n/**\n * Converte hex para HSL\n */\nexport function hexToHSL(hex: string): { h: number; s: number; l: number } {\n const rgb = hexToRgb(hex)\n if (!rgb) return { h: 0, s: 0, l: 50 }\n\n const r = rgb.r / 255\n const g = rgb.g / 255\n const b = rgb.b / 255\n\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n const l = (max + min) / 2\n\n if (max === min) return { h: 0, s: 0, l: l * 100 }\n\n const d = max - min\n const s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\n\n let h = 0\n if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6\n else if (max === g) h = ((b - r) / d + 2) / 6\n else h = ((r - g) / d + 4) / 6\n\n return { h: h * 360, s: s * 100, l: l * 100 }\n}\n\n/**\n * Converte HSL para hex\n */\nexport function hslToHex(h: number, s: number, l: number): string {\n const sNorm = s / 100\n const lNorm = l / 100\n\n const c = (1 - Math.abs(2 * lNorm - 1)) * sNorm\n const x = c * (1 - Math.abs(((h / 60) % 2) - 1))\n const m = lNorm - c / 2\n\n let r = 0, g = 0, b = 0\n if (h < 60) { r = c; g = x; b = 0 }\n else if (h < 120) { r = x; g = c; b = 0 }\n else if (h < 180) { r = 0; g = c; b = x }\n else if (h < 240) { r = 0; g = x; b = c }\n else if (h < 300) { r = x; g = 0; b = c }\n else { r = c; g = 0; b = x }\n\n const toHex = (v: number) => {\n const hex = Math.round((v + m) * 255).toString(16)\n return hex.length === 1 ? \"0\" + hex : hex\n }\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`\n}\n\n// ============================================================================\n// Luminance & Contrast (WCAG 2.1)\n// ============================================================================\n\n/**\n * Calcula luminancia relativa (WCAG 2.1)\n * Retorna valor entre 0 (preto) e 1 (branco)\n */\nexport function getLuminance(hex: string): number {\n const rgb = hexToRgb(hex)\n if (!rgb) return 0.5\n\n const [r, g, b] = [rgb.r / 255, rgb.g / 255, rgb.b / 255].map((val) => {\n return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4)\n })\n\n return 0.2126 * r + 0.7152 * g + 0.0722 * b\n}\n\n/**\n * Detecta se uma cor e clara (luminancia > 0.5)\n */\nexport function isLightColor(hex: string): boolean {\n return getLuminance(hex) > 0.5\n}\n\n/**\n * Detecta se uma cor e escura (luminancia <= 0.5)\n */\nexport function isDarkColor(hex: string): boolean {\n return !isLightColor(hex)\n}\n\n/**\n * Calcula contrast ratio entre duas cores (WCAG 2.1)\n * Retorna valor entre 1 (sem contraste) e 21 (maximo)\n */\nexport function contrastRatio(fg: string, bg: string): number {\n const l1 = getLuminance(fg)\n const l2 = getLuminance(bg)\n const lighter = Math.max(l1, l2)\n const darker = Math.min(l1, l2)\n return (lighter + 0.05) / (darker + 0.05)\n}\n\n// ============================================================================\n// Color Manipulation\n// ============================================================================\n\n/**\n * Escurece uma cor por amount (0-100, reduz lightness)\n */\nexport function darken(hex: string, amount: number): string {\n const hsl = hexToHSL(hex)\n return hslToHex(hsl.h, hsl.s, Math.max(0, hsl.l - amount))\n}\n\n/**\n * Clareia uma cor por amount (0-100, aumenta lightness)\n */\nexport function lighten(hex: string, amount: number): string {\n const hsl = hexToHSL(hex)\n return hslToHex(hsl.h, hsl.s, Math.min(100, hsl.l + amount))\n}\n\n/**\n * Ajusta foreground (clareia ou escurece) ate atingir minRatio de contraste com bg\n * Default minRatio = 4.5 (WCAG AA para texto normal)\n */\nexport function ensureContrast(fg: string, bg: string, minRatio: number = 4.5): string {\n if (contrastRatio(fg, bg) >= minRatio) return fg\n\n const bgLum = getLuminance(bg)\n const hsl = hexToHSL(fg)\n\n // Tentar clarear se bg e escuro, escurecer se bg e claro\n const direction = bgLum < 0.5 ? 1 : -1\n let bestColor = fg\n let bestRatio = contrastRatio(fg, bg)\n\n for (let step = 5; step <= 100; step += 5) {\n const newL = Math.max(0, Math.min(100, hsl.l + direction * step))\n const candidate = hslToHex(hsl.h, hsl.s, newL)\n const ratio = contrastRatio(candidate, bg)\n if (ratio > bestRatio) {\n bestColor = candidate\n bestRatio = ratio\n }\n if (ratio >= minRatio) return candidate\n }\n\n // Fallback: branco ou preto (maximo contraste)\n if (bestRatio < minRatio) {\n return bgLum < 0.5 ? \"#ffffff\" : \"#000000\"\n }\n return bestColor\n}\n\n// ============================================================================\n// Palette Derivation\n// ============================================================================\n\nexport interface DerivedPaletteColors {\n /** Theme color tokens (patch em /theme/colors/*) */\n themeColors: {\n primary: string;\n secondary: string;\n accent: string;\n bg: string;\n surface: string;\n text: string;\n primaryHover: string;\n primaryText: string;\n secondaryHover: string;\n mutedText: string;\n border: string;\n linkColor: string;\n menuLinkColor: string;\n ring: string;\n };\n\n /** Hero gradient colors */\n heroGradientStart: string;\n heroGradientEnd: string;\n heroTitleColor: string;\n heroSubtitleColor: string;\n heroDescColor: string;\n\n /** Navbar */\n navbarBg: string;\n\n /** Footer */\n footerLinkHover: string;\n}\n\n/**\n * Deriva todas as cores da paleta a partir dos seeds\n */\nexport function derivePaletteColors(palette: ColorPalette): DerivedPaletteColors {\n const bgLight = isLightColor(palette.background)\n const primaryText = ensureContrast(\"#ffffff\", palette.primary)\n\n const mutedText = bgLight ? \"#6b7280\" : \"#9ca3af\"\n const border = bgLight ? darken(palette.background, 12) : lighten(palette.background, 15)\n const menuLinkColor = palette.menuLinkColor || palette.primary\n const linkColor = palette.linkColor || palette.primary\n\n // Hero gradients: usar paleta se definido, senao derivar do primary/secondary\n const heroGradientStart = palette.heroGradientStart || darken(palette.primary, 35)\n const heroGradientEnd = palette.heroGradientEnd || darken(palette.secondary, 25)\n\n // Hero text colors: garantir contraste sobre o gradiente start (area mais escura)\n const heroTitleColor = ensureContrast(\"#ffffff\", heroGradientStart, 7)\n const heroSubtitleColor = ensureContrast(\n lighten(heroTitleColor, 10),\n heroGradientStart,\n 4.5\n )\n const heroDescColor = ensureContrast(\n lighten(heroTitleColor, 20),\n heroGradientStart,\n 4.5\n )\n\n return {\n themeColors: {\n primary: palette.primary,\n secondary: palette.secondary,\n accent: palette.accent,\n bg: palette.background,\n surface: palette.surface || (bgLight ? \"#f8fafc\" : lighten(palette.background, 5)),\n text: palette.text,\n primaryHover: darken(palette.primary, 10),\n primaryText,\n secondaryHover: darken(palette.secondary, 10),\n mutedText,\n border,\n linkColor,\n menuLinkColor,\n ring: palette.primary,\n },\n heroGradientStart,\n heroGradientEnd,\n heroTitleColor,\n heroSubtitleColor,\n heroDescColor,\n navbarBg: palette.background,\n footerLinkHover: lighten(palette.primary, 20),\n }\n}\n"],"names":["hexToRgb","hex","result","hexToHSL","rgb","r","g","b","max","min","l","d","s","h","hslToHex","sNorm","lNorm","c","x","m","toHex","v","getLuminance","val","isLightColor","contrastRatio","fg","bg","l1","l2","lighter","darker","darken","amount","hsl","lighten","ensureContrast","minRatio","bgLum","direction","bestColor","bestRatio","step","newL","candidate","ratio","derivePaletteColors","palette","bgLight","primaryText","mutedText","border","menuLinkColor","linkColor","heroGradientStart","heroGradientEnd","heroTitleColor","heroSubtitleColor","heroDescColor"],"mappings":"AAcO,SAASA,EAASC,GAAyD;AAChF,QAAMC,IAAS,4CAA4C,KAAKD,CAAG;AACnE,SAAOC,IACH;AAAA,IACE,GAAG,SAASA,EAAO,CAAC,GAAG,EAAE;AAAA,IACzB,GAAG,SAASA,EAAO,CAAC,GAAG,EAAE;AAAA,IACzB,GAAG,SAASA,EAAO,CAAC,GAAG,EAAE;AAAA,EAAA,IAE3B;AACN;AAKO,S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UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAeD,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,UAAU,EACV,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EAAE,WAAW,EAAE,+DAA+D;AACxF,gBAAgB,EAChB,UAAU,GACX,EAAE,sBAAsB,kDA6XxB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as A, useRef as B, useCallback as F, useEffect as V } from "react";
|
|
3
3
|
import { matchDynamicPage as W } from "../engine/plugins/dynamicPageResolver.js";
|
|
4
4
|
import { hydratePageWithContent as G } from "../engine/plugins/contentHydration.js";
|
|
5
5
|
import { logger as z } from "../utils/logger.js";
|
|
6
|
-
import { defaultThemeTokens as
|
|
6
|
+
import { defaultThemeTokens as P } from "../engine/schema/themeTokens.js";
|
|
7
7
|
import { exportPageToHtml as _ } from "../engine/export/exportHtml.js";
|
|
8
8
|
import { createEmptySiteDocument as q } from "../engine/schema/siteDocument.js";
|
|
9
9
|
function J(o) {
|
|
@@ -23,15 +23,15 @@ function re({
|
|
|
23
23
|
apiBaseUrl: r,
|
|
24
24
|
projectId: h,
|
|
25
25
|
pageSlug: n,
|
|
26
|
-
schoolSlug:
|
|
27
|
-
schoolData:
|
|
26
|
+
schoolSlug: b,
|
|
27
|
+
schoolData: D,
|
|
28
28
|
// reservado para header/navbar dinâmico (logo, nome da escola)
|
|
29
|
-
contentProviders:
|
|
30
|
-
onNavigate:
|
|
29
|
+
contentProviders: C,
|
|
30
|
+
onNavigate: c
|
|
31
31
|
}) {
|
|
32
|
-
const [s,
|
|
33
|
-
|
|
34
|
-
const
|
|
32
|
+
const [s, E] = A(null), [j, w] = A(null), [p, H] = A(!0), [f, I] = A(null), [M, y] = A(null), k = B(c);
|
|
33
|
+
k.current = c;
|
|
34
|
+
const L = F((e) => {
|
|
35
35
|
const t = `<script>
|
|
36
36
|
(function() {
|
|
37
37
|
document.addEventListener('click', function(e) {
|
|
@@ -54,14 +54,14 @@ function re({
|
|
|
54
54
|
<\/script>`;
|
|
55
55
|
return e.includes("</body>") ? e.replace("</body>", `${t}</body>`) : e + t;
|
|
56
56
|
}, []);
|
|
57
|
-
if (
|
|
57
|
+
if (V(() => {
|
|
58
58
|
const e = (t) => {
|
|
59
|
-
t.data?.type === "viewer-navigate" && t.data?.href &&
|
|
59
|
+
t.data?.type === "viewer-navigate" && t.data?.href && k.current && k.current(t.data.href);
|
|
60
60
|
};
|
|
61
61
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
62
|
-
}, []),
|
|
62
|
+
}, []), V(() => {
|
|
63
63
|
let e = !1;
|
|
64
|
-
return
|
|
64
|
+
return H(!0), I(null), (async () => {
|
|
65
65
|
try {
|
|
66
66
|
const t = await fetch(
|
|
67
67
|
`${r}/sites/${o}?projectId=${h}`
|
|
@@ -71,49 +71,49 @@ function re({
|
|
|
71
71
|
const i = await t.json();
|
|
72
72
|
if (e) return;
|
|
73
73
|
if (i.template) {
|
|
74
|
-
const l = i.template.schemaVersion,
|
|
75
|
-
if (l === 2 || l === "2" ||
|
|
74
|
+
const l = i.template.schemaVersion, x = i.template.pages && Array.isArray(i.template.pages);
|
|
75
|
+
if (l === 2 || l === "2" || x) {
|
|
76
76
|
const u = i.template;
|
|
77
|
-
Array.isArray(u.pages) || (u.pages = []), u.schemaVersion !== 2 && u.schemaVersion !== "2" && (u.schemaVersion = 2),
|
|
77
|
+
Array.isArray(u.pages) || (u.pages = []), u.schemaVersion !== 2 && u.schemaVersion !== "2" && (u.schemaVersion = 2), E(u);
|
|
78
78
|
} else
|
|
79
79
|
throw new Error(
|
|
80
80
|
"Formato de template legado não suportado. Por favor, recrie o site."
|
|
81
81
|
);
|
|
82
82
|
} else
|
|
83
|
-
|
|
84
|
-
if (i.publishedHtml && J(i.publishedHtml) ?
|
|
83
|
+
E(null);
|
|
84
|
+
if (i.publishedHtml && J(i.publishedHtml) ? w(i.publishedHtml) : w(null), !i.template && !i.publishedHtml)
|
|
85
85
|
throw new Error("Template não encontrado");
|
|
86
86
|
} catch (t) {
|
|
87
87
|
e || I(
|
|
88
88
|
t instanceof Error ? t.message : "Erro ao carregar landing page"
|
|
89
89
|
);
|
|
90
90
|
} finally {
|
|
91
|
-
e ||
|
|
91
|
+
e || H(!1);
|
|
92
92
|
}
|
|
93
93
|
})(), () => {
|
|
94
94
|
e = !0;
|
|
95
95
|
};
|
|
96
|
-
}, [o, r, h]),
|
|
96
|
+
}, [o, r, h]), V(() => {
|
|
97
97
|
if (!s) {
|
|
98
98
|
y(null);
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
let e = !1;
|
|
102
|
-
const t = Array.isArray(s.pages) ? s.pages : [], i = K(
|
|
102
|
+
const t = Array.isArray(s.pages) ? s.pages : [], i = K(C);
|
|
103
103
|
if (i.size === 0) {
|
|
104
104
|
y(null);
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
let l,
|
|
107
|
+
let l, x = {};
|
|
108
108
|
if (n) {
|
|
109
109
|
const d = t.find(
|
|
110
|
-
(
|
|
110
|
+
(m) => m.slug === n || m.id === n
|
|
111
111
|
);
|
|
112
112
|
if (d)
|
|
113
113
|
l = d;
|
|
114
114
|
else {
|
|
115
|
-
const
|
|
116
|
-
|
|
115
|
+
const m = W(t, n);
|
|
116
|
+
m && (l = m.page, x = m.params);
|
|
117
117
|
}
|
|
118
118
|
} else
|
|
119
119
|
l = t.find((d) => d.id === "home") ?? t[0];
|
|
@@ -121,32 +121,33 @@ function re({
|
|
|
121
121
|
y(null);
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
|
-
const
|
|
124
|
+
const T = !!l.dataSource, u = l.structure?.some(
|
|
125
125
|
(d) => d.type === "blogPostGrid"
|
|
126
126
|
);
|
|
127
|
-
if (!
|
|
127
|
+
if (!T && !u) {
|
|
128
128
|
y(null);
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
let R = l;
|
|
132
|
-
return !
|
|
132
|
+
return !T && u && (R = {
|
|
133
133
|
...l,
|
|
134
134
|
dataSource: { mode: "list", provider: "blog-posts" }
|
|
135
|
-
}), G(R, i,
|
|
135
|
+
}), G(R, i, x).then((d) => {
|
|
136
136
|
if (e) return;
|
|
137
|
-
const
|
|
137
|
+
const m = N(
|
|
138
138
|
d,
|
|
139
139
|
s,
|
|
140
|
-
|
|
141
|
-
t
|
|
140
|
+
b,
|
|
141
|
+
t,
|
|
142
|
+
!1
|
|
142
143
|
);
|
|
143
|
-
y(
|
|
144
|
+
y(m ?? null);
|
|
144
145
|
}).catch((d) => {
|
|
145
|
-
e || (z.error("Error
|
|
146
|
+
e || (z.error("Error in content hydration:", d), y(null));
|
|
146
147
|
}), () => {
|
|
147
148
|
e = !0;
|
|
148
149
|
};
|
|
149
|
-
}, [s, n,
|
|
150
|
+
}, [s, n, C, b]), p)
|
|
150
151
|
return /* @__PURE__ */ a(
|
|
151
152
|
"div",
|
|
152
153
|
{
|
|
@@ -159,7 +160,7 @@ function re({
|
|
|
159
160
|
children: /* @__PURE__ */ a("div", { children: "Carregando..." })
|
|
160
161
|
}
|
|
161
162
|
);
|
|
162
|
-
if (
|
|
163
|
+
if (f)
|
|
163
164
|
return /* @__PURE__ */ a(
|
|
164
165
|
"div",
|
|
165
166
|
{
|
|
@@ -169,14 +170,14 @@ function re({
|
|
|
169
170
|
justifyContent: "center",
|
|
170
171
|
minHeight: "100vh"
|
|
171
172
|
},
|
|
172
|
-
children: /* @__PURE__ */ a("div", { children:
|
|
173
|
+
children: /* @__PURE__ */ a("div", { children: f || "Landing page não encontrada" })
|
|
173
174
|
}
|
|
174
175
|
);
|
|
175
|
-
if (
|
|
176
|
+
if (j && (!n || n === "home") && !s)
|
|
176
177
|
return /* @__PURE__ */ a(
|
|
177
178
|
"iframe",
|
|
178
179
|
{
|
|
179
|
-
srcDoc:
|
|
180
|
+
srcDoc: L(j),
|
|
180
181
|
title: "Site publicado",
|
|
181
182
|
style: {
|
|
182
183
|
width: "100%",
|
|
@@ -188,8 +189,8 @@ function re({
|
|
|
188
189
|
);
|
|
189
190
|
if (!s)
|
|
190
191
|
return null;
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
192
|
+
const g = Array.isArray(s.pages) ? s.pages : [];
|
|
193
|
+
if (g.length === 0)
|
|
193
194
|
return /* @__PURE__ */ a(
|
|
194
195
|
"div",
|
|
195
196
|
{
|
|
@@ -208,7 +209,7 @@ function re({
|
|
|
208
209
|
return /* @__PURE__ */ a(
|
|
209
210
|
"iframe",
|
|
210
211
|
{
|
|
211
|
-
srcDoc:
|
|
212
|
+
srcDoc: L(M),
|
|
212
213
|
title: "Site",
|
|
213
214
|
style: {
|
|
214
215
|
width: "100%",
|
|
@@ -218,12 +219,12 @@ function re({
|
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
221
|
);
|
|
221
|
-
let
|
|
222
|
-
if (!
|
|
223
|
-
const e = W(
|
|
224
|
-
e && (
|
|
222
|
+
let v = (n ? g.find((e) => e.slug === n || e.id === n) : null) ?? null;
|
|
223
|
+
if (!v && n) {
|
|
224
|
+
const e = W(g, n);
|
|
225
|
+
e && (v = e.page);
|
|
225
226
|
}
|
|
226
|
-
if (
|
|
227
|
+
if (v || (v = g.find((e) => e.id === "home") ?? g[0]), !v)
|
|
227
228
|
return /* @__PURE__ */ a(
|
|
228
229
|
"div",
|
|
229
230
|
{
|
|
@@ -236,11 +237,11 @@ function re({
|
|
|
236
237
|
children: /* @__PURE__ */ a("div", { children: "Página não encontrada" })
|
|
237
238
|
}
|
|
238
239
|
);
|
|
239
|
-
const $ = N(
|
|
240
|
+
const $ = N(v, s, b, g);
|
|
240
241
|
return $ ? /* @__PURE__ */ a(
|
|
241
242
|
"iframe",
|
|
242
243
|
{
|
|
243
|
-
srcDoc:
|
|
244
|
+
srcDoc: L($),
|
|
244
245
|
title: "Site",
|
|
245
246
|
style: {
|
|
246
247
|
width: "100%",
|
|
@@ -264,30 +265,30 @@ function re({
|
|
|
264
265
|
}
|
|
265
266
|
);
|
|
266
267
|
}
|
|
267
|
-
function N(o, r, h, n) {
|
|
268
|
-
const
|
|
268
|
+
function N(o, r, h, n, b = !0) {
|
|
269
|
+
const D = {
|
|
269
270
|
...o,
|
|
270
271
|
structure: Array.isArray(o.structure) ? o.structure : []
|
|
271
|
-
},
|
|
272
|
-
...
|
|
272
|
+
}, C = q(""), c = r.theme && typeof r.theme == "object" ? r.theme : null, s = c ? {
|
|
273
|
+
...P,
|
|
273
274
|
...c,
|
|
274
|
-
colors: c.colors && typeof c.colors == "object" ? { ...
|
|
275
|
-
typography: c.typography && typeof c.typography == "object" ? { ...
|
|
276
|
-
} :
|
|
275
|
+
colors: c.colors && typeof c.colors == "object" ? { ...P.colors, ...c.colors } : P.colors,
|
|
276
|
+
typography: c.typography && typeof c.typography == "object" ? { ...P.typography, ...c.typography } : P.typography
|
|
277
|
+
} : C.theme, E = {
|
|
277
278
|
...r,
|
|
278
279
|
schemaVersion: 2,
|
|
279
|
-
theme:
|
|
280
|
-
},
|
|
281
|
-
...
|
|
282
|
-
structure: Array.isArray(
|
|
280
|
+
theme: s
|
|
281
|
+
}, j = h ? `/site/escola/${h}` : "/site", w = n ?? r.pages, p = w.find((f) => f.id === "home") ?? w[0], H = p && p.id !== D.id ? {
|
|
282
|
+
...p,
|
|
283
|
+
structure: Array.isArray(p.structure) ? p.structure : []
|
|
283
284
|
} : void 0;
|
|
284
285
|
try {
|
|
285
286
|
const f = _(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
287
|
+
D,
|
|
288
|
+
E,
|
|
289
|
+
b,
|
|
290
|
+
j,
|
|
291
|
+
H ? { layoutFromPage: H } : void 0
|
|
291
292
|
);
|
|
292
293
|
return !f || !f.trim() ? null : f;
|
|
293
294
|
} catch (f) {
|