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

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