@mission-studio/puck 1.0.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.
@@ -0,0 +1,509 @@
1
+ import {
2
+ BorderRadiusField,
3
+ Button,
4
+ ColorPickerField,
5
+ EntryBoundTextField,
6
+ ResponsiveToggleField,
7
+ ShadowField,
8
+ SpacingSliderField,
9
+ ThemeableColorField,
10
+ TypographyField,
11
+ createBorderRadiusField,
12
+ createColorField,
13
+ createEntryBoundTextField,
14
+ createResponsiveField,
15
+ createShadowField,
16
+ createSpacingField,
17
+ createThemeableColorField,
18
+ createTypographyField
19
+ } from "./chunk-OZYZPWP7.mjs";
20
+ import {
21
+ allColorPresets,
22
+ neutralColors
23
+ } from "./chunk-UJTTHDZA.mjs";
24
+ import {
25
+ DEFAULT_THEME,
26
+ EntriesProvider,
27
+ ThemeProvider,
28
+ borderRadiusScale,
29
+ fontFamilies,
30
+ fontSizes,
31
+ fontWeights,
32
+ getBorderRadiusCSS,
33
+ getClosestBorderRadiusValue,
34
+ getClosestSpacingValue,
35
+ getFontSizeCSS,
36
+ getShadowCSS,
37
+ shadowPresets,
38
+ spacingScale,
39
+ useEntries,
40
+ useTheme
41
+ } from "./chunk-TTKY3YGP.mjs";
42
+
43
+ // components/editor/TemplatesList.tsx
44
+ import { usePuck } from "@measured/puck";
45
+ import { LayoutTemplate } from "lucide-react";
46
+
47
+ // templates.ts
48
+ var generateId = () => `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
49
+ var templates = [
50
+ {
51
+ name: "Hero Section",
52
+ description: "Title, subtitle, and CTA button",
53
+ category: "Templates",
54
+ getData: () => {
55
+ const sectionId = `Section-${generateId()}`;
56
+ const textBlockId = `TextBlock-${generateId()}`;
57
+ const popupId = `Popup-${generateId()}`;
58
+ return {
59
+ content: [
60
+ {
61
+ type: "Section",
62
+ props: {
63
+ id: sectionId,
64
+ verticalPadding: 96,
65
+ horizontalPadding: 32,
66
+ gap: 24,
67
+ backgroundColor: { color: "#111827", opacity: 100 },
68
+ shadow: "none",
69
+ borderRadius: 0,
70
+ contentMaxWidth: "1200px",
71
+ visibility: { mobile: true, desktop: true }
72
+ }
73
+ }
74
+ ],
75
+ zones: {
76
+ [`${sectionId}:content`]: [
77
+ {
78
+ type: "TextBlock",
79
+ props: {
80
+ id: textBlockId,
81
+ title: "Welcome to Your Site",
82
+ subtitle: "A powerful headline that captures attention",
83
+ body: "",
84
+ alignment: "center",
85
+ textSize: "xlarge",
86
+ textColor: { color: "#FFFFFF", opacity: 100 },
87
+ subtitleBodyColor: { color: "#9CA3AF", opacity: 100 },
88
+ useGradientText: false,
89
+ gradientColor1: { color: "#3B82F6", opacity: 100 },
90
+ gradientColor2: { color: "#8B5CF6", opacity: 100 }
91
+ }
92
+ },
93
+ {
94
+ type: "Popup",
95
+ props: {
96
+ id: popupId,
97
+ ctaText: "Get Started",
98
+ buttonColor: { color: "#3B82F6", opacity: 100 },
99
+ textColor: { color: "#FFFFFF", opacity: 100 },
100
+ iconPosition: "right",
101
+ size: "large",
102
+ width: "medium",
103
+ textLink: false
104
+ }
105
+ }
106
+ ]
107
+ }
108
+ };
109
+ }
110
+ },
111
+ {
112
+ name: "Features Grid",
113
+ description: "Heading with feature cards below",
114
+ category: "Templates",
115
+ getData: () => {
116
+ const sectionId = `Section-${generateId()}`;
117
+ const featureGridId = `FeatureGrid-${generateId()}`;
118
+ return {
119
+ content: [
120
+ {
121
+ type: "Section",
122
+ props: {
123
+ id: sectionId,
124
+ verticalPadding: 64,
125
+ horizontalPadding: 32,
126
+ gap: 24,
127
+ backgroundColor: { color: "#FFFFFF", opacity: 100 },
128
+ shadow: "none",
129
+ borderRadius: 0,
130
+ contentMaxWidth: "1200px",
131
+ visibility: { mobile: true, desktop: true }
132
+ }
133
+ }
134
+ ],
135
+ zones: {
136
+ [`${sectionId}:content`]: [
137
+ {
138
+ type: "FeatureGrid",
139
+ props: {
140
+ id: featureGridId,
141
+ heading: "Why Choose Us",
142
+ description: "Everything you need to succeed",
143
+ features: [
144
+ {
145
+ icon: "Zap",
146
+ title: "Fast",
147
+ description: "Lightning quick performance"
148
+ },
149
+ {
150
+ icon: "Shield",
151
+ title: "Secure",
152
+ description: "Enterprise-grade security"
153
+ },
154
+ {
155
+ icon: "Heart",
156
+ title: "Reliable",
157
+ description: "99.9% uptime guaranteed"
158
+ }
159
+ ],
160
+ columns: 3,
161
+ align: "center",
162
+ size: "medium",
163
+ iconColor: { color: "#3B82F6", opacity: 100 },
164
+ textColor: { color: "#000000", opacity: 100 }
165
+ }
166
+ }
167
+ ]
168
+ }
169
+ };
170
+ }
171
+ },
172
+ {
173
+ name: "CTA Banner",
174
+ description: "Call to action with button",
175
+ category: "Templates",
176
+ getData: () => {
177
+ const sectionId = `Section-${generateId()}`;
178
+ const textBlockId = `TextBlock-${generateId()}`;
179
+ const popupId = `Popup-${generateId()}`;
180
+ return {
181
+ content: [
182
+ {
183
+ type: "Section",
184
+ props: {
185
+ id: sectionId,
186
+ verticalPadding: 48,
187
+ horizontalPadding: 32,
188
+ gap: 16,
189
+ backgroundColor: { color: "#3B82F6", opacity: 100 },
190
+ shadow: "none",
191
+ borderRadius: 12,
192
+ contentMaxWidth: "900px",
193
+ visibility: { mobile: true, desktop: true }
194
+ }
195
+ }
196
+ ],
197
+ zones: {
198
+ [`${sectionId}:content`]: [
199
+ {
200
+ type: "TextBlock",
201
+ props: {
202
+ id: textBlockId,
203
+ title: "Ready to get started?",
204
+ subtitle: "Join thousands of satisfied customers today.",
205
+ body: "",
206
+ alignment: "center",
207
+ textSize: "large",
208
+ textColor: { color: "#FFFFFF", opacity: 100 },
209
+ subtitleBodyColor: { color: "#DBEAFE", opacity: 100 },
210
+ useGradientText: false,
211
+ gradientColor1: { color: "#3B82F6", opacity: 100 },
212
+ gradientColor2: { color: "#8B5CF6", opacity: 100 }
213
+ }
214
+ },
215
+ {
216
+ type: "Popup",
217
+ props: {
218
+ id: popupId,
219
+ ctaText: "Start Free Trial",
220
+ buttonColor: { color: "#FFFFFF", opacity: 100 },
221
+ textColor: { color: "#3B82F6", opacity: 100 },
222
+ iconPosition: "right",
223
+ size: "large",
224
+ width: "medium",
225
+ textLink: false
226
+ }
227
+ }
228
+ ]
229
+ }
230
+ };
231
+ }
232
+ },
233
+ {
234
+ name: "Text Section",
235
+ description: "Simple heading and paragraph",
236
+ category: "Templates",
237
+ getData: () => {
238
+ const sectionId = `Section-${generateId()}`;
239
+ const textBlockId = `TextBlock-${generateId()}`;
240
+ return {
241
+ content: [
242
+ {
243
+ type: "Section",
244
+ props: {
245
+ id: sectionId,
246
+ verticalPadding: 64,
247
+ horizontalPadding: 32,
248
+ gap: 24,
249
+ backgroundColor: { color: "#FFFFFF", opacity: 100 },
250
+ shadow: "none",
251
+ borderRadius: 0,
252
+ contentMaxWidth: "800px",
253
+ visibility: { mobile: true, desktop: true }
254
+ }
255
+ }
256
+ ],
257
+ zones: {
258
+ [`${sectionId}:content`]: [
259
+ {
260
+ type: "TextBlock",
261
+ props: {
262
+ id: textBlockId,
263
+ title: "About Us",
264
+ subtitle: "",
265
+ body: "<p>We are a team of passionate individuals dedicated to building great products. Our mission is to help businesses succeed by providing innovative solutions that drive growth and efficiency.</p><p>Founded in 2020, we've helped hundreds of companies transform their digital presence.</p>",
266
+ alignment: "left",
267
+ textSize: "medium",
268
+ textColor: { color: "#111827", opacity: 100 },
269
+ subtitleBodyColor: { color: "#4B5563", opacity: 100 },
270
+ useGradientText: false,
271
+ gradientColor1: { color: "#3B82F6", opacity: 100 },
272
+ gradientColor2: { color: "#8B5CF6", opacity: 100 }
273
+ }
274
+ }
275
+ ]
276
+ }
277
+ };
278
+ }
279
+ },
280
+ {
281
+ name: "Image Section",
282
+ description: "Centered image with caption",
283
+ category: "Templates",
284
+ getData: () => {
285
+ const sectionId = `Section-${generateId()}`;
286
+ const imageId = `CustomImage-${generateId()}`;
287
+ const textBlockId = `TextBlock-${generateId()}`;
288
+ return {
289
+ content: [
290
+ {
291
+ type: "Section",
292
+ props: {
293
+ id: sectionId,
294
+ verticalPadding: 48,
295
+ horizontalPadding: 32,
296
+ gap: 16,
297
+ backgroundColor: { color: "#F9FAFB", opacity: 100 },
298
+ shadow: "none",
299
+ borderRadius: 0,
300
+ contentMaxWidth: "1000px",
301
+ visibility: { mobile: true, desktop: true }
302
+ }
303
+ }
304
+ ],
305
+ zones: {
306
+ [`${sectionId}:content`]: [
307
+ {
308
+ type: "CustomImage",
309
+ props: {
310
+ id: imageId,
311
+ image: "https://placehold.co/1200x600/e2e8f0/64748b?text=Your+Image+Here",
312
+ alt: "Placeholder image",
313
+ maxWidth: 1e3,
314
+ alignment: "center",
315
+ fitContent: false
316
+ }
317
+ },
318
+ {
319
+ type: "TextBlock",
320
+ props: {
321
+ id: textBlockId,
322
+ title: "",
323
+ subtitle: "Add a caption or description for your image here.",
324
+ body: "",
325
+ alignment: "center",
326
+ textSize: "small",
327
+ textColor: { color: "#111827", opacity: 100 },
328
+ subtitleBodyColor: { color: "#6B7280", opacity: 100 },
329
+ useGradientText: false,
330
+ gradientColor1: { color: "#3B82F6", opacity: 100 },
331
+ gradientColor2: { color: "#8B5CF6", opacity: 100 }
332
+ }
333
+ }
334
+ ]
335
+ }
336
+ };
337
+ }
338
+ },
339
+ {
340
+ name: "Features List",
341
+ description: "Bullet points with icons",
342
+ category: "Templates",
343
+ getData: () => {
344
+ const sectionId = `Section-${generateId()}`;
345
+ const textBlockId = `TextBlock-${generateId()}`;
346
+ const featuresListId = `FeaturesList-${generateId()}`;
347
+ return {
348
+ content: [
349
+ {
350
+ type: "Section",
351
+ props: {
352
+ id: sectionId,
353
+ verticalPadding: 64,
354
+ horizontalPadding: 32,
355
+ gap: 32,
356
+ backgroundColor: { color: "#FFFFFF", opacity: 100 },
357
+ shadow: "none",
358
+ borderRadius: 0,
359
+ contentMaxWidth: "800px",
360
+ visibility: { mobile: true, desktop: true }
361
+ }
362
+ }
363
+ ],
364
+ zones: {
365
+ [`${sectionId}:content`]: [
366
+ {
367
+ type: "TextBlock",
368
+ props: {
369
+ id: textBlockId,
370
+ title: "What's Included",
371
+ subtitle: "",
372
+ body: "",
373
+ alignment: "left",
374
+ textSize: "large",
375
+ textColor: { color: "#111827", opacity: 100 },
376
+ subtitleBodyColor: { color: "#6B7280", opacity: 100 },
377
+ useGradientText: false,
378
+ gradientColor1: { color: "#3B82F6", opacity: 100 },
379
+ gradientColor2: { color: "#8B5CF6", opacity: 100 }
380
+ }
381
+ },
382
+ {
383
+ type: "FeaturesList",
384
+ props: {
385
+ id: featuresListId,
386
+ features: [
387
+ {
388
+ icon: "Check",
389
+ title: "Unlimited projects",
390
+ description: "Create as many as you need"
391
+ },
392
+ {
393
+ icon: "Check",
394
+ title: "Priority support",
395
+ description: "Get help when you need it"
396
+ },
397
+ {
398
+ icon: "Check",
399
+ title: "Advanced analytics",
400
+ description: "Track your performance"
401
+ },
402
+ {
403
+ icon: "Check",
404
+ title: "Custom integrations",
405
+ description: "Connect your favorite tools"
406
+ }
407
+ ],
408
+ align: "left",
409
+ size: "medium",
410
+ iconColor: { color: "#10B981", opacity: 100 }
411
+ }
412
+ }
413
+ ]
414
+ }
415
+ };
416
+ }
417
+ }
418
+ ];
419
+ function insertTemplate(currentData, template, insertIndex = -1) {
420
+ const templateData = template.getData();
421
+ const newContent = [...currentData.content];
422
+ const contentToInsert = templateData.content || [];
423
+ if (insertIndex === -1) {
424
+ newContent.push(...contentToInsert);
425
+ } else {
426
+ newContent.splice(insertIndex, 0, ...contentToInsert);
427
+ }
428
+ const newZones = {
429
+ ...currentData.zones,
430
+ ...templateData.zones
431
+ };
432
+ return {
433
+ ...currentData,
434
+ content: newContent,
435
+ zones: newZones
436
+ };
437
+ }
438
+
439
+ // components/editor/TemplatesList.tsx
440
+ import { jsx, jsxs } from "react/jsx-runtime";
441
+ function TemplatesList() {
442
+ const { appState, dispatch } = usePuck();
443
+ const handleInsertTemplate = (templateIndex) => {
444
+ const template = templates[templateIndex];
445
+ const newData = insertTemplate(appState.data, template);
446
+ dispatch({
447
+ type: "setData",
448
+ data: newData
449
+ });
450
+ };
451
+ return /* @__PURE__ */ jsxs("div", { className: "p-3", children: [
452
+ /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center gap-2 text-xs font-medium text-gray-500 uppercase", children: [
453
+ /* @__PURE__ */ jsx(LayoutTemplate, { className: "size-3" }),
454
+ "Templates"
455
+ ] }),
456
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: templates.map((template, index) => /* @__PURE__ */ jsx(
457
+ Button,
458
+ {
459
+ variant: "outline",
460
+ size: "sm",
461
+ className: "h-auto justify-start px-3 py-2",
462
+ onClick: () => handleInsertTemplate(index),
463
+ children: /* @__PURE__ */ jsxs("div", { className: "text-left", children: [
464
+ /* @__PURE__ */ jsx("div", { className: "font-medium", children: template.name }),
465
+ /* @__PURE__ */ jsx("div", { className: "text-muted-foreground text-xs", children: template.description })
466
+ ] })
467
+ },
468
+ template.name
469
+ )) })
470
+ ] });
471
+ }
472
+ export {
473
+ BorderRadiusField,
474
+ ColorPickerField,
475
+ DEFAULT_THEME,
476
+ EntriesProvider,
477
+ EntryBoundTextField,
478
+ ResponsiveToggleField,
479
+ ShadowField,
480
+ SpacingSliderField,
481
+ TemplatesList,
482
+ ThemeProvider,
483
+ ThemeableColorField,
484
+ TypographyField,
485
+ allColorPresets,
486
+ borderRadiusScale,
487
+ createBorderRadiusField,
488
+ createColorField,
489
+ createEntryBoundTextField,
490
+ createResponsiveField,
491
+ createShadowField,
492
+ createSpacingField,
493
+ createThemeableColorField,
494
+ createTypographyField,
495
+ fontFamilies,
496
+ fontSizes,
497
+ fontWeights,
498
+ getBorderRadiusCSS,
499
+ getClosestBorderRadiusValue,
500
+ getClosestSpacingValue,
501
+ getFontSizeCSS,
502
+ getShadowCSS,
503
+ neutralColors,
504
+ shadowPresets,
505
+ spacingScale,
506
+ templates,
507
+ useEntries,
508
+ useTheme
509
+ };