@cntrl-site/components 1.0.120-alpha.0 → 1.0.120-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sources.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { W as e, b as t, T as i, h as o, g as r, S as a, P as s, O as l, i as c, a as d, M as u, L as g, e as m, f as p, H as h, j as f, G as v, F as P, d as x, c as b, C as y, k as S, B as C } from "./ChroniclesComponent-CeaJBqKz.mjs";
2
- const w = `import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
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-CQhnb---.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
- `, $ = `import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
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
- `, I = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
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
- `, E = `import { useCallback, useEffect, useMemo, useState } from 'react';
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
- `, T = `import React, { useMemo, useState } from 'react';
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
- `, n = `import { CommonComponentProps } from '../props';
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 { memo, useCallback, useEffect, useLayoutEffect, useRef, useState, useMemo } from 'react';
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
- position: relative;
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-list {
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 .\${P}-item-slide {
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 .\${P}-item-slide {
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 .\${P}-item-slide {
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 .\${P}-item-slide {
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 .\${P}-item-slide {
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 .\${P}-item-slide {
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 wrapSlideIndex(index: number, count: number): number {
6203
- if (count <= 0) return 0;
6204
- return ((index % count) + count) % count;
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
- const LightboxMediaPreloadPool = memo(function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
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 GRID_SLIDE_CLASS = 'cntrl-grid-slide';
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
- return video.closest(\`.\${GRID_SLIDE_PLAYING_CLASS}\`) !== null;
6388
- }
6389
-
6390
- type GridEntrySliderProps = {
6391
- prefix: string;
6392
- slides: React.ReactNode[];
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
- isSliderSlide = false,
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
- isSliderSlide?: boolean;
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 isSliderSlide
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: GRID_SLIDE_VIDEOS, shouldPlay: shouldPlaySlideVideo });
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 titleTextStyle = useMemo(() => ({
7688
- ...omitTextColors(textStylesToCss({
7689
- fontSettings: {
7690
- fontFamily: titleFontFamily,
7691
- fontWeight: titleFontSettings?.fontWeight ?? 400,
7692
- fontStyle: titleFontSettings?.fontStyle ?? 'normal',
7693
- },
7694
- fontSize: titleFontSize ?? 0.01,
7695
- lineHeight: titleLineHeight,
7696
- letterSpacing: titleLetterSpacing ?? 0,
7697
- wordSpacing: titleWordSpacing ?? 0,
7698
- textAppearance: titleTextAppearance,
7699
- color: titleColor,
7700
- }, isEditor)),
7701
- ...getGridTextLeadingVars(titleFontSize, titleLineHeight, P, isEditor),
7702
- } as React.CSSProperties), [
7703
- titleFontFamily, titleFontSettings, titleFontSize, titleLineHeight, titleLetterSpacing,
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 subtitleTextStyle = useMemo(() => ({
7708
- ...omitTextColors(textStylesToCss({
7709
- fontSettings: {
7710
- fontFamily: subtitleFontFamily,
7711
- fontWeight: subtitleFontSettings?.fontWeight ?? 400,
7712
- fontStyle: subtitleFontSettings?.fontStyle ?? 'normal',
7713
- },
7714
- fontSize: subtitleFontSize ?? 0.01,
7715
- lineHeight: subtitleLineHeight,
7716
- letterSpacing: subtitleLetterSpacing ?? 0,
7717
- wordSpacing: subtitleWordSpacing ?? 0,
7718
- textAppearance: subtitleTextAppearance,
7719
- color: subtitleColor,
7720
- }, isEditor)),
7721
- ...getGridTextLeadingVars(subtitleFontSize, subtitleLineHeight, P, isEditor),
7722
- } as React.CSSProperties), [
7723
- subtitleFontFamily, subtitleFontSettings, subtitleFontSize, subtitleLineHeight, subtitleLetterSpacing,
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 lightboxCounterFieldCss = useMemo(() => ({
7728
- ...omitTextColors(textStylesToCss({
7729
- fontSettings: {
7730
- fontFamily: lightboxCounterFontFamily,
7731
- fontWeight: lightboxCounterFontSettings?.fontWeight ?? 400,
7732
- fontStyle: lightboxCounterFontSettings?.fontStyle ?? 'normal',
7733
- },
7734
- fontSize: lightboxCounterFontSize ?? 0.01,
7735
- lineHeight: lightboxCounterLineHeight,
7736
- letterSpacing: lightboxCounterLetterSpacing ?? 0,
7737
- wordSpacing: lightboxCounterWordSpacing ?? 0,
7738
- textAppearance: lightboxCounterTextAppearance,
7739
- color: lightboxCounterColor,
7740
- }, isEditor)),
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 = useMemo(() => buildColorVars(P, {
7479
+ const colorVars = buildColorVars(P, {
7768
7480
  titleColor,
7769
7481
  subtitleColor,
7770
7482
  lightboxCounterColor,
7771
- }, COLOR_VAR_MAP, STATE_KEYS), [P, titleColor, subtitleColor, lightboxCounterColor]);
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 customLayout = customGrid && Array.isArray(customGrid.blocks) && customGrid.blocks.length > 0 ? customGrid : undefined;
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 = useMemo<any[]>(() => (content ?? []).slice(0, resEntriesCount), [content, resEntriesCount]);
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
- const entriesMedia = useMemo(() => cropContent.map((item: any) => {
7792
- const displayItems = getGridDisplayItems(item.gallery);
7793
- const lightboxItemsForEntry = displayItems
7794
- .filter(entry => entry.lightboxMedia)
7795
- .map(entry => entry.lightboxMedia!);
7796
- const lightboxIndexes = displayItems.map(({ lightboxMedia }) => (lightboxMedia
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?.columnsCount ?? 1;
7508
+ const columnsCount = gridLayout.columnsCount;
7814
7509
  const entryWidthScaled = scalingValue(size ?? 0, isEditor);
7815
- const isFitSlider = slider !== 'off' && (customLayout ? isAutoHeight : !isCover);
7510
+ const imageWrapperWidth = entryWidthScaled;
7511
+ const isFitSlider = !isCover && slider !== 'off';
7816
7512
 
7817
7513
  const itemsInLastRow = cropContent.length % columnsCount || columnsCount;
7818
- const isPartialLastRow = !customLayout && itemsInLastRow < columnsCount && cropContent.length > 0;
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 getImageWrapperStyle = (
7827
- entryWidth: string,
7828
- slot?: CustomGridSlot,
7829
- media?: { aspect?: number; isEmpty: boolean },
7830
- ): React.CSSProperties => ({
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 = !customLayout && alignEntries === 'on';
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 = isAutoHeight
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 shouldMeasureEntries = (customLayout?.beat ?? 0) > 0 || isPlacedLayout;
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 getLightboxPortalStyle = (): React.CSSProperties => {
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\` : ''}\${customLayout ? \` \${P}-custom-layout\` : ''}\${isTextOutside ? \` \${P}-text-outside\` : ''}\${isAutoHeight ? \` \${P}-auto-height\` : ''} \${P}-image-align-\${customLayout ? 'top' : align} \${wrapperStateClasses}\`.trim()}
8014
- style={wrapperLayoutStyle}>
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, ...titleTextStyle }}>
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, ...subtitleTextStyle }}>
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, ...titleTextStyle }}>
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, ...subtitleTextStyle }}>
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 = lightboxIndexes[0];
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={entryImageStyle}
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
- <GridEntrySlider
8193
- key={\`\${transition}-\${itemSize}-\${direction}-\${sliderTiming}-\${layoutId}-\${displayItems.length}\`}
8194
- prefix={P}
8195
- isFade={transition === 'fade'}
8196
- direction={direction}
8197
- intervalMs={sliderTiming * 1000}
8198
- slides={displayItems.map(({ displayMedia }, imgIndex) => {
8199
- const lightboxIndex = lightboxIndexes[imgIndex];
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
- <GridMediaItem
8202
- media={displayMedia}
8203
- className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
8204
- style={imageStyle}
8205
- hasLightbox={lightbox === 'on'}
8206
- isSliderSlide
8207
- onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
8208
- ? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
8209
- : undefined}
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, ...titleTextStyle }}
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, ...subtitleTextStyle }}
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={itemStyle}
7886
+ style={gridColumn && !shouldAlignEntries ? { gridColumn } : undefined}
8266
7887
  >
8267
7888
  <div
8268
- ref={(el) => { itemInnerRefs.current[index] = el; }}
8269
- className={\`\${isEditMode
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(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`
8275
- : itemWidthScaled,
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={getLightboxPortalStyle()} data-selection="none">
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?: GridLayoutConfig;
8386
- customGrid?: CustomGridLayout;
7980
+ gridLayout: GridLayoutConfig;
8387
7981
  textBoxWidth: number;
8388
- verticalGap?: number;
8389
- entriesCount?: number;
7982
+ verticalGap: number;
7983
+ entriesCount: number;
8390
7984
  lightbox: 'on' | 'off';
8391
- imageDisplay: 'fit' | 'cover' | {
7985
+ imageDisplay: {
8392
7986
  display: 'fit' | 'cover';
8393
- ratioValue?: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
8394
- reversed?: boolean;
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?: 'on' | 'off';
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
- `, R = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
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
- `, M = `import { CommonComponentProps } from '../props';
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
- `, L = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
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
- `, k = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
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
- `, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
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
- `, N = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
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
- `, H = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
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
- `, O = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
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
- `, _ = `import React, { useMemo, useState } from 'react';
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
- `, F = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
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
- `, W = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
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
- `, D = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
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
- `, B = `import React, { useCallback, useEffect, useRef, useState } from 'react';
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 };
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
- function advanceTrackPosition(
23194
- prev: number,
23195
- step: 1 | -1,
23196
- count: number,
23197
- hasClones: boolean,
23198
- ): { position: number; hitBoundary: boolean } {
23199
- if (!hasClones) {
23200
- return { position: wrapIndex(prev + step, count), hitBoundary: false };
23201
- }
23202
- const next = prev + step;
23203
- if (next >= 0 && next <= count + 1) {
23204
- return { position: next, hitBoundary: false };
23205
- }
23206
- return {
23207
- position: step > 0 ? count + 1 : 0,
23208
- hitBoundary: true,
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
- function getCSS(P: string, isEditor?: boolean): string {
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-active {
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}-contain {
23504
- object-fit: contain;
23107
+ .\${P}-transition-fade .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23108
+ animation: \${P}-fade-in \${transitionDurationMs}ms \${TRANSITION_EASING};
23505
23109
  }
23506
- .\${P}-cover {
23507
- object-fit: cover;
23110
+ .\${P}-transition-reveal .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23111
+ animation: \${P}-reveal-horizontal \${transitionDurationMs}ms ease;
23508
23112
  }
23509
- .\${P}-transition-reveal .\${P}-slide.\${P}-is-active .\${P}-slider-image {
23510
- animation: \${P}-reveal-horizontal \${TRANSITION_DURATION_MS}ms ease;
23113
+ .\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23114
+ animation: \${P}-reveal-vertical \${transitionDurationMs}ms ease;
23511
23115
  }
23512
- .\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-active .\${P}-slider-image {
23513
- animation: \${P}-reveal-vertical \${TRANSITION_DURATION_MS}ms ease;
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,36 @@ 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
- const [trackPosition, setTrackPosition] = useState(hasClones ? 1 : 0);
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
+ const [transitionLayers, setTransitionLayers] = useState<TransitionLayer[]>([{ index: activeIndex, key: 0 }]);
23190
+ const topLayer = transitionLayers[transitionLayers.length - 1];
23191
+ if (isLayered && topLayer.index !== activeIndex) {
23192
+ // Over the limit, drop the oldest layer still animating, never the fully shown bottom one.
23193
+ const kept = transitionLayers.length >= MAX_TRANSITION_LAYERS
23194
+ ? [transitionLayers[0], ...transitionLayers.slice(2)]
23195
+ : transitionLayers;
23196
+ setTransitionLayers([...kept, { index: activeIndex, key: topLayer.key + 1 }]);
23197
+ }
23198
+ const handleLayerEnd = (key: number) => {
23199
+ // A fully shown layer covers everything under it, so those layers are dropped.
23200
+ setTransitionLayers((layers) => {
23201
+ const position = layers.findIndex((layer) => layer.key === key);
23202
+ return position > 0 ? layers.slice(position) : layers;
23203
+ });
23204
+ };
23205
+ const renderSlideItem = (item: Slider20Item | undefined) => item && (
23206
+ <div className={\`\${P}-slider-item\`}>
23207
+ <div className={\`\${P}-img-wrapper\`}>
23208
+ <img
23209
+ className={\`\${P}-slider-image\`}
23210
+ src={item.image.assetId} alt={item.image.name ?? ''}
23211
+ draggable={false}
23212
+ />
23213
+ </div>
23214
+ </div>
23215
+ );
23216
+ const [trackPosition, setTrackPosition] = useState(hasClones ? count : 0);
23572
23217
  const [isMoving, setIsMoving] = useState(false);
23573
23218
  const [skipTransition, setSkipTransition] = useState(false);
23574
23219
  const [isDragging, setIsDragging] = useState(false);
@@ -23578,8 +23223,6 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23578
23223
  const isMovingRef = useRef(false);
23579
23224
  const trackPositionRef = useRef(trackPosition);
23580
23225
  trackPositionRef.current = trackPosition;
23581
- const pendingAnimatedPositionRef = useRef<number | null>(null);
23582
- const pendingStepsRef = useRef(0);
23583
23226
  const trackRef = useRef<HTMLDivElement | null>(null);
23584
23227
  const listRef = useRef<HTMLDivElement | null>(null);
23585
23228
  const dragRef = useRef<DragState | null>(null);
@@ -23590,59 +23233,56 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23590
23233
  setIsMoving(value);
23591
23234
  }, []);
23592
23235
 
23236
+ // Where the track is on screen right now, mid-transition included, in slide units.
23237
+ const readVisualPosition = useCallback((): number => {
23238
+ const list = listRef.current;
23239
+ const size = list ? readSlideSizePx(list, isHorizontal) : 0;
23240
+ if (!list || size <= 0) return trackPositionRef.current;
23241
+ // Rounded so a settled track reads as a whole position.
23242
+ return Math.round((-readTrackTranslatePx(list, isHorizontal) / size) * 1000) / 1000;
23243
+ }, [isHorizontal]);
23244
+
23245
+ // Moves the track to \`target\` from wherever it is now. When the visual position is outside
23246
+ // the middle copy, it is first teleported by a whole copy (no visible change), so rapid
23247
+ // navigation never runs off the rendered slides and never snaps mid-animation.
23248
+ const moveTrack = useCallback((getTarget: (visual: number, shift: number) => number) => {
23249
+ const visual = readVisualPosition();
23250
+ const shift = getMiddleCopyShift(visual, count);
23251
+ const target = getTarget(visual - shift, shift);
23252
+ const list = listRef.current;
23253
+ if (shift !== 0 && list) {
23254
+ const transitionValue = list.style.transition;
23255
+ list.style.transition = 'none';
23256
+ list.style.transform = getTrackTranslate(visual - shift, 0, isHorizontal);
23257
+ void list.offsetWidth;
23258
+ list.style.transition = transitionValue && transitionValue !== 'none'
23259
+ ? transitionValue
23260
+ : \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`;
23261
+ list.style.transform = getTrackTranslate(target, 0, isHorizontal);
23262
+ }
23263
+ trackPositionRef.current = target;
23264
+ setActiveIndex(wrapIndex(target, count));
23265
+ setSkipTransition(false);
23266
+ setTrackPosition(target);
23267
+ }, [count, isHorizontal, readVisualPosition, transitionDurationMs]);
23268
+
23593
23269
  const goBySteps = useCallback((steps: number) => {
23594
23270
  if (count < 2 || steps === 0) return;
23595
- const direction = steps > 0 ? 1 : -1;
23596
- const total = Math.abs(steps);
23597
23271
  setAnimateDots(true);
23598
23272
  setMoving(true);
23599
23273
  if (!isSlideTransition) {
23600
23274
  setActiveIndex((prev) => wrapIndex(prev + steps, count));
23601
23275
  return;
23602
23276
  }
23603
-
23604
- let position = trackPositionRef.current;
23605
- const isOnClone = hasClones && (position === 0 || position === count + 1);
23606
- const cloneSnapPosition = isOnClone ? activeIndex + 1 : null;
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
- }
23622
-
23623
- const appliedSteps = total - remaining;
23624
- if (appliedSteps > 0) {
23625
- setActiveIndex((prev) => wrapIndex(prev + appliedSteps * direction, count));
23626
- }
23627
-
23628
- trackPositionRef.current = position;
23629
-
23630
- if (cloneSnapPosition !== null) {
23631
- trackPositionRef.current = cloneSnapPosition;
23632
- if (position === cloneSnapPosition) {
23633
- setSkipTransition(true);
23634
- setTrackPosition(position);
23635
- return;
23636
- }
23637
- pendingAnimatedPositionRef.current = position;
23638
- setSkipTransition(true);
23639
- setTrackPosition(cloneSnapPosition);
23640
- return;
23641
- }
23642
-
23643
- setSkipTransition(false);
23644
- setTrackPosition(position);
23645
- }, [activeIndex, count, hasClones, isSlideTransition, setMoving]);
23277
+ moveTrack((visual, shift) => {
23278
+ // Continue from the previous target so quick clicks add up, but never get more than
23279
+ // count - 1 slides away from what is on screen, which keeps the target inside the copies.
23280
+ const previousTarget = trackPositionRef.current - shift;
23281
+ const base = Math.abs(previousTarget - visual) < count ? previousTarget : Math.round(visual);
23282
+ const maxDistance = count - 1;
23283
+ return Math.min(Math.max(base + steps, Math.ceil(visual - maxDistance)), Math.floor(visual + maxDistance));
23284
+ });
23285
+ }, [count, isSlideTransition, moveTrack, setMoving]);
23646
23286
 
23647
23287
  const goBy = useCallback((step: 1 | -1) => {
23648
23288
  goBySteps(step);
@@ -23654,58 +23294,37 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23654
23294
  if (target === activeIndex && !isMovingRef.current) return;
23655
23295
  setAnimateDots(true);
23656
23296
  setMoving(true);
23657
- setActiveIndex(target);
23658
- if (isSlideTransition) {
23659
- const position = target + (hasClones ? 1 : 0);
23660
- pendingAnimatedPositionRef.current = null;
23661
- pendingStepsRef.current = 0;
23662
- trackPositionRef.current = position;
23663
- setSkipTransition(false);
23664
- setTrackPosition(position);
23297
+ if (!isSlideTransition) {
23298
+ setActiveIndex(target);
23299
+ return;
23665
23300
  }
23666
- }, [activeIndex, count, hasClones, isSlideTransition, setMoving]);
23301
+ moveTrack(() => count + target);
23302
+ }, [activeIndex, count, isSlideTransition, moveTrack, setMoving]);
23667
23303
 
23668
23304
  useEffect(() => {
23669
23305
  if (!isMoving) return;
23670
23306
  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
23307
  setMoving(false);
23678
- }, TRANSITION_DURATION_MS);
23308
+ if (!hasClones) return;
23309
+ const shift = getMiddleCopyShift(trackPosition, count);
23310
+ if (shift === 0) return;
23311
+ setSkipTransition(true);
23312
+ setTrackPosition(trackPosition - shift);
23313
+ }, transitionDurationMs);
23679
23314
  return () => window.clearTimeout(timeoutId);
23680
- }, [activeIndex, count, hasClones, isMoving, setMoving, trackPosition]);
23315
+ }, [count, hasClones, isMoving, setMoving, trackPosition, transitionDurationMs]);
23681
23316
 
23682
23317
  useEffect(() => {
23683
23318
  if (!skipTransition) return;
23684
23319
  let innerId = 0;
23685
23320
  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
- });
23321
+ innerId = requestAnimationFrame(() => setSkipTransition(false));
23703
23322
  });
23704
23323
  return () => {
23705
23324
  cancelAnimationFrame(outerId);
23706
23325
  cancelAnimationFrame(innerId);
23707
23326
  };
23708
- }, [goBySteps, setMoving, skipTransition]);
23327
+ }, [skipTransition]);
23709
23328
 
23710
23329
  const structureKey = \`\${hasClones}:\${count}\`;
23711
23330
  const prevStructureKeyRef = useRef(structureKey);
@@ -23719,7 +23338,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23719
23338
  setDragOffset(0);
23720
23339
  setActiveIndex(nextIndex);
23721
23340
  setSkipTransition(true);
23722
- setTrackPosition(nextIndex + (hasClones ? 1 : 0));
23341
+ setTrackPosition(nextIndex + (hasClones ? count : 0));
23723
23342
  }, [activeIndex, count, hasClones, structureKey]);
23724
23343
 
23725
23344
  useEffect(() => {
@@ -23798,31 +23417,23 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23798
23417
  if (!isDragTrigger || count < 2 || !track) return;
23799
23418
  if (event.pointerType === 'mouse' && event.button !== 0) return;
23800
23419
 
23801
- pendingAnimatedPositionRef.current = null;
23802
- pendingStepsRef.current = 0;
23803
-
23804
23420
  if (isMovingRef.current) {
23805
23421
  setMoving(false);
23806
23422
  }
23807
23423
 
23424
+ // Freeze the track where it is on screen and drag from there.
23808
23425
  let baseOffset = 0;
23809
23426
  const list = listRef.current;
23810
23427
  if (isSlideTransition && list) {
23811
- const size = isHorizontal ? list.offsetWidth : list.offsetHeight;
23428
+ const size = readSlideSizePx(list, isHorizontal);
23812
23429
  if (size > 0) {
23813
- const currentPx = readTrackTranslatePx(list, isHorizontal);
23814
- let syncedPosition = trackPositionRef.current;
23815
- const isOnClone = hasClones && (syncedPosition === 0 || syncedPosition === count + 1);
23816
-
23817
- if (isOnClone) {
23818
- syncedPosition = activeIndex + 1;
23819
- trackPositionRef.current = syncedPosition;
23820
- setSkipTransition(true);
23821
- setTrackPosition(syncedPosition);
23822
- baseOffset = 0;
23823
- } else {
23824
- baseOffset = currentPx + syncedPosition * size;
23825
- }
23430
+ const visual = readVisualPosition();
23431
+ const middleVisual = hasClones ? visual - getMiddleCopyShift(visual, count) : visual;
23432
+ const basePosition = Math.round(middleVisual);
23433
+ baseOffset = (basePosition - middleVisual) * size;
23434
+ trackPositionRef.current = basePosition;
23435
+ setSkipTransition(true);
23436
+ setTrackPosition(basePosition);
23826
23437
  setDragOffset(baseOffset);
23827
23438
  }
23828
23439
  }
@@ -23888,19 +23499,19 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23888
23499
  finishDrag(event);
23889
23500
  };
23890
23501
 
23891
- const trackTranslate = isHorizontal
23892
- ? \`translate3d(calc(\${-trackPosition * 100}% + \${dragOffset}px), 0, 0)\`
23893
- : \`translate3d(0, calc(\${-trackPosition * 100}% + \${dragOffset}px), 0)\`;
23894
- const slides = hasClones ? [items[count - 1], ...items, items[0]] : items;
23502
+ const trackTranslate = getTrackTranslate(trackPosition, dragOffset, isHorizontal);
23503
+ const slides = hasClones ? Array.from({ length: TRACK_COPIES }, () => items).flat() : items;
23895
23504
 
23896
23505
  return (
23897
23506
  <>
23898
- <style dangerouslySetInnerHTML={{ __html: getCSS(P, isEditor) }} />
23507
+ <style dangerouslySetInnerHTML={{ __html: getCSS(P, transitionDurationMs, isEditor) }} />
23899
23508
  <div
23900
23509
  className={cn(\`\${P}-wrapper\`, {
23901
- [\`\${P}-transition-reveal\`]: transition === 'reveal',
23902
- [\`\${P}-transition-reveal-vertical\`]: transition === 'reveal' && !isHorizontal,
23510
+ [\`\${P}-transition-fade\`]: transition === 'fade in',
23511
+ [\`\${P}-transition-reveal\`]: isReveal,
23512
+ [\`\${P}-transition-reveal-vertical\`]: isReveal && !isHorizontal,
23903
23513
  })}
23514
+ data-active-index={activeIndex}
23904
23515
  onMouseEnter={() => setIsHovered(true)}
23905
23516
  onMouseLeave={() => setIsHovered(false)}
23906
23517
  >
@@ -23916,6 +23527,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23916
23527
  [\`\${P}-track-draggable\`]: isDragTrigger,
23917
23528
  [\`\${P}-track-draggable-vertical\`]: isDragTrigger && !isHorizontal,
23918
23529
  })}
23530
+ style={trackRadiusStyle}
23919
23531
  onPointerDown={handlePointerDown}
23920
23532
  onPointerMove={handlePointerMove}
23921
23533
  onPointerUp={handlePointerUp}
@@ -23938,38 +23550,29 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23938
23550
  transform: trackTranslate,
23939
23551
  transition: isDragging || skipTransition
23940
23552
  ? 'none'
23941
- : \`transform \${TRANSITION_DURATION_MS}ms \${TRANSITION_EASING}\`,
23553
+ : \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`,
23942
23554
  }
23943
23555
  : undefined}
23944
23556
  >
23945
23557
  {slides.map((item, slideIndex) => {
23946
- const itemIndex = hasClones ? wrapIndex(slideIndex - 1, count) : slideIndex;
23947
- const isClone = hasClones && (slideIndex === 0 || slideIndex === count + 1);
23948
- const key = isClone
23949
- ? \`clone-\${slideIndex === 0 ? 'start' : 'end'}\`
23950
- : \`slide-\${itemIndex}\`;
23558
+ const itemIndex = wrapIndex(slideIndex, count);
23559
+ const key = \`slide-\${Math.floor(slideIndex / count)}-\${itemIndex}\`;
23951
23560
  return (
23952
- <div
23953
- key={key}
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>
23561
+ <div key={key} className={\`\${P}-slide\`}>
23562
+ {renderSlideItem(item)}
23970
23563
  </div>
23971
23564
  );
23972
23565
  })}
23566
+ {isLayered && transitionLayers.map((layer, layerPosition) => (
23567
+ <div
23568
+ key={\`layer-\${layer.key}\`}
23569
+ className={cn(\`\${P}-slide\`, \`\${P}-is-layer\`)}
23570
+ style={{ zIndex: layerPosition + 1 }}
23571
+ onAnimationEnd={() => handleLayerEnd(layer.key)}
23572
+ >
23573
+ {renderSlideItem(items[layer.index])}
23574
+ </div>
23575
+ ))}
23973
23576
  </div>
23974
23577
  {isClickTrigger && (
23975
23578
  <div
@@ -24141,7 +23744,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
24141
23744
  style={{
24142
23745
  ...titleStyle,
24143
23746
  width: TITLE_WIDTH_SETTINGS.sizing === 'auto' ? 'max-content' : scalingValue(TITLE_WIDTH_SETTINGS.width, isEditor),
24144
- transitionDuration: \`\${Math.round(TRANSITION_DURATION_MS / 2)}ms\`,
23747
+ transitionDuration: \`\${Math.round(transitionDurationMs / 2)}ms\`,
24145
23748
  }}
24146
23749
  >
24147
23750
  <div
@@ -24175,7 +23778,7 @@ function ArrowIcon({ color, className }: { color: string, className: string }) {
24175
23778
  </svg>
24176
23779
  );
24177
23780
  }
24178
- `, z = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
23781
+ `, B = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
24179
23782
  import cn from 'classnames';
24180
23783
  import { CommonComponentProps } from '../props';
24181
23784
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
@@ -24806,7 +24409,7 @@ type TestimonialsSettings = {
24806
24409
  logoHeight: number;
24807
24410
  captionMarginTop: number;
24808
24411
  };
24809
- `, V = `import cn from 'classnames';
24412
+ `, z = `import cn from 'classnames';
24810
24413
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
24811
24414
  import { CommonComponentProps } from '../props';
24812
24415
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
@@ -25302,7 +24905,7 @@ type TestimonialsSettings = {
25302
24905
  icon?: string | null;
25303
24906
  };
25304
24907
  };
25305
- `, G = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
24908
+ `, V = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
25306
24909
  import type React from 'react';
25307
24910
  import { createPortal } from 'react-dom';
25308
24911
  import { CommonComponentProps } from '../props';
@@ -25835,31 +25438,30 @@ export function Waterfall({
25835
25438
  </>
25836
25439
  );
25837
25440
  }
25838
- `, K = {
25839
- [C.id]: w,
25840
- [S.id]: $,
25841
- [y.id]: I,
25842
- [b.id]: n,
25843
- [x.id]: E,
25844
- [P.id]: T,
25845
- [v.id]: n,
25846
- [f.id]: R,
25847
- [h.id]: M,
25848
- [p.id]: L,
25849
- [m.id]: k,
25850
- [g.id]: A,
25851
- [u.id]: N,
25852
- [d.id]: H,
25853
- [c.id]: O,
25854
- [l.id]: _,
25855
- [s.id]: F,
25856
- [a.id]: W,
25857
- [r.id]: D,
25858
- [o.id]: B,
25859
- [i.id]: z,
25860
- [t.id]: V,
25861
- [e.id]: G
25441
+ `, U = {
25442
+ [y.id]: S,
25443
+ [b.id]: w,
25444
+ [x.id]: C,
25445
+ [P.id]: $,
25446
+ [v.id]: I,
25447
+ [f.id]: E,
25448
+ [h.id]: T,
25449
+ [p.id]: R,
25450
+ [m.id]: M,
25451
+ [g.id]: L,
25452
+ [u.id]: k,
25453
+ [c.id]: A,
25454
+ [d.id]: N,
25455
+ [l.id]: H,
25456
+ [s.id]: O,
25457
+ [a.id]: _,
25458
+ [r.id]: F,
25459
+ [o.id]: W,
25460
+ [i.id]: D,
25461
+ [t.id]: B,
25462
+ [e.id]: z,
25463
+ [n.id]: V
25862
25464
  };
25863
25465
  export {
25864
- K as componentSources
25466
+ U as componentSources
25865
25467
  };