@charisol/plexo-sdk 1.4.40 → 1.4.41
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/toReact-BBzjWoFG.js +595 -0
- package/dist/v2/canvas/layoutRoles.d.ts +12 -0
- package/dist/v2/canvas/useDraggableNode.d.ts +2 -12
- package/dist/v2/compile/index.d.ts +15 -0
- package/dist/v2/store/brandDefaults.d.ts +4 -0
- package/dist/v2-compile.js +9 -0
- package/dist/v2.js +1854 -2439
- package/package.json +6 -1
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
//#region src/v2/store/seed.ts
|
|
2
|
+
function e() {
|
|
3
|
+
return {
|
|
4
|
+
nodes: {
|
|
5
|
+
sec1: {
|
|
6
|
+
id: "sec1",
|
|
7
|
+
type: "Section",
|
|
8
|
+
parentId: null,
|
|
9
|
+
children: [
|
|
10
|
+
"sec1-heading",
|
|
11
|
+
"sec1-body",
|
|
12
|
+
"sec1-btn"
|
|
13
|
+
],
|
|
14
|
+
props: { name: "Hero" },
|
|
15
|
+
styles: {
|
|
16
|
+
backgroundColor: "#0f172a",
|
|
17
|
+
height: 420
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"sec1-heading": {
|
|
21
|
+
id: "sec1-heading",
|
|
22
|
+
type: "Text",
|
|
23
|
+
parentId: "sec1",
|
|
24
|
+
children: [],
|
|
25
|
+
props: { content: "Light That Listens" },
|
|
26
|
+
styles: {
|
|
27
|
+
x: 48,
|
|
28
|
+
y: 48,
|
|
29
|
+
width: 480,
|
|
30
|
+
height: 110,
|
|
31
|
+
fontSize: 48,
|
|
32
|
+
color: "#e2f65a",
|
|
33
|
+
fontWeight: "bold"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"sec1-body": {
|
|
37
|
+
id: "sec1-body",
|
|
38
|
+
type: "Text",
|
|
39
|
+
parentId: "sec1",
|
|
40
|
+
children: [],
|
|
41
|
+
props: { content: "A smart ambient mood orchestrator that adapts to your life." },
|
|
42
|
+
styles: {
|
|
43
|
+
x: 48,
|
|
44
|
+
y: 168,
|
|
45
|
+
width: 440,
|
|
46
|
+
height: 60,
|
|
47
|
+
fontSize: 18,
|
|
48
|
+
color: "#e2e8f0"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"sec1-btn": {
|
|
52
|
+
id: "sec1-btn",
|
|
53
|
+
type: "Button",
|
|
54
|
+
parentId: "sec1",
|
|
55
|
+
children: [],
|
|
56
|
+
props: {
|
|
57
|
+
label: "Pre-order now",
|
|
58
|
+
href: "#"
|
|
59
|
+
},
|
|
60
|
+
styles: {
|
|
61
|
+
x: 48,
|
|
62
|
+
y: 248,
|
|
63
|
+
width: 180,
|
|
64
|
+
height: 44,
|
|
65
|
+
backgroundColor: "#e2f65a",
|
|
66
|
+
color: "#0f172a",
|
|
67
|
+
borderRadius: 999
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
sec2: {
|
|
71
|
+
id: "sec2",
|
|
72
|
+
type: "Section",
|
|
73
|
+
parentId: null,
|
|
74
|
+
children: ["sec2-container", "sec2-btn"],
|
|
75
|
+
props: { name: "Feature" },
|
|
76
|
+
styles: {
|
|
77
|
+
backgroundColor: "#4b5320",
|
|
78
|
+
height: 420
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"sec2-container": {
|
|
82
|
+
id: "sec2-container",
|
|
83
|
+
type: "Container",
|
|
84
|
+
parentId: "sec2",
|
|
85
|
+
children: ["sec2-cell-image", "sec2-cell-text"],
|
|
86
|
+
props: {},
|
|
87
|
+
styles: {
|
|
88
|
+
y: 48,
|
|
89
|
+
height: 300,
|
|
90
|
+
gap: 32,
|
|
91
|
+
containerRole: "row"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"sec2-cell-image": {
|
|
95
|
+
id: "sec2-cell-image",
|
|
96
|
+
type: "Container",
|
|
97
|
+
parentId: "sec2-container",
|
|
98
|
+
children: ["sec2-image"],
|
|
99
|
+
props: {},
|
|
100
|
+
styles: { containerRole: "cell" }
|
|
101
|
+
},
|
|
102
|
+
"sec2-image": {
|
|
103
|
+
id: "sec2-image",
|
|
104
|
+
type: "Image",
|
|
105
|
+
parentId: "sec2-cell-image",
|
|
106
|
+
children: [],
|
|
107
|
+
props: {
|
|
108
|
+
src: "https://placehold.co/360x240",
|
|
109
|
+
alt: "Darle Lumina lighting fixture"
|
|
110
|
+
},
|
|
111
|
+
styles: { borderRadius: 12 }
|
|
112
|
+
},
|
|
113
|
+
"sec2-cell-text": {
|
|
114
|
+
id: "sec2-cell-text",
|
|
115
|
+
type: "Container",
|
|
116
|
+
parentId: "sec2-container",
|
|
117
|
+
children: ["sec2-text"],
|
|
118
|
+
props: {},
|
|
119
|
+
styles: { containerRole: "cell" }
|
|
120
|
+
},
|
|
121
|
+
"sec2-text": {
|
|
122
|
+
id: "sec2-text",
|
|
123
|
+
type: "Text",
|
|
124
|
+
parentId: "sec2-cell-text",
|
|
125
|
+
children: [],
|
|
126
|
+
props: { content: "Is your lighting in tune with you?" },
|
|
127
|
+
styles: {
|
|
128
|
+
fontSize: 24,
|
|
129
|
+
color: "#f7f7d5"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"sec2-btn": {
|
|
133
|
+
id: "sec2-btn",
|
|
134
|
+
type: "Button",
|
|
135
|
+
parentId: "sec2",
|
|
136
|
+
children: [],
|
|
137
|
+
props: {
|
|
138
|
+
label: "Learn more",
|
|
139
|
+
href: "#"
|
|
140
|
+
},
|
|
141
|
+
styles: {
|
|
142
|
+
x: 48,
|
|
143
|
+
y: 352,
|
|
144
|
+
width: 160,
|
|
145
|
+
height: 44,
|
|
146
|
+
backgroundColor: "#f7f7d5",
|
|
147
|
+
color: "#4b5320",
|
|
148
|
+
borderRadius: 999
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
pageOrder: ["sec1", "sec2"]
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/v2/canvas/modelRect.ts
|
|
157
|
+
function t(e) {
|
|
158
|
+
let { x: t, y: n, width: r, height: i } = e.styles;
|
|
159
|
+
return {
|
|
160
|
+
x: typeof t == "number" ? t : 0,
|
|
161
|
+
y: typeof n == "number" ? n : 0,
|
|
162
|
+
width: typeof r == "number" ? r : 0,
|
|
163
|
+
height: typeof i == "number" ? i : 0
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/v2/store/brandDefaults.ts
|
|
168
|
+
var n = [{
|
|
169
|
+
id: "pill",
|
|
170
|
+
label: "Pill",
|
|
171
|
+
slots: [
|
|
172
|
+
{
|
|
173
|
+
id: "primary",
|
|
174
|
+
label: "Primary",
|
|
175
|
+
styles: {
|
|
176
|
+
backgroundColor: "#e2f65a",
|
|
177
|
+
color: "#0f172a",
|
|
178
|
+
borderRadius: 999
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: "secondary",
|
|
183
|
+
label: "Secondary",
|
|
184
|
+
styles: {
|
|
185
|
+
backgroundColor: "#ffffff",
|
|
186
|
+
color: "#0f172a",
|
|
187
|
+
borderRadius: 999
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: "tertiary",
|
|
192
|
+
label: "Tertiary",
|
|
193
|
+
styles: {
|
|
194
|
+
backgroundColor: "transparent",
|
|
195
|
+
color: "#0f172a",
|
|
196
|
+
borderRadius: 999
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
}, {
|
|
201
|
+
id: "sharp",
|
|
202
|
+
label: "Sharp",
|
|
203
|
+
slots: [
|
|
204
|
+
{
|
|
205
|
+
id: "primary",
|
|
206
|
+
label: "Primary",
|
|
207
|
+
styles: {
|
|
208
|
+
backgroundColor: "#e2f65a",
|
|
209
|
+
color: "#0f172a",
|
|
210
|
+
borderRadius: 2
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
id: "secondary",
|
|
215
|
+
label: "Secondary",
|
|
216
|
+
styles: {
|
|
217
|
+
backgroundColor: "#ffffff",
|
|
218
|
+
color: "#0f172a",
|
|
219
|
+
borderRadius: 2
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: "tertiary",
|
|
224
|
+
label: "Tertiary",
|
|
225
|
+
styles: {
|
|
226
|
+
backgroundColor: "transparent",
|
|
227
|
+
color: "#0f172a",
|
|
228
|
+
borderRadius: 2
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
}], r = [{
|
|
233
|
+
id: "rounded",
|
|
234
|
+
label: "Rounded",
|
|
235
|
+
slots: [{
|
|
236
|
+
id: "box1",
|
|
237
|
+
label: "Box 1",
|
|
238
|
+
styles: {
|
|
239
|
+
backgroundColor: "#4b5320",
|
|
240
|
+
borderRadius: 16
|
|
241
|
+
}
|
|
242
|
+
}, {
|
|
243
|
+
id: "box2",
|
|
244
|
+
label: "Box 2",
|
|
245
|
+
styles: {
|
|
246
|
+
backgroundColor: "#0f172a",
|
|
247
|
+
borderRadius: 8
|
|
248
|
+
}
|
|
249
|
+
}]
|
|
250
|
+
}, {
|
|
251
|
+
id: "sharp-box",
|
|
252
|
+
label: "Sharp",
|
|
253
|
+
slots: [{
|
|
254
|
+
id: "box1",
|
|
255
|
+
label: "Box 1",
|
|
256
|
+
styles: {
|
|
257
|
+
backgroundColor: "#4b5320",
|
|
258
|
+
borderRadius: 0
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
id: "box2",
|
|
262
|
+
label: "Box 2",
|
|
263
|
+
styles: {
|
|
264
|
+
backgroundColor: "#0f172a",
|
|
265
|
+
borderRadius: 2
|
|
266
|
+
}
|
|
267
|
+
}]
|
|
268
|
+
}], i = [{
|
|
269
|
+
id: "default",
|
|
270
|
+
label: "Default",
|
|
271
|
+
slots: [
|
|
272
|
+
{
|
|
273
|
+
id: "heading1",
|
|
274
|
+
label: "Heading 1",
|
|
275
|
+
styles: {
|
|
276
|
+
fontSize: 48,
|
|
277
|
+
fontWeight: "bold",
|
|
278
|
+
lineHeight: 1.1
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
id: "heading2",
|
|
283
|
+
label: "Heading 2",
|
|
284
|
+
styles: {
|
|
285
|
+
fontSize: 36,
|
|
286
|
+
fontWeight: "bold",
|
|
287
|
+
lineHeight: 1.15
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
id: "heading3",
|
|
292
|
+
label: "Heading 3",
|
|
293
|
+
styles: {
|
|
294
|
+
fontSize: 28,
|
|
295
|
+
fontWeight: "bold",
|
|
296
|
+
lineHeight: 1.2
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
id: "heading4",
|
|
301
|
+
label: "Heading 4",
|
|
302
|
+
styles: {
|
|
303
|
+
fontSize: 22,
|
|
304
|
+
fontWeight: "bold",
|
|
305
|
+
lineHeight: 1.25
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
id: "heading5",
|
|
310
|
+
label: "Heading 5",
|
|
311
|
+
styles: {
|
|
312
|
+
fontSize: 18,
|
|
313
|
+
fontWeight: "bold",
|
|
314
|
+
lineHeight: 1.3
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
id: "heading6",
|
|
319
|
+
label: "Heading 6",
|
|
320
|
+
styles: {
|
|
321
|
+
fontSize: 16,
|
|
322
|
+
fontWeight: "bold",
|
|
323
|
+
lineHeight: 1.3
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
id: "paragraph1",
|
|
328
|
+
label: "Paragraph 1",
|
|
329
|
+
styles: {
|
|
330
|
+
fontSize: 18,
|
|
331
|
+
fontWeight: "normal",
|
|
332
|
+
lineHeight: 1.5
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
id: "paragraph2",
|
|
337
|
+
label: "Paragraph 2",
|
|
338
|
+
styles: {
|
|
339
|
+
fontSize: 16,
|
|
340
|
+
fontWeight: "normal",
|
|
341
|
+
lineHeight: 1.5
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
id: "paragraph3",
|
|
346
|
+
label: "Paragraph 3",
|
|
347
|
+
styles: {
|
|
348
|
+
fontSize: 14,
|
|
349
|
+
fontWeight: "normal",
|
|
350
|
+
lineHeight: 1.5
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
]
|
|
354
|
+
}];
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/v2/canvas/layoutRoles.ts
|
|
357
|
+
function a(e, t, n) {
|
|
358
|
+
return e === "Container" && t === "Section" && n?.containerRole === "row";
|
|
359
|
+
}
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region src/v2/canvas/resolveBoxStyle.ts
|
|
362
|
+
var o = {
|
|
363
|
+
none: "none",
|
|
364
|
+
sm: "0 1px 3px rgba(15,23,42,0.14)",
|
|
365
|
+
md: "0 6px 16px rgba(15,23,42,0.18)",
|
|
366
|
+
lg: "0 16px 40px rgba(15,23,42,0.24)"
|
|
367
|
+
}, s = [
|
|
368
|
+
"none",
|
|
369
|
+
"sm",
|
|
370
|
+
"md",
|
|
371
|
+
"lg"
|
|
372
|
+
], c = [
|
|
373
|
+
"solid",
|
|
374
|
+
"dashed",
|
|
375
|
+
"dotted"
|
|
376
|
+
];
|
|
377
|
+
function l(e) {
|
|
378
|
+
let t = { overflow: "hidden" }, n = typeof e.borderWidth == "number" ? e.borderWidth : 0, r = e.borderStyle || "solid";
|
|
379
|
+
n > 0 && (t.border = `${n}px ${r} ${e.borderColor || "#0f172a"}`), typeof e.borderRadius == "number" && (t.borderRadius = e.borderRadius);
|
|
380
|
+
let i = e.boxShadowPreset || "none";
|
|
381
|
+
return i !== "none" && o[i] && (t.boxShadow = o[i]), t;
|
|
382
|
+
}
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/v2/compile/toReact.ts
|
|
385
|
+
var u = 1400, d = 400, f = /^[A-Z][A-Za-z0-9_]*$/;
|
|
386
|
+
function p(e) {
|
|
387
|
+
return JSON.stringify(e);
|
|
388
|
+
}
|
|
389
|
+
function m(e) {
|
|
390
|
+
return `{${p(Object.fromEntries(Object.entries(e).filter(([, e]) => e != null && e !== "")))}}`;
|
|
391
|
+
}
|
|
392
|
+
function h(e, n) {
|
|
393
|
+
let r = t(e);
|
|
394
|
+
if (a(e.type, n?.type, e.styles)) return {
|
|
395
|
+
position: "absolute",
|
|
396
|
+
left: 0,
|
|
397
|
+
right: 0,
|
|
398
|
+
top: r.y,
|
|
399
|
+
height: r.height
|
|
400
|
+
};
|
|
401
|
+
if (n?.type === "Container") {
|
|
402
|
+
let t = typeof e.styles.width == "number", n = typeof e.styles.height == "number";
|
|
403
|
+
return {
|
|
404
|
+
position: "relative",
|
|
405
|
+
flex: t ? `0 0 ${r.width}px` : "1 1 0%",
|
|
406
|
+
width: t ? r.width : void 0,
|
|
407
|
+
height: n ? r.height : "100%"
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
position: "absolute",
|
|
412
|
+
left: r.x,
|
|
413
|
+
top: r.y,
|
|
414
|
+
width: r.width,
|
|
415
|
+
height: r.height
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function g(e, t = "#") {
|
|
419
|
+
if (!e) return t;
|
|
420
|
+
let n = e.trim();
|
|
421
|
+
return /^(https?:|mailto:|tel:|\/|#)/i.test(n) ? n : t;
|
|
422
|
+
}
|
|
423
|
+
function _(e, t, n, r) {
|
|
424
|
+
let i = e[t];
|
|
425
|
+
if (!i) return "";
|
|
426
|
+
let a = i.parentId ? e[i.parentId] : void 0, o = " ".repeat(r), s = l(i.styles), c = h(i, a), u = i.styles;
|
|
427
|
+
switch (i.type) {
|
|
428
|
+
case "Text": {
|
|
429
|
+
let e = [
|
|
430
|
+
"p",
|
|
431
|
+
"span",
|
|
432
|
+
"h1",
|
|
433
|
+
"h2",
|
|
434
|
+
"h3",
|
|
435
|
+
"h4",
|
|
436
|
+
"h5",
|
|
437
|
+
"h6"
|
|
438
|
+
].includes(String(u.htmlTag)) ? String(u.htmlTag) : "p", t = u.textStyleRef ? n.textStyles?.[String(u.textStyleRef)] : void 0;
|
|
439
|
+
return `${o}<${e} style=${m({
|
|
440
|
+
...c,
|
|
441
|
+
fontSize: t?.fontSize ?? u.fontSize,
|
|
442
|
+
fontWeight: t?.fontWeight ?? u.fontWeight,
|
|
443
|
+
lineHeight: t?.lineHeight,
|
|
444
|
+
color: u.color,
|
|
445
|
+
textAlign: u.textAlign,
|
|
446
|
+
margin: 0,
|
|
447
|
+
...s
|
|
448
|
+
})}>{${p(i.props.content)}}</${e}>`;
|
|
449
|
+
}
|
|
450
|
+
case "Image": {
|
|
451
|
+
let e = {
|
|
452
|
+
...c,
|
|
453
|
+
objectFit: u.objectFit || "cover",
|
|
454
|
+
display: "block",
|
|
455
|
+
...s
|
|
456
|
+
};
|
|
457
|
+
return `${o}<img src=${p(i.props.src)} alt=${p(i.props.alt ?? "")} loading="lazy" style=${m(e)} />`;
|
|
458
|
+
}
|
|
459
|
+
case "Button": {
|
|
460
|
+
let e = {
|
|
461
|
+
...c,
|
|
462
|
+
display: "inline-flex",
|
|
463
|
+
alignItems: "center",
|
|
464
|
+
justifyContent: u.textAlign === "left" ? "flex-start" : u.textAlign === "right" ? "flex-end" : "center",
|
|
465
|
+
backgroundColor: u.backgroundColor,
|
|
466
|
+
color: u.color,
|
|
467
|
+
fontWeight: u.fontWeight ?? 600,
|
|
468
|
+
textDecoration: "none",
|
|
469
|
+
border: "none",
|
|
470
|
+
cursor: "pointer",
|
|
471
|
+
...s
|
|
472
|
+
};
|
|
473
|
+
return i.props.href ? `${o}<a href=${p(g(i.props.href))} style=${m(e)}>{${p(i.props.label)}}</a>` : `${o}<button type="button" style=${m(e)}>{${p(i.props.label)}}</button>`;
|
|
474
|
+
}
|
|
475
|
+
case "Container": {
|
|
476
|
+
let t = {
|
|
477
|
+
...c,
|
|
478
|
+
display: "flex",
|
|
479
|
+
flexDirection: "row",
|
|
480
|
+
gap: typeof u.gap == "number" ? u.gap : void 0,
|
|
481
|
+
backgroundColor: u.backgroundColor,
|
|
482
|
+
...s
|
|
483
|
+
}, a = i.children.map((t) => _(e, t, n, r + 1)).filter(Boolean);
|
|
484
|
+
return a.length ? `${o}<div style=${m(t)}>\n${a.join("\n")}\n${o}</div>` : `${o}<div style=${m(t)} />`;
|
|
485
|
+
}
|
|
486
|
+
case "Input": {
|
|
487
|
+
let e = {
|
|
488
|
+
width: "100%",
|
|
489
|
+
padding: "10px 12px",
|
|
490
|
+
borderRadius: 8,
|
|
491
|
+
border: "1px solid #cbd5e1",
|
|
492
|
+
font: "inherit"
|
|
493
|
+
}, t = i.props.fieldType === "textarea" ? `<textarea name=${p(i.props.label)} placeholder=${p(i.props.placeholder ?? "")}${i.props.required ? " required" : ""} style=${m({
|
|
494
|
+
...e,
|
|
495
|
+
height: "100%",
|
|
496
|
+
resize: "none"
|
|
497
|
+
})} />` : `<input type=${p(i.props.fieldType)} name=${p(i.props.label)} placeholder=${p(i.props.placeholder ?? "")}${i.props.required ? " required" : ""} style=${m(e)} />`;
|
|
498
|
+
return `${o}<label style=${m({
|
|
499
|
+
...c,
|
|
500
|
+
display: "flex",
|
|
501
|
+
flexDirection: "column",
|
|
502
|
+
gap: 6,
|
|
503
|
+
fontSize: 14,
|
|
504
|
+
color: u.color
|
|
505
|
+
})}>\n${o} <span>{${p(i.props.label)}}</span>\n${o} ${t}\n${o}</label>`;
|
|
506
|
+
}
|
|
507
|
+
case "Embed": return i.props.kind === "video" ? `${o}<video src=${p(g(i.props.url, ""))}${i.props.coverImage ? ` poster=${p(i.props.coverImage)}` : ""} controls playsInline style=${m({
|
|
508
|
+
...c,
|
|
509
|
+
objectFit: "cover",
|
|
510
|
+
...s
|
|
511
|
+
})} />` : `${o}<iframe title="Embedded content" sandbox="allow-scripts allow-popups allow-forms" srcDoc=${p(i.props.html ?? "")} style=${m({
|
|
512
|
+
...c,
|
|
513
|
+
border: "none",
|
|
514
|
+
...s
|
|
515
|
+
})} />`;
|
|
516
|
+
case "Menu": {
|
|
517
|
+
let e = i.props.layout === "vertical", t = i.props.links.map((e) => `${o} <a href=${p(g(e.href))} style=${m({
|
|
518
|
+
color: u.color,
|
|
519
|
+
textDecoration: "none",
|
|
520
|
+
fontSize: u.fontSize,
|
|
521
|
+
fontWeight: u.fontWeight
|
|
522
|
+
})}>{${p(e.label)}}</a>`).join("\n");
|
|
523
|
+
return `${o}<nav style=${m({
|
|
524
|
+
...c,
|
|
525
|
+
display: "flex",
|
|
526
|
+
flexDirection: e ? "column" : "row",
|
|
527
|
+
alignItems: e ? "flex-start" : "center",
|
|
528
|
+
gap: typeof u.gap == "number" ? u.gap : 24,
|
|
529
|
+
...s
|
|
530
|
+
})}>\n${t}\n${o}</nav>`;
|
|
531
|
+
}
|
|
532
|
+
default: return "";
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function v(e, t, n) {
|
|
536
|
+
let r = t.styles, i = typeof r.height == "number" ? r.height : d, a = r.pinned === "true", o = {
|
|
537
|
+
position: a ? "sticky" : "relative",
|
|
538
|
+
top: a ? 0 : void 0,
|
|
539
|
+
zIndex: a ? 50 : void 0,
|
|
540
|
+
backgroundColor: r.backgroundColor,
|
|
541
|
+
backgroundImage: r.backgroundImage ? `url(${JSON.stringify(String(r.backgroundImage))})` : void 0,
|
|
542
|
+
backgroundSize: r.backgroundImage ? "cover" : void 0,
|
|
543
|
+
backgroundPosition: r.backgroundImage ? "center" : void 0,
|
|
544
|
+
...l(r)
|
|
545
|
+
}, s = t.children.map((t) => _(e, t, n, 4)).filter(Boolean).join("\n");
|
|
546
|
+
return `${t.props.name ? ` {/* ${t.props.name.replace(/\*\//g, "* /")} */}\n` : ""} <section data-section=${p(t.props.name ?? t.id)} style=${m(o)}>
|
|
547
|
+
<FitToWidth height={${i}}>
|
|
548
|
+
${s}
|
|
549
|
+
</FitToWidth>
|
|
550
|
+
</section>`;
|
|
551
|
+
}
|
|
552
|
+
function y(e, t, n) {
|
|
553
|
+
if (!f.test(n.componentName)) throw Error(`"${n.componentName}" isn't a valid component name — use PascalCase letters and numbers.`);
|
|
554
|
+
let r = t.map((t) => e[t]).filter((e) => !!e && e.type === "Section").map((t) => v(e, t, n)).join("\n");
|
|
555
|
+
return `// Generated by Plexo from a visual design. Edit it visually in the app editor's Design view
|
|
556
|
+
// (which regenerates this file), or turn it into regular code by editing here.
|
|
557
|
+
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
558
|
+
|
|
559
|
+
const DESIGN_WIDTH = ${u};
|
|
560
|
+
|
|
561
|
+
/** Lays a section out exactly as designed at ${u}px, scaled down to fit narrower screens. */
|
|
562
|
+
function FitToWidth({ height, children }: { height: number; children: ReactNode }) {
|
|
563
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
564
|
+
const [scale, setScale] = useState(1);
|
|
565
|
+
useEffect(() => {
|
|
566
|
+
const el = ref.current;
|
|
567
|
+
if (!el) return;
|
|
568
|
+
const observer = new ResizeObserver(([entry]) => setScale(Math.min(1, entry.contentRect.width / DESIGN_WIDTH)));
|
|
569
|
+
observer.observe(el);
|
|
570
|
+
return () => observer.disconnect();
|
|
571
|
+
}, []);
|
|
572
|
+
return (
|
|
573
|
+
<div ref={ref} style={{ width: "100%", height: height * scale, overflow: "hidden" }}>
|
|
574
|
+
<div style={{ position: "relative", width: DESIGN_WIDTH, maxWidth: "none", height, margin: "0 auto", transform: \`scale(\${scale})\`, transformOrigin: "top left" }}>
|
|
575
|
+
{children}
|
|
576
|
+
</div>
|
|
577
|
+
</div>
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export default function ${n.componentName}() {
|
|
582
|
+
return (
|
|
583
|
+
<div>
|
|
584
|
+
${r}
|
|
585
|
+
</div>
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
`;
|
|
589
|
+
}
|
|
590
|
+
function b(e) {
|
|
591
|
+
let t = e.replace(/[^A-Za-z0-9]+/g, " ").trim().split(" ").filter(Boolean).map((e) => e[0].toUpperCase() + e.slice(1)).join("");
|
|
592
|
+
return /^[A-Z]/.test(t) ? t : `Design${t}`;
|
|
593
|
+
}
|
|
594
|
+
//#endregion
|
|
595
|
+
export { s as a, r as c, t as d, e as f, c as i, n as l, y as n, l as o, b as r, a as s, u as t, i as u };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PlexoNode, PlexoNodeType } from '../store/types';
|
|
2
|
+
/** A Container is only a full-bleed "row" (spanning its section edge-to-edge like a Wix
|
|
3
|
+
* Strip, x/width ignored) when it's explicitly marked `styles.containerRole === 'row'`
|
|
4
|
+
* — set by the "Cell row" seed/preset builders (rowContainer() in elementCatalog.tsx,
|
|
5
|
+
* the seed fixture). Any other Container parented directly to a Section (a "Box"/
|
|
6
|
+
* "Card"/"Divider" preset, or a freeform box the user just drew) keeps its own x/y/
|
|
7
|
+
* width/height — the two used to be conflated (any Container-child-of-Section was
|
|
8
|
+
* forced full-bleed), which silently broke every non-row Container preset by
|
|
9
|
+
* stretching it to the full section width and ignoring its intended position/size. A
|
|
10
|
+
* nested Container (a "cell" living inside a row) is unaffected either way — it always
|
|
11
|
+
* gets ordinary flex-item sizing from its row parent regardless of this flag. */
|
|
12
|
+
export declare function isFullBleedRow(nodeType: PlexoNodeType | undefined, parentType: PlexoNodeType | undefined, styles?: PlexoNode['styles']): boolean;
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type { PlexoNode
|
|
3
|
-
|
|
4
|
-
* Strip, x/width ignored) when it's explicitly marked `styles.containerRole === 'row'`
|
|
5
|
-
* — set by the "Cell row" seed/preset builders (rowContainer() in elementCatalog.tsx,
|
|
6
|
-
* the seed fixture). Any other Container parented directly to a Section (a "Box"/
|
|
7
|
-
* "Card"/"Divider" preset, or a freeform box the user just drew) keeps its own x/y/
|
|
8
|
-
* width/height — the two used to be conflated (any Container-child-of-Section was
|
|
9
|
-
* forced full-bleed), which silently broke every non-row Container preset by
|
|
10
|
-
* stretching it to the full section width and ignoring its intended position/size. A
|
|
11
|
-
* nested Container (a "cell" living inside a row) is unaffected either way — it always
|
|
12
|
-
* gets ordinary flex-item sizing from its row parent regardless of this flag. */
|
|
13
|
-
export declare function isFullBleedRow(nodeType: PlexoNodeType | undefined, parentType: PlexoNodeType | undefined, styles?: PlexoNode['styles']): boolean;
|
|
2
|
+
import type { PlexoNode } from '../store/types';
|
|
3
|
+
export { isFullBleedRow } from './layoutRoles';
|
|
14
4
|
/**
|
|
15
5
|
* Shared wiring for every draggable node type (Text/Image/Button/Container — anything
|
|
16
6
|
* but Section, which isn't pointer-draggable in Phase 3). Centralizes the placement
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TextStyleSlots } from './toReact';
|
|
2
|
+
export { compilePageToReact, componentNameFor, DESIGN_WIDTH, type CompileOptions, type TextStyleSlots } from './toReact';
|
|
3
|
+
export { buildSeedNodes } from '../store/seed';
|
|
4
|
+
export { BUTTON_SETS as DEFAULT_BUTTON_SETS, BOX_SETS as DEFAULT_BOX_SETS, TEXT_STYLE_SETS as DEFAULT_TEXT_STYLE_SETS } from '../store/brandDefaults';
|
|
5
|
+
export type { PlexoNode, PlexoNodeType, SectionNode } from '../store/types';
|
|
6
|
+
export type { StyleSet, StyleSlot } from '../store/brandTypes';
|
|
7
|
+
/** The text style slots of a brand's active text style set (the built-in set when none is
|
|
8
|
+
* given), in the shape compilePageToReact's `textStyles` option takes. */
|
|
9
|
+
export declare function textStyleSlots(sets?: Array<{
|
|
10
|
+
id: string;
|
|
11
|
+
slots: Array<{
|
|
12
|
+
id: string;
|
|
13
|
+
styles: Record<string, string | number>;
|
|
14
|
+
}>;
|
|
15
|
+
}>, activeId?: string): TextStyleSlots;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { c as e, f as t, l as n, n as r, r as i, t as a, u as o } from "./toReact-BBzjWoFG.js";
|
|
2
|
+
//#region src/v2/compile/index.ts
|
|
3
|
+
function s(e = o, t) {
|
|
4
|
+
let n = e.find((e) => e.id === t) ?? e[0], r = {};
|
|
5
|
+
for (let e of n?.slots ?? []) r[e.id] = e.styles;
|
|
6
|
+
return r;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { e as DEFAULT_BOX_SETS, n as DEFAULT_BUTTON_SETS, o as DEFAULT_TEXT_STYLE_SETS, a as DESIGN_WIDTH, t as buildSeedNodes, r as compilePageToReact, i as componentNameFor, s as textStyleSlots };
|