@commercetools-demo/puck-editor 0.1.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,389 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { Config, ComponentConfig } from '@measured/puck';
3
+ import { PuckData, PuckStateInfo } from '@commercetools-demo/puck-types';
4
+
5
+ interface PuckEditorProps {
6
+ /** Service base URL, e.g. "http://localhost:8080" */
7
+ baseURL: string;
8
+ /** CommerceTools project key */
9
+ projectKey: string;
10
+ /** Business unit key */
11
+ businessUnitKey: string;
12
+ /** JWT bearer token — required for save/publish mutations */
13
+ jwtToken: string;
14
+ /** The key of the puck page to edit */
15
+ pageKey: string;
16
+ /**
17
+ * Puck component config.
18
+ * Defaults to `defaultPuckConfig` (all built-in components).
19
+ * Consumers can extend or replace.
20
+ */
21
+ config?: Config;
22
+ /** Called after a successful publish */
23
+ onPublish?: (puckData: PuckData) => void;
24
+ /** Called after each auto-save */
25
+ onSave?: (puckData: PuckData) => void;
26
+ /** Called when an error occurs */
27
+ onError?: (error: Error) => void;
28
+ /** Show the Publish button in the toolbar. Default: true */
29
+ showPublishButton?: boolean;
30
+ /** Debounce delay for auto-save in ms. Default: 1500 */
31
+ autoSaveDebounceMs?: number;
32
+ }
33
+ declare const PuckEditor: React.FC<PuckEditorProps>;
34
+
35
+ /**
36
+ * Default Puck configuration with built-in components.
37
+ *
38
+ * Consumers can extend this:
39
+ * ```ts
40
+ * import { defaultPuckConfig } from '@commercetools-demo/puck-editor';
41
+ * const myConfig = {
42
+ * ...defaultPuckConfig,
43
+ * components: { ...defaultPuckConfig.components, MyComponent },
44
+ * };
45
+ * ```
46
+ */
47
+ declare const defaultPuckConfig: Config;
48
+
49
+ interface HeroProps {
50
+ heading: string;
51
+ subheading?: string;
52
+ backgroundImage?: string;
53
+ ctaText?: string;
54
+ ctaUrl?: string;
55
+ layout?: 'centered' | 'left-aligned';
56
+ minHeight?: string;
57
+ }
58
+ declare const Hero: ComponentConfig<HeroProps>;
59
+
60
+ interface RichTextProps {
61
+ content: string;
62
+ align?: 'left' | 'center' | 'right';
63
+ maxWidth?: string;
64
+ padding?: string;
65
+ }
66
+ declare const RichText: ComponentConfig<RichTextProps>;
67
+
68
+ interface ColumnsProps {
69
+ columnCount?: 2 | 3 | 4;
70
+ gap?: string;
71
+ padding?: string;
72
+ }
73
+ declare const Columns: ComponentConfig<ColumnsProps>;
74
+
75
+ interface ImageProps {
76
+ src: string;
77
+ alt?: string;
78
+ caption?: string;
79
+ width?: string;
80
+ height?: string;
81
+ objectFit?: 'cover' | 'contain' | 'fill';
82
+ borderRadius?: string;
83
+ align?: 'left' | 'center' | 'right';
84
+ }
85
+ declare const Image: ComponentConfig<ImageProps>;
86
+
87
+ interface ButtonProps {
88
+ label: string;
89
+ href?: string;
90
+ variant?: 'primary' | 'secondary' | 'outline';
91
+ size?: 'sm' | 'md' | 'lg';
92
+ align?: 'left' | 'center' | 'right';
93
+ openInNewTab?: boolean;
94
+ }
95
+ declare const Button: ComponentConfig<ButtonProps>;
96
+
97
+ interface CardProps {
98
+ title: string;
99
+ body?: string;
100
+ imageUrl?: string;
101
+ ctaText?: string;
102
+ ctaUrl?: string;
103
+ shadow?: boolean;
104
+ borderRadius?: string;
105
+ }
106
+ declare const Card: ComponentConfig<CardProps>;
107
+
108
+ interface SpacerProps {
109
+ height?: string;
110
+ showLine?: boolean;
111
+ lineColor?: string;
112
+ }
113
+ declare const Spacer: ComponentConfig<SpacerProps>;
114
+
115
+ type DatasourceType = 'product-by-sku' | 'products-by-sku';
116
+ interface DatasourceValue {
117
+ type: DatasourceType;
118
+ skus: string[];
119
+ /** Pre-resolved by the server on published/preview endpoints — use directly in render. */
120
+ resolvedData?: unknown;
121
+ }
122
+ interface DatasourceFieldProps {
123
+ value: DatasourceValue | undefined;
124
+ onChange: (value: DatasourceValue) => void;
125
+ }
126
+ declare const DatasourceField: React.FC<DatasourceFieldProps>;
127
+
128
+ interface ProductTeaserProps {
129
+ datasource: DatasourceValue;
130
+ richText: string;
131
+ }
132
+ declare const ProductTeaser: ComponentConfig<ProductTeaserProps>;
133
+
134
+ interface HeroBannerProps {
135
+ title: string;
136
+ subtitle: string;
137
+ image: string;
138
+ }
139
+ declare const HeroBanner: ComponentConfig<HeroBannerProps>;
140
+
141
+ interface TextBlockProps {
142
+ content: string;
143
+ }
144
+ declare const TextBlock: ComponentConfig<TextBlockProps>;
145
+
146
+ interface CategoryGridProps {
147
+ category1Image: string;
148
+ category1Label: string;
149
+ category1Link: string;
150
+ category2Image: string;
151
+ category2Label: string;
152
+ category2Link: string;
153
+ category3Image: string;
154
+ category3Label: string;
155
+ category3Link: string;
156
+ category4Image: string;
157
+ category4Label: string;
158
+ category4Link: string;
159
+ }
160
+ declare const CategoryGrid: ComponentConfig<CategoryGridProps>;
161
+
162
+ interface CategoryHeroProps {
163
+ title: string;
164
+ subtitle: string;
165
+ image: string;
166
+ ctaText: string;
167
+ ctaLink: string;
168
+ }
169
+ declare const CategoryHero: ComponentConfig<CategoryHeroProps>;
170
+
171
+ interface CheckoutPromoBannerProps {
172
+ title: string;
173
+ message: string;
174
+ ctaText: string;
175
+ ctaLink: string;
176
+ }
177
+ declare const CheckoutPromoBanner: ComponentConfig<CheckoutPromoBannerProps>;
178
+
179
+ interface CountdownBannerProps {
180
+ headline: string;
181
+ subline: string;
182
+ endDate: string;
183
+ ctaText: string;
184
+ ctaLink: string;
185
+ background: string;
186
+ }
187
+ declare const CountdownBanner: ComponentConfig<CountdownBannerProps>;
188
+
189
+ interface CrossSellBlockProps {
190
+ title: string;
191
+ products: DatasourceValue;
192
+ ctaText: string;
193
+ }
194
+ declare const CrossSellBlock: ComponentConfig<CrossSellBlockProps>;
195
+
196
+ interface DeliveryMessageProps {
197
+ message: string;
198
+ threshold: string;
199
+ }
200
+ declare const DeliveryMessage: ComponentConfig<DeliveryMessageProps>;
201
+
202
+ interface DividerProps {
203
+ lineStyle: 'solid' | 'dashed' | 'dotted';
204
+ spacing: string;
205
+ }
206
+ declare const Divider: ComponentConfig<DividerProps>;
207
+
208
+ interface EmptyStateProps {
209
+ image: string;
210
+ title: string;
211
+ description: string;
212
+ ctaText: string;
213
+ ctaLink: string;
214
+ }
215
+ declare const EmptyState: ComponentConfig<EmptyStateProps>;
216
+
217
+ interface FAQAccordionProps {
218
+ question1: string;
219
+ answer1: string;
220
+ question2: string;
221
+ answer2: string;
222
+ question3: string;
223
+ answer3: string;
224
+ question4: string;
225
+ answer4: string;
226
+ }
227
+ declare const FAQAccordion: ComponentConfig<FAQAccordionProps>;
228
+
229
+ interface FooterBlockProps {
230
+ column1: string;
231
+ column2: string;
232
+ column3: string;
233
+ copyright: string;
234
+ }
235
+ declare const FooterBlock: ComponentConfig<FooterBlockProps>;
236
+
237
+ interface ImageBlockProps {
238
+ image: string;
239
+ caption: string;
240
+ link: string;
241
+ }
242
+ declare const ImageBlock: ComponentConfig<ImageBlockProps>;
243
+
244
+ interface NewsletterSignupProps {
245
+ title: string;
246
+ subtitle: string;
247
+ ctaText: string;
248
+ placeholder: string;
249
+ }
250
+ declare const NewsletterSignup: ComponentConfig<NewsletterSignupProps>;
251
+
252
+ interface ProductBannerProps {
253
+ title: string;
254
+ description: string;
255
+ ctaText: string;
256
+ ctaLink: string;
257
+ product: DatasourceValue;
258
+ productOnLeft: boolean;
259
+ background: string;
260
+ }
261
+ declare const ProductBanner: ComponentConfig<ProductBannerProps>;
262
+
263
+ interface ProductGridHeaderProps {
264
+ title: string;
265
+ description: string;
266
+ }
267
+ declare const ProductGridHeader: ComponentConfig<ProductGridHeaderProps>;
268
+
269
+ interface ProductSliderProps {
270
+ title: string;
271
+ subtitle: string;
272
+ products: DatasourceValue;
273
+ }
274
+ declare const ProductSlider: ComponentConfig<ProductSliderProps>;
275
+
276
+ interface PromotionalBannerProps {
277
+ image: string;
278
+ title: string;
279
+ subtitle: string;
280
+ ctaText: string;
281
+ ctaLink: string;
282
+ background: string;
283
+ }
284
+ declare const PromotionalBanner: ComponentConfig<PromotionalBannerProps>;
285
+
286
+ interface RelatedProductsSliderProps {
287
+ title: string;
288
+ subtitle: string;
289
+ products: DatasourceValue;
290
+ }
291
+ declare const RelatedProductsSlider: ComponentConfig<RelatedProductsSliderProps>;
292
+
293
+ interface SocialLinksProps {
294
+ link1Label: string;
295
+ link1Url: string;
296
+ link2Label: string;
297
+ link2Url: string;
298
+ link3Label: string;
299
+ link3Url: string;
300
+ link4Label: string;
301
+ link4Url: string;
302
+ }
303
+ declare const SocialLinks: ComponentConfig<SocialLinksProps>;
304
+
305
+ interface TabContentProps {
306
+ tabLabel: string;
307
+ content: string;
308
+ }
309
+ declare const TabContent: ComponentConfig<TabContentProps>;
310
+
311
+ interface TestimonialsSliderProps {
312
+ quote1: string;
313
+ author1: string;
314
+ role1: string;
315
+ quote2: string;
316
+ author2: string;
317
+ role2: string;
318
+ quote3: string;
319
+ author3: string;
320
+ role3: string;
321
+ }
322
+ declare const TestimonialsSlider: ComponentConfig<TestimonialsSliderProps>;
323
+
324
+ interface ThankYouContentProps {
325
+ headline: string;
326
+ message: string;
327
+ ctaText: string;
328
+ ctaLink: string;
329
+ }
330
+ declare const ThankYouContent: ComponentConfig<ThankYouContentProps>;
331
+
332
+ interface TrustBadgesProps {
333
+ badge1Icon: string;
334
+ badge1Label: string;
335
+ badge2Icon: string;
336
+ badge2Label: string;
337
+ badge3Icon: string;
338
+ badge3Label: string;
339
+ badge4Icon: string;
340
+ badge4Label: string;
341
+ }
342
+ declare const TrustBadges: ComponentConfig<TrustBadgesProps>;
343
+
344
+ interface VideoBlockProps {
345
+ videoUrl: string;
346
+ posterImage: string;
347
+ title: string;
348
+ caption: string;
349
+ }
350
+ declare const VideoBlock: ComponentConfig<VideoBlockProps>;
351
+
352
+ interface WebsiteLogoProps {
353
+ logo: string;
354
+ maxWidth: string;
355
+ maxHeight: string;
356
+ }
357
+ declare const WebsiteLogo: ComponentConfig<WebsiteLogoProps>;
358
+
359
+ interface ImagePickerFieldProps {
360
+ value: string;
361
+ onChange: (value: string) => void;
362
+ /** Only show images (default: true) */
363
+ imagesOnly?: boolean;
364
+ }
365
+ declare const ImagePickerField: React.FC<ImagePickerFieldProps>;
366
+
367
+ interface EditorToolbarProps {
368
+ saving: boolean;
369
+ isDirty: boolean;
370
+ states: PuckStateInfo;
371
+ onSave: () => void;
372
+ onPublish: () => void;
373
+ onRevert: () => void;
374
+ showPublishButton: boolean;
375
+ }
376
+ declare const EditorToolbar: React.FC<EditorToolbarProps>;
377
+
378
+ declare const ComponentSearchProvider: React.FC<{
379
+ children: ReactNode;
380
+ }>;
381
+ declare const ComponentsPanel: React.FC<{
382
+ children: ReactNode;
383
+ }>;
384
+ declare const ComponentItemFilter: React.FC<{
385
+ children: ReactNode;
386
+ name: string;
387
+ }>;
388
+
389
+ export { Button, type ButtonProps, Card, type CardProps, CategoryGrid, type CategoryGridProps, CategoryHero, type CategoryHeroProps, CheckoutPromoBanner, type CheckoutPromoBannerProps, Columns, type ColumnsProps, ComponentItemFilter, ComponentSearchProvider, ComponentsPanel, CountdownBanner, type CountdownBannerProps, CrossSellBlock, type CrossSellBlockProps, DatasourceField, type DatasourceFieldProps, type DatasourceType, type DatasourceValue, DeliveryMessage, type DeliveryMessageProps, Divider, type DividerProps, EditorToolbar, type EditorToolbarProps, EmptyState, type EmptyStateProps, FAQAccordion, type FAQAccordionProps, FooterBlock, type FooterBlockProps, Hero, HeroBanner, type HeroBannerProps, type HeroProps, Image, ImageBlock, type ImageBlockProps, ImagePickerField, type ImagePickerFieldProps, type ImageProps, NewsletterSignup, type NewsletterSignupProps, ProductBanner, type ProductBannerProps, ProductGridHeader, type ProductGridHeaderProps, ProductSlider, type ProductSliderProps, ProductTeaser, type ProductTeaserProps, PromotionalBanner, type PromotionalBannerProps, PuckEditor, type PuckEditorProps, RelatedProductsSlider, type RelatedProductsSliderProps, RichText, type RichTextProps, SocialLinks, type SocialLinksProps, Spacer, type SpacerProps, TabContent, type TabContentProps, TestimonialsSlider, type TestimonialsSliderProps, TextBlock, type TextBlockProps, ThankYouContent, type ThankYouContentProps, TrustBadges, type TrustBadgesProps, VideoBlock, type VideoBlockProps, WebsiteLogo, type WebsiteLogoProps, defaultPuckConfig };