@cntrl-site/components 1.0.106-alpha.0 → 1.0.107-alpha.1
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/dist/ArchivePopup-DMpGP8r2.js +176 -0
- package/dist/ArchivePopup-X4EtTAyA.mjs +694 -0
- package/dist/ArchivePopupComponent-BTniPIfi.js +1 -0
- package/dist/{PretextComponent-j-OsRZTx.mjs → ArchivePopupComponent-GgAT2Avz.mjs} +954 -479
- package/dist/ClickGallerie-CYQMgrIr.js +36 -0
- package/dist/ClickGallerie-o2U6oyOF.mjs +272 -0
- package/dist/Components/ArchivePopup/ArchivePopup.d.ts +154 -0
- package/dist/Components/ArchivePopup/ArchivePopupComponent.d.ts +288 -0
- package/dist/Components/ClickGallerie/ClickGallerie.d.ts +2 -1
- package/dist/Components/Helix/Helix.d.ts +4 -1
- package/dist/Components/Hive/Hive.d.ts +4 -1
- package/dist/Components/ImageRevealSlider/ImageRevealSlider.d.ts +2 -1
- package/dist/Components/List/List.d.ts +6 -2
- package/dist/Components/Marquee/Marquee.d.ts +6 -2
- package/dist/Components/MarqueeText/MarqueeText.d.ts +2 -1
- package/dist/Components/Mercury/Mercury.d.ts +4 -1
- package/dist/Components/Waterfall/WaterfallLightbox.d.ts +4 -1
- package/dist/Components/utils/EmbedMediaFrame.d.ts +27 -0
- package/dist/Components/utils/LinkWrapper.d.ts +16 -0
- package/dist/Components/utils/embedMedia.d.ts +40 -0
- package/dist/Components/utils/index.d.ts +6 -0
- package/dist/{ControlSlider-SiOt22l_.js → ControlSlider-Kkec-i14.js} +1 -1
- package/dist/{ControlSlider-pZv7H6BU.mjs → ControlSlider-LcZmviGX.mjs} +1 -1
- package/dist/EmbedMediaFrame-DsOTKE4i.js +1 -0
- package/dist/EmbedMediaFrame-DwHeOAy5.mjs +164 -0
- package/dist/{FAQ-C7823fyi.js → FAQ-BxhMo7T8.js} +1 -1
- package/dist/{FAQ-CZ39u4m8.mjs → FAQ-CdwSft5p.mjs} +1 -1
- package/dist/Grid-CFHTP3mb.js +378 -0
- package/dist/Grid-e-gLfsji.mjs +1590 -0
- package/dist/Helix-BpLo9FD3.js +43 -0
- package/dist/Helix-CidI3ucE.mjs +324 -0
- package/dist/{Hive-D6-R6TwM.mjs → Hive-BsmFHk2i.mjs} +505 -475
- package/dist/Hive-D1j6wZpV.js +321 -0
- package/dist/ImageRevealSlider-BuukTGAK.js +1 -0
- package/dist/{ImageRevealSlider-BdFGyVEP.mjs → ImageRevealSlider-Df9sygk9.mjs} +63 -70
- package/dist/{Lightbox-eP9qAZzL.mjs → Lightbox-C_fXsfdz.mjs} +1 -1
- package/dist/{Lightbox-CIss_nOG.js → Lightbox-DaunVrkp.js} +1 -1
- package/dist/LinkWrapper-Ca84iPtg.js +1 -0
- package/dist/LinkWrapper-DZs9hlOn.mjs +13 -0
- package/dist/{List-DW7fyJbf.mjs → List-Bh_-l9vD.mjs} +532 -520
- package/dist/List-DVvpQ24J.js +377 -0
- package/dist/Marquee-DByooiWP.mjs +578 -0
- package/dist/Marquee-DfIP-tIN.js +133 -0
- package/dist/{MarqueeText-Rzt2fJYt.mjs → MarqueeText-D6FNCe6P.mjs} +115 -114
- package/dist/MarqueeText-DsUiV6Zv.js +132 -0
- package/dist/Mercury-B-s2Kvuq.js +267 -0
- package/dist/Mercury-CCW0Es-s.mjs +1700 -0
- package/dist/{RichTextRenderer-B6WtTYlR.mjs → RichTextRenderer-BptwNpbJ.mjs} +10 -9
- package/dist/RichTextRenderer-K90Dd7pt.js +1 -0
- package/dist/{Slider20-Dm8BeCli.mjs → Slider20-CCzixTiN.mjs} +1 -1
- package/dist/{Slider20-C9o2REDl.js → Slider20-fMVeRfgx.js} +1 -1
- package/dist/{TestimonialGrid-CPu4qQ6B.mjs → TestimonialGrid-CbsVxSn9.mjs} +1 -1
- package/dist/{TestimonialGrid-D4ieiz9e.js → TestimonialGrid-CiCagfBU.js} +1 -1
- package/dist/{TestimonialSingle-DLdnAVF7.mjs → TestimonialSingle-BVm3Amrl.mjs} +1 -1
- package/dist/{TestimonialSingle-CVu15ZtV.js → TestimonialSingle-BWXynGjv.js} +1 -1
- package/dist/Waterfall-3kKioKh2.mjs +1432 -0
- package/dist/Waterfall-DII4-WV5.js +288 -0
- package/dist/{components-D2LyuDm-.mjs → components-DKuQ8PUa.mjs} +19 -18
- package/dist/components-SEwSqFrQ.js +1 -0
- package/dist/content/postFieldBindings.d.ts +29 -0
- package/dist/elements.js +1 -1
- package/dist/elements.mjs +22 -21
- package/dist/elements.node.js +1 -1
- package/dist/elements.node.mjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +52 -15
- package/dist/sources.js +1331 -233
- package/dist/sources.mjs +1355 -256
- package/dist/types/SchemaV1.d.ts +53 -1
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +30 -20
- package/package.json +1 -1
- package/dist/ClickGallerie-D7g093HX.js +0 -36
- package/dist/ClickGallerie-QSOQjSdv.mjs +0 -271
- package/dist/Grid-BBpdl60K.js +0 -374
- package/dist/Grid-DS53S_gA.mjs +0 -1576
- package/dist/Helix-BPn9V1sg.mjs +0 -315
- package/dist/Helix-DcgsCc4D.js +0 -43
- package/dist/Hive-n8Fz-j3o.js +0 -321
- package/dist/ImageRevealSlider-BBWtFjUF.js +0 -1
- package/dist/List-C32WImI3.js +0 -377
- package/dist/Marquee-DOIRRCu4.js +0 -133
- package/dist/Marquee-O_PDwlIb.mjs +0 -564
- package/dist/MarqueeText-DkaO2lQ5.js +0 -132
- package/dist/Mercury-C9D10TTT.mjs +0 -1702
- package/dist/Mercury-DynO-NxY.js +0 -267
- package/dist/PretextComponent-BnsS2zJ6.js +0 -1
- package/dist/RichTextRenderer-CIy6yI8U.js +0 -1
- package/dist/Waterfall-DC2WQ3GT.js +0 -287
- package/dist/Waterfall-Yud2VR62.mjs +0 -1404
- package/dist/components-B9Vdjf0w.js +0 -1
package/dist/sources.mjs
CHANGED
|
@@ -1,5 +1,1003 @@
|
|
|
1
|
-
import { W as n, b as e, T as t, g as i, f as o, S as r, P as a, O as s, h as l, a as c, M as d, L as u, d as g, e as m, H as p, i as h, G as f, F as v, c as P, C as x, B as b } from "./
|
|
2
|
-
const
|
|
1
|
+
import { W as n, b as e, T as t, g as i, f as o, S as r, P as a, O as s, h as l, a as c, M as d, L as u, d as g, e as m, H as p, i as h, G as f, F as v, c as P, C as x, B as b, A as y } from "./ArchivePopupComponent-GgAT2Avz.mjs";
|
|
2
|
+
const S = `import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
import { CommonComponentProps } from '../props';
|
|
6
|
+
import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index';
|
|
7
|
+
import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
|
|
8
|
+
import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss';
|
|
9
|
+
import { useLightboxScrollLock } from '../utils/useLightboxScrollLock';
|
|
10
|
+
|
|
11
|
+
type ArchivePopupMedia = {
|
|
12
|
+
assetId: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
type?: 'image' | 'video';
|
|
15
|
+
objectFit?: 'cover' | 'contain';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Columns count the group column too, so the least is the group and its title. */
|
|
19
|
+
export const ARCHIVE_POPUP_MIN_COLUMNS = 2;
|
|
20
|
+
export const ARCHIVE_POPUP_MAX_COLUMNS = 5;
|
|
21
|
+
/** The fields of the columns after the title, in order; \`columns\` decides how many of them a row shows. */
|
|
22
|
+
export const ARCHIVE_POPUP_EXTRA_TITLE_KEYS = ['title2', 'title3', 'title4'] as const;
|
|
23
|
+
/** Every column but the last has a width of its own, like Programme's; the last takes what is left of the row. */
|
|
24
|
+
export const ARCHIVE_POPUP_COLUMN_WIDTH_KEYS = ['column1Width', 'column2Width', 'column3Width', 'column4Width'] as const;
|
|
25
|
+
|
|
26
|
+
type ArchivePopupColumnWidthKey = typeof ARCHIVE_POPUP_COLUMN_WIDTH_KEYS[number];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Where A's panel sits on the screen, as \`left\`/\`top\` of the screen and of the panel alike, so 0% is flush with
|
|
30
|
+
* one edge and 100% with the other. Named like Mercury's title position; center comes first because the editor
|
|
31
|
+
* puts the first value into a popup saved before there was a position, and those were centred.
|
|
32
|
+
*/
|
|
33
|
+
const PANEL_POSITION_OFFSETS = {
|
|
34
|
+
center: { x: '50%', y: '50%' },
|
|
35
|
+
'left-top': { x: '0%', y: '0%' },
|
|
36
|
+
'top-center': { x: '50%', y: '0%' },
|
|
37
|
+
'top-right': { x: '100%', y: '0%' },
|
|
38
|
+
'left-center': { x: '0%', y: '50%' },
|
|
39
|
+
'right-center': { x: '100%', y: '50%' },
|
|
40
|
+
'left-bottom': { x: '0%', y: '100%' },
|
|
41
|
+
'bottom-center': { x: '50%', y: '100%' },
|
|
42
|
+
'right-bottom': { x: '100%', y: '100%' },
|
|
43
|
+
} as const;
|
|
44
|
+
|
|
45
|
+
export type ArchivePopupPanelPosition = keyof typeof PANEL_POSITION_OFFSETS;
|
|
46
|
+
|
|
47
|
+
export const ARCHIVE_POPUP_PANEL_POSITIONS = Object.keys(PANEL_POSITION_OFFSETS) as ArchivePopupPanelPosition[];
|
|
48
|
+
|
|
49
|
+
/** Each column of a row has a text style of its own, the group column's being \`column1\`. */
|
|
50
|
+
export const ARCHIVE_POPUP_COLUMN_STYLE_PREFIXES = ['column1', 'column2', 'column3', 'column4', 'column5'] as const;
|
|
51
|
+
|
|
52
|
+
type ArchivePopupColumnStylePrefix = typeof ARCHIVE_POPUP_COLUMN_STYLE_PREFIXES[number];
|
|
53
|
+
|
|
54
|
+
type ArchivePopupTitle = any[] | string;
|
|
55
|
+
|
|
56
|
+
export type ArchivePopupContentItem = {
|
|
57
|
+
group?: string;
|
|
58
|
+
/** Rich text, so parts of a title can be linked; a plain string is still shown as is. */
|
|
59
|
+
title?: ArchivePopupTitle;
|
|
60
|
+
title2?: ArchivePopupTitle;
|
|
61
|
+
title3?: ArchivePopupTitle;
|
|
62
|
+
title4?: ArchivePopupTitle;
|
|
63
|
+
image?: ArchivePopupMedia;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type FontSettings = { fontWeight: number; fontStyle: string };
|
|
67
|
+
|
|
68
|
+
type Padding = { top: number; right: number; bottom: number; left: number };
|
|
69
|
+
|
|
70
|
+
/** A text style as settings hold it, each field under the name of what it styles, e.g. \`triggerFontSize\`. */
|
|
71
|
+
type TextStyleFields = {
|
|
72
|
+
FontFamily?: string;
|
|
73
|
+
FontSettings?: FontSettings;
|
|
74
|
+
FontSize?: number;
|
|
75
|
+
LineHeight?: number;
|
|
76
|
+
LetterSpacing?: number;
|
|
77
|
+
WordSpacing?: number;
|
|
78
|
+
TextAlign?: TextStyles['textAlign'];
|
|
79
|
+
TextAppearance?: TextStyles['textAppearance'];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
type PrefixedTextStyle<Prefix extends string> = {
|
|
83
|
+
[Key in keyof TextStyleFields as \`\${Prefix}\${Key}\`]?: TextStyleFields[Key];
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
type ArchivePopupSettings = PrefixedTextStyle<'trigger'>
|
|
87
|
+
& PrefixedTextStyle<ArchivePopupColumnStylePrefix>
|
|
88
|
+
// One style every column shared before each had its own; a column with no style of its own still shows it.
|
|
89
|
+
& PrefixedTextStyle<'list'>
|
|
90
|
+
& {
|
|
91
|
+
/** \`a\` opens from a label; \`b\` is always open, in place on the page. */
|
|
92
|
+
type?: 'a' | 'b';
|
|
93
|
+
triggerLabel?: string;
|
|
94
|
+
closeLabel?: string;
|
|
95
|
+
/** Every column of a row, the group column included. */
|
|
96
|
+
columns?: number;
|
|
97
|
+
columnGap?: number;
|
|
98
|
+
column1Width?: number;
|
|
99
|
+
column2Width?: number;
|
|
100
|
+
column3Width?: number;
|
|
101
|
+
column4Width?: number;
|
|
102
|
+
/** A only: B's panel stays where it is placed on the page. */
|
|
103
|
+
panelPosition?: string;
|
|
104
|
+
panelWidth?: number;
|
|
105
|
+
panelPadding?: Padding;
|
|
106
|
+
panelRadius?: number;
|
|
107
|
+
groupGap?: number;
|
|
108
|
+
triggerColor?: string;
|
|
109
|
+
triggerHoverColor?: string;
|
|
110
|
+
closeColor?: string;
|
|
111
|
+
closeHoverColor?: string;
|
|
112
|
+
panelColor?: string;
|
|
113
|
+
textColor?: string;
|
|
114
|
+
textHoverColor?: string;
|
|
115
|
+
overlayColor?: string;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type ArchivePopupProps = {
|
|
119
|
+
settings: ArchivePopupSettings;
|
|
120
|
+
content?: ArchivePopupContentItem[];
|
|
121
|
+
isEditor?: boolean;
|
|
122
|
+
isEditMode?: boolean;
|
|
123
|
+
isPreviewMode?: boolean;
|
|
124
|
+
activeEvent?: string;
|
|
125
|
+
portalId?: string;
|
|
126
|
+
} & CommonComponentProps;
|
|
127
|
+
|
|
128
|
+
export type ArchivePopupRow = {
|
|
129
|
+
item: ArchivePopupContentItem;
|
|
130
|
+
index: number;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export type ArchivePopupGroup = {
|
|
134
|
+
label: string;
|
|
135
|
+
rows: ArchivePopupRow[];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
type ColorKeys =
|
|
139
|
+
| 'triggerColor'
|
|
140
|
+
| 'triggerHoverColor'
|
|
141
|
+
| 'closeColor'
|
|
142
|
+
| 'closeHoverColor'
|
|
143
|
+
| 'panelColor'
|
|
144
|
+
| 'textColor'
|
|
145
|
+
| 'textHoverColor'
|
|
146
|
+
| 'overlayColor';
|
|
147
|
+
|
|
148
|
+
const COLOR_VAR_MAP: Record<ColorKeys, string> = {
|
|
149
|
+
triggerColor: 'trigger-color',
|
|
150
|
+
triggerHoverColor: 'trigger-hover-color',
|
|
151
|
+
closeColor: 'close-color',
|
|
152
|
+
closeHoverColor: 'close-hover-color',
|
|
153
|
+
panelColor: 'panel-color',
|
|
154
|
+
textColor: 'text-color',
|
|
155
|
+
textHoverColor: 'text-hover-color',
|
|
156
|
+
overlayColor: 'overlay-color',
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const STATE_KEYS = ['hover', 'open'] as const;
|
|
160
|
+
|
|
161
|
+
const OVERLAY_ANIM_MS = 300;
|
|
162
|
+
// The least a padding handle is drawn at, so a zero padding can still be grabbed.
|
|
163
|
+
const PADDING_HANDLE_SIZE = 0.004;
|
|
164
|
+
const COLUMN_RESIZE_HANDLE_WIDTH = 0.004;
|
|
165
|
+
// The least a column is dragged down to, in pixels of the layout.
|
|
166
|
+
const MIN_COLUMN_WIDTH_PX = 20;
|
|
167
|
+
const DEFAULT_COLUMN_GAP = 0.0139;
|
|
168
|
+
const DEFAULT_PANEL_WIDTH = 0.3194;
|
|
169
|
+
const DEFAULT_PANEL_PADDING: Padding = { top: 0.00972, right: 0.00972, bottom: 0.00972, left: 0.00972 };
|
|
170
|
+
const IMAGE_FADE_MS = 800;
|
|
171
|
+
|
|
172
|
+
const LIGHTBOX_CSS_VARS = [
|
|
173
|
+
'--cntrl-article-width',
|
|
174
|
+
'--cntrl-article-top',
|
|
175
|
+
'--cntrl-article-left',
|
|
176
|
+
'--cntrl-viewport-height',
|
|
177
|
+
] as const;
|
|
178
|
+
|
|
179
|
+
// A row with an empty group continues the group above it, so the label only has to be typed once.
|
|
180
|
+
type ColumnLayoutSettings = Pick<ArchivePopupSettings, 'columns' | 'columnGap' | 'panelWidth' | 'panelPadding'>
|
|
181
|
+
& Partial<Record<ArchivePopupColumnWidthKey, number>>;
|
|
182
|
+
|
|
183
|
+
function getColumnCount(columns: number | undefined): number {
|
|
184
|
+
return Math.min(Math.max(Math.round(columns ?? ARCHIVE_POPUP_MIN_COLUMNS), ARCHIVE_POPUP_MIN_COLUMNS), ARCHIVE_POPUP_MAX_COLUMNS);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** The width a row's columns share: the panel's, less its padding and the gaps between them. */
|
|
188
|
+
function getColumnsSpace(settings: ColumnLayoutSettings): number {
|
|
189
|
+
const { panelWidth = DEFAULT_PANEL_WIDTH, panelPadding = DEFAULT_PANEL_PADDING, columnGap = DEFAULT_COLUMN_GAP } = settings;
|
|
190
|
+
const gaps = (getColumnCount(settings.columns) - 1) * columnGap;
|
|
191
|
+
return Math.max(0, panelWidth - panelPadding.left - panelPadding.right - gaps);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function getArchivePopupEqualColumnWidths(settings: ColumnLayoutSettings): Partial<Record<ArchivePopupColumnWidthKey, number>> {
|
|
195
|
+
const count = getColumnCount(settings.columns);
|
|
196
|
+
const width = getColumnsSpace(settings) / count;
|
|
197
|
+
return Object.fromEntries(ARCHIVE_POPUP_COLUMN_WIDTH_KEYS.slice(0, count - 1).map((key) => [key, width]));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Every column's width, the last taking what the others leave. A column with no width of its own gets an equal share,
|
|
202
|
+
* and widths that no longer fit, after the panel narrows or a column is added, shrink together until they do.
|
|
203
|
+
*/
|
|
204
|
+
export function resolveArchivePopupColumnWidths(settings: ColumnLayoutSettings): number[] {
|
|
205
|
+
const count = getColumnCount(settings.columns);
|
|
206
|
+
const space = getColumnsSpace(settings);
|
|
207
|
+
const sized = ARCHIVE_POPUP_COLUMN_WIDTH_KEYS.slice(0, count - 1).map((key) => {
|
|
208
|
+
const width = settings[key];
|
|
209
|
+
return typeof width === 'number' ? Math.max(0, width) : space / count;
|
|
210
|
+
});
|
|
211
|
+
const sizedTotal = sized.reduce((sum, width) => sum + width, 0);
|
|
212
|
+
const scale = sizedTotal > space ? space / sizedTotal : 1;
|
|
213
|
+
const fitted = sized.map((width) => width * scale);
|
|
214
|
+
return [...fitted, Math.max(0, space - sizedTotal * scale)];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Like Programme, a new column count starts the columns over at equal widths. */
|
|
218
|
+
export function applyArchivePopupColumnCountChange(
|
|
219
|
+
nextSettings: Record<string, any>,
|
|
220
|
+
prevSettings: Record<string, any>,
|
|
221
|
+
): Record<string, any> {
|
|
222
|
+
if (typeof nextSettings.columns !== 'number' || nextSettings.columns === prevSettings.columns) {
|
|
223
|
+
return nextSettings;
|
|
224
|
+
}
|
|
225
|
+
return { ...nextSettings, ...getArchivePopupEqualColumnWidths({ ...prevSettings, ...nextSettings }) };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// The columns stay in proportion when the panel is drawn narrower than its width, on a small screen.
|
|
229
|
+
function getGridTemplateColumns(widths: number[]): string {
|
|
230
|
+
const total = widths.reduce((sum, width) => sum + width, 0);
|
|
231
|
+
return widths.map((width) => \`minmax(0, \${total > 0 ? (width / total) * 100 : 1}fr)\`).join(' ');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export function groupArchiveRows(items: ArchivePopupContentItem[]): ArchivePopupGroup[] {
|
|
235
|
+
const groups: ArchivePopupGroup[] = [];
|
|
236
|
+
items.forEach((item, index) => {
|
|
237
|
+
const label = item.group?.trim() ?? '';
|
|
238
|
+
const current = groups[groups.length - 1];
|
|
239
|
+
if (!current || (label !== '' && label !== current.label)) {
|
|
240
|
+
groups.push({ label, rows: [{ item, index }] });
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
current.rows.push({ item, index });
|
|
244
|
+
});
|
|
245
|
+
return groups;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function isVideoMedia(media: ArchivePopupMedia): boolean {
|
|
249
|
+
if (media.type === 'video') return true;
|
|
250
|
+
if (media.type === 'image') return false;
|
|
251
|
+
return /\\.(mp4|webm|ogg|mov)(\\?|$)/i.test(media.name ?? '') || /\\.(mp4|webm|ogg|mov)(\\?|$)/i.test(media.assetId);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function findLayoutContainer(element: HTMLElement | null): HTMLElement | null {
|
|
255
|
+
let el = element;
|
|
256
|
+
while (el) {
|
|
257
|
+
if (getComputedStyle(el).getPropertyValue('--cntrl-article-width').trim()) {
|
|
258
|
+
return el;
|
|
259
|
+
}
|
|
260
|
+
el = el.parentElement;
|
|
261
|
+
}
|
|
262
|
+
return element;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function getLightboxLayoutStyle(container: HTMLElement | null): CSSProperties {
|
|
266
|
+
const style: Record<string, string> = {};
|
|
267
|
+
const layoutContainer = findLayoutContainer(container);
|
|
268
|
+
if (!layoutContainer) return style;
|
|
269
|
+
const computed = getComputedStyle(layoutContainer);
|
|
270
|
+
for (const varName of LIGHTBOX_CSS_VARS) {
|
|
271
|
+
const value = computed.getPropertyValue(varName).trim();
|
|
272
|
+
if (value) {
|
|
273
|
+
style[varName] = value;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return style;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function resolveTextStyle(settings: ArchivePopupSettings, prefix: string, fallbackPrefix?: string): TextStyles {
|
|
280
|
+
const values = settings as Record<string, unknown>;
|
|
281
|
+
const read = <Key extends keyof TextStyleFields>(key: Key) => (
|
|
282
|
+
values[\`\${prefix}\${key}\`] ?? (fallbackPrefix ? values[\`\${fallbackPrefix}\${key}\`] : undefined)
|
|
283
|
+
) as TextStyleFields[Key];
|
|
284
|
+
const fontSettings = read('FontSettings');
|
|
285
|
+
return {
|
|
286
|
+
fontSettings: {
|
|
287
|
+
fontFamily: read('FontFamily'),
|
|
288
|
+
fontWeight: fontSettings?.fontWeight ?? 400,
|
|
289
|
+
fontStyle: fontSettings?.fontStyle ?? 'normal',
|
|
290
|
+
},
|
|
291
|
+
fontSize: read('FontSize') ?? 0.01,
|
|
292
|
+
lineHeight: read('LineHeight'),
|
|
293
|
+
letterSpacing: read('LetterSpacing') ?? 0,
|
|
294
|
+
wordSpacing: read('WordSpacing') ?? 0,
|
|
295
|
+
textAlign: read('TextAlign'),
|
|
296
|
+
textAppearance: read('TextAppearance'),
|
|
297
|
+
color: '#000000',
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function getCSS(P: string): string {
|
|
302
|
+
return \`
|
|
303
|
+
.\${P}-trigger,
|
|
304
|
+
.\${P}-close {
|
|
305
|
+
display: inline-block;
|
|
306
|
+
margin: 0;
|
|
307
|
+
padding: 0;
|
|
308
|
+
border: 0;
|
|
309
|
+
background: none;
|
|
310
|
+
cursor: pointer;
|
|
311
|
+
white-space: nowrap;
|
|
312
|
+
transition: color 150ms ease;
|
|
313
|
+
-webkit-appearance: none;
|
|
314
|
+
appearance: none;
|
|
315
|
+
-webkit-tap-highlight-color: transparent;
|
|
316
|
+
}
|
|
317
|
+
.\${P}-trigger {
|
|
318
|
+
color: var(--\${P}-trigger-color);
|
|
319
|
+
}
|
|
320
|
+
.\${P}-close {
|
|
321
|
+
color: var(--\${P}-close-color);
|
|
322
|
+
}
|
|
323
|
+
.\${P}-trigger:focus,
|
|
324
|
+
.\${P}-close:focus {
|
|
325
|
+
outline: none;
|
|
326
|
+
}
|
|
327
|
+
.\${P}-trigger:focus-visible,
|
|
328
|
+
.\${P}-close:focus-visible {
|
|
329
|
+
outline: 1px solid currentColor;
|
|
330
|
+
outline-offset: 2px;
|
|
331
|
+
}
|
|
332
|
+
.\${P}-interactive .\${P}-trigger:hover,
|
|
333
|
+
.\${P}-state-hover .\${P}-trigger {
|
|
334
|
+
color: var(--\${P}-trigger-hover-color, var(--\${P}-trigger-color));
|
|
335
|
+
}
|
|
336
|
+
.\${P}-close:hover {
|
|
337
|
+
color: var(--\${P}-close-hover-color, var(--\${P}-close-color));
|
|
338
|
+
}
|
|
339
|
+
.\${P}-editor .\${P}-trigger {
|
|
340
|
+
cursor: default;
|
|
341
|
+
}
|
|
342
|
+
.\${P}-overlay {
|
|
343
|
+
position: fixed;
|
|
344
|
+
inset: 0;
|
|
345
|
+
z-index: 9997;
|
|
346
|
+
overflow: hidden;
|
|
347
|
+
overscroll-behavior: none;
|
|
348
|
+
opacity: 0;
|
|
349
|
+
pointer-events: none;
|
|
350
|
+
transition: opacity \${OVERLAY_ANIM_MS}ms ease;
|
|
351
|
+
}
|
|
352
|
+
.\${P}-inline-layer {
|
|
353
|
+
position: fixed;
|
|
354
|
+
inset: 0;
|
|
355
|
+
z-index: 9997;
|
|
356
|
+
overflow: hidden;
|
|
357
|
+
pointer-events: none;
|
|
358
|
+
}
|
|
359
|
+
.\${P}-overlay-editor {
|
|
360
|
+
inset: auto;
|
|
361
|
+
top: var(--cntrl-article-top, 0);
|
|
362
|
+
left: var(--cntrl-article-left, 0);
|
|
363
|
+
width: var(--cntrl-article-width, 100vw) !important;
|
|
364
|
+
height: var(--cntrl-viewport-height, 100vh) !important;
|
|
365
|
+
}
|
|
366
|
+
.\${P}-overlay-edit-mode {
|
|
367
|
+
z-index: 1;
|
|
368
|
+
}
|
|
369
|
+
.\${P}-overlay-active {
|
|
370
|
+
opacity: 1;
|
|
371
|
+
pointer-events: auto;
|
|
372
|
+
}
|
|
373
|
+
.\${P}-backdrop {
|
|
374
|
+
position: absolute;
|
|
375
|
+
inset: 0;
|
|
376
|
+
background-color: var(--\${P}-overlay-color);
|
|
377
|
+
}
|
|
378
|
+
.\${P}-media-layer {
|
|
379
|
+
position: absolute;
|
|
380
|
+
inset: 0;
|
|
381
|
+
pointer-events: none;
|
|
382
|
+
}
|
|
383
|
+
.\${P}-media {
|
|
384
|
+
position: absolute;
|
|
385
|
+
inset: 0;
|
|
386
|
+
width: 100%;
|
|
387
|
+
height: 100%;
|
|
388
|
+
object-fit: cover;
|
|
389
|
+
opacity: 0;
|
|
390
|
+
transition: opacity \${IMAGE_FADE_MS}ms cubic-bezier(0, 0, 0.58, 1);
|
|
391
|
+
}
|
|
392
|
+
.\${P}-media-contain {
|
|
393
|
+
object-fit: contain;
|
|
394
|
+
}
|
|
395
|
+
.\${P}-media-visible {
|
|
396
|
+
opacity: 1;
|
|
397
|
+
}
|
|
398
|
+
.\${P}-close {
|
|
399
|
+
position: absolute;
|
|
400
|
+
z-index: 2;
|
|
401
|
+
}
|
|
402
|
+
.\${P}-panel {
|
|
403
|
+
position: absolute;
|
|
404
|
+
top: var(--\${P}-panel-y);
|
|
405
|
+
left: var(--\${P}-panel-x);
|
|
406
|
+
z-index: 1;
|
|
407
|
+
box-sizing: border-box;
|
|
408
|
+
max-width: 100%;
|
|
409
|
+
max-height: 100%;
|
|
410
|
+
overflow-y: auto;
|
|
411
|
+
transform: translate(calc(-1 * var(--\${P}-panel-x)), calc(-1 * var(--\${P}-panel-y) + 12px));
|
|
412
|
+
background-color: var(--\${P}-panel-color);
|
|
413
|
+
color: var(--\${P}-text-color);
|
|
414
|
+
overscroll-behavior: contain;
|
|
415
|
+
transition: transform \${OVERLAY_ANIM_MS}ms cubic-bezier(0, 0, 0.58, 1);
|
|
416
|
+
}
|
|
417
|
+
.\${P}-overlay-active .\${P}-panel {
|
|
418
|
+
transform: translate(calc(-1 * var(--\${P}-panel-x)), calc(-1 * var(--\${P}-panel-y)));
|
|
419
|
+
}
|
|
420
|
+
.\${P}-panel-settled {
|
|
421
|
+
transition: none;
|
|
422
|
+
}
|
|
423
|
+
.\${P}-panel-inline {
|
|
424
|
+
position: relative;
|
|
425
|
+
top: auto;
|
|
426
|
+
left: auto;
|
|
427
|
+
max-height: none;
|
|
428
|
+
transform: none;
|
|
429
|
+
transition: none;
|
|
430
|
+
}
|
|
431
|
+
.\${P}-media-layer-instant .\${P}-media {
|
|
432
|
+
transition: none;
|
|
433
|
+
}
|
|
434
|
+
.\${P}-panel-copy {
|
|
435
|
+
position: absolute;
|
|
436
|
+
pointer-events: none;
|
|
437
|
+
}
|
|
438
|
+
.\${P}-panel-copy .\${P}-row-active .\${P}-title {
|
|
439
|
+
color: var(--\${P}-text-hover-color, var(--\${P}-text-color));
|
|
440
|
+
}
|
|
441
|
+
@media (prefers-reduced-motion: reduce) {
|
|
442
|
+
.\${P}-panel {
|
|
443
|
+
transition: none;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
.\${P}-group ~ .\${P}-group {
|
|
447
|
+
margin-top: var(--\${P}-group-gap);
|
|
448
|
+
}
|
|
449
|
+
.\${P}-row {
|
|
450
|
+
display: grid;
|
|
451
|
+
grid-template-columns: var(--\${P}-grid-columns);
|
|
452
|
+
column-gap: var(--\${P}-column-gap);
|
|
453
|
+
align-items: baseline;
|
|
454
|
+
}
|
|
455
|
+
.\${P}-group-label {
|
|
456
|
+
min-width: 0;
|
|
457
|
+
overflow-wrap: anywhere;
|
|
458
|
+
}
|
|
459
|
+
.\${P}-title {
|
|
460
|
+
min-width: 0;
|
|
461
|
+
overflow-wrap: anywhere;
|
|
462
|
+
transition: color 150ms cubic-bezier(0, 0, 0.58, 1);
|
|
463
|
+
}
|
|
464
|
+
.\${P}-control-anchor {
|
|
465
|
+
position: absolute;
|
|
466
|
+
pointer-events: none;
|
|
467
|
+
z-index: 2;
|
|
468
|
+
}
|
|
469
|
+
.\${P}-title a {
|
|
470
|
+
text-decoration: inherit;
|
|
471
|
+
}
|
|
472
|
+
.\${P}-interactive .\${P}-row:hover .\${P}-title,
|
|
473
|
+
.\${P}-row:focus-within .\${P}-title,
|
|
474
|
+
.\${P}-state-hover .\${P}-row:first-child .\${P}-title {
|
|
475
|
+
color: var(--\${P}-text-hover-color, var(--\${P}-text-color));
|
|
476
|
+
}
|
|
477
|
+
\`;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function ArchivePopupMediaItem({
|
|
481
|
+
P,
|
|
482
|
+
media,
|
|
483
|
+
isVisible,
|
|
484
|
+
}: {
|
|
485
|
+
P: string;
|
|
486
|
+
media: ArchivePopupMedia;
|
|
487
|
+
isVisible: boolean;
|
|
488
|
+
}) {
|
|
489
|
+
const videoRef = useRef<HTMLVideoElement>(null);
|
|
490
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
491
|
+
const isVideo = isVideoMedia(media);
|
|
492
|
+
const className = cn(
|
|
493
|
+
\`\${P}-media\`,
|
|
494
|
+
media.objectFit === 'contain' && \`\${P}-media-contain\`,
|
|
495
|
+
isVisible && isLoaded && \`\${P}-media-visible\`,
|
|
496
|
+
);
|
|
497
|
+
|
|
498
|
+
useEffect(() => {
|
|
499
|
+
const video = videoRef.current;
|
|
500
|
+
if (!isVideo || !video) return;
|
|
501
|
+
if (isVisible) {
|
|
502
|
+
video.play()?.catch(() => {});
|
|
503
|
+
} else {
|
|
504
|
+
video.pause();
|
|
505
|
+
}
|
|
506
|
+
}, [isVideo, isVisible]);
|
|
507
|
+
|
|
508
|
+
if (isVideo) {
|
|
509
|
+
return (
|
|
510
|
+
<video
|
|
511
|
+
ref={videoRef}
|
|
512
|
+
className={className}
|
|
513
|
+
src={media.assetId}
|
|
514
|
+
muted
|
|
515
|
+
loop
|
|
516
|
+
playsInline
|
|
517
|
+
preload="auto"
|
|
518
|
+
onLoadedData={() => setIsLoaded(true)}
|
|
519
|
+
/>
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return (
|
|
524
|
+
<img
|
|
525
|
+
className={className}
|
|
526
|
+
src={media.assetId}
|
|
527
|
+
alt=""
|
|
528
|
+
decoding="async"
|
|
529
|
+
onLoad={() => setIsLoaded(true)}
|
|
530
|
+
/>
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// A line in each gap, at the right edge of the column it sizes, as Programme's are.
|
|
535
|
+
function renderColumnWidthControls(
|
|
536
|
+
P: string,
|
|
537
|
+
widths: number[],
|
|
538
|
+
paddingLeft: number,
|
|
539
|
+
columnGap: number,
|
|
540
|
+
scaled: (value: number) => string,
|
|
541
|
+
) {
|
|
542
|
+
const lastWidth = widths[widths.length - 1];
|
|
543
|
+
let columnLeft = paddingLeft;
|
|
544
|
+
return widths.slice(0, -1).map((width, index) => {
|
|
545
|
+
const gapCenter = columnLeft + width + columnGap / 2;
|
|
546
|
+
columnLeft += width + columnGap;
|
|
547
|
+
return (
|
|
548
|
+
<div
|
|
549
|
+
key={ARCHIVE_POPUP_COLUMN_WIDTH_KEYS[index]}
|
|
550
|
+
data-controls={ARCHIVE_POPUP_COLUMN_WIDTH_KEYS[index]}
|
|
551
|
+
data-controls-axis="x"
|
|
552
|
+
data-controls-variant="column-width"
|
|
553
|
+
data-controls-min={String(MIN_COLUMN_WIDTH_PX)}
|
|
554
|
+
// a column grows into the last one, which the editor keeps from going under its own least
|
|
555
|
+
data-controls-max-fraction={String(width + lastWidth)}
|
|
556
|
+
className={\`\${P}-control-anchor\`}
|
|
557
|
+
style={{ top: 0, left: scaled(gapCenter - COLUMN_RESIZE_HANDLE_WIDTH / 2), width: scaled(COLUMN_RESIZE_HANDLE_WIDTH), height: '100%' }}
|
|
558
|
+
/>
|
|
559
|
+
);
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function renderPanelPaddingControls(
|
|
564
|
+
P: string,
|
|
565
|
+
panelWidth: number,
|
|
566
|
+
padding: Padding,
|
|
567
|
+
scaled: (value: number) => string,
|
|
568
|
+
) {
|
|
569
|
+
const handleSize = (value: number) => scaled(Math.max(value, PADDING_HANDLE_SIZE));
|
|
570
|
+
return (
|
|
571
|
+
<>
|
|
572
|
+
<div
|
|
573
|
+
data-controls="panelPadding.top"
|
|
574
|
+
data-controls-axis="y"
|
|
575
|
+
data-controls-variant="row-padding"
|
|
576
|
+
data-controls-min="0"
|
|
577
|
+
className={\`\${P}-control-anchor\`}
|
|
578
|
+
style={{ top: 0, left: 0, width: '100%', height: handleSize(padding.top) }}
|
|
579
|
+
/>
|
|
580
|
+
<div
|
|
581
|
+
data-controls="panelPadding.bottom"
|
|
582
|
+
data-controls-axis="y"
|
|
583
|
+
data-controls-variant="row-padding"
|
|
584
|
+
data-controls-reverse=""
|
|
585
|
+
data-controls-min="0"
|
|
586
|
+
className={\`\${P}-control-anchor\`}
|
|
587
|
+
style={{ bottom: 0, left: 0, width: '100%', height: handleSize(padding.bottom) }}
|
|
588
|
+
/>
|
|
589
|
+
<div
|
|
590
|
+
data-controls="panelPadding.left"
|
|
591
|
+
data-controls-axis="x"
|
|
592
|
+
data-controls-variant="column-padding"
|
|
593
|
+
data-controls-min="0"
|
|
594
|
+
data-controls-max-fraction={String(Math.max(0, panelWidth - padding.right))}
|
|
595
|
+
className={\`\${P}-control-anchor\`}
|
|
596
|
+
style={{ top: 0, left: 0, width: handleSize(padding.left), height: '100%' }}
|
|
597
|
+
/>
|
|
598
|
+
<div
|
|
599
|
+
data-controls="panelPadding.right"
|
|
600
|
+
data-controls-axis="x"
|
|
601
|
+
data-controls-variant="column-padding"
|
|
602
|
+
data-controls-reverse=""
|
|
603
|
+
data-controls-min="0"
|
|
604
|
+
data-controls-max-fraction={String(Math.max(0, panelWidth - padding.left))}
|
|
605
|
+
className={\`\${P}-control-anchor\`}
|
|
606
|
+
style={{ top: 0, right: 0, width: handleSize(padding.right), height: '100%' }}
|
|
607
|
+
/>
|
|
608
|
+
</>
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
export function ArchivePopup({
|
|
613
|
+
settings,
|
|
614
|
+
content,
|
|
615
|
+
isEditor,
|
|
616
|
+
isEditMode,
|
|
617
|
+
isPreviewMode,
|
|
618
|
+
activeEvent,
|
|
619
|
+
portalId,
|
|
620
|
+
currentState,
|
|
621
|
+
unavailableStates,
|
|
622
|
+
}: ArchivePopupProps) {
|
|
623
|
+
const { prefix: P } = useScopedStyles();
|
|
624
|
+
const {
|
|
625
|
+
type = 'a',
|
|
626
|
+
triggerLabel = 'Archive',
|
|
627
|
+
closeLabel = 'Close',
|
|
628
|
+
columns = ARCHIVE_POPUP_MIN_COLUMNS,
|
|
629
|
+
columnGap = DEFAULT_COLUMN_GAP,
|
|
630
|
+
panelPosition,
|
|
631
|
+
panelWidth = DEFAULT_PANEL_WIDTH,
|
|
632
|
+
panelPadding = DEFAULT_PANEL_PADDING,
|
|
633
|
+
panelRadius = 0,
|
|
634
|
+
groupGap = 0.0139,
|
|
635
|
+
triggerColor = '#000000',
|
|
636
|
+
triggerHoverColor = '#666666',
|
|
637
|
+
closeColor = '#000000',
|
|
638
|
+
closeHoverColor = '#666666',
|
|
639
|
+
panelColor = '#FFFFFF',
|
|
640
|
+
textColor = '#333132',
|
|
641
|
+
textHoverColor = '#BBBBBB',
|
|
642
|
+
overlayColor = '#FFFFFFE6',
|
|
643
|
+
} = settings;
|
|
644
|
+
const items = content ?? [];
|
|
645
|
+
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
646
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
647
|
+
const overlayRef = useRef<HTMLDivElement>(null);
|
|
648
|
+
const closeRef = useRef<HTMLButtonElement>(null);
|
|
649
|
+
const panelRef = useRef<HTMLDivElement>(null);
|
|
650
|
+
const inlineLayerRef = useRef<HTMLDivElement>(null);
|
|
651
|
+
const [isOpenUser, setIsOpen] = useState(false);
|
|
652
|
+
const [isOverlayMounted, setIsOverlayMounted] = useState(false);
|
|
653
|
+
const [isOverlayActive, setIsOverlayActive] = useState(false);
|
|
654
|
+
const [isOverlaySettled, setIsOverlaySettled] = useState(false);
|
|
655
|
+
const [activeIndex, setActiveIndex] = useState<number | null>(null);
|
|
656
|
+
const [mountedMedia, setMountedMedia] = useState<Set<number>>(() => new Set());
|
|
657
|
+
const [closePosition, setClosePosition] = useState<{ top: number; left: number } | null>(null);
|
|
658
|
+
const [layoutStyle, setLayoutStyle] = useState<CSSProperties>({});
|
|
659
|
+
const [copyRect, setCopyRect] = useState<{ top: number; left: number; width: number } | null>(null);
|
|
660
|
+
const [isMediaCut, setIsMediaCut] = useState(false);
|
|
661
|
+
|
|
662
|
+
const isEditorCanvas = Boolean(isEditor && !isPreviewMode);
|
|
663
|
+
const isInteractive = !isEditor || Boolean(isPreviewMode);
|
|
664
|
+
// B has no popup to open: its panel is always shown in place of the label.
|
|
665
|
+
const isInline = type === 'b';
|
|
666
|
+
const isOpenPinned = isEditorCanvas && currentState === 'open' && !unavailableStates?.includes('open');
|
|
667
|
+
// Escape from preview lands in edit mode: a popup opened there stays open, with its controls.
|
|
668
|
+
const isOpen = !isInline && (isOpenPinned || ((isInteractive || Boolean(isEditMode)) && isOpenUser));
|
|
669
|
+
const scaled = (value: number) => scalingValue(value, isEditor ?? false);
|
|
670
|
+
const scopedCss = useMemo(() => getCSS(P), [P]);
|
|
671
|
+
const groups = useMemo(() => groupArchiveRows(content ?? []), [content]);
|
|
672
|
+
const panelOffset = PANEL_POSITION_OFFSETS[panelPosition as ArchivePopupPanelPosition] ?? PANEL_POSITION_OFFSETS.center;
|
|
673
|
+
const columnCount = getColumnCount(columns);
|
|
674
|
+
const columnWidths = resolveArchivePopupColumnWidths(settings);
|
|
675
|
+
// the group takes the first column, the titles the rest
|
|
676
|
+
const titleKeys = ['title', ...ARCHIVE_POPUP_EXTRA_TITLE_KEYS].slice(0, columnCount - 1) as Array<'title' | typeof ARCHIVE_POPUP_EXTRA_TITLE_KEYS[number]>;
|
|
677
|
+
|
|
678
|
+
useLightboxScrollLock(isOpen && !isEditorCanvas);
|
|
679
|
+
|
|
680
|
+
useEffect(() => {
|
|
681
|
+
if (isEditorCanvas && !isEditMode) setIsOpen(false);
|
|
682
|
+
}, [isEditorCanvas, isEditMode]);
|
|
683
|
+
|
|
684
|
+
useEffect(() => {
|
|
685
|
+
if (isOpen) {
|
|
686
|
+
setLayoutStyle(getLightboxLayoutStyle(wrapperRef.current));
|
|
687
|
+
setIsOverlayMounted(true);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
setIsOverlayActive(false);
|
|
691
|
+
setActiveIndex(null);
|
|
692
|
+
const timer = window.setTimeout(() => setIsOverlayMounted(false), OVERLAY_ANIM_MS);
|
|
693
|
+
return () => window.clearTimeout(timer);
|
|
694
|
+
}, [isOpen]);
|
|
695
|
+
|
|
696
|
+
// Activate only after the mounted overlay's hidden styles are applied, or the appear has nothing to transition from.
|
|
697
|
+
useEffect(() => {
|
|
698
|
+
if (!isOpen || !isOverlayMounted) return;
|
|
699
|
+
overlayRef.current?.getBoundingClientRect();
|
|
700
|
+
const frame = requestAnimationFrame(() => setIsOverlayActive(true));
|
|
701
|
+
return () => cancelAnimationFrame(frame);
|
|
702
|
+
}, [isOpen, isOverlayMounted]);
|
|
703
|
+
|
|
704
|
+
// Canvas controls measure their anchors once, so they wait for the panel to finish sliding in.
|
|
705
|
+
useEffect(() => {
|
|
706
|
+
if (!isOverlayActive) {
|
|
707
|
+
setIsOverlaySettled(false);
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
const timer = window.setTimeout(() => setIsOverlaySettled(true), OVERLAY_ANIM_MS);
|
|
711
|
+
return () => window.clearTimeout(timer);
|
|
712
|
+
}, [isOverlayActive]);
|
|
713
|
+
|
|
714
|
+
// The close button sits exactly where the trigger is, so the label swaps in place.
|
|
715
|
+
const updateClosePosition = useCallback(() => {
|
|
716
|
+
const trigger = triggerRef.current;
|
|
717
|
+
const overlay = overlayRef.current;
|
|
718
|
+
if (!trigger || !overlay) return;
|
|
719
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
720
|
+
const overlayRect = overlay.getBoundingClientRect();
|
|
721
|
+
setClosePosition({ top: triggerRect.top - overlayRect.top, left: triggerRect.left - overlayRect.left });
|
|
722
|
+
}, []);
|
|
723
|
+
|
|
724
|
+
useLayoutEffect(() => {
|
|
725
|
+
if (!isOverlayMounted) return;
|
|
726
|
+
updateClosePosition();
|
|
727
|
+
window.addEventListener('resize', updateClosePosition);
|
|
728
|
+
return () => window.removeEventListener('resize', updateClosePosition);
|
|
729
|
+
}, [isOverlayMounted, updateClosePosition]);
|
|
730
|
+
|
|
731
|
+
useEffect(() => {
|
|
732
|
+
if (!isOpen || !isInteractive) return;
|
|
733
|
+
closeRef.current?.focus({ preventScroll: true });
|
|
734
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
735
|
+
if (event.key === 'Escape') setIsOpen(false);
|
|
736
|
+
};
|
|
737
|
+
document.addEventListener('keydown', onKeyDown);
|
|
738
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
739
|
+
}, [isOpen, isInteractive]);
|
|
740
|
+
|
|
741
|
+
// B's media fills the screen above the page, so a copy of the panel is laid exactly over the real one to stay readable.
|
|
742
|
+
useLayoutEffect(() => {
|
|
743
|
+
if (!isInline || activeIndex === null) return;
|
|
744
|
+
const panelEl = panelRef.current;
|
|
745
|
+
const layer = inlineLayerRef.current;
|
|
746
|
+
if (!panelEl || !layer) return;
|
|
747
|
+
const panelRect = panelEl.getBoundingClientRect();
|
|
748
|
+
const layerRect = layer.getBoundingClientRect();
|
|
749
|
+
setCopyRect({ top: panelRect.top - layerRect.top, left: panelRect.left - layerRect.left, width: panelRect.width });
|
|
750
|
+
}, [isInline, activeIndex]);
|
|
751
|
+
|
|
752
|
+
// The copy stays over the list while the media fades out, so the list never shows through a fading image.
|
|
753
|
+
useEffect(() => {
|
|
754
|
+
if (activeIndex !== null) return;
|
|
755
|
+
const timer = window.setTimeout(() => setCopyRect(null), IMAGE_FADE_MS);
|
|
756
|
+
return () => window.clearTimeout(timer);
|
|
757
|
+
}, [activeIndex]);
|
|
758
|
+
|
|
759
|
+
// The copy is only true to the panel until the page moves, so scrolling cuts the media at once rather than locking it,
|
|
760
|
+
// fading out included: a copy left over the list would stay put while the list scrolls away under it.
|
|
761
|
+
const isCopyShown = copyRect !== null;
|
|
762
|
+
useEffect(() => {
|
|
763
|
+
if (!isInline || !isCopyShown) return;
|
|
764
|
+
const cut = () => {
|
|
765
|
+
setIsMediaCut(true);
|
|
766
|
+
setActiveIndex(null);
|
|
767
|
+
setCopyRect(null);
|
|
768
|
+
};
|
|
769
|
+
document.addEventListener('scroll', cut, { capture: true, passive: true });
|
|
770
|
+
window.addEventListener('resize', cut);
|
|
771
|
+
return () => {
|
|
772
|
+
document.removeEventListener('scroll', cut, { capture: true });
|
|
773
|
+
window.removeEventListener('resize', cut);
|
|
774
|
+
};
|
|
775
|
+
}, [isInline, isCopyShown]);
|
|
776
|
+
|
|
777
|
+
const close = () => {
|
|
778
|
+
if (!isInteractive) return;
|
|
779
|
+
setIsOpen(false);
|
|
780
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
const showRowMedia = (index: number) => {
|
|
784
|
+
if (!isInteractive || !items[index]?.image?.assetId) {
|
|
785
|
+
setActiveIndex(null);
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
setMountedMedia((prev) => (prev.has(index) ? prev : new Set(prev).add(index)));
|
|
789
|
+
if (isInline && activeIndex === null) setLayoutStyle(getLightboxLayoutStyle(wrapperRef.current));
|
|
790
|
+
setIsMediaCut(false);
|
|
791
|
+
setActiveIndex(index);
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
const hideRowMedia = (index: number) => {
|
|
795
|
+
setActiveIndex((current) => (current === index ? null : current));
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
// Title links only navigate on a live page or in preview, not on the editor canvas.
|
|
799
|
+
const onPanelClickCapture = (event: MouseEvent<HTMLDivElement>) => {
|
|
800
|
+
if (!isInteractive && (event.target as HTMLElement).closest('a')) {
|
|
801
|
+
event.preventDefault();
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
const triggerTypographyCss = omitTextColors(textStylesToCss(resolveTextStyle(settings, 'trigger'), isEditor));
|
|
806
|
+
const columnTypographyCss = ARCHIVE_POPUP_COLUMN_STYLE_PREFIXES.slice(0, columnCount).map((prefix) => (
|
|
807
|
+
omitTextColors(textStylesToCss(resolveTextStyle(settings, prefix, 'list'), isEditor))
|
|
808
|
+
));
|
|
809
|
+
|
|
810
|
+
const colorVars = buildColorVars(P, {
|
|
811
|
+
triggerColor,
|
|
812
|
+
triggerHoverColor,
|
|
813
|
+
closeColor,
|
|
814
|
+
closeHoverColor,
|
|
815
|
+
panelColor,
|
|
816
|
+
textColor,
|
|
817
|
+
textHoverColor,
|
|
818
|
+
overlayColor,
|
|
819
|
+
}, COLOR_VAR_MAP, STATE_KEYS);
|
|
820
|
+
const stateClass = activeEvent && activeEvent !== 'default' ? \`\${P}-state-\${activeEvent}\` : '';
|
|
821
|
+
const interactiveClass = isInteractive ? \`\${P}-interactive\` : '';
|
|
822
|
+
|
|
823
|
+
const mediaLayer = (
|
|
824
|
+
<div className={cn(\`\${P}-media-layer\`, isMediaCut && \`\${P}-media-layer-instant\`)} aria-hidden="true">
|
|
825
|
+
{[...mountedMedia].map((index) => {
|
|
826
|
+
const media = items[index]?.image;
|
|
827
|
+
if (!media?.assetId) return null;
|
|
828
|
+
return (
|
|
829
|
+
<ArchivePopupMediaItem
|
|
830
|
+
key={\`\${index}-\${media.assetId}\`}
|
|
831
|
+
P={P}
|
|
832
|
+
media={media}
|
|
833
|
+
isVisible={activeIndex === index}
|
|
834
|
+
/>
|
|
835
|
+
);
|
|
836
|
+
})}
|
|
837
|
+
</div>
|
|
838
|
+
);
|
|
839
|
+
// Inline there is no slide-in to wait for, so the canvas controls can measure straight away.
|
|
840
|
+
const showPanelControls = Boolean(isEditMode) && (isInline || isOverlaySettled);
|
|
841
|
+
|
|
842
|
+
const renderPanel = (isCopy: boolean) => (
|
|
843
|
+
<div
|
|
844
|
+
ref={isCopy ? undefined : panelRef}
|
|
845
|
+
className={cn(
|
|
846
|
+
\`\${P}-panel\`,
|
|
847
|
+
// Only the open and close slide; once open, a new position or size moves the panel straight there.
|
|
848
|
+
isOverlayActive && isOverlaySettled && \`\${P}-panel-settled\`,
|
|
849
|
+
isInline && \`\${P}-panel-inline\`,
|
|
850
|
+
isCopy && \`\${P}-panel-copy\`,
|
|
851
|
+
)}
|
|
852
|
+
style={{
|
|
853
|
+
width: scaled(panelWidth),
|
|
854
|
+
paddingTop: scaled(panelPadding.top),
|
|
855
|
+
paddingRight: scaled(panelPadding.right),
|
|
856
|
+
paddingBottom: scaled(panelPadding.bottom),
|
|
857
|
+
paddingLeft: scaled(panelPadding.left),
|
|
858
|
+
borderRadius: scaled(panelRadius),
|
|
859
|
+
[\`--\${P}-group-gap\`]: scaled(groupGap),
|
|
860
|
+
[\`--\${P}-panel-x\`]: panelOffset.x,
|
|
861
|
+
[\`--\${P}-panel-y\`]: panelOffset.y,
|
|
862
|
+
[\`--\${P}-grid-columns\`]: getGridTemplateColumns(columnWidths),
|
|
863
|
+
[\`--\${P}-column-gap\`]: scaled(columnGap),
|
|
864
|
+
...(isCopy && copyRect ? { top: copyRect.top, left: copyRect.left, width: copyRect.width } : {}),
|
|
865
|
+
} as CSSProperties}
|
|
866
|
+
data-lightbox-scrollable={isInline ? undefined : ''}
|
|
867
|
+
aria-hidden={isCopy || undefined}
|
|
868
|
+
onMouseLeave={isCopy ? undefined : () => setActiveIndex(null)}
|
|
869
|
+
onClickCapture={isCopy ? undefined : onPanelClickCapture}
|
|
870
|
+
>
|
|
871
|
+
{!isCopy && showPanelControls && renderPanelPaddingControls(P, panelWidth, panelPadding, scaled)}
|
|
872
|
+
{!isCopy && showPanelControls && renderColumnWidthControls(P, columnWidths, panelPadding.left, columnGap, scaled)}
|
|
873
|
+
{groups.map((group, groupIndex) => (
|
|
874
|
+
<Fragment key={groupIndex}>
|
|
875
|
+
{!isCopy && showPanelControls && groupIndex > 0 && (
|
|
876
|
+
// Left at its static top, the anchor sits right where the gap above this group starts.
|
|
877
|
+
<div
|
|
878
|
+
data-controls="groupGap"
|
|
879
|
+
data-controls-paired=""
|
|
880
|
+
data-controls-axis="y"
|
|
881
|
+
data-controls-reverse=""
|
|
882
|
+
data-controls-min="0"
|
|
883
|
+
className={\`\${P}-control-anchor\`}
|
|
884
|
+
style={{ left: 0, width: '100%', height: scaled(Math.max(groupGap, PADDING_HANDLE_SIZE)) }}
|
|
885
|
+
/>
|
|
886
|
+
)}
|
|
887
|
+
<div className={\`\${P}-group\`}>
|
|
888
|
+
{group.rows.map(({ item, index }, rowIndex) => (
|
|
889
|
+
<div
|
|
890
|
+
key={index}
|
|
891
|
+
className={cn(\`\${P}-row\`, isCopy && index === activeIndex && \`\${P}-row-active\`)}
|
|
892
|
+
{...(isCopy ? {} : {
|
|
893
|
+
onMouseEnter: () => showRowMedia(index),
|
|
894
|
+
onMouseLeave: () => hideRowMedia(index),
|
|
895
|
+
onFocus: () => showRowMedia(index),
|
|
896
|
+
onBlur: () => hideRowMedia(index),
|
|
897
|
+
})}
|
|
898
|
+
>
|
|
899
|
+
<span className={\`\${P}-group-label\`} style={columnTypographyCss[0]}>
|
|
900
|
+
{rowIndex === 0 ? group.label : ''}
|
|
901
|
+
</span>
|
|
902
|
+
{titleKeys.map((key, titleIndex) => {
|
|
903
|
+
const title = item[key];
|
|
904
|
+
return (
|
|
905
|
+
<div key={key} className={\`\${P}-title\`} style={columnTypographyCss[titleIndex + 1]}>
|
|
906
|
+
{Array.isArray(title) ? <RichTextRenderer content={title} /> : title}
|
|
907
|
+
</div>
|
|
908
|
+
);
|
|
909
|
+
})}
|
|
910
|
+
</div>
|
|
911
|
+
))}
|
|
912
|
+
</div>
|
|
913
|
+
</Fragment>
|
|
914
|
+
))}
|
|
915
|
+
</div>
|
|
916
|
+
);
|
|
917
|
+
|
|
918
|
+
const overlay = isOverlayMounted ? (
|
|
919
|
+
<div
|
|
920
|
+
ref={overlayRef}
|
|
921
|
+
className={cn(
|
|
922
|
+
\`\${P}-overlay\`,
|
|
923
|
+
isEditor && \`\${P}-overlay-editor\`,
|
|
924
|
+
isEditMode && \`\${P}-overlay-edit-mode\`,
|
|
925
|
+
isOverlayActive && \`\${P}-overlay-active\`,
|
|
926
|
+
interactiveClass,
|
|
927
|
+
stateClass,
|
|
928
|
+
)}
|
|
929
|
+
style={{ ...colorVars, ...layoutStyle }}
|
|
930
|
+
role="dialog"
|
|
931
|
+
aria-modal="true"
|
|
932
|
+
aria-label={triggerLabel}
|
|
933
|
+
data-selection="none"
|
|
934
|
+
>
|
|
935
|
+
<div className={\`\${P}-backdrop\`} aria-hidden="true" onClick={close} />
|
|
936
|
+
{mediaLayer}
|
|
937
|
+
<button
|
|
938
|
+
ref={closeRef}
|
|
939
|
+
type="button"
|
|
940
|
+
className={\`\${P}-close\`}
|
|
941
|
+
style={{
|
|
942
|
+
...triggerTypographyCss,
|
|
943
|
+
top: closePosition?.top ?? 0,
|
|
944
|
+
left: closePosition?.left ?? 0,
|
|
945
|
+
visibility: closePosition ? 'visible' : 'hidden',
|
|
946
|
+
}}
|
|
947
|
+
onClick={close}
|
|
948
|
+
>
|
|
949
|
+
{closeLabel}
|
|
950
|
+
</button>
|
|
951
|
+
{renderPanel(false)}
|
|
952
|
+
</div>
|
|
953
|
+
) : null;
|
|
954
|
+
|
|
955
|
+
const inlineLayer = isInline && mountedMedia.size > 0 ? (
|
|
956
|
+
<div
|
|
957
|
+
ref={inlineLayerRef}
|
|
958
|
+
className={cn(\`\${P}-inline-layer\`, isEditor && \`\${P}-overlay-editor\`, interactiveClass, stateClass)}
|
|
959
|
+
style={{ ...colorVars, ...layoutStyle }}
|
|
960
|
+
aria-hidden="true"
|
|
961
|
+
data-selection="none"
|
|
962
|
+
>
|
|
963
|
+
{mediaLayer}
|
|
964
|
+
{copyRect && renderPanel(true)}
|
|
965
|
+
</div>
|
|
966
|
+
) : null;
|
|
967
|
+
const portalContent = overlay ?? inlineLayer;
|
|
968
|
+
|
|
969
|
+
return (
|
|
970
|
+
<>
|
|
971
|
+
<style dangerouslySetInnerHTML={{ __html: scopedCss }} />
|
|
972
|
+
<div
|
|
973
|
+
ref={wrapperRef}
|
|
974
|
+
className={cn(isEditorCanvas && \`\${P}-editor\`, interactiveClass, stateClass)}
|
|
975
|
+
style={colorVars}
|
|
976
|
+
>
|
|
977
|
+
{isInline ? renderPanel(false) : (
|
|
978
|
+
<button
|
|
979
|
+
ref={triggerRef}
|
|
980
|
+
type="button"
|
|
981
|
+
className={\`\${P}-trigger\`}
|
|
982
|
+
style={triggerTypographyCss}
|
|
983
|
+
aria-haspopup="dialog"
|
|
984
|
+
aria-expanded={isOpen}
|
|
985
|
+
onClick={() => {
|
|
986
|
+
if (isInteractive) setIsOpen(true);
|
|
987
|
+
}}
|
|
988
|
+
>
|
|
989
|
+
{triggerLabel}
|
|
990
|
+
</button>
|
|
991
|
+
)}
|
|
992
|
+
</div>
|
|
993
|
+
{portalContent && typeof document !== 'undefined' && createPortal(
|
|
994
|
+
portalContent,
|
|
995
|
+
(portalId ? document.getElementById(portalId) : null) ?? document.body,
|
|
996
|
+
)}
|
|
997
|
+
</>
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
`, C = `import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
|
|
3
1001
|
import { CommonComponentProps } from '../props';
|
|
4
1002
|
import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
|
|
5
1003
|
import { useLightboxScrollLock } from '../utils/useLightboxScrollLock';
|
|
@@ -2640,16 +3638,16 @@ export function Burger({
|
|
|
2640
3638
|
</div>
|
|
2641
3639
|
);
|
|
2642
3640
|
}
|
|
2643
|
-
`,
|
|
3641
|
+
`, w = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2644
3642
|
import { CommonComponentProps } from '../props';
|
|
2645
|
-
import { useScopedStyles } from '../utils/index';
|
|
3643
|
+
import { LinkWrapper, useScopedStyles, type ContentLink } from '../utils/index';
|
|
2646
3644
|
|
|
2647
3645
|
type ClickGallerieItem = {
|
|
2648
3646
|
image: {
|
|
2649
3647
|
assetId: string;
|
|
2650
3648
|
name: string;
|
|
2651
3649
|
};
|
|
2652
|
-
link
|
|
3650
|
+
link?: ContentLink;
|
|
2653
3651
|
};
|
|
2654
3652
|
|
|
2655
3653
|
type ImageSizeSettings = {
|
|
@@ -2684,7 +3682,7 @@ type ImageMeta = {
|
|
|
2684
3682
|
interface PlacedImage {
|
|
2685
3683
|
id: number;
|
|
2686
3684
|
assetId: string;
|
|
2687
|
-
link
|
|
3685
|
+
link?: ContentLink;
|
|
2688
3686
|
name: string;
|
|
2689
3687
|
x: number;
|
|
2690
3688
|
y: number;
|
|
@@ -3147,13 +4145,9 @@ export function ClickGallerie({ settings, content = [], isEditor }: ClickGalleri
|
|
|
3147
4145
|
cursor: useCustomCursor ? 'none' : 'default',
|
|
3148
4146
|
}}
|
|
3149
4147
|
>
|
|
3150
|
-
{target === 'area'
|
|
3151
|
-
<a href={img.link} target="_blank" rel="noreferrer" className={\`\${P}-link\`}>
|
|
3152
|
-
<img src={img.assetId} alt={img.name} className={\`\${P}-image\`} />
|
|
3153
|
-
</a>
|
|
3154
|
-
) : (
|
|
4148
|
+
<LinkWrapper link={target === 'area' ? img.link : undefined} className={\`\${P}-link\`}>
|
|
3155
4149
|
<img src={img.assetId} alt={img.name} className={\`\${P}-image\`} />
|
|
3156
|
-
|
|
4150
|
+
</LinkWrapper>
|
|
3157
4151
|
</div>
|
|
3158
4152
|
))}
|
|
3159
4153
|
{isInside && useCustomCursor && (
|
|
@@ -3173,7 +4167,7 @@ export function ClickGallerie({ settings, content = [], isEditor }: ClickGalleri
|
|
|
3173
4167
|
</>
|
|
3174
4168
|
);
|
|
3175
4169
|
}
|
|
3176
|
-
`,
|
|
4170
|
+
`, $ = `import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3177
4171
|
import cn from 'classnames';
|
|
3178
4172
|
import { CommonComponentProps } from '../props';
|
|
3179
4173
|
import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index';
|
|
@@ -3921,7 +4915,7 @@ export function FAQ({ settings, content, isEditor, isPreviewMode, isEditMode, ac
|
|
|
3921
4915
|
</>
|
|
3922
4916
|
);
|
|
3923
4917
|
}
|
|
3924
|
-
`,
|
|
4918
|
+
`, I = `import React, { useMemo, useState } from 'react';
|
|
3925
4919
|
import { CommonComponentProps } from '../props';
|
|
3926
4920
|
import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
|
|
3927
4921
|
import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
|
|
@@ -4559,12 +5553,14 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
|
|
|
4559
5553
|
};
|
|
4560
5554
|
|
|
4561
5555
|
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
4562
|
-
`,
|
|
5556
|
+
`, T = `import { Splide, SplideSlide } from '@splidejs/react-splide';
|
|
4563
5557
|
import '@splidejs/react-splide/css/core';
|
|
4564
5558
|
import { CommonComponentProps } from '../props';
|
|
5559
|
+
import { EmbedMediaFrame, getEmbedAspect, getEmbedPlayback, isEmbedMedia } from '../utils/index';
|
|
4565
5560
|
import {
|
|
4566
5561
|
buildColorVars,
|
|
4567
5562
|
getFormFieldValidationError,
|
|
5563
|
+
LinkWrapper,
|
|
4568
5564
|
scalingValue,
|
|
4569
5565
|
useLazyVideos,
|
|
4570
5566
|
useScopedStyles,
|
|
@@ -4671,6 +5667,10 @@ function getCSS(P: string): string {
|
|
|
4671
5667
|
max-width: 100%;
|
|
4672
5668
|
object-fit: contain;
|
|
4673
5669
|
}
|
|
5670
|
+
.\${P}-item-image-wrapper-fit-slider > .\${P}-item-image-wrapper-sizer div {
|
|
5671
|
+
grid-area: 1 / 1;
|
|
5672
|
+
width: 100%;
|
|
5673
|
+
}
|
|
4674
5674
|
.\${P}-item-image-wrapper-fit-slider > .\${P}-item-slider {
|
|
4675
5675
|
position: absolute;
|
|
4676
5676
|
inset: 0;
|
|
@@ -5064,7 +6064,10 @@ type SwipeAxis = 'none' | 'horizontal' | 'vertical';
|
|
|
5064
6064
|
type GridMedia = {
|
|
5065
6065
|
assetId: string;
|
|
5066
6066
|
name?: string;
|
|
5067
|
-
type: 'image' | 'video';
|
|
6067
|
+
type: 'image' | 'video' | 'vimeo' | 'youtube';
|
|
6068
|
+
thumbnail?: string;
|
|
6069
|
+
width?: number;
|
|
6070
|
+
height?: number;
|
|
5068
6071
|
};
|
|
5069
6072
|
|
|
5070
6073
|
type GridMediaPair = {
|
|
@@ -5120,8 +6123,7 @@ function getGridDisplayItems(image: GridMedia[] | GridMediaPair[] | undefined):
|
|
|
5120
6123
|
}
|
|
5121
6124
|
|
|
5122
6125
|
function isVideoMedia(media: GridMedia): boolean {
|
|
5123
|
-
|
|
5124
|
-
return false;
|
|
6126
|
+
return !isEmbedMedia(media) && media.type === 'video';
|
|
5125
6127
|
}
|
|
5126
6128
|
|
|
5127
6129
|
function collectGridLightboxMedia(content: any[]): GridMedia[] {
|
|
@@ -5145,7 +6147,9 @@ function collectGridLightboxMedia(content: any[]): GridMedia[] {
|
|
|
5145
6147
|
function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
|
|
5146
6148
|
const [pool, setPool] = useState<HTMLDivElement | null>(null);
|
|
5147
6149
|
useLazyVideos(pool, { preload: 'metadata' });
|
|
5148
|
-
|
|
6150
|
+
// an embed's player is only ever framed where it shows
|
|
6151
|
+
const files = mediaList.filter(media => !isEmbedMedia(media));
|
|
6152
|
+
if (files.length === 0) return null;
|
|
5149
6153
|
|
|
5150
6154
|
return (
|
|
5151
6155
|
<div
|
|
@@ -5160,7 +6164,7 @@ function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
|
|
|
5160
6164
|
pointerEvents: 'none',
|
|
5161
6165
|
}}
|
|
5162
6166
|
>
|
|
5163
|
-
{
|
|
6167
|
+
{files.map((media) => (
|
|
5164
6168
|
isVideoMedia(media) ? (
|
|
5165
6169
|
<video
|
|
5166
6170
|
key={media.assetId}
|
|
@@ -5202,15 +6206,34 @@ function GridMediaItem({
|
|
|
5202
6206
|
media,
|
|
5203
6207
|
className,
|
|
5204
6208
|
style,
|
|
6209
|
+
hasLightbox,
|
|
5205
6210
|
isSplideSlide = false,
|
|
5206
6211
|
onMediaClick,
|
|
5207
6212
|
}: {
|
|
5208
6213
|
media: GridMedia;
|
|
5209
6214
|
className: string;
|
|
5210
6215
|
style: React.CSSProperties;
|
|
6216
|
+
/** An embed then plays here as a silent loop, and as it was set to in the lightbox. */
|
|
6217
|
+
hasLightbox: boolean;
|
|
5211
6218
|
isSplideSlide?: boolean;
|
|
5212
6219
|
onMediaClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
5213
6220
|
}) {
|
|
6221
|
+
if (isEmbedMedia(media)) {
|
|
6222
|
+
return (
|
|
6223
|
+
<EmbedMediaFrame
|
|
6224
|
+
media={media}
|
|
6225
|
+
fit={style.objectFit === 'contain' ? 'contain' : 'cover'}
|
|
6226
|
+
silentLoop={hasLightbox}
|
|
6227
|
+
className={className}
|
|
6228
|
+
style={{
|
|
6229
|
+
...style,
|
|
6230
|
+
cursor: onMediaClick ? 'pointer' : 'default',
|
|
6231
|
+
}}
|
|
6232
|
+
onClick={onMediaClick}
|
|
6233
|
+
/>
|
|
6234
|
+
);
|
|
6235
|
+
}
|
|
6236
|
+
|
|
5214
6237
|
if (isVideoMedia(media)) {
|
|
5215
6238
|
const videoProps = {
|
|
5216
6239
|
src: media.assetId,
|
|
@@ -5281,20 +6304,14 @@ function getContainRect(box: AnimRect, natural: { width: number; height: number
|
|
|
5281
6304
|
|
|
5282
6305
|
function LightboxVideo({
|
|
5283
6306
|
src,
|
|
5284
|
-
phase,
|
|
5285
6307
|
mediaRef,
|
|
5286
6308
|
mediaStyle,
|
|
5287
6309
|
onLoadedMetadata,
|
|
5288
|
-
onClick,
|
|
5289
|
-
onMouseMove,
|
|
5290
6310
|
}: {
|
|
5291
6311
|
src: string;
|
|
5292
|
-
phase: 'opening' | 'open' | 'closing';
|
|
5293
6312
|
mediaRef: React.RefObject<HTMLVideoElement>;
|
|
5294
6313
|
mediaStyle: React.CSSProperties;
|
|
5295
6314
|
onLoadedMetadata: (e: React.SyntheticEvent<HTMLVideoElement>) => void;
|
|
5296
|
-
onClick: (e: React.MouseEvent<HTMLVideoElement>) => void;
|
|
5297
|
-
onMouseMove: (e: React.MouseEvent<HTMLVideoElement>) => void;
|
|
5298
6315
|
}) {
|
|
5299
6316
|
useEffect(() => {
|
|
5300
6317
|
const video = mediaRef.current;
|
|
@@ -5309,12 +6326,12 @@ function LightboxVideo({
|
|
|
5309
6326
|
<video
|
|
5310
6327
|
ref={mediaRef}
|
|
5311
6328
|
src={src}
|
|
5312
|
-
|
|
6329
|
+
muted
|
|
6330
|
+
autoPlay
|
|
6331
|
+
loop
|
|
5313
6332
|
playsInline
|
|
5314
6333
|
preload='auto'
|
|
5315
6334
|
onLoadedMetadata={onLoadedMetadata}
|
|
5316
|
-
onClick={onClick}
|
|
5317
|
-
onMouseMove={onMouseMove}
|
|
5318
6335
|
style={mediaStyle}
|
|
5319
6336
|
/>
|
|
5320
6337
|
);
|
|
@@ -5499,7 +6516,7 @@ function Lightbox({
|
|
|
5499
6516
|
const prevItemUrlRef = useRef<string | undefined>(undefined);
|
|
5500
6517
|
const currentItem = items[index];
|
|
5501
6518
|
const isCurrentVideo = currentItem ? isVideoMedia(currentItem) : false;
|
|
5502
|
-
const
|
|
6519
|
+
const isCurrentEmbed = currentItem ? isEmbedMedia(currentItem) : false;
|
|
5503
6520
|
const isSliding = slideDir !== null;
|
|
5504
6521
|
|
|
5505
6522
|
const handleMediaLoad = useCallback((e: React.SyntheticEvent<HTMLImageElement | HTMLVideoElement>) => {
|
|
@@ -5853,50 +6870,14 @@ function Lightbox({
|
|
|
5853
6870
|
const swipeBackdropOpacity = swipeOffset > 0 ? Math.max(0, 1 - swipeOffset / 500) : 1;
|
|
5854
6871
|
const swipeMediaOpacity = swipeOffset > 0 ? Math.max(0.35, 1 - swipeOffset / 500) : 1;
|
|
5855
6872
|
|
|
6873
|
+
// an embed's player reports no size of its own, so its stored aspect stands in
|
|
6874
|
+
const naturalSize = isCurrentEmbed && currentItem
|
|
6875
|
+
? { width: getEmbedAspect(currentItem), height: 1 }
|
|
6876
|
+
: mediaNaturalSize;
|
|
5856
6877
|
const contentRect = finalRect
|
|
5857
|
-
? (isCover ? finalRect : getContainRect(finalRect,
|
|
6878
|
+
? (isCover ? finalRect : getContainRect(finalRect, naturalSize))
|
|
5858
6879
|
: null;
|
|
5859
6880
|
|
|
5860
|
-
const handleVideoClick = (e: React.MouseEvent<HTMLVideoElement>) => {
|
|
5861
|
-
e.stopPropagation();
|
|
5862
|
-
if (touchInteractionRef.current) {
|
|
5863
|
-
touchInteractionRef.current = false;
|
|
5864
|
-
return;
|
|
5865
|
-
}
|
|
5866
|
-
if (items.length <= 1) return;
|
|
5867
|
-
|
|
5868
|
-
const rect = contentRect ?? e.currentTarget.getBoundingClientRect();
|
|
5869
|
-
const y = e.clientY - rect.top;
|
|
5870
|
-
const controlsZoneHeight = Math.min(52, rect.height * 0.2);
|
|
5871
|
-
|
|
5872
|
-
if (y > rect.height - controlsZoneHeight) {
|
|
5873
|
-
return;
|
|
5874
|
-
}
|
|
5875
|
-
|
|
5876
|
-
if (e.clientX - rect.left < rect.width / 2) {
|
|
5877
|
-
startProgrammaticSlide(-1);
|
|
5878
|
-
return;
|
|
5879
|
-
}
|
|
5880
|
-
|
|
5881
|
-
startProgrammaticSlide(1);
|
|
5882
|
-
};
|
|
5883
|
-
|
|
5884
|
-
const handleVideoMouseMove = (e: React.MouseEvent<HTMLVideoElement>) => {
|
|
5885
|
-
if (items.length <= 1) return;
|
|
5886
|
-
|
|
5887
|
-
const rect = contentRect ?? e.currentTarget.getBoundingClientRect();
|
|
5888
|
-
const x = e.clientX - rect.left;
|
|
5889
|
-
const y = e.clientY - rect.top;
|
|
5890
|
-
const controlsZoneHeight = Math.min(52, rect.height * 0.2);
|
|
5891
|
-
|
|
5892
|
-
if (y > rect.height - controlsZoneHeight) {
|
|
5893
|
-
e.currentTarget.style.cursor = 'default';
|
|
5894
|
-
return;
|
|
5895
|
-
}
|
|
5896
|
-
|
|
5897
|
-
e.currentTarget.style.cursor = x < rect.width / 2 ? 'w-resize' : 'e-resize';
|
|
5898
|
-
};
|
|
5899
|
-
|
|
5900
6881
|
const backingBaseStyle: React.CSSProperties = {
|
|
5901
6882
|
position: 'fixed',
|
|
5902
6883
|
top: viewportRect?.top,
|
|
@@ -5941,8 +6922,7 @@ function Lightbox({
|
|
|
5941
6922
|
width: contentRect?.width,
|
|
5942
6923
|
height: contentRect?.height,
|
|
5943
6924
|
objectFit: objectFitStyle,
|
|
5944
|
-
pointerEvents:
|
|
5945
|
-
touchAction: isCurrentVideo && isOpen ? 'none' : undefined,
|
|
6925
|
+
pointerEvents: 'none',
|
|
5946
6926
|
};
|
|
5947
6927
|
|
|
5948
6928
|
const slideWidth = viewportRect?.width ?? 0;
|
|
@@ -5965,10 +6945,14 @@ function Lightbox({
|
|
|
5965
6945
|
pointerEvents: 'none',
|
|
5966
6946
|
};
|
|
5967
6947
|
|
|
6948
|
+
// over an embed with controls the overlays stop short of the player's own control bar
|
|
6949
|
+
const navOverlayInset = isCurrentEmbed && currentItem && getEmbedPlayback(currentItem).controls && contentRect
|
|
6950
|
+
? Math.min(52, contentRect.height * 0.2)
|
|
6951
|
+
: 0;
|
|
5968
6952
|
const navOverlayBaseStyle = contentRect ? {
|
|
5969
6953
|
position: 'fixed' as const,
|
|
5970
6954
|
top: contentRect.top,
|
|
5971
|
-
height: contentRect.height,
|
|
6955
|
+
height: contentRect.height - navOverlayInset,
|
|
5972
6956
|
width: contentRect.width / 2,
|
|
5973
6957
|
zIndex: 9999,
|
|
5974
6958
|
} : null;
|
|
@@ -6069,11 +7053,20 @@ function Lightbox({
|
|
|
6069
7053
|
|
|
6070
7054
|
{finalRect && viewportRect && neighborItem && (
|
|
6071
7055
|
<div style={neighborBackingStyle} onTransitionEnd={handleSlideTransitionEnd}>
|
|
6072
|
-
{
|
|
7056
|
+
{isEmbedMedia(neighborItem) ? (
|
|
7057
|
+
<img
|
|
7058
|
+
key={\`neighbor-\${neighborIndex}-\${neighborItem.assetId}\`}
|
|
7059
|
+
src={neighborItem.thumbnail}
|
|
7060
|
+
alt={neighborItem.name}
|
|
7061
|
+
style={neighborMediaStyle}
|
|
7062
|
+
/>
|
|
7063
|
+
) : isVideoMedia(neighborItem) ? (
|
|
6073
7064
|
<video
|
|
6074
7065
|
key={\`neighbor-\${neighborIndex}-\${neighborItem.assetId}\`}
|
|
6075
7066
|
src={neighborItem.assetId}
|
|
6076
7067
|
muted
|
|
7068
|
+
autoPlay
|
|
7069
|
+
loop
|
|
6077
7070
|
playsInline
|
|
6078
7071
|
preload='auto'
|
|
6079
7072
|
style={neighborMediaStyle}
|
|
@@ -6091,16 +7084,22 @@ function Lightbox({
|
|
|
6091
7084
|
|
|
6092
7085
|
{finalRect && viewportRect && currentItem && (
|
|
6093
7086
|
<div style={currentBackingStyle} onTransitionEnd={handleSlideTransitionEnd}>
|
|
6094
|
-
{
|
|
7087
|
+
{isCurrentEmbed ? (
|
|
7088
|
+
<EmbedMediaFrame
|
|
7089
|
+
key={\`\${index}-\${currentItem.assetId}\`}
|
|
7090
|
+
media={currentItem}
|
|
7091
|
+
fit={isCover ? 'cover' : 'contain'}
|
|
7092
|
+
lazy={false}
|
|
7093
|
+
startsAtOnce
|
|
7094
|
+
style={currentMediaStyle}
|
|
7095
|
+
/>
|
|
7096
|
+
) : isCurrentVideo ? (
|
|
6095
7097
|
<LightboxVideo
|
|
6096
7098
|
key={\`\${index}-\${currentItem.assetId}\`}
|
|
6097
7099
|
src={currentItem.assetId}
|
|
6098
|
-
phase={phase}
|
|
6099
7100
|
mediaRef={mediaRef as React.RefObject<HTMLVideoElement>}
|
|
6100
7101
|
mediaStyle={currentMediaStyle}
|
|
6101
7102
|
onLoadedMetadata={handleMediaLoad}
|
|
6102
|
-
onClick={handleVideoClick}
|
|
6103
|
-
onMouseMove={handleVideoMouseMove}
|
|
6104
7103
|
/>
|
|
6105
7104
|
) : (
|
|
6106
7105
|
<img
|
|
@@ -6115,7 +7114,7 @@ function Lightbox({
|
|
|
6115
7114
|
</div>
|
|
6116
7115
|
)}
|
|
6117
7116
|
|
|
6118
|
-
{isOpen && navOverlayBaseStyle && items.length > 1 &&
|
|
7117
|
+
{isOpen && navOverlayBaseStyle && items.length > 1 && (
|
|
6119
7118
|
<>
|
|
6120
7119
|
<div
|
|
6121
7120
|
style={{
|
|
@@ -6463,7 +7462,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6463
7462
|
{cropContent.map((item: any, index: number) => {
|
|
6464
7463
|
const hasTitle = hasText(item.title);
|
|
6465
7464
|
const hasSubtitle = hasText(item.subtitle);
|
|
6466
|
-
const itemLink =
|
|
7465
|
+
const itemLink = lightbox === 'off' && item.link?.value ? item.link : undefined;
|
|
6467
7466
|
const isLastRow = Math.floor(index / columnsCount)
|
|
6468
7467
|
=== Math.ceil(cropContent.length / columnsCount) - 1;
|
|
6469
7468
|
const gridColumn = isPartialLastRow && index >= lastRowStartIndex
|
|
@@ -6565,16 +7564,11 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6565
7564
|
</div>
|
|
6566
7565
|
) : null;
|
|
6567
7566
|
|
|
6568
|
-
const alignedTextRows =
|
|
6569
|
-
<
|
|
6570
|
-
{titleRow}
|
|
6571
|
-
{subtitleRow}
|
|
6572
|
-
</a>
|
|
6573
|
-
) : (
|
|
6574
|
-
<>
|
|
7567
|
+
const alignedTextRows = (
|
|
7568
|
+
<LinkWrapper link={itemLink} className={\`\${P}-item-text-link\`}>
|
|
6575
7569
|
{titleRow}
|
|
6576
7570
|
{subtitleRow}
|
|
6577
|
-
|
|
7571
|
+
</LinkWrapper>
|
|
6578
7572
|
);
|
|
6579
7573
|
|
|
6580
7574
|
const displayItems = getGridDisplayItems(item.gallery);
|
|
@@ -6598,6 +7592,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6598
7592
|
media={displayMedia}
|
|
6599
7593
|
className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
|
|
6600
7594
|
style={imageStyle}
|
|
7595
|
+
hasLightbox={lightbox === 'on'}
|
|
6601
7596
|
onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
|
|
6602
7597
|
? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
|
|
6603
7598
|
: undefined}
|
|
@@ -6609,7 +7604,9 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6609
7604
|
{isFitSlider && (
|
|
6610
7605
|
<div className={\`\${P}-item-image-wrapper-sizer\`} aria-hidden="true">
|
|
6611
7606
|
{displayItems.map(({ displayMedia }) => (
|
|
6612
|
-
|
|
7607
|
+
isEmbedMedia(displayMedia) ? (
|
|
7608
|
+
<div key={\`sizer-\${displayMedia.assetId}\`} style={{ aspectRatio: \`\${getEmbedAspect(displayMedia)}\` }} />
|
|
7609
|
+
) : isVideoMedia(displayMedia) ? (
|
|
6613
7610
|
<LazyVideo key={\`sizer-\${displayMedia.assetId}\`} src={displayMedia.assetId} nearPreload='metadata' muted playsInline />
|
|
6614
7611
|
) : (
|
|
6615
7612
|
<img key={\`sizer-\${displayMedia.assetId}\`} src={displayMedia.assetId} alt="" />
|
|
@@ -6651,6 +7648,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6651
7648
|
media={displayMedia}
|
|
6652
7649
|
className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
|
|
6653
7650
|
style={imageStyle}
|
|
7651
|
+
hasLightbox={lightbox === 'on'}
|
|
6654
7652
|
isSplideSlide
|
|
6655
7653
|
onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
|
|
6656
7654
|
? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
|
|
@@ -6698,6 +7696,15 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6698
7696
|
</>
|
|
6699
7697
|
) : null;
|
|
6700
7698
|
|
|
7699
|
+
// the aligned layout sizes this box whether or not it links anywhere
|
|
7700
|
+
const alignedImage = itemLink ? (
|
|
7701
|
+
<LinkWrapper link={itemLink} className={\`\${P}-item-image-link\`}>
|
|
7702
|
+
{imageContent}
|
|
7703
|
+
</LinkWrapper>
|
|
7704
|
+
) : (
|
|
7705
|
+
<a className={\`\${P}-item-image-link\`}>{imageContent}</a>
|
|
7706
|
+
);
|
|
7707
|
+
|
|
6701
7708
|
return (
|
|
6702
7709
|
<div
|
|
6703
7710
|
key={index}
|
|
@@ -6720,29 +7727,25 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
6720
7727
|
{isTextBeforeImage ? (
|
|
6721
7728
|
<>
|
|
6722
7729
|
{alignedTextRows}
|
|
6723
|
-
|
|
6724
|
-
{imageContent}
|
|
6725
|
-
</a>
|
|
7730
|
+
{alignedImage}
|
|
6726
7731
|
</>
|
|
6727
7732
|
) : (
|
|
6728
7733
|
<>
|
|
6729
|
-
|
|
6730
|
-
{imageContent}
|
|
6731
|
-
</a>
|
|
7734
|
+
{alignedImage}
|
|
6732
7735
|
{alignedTextRows}
|
|
6733
7736
|
</>
|
|
6734
7737
|
)}
|
|
6735
7738
|
</>
|
|
6736
7739
|
) : itemLink ? (
|
|
6737
7740
|
<>
|
|
6738
|
-
<
|
|
7741
|
+
<LinkWrapper link={itemLink} className={\`\${P}-item-image-link\`}>
|
|
6739
7742
|
{typeCTextBlock}
|
|
6740
7743
|
{imageContent}
|
|
6741
|
-
</
|
|
7744
|
+
</LinkWrapper>
|
|
6742
7745
|
{!isTextBeforeImage && (
|
|
6743
|
-
<
|
|
7746
|
+
<LinkWrapper link={itemLink} className={\`\${P}-item-text-link\`}>
|
|
6744
7747
|
{typeABText}
|
|
6745
|
-
</
|
|
7748
|
+
</LinkWrapper>
|
|
6746
7749
|
)}
|
|
6747
7750
|
</>
|
|
6748
7751
|
) : (
|
|
@@ -6865,10 +7868,11 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
|
|
|
6865
7868
|
};
|
|
6866
7869
|
|
|
6867
7870
|
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
6868
|
-
`,
|
|
7871
|
+
`, E = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
|
|
6869
7872
|
import { CommonComponentProps } from '../props';
|
|
6870
7873
|
import { scalingValue } from '../utils/scalingValue';
|
|
6871
7874
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
7875
|
+
import { EmbedMediaFrame, isEmbedMedia } from '../utils/index';
|
|
6872
7876
|
import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
|
|
6873
7877
|
|
|
6874
7878
|
const DEG_PER_SEC_PER_SPEED_UNIT = 10;
|
|
@@ -6939,7 +7943,10 @@ function getCSS(P: string): string {
|
|
|
6939
7943
|
type HelixMedia = {
|
|
6940
7944
|
assetId?: string;
|
|
6941
7945
|
name?: string;
|
|
6942
|
-
type?: 'image' | 'video';
|
|
7946
|
+
type?: 'image' | 'video' | 'vimeo' | 'youtube';
|
|
7947
|
+
thumbnail?: string;
|
|
7948
|
+
width?: number;
|
|
7949
|
+
height?: number;
|
|
6943
7950
|
};
|
|
6944
7951
|
|
|
6945
7952
|
export type HelixContentItem = {
|
|
@@ -7034,6 +8041,7 @@ function getAspectHeightFactor(imageDisplay: ImageDisplay): number {
|
|
|
7034
8041
|
}
|
|
7035
8042
|
|
|
7036
8043
|
function isVideoMedia(media: HelixMedia): boolean {
|
|
8044
|
+
if (isEmbedMedia(media)) return false;
|
|
7037
8045
|
if (media.type === 'video') return true;
|
|
7038
8046
|
if (media.type === 'image') return false;
|
|
7039
8047
|
return /\\.(mp4|webm|ogg|mov)(\\?|$)/i.test(media.name ?? '') || /\\.(mp4|webm|ogg|mov)(\\?|$)/i.test(media.assetId ?? '');
|
|
@@ -7381,7 +8389,15 @@ export function Helix({
|
|
|
7381
8389
|
objectPosition: 'center',
|
|
7382
8390
|
}
|
|
7383
8391
|
: mediaStyle;
|
|
7384
|
-
const mediaNode =
|
|
8392
|
+
const mediaNode = isEmbedMedia(media) ? (
|
|
8393
|
+
<EmbedMediaFrame
|
|
8394
|
+
className={\`\${P}-media\`}
|
|
8395
|
+
// the frame positions itself inline, so the cover's absolute placement is given the same way
|
|
8396
|
+
style={isCover ? { ...coverMediaStyle, position: 'absolute', inset: 0 } : coverMediaStyle}
|
|
8397
|
+
media={media}
|
|
8398
|
+
fit={isCover ? 'cover' : 'contain'}
|
|
8399
|
+
/>
|
|
8400
|
+
) : isVideoMedia(media) ? (
|
|
7385
8401
|
<LazyVideo
|
|
7386
8402
|
className={\`\${P}-media\`}
|
|
7387
8403
|
style={coverMediaStyle}
|
|
@@ -7425,8 +8441,8 @@ export function Helix({
|
|
|
7425
8441
|
</>
|
|
7426
8442
|
);
|
|
7427
8443
|
}
|
|
7428
|
-
`,
|
|
7429
|
-
import { scalingValue, useLazyVideos, useScopedStyles } from '../utils/index';
|
|
8444
|
+
`, R = `import { CommonComponentProps } from '../props';
|
|
8445
|
+
import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, scalingValue, useLazyVideos, useScopedStyles } from '../utils/index';
|
|
7430
8446
|
import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
|
|
7431
8447
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
7432
8448
|
import { createPortal } from 'react-dom';
|
|
@@ -7788,7 +8804,10 @@ type HiveMedia = {
|
|
|
7788
8804
|
assetId: string;
|
|
7789
8805
|
name?: string;
|
|
7790
8806
|
objectFit?: 'cover' | 'contain';
|
|
7791
|
-
type?: 'image' | 'video';
|
|
8807
|
+
type?: 'image' | 'video' | 'vimeo' | 'youtube';
|
|
8808
|
+
thumbnail?: string;
|
|
8809
|
+
width?: number;
|
|
8810
|
+
height?: number;
|
|
7792
8811
|
};
|
|
7793
8812
|
|
|
7794
8813
|
type HiveMediaPair = {
|
|
@@ -7986,6 +9005,11 @@ function preloadMediaDimensions(
|
|
|
7986
9005
|
media: HiveMedia,
|
|
7987
9006
|
onDimensions: (url: string, width: number, height: number) => void,
|
|
7988
9007
|
) {
|
|
9008
|
+
if (isEmbedMedia(media)) {
|
|
9009
|
+
onDimensions(media.assetId, getEmbedAspect(media), 1);
|
|
9010
|
+
return;
|
|
9011
|
+
}
|
|
9012
|
+
|
|
7989
9013
|
if (isVideoMedia(media)) {
|
|
7990
9014
|
const video = document.createElement('video');
|
|
7991
9015
|
const handleMetadata = () => {
|
|
@@ -8033,7 +9057,9 @@ function collectAllHiveMedia(content: HiveContentItem[]): HiveMedia[] {
|
|
|
8033
9057
|
function PreloadedMediaPool({ mediaList }: { mediaList: HiveMedia[] }) {
|
|
8034
9058
|
const [pool, setPool] = useState<HTMLDivElement | null>(null);
|
|
8035
9059
|
useLazyVideos(pool, { preload: 'metadata' });
|
|
8036
|
-
|
|
9060
|
+
// an embed's player is only ever framed where it shows
|
|
9061
|
+
const files = mediaList.filter(media => !isEmbedMedia(media));
|
|
9062
|
+
if (files.length === 0) return null;
|
|
8037
9063
|
|
|
8038
9064
|
return (
|
|
8039
9065
|
<div
|
|
@@ -8048,7 +9074,7 @@ function PreloadedMediaPool({ mediaList }: { mediaList: HiveMedia[] }) {
|
|
|
8048
9074
|
pointerEvents: 'none',
|
|
8049
9075
|
}}
|
|
8050
9076
|
>
|
|
8051
|
-
{
|
|
9077
|
+
{files.map((media) => (
|
|
8052
9078
|
isVideoMedia(media) ? (
|
|
8053
9079
|
<video
|
|
8054
9080
|
key={media.assetId}
|
|
@@ -8253,6 +9279,7 @@ function getDisplayItems(gallery: HiveMedia[] | HiveMediaPair[] | undefined): Di
|
|
|
8253
9279
|
}
|
|
8254
9280
|
|
|
8255
9281
|
function isVideoMedia(media: HiveMedia): boolean {
|
|
9282
|
+
if (isEmbedMedia(media)) return false;
|
|
8256
9283
|
if (media.type === 'video') return true;
|
|
8257
9284
|
return /\\.(mp4|webm|ogg|mov)(\\?|#|$)/i.test(media.assetId);
|
|
8258
9285
|
}
|
|
@@ -8270,6 +9297,24 @@ function MediaItem({
|
|
|
8270
9297
|
gridIndex?: number;
|
|
8271
9298
|
onMediaClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
8272
9299
|
}) {
|
|
9300
|
+
if (isEmbedMedia(media)) {
|
|
9301
|
+
return (
|
|
9302
|
+
<EmbedMediaFrame
|
|
9303
|
+
media={media}
|
|
9304
|
+
fit={style.objectFit === 'contain' ? 'contain' : 'cover'}
|
|
9305
|
+
// a cell opens the lightbox, where the video plays as it was set to
|
|
9306
|
+
silentLoop
|
|
9307
|
+
className={className}
|
|
9308
|
+
data-hive-grid-index={gridIndex}
|
|
9309
|
+
style={{
|
|
9310
|
+
...style,
|
|
9311
|
+
cursor: onMediaClick ? 'pointer' : 'default',
|
|
9312
|
+
}}
|
|
9313
|
+
onClick={onMediaClick}
|
|
9314
|
+
/>
|
|
9315
|
+
);
|
|
9316
|
+
}
|
|
9317
|
+
|
|
8273
9318
|
if (isVideoMedia(media)) {
|
|
8274
9319
|
return (
|
|
8275
9320
|
<LazyVideo
|
|
@@ -8306,7 +9351,6 @@ function MediaItem({
|
|
|
8306
9351
|
|
|
8307
9352
|
function LightboxVideo({
|
|
8308
9353
|
src,
|
|
8309
|
-
phase,
|
|
8310
9354
|
onMediaElement,
|
|
8311
9355
|
wrapperStyle,
|
|
8312
9356
|
videoStyle,
|
|
@@ -8314,7 +9358,6 @@ function LightboxVideo({
|
|
|
8314
9358
|
onTransitionEnd,
|
|
8315
9359
|
}: {
|
|
8316
9360
|
src: string;
|
|
8317
|
-
phase: 'opening' | 'open' | 'closing';
|
|
8318
9361
|
onMediaElement?: (element: HTMLVideoElement | null) => void;
|
|
8319
9362
|
wrapperStyle: React.CSSProperties;
|
|
8320
9363
|
videoStyle: React.CSSProperties;
|
|
@@ -8339,11 +9382,12 @@ function LightboxVideo({
|
|
|
8339
9382
|
key={src}
|
|
8340
9383
|
ref={videoRef}
|
|
8341
9384
|
src={src}
|
|
8342
|
-
|
|
9385
|
+
muted
|
|
9386
|
+
autoPlay
|
|
9387
|
+
loop
|
|
8343
9388
|
playsInline
|
|
8344
9389
|
preload='auto'
|
|
8345
9390
|
onLoadedMetadata={onLoadedMetadata}
|
|
8346
|
-
onClick={(e) => e.stopPropagation()}
|
|
8347
9391
|
style={videoStyle}
|
|
8348
9392
|
/>
|
|
8349
9393
|
</div>
|
|
@@ -8361,11 +9405,17 @@ function LightboxSideMedia({
|
|
|
8361
9405
|
onTransitionEnd?: (e: React.TransitionEvent<HTMLElement>) => void;
|
|
8362
9406
|
onMeasure?: (url: string, width: number, height: number) => void;
|
|
8363
9407
|
}) {
|
|
9408
|
+
if (isEmbedMedia(media)) {
|
|
9409
|
+
return <img src={media.thumbnail} alt={media.name} style={style} onTransitionEnd={onTransitionEnd} />;
|
|
9410
|
+
}
|
|
9411
|
+
|
|
8364
9412
|
if (isVideoMedia(media)) {
|
|
8365
9413
|
return (
|
|
8366
9414
|
<video
|
|
8367
9415
|
src={media.assetId}
|
|
8368
9416
|
muted
|
|
9417
|
+
autoPlay
|
|
9418
|
+
loop
|
|
8369
9419
|
playsInline
|
|
8370
9420
|
preload='auto'
|
|
8371
9421
|
style={style}
|
|
@@ -8473,6 +9523,7 @@ function Lightbox({
|
|
|
8473
9523
|
const prevItemUrlRef = useRef<string | undefined>(undefined);
|
|
8474
9524
|
const currentItem = items[index];
|
|
8475
9525
|
const isCurrentVideo = currentItem ? isVideoMedia(currentItem) : false;
|
|
9526
|
+
const isCurrentEmbed = currentItem ? isEmbedMedia(currentItem) : false;
|
|
8476
9527
|
const isHorizontalNavActive = navSwipeOffset !== 0 || navSwipeAnimating;
|
|
8477
9528
|
const allowSwipeDismiss = !isEditMode && (!isEditor || Boolean(isPreviewMode));
|
|
8478
9529
|
const allowNavigation = canNavigate && !isEditMode;
|
|
@@ -9237,10 +10288,9 @@ function Lightbox({
|
|
|
9237
10288
|
: phase === 'opening' || isClosing
|
|
9238
10289
|
? \`opacity \${LIGHTBOX_ANIM_MS}ms \${LIGHTBOX_EASING}\`
|
|
9239
10290
|
: 'none',
|
|
9240
|
-
pointerEvents:
|
|
9241
|
-
touchAction: isCurrentVideo && isOpen ? 'none' : undefined,
|
|
10291
|
+
pointerEvents: 'none',
|
|
9242
10292
|
zIndex: 1,
|
|
9243
|
-
overflow: isCurrentVideo ? 'hidden' : undefined,
|
|
10293
|
+
overflow: isCurrentVideo || isCurrentEmbed ? 'hidden' : undefined,
|
|
9244
10294
|
};
|
|
9245
10295
|
|
|
9246
10296
|
const lightboxVideoStyle: React.CSSProperties = {
|
|
@@ -9248,7 +10298,7 @@ function Lightbox({
|
|
|
9248
10298
|
height: '100%',
|
|
9249
10299
|
display: 'block',
|
|
9250
10300
|
objectFit: 'contain',
|
|
9251
|
-
pointerEvents:
|
|
10301
|
+
pointerEvents: 'none',
|
|
9252
10302
|
};
|
|
9253
10303
|
|
|
9254
10304
|
const getSideMediaStyle = (
|
|
@@ -9486,11 +10536,20 @@ function Lightbox({
|
|
|
9486
10536
|
)}
|
|
9487
10537
|
|
|
9488
10538
|
{finalRect && currentItem && (
|
|
9489
|
-
|
|
10539
|
+
isCurrentEmbed ? (
|
|
10540
|
+
<div key={\`\${index}-\${currentItem.assetId}\`} style={mediaStyle} onTransitionEnd={handleNavSwipeTransitionEnd}>
|
|
10541
|
+
<EmbedMediaFrame
|
|
10542
|
+
media={currentItem}
|
|
10543
|
+
fit="contain"
|
|
10544
|
+
lazy={false}
|
|
10545
|
+
startsAtOnce
|
|
10546
|
+
style={lightboxVideoStyle}
|
|
10547
|
+
/>
|
|
10548
|
+
</div>
|
|
10549
|
+
) : isCurrentVideo ? (
|
|
9490
10550
|
<LightboxVideo
|
|
9491
10551
|
key={\`\${index}-\${currentItem.assetId}\`}
|
|
9492
10552
|
src={currentItem.assetId}
|
|
9493
|
-
phase={phase}
|
|
9494
10553
|
onMediaElement={setCenterMediaElement}
|
|
9495
10554
|
wrapperStyle={mediaStyle}
|
|
9496
10555
|
videoStyle={lightboxVideoStyle}
|
|
@@ -9771,7 +10830,7 @@ export function Hive({
|
|
|
9771
10830
|
</>
|
|
9772
10831
|
);
|
|
9773
10832
|
}
|
|
9774
|
-
`,
|
|
10833
|
+
`, M = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
|
|
9775
10834
|
import { createPortal } from 'react-dom';
|
|
9776
10835
|
import { CommonComponentProps } from '../props';
|
|
9777
10836
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
@@ -10536,7 +11595,7 @@ export type LightboxJournalSettings = {
|
|
|
10536
11595
|
closeIconColor: string;
|
|
10537
11596
|
closeIconHoverColor: string;
|
|
10538
11597
|
};
|
|
10539
|
-
`,
|
|
11598
|
+
`, L = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
|
|
10540
11599
|
import { createPortal } from 'react-dom';
|
|
10541
11600
|
import { CommonComponentProps } from '../props';
|
|
10542
11601
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
@@ -11082,10 +12141,10 @@ export const LightboxStrip = ({ settings, content, isEditor, isEditMode, isPrevi
|
|
|
11082
12141
|
</>
|
|
11083
12142
|
);
|
|
11084
12143
|
};
|
|
11085
|
-
`,
|
|
12144
|
+
`, k = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
|
11086
12145
|
import { createPortal } from 'react-dom';
|
|
11087
12146
|
import { CommonComponentProps } from '../props';
|
|
11088
|
-
import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index';
|
|
12147
|
+
import { buildColorVars, EmbedMediaFrame, isEmbedMedia, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
|
|
11089
12148
|
import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss';
|
|
11090
12149
|
import type { LayoutItem, LayoutTab } from '../../types/SchemaV1';
|
|
11091
12150
|
|
|
@@ -11215,7 +12274,10 @@ type ListMedia = {
|
|
|
11215
12274
|
objectFit?: 'cover' | 'contain';
|
|
11216
12275
|
assetId: string;
|
|
11217
12276
|
name: string;
|
|
11218
|
-
type?: 'image' | 'video';
|
|
12277
|
+
type?: 'image' | 'video' | 'vimeo' | 'youtube';
|
|
12278
|
+
thumbnail?: string;
|
|
12279
|
+
width?: number;
|
|
12280
|
+
height?: number;
|
|
11219
12281
|
};
|
|
11220
12282
|
|
|
11221
12283
|
type ListContentItem = {
|
|
@@ -11225,14 +12287,14 @@ type ListContentItem = {
|
|
|
11225
12287
|
DColumnWidth?: string;
|
|
11226
12288
|
EColumnWidth?: string;
|
|
11227
12289
|
image?: ListMedia;
|
|
11228
|
-
link?:
|
|
12290
|
+
link?: ContentLink;
|
|
11229
12291
|
};
|
|
11230
12292
|
|
|
11231
12293
|
type ListItemRow = {
|
|
11232
12294
|
id: string | number;
|
|
11233
12295
|
cells: Record<string, React.ReactNode>;
|
|
11234
12296
|
image?: ListContentItem['image'];
|
|
11235
|
-
link?:
|
|
12297
|
+
link?: ContentLink;
|
|
11236
12298
|
};
|
|
11237
12299
|
|
|
11238
12300
|
type HoverImageState = {
|
|
@@ -11240,10 +12302,13 @@ type HoverImageState = {
|
|
|
11240
12302
|
assetId: string;
|
|
11241
12303
|
objectFit: 'cover' | 'contain';
|
|
11242
12304
|
isVideo: boolean;
|
|
12305
|
+
/** The media itself when it is a Vimeo or YouTube video, framed rather than drawn. */
|
|
12306
|
+
embed?: ListMedia;
|
|
11243
12307
|
widthPx: number;
|
|
11244
12308
|
};
|
|
11245
12309
|
|
|
11246
12310
|
function isVideoMedia(media: Pick<ListMedia, 'assetId' | 'type' | 'name'>): boolean {
|
|
12311
|
+
if (isEmbedMedia(media)) return false;
|
|
11247
12312
|
if (media.type === 'video') return true;
|
|
11248
12313
|
if (media.type === 'image') return false;
|
|
11249
12314
|
const name = media.name ?? '';
|
|
@@ -11256,7 +12321,7 @@ function ListHoverMedia({
|
|
|
11256
12321
|
className,
|
|
11257
12322
|
style,
|
|
11258
12323
|
}: {
|
|
11259
|
-
media: Pick<HoverImageState, 'assetId' | 'objectFit' | 'isVideo'>;
|
|
12324
|
+
media: Pick<HoverImageState, 'assetId' | 'objectFit' | 'isVideo' | 'embed'>;
|
|
11260
12325
|
className: string;
|
|
11261
12326
|
style: React.CSSProperties;
|
|
11262
12327
|
}) {
|
|
@@ -11273,6 +12338,18 @@ function ListHoverMedia({
|
|
|
11273
12338
|
}
|
|
11274
12339
|
}, [media.isVideo, media.assetId]);
|
|
11275
12340
|
|
|
12341
|
+
if (media.embed) {
|
|
12342
|
+
return (
|
|
12343
|
+
<EmbedMediaFrame
|
|
12344
|
+
media={media.embed}
|
|
12345
|
+
startsAtOnce
|
|
12346
|
+
fit="contain"
|
|
12347
|
+
className={className}
|
|
12348
|
+
style={style}
|
|
12349
|
+
/>
|
|
12350
|
+
);
|
|
12351
|
+
}
|
|
12352
|
+
|
|
11276
12353
|
if (media.isVideo) {
|
|
11277
12354
|
return (
|
|
11278
12355
|
<video
|
|
@@ -13435,6 +14512,7 @@ export function List({ settings, content, isEditor, isPreviewMode, isEditMode, a
|
|
|
13435
14512
|
assetId: image.assetId,
|
|
13436
14513
|
objectFit: 'contain',
|
|
13437
14514
|
isVideo: isVideoMedia(image),
|
|
14515
|
+
embed: isEmbedMedia(image) ? image : undefined,
|
|
13438
14516
|
widthPx,
|
|
13439
14517
|
});
|
|
13440
14518
|
hoverShowPositionRef.current = { x, y };
|
|
@@ -13720,7 +14798,7 @@ export function List({ settings, content, isEditor, isPreviewMode, isEditMode, a
|
|
|
13720
14798
|
>
|
|
13721
14799
|
<div style={{ width: '100%', position: 'relative' }}>
|
|
13722
14800
|
{visibleRows.map((row, rowIdx) => {
|
|
13723
|
-
const hasLink = (row.link?.length ?? 0) > 0;
|
|
14801
|
+
const hasLink = (row.link?.value.length ?? 0) > 0;
|
|
13724
14802
|
const RowElement = hasLink && (!isEditor || isPreviewMode) ? 'a' : 'div';
|
|
13725
14803
|
const rowStyle = getEntryDividerWidths(
|
|
13726
14804
|
rowIdx,
|
|
@@ -13737,7 +14815,7 @@ export function List({ settings, content, isEditor, isPreviewMode, isEditMode, a
|
|
|
13737
14815
|
key={row.id}
|
|
13738
14816
|
ref={rowIdx === 0 ? (el: HTMLElement | null) => { firstRowRef.current = el; } : undefined}
|
|
13739
14817
|
className={\`\${P}-list-item\${hasLink || entryHoverShowOption === 'always' ? \` \${P}-list-item-has-link\` : ''}\${showCutLabel && rowIdx === visibleRows.length - 1 ? \` \${P}-list-item-before-cut\` : ''}\`}
|
|
13740
|
-
{...(hasLink ? { href: row.link, target: '_blank' } : {})}
|
|
14818
|
+
{...(hasLink ? { href: row.link?.value, target: row.link?.target === 'blank' ? '_blank' : '_self' } : {})}
|
|
13741
14819
|
style={rowStyle}
|
|
13742
14820
|
onMouseEnter={(event) => {
|
|
13743
14821
|
if (revealHoverActive && (hasLink || entryHoverShowOption === 'always')) {
|
|
@@ -14168,11 +15246,10 @@ export function List({ settings, content, isEditor, isPreviewMode, isEditMode, a
|
|
|
14168
15246
|
</>
|
|
14169
15247
|
);
|
|
14170
15248
|
}
|
|
14171
|
-
`,
|
|
15249
|
+
`, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
|
14172
15250
|
import cn from 'classnames';
|
|
14173
15251
|
import { CommonComponentProps } from '../props';
|
|
14174
|
-
import { scalingValue } from '../utils/
|
|
14175
|
-
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
15252
|
+
import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
|
|
14176
15253
|
import { NEAR_VIEWPORT_MARGIN, observeIntersection } from '../utils/observeIntersection';
|
|
14177
15254
|
import { pauseVideo, playVideo, raisePreload } from '../utils/useLazyVideos';
|
|
14178
15255
|
|
|
@@ -14401,6 +15478,7 @@ const isAnyCopyOfSlotInView = (wrapper: Element, itemIndex: number): boolean =>
|
|
|
14401
15478
|
};
|
|
14402
15479
|
|
|
14403
15480
|
const isVideoMedia = (media: Pick<NonNullable<MarqueeItem['image']>, 'assetId' | 'type' | 'name'>): boolean => {
|
|
15481
|
+
if (isEmbedMedia(media)) return false;
|
|
14404
15482
|
if (media.type === 'video') return true;
|
|
14405
15483
|
if (media.type === 'image') return false;
|
|
14406
15484
|
const name = media.name ?? '';
|
|
@@ -14442,11 +15520,13 @@ const MarqueeItemCard = ({
|
|
|
14442
15520
|
}: MarqueeItemCardProps) => {
|
|
14443
15521
|
const mediaRef = useRef<HTMLImageElement | HTMLVideoElement | null>(null);
|
|
14444
15522
|
const isVideo = Boolean(item.image?.assetId && isVideoMedia(item.image));
|
|
15523
|
+
// an embed's box is sized from what is stored, so there is nothing to wait for
|
|
15524
|
+
const isEmbed = Boolean(item.image?.assetId && isEmbedMedia(item.image));
|
|
14445
15525
|
|
|
14446
15526
|
useLayoutEffect(() => {
|
|
14447
15527
|
if (!isFirstSet) return;
|
|
14448
|
-
if (isMediaReady(mediaRef.current)) onFirstSetImageDone?.();
|
|
14449
|
-
}, [isFirstSet, item.image?.assetId, onFirstSetImageDone]);
|
|
15528
|
+
if (isEmbed || isMediaReady(mediaRef.current)) onFirstSetImageDone?.();
|
|
15529
|
+
}, [isFirstSet, isEmbed, item.image?.assetId, onFirstSetImageDone]);
|
|
14450
15530
|
|
|
14451
15531
|
const isCover = imageFit.display === 'cover';
|
|
14452
15532
|
const ratioValue = imageFit.ratioValue ?? '1:1';
|
|
@@ -14485,9 +15565,27 @@ const MarqueeItemCard = ({
|
|
|
14485
15565
|
...radiusStyle,
|
|
14486
15566
|
};
|
|
14487
15567
|
|
|
15568
|
+
// a frame has no size of its own: fitted, it takes the box a video of its aspect would
|
|
15569
|
+
const embedAspect = isEmbed && item.image ? getEmbedAspect(item.image) : null;
|
|
15570
|
+
const embedStyle: CSSProperties | undefined = embedAspect === null
|
|
15571
|
+
? undefined
|
|
15572
|
+
: isCover
|
|
15573
|
+
? mediaStyle
|
|
15574
|
+
: {
|
|
15575
|
+
...mediaStyle,
|
|
15576
|
+
width: scaled(imageMaxWidth / embedAspect > imageMaxHeight ? imageMaxHeight * embedAspect : imageMaxWidth),
|
|
15577
|
+
height: scaled(imageMaxWidth / embedAspect > imageMaxHeight ? imageMaxHeight : imageMaxWidth / embedAspect),
|
|
15578
|
+
};
|
|
15579
|
+
|
|
14488
15580
|
const imageNode =
|
|
14489
15581
|
item.image?.assetId &&
|
|
14490
|
-
(
|
|
15582
|
+
(isEmbed ? (
|
|
15583
|
+
<EmbedMediaFrame
|
|
15584
|
+
media={item.image}
|
|
15585
|
+
fit={isCover ? 'cover' : 'contain'}
|
|
15586
|
+
style={embedStyle}
|
|
15587
|
+
/>
|
|
15588
|
+
) : isVideo ? (
|
|
14491
15589
|
<video
|
|
14492
15590
|
ref={(el) => { mediaRef.current = el; }}
|
|
14493
15591
|
src={item.image.assetId}
|
|
@@ -14542,14 +15640,11 @@ const MarqueeItemCard = ({
|
|
|
14542
15640
|
}),
|
|
14543
15641
|
}}
|
|
14544
15642
|
>
|
|
14545
|
-
{imageNode &&
|
|
14546
|
-
|
|
14547
|
-
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
)
|
|
14551
|
-
: imageNode
|
|
14552
|
-
}
|
|
15643
|
+
{imageNode && (
|
|
15644
|
+
<LinkWrapper link={item.link} className={cn(\`\${P}-marquee-link\`, !isCover && \`\${P}-marquee-link-contain\`)}>
|
|
15645
|
+
{imageNode}
|
|
15646
|
+
</LinkWrapper>
|
|
15647
|
+
)}
|
|
14553
15648
|
</div>
|
|
14554
15649
|
</div>
|
|
14555
15650
|
);
|
|
@@ -14978,9 +16073,12 @@ export type MarqueeItem = {
|
|
|
14978
16073
|
image?: {
|
|
14979
16074
|
assetId?: string;
|
|
14980
16075
|
name?: string;
|
|
14981
|
-
type?: 'image' | 'video';
|
|
16076
|
+
type?: 'image' | 'video' | 'vimeo' | 'youtube';
|
|
16077
|
+
thumbnail?: string;
|
|
16078
|
+
width?: number;
|
|
16079
|
+
height?: number;
|
|
14982
16080
|
};
|
|
14983
|
-
link?:
|
|
16081
|
+
link?: ContentLink;
|
|
14984
16082
|
};
|
|
14985
16083
|
|
|
14986
16084
|
export type MarqueeSettings = {
|
|
@@ -15006,11 +16104,10 @@ type MarqueeProps = {
|
|
|
15006
16104
|
isPreviewMode?: boolean;
|
|
15007
16105
|
isEditMode?: boolean;
|
|
15008
16106
|
} & CommonComponentProps;
|
|
15009
|
-
`,
|
|
16107
|
+
`, N = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
|
|
15010
16108
|
import cn from 'classnames';
|
|
15011
16109
|
import { CommonComponentProps } from '../props';
|
|
15012
|
-
import { scalingValue } from '../utils/
|
|
15013
|
-
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
16110
|
+
import { LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
|
|
15014
16111
|
import { textStylesToCss } from '../utils/textStylesToCss';
|
|
15015
16112
|
import { observeIntersection } from '../utils/observeIntersection';
|
|
15016
16113
|
|
|
@@ -15350,9 +16447,7 @@ const MarqueeTextItemView = ({ item, prefix: P, textCss, capHeightPx, opticalOff
|
|
|
15350
16447
|
);
|
|
15351
16448
|
return (
|
|
15352
16449
|
<div className={\`\${P}-item\`} data-marquee-text-item style={{ gap: imageGapPx }}>
|
|
15353
|
-
{item.link
|
|
15354
|
-
? <a href={item.link} className={\`\${P}-item-link\`} style={{ gap: imageGapPx }}>{content}</a>
|
|
15355
|
-
: content}
|
|
16450
|
+
<LinkWrapper link={item.link} className={\`\${P}-item-link\`} style={{ gap: imageGapPx }}>{content}</LinkWrapper>
|
|
15356
16451
|
</div>
|
|
15357
16452
|
);
|
|
15358
16453
|
};
|
|
@@ -15435,7 +16530,7 @@ export const MarqueeText = ({ settings, content, isEditor, isPreviewMode }: Marq
|
|
|
15435
16530
|
const [ribbonHeightPx, setRibbonHeightPx] = useState(0);
|
|
15436
16531
|
|
|
15437
16532
|
const contentKey = useMemo(
|
|
15438
|
-
() => (content ?? []).map((i) => \`\${i.text}\\0\${i.image?.assetId ?? ''}\\0\${i.link ?? ''}\`).join('\\0'),
|
|
16533
|
+
() => (content ?? []).map((i) => \`\${i.text}\\0\${i.image?.assetId ?? ''}\\0\${i.link?.value ?? ''}\`).join('\\0'),
|
|
15439
16534
|
[content],
|
|
15440
16535
|
);
|
|
15441
16536
|
const [contentSequenceRepeat, setContentSequenceRepeat] = useState(MIN_CONTENT_SEQUENCE_REPEAT);
|
|
@@ -15916,7 +17011,7 @@ export type MarqueeTextItem = {
|
|
|
15916
17011
|
assetId?: string;
|
|
15917
17012
|
name?: string;
|
|
15918
17013
|
};
|
|
15919
|
-
link?:
|
|
17014
|
+
link?: ContentLink;
|
|
15920
17015
|
};
|
|
15921
17016
|
|
|
15922
17017
|
export type MarqueeTextSettings = {
|
|
@@ -15952,10 +17047,11 @@ type MarqueeTextProps = {
|
|
|
15952
17047
|
isPreviewMode?: boolean;
|
|
15953
17048
|
isEditMode?: boolean;
|
|
15954
17049
|
} & CommonComponentProps;
|
|
15955
|
-
`,
|
|
17050
|
+
`, H = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
15956
17051
|
import { createPortal } from 'react-dom';
|
|
15957
17052
|
import type React from 'react';
|
|
15958
17053
|
import { CommonComponentProps } from '../props';
|
|
17054
|
+
import { EmbedMediaFrame, getEmbedAspect, getEmbedPlayback, isEmbedMedia } from '../utils/index';
|
|
15959
17055
|
import {
|
|
15960
17056
|
buildColorVars,
|
|
15961
17057
|
scalingValue,
|
|
@@ -16347,8 +17443,11 @@ function getTitlePositionAxes(position: TitlePosition): TitlePositionAxes {
|
|
|
16347
17443
|
type MercuryMedia = {
|
|
16348
17444
|
assetId: string;
|
|
16349
17445
|
name?: string;
|
|
16350
|
-
type?: 'image' | 'video';
|
|
17446
|
+
type?: 'image' | 'video' | 'vimeo' | 'youtube';
|
|
16351
17447
|
objectFit?: 'cover' | 'contain';
|
|
17448
|
+
thumbnail?: string;
|
|
17449
|
+
width?: number;
|
|
17450
|
+
height?: number;
|
|
16352
17451
|
};
|
|
16353
17452
|
|
|
16354
17453
|
type MercuryMediaPair = {
|
|
@@ -16587,21 +17686,15 @@ function resolveLightboxImageDisplay(
|
|
|
16587
17686
|
|
|
16588
17687
|
function LightboxVideo({
|
|
16589
17688
|
src,
|
|
16590
|
-
phase,
|
|
16591
17689
|
mediaRef,
|
|
16592
17690
|
mediaStyle,
|
|
16593
17691
|
onLoadedMetadata,
|
|
16594
|
-
onClick,
|
|
16595
|
-
onMouseMove,
|
|
16596
17692
|
onTransitionEnd,
|
|
16597
17693
|
}: {
|
|
16598
17694
|
src: string;
|
|
16599
|
-
phase: 'opening' | 'open' | 'closing';
|
|
16600
17695
|
mediaRef: React.RefObject<HTMLVideoElement>;
|
|
16601
17696
|
mediaStyle: React.CSSProperties;
|
|
16602
17697
|
onLoadedMetadata: () => void;
|
|
16603
|
-
onClick: (e: React.MouseEvent<HTMLVideoElement>) => void;
|
|
16604
|
-
onMouseMove: (e: React.MouseEvent<HTMLVideoElement>) => void;
|
|
16605
17698
|
onTransitionEnd: (e: React.TransitionEvent<HTMLVideoElement>) => void;
|
|
16606
17699
|
}) {
|
|
16607
17700
|
useEffect(() => {
|
|
@@ -16617,12 +17710,12 @@ function LightboxVideo({
|
|
|
16617
17710
|
<video
|
|
16618
17711
|
ref={mediaRef}
|
|
16619
17712
|
src={src}
|
|
16620
|
-
|
|
17713
|
+
muted
|
|
17714
|
+
autoPlay
|
|
17715
|
+
loop
|
|
16621
17716
|
playsInline
|
|
16622
17717
|
preload="auto"
|
|
16623
17718
|
onLoadedMetadata={onLoadedMetadata}
|
|
16624
|
-
onClick={onClick}
|
|
16625
|
-
onMouseMove={onMouseMove}
|
|
16626
17719
|
onTransitionEnd={onTransitionEnd}
|
|
16627
17720
|
style={mediaStyle}
|
|
16628
17721
|
/>
|
|
@@ -16798,6 +17891,7 @@ function Lightbox({
|
|
|
16798
17891
|
const prevIndexRef = useRef(index);
|
|
16799
17892
|
const currentItem = items[index];
|
|
16800
17893
|
const isCurrentVideo = currentItem ? isVideoMedia(currentItem) : false;
|
|
17894
|
+
const isCurrentEmbed = currentItem ? isEmbedMedia(currentItem) : false;
|
|
16801
17895
|
const isHorizontalNavActive = navSwipeOffset !== 0 || navSwipeAnimating;
|
|
16802
17896
|
|
|
16803
17897
|
const setNavSwipeAnimatingState = useCallback((value: boolean) => {
|
|
@@ -16834,18 +17928,22 @@ function Lightbox({
|
|
|
16834
17928
|
return;
|
|
16835
17929
|
}
|
|
16836
17930
|
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
|
|
17931
|
+
// an embed's player reports no size of its own, so its stored aspect stands in
|
|
17932
|
+
let ir = currentItem && isEmbedMedia(currentItem) ? getEmbedAspect(currentItem) : null;
|
|
17933
|
+
if (ir === null) {
|
|
17934
|
+
if (!media) {
|
|
17935
|
+
setFinalRect(getGhostRect(ghost));
|
|
17936
|
+
return;
|
|
17937
|
+
}
|
|
16841
17938
|
|
|
16842
|
-
|
|
16843
|
-
|
|
16844
|
-
|
|
16845
|
-
|
|
17939
|
+
const { width: nw, height: nh } = getLightboxMediaDimensions(media);
|
|
17940
|
+
if (!nw || !nh) {
|
|
17941
|
+
setFinalRect(getGhostRect(ghost));
|
|
17942
|
+
return;
|
|
17943
|
+
}
|
|
17944
|
+
ir = nw / nh;
|
|
16846
17945
|
}
|
|
16847
17946
|
|
|
16848
|
-
const ir = nw / nh;
|
|
16849
17947
|
const cr = cw / ch;
|
|
16850
17948
|
if (ir > cr) {
|
|
16851
17949
|
const dh = cw / ir;
|
|
@@ -16854,7 +17952,7 @@ function Lightbox({
|
|
|
16854
17952
|
const dw = ch * ir;
|
|
16855
17953
|
setFinalRect({ width: dw, height: ch, left: cb.left + (cw - dw) / 2, top: cb.top });
|
|
16856
17954
|
}
|
|
16857
|
-
}, [imageDisplay]);
|
|
17955
|
+
}, [imageDisplay, currentItem]);
|
|
16858
17956
|
|
|
16859
17957
|
useEffect(() => {
|
|
16860
17958
|
computeFinalRect();
|
|
@@ -17074,46 +18172,6 @@ function Lightbox({
|
|
|
17074
18172
|
const swipeBackdropOpacity = swipeOffset > 0 ? Math.max(0, 1 - swipeOffset / 500) : 1;
|
|
17075
18173
|
const swipeMediaOpacity = swipeOffset > 0 ? Math.max(0.35, 1 - swipeOffset / 500) : 1;
|
|
17076
18174
|
|
|
17077
|
-
const handleVideoClick = (e: React.MouseEvent<HTMLVideoElement>) => {
|
|
17078
|
-
e.stopPropagation();
|
|
17079
|
-
if (touchInteractionRef.current) {
|
|
17080
|
-
touchInteractionRef.current = false;
|
|
17081
|
-
return;
|
|
17082
|
-
}
|
|
17083
|
-
if (items.length <= 1) return;
|
|
17084
|
-
|
|
17085
|
-
const rect = e.currentTarget.getBoundingClientRect();
|
|
17086
|
-
const y = e.clientY - rect.top;
|
|
17087
|
-
const controlsZoneHeight = Math.min(52, rect.height * 0.2);
|
|
17088
|
-
|
|
17089
|
-
if (y > rect.height - controlsZoneHeight) {
|
|
17090
|
-
return;
|
|
17091
|
-
}
|
|
17092
|
-
|
|
17093
|
-
if (e.clientX - rect.left < rect.width / 2) {
|
|
17094
|
-
onPrev();
|
|
17095
|
-
return;
|
|
17096
|
-
}
|
|
17097
|
-
|
|
17098
|
-
onNext();
|
|
17099
|
-
};
|
|
17100
|
-
|
|
17101
|
-
const handleVideoMouseMove = (e: React.MouseEvent<HTMLVideoElement>) => {
|
|
17102
|
-
if (items.length <= 1) return;
|
|
17103
|
-
|
|
17104
|
-
const rect = e.currentTarget.getBoundingClientRect();
|
|
17105
|
-
const x = e.clientX - rect.left;
|
|
17106
|
-
const y = e.clientY - rect.top;
|
|
17107
|
-
const controlsZoneHeight = Math.min(52, rect.height * 0.2);
|
|
17108
|
-
|
|
17109
|
-
if (y > rect.height - controlsZoneHeight) {
|
|
17110
|
-
e.currentTarget.style.cursor = 'default';
|
|
17111
|
-
return;
|
|
17112
|
-
}
|
|
17113
|
-
|
|
17114
|
-
e.currentTarget.style.cursor = x < rect.width / 2 ? 'w-resize' : 'e-resize';
|
|
17115
|
-
};
|
|
17116
|
-
|
|
17117
18175
|
const handleNavSwipeTransitionEnd = useCallback((e: React.TransitionEvent<HTMLElement>) => {
|
|
17118
18176
|
if (e.propertyName !== 'transform' || !navSwipeAnimatingRef.current) return;
|
|
17119
18177
|
|
|
@@ -17149,15 +18207,18 @@ function Lightbox({
|
|
|
17149
18207
|
: phase === 'opening' || isClosing
|
|
17150
18208
|
? \`opacity \${LIGHTBOX_ANIM_MS}ms \${LIGHTBOX_EASING}\`
|
|
17151
18209
|
: 'none',
|
|
17152
|
-
pointerEvents:
|
|
17153
|
-
touchAction: isCurrentVideo && isOpen ? 'none' : undefined,
|
|
18210
|
+
pointerEvents: 'none',
|
|
17154
18211
|
zIndex: 9998,
|
|
17155
18212
|
};
|
|
17156
18213
|
|
|
18214
|
+
// over an embed with controls the overlays stop short of the player's own control bar
|
|
18215
|
+
const navOverlayInset = isCurrentEmbed && currentItem && getEmbedPlayback(currentItem).controls && finalRect
|
|
18216
|
+
? Math.min(52, finalRect.height * 0.2)
|
|
18217
|
+
: 0;
|
|
17157
18218
|
const navOverlayBaseStyle = finalRect ? {
|
|
17158
18219
|
position: 'fixed' as const,
|
|
17159
18220
|
top: finalRect.top,
|
|
17160
|
-
height: finalRect.height,
|
|
18221
|
+
height: finalRect.height - navOverlayInset,
|
|
17161
18222
|
width: finalRect.width / 2,
|
|
17162
18223
|
zIndex: 9999,
|
|
17163
18224
|
} : null;
|
|
@@ -17257,16 +18318,23 @@ function Lightbox({
|
|
|
17257
18318
|
</div>
|
|
17258
18319
|
|
|
17259
18320
|
{finalRect && currentItem && (
|
|
17260
|
-
|
|
18321
|
+
isCurrentEmbed ? (
|
|
18322
|
+
<EmbedMediaFrame
|
|
18323
|
+
key={\`\${index}-\${currentItem.assetId}\`}
|
|
18324
|
+
media={currentItem}
|
|
18325
|
+
fit={imageDisplay === 'cover' ? 'cover' : 'contain'}
|
|
18326
|
+
lazy={false}
|
|
18327
|
+
startsAtOnce
|
|
18328
|
+
style={mediaStyle}
|
|
18329
|
+
onTransitionEnd={handleNavSwipeTransitionEnd}
|
|
18330
|
+
/>
|
|
18331
|
+
) : isCurrentVideo ? (
|
|
17261
18332
|
<LightboxVideo
|
|
17262
18333
|
key={\`\${index}-\${currentItem.assetId}\`}
|
|
17263
18334
|
src={currentItem.assetId}
|
|
17264
|
-
phase={phase}
|
|
17265
18335
|
mediaRef={mediaRef as React.RefObject<HTMLVideoElement>}
|
|
17266
18336
|
mediaStyle={mediaStyle}
|
|
17267
18337
|
onLoadedMetadata={computeFinalRect}
|
|
17268
|
-
onClick={handleVideoClick}
|
|
17269
|
-
onMouseMove={handleVideoMouseMove}
|
|
17270
18338
|
onTransitionEnd={handleNavSwipeTransitionEnd}
|
|
17271
18339
|
/>
|
|
17272
18340
|
) : (
|
|
@@ -17282,7 +18350,7 @@ function Lightbox({
|
|
|
17282
18350
|
)
|
|
17283
18351
|
)}
|
|
17284
18352
|
|
|
17285
|
-
{isOpen && navOverlayBaseStyle && items.length > 1 &&
|
|
18353
|
+
{isOpen && navOverlayBaseStyle && items.length > 1 && (
|
|
17286
18354
|
<>
|
|
17287
18355
|
<div
|
|
17288
18356
|
style={{
|
|
@@ -17347,6 +18415,7 @@ function GalleryMediaItem({
|
|
|
17347
18415
|
galleryPaddingBetween = 0,
|
|
17348
18416
|
showPaddingAfter = false,
|
|
17349
18417
|
showControls = false,
|
|
18418
|
+
hasLightbox,
|
|
17350
18419
|
onMediaClick,
|
|
17351
18420
|
}: {
|
|
17352
18421
|
P: string;
|
|
@@ -17359,6 +18428,8 @@ function GalleryMediaItem({
|
|
|
17359
18428
|
galleryPaddingBetween?: number;
|
|
17360
18429
|
showPaddingAfter?: boolean;
|
|
17361
18430
|
showControls?: boolean;
|
|
18431
|
+
/** An embed then plays here as a silent loop, and as it was set to in the lightbox. */
|
|
18432
|
+
hasLightbox: boolean;
|
|
17362
18433
|
onMediaClick?: () => void;
|
|
17363
18434
|
}) {
|
|
17364
18435
|
const mediaClassName = \`\${P}-gallery-\${isVideoMedia(media) ? 'video' : 'image'}\`;
|
|
@@ -17408,7 +18479,14 @@ function GalleryMediaItem({
|
|
|
17408
18479
|
};
|
|
17409
18480
|
const galleryPaddingBetweenHeight = Math.max(galleryPaddingBetween, PADDING_HANDLE_SIZE);
|
|
17410
18481
|
|
|
17411
|
-
const mediaNode =
|
|
18482
|
+
const mediaNode = isEmbedMedia(media) ? (
|
|
18483
|
+
<EmbedMediaFrame
|
|
18484
|
+
{...mediaProps}
|
|
18485
|
+
media={media}
|
|
18486
|
+
fit={isCover ? 'cover' : 'contain'}
|
|
18487
|
+
silentLoop={hasLightbox}
|
|
18488
|
+
/>
|
|
18489
|
+
) : isVideoMedia(media) ? (
|
|
17412
18490
|
<LazyVideo
|
|
17413
18491
|
{...mediaProps}
|
|
17414
18492
|
src={media.assetId}
|
|
@@ -18351,6 +19429,7 @@ export function Mercury({
|
|
|
18351
19429
|
galleryPaddingBetween={galleryPaddingBetween}
|
|
18352
19430
|
showPaddingAfter={mediaIndex < displayItems.length - 1}
|
|
18353
19431
|
showControls={showControls}
|
|
19432
|
+
hasLightbox={lightbox === 'on'}
|
|
18354
19433
|
onMediaClick={canOpenLightbox && lightboxItemIndex >= 0
|
|
18355
19434
|
? () => openLightbox(lightboxItemsForEntry, lightboxItemIndex)
|
|
18356
19435
|
: undefined}
|
|
@@ -18402,6 +19481,7 @@ export function Mercury({
|
|
|
18402
19481
|
galleryPaddingBetween={galleryPaddingBetween}
|
|
18403
19482
|
showPaddingAfter={mediaIndex < displayItems.length - 1}
|
|
18404
19483
|
showControls={showControls}
|
|
19484
|
+
hasLightbox={lightbox === 'on'}
|
|
18405
19485
|
onMediaClick={canOpenLightbox && lightboxItemIndex >= 0
|
|
18406
19486
|
? () => openLightbox(lightboxItemsForEntry, lightboxItemIndex)
|
|
18407
19487
|
: undefined}
|
|
@@ -18449,7 +19529,7 @@ export function Mercury({
|
|
|
18449
19529
|
</>
|
|
18450
19530
|
);
|
|
18451
19531
|
}
|
|
18452
|
-
`,
|
|
19532
|
+
`, O = `import React, { useMemo, useState } from 'react';
|
|
18453
19533
|
import { CommonComponentProps } from '../props';
|
|
18454
19534
|
import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
|
|
18455
19535
|
import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
|
|
@@ -19028,7 +20108,7 @@ const COLOR_VAR_MAP: Record<OnelinerColorKeys, string> = {
|
|
|
19028
20108
|
};
|
|
19029
20109
|
|
|
19030
20110
|
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
19031
|
-
`,
|
|
20111
|
+
`, _ = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
19032
20112
|
import type React from 'react';
|
|
19033
20113
|
import { CommonComponentProps } from '../props';
|
|
19034
20114
|
import { scalingValue, useScopedStyles } from '../utils/index';
|
|
@@ -19867,7 +20947,7 @@ export function Pretext({ settings, content, isEditor, isPreviewMode, isEditMode
|
|
|
19867
20947
|
</>
|
|
19868
20948
|
);
|
|
19869
20949
|
}
|
|
19870
|
-
`,
|
|
20950
|
+
`, F = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
19871
20951
|
import cn from 'classnames';
|
|
19872
20952
|
import { CommonComponentProps } from '../props';
|
|
19873
20953
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
@@ -20495,7 +21575,7 @@ export function Scale({ settings, content, isEditor, isPreviewMode }: ScaleProps
|
|
|
20495
21575
|
</>
|
|
20496
21576
|
);
|
|
20497
21577
|
}
|
|
20498
|
-
`,
|
|
21578
|
+
`, W = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
|
|
20499
21579
|
import { SvgImage } from '../helpers/SvgImage/SvgImage';
|
|
20500
21580
|
import { CommonComponentProps } from '../props';
|
|
20501
21581
|
import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
|
|
@@ -21127,7 +22207,7 @@ export function SimpleButton({ settings, isEditor, isPreviewMode, activeEvent, h
|
|
|
21127
22207
|
</>
|
|
21128
22208
|
);
|
|
21129
22209
|
}
|
|
21130
|
-
`,
|
|
22210
|
+
`, D = `import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
21131
22211
|
import cn from 'classnames';
|
|
21132
22212
|
import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
|
|
21133
22213
|
import { scalingValue } from '../utils/scalingValue';
|
|
@@ -22309,7 +23389,7 @@ function ArrowIcon({ color, className }: { color: string, className: string }) {
|
|
|
22309
23389
|
</svg>
|
|
22310
23390
|
);
|
|
22311
23391
|
}
|
|
22312
|
-
`,
|
|
23392
|
+
`, B = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
22313
23393
|
import cn from 'classnames';
|
|
22314
23394
|
import { CommonComponentProps } from '../props';
|
|
22315
23395
|
import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
|
|
@@ -22940,7 +24020,7 @@ type TestimonialsSettings = {
|
|
|
22940
24020
|
logoHeight: number;
|
|
22941
24021
|
captionMarginTop: number;
|
|
22942
24022
|
};
|
|
22943
|
-
`,
|
|
24023
|
+
`, z = `import cn from 'classnames';
|
|
22944
24024
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
22945
24025
|
import { CommonComponentProps } from '../props';
|
|
22946
24026
|
import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
|
|
@@ -23436,10 +24516,11 @@ type TestimonialsSettings = {
|
|
|
23436
24516
|
icon?: string | null;
|
|
23437
24517
|
};
|
|
23438
24518
|
};
|
|
23439
|
-
`,
|
|
24519
|
+
`, V = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
23440
24520
|
import type React from 'react';
|
|
23441
24521
|
import { createPortal } from 'react-dom';
|
|
23442
24522
|
import { CommonComponentProps } from '../props';
|
|
24523
|
+
import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia } from '../utils/index';
|
|
23443
24524
|
import { getContainedMediaTransformOrigin } from '../utils/getImageRect';
|
|
23444
24525
|
import { scalingValue, useScopedStyles } from '../utils/index';
|
|
23445
24526
|
import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
|
|
@@ -23559,7 +24640,8 @@ function getCSS(P: string): string {
|
|
|
23559
24640
|
object-position: bottom;
|
|
23560
24641
|
}
|
|
23561
24642
|
.\${P}-item-image-hover-scale img,
|
|
23562
|
-
.\${P}-item-image-hover-scale video
|
|
24643
|
+
.\${P}-item-image-hover-scale video,
|
|
24644
|
+
.\${P}-item-image-hover-scale [data-embed-frame] {
|
|
23563
24645
|
transition: transform 0.3s ease;
|
|
23564
24646
|
}
|
|
23565
24647
|
.\${P}-item-image-hover-scale:hover {
|
|
@@ -23765,7 +24847,9 @@ export function Waterfall({
|
|
|
23765
24847
|
return style as React.CSSProperties;
|
|
23766
24848
|
})();
|
|
23767
24849
|
|
|
23768
|
-
const
|
|
24850
|
+
const hasLightbox = (settings?.lightbox ?? 'on') === 'on';
|
|
24851
|
+
// an embed in a cell that opens the lightbox plays there as it was set to, and here as a silent loop
|
|
24852
|
+
const canOpenLightbox = hasLightbox && (!isEditor || isPreviewMode || isEditMode);
|
|
23769
24853
|
const allLightboxEntries = useMemo(() => buildLightboxEntries(items), [items]);
|
|
23770
24854
|
const allMedia = useMemo(() => collectAllWaterfallMedia(items), [items]);
|
|
23771
24855
|
|
|
@@ -23869,8 +24953,22 @@ export function Waterfall({
|
|
|
23869
24953
|
objectFitMode === 'contain' ? \`\${P}-item-image-fit\` : undefined,
|
|
23870
24954
|
imageHoverClass,
|
|
23871
24955
|
].filter(Boolean).join(' ')}
|
|
24956
|
+
// a frame reports no size of its own, so the stored aspect is set here up front
|
|
24957
|
+
style={isEmbedMedia(item.image)
|
|
24958
|
+
? { [\`--\${P}-item-media-aspect\`]: String(getEmbedAspect(item.image)) } as React.CSSProperties
|
|
24959
|
+
: undefined}
|
|
23872
24960
|
>
|
|
23873
|
-
{item.image
|
|
24961
|
+
{isEmbedMedia(item.image) ? (
|
|
24962
|
+
<EmbedMediaFrame
|
|
24963
|
+
media={item.image}
|
|
24964
|
+
fit={objectFitMode}
|
|
24965
|
+
silentLoop={hasLightbox}
|
|
24966
|
+
data-waterfall-index={index}
|
|
24967
|
+
// placed the way the image rule above places a picture, inline since the frame positions itself inline
|
|
24968
|
+
style={{ ...imageStyle, position: 'absolute', left: 0, bottom: 0, width: '100%', height: '1cap' }}
|
|
24969
|
+
onClick={handleOpen}
|
|
24970
|
+
/>
|
|
24971
|
+
) : item.image.type === 'video' ? (
|
|
23874
24972
|
<LazyVideo
|
|
23875
24973
|
ref={syncFitMediaLayout}
|
|
23876
24974
|
src={item.image.assetId}
|
|
@@ -23951,29 +25049,30 @@ export function Waterfall({
|
|
|
23951
25049
|
</>
|
|
23952
25050
|
);
|
|
23953
25051
|
}
|
|
23954
|
-
`,
|
|
23955
|
-
[
|
|
23956
|
-
[
|
|
23957
|
-
[
|
|
23958
|
-
[
|
|
23959
|
-
[
|
|
23960
|
-
[
|
|
23961
|
-
[
|
|
23962
|
-
[
|
|
23963
|
-
[
|
|
23964
|
-
[
|
|
23965
|
-
[
|
|
23966
|
-
[
|
|
23967
|
-
[
|
|
23968
|
-
[
|
|
23969
|
-
[
|
|
23970
|
-
[
|
|
23971
|
-
[
|
|
23972
|
-
[
|
|
23973
|
-
[
|
|
23974
|
-
[
|
|
23975
|
-
[
|
|
25052
|
+
`, U = {
|
|
25053
|
+
[y.id]: S,
|
|
25054
|
+
[b.id]: C,
|
|
25055
|
+
[x.id]: w,
|
|
25056
|
+
[P.id]: $,
|
|
25057
|
+
[v.id]: I,
|
|
25058
|
+
[f.id]: T,
|
|
25059
|
+
[h.id]: E,
|
|
25060
|
+
[p.id]: R,
|
|
25061
|
+
[m.id]: M,
|
|
25062
|
+
[g.id]: L,
|
|
25063
|
+
[u.id]: k,
|
|
25064
|
+
[d.id]: A,
|
|
25065
|
+
[c.id]: N,
|
|
25066
|
+
[l.id]: H,
|
|
25067
|
+
[s.id]: O,
|
|
25068
|
+
[a.id]: _,
|
|
25069
|
+
[r.id]: F,
|
|
25070
|
+
[o.id]: W,
|
|
25071
|
+
[i.id]: D,
|
|
25072
|
+
[t.id]: B,
|
|
25073
|
+
[e.id]: z,
|
|
25074
|
+
[n.id]: V
|
|
23976
25075
|
};
|
|
23977
25076
|
export {
|
|
23978
|
-
|
|
25077
|
+
U as componentSources
|
|
23979
25078
|
};
|