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