@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.mjs CHANGED
@@ -1,5 +1,5 @@
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';
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';
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
- `, w = `import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
2732
+ `, $ = `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
- `, C = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3779
+ `, I = `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
- `, $ = `import { useCallback, useEffect, useMemo, useState } from 'react';
4308
+ `, E = `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
- `, I = `import React, { useMemo, useState } from 'react';
5052
+ `, T = `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,9 +5687,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
5687
5687
  };
5688
5688
 
5689
5689
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
5690
- `, E = `import { Splide, SplideSlide } from '@splidejs/react-splide';
5691
- import '@splidejs/react-splide/css/core';
5692
- import { CommonComponentProps } from '../props';
5690
+ `, n = `import { CommonComponentProps } from '../props';
5693
5691
  import { EmbedMediaFrame, getEmbedAspect, getEmbedPlayback, isEmbedMedia } from '../utils/index';
5694
5692
  import {
5695
5693
  buildColorVars,
@@ -5699,7 +5697,7 @@ import {
5699
5697
  useLazyVideos,
5700
5698
  useScopedStyles,
5701
5699
  } from '../utils/index';
5702
- import { useCallback, useEffect, useLayoutEffect, useRef, useState, useMemo } from 'react';
5700
+ import { memo, useCallback, useEffect, useLayoutEffect, useRef, useState, useMemo } from 'react';
5703
5701
  import { createPortal } from 'react-dom';
5704
5702
  import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss';
5705
5703
  import { SvgImage } from '../helpers/SvgImage/SvgImage';
@@ -5816,15 +5814,23 @@ function getCSS(P: string): string {
5816
5814
  width: 100%;
5817
5815
  overflow: hidden;
5818
5816
  }
5819
- .\${P}-item-slider .splide__track {
5820
- overflow: hidden;
5821
- }
5822
5817
  .\${P}-item-image-link {
5823
5818
  width: 100%;
5824
5819
  display: flex;
5825
5820
  flex-direction: column;
5826
5821
  align-items: center;
5827
5822
  }
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
+ }
5828
5834
  .\${P}-item-text-link {
5829
5835
  display: flex;
5830
5836
  flex-direction: column;
@@ -5845,18 +5851,47 @@ function getCSS(P: string): string {
5845
5851
  display: block;
5846
5852
  max-width: 100%;
5847
5853
  }
5848
- .\${P}-item-slider,
5849
- .\${P}-item-slider .splide__track,
5850
- .\${P}-item-slider .splide__list,
5851
- .\${P}-item-slider .splide__slide {
5854
+ .\${P}-item-slider {
5855
+ position: relative;
5852
5856
  width: 100%;
5853
5857
  height: 100%;
5858
+ overflow: hidden;
5854
5859
  }
5855
- .\${P}-item-slider .splide__slide {
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%;
5856
5880
  display: flex;
5857
5881
  justify-content: center;
5858
5882
  align-items: center;
5859
5883
  }
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
+ }
5860
5895
  .\${P}-item-title {
5861
5896
  white-space: normal;
5862
5897
  overflow-wrap: anywhere;
@@ -6003,13 +6038,13 @@ function getCSS(P: string): string {
6003
6038
  .\${P}-image-align-bottom .\${P}-item-image-wrapper:not(.\${P}-item-image-wrapper-fit-slider) {
6004
6039
  align-items: flex-end;
6005
6040
  }
6006
- .\${P}-image-align-top .\${P}-item-slider .splide__slide {
6041
+ .\${P}-image-align-top .\${P}-item-slider .\${P}-item-slide {
6007
6042
  align-items: flex-start;
6008
6043
  }
6009
- .\${P}-image-align-center .\${P}-item-slider .splide__slide {
6044
+ .\${P}-image-align-center .\${P}-item-slider .\${P}-item-slide {
6010
6045
  align-items: center;
6011
6046
  }
6012
- .\${P}-image-align-bottom .\${P}-item-slider .splide__slide {
6047
+ .\${P}-image-align-bottom .\${P}-item-slider .\${P}-item-slide {
6013
6048
  align-items: flex-end;
6014
6049
  }
6015
6050
  .\${P}-align-entries .\${P}-item {
@@ -6090,13 +6125,13 @@ function getCSS(P: string): string {
6090
6125
  .\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-image-wrapper:not(.\${P}-item-image-wrapper-fit-slider) {
6091
6126
  align-items: flex-end;
6092
6127
  }
6093
- .\${P}-image-align-top.\${P}-align-entries .\${P}-item-slider .splide__slide {
6128
+ .\${P}-image-align-top.\${P}-align-entries .\${P}-item-slider .\${P}-item-slide {
6094
6129
  align-items: flex-start;
6095
6130
  }
6096
- .\${P}-image-align-center.\${P}-align-entries .\${P}-item-slider .splide__slide {
6131
+ .\${P}-image-align-center.\${P}-align-entries .\${P}-item-slider .\${P}-item-slide {
6097
6132
  align-items: center;
6098
6133
  }
6099
- .\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-slider .splide__slide {
6134
+ .\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-slider .\${P}-item-slide {
6100
6135
  align-items: flex-end;
6101
6136
  }
6102
6137
  .\${P}-image-align-top.\${P}-align-entries .\${P}-item-image-link {
@@ -6164,27 +6199,9 @@ function pickRandomSlideDirection(): 'ltr' | 'ttb' {
6164
6199
  return Math.random() < 0.5 ? 'ltr' : 'ttb';
6165
6200
  }
6166
6201
 
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
- });
6202
+ function wrapSlideIndex(index: number, count: number): number {
6203
+ if (count <= 0) return 0;
6204
+ return ((index % count) + count) % count;
6188
6205
  }
6189
6206
 
6190
6207
  type GridProps = {
@@ -6224,6 +6241,8 @@ type LightboxProps = {
6224
6241
 
6225
6242
  const LIGHTBOX_ANIM_MS = 500;
6226
6243
  const SLIDER_TRANSITION_MS = 750;
6244
+ const SLIDER_EASING = 'cubic-bezier(0.25, 1, 0.5, 1)';
6245
+ const SLIDER_DEFAULT_INTERVAL_MS = 5000;
6227
6246
  const LIGHTBOX_EASING = 'cubic-bezier(0.22, 1, 0.36, 1)';
6228
6247
  const SWIPE_CLOSE_THRESHOLD = 72;
6229
6248
  const SWIPE_NAV_THRESHOLD = 50;
@@ -6313,7 +6332,7 @@ function collectGridLightboxMedia(content: any[]): GridMedia[] {
6313
6332
  return result;
6314
6333
  }
6315
6334
 
6316
- function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
6335
+ const LightboxMediaPreloadPool = memo(function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
6317
6336
  const [pool, setPool] = useState<HTMLDivElement | null>(null);
6318
6337
  useLazyVideos(pool, { preload: 'metadata' });
6319
6338
  // an embed's player is only ever framed where it shows
@@ -6352,7 +6371,7 @@ function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
6352
6371
  ))}
6353
6372
  </div>
6354
6373
  );
6355
- }
6374
+ });
6356
6375
 
6357
6376
  function unloadVideoElement(video: HTMLVideoElement) {
6358
6377
  video.pause();
@@ -6360,15 +6379,121 @@ function unloadVideoElement(video: HTMLVideoElement) {
6360
6379
  video.load();
6361
6380
  }
6362
6381
 
6363
- const SPLIDE_SLIDE_VIDEOS = '.splide__slide video';
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\`;
6364
6385
 
6365
6386
  function shouldPlaySlideVideo(video: HTMLVideoElement): boolean {
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;
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
+ );
6372
6497
  }
6373
6498
 
6374
6499
  function GridMediaItem({
@@ -6376,7 +6501,7 @@ function GridMediaItem({
6376
6501
  className,
6377
6502
  style,
6378
6503
  hasLightbox,
6379
- isSplideSlide = false,
6504
+ isSliderSlide = false,
6380
6505
  onMediaClick,
6381
6506
  }: {
6382
6507
  media: GridMedia;
@@ -6384,7 +6509,7 @@ function GridMediaItem({
6384
6509
  style: React.CSSProperties;
6385
6510
  /** An embed then plays here as a silent loop, and as it was set to in the lightbox. */
6386
6511
  hasLightbox: boolean;
6387
- isSplideSlide?: boolean;
6512
+ isSliderSlide?: boolean;
6388
6513
  onMediaClick?: (e: React.MouseEvent<HTMLElement>) => void;
6389
6514
  }) {
6390
6515
  if (isEmbedMedia(media)) {
@@ -6416,7 +6541,7 @@ function GridMediaItem({
6416
6541
  playsInline: true,
6417
6542
  onClick: onMediaClick,
6418
6543
  };
6419
- return isSplideSlide
6544
+ return isSliderSlide
6420
6545
  ? <video {...videoProps} preload='none' />
6421
6546
  : <LazyVideo {...videoProps} autoPlay />;
6422
6547
  }
@@ -6445,7 +6570,7 @@ function GridItemMediaWrapper({
6445
6570
  children: React.ReactNode;
6446
6571
  }) {
6447
6572
  const [wrapper, setWrapper] = useState<HTMLDivElement | null>(null);
6448
- useLazyVideos(wrapper, { autoPlay: true, selector: SPLIDE_SLIDE_VIDEOS, shouldPlay: shouldPlaySlideVideo });
6573
+ useLazyVideos(wrapper, { autoPlay: true, selector: GRID_SLIDE_VIDEOS, shouldPlay: shouldPlaySlideVideo });
6449
6574
 
6450
6575
  return (
6451
6576
  <div ref={setWrapper} className={className} style={style}>
@@ -7346,11 +7471,169 @@ function resolveLightboxImageDisplay(
7346
7471
  return value?.display === 'cover' ? 'cover' : 'fit';
7347
7472
  }
7348
7473
 
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
+
7349
7631
  export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, metadata, activeEvent, layoutId, portalId }: GridProps) {
7350
7632
  const { prefix: P } = useScopedStyles();
7351
7633
  const {
7352
7634
  type = 'a',
7353
7635
  gridLayout,
7636
+ customGrid,
7354
7637
  textBoxWidth = 100,
7355
7638
  verticalGap,
7356
7639
  entriesCount,
@@ -7398,62 +7681,69 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7398
7681
  hover = 'none',
7399
7682
  alignEntries = 'off',
7400
7683
  align = 'top',
7684
+ textGrowth = 'inside',
7401
7685
  } = settings;
7402
7686
 
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;
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
+ ]);
7420
7706
 
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;
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
+ ]);
7438
7726
 
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,
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)),
7455
7741
  ...getGridTextLeadingVars(lightboxCounterFontSize, lightboxCounterLineHeight, P, isEditor),
7456
- } as React.CSSProperties;
7742
+ } as React.CSSProperties), [
7743
+ lightboxCounterFontFamily, lightboxCounterFontSettings, lightboxCounterFontSize, lightboxCounterLineHeight,
7744
+ lightboxCounterLetterSpacing, lightboxCounterWordSpacing, lightboxCounterTextAppearance, lightboxCounterColor,
7745
+ isEditor, P,
7746
+ ]);
7457
7747
 
7458
7748
  const titleTextClassName = getGridTextClassName(
7459
7749
  titleFontSize,
@@ -7467,8 +7757,6 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7467
7757
  \`\${P}-item-subtitle\`,
7468
7758
  \`\${P}-text-tight-leading\`,
7469
7759
  );
7470
- const titleTextLeadingVars = getGridTextLeadingVars(titleFontSize, titleLineHeight, P, isEditor);
7471
- const subtitleTextLeadingVars = getGridTextLeadingVars(subtitleFontSize, subtitleLineHeight, P, isEditor);
7472
7760
  const lightboxCounterClassName = getGridTextClassName(
7473
7761
  lightboxCounterFontSize,
7474
7762
  lightboxCounterLineHeight,
@@ -7476,42 +7764,58 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7476
7764
  \`\${P}-text-tight-leading\`,
7477
7765
  );
7478
7766
 
7479
- const colorVars = buildColorVars(P, {
7767
+ const colorVars = useMemo(() => buildColorVars(P, {
7480
7768
  titleColor,
7481
7769
  subtitleColor,
7482
7770
  lightboxCounterColor,
7483
- }, COLOR_VAR_MAP, STATE_KEYS);
7771
+ }, COLOR_VAR_MAP, STATE_KEYS), [P, titleColor, subtitleColor, lightboxCounterColor]);
7484
7772
 
7485
7773
  const stateClass = activeEvent && activeEvent !== 'default' ? \`\${P}-state-\${activeEvent}\` : '';
7486
7774
  const showTextOnHover = showText === 'on hover' && (!isEditor || isPreviewMode);
7487
7775
  const hoverEffectClass = hover !== 'none' && (!isEditor || isPreviewMode) ? \` \${P}-hover-\${hover}\` : '';
7488
7776
  const wrapperStateClasses = \`\${stateClass}\${showTextOnHover ? \` \${P}-show-text-hover\` : ''}\${hoverEffectClass}\`.trim();
7489
7777
 
7490
- const resEntriesCount = entriesCount === 0 ? Infinity : entriesCount;
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[]>([]);
7491
7785
 
7492
- const cropContent = (content ?? []).slice(0, resEntriesCount);
7786
+ const cropContent = useMemo<any[]>(() => (content ?? []).slice(0, resEntriesCount), [content, resEntriesCount]);
7493
7787
  const lightboxMediaToPreload = useMemo(
7494
7788
  () => (lightbox === 'on' ? collectGridLightboxMedia(cropContent) : []),
7495
7789
  [cropContent, lightbox],
7496
7790
  );
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;
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;
7503
7808
  const [rW, rH] = ratioValue.split(':').map(Number);
7504
7809
  const effW = ratioReversed ? rH : rW;
7505
7810
  const effH = ratioReversed ? rW : rH;
7506
7811
  const aspectRatio = \`\${effW} / \${effH}\`;
7507
7812
 
7508
- const columnsCount = gridLayout.columnsCount;
7813
+ const columnsCount = gridLayout?.columnsCount ?? 1;
7509
7814
  const entryWidthScaled = scalingValue(size ?? 0, isEditor);
7510
- const imageWrapperWidth = entryWidthScaled;
7511
- const isFitSlider = !isCover && slider !== 'off';
7815
+ const isFitSlider = slider !== 'off' && (customLayout ? isAutoHeight : !isCover);
7512
7816
 
7513
7817
  const itemsInLastRow = cropContent.length % columnsCount || columnsCount;
7514
- const isPartialLastRow = itemsInLastRow < columnsCount && cropContent.length > 0;
7818
+ const isPartialLastRow = !customLayout && itemsInLastRow < columnsCount && cropContent.length > 0;
7515
7819
  const lastRowStartIndex = cropContent.length - itemsInLastRow;
7516
7820
  const lastRowStartColumn = isPartialLastRow
7517
7821
  ? Math.floor((columnsCount - itemsInLastRow) / 2) + 1
@@ -7519,24 +7823,46 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7519
7823
 
7520
7824
  const imageBorderRadius = imageCorners ? scalingValue(imageCorners, isEditor) : undefined;
7521
7825
 
7522
- const imageWrapperStyle: React.CSSProperties = {
7523
- width: imageWrapperWidth,
7524
- ...(isCover
7525
- ? { aspectRatio, height: 'auto', overflow: 'hidden' }
7526
- : { height: 'auto' }),
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' }),
7527
7846
  ...(imageBorderRadius ? { borderRadius: imageBorderRadius, overflow: 'hidden' } : {}),
7528
- };
7847
+ });
7529
7848
 
7530
7849
  const imageWrapperClassName = \`\${P}-item-image-wrapper\${isFitSlider ? \` \${P}-item-image-wrapper-fit-slider\` : ''}\`.trim();
7531
7850
  const isTextBeforeImage = type === 'd' || type === 'e' || type === 'f';
7532
- const shouldAlignEntries = alignEntries === 'on';
7533
- const textBoxWidthStyle = \`calc(\${scalingValue(size ?? 0, isEditor)} * (\${textBoxWidth} / 100))\`;
7534
- const controlWidthStyle = scalingValue(size * textBoxWidth / 100, isEditor);
7851
+ const shouldAlignEntries = !customLayout && alignEntries === 'on';
7535
7852
 
7536
7853
  const imageRadiusStyle = imageBorderRadius
7537
7854
  ? { borderRadius: imageBorderRadius, [MEDIA_RADIUS_VAR]: imageBorderRadius } as React.CSSProperties
7538
7855
  : {};
7539
- const imageStyle: React.CSSProperties = isCover
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
7540
7866
  ? {
7541
7867
  objectFit: 'cover',
7542
7868
  pointerEvents: 'auto',
@@ -7551,31 +7877,92 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7551
7877
  width: 'auto',
7552
7878
  height: 'auto',
7553
7879
  maxWidth: '100%',
7880
+ ...(customLayout ? { maxHeight: '100%' } : {}),
7554
7881
  ...imageRadiusStyle,
7555
7882
  };
7556
7883
 
7557
- const [containerWidth, setContainerWidth] = useState(0);
7558
- const containerRef = useRef<HTMLDivElement>(null);
7559
-
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);
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));
7575
7907
  return () => ro.disconnect();
7576
- }, []);
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
+ };
7577
7962
 
7578
- const lightboxPortalStyle = (() => {
7963
+ const containerRef = useRef<HTMLDivElement>(null);
7964
+
7965
+ const getLightboxPortalStyle = (): React.CSSProperties => {
7579
7966
  const style: Record<string, string> = { ...(colorVars as Record<string, string>) };
7580
7967
  const articleWidth = containerRef.current
7581
7968
  ? getComputedStyle(containerRef.current).getPropertyValue('--cntrl-article-width').trim()
@@ -7584,7 +7971,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7584
7971
  style['--cntrl-article-width'] = articleWidth;
7585
7972
  }
7586
7973
  return style as React.CSSProperties;
7587
- })();
7974
+ };
7588
7975
 
7589
7976
  const [lightboxOpen, setLightboxOpen] = useState(false);
7590
7977
  const [lightboxItems, setLightboxItems] = useState<GridMedia[]>([]);
@@ -7623,16 +8010,8 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7623
8010
  <div style={colorVars}>
7624
8011
  <div
7625
8012
  ref={containerRef}
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
- }}>
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}>
7636
8015
  {cropContent.map((item: any, index: number) => {
7637
8016
  const hasTitle = hasText(item.title);
7638
8017
  const hasSubtitle = hasText(item.subtitle);
@@ -7642,11 +8021,40 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7642
8021
  const gridColumn = isPartialLastRow && index >= lastRowStartIndex
7643
8022
  ? \`\${lastRowStartColumn + (index - lastRowStartIndex)}\`
7644
8023
  : 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;
7645
8053
 
7646
8054
  const typeCTextBlock = isTextBeforeImage ? (
7647
8055
  <div className={\`\${P}-item-text-block\`}>
7648
8056
  {hasTitle && (
7649
- <p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleFieldCss, ...titleTextLeadingVars }}>
8057
+ <p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleTextStyle }}>
7650
8058
  {item.title}
7651
8059
  </p>
7652
8060
  )}
@@ -7661,7 +8069,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7661
8069
  />
7662
8070
  )}
7663
8071
  {hasSubtitle && (
7664
- <p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleFieldCss, ...subtitleTextLeadingVars }}>
8072
+ <p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleTextStyle }}>
7665
8073
  {item.subtitle}
7666
8074
  </p>
7667
8075
  )}
@@ -7691,7 +8099,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7691
8099
  />
7692
8100
  )}
7693
8101
  {hasTitle && (
7694
- <p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleFieldCss, ...titleTextLeadingVars }}>
8102
+ <p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleTextStyle }}>
7695
8103
  {item.title}
7696
8104
  </p>
7697
8105
  )}
@@ -7721,7 +8129,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7721
8129
  />
7722
8130
  )}
7723
8131
  {hasSubtitle && (
7724
- <p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleFieldCss, ...subtitleTextLeadingVars }}>
8132
+ <p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleTextStyle }}>
7725
8133
  {item.subtitle}
7726
8134
  </p>
7727
8135
  )}
@@ -7745,11 +8153,6 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7745
8153
  </LinkWrapper>
7746
8154
  );
7747
8155
 
7748
- const displayItems = getGridDisplayItems(item.gallery);
7749
- const lightboxItemsForEntry = displayItems
7750
- .filter(entry => entry.lightboxMedia)
7751
- .map(entry => entry.lightboxMedia!);
7752
-
7753
8156
  const imageContent = (
7754
8157
  <GridItemMediaWrapper className={imageWrapperClassName} style={imageWrapperStyle}>
7755
8158
  {displayItems.length === 0
@@ -7757,15 +8160,13 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7757
8160
  : slider === 'off'
7758
8161
  ?
7759
8162
  (() => {
7760
- const { displayMedia, lightboxMedia } = displayItems[0];
7761
- const lightboxIndex = lightboxMedia
7762
- ? lightboxItemsForEntry.findIndex(item => item.assetId === lightboxMedia.assetId)
7763
- : -1;
8163
+ const { displayMedia } = displayItems[0];
8164
+ const lightboxIndex = lightboxIndexes[0];
7764
8165
  return (
7765
8166
  <GridMediaItem
7766
8167
  media={displayMedia}
7767
8168
  className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
7768
- style={imageStyle}
8169
+ style={entryImageStyle}
7769
8170
  hasLightbox={lightbox === 'on'}
7770
8171
  onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
7771
8172
  ? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
@@ -7788,50 +8189,28 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7788
8189
  ))}
7789
8190
  </div>
7790
8191
  )}
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;
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];
7819
8200
  return (
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>
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
+ />
7832
8211
  );
7833
8212
  })}
7834
- </Splide>
8213
+ />
7835
8214
  </>
7836
8215
  }
7837
8216
  </GridItemMediaWrapper>
@@ -7849,7 +8228,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7849
8228
  />
7850
8229
  <p
7851
8230
  className={titleTextClassName}
7852
- style={{ width: textBoxWidthStyle, ...titleFieldCss, ...titleTextLeadingVars }}
8231
+ style={{ width: textBoxWidthStyle, ...titleTextStyle }}
7853
8232
  >
7854
8233
  {item.title}
7855
8234
  </p>
@@ -7863,7 +8242,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7863
8242
  />
7864
8243
  <p
7865
8244
  className={subtitleTextClassName}
7866
- style={{ width: textBoxWidthStyle, ...subtitleFieldCss, ...subtitleTextLeadingVars }}
8245
+ style={{ width: textBoxWidthStyle, ...subtitleTextStyle }}
7867
8246
  >
7868
8247
  {item.subtitle}
7869
8248
  </p>
@@ -7883,16 +8262,18 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7883
8262
  <div
7884
8263
  key={index}
7885
8264
  className={\`\${P}-item\`.trim()}
7886
- style={gridColumn && !shouldAlignEntries ? { gridColumn } : undefined}
8265
+ style={itemStyle}
7887
8266
  >
7888
8267
  <div
7889
- className={\`\${isEditMode
7890
- ? \`\${P}-item-inner\`
8268
+ ref={(el) => { itemInnerRefs.current[index] = el; }}
8269
+ className={\`\${isEditMode
8270
+ ? \`\${P}-item-inner\`
7891
8271
  : \`\${P}-item-inner-hidden\`}\${shouldAlignEntries && isLastRow ? \` \${P}-item-inner-last-row\` : ''}\`.trim()}
7892
8272
  style={{
7893
8273
  width: (textBoxWidth ?? 0) > 100
7894
- ? \`calc(\${entryWidthScaled} * (\${textBoxWidth} / 100))\`
7895
- : entryWidthScaled,
8274
+ ? \`calc(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`
8275
+ : itemWidthScaled,
8276
+ ...(customSlot && !isTextOutside && !isAutoHeight ? { height: scalingValue(customSlot.height, isEditor) } : {}),
7896
8277
  ...(gridColumn && shouldAlignEntries ? { gridColumn } : {}),
7897
8278
  }}
7898
8279
  >
@@ -7938,7 +8319,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7938
8319
  {(!isEditor || isPreviewMode) && lightboxOpen && typeof document !== 'undefined' && lightbox === 'on' && (() => {
7939
8320
  const portalTarget = (portalId ? document.getElementById(portalId) : null) ?? document.body;
7940
8321
  return createPortal(
7941
- <div style={lightboxPortalStyle} data-selection="none">
8322
+ <div style={getLightboxPortalStyle()} data-selection="none">
7942
8323
  <Lightbox
7943
8324
  prefix={P}
7944
8325
  items={lightboxItems}
@@ -7975,17 +8356,42 @@ type GridLayoutConfig = {
7975
8356
  lockedParam?: 'wrapperWidth' | 'entryWidth' | 'horizontalGap' | null;
7976
8357
  };
7977
8358
 
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
+
7978
8383
  type GridSettings = {
7979
8384
  type: 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
7980
- gridLayout: GridLayoutConfig;
8385
+ gridLayout?: GridLayoutConfig;
8386
+ customGrid?: CustomGridLayout;
7981
8387
  textBoxWidth: number;
7982
- verticalGap: number;
7983
- entriesCount: number;
8388
+ verticalGap?: number;
8389
+ entriesCount?: number;
7984
8390
  lightbox: 'on' | 'off';
7985
- imageDisplay: {
8391
+ imageDisplay: 'fit' | 'cover' | {
7986
8392
  display: 'fit' | 'cover';
7987
- ratioValue: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
7988
- reversed: boolean;
8393
+ ratioValue?: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
8394
+ reversed?: boolean;
7989
8395
  };
7990
8396
  imageCorners?: number;
7991
8397
  lightboxImageDisplay?: 'fit' | 'cover' | { display?: 'fit' | 'cover' };
@@ -7995,8 +8401,9 @@ type GridSettings = {
7995
8401
  transition: 'fade' | 'slide',
7996
8402
  showText: 'always' | 'on hover';
7997
8403
  hover?: 'none' | 'zoom-in' | 'greyscale' | 'scale-down';
7998
- alignEntries: 'on' | 'off';
8404
+ alignEntries?: 'on' | 'off';
7999
8405
  align?: 'top' | 'center' | 'bottom';
8406
+ textGrowth?: 'inside' | 'outside';
8000
8407
  titleMarginTop: number;
8001
8408
  subtitleMarginTop: number;
8002
8409
  titleColor: string;
@@ -8043,7 +8450,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
8043
8450
  };
8044
8451
 
8045
8452
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
8046
- `, T = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
8453
+ `, R = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
8047
8454
  import { CommonComponentProps } from '../props';
8048
8455
  import { scalingValue } from '../utils/scalingValue';
8049
8456
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -8616,7 +9023,7 @@ export function Helix({
8616
9023
  </>
8617
9024
  );
8618
9025
  }
8619
- `, R = `import { CommonComponentProps } from '../props';
9026
+ `, M = `import { CommonComponentProps } from '../props';
8620
9027
  import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, scalingValue, useLazyVideos, useScopedStyles } from '../utils/index';
8621
9028
  import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
8622
9029
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
@@ -11068,7 +11475,7 @@ export function Hive({
11068
11475
  </>
11069
11476
  );
11070
11477
  }
11071
- `, M = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
11478
+ `, L = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
11072
11479
  import { createPortal } from 'react-dom';
11073
11480
  import { CommonComponentProps } from '../props';
11074
11481
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -11871,7 +12278,7 @@ export type LightboxJournalSettings = {
11871
12278
  closeIconColor: string;
11872
12279
  closeIconHoverColor: string;
11873
12280
  };
11874
- `, L = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
12281
+ `, k = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
11875
12282
  import { createPortal } from 'react-dom';
11876
12283
  import { CommonComponentProps } from '../props';
11877
12284
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -12455,7 +12862,7 @@ export const LightboxStrip = ({ settings, content, isEditor, isEditMode, isPrevi
12455
12862
  </>
12456
12863
  );
12457
12864
  };
12458
- `, k = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
12865
+ `, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
12459
12866
  import { createPortal } from 'react-dom';
12460
12867
  import { CommonComponentProps } from '../props';
12461
12868
  import { buildColorVars, EmbedMediaFrame, isEmbedMedia, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -15560,7 +15967,7 @@ export function List({ settings, content, isEditor, isPreviewMode, isEditMode, a
15560
15967
  </>
15561
15968
  );
15562
15969
  }
15563
- `, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
15970
+ `, N = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
15564
15971
  import cn from 'classnames';
15565
15972
  import { CommonComponentProps } from '../props';
15566
15973
  import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -16418,7 +16825,7 @@ type MarqueeProps = {
16418
16825
  isPreviewMode?: boolean;
16419
16826
  isEditMode?: boolean;
16420
16827
  } & CommonComponentProps;
16421
- `, N = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
16828
+ `, H = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
16422
16829
  import cn from 'classnames';
16423
16830
  import { CommonComponentProps } from '../props';
16424
16831
  import { LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -17361,7 +17768,7 @@ type MarqueeTextProps = {
17361
17768
  isPreviewMode?: boolean;
17362
17769
  isEditMode?: boolean;
17363
17770
  } & CommonComponentProps;
17364
- `, H = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
17771
+ `, O = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
17365
17772
  import { createPortal } from 'react-dom';
17366
17773
  import type React from 'react';
17367
17774
  import { CommonComponentProps } from '../props';
@@ -19843,7 +20250,7 @@ export function Mercury({
19843
20250
  </>
19844
20251
  );
19845
20252
  }
19846
- `, O = `import React, { useMemo, useState } from 'react';
20253
+ `, _ = `import React, { useMemo, useState } from 'react';
19847
20254
  import { CommonComponentProps } from '../props';
19848
20255
  import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
19849
20256
  import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
@@ -20422,7 +20829,7 @@ const COLOR_VAR_MAP: Record<OnelinerColorKeys, string> = {
20422
20829
  };
20423
20830
 
20424
20831
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
20425
- `, _ = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
20832
+ `, F = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
20426
20833
  import type React from 'react';
20427
20834
  import { CommonComponentProps } from '../props';
20428
20835
  import { scalingValue, useScopedStyles } from '../utils/index';
@@ -21261,7 +21668,7 @@ export function Pretext({ settings, content, isEditor, isPreviewMode, isEditMode
21261
21668
  </>
21262
21669
  );
21263
21670
  }
21264
- `, F = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
21671
+ `, W = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
21265
21672
  import cn from 'classnames';
21266
21673
  import { CommonComponentProps } from '../props';
21267
21674
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -21889,7 +22296,7 @@ export function Scale({ settings, content, isEditor, isPreviewMode }: ScaleProps
21889
22296
  </>
21890
22297
  );
21891
22298
  }
21892
- `, W = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
22299
+ `, D = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
21893
22300
  import { SvgImage } from '../helpers/SvgImage/SvgImage';
21894
22301
  import { CommonComponentProps } from '../props';
21895
22302
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
@@ -22586,7 +22993,7 @@ export function SimpleButton({ settings, isEditor, isPreviewMode, activeEvent, h
22586
22993
  </>
22587
22994
  );
22588
22995
  }
22589
- `, D = `import React, { useCallback, useEffect, useRef, useState } from 'react';
22996
+ `, B = `import React, { useCallback, useEffect, useRef, useState } from 'react';
22590
22997
  import cn from 'classnames';
22591
22998
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
22592
22999
  import { scalingValue } from '../utils/scalingValue';
@@ -22599,6 +23006,7 @@ type Slider20Item = {
22599
23006
  image: {
22600
23007
  assetId: string;
22601
23008
  name?: string;
23009
+ objectFit?: 'cover' | 'contain';
22602
23010
  };
22603
23011
  imageCaption: any[];
22604
23012
  };
@@ -22620,7 +23028,6 @@ type Slider20Settings = {
22620
23028
  trigger?: Slider20Trigger;
22621
23029
  direction?: Slider20Direction;
22622
23030
  transition?: Slider20Transition;
22623
- transitionSpeed?: number;
22624
23031
  nav?: Slider20Nav;
22625
23032
  navSize?: Slider20NavSize;
22626
23033
  navUnit?: number;
@@ -22651,7 +23058,6 @@ type Slider20Settings = {
22651
23058
  fontVariant?: 'normal' | 'small-caps';
22652
23059
  };
22653
23060
  captionMarginTop?: number;
22654
- imageCorners?: number;
22655
23061
  };
22656
23062
 
22657
23063
  type Slider20Props = {
@@ -22663,7 +23069,6 @@ type Slider20Props = {
22663
23069
  } & CommonComponentProps;
22664
23070
 
22665
23071
  type Offset = { x: number; y: number };
22666
- type TransitionLayer = { index: number; key: number };
22667
23072
  type Point = { x: number; y: number };
22668
23073
  type LocalAxes = { ex: Point; ey: Point; det: number };
22669
23074
 
@@ -22681,11 +23086,9 @@ type DragState = {
22681
23086
  };
22682
23087
 
22683
23088
  const TRANSITION_DURATION_MS = 500;
22684
- const DEFAULT_TRANSITION_SPEED = 1;
22685
23089
  const TRANSITION_EASING = 'cubic-bezier(0.25, 1, 0.5, 1)';
22686
23090
  const TRANSITION_BACKGROUND_COLOR: string | null = null;
22687
23091
  const DOT_ANIMATION_MS = 300;
22688
- const MAX_TRANSITION_LAYERS = 40;
22689
23092
  const DRAG_START_THRESHOLD_PX = 5;
22690
23093
  const DRAG_DISTANCE_RATIO = 0.15;
22691
23094
  const DRAG_FLICK_VELOCITY = 0.4;
@@ -22787,24 +23190,23 @@ function wrapIndex(index: number, count: number): number {
22787
23190
  return ((index % count) + count) % count;
22788
23191
  }
22789
23192
 
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;
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
+ };
22808
23210
  }
22809
23211
 
22810
23212
  function readTrackTranslatePx(element: HTMLElement, isHorizontal: boolean): number {
@@ -22846,13 +23248,7 @@ function toLocalDelta(axes: LocalAxes, dx: number, dy: number): Point {
22846
23248
  };
22847
23249
  }
22848
23250
 
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 {
23251
+ function getCSS(P: string, isEditor?: boolean): string {
22856
23252
  return \`
22857
23253
  .\${P}-wrapper {
22858
23254
  position: relative;
@@ -22913,8 +23309,6 @@ function getCSS(P: string, transitionDurationMs: number, isEditor?: boolean): st
22913
23309
  }
22914
23310
  .\${P}-list-fade {
22915
23311
  display: block;
22916
- /* Keeps the transition layers' z-index below the arrows, dots and click overlay. */
22917
- isolation: isolate;
22918
23312
  }
22919
23313
  .\${P}-slide {
22920
23314
  position: relative;
@@ -22927,9 +23321,11 @@ function getCSS(P: string, transitionDurationMs: number, isEditor?: boolean): st
22927
23321
  top: 0;
22928
23322
  left: 0;
22929
23323
  opacity: 0;
23324
+ transition: opacity \${TRANSITION_DURATION_MS}ms \${TRANSITION_EASING};
22930
23325
  }
22931
- .\${P}-list-fade .\${P}-slide.\${P}-is-layer {
23326
+ .\${P}-list-fade .\${P}-slide.\${P}-is-active {
22932
23327
  opacity: 1;
23328
+ z-index: 1;
22933
23329
  }
22934
23330
  .\${P}-slider-item {
22935
23331
  width: 100%;
@@ -23104,18 +23500,17 @@ function getCSS(P: string, transitionDurationMs: number, isEditor?: boolean): st
23104
23500
  cursor: pointer;
23105
23501
  z-index: 2;
23106
23502
  }
23107
- .\${P}-transition-fade .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23108
- animation: \${P}-fade-in \${transitionDurationMs}ms \${TRANSITION_EASING};
23503
+ .\${P}-contain {
23504
+ object-fit: contain;
23109
23505
  }
23110
- .\${P}-transition-reveal .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23111
- animation: \${P}-reveal-horizontal \${transitionDurationMs}ms ease;
23506
+ .\${P}-cover {
23507
+ object-fit: cover;
23112
23508
  }
23113
- .\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23114
- animation: \${P}-reveal-vertical \${transitionDurationMs}ms ease;
23509
+ .\${P}-transition-reveal .\${P}-slide.\${P}-is-active .\${P}-slider-image {
23510
+ animation: \${P}-reveal-horizontal \${TRANSITION_DURATION_MS}ms ease;
23115
23511
  }
23116
- @keyframes \${P}-fade-in {
23117
- from { opacity: 0; }
23118
- to { opacity: 1; }
23512
+ .\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-active .\${P}-slider-image {
23513
+ animation: \${P}-reveal-vertical \${TRANSITION_DURATION_MS}ms ease;
23119
23514
  }
23120
23515
  @keyframes \${P}-reveal-horizontal {
23121
23516
  from { clip-path: inset(0 100% 0 0); }
@@ -23138,8 +23533,6 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23138
23533
  const autoPlayIntervalS = trigger.value ?? DEFAULT_TRIGGER.value;
23139
23534
  const direction: Slider20Direction = settings?.direction ?? 'horizontal';
23140
23535
  const transition: Slider20Transition = settings?.transition ?? 'slide';
23141
- const transitionSpeed = typeof settings?.transitionSpeed === 'number' ? settings.transitionSpeed : DEFAULT_TRANSITION_SPEED;
23142
- const transitionDurationMs = getTransitionDurationMs(transitionSpeed);
23143
23536
  const nav: Slider20Nav = settings?.nav ?? 'classic';
23144
23537
  const navSize: Slider20NavSize = settings?.navSize ?? 'm';
23145
23538
  const navSizeValues = NAV_SIZES[navSize];
@@ -23157,21 +23550,12 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23157
23550
  const navBackgroundColor = settings?.navBackgroundColor ?? PAGINATION.colors.background;
23158
23551
  const linkColor = settings?.linkColor ?? IMAGE_CAPTION.linkColor;
23159
23552
  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;
23166
23553
  const isHorizontal = direction === 'horizontal';
23167
23554
  const isClickTrigger = triggerType === 'click';
23168
23555
  const isDragTrigger = triggerType === 'drag';
23169
23556
  const isAutoPlaying = triggerType === 'auto' && (!isEditor || Boolean(isPreviewMode));
23170
23557
  const pauseAutoOnHover = !isEditor;
23171
23558
  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;
23175
23559
  const showClassicNav = nav === 'classic';
23176
23560
  const showControls = controlsShow !== 'never' && controlsMaxWidth > 0;
23177
23561
  const isControlsOnHover = controlsShow === 'on hover';
@@ -23184,36 +23568,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23184
23568
 
23185
23569
  const hasClones = isSlideTransition && count > 1;
23186
23570
  const [activeIndex, setActiveIndex] = useState(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);
23571
+ const [trackPosition, setTrackPosition] = useState(hasClones ? 1 : 0);
23217
23572
  const [isMoving, setIsMoving] = useState(false);
23218
23573
  const [skipTransition, setSkipTransition] = useState(false);
23219
23574
  const [isDragging, setIsDragging] = useState(false);
@@ -23223,6 +23578,8 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23223
23578
  const isMovingRef = useRef(false);
23224
23579
  const trackPositionRef = useRef(trackPosition);
23225
23580
  trackPositionRef.current = trackPosition;
23581
+ const pendingAnimatedPositionRef = useRef<number | null>(null);
23582
+ const pendingStepsRef = useRef(0);
23226
23583
  const trackRef = useRef<HTMLDivElement | null>(null);
23227
23584
  const listRef = useRef<HTMLDivElement | null>(null);
23228
23585
  const dragRef = useRef<DragState | null>(null);
@@ -23233,56 +23590,59 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23233
23590
  setIsMoving(value);
23234
23591
  }, []);
23235
23592
 
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
-
23269
23593
  const goBySteps = useCallback((steps: number) => {
23270
23594
  if (count < 2 || steps === 0) return;
23595
+ const direction = steps > 0 ? 1 : -1;
23596
+ const total = Math.abs(steps);
23271
23597
  setAnimateDots(true);
23272
23598
  setMoving(true);
23273
23599
  if (!isSlideTransition) {
23274
23600
  setActiveIndex((prev) => wrapIndex(prev + steps, count));
23275
23601
  return;
23276
23602
  }
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]);
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]);
23286
23646
 
23287
23647
  const goBy = useCallback((step: 1 | -1) => {
23288
23648
  goBySteps(step);
@@ -23294,37 +23654,58 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23294
23654
  if (target === activeIndex && !isMovingRef.current) return;
23295
23655
  setAnimateDots(true);
23296
23656
  setMoving(true);
23297
- if (!isSlideTransition) {
23298
- setActiveIndex(target);
23299
- return;
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);
23300
23665
  }
23301
- moveTrack(() => count + target);
23302
- }, [activeIndex, count, isSlideTransition, moveTrack, setMoving]);
23666
+ }, [activeIndex, count, hasClones, isSlideTransition, setMoving]);
23303
23667
 
23304
23668
  useEffect(() => {
23305
23669
  if (!isMoving) return;
23306
23670
  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
+ }
23307
23677
  setMoving(false);
23308
- if (!hasClones) return;
23309
- const shift = getMiddleCopyShift(trackPosition, count);
23310
- if (shift === 0) return;
23311
- setSkipTransition(true);
23312
- setTrackPosition(trackPosition - shift);
23313
- }, transitionDurationMs);
23678
+ }, TRANSITION_DURATION_MS);
23314
23679
  return () => window.clearTimeout(timeoutId);
23315
- }, [count, hasClones, isMoving, setMoving, trackPosition, transitionDurationMs]);
23680
+ }, [activeIndex, count, hasClones, isMoving, setMoving, trackPosition]);
23316
23681
 
23317
23682
  useEffect(() => {
23318
23683
  if (!skipTransition) return;
23319
23684
  let innerId = 0;
23320
23685
  const outerId = requestAnimationFrame(() => {
23321
- innerId = requestAnimationFrame(() => setSkipTransition(false));
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
+ });
23322
23703
  });
23323
23704
  return () => {
23324
23705
  cancelAnimationFrame(outerId);
23325
23706
  cancelAnimationFrame(innerId);
23326
23707
  };
23327
- }, [skipTransition]);
23708
+ }, [goBySteps, setMoving, skipTransition]);
23328
23709
 
23329
23710
  const structureKey = \`\${hasClones}:\${count}\`;
23330
23711
  const prevStructureKeyRef = useRef(structureKey);
@@ -23338,7 +23719,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23338
23719
  setDragOffset(0);
23339
23720
  setActiveIndex(nextIndex);
23340
23721
  setSkipTransition(true);
23341
- setTrackPosition(nextIndex + (hasClones ? count : 0));
23722
+ setTrackPosition(nextIndex + (hasClones ? 1 : 0));
23342
23723
  }, [activeIndex, count, hasClones, structureKey]);
23343
23724
 
23344
23725
  useEffect(() => {
@@ -23417,23 +23798,31 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23417
23798
  if (!isDragTrigger || count < 2 || !track) return;
23418
23799
  if (event.pointerType === 'mouse' && event.button !== 0) return;
23419
23800
 
23801
+ pendingAnimatedPositionRef.current = null;
23802
+ pendingStepsRef.current = 0;
23803
+
23420
23804
  if (isMovingRef.current) {
23421
23805
  setMoving(false);
23422
23806
  }
23423
23807
 
23424
- // Freeze the track where it is on screen and drag from there.
23425
23808
  let baseOffset = 0;
23426
23809
  const list = listRef.current;
23427
23810
  if (isSlideTransition && list) {
23428
- const size = readSlideSizePx(list, isHorizontal);
23811
+ const size = isHorizontal ? list.offsetWidth : list.offsetHeight;
23429
23812
  if (size > 0) {
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);
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
+ }
23437
23826
  setDragOffset(baseOffset);
23438
23827
  }
23439
23828
  }
@@ -23499,19 +23888,19 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23499
23888
  finishDrag(event);
23500
23889
  };
23501
23890
 
23502
- const trackTranslate = getTrackTranslate(trackPosition, dragOffset, isHorizontal);
23503
- const slides = hasClones ? Array.from({ length: TRACK_COPIES }, () => items).flat() : items;
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;
23504
23895
 
23505
23896
  return (
23506
23897
  <>
23507
- <style dangerouslySetInnerHTML={{ __html: getCSS(P, transitionDurationMs, isEditor) }} />
23898
+ <style dangerouslySetInnerHTML={{ __html: getCSS(P, isEditor) }} />
23508
23899
  <div
23509
23900
  className={cn(\`\${P}-wrapper\`, {
23510
- [\`\${P}-transition-fade\`]: transition === 'fade in',
23511
- [\`\${P}-transition-reveal\`]: isReveal,
23512
- [\`\${P}-transition-reveal-vertical\`]: isReveal && !isHorizontal,
23901
+ [\`\${P}-transition-reveal\`]: transition === 'reveal',
23902
+ [\`\${P}-transition-reveal-vertical\`]: transition === 'reveal' && !isHorizontal,
23513
23903
  })}
23514
- data-active-index={activeIndex}
23515
23904
  onMouseEnter={() => setIsHovered(true)}
23516
23905
  onMouseLeave={() => setIsHovered(false)}
23517
23906
  >
@@ -23527,7 +23916,6 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23527
23916
  [\`\${P}-track-draggable\`]: isDragTrigger,
23528
23917
  [\`\${P}-track-draggable-vertical\`]: isDragTrigger && !isHorizontal,
23529
23918
  })}
23530
- style={trackRadiusStyle}
23531
23919
  onPointerDown={handlePointerDown}
23532
23920
  onPointerMove={handlePointerMove}
23533
23921
  onPointerUp={handlePointerUp}
@@ -23550,29 +23938,38 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23550
23938
  transform: trackTranslate,
23551
23939
  transition: isDragging || skipTransition
23552
23940
  ? 'none'
23553
- : \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`,
23941
+ : \`transform \${TRANSITION_DURATION_MS}ms \${TRANSITION_EASING}\`,
23554
23942
  }
23555
23943
  : undefined}
23556
23944
  >
23557
23945
  {slides.map((item, slideIndex) => {
23558
- const itemIndex = wrapIndex(slideIndex, count);
23559
- const key = \`slide-\${Math.floor(slideIndex / count)}-\${itemIndex}\`;
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}\`;
23560
23951
  return (
23561
- <div key={key} className={\`\${P}-slide\`}>
23562
- {renderSlideItem(item)}
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>
23563
23970
  </div>
23564
23971
  );
23565
23972
  })}
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
- ))}
23576
23973
  </div>
23577
23974
  {isClickTrigger && (
23578
23975
  <div
@@ -23744,7 +24141,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23744
24141
  style={{
23745
24142
  ...titleStyle,
23746
24143
  width: TITLE_WIDTH_SETTINGS.sizing === 'auto' ? 'max-content' : scalingValue(TITLE_WIDTH_SETTINGS.width, isEditor),
23747
- transitionDuration: \`\${Math.round(transitionDurationMs / 2)}ms\`,
24144
+ transitionDuration: \`\${Math.round(TRANSITION_DURATION_MS / 2)}ms\`,
23748
24145
  }}
23749
24146
  >
23750
24147
  <div
@@ -23778,7 +24175,7 @@ function ArrowIcon({ color, className }: { color: string, className: string }) {
23778
24175
  </svg>
23779
24176
  );
23780
24177
  }
23781
- `, B = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
24178
+ `, z = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
23782
24179
  import cn from 'classnames';
23783
24180
  import { CommonComponentProps } from '../props';
23784
24181
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
@@ -24409,7 +24806,7 @@ type TestimonialsSettings = {
24409
24806
  logoHeight: number;
24410
24807
  captionMarginTop: number;
24411
24808
  };
24412
- `, z = `import cn from 'classnames';
24809
+ `, V = `import cn from 'classnames';
24413
24810
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
24414
24811
  import { CommonComponentProps } from '../props';
24415
24812
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
@@ -24905,7 +25302,7 @@ type TestimonialsSettings = {
24905
25302
  icon?: string | null;
24906
25303
  };
24907
25304
  };
24908
- `, V = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
25305
+ `, G = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
24909
25306
  import type React from 'react';
24910
25307
  import { createPortal } from 'react-dom';
24911
25308
  import { CommonComponentProps } from '../props';
@@ -25438,30 +25835,31 @@ export function Waterfall({
25438
25835
  </>
25439
25836
  );
25440
25837
  }
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
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
25464
25862
  };
25465
25863
  export {
25466
- U as componentSources
25864
+ K as componentSources
25467
25865
  };