@storepecker/editor-bridge 1.0.1

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/index.js ADDED
@@ -0,0 +1,587 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ CSS_VAR_MAP: () => CSS_VAR_MAP,
24
+ EditorContext: () => EditorContext,
25
+ EditorProvider: () => EditorProvider,
26
+ SectionWrapper: () => SectionWrapper,
27
+ syncCSSVars: () => syncCSSVars,
28
+ useBranding: () => useBranding,
29
+ useColorScheme: () => useColorScheme,
30
+ useEditorMode: () => useEditorMode,
31
+ useFontStyles: () => useFontStyles,
32
+ useFooterConfig: () => useFooterConfig,
33
+ useHeroConfig: () => useHeroConfig,
34
+ useLandingConfig: () => useLandingConfig,
35
+ useNavbarConfig: () => useNavbarConfig,
36
+ useSectionById: () => useSectionById,
37
+ useSections: () => useSections,
38
+ useSocialLinks: () => useSocialLinks
39
+ });
40
+ module.exports = __toCommonJS(index_exports);
41
+
42
+ // src/provider/EditorProvider.tsx
43
+ var import_react2 = require("react");
44
+
45
+ // src/provider/EditorContext.ts
46
+ var import_react = require("react");
47
+ var EditorContext = (0, import_react.createContext)(null);
48
+
49
+ // src/provider/config-reducer.ts
50
+ function toReducerAction(msg) {
51
+ switch (msg.type) {
52
+ case "editor:init":
53
+ case "editor:full-replace":
54
+ return { type: "FULL_REPLACE", config: msg.payload.config };
55
+ case "editor:update":
56
+ return { type: "UPDATE_PATH", path: msg.payload.path, value: msg.payload.value };
57
+ case "editor:hero-update":
58
+ return { type: "HERO_UPDATE", data: msg.payload };
59
+ case "editor:hero-slide-add":
60
+ return { type: "HERO_SLIDE_ADD", slide: msg.payload.slide, position: msg.payload.position };
61
+ case "editor:hero-slide-remove":
62
+ return { type: "HERO_SLIDE_REMOVE", slideId: msg.payload.slideId };
63
+ case "editor:hero-slides-reorder":
64
+ return { type: "HERO_SLIDES_REORDER", slideIds: msg.payload.slideIds };
65
+ case "editor:hero-slide-update":
66
+ return { type: "HERO_SLIDE_UPDATE", slideId: msg.payload.slideId, data: msg.payload.data };
67
+ case "editor:sections-reorder":
68
+ return { type: "SECTIONS_REORDER", sectionIds: msg.payload.sectionIds };
69
+ case "editor:section-add":
70
+ return { type: "SECTION_ADD", section: msg.payload.section, position: msg.payload.position };
71
+ case "editor:section-remove":
72
+ return { type: "SECTION_REMOVE", sectionId: msg.payload.sectionId };
73
+ case "editor:section-toggle":
74
+ return { type: "SECTION_TOGGLE", sectionId: msg.payload.sectionId, enabled: msg.payload.enabled };
75
+ case "editor:section-update":
76
+ return { type: "SECTION_UPDATE", sectionId: msg.payload.sectionId, data: msg.payload.data };
77
+ case "editor:navbar-update":
78
+ return { type: "NAVBAR_UPDATE", data: msg.payload };
79
+ case "editor:navbar-ribbon-update":
80
+ return { type: "NAVBAR_RIBBON_UPDATE", data: msg.payload };
81
+ case "editor:navbar-ribbon-message-add":
82
+ return { type: "NAVBAR_RIBBON_MSG_ADD", message: msg.payload.message, position: msg.payload.position };
83
+ case "editor:navbar-ribbon-message-remove":
84
+ return { type: "NAVBAR_RIBBON_MSG_REMOVE", index: msg.payload.index };
85
+ case "editor:navbar-ribbon-messages-reorder":
86
+ return { type: "NAVBAR_RIBBON_MSGS_REORDER", messages: msg.payload.messages };
87
+ case "editor:navbar-element-update":
88
+ return { type: "NAVBAR_ELEMENT_UPDATE", key: msg.payload.key, data: msg.payload.data };
89
+ case "editor:navbar-element-add":
90
+ return { type: "NAVBAR_ELEMENT_ADD", element: msg.payload.element, position: msg.payload.position };
91
+ case "editor:navbar-element-remove":
92
+ return { type: "NAVBAR_ELEMENT_REMOVE", key: msg.payload.key };
93
+ case "editor:navbar-elements-reorder":
94
+ return { type: "NAVBAR_ELEMENTS_REORDER", elements: msg.payload.elements };
95
+ case "editor:footer-update":
96
+ return { type: "FOOTER_UPDATE", data: msg.payload };
97
+ case "editor:color-scheme-update":
98
+ return { type: "COLOR_SCHEME_UPDATE", data: msg.payload };
99
+ case "editor:font-styles-update":
100
+ return { type: "FONT_STYLES_UPDATE", data: msg.payload };
101
+ case "editor:social-links-update":
102
+ return { type: "SOCIAL_LINKS_UPDATE", data: msg.payload };
103
+ case "editor:branding-update":
104
+ return { type: "BRANDING_UPDATE", data: msg.payload };
105
+ case "editor:advanced-update":
106
+ return { type: "ADVANCED_UPDATE", data: msg.payload };
107
+ default:
108
+ return null;
109
+ }
110
+ }
111
+ function configReducer(state, action) {
112
+ switch (action.type) {
113
+ case "FULL_REPLACE":
114
+ return action.config;
115
+ case "UPDATE_PATH":
116
+ return setByPath(state, action.path, action.value);
117
+ // ── Hero ──
118
+ case "HERO_UPDATE":
119
+ return { ...state, hero: { ...state.hero, ...action.data } };
120
+ case "HERO_SLIDE_ADD": {
121
+ const slides = [...state.hero.sliderSettings];
122
+ slides.splice(action.position, 0, action.slide);
123
+ return { ...state, hero: { ...state.hero, sliderSettings: slides } };
124
+ }
125
+ case "HERO_SLIDE_REMOVE":
126
+ return {
127
+ ...state,
128
+ hero: {
129
+ ...state.hero,
130
+ sliderSettings: state.hero.sliderSettings.filter((s) => s.id !== action.slideId)
131
+ }
132
+ };
133
+ case "HERO_SLIDES_REORDER": {
134
+ const reordered = action.slideIds.map((id) => state.hero.sliderSettings.find((s) => s.id === id)).filter(Boolean);
135
+ return { ...state, hero: { ...state.hero, sliderSettings: reordered } };
136
+ }
137
+ case "HERO_SLIDE_UPDATE":
138
+ return {
139
+ ...state,
140
+ hero: {
141
+ ...state.hero,
142
+ sliderSettings: state.hero.sliderSettings.map(
143
+ (s) => s.id === action.slideId ? { ...s, ...action.data } : s
144
+ )
145
+ }
146
+ };
147
+ // ── Sections ──
148
+ case "SECTIONS_REORDER": {
149
+ const reordered = action.sectionIds.map((id) => state.sections.find((s) => s.id === id)).filter(Boolean);
150
+ return { ...state, sections: reordered };
151
+ }
152
+ case "SECTION_ADD": {
153
+ const sections = [...state.sections];
154
+ sections.splice(action.position, 0, action.section);
155
+ return { ...state, sections };
156
+ }
157
+ case "SECTION_REMOVE":
158
+ return { ...state, sections: state.sections.filter((s) => s.id !== action.sectionId) };
159
+ case "SECTION_TOGGLE":
160
+ return {
161
+ ...state,
162
+ sections: state.sections.map(
163
+ (s) => s.id === action.sectionId ? { ...s, enabled: action.enabled } : s
164
+ )
165
+ };
166
+ case "SECTION_UPDATE":
167
+ return {
168
+ ...state,
169
+ sections: state.sections.map(
170
+ (s) => s.id === action.sectionId ? { ...s, ...action.data } : s
171
+ )
172
+ };
173
+ // ── Navbar ──
174
+ case "NAVBAR_UPDATE": {
175
+ const { ribbonbar, navElements, ...rest } = action.data;
176
+ let navbar = { ...state.navbar, ...rest };
177
+ if (ribbonbar) navbar = { ...navbar, ribbonbar: { ...navbar.ribbonbar, ...ribbonbar } };
178
+ if (navElements) navbar = { ...navbar, navElements };
179
+ return { ...state, navbar };
180
+ }
181
+ case "NAVBAR_RIBBON_UPDATE":
182
+ return {
183
+ ...state,
184
+ navbar: {
185
+ ...state.navbar,
186
+ ribbonbar: { ...state.navbar.ribbonbar, ...action.data }
187
+ }
188
+ };
189
+ case "NAVBAR_RIBBON_MSG_ADD": {
190
+ const messages = [...state.navbar.ribbonbar.messages];
191
+ messages.splice(action.position, 0, action.message);
192
+ return {
193
+ ...state,
194
+ navbar: {
195
+ ...state.navbar,
196
+ ribbonbar: { ...state.navbar.ribbonbar, messages }
197
+ }
198
+ };
199
+ }
200
+ case "NAVBAR_RIBBON_MSG_REMOVE": {
201
+ const messages = state.navbar.ribbonbar.messages.filter((_, i) => i !== action.index);
202
+ return {
203
+ ...state,
204
+ navbar: {
205
+ ...state.navbar,
206
+ ribbonbar: { ...state.navbar.ribbonbar, messages }
207
+ }
208
+ };
209
+ }
210
+ case "NAVBAR_RIBBON_MSGS_REORDER":
211
+ return {
212
+ ...state,
213
+ navbar: {
214
+ ...state.navbar,
215
+ ribbonbar: { ...state.navbar.ribbonbar, messages: action.messages }
216
+ }
217
+ };
218
+ case "NAVBAR_ELEMENT_UPDATE":
219
+ return {
220
+ ...state,
221
+ navbar: {
222
+ ...state.navbar,
223
+ navElements: state.navbar.navElements.map(
224
+ (el) => el.key === action.key ? { ...el, ...action.data } : el
225
+ )
226
+ }
227
+ };
228
+ case "NAVBAR_ELEMENT_ADD": {
229
+ const navElements = [...state.navbar.navElements];
230
+ navElements.splice(action.position, 0, action.element);
231
+ return { ...state, navbar: { ...state.navbar, navElements } };
232
+ }
233
+ case "NAVBAR_ELEMENT_REMOVE":
234
+ return {
235
+ ...state,
236
+ navbar: {
237
+ ...state.navbar,
238
+ navElements: state.navbar.navElements.filter((el) => el.key !== action.key)
239
+ }
240
+ };
241
+ case "NAVBAR_ELEMENTS_REORDER":
242
+ return { ...state, navbar: { ...state.navbar, navElements: action.elements } };
243
+ // ── Top-level ──
244
+ case "FOOTER_UPDATE":
245
+ return { ...state, footer: { ...state.footer, ...action.data } };
246
+ case "COLOR_SCHEME_UPDATE":
247
+ return { ...state, color_scheme: { ...state.color_scheme, ...action.data } };
248
+ case "FONT_STYLES_UPDATE": {
249
+ const font_styles = { ...state.font_styles };
250
+ if (action.data.body) font_styles.body = { ...font_styles.body, ...action.data.body };
251
+ if (action.data.heading) font_styles.heading = { ...font_styles.heading, ...action.data.heading };
252
+ return { ...state, font_styles };
253
+ }
254
+ case "SOCIAL_LINKS_UPDATE":
255
+ return { ...state, social_links: { ...state.social_links, ...action.data } };
256
+ case "BRANDING_UPDATE":
257
+ return { ...state, ...action.data };
258
+ case "ADVANCED_UPDATE":
259
+ return { ...state, ...action.data };
260
+ default:
261
+ return state;
262
+ }
263
+ }
264
+ function setByPath(obj, path, value) {
265
+ const keys = path.split(".");
266
+ if (keys.length === 1) return { ...obj, [keys[0]]: value };
267
+ const [head, ...tail] = keys;
268
+ return { ...obj, [head]: setByPath(obj[head] ?? {}, tail.join("."), value) };
269
+ }
270
+
271
+ // src/css/css-var-sync.ts
272
+ var CSS_VAR_MAP = {
273
+ primary: "--primary",
274
+ secondary: "--secondary",
275
+ btnText: "--btn-text",
276
+ textPrimary: "--text-primary",
277
+ textSecondary: "--text-secondary",
278
+ bodyBackground: "--bg-primary",
279
+ bodyBackground1: "--bg-primary-smoke",
280
+ bodyBackgroundSecondary: "--bg-secondary-color",
281
+ bodyBackgroundDark: "--bg-dark",
282
+ borderBackground: "--bg-border",
283
+ headerbg: "--header-bg",
284
+ textColor: "--text-color",
285
+ footerBgColor: "--footer-bg",
286
+ footerTextColor: "--footer-text"
287
+ };
288
+ function syncCSSVars(colorScheme, fontStyles, overrides) {
289
+ const root = document.documentElement;
290
+ const varMap = overrides ? { ...CSS_VAR_MAP, ...overrides } : CSS_VAR_MAP;
291
+ for (const [configKey, cssVar] of Object.entries(varMap)) {
292
+ const value = colorScheme[configKey];
293
+ if (value !== void 0 && value !== null && value !== "") {
294
+ root.style.setProperty(cssVar, value);
295
+ }
296
+ }
297
+ if (fontStyles?.heading) {
298
+ root.style.setProperty("--heading-font", `'${fontStyles.heading.font_family}'`);
299
+ root.style.setProperty("--heading-weight", String(fontStyles.heading.font_weight));
300
+ loadGoogleFont(fontStyles.heading.font_url);
301
+ }
302
+ if (fontStyles?.body) {
303
+ root.style.setProperty("--body-font", `'${fontStyles.body.font_family}'`);
304
+ root.style.setProperty("--body-weight", String(fontStyles.body.font_weight));
305
+ loadGoogleFont(fontStyles.body.font_url);
306
+ }
307
+ }
308
+ function loadGoogleFont(url) {
309
+ if (!url) return;
310
+ if (document.querySelector(`link[href="${url}"]`)) return;
311
+ const link = document.createElement("link");
312
+ link.rel = "stylesheet";
313
+ link.href = url;
314
+ document.head.appendChild(link);
315
+ }
316
+
317
+ // src/provider/EditorProvider.tsx
318
+ var import_jsx_runtime = require("react/jsx-runtime");
319
+ function EditorProvider({
320
+ initialConfig,
321
+ editorOrigin = "*",
322
+ cssVarOverrides,
323
+ children
324
+ }) {
325
+ const [isEditorMode, setIsEditorMode] = (0, import_react2.useState)(false);
326
+ const [config, dispatch] = (0, import_react2.useReducer)(configReducer, initialConfig);
327
+ const positionTimerRef = (0, import_react2.useRef)(null);
328
+ const prevColorRef = (0, import_react2.useRef)(initialConfig.color_scheme);
329
+ const prevFontRef = (0, import_react2.useRef)(initialConfig.font_styles);
330
+ (0, import_react2.useEffect)(() => {
331
+ if (typeof window === "undefined") return;
332
+ const params = new URLSearchParams(window.location.search);
333
+ const inIframe = window.self !== window.top;
334
+ if (inIframe && params.get("editor") === "true") {
335
+ setIsEditorMode(true);
336
+ document.body.classList.add("editor-mode-active");
337
+ }
338
+ return () => {
339
+ document.body.classList.remove("editor-mode-active");
340
+ };
341
+ }, []);
342
+ (0, import_react2.useEffect)(() => {
343
+ if (!isEditorMode) return;
344
+ const handler = (event) => {
345
+ if (editorOrigin !== "*" && event.origin !== editorOrigin) return;
346
+ const msg = event.data;
347
+ if (!msg?.type?.startsWith("editor:")) return;
348
+ if (msg.type === "editor:navigate") {
349
+ const url = new URL(msg.payload.url, window.location.origin);
350
+ url.searchParams.set("editor", "true");
351
+ window.location.href = url.toString();
352
+ return;
353
+ }
354
+ if (msg.type === "editor:highlight-section") {
355
+ document.querySelectorAll("[data-section-id]").forEach((el) => {
356
+ el.classList.toggle(
357
+ "editor-section-highlight",
358
+ el.getAttribute("data-section-id") === msg.payload.sectionId
359
+ );
360
+ });
361
+ return;
362
+ }
363
+ const action = toReducerAction(msg);
364
+ if (action) dispatch(action);
365
+ };
366
+ window.addEventListener("message", handler);
367
+ return () => window.removeEventListener("message", handler);
368
+ }, [isEditorMode, editorOrigin]);
369
+ (0, import_react2.useEffect)(() => {
370
+ if (!isEditorMode) return;
371
+ const timer = setTimeout(() => {
372
+ sendToEditor({
373
+ type: "store:ready",
374
+ payload: { sections: getSectionPositions() }
375
+ });
376
+ }, 600);
377
+ return () => clearTimeout(timer);
378
+ }, [isEditorMode]);
379
+ (0, import_react2.useEffect)(() => {
380
+ if (!isEditorMode) return;
381
+ if (config.color_scheme !== prevColorRef.current || config.font_styles !== prevFontRef.current) {
382
+ syncCSSVars(config.color_scheme, config.font_styles, cssVarOverrides);
383
+ prevColorRef.current = config.color_scheme;
384
+ prevFontRef.current = config.font_styles;
385
+ }
386
+ }, [isEditorMode, config.color_scheme, config.font_styles, cssVarOverrides]);
387
+ (0, import_react2.useEffect)(() => {
388
+ if (!isEditorMode) return;
389
+ if (positionTimerRef.current) clearTimeout(positionTimerRef.current);
390
+ positionTimerRef.current = setTimeout(() => {
391
+ sendToEditor({
392
+ type: "store:sections-updated",
393
+ payload: { sections: getSectionPositions() }
394
+ });
395
+ }, 300);
396
+ }, [config.sections, config.hero, isEditorMode]);
397
+ const value = (0, import_react2.useMemo)(
398
+ () => ({ isEditorMode, config }),
399
+ [isEditorMode, config]
400
+ );
401
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EditorContext.Provider, { value, children: [
402
+ isEditorMode && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditorStylesInline, {}),
403
+ children
404
+ ] });
405
+ }
406
+ function sendToEditor(message) {
407
+ if (typeof window === "undefined" || window.self === window.top) return;
408
+ window.parent.postMessage(message, "*");
409
+ }
410
+ function getSectionPositions() {
411
+ return Array.from(document.querySelectorAll("[data-section-id]")).map((el) => ({
412
+ id: el.getAttribute("data-section-id"),
413
+ type: el.getAttribute("data-section-type") || "",
414
+ rect: el.getBoundingClientRect()
415
+ }));
416
+ }
417
+ function EditorStylesInline() {
418
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: `
419
+ [data-section-id] {
420
+ position: relative;
421
+ transition: outline 0.15s ease;
422
+ }
423
+ [data-section-id]:hover {
424
+ outline: 2px solid rgba(59, 130, 246, 0.5);
425
+ outline-offset: -2px;
426
+ cursor: pointer;
427
+ }
428
+ .editor-section-highlight {
429
+ outline: 2px solid #3b82f6 !important;
430
+ outline-offset: -2px;
431
+ }
432
+ .editor-section-disabled {
433
+ opacity: 0.35;
434
+ }
435
+ .editor-mode-active a,
436
+ .editor-mode-active button:not([data-editor-control]),
437
+ .editor-mode-active input,
438
+ .editor-mode-active select,
439
+ .editor-mode-active form,
440
+ .editor-mode-active textarea {
441
+ pointer-events: none !important;
442
+ }
443
+ [data-section-id] > .editor-click-overlay {
444
+ pointer-events: auto !important;
445
+ }
446
+ ` });
447
+ }
448
+
449
+ // src/hooks/useEditorMode.ts
450
+ var import_react3 = require("react");
451
+ function useEditorMode() {
452
+ const ctx = (0, import_react3.useContext)(EditorContext);
453
+ return { isEditorMode: ctx?.isEditorMode ?? false };
454
+ }
455
+
456
+ // src/hooks/useLandingConfig.ts
457
+ var import_react4 = require("react");
458
+ function useLandingConfig() {
459
+ return (0, import_react4.useContext)(EditorContext)?.config ?? null;
460
+ }
461
+
462
+ // src/hooks/useHeroConfig.ts
463
+ var import_react5 = require("react");
464
+ function useHeroConfig() {
465
+ return (0, import_react5.useContext)(EditorContext)?.config?.hero ?? null;
466
+ }
467
+
468
+ // src/hooks/useSections.ts
469
+ var import_react6 = require("react");
470
+ function useSections() {
471
+ const ctx = (0, import_react6.useContext)(EditorContext);
472
+ return (0, import_react6.useMemo)(() => ctx?.config?.sections ?? [], [ctx?.config?.sections]);
473
+ }
474
+
475
+ // src/hooks/useSectionById.ts
476
+ var import_react7 = require("react");
477
+ function useSectionById(sectionId) {
478
+ const ctx = (0, import_react7.useContext)(EditorContext);
479
+ return (0, import_react7.useMemo)(
480
+ () => ctx?.config?.sections.find((s) => s.id === sectionId),
481
+ [ctx?.config?.sections, sectionId]
482
+ );
483
+ }
484
+
485
+ // src/hooks/useNavbarConfig.ts
486
+ var import_react8 = require("react");
487
+ function useNavbarConfig() {
488
+ return (0, import_react8.useContext)(EditorContext)?.config?.navbar ?? null;
489
+ }
490
+
491
+ // src/hooks/useFooterConfig.ts
492
+ var import_react9 = require("react");
493
+ function useFooterConfig() {
494
+ return (0, import_react9.useContext)(EditorContext)?.config?.footer ?? null;
495
+ }
496
+
497
+ // src/hooks/useColorScheme.ts
498
+ var import_react10 = require("react");
499
+ function useColorScheme() {
500
+ return (0, import_react10.useContext)(EditorContext)?.config?.color_scheme ?? null;
501
+ }
502
+
503
+ // src/hooks/useFontStyles.ts
504
+ var import_react11 = require("react");
505
+ function useFontStyles() {
506
+ return (0, import_react11.useContext)(EditorContext)?.config?.font_styles ?? null;
507
+ }
508
+
509
+ // src/hooks/useBranding.ts
510
+ var import_react12 = require("react");
511
+ function useBranding() {
512
+ const ctx = (0, import_react12.useContext)(EditorContext);
513
+ return (0, import_react12.useMemo)(() => {
514
+ if (!ctx?.config) return null;
515
+ const c = ctx.config;
516
+ return {
517
+ logo: c.logo,
518
+ secondary_logo: c.secondary_logo,
519
+ favicon: c.favicon,
520
+ store_name: c.store_name,
521
+ store_description: c.store_description
522
+ };
523
+ }, [
524
+ ctx?.config?.logo,
525
+ ctx?.config?.secondary_logo,
526
+ ctx?.config?.favicon,
527
+ ctx?.config?.store_name,
528
+ ctx?.config?.store_description
529
+ ]);
530
+ }
531
+
532
+ // src/hooks/useSocialLinks.ts
533
+ var import_react13 = require("react");
534
+ function useSocialLinks() {
535
+ return (0, import_react13.useContext)(EditorContext)?.config?.social_links ?? null;
536
+ }
537
+
538
+ // src/components/SectionWrapper.tsx
539
+ var import_jsx_runtime2 = require("react/jsx-runtime");
540
+ function SectionWrapper({
541
+ sectionId,
542
+ sectionType,
543
+ enabled = true,
544
+ className = "",
545
+ children
546
+ }) {
547
+ const { isEditorMode } = useEditorMode();
548
+ if (!enabled && !isEditorMode) return null;
549
+ const handleClick = isEditorMode ? (e) => {
550
+ e.preventDefault();
551
+ e.stopPropagation();
552
+ window.parent.postMessage(
553
+ { type: "store:section-clicked", payload: { sectionId } },
554
+ "*"
555
+ );
556
+ } : void 0;
557
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
558
+ "div",
559
+ {
560
+ "data-section-id": sectionId,
561
+ "data-section-type": sectionType,
562
+ className: `${!enabled && isEditorMode ? "editor-section-disabled" : ""} ${className}`.trim(),
563
+ onClick: handleClick,
564
+ children
565
+ }
566
+ );
567
+ }
568
+ // Annotate the CommonJS export names for ESM import in node:
569
+ 0 && (module.exports = {
570
+ CSS_VAR_MAP,
571
+ EditorContext,
572
+ EditorProvider,
573
+ SectionWrapper,
574
+ syncCSSVars,
575
+ useBranding,
576
+ useColorScheme,
577
+ useEditorMode,
578
+ useFontStyles,
579
+ useFooterConfig,
580
+ useHeroConfig,
581
+ useLandingConfig,
582
+ useNavbarConfig,
583
+ useSectionById,
584
+ useSections,
585
+ useSocialLinks
586
+ });
587
+ //# sourceMappingURL=index.js.map