@spillway-cms/blocks 0.0.0-stage → 0.1.2

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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/dist/ask.d.ts +39 -0
  3. package/dist/ask.js +96 -0
  4. package/dist/ask.js.map +1 -0
  5. package/dist/calendar.d.ts +42 -0
  6. package/dist/calendar.js +96 -0
  7. package/dist/calendar.js.map +1 -0
  8. package/dist/collection.d.ts +89 -0
  9. package/dist/collection.js +304 -0
  10. package/dist/collection.js.map +1 -0
  11. package/dist/config.d.ts +246 -0
  12. package/dist/config.js +638 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/css.d.ts +1 -0
  15. package/dist/css.js +606 -0
  16. package/dist/css.js.map +1 -0
  17. package/dist/docs-feedback.d.ts +34 -0
  18. package/dist/docs-feedback.js +57 -0
  19. package/dist/docs-feedback.js.map +1 -0
  20. package/dist/examples.d.ts +12 -0
  21. package/dist/examples.js +85 -0
  22. package/dist/examples.js.map +1 -0
  23. package/dist/experiment.d.ts +18 -0
  24. package/dist/experiment.js +20 -0
  25. package/dist/experiment.js.map +1 -0
  26. package/dist/form.d.ts +40 -0
  27. package/dist/form.js +252 -0
  28. package/dist/form.js.map +1 -0
  29. package/dist/gallery.d.ts +36 -0
  30. package/dist/gallery.js +114 -0
  31. package/dist/gallery.js.map +1 -0
  32. package/dist/image.d.ts +41 -0
  33. package/dist/image.js +39 -0
  34. package/dist/image.js.map +1 -0
  35. package/dist/index.d.ts +54 -0
  36. package/dist/index.js +31 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/layouts.d.ts +8 -0
  39. package/dist/layouts.js +81 -0
  40. package/dist/layouts.js.map +1 -0
  41. package/dist/markdown.d.ts +32 -0
  42. package/dist/markdown.js +283 -0
  43. package/dist/markdown.js.map +1 -0
  44. package/dist/marketing.d.ts +70 -0
  45. package/dist/marketing.js +208 -0
  46. package/dist/marketing.js.map +1 -0
  47. package/dist/menu.d.ts +43 -0
  48. package/dist/menu.js +75 -0
  49. package/dist/menu.js.map +1 -0
  50. package/dist/meta.d.ts +14 -0
  51. package/dist/meta.js +198 -0
  52. package/dist/meta.js.map +1 -0
  53. package/dist/module-block.d.ts +32 -0
  54. package/dist/module-block.js +76 -0
  55. package/dist/module-block.js.map +1 -0
  56. package/dist/motion.d.ts +19 -0
  57. package/dist/motion.js +161 -0
  58. package/dist/motion.js.map +1 -0
  59. package/dist/personalize.d.ts +18 -0
  60. package/dist/personalize.js +32 -0
  61. package/dist/personalize.js.map +1 -0
  62. package/dist/players.d.ts +30 -0
  63. package/dist/players.js +95 -0
  64. package/dist/players.js.map +1 -0
  65. package/dist/registry-browse.d.ts +31 -0
  66. package/dist/registry-browse.js +97 -0
  67. package/dist/registry-browse.js.map +1 -0
  68. package/dist/registry-gallery.d.ts +22 -0
  69. package/dist/registry-gallery.js +73 -0
  70. package/dist/registry-gallery.js.map +1 -0
  71. package/dist/registry-org.d.ts +22 -0
  72. package/dist/registry-org.js +44 -0
  73. package/dist/registry-org.js.map +1 -0
  74. package/dist/registry-package.d.ts +27 -0
  75. package/dist/registry-package.js +145 -0
  76. package/dist/registry-package.js.map +1 -0
  77. package/dist/registry-publisher.d.ts +20 -0
  78. package/dist/registry-publisher.js +46 -0
  79. package/dist/registry-publisher.js.map +1 -0
  80. package/dist/registry-shared.d.ts +29 -0
  81. package/dist/registry-shared.js +122 -0
  82. package/dist/registry-shared.js.map +1 -0
  83. package/dist/registry-stats.d.ts +15 -0
  84. package/dist/registry-stats.js +42 -0
  85. package/dist/registry-stats.js.map +1 -0
  86. package/dist/registry-types.d.ts +218 -0
  87. package/dist/registry-types.js +29 -0
  88. package/dist/registry-types.js.map +1 -0
  89. package/dist/sanitize.d.ts +37 -0
  90. package/dist/sanitize.js +293 -0
  91. package/dist/sanitize.js.map +1 -0
  92. package/dist/search.d.ts +25 -0
  93. package/dist/search.js +77 -0
  94. package/dist/search.js.map +1 -0
  95. package/dist/shared.d.ts +27 -0
  96. package/dist/shared.js +59 -0
  97. package/dist/shared.js.map +1 -0
  98. package/dist/status-board.d.ts +49 -0
  99. package/dist/status-board.js +81 -0
  100. package/dist/status-board.js.map +1 -0
  101. package/dist/story.d.ts +23 -0
  102. package/dist/story.js +58 -0
  103. package/dist/story.js.map +1 -0
  104. package/dist/styles.css +1361 -0
  105. package/dist/styles.d.ts +37 -0
  106. package/dist/styles.js +242 -0
  107. package/dist/styles.js.map +1 -0
  108. package/package.json +47 -3
  109. package/README.md +0 -3
package/dist/config.js ADDED
@@ -0,0 +1,638 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { cloneElement, isValidElement } from 'react';
3
+ import { MOTION_ENTRANCES, MOTION_HOVERS, MOTION_SCROLLS } from '@spillway-cms/shared';
4
+ import { calendarComponent } from './calendar.js';
5
+ import { collectionComponent } from './collection.js';
6
+ import { renderForm } from './form.js';
7
+ import { ResponsiveImage, WIDE_SIZES } from './image.js';
8
+ import { createSharedComponent } from './shared.js';
9
+ import { personalizeComponent } from './personalize.js';
10
+ import { experimentComponent } from './experiment.js';
11
+ import { registryBrowseComponent } from './registry-browse.js';
12
+ import { registryPackageComponent } from './registry-package.js';
13
+ import { galleryComponent } from './gallery.js';
14
+ import { faqComponent, logoStripComponent, statsComponent, testimonialsComponent } from './marketing.js';
15
+ import { scrollytellingComponent } from './story.js';
16
+ import { lottieComponent, model3dComponent } from './players.js';
17
+ import { searchComponent } from './search.js';
18
+ import { askComponent } from './ask.js';
19
+ import { menuBlockComponent } from './menu.js';
20
+ import { registryStatsComponent } from './registry-stats.js';
21
+ import { statusBoardComponent } from './status-board.js';
22
+ import { themeGalleryComponent } from './registry-gallery.js';
23
+ import { publisherProfileComponent } from './registry-publisher.js';
24
+ import { orgProfileComponent } from './registry-org.js';
25
+ import { docsFeedbackComponent } from './docs-feedback.js';
26
+ import { moduleBlockComponent } from './module-block.js';
27
+ import { DEFAULT_EMBED_HOSTS } from '@spillway-cms/shared';
28
+ import { holdEmbedHtml, isPlainText, keyboardScrollable, sanitizeEmbedHtml, sanitizeTextHtml } from './sanitize.js';
29
+ /** `https://www.youtube.com/embed/x` → `www.youtube.com`; empty when it is not a URL. */
30
+ function hostOf(url) {
31
+ try {
32
+ return new URL(url).host;
33
+ }
34
+ catch {
35
+ return '';
36
+ }
37
+ }
38
+ import { styleClassFor } from './styles.js';
39
+ // ---------- Helpers (pure) ----------
40
+ const alignOptions = [
41
+ { label: 'Left', value: 'left' },
42
+ { label: 'Center', value: 'center' },
43
+ ];
44
+ const textAlignOptions = [
45
+ { label: 'Left', value: 'left' },
46
+ { label: 'Center', value: 'center' },
47
+ { label: 'Right', value: 'right' },
48
+ ];
49
+ const yesNo = [
50
+ { label: 'Yes', value: true },
51
+ { label: 'No', value: false },
52
+ ];
53
+ function cx(...parts) {
54
+ return parts.filter(Boolean).join(' ');
55
+ }
56
+ /** Split plain text into paragraphs on blank lines; single newlines become <br>. */
57
+ function paragraphs(text) {
58
+ return text
59
+ .replace(/\r\n?/g, '\n')
60
+ .split(/\n\s*\n/)
61
+ .map((p) => p.trim())
62
+ .filter((p) => p.length > 0)
63
+ .map((p, i) => {
64
+ const lines = p.split('\n');
65
+ return (_jsx("p", { children: lines.map((line, j) => (_jsxs("span", { children: [j > 0 ? _jsx("br", {}) : null, line] }, j))) }, i));
66
+ });
67
+ }
68
+ function isExternal(href) {
69
+ return /^(https?:)?\/\//i.test(href);
70
+ }
71
+ function Button({ label, href, variant, newTab, }) {
72
+ if (!label)
73
+ return null;
74
+ const external = isExternal(href);
75
+ return (_jsx("a", { className: cx('sw-button', `sw-button--${variant}`), href: href || '#', target: newTab ? '_blank' : undefined, rel: newTab || external ? 'noopener' : undefined, children: label }));
76
+ }
77
+ // ---------- Config ----------
78
+ export const config = {
79
+ categories: {
80
+ layout: { title: 'Layout', components: ['Section', 'Columns', 'Spacer', 'Divider'] },
81
+ content: { title: 'Content', components: ['Heading', 'Text', 'Image', 'Gallery', 'Embed', 'Lottie', 'Model3D', 'Button', 'Buttons', 'Search', 'Ask', 'Menu'] },
82
+ marketing: { title: 'Marketing', components: ['Hero', 'CallToAction', 'Cards', 'Faq', 'Testimonials', 'Stats', 'LogoStrip', 'Scrollytelling', 'Collection', 'Calendar', 'Form', 'Shared'] },
83
+ // The docs kit's feedback block; the admin lists it only on a site that has the docs_feedback form.
84
+ docs: { title: 'Docs', components: ['DocsFeedback'] },
85
+ // The package registry's public pages; the admin lists them only on an instance that hosts the registry (REGISTRY_HOST=1).
86
+ registry: { title: 'Registry', components: ['RegistryBrowse', 'RegistryPackage', 'RegistryStats', 'ThemeGallery', 'PublisherProfile', 'OrgProfile'] },
87
+ // Blocks most pages do not need, collapsed in the blocks panel until opened.
88
+ advanced: { title: 'Advanced', components: ['Personalize', 'Experiment', 'StatusBoard'], defaultExpanded: false },
89
+ // Blocks installed modules provide (docs/modules.md); the admin replaces this component's fields with the modules' own definitions.
90
+ modules: { title: 'Modules', components: ['ModuleBlock'] },
91
+ },
92
+ root: {
93
+ label: 'Page',
94
+ fields: {
95
+ title: { type: 'text', label: 'Page title' },
96
+ },
97
+ defaultProps: { title: '' },
98
+ // A div, not main: the shell (and a headless site's own layout) owns the page's one main landmark.
99
+ render: ({ children }) => _jsx("div", { className: "sw-page", children: children }),
100
+ },
101
+ components: {
102
+ // ----- Marketing -----
103
+ // Saved query rendered as cards, list or grid; items are resolved by the server (see src/collection.tsx).
104
+ Collection: collectionComponent,
105
+ // A block from the component library, resolved by the server (see src/shared.tsx).
106
+ Shared: createSharedComponent(() => config),
107
+ // Month grid or list of a collection's event occurrences; resolved by the server (see src/calendar.tsx).
108
+ Calendar: calendarComponent,
109
+ // Islands: content per audience or per experiment variant; the server picks what each visitor sees (see src/personalize.tsx, src/experiment.tsx).
110
+ Personalize: personalizeComponent,
111
+ Experiment: experimentComponent,
112
+ // Registry (the project site): browse, package page, totals, theme directory and publisher profile; filled in by the
113
+ // registry service on a registry host (REGISTRY_HOST=1), placeholders elsewhere (see src/registry-*.tsx).
114
+ RegistryBrowse: registryBrowseComponent,
115
+ RegistryPackage: registryPackageComponent,
116
+ RegistryStats: registryStatsComponent,
117
+ ThemeGallery: themeGalleryComponent,
118
+ PublisherProfile: publisherProfileComponent,
119
+ OrgProfile: orgProfileComponent,
120
+ // "Was this page helpful?" at the end of a documentation page; posts to a form the site defines (see src/docs-feedback.tsx).
121
+ DocsFeedback: docsFeedbackComponent,
122
+ // Other instances' health and 90-day uptime, fetched by the server (the project site's /status; see src/status-board.tsx).
123
+ StatusBoard: statusBoardComponent,
124
+ // A block an installed module renders on the server (see src/module-block.tsx); the server's resolver fills `html`.
125
+ ModuleBlock: moduleBlockComponent,
126
+ Form: {
127
+ label: 'Form',
128
+ fields: {
129
+ formKey: { type: 'text', label: 'Form key', placeholder: 'contact (from Forms in the admin)' },
130
+ title: { type: 'text', label: 'Title', contentEditable: true },
131
+ intro: { type: 'textarea', label: 'Intro text', contentEditable: true },
132
+ submitLabel: { type: 'text', label: 'Button label override', placeholder: 'Leave empty to use the form definition' },
133
+ },
134
+ defaultProps: { formKey: '', title: '', intro: '', submitLabel: '' },
135
+ // `form` is not a Puck field: the server attaches the FormDefinition before render.
136
+ render: (props) => renderForm(props),
137
+ },
138
+ Hero: {
139
+ label: 'Hero',
140
+ fields: {
141
+ eyebrow: { type: 'text', label: 'Eyebrow', placeholder: 'Short label above the title', contentEditable: true },
142
+ title: { type: 'text', label: 'Title', contentEditable: true },
143
+ subtitle: { type: 'textarea', label: 'Subtitle', contentEditable: true },
144
+ primaryLabel: { type: 'text', label: 'Primary button label' },
145
+ primaryHref: { type: 'text', label: 'Primary button link', placeholder: '/get-started' },
146
+ secondaryLabel: { type: 'text', label: 'Secondary button label' },
147
+ secondaryHref: { type: 'text', label: 'Secondary button link' },
148
+ backgroundImage: { type: 'text', label: 'Background image URL', placeholder: '/media/...' },
149
+ backgroundVideo: { type: 'text', label: 'Background video URL (needs a background image as its poster)', placeholder: '/media/....mp4' },
150
+ align: { type: 'radio', label: 'Alignment', options: alignOptions },
151
+ size: {
152
+ type: 'radio',
153
+ label: 'Size',
154
+ options: [
155
+ { label: 'Default', value: 'default' },
156
+ { label: 'Large', value: 'large' },
157
+ ],
158
+ },
159
+ },
160
+ defaultProps: {
161
+ eyebrow: 'Introducing',
162
+ title: 'A headline that says what you do',
163
+ subtitle: 'One or two sentences that explain the value and who it is for.',
164
+ primaryLabel: 'Get started',
165
+ primaryHref: '#',
166
+ secondaryLabel: 'Learn more',
167
+ secondaryHref: '#',
168
+ backgroundImage: '',
169
+ align: 'center',
170
+ size: 'default',
171
+ },
172
+ render: ({ eyebrow, title, subtitle, primaryLabel, primaryHref, secondaryLabel, secondaryHref, backgroundImage, backgroundVideo, align, size, style, backgroundMedia, }) => {
173
+ const video = backgroundVideo && backgroundImage && /\.(mp4|webm)(\?.*)?$/i.test(backgroundVideo) ? backgroundVideo : null;
174
+ const hasImage = Boolean(backgroundImage);
175
+ // A library image becomes a real, eagerly loaded picture behind the text (first paint matters for a hero);
176
+ // any other URL stays a CSS background.
177
+ const hasPicture = hasImage && Boolean(backgroundMedia) && !video;
178
+ const hasActions = Boolean(primaryLabel || secondaryLabel);
179
+ return (_jsxs("section", { className: cx('sw-block', 'sw-hero', `sw-hero--${size}`, hasImage && 'sw-hero--image', `sw-align-${align}`, styleClassFor('Hero', style)), style: hasImage && !hasPicture && !video ? { backgroundImage: `url("${backgroundImage}")` } : undefined, children: [video ? (_jsxs(_Fragment, { children: [_jsx("video", { className: "sw-hero__bg sw-hero__video", muted: true, loop: true, playsInline: true, preload: "none", poster: backgroundMedia?.url ?? backgroundImage, "aria-hidden": "true", "data-sw-bg-video": "", children: _jsx("source", { src: video, type: /\.webm(\?.*)?$/i.test(video) ? 'video/webm' : 'video/mp4' }) }), _jsx("button", { type: "button", className: "sw-video-toggle", "data-sw-video-toggle": "", "aria-pressed": "false", hidden: true, children: "Pause background video" })] })) : null, hasPicture ? (_jsx(ResponsiveImage, { className: "sw-hero__bg", src: backgroundImage, alt: "", media: backgroundMedia, sizes: "100vw", loading: "eager", aspect: { w: 16, h: 7 } })) : null, _jsx("div", { className: "sw-container", children: _jsxs("div", { className: "sw-hero__inner", children: [eyebrow ? _jsx("span", { className: "sw-hero__eyebrow", children: eyebrow }) : null, _jsx("h1", { className: "sw-hero__title", children: title }), subtitle ? _jsx("p", { className: "sw-hero__subtitle", children: subtitle }) : null, hasActions ? (_jsxs("div", { className: "sw-actions", children: [_jsx(Button, { label: primaryLabel, href: primaryHref, variant: "primary" }), _jsx(Button, { label: secondaryLabel, href: secondaryHref, variant: "secondary" })] })) : null] }) })] }));
180
+ },
181
+ },
182
+ CallToAction: {
183
+ label: 'Call to action',
184
+ fields: {
185
+ title: { type: 'text', label: 'Title', contentEditable: true },
186
+ text: { type: 'textarea', label: 'Text', contentEditable: true },
187
+ buttonLabel: { type: 'text', label: 'Button label' },
188
+ buttonHref: { type: 'text', label: 'Button link' },
189
+ },
190
+ defaultProps: {
191
+ title: 'Ready to get started?',
192
+ text: 'Tell the reader what happens next and why it is worth their time.',
193
+ buttonLabel: 'Contact us',
194
+ buttonHref: '#',
195
+ },
196
+ // `sw-cta--band` and `sw-cta--card` stay on the two looks this block had before styles, so they render the same without the style rules.
197
+ render: ({ title, text, buttonLabel, buttonHref, style }) => (_jsx("section", { className: cx('sw-block', 'sw-cta', (!style || style === 'band' || style === 'card') && `sw-cta--${style || 'band'}`, styleClassFor('CallToAction', style)), children: _jsx("div", { className: "sw-container", children: _jsxs("div", { className: "sw-cta__box", children: [_jsx("h2", { className: "sw-cta__title", children: title }), text ? _jsx("p", { className: "sw-cta__text", children: text }) : null, buttonLabel ? (_jsx("div", { className: "sw-actions", children: _jsx(Button, { label: buttonLabel, href: buttonHref, variant: "primary" }) })) : null] }) }) })),
198
+ },
199
+ Cards: {
200
+ label: 'Cards',
201
+ fields: {
202
+ cards: {
203
+ type: 'array',
204
+ label: 'Cards',
205
+ min: 1,
206
+ max: 12,
207
+ getItemSummary: (item, i) => item.title || `Card ${(i ?? 0) + 1}`,
208
+ arrayFields: {
209
+ title: { type: 'text', label: 'Title', contentEditable: true },
210
+ text: { type: 'textarea', label: 'Text', contentEditable: true },
211
+ href: { type: 'text', label: 'Link', placeholder: '/page or https://...' },
212
+ imageUrl: { type: 'text', label: 'Image URL', placeholder: '/media/...' },
213
+ },
214
+ defaultItemProps: { title: 'Card title', text: 'A short description.', href: '', imageUrl: '' },
215
+ },
216
+ columns: {
217
+ type: 'radio',
218
+ label: 'Columns',
219
+ options: [
220
+ { label: '2', value: 2 },
221
+ { label: '3', value: 3 },
222
+ { label: '4', value: 4 },
223
+ ],
224
+ },
225
+ titleLevel: {
226
+ type: 'radio',
227
+ label: 'Title level',
228
+ options: [
229
+ { label: 'H2', value: 'h2' },
230
+ { label: 'H3', value: 'h3' },
231
+ ],
232
+ },
233
+ },
234
+ defaultProps: {
235
+ cards: [
236
+ { title: 'First point', text: 'Explain one benefit in a sentence or two.', href: '', imageUrl: '' },
237
+ { title: 'Second point', text: 'Explain another benefit in a sentence or two.', href: '', imageUrl: '' },
238
+ { title: 'Third point', text: 'Explain a third benefit in a sentence or two.', href: '', imageUrl: '' },
239
+ ],
240
+ columns: 3,
241
+ titleLevel: 'h3',
242
+ },
243
+ render: ({ cards, columns, titleLevel, style }) => {
244
+ const Title = titleLevel === 'h2' ? 'h2' : 'h3';
245
+ return (_jsx("section", { className: cx('sw-block', 'sw-cards', `sw-cards--${columns}`, styleClassFor('Cards', style)), children: _jsx("div", { className: "sw-container", children: _jsx("ul", { className: "sw-cards__grid", children: (cards ?? []).map((card, i) => {
246
+ const linked = Boolean(card.href);
247
+ return (_jsxs("li", { className: cx('sw-card', linked && 'sw-card--link'), children: [card.imageUrl ? _jsx("img", { className: "sw-card__image", src: card.imageUrl, alt: "" }) : null, _jsxs("div", { className: "sw-card__body", children: [_jsx(Title, { className: "sw-card__title", children: linked ? _jsx("a", { href: card.href, children: card.title }) : card.title }), card.text ? _jsx("p", { className: "sw-card__text", children: card.text }) : null, linked ? (_jsx("span", { className: "sw-card__more", "aria-hidden": "true", children: "Read more \u2192" })) : null] })] }, i));
248
+ }) }) }) }));
249
+ },
250
+ },
251
+ // ----- Content -----
252
+ Heading: {
253
+ label: 'Heading',
254
+ fields: {
255
+ text: { type: 'text', label: 'Text', contentEditable: true },
256
+ level: {
257
+ type: 'select',
258
+ label: 'Level',
259
+ options: [
260
+ { label: 'H1', value: 'h1' },
261
+ { label: 'H2', value: 'h2' },
262
+ { label: 'H3', value: 'h3' },
263
+ { label: 'H4', value: 'h4' },
264
+ ],
265
+ },
266
+ align: { type: 'radio', label: 'Alignment', options: textAlignOptions },
267
+ },
268
+ defaultProps: { text: 'Section heading', level: 'h2', align: 'left' },
269
+ render: ({ text, level, align, style }) => {
270
+ const Tag = level;
271
+ return (_jsx("section", { className: cx('sw-block', 'sw-heading', `sw-align-${align}`, styleClassFor('Heading', style)), children: _jsx("div", { className: "sw-container", children: _jsx(Tag, { className: "sw-heading__text", children: text }) }) }));
272
+ },
273
+ },
274
+ Text: {
275
+ label: 'Text',
276
+ fields: {
277
+ content: { type: 'textarea', label: 'Content' },
278
+ format: {
279
+ type: 'select',
280
+ label: 'Format',
281
+ options: [
282
+ { label: 'Paragraphs (plain text, blank line = new paragraph)', value: 'paragraphs' },
283
+ { label: 'HTML', value: 'html' },
284
+ ],
285
+ },
286
+ size: {
287
+ type: 'radio',
288
+ label: 'Size',
289
+ options: [
290
+ { label: 'Normal', value: 'normal' },
291
+ { label: 'Lead', value: 'lead' },
292
+ ],
293
+ },
294
+ align: { type: 'radio', label: 'Alignment', options: textAlignOptions },
295
+ },
296
+ // New blocks start as HTML: the page builder edits it visually, with an HTML view for people who want the markup.
297
+ defaultProps: {
298
+ content: '<p>Write a paragraph here.</p><p>This is a second paragraph.</p>',
299
+ format: 'html',
300
+ size: 'normal',
301
+ align: 'left',
302
+ },
303
+ // Content without tags renders as paragraphs whatever the format says (an AI layout or API writer that left the format
304
+ // out gets the HTML default), so its blank lines still start paragraphs.
305
+ // `content` is a string everywhere the page renders. Only on the page builder's canvas, where the admin makes it a rich
306
+ // text field edited in place, Puck hands over its own editor instead (admin src/screens/content/textBlock.tsx).
307
+ render: ({ content, format, size, align, style }) => (_jsx("section", { className: cx('sw-block', 'sw-text', `sw-text--${size}`, `sw-align-${align}`, styleClassFor('Text', style)), children: _jsx("div", { className: "sw-container", children: content !== null && content !== undefined && typeof content !== 'string' ? (_jsx("div", { className: "sw-prose sw-prose--editing", children: content })) : format === 'html' && !isPlainText(content ?? '') ? (_jsx("div", { className: "sw-prose", dangerouslySetInnerHTML: { __html: keyboardScrollable(sanitizeTextHtml(content ?? '')) } })) : (_jsx("div", { className: "sw-prose", children: paragraphs(content ?? '') })) }) })),
308
+ },
309
+ Image: {
310
+ label: 'Image',
311
+ fields: {
312
+ src: { type: 'text', label: 'Image URL', placeholder: '/media/<id>/<filename>' },
313
+ alt: { type: 'text', label: 'Alt text (required)', placeholder: 'Describe the image' },
314
+ caption: { type: 'text', label: 'Caption', contentEditable: true },
315
+ width: {
316
+ type: 'radio',
317
+ label: 'Width',
318
+ options: [
319
+ { label: 'Normal', value: 'normal' },
320
+ { label: 'Wide', value: 'wide' },
321
+ { label: 'Full', value: 'full' },
322
+ ],
323
+ },
324
+ rounded: { type: 'radio', label: 'Rounded corners', options: yesNo },
325
+ },
326
+ defaultProps: { src: '', alt: '', caption: '', width: 'normal', rounded: true },
327
+ render: ({ src, alt, caption, width, rounded, media }) => (_jsx("section", { className: cx('sw-block', 'sw-image', `sw-image--${width}`, rounded && 'sw-image--rounded'), children: _jsx("div", { className: cx(width === 'full' ? undefined : 'sw-container', width === 'wide' && 'sw-container--wide'), children: _jsxs("figure", { className: "sw-image__figure", children: [src ? (_jsx(ResponsiveImage, { className: "sw-image__img", src: src, alt: alt ?? '', media: media, sizes: width === 'normal' ? '(max-width: 1120px) 100vw, 1120px' : width === 'wide' ? WIDE_SIZES : '100vw' })) : (_jsx("div", { className: "sw-image__img sw-image__placeholder", role: "img", "aria-label": "No image selected" })), caption ? _jsx("figcaption", { className: "sw-image__caption", children: caption }) : null] }) }) })),
328
+ },
329
+ Gallery: galleryComponent,
330
+ Faq: faqComponent,
331
+ Testimonials: testimonialsComponent,
332
+ Stats: statsComponent,
333
+ LogoStrip: logoStripComponent,
334
+ Scrollytelling: scrollytellingComponent,
335
+ Lottie: lottieComponent,
336
+ Model3D: model3dComponent,
337
+ Search: searchComponent,
338
+ Ask: askComponent,
339
+ Menu: menuBlockComponent,
340
+ Embed: {
341
+ label: 'Embed',
342
+ fields: {
343
+ html: { type: 'textarea', label: 'Embed HTML', placeholder: '<iframe src="https://www.youtube.com/embed/..."></iframe>' },
344
+ caption: { type: 'text', label: 'Caption' },
345
+ },
346
+ defaultProps: { html: '', caption: '' },
347
+ render: ({ html, caption, allowedHosts, consent }) => {
348
+ const clean = sanitizeEmbedHtml(html ?? '', Array.isArray(allowedHosts) && allowedHosts.length ? allowedHosts : DEFAULT_EMBED_HOSTS);
349
+ // With the consent banner on, a third-party frame waits behind a notice until the visitor allows it (docs/blocks.md, Embed).
350
+ const held = consent ? holdEmbedHtml(clean) : { html: clean, sources: [] };
351
+ const host = held.sources.length ? hostOf(held.sources[0]) : '';
352
+ return (_jsx("section", { className: "sw-block sw-embed", children: _jsxs("div", { className: "sw-container", children: [_jsx("div", { className: "sw-embed__frame", dangerouslySetInnerHTML: { __html: held.html } }), held.sources.length ? (_jsxs("div", { className: "sw-embed__consent", "data-sw-consent-notice": "", children: [_jsxs("p", { className: "sw-embed__consent-text", children: ["This content is hosted by ", host || 'another site', ", which may set cookies. It loads when you allow marketing and embedded content."] }), _jsxs("div", { className: "sw-embed__consent-actions", children: [_jsx("button", { type: "button", className: "sw-button sw-button--primary", "data-sw-consent-load": "", children: "Load content" }), _jsxs("a", { className: "sw-embed__consent-link", href: held.sources[0], target: "_blank", rel: "noopener noreferrer", children: ["Open on ", host || 'the original site'] })] })] })) : null, caption ? _jsx("p", { className: "sw-embed__caption", children: caption }) : null] }) }));
353
+ },
354
+ },
355
+ Button: {
356
+ label: 'Button',
357
+ fields: {
358
+ label: { type: 'text', label: 'Label' },
359
+ href: { type: 'text', label: 'Link' },
360
+ align: { type: 'radio', label: 'Alignment', options: textAlignOptions },
361
+ },
362
+ defaultProps: { label: 'Learn more', href: '#', align: 'left' },
363
+ // The emphasis comes from the style; the old `variant` only picks the style of a Button saved without one.
364
+ render: ({ label, href, variant, align, style }) => (_jsx("section", { className: cx('sw-block', 'sw-button-block', `sw-align-${align}`, styleClassFor('Button', style || (variant === 'secondary' ? 'secondary' : ''))), children: _jsx("div", { className: "sw-container", children: _jsx("div", { className: "sw-actions", children: _jsx(Button, { label: label, href: href, variant: variant === 'secondary' ? 'secondary' : 'primary' }) }) }) })),
365
+ },
366
+ Buttons: {
367
+ label: 'Buttons',
368
+ fields: {
369
+ buttons: {
370
+ type: 'array',
371
+ label: 'Buttons',
372
+ min: 1,
373
+ max: 4,
374
+ getItemSummary: (item, i) => item.label || `Button ${(i ?? 0) + 1}`,
375
+ arrayFields: {
376
+ label: { type: 'text', label: 'Label' },
377
+ href: { type: 'text', label: 'Link', placeholder: '/page or https://...' },
378
+ emphasis: {
379
+ type: 'radio',
380
+ label: 'Emphasis',
381
+ options: [
382
+ { label: 'Primary', value: 'primary' },
383
+ { label: 'Secondary', value: 'secondary' },
384
+ { label: 'Text link', value: 'link' },
385
+ ],
386
+ },
387
+ newTab: { type: 'radio', label: 'Open in a new tab', options: yesNo },
388
+ },
389
+ defaultItemProps: { label: 'Learn more', href: '', emphasis: 'secondary', newTab: false },
390
+ },
391
+ align: { type: 'radio', label: 'Alignment', options: textAlignOptions },
392
+ },
393
+ defaultProps: {
394
+ buttons: [
395
+ { label: 'Get started', href: '', emphasis: 'primary', newTab: false },
396
+ { label: 'Learn more', href: '', emphasis: 'secondary', newTab: false },
397
+ ],
398
+ align: 'left',
399
+ },
400
+ render: ({ buttons, align }) => (_jsx("section", { className: cx('sw-block', 'sw-button-block', 'sw-buttons', `sw-align-${align}`), children: _jsx("div", { className: "sw-container", children: _jsx("div", { className: "sw-actions", children: (buttons ?? []).map((b, i) => (_jsx(Button, { label: b.label, href: b.href, variant: b.emphasis === 'secondary' || b.emphasis === 'link' ? b.emphasis : 'primary', newTab: b.newTab === true }, i))) }) }) })),
401
+ },
402
+ // ----- Layout -----
403
+ Section: {
404
+ label: 'Section',
405
+ fields: {
406
+ content: { type: 'slot', label: 'Content' },
407
+ background: {
408
+ type: 'select',
409
+ label: 'Background',
410
+ options: [
411
+ { label: 'Page background', value: 'none' },
412
+ { label: 'Surface', value: 'surface' },
413
+ { label: 'Primary color', value: 'primary' },
414
+ { label: 'Secondary color', value: 'secondary' },
415
+ { label: 'Dark', value: 'dark' },
416
+ ],
417
+ },
418
+ width: {
419
+ type: 'radio',
420
+ label: 'Width',
421
+ options: [
422
+ { label: 'Narrow', value: 'narrow' },
423
+ { label: 'Normal', value: 'normal' },
424
+ { label: 'Wide', value: 'wide' },
425
+ ],
426
+ },
427
+ },
428
+ defaultProps: { content: [], background: 'surface', width: 'normal' },
429
+ render: ({ content: Content, background, width }) => {
430
+ const bg = ['surface', 'primary', 'secondary', 'dark'].includes(background) ? background : 'none';
431
+ return (_jsx("section", { className: cx('sw-block', 'sw-section', `sw-section--bg-${bg}`, bg !== 'none' && 'sw-section--filled', (bg === 'primary' || bg === 'secondary' || bg === 'dark') && 'sw-section--on-dark'), children: _jsx("div", { className: cx('sw-container', width === 'narrow' && 'sw-container--narrow', width === 'wide' && 'sw-container--wide'), children: _jsx(Content, { className: "sw-section__body" }) }) }));
432
+ },
433
+ },
434
+ Columns: {
435
+ label: 'Columns',
436
+ fields: {
437
+ columns: {
438
+ type: 'array',
439
+ label: 'Columns',
440
+ min: 2,
441
+ max: 4,
442
+ getItemSummary: (_item, i) => `Column ${(i ?? 0) + 1}`,
443
+ arrayFields: {
444
+ content: { type: 'slot', label: 'Content' },
445
+ },
446
+ defaultItemProps: { content: [] },
447
+ },
448
+ ratio: {
449
+ type: 'select',
450
+ label: 'Widths (two columns)',
451
+ options: [
452
+ { label: 'Equal', value: 'equal' },
453
+ { label: 'Wide first (2:1)', value: 'wide-left' },
454
+ { label: 'Wide second (1:2)', value: 'wide-right' },
455
+ ],
456
+ },
457
+ gap: {
458
+ type: 'radio',
459
+ label: 'Gap',
460
+ options: [
461
+ { label: 'S', value: 's' },
462
+ { label: 'M', value: 'normal' },
463
+ { label: 'L', value: 'l' },
464
+ ],
465
+ },
466
+ valign: {
467
+ type: 'radio',
468
+ label: 'Vertical alignment',
469
+ options: [
470
+ { label: 'Top', value: 'top' },
471
+ { label: 'Center', value: 'center' },
472
+ { label: 'Bottom', value: 'bottom' },
473
+ ],
474
+ },
475
+ },
476
+ defaultProps: {
477
+ columns: [{ content: [] }, { content: [] }],
478
+ ratio: 'equal',
479
+ gap: 'normal',
480
+ valign: 'top',
481
+ },
482
+ render: ({ columns, gap, ratio, valign }) => {
483
+ const list = columns ?? [];
484
+ const count = Math.min(4, Math.max(2, list.length));
485
+ const g = gap === 's' || gap === 'l' ? gap : 'normal';
486
+ return (_jsx("section", { className: cx('sw-block', 'sw-columns', `sw-columns--${count}`, `sw-columns--gap-${g}`, count === 2 && (ratio === 'wide-left' || ratio === 'wide-right') && `sw-columns--${ratio}`, (valign === 'center' || valign === 'bottom') && `sw-columns--valign-${valign}`), children: _jsx("div", { className: "sw-container", children: _jsx("div", { className: "sw-columns__grid", children: list.map((column, i) => {
487
+ const Content = column.content;
488
+ return _jsx(Content, { className: "sw-column" }, i);
489
+ }) }) }) }));
490
+ },
491
+ },
492
+ Spacer: {
493
+ label: 'Spacer',
494
+ fields: {
495
+ size: {
496
+ type: 'radio',
497
+ label: 'Size',
498
+ options: [
499
+ { label: 'S', value: 's' },
500
+ { label: 'M', value: 'm' },
501
+ { label: 'L', value: 'l' },
502
+ { label: 'XL', value: 'xl' },
503
+ ],
504
+ },
505
+ },
506
+ defaultProps: { size: 'm' },
507
+ render: ({ size }) => _jsx("div", { className: cx('sw-block', 'sw-spacer', `sw-spacer--${size}`), "aria-hidden": "true" }),
508
+ },
509
+ Divider: {
510
+ label: 'Divider',
511
+ fields: {
512
+ width: {
513
+ type: 'radio',
514
+ label: 'Width',
515
+ options: [
516
+ { label: 'Normal', value: 'normal' },
517
+ { label: 'Narrow', value: 'narrow' },
518
+ ],
519
+ },
520
+ },
521
+ defaultProps: { width: 'normal' },
522
+ render: ({ width }) => (_jsx("div", { className: "sw-block sw-divider", children: _jsx("div", { className: cx('sw-container', width === 'narrow' && 'sw-container--narrow'), children: _jsx("hr", { className: "sw-divider__rule" }) }) })),
523
+ },
524
+ },
525
+ };
526
+ // ---------- Space above and below ----------
527
+ /**
528
+ * Every layout, content and marketing block gets a Space above and a Space below field. The step's class goes on the
529
+ * block's own root element (merged into its className), so blocks stay siblings and the automatic rhythm between them
530
+ * still applies when the field is Auto. Spacer is spacing already, and Shared renders another page's blocks.
531
+ */
532
+ const SPACE_STEPS = ['auto', 'none', 's', 'm', 'l', 'xl'];
533
+ const spaceOptions = [
534
+ { label: 'Auto', value: 'auto' },
535
+ { label: 'None', value: 'none' },
536
+ { label: 'S', value: 's' },
537
+ { label: 'M', value: 'm' },
538
+ { label: 'L', value: 'l' },
539
+ { label: 'XL', value: 'xl' },
540
+ ];
541
+ export const SPACED_BLOCKS = ['Section', 'Columns', 'Divider', 'Heading', 'Text', 'Image', 'Gallery', 'Search', 'Ask', 'Embed', 'Lottie', 'Model3D', 'Button', 'Buttons', 'Hero', 'CallToAction', 'Cards', 'Faq', 'Testimonials', 'Stats', 'LogoStrip', 'Scrollytelling', 'Collection', 'Calendar', 'Form'];
542
+ /** The classes for a block's Space above and Space below; unknown values are ignored. */
543
+ export function spacingClasses(props) {
544
+ const out = [];
545
+ const above = props?.spaceAbove;
546
+ const below = props?.spaceBelow;
547
+ if (above && above !== 'auto' && SPACE_STEPS.includes(above))
548
+ out.push(`sw-space-above-${above}`);
549
+ if (below && below !== 'auto' && SPACE_STEPS.includes(below))
550
+ out.push(`sw-space-below-${below}`);
551
+ return out.join(' ');
552
+ }
553
+ /** Blocks whose items (cards, images, logos, quotes, buttons, list items) can arrive one after another and respond to hover. */
554
+ export const MOTION_ITEM_BLOCKS = ['Image', 'Gallery', 'Buttons', 'Button', 'Cards', 'Faq', 'Testimonials', 'Stats', 'LogoStrip', 'Collection'];
555
+ const ENTRANCE_LABELS = { none: 'None', fade: 'Fade in', rise: 'Rise', scale: 'Scale up', 'slide-left': 'Slide from the left', 'slide-right': 'Slide from the right' };
556
+ /** Blocks with a background image that parallax can move. */
557
+ export const MOTION_PARALLAX_BLOCKS = ['Hero'];
558
+ const SCROLL_LABELS = { none: 'None', parallax: 'Parallax background', 'fade-out': 'Fade out as it leaves', pin: 'Pin while the next blocks scroll over' };
559
+ const HOVER_LABELS = { none: 'None', lift: 'Lift', zoom: 'Zoom the image', tilt: 'Tilt (expressive brands only)' };
560
+ const DELAYS = ['none', 'short', 'medium'];
561
+ /**
562
+ * A block's Motion settings as attributes on its root element (docs/dev/motion.md): `data-motion` (the entrance), `data-motion-delay`,
563
+ * `data-motion-stagger` and `data-motion-hover`. Unknown values are dropped. Nothing moves until the page's motion script arms them,
564
+ * and only when the brand's motion level is not off and the visitor has not asked for reduced motion.
565
+ */
566
+ export function motionAttributes(motion, itemBlock, parallaxBlock = false) {
567
+ if (!motion || typeof motion !== 'object')
568
+ return {};
569
+ const out = {};
570
+ if (motion.entrance && motion.entrance !== 'none' && MOTION_ENTRANCES.includes(motion.entrance)) {
571
+ out['data-motion'] = motion.entrance;
572
+ if (motion.delay && motion.delay !== 'none' && DELAYS.includes(motion.delay))
573
+ out['data-motion-delay'] = motion.delay;
574
+ if (itemBlock && motion.stagger === true)
575
+ out['data-motion-stagger'] = '';
576
+ }
577
+ if (itemBlock && motion.hover && motion.hover !== 'none' && MOTION_HOVERS.includes(motion.hover))
578
+ out['data-motion-hover'] = motion.hover;
579
+ if (motion.scroll && motion.scroll !== 'none' && MOTION_SCROLLS.includes(motion.scroll) && (motion.scroll !== 'parallax' || parallaxBlock))
580
+ out['data-motion-scroll'] = motion.scroll;
581
+ return out;
582
+ }
583
+ /** Blocks that need the motion script when the brand's motion is on (it arms them; without it they stay as they render on the server). */
584
+ export const MOTION_SCRIPT_BLOCKS = ['Scrollytelling', 'Lottie', 'Model3D'];
585
+ /** Blocks whose self-hosted player the motion script loads whatever the motion level: the page carries the script for them. */
586
+ export const PLAYER_BLOCKS = ['Lottie', 'Model3D'];
587
+ /**
588
+ * Whether a block asks for any motion (the page then carries the motion script): Motion settings, Stats that count up, a marquee,
589
+ * a Hero's video, or a block in MOTION_SCRIPT_BLOCKS (pass its type).
590
+ */
591
+ export function hasMotion(props, type) {
592
+ if (type && MOTION_SCRIPT_BLOCKS.includes(type))
593
+ return true;
594
+ // A module block resolved as a scene (its props carry `scene`).
595
+ if (type === 'ModuleBlock' && props?.scene)
596
+ return true;
597
+ const m = props?.motion;
598
+ if (m && ((m.entrance && m.entrance !== 'none') || (m.hover && m.hover !== 'none') || (m.scroll && m.scroll !== 'none')))
599
+ return true;
600
+ return props?.countUp === true || props?.marquee === true || Boolean(props?.backgroundVideo && props?.backgroundImage);
601
+ }
602
+ for (const name of SPACED_BLOCKS) {
603
+ const component = config.components[name];
604
+ const itemBlock = MOTION_ITEM_BLOCKS.includes(name);
605
+ const parallaxBlock = MOTION_PARALLAX_BLOCKS.includes(name);
606
+ component.fields = {
607
+ ...component.fields,
608
+ spaceAbove: { type: 'select', label: 'Space above', options: spaceOptions },
609
+ spaceBelow: { type: 'select', label: 'Space below', options: spaceOptions },
610
+ motion: {
611
+ type: 'object',
612
+ label: 'Motion',
613
+ objectFields: {
614
+ entrance: { type: 'select', label: 'Entrance', options: MOTION_ENTRANCES.map((v) => ({ label: ENTRANCE_LABELS[v] ?? v, value: v })) },
615
+ delay: { type: 'select', label: 'Delay', options: [{ label: 'None', value: 'none' }, { label: 'Short', value: 'short' }, { label: 'Medium', value: 'medium' }] },
616
+ ...(itemBlock
617
+ ? {
618
+ stagger: { type: 'radio', label: 'Items one after another', options: [{ label: 'Off', value: false }, { label: 'On', value: true }] },
619
+ hover: { type: 'select', label: 'On hover', options: MOTION_HOVERS.map((v) => ({ label: HOVER_LABELS[v] ?? v, value: v })) },
620
+ }
621
+ : {}),
622
+ scroll: { type: 'select', label: 'On scroll', options: MOTION_SCROLLS.filter((v) => v !== 'parallax' || parallaxBlock).map((v) => ({ label: SCROLL_LABELS[v] ?? v, value: v })) },
623
+ },
624
+ },
625
+ };
626
+ component.defaultProps = { ...component.defaultProps, spaceAbove: 'auto', spaceBelow: 'auto' };
627
+ const render = component.render;
628
+ component.render = (props) => {
629
+ const el = render(props);
630
+ const extra = spacingClasses(props);
631
+ const motion = motionAttributes(props.motion, itemBlock, parallaxBlock);
632
+ if ((!extra && !Object.keys(motion).length) || !isValidElement(el))
633
+ return el;
634
+ const element = el;
635
+ return cloneElement(element, { className: cx(element.props.className, extra) || undefined, ...motion });
636
+ };
637
+ }
638
+ //# sourceMappingURL=config.js.map