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
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { LIGHTBOX_CLASS_MAP as C, LIGHTBOX_CLOSE_EVENT, LIGHTBOX_LABELS as L, LIGHTBOX_SKIP_ATTRIBUTE, } from '../../../blocks/builtins/lightbox.js';
|
|
5
|
+
import { labelOf, textOr } from '../../../blocks/builtins/shared.js';
|
|
6
|
+
import { Chevron, CloseIcon } from './glyphs.js';
|
|
7
|
+
/** The opening: the backdrop fades in and the photo grows a little as it fades in. */
|
|
8
|
+
const OPEN_MS = 320;
|
|
9
|
+
/** A step: the old photo slides out as the new one slides in. */
|
|
10
|
+
const STEP_MS = 260;
|
|
11
|
+
const CLOSE_MS = 200;
|
|
12
|
+
const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';
|
|
13
|
+
const EASE_IN = 'cubic-bezier(0.4, 0, 1, 1)';
|
|
14
|
+
/** A photo that loads faster than this shows no loading ring. */
|
|
15
|
+
const LOADING_DELAY_MS = 150;
|
|
16
|
+
/** How far a photo slides when it steps, in percent of its width. */
|
|
17
|
+
const STEP_SHIFT = 4;
|
|
18
|
+
const reducedMotion = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
19
|
+
/** The images of a lightbox, not the large photos of its own dialog. */
|
|
20
|
+
const imagesIn = (root) => [...root.querySelectorAll('img')].filter((img) => !img.closest('dialog'));
|
|
21
|
+
/** The image a click or a key on `target` opens: the image itself, or the one inside a link or button. */
|
|
22
|
+
function imageAt(target) {
|
|
23
|
+
if (!(target instanceof Element) || target.closest('dialog'))
|
|
24
|
+
return null;
|
|
25
|
+
return target.closest('img') ?? target.closest('a, button')?.querySelector('img') ?? null;
|
|
26
|
+
}
|
|
27
|
+
/** The key that makes two images one photo: the `src` attribute. */
|
|
28
|
+
const sourceOf = (img) => img.getAttribute('src') ?? img.src;
|
|
29
|
+
/**
|
|
30
|
+
* The photos of a set: the images in page order, without skipped ones (`data-lightbox-skip` on the
|
|
31
|
+
* image or round it), each source once. `images[i]` is the page image of `photos[i]`.
|
|
32
|
+
*/
|
|
33
|
+
export function photoSet(list) {
|
|
34
|
+
const seen = new Set();
|
|
35
|
+
const images = [];
|
|
36
|
+
for (const img of list) {
|
|
37
|
+
const source = sourceOf(img);
|
|
38
|
+
if (img.closest(`[${LIGHTBOX_SKIP_ATTRIBUTE}]`) || seen.has(source))
|
|
39
|
+
continue;
|
|
40
|
+
seen.add(source);
|
|
41
|
+
images.push(img);
|
|
42
|
+
}
|
|
43
|
+
return { images, photos: images.map((img) => ({ src: img.currentSrc || img.src, srcSet: img.srcset, alt: img.alt })) };
|
|
44
|
+
}
|
|
45
|
+
/** Where a click on `target` opens the set: at the photo with its source, else at the first photo. */
|
|
46
|
+
export const openIndex = (images, target) => {
|
|
47
|
+
const source = sourceOf(target);
|
|
48
|
+
return Math.max(0, images.findIndex((img) => sourceOf(img) === source));
|
|
49
|
+
};
|
|
50
|
+
/** The next index in a list of `count`, wrapping around. */
|
|
51
|
+
export const stepIndex = (index, by, count) => (count > 0 ? (index + by + count) % count : 0);
|
|
52
|
+
/** Shortest sideways move, in CSS pixels, that counts as a swipe. */
|
|
53
|
+
const SWIPE_DISTANCE = 50;
|
|
54
|
+
/**
|
|
55
|
+
* The step of a swipe that moved `dx` sideways and `dy` down: 1 (next) for a swipe to the left,
|
|
56
|
+
* -1 (previous) for a swipe to the right, 0 when it was short or mostly vertical.
|
|
57
|
+
*/
|
|
58
|
+
export function swipeStep(dx, dy, distance = SWIPE_DISTANCE) {
|
|
59
|
+
if (Math.abs(dx) < distance || Math.abs(dx) <= Math.abs(dy))
|
|
60
|
+
return 0;
|
|
61
|
+
return dx < 0 ? 1 : -1;
|
|
62
|
+
}
|
|
63
|
+
/** Fades the dialog and its backdrop. A browser without `pseudoElement` animations skips the backdrop. */
|
|
64
|
+
function fadeDialog(dialog, frames, options) {
|
|
65
|
+
const animations = [dialog.animate(frames, options)];
|
|
66
|
+
try {
|
|
67
|
+
animations.push(dialog.animate(frames, { ...options, pseudoElement: '::backdrop' }));
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// The backdrop shows at once.
|
|
71
|
+
}
|
|
72
|
+
return animations;
|
|
73
|
+
}
|
|
74
|
+
/** The loading ring fades in only when the photo is still loading after a moment. */
|
|
75
|
+
function fadeInLater(ring) {
|
|
76
|
+
const fade = ring?.animate([{ opacity: 0 }, { opacity: 1 }], { delay: LOADING_DELAY_MS, duration: 200, fill: 'both' });
|
|
77
|
+
return () => fade?.cancel();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A container whose images open full screen. The native modal dialog traps the focus, makes the
|
|
81
|
+
* page inert, closes on Escape and gives the focus back. Arrow keys step through the images.
|
|
82
|
+
* Images get `tabindex="0"` and `role="button"`, so the keyboard can open them. On touch screens a
|
|
83
|
+
* sideways swipe steps too (pointer events; a mouse drag does not). Off on the canvas,
|
|
84
|
+
* so a click selects an image there.
|
|
85
|
+
*
|
|
86
|
+
* Motion: the dialog and its backdrop fade in, and the photo grows from 96% as it loads; a step
|
|
87
|
+
* slides the old photo out and the new one in; closing fades out. Under reduced motion only the
|
|
88
|
+
* fades stay. A photo that has not loaded after a moment shows a spinning ring.
|
|
89
|
+
*/
|
|
90
|
+
export function Lightbox({ props, className, attributes, slotAttributes, slots, mode }) {
|
|
91
|
+
const root = useRef(null);
|
|
92
|
+
const dialog = useRef(null);
|
|
93
|
+
const photoRef = useRef(null);
|
|
94
|
+
const leavingRef = useRef(null);
|
|
95
|
+
const [photos, setPhotos] = useState([]);
|
|
96
|
+
const [index, setIndex] = useState(0);
|
|
97
|
+
const [loaded, setLoaded] = useState(false);
|
|
98
|
+
/** The photo that slides out during a step. */
|
|
99
|
+
const [leaving, setLeaving] = useState(null);
|
|
100
|
+
/** The page image of each photo, for the close event. */
|
|
101
|
+
const images = useRef([]);
|
|
102
|
+
/** How the next photo comes in: `open` (grows in) or the step (1 or -1, slides in). */
|
|
103
|
+
const entrance = useRef('open');
|
|
104
|
+
const closing = useRef(false);
|
|
105
|
+
const steps = useRef(0);
|
|
106
|
+
/** Where a touch or pen swipe started; `swiped` drops the click that follows a swipe. */
|
|
107
|
+
const swipe = useRef(null);
|
|
108
|
+
const swiped = useRef(false);
|
|
109
|
+
const canvas = mode === 'canvas';
|
|
110
|
+
const group = textOr(props.group, '');
|
|
111
|
+
const open = photos.length > 0;
|
|
112
|
+
// Runs after every render: repeats and lists can add images.
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!root.current || canvas)
|
|
115
|
+
return;
|
|
116
|
+
for (const img of imagesIn(root.current)) {
|
|
117
|
+
if (img.closest('a, button') || img.hasAttribute('tabindex'))
|
|
118
|
+
continue;
|
|
119
|
+
img.tabIndex = 0;
|
|
120
|
+
img.setAttribute('role', 'button');
|
|
121
|
+
img.setAttribute('aria-haspopup', 'dialog');
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
const element = dialog.current;
|
|
126
|
+
if (!open || !element || element.open)
|
|
127
|
+
return;
|
|
128
|
+
element.showModal();
|
|
129
|
+
fadeDialog(element, [{ opacity: 0 }, { opacity: 1 }], { duration: OPEN_MS, easing: EASE_OUT });
|
|
130
|
+
}, [open]);
|
|
131
|
+
// The photo of the last step slides out, then goes.
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
const element = leavingRef.current;
|
|
134
|
+
if (!element || !leaving)
|
|
135
|
+
return;
|
|
136
|
+
const out = element.animate([
|
|
137
|
+
{ opacity: 1, transform: 'none' },
|
|
138
|
+
{ opacity: 0, transform: `translateX(${-leaving.by * STEP_SHIFT}%)` },
|
|
139
|
+
], { duration: STEP_MS, easing: EASE_OUT, fill: 'forwards' });
|
|
140
|
+
out.onfinish = () => setLeaving((current) => (current === leaving ? null : current));
|
|
141
|
+
return () => out.cancel();
|
|
142
|
+
}, [leaving]);
|
|
143
|
+
const show = (target) => {
|
|
144
|
+
const scope = group ? [...document.querySelectorAll(`[data-lightbox-group="${CSS.escape(group)}"]`)] : [root.current];
|
|
145
|
+
const set = photoSet(scope.flatMap(imagesIn));
|
|
146
|
+
images.current = set.images;
|
|
147
|
+
entrance.current = 'open';
|
|
148
|
+
closing.current = false;
|
|
149
|
+
setLeaving(null);
|
|
150
|
+
setLoaded(false);
|
|
151
|
+
setPhotos(set.photos);
|
|
152
|
+
setIndex(openIndex(set.images, target));
|
|
153
|
+
};
|
|
154
|
+
const onClick = (event) => {
|
|
155
|
+
const img = canvas ? null : imageAt(event.target);
|
|
156
|
+
if (!img)
|
|
157
|
+
return;
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
show(img);
|
|
160
|
+
};
|
|
161
|
+
const onKeyDown = (event) => {
|
|
162
|
+
if (canvas || (event.key !== 'Enter' && event.key !== ' '))
|
|
163
|
+
return;
|
|
164
|
+
if (!(event.target instanceof HTMLImageElement) || event.target.closest('dialog'))
|
|
165
|
+
return;
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
show(event.target);
|
|
168
|
+
};
|
|
169
|
+
const step = (by) => {
|
|
170
|
+
if (photos.length < 2 || closing.current)
|
|
171
|
+
return;
|
|
172
|
+
// The shown photo slides out over the next one (no slide under reduced motion).
|
|
173
|
+
if (loaded && !reducedMotion())
|
|
174
|
+
setLeaving({ photo: photos[index], by, key: ++steps.current });
|
|
175
|
+
else
|
|
176
|
+
setLeaving(null);
|
|
177
|
+
entrance.current = by;
|
|
178
|
+
setLoaded(false);
|
|
179
|
+
setIndex(stepIndex(index, by, photos.length));
|
|
180
|
+
};
|
|
181
|
+
const onPhotoLoad = (event) => {
|
|
182
|
+
setLoaded(true);
|
|
183
|
+
const kind = entrance.current;
|
|
184
|
+
const still = reducedMotion();
|
|
185
|
+
const from = kind === 'open' ? 'scale(0.96)' : `translateX(${kind * STEP_SHIFT}%)`;
|
|
186
|
+
event.currentTarget.animate([
|
|
187
|
+
{ opacity: 0, transform: still ? 'none' : from },
|
|
188
|
+
{ opacity: 1, transform: 'none' },
|
|
189
|
+
], { duration: kind === 'open' ? OPEN_MS : STEP_MS, easing: EASE_OUT });
|
|
190
|
+
};
|
|
191
|
+
const close = () => {
|
|
192
|
+
const element = dialog.current;
|
|
193
|
+
if (!element?.open || closing.current)
|
|
194
|
+
return;
|
|
195
|
+
closing.current = true;
|
|
196
|
+
const options = { duration: CLOSE_MS, easing: EASE_IN, fill: 'forwards' };
|
|
197
|
+
const animations = fadeDialog(element, [{ opacity: 1 }, { opacity: 0 }], options);
|
|
198
|
+
if (!reducedMotion()) {
|
|
199
|
+
const shrink = photoRef.current?.animate([{ transform: 'none' }, { transform: 'scale(0.97)' }], options);
|
|
200
|
+
if (shrink)
|
|
201
|
+
animations.push(shrink);
|
|
202
|
+
}
|
|
203
|
+
void Promise.all(animations.map((animation) => animation.finished))
|
|
204
|
+
.catch(() => { })
|
|
205
|
+
.then(() => element.close());
|
|
206
|
+
};
|
|
207
|
+
const onClose = () => {
|
|
208
|
+
closing.current = false;
|
|
209
|
+
const image = images.current[index];
|
|
210
|
+
images.current = [];
|
|
211
|
+
setPhotos([]);
|
|
212
|
+
setLeaving(null);
|
|
213
|
+
image?.dispatchEvent(new CustomEvent(LIGHTBOX_CLOSE_EVENT, { bubbles: true, detail: { index } }));
|
|
214
|
+
};
|
|
215
|
+
const onSwipeStart = (event) => {
|
|
216
|
+
swiped.current = false;
|
|
217
|
+
swipe.current = event.pointerType === 'mouse' || !event.isPrimary ? null : { x: event.clientX, y: event.clientY, id: event.pointerId };
|
|
218
|
+
};
|
|
219
|
+
const onSwipeEnd = (event) => {
|
|
220
|
+
const start = swipe.current;
|
|
221
|
+
swipe.current = null;
|
|
222
|
+
if (!start || start.id !== event.pointerId)
|
|
223
|
+
return;
|
|
224
|
+
const by = swipeStep(event.clientX - start.x, event.clientY - start.y);
|
|
225
|
+
if (by === 0 || photos.length < 2)
|
|
226
|
+
return;
|
|
227
|
+
swiped.current = true;
|
|
228
|
+
step(by);
|
|
229
|
+
};
|
|
230
|
+
const label = (name) => labelOf(props, L, name, { n: index + 1, count: photos.length });
|
|
231
|
+
const photo = photos[index];
|
|
232
|
+
const caption = props.captions === true && photo?.alt ? photo.alt : '';
|
|
233
|
+
const showCount = props.count !== false && photos.length > 1;
|
|
234
|
+
return (_jsxs("div", { ...attributes, ...slotAttributes.children, ref: root, className: className ? `${className} ${C.root}` : C.root, "data-lightbox-group": group || undefined, onClick: onClick, onKeyDown: onKeyDown, children: [slots.children, open && photo ? (_jsxs("dialog", { ref: dialog, "aria-label": textOr(props.label, 'Photos'), className: C.dialog, onCancel: (event) => {
|
|
235
|
+
// Escape: close with the fade, not at once. The browser may refuse to wait; it then closes.
|
|
236
|
+
if (!event.cancelable)
|
|
237
|
+
return;
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
close();
|
|
240
|
+
}, onClose: onClose, onPointerDown: onSwipeStart, onPointerUp: onSwipeEnd, onPointerCancel: () => (swipe.current = null), onClickCapture: (event) => {
|
|
241
|
+
// The click after a swipe would close the dialog (a click beside the photo).
|
|
242
|
+
if (!swiped.current)
|
|
243
|
+
return;
|
|
244
|
+
swiped.current = false;
|
|
245
|
+
event.stopPropagation();
|
|
246
|
+
}, onKeyDown: (event) => {
|
|
247
|
+
if (event.key === 'ArrowRight')
|
|
248
|
+
step(1);
|
|
249
|
+
if (event.key === 'ArrowLeft')
|
|
250
|
+
step(-1);
|
|
251
|
+
}, children: [_jsxs("figure", { className: C.figure, "aria-busy": loaded ? undefined : true, onClick: (event) => event.target === event.currentTarget && close(), children: [leaving ? (_jsx("img", { ref: leavingRef, "data-lightbox-photo": "leaving", className: C.photo, src: leaving.photo.src, ...(leaving.photo.srcSet ? { srcSet: leaving.photo.srcSet, sizes: '100vw' } : {}), alt: "", "aria-hidden": "true" }, `leaving-${leaving.key}`)) : null, _jsx("img", { ref: photoRef, "data-lightbox-photo": "", className: C.photo, style: loaded ? undefined : { opacity: 0 }, src: photo.src, ...(photo.srcSet ? { srcSet: photo.srcSet, sizes: '100vw' } : {}), alt: photo.alt, onLoad: onPhotoLoad, onError: () => setLoaded(true) }, index), _jsxs("figcaption", { className: `${C.caption} ${caption ? '' : C.hidden}`, "aria-live": "polite", children: [caption ? `${caption}. ` : '', label('countLabel')] })] }), loaded ? null : _jsx("span", { ref: fadeInLater, "data-lightbox-loading": "", "aria-hidden": "true", className: C.loading, style: { opacity: 0 } }, index), showCount ? (_jsx("span", { "data-lightbox-count": "", "aria-hidden": "true", className: C.count, children: label('countLabel') })) : null, _jsx("button", { type: "button", "data-lightbox-button": "close", "aria-label": label('closeLabel'), className: `${C.button} ${C.close}`, onClick: close, children: _jsx(CloseIcon, { className: C.icon }) }), photos.length > 1 ? (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", "data-lightbox-button": "previous", "aria-label": label('previousLabel'), className: `${C.button} ${C.previous}`, onClick: () => step(-1), children: _jsx(Chevron, { className: C.icon, direction: "left" }) }), _jsx("button", { type: "button", "data-lightbox-button": "next", "aria-label": label('nextLabel'), className: `${C.button} ${C.next}`, onClick: () => step(1), children: _jsx(Chevron, { className: C.icon, direction: "right" }) })] })) : null] })) : null] }));
|
|
252
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BlockComponentProps } from '../../render/types.js';
|
|
2
|
+
/** Maps a stored media URL to the one the site serves, e.g. an absolute URL to its path. */
|
|
3
|
+
export type MediaUrl = (url: string) => string;
|
|
4
|
+
/**
|
|
5
|
+
* The media backdrop component, with `mediaUrl` applied to the URLs of its uploads (the photo and
|
|
6
|
+
* its sizes, the video, the poster). `builtinComponents({ mediaUrl })` uses it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function mediaBackdropComponent(mediaUrl?: MediaUrl): (block: BlockComponentProps) => import("react").JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* A photo or a muted looping video behind the block's content. The media and the optional
|
|
11
|
+
* overlay are absolute children (`data-backdrop-media`, `data-backdrop-overlay`); the slot's
|
|
12
|
+
* blocks follow them, so the block's className lays out the content.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MediaBackdrop: (block: BlockComponentProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { preload } from 'react-dom';
|
|
3
|
+
import { MEDIA_BACKDROP_CLASS_MAP as C } from '../../../blocks/builtins/mediaBackdrop.js';
|
|
4
|
+
import { textOr } from '../../../blocks/builtins/shared.js';
|
|
5
|
+
import { editableImage } from '../../render/editable.js';
|
|
6
|
+
import { focalStyle, isDoc, srcSetOf } from '../Image.js';
|
|
7
|
+
import { BackdropVideo } from './BackdropVideo.js';
|
|
8
|
+
/** The media document with `mediaUrl` applied to its file and to each image size. */
|
|
9
|
+
function docOf(value, mediaUrl) {
|
|
10
|
+
if (!isDoc(value))
|
|
11
|
+
return null;
|
|
12
|
+
const doc = value;
|
|
13
|
+
if (!mediaUrl)
|
|
14
|
+
return doc;
|
|
15
|
+
const sizes = doc.sizes && typeof doc.sizes === 'object' ? doc.sizes : null;
|
|
16
|
+
return {
|
|
17
|
+
...doc,
|
|
18
|
+
url: mediaUrl(doc.url),
|
|
19
|
+
...(sizes
|
|
20
|
+
? {
|
|
21
|
+
sizes: Object.fromEntries(Object.entries(sizes).map(([name, size]) => [name, isDoc(size) ? { ...size, url: mediaUrl(size.url) } : size])),
|
|
22
|
+
}
|
|
23
|
+
: {}),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The media backdrop component, with `mediaUrl` applied to the URLs of its uploads (the photo and
|
|
28
|
+
* its sizes, the video, the poster). `builtinComponents({ mediaUrl })` uses it.
|
|
29
|
+
*/
|
|
30
|
+
export function mediaBackdropComponent(mediaUrl) {
|
|
31
|
+
return function MediaBackdrop(block) {
|
|
32
|
+
return backdrop(block, mediaUrl);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A photo or a muted looping video behind the block's content. The media and the optional
|
|
37
|
+
* overlay are absolute children (`data-backdrop-media`, `data-backdrop-overlay`); the slot's
|
|
38
|
+
* blocks follow them, so the block's className lays out the content.
|
|
39
|
+
*/
|
|
40
|
+
export const MediaBackdrop = mediaBackdropComponent();
|
|
41
|
+
function backdrop(block, mediaUrl) {
|
|
42
|
+
const { props, className, attributes, slotAttributes, slots, mode } = block;
|
|
43
|
+
const image = docOf(props.image, mediaUrl);
|
|
44
|
+
// `videoUrl` is a link an editor typed, not a stored upload, so it stays as it is.
|
|
45
|
+
const videoSrc = docOf(props.video, mediaUrl)?.url ?? textOr(props.videoUrl, '');
|
|
46
|
+
const priority = props.priority === true;
|
|
47
|
+
let media = null;
|
|
48
|
+
if (videoSrc) {
|
|
49
|
+
const poster = docOf(props.poster, mediaUrl) ?? image;
|
|
50
|
+
if (poster && priority)
|
|
51
|
+
preload(poster.url, { as: 'image', fetchPriority: 'high' });
|
|
52
|
+
media = (_jsx(BackdropVideo, { src: videoSrc, poster: poster?.url, className: C.media, style: focalStyle(poster), priority: priority, play: mode !== 'canvas' }, videoSrc));
|
|
53
|
+
}
|
|
54
|
+
else if (image) {
|
|
55
|
+
const srcSet = srcSetOf(image);
|
|
56
|
+
media = (_jsx("img", { ...editableImage(mode, 'image'), "data-backdrop-media": "", className: C.media, src: image.url, ...(srcSet ? { srcSet, sizes: textOr(props.sizes, '100vw') } : {}),
|
|
57
|
+
// A background is decoration unless the block names it.
|
|
58
|
+
alt: textOr(props.alt, ''), width: typeof image.width === 'number' ? image.width : undefined, height: typeof image.height === 'number' ? image.height : undefined, style: focalStyle(image), loading: priority ? 'eager' : 'lazy', ...(priority ? { fetchPriority: 'high' } : {}) }));
|
|
59
|
+
}
|
|
60
|
+
return (_jsxs("div", { ...attributes, ...slotAttributes.children, className: className, children: [media, props.overlay === true ? _jsx("div", { "data-backdrop-overlay": "", "aria-hidden": "true", className: C.overlay }) : null, slots.children] }));
|
|
61
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BlockComponentProps } from '../../render/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A live saved section: its blocks, with no element of its own on the site. On the canvas an
|
|
4
|
+
* element with `display: contents` holds the editor attributes, so the editor can select it.
|
|
5
|
+
* The blocks come from `loadLayoutData` (or the canvas); without them the site shows nothing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SectionRef({ block, slots, attributes, mode }: BlockComponentProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SECTION_REF_SLOT } from '../../../blocks/builtins/sectionRef.js';
|
|
3
|
+
import { PlaceholderBox } from '../placeholder.js';
|
|
4
|
+
const CONTENTS = { display: 'contents' };
|
|
5
|
+
/**
|
|
6
|
+
* A live saved section: its blocks, with no element of its own on the site. On the canvas an
|
|
7
|
+
* element with `display: contents` holds the editor attributes, so the editor can select it.
|
|
8
|
+
* The blocks come from `loadLayoutData` (or the canvas); without them the site shows nothing.
|
|
9
|
+
*/
|
|
10
|
+
export function SectionRef({ block, slots, attributes, mode }) {
|
|
11
|
+
const loaded = (block.slots?.[SECTION_REF_SLOT]?.length ?? 0) > 0;
|
|
12
|
+
if (mode !== 'canvas')
|
|
13
|
+
return loaded ? slots[SECTION_REF_SLOT] : null;
|
|
14
|
+
if (!loaded)
|
|
15
|
+
return _jsx(PlaceholderBox, { attributes: attributes, label: "Saved section: pick one in the Content tab" });
|
|
16
|
+
return (_jsx("div", { ...attributes, style: CONTENTS, children: slots[SECTION_REF_SLOT] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BlockComponentProps } from '../../render/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Links to the H2 headings of the bound rich text (`content`). The ids come from `headingId`, the
|
|
4
|
+
* same function that gives the headings on the page their ids. The canvas shows sample links when
|
|
5
|
+
* there are too few headings, so the block can be selected and styled.
|
|
6
|
+
*/
|
|
7
|
+
export declare function TableOfContents({ props, className, attributes, mode }: BlockComponentProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { lexicalHeadings } from '../../../blocks/builtins/headingId.js';
|
|
3
|
+
import { textOr } from '../../../blocks/builtins/shared.js';
|
|
4
|
+
const SAMPLE = [
|
|
5
|
+
{ id: 'sample-1', text: 'First heading of the text (sample)' },
|
|
6
|
+
{ id: 'sample-2', text: 'Second heading (sample)' },
|
|
7
|
+
{ id: 'sample-3', text: 'Third heading (sample)' },
|
|
8
|
+
];
|
|
9
|
+
/**
|
|
10
|
+
* Links to the H2 headings of the bound rich text (`content`). The ids come from `headingId`, the
|
|
11
|
+
* same function that gives the headings on the page their ids. The canvas shows sample links when
|
|
12
|
+
* there are too few headings, so the block can be selected and styled.
|
|
13
|
+
*/
|
|
14
|
+
export function TableOfContents({ props, className, attributes, mode }) {
|
|
15
|
+
const min = typeof props.minHeadings === 'number' ? props.minHeadings : 3;
|
|
16
|
+
const found = lexicalHeadings(props.content);
|
|
17
|
+
const headings = found.length >= min ? found : mode === 'canvas' ? SAMPLE : [];
|
|
18
|
+
if (headings.length === 0)
|
|
19
|
+
return null;
|
|
20
|
+
return (_jsx("nav", { ...attributes, "aria-label": textOr(props.label, 'On this page'), className: className, children: headings.map((heading, i) => (_jsx("a", { href: `#${heading.id}`, children: heading.text }, `${heading.id}-${i}`))) }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type GlyphProps = {
|
|
2
|
+
className: string;
|
|
3
|
+
};
|
|
4
|
+
export declare function Chevron({ className, direction }: GlyphProps & {
|
|
5
|
+
direction: 'left' | 'right';
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export declare function CloseIcon({ className }: GlyphProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function Chevron({ className, direction }) {
|
|
3
|
+
return (_jsx("svg", { className: className, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: direction === 'left' ? 'M12.5 4.5 7 10l5.5 5.5' : 'M7.5 4.5 13 10l-5.5 5.5' }) }));
|
|
4
|
+
}
|
|
5
|
+
export function CloseIcon({ className }) {
|
|
6
|
+
return (_jsx("svg", { className: className, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M5 5l10 10M15 5L5 15" }) }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BlockComponents } from '../../render/types.js';
|
|
2
|
+
import { type IconMap } from './Icon.js';
|
|
3
|
+
import { type MediaUrl } from './MediaBackdrop.js';
|
|
4
|
+
export type BuiltinComponentsOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* The site's icons by name, for the `icon` block and the button's `icon` prop. The same names as
|
|
7
|
+
* `builtinBlocks({ icons })` and `defaultBlocks({ icons })`.
|
|
8
|
+
*/
|
|
9
|
+
icons?: IconMap;
|
|
10
|
+
/**
|
|
11
|
+
* Maps a stored media URL to the one the site serves, for the media backdrop's uploads. Example:
|
|
12
|
+
* `(url) => new URL(url, 'http://x').pathname` serves absolute URLs from the current host.
|
|
13
|
+
*/
|
|
14
|
+
mediaUrl?: MediaUrl;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The components of every built-in block. Merge them into your components map:
|
|
18
|
+
* `{ ...builtinComponents({ icons }), ...yours }`. A key of yours with the same type wins.
|
|
19
|
+
* Components of blocks you did not include are never rendered. To keep their code out of the
|
|
20
|
+
* bundle, import single components (`Carousel`, `Lightbox`, …) instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare function builtinComponents(options?: BuiltinComponentsOptions): BlockComponents;
|
|
23
|
+
export { buttonComponent } from '../Button.js';
|
|
24
|
+
export { Accordion } from './Accordion.js';
|
|
25
|
+
export { Carousel } from './Carousel.js';
|
|
26
|
+
export { Disclosure } from './Disclosure.js';
|
|
27
|
+
export { FilterLink } from './FilterLink.js';
|
|
28
|
+
export { iconComponent, type IconComponent, type IconMap } from './Icon.js';
|
|
29
|
+
export { Lightbox } from './Lightbox.js';
|
|
30
|
+
export { MediaBackdrop, mediaBackdropComponent, type MediaUrl } from './MediaBackdrop.js';
|
|
31
|
+
export { SectionRef } from './SectionRef.js';
|
|
32
|
+
export { TableOfContents } from './TableOfContents.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Components of the opt-in built-in blocks (`builtinBlocks()` in `payload-canvas/blocks`).
|
|
2
|
+
// Client-safe: the site and the canvas use the same map.
|
|
3
|
+
import { buttonComponent } from '../Button.js';
|
|
4
|
+
import { Accordion } from './Accordion.js';
|
|
5
|
+
import { Carousel } from './Carousel.js';
|
|
6
|
+
import { Disclosure } from './Disclosure.js';
|
|
7
|
+
import { FilterLink } from './FilterLink.js';
|
|
8
|
+
import { iconComponent } from './Icon.js';
|
|
9
|
+
import { Lightbox } from './Lightbox.js';
|
|
10
|
+
import { mediaBackdropComponent } from './MediaBackdrop.js';
|
|
11
|
+
import { SectionRef } from './SectionRef.js';
|
|
12
|
+
import { TableOfContents } from './TableOfContents.js';
|
|
13
|
+
/**
|
|
14
|
+
* The components of every built-in block. Merge them into your components map:
|
|
15
|
+
* `{ ...builtinComponents({ icons }), ...yours }`. A key of yours with the same type wins.
|
|
16
|
+
* Components of blocks you did not include are never rendered. To keep their code out of the
|
|
17
|
+
* bundle, import single components (`Carousel`, `Lightbox`, …) instead.
|
|
18
|
+
*/
|
|
19
|
+
export function builtinComponents(options = {}) {
|
|
20
|
+
const components = { disclosure: Disclosure, accordion: Accordion, lightbox: Lightbox, carousel: Carousel, tableOfContents: TableOfContents, filterLink: FilterLink, mediaBackdrop: mediaBackdropComponent(options.mediaUrl), sectionRef: SectionRef };
|
|
21
|
+
if (options.icons) {
|
|
22
|
+
components.icon = iconComponent(options.icons);
|
|
23
|
+
components.button = buttonComponent(options.icons);
|
|
24
|
+
}
|
|
25
|
+
return components;
|
|
26
|
+
}
|
|
27
|
+
export { buttonComponent } from '../Button.js';
|
|
28
|
+
export { Accordion } from './Accordion.js';
|
|
29
|
+
export { Carousel } from './Carousel.js';
|
|
30
|
+
export { Disclosure } from './Disclosure.js';
|
|
31
|
+
export { FilterLink } from './FilterLink.js';
|
|
32
|
+
export { iconComponent } from './Icon.js';
|
|
33
|
+
export { Lightbox } from './Lightbox.js';
|
|
34
|
+
export { MediaBackdrop, mediaBackdropComponent } from './MediaBackdrop.js';
|
|
35
|
+
export { SectionRef } from './SectionRef.js';
|
|
36
|
+
export { TableOfContents } from './TableOfContents.js';
|
package/dist/react/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { defaultResolveLink, linkAttributes, resolveLinkValue, toLinkValue, type
|
|
|
3
3
|
export { parseVideoUrl, type VideoEmbed } from './components/videoUrl.js';
|
|
4
4
|
export { editableImage, editableText, EDITABLE_IMAGE_ATTRIBUTE, EDITABLE_TEXT_ATTRIBUTE } from './render/editable.js';
|
|
5
5
|
export { defaultComponents } from './components/index.js';
|
|
6
|
+
export * from './components/builtins/index.js';
|
|
6
7
|
export { BuilderStyle, RenderLayout } from './render/RenderLayout.js';
|
|
7
8
|
export { MotionRuntime } from './motion/MotionRuntime.js';
|
|
8
9
|
export { MotionStyle, MOTION_CSS } from './motion/style.js';
|
|
@@ -13,7 +14,8 @@ export { LAYOUT_ROOT_ATTRIBUTE, REGION_ATTRIBUTE, siteRegion, type RegionMark }
|
|
|
13
14
|
export { LayoutOutlet } from './render/LayoutOutlet.js';
|
|
14
15
|
export type { CanvasDocumentRef, CanvasScope, CanvasServer, CanvasServerRequest, CanvasServerResponse, CanvasServerResult, } from './render/canvasServerTypes.js';
|
|
15
16
|
export { loadLayoutData, resolveLayoutData, urlResolver, type LoadLayoutOptions } from './render/resolve.js';
|
|
16
|
-
export {
|
|
17
|
+
export { attachSections } from './render/sections.js';
|
|
18
|
+
export { attachListItems, LIST_PAGE_PARAMS_PROP, LIST_PAGES_PROP, listItemsOf, listQueries, loadedLists, PAGE_PARAM, pageLinks, pageOf, pageParamOf, pageWindow, RANDOM_SORT, withDateTokens, withPageParams, type ListPages, type ListQuery, type LoadedList, type ListQueryParams, } from './render/lists.js';
|
|
17
19
|
export { fieldFor } from './components/Field.js';
|
|
18
20
|
export { renderRichText } from './components/RichText.js';
|
|
19
21
|
export { applyThemeOutput, ThemeLive } from './theme/ThemeLive.js';
|
package/dist/react/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { defaultResolveLink, linkAttributes, resolveLinkValue, toLinkValue, } fr
|
|
|
5
5
|
export { parseVideoUrl } from './components/videoUrl.js';
|
|
6
6
|
export { editableImage, editableText, EDITABLE_IMAGE_ATTRIBUTE, EDITABLE_TEXT_ATTRIBUTE } from './render/editable.js';
|
|
7
7
|
export { defaultComponents } from './components/index.js';
|
|
8
|
+
export * from './components/builtins/index.js';
|
|
8
9
|
export { BuilderStyle, RenderLayout } from './render/RenderLayout.js';
|
|
9
10
|
export { MotionRuntime } from './motion/MotionRuntime.js';
|
|
10
11
|
export { MotionStyle, MOTION_CSS } from './motion/style.js';
|
|
@@ -14,7 +15,8 @@ export { renderOnServer, withPageData } from './render/marks.js';
|
|
|
14
15
|
export { LAYOUT_ROOT_ATTRIBUTE, REGION_ATTRIBUTE, siteRegion } from './render/regions.js';
|
|
15
16
|
export { LayoutOutlet } from './render/LayoutOutlet.js';
|
|
16
17
|
export { loadLayoutData, resolveLayoutData, urlResolver } from './render/resolve.js';
|
|
17
|
-
export {
|
|
18
|
+
export { attachSections } from './render/sections.js';
|
|
19
|
+
export { attachListItems, LIST_PAGE_PARAMS_PROP, LIST_PAGES_PROP, listItemsOf, listQueries, loadedLists, PAGE_PARAM, pageLinks, pageOf, pageParamOf, pageWindow, RANDOM_SORT, withDateTokens, withPageParams, } from './render/lists.js';
|
|
18
20
|
export { fieldFor } from './components/Field.js';
|
|
19
21
|
export { renderRichText } from './components/RichText.js';
|
|
20
22
|
export { applyThemeOutput, ThemeLive } from './theme/ThemeLive.js';
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
// - Loops: an endless animation that pauses while the block is out of view (`inView`).
|
|
12
12
|
//
|
|
13
13
|
// Properties: entrances, hover and press animate `opacity`, `transform`, `filter` and `clip-path`;
|
|
14
|
-
// scroll and loop effects use the separate `translate`, `scale` and `opacity` properties
|
|
15
|
-
// add to the others instead of replacing them. Nothing changes layout, so nothing shifts.
|
|
14
|
+
// scroll and loop effects use the separate `translate`, `scale` and `opacity` properties (and
|
|
15
|
+
// `filter` for the recede dim), so they add to the others instead of replacing them. Nothing changes layout, so nothing shifts.
|
|
16
16
|
import { hover, inView, press, scroll, spring, stagger } from 'motion';
|
|
17
17
|
import { animate } from 'motion/mini';
|
|
18
18
|
import { EASING_CURVES, enterFrom, enterTiming, enterView, interactTransform, loopPlan, MOTION_ATTR, MOTION_ITEM_ATTR, MOTION_READY_ATTR, MOTION_REVEAL_ATTR, parseMotionAttribute, scrollPlan, SPRING_BOUNCE, staggersChildren, } from '../../core/index.js';
|
|
@@ -416,10 +416,13 @@ class MotionController {
|
|
|
416
416
|
if (!plan)
|
|
417
417
|
return;
|
|
418
418
|
const { el } = entry;
|
|
419
|
-
const
|
|
420
|
-
|
|
419
|
+
const target = plan.target === 'next' ? el.nextElementSibling : el;
|
|
420
|
+
if (!(target instanceof HTMLElement))
|
|
421
|
+
return;
|
|
422
|
+
const anim = animate(el, plan.keyframes, { ease: 'linear', duration: 1 });
|
|
423
|
+
const options = { target, offset: plan.offset, container: this.doc.scrollingElement ?? undefined };
|
|
421
424
|
let stop;
|
|
422
|
-
if (insideScrollBox(
|
|
425
|
+
if (insideScrollBox(target)) {
|
|
423
426
|
// A native ViewTimeline follows the nearest scroll box, and `overflow: hidden` (the usual
|
|
424
427
|
// parallax frame) makes one that never scrolls. Follow the page scroll in JavaScript instead.
|
|
425
428
|
anim.pause();
|
|
@@ -433,7 +436,8 @@ class MotionController {
|
|
|
433
436
|
entry.stops.push(() => {
|
|
434
437
|
stop();
|
|
435
438
|
anim.cancel();
|
|
436
|
-
|
|
439
|
+
for (const property of Object.keys(plan.keyframes))
|
|
440
|
+
el.style.removeProperty(property);
|
|
437
441
|
});
|
|
438
442
|
}
|
|
439
443
|
setupLoop(entry) {
|
|
@@ -7,7 +7,7 @@ import type { RenderLayoutProps } from './types.js';
|
|
|
7
7
|
* With `context`, bound props and Field blocks read that document. Collection lists render their
|
|
8
8
|
* `item` slot once per document (load them with `loadLayoutData`).
|
|
9
9
|
*/
|
|
10
|
-
export declare function RenderLayout({ layout, components, css, mode, blocks, resolveLink, context, pageData, }: RenderLayoutProps): ReactNode;
|
|
10
|
+
export declare function RenderLayout({ layout, components, css, mode, blocks, resolveLink, context, pageData, relations, }: RenderLayoutProps): ReactNode;
|
|
11
11
|
export type PreviewBlockOptions = Pick<RenderLayoutProps, 'components' | 'blocks' | 'resolveLink' | 'context' | 'pageData'>;
|
|
12
12
|
/**
|
|
13
13
|
* Server preview for the canvas (`createCanvasServer`): renders one block (its data already
|