@cntrl-site/components 1.0.120-alpha.0 → 1.0.120
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/ChroniclesComponent-5ZbqHNpi.js +1 -0
- package/dist/{ChroniclesComponent-CeaJBqKz.mjs → ChroniclesComponent-8lhIeord.mjs} +541 -603
- package/dist/Components/Grid/Grid.d.ts +7 -31
- package/dist/Components/Slider20/Slider20.d.ts +2 -1
- package/dist/ControlSlider-C8ckUIDm.js +1 -0
- package/dist/{ControlSlider-BBAXRDLP.mjs → ControlSlider-DqKfaKMG.mjs} +3 -2
- package/dist/Grid-C4hO8KCr.js +408 -0
- package/dist/Grid-Dud7PLS9.mjs +1622 -0
- package/dist/Slider20-C2o_EB1I.mjs +872 -0
- package/dist/Slider20-DzxWCTg-.js +273 -0
- package/dist/{components-Cp5lKUwh.js → components-BHB4G3ma.js} +1 -1
- package/dist/{components-DoYrYUvq.mjs → components-CBJ6asBX.mjs} +13 -14
- package/dist/components.css +1 -1
- package/dist/elements.js +1 -1
- package/dist/elements.mjs +8 -9
- package/dist/elements.node.js +1 -1
- package/dist/elements.node.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +2 -2
- package/dist/sources.js +447 -809
- package/dist/sources.mjs +485 -848
- package/package.json +1 -1
- package/dist/ChroniclesComponent-DK6L2w5h.js +0 -1
- package/dist/Components/Grid/CustomGridComponent.d.ts +0 -41
- package/dist/ControlSlider-BCkVFl4w.js +0 -1
- package/dist/Grid-By7t2l11.js +0 -445
- package/dist/Grid-If8uE2Sy.mjs +0 -1865
- package/dist/Slider20-BOmjDRf2.js +0 -272
- package/dist/Slider20-DUi6qwnd.mjs +0 -851
package/dist/sources.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as
|
|
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 d, M as c, 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, j as b, B as y } from "./ChroniclesComponent-8lhIeord.mjs";
|
|
2
|
+
const S = `import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
|
|
3
3
|
import { CommonComponentProps } from '../props';
|
|
4
4
|
import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
|
|
5
5
|
import { useLightboxScrollLock } from '../utils/useLightboxScrollLock';
|
|
@@ -2729,7 +2729,7 @@ export function Burger({
|
|
|
2729
2729
|
</div>
|
|
2730
2730
|
);
|
|
2731
2731
|
}
|
|
2732
|
-
`,
|
|
2732
|
+
`, w = `import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
|
|
2733
2733
|
import { createPortal } from 'react-dom';
|
|
2734
2734
|
import cn from 'classnames';
|
|
2735
2735
|
import { CommonComponentProps } from '../props';
|
|
@@ -3776,7 +3776,7 @@ export function Chronicles({
|
|
|
3776
3776
|
</>
|
|
3777
3777
|
);
|
|
3778
3778
|
}
|
|
3779
|
-
`,
|
|
3779
|
+
`, C = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3780
3780
|
import { CommonComponentProps } from '../props';
|
|
3781
3781
|
import { LinkWrapper, useScopedStyles, type ContentLink } from '../utils/index';
|
|
3782
3782
|
|
|
@@ -4305,7 +4305,7 @@ export function ClickGallerie({ settings, content = [], isEditor }: ClickGalleri
|
|
|
4305
4305
|
</>
|
|
4306
4306
|
);
|
|
4307
4307
|
}
|
|
4308
|
-
`,
|
|
4308
|
+
`, $ = `import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4309
4309
|
import cn from 'classnames';
|
|
4310
4310
|
import { CommonComponentProps } from '../props';
|
|
4311
4311
|
import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index';
|
|
@@ -5049,7 +5049,7 @@ export function FAQ({ settings, content, isEditor, isPreviewMode, isEditMode, ac
|
|
|
5049
5049
|
</>
|
|
5050
5050
|
);
|
|
5051
5051
|
}
|
|
5052
|
-
`,
|
|
5052
|
+
`, I = `import React, { useMemo, useState } from 'react';
|
|
5053
5053
|
import { CommonComponentProps } from '../props';
|
|
5054
5054
|
import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
|
|
5055
5055
|
import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
|
|
@@ -5687,7 +5687,9 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
|
|
|
5687
5687
|
};
|
|
5688
5688
|
|
|
5689
5689
|
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
5690
|
-
`,
|
|
5690
|
+
`, E = `import { Splide, SplideSlide } from '@splidejs/react-splide';
|
|
5691
|
+
import '@splidejs/react-splide/css/core';
|
|
5692
|
+
import { CommonComponentProps } from '../props';
|
|
5691
5693
|
import { EmbedMediaFrame, getEmbedAspect, getEmbedPlayback, isEmbedMedia } from '../utils/index';
|
|
5692
5694
|
import {
|
|
5693
5695
|
buildColorVars,
|
|
@@ -5697,7 +5699,7 @@ import {
|
|
|
5697
5699
|
useLazyVideos,
|
|
5698
5700
|
useScopedStyles,
|
|
5699
5701
|
} from '../utils/index';
|
|
5700
|
-
import {
|
|
5702
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState, useMemo } from 'react';
|
|
5701
5703
|
import { createPortal } from 'react-dom';
|
|
5702
5704
|
import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss';
|
|
5703
5705
|
import { SvgImage } from '../helpers/SvgImage/SvgImage';
|
|
@@ -5814,23 +5816,15 @@ function getCSS(P: string): string {
|
|
|
5814
5816
|
width: 100%;
|
|
5815
5817
|
overflow: hidden;
|
|
5816
5818
|
}
|
|
5819
|
+
.\${P}-item-slider .splide__track {
|
|
5820
|
+
overflow: hidden;
|
|
5821
|
+
}
|
|
5817
5822
|
.\${P}-item-image-link {
|
|
5818
5823
|
width: 100%;
|
|
5819
5824
|
display: flex;
|
|
5820
5825
|
flex-direction: column;
|
|
5821
5826
|
align-items: center;
|
|
5822
5827
|
}
|
|
5823
|
-
.\${P}-custom-layout .\${P}-item-image-link {
|
|
5824
|
-
flex: 1 1 0%;
|
|
5825
|
-
min-height: 0;
|
|
5826
|
-
}
|
|
5827
|
-
.\${P}-custom-layout.\${P}-text-outside .\${P}-item-image-link,
|
|
5828
|
-
.\${P}-custom-layout.\${P}-auto-height .\${P}-item-image-link {
|
|
5829
|
-
flex: none;
|
|
5830
|
-
}
|
|
5831
|
-
.\${P}-auto-height .\${P}-item-image-wrapper-fit-slider > .\${P}-item-image-wrapper-sizer :is(img, video) {
|
|
5832
|
-
width: 100%;
|
|
5833
|
-
}
|
|
5834
5828
|
.\${P}-item-text-link {
|
|
5835
5829
|
display: flex;
|
|
5836
5830
|
flex-direction: column;
|
|
@@ -5851,47 +5845,18 @@ function getCSS(P: string): string {
|
|
|
5851
5845
|
display: block;
|
|
5852
5846
|
max-width: 100%;
|
|
5853
5847
|
}
|
|
5854
|
-
.\${P}-item-slider
|
|
5855
|
-
|
|
5848
|
+
.\${P}-item-slider,
|
|
5849
|
+
.\${P}-item-slider .splide__track,
|
|
5850
|
+
.\${P}-item-slider .splide__list,
|
|
5851
|
+
.\${P}-item-slider .splide__slide {
|
|
5856
5852
|
width: 100%;
|
|
5857
5853
|
height: 100%;
|
|
5858
|
-
overflow: hidden;
|
|
5859
5854
|
}
|
|
5860
|
-
.\${P}-item-slider
|
|
5861
|
-
position: relative;
|
|
5862
|
-
display: flex;
|
|
5863
|
-
flex-direction: row;
|
|
5864
|
-
width: 100%;
|
|
5865
|
-
height: 100%;
|
|
5866
|
-
will-change: transform;
|
|
5867
|
-
}
|
|
5868
|
-
.\${P}-item-slider-list-vertical {
|
|
5869
|
-
flex-direction: column;
|
|
5870
|
-
}
|
|
5871
|
-
.\${P}-item-slider-list-fade {
|
|
5872
|
-
display: block;
|
|
5873
|
-
will-change: auto;
|
|
5874
|
-
}
|
|
5875
|
-
.\${P}-item-slide {
|
|
5876
|
-
position: relative;
|
|
5877
|
-
flex: 0 0 100%;
|
|
5878
|
-
width: 100%;
|
|
5879
|
-
height: 100%;
|
|
5855
|
+
.\${P}-item-slider .splide__slide {
|
|
5880
5856
|
display: flex;
|
|
5881
5857
|
justify-content: center;
|
|
5882
5858
|
align-items: center;
|
|
5883
5859
|
}
|
|
5884
|
-
.\${P}-item-slider-list-fade .\${P}-item-slide {
|
|
5885
|
-
position: absolute;
|
|
5886
|
-
top: 0;
|
|
5887
|
-
left: 0;
|
|
5888
|
-
opacity: 0;
|
|
5889
|
-
transition: opacity \${SLIDER_TRANSITION_MS}ms \${SLIDER_EASING};
|
|
5890
|
-
}
|
|
5891
|
-
.\${P}-item-slider-list-fade .\${P}-item-slide-active {
|
|
5892
|
-
opacity: 1;
|
|
5893
|
-
z-index: 1;
|
|
5894
|
-
}
|
|
5895
5860
|
.\${P}-item-title {
|
|
5896
5861
|
white-space: normal;
|
|
5897
5862
|
overflow-wrap: anywhere;
|
|
@@ -6038,13 +6003,13 @@ function getCSS(P: string): string {
|
|
|
6038
6003
|
.\${P}-image-align-bottom .\${P}-item-image-wrapper:not(.\${P}-item-image-wrapper-fit-slider) {
|
|
6039
6004
|
align-items: flex-end;
|
|
6040
6005
|
}
|
|
6041
|
-
.\${P}-image-align-top .\${P}-item-slider
|
|
6006
|
+
.\${P}-image-align-top .\${P}-item-slider .splide__slide {
|
|
6042
6007
|
align-items: flex-start;
|
|
6043
6008
|
}
|
|
6044
|
-
.\${P}-image-align-center .\${P}-item-slider
|
|
6009
|
+
.\${P}-image-align-center .\${P}-item-slider .splide__slide {
|
|
6045
6010
|
align-items: center;
|
|
6046
6011
|
}
|
|
6047
|
-
.\${P}-image-align-bottom .\${P}-item-slider
|
|
6012
|
+
.\${P}-image-align-bottom .\${P}-item-slider .splide__slide {
|
|
6048
6013
|
align-items: flex-end;
|
|
6049
6014
|
}
|
|
6050
6015
|
.\${P}-align-entries .\${P}-item {
|
|
@@ -6125,13 +6090,13 @@ function getCSS(P: string): string {
|
|
|
6125
6090
|
.\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-image-wrapper:not(.\${P}-item-image-wrapper-fit-slider) {
|
|
6126
6091
|
align-items: flex-end;
|
|
6127
6092
|
}
|
|
6128
|
-
.\${P}-image-align-top.\${P}-align-entries .\${P}-item-slider
|
|
6093
|
+
.\${P}-image-align-top.\${P}-align-entries .\${P}-item-slider .splide__slide {
|
|
6129
6094
|
align-items: flex-start;
|
|
6130
6095
|
}
|
|
6131
|
-
.\${P}-image-align-center.\${P}-align-entries .\${P}-item-slider
|
|
6096
|
+
.\${P}-image-align-center.\${P}-align-entries .\${P}-item-slider .splide__slide {
|
|
6132
6097
|
align-items: center;
|
|
6133
6098
|
}
|
|
6134
|
-
.\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-slider
|
|
6099
|
+
.\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-slider .splide__slide {
|
|
6135
6100
|
align-items: flex-end;
|
|
6136
6101
|
}
|
|
6137
6102
|
.\${P}-image-align-top.\${P}-align-entries .\${P}-item-image-link {
|
|
@@ -6199,9 +6164,27 @@ function pickRandomSlideDirection(): 'ltr' | 'ttb' {
|
|
|
6199
6164
|
return Math.random() < 0.5 ? 'ltr' : 'ttb';
|
|
6200
6165
|
}
|
|
6201
6166
|
|
|
6202
|
-
function
|
|
6203
|
-
|
|
6204
|
-
|
|
6167
|
+
function resumeSplideAutoplay(splide: { Components: { Autoplay?: { pause: (stop?: boolean) => void; play: () => void } } }) {
|
|
6168
|
+
const autoplay = splide.Components.Autoplay;
|
|
6169
|
+
if (!autoplay) return;
|
|
6170
|
+
autoplay.pause(false);
|
|
6171
|
+
autoplay.play();
|
|
6172
|
+
}
|
|
6173
|
+
|
|
6174
|
+
function handleRandomSlideMoved(splide: {
|
|
6175
|
+
options: { direction?: string };
|
|
6176
|
+
Components: { Autoplay?: { pause: (stop?: boolean) => void; play: () => void } };
|
|
6177
|
+
}) {
|
|
6178
|
+
const next = pickRandomSlideDirection();
|
|
6179
|
+
if (splide.options.direction !== next) {
|
|
6180
|
+
splide.options = { ...splide.options, direction: next };
|
|
6181
|
+
}
|
|
6182
|
+
|
|
6183
|
+
requestAnimationFrame(() => {
|
|
6184
|
+
requestAnimationFrame(() => {
|
|
6185
|
+
resumeSplideAutoplay(splide);
|
|
6186
|
+
});
|
|
6187
|
+
});
|
|
6205
6188
|
}
|
|
6206
6189
|
|
|
6207
6190
|
type GridProps = {
|
|
@@ -6241,8 +6224,6 @@ type LightboxProps = {
|
|
|
6241
6224
|
|
|
6242
6225
|
const LIGHTBOX_ANIM_MS = 500;
|
|
6243
6226
|
const SLIDER_TRANSITION_MS = 750;
|
|
6244
|
-
const SLIDER_EASING = 'cubic-bezier(0.25, 1, 0.5, 1)';
|
|
6245
|
-
const SLIDER_DEFAULT_INTERVAL_MS = 5000;
|
|
6246
6227
|
const LIGHTBOX_EASING = 'cubic-bezier(0.22, 1, 0.36, 1)';
|
|
6247
6228
|
const SWIPE_CLOSE_THRESHOLD = 72;
|
|
6248
6229
|
const SWIPE_NAV_THRESHOLD = 50;
|
|
@@ -6332,7 +6313,7 @@ function collectGridLightboxMedia(content: any[]): GridMedia[] {
|
|
|
6332
6313
|
return result;
|
|
6333
6314
|
}
|
|
6334
6315
|
|
|
6335
|
-
|
|
6316
|
+
function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
|
|
6336
6317
|
const [pool, setPool] = useState<HTMLDivElement | null>(null);
|
|
6337
6318
|
useLazyVideos(pool, { preload: 'metadata' });
|
|
6338
6319
|
// an embed's player is only ever framed where it shows
|
|
@@ -6371,7 +6352,7 @@ const LightboxMediaPreloadPool = memo(function LightboxMediaPreloadPool({ mediaL
|
|
|
6371
6352
|
))}
|
|
6372
6353
|
</div>
|
|
6373
6354
|
);
|
|
6374
|
-
}
|
|
6355
|
+
}
|
|
6375
6356
|
|
|
6376
6357
|
function unloadVideoElement(video: HTMLVideoElement) {
|
|
6377
6358
|
video.pause();
|
|
@@ -6379,121 +6360,15 @@ function unloadVideoElement(video: HTMLVideoElement) {
|
|
|
6379
6360
|
video.load();
|
|
6380
6361
|
}
|
|
6381
6362
|
|
|
6382
|
-
const
|
|
6383
|
-
const GRID_SLIDE_PLAYING_CLASS = 'cntrl-grid-slide-playing';
|
|
6384
|
-
const GRID_SLIDE_VIDEOS = \`.\${GRID_SLIDE_CLASS} video\`;
|
|
6363
|
+
const SPLIDE_SLIDE_VIDEOS = '.splide__slide video';
|
|
6385
6364
|
|
|
6386
6365
|
function shouldPlaySlideVideo(video: HTMLVideoElement): boolean {
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
isFade: boolean;
|
|
6394
|
-
direction: GridSettings['direction'];
|
|
6395
|
-
intervalMs: number;
|
|
6396
|
-
};
|
|
6397
|
-
|
|
6398
|
-
function GridEntrySlider({ prefix: P, slides, isFade, direction, intervalMs }: GridEntrySliderProps) {
|
|
6399
|
-
const count = slides.length;
|
|
6400
|
-
const hasClones = !isFade && count > 1;
|
|
6401
|
-
const isRandom = !isFade && direction === 'random';
|
|
6402
|
-
const delayMs = Number.isFinite(intervalMs) && intervalMs > 0 ? intervalMs : SLIDER_DEFAULT_INTERVAL_MS;
|
|
6403
|
-
const [position, setPosition] = useState(hasClones ? 1 : 0);
|
|
6404
|
-
const [axis, setAxis] = useState<'ltr' | 'ttb'>(!isFade && direction === 'vertical' ? 'ttb' : 'ltr');
|
|
6405
|
-
const [isMoving, setIsMoving] = useState(false);
|
|
6406
|
-
const [skipTransition, setSkipTransition] = useState(false);
|
|
6407
|
-
const [cycle, setCycle] = useState(0);
|
|
6408
|
-
const isMovingRef = useRef(false);
|
|
6409
|
-
|
|
6410
|
-
useEffect(() => {
|
|
6411
|
-
if (count < 2) return;
|
|
6412
|
-
const timeoutId = window.setTimeout(() => {
|
|
6413
|
-
if (isMovingRef.current) {
|
|
6414
|
-
setCycle(prev => prev + 1);
|
|
6415
|
-
return;
|
|
6416
|
-
}
|
|
6417
|
-
isMovingRef.current = true;
|
|
6418
|
-
setIsMoving(true);
|
|
6419
|
-
setSkipTransition(false);
|
|
6420
|
-
setPosition(prev => (hasClones ? prev + 1 : wrapSlideIndex(prev + 1, count)));
|
|
6421
|
-
if (!isRandom) setCycle(prev => prev + 1);
|
|
6422
|
-
}, delayMs);
|
|
6423
|
-
return () => window.clearTimeout(timeoutId);
|
|
6424
|
-
}, [count, cycle, delayMs, hasClones, isRandom]);
|
|
6425
|
-
|
|
6426
|
-
useEffect(() => {
|
|
6427
|
-
if (!isMoving) return;
|
|
6428
|
-
const timeoutId = window.setTimeout(() => {
|
|
6429
|
-
const isOnClone = hasClones && position === count + 1;
|
|
6430
|
-
const nextAxis = isRandom ? pickRandomSlideDirection() : axis;
|
|
6431
|
-
if (isOnClone || nextAxis !== axis) {
|
|
6432
|
-
setSkipTransition(true);
|
|
6433
|
-
if (isOnClone) setPosition(1);
|
|
6434
|
-
setAxis(nextAxis);
|
|
6435
|
-
}
|
|
6436
|
-
isMovingRef.current = false;
|
|
6437
|
-
setIsMoving(false);
|
|
6438
|
-
if (isRandom) setCycle(prev => prev + 1);
|
|
6439
|
-
}, SLIDER_TRANSITION_MS);
|
|
6440
|
-
return () => window.clearTimeout(timeoutId);
|
|
6441
|
-
}, [axis, count, hasClones, isMoving, isRandom, position]);
|
|
6442
|
-
|
|
6443
|
-
useEffect(() => {
|
|
6444
|
-
if (!skipTransition) return;
|
|
6445
|
-
let innerId = 0;
|
|
6446
|
-
const outerId = requestAnimationFrame(() => {
|
|
6447
|
-
innerId = requestAnimationFrame(() => setSkipTransition(false));
|
|
6448
|
-
});
|
|
6449
|
-
return () => {
|
|
6450
|
-
cancelAnimationFrame(outerId);
|
|
6451
|
-
cancelAnimationFrame(innerId);
|
|
6452
|
-
};
|
|
6453
|
-
}, [skipTransition]);
|
|
6454
|
-
|
|
6455
|
-
const slotsCount = hasClones ? count + 2 : count;
|
|
6456
|
-
const getItemIndex = (slot: number) => (hasClones ? wrapSlideIndex(slot - 1, count) : slot);
|
|
6457
|
-
const isCloneSlot = (slot: number) => hasClones && (slot === 0 || slot === count + 1);
|
|
6458
|
-
const activeIndex = getItemIndex(position);
|
|
6459
|
-
const nextSlot = position + 1 < slotsCount ? position + 1 : -1;
|
|
6460
|
-
const isPlayingSlot = (slot: number) => isFade
|
|
6461
|
-
|| (slot === position && !isCloneSlot(slot))
|
|
6462
|
-
|| slot === nextSlot
|
|
6463
|
-
|| (nextSlot >= 0 && !isCloneSlot(slot) && getItemIndex(slot) === getItemIndex(nextSlot));
|
|
6464
|
-
const isVertical = !isFade && axis === 'ttb';
|
|
6465
|
-
const listStyle: React.CSSProperties | undefined = isFade
|
|
6466
|
-
? undefined
|
|
6467
|
-
: {
|
|
6468
|
-
transform: isVertical
|
|
6469
|
-
? \`translate3d(0, \${-position * 100}%, 0)\`
|
|
6470
|
-
: \`translate3d(\${-position * 100}%, 0, 0)\`,
|
|
6471
|
-
transition: skipTransition ? 'none' : \`transform \${SLIDER_TRANSITION_MS}ms \${SLIDER_EASING}\`,
|
|
6472
|
-
};
|
|
6473
|
-
|
|
6474
|
-
return (
|
|
6475
|
-
<div className={\`\${P}-item-slider\`}>
|
|
6476
|
-
<div
|
|
6477
|
-
className={\`\${P}-item-slider-list\${isFade ? \` \${P}-item-slider-list-fade\` : ''}\${isVertical ? \` \${P}-item-slider-list-vertical\` : ''}\`}
|
|
6478
|
-
style={listStyle}
|
|
6479
|
-
>
|
|
6480
|
-
{Array.from({ length: slotsCount }, (_, slot) => {
|
|
6481
|
-
const itemIndex = getItemIndex(slot);
|
|
6482
|
-
const isClone = isCloneSlot(slot);
|
|
6483
|
-
const isShown = isFade ? itemIndex === activeIndex : slot === position;
|
|
6484
|
-
return (
|
|
6485
|
-
<div
|
|
6486
|
-
key={isClone ? \`clone-\${slot === 0 ? 'start' : 'end'}\` : \`slide-\${itemIndex}\`}
|
|
6487
|
-
className={\`\${P}-item-slide \${GRID_SLIDE_CLASS}\${isFade && isShown ? \` \${P}-item-slide-active\` : ''}\${isPlayingSlot(slot) ? \` \${GRID_SLIDE_PLAYING_CLASS}\` : ''}\`}
|
|
6488
|
-
aria-hidden={isShown ? undefined : true}
|
|
6489
|
-
>
|
|
6490
|
-
{slides[itemIndex]}
|
|
6491
|
-
</div>
|
|
6492
|
-
);
|
|
6493
|
-
})}
|
|
6494
|
-
</div>
|
|
6495
|
-
</div>
|
|
6496
|
-
);
|
|
6366
|
+
if (video.closest('.splide--fade, .splide__slide.is-active:not(.splide__slide--clone), .splide__slide.is-next')) return true;
|
|
6367
|
+
const slide = video.closest<HTMLElement>('.splide__slide');
|
|
6368
|
+
if (!slide || slide.classList.contains('splide__slide--clone')) return false;
|
|
6369
|
+
const slideIndex = slide.dataset.slideIndex;
|
|
6370
|
+
const upcomingSlide = slide.parentElement?.querySelector<HTMLElement>('.splide__slide.is-next');
|
|
6371
|
+
return slideIndex !== undefined && upcomingSlide?.dataset.slideIndex === slideIndex;
|
|
6497
6372
|
}
|
|
6498
6373
|
|
|
6499
6374
|
function GridMediaItem({
|
|
@@ -6501,7 +6376,7 @@ function GridMediaItem({
|
|
|
6501
6376
|
className,
|
|
6502
6377
|
style,
|
|
6503
6378
|
hasLightbox,
|
|
6504
|
-
|
|
6379
|
+
isSplideSlide = false,
|
|
6505
6380
|
onMediaClick,
|
|
6506
6381
|
}: {
|
|
6507
6382
|
media: GridMedia;
|
|
@@ -6509,7 +6384,7 @@ function GridMediaItem({
|
|
|
6509
6384
|
style: React.CSSProperties;
|
|
6510
6385
|
/** An embed then plays here as a silent loop, and as it was set to in the lightbox. */
|
|
6511
6386
|
hasLightbox: boolean;
|
|
6512
|
-
|
|
6387
|
+
isSplideSlide?: boolean;
|
|
6513
6388
|
onMediaClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
6514
6389
|
}) {
|
|
6515
6390
|
if (isEmbedMedia(media)) {
|
|
@@ -6541,7 +6416,7 @@ function GridMediaItem({
|
|
|
6541
6416
|
playsInline: true,
|
|
6542
6417
|
onClick: onMediaClick,
|
|
6543
6418
|
};
|
|
6544
|
-
return
|
|
6419
|
+
return isSplideSlide
|
|
6545
6420
|
? <video {...videoProps} preload='none' />
|
|
6546
6421
|
: <LazyVideo {...videoProps} autoPlay />;
|
|
6547
6422
|
}
|
|
@@ -6570,7 +6445,7 @@ function GridItemMediaWrapper({
|
|
|
6570
6445
|
children: React.ReactNode;
|
|
6571
6446
|
}) {
|
|
6572
6447
|
const [wrapper, setWrapper] = useState<HTMLDivElement | null>(null);
|
|
6573
|
-
useLazyVideos(wrapper, { autoPlay: true, selector:
|
|
6448
|
+
useLazyVideos(wrapper, { autoPlay: true, selector: SPLIDE_SLIDE_VIDEOS, shouldPlay: shouldPlaySlideVideo });
|
|
6574
6449
|
|
|
6575
6450
|
return (
|
|
6576
6451
|
<div ref={setWrapper} className={className} style={style}>
|
|
@@ -7471,169 +7346,11 @@ function resolveLightboxImageDisplay(
|
|
|
7471
7346
|
return value?.display === 'cover' ? 'cover' : 'fit';
|
|
7472
7347
|
}
|
|
7473
7348
|
|
|
7474
|
-
function getCustomGridSpanWidth(layout: CustomGridLayout, span: number): number {
|
|
7475
|
-
return layout.columnWidth * span + layout.gutterWidth * Math.max(0, span - 1);
|
|
7476
|
-
}
|
|
7477
|
-
|
|
7478
|
-
type CustomGridSlot = {
|
|
7479
|
-
column: number;
|
|
7480
|
-
span: number;
|
|
7481
|
-
width: number;
|
|
7482
|
-
top: number;
|
|
7483
|
-
height: number;
|
|
7484
|
-
gridColumn: string;
|
|
7485
|
-
};
|
|
7486
|
-
|
|
7487
|
-
function getCustomGridBlocksBottom(layout: CustomGridLayout): number {
|
|
7488
|
-
return layout.blocks.reduce((bottom, block) => Math.max(bottom, Math.max(0, block.top) + Math.max(0, block.height)), 0);
|
|
7489
|
-
}
|
|
7490
|
-
|
|
7491
|
-
function getCustomGridVerticalGap(layout: CustomGridLayout): number {
|
|
7492
|
-
if (typeof layout.verticalGap === 'number') return Math.max(0, layout.verticalGap);
|
|
7493
|
-
return Math.max(0, (layout.repeatHeight ?? 0) - getCustomGridBlocksBottom(layout));
|
|
7494
|
-
}
|
|
7495
|
-
|
|
7496
|
-
function getCustomGridSlot(layout: CustomGridLayout, index: number): CustomGridSlot {
|
|
7497
|
-
const block = layout.blocks[index % layout.blocks.length];
|
|
7498
|
-
const span = Math.min(Math.max(1, Math.round(block.span)), layout.columnsCount);
|
|
7499
|
-
const column = Math.min(Math.max(0, Math.round(block.column)), layout.columnsCount - span);
|
|
7500
|
-
return {
|
|
7501
|
-
column,
|
|
7502
|
-
span,
|
|
7503
|
-
width: getCustomGridSpanWidth(layout, span),
|
|
7504
|
-
top: Math.max(0, block.top),
|
|
7505
|
-
height: Math.max(0, block.height),
|
|
7506
|
-
gridColumn: \`\${column + 1} / span \${span}\`,
|
|
7507
|
-
};
|
|
7508
|
-
}
|
|
7509
|
-
|
|
7510
|
-
const EDGE_TOLERANCE = 1e-6;
|
|
7511
|
-
|
|
7512
|
-
function getCustomGridRows(layout: CustomGridLayout, entriesCount: number, entryHeights?: number[]) {
|
|
7513
|
-
const beat = layout.beat ?? 0;
|
|
7514
|
-
const onBeats = beat > 0 && !!entryHeights;
|
|
7515
|
-
const snapUp = (value: number) => Math.ceil(value / beat - 1e-3) * beat;
|
|
7516
|
-
const tracks: (number | 'auto')[] = [];
|
|
7517
|
-
const gridRows: string[] = [];
|
|
7518
|
-
const verticalGap = getCustomGridVerticalGap(layout);
|
|
7519
|
-
for (let groupStart = 0; groupStart < entriesCount; groupStart += layout.blocks.length) {
|
|
7520
|
-
if (groupStart > 0 && verticalGap > 0) tracks.push(verticalGap);
|
|
7521
|
-
const slots = Array.from(
|
|
7522
|
-
{ length: Math.min(layout.blocks.length, entriesCount - groupStart) },
|
|
7523
|
-
(_, index) => getCustomGridSlot(layout, groupStart + index),
|
|
7524
|
-
);
|
|
7525
|
-
const ends = slots.map((slot) => {
|
|
7526
|
-
const under = slots.filter(other => other.column < slot.column + slot.span
|
|
7527
|
-
&& slot.column < other.column + other.span
|
|
7528
|
-
&& other.top >= slot.top + slot.height - EDGE_TOLERANCE);
|
|
7529
|
-
return under.length > 0 ? Math.min(...under.map(other => other.top)) : undefined;
|
|
7530
|
-
});
|
|
7531
|
-
const tops = [0, ...slots.map(slot => slot.top)]
|
|
7532
|
-
.sort((a, b) => a - b)
|
|
7533
|
-
.filter((top, index, sorted) => index === 0 || top - sorted[index - 1] > EDGE_TOLERANCE);
|
|
7534
|
-
const isSame = (a: number, b: number) => Math.abs(a - b) <= EDGE_TOLERANCE;
|
|
7535
|
-
const getTop = (value: number) => tops.findIndex(top => isSame(top, value));
|
|
7536
|
-
const positions: number[] = [];
|
|
7537
|
-
let position = 0;
|
|
7538
|
-
const pushContentTrack = (isEnding: (end: number | undefined) => boolean) => {
|
|
7539
|
-
const ending = slots.flatMap((slot, index) => (isEnding(ends[index]) ? [{ slot, entry: groupStart + index }] : []));
|
|
7540
|
-
if (ending.length === 0) return;
|
|
7541
|
-
if (!onBeats) {
|
|
7542
|
-
tracks.push('auto');
|
|
7543
|
-
return;
|
|
7544
|
-
}
|
|
7545
|
-
const needed = Math.max(...ending.map(({ slot, entry }) => positions[getTop(slot.top)] + (entryHeights[entry] ?? 0)));
|
|
7546
|
-
const track = Math.max(0, snapUp(needed) - position);
|
|
7547
|
-
tracks.push(track);
|
|
7548
|
-
position += track;
|
|
7549
|
-
};
|
|
7550
|
-
const lines = tops.map((top, index) => {
|
|
7551
|
-
if (index > 0) {
|
|
7552
|
-
tracks.push(top - tops[index - 1]);
|
|
7553
|
-
position += top - tops[index - 1];
|
|
7554
|
-
}
|
|
7555
|
-
pushContentTrack(end => end !== undefined && isSame(end, top));
|
|
7556
|
-
positions.push(position);
|
|
7557
|
-
return tracks.length + 1;
|
|
7558
|
-
});
|
|
7559
|
-
pushContentTrack(end => end === undefined);
|
|
7560
|
-
const groupEnd = tracks.length + 1;
|
|
7561
|
-
const getLine = (value: number) => lines[getTop(value)];
|
|
7562
|
-
slots.forEach((slot, index) => {
|
|
7563
|
-
const end = ends[index];
|
|
7564
|
-
gridRows.push(\`\${getLine(slot.top)} / \${end === undefined ? groupEnd : getLine(end)}\`);
|
|
7565
|
-
});
|
|
7566
|
-
}
|
|
7567
|
-
return { tracks, gridRows };
|
|
7568
|
-
}
|
|
7569
|
-
|
|
7570
|
-
function getGridMediaAspect(media: GridMedia): number | undefined {
|
|
7571
|
-
if (isEmbedMedia(media)) return getEmbedAspect(media);
|
|
7572
|
-
return media.width && media.height && media.width > 0 && media.height > 0 ? media.width / media.height : undefined;
|
|
7573
|
-
}
|
|
7574
|
-
|
|
7575
|
-
function placeCustomGridRows(layout: CustomGridLayout, slots: CustomGridSlot[], heights: number[]) {
|
|
7576
|
-
const groupSize = layout.blocks.length;
|
|
7577
|
-
const verticalGap = getCustomGridVerticalGap(layout);
|
|
7578
|
-
const rowTops = slots.slice(0, groupSize)
|
|
7579
|
-
.map(slot => slot.top)
|
|
7580
|
-
.sort((a, b) => a - b)
|
|
7581
|
-
.filter((top, index, sorted) => index === 0 || top - sorted[index - 1] > EDGE_TOLERANCE);
|
|
7582
|
-
const tops: number[] = [];
|
|
7583
|
-
let top = 0;
|
|
7584
|
-
let bottom = 0;
|
|
7585
|
-
for (let start = 0; start < slots.length; start += groupSize) {
|
|
7586
|
-
for (const rowTop of rowTops) {
|
|
7587
|
-
const entries = Array.from({ length: Math.min(groupSize, slots.length - start) }, (_, index) => start + index)
|
|
7588
|
-
.filter(entry => Math.abs(slots[entry].top - rowTop) <= EDGE_TOLERANCE);
|
|
7589
|
-
if (entries.length === 0) continue;
|
|
7590
|
-
entries.forEach((entry) => {
|
|
7591
|
-
tops[entry] = top;
|
|
7592
|
-
});
|
|
7593
|
-
bottom = Math.max(...entries.map(entry => top + heights[entry]));
|
|
7594
|
-
top = bottom + verticalGap;
|
|
7595
|
-
}
|
|
7596
|
-
}
|
|
7597
|
-
return { tops, bottom };
|
|
7598
|
-
}
|
|
7599
|
-
|
|
7600
|
-
function placeCustomGridEntries(layout: CustomGridLayout, slots: CustomGridSlot[], heights: number[]) {
|
|
7601
|
-
if (layout.gridType === 'rows') return placeCustomGridRows(layout, slots, heights);
|
|
7602
|
-
const groupSize = layout.blocks.length;
|
|
7603
|
-
const verticalGap = getCustomGridVerticalGap(layout);
|
|
7604
|
-
const isMasonry = layout.masonry === 'on';
|
|
7605
|
-
const tops: number[] = [];
|
|
7606
|
-
const placed: { column: number; span: number; bottom: number; group: number }[] = [];
|
|
7607
|
-
const getBottom = (items: typeof placed) => items.reduce((bottom, item) => Math.max(bottom, item.bottom), 0);
|
|
7608
|
-
let groupStart = 0;
|
|
7609
|
-
for (let start = 0; start < slots.length; start += groupSize) {
|
|
7610
|
-
const group = start / groupSize;
|
|
7611
|
-
const entries = Array.from({ length: Math.min(groupSize, slots.length - start) }, (_, index) => start + index)
|
|
7612
|
-
.sort((a, b) => slots[a].top - slots[b].top || a - b);
|
|
7613
|
-
for (const entry of entries) {
|
|
7614
|
-
const slot = slots[entry];
|
|
7615
|
-
const sharesColumns = (other: { column: number; span: number }) => other.column < slot.column + slot.span
|
|
7616
|
-
&& slot.column < other.column + other.span;
|
|
7617
|
-
const above = entries.filter(other => other !== entry && tops[other] !== undefined && sharesColumns(slots[other])
|
|
7618
|
-
&& slots[other].top + slots[other].height <= slot.top + EDGE_TOLERANCE);
|
|
7619
|
-
const earlier = isMasonry ? placed.filter(item => item.group < group && sharesColumns(item)) : [];
|
|
7620
|
-
const candidates = above.map(other => tops[other] + heights[other] + slot.top - (slots[other].top + slots[other].height));
|
|
7621
|
-
if (earlier.length > 0) candidates.push(getBottom(earlier) + verticalGap);
|
|
7622
|
-
if (candidates.length === 0) candidates.push(groupStart + slot.top);
|
|
7623
|
-
tops[entry] = Math.max(...candidates);
|
|
7624
|
-
placed.push({ column: slot.column, span: slot.span, bottom: tops[entry] + heights[entry], group });
|
|
7625
|
-
}
|
|
7626
|
-
groupStart = getBottom(placed) + verticalGap;
|
|
7627
|
-
}
|
|
7628
|
-
return { tops, bottom: getBottom(placed) };
|
|
7629
|
-
}
|
|
7630
|
-
|
|
7631
7349
|
export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, metadata, activeEvent, layoutId, portalId }: GridProps) {
|
|
7632
7350
|
const { prefix: P } = useScopedStyles();
|
|
7633
7351
|
const {
|
|
7634
7352
|
type = 'a',
|
|
7635
7353
|
gridLayout,
|
|
7636
|
-
customGrid,
|
|
7637
7354
|
textBoxWidth = 100,
|
|
7638
7355
|
verticalGap,
|
|
7639
7356
|
entriesCount,
|
|
@@ -7681,69 +7398,62 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7681
7398
|
hover = 'none',
|
|
7682
7399
|
alignEntries = 'off',
|
|
7683
7400
|
align = 'top',
|
|
7684
|
-
textGrowth = 'inside',
|
|
7685
7401
|
} = settings;
|
|
7686
7402
|
|
|
7687
|
-
const
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
titleWordSpacing, titleTextAppearance, titleColor, isEditor, P,
|
|
7705
|
-
]);
|
|
7403
|
+
const resolvedTitleTextStyle: TextStyles = {
|
|
7404
|
+
fontSettings: {
|
|
7405
|
+
fontFamily: titleFontFamily,
|
|
7406
|
+
fontWeight: titleFontSettings?.fontWeight ?? 400,
|
|
7407
|
+
fontStyle: titleFontSettings?.fontStyle ?? 'normal',
|
|
7408
|
+
},
|
|
7409
|
+
fontSize: titleFontSize ?? 0.01,
|
|
7410
|
+
lineHeight: titleLineHeight,
|
|
7411
|
+
letterSpacing: titleLetterSpacing ?? 0,
|
|
7412
|
+
wordSpacing: titleWordSpacing ?? 0,
|
|
7413
|
+
textAppearance: titleTextAppearance,
|
|
7414
|
+
color: titleColor,
|
|
7415
|
+
};
|
|
7416
|
+
const titleTypographyCss = omitTextColors(textStylesToCss(resolvedTitleTextStyle, isEditor));
|
|
7417
|
+
const titleFieldCss = {
|
|
7418
|
+
...titleTypographyCss,
|
|
7419
|
+
} as React.CSSProperties;
|
|
7706
7420
|
|
|
7707
|
-
const
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
subtitleWordSpacing, subtitleTextAppearance, subtitleColor, isEditor, P,
|
|
7725
|
-
]);
|
|
7421
|
+
const resolvedSubtitleTextStyle: TextStyles = {
|
|
7422
|
+
fontSettings: {
|
|
7423
|
+
fontFamily: subtitleFontFamily,
|
|
7424
|
+
fontWeight: subtitleFontSettings?.fontWeight ?? 400,
|
|
7425
|
+
fontStyle: subtitleFontSettings?.fontStyle ?? 'normal',
|
|
7426
|
+
},
|
|
7427
|
+
fontSize: subtitleFontSize ?? 0.01,
|
|
7428
|
+
lineHeight: subtitleLineHeight,
|
|
7429
|
+
letterSpacing: subtitleLetterSpacing ?? 0,
|
|
7430
|
+
wordSpacing: subtitleWordSpacing ?? 0,
|
|
7431
|
+
textAppearance: subtitleTextAppearance,
|
|
7432
|
+
color: subtitleColor,
|
|
7433
|
+
};
|
|
7434
|
+
const subtitleTypographyCss = omitTextColors(textStylesToCss(resolvedSubtitleTextStyle, isEditor));
|
|
7435
|
+
const subtitleFieldCss = {
|
|
7436
|
+
...subtitleTypographyCss,
|
|
7437
|
+
} as React.CSSProperties;
|
|
7726
7438
|
|
|
7727
|
-
const
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7439
|
+
const resolvedLightboxCounterTextStyle: TextStyles = {
|
|
7440
|
+
fontSettings: {
|
|
7441
|
+
fontFamily: lightboxCounterFontFamily,
|
|
7442
|
+
fontWeight: lightboxCounterFontSettings?.fontWeight ?? 400,
|
|
7443
|
+
fontStyle: lightboxCounterFontSettings?.fontStyle ?? 'normal',
|
|
7444
|
+
},
|
|
7445
|
+
fontSize: lightboxCounterFontSize ?? 0.01,
|
|
7446
|
+
lineHeight: lightboxCounterLineHeight,
|
|
7447
|
+
letterSpacing: lightboxCounterLetterSpacing ?? 0,
|
|
7448
|
+
wordSpacing: lightboxCounterWordSpacing ?? 0,
|
|
7449
|
+
textAppearance: lightboxCounterTextAppearance,
|
|
7450
|
+
color: lightboxCounterColor,
|
|
7451
|
+
};
|
|
7452
|
+
const lightboxCounterTypographyCss = omitTextColors(textStylesToCss(resolvedLightboxCounterTextStyle, isEditor));
|
|
7453
|
+
const lightboxCounterFieldCss = {
|
|
7454
|
+
...lightboxCounterTypographyCss,
|
|
7741
7455
|
...getGridTextLeadingVars(lightboxCounterFontSize, lightboxCounterLineHeight, P, isEditor),
|
|
7742
|
-
} as React.CSSProperties
|
|
7743
|
-
lightboxCounterFontFamily, lightboxCounterFontSettings, lightboxCounterFontSize, lightboxCounterLineHeight,
|
|
7744
|
-
lightboxCounterLetterSpacing, lightboxCounterWordSpacing, lightboxCounterTextAppearance, lightboxCounterColor,
|
|
7745
|
-
isEditor, P,
|
|
7746
|
-
]);
|
|
7456
|
+
} as React.CSSProperties;
|
|
7747
7457
|
|
|
7748
7458
|
const titleTextClassName = getGridTextClassName(
|
|
7749
7459
|
titleFontSize,
|
|
@@ -7757,6 +7467,8 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7757
7467
|
\`\${P}-item-subtitle\`,
|
|
7758
7468
|
\`\${P}-text-tight-leading\`,
|
|
7759
7469
|
);
|
|
7470
|
+
const titleTextLeadingVars = getGridTextLeadingVars(titleFontSize, titleLineHeight, P, isEditor);
|
|
7471
|
+
const subtitleTextLeadingVars = getGridTextLeadingVars(subtitleFontSize, subtitleLineHeight, P, isEditor);
|
|
7760
7472
|
const lightboxCounterClassName = getGridTextClassName(
|
|
7761
7473
|
lightboxCounterFontSize,
|
|
7762
7474
|
lightboxCounterLineHeight,
|
|
@@ -7764,58 +7476,42 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7764
7476
|
\`\${P}-text-tight-leading\`,
|
|
7765
7477
|
);
|
|
7766
7478
|
|
|
7767
|
-
const colorVars =
|
|
7479
|
+
const colorVars = buildColorVars(P, {
|
|
7768
7480
|
titleColor,
|
|
7769
7481
|
subtitleColor,
|
|
7770
7482
|
lightboxCounterColor,
|
|
7771
|
-
}, COLOR_VAR_MAP, STATE_KEYS)
|
|
7483
|
+
}, COLOR_VAR_MAP, STATE_KEYS);
|
|
7772
7484
|
|
|
7773
7485
|
const stateClass = activeEvent && activeEvent !== 'default' ? \`\${P}-state-\${activeEvent}\` : '';
|
|
7774
7486
|
const showTextOnHover = showText === 'on hover' && (!isEditor || isPreviewMode);
|
|
7775
7487
|
const hoverEffectClass = hover !== 'none' && (!isEditor || isPreviewMode) ? \` \${P}-hover-\${hover}\` : '';
|
|
7776
7488
|
const wrapperStateClasses = \`\${stateClass}\${showTextOnHover ? \` \${P}-show-text-hover\` : ''}\${hoverEffectClass}\`.trim();
|
|
7777
7489
|
|
|
7778
|
-
const
|
|
7779
|
-
const resEntriesCount = customLayout || entriesCount === 0 ? Infinity : entriesCount;
|
|
7780
|
-
const isTextOutside = !!customLayout && (customLayout.textGrowth ?? textGrowth) === 'outside';
|
|
7781
|
-
const isAutoHeight = customLayout?.cellHeight === 'auto';
|
|
7782
|
-
const isPlacedLayout = isAutoHeight || customLayout?.masonry === 'on';
|
|
7783
|
-
const itemInnerRefs = useRef<(HTMLDivElement | null)[]>([]);
|
|
7784
|
-
const [customEntryHeights, setCustomEntryHeights] = useState<number[]>([]);
|
|
7490
|
+
const resEntriesCount = entriesCount === 0 ? Infinity : entriesCount;
|
|
7785
7491
|
|
|
7786
|
-
const cropContent =
|
|
7492
|
+
const cropContent = (content ?? []).slice(0, resEntriesCount);
|
|
7787
7493
|
const lightboxMediaToPreload = useMemo(
|
|
7788
7494
|
() => (lightbox === 'on' ? collectGridLightboxMedia(cropContent) : []),
|
|
7789
7495
|
[cropContent, lightbox],
|
|
7790
7496
|
);
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
? lightboxItemsForEntry.findIndex(media => media.assetId === lightboxMedia.assetId)
|
|
7798
|
-
: -1));
|
|
7799
|
-
return { displayItems, lightboxItemsForEntry, lightboxIndexes };
|
|
7800
|
-
}), [cropContent]);
|
|
7801
|
-
|
|
7802
|
-
const size = gridLayout?.entryWidth ?? 0.2;
|
|
7803
|
-
|
|
7804
|
-
const imageDisplaySettings = typeof imageDisplay === 'string' ? { display: imageDisplay } : imageDisplay;
|
|
7805
|
-
const isCover = (customLayout?.mediaDisplay ?? imageDisplaySettings?.display) === 'cover';
|
|
7806
|
-
const ratioValue = imageDisplaySettings?.ratioValue ?? '1:1';
|
|
7807
|
-
const ratioReversed = imageDisplaySettings?.reversed ?? false;
|
|
7497
|
+
|
|
7498
|
+
const size = gridLayout.entryWidth ?? 0.2;
|
|
7499
|
+
|
|
7500
|
+
const isCover = imageDisplay?.display === 'cover';
|
|
7501
|
+
const ratioValue = imageDisplay?.ratioValue ?? '1:1';
|
|
7502
|
+
const ratioReversed = imageDisplay?.reversed ?? false;
|
|
7808
7503
|
const [rW, rH] = ratioValue.split(':').map(Number);
|
|
7809
7504
|
const effW = ratioReversed ? rH : rW;
|
|
7810
7505
|
const effH = ratioReversed ? rW : rH;
|
|
7811
7506
|
const aspectRatio = \`\${effW} / \${effH}\`;
|
|
7812
7507
|
|
|
7813
|
-
const columnsCount = gridLayout
|
|
7508
|
+
const columnsCount = gridLayout.columnsCount;
|
|
7814
7509
|
const entryWidthScaled = scalingValue(size ?? 0, isEditor);
|
|
7815
|
-
const
|
|
7510
|
+
const imageWrapperWidth = entryWidthScaled;
|
|
7511
|
+
const isFitSlider = !isCover && slider !== 'off';
|
|
7816
7512
|
|
|
7817
7513
|
const itemsInLastRow = cropContent.length % columnsCount || columnsCount;
|
|
7818
|
-
const isPartialLastRow =
|
|
7514
|
+
const isPartialLastRow = itemsInLastRow < columnsCount && cropContent.length > 0;
|
|
7819
7515
|
const lastRowStartIndex = cropContent.length - itemsInLastRow;
|
|
7820
7516
|
const lastRowStartColumn = isPartialLastRow
|
|
7821
7517
|
? Math.floor((columnsCount - itemsInLastRow) / 2) + 1
|
|
@@ -7823,46 +7519,24 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7823
7519
|
|
|
7824
7520
|
const imageBorderRadius = imageCorners ? scalingValue(imageCorners, isEditor) : undefined;
|
|
7825
7521
|
|
|
7826
|
-
const
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
width: entryWidth,
|
|
7832
|
-
...(slot && isAutoHeight
|
|
7833
|
-
? {
|
|
7834
|
-
height: media?.isEmpty ? scalingValue(slot.height, isEditor) : 'auto',
|
|
7835
|
-
flexShrink: 0,
|
|
7836
|
-
overflow: 'hidden',
|
|
7837
|
-
...(media?.aspect && !isFitSlider ? { aspectRatio: \`\${media.aspect}\` } : {}),
|
|
7838
|
-
}
|
|
7839
|
-
: slot
|
|
7840
|
-
? isTextOutside
|
|
7841
|
-
? { height: scalingValue(slot.height, isEditor), flexShrink: 0, overflow: 'hidden' }
|
|
7842
|
-
: { flex: '1 1 0%', minHeight: 0, overflow: 'hidden' }
|
|
7843
|
-
: isCover
|
|
7844
|
-
? { aspectRatio, height: 'auto', overflow: 'hidden' }
|
|
7845
|
-
: { height: 'auto' }),
|
|
7522
|
+
const imageWrapperStyle: React.CSSProperties = {
|
|
7523
|
+
width: imageWrapperWidth,
|
|
7524
|
+
...(isCover
|
|
7525
|
+
? { aspectRatio, height: 'auto', overflow: 'hidden' }
|
|
7526
|
+
: { height: 'auto' }),
|
|
7846
7527
|
...(imageBorderRadius ? { borderRadius: imageBorderRadius, overflow: 'hidden' } : {}),
|
|
7847
|
-
}
|
|
7528
|
+
};
|
|
7848
7529
|
|
|
7849
7530
|
const imageWrapperClassName = \`\${P}-item-image-wrapper\${isFitSlider ? \` \${P}-item-image-wrapper-fit-slider\` : ''}\`.trim();
|
|
7850
7531
|
const isTextBeforeImage = type === 'd' || type === 'e' || type === 'f';
|
|
7851
|
-
const shouldAlignEntries =
|
|
7532
|
+
const shouldAlignEntries = alignEntries === 'on';
|
|
7533
|
+
const textBoxWidthStyle = \`calc(\${scalingValue(size ?? 0, isEditor)} * (\${textBoxWidth} / 100))\`;
|
|
7534
|
+
const controlWidthStyle = scalingValue(size * textBoxWidth / 100, isEditor);
|
|
7852
7535
|
|
|
7853
7536
|
const imageRadiusStyle = imageBorderRadius
|
|
7854
7537
|
? { borderRadius: imageBorderRadius, [MEDIA_RADIUS_VAR]: imageBorderRadius } as React.CSSProperties
|
|
7855
7538
|
: {};
|
|
7856
|
-
const imageStyle: React.CSSProperties =
|
|
7857
|
-
? {
|
|
7858
|
-
objectFit: isFitSlider && !isCover ? 'contain' : 'cover',
|
|
7859
|
-
pointerEvents: 'auto',
|
|
7860
|
-
width: '100%',
|
|
7861
|
-
height: '100%',
|
|
7862
|
-
maxWidth: '100%',
|
|
7863
|
-
...imageRadiusStyle,
|
|
7864
|
-
}
|
|
7865
|
-
: isCover
|
|
7539
|
+
const imageStyle: React.CSSProperties = isCover
|
|
7866
7540
|
? {
|
|
7867
7541
|
objectFit: 'cover',
|
|
7868
7542
|
pointerEvents: 'auto',
|
|
@@ -7877,92 +7551,31 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7877
7551
|
width: 'auto',
|
|
7878
7552
|
height: 'auto',
|
|
7879
7553
|
maxWidth: '100%',
|
|
7880
|
-
...(customLayout ? { maxHeight: '100%' } : {}),
|
|
7881
7554
|
...imageRadiusStyle,
|
|
7882
7555
|
};
|
|
7883
7556
|
|
|
7884
|
-
const
|
|
7885
|
-
const customGridWidth = customLayout ? getCustomGridSpanWidth(customLayout, customLayout.columnsCount) : 0;
|
|
7886
|
-
useLayoutEffect(() => {
|
|
7887
|
-
if (!shouldMeasureEntries) {
|
|
7888
|
-
setCustomEntryHeights(prev => (prev.length > 0 ? [] : prev));
|
|
7889
|
-
return;
|
|
7890
|
-
}
|
|
7891
|
-
const wrapper = containerRef.current;
|
|
7892
|
-
const inners = itemInnerRefs.current.slice(0, cropContent.length);
|
|
7893
|
-
const measure = () => {
|
|
7894
|
-
const unit = wrapper && customGridWidth > 0 ? wrapper.offsetWidth / customGridWidth : 0;
|
|
7895
|
-
if (unit <= 0) return;
|
|
7896
|
-
const heights = inners.map(inner => (inner ? inner.offsetHeight / unit : 0));
|
|
7897
|
-
setCustomEntryHeights(prev => (
|
|
7898
|
-
prev.length === heights.length && prev.every((height, index) => Math.abs(height - heights[index]) < 1e-5)
|
|
7899
|
-
? prev
|
|
7900
|
-
: heights
|
|
7901
|
-
));
|
|
7902
|
-
};
|
|
7903
|
-
measure();
|
|
7904
|
-
const ro = new ResizeObserver(measure);
|
|
7905
|
-
if (wrapper) ro.observe(wrapper);
|
|
7906
|
-
inners.forEach(inner => inner && ro.observe(inner));
|
|
7907
|
-
return () => ro.disconnect();
|
|
7908
|
-
}, [shouldMeasureEntries, cropContent.length, customGridWidth, P]);
|
|
7909
|
-
const measuredEntryHeights = shouldMeasureEntries && customEntryHeights.length === cropContent.length
|
|
7910
|
-
? customEntryHeights
|
|
7911
|
-
: undefined;
|
|
7912
|
-
const customRows = useMemo(() => {
|
|
7913
|
-
if (!customLayout) return undefined;
|
|
7914
|
-
const rows = getCustomGridRows(customLayout, cropContent.length, measuredEntryHeights);
|
|
7915
|
-
return {
|
|
7916
|
-
gridRows: rows.gridRows,
|
|
7917
|
-
gridTemplateRows: rows.tracks.length
|
|
7918
|
-
? rows.tracks.map(track => (track === 'auto' ? 'auto' : scalingValue(track, isEditor))).join(' ')
|
|
7919
|
-
: 'auto',
|
|
7920
|
-
};
|
|
7921
|
-
}, [customLayout, cropContent.length, measuredEntryHeights, isEditor]);
|
|
7922
|
-
const customSlots = useMemo(
|
|
7923
|
-
() => (customLayout ? cropContent.map((_, index) => getCustomGridSlot(customLayout, index)) : undefined),
|
|
7924
|
-
[customLayout, cropContent.length],
|
|
7925
|
-
);
|
|
7926
|
-
const entryMediaAspects = useMemo(
|
|
7927
|
-
() => entriesMedia.map(({ displayItems }) => (
|
|
7928
|
-
isAutoHeight && displayItems.length > 0 ? getGridMediaAspect(displayItems[0].displayMedia) : undefined
|
|
7929
|
-
)),
|
|
7930
|
-
[entriesMedia, isAutoHeight],
|
|
7931
|
-
);
|
|
7932
|
-
const customPlacement = useMemo(() => {
|
|
7933
|
-
if (!customLayout || !customSlots || !isPlacedLayout) return undefined;
|
|
7934
|
-
const beat = customLayout.beat ?? 0;
|
|
7935
|
-
const heights = customSlots.map((slot, index) => {
|
|
7936
|
-
const aspects = entriesMedia[index].displayItems.map(({ displayMedia }) => getGridMediaAspect(displayMedia));
|
|
7937
|
-
const known = aspects.filter((aspect): aspect is number => aspect !== undefined);
|
|
7938
|
-
const estimate = isAutoHeight && known.length > 0 ? Math.max(...known.map(aspect => slot.width / aspect)) : slot.height;
|
|
7939
|
-
const height = measuredEntryHeights?.[index] ?? estimate;
|
|
7940
|
-
return beat > 0 ? Math.ceil(height / beat - 1e-3) * beat : height;
|
|
7941
|
-
});
|
|
7942
|
-
return placeCustomGridEntries(customLayout, customSlots, heights);
|
|
7943
|
-
}, [customLayout, customSlots, isPlacedLayout, isAutoHeight, entriesMedia, measuredEntryHeights]);
|
|
7944
|
-
const wrapperLayoutStyle: React.CSSProperties = customLayout
|
|
7945
|
-
? {
|
|
7946
|
-
gridTemplateColumns: \`repeat(\${customLayout.columnsCount}, \${scalingValue(customLayout.columnWidth, isEditor)})\`,
|
|
7947
|
-
gridTemplateRows: customRows?.gridTemplateRows ?? 'auto',
|
|
7948
|
-
rowGap: 0,
|
|
7949
|
-
columnGap: scalingValue(customLayout.gutterWidth, isEditor),
|
|
7950
|
-
width: scalingValue(getCustomGridSpanWidth(customLayout, customLayout.columnsCount), isEditor),
|
|
7951
|
-
...(customPlacement ? { position: 'relative', height: scalingValue(customPlacement.bottom, isEditor) } : {}),
|
|
7952
|
-
}
|
|
7953
|
-
: {
|
|
7954
|
-
gridTemplateColumns: \`repeat(\${columnsCount}, \${entryWidthScaled})\`,
|
|
7955
|
-
rowGap: shouldAlignEntries ? 0 : scalingValue(verticalGap ?? 0, isEditor),
|
|
7956
|
-
columnGap: scalingValue(gridLayout?.horizontalGap ?? 0, isEditor),
|
|
7957
|
-
width: scalingValue(gridLayout?.wrapperWidth ?? 0, isEditor),
|
|
7958
|
-
...(shouldAlignEntries
|
|
7959
|
-
? { [\`--\${P}-align-entries-row-gap\`]: scalingValue(verticalGap ?? 0, isEditor) }
|
|
7960
|
-
: {}),
|
|
7961
|
-
};
|
|
7962
|
-
|
|
7557
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
7963
7558
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
7964
7559
|
|
|
7965
|
-
const
|
|
7560
|
+
const resolvedSplideDirection = transition === 'fade'
|
|
7561
|
+
? 'ltr'
|
|
7562
|
+
: direction === 'horizontal'
|
|
7563
|
+
? 'ltr'
|
|
7564
|
+
: direction === 'vertical'
|
|
7565
|
+
? 'ttb'
|
|
7566
|
+
: 'ltr';
|
|
7567
|
+
|
|
7568
|
+
useEffect(() => {
|
|
7569
|
+
const el = containerRef.current;
|
|
7570
|
+
if (!el) return;
|
|
7571
|
+
const ro = new ResizeObserver((entries) => {
|
|
7572
|
+
setContainerWidth(Math.round(entries[0].contentRect.width));
|
|
7573
|
+
});
|
|
7574
|
+
ro.observe(el);
|
|
7575
|
+
return () => ro.disconnect();
|
|
7576
|
+
}, []);
|
|
7577
|
+
|
|
7578
|
+
const lightboxPortalStyle = (() => {
|
|
7966
7579
|
const style: Record<string, string> = { ...(colorVars as Record<string, string>) };
|
|
7967
7580
|
const articleWidth = containerRef.current
|
|
7968
7581
|
? getComputedStyle(containerRef.current).getPropertyValue('--cntrl-article-width').trim()
|
|
@@ -7971,7 +7584,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7971
7584
|
style['--cntrl-article-width'] = articleWidth;
|
|
7972
7585
|
}
|
|
7973
7586
|
return style as React.CSSProperties;
|
|
7974
|
-
};
|
|
7587
|
+
})();
|
|
7975
7588
|
|
|
7976
7589
|
const [lightboxOpen, setLightboxOpen] = useState(false);
|
|
7977
7590
|
const [lightboxItems, setLightboxItems] = useState<GridMedia[]>([]);
|
|
@@ -8010,8 +7623,16 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8010
7623
|
<div style={colorVars}>
|
|
8011
7624
|
<div
|
|
8012
7625
|
ref={containerRef}
|
|
8013
|
-
className={\`\${P}-wrapper \${P}-type-\${type}\${shouldAlignEntries ? \` \${P}-align-entries\` : ''}
|
|
8014
|
-
style={
|
|
7626
|
+
className={\`\${P}-wrapper \${P}-type-\${type}\${shouldAlignEntries ? \` \${P}-align-entries\` : ''} \${P}-image-align-\${align} \${wrapperStateClasses}\`.trim()}
|
|
7627
|
+
style={{
|
|
7628
|
+
gridTemplateColumns: \`repeat(\${columnsCount}, \${entryWidthScaled})\`,
|
|
7629
|
+
rowGap: shouldAlignEntries ? 0 : scalingValue(verticalGap ?? 0, isEditor),
|
|
7630
|
+
columnGap: scalingValue(gridLayout.horizontalGap ?? 0, isEditor),
|
|
7631
|
+
width: scalingValue(gridLayout.wrapperWidth ?? 0, isEditor),
|
|
7632
|
+
...(shouldAlignEntries
|
|
7633
|
+
? { [\`--\${P}-align-entries-row-gap\`]: scalingValue(verticalGap ?? 0, isEditor) }
|
|
7634
|
+
: {}),
|
|
7635
|
+
}}>
|
|
8015
7636
|
{cropContent.map((item: any, index: number) => {
|
|
8016
7637
|
const hasTitle = hasText(item.title);
|
|
8017
7638
|
const hasSubtitle = hasText(item.subtitle);
|
|
@@ -8021,40 +7642,11 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8021
7642
|
const gridColumn = isPartialLastRow && index >= lastRowStartIndex
|
|
8022
7643
|
? \`\${lastRowStartColumn + (index - lastRowStartIndex)}\`
|
|
8023
7644
|
: undefined;
|
|
8024
|
-
const customSlot = customSlots?.[index];
|
|
8025
|
-
const itemSize = customSlot?.width ?? size;
|
|
8026
|
-
const itemWidthScaled = scalingValue(itemSize, isEditor);
|
|
8027
|
-
const textBoxWidthStyle = \`calc(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`;
|
|
8028
|
-
const controlWidthStyle = scalingValue(itemSize * textBoxWidth / 100, isEditor);
|
|
8029
|
-
const { displayItems, lightboxItemsForEntry, lightboxIndexes } = entriesMedia[index];
|
|
8030
|
-
const mediaAspect = slider === 'off' ? entryMediaAspects[index] : undefined;
|
|
8031
|
-
const imageWrapperStyle = getImageWrapperStyle(
|
|
8032
|
-
itemWidthScaled,
|
|
8033
|
-
customSlot,
|
|
8034
|
-
{ aspect: mediaAspect, isEmpty: displayItems.length === 0 },
|
|
8035
|
-
);
|
|
8036
|
-
const entryImageStyle = isAutoHeight && slider === 'off' && !mediaAspect
|
|
8037
|
-
? { ...imageStyle, height: 'auto' }
|
|
8038
|
-
: imageStyle;
|
|
8039
|
-
const itemStyle: React.CSSProperties | undefined = customSlot && customLayout && customPlacement
|
|
8040
|
-
? {
|
|
8041
|
-
position: 'absolute',
|
|
8042
|
-
left: scalingValue(customSlot.column * (customLayout.columnWidth + customLayout.gutterWidth), isEditor),
|
|
8043
|
-
top: scalingValue(customPlacement.tops[index], isEditor),
|
|
8044
|
-
width: itemWidthScaled,
|
|
8045
|
-
}
|
|
8046
|
-
: customSlot
|
|
8047
|
-
? {
|
|
8048
|
-
gridColumn: customSlot.gridColumn,
|
|
8049
|
-
gridRow: customRows?.gridRows[index],
|
|
8050
|
-
alignSelf: 'start',
|
|
8051
|
-
}
|
|
8052
|
-
: gridColumn && !shouldAlignEntries ? { gridColumn } : undefined;
|
|
8053
7645
|
|
|
8054
7646
|
const typeCTextBlock = isTextBeforeImage ? (
|
|
8055
7647
|
<div className={\`\${P}-item-text-block\`}>
|
|
8056
7648
|
{hasTitle && (
|
|
8057
|
-
<p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...
|
|
7649
|
+
<p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleFieldCss, ...titleTextLeadingVars }}>
|
|
8058
7650
|
{item.title}
|
|
8059
7651
|
</p>
|
|
8060
7652
|
)}
|
|
@@ -8069,7 +7661,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8069
7661
|
/>
|
|
8070
7662
|
)}
|
|
8071
7663
|
{hasSubtitle && (
|
|
8072
|
-
<p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...
|
|
7664
|
+
<p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleFieldCss, ...subtitleTextLeadingVars }}>
|
|
8073
7665
|
{item.subtitle}
|
|
8074
7666
|
</p>
|
|
8075
7667
|
)}
|
|
@@ -8099,7 +7691,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8099
7691
|
/>
|
|
8100
7692
|
)}
|
|
8101
7693
|
{hasTitle && (
|
|
8102
|
-
<p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...
|
|
7694
|
+
<p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleFieldCss, ...titleTextLeadingVars }}>
|
|
8103
7695
|
{item.title}
|
|
8104
7696
|
</p>
|
|
8105
7697
|
)}
|
|
@@ -8129,7 +7721,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8129
7721
|
/>
|
|
8130
7722
|
)}
|
|
8131
7723
|
{hasSubtitle && (
|
|
8132
|
-
<p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...
|
|
7724
|
+
<p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleFieldCss, ...subtitleTextLeadingVars }}>
|
|
8133
7725
|
{item.subtitle}
|
|
8134
7726
|
</p>
|
|
8135
7727
|
)}
|
|
@@ -8153,6 +7745,11 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8153
7745
|
</LinkWrapper>
|
|
8154
7746
|
);
|
|
8155
7747
|
|
|
7748
|
+
const displayItems = getGridDisplayItems(item.gallery);
|
|
7749
|
+
const lightboxItemsForEntry = displayItems
|
|
7750
|
+
.filter(entry => entry.lightboxMedia)
|
|
7751
|
+
.map(entry => entry.lightboxMedia!);
|
|
7752
|
+
|
|
8156
7753
|
const imageContent = (
|
|
8157
7754
|
<GridItemMediaWrapper className={imageWrapperClassName} style={imageWrapperStyle}>
|
|
8158
7755
|
{displayItems.length === 0
|
|
@@ -8160,13 +7757,15 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8160
7757
|
: slider === 'off'
|
|
8161
7758
|
?
|
|
8162
7759
|
(() => {
|
|
8163
|
-
const { displayMedia } = displayItems[0];
|
|
8164
|
-
const lightboxIndex =
|
|
7760
|
+
const { displayMedia, lightboxMedia } = displayItems[0];
|
|
7761
|
+
const lightboxIndex = lightboxMedia
|
|
7762
|
+
? lightboxItemsForEntry.findIndex(item => item.assetId === lightboxMedia.assetId)
|
|
7763
|
+
: -1;
|
|
8165
7764
|
return (
|
|
8166
7765
|
<GridMediaItem
|
|
8167
7766
|
media={displayMedia}
|
|
8168
7767
|
className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
|
|
8169
|
-
style={
|
|
7768
|
+
style={imageStyle}
|
|
8170
7769
|
hasLightbox={lightbox === 'on'}
|
|
8171
7770
|
onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
|
|
8172
7771
|
? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
|
|
@@ -8189,28 +7788,50 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8189
7788
|
))}
|
|
8190
7789
|
</div>
|
|
8191
7790
|
)}
|
|
8192
|
-
<
|
|
8193
|
-
key={\`\${transition}-\${
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
7791
|
+
<Splide
|
|
7792
|
+
key={\`\${transition}-\${size}-\${direction}-\${sliderTiming}-\${containerWidth}-\${layoutId}\`}
|
|
7793
|
+
className={\`\${P}-item-slider\`}
|
|
7794
|
+
options={{
|
|
7795
|
+
arrows: false,
|
|
7796
|
+
pagination: false,
|
|
7797
|
+
drag: false,
|
|
7798
|
+
perPage: 1,
|
|
7799
|
+
autoplay: true,
|
|
7800
|
+
interval: sliderTiming * 1000,
|
|
7801
|
+
width: '100%',
|
|
7802
|
+
height: '100%',
|
|
7803
|
+
speed: SLIDER_TRANSITION_MS,
|
|
7804
|
+
type: transition === 'fade' ? 'fade' : 'loop',
|
|
7805
|
+
rewind: transition === 'fade',
|
|
7806
|
+
pauseOnHover: false,
|
|
7807
|
+
pauseOnFocus: false,
|
|
7808
|
+
direction: resolvedSplideDirection,
|
|
7809
|
+
}}
|
|
7810
|
+
onMoved={(splide) => {
|
|
7811
|
+
if (direction !== 'random' || transition === 'fade') return;
|
|
7812
|
+
handleRandomSlideMoved(splide);
|
|
7813
|
+
}}
|
|
7814
|
+
>
|
|
7815
|
+
{displayItems.map(({ displayMedia, lightboxMedia }, imgIndex) => {
|
|
7816
|
+
const lightboxIndex = lightboxMedia
|
|
7817
|
+
? lightboxItemsForEntry.findIndex(item => item.assetId === lightboxMedia.assetId)
|
|
7818
|
+
: -1;
|
|
8200
7819
|
return (
|
|
8201
|
-
<
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
7820
|
+
<SplideSlide key={imgIndex} data-slide-index={imgIndex}>
|
|
7821
|
+
<GridMediaItem
|
|
7822
|
+
media={displayMedia}
|
|
7823
|
+
className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
|
|
7824
|
+
style={imageStyle}
|
|
7825
|
+
hasLightbox={lightbox === 'on'}
|
|
7826
|
+
isSplideSlide
|
|
7827
|
+
onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
|
|
7828
|
+
? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
|
|
7829
|
+
: undefined}
|
|
7830
|
+
/>
|
|
7831
|
+
</SplideSlide>
|
|
8211
7832
|
);
|
|
8212
7833
|
})}
|
|
8213
|
-
|
|
7834
|
+
</Splide>
|
|
8214
7835
|
</>
|
|
8215
7836
|
}
|
|
8216
7837
|
</GridItemMediaWrapper>
|
|
@@ -8228,7 +7849,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8228
7849
|
/>
|
|
8229
7850
|
<p
|
|
8230
7851
|
className={titleTextClassName}
|
|
8231
|
-
style={{ width: textBoxWidthStyle, ...
|
|
7852
|
+
style={{ width: textBoxWidthStyle, ...titleFieldCss, ...titleTextLeadingVars }}
|
|
8232
7853
|
>
|
|
8233
7854
|
{item.title}
|
|
8234
7855
|
</p>
|
|
@@ -8242,7 +7863,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8242
7863
|
/>
|
|
8243
7864
|
<p
|
|
8244
7865
|
className={subtitleTextClassName}
|
|
8245
|
-
style={{ width: textBoxWidthStyle, ...
|
|
7866
|
+
style={{ width: textBoxWidthStyle, ...subtitleFieldCss, ...subtitleTextLeadingVars }}
|
|
8246
7867
|
>
|
|
8247
7868
|
{item.subtitle}
|
|
8248
7869
|
</p>
|
|
@@ -8262,18 +7883,16 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8262
7883
|
<div
|
|
8263
7884
|
key={index}
|
|
8264
7885
|
className={\`\${P}-item\`.trim()}
|
|
8265
|
-
style={
|
|
7886
|
+
style={gridColumn && !shouldAlignEntries ? { gridColumn } : undefined}
|
|
8266
7887
|
>
|
|
8267
7888
|
<div
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
? \`\${P}-item-inner\`
|
|
7889
|
+
className={\`\${isEditMode
|
|
7890
|
+
? \`\${P}-item-inner\`
|
|
8271
7891
|
: \`\${P}-item-inner-hidden\`}\${shouldAlignEntries && isLastRow ? \` \${P}-item-inner-last-row\` : ''}\`.trim()}
|
|
8272
7892
|
style={{
|
|
8273
7893
|
width: (textBoxWidth ?? 0) > 100
|
|
8274
|
-
? \`calc(\${
|
|
8275
|
-
:
|
|
8276
|
-
...(customSlot && !isTextOutside && !isAutoHeight ? { height: scalingValue(customSlot.height, isEditor) } : {}),
|
|
7894
|
+
? \`calc(\${entryWidthScaled} * (\${textBoxWidth} / 100))\`
|
|
7895
|
+
: entryWidthScaled,
|
|
8277
7896
|
...(gridColumn && shouldAlignEntries ? { gridColumn } : {}),
|
|
8278
7897
|
}}
|
|
8279
7898
|
>
|
|
@@ -8319,7 +7938,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8319
7938
|
{(!isEditor || isPreviewMode) && lightboxOpen && typeof document !== 'undefined' && lightbox === 'on' && (() => {
|
|
8320
7939
|
const portalTarget = (portalId ? document.getElementById(portalId) : null) ?? document.body;
|
|
8321
7940
|
return createPortal(
|
|
8322
|
-
<div style={
|
|
7941
|
+
<div style={lightboxPortalStyle} data-selection="none">
|
|
8323
7942
|
<Lightbox
|
|
8324
7943
|
prefix={P}
|
|
8325
7944
|
items={lightboxItems}
|
|
@@ -8356,42 +7975,17 @@ type GridLayoutConfig = {
|
|
|
8356
7975
|
lockedParam?: 'wrapperWidth' | 'entryWidth' | 'horizontalGap' | null;
|
|
8357
7976
|
};
|
|
8358
7977
|
|
|
8359
|
-
type CustomGridBlock = {
|
|
8360
|
-
column: number;
|
|
8361
|
-
span: number;
|
|
8362
|
-
top: number;
|
|
8363
|
-
height: number;
|
|
8364
|
-
};
|
|
8365
|
-
|
|
8366
|
-
type CustomGridLayout = {
|
|
8367
|
-
columnsCount: number;
|
|
8368
|
-
columnWidth: number;
|
|
8369
|
-
gutterWidth: number;
|
|
8370
|
-
maxWidth: number | null;
|
|
8371
|
-
verticalGap?: number;
|
|
8372
|
-
beat?: number;
|
|
8373
|
-
repeatHeight?: number;
|
|
8374
|
-
blocks: CustomGridBlock[];
|
|
8375
|
-
gridType?: 'masonry' | 'stacked' | 'rows' | 'freeform';
|
|
8376
|
-
cellHeight?: 'manual' | 'auto';
|
|
8377
|
-
masonry?: 'off' | 'on';
|
|
8378
|
-
rows?: number;
|
|
8379
|
-
mediaDisplay?: 'fit' | 'cover';
|
|
8380
|
-
textGrowth?: 'inside' | 'outside';
|
|
8381
|
-
};
|
|
8382
|
-
|
|
8383
7978
|
type GridSettings = {
|
|
8384
7979
|
type: 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
|
|
8385
|
-
gridLayout
|
|
8386
|
-
customGrid?: CustomGridLayout;
|
|
7980
|
+
gridLayout: GridLayoutConfig;
|
|
8387
7981
|
textBoxWidth: number;
|
|
8388
|
-
verticalGap
|
|
8389
|
-
entriesCount
|
|
7982
|
+
verticalGap: number;
|
|
7983
|
+
entriesCount: number;
|
|
8390
7984
|
lightbox: 'on' | 'off';
|
|
8391
|
-
imageDisplay:
|
|
7985
|
+
imageDisplay: {
|
|
8392
7986
|
display: 'fit' | 'cover';
|
|
8393
|
-
ratioValue
|
|
8394
|
-
reversed
|
|
7987
|
+
ratioValue: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
|
|
7988
|
+
reversed: boolean;
|
|
8395
7989
|
};
|
|
8396
7990
|
imageCorners?: number;
|
|
8397
7991
|
lightboxImageDisplay?: 'fit' | 'cover' | { display?: 'fit' | 'cover' };
|
|
@@ -8401,9 +7995,8 @@ type GridSettings = {
|
|
|
8401
7995
|
transition: 'fade' | 'slide',
|
|
8402
7996
|
showText: 'always' | 'on hover';
|
|
8403
7997
|
hover?: 'none' | 'zoom-in' | 'greyscale' | 'scale-down';
|
|
8404
|
-
alignEntries
|
|
7998
|
+
alignEntries: 'on' | 'off';
|
|
8405
7999
|
align?: 'top' | 'center' | 'bottom';
|
|
8406
|
-
textGrowth?: 'inside' | 'outside';
|
|
8407
8000
|
titleMarginTop: number;
|
|
8408
8001
|
subtitleMarginTop: number;
|
|
8409
8002
|
titleColor: string;
|
|
@@ -8450,7 +8043,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
|
|
|
8450
8043
|
};
|
|
8451
8044
|
|
|
8452
8045
|
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
8453
|
-
`,
|
|
8046
|
+
`, T = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
|
|
8454
8047
|
import { CommonComponentProps } from '../props';
|
|
8455
8048
|
import { scalingValue } from '../utils/scalingValue';
|
|
8456
8049
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
@@ -9023,7 +8616,7 @@ export function Helix({
|
|
|
9023
8616
|
</>
|
|
9024
8617
|
);
|
|
9025
8618
|
}
|
|
9026
|
-
`,
|
|
8619
|
+
`, R = `import { CommonComponentProps } from '../props';
|
|
9027
8620
|
import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, scalingValue, useLazyVideos, useScopedStyles } from '../utils/index';
|
|
9028
8621
|
import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
|
|
9029
8622
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
@@ -11475,7 +11068,7 @@ export function Hive({
|
|
|
11475
11068
|
</>
|
|
11476
11069
|
);
|
|
11477
11070
|
}
|
|
11478
|
-
`,
|
|
11071
|
+
`, M = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
|
|
11479
11072
|
import { createPortal } from 'react-dom';
|
|
11480
11073
|
import { CommonComponentProps } from '../props';
|
|
11481
11074
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
@@ -12278,7 +11871,7 @@ export type LightboxJournalSettings = {
|
|
|
12278
11871
|
closeIconColor: string;
|
|
12279
11872
|
closeIconHoverColor: string;
|
|
12280
11873
|
};
|
|
12281
|
-
`,
|
|
11874
|
+
`, L = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
|
|
12282
11875
|
import { createPortal } from 'react-dom';
|
|
12283
11876
|
import { CommonComponentProps } from '../props';
|
|
12284
11877
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
@@ -12862,7 +12455,7 @@ export const LightboxStrip = ({ settings, content, isEditor, isEditMode, isPrevi
|
|
|
12862
12455
|
</>
|
|
12863
12456
|
);
|
|
12864
12457
|
};
|
|
12865
|
-
`,
|
|
12458
|
+
`, k = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
|
12866
12459
|
import { createPortal } from 'react-dom';
|
|
12867
12460
|
import { CommonComponentProps } from '../props';
|
|
12868
12461
|
import { buildColorVars, EmbedMediaFrame, isEmbedMedia, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
|
|
@@ -15967,7 +15560,7 @@ export function List({ settings, content, isEditor, isPreviewMode, isEditMode, a
|
|
|
15967
15560
|
</>
|
|
15968
15561
|
);
|
|
15969
15562
|
}
|
|
15970
|
-
`,
|
|
15563
|
+
`, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
|
15971
15564
|
import cn from 'classnames';
|
|
15972
15565
|
import { CommonComponentProps } from '../props';
|
|
15973
15566
|
import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
|
|
@@ -16825,7 +16418,7 @@ type MarqueeProps = {
|
|
|
16825
16418
|
isPreviewMode?: boolean;
|
|
16826
16419
|
isEditMode?: boolean;
|
|
16827
16420
|
} & CommonComponentProps;
|
|
16828
|
-
`,
|
|
16421
|
+
`, N = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
|
|
16829
16422
|
import cn from 'classnames';
|
|
16830
16423
|
import { CommonComponentProps } from '../props';
|
|
16831
16424
|
import { LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
|
|
@@ -17768,7 +17361,7 @@ type MarqueeTextProps = {
|
|
|
17768
17361
|
isPreviewMode?: boolean;
|
|
17769
17362
|
isEditMode?: boolean;
|
|
17770
17363
|
} & CommonComponentProps;
|
|
17771
|
-
`,
|
|
17364
|
+
`, H = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
17772
17365
|
import { createPortal } from 'react-dom';
|
|
17773
17366
|
import type React from 'react';
|
|
17774
17367
|
import { CommonComponentProps } from '../props';
|
|
@@ -20250,7 +19843,7 @@ export function Mercury({
|
|
|
20250
19843
|
</>
|
|
20251
19844
|
);
|
|
20252
19845
|
}
|
|
20253
|
-
`,
|
|
19846
|
+
`, O = `import React, { useMemo, useState } from 'react';
|
|
20254
19847
|
import { CommonComponentProps } from '../props';
|
|
20255
19848
|
import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
|
|
20256
19849
|
import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
|
|
@@ -20829,7 +20422,7 @@ const COLOR_VAR_MAP: Record<OnelinerColorKeys, string> = {
|
|
|
20829
20422
|
};
|
|
20830
20423
|
|
|
20831
20424
|
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
20832
|
-
`,
|
|
20425
|
+
`, _ = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
20833
20426
|
import type React from 'react';
|
|
20834
20427
|
import { CommonComponentProps } from '../props';
|
|
20835
20428
|
import { scalingValue, useScopedStyles } from '../utils/index';
|
|
@@ -21668,7 +21261,7 @@ export function Pretext({ settings, content, isEditor, isPreviewMode, isEditMode
|
|
|
21668
21261
|
</>
|
|
21669
21262
|
);
|
|
21670
21263
|
}
|
|
21671
|
-
`,
|
|
21264
|
+
`, F = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
21672
21265
|
import cn from 'classnames';
|
|
21673
21266
|
import { CommonComponentProps } from '../props';
|
|
21674
21267
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
@@ -22296,7 +21889,7 @@ export function Scale({ settings, content, isEditor, isPreviewMode }: ScaleProps
|
|
|
22296
21889
|
</>
|
|
22297
21890
|
);
|
|
22298
21891
|
}
|
|
22299
|
-
`,
|
|
21892
|
+
`, W = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
|
|
22300
21893
|
import { SvgImage } from '../helpers/SvgImage/SvgImage';
|
|
22301
21894
|
import { CommonComponentProps } from '../props';
|
|
22302
21895
|
import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
|
|
@@ -22993,7 +22586,7 @@ export function SimpleButton({ settings, isEditor, isPreviewMode, activeEvent, h
|
|
|
22993
22586
|
</>
|
|
22994
22587
|
);
|
|
22995
22588
|
}
|
|
22996
|
-
`,
|
|
22589
|
+
`, D = `import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
22997
22590
|
import cn from 'classnames';
|
|
22998
22591
|
import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
|
|
22999
22592
|
import { scalingValue } from '../utils/scalingValue';
|
|
@@ -23006,7 +22599,6 @@ type Slider20Item = {
|
|
|
23006
22599
|
image: {
|
|
23007
22600
|
assetId: string;
|
|
23008
22601
|
name?: string;
|
|
23009
|
-
objectFit?: 'cover' | 'contain';
|
|
23010
22602
|
};
|
|
23011
22603
|
imageCaption: any[];
|
|
23012
22604
|
};
|
|
@@ -23028,6 +22620,7 @@ type Slider20Settings = {
|
|
|
23028
22620
|
trigger?: Slider20Trigger;
|
|
23029
22621
|
direction?: Slider20Direction;
|
|
23030
22622
|
transition?: Slider20Transition;
|
|
22623
|
+
transitionSpeed?: number;
|
|
23031
22624
|
nav?: Slider20Nav;
|
|
23032
22625
|
navSize?: Slider20NavSize;
|
|
23033
22626
|
navUnit?: number;
|
|
@@ -23058,6 +22651,7 @@ type Slider20Settings = {
|
|
|
23058
22651
|
fontVariant?: 'normal' | 'small-caps';
|
|
23059
22652
|
};
|
|
23060
22653
|
captionMarginTop?: number;
|
|
22654
|
+
imageCorners?: number;
|
|
23061
22655
|
};
|
|
23062
22656
|
|
|
23063
22657
|
type Slider20Props = {
|
|
@@ -23069,6 +22663,7 @@ type Slider20Props = {
|
|
|
23069
22663
|
} & CommonComponentProps;
|
|
23070
22664
|
|
|
23071
22665
|
type Offset = { x: number; y: number };
|
|
22666
|
+
type TransitionLayer = { index: number; key: number; isAnimated: boolean };
|
|
23072
22667
|
type Point = { x: number; y: number };
|
|
23073
22668
|
type LocalAxes = { ex: Point; ey: Point; det: number };
|
|
23074
22669
|
|
|
@@ -23086,9 +22681,11 @@ type DragState = {
|
|
|
23086
22681
|
};
|
|
23087
22682
|
|
|
23088
22683
|
const TRANSITION_DURATION_MS = 500;
|
|
22684
|
+
const DEFAULT_TRANSITION_SPEED = 1;
|
|
23089
22685
|
const TRANSITION_EASING = 'cubic-bezier(0.25, 1, 0.5, 1)';
|
|
23090
22686
|
const TRANSITION_BACKGROUND_COLOR: string | null = null;
|
|
23091
22687
|
const DOT_ANIMATION_MS = 300;
|
|
22688
|
+
const MAX_TRANSITION_LAYERS = 40;
|
|
23092
22689
|
const DRAG_START_THRESHOLD_PX = 5;
|
|
23093
22690
|
const DRAG_DISTANCE_RATIO = 0.15;
|
|
23094
22691
|
const DRAG_FLICK_VELOCITY = 0.4;
|
|
@@ -23190,23 +22787,24 @@ function wrapIndex(index: number, count: number): number {
|
|
|
23190
22787
|
return ((index % count) + count) % count;
|
|
23191
22788
|
}
|
|
23192
22789
|
|
|
23193
|
-
|
|
23194
|
-
|
|
23195
|
-
|
|
23196
|
-
|
|
23197
|
-
|
|
23198
|
-
|
|
23199
|
-
|
|
23200
|
-
|
|
23201
|
-
|
|
23202
|
-
|
|
23203
|
-
|
|
23204
|
-
|
|
23205
|
-
|
|
23206
|
-
|
|
23207
|
-
|
|
23208
|
-
|
|
23209
|
-
|
|
22790
|
+
// Slide mode renders the items three times; shifting the track by one copy is invisible.
|
|
22791
|
+
const TRACK_COPIES = 3;
|
|
22792
|
+
|
|
22793
|
+
function getTrackTranslate(position: number, offsetPx: number, isHorizontal: boolean): string {
|
|
22794
|
+
return isHorizontal
|
|
22795
|
+
? \`translate3d(calc(\${-position * 100}% + \${offsetPx}px), 0, 0)\`
|
|
22796
|
+
: \`translate3d(0, calc(\${-position * 100}% + \${offsetPx}px), 0)\`;
|
|
22797
|
+
}
|
|
22798
|
+
|
|
22799
|
+
// Shift (a multiple of count) that moves a position into the middle copy.
|
|
22800
|
+
function getMiddleCopyShift(position: number, count: number): number {
|
|
22801
|
+
return (Math.floor(position / count) - 1) * count;
|
|
22802
|
+
}
|
|
22803
|
+
|
|
22804
|
+
// Untransformed, unrounded size of one slide (offsetWidth rounds, the canvas zoom scales rects).
|
|
22805
|
+
function readSlideSizePx(element: HTMLElement, isHorizontal: boolean): number {
|
|
22806
|
+
const style = window.getComputedStyle(element);
|
|
22807
|
+
return parseFloat(isHorizontal ? style.width : style.height) || 0;
|
|
23210
22808
|
}
|
|
23211
22809
|
|
|
23212
22810
|
function readTrackTranslatePx(element: HTMLElement, isHorizontal: boolean): number {
|
|
@@ -23248,7 +22846,13 @@ function toLocalDelta(axes: LocalAxes, dx: number, dy: number): Point {
|
|
|
23248
22846
|
};
|
|
23249
22847
|
}
|
|
23250
22848
|
|
|
23251
|
-
|
|
22849
|
+
// Speed 0..2 maps to 2000ms..125ms on a log scale; speed 1 keeps the base 500ms.
|
|
22850
|
+
function getTransitionDurationMs(speed: number): number {
|
|
22851
|
+
const clamped = Math.min(Math.max(speed, 0), 2);
|
|
22852
|
+
return Math.round(TRANSITION_DURATION_MS * Math.pow(4, 1 - clamped));
|
|
22853
|
+
}
|
|
22854
|
+
|
|
22855
|
+
function getCSS(P: string, transitionDurationMs: number, isEditor?: boolean): string {
|
|
23252
22856
|
return \`
|
|
23253
22857
|
.\${P}-wrapper {
|
|
23254
22858
|
position: relative;
|
|
@@ -23309,6 +22913,8 @@ function getCSS(P: string, isEditor?: boolean): string {
|
|
|
23309
22913
|
}
|
|
23310
22914
|
.\${P}-list-fade {
|
|
23311
22915
|
display: block;
|
|
22916
|
+
/* Keeps the transition layers' z-index below the arrows, dots and click overlay. */
|
|
22917
|
+
isolation: isolate;
|
|
23312
22918
|
}
|
|
23313
22919
|
.\${P}-slide {
|
|
23314
22920
|
position: relative;
|
|
@@ -23321,11 +22927,9 @@ function getCSS(P: string, isEditor?: boolean): string {
|
|
|
23321
22927
|
top: 0;
|
|
23322
22928
|
left: 0;
|
|
23323
22929
|
opacity: 0;
|
|
23324
|
-
transition: opacity \${TRANSITION_DURATION_MS}ms \${TRANSITION_EASING};
|
|
23325
22930
|
}
|
|
23326
|
-
.\${P}-list-fade .\${P}-slide.\${P}-is-
|
|
22931
|
+
.\${P}-list-fade .\${P}-slide.\${P}-is-layer {
|
|
23327
22932
|
opacity: 1;
|
|
23328
|
-
z-index: 1;
|
|
23329
22933
|
}
|
|
23330
22934
|
.\${P}-slider-item {
|
|
23331
22935
|
width: 100%;
|
|
@@ -23500,17 +23104,18 @@ function getCSS(P: string, isEditor?: boolean): string {
|
|
|
23500
23104
|
cursor: pointer;
|
|
23501
23105
|
z-index: 2;
|
|
23502
23106
|
}
|
|
23503
|
-
.\${P}-
|
|
23504
|
-
|
|
23107
|
+
.\${P}-transition-fade .\${P}-slide.\${P}-is-animated .\${P}-slider-image {
|
|
23108
|
+
animation: \${P}-fade-in \${transitionDurationMs}ms \${TRANSITION_EASING};
|
|
23505
23109
|
}
|
|
23506
|
-
.\${P}-
|
|
23507
|
-
|
|
23110
|
+
.\${P}-transition-reveal .\${P}-slide.\${P}-is-animated .\${P}-slider-image {
|
|
23111
|
+
animation: \${P}-reveal-horizontal \${transitionDurationMs}ms ease;
|
|
23508
23112
|
}
|
|
23509
|
-
.\${P}-transition-reveal .\${P}-slide.\${P}-is-
|
|
23510
|
-
animation: \${P}-reveal-
|
|
23113
|
+
.\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-animated .\${P}-slider-image {
|
|
23114
|
+
animation: \${P}-reveal-vertical \${transitionDurationMs}ms ease;
|
|
23511
23115
|
}
|
|
23512
|
-
|
|
23513
|
-
|
|
23116
|
+
@keyframes \${P}-fade-in {
|
|
23117
|
+
from { opacity: 0; }
|
|
23118
|
+
to { opacity: 1; }
|
|
23514
23119
|
}
|
|
23515
23120
|
@keyframes \${P}-reveal-horizontal {
|
|
23516
23121
|
from { clip-path: inset(0 100% 0 0); }
|
|
@@ -23533,6 +23138,8 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
23533
23138
|
const autoPlayIntervalS = trigger.value ?? DEFAULT_TRIGGER.value;
|
|
23534
23139
|
const direction: Slider20Direction = settings?.direction ?? 'horizontal';
|
|
23535
23140
|
const transition: Slider20Transition = settings?.transition ?? 'slide';
|
|
23141
|
+
const transitionSpeed = typeof settings?.transitionSpeed === 'number' ? settings.transitionSpeed : DEFAULT_TRANSITION_SPEED;
|
|
23142
|
+
const transitionDurationMs = getTransitionDurationMs(transitionSpeed);
|
|
23536
23143
|
const nav: Slider20Nav = settings?.nav ?? 'classic';
|
|
23537
23144
|
const navSize: Slider20NavSize = settings?.navSize ?? 'm';
|
|
23538
23145
|
const navSizeValues = NAV_SIZES[navSize];
|
|
@@ -23550,12 +23157,21 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
23550
23157
|
const navBackgroundColor = settings?.navBackgroundColor ?? PAGINATION.colors.background;
|
|
23551
23158
|
const linkColor = settings?.linkColor ?? IMAGE_CAPTION.linkColor;
|
|
23552
23159
|
const captionMarginTop = typeof settings?.captionMarginTop === 'number' ? settings.captionMarginTop : 0;
|
|
23160
|
+
const imageCorners = typeof settings?.imageCorners === 'number' ? settings.imageCorners : 0;
|
|
23161
|
+
// Rounding the track (not each image) keeps the corners steady while slides move under it.
|
|
23162
|
+
// isolation makes Safari clip the transformed list to the radius.
|
|
23163
|
+
const trackRadiusStyle: React.CSSProperties | undefined = imageCorners > 0
|
|
23164
|
+
? { borderRadius: scalingValue(imageCorners, isEditor), isolation: 'isolate' }
|
|
23165
|
+
: undefined;
|
|
23553
23166
|
const isHorizontal = direction === 'horizontal';
|
|
23554
23167
|
const isClickTrigger = triggerType === 'click';
|
|
23555
23168
|
const isDragTrigger = triggerType === 'drag';
|
|
23556
23169
|
const isAutoPlaying = triggerType === 'auto' && (!isEditor || Boolean(isPreviewMode));
|
|
23557
23170
|
const pauseAutoOnHover = !isEditor;
|
|
23558
23171
|
const isSlideTransition = transition === 'slide';
|
|
23172
|
+
const isReveal = transition === 'reveal';
|
|
23173
|
+
// Fade and reveal draw each new slide as a layer over the previous ones.
|
|
23174
|
+
const isLayered = !isSlideTransition;
|
|
23559
23175
|
const showClassicNav = nav === 'classic';
|
|
23560
23176
|
const showControls = controlsShow !== 'never' && controlsMaxWidth > 0;
|
|
23561
23177
|
const isControlsOnHover = controlsShow === 'on hover';
|
|
@@ -23568,7 +23184,39 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
23568
23184
|
|
|
23569
23185
|
const hasClones = isSlideTransition && count > 1;
|
|
23570
23186
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
23571
|
-
|
|
23187
|
+
// Layers stack bottom to top: each new slide fades or reveals over the ones still animating,
|
|
23188
|
+
// which keep their own animation. The same slide can sit in the stack more than once.
|
|
23189
|
+
// The first slide is shown as is on load, without a transition.
|
|
23190
|
+
const [transitionLayers, setTransitionLayers] = useState<TransitionLayer[]>([
|
|
23191
|
+
{ index: activeIndex, key: 0, isAnimated: false },
|
|
23192
|
+
]);
|
|
23193
|
+
const topLayer = transitionLayers[transitionLayers.length - 1];
|
|
23194
|
+
if (isLayered && topLayer.index !== activeIndex) {
|
|
23195
|
+
// Over the limit, drop the oldest layer still animating, never the fully shown bottom one.
|
|
23196
|
+
const kept = transitionLayers.length >= MAX_TRANSITION_LAYERS
|
|
23197
|
+
? [transitionLayers[0], ...transitionLayers.slice(2)]
|
|
23198
|
+
: transitionLayers;
|
|
23199
|
+
setTransitionLayers([...kept, { index: activeIndex, key: topLayer.key + 1, isAnimated: true }]);
|
|
23200
|
+
}
|
|
23201
|
+
const handleLayerEnd = (key: number) => {
|
|
23202
|
+
// A fully shown layer covers everything under it, so those layers are dropped.
|
|
23203
|
+
setTransitionLayers((layers) => {
|
|
23204
|
+
const position = layers.findIndex((layer) => layer.key === key);
|
|
23205
|
+
return position > 0 ? layers.slice(position) : layers;
|
|
23206
|
+
});
|
|
23207
|
+
};
|
|
23208
|
+
const renderSlideItem = (item: Slider20Item | undefined) => item && (
|
|
23209
|
+
<div className={\`\${P}-slider-item\`}>
|
|
23210
|
+
<div className={\`\${P}-img-wrapper\`}>
|
|
23211
|
+
<img
|
|
23212
|
+
className={\`\${P}-slider-image\`}
|
|
23213
|
+
src={item.image.assetId} alt={item.image.name ?? ''}
|
|
23214
|
+
draggable={false}
|
|
23215
|
+
/>
|
|
23216
|
+
</div>
|
|
23217
|
+
</div>
|
|
23218
|
+
);
|
|
23219
|
+
const [trackPosition, setTrackPosition] = useState(hasClones ? count : 0);
|
|
23572
23220
|
const [isMoving, setIsMoving] = useState(false);
|
|
23573
23221
|
const [skipTransition, setSkipTransition] = useState(false);
|
|
23574
23222
|
const [isDragging, setIsDragging] = useState(false);
|
|
@@ -23578,73 +23226,100 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
23578
23226
|
const isMovingRef = useRef(false);
|
|
23579
23227
|
const trackPositionRef = useRef(trackPosition);
|
|
23580
23228
|
trackPositionRef.current = trackPosition;
|
|
23581
|
-
const pendingAnimatedPositionRef = useRef<number | null>(null);
|
|
23582
|
-
const pendingStepsRef = useRef(0);
|
|
23583
23229
|
const trackRef = useRef<HTMLDivElement | null>(null);
|
|
23584
23230
|
const listRef = useRef<HTMLDivElement | null>(null);
|
|
23585
23231
|
const dragRef = useRef<DragState | null>(null);
|
|
23586
23232
|
const activePointerIdRef = useRef<number | null>(null);
|
|
23587
23233
|
|
|
23234
|
+
const activeIndexRef = useRef(activeIndex);
|
|
23235
|
+
activeIndexRef.current = activeIndex;
|
|
23236
|
+
const revealTargetRef = useRef(activeIndex);
|
|
23237
|
+
const revealTimerRef = useRef<number | null>(null);
|
|
23238
|
+
|
|
23588
23239
|
const setMoving = useCallback((value: boolean) => {
|
|
23589
23240
|
isMovingRef.current = value;
|
|
23590
23241
|
setIsMoving(value);
|
|
23591
23242
|
}, []);
|
|
23592
23243
|
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
|
|
23597
|
-
|
|
23598
|
-
|
|
23599
|
-
if (!isSlideTransition) {
|
|
23600
|
-
setActiveIndex((prev) => wrapIndex(prev + steps, count));
|
|
23244
|
+
// Reveal starts a new layer at most every half transition, so quick clicks never run more
|
|
23245
|
+
// than two reveals at once, evenly spaced. Clicks in between only move the pending target,
|
|
23246
|
+
// which is shown when the next slot opens.
|
|
23247
|
+
const changeLayeredIndex = useCallback((getTarget: (current: number) => number) => {
|
|
23248
|
+
if (!isReveal) {
|
|
23249
|
+
setActiveIndex((prev) => wrapIndex(getTarget(prev), count));
|
|
23601
23250
|
return;
|
|
23602
23251
|
}
|
|
23252
|
+
const isWaiting = revealTimerRef.current !== null;
|
|
23253
|
+
const base = isWaiting ? revealTargetRef.current : activeIndexRef.current;
|
|
23254
|
+
revealTargetRef.current = wrapIndex(getTarget(base), count);
|
|
23255
|
+
if (isWaiting) return;
|
|
23256
|
+
const startReveal = (index: number) => {
|
|
23257
|
+
activeIndexRef.current = index;
|
|
23258
|
+
setActiveIndex(index);
|
|
23259
|
+
revealTimerRef.current = window.setTimeout(() => {
|
|
23260
|
+
revealTimerRef.current = null;
|
|
23261
|
+
if (revealTargetRef.current !== activeIndexRef.current) startReveal(revealTargetRef.current);
|
|
23262
|
+
}, transitionDurationMs / 2);
|
|
23263
|
+
};
|
|
23264
|
+
startReveal(revealTargetRef.current);
|
|
23265
|
+
}, [count, isReveal, transitionDurationMs]);
|
|
23603
23266
|
|
|
23604
|
-
|
|
23605
|
-
|
|
23606
|
-
|
|
23607
|
-
|
|
23608
|
-
if (isOnClone) {
|
|
23609
|
-
position = activeIndex + 1;
|
|
23610
|
-
}
|
|
23611
|
-
|
|
23612
|
-
let remaining = total;
|
|
23613
|
-
while (remaining > 0) {
|
|
23614
|
-
const result = advanceTrackPosition(position, direction, count, hasClones);
|
|
23615
|
-
position = result.position;
|
|
23616
|
-
remaining -= 1;
|
|
23617
|
-
if (result.hitBoundary) {
|
|
23618
|
-
pendingStepsRef.current = remaining * direction;
|
|
23619
|
-
break;
|
|
23620
|
-
}
|
|
23621
|
-
}
|
|
23267
|
+
useEffect(() => () => {
|
|
23268
|
+
if (revealTimerRef.current !== null) window.clearTimeout(revealTimerRef.current);
|
|
23269
|
+
}, []);
|
|
23622
23270
|
|
|
23623
|
-
|
|
23624
|
-
|
|
23625
|
-
|
|
23271
|
+
// Where the track is on screen right now, mid-transition included, in slide units.
|
|
23272
|
+
const readVisualPosition = useCallback((): number => {
|
|
23273
|
+
const list = listRef.current;
|
|
23274
|
+
const size = list ? readSlideSizePx(list, isHorizontal) : 0;
|
|
23275
|
+
if (!list || size <= 0) return trackPositionRef.current;
|
|
23276
|
+
// Rounded so a settled track reads as a whole position.
|
|
23277
|
+
return Math.round((-readTrackTranslatePx(list, isHorizontal) / size) * 1000) / 1000;
|
|
23278
|
+
}, [isHorizontal]);
|
|
23279
|
+
|
|
23280
|
+
// Moves the track to \`target\` from wherever it is now. When the visual position is outside
|
|
23281
|
+
// the middle copy, it is first teleported by a whole copy (no visible change), so rapid
|
|
23282
|
+
// navigation never runs off the rendered slides and never snaps mid-animation.
|
|
23283
|
+
const moveTrack = useCallback((getTarget: (visual: number, shift: number) => number) => {
|
|
23284
|
+
const visual = readVisualPosition();
|
|
23285
|
+
const shift = getMiddleCopyShift(visual, count);
|
|
23286
|
+
const target = getTarget(visual - shift, shift);
|
|
23287
|
+
const list = listRef.current;
|
|
23288
|
+
if (shift !== 0 && list) {
|
|
23289
|
+
const transitionValue = list.style.transition;
|
|
23290
|
+
list.style.transition = 'none';
|
|
23291
|
+
list.style.transform = getTrackTranslate(visual - shift, 0, isHorizontal);
|
|
23292
|
+
void list.offsetWidth;
|
|
23293
|
+
list.style.transition = transitionValue && transitionValue !== 'none'
|
|
23294
|
+
? transitionValue
|
|
23295
|
+
: \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`;
|
|
23296
|
+
list.style.transform = getTrackTranslate(target, 0, isHorizontal);
|
|
23626
23297
|
}
|
|
23298
|
+
trackPositionRef.current = target;
|
|
23299
|
+
setActiveIndex(wrapIndex(target, count));
|
|
23300
|
+
setSkipTransition(false);
|
|
23301
|
+
setTrackPosition(target);
|
|
23302
|
+
}, [count, isHorizontal, readVisualPosition, transitionDurationMs]);
|
|
23627
23303
|
|
|
23628
|
-
|
|
23629
|
-
|
|
23630
|
-
|
|
23631
|
-
|
|
23632
|
-
|
|
23633
|
-
|
|
23634
|
-
setTrackPosition(position);
|
|
23635
|
-
return;
|
|
23636
|
-
}
|
|
23637
|
-
pendingAnimatedPositionRef.current = position;
|
|
23638
|
-
setSkipTransition(true);
|
|
23639
|
-
setTrackPosition(cloneSnapPosition);
|
|
23304
|
+
const goBySteps = useCallback((steps: number) => {
|
|
23305
|
+
if (count < 2 || steps === 0) return;
|
|
23306
|
+
setAnimateDots(true);
|
|
23307
|
+
setMoving(true);
|
|
23308
|
+
if (!isSlideTransition) {
|
|
23309
|
+
changeLayeredIndex((current) => current + steps);
|
|
23640
23310
|
return;
|
|
23641
23311
|
}
|
|
23312
|
+
moveTrack((visual, shift) => {
|
|
23313
|
+
// Continue from the previous target so quick clicks add up, but never get more than
|
|
23314
|
+
// count - 1 slides away from what is on screen, which keeps the target inside the copies.
|
|
23315
|
+
const previousTarget = trackPositionRef.current - shift;
|
|
23316
|
+
const base = Math.abs(previousTarget - visual) < count ? previousTarget : Math.round(visual);
|
|
23317
|
+
const maxDistance = count - 1;
|
|
23318
|
+
return Math.min(Math.max(base + steps, Math.ceil(visual - maxDistance)), Math.floor(visual + maxDistance));
|
|
23319
|
+
});
|
|
23320
|
+
}, [changeLayeredIndex, count, isSlideTransition, moveTrack, setMoving]);
|
|
23642
23321
|
|
|
23643
|
-
|
|
23644
|
-
setTrackPosition(position);
|
|
23645
|
-
}, [activeIndex, count, hasClones, isSlideTransition, setMoving]);
|
|
23646
|
-
|
|
23647
|
-
const goBy = useCallback((step: 1 | -1) => {
|
|
23322
|
+
const goBy =useCallback((step: 1 | -1) => {
|
|
23648
23323
|
goBySteps(step);
|
|
23649
23324
|
}, [goBySteps]);
|
|
23650
23325
|
|
|
@@ -23654,58 +23329,37 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
23654
23329
|
if (target === activeIndex && !isMovingRef.current) return;
|
|
23655
23330
|
setAnimateDots(true);
|
|
23656
23331
|
setMoving(true);
|
|
23657
|
-
|
|
23658
|
-
|
|
23659
|
-
|
|
23660
|
-
pendingAnimatedPositionRef.current = null;
|
|
23661
|
-
pendingStepsRef.current = 0;
|
|
23662
|
-
trackPositionRef.current = position;
|
|
23663
|
-
setSkipTransition(false);
|
|
23664
|
-
setTrackPosition(position);
|
|
23332
|
+
if (!isSlideTransition) {
|
|
23333
|
+
changeLayeredIndex(() => target);
|
|
23334
|
+
return;
|
|
23665
23335
|
}
|
|
23666
|
-
|
|
23336
|
+
moveTrack(() => count + target);
|
|
23337
|
+
}, [activeIndex, changeLayeredIndex, count, isSlideTransition, moveTrack, setMoving]);
|
|
23667
23338
|
|
|
23668
23339
|
useEffect(() => {
|
|
23669
23340
|
if (!isMoving) return;
|
|
23670
23341
|
const timeoutId = window.setTimeout(() => {
|
|
23671
|
-
if (hasClones && (trackPosition === 0 || trackPosition === count + 1)) {
|
|
23672
|
-
pendingAnimatedPositionRef.current = null;
|
|
23673
|
-
setSkipTransition(true);
|
|
23674
|
-
setTrackPosition(activeIndex + 1);
|
|
23675
|
-
return;
|
|
23676
|
-
}
|
|
23677
23342
|
setMoving(false);
|
|
23678
|
-
|
|
23343
|
+
if (!hasClones) return;
|
|
23344
|
+
const shift = getMiddleCopyShift(trackPosition, count);
|
|
23345
|
+
if (shift === 0) return;
|
|
23346
|
+
setSkipTransition(true);
|
|
23347
|
+
setTrackPosition(trackPosition - shift);
|
|
23348
|
+
}, transitionDurationMs);
|
|
23679
23349
|
return () => window.clearTimeout(timeoutId);
|
|
23680
|
-
}, [
|
|
23350
|
+
}, [count, hasClones, isMoving, setMoving, trackPosition, transitionDurationMs]);
|
|
23681
23351
|
|
|
23682
23352
|
useEffect(() => {
|
|
23683
23353
|
if (!skipTransition) return;
|
|
23684
23354
|
let innerId = 0;
|
|
23685
23355
|
const outerId = requestAnimationFrame(() => {
|
|
23686
|
-
innerId = requestAnimationFrame(() =>
|
|
23687
|
-
const pendingPosition = pendingAnimatedPositionRef.current;
|
|
23688
|
-
pendingAnimatedPositionRef.current = null;
|
|
23689
|
-
const pendingSteps = pendingStepsRef.current;
|
|
23690
|
-
pendingStepsRef.current = 0;
|
|
23691
|
-
setSkipTransition(false);
|
|
23692
|
-
if (pendingPosition !== null) {
|
|
23693
|
-
trackPositionRef.current = pendingPosition;
|
|
23694
|
-
setTrackPosition(pendingPosition);
|
|
23695
|
-
return;
|
|
23696
|
-
}
|
|
23697
|
-
if (pendingSteps !== 0) {
|
|
23698
|
-
goBySteps(pendingSteps);
|
|
23699
|
-
return;
|
|
23700
|
-
}
|
|
23701
|
-
setMoving(false);
|
|
23702
|
-
});
|
|
23356
|
+
innerId = requestAnimationFrame(() => setSkipTransition(false));
|
|
23703
23357
|
});
|
|
23704
23358
|
return () => {
|
|
23705
23359
|
cancelAnimationFrame(outerId);
|
|
23706
23360
|
cancelAnimationFrame(innerId);
|
|
23707
23361
|
};
|
|
23708
|
-
}, [
|
|
23362
|
+
}, [skipTransition]);
|
|
23709
23363
|
|
|
23710
23364
|
const structureKey = \`\${hasClones}:\${count}\`;
|
|
23711
23365
|
const prevStructureKeyRef = useRef(structureKey);
|
|
@@ -23719,7 +23373,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
23719
23373
|
setDragOffset(0);
|
|
23720
23374
|
setActiveIndex(nextIndex);
|
|
23721
23375
|
setSkipTransition(true);
|
|
23722
|
-
setTrackPosition(nextIndex + (hasClones ?
|
|
23376
|
+
setTrackPosition(nextIndex + (hasClones ? count : 0));
|
|
23723
23377
|
}, [activeIndex, count, hasClones, structureKey]);
|
|
23724
23378
|
|
|
23725
23379
|
useEffect(() => {
|
|
@@ -23798,31 +23452,23 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
23798
23452
|
if (!isDragTrigger || count < 2 || !track) return;
|
|
23799
23453
|
if (event.pointerType === 'mouse' && event.button !== 0) return;
|
|
23800
23454
|
|
|
23801
|
-
pendingAnimatedPositionRef.current = null;
|
|
23802
|
-
pendingStepsRef.current = 0;
|
|
23803
|
-
|
|
23804
23455
|
if (isMovingRef.current) {
|
|
23805
23456
|
setMoving(false);
|
|
23806
23457
|
}
|
|
23807
23458
|
|
|
23459
|
+
// Freeze the track where it is on screen and drag from there.
|
|
23808
23460
|
let baseOffset = 0;
|
|
23809
23461
|
const list = listRef.current;
|
|
23810
23462
|
if (isSlideTransition && list) {
|
|
23811
|
-
const size =
|
|
23463
|
+
const size = readSlideSizePx(list, isHorizontal);
|
|
23812
23464
|
if (size > 0) {
|
|
23813
|
-
const
|
|
23814
|
-
|
|
23815
|
-
const
|
|
23816
|
-
|
|
23817
|
-
|
|
23818
|
-
|
|
23819
|
-
|
|
23820
|
-
setSkipTransition(true);
|
|
23821
|
-
setTrackPosition(syncedPosition);
|
|
23822
|
-
baseOffset = 0;
|
|
23823
|
-
} else {
|
|
23824
|
-
baseOffset = currentPx + syncedPosition * size;
|
|
23825
|
-
}
|
|
23465
|
+
const visual = readVisualPosition();
|
|
23466
|
+
const middleVisual = hasClones ? visual - getMiddleCopyShift(visual, count) : visual;
|
|
23467
|
+
const basePosition = Math.round(middleVisual);
|
|
23468
|
+
baseOffset = (basePosition - middleVisual) * size;
|
|
23469
|
+
trackPositionRef.current = basePosition;
|
|
23470
|
+
setSkipTransition(true);
|
|
23471
|
+
setTrackPosition(basePosition);
|
|
23826
23472
|
setDragOffset(baseOffset);
|
|
23827
23473
|
}
|
|
23828
23474
|
}
|
|
@@ -23888,19 +23534,19 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
23888
23534
|
finishDrag(event);
|
|
23889
23535
|
};
|
|
23890
23536
|
|
|
23891
|
-
const trackTranslate = isHorizontal
|
|
23892
|
-
|
|
23893
|
-
: \`translate3d(0, calc(\${-trackPosition * 100}% + \${dragOffset}px), 0)\`;
|
|
23894
|
-
const slides = hasClones ? [items[count - 1], ...items, items[0]] : items;
|
|
23537
|
+
const trackTranslate = getTrackTranslate(trackPosition, dragOffset, isHorizontal);
|
|
23538
|
+
const slides = hasClones ? Array.from({ length: TRACK_COPIES }, () => items).flat() : items;
|
|
23895
23539
|
|
|
23896
23540
|
return (
|
|
23897
23541
|
<>
|
|
23898
|
-
<style dangerouslySetInnerHTML={{ __html: getCSS(P, isEditor) }} />
|
|
23542
|
+
<style dangerouslySetInnerHTML={{ __html: getCSS(P, transitionDurationMs, isEditor) }} />
|
|
23899
23543
|
<div
|
|
23900
23544
|
className={cn(\`\${P}-wrapper\`, {
|
|
23901
|
-
[\`\${P}-transition-
|
|
23902
|
-
[\`\${P}-transition-reveal
|
|
23545
|
+
[\`\${P}-transition-fade\`]: transition === 'fade in',
|
|
23546
|
+
[\`\${P}-transition-reveal\`]: isReveal,
|
|
23547
|
+
[\`\${P}-transition-reveal-vertical\`]: isReveal && !isHorizontal,
|
|
23903
23548
|
})}
|
|
23549
|
+
data-active-index={activeIndex}
|
|
23904
23550
|
onMouseEnter={() => setIsHovered(true)}
|
|
23905
23551
|
onMouseLeave={() => setIsHovered(false)}
|
|
23906
23552
|
>
|
|
@@ -23916,6 +23562,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
23916
23562
|
[\`\${P}-track-draggable\`]: isDragTrigger,
|
|
23917
23563
|
[\`\${P}-track-draggable-vertical\`]: isDragTrigger && !isHorizontal,
|
|
23918
23564
|
})}
|
|
23565
|
+
style={trackRadiusStyle}
|
|
23919
23566
|
onPointerDown={handlePointerDown}
|
|
23920
23567
|
onPointerMove={handlePointerMove}
|
|
23921
23568
|
onPointerUp={handlePointerUp}
|
|
@@ -23938,38 +23585,29 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
23938
23585
|
transform: trackTranslate,
|
|
23939
23586
|
transition: isDragging || skipTransition
|
|
23940
23587
|
? 'none'
|
|
23941
|
-
: \`transform \${
|
|
23588
|
+
: \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`,
|
|
23942
23589
|
}
|
|
23943
23590
|
: undefined}
|
|
23944
23591
|
>
|
|
23945
23592
|
{slides.map((item, slideIndex) => {
|
|
23946
|
-
const itemIndex =
|
|
23947
|
-
const
|
|
23948
|
-
const key = isClone
|
|
23949
|
-
? \`clone-\${slideIndex === 0 ? 'start' : 'end'}\`
|
|
23950
|
-
: \`slide-\${itemIndex}\`;
|
|
23593
|
+
const itemIndex = wrapIndex(slideIndex, count);
|
|
23594
|
+
const key = \`slide-\${Math.floor(slideIndex / count)}-\${itemIndex}\`;
|
|
23951
23595
|
return (
|
|
23952
|
-
<div
|
|
23953
|
-
|
|
23954
|
-
className={cn(\`\${P}-slide\`, {
|
|
23955
|
-
[\`\${P}-is-active\`]: !isSlideTransition && itemIndex === activeIndex,
|
|
23956
|
-
})}
|
|
23957
|
-
>
|
|
23958
|
-
<div className={\`\${P}-slider-item\`}>
|
|
23959
|
-
<div className={\`\${P}-img-wrapper\`}>
|
|
23960
|
-
<img
|
|
23961
|
-
className={cn(\`\${P}-slider-image\`, {
|
|
23962
|
-
[\`\${P}-contain\`]: item.image.objectFit === 'contain',
|
|
23963
|
-
[\`\${P}-cover\`]: item.image.objectFit === 'cover'
|
|
23964
|
-
})}
|
|
23965
|
-
src={item.image.assetId} alt={item.image.name ?? ''}
|
|
23966
|
-
draggable={false}
|
|
23967
|
-
/>
|
|
23968
|
-
</div>
|
|
23969
|
-
</div>
|
|
23596
|
+
<div key={key} className={\`\${P}-slide\`}>
|
|
23597
|
+
{renderSlideItem(item)}
|
|
23970
23598
|
</div>
|
|
23971
23599
|
);
|
|
23972
23600
|
})}
|
|
23601
|
+
{isLayered && transitionLayers.map((layer, layerPosition) => (
|
|
23602
|
+
<div
|
|
23603
|
+
key={\`layer-\${layer.key}\`}
|
|
23604
|
+
className={cn(\`\${P}-slide\`, \`\${P}-is-layer\`, { [\`\${P}-is-animated\`]: layer.isAnimated })}
|
|
23605
|
+
style={{ zIndex: layerPosition + 1 }}
|
|
23606
|
+
onAnimationEnd={() => handleLayerEnd(layer.key)}
|
|
23607
|
+
>
|
|
23608
|
+
{renderSlideItem(items[layer.index])}
|
|
23609
|
+
</div>
|
|
23610
|
+
))}
|
|
23973
23611
|
</div>
|
|
23974
23612
|
{isClickTrigger && (
|
|
23975
23613
|
<div
|
|
@@ -24141,7 +23779,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
|
|
|
24141
23779
|
style={{
|
|
24142
23780
|
...titleStyle,
|
|
24143
23781
|
width: TITLE_WIDTH_SETTINGS.sizing === 'auto' ? 'max-content' : scalingValue(TITLE_WIDTH_SETTINGS.width, isEditor),
|
|
24144
|
-
transitionDuration: \`\${Math.round(
|
|
23782
|
+
transitionDuration: \`\${Math.round(transitionDurationMs / 2)}ms\`,
|
|
24145
23783
|
}}
|
|
24146
23784
|
>
|
|
24147
23785
|
<div
|
|
@@ -24175,7 +23813,7 @@ function ArrowIcon({ color, className }: { color: string, className: string }) {
|
|
|
24175
23813
|
</svg>
|
|
24176
23814
|
);
|
|
24177
23815
|
}
|
|
24178
|
-
`,
|
|
23816
|
+
`, B = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
24179
23817
|
import cn from 'classnames';
|
|
24180
23818
|
import { CommonComponentProps } from '../props';
|
|
24181
23819
|
import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
|
|
@@ -24806,7 +24444,7 @@ type TestimonialsSettings = {
|
|
|
24806
24444
|
logoHeight: number;
|
|
24807
24445
|
captionMarginTop: number;
|
|
24808
24446
|
};
|
|
24809
|
-
`,
|
|
24447
|
+
`, z = `import cn from 'classnames';
|
|
24810
24448
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
24811
24449
|
import { CommonComponentProps } from '../props';
|
|
24812
24450
|
import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
|
|
@@ -25302,7 +24940,7 @@ type TestimonialsSettings = {
|
|
|
25302
24940
|
icon?: string | null;
|
|
25303
24941
|
};
|
|
25304
24942
|
};
|
|
25305
|
-
`,
|
|
24943
|
+
`, V = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
25306
24944
|
import type React from 'react';
|
|
25307
24945
|
import { createPortal } from 'react-dom';
|
|
25308
24946
|
import { CommonComponentProps } from '../props';
|
|
@@ -25835,31 +25473,30 @@ export function Waterfall({
|
|
|
25835
25473
|
</>
|
|
25836
25474
|
);
|
|
25837
25475
|
}
|
|
25838
|
-
`,
|
|
25839
|
-
[
|
|
25840
|
-
[
|
|
25841
|
-
[
|
|
25842
|
-
[
|
|
25843
|
-
[
|
|
25844
|
-
[
|
|
25845
|
-
[
|
|
25846
|
-
[
|
|
25847
|
-
[
|
|
25848
|
-
[
|
|
25849
|
-
[
|
|
25850
|
-
[
|
|
25851
|
-
[
|
|
25852
|
-
[
|
|
25853
|
-
[
|
|
25854
|
-
[
|
|
25855
|
-
[
|
|
25856
|
-
[
|
|
25857
|
-
[
|
|
25858
|
-
[
|
|
25859
|
-
[
|
|
25860
|
-
[
|
|
25861
|
-
[e.id]: G
|
|
25476
|
+
`, U = {
|
|
25477
|
+
[y.id]: S,
|
|
25478
|
+
[b.id]: w,
|
|
25479
|
+
[x.id]: C,
|
|
25480
|
+
[P.id]: $,
|
|
25481
|
+
[v.id]: I,
|
|
25482
|
+
[f.id]: E,
|
|
25483
|
+
[h.id]: T,
|
|
25484
|
+
[p.id]: R,
|
|
25485
|
+
[m.id]: M,
|
|
25486
|
+
[g.id]: L,
|
|
25487
|
+
[u.id]: k,
|
|
25488
|
+
[c.id]: A,
|
|
25489
|
+
[d.id]: N,
|
|
25490
|
+
[l.id]: H,
|
|
25491
|
+
[s.id]: O,
|
|
25492
|
+
[a.id]: _,
|
|
25493
|
+
[r.id]: F,
|
|
25494
|
+
[o.id]: W,
|
|
25495
|
+
[i.id]: D,
|
|
25496
|
+
[t.id]: B,
|
|
25497
|
+
[e.id]: z,
|
|
25498
|
+
[n.id]: V
|
|
25862
25499
|
};
|
|
25863
25500
|
export {
|
|
25864
|
-
|
|
25501
|
+
U as componentSources
|
|
25865
25502
|
};
|