payload-canvas 0.2.0 → 0.4.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.
- package/README.md +500 -25
- package/dist/admin/diff/changes.js +8 -0
- package/dist/admin/editor/Inspector.js +49 -4
- package/dist/admin/editor/Outline.js +12 -10
- package/dist/admin/editor/actions.d.ts +9 -1
- package/dist/admin/editor/actions.js +38 -3
- package/dist/admin/editor/empty/EmptyStart.js +29 -3
- package/dist/admin/editor/fields/GroupField.d.ts +5 -2
- package/dist/admin/editor/fields/GroupField.js +6 -2
- package/dist/admin/editor/fields/WhereField.d.ts +17 -0
- package/dist/admin/editor/fields/WhereField.js +67 -0
- package/dist/admin/editor/fields/fields.scss +89 -0
- package/dist/admin/editor/fields/whereRows.d.ts +28 -0
- package/dist/admin/editor/fields/whereRows.js +118 -0
- package/dist/admin/editor/icons.d.ts +1 -0
- package/dist/admin/editor/icons.js +2 -0
- package/dist/admin/editor/locale/LocaleField.d.ts +1 -1
- package/dist/admin/editor/locale/LocaleField.js +3 -1
- package/dist/admin/editor/menu/blockMenu.js +5 -1
- package/dist/admin/editor/motion/MotionPanel.js +1 -1
- package/dist/admin/editor/motion/model.js +2 -2
- package/dist/admin/editor/renderField.d.ts +3 -1
- package/dist/admin/editor/renderField.js +13 -4
- package/dist/admin/editor/runtime.js +1 -0
- package/dist/admin/editor/styles/SiteClasses.d.ts +9 -0
- package/dist/admin/editor/styles/SiteClasses.js +31 -0
- package/dist/admin/editor/styles/StylesPanel.d.ts +3 -1
- package/dist/admin/editor/styles/StylesPanel.js +9 -6
- package/dist/admin/editor/styles/context.d.ts +9 -2
- package/dist/admin/editor/styles/context.js +14 -9
- package/dist/admin/editor/styles/controls.js +2 -2
- package/dist/admin/editor/styles/sections.js +1 -1
- package/dist/admin/editor/styles/styles.scss +54 -0
- package/dist/admin/editor/templates/Bindable.d.ts +13 -5
- package/dist/admin/editor/templates/Bindable.js +73 -17
- package/dist/admin/editor/templates/binding.d.ts +11 -4
- package/dist/admin/editor/templates/binding.js +23 -3
- package/dist/ai/prompt.js +8 -2
- package/dist/ai/tools.js +11 -2
- package/dist/blocks/builtins/carousel.d.ts +32 -0
- package/dist/blocks/builtins/carousel.js +122 -0
- package/dist/blocks/builtins/disclosure.d.ts +13 -0
- package/dist/blocks/builtins/disclosure.js +107 -0
- package/dist/blocks/builtins/faq.d.ts +17 -0
- package/dist/blocks/builtins/faq.js +88 -0
- package/dist/blocks/builtins/filterLink.d.ts +22 -0
- package/dist/blocks/builtins/filterLink.js +76 -0
- package/dist/blocks/builtins/headingId.d.ts +15 -0
- package/dist/blocks/builtins/headingId.js +36 -0
- package/dist/blocks/builtins/icon.d.ts +8 -0
- package/dist/blocks/builtins/icon.js +45 -0
- package/dist/blocks/builtins/index.d.ts +35 -0
- package/dist/blocks/builtins/index.js +50 -0
- package/dist/blocks/builtins/lightbox.d.ts +43 -0
- package/dist/blocks/builtins/lightbox.js +93 -0
- package/dist/blocks/builtins/mediaBackdrop.d.ts +11 -0
- package/dist/blocks/builtins/mediaBackdrop.js +79 -0
- package/dist/blocks/builtins/sectionRef.d.ts +26 -0
- package/dist/blocks/builtins/sectionRef.js +78 -0
- package/dist/blocks/builtins/shared.d.ts +33 -0
- package/dist/blocks/builtins/shared.js +70 -0
- package/dist/blocks/builtins/tableOfContents.d.ts +3 -0
- package/dist/blocks/builtins/tableOfContents.js +44 -0
- package/dist/blocks/defaults.d.ts +19 -1
- package/dist/blocks/defaults.js +413 -20
- package/dist/blocks/index.d.ts +4 -2
- package/dist/blocks/index.js +3 -1
- package/dist/core/attrs.d.ts +27 -0
- package/dist/core/attrs.js +132 -0
- package/dist/core/bindings.d.ts +122 -11
- package/dist/core/bindings.js +504 -19
- package/dist/core/blocks.d.ts +46 -1
- package/dist/core/blocks.js +136 -0
- package/dist/core/classes.d.ts +10 -2
- package/dist/core/classes.js +34 -5
- package/dist/core/headings.d.ts +21 -0
- package/dist/core/headings.js +47 -0
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +4 -2
- package/dist/core/motion.d.ts +18 -9
- package/dist/core/motion.js +20 -12
- package/dist/core/operations.js +59 -2
- package/dist/core/payloadBlocks.js +3 -1
- package/dist/core/schema.js +20 -0
- package/dist/core/tree.js +24 -1
- package/dist/core/types.d.ts +87 -0
- package/dist/core/validate.js +29 -4
- package/dist/css/tokens.d.ts +6 -3
- package/dist/css/tokens.js +48 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +50 -13
- package/dist/mcp/shared.d.ts +3 -0
- package/dist/mcp/shared.js +23 -8
- package/dist/plugin/index.d.ts +8 -0
- package/dist/plugin/index.js +26 -8
- package/dist/plugin/listCollections.d.ts +17 -2
- package/dist/plugin/listCollections.js +44 -7
- package/dist/plugin/references.d.ts +5 -0
- package/dist/plugin/references.js +1 -1
- package/dist/plugin/templates.d.ts +4 -0
- package/dist/plugin/templates.js +23 -4
- package/dist/protocol/index.d.ts +2 -0
- package/dist/react/canvas/BuilderCanvas.js +5 -3
- package/dist/react/canvas/fetchDocs.d.ts +16 -2
- package/dist/react/canvas/fetchDocs.js +42 -9
- package/dist/react/canvas/measure.d.ts +3 -1
- package/dist/react/canvas/measure.js +26 -2
- package/dist/react/canvas/resolveLayout.d.ts +1 -1
- package/dist/react/canvas/resolveLayout.js +17 -6
- package/dist/react/canvas/serverBlocks.d.ts +11 -0
- package/dist/react/canvas/serverBlocks.js +28 -1
- package/dist/react/components/Button.d.ts +11 -2
- package/dist/react/components/Button.js +43 -6
- package/dist/react/components/CollectionList.d.ts +6 -3
- package/dist/react/components/CollectionList.js +21 -7
- package/dist/react/components/Container.js +4 -1
- package/dist/react/components/Field.js +13 -2
- package/dist/react/components/Heading.js +9 -2
- package/dist/react/components/Image.d.ts +9 -0
- package/dist/react/components/Image.js +16 -1
- package/dist/react/components/List.d.ts +1 -0
- package/dist/react/components/List.js +6 -0
- package/dist/react/components/Menu.d.ts +16 -0
- package/dist/react/components/Menu.js +83 -19
- package/dist/react/components/RichText.d.ts +8 -3
- package/dist/react/components/RichText.js +25 -4
- package/dist/react/components/builtins/Accordion.d.ts +9 -0
- package/dist/react/components/builtins/Accordion.js +37 -0
- package/dist/react/components/builtins/BackdropVideo.d.ts +13 -0
- package/dist/react/components/builtins/BackdropVideo.js +16 -0
- package/dist/react/components/builtins/Carousel.d.ts +13 -0
- package/dist/react/components/builtins/Carousel.js +134 -0
- package/dist/react/components/builtins/Disclosure.d.ts +7 -0
- package/dist/react/components/builtins/Disclosure.js +13 -0
- package/dist/react/components/builtins/FilterLink.d.ts +8 -0
- package/dist/react/components/builtins/FilterLink.js +30 -0
- package/dist/react/components/builtins/Icon.d.ts +14 -0
- package/dist/react/components/builtins/Icon.js +28 -0
- package/dist/react/components/builtins/Lightbox.d.ts +45 -0
- package/dist/react/components/builtins/Lightbox.js +252 -0
- package/dist/react/components/builtins/MediaBackdrop.d.ts +14 -0
- package/dist/react/components/builtins/MediaBackdrop.js +61 -0
- package/dist/react/components/builtins/SectionRef.d.ts +7 -0
- package/dist/react/components/builtins/SectionRef.js +17 -0
- package/dist/react/components/builtins/TableOfContents.d.ts +7 -0
- package/dist/react/components/builtins/TableOfContents.js +21 -0
- package/dist/react/components/builtins/glyphs.d.ts +8 -0
- package/dist/react/components/builtins/glyphs.js +7 -0
- package/dist/react/components/builtins/index.d.ts +32 -0
- package/dist/react/components/builtins/index.js +36 -0
- package/dist/react/components/index.js +2 -0
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.js +3 -1
- package/dist/react/motion/runtime.js +10 -6
- package/dist/react/render/RenderLayout.d.ts +1 -1
- package/dist/react/render/RenderLayout.js +76 -23
- package/dist/react/render/lists.d.ts +107 -5
- package/dist/react/render/lists.js +284 -9
- package/dist/react/render/resolve.d.ts +22 -2
- package/dist/react/render/resolve.js +45 -22
- package/dist/react/render/sections.d.ts +9 -0
- package/dist/react/render/sections.js +51 -0
- package/dist/react/render/types.d.ts +6 -1
- package/dist/react/server.d.ts +3 -1
- package/dist/react/server.js +53 -2
- package/dist/react/theme/ThemeStyle.d.ts +13 -2
- package/dist/react/theme/ThemeStyle.js +12 -2
- package/package.json +1 -1
package/dist/blocks/defaults.js
CHANGED
|
@@ -1,8 +1,39 @@
|
|
|
1
1
|
import { defineBlock } from '../core/blocks.js';
|
|
2
|
-
import { COLLECTION_LIST_BLOCK, FIELD_BLOCK, LIST_ITEM_SLOT } from '../core/bindings.js';
|
|
2
|
+
import { COLLECTION_LIST_BLOCK, FIELD_BLOCK, INDEX_PATH, ITEM_PATH, LIST_EMPTY_SLOT, LIST_ITEM_SLOT, PAGE_PATH, PARENT_PATH, REPEAT_BLOCK } from '../core/bindings.js';
|
|
3
3
|
import { TEXT_LIST_BLOCK, TEXT_LIST_ITEM_BLOCK, TEXT_LIST_SLOT } from '../core/textList.js';
|
|
4
4
|
import { BUILDER_CSS_CLASS } from '../css/marker.js';
|
|
5
5
|
import { linkField, when } from './link.js';
|
|
6
|
+
/** "arrowUpRight" -> "arrow up right". */
|
|
7
|
+
export const iconLabel = (name) => name.replace(/([A-Z])/g, ' $1').toLowerCase();
|
|
8
|
+
/** The button's icon props, for a site with an icon set (`defaultBlocks({ icons })`). */
|
|
9
|
+
function buttonIconFields(names) {
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
name: 'icon',
|
|
13
|
+
type: 'select',
|
|
14
|
+
label: 'Icon',
|
|
15
|
+
options: names.map((value) => ({ label: iconLabel(value), value })),
|
|
16
|
+
admin: { description: "Optional. An icon of the site's icon set next to the label. Screen readers skip it." },
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'iconPosition',
|
|
20
|
+
type: 'select',
|
|
21
|
+
label: 'Icon position',
|
|
22
|
+
defaultValue: 'end',
|
|
23
|
+
options: [
|
|
24
|
+
{ label: 'Before the label', value: 'start' },
|
|
25
|
+
{ label: 'After the label', value: 'end' },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'iconClassName',
|
|
30
|
+
type: 'text',
|
|
31
|
+
label: 'Icon classes',
|
|
32
|
+
defaultValue: 'size-4 shrink-0',
|
|
33
|
+
admin: { description: 'Tailwind classes of the icon, for example "size-5".', custom: { builderClasses: true } },
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
6
37
|
/** Block types a Link block may hold directly: content without its own links or controls. */
|
|
7
38
|
const LINK_CONTENT = ['stack', 'grid', 'heading', 'text', 'image', 'list', 'quote', 'divider', 'spacer', 'field'];
|
|
8
39
|
/**
|
|
@@ -39,6 +70,19 @@ export const MENU_CLASS_MAP = withMarker({
|
|
|
39
70
|
panelList: 'flex flex-col',
|
|
40
71
|
panelLink: 'flex min-h-12 items-center border-b border-border py-3 text-lg ' +
|
|
41
72
|
'aria-[current=page]:font-semibold aria-[current=page]:underline decoration-1 underline-offset-8',
|
|
73
|
+
/** A link with children (one level): a <details> dropdown next to, or in place of, the link. */
|
|
74
|
+
submenu: 'relative flex items-center gap-1',
|
|
75
|
+
submenuDetails: 'group/submenu',
|
|
76
|
+
submenuToggle: 'inline-flex cursor-pointer list-none items-center gap-1 py-2 opacity-75 transition-opacity hover:opacity-100 ' +
|
|
77
|
+
'aria-[current=true]:opacity-100 [&::-webkit-details-marker]:hidden',
|
|
78
|
+
submenuIcon: 'size-4 transition-transform group-open/submenu:rotate-180 motion-reduce:transition-none',
|
|
79
|
+
submenuList: 'absolute top-full left-0 z-50 flex min-w-48 flex-col border border-border bg-background p-2 text-foreground shadow-md',
|
|
80
|
+
submenuLink: 'flex min-h-10 items-center px-3 py-2 opacity-75 transition-opacity hover:opacity-100 ' +
|
|
81
|
+
'aria-[current=page]:opacity-100 aria-[current=page]:underline decoration-1 underline-offset-8',
|
|
82
|
+
/** The children of a link in the small-screen panel: a nested list. */
|
|
83
|
+
panelSubList: 'flex flex-col pl-4',
|
|
84
|
+
panelSubLink: 'flex min-h-11 items-center py-2 text-base ' +
|
|
85
|
+
'aria-[current=page]:font-semibold aria-[current=page]:underline decoration-1 underline-offset-8',
|
|
42
86
|
/** The optional button after the links in the panel. */
|
|
43
87
|
panelCta: 'mt-5 flex min-h-12 items-center justify-center rounded-full bg-primary px-6 text-base font-medium ' +
|
|
44
88
|
'text-primary-foreground transition-colors hover:bg-[color-mix(in_oklch,var(--color-primary),black_14%)]',
|
|
@@ -60,7 +104,7 @@ const FIELD_CLASSES = Object.values(FIELD_CLASS_MAP)
|
|
|
60
104
|
.filter((cls) => cls !== BUILDER_CSS_CLASS);
|
|
61
105
|
/**
|
|
62
106
|
* The built-in blocks: stack, grid, heading, text, richText, image, button, link, menu, list (with
|
|
63
|
-
* its listItem blocks), quote, divider, spacer, video, and the dynamic blocks field and
|
|
107
|
+
* its listItem blocks), quote, divider, spacer, video, and the dynamic blocks field, collectionList and repeat.
|
|
64
108
|
*/
|
|
65
109
|
export function defaultBlocks(options) {
|
|
66
110
|
const mediaCollection = (options?.mediaCollection ?? 'media');
|
|
@@ -87,6 +131,16 @@ export function defaultBlocks(options) {
|
|
|
87
131
|
{ label: 'Navigation (nav)', value: 'nav' },
|
|
88
132
|
{ label: 'Article or post (article)', value: 'article' },
|
|
89
133
|
{ label: 'Side note (aside)', value: 'aside' },
|
|
134
|
+
{ label: 'Numbered list (ol)', value: 'ol' },
|
|
135
|
+
{ label: 'Bullet list (ul)', value: 'ul' },
|
|
136
|
+
{ label: 'List item (li)', value: 'li' },
|
|
137
|
+
{ label: 'Term list (dl)', value: 'dl' },
|
|
138
|
+
{ label: 'Term (dt)', value: 'dt' },
|
|
139
|
+
{ label: 'Term description (dd)', value: 'dd' },
|
|
140
|
+
{ label: 'Figure (figure)', value: 'figure' },
|
|
141
|
+
{ label: 'Figure caption (figcaption)', value: 'figcaption' },
|
|
142
|
+
{ label: 'Paragraph (p)', value: 'p' },
|
|
143
|
+
{ label: 'Inline group (span)', value: 'span' },
|
|
90
144
|
],
|
|
91
145
|
defaultValue: 'div',
|
|
92
146
|
admin: {
|
|
@@ -99,7 +153,8 @@ export function defaultBlocks(options) {
|
|
|
99
153
|
defaultClassName: 'flex flex-col gap-4',
|
|
100
154
|
ai: {
|
|
101
155
|
description: 'A container that lays out its children in a column (or a row with "flex-row"). ' +
|
|
102
|
-
'Use it to group blocks and build sections. Set "as" to "section", "header", "footer" and so on for semantic HTML
|
|
156
|
+
'Use it to group blocks and build sections. Set "as" to "section", "header", "footer" and so on for semantic HTML; ' +
|
|
157
|
+
'"ol"/"ul" with "li" children for lists, "dl" with "dt"/"dd" for term lists, "figure" with "figcaption", "p" or "span" for text runs.',
|
|
103
158
|
example: {
|
|
104
159
|
type: 'stack',
|
|
105
160
|
props: { as: 'section' },
|
|
@@ -163,11 +218,21 @@ export function defaultBlocks(options) {
|
|
|
163
218
|
'Heading 2 for each section, and Heading 3 inside a section.',
|
|
164
219
|
},
|
|
165
220
|
},
|
|
221
|
+
{
|
|
222
|
+
name: 'accent',
|
|
223
|
+
type: 'text',
|
|
224
|
+
label: 'Accent words',
|
|
225
|
+
localized: true,
|
|
226
|
+
admin: {
|
|
227
|
+
description: 'Words of the heading to highlight, for example "Brisbane". They render as <em>; style them with classes like [&_em]:text-primary.',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
166
230
|
],
|
|
167
231
|
// `break-words`: a long word (a URL, a product code) wraps instead of widening the page.
|
|
168
232
|
defaultClassName: 'text-3xl font-bold break-words',
|
|
169
233
|
ai: {
|
|
170
|
-
description: 'A page or section heading. Use level "1" once per page, "2" for sections.'
|
|
234
|
+
description: 'A page or section heading. Use level "1" once per page, "2" for sections. "accent" names words of the text ' +
|
|
235
|
+
'to highlight: they render as <em>, styled with className variants such as "[&_em]:text-primary [&_em]:not-italic".',
|
|
171
236
|
example: { type: 'heading', props: { text: 'Our services', level: '2' }, className: 'text-3xl font-bold' },
|
|
172
237
|
},
|
|
173
238
|
});
|
|
@@ -188,11 +253,20 @@ export function defaultBlocks(options) {
|
|
|
188
253
|
label: 'Rich text',
|
|
189
254
|
icon: 'richText',
|
|
190
255
|
category: 'Content',
|
|
191
|
-
fields: [
|
|
256
|
+
fields: [
|
|
257
|
+
{ name: 'content', type: 'richText', label: 'Content', required: true, localized: true },
|
|
258
|
+
{
|
|
259
|
+
name: 'headingIds',
|
|
260
|
+
type: 'checkbox',
|
|
261
|
+
label: 'Heading ids',
|
|
262
|
+
admin: { description: 'Each heading gets an id from its text, so a table of contents can link to it ("#prices").' },
|
|
263
|
+
},
|
|
264
|
+
],
|
|
192
265
|
defaultClassName: 'prose',
|
|
193
266
|
ai: {
|
|
194
267
|
description: 'Formatted text (Lexical JSON): paragraphs, headings, bold and italic, links and lists. ' +
|
|
195
|
-
'Use it for articles and longer copy. The "prose" class styles the content.'
|
|
268
|
+
'Use it for articles and longer copy. The "prose" class styles the content. "headingIds": true gives each ' +
|
|
269
|
+
'heading an id from its text, for "#id" links.',
|
|
196
270
|
example: {
|
|
197
271
|
type: 'richText',
|
|
198
272
|
className: 'prose',
|
|
@@ -242,13 +316,28 @@ export function defaultBlocks(options) {
|
|
|
242
316
|
localized: true,
|
|
243
317
|
admin: { description: 'Describes the image for people who cannot see it. Leave empty to use the alt text saved with the image.' },
|
|
244
318
|
},
|
|
319
|
+
{
|
|
320
|
+
name: 'priority',
|
|
321
|
+
type: 'checkbox',
|
|
322
|
+
label: 'Load first',
|
|
323
|
+
admin: { description: 'For the main image at the top of the page: it loads at once with high priority instead of lazily.' },
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: 'sizes',
|
|
327
|
+
type: 'text',
|
|
328
|
+
label: 'Sizes',
|
|
329
|
+
admin: { description: 'The width the image shows at, for the browser to pick a file, for example "(min-width: 768px) 50vw, 100vw". Empty: the full width.' },
|
|
330
|
+
},
|
|
245
331
|
],
|
|
246
332
|
ai: {
|
|
247
333
|
description: `An image from the "${mediaCollection}" collection, stored by its document ID. ` +
|
|
248
|
-
'Without an image it renders nothing on the site.'
|
|
334
|
+
'Without an image it renders nothing on the site. Set "priority": true on the hero image (the largest image ' +
|
|
335
|
+
'at the top: it loads eagerly with fetchpriority high). "sizes" is the HTML sizes attribute, e.g. ' +
|
|
336
|
+
'"(min-width: 768px) 50vw, 100vw". The media focal point (focalX, focalY) sets object-position.',
|
|
249
337
|
example: { type: 'image', props: { image: 1, alt: 'Team photo' }, className: 'w-full rounded-lg' },
|
|
250
338
|
},
|
|
251
339
|
});
|
|
340
|
+
const icons = options?.icons ?? [];
|
|
252
341
|
const button = defineBlock({
|
|
253
342
|
type: 'button',
|
|
254
343
|
label: 'Button',
|
|
@@ -257,11 +346,17 @@ export function defaultBlocks(options) {
|
|
|
257
346
|
fields: [
|
|
258
347
|
{ name: 'label', type: 'text', label: 'Label', required: true, localized: true },
|
|
259
348
|
linkField({ collections: linkCollections }),
|
|
349
|
+
...(icons.length > 0 ? buttonIconFields(icons) : []),
|
|
260
350
|
],
|
|
261
|
-
defaultClassName: 'inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground'
|
|
351
|
+
defaultClassName: 'inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground' +
|
|
352
|
+
(icons.length > 0 ? ' gap-2' : ''),
|
|
262
353
|
ai: {
|
|
263
354
|
description: 'A call-to-action button. "link.type" is "url" (set "link.url") or "reference" (set "link.reference" to ' +
|
|
264
|
-
'{ relationTo, value }). Without a link it renders as plain text.'
|
|
355
|
+
'{ relationTo, value }). Without a link it renders as plain text.' +
|
|
356
|
+
(icons.length > 0
|
|
357
|
+
? ` Optional "icon" (one of: ${icons.join(', ')}) shows an icon before ("iconPosition": "start") or after ` +
|
|
358
|
+
'("end", the default) the label; "iconClassName" sizes it (default "size-4 shrink-0").'
|
|
359
|
+
: ''),
|
|
265
360
|
example: {
|
|
266
361
|
type: 'button',
|
|
267
362
|
props: { label: 'Contact us', link: exampleLink },
|
|
@@ -277,11 +372,13 @@ export function defaultBlocks(options) {
|
|
|
277
372
|
fields: [linkField({ collections: linkCollections })],
|
|
278
373
|
// Interactive content inside <a> is invalid HTML. `allow` limits direct children; `disallow`
|
|
279
374
|
// refuses these types at any depth (a button inside a stack inside the link, for example).
|
|
280
|
-
|
|
375
|
+
// `allowInline`: custom blocks marked `inline: true` (an icon, a badge) may go in directly too.
|
|
376
|
+
slots: { children: { label: 'Content', allow: LINK_CONTENT, disallow: INTERACTIVE, allowInline: true } },
|
|
281
377
|
defaultClassName: 'block',
|
|
282
378
|
ai: {
|
|
283
379
|
description: 'A clickable container: everything inside it links to one place. Use it for cards that link to a page. ' +
|
|
284
|
-
`It holds only ${LINK_CONTENT.join(', ')} blocks
|
|
380
|
+
`It holds only ${LINK_CONTENT.join(', ')} blocks and the site's inline blocks (see the slot's accepted types), ` +
|
|
381
|
+
'and never links, buttons, forms, menus or lists of links.',
|
|
285
382
|
example: {
|
|
286
383
|
type: 'link',
|
|
287
384
|
props: { link: exampleLink },
|
|
@@ -309,6 +406,19 @@ export function defaultBlocks(options) {
|
|
|
309
406
|
fields: [
|
|
310
407
|
{ name: 'label', type: 'text', label: 'Label', required: true, localized: true },
|
|
311
408
|
linkField({ collections: linkCollections }),
|
|
409
|
+
{
|
|
410
|
+
name: 'children',
|
|
411
|
+
type: 'array',
|
|
412
|
+
label: 'Dropdown links',
|
|
413
|
+
admin: {
|
|
414
|
+
description: 'Optional. Links under this one (one level), shown in a dropdown. The link above is optional when it has ' +
|
|
415
|
+
'dropdown links: without it the label opens the dropdown.',
|
|
416
|
+
},
|
|
417
|
+
fields: [
|
|
418
|
+
{ name: 'label', type: 'text', label: 'Label', required: true, localized: true },
|
|
419
|
+
linkField({ collections: linkCollections }),
|
|
420
|
+
],
|
|
421
|
+
},
|
|
312
422
|
],
|
|
313
423
|
},
|
|
314
424
|
{
|
|
@@ -319,6 +429,24 @@ export function defaultBlocks(options) {
|
|
|
319
429
|
localized: true,
|
|
320
430
|
admin: { description: 'Read by screen readers, for example "Main" or "Footer".' },
|
|
321
431
|
},
|
|
432
|
+
{
|
|
433
|
+
name: 'toggleLabel',
|
|
434
|
+
type: 'text',
|
|
435
|
+
label: 'Menu button text',
|
|
436
|
+
defaultValue: 'Menu',
|
|
437
|
+
localized: true,
|
|
438
|
+
admin: { description: 'The text of the button that opens the links on small screens.' },
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
name: 'submenuLabel',
|
|
442
|
+
type: 'text',
|
|
443
|
+
label: 'Dropdown button name',
|
|
444
|
+
defaultValue: '{label} menu',
|
|
445
|
+
localized: true,
|
|
446
|
+
admin: {
|
|
447
|
+
description: 'Read by screen readers on the small arrow button next to a link with dropdown links. {label} is the link label.',
|
|
448
|
+
},
|
|
449
|
+
},
|
|
322
450
|
{
|
|
323
451
|
name: 'collapse',
|
|
324
452
|
type: 'select',
|
|
@@ -350,7 +478,10 @@ export function defaultBlocks(options) {
|
|
|
350
478
|
'On small screens the links fold into a "Menu" button that opens a panel ("collapse": "md" or "lg"; ' +
|
|
351
479
|
'"never" keeps the links visible, for footers). The className lays out the links. ' +
|
|
352
480
|
'Put it in a header stack that has the "relative" class, so the panel opens below the header. ' +
|
|
353
|
-
'Optional "ctaLabel" and "cta" (a link) add a button as the last row of the small-screen panel.'
|
|
481
|
+
'Optional "ctaLabel" and "cta" (a link) add a button as the last row of the small-screen panel. "toggleLabel" is the text of the menu button (default "Menu"; translate it per locale). ' +
|
|
482
|
+
'An item may have "children" (one level of { label, link }): a dropdown. With its own link the item shows the link and a ' +
|
|
483
|
+
'small arrow button that opens the dropdown ("submenuLabel" names that button, default "{label} menu"); without a link the ' +
|
|
484
|
+
'label itself opens it. On small screens the children show as a nested list in the panel.',
|
|
354
485
|
example: {
|
|
355
486
|
type: 'menu',
|
|
356
487
|
props: {
|
|
@@ -358,6 +489,13 @@ export function defaultBlocks(options) {
|
|
|
358
489
|
collapse: 'md',
|
|
359
490
|
items: [
|
|
360
491
|
{ label: 'About', link: { type: 'url', url: '/about' } },
|
|
492
|
+
{
|
|
493
|
+
label: 'Services',
|
|
494
|
+
children: [
|
|
495
|
+
{ label: 'Dinner dates', link: { type: 'url', url: '/services/dinner' } },
|
|
496
|
+
{ label: 'Travel', link: { type: 'url', url: '/services/travel' } },
|
|
497
|
+
],
|
|
498
|
+
},
|
|
361
499
|
{ label: 'Contact', link: { type: 'url', url: '/contact' } },
|
|
362
500
|
],
|
|
363
501
|
},
|
|
@@ -389,16 +527,28 @@ export function defaultBlocks(options) {
|
|
|
389
527
|
},
|
|
390
528
|
},
|
|
391
529
|
});
|
|
530
|
+
const itemLink = linkField({ collections: linkCollections });
|
|
392
531
|
const listItem = defineBlock({
|
|
393
532
|
type: TEXT_LIST_ITEM_BLOCK,
|
|
394
533
|
label: 'List item',
|
|
395
534
|
icon: 'text',
|
|
396
535
|
category: 'Content',
|
|
397
|
-
fields: [
|
|
536
|
+
fields: [
|
|
537
|
+
{ name: 'text', type: 'text', label: 'Text', required: true, localized: true },
|
|
538
|
+
{
|
|
539
|
+
...itemLink,
|
|
540
|
+
admin: {
|
|
541
|
+
...itemLink.admin,
|
|
542
|
+
description: 'Optional. The item text becomes a link. Leave it empty in a list inside a Link block: a link cannot hold another link.',
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
],
|
|
398
546
|
parents: [TEXT_LIST_BLOCK],
|
|
399
547
|
ai: {
|
|
400
|
-
description: `One item (<li>) of a "${TEXT_LIST_BLOCK}" block. It goes only in a list's "${TEXT_LIST_SLOT}" slot
|
|
401
|
-
|
|
548
|
+
description: `One item (<li>) of a "${TEXT_LIST_BLOCK}" block. It goes only in a list's "${TEXT_LIST_SLOT}" slot. ` +
|
|
549
|
+
'Optional "link" makes the whole item text a link (<li><a>text</a></li>); without a link it is plain text. ' +
|
|
550
|
+
'Never set a link on items of a list inside a "link" block.',
|
|
551
|
+
example: { type: TEXT_LIST_ITEM_BLOCK, props: { text: 'Pricing', link: exampleLink } },
|
|
402
552
|
},
|
|
403
553
|
});
|
|
404
554
|
const quote = defineBlock({
|
|
@@ -508,13 +658,30 @@ export function defaultBlocks(options) {
|
|
|
508
658
|
localized: true,
|
|
509
659
|
admin: { description: 'Shown when this field is empty.' },
|
|
510
660
|
},
|
|
661
|
+
{
|
|
662
|
+
name: 'format',
|
|
663
|
+
type: 'text',
|
|
664
|
+
label: 'Format',
|
|
665
|
+
admin: {
|
|
666
|
+
description: 'For a number, date or text: "currency:AUD" ($1,200), "number" (1,200), "date:en-AU:Australia/Brisbane" ' +
|
|
667
|
+
'(a date in that language and time zone) or "firstSentence". Empty: the value as it is.',
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
name: 'headingIds',
|
|
672
|
+
type: 'checkbox',
|
|
673
|
+
label: 'Heading ids',
|
|
674
|
+
admin: { description: 'For rich text: each heading gets an id from its text, so a table of contents can link to it ("#prices").' },
|
|
675
|
+
},
|
|
511
676
|
],
|
|
512
677
|
classes: FIELD_CLASSES,
|
|
513
678
|
ai: {
|
|
514
679
|
description: 'Shows one field of the current document in a template, rendered by its value: rich text as formatted ' +
|
|
515
680
|
'text, an upload as an image, a date as a formatted date, a relationship as its title, text as text. ' +
|
|
516
681
|
'"path" is a dot path from getBindingSources (e.g. "content", "author.name"). Only works in templates ' +
|
|
517
|
-
'and inside a collection list item.'
|
|
682
|
+
'and inside a collection list item. "format" formats a number, date or text with a binding formatter: ' +
|
|
683
|
+
'"currency:AUD", "number", "date:en-AU:Australia/Brisbane" or "firstSentence". "headingIds": true gives each ' +
|
|
684
|
+
'rich-text heading an id from its text (e.g. "Our prices" -> "our-prices", repeats get "-2"), for "#id" links.',
|
|
518
685
|
example: { type: FIELD_BLOCK, props: { path: 'content' }, className: 'prose max-w-none' },
|
|
519
686
|
},
|
|
520
687
|
});
|
|
@@ -534,8 +701,28 @@ export function defaultBlocks(options) {
|
|
|
534
701
|
type: 'text',
|
|
535
702
|
label: 'Sort',
|
|
536
703
|
defaultValue: '-createdAt',
|
|
537
|
-
admin: {
|
|
704
|
+
admin: {
|
|
705
|
+
description: 'The field to sort by, for example "publishedAt". Put a "-" in front for newest or largest first: "-publishedAt". ' +
|
|
706
|
+
'"$random" shuffles the newest 100 matches once per page build.',
|
|
707
|
+
},
|
|
538
708
|
},
|
|
709
|
+
listCollections && listCollections.length > 0
|
|
710
|
+
? {
|
|
711
|
+
name: 'ids',
|
|
712
|
+
type: 'relationship',
|
|
713
|
+
label: 'Picked documents',
|
|
714
|
+
// The slugs come from the app, so they cannot match Payload's generated slug type.
|
|
715
|
+
relationTo: (listCollections.length === 1 ? listCollections[0] : listCollections),
|
|
716
|
+
hasMany: true,
|
|
717
|
+
admin: { description: 'Only these documents, in this order. Limit, sort, skip and pages then do not apply.' },
|
|
718
|
+
}
|
|
719
|
+
: {
|
|
720
|
+
name: 'ids',
|
|
721
|
+
type: 'text',
|
|
722
|
+
label: 'Picked document ids',
|
|
723
|
+
hasMany: true,
|
|
724
|
+
admin: { description: 'Only these documents, in this order. Limit, sort, skip and pages then do not apply.' },
|
|
725
|
+
},
|
|
539
726
|
{
|
|
540
727
|
name: 'excludeCurrent',
|
|
541
728
|
type: 'checkbox',
|
|
@@ -543,14 +730,135 @@ export function defaultBlocks(options) {
|
|
|
543
730
|
defaultValue: true,
|
|
544
731
|
admin: { description: 'On a page made from a template, the item that the page shows is not listed again.' },
|
|
545
732
|
},
|
|
733
|
+
{
|
|
734
|
+
name: 'filterField',
|
|
735
|
+
type: 'text',
|
|
736
|
+
label: 'Filter by field',
|
|
737
|
+
admin: {
|
|
738
|
+
description: 'Only documents related to the current document through this field, for example "services" or "category". ' +
|
|
739
|
+
'Works on pages made from a template. On other pages the list is not filtered.',
|
|
740
|
+
},
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
name: 'filterBy',
|
|
744
|
+
type: 'select',
|
|
745
|
+
label: 'Relation',
|
|
746
|
+
defaultValue: 'current',
|
|
747
|
+
options: [
|
|
748
|
+
{ label: 'The listed documents\' field holds the current document', value: 'current' },
|
|
749
|
+
{ label: 'The listed documents share a value with the current document\'s field', value: 'shared' },
|
|
750
|
+
{ label: 'The current document\'s field points to the listed documents', value: 'linked' },
|
|
751
|
+
],
|
|
752
|
+
admin: { description: 'How "Filter by field" relates the listed documents to the current document.' },
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
name: 'where',
|
|
756
|
+
type: 'json',
|
|
757
|
+
label: 'Where',
|
|
758
|
+
admin: {
|
|
759
|
+
description: 'A Payload where query, added to the filter. Example: { "featured": { "equals": true } }. Dates may use ' +
|
|
760
|
+
'"$now", "$now-30d" or "$now+12h".',
|
|
761
|
+
// The inspector edits it as condition rows over the fields of the chosen collection.
|
|
762
|
+
custom: { builderWhere: { collectionField: 'collection' } },
|
|
763
|
+
},
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
name: 'queryFilters',
|
|
767
|
+
type: 'json',
|
|
768
|
+
label: 'URL filters',
|
|
769
|
+
admin: {
|
|
770
|
+
description: 'Filters from the page URL: { "param": { "value": where } }. Example: { "available": { "today": { "availableToday": ' +
|
|
771
|
+
'{ "equals": true } } } } filters on ?available=today. Several values of one parameter are OR-ed, parameters are AND-ed.',
|
|
772
|
+
},
|
|
773
|
+
},
|
|
774
|
+
{ name: 'offset', type: 'number', label: 'Skip items', min: 0, admin: { description: 'Documents to leave out at the start.' } },
|
|
775
|
+
{
|
|
776
|
+
name: 'paginate',
|
|
777
|
+
type: 'select',
|
|
778
|
+
label: 'Pages',
|
|
779
|
+
defaultValue: 'none',
|
|
780
|
+
options: [
|
|
781
|
+
{ label: 'None: only the first items', value: 'none' },
|
|
782
|
+
{ label: 'Pages with ?page=N links', value: 'pages' },
|
|
783
|
+
],
|
|
784
|
+
admin: {
|
|
785
|
+
description: 'Pages: "Number of items" per page, with page links under the list. Long lists show the first, the last and the ' +
|
|
786
|
+
'pages around the current one, with "…" between. "Skip items" does not apply.',
|
|
787
|
+
},
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
name: 'pageParam',
|
|
791
|
+
type: 'text',
|
|
792
|
+
label: 'Page parameter',
|
|
793
|
+
admin: {
|
|
794
|
+
description: 'The URL parameter of the page number. Empty: "page". Give each paginated list on one page its own, for example ' +
|
|
795
|
+
'"reviewsPage". Letters, digits, _ and -.',
|
|
796
|
+
...when('paginate', 'pages'),
|
|
797
|
+
},
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
name: 'pagerLabel',
|
|
801
|
+
type: 'text',
|
|
802
|
+
label: 'Page links: label for screen readers',
|
|
803
|
+
defaultValue: 'Pages',
|
|
804
|
+
localized: true,
|
|
805
|
+
admin: when('paginate', 'pages'),
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
name: 'pagerClassName',
|
|
809
|
+
type: 'text',
|
|
810
|
+
label: 'Page links: classes',
|
|
811
|
+
defaultValue: 'flex flex-wrap gap-2',
|
|
812
|
+
admin: {
|
|
813
|
+
description: 'Classes of the element that holds the page links. A gap ("…") is a span with data-page-gap.',
|
|
814
|
+
custom: { builderClasses: true },
|
|
815
|
+
},
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
name: 'pageLinkClassName',
|
|
819
|
+
type: 'text',
|
|
820
|
+
label: 'Page link: classes',
|
|
821
|
+
admin: { description: 'Classes of each page link. The current page has aria-current="page", e.g. "aria-[current=page]:font-bold".', custom: { builderClasses: true } },
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
name: 'depth',
|
|
825
|
+
type: 'select',
|
|
826
|
+
label: 'Related data depth',
|
|
827
|
+
defaultValue: '1',
|
|
828
|
+
options: [
|
|
829
|
+
{ label: '1: the related documents of each item', value: '1' },
|
|
830
|
+
{ label: '2: also their related documents (larger)', value: '2' },
|
|
831
|
+
],
|
|
832
|
+
admin: { description: 'How far related documents of each item load, for example 2 to reach a category\'s image.' },
|
|
833
|
+
},
|
|
546
834
|
],
|
|
547
|
-
slots: { [LIST_ITEM_SLOT]: { label: 'Item' } },
|
|
835
|
+
slots: { [LIST_ITEM_SLOT]: { label: 'Item' }, [LIST_EMPTY_SLOT]: { label: 'When empty', styles: true } },
|
|
548
836
|
defaultClassName: 'grid grid-cols-1 gap-6 md:grid-cols-3',
|
|
549
837
|
ai: {
|
|
550
838
|
description: 'Lists the latest documents of a collection (e.g. "latest posts"). The "item" slot is the design of ONE ' +
|
|
551
839
|
'item: it repeats for every document. Blocks in it bind to the ITEM\'s fields with "bindings", e.g. a ' +
|
|
552
840
|
'heading with bindings { "text": "title" } and a link with bindings { "link": "$url" } (the item\'s URL). ' +
|
|
553
|
-
'Only published documents show on the site.'
|
|
841
|
+
'Only published documents show on the site. ' +
|
|
842
|
+
'To list documents related to the current document (templates only; ignored on normal pages), set ' +
|
|
843
|
+
'"filterField" (a field name) and "filterBy": "current" (default) lists documents whose filterField holds ' +
|
|
844
|
+
'the current document (e.g. on a service template, models whose "services" include this service); ' +
|
|
845
|
+
'"shared" lists documents whose filterField shares a value with the current document\'s filterField ' +
|
|
846
|
+
'(e.g. similar models with a "category" in common, posts with the same "category" text); "linked" lists ' +
|
|
847
|
+
'the documents the current document\'s filterField points to (e.g. on a model template, the model\'s ' +
|
|
848
|
+
'"services"). With "shared" or "linked" and an empty field, the list is empty. "where" is a static Payload ' +
|
|
849
|
+
'where query AND-ed with the rest, e.g. { "featured": { "equals": true } }; date values may be "$now", ' +
|
|
850
|
+
'"$now-30d" or "$now+7d" (units d and h). "queryFilters" filters by the page URL: { "<param>": { "<value>": where } }, ' +
|
|
851
|
+
'e.g. { "available": { "today": { "availableToday": { "equals": true } } } } for ?available=today; values of one ' +
|
|
852
|
+
'param (repeated or comma-separated) are OR-ed, params are AND-ed; the canvas ignores them. "offset" skips ' +
|
|
853
|
+
'documents. "depth" ("1" or "2") is how deep related documents load. "ids" picks documents by id and keeps the ' +
|
|
854
|
+
'pick order (limit, sort, offset and pages then do not apply). "sort": "$random" shuffles the newest 100 ' +
|
|
855
|
+
'matches once per page build. "paginate": "pages" shows "limit" items per page with crawlable ?page=N links ' +
|
|
856
|
+
'under the list ("pagerClassName" and "pageLinkClassName" style them; the current link has aria-current="page"; long ' +
|
|
857
|
+
'lists show "…" gaps as <span data-page-gap>). Two paginated lists on one page need their own "pageParam" ' +
|
|
858
|
+
'(default "page"), for example "reviewsPage". "pagerLabel" names the page links for screen readers (default "Pages"). ' +
|
|
859
|
+
'The "empty" slot shows instead of the ' +
|
|
860
|
+
'items when no document matches (e.g. a text "Nobody is available today"); it renders in its own div, styled ' +
|
|
861
|
+
'with "slotClassName": { "empty": "col-span-full ..." }.',
|
|
554
862
|
example: {
|
|
555
863
|
type: COLLECTION_LIST_BLOCK,
|
|
556
864
|
props: { collection: 'posts', limit: 3, sort: '-createdAt' },
|
|
@@ -574,5 +882,90 @@ export function defaultBlocks(options) {
|
|
|
574
882
|
},
|
|
575
883
|
},
|
|
576
884
|
});
|
|
577
|
-
|
|
885
|
+
const repeat = defineBlock({
|
|
886
|
+
type: REPEAT_BLOCK,
|
|
887
|
+
label: 'Repeat',
|
|
888
|
+
icon: 'repeat',
|
|
889
|
+
category: 'Dynamic',
|
|
890
|
+
fields: [
|
|
891
|
+
{
|
|
892
|
+
name: 'path',
|
|
893
|
+
type: 'text',
|
|
894
|
+
label: 'Field',
|
|
895
|
+
required: true,
|
|
896
|
+
admin: {
|
|
897
|
+
description: 'The list field of the current document to repeat, for example "faqs" (an array), "galleryImages" or "services" ' +
|
|
898
|
+
'(many uploads or relationships) or "tags" (many values). Inside a collection list: a field of each item.',
|
|
899
|
+
},
|
|
900
|
+
},
|
|
901
|
+
{ name: 'limit', type: 'number', label: 'Number of rows', min: 1, admin: { description: 'Empty: every row.' } },
|
|
902
|
+
{ name: 'offset', type: 'number', label: 'Skip rows', min: 0, admin: { description: 'Rows to leave out at the start, for example 1 to skip the first photo.' } },
|
|
903
|
+
listCollections && listCollections.length > 0
|
|
904
|
+
? {
|
|
905
|
+
name: 'collection',
|
|
906
|
+
type: 'select',
|
|
907
|
+
label: 'Related collection',
|
|
908
|
+
options: listCollections,
|
|
909
|
+
admin: { description: 'For a relationship field: the collection of its documents, so "$url" links to each one.' },
|
|
910
|
+
}
|
|
911
|
+
: {
|
|
912
|
+
name: 'collection',
|
|
913
|
+
type: 'text',
|
|
914
|
+
label: 'Related collection',
|
|
915
|
+
admin: { description: 'For a relationship field: the collection of its documents, so "$url" links to each one.' },
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
name: 'as',
|
|
919
|
+
type: 'select',
|
|
920
|
+
label: 'Wrapper',
|
|
921
|
+
defaultValue: 'div',
|
|
922
|
+
options: [
|
|
923
|
+
{ label: 'A div around the rows', value: 'div' },
|
|
924
|
+
{ label: 'None: the rows sit in the parent', value: 'none' },
|
|
925
|
+
],
|
|
926
|
+
admin: {
|
|
927
|
+
description: 'None: the rows become direct children of the parent block, for example the cells of a grid or the items of a list. ' +
|
|
928
|
+
"The repeat's own classes and animations then do nothing.",
|
|
929
|
+
},
|
|
930
|
+
},
|
|
931
|
+
],
|
|
932
|
+
slots: { [LIST_ITEM_SLOT]: { label: 'Row' } },
|
|
933
|
+
defaultClassName: 'flex flex-col gap-4',
|
|
934
|
+
ai: {
|
|
935
|
+
description: 'Repeats its "item" slot once per row of a list field of the CURRENT document (templates; inside a collection ' +
|
|
936
|
+
'list item, of each listed document; inside another repeat, of the row). "path" is the field: an array ' +
|
|
937
|
+
'(e.g. FAQs, rates), a hasMany upload (e.g. a gallery), a hasMany relationship, or hasMany text/select. ' +
|
|
938
|
+
'Blocks in "item" bind to the ROW: the field names of an array row (e.g. "question", "price"), the related ' +
|
|
939
|
+
`document's fields (e.g. "name"; "$url" when "collection" names its collection), "${ITEM_PATH}" (the row value ` +
|
|
940
|
+
`itself: an upload for an image, a text for a text block), "${INDEX_PATH}" (the row number from 1), ` +
|
|
941
|
+
`"${PARENT_PATH}.<field>" (the enclosing document, e.g. "${PARENT_PATH}.name") and "${PAGE_PATH}.<field>" (the page's ` +
|
|
942
|
+
'document). "limit" and "offset" pick rows (offset 1 skips the first). "as": "div" (default) wraps the rows in ' +
|
|
943
|
+
'a div that takes the className; "none" renders the rows with no wrapper, as direct children of the parent ' +
|
|
944
|
+
'(e.g. cells of a grid, items of a stack with as "ul"), and then className and motion do nothing. ' +
|
|
945
|
+
'On a page without a current document ' +
|
|
946
|
+
'it shows nothing. Example 2 (photos): { "type": "repeat", "props": { "path": "galleryImages", "offset": 1 }, ' +
|
|
947
|
+
`"slots": { "item": [{ "type": "image", "bindings": { "image": "${ITEM_PATH}" } }] } }.`,
|
|
948
|
+
example: {
|
|
949
|
+
type: REPEAT_BLOCK,
|
|
950
|
+
props: { path: 'faqs' },
|
|
951
|
+
className: 'flex flex-col gap-4',
|
|
952
|
+
slots: {
|
|
953
|
+
[LIST_ITEM_SLOT]: [
|
|
954
|
+
{
|
|
955
|
+
id: 'b_example_1',
|
|
956
|
+
type: 'stack',
|
|
957
|
+
className: 'flex flex-col gap-2 rounded-lg border p-4',
|
|
958
|
+
slots: {
|
|
959
|
+
children: [
|
|
960
|
+
{ id: 'b_example_2', type: 'heading', props: { level: '3' }, bindings: { text: 'question' } },
|
|
961
|
+
{ id: 'b_example_3', type: 'text', bindings: { text: 'answer' } },
|
|
962
|
+
],
|
|
963
|
+
},
|
|
964
|
+
},
|
|
965
|
+
],
|
|
966
|
+
},
|
|
967
|
+
},
|
|
968
|
+
},
|
|
969
|
+
});
|
|
970
|
+
return [stack, grid, heading, text, richText, image, button, link, menu, list, listItem, quote, divider, spacer, video, field, collectionList, repeat];
|
|
578
971
|
}
|
package/dist/blocks/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { defaultBlocks, FIELD_CLASS_MAP, MENU_CLASS_MAP, type DefaultBlocksOptions } from './defaults.js';
|
|
2
|
+
export * from './builtins/index.js';
|
|
2
3
|
export { isLinkField, linkField, type BuilderCondition, type LinkFieldOptions } from './link.js';
|
|
3
4
|
export { fromPayloadBlocks, type FromPayloadBlocksOptions, type PayloadBlockOverride } from './payload.js';
|
|
4
|
-
export { defineBlock } from '../core/blocks.js';
|
|
5
|
+
export { defineBlock, defineSection, type SectionBlockInput, type SectionInput, sectionsWithVariants, withDefaultClassNames, withInlineBlocks } from '../core/blocks.js';
|
|
5
6
|
export { BUILDER_CSS_CLASS, withBuilderCssClass } from '../css/marker.js';
|
|
6
|
-
export
|
|
7
|
+
export { listCollectionsOf, prepareBlocks } from '../plugin/listCollections.js';
|
|
8
|
+
export type { Block, BlockDefinition, BlockProps, Layout, SectionDefinition, SectionVariant, SlotDefinition, } from '../core/types.js';
|
package/dist/blocks/index.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// site, the canvas iframe and payload.config.ts can all import the same blocks list.
|
|
3
3
|
// No `node:` imports and no Payload runtime imports here (type imports only). A test checks it.
|
|
4
4
|
export { defaultBlocks, FIELD_CLASS_MAP, MENU_CLASS_MAP } from './defaults.js';
|
|
5
|
+
export * from './builtins/index.js';
|
|
5
6
|
export { isLinkField, linkField } from './link.js';
|
|
6
7
|
export { fromPayloadBlocks } from './payload.js';
|
|
7
|
-
export { defineBlock } from '../core/blocks.js';
|
|
8
|
+
export { defineBlock, defineSection, sectionsWithVariants, withDefaultClassNames, withInlineBlocks } from '../core/blocks.js';
|
|
8
9
|
export { BUILDER_CSS_CLASS, withBuilderCssClass } from '../css/marker.js';
|
|
10
|
+
export { listCollectionsOf, prepareBlocks } from '../plugin/listCollections.js';
|