@cntrl-site/components 1.0.118-alpha.4 → 1.0.118-alpha.9

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.
Files changed (71) hide show
  1. package/dist/{Burger-DyORh_vF.mjs → Burger-C8JIQQwm.mjs} +330 -307
  2. package/dist/Burger-C_SjPZWp.js +669 -0
  3. package/dist/{ChroniclesComponent-DVoJ0kdT.mjs → ChroniclesComponent-Bf8jxaas.mjs} +512 -442
  4. package/dist/ChroniclesComponent-XAHXrzRb.js +1 -0
  5. package/dist/Components/Burger/Burger.d.ts +4 -2
  6. package/dist/Components/Grid/CustomGridComponent.d.ts +41 -0
  7. package/dist/Components/Grid/Grid.d.ts +27 -7
  8. package/dist/Components/helpers/SvgImage/loadSvgMaskUrl.d.ts +0 -7
  9. package/dist/{ControlSlider-3w-bHQEg.mjs → ControlSlider-BBAXRDLP.mjs} +3 -4
  10. package/dist/ControlSlider-BCkVFl4w.js +1 -0
  11. package/dist/{FAQ-GmiwRdFq.mjs → FAQ-CJHCMSBa.mjs} +1 -1
  12. package/dist/{FAQ-7HEkaoU6.js → FAQ-DLh63Utr.js} +1 -1
  13. package/dist/Grid-Dwn03N-q.mjs +1853 -0
  14. package/dist/Grid-pyPdnAeI.js +445 -0
  15. package/dist/{Hive-34KvKNsa.js → Hive-CzabuuCc.js} +1 -1
  16. package/dist/{Hive-7xHXyMM1.mjs → Hive-DyxYd5eg.mjs} +1 -1
  17. package/dist/{HiveLightboxTitles-BCoL46-V.mjs → HiveLightboxTitles-DhEeFKWs.mjs} +1 -1
  18. package/dist/{HiveLightboxTitles-DEeyQGcf.js → HiveLightboxTitles-DlyptAaK.js} +1 -1
  19. package/dist/{Lightbox-DzPqgKP4.mjs → Lightbox-BY99NS14.mjs} +1 -1
  20. package/dist/{Lightbox-Cb7lyaNt.js → Lightbox-DZckgBzK.js} +1 -1
  21. package/dist/{LightboxJournal-DisD2DLv.mjs → LightboxJournal-BDUs6T0B.mjs} +1 -1
  22. package/dist/{LightboxJournal-B-vul_be.js → LightboxJournal-Bf_rZzmz.js} +1 -1
  23. package/dist/{LightboxStrip-wCHUhAqN.mjs → LightboxStrip-Cuhb2fIR.mjs} +1 -1
  24. package/dist/{LightboxStrip-YDyEPEb6.js → LightboxStrip-RA4ABUC-.js} +1 -1
  25. package/dist/{Mercury-BmhtFYOw.js → Mercury-B-s2Kvuq.js} +1 -1
  26. package/dist/{Mercury-Q788wrYQ.mjs → Mercury-CCW0Es-s.mjs} +1 -1
  27. package/dist/{OnelinerForm-D8WIB9Qy.mjs → OnelinerForm-BEu7_sho.mjs} +1 -1
  28. package/dist/{OnelinerForm-CUmY-bXL.js → OnelinerForm-C2Y_XMCY.js} +1 -1
  29. package/dist/{SimpleButton-DTpzfmb6.mjs → SimpleButton-C-o2W9bS.mjs} +1 -1
  30. package/dist/{SimpleButton-DtaCYa3y.js → SimpleButton-nGEcO2gB.js} +1 -1
  31. package/dist/{Slider20-q0iGgnE3.js → Slider20-BOmjDRf2.js} +1 -1
  32. package/dist/{Slider20-CKngROrc.mjs → Slider20-DUi6qwnd.mjs} +1 -1
  33. package/dist/SvgImage-B5mR9y6q.mjs +51 -0
  34. package/dist/SvgImage-DFlmxAoL.js +1 -0
  35. package/dist/{TestimonialSingle-CpEUendN.js → TestimonialSingle-BORQom3u.js} +1 -1
  36. package/dist/{TestimonialSingle-Bax71Hyo.mjs → TestimonialSingle-DrnyReim.mjs} +1 -1
  37. package/dist/{Waterfall-znaoynn5.mjs → Waterfall-3kKioKh2.mjs} +1 -1
  38. package/dist/{Waterfall-B9YWMhrg.js → Waterfall-DII4-WV5.js} +1 -1
  39. package/dist/{components-eK82xypT.mjs → components-IX-rNSn-.mjs} +30 -653
  40. package/dist/components-QVeWZKot.js +1 -0
  41. package/dist/components.css +1 -1
  42. package/dist/elements.js +1 -1
  43. package/dist/elements.mjs +24 -24
  44. package/dist/elements.node.js +1 -1
  45. package/dist/elements.node.mjs +1 -1
  46. package/dist/index.d.ts +1 -3
  47. package/dist/index.js +1 -1
  48. package/dist/index.mjs +36 -63
  49. package/dist/loadSvgMaskUrl-DfF7ay6h.js +1 -0
  50. package/dist/loadSvgMaskUrl-xHgGYgPe.mjs +20 -0
  51. package/dist/sources.js +676 -244
  52. package/dist/sources.mjs +717 -284
  53. package/dist/types/Component.d.ts +0 -7
  54. package/dist/types/SchemaV1.d.ts +0 -3
  55. package/package.json +1 -1
  56. package/dist/Burger-B4kXX9aY.js +0 -669
  57. package/dist/ChroniclesComponent-Nm_yIRmr.js +0 -1
  58. package/dist/Components/PopupMenu/PopupMenu.d.ts +0 -73
  59. package/dist/Components/PopupMenu/PopupMenuComponent.d.ts +0 -594
  60. package/dist/Components/PopupMenu/popupMenuLayout.d.ts +0 -203
  61. package/dist/Components/PopupMenu/popupMenuSnap.d.ts +0 -61
  62. package/dist/ControlSlider-DB4nbVLT.js +0 -1
  63. package/dist/Grid-BuRdth9A.mjs +0 -1622
  64. package/dist/Grid-tqSSYh2-.js +0 -408
  65. package/dist/PopupMenu-CYdDyzEt.mjs +0 -1372
  66. package/dist/PopupMenu-Di1fHgho.js +0 -409
  67. package/dist/SvgImage-CwRq9-ec.mjs +0 -56
  68. package/dist/SvgImage-_QN8ngad.js +0 -1
  69. package/dist/components-BYoTPJk3.js +0 -1
  70. package/dist/loadSvgMaskUrl-B6kHUyof.js +0 -1
  71. package/dist/loadSvgMaskUrl-DUhCVvpl.mjs +0 -39
package/dist/sources.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./ChroniclesComponent-Nm_yIRmr.js"),e=`import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./ChroniclesComponent-XAHXrzRb.js"),t=`import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
2
2
  import { CommonComponentProps } from '../props';
3
3
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
4
4
  import { useLightboxScrollLock } from '../utils/useLightboxScrollLock';
@@ -27,11 +27,12 @@ type BurgerShowInValue = string | Record<string, string>;
27
27
 
28
28
  type BurgerLink = {
29
29
  link?: {
30
- type?: 'url' | 'page' | 'anchor';
30
+ type?: 'url' | 'page' | 'anchor' | 'file';
31
31
  value?: string;
32
32
  target?: string;
33
33
  anchor?: string;
34
34
  url?: string;
35
+ download?: string;
35
36
  };
36
37
  mode?: 'page' | 'url';
37
38
  page?: string;
@@ -256,10 +257,11 @@ function isBlankTarget(target?: string): boolean {
256
257
  }
257
258
 
258
259
  function getBurgerDest(item: BurgerLink): {
259
- type: 'url' | 'page' | 'anchor';
260
+ type: 'url' | 'page' | 'anchor' | 'file';
260
261
  value: string;
261
262
  target?: '_blank';
262
263
  anchor?: string;
264
+ download?: string;
263
265
  } {
264
266
  const dest = item.link;
265
267
  if (dest && typeof dest === 'object') {
@@ -273,8 +275,12 @@ function getBurgerDest(item: BurgerLink): {
273
275
  if (dest.type === 'page') {
274
276
  return { type: 'page', value: dest.value ?? '', target, anchor: dest.anchor };
275
277
  }
278
+ if (dest.type === 'file') {
279
+ return { type: 'file', value: dest.value ?? '' };
280
+ }
281
+ // a published file link comes as its file's url, with the name to download it under
276
282
  if (typeof dest.url === 'string') {
277
- return { type: 'url', value: dest.url, target };
283
+ return { type: 'url', value: dest.url, target, download: typeof dest.download === 'string' ? dest.download : undefined };
278
284
  }
279
285
  }
280
286
  const target = isBlankTarget(item.openIn) ? '_blank' : undefined;
@@ -295,12 +301,17 @@ function resolveBurgerLink(item: BurgerLink, pages?: BurgerPageRef[]): {
295
301
  label: string;
296
302
  href: string;
297
303
  target?: '_blank';
304
+ download?: string;
298
305
  } {
299
306
  const label = item.label || 'Link';
300
307
  const dest = getBurgerDest(item);
301
308
 
302
309
  if (dest.type === 'url') {
303
- return { label, href: dest.value, target: dest.target };
310
+ return { label, href: dest.value, target: dest.target, download: dest.download };
311
+ }
312
+ if (dest.type === 'file') {
313
+ // only the editor sees a file by its id, and downloads it through onLinkNavigate, right on the click
314
+ return { label, href: dest.value ? '#' : '', target: '_blank' };
304
315
  }
305
316
  if (dest.type === 'anchor') {
306
317
  const anchor = dest.value.replace(/^#/, '');
@@ -912,10 +923,11 @@ function renderTextPaddingControls(
912
923
  type ColorKeys = 'iconColor' | 'closeButtonColor' | 'linkColor' | 'openLinkColor' | 'compactIconColor' | 'compactLinkColor' | 'compactLogoColor' | 'compactBackgroundColor' | 'openLogoColor' | 'menuBackgroundColor' | 'overlayColor' | 'backgroundColor' | 'logoColor';
913
924
 
914
925
  export type BurgerLinkNavigateEvent = {
915
- mode: 'page' | 'url';
926
+ mode: 'page' | 'url' | 'file';
916
927
  href: string;
917
928
  page?: string;
918
929
  url?: string;
930
+ file?: string;
919
931
  anchor?: string;
920
932
  target?: '_blank';
921
933
  };
@@ -1767,6 +1779,28 @@ function findAnchorTarget(hash: string): HTMLElement | null {
1767
1779
  return target instanceof HTMLElement ? target : null;
1768
1780
  }
1769
1781
 
1782
+ // the file is on the cdn, another origin, where the download attribute alone opens it instead
1783
+ function downloadFile(url: string, name: string) {
1784
+ fetch(url)
1785
+ .then((response) => {
1786
+ if (!response.ok) throw new Error(\`Could not download \${url}: \${response.status}\`);
1787
+ return response.blob();
1788
+ })
1789
+ .then((blob) => {
1790
+ const objectUrl = URL.createObjectURL(blob);
1791
+ const link = document.createElement('a');
1792
+ link.href = objectUrl;
1793
+ link.download = name || decodeURIComponent(url.split('?')[0].split('/').pop() ?? '');
1794
+ document.body.appendChild(link);
1795
+ link.click();
1796
+ link.remove();
1797
+ window.setTimeout(() => URL.revokeObjectURL(objectUrl), 0);
1798
+ })
1799
+ .catch(() => {
1800
+ window.location.assign(url);
1801
+ });
1802
+ }
1803
+
1770
1804
  function scrollToAnchor(hash: string): boolean {
1771
1805
  const target = findAnchorTarget(hash);
1772
1806
  if (!target) return false;
@@ -1800,10 +1834,11 @@ function handleLinkClick(
1800
1834
  const resolved = resolveBurgerLink(item, pages);
1801
1835
  const dest = getBurgerDest(item);
1802
1836
  const navigateEvent: BurgerLinkNavigateEvent = {
1803
- mode: dest.type === 'url' ? 'url' : 'page',
1837
+ mode: dest.type === 'url' || dest.type === 'file' ? dest.type : 'page',
1804
1838
  href: resolved.href || href,
1805
1839
  page: dest.type === 'page' ? dest.value : undefined,
1806
1840
  url: dest.type === 'url' ? dest.value : undefined,
1841
+ file: dest.type === 'file' ? dest.value : undefined,
1807
1842
  anchor: dest.type === 'anchor'
1808
1843
  ? dest.value.replace(/^#/, '')
1809
1844
  : (dest.anchor ?? '').replace(/^#/, ''),
@@ -1825,6 +1860,14 @@ function handleLinkClick(
1825
1860
  return;
1826
1861
  }
1827
1862
 
1863
+ const download = item ? getBurgerDest(item).download : undefined;
1864
+ if (download !== undefined && href && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey) {
1865
+ event.preventDefault();
1866
+ downloadFile(href, download);
1867
+ onClose();
1868
+ return;
1869
+ }
1870
+
1828
1871
  if (!opensInNewTab && hash && isSameDocumentHref(href) && findAnchorTarget(hash)) {
1829
1872
  event.preventDefault();
1830
1873
  runAfterClose(() => scrollToAnchor(hash));
@@ -2430,12 +2473,13 @@ export function Burger({
2430
2473
  const showOpenNavControls = showControls && isOpen;
2431
2474
 
2432
2475
  const renderOpenNavItems = (linkClassName: string) => items.filter((item) => isVisibleInOpenNav(item, layoutId)).map((item, index) => {
2433
- const { label, href, target } = resolveBurgerLink(item, pages);
2476
+ const { label, href, target, download } = resolveBurgerLink(item, pages);
2434
2477
  const linkNode = href ? (
2435
2478
  <a
2436
2479
  href={href}
2437
2480
  target={target}
2438
2481
  rel={target === '_blank' ? 'noopener noreferrer' : undefined}
2482
+ download={download}
2439
2483
  className={\`\${linkClassName} \${P}-has-href\`}
2440
2484
  onClick={(event) => onNavLinkClick(event, item)}
2441
2485
  >
@@ -2547,7 +2591,7 @@ export function Burger({
2547
2591
  };
2548
2592
 
2549
2593
  const renderNavLink = (item: BurgerLink, index: number) => {
2550
- const { label, href, target } = resolveBurgerLink(item, pages);
2594
+ const { label, href, target, download } = resolveBurgerLink(item, pages);
2551
2595
  const textContent = (
2552
2596
  <span className={navLinkTextClassName} style={navLinkTextStyle}>
2553
2597
  {renderMultilineText(label)}
@@ -2566,6 +2610,7 @@ export function Burger({
2566
2610
  href={href}
2567
2611
  target={target}
2568
2612
  rel={target === '_blank' ? 'noopener noreferrer' : undefined}
2613
+ download={download}
2569
2614
  className={\`\${P}-nav-link \${P}-has-href\`}
2570
2615
  onClick={(event) => onNavLinkClick(event, item)}
2571
2616
  >
@@ -2683,7 +2728,7 @@ export function Burger({
2683
2728
  </div>
2684
2729
  );
2685
2730
  }
2686
- `,t=`import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
2731
+ `,i=`import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
2687
2732
  import { createPortal } from 'react-dom';
2688
2733
  import cn from 'classnames';
2689
2734
  import { CommonComponentProps } from '../props';
@@ -3730,7 +3775,7 @@ export function Chronicles({
3730
3775
  </>
3731
3776
  );
3732
3777
  }
3733
- `,i=`import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3778
+ `,o=`import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3734
3779
  import { CommonComponentProps } from '../props';
3735
3780
  import { LinkWrapper, useScopedStyles, type ContentLink } from '../utils/index';
3736
3781
 
@@ -4259,7 +4304,7 @@ export function ClickGallerie({ settings, content = [], isEditor }: ClickGalleri
4259
4304
  </>
4260
4305
  );
4261
4306
  }
4262
- `,o=`import { useCallback, useEffect, useMemo, useState } from 'react';
4307
+ `,r=`import { useCallback, useEffect, useMemo, useState } from 'react';
4263
4308
  import cn from 'classnames';
4264
4309
  import { CommonComponentProps } from '../props';
4265
4310
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index';
@@ -5003,7 +5048,7 @@ export function FAQ({ settings, content, isEditor, isPreviewMode, isEditMode, ac
5003
5048
  </>
5004
5049
  );
5005
5050
  }
5006
- `,r=`import React, { useMemo, useState } from 'react';
5051
+ `,a=`import React, { useMemo, useState } from 'react';
5007
5052
  import { CommonComponentProps } from '../props';
5008
5053
  import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
5009
5054
  import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
@@ -5641,9 +5686,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
5641
5686
  };
5642
5687
 
5643
5688
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
5644
- `,a=`import { Splide, SplideSlide } from '@splidejs/react-splide';
5645
- import '@splidejs/react-splide/css/core';
5646
- import { CommonComponentProps } from '../props';
5689
+ `,e=`import { CommonComponentProps } from '../props';
5647
5690
  import { EmbedMediaFrame, getEmbedAspect, getEmbedPlayback, isEmbedMedia } from '../utils/index';
5648
5691
  import {
5649
5692
  buildColorVars,
@@ -5653,7 +5696,7 @@ import {
5653
5696
  useLazyVideos,
5654
5697
  useScopedStyles,
5655
5698
  } from '../utils/index';
5656
- import { useCallback, useEffect, useLayoutEffect, useRef, useState, useMemo } from 'react';
5699
+ import { memo, useCallback, useEffect, useLayoutEffect, useRef, useState, useMemo } from 'react';
5657
5700
  import { createPortal } from 'react-dom';
5658
5701
  import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss';
5659
5702
  import { SvgImage } from '../helpers/SvgImage/SvgImage';
@@ -5770,15 +5813,23 @@ function getCSS(P: string): string {
5770
5813
  width: 100%;
5771
5814
  overflow: hidden;
5772
5815
  }
5773
- .\${P}-item-slider .splide__track {
5774
- overflow: hidden;
5775
- }
5776
5816
  .\${P}-item-image-link {
5777
5817
  width: 100%;
5778
5818
  display: flex;
5779
5819
  flex-direction: column;
5780
5820
  align-items: center;
5781
5821
  }
5822
+ .\${P}-custom-layout .\${P}-item-image-link {
5823
+ flex: 1 1 0%;
5824
+ min-height: 0;
5825
+ }
5826
+ .\${P}-custom-layout.\${P}-text-outside .\${P}-item-image-link,
5827
+ .\${P}-custom-layout.\${P}-auto-height .\${P}-item-image-link {
5828
+ flex: none;
5829
+ }
5830
+ .\${P}-auto-height .\${P}-item-image-wrapper-fit-slider > .\${P}-item-image-wrapper-sizer :is(img, video) {
5831
+ width: 100%;
5832
+ }
5782
5833
  .\${P}-item-text-link {
5783
5834
  display: flex;
5784
5835
  flex-direction: column;
@@ -5799,18 +5850,47 @@ function getCSS(P: string): string {
5799
5850
  display: block;
5800
5851
  max-width: 100%;
5801
5852
  }
5802
- .\${P}-item-slider,
5803
- .\${P}-item-slider .splide__track,
5804
- .\${P}-item-slider .splide__list,
5805
- .\${P}-item-slider .splide__slide {
5853
+ .\${P}-item-slider {
5854
+ position: relative;
5806
5855
  width: 100%;
5807
5856
  height: 100%;
5857
+ overflow: hidden;
5858
+ }
5859
+ .\${P}-item-slider-list {
5860
+ position: relative;
5861
+ display: flex;
5862
+ flex-direction: row;
5863
+ width: 100%;
5864
+ height: 100%;
5865
+ will-change: transform;
5808
5866
  }
5809
- .\${P}-item-slider .splide__slide {
5867
+ .\${P}-item-slider-list-vertical {
5868
+ flex-direction: column;
5869
+ }
5870
+ .\${P}-item-slider-list-fade {
5871
+ display: block;
5872
+ will-change: auto;
5873
+ }
5874
+ .\${P}-item-slide {
5875
+ position: relative;
5876
+ flex: 0 0 100%;
5877
+ width: 100%;
5878
+ height: 100%;
5810
5879
  display: flex;
5811
5880
  justify-content: center;
5812
5881
  align-items: center;
5813
5882
  }
5883
+ .\${P}-item-slider-list-fade .\${P}-item-slide {
5884
+ position: absolute;
5885
+ top: 0;
5886
+ left: 0;
5887
+ opacity: 0;
5888
+ transition: opacity \${SLIDER_TRANSITION_MS}ms \${SLIDER_EASING};
5889
+ }
5890
+ .\${P}-item-slider-list-fade .\${P}-item-slide-active {
5891
+ opacity: 1;
5892
+ z-index: 1;
5893
+ }
5814
5894
  .\${P}-item-title {
5815
5895
  white-space: normal;
5816
5896
  overflow-wrap: anywhere;
@@ -5957,13 +6037,13 @@ function getCSS(P: string): string {
5957
6037
  .\${P}-image-align-bottom .\${P}-item-image-wrapper:not(.\${P}-item-image-wrapper-fit-slider) {
5958
6038
  align-items: flex-end;
5959
6039
  }
5960
- .\${P}-image-align-top .\${P}-item-slider .splide__slide {
6040
+ .\${P}-image-align-top .\${P}-item-slider .\${P}-item-slide {
5961
6041
  align-items: flex-start;
5962
6042
  }
5963
- .\${P}-image-align-center .\${P}-item-slider .splide__slide {
6043
+ .\${P}-image-align-center .\${P}-item-slider .\${P}-item-slide {
5964
6044
  align-items: center;
5965
6045
  }
5966
- .\${P}-image-align-bottom .\${P}-item-slider .splide__slide {
6046
+ .\${P}-image-align-bottom .\${P}-item-slider .\${P}-item-slide {
5967
6047
  align-items: flex-end;
5968
6048
  }
5969
6049
  .\${P}-align-entries .\${P}-item {
@@ -6044,13 +6124,13 @@ function getCSS(P: string): string {
6044
6124
  .\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-image-wrapper:not(.\${P}-item-image-wrapper-fit-slider) {
6045
6125
  align-items: flex-end;
6046
6126
  }
6047
- .\${P}-image-align-top.\${P}-align-entries .\${P}-item-slider .splide__slide {
6127
+ .\${P}-image-align-top.\${P}-align-entries .\${P}-item-slider .\${P}-item-slide {
6048
6128
  align-items: flex-start;
6049
6129
  }
6050
- .\${P}-image-align-center.\${P}-align-entries .\${P}-item-slider .splide__slide {
6130
+ .\${P}-image-align-center.\${P}-align-entries .\${P}-item-slider .\${P}-item-slide {
6051
6131
  align-items: center;
6052
6132
  }
6053
- .\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-slider .splide__slide {
6133
+ .\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-slider .\${P}-item-slide {
6054
6134
  align-items: flex-end;
6055
6135
  }
6056
6136
  .\${P}-image-align-top.\${P}-align-entries .\${P}-item-image-link {
@@ -6118,27 +6198,9 @@ function pickRandomSlideDirection(): 'ltr' | 'ttb' {
6118
6198
  return Math.random() < 0.5 ? 'ltr' : 'ttb';
6119
6199
  }
6120
6200
 
6121
- function resumeSplideAutoplay(splide: { Components: { Autoplay?: { pause: (stop?: boolean) => void; play: () => void } } }) {
6122
- const autoplay = splide.Components.Autoplay;
6123
- if (!autoplay) return;
6124
- autoplay.pause(false);
6125
- autoplay.play();
6126
- }
6127
-
6128
- function handleRandomSlideMoved(splide: {
6129
- options: { direction?: string };
6130
- Components: { Autoplay?: { pause: (stop?: boolean) => void; play: () => void } };
6131
- }) {
6132
- const next = pickRandomSlideDirection();
6133
- if (splide.options.direction !== next) {
6134
- splide.options = { ...splide.options, direction: next };
6135
- }
6136
-
6137
- requestAnimationFrame(() => {
6138
- requestAnimationFrame(() => {
6139
- resumeSplideAutoplay(splide);
6140
- });
6141
- });
6201
+ function wrapSlideIndex(index: number, count: number): number {
6202
+ if (count <= 0) return 0;
6203
+ return ((index % count) + count) % count;
6142
6204
  }
6143
6205
 
6144
6206
  type GridProps = {
@@ -6178,6 +6240,8 @@ type LightboxProps = {
6178
6240
 
6179
6241
  const LIGHTBOX_ANIM_MS = 500;
6180
6242
  const SLIDER_TRANSITION_MS = 750;
6243
+ const SLIDER_EASING = 'cubic-bezier(0.25, 1, 0.5, 1)';
6244
+ const SLIDER_DEFAULT_INTERVAL_MS = 5000;
6181
6245
  const LIGHTBOX_EASING = 'cubic-bezier(0.22, 1, 0.36, 1)';
6182
6246
  const SWIPE_CLOSE_THRESHOLD = 72;
6183
6247
  const SWIPE_NAV_THRESHOLD = 50;
@@ -6267,7 +6331,7 @@ function collectGridLightboxMedia(content: any[]): GridMedia[] {
6267
6331
  return result;
6268
6332
  }
6269
6333
 
6270
- function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
6334
+ const LightboxMediaPreloadPool = memo(function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
6271
6335
  const [pool, setPool] = useState<HTMLDivElement | null>(null);
6272
6336
  useLazyVideos(pool, { preload: 'metadata' });
6273
6337
  // an embed's player is only ever framed where it shows
@@ -6306,7 +6370,7 @@ function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
6306
6370
  ))}
6307
6371
  </div>
6308
6372
  );
6309
- }
6373
+ });
6310
6374
 
6311
6375
  function unloadVideoElement(video: HTMLVideoElement) {
6312
6376
  video.pause();
@@ -6314,15 +6378,121 @@ function unloadVideoElement(video: HTMLVideoElement) {
6314
6378
  video.load();
6315
6379
  }
6316
6380
 
6317
- const SPLIDE_SLIDE_VIDEOS = '.splide__slide video';
6381
+ const GRID_SLIDE_CLASS = 'cntrl-grid-slide';
6382
+ const GRID_SLIDE_PLAYING_CLASS = 'cntrl-grid-slide-playing';
6383
+ const GRID_SLIDE_VIDEOS = \`.\${GRID_SLIDE_CLASS} video\`;
6318
6384
 
6319
6385
  function shouldPlaySlideVideo(video: HTMLVideoElement): boolean {
6320
- if (video.closest('.splide--fade, .splide__slide.is-active:not(.splide__slide--clone), .splide__slide.is-next')) return true;
6321
- const slide = video.closest<HTMLElement>('.splide__slide');
6322
- if (!slide || slide.classList.contains('splide__slide--clone')) return false;
6323
- const slideIndex = slide.dataset.slideIndex;
6324
- const upcomingSlide = slide.parentElement?.querySelector<HTMLElement>('.splide__slide.is-next');
6325
- return slideIndex !== undefined && upcomingSlide?.dataset.slideIndex === slideIndex;
6386
+ return video.closest(\`.\${GRID_SLIDE_PLAYING_CLASS}\`) !== null;
6387
+ }
6388
+
6389
+ type GridEntrySliderProps = {
6390
+ prefix: string;
6391
+ slides: React.ReactNode[];
6392
+ isFade: boolean;
6393
+ direction: GridSettings['direction'];
6394
+ intervalMs: number;
6395
+ };
6396
+
6397
+ function GridEntrySlider({ prefix: P, slides, isFade, direction, intervalMs }: GridEntrySliderProps) {
6398
+ const count = slides.length;
6399
+ const hasClones = !isFade && count > 1;
6400
+ const isRandom = !isFade && direction === 'random';
6401
+ const delayMs = Number.isFinite(intervalMs) && intervalMs > 0 ? intervalMs : SLIDER_DEFAULT_INTERVAL_MS;
6402
+ const [position, setPosition] = useState(hasClones ? 1 : 0);
6403
+ const [axis, setAxis] = useState<'ltr' | 'ttb'>(!isFade && direction === 'vertical' ? 'ttb' : 'ltr');
6404
+ const [isMoving, setIsMoving] = useState(false);
6405
+ const [skipTransition, setSkipTransition] = useState(false);
6406
+ const [cycle, setCycle] = useState(0);
6407
+ const isMovingRef = useRef(false);
6408
+
6409
+ useEffect(() => {
6410
+ if (count < 2) return;
6411
+ const timeoutId = window.setTimeout(() => {
6412
+ if (isMovingRef.current) {
6413
+ setCycle(prev => prev + 1);
6414
+ return;
6415
+ }
6416
+ isMovingRef.current = true;
6417
+ setIsMoving(true);
6418
+ setSkipTransition(false);
6419
+ setPosition(prev => (hasClones ? prev + 1 : wrapSlideIndex(prev + 1, count)));
6420
+ if (!isRandom) setCycle(prev => prev + 1);
6421
+ }, delayMs);
6422
+ return () => window.clearTimeout(timeoutId);
6423
+ }, [count, cycle, delayMs, hasClones, isRandom]);
6424
+
6425
+ useEffect(() => {
6426
+ if (!isMoving) return;
6427
+ const timeoutId = window.setTimeout(() => {
6428
+ const isOnClone = hasClones && position === count + 1;
6429
+ const nextAxis = isRandom ? pickRandomSlideDirection() : axis;
6430
+ if (isOnClone || nextAxis !== axis) {
6431
+ setSkipTransition(true);
6432
+ if (isOnClone) setPosition(1);
6433
+ setAxis(nextAxis);
6434
+ }
6435
+ isMovingRef.current = false;
6436
+ setIsMoving(false);
6437
+ if (isRandom) setCycle(prev => prev + 1);
6438
+ }, SLIDER_TRANSITION_MS);
6439
+ return () => window.clearTimeout(timeoutId);
6440
+ }, [axis, count, hasClones, isMoving, isRandom, position]);
6441
+
6442
+ useEffect(() => {
6443
+ if (!skipTransition) return;
6444
+ let innerId = 0;
6445
+ const outerId = requestAnimationFrame(() => {
6446
+ innerId = requestAnimationFrame(() => setSkipTransition(false));
6447
+ });
6448
+ return () => {
6449
+ cancelAnimationFrame(outerId);
6450
+ cancelAnimationFrame(innerId);
6451
+ };
6452
+ }, [skipTransition]);
6453
+
6454
+ const slotsCount = hasClones ? count + 2 : count;
6455
+ const getItemIndex = (slot: number) => (hasClones ? wrapSlideIndex(slot - 1, count) : slot);
6456
+ const isCloneSlot = (slot: number) => hasClones && (slot === 0 || slot === count + 1);
6457
+ const activeIndex = getItemIndex(position);
6458
+ const nextSlot = position + 1 < slotsCount ? position + 1 : -1;
6459
+ const isPlayingSlot = (slot: number) => isFade
6460
+ || (slot === position && !isCloneSlot(slot))
6461
+ || slot === nextSlot
6462
+ || (nextSlot >= 0 && !isCloneSlot(slot) && getItemIndex(slot) === getItemIndex(nextSlot));
6463
+ const isVertical = !isFade && axis === 'ttb';
6464
+ const listStyle: React.CSSProperties | undefined = isFade
6465
+ ? undefined
6466
+ : {
6467
+ transform: isVertical
6468
+ ? \`translate3d(0, \${-position * 100}%, 0)\`
6469
+ : \`translate3d(\${-position * 100}%, 0, 0)\`,
6470
+ transition: skipTransition ? 'none' : \`transform \${SLIDER_TRANSITION_MS}ms \${SLIDER_EASING}\`,
6471
+ };
6472
+
6473
+ return (
6474
+ <div className={\`\${P}-item-slider\`}>
6475
+ <div
6476
+ className={\`\${P}-item-slider-list\${isFade ? \` \${P}-item-slider-list-fade\` : ''}\${isVertical ? \` \${P}-item-slider-list-vertical\` : ''}\`}
6477
+ style={listStyle}
6478
+ >
6479
+ {Array.from({ length: slotsCount }, (_, slot) => {
6480
+ const itemIndex = getItemIndex(slot);
6481
+ const isClone = isCloneSlot(slot);
6482
+ const isShown = isFade ? itemIndex === activeIndex : slot === position;
6483
+ return (
6484
+ <div
6485
+ key={isClone ? \`clone-\${slot === 0 ? 'start' : 'end'}\` : \`slide-\${itemIndex}\`}
6486
+ className={\`\${P}-item-slide \${GRID_SLIDE_CLASS}\${isFade && isShown ? \` \${P}-item-slide-active\` : ''}\${isPlayingSlot(slot) ? \` \${GRID_SLIDE_PLAYING_CLASS}\` : ''}\`}
6487
+ aria-hidden={isShown ? undefined : true}
6488
+ >
6489
+ {slides[itemIndex]}
6490
+ </div>
6491
+ );
6492
+ })}
6493
+ </div>
6494
+ </div>
6495
+ );
6326
6496
  }
6327
6497
 
6328
6498
  function GridMediaItem({
@@ -6330,7 +6500,7 @@ function GridMediaItem({
6330
6500
  className,
6331
6501
  style,
6332
6502
  hasLightbox,
6333
- isSplideSlide = false,
6503
+ isSliderSlide = false,
6334
6504
  onMediaClick,
6335
6505
  }: {
6336
6506
  media: GridMedia;
@@ -6338,7 +6508,7 @@ function GridMediaItem({
6338
6508
  style: React.CSSProperties;
6339
6509
  /** An embed then plays here as a silent loop, and as it was set to in the lightbox. */
6340
6510
  hasLightbox: boolean;
6341
- isSplideSlide?: boolean;
6511
+ isSliderSlide?: boolean;
6342
6512
  onMediaClick?: (e: React.MouseEvent<HTMLElement>) => void;
6343
6513
  }) {
6344
6514
  if (isEmbedMedia(media)) {
@@ -6370,7 +6540,7 @@ function GridMediaItem({
6370
6540
  playsInline: true,
6371
6541
  onClick: onMediaClick,
6372
6542
  };
6373
- return isSplideSlide
6543
+ return isSliderSlide
6374
6544
  ? <video {...videoProps} preload='none' />
6375
6545
  : <LazyVideo {...videoProps} autoPlay />;
6376
6546
  }
@@ -6399,7 +6569,7 @@ function GridItemMediaWrapper({
6399
6569
  children: React.ReactNode;
6400
6570
  }) {
6401
6571
  const [wrapper, setWrapper] = useState<HTMLDivElement | null>(null);
6402
- useLazyVideos(wrapper, { autoPlay: true, selector: SPLIDE_SLIDE_VIDEOS, shouldPlay: shouldPlaySlideVideo });
6572
+ useLazyVideos(wrapper, { autoPlay: true, selector: GRID_SLIDE_VIDEOS, shouldPlay: shouldPlaySlideVideo });
6403
6573
 
6404
6574
  return (
6405
6575
  <div ref={setWrapper} className={className} style={style}>
@@ -7300,11 +7470,149 @@ function resolveLightboxImageDisplay(
7300
7470
  return value?.display === 'cover' ? 'cover' : 'fit';
7301
7471
  }
7302
7472
 
7473
+ function getCustomGridSpanWidth(layout: CustomGridLayout, span: number): number {
7474
+ return layout.columnWidth * span + layout.gutterWidth * Math.max(0, span - 1);
7475
+ }
7476
+
7477
+ type CustomGridSlot = {
7478
+ column: number;
7479
+ span: number;
7480
+ width: number;
7481
+ top: number;
7482
+ height: number;
7483
+ gridColumn: string;
7484
+ };
7485
+
7486
+ function getCustomGridBlocksBottom(layout: CustomGridLayout): number {
7487
+ return layout.blocks.reduce((bottom, block) => Math.max(bottom, Math.max(0, block.top) + Math.max(0, block.height)), 0);
7488
+ }
7489
+
7490
+ function getCustomGridVerticalGap(layout: CustomGridLayout): number {
7491
+ if (typeof layout.verticalGap === 'number') return Math.max(0, layout.verticalGap);
7492
+ return Math.max(0, (layout.repeatHeight ?? 0) - getCustomGridBlocksBottom(layout));
7493
+ }
7494
+
7495
+ function getCustomGridSlot(layout: CustomGridLayout, index: number): CustomGridSlot {
7496
+ const block = layout.blocks[index % layout.blocks.length];
7497
+ const span = Math.min(Math.max(1, Math.round(block.span)), layout.columnsCount);
7498
+ const column = Math.min(Math.max(0, Math.round(block.column)), layout.columnsCount - span);
7499
+ return {
7500
+ column,
7501
+ span,
7502
+ width: getCustomGridSpanWidth(layout, span),
7503
+ top: Math.max(0, block.top),
7504
+ height: Math.max(0, block.height),
7505
+ gridColumn: \`\${column + 1} / span \${span}\`,
7506
+ };
7507
+ }
7508
+
7509
+ const EDGE_TOLERANCE = 1e-6;
7510
+
7511
+ function getCustomGridRows(layout: CustomGridLayout, entriesCount: number, entryHeights?: number[]) {
7512
+ const beat = layout.beat ?? 0;
7513
+ const onBeats = beat > 0 && !!entryHeights;
7514
+ const snapUp = (value: number) => Math.ceil(value / beat - 1e-3) * beat;
7515
+ const tracks: (number | 'auto')[] = [];
7516
+ const gridRows: string[] = [];
7517
+ const verticalGap = getCustomGridVerticalGap(layout);
7518
+ for (let groupStart = 0; groupStart < entriesCount; groupStart += layout.blocks.length) {
7519
+ if (groupStart > 0 && verticalGap > 0) tracks.push(verticalGap);
7520
+ const slots = Array.from(
7521
+ { length: Math.min(layout.blocks.length, entriesCount - groupStart) },
7522
+ (_, index) => getCustomGridSlot(layout, groupStart + index),
7523
+ );
7524
+ const ends = slots.map((slot) => {
7525
+ const under = slots.filter(other => other.column < slot.column + slot.span
7526
+ && slot.column < other.column + other.span
7527
+ && other.top >= slot.top + slot.height - EDGE_TOLERANCE);
7528
+ return under.length > 0 ? Math.min(...under.map(other => other.top)) : undefined;
7529
+ });
7530
+ const tops = [0, ...slots.map(slot => slot.top)]
7531
+ .sort((a, b) => a - b)
7532
+ .filter((top, index, sorted) => index === 0 || top - sorted[index - 1] > EDGE_TOLERANCE);
7533
+ const isSame = (a: number, b: number) => Math.abs(a - b) <= EDGE_TOLERANCE;
7534
+ const getTop = (value: number) => tops.findIndex(top => isSame(top, value));
7535
+ const positions: number[] = [];
7536
+ let position = 0;
7537
+ const pushContentTrack = (isEnding: (end: number | undefined) => boolean) => {
7538
+ const ending = slots.flatMap((slot, index) => (isEnding(ends[index]) ? [{ slot, entry: groupStart + index }] : []));
7539
+ if (ending.length === 0) return;
7540
+ if (!onBeats) {
7541
+ tracks.push('auto');
7542
+ return;
7543
+ }
7544
+ const needed = Math.max(...ending.map(({ slot, entry }) => positions[getTop(slot.top)] + (entryHeights[entry] ?? 0)));
7545
+ const track = Math.max(0, snapUp(needed) - position);
7546
+ tracks.push(track);
7547
+ position += track;
7548
+ };
7549
+ const lines = tops.map((top, index) => {
7550
+ if (index > 0) {
7551
+ tracks.push(top - tops[index - 1]);
7552
+ position += top - tops[index - 1];
7553
+ }
7554
+ pushContentTrack(end => end !== undefined && isSame(end, top));
7555
+ positions.push(position);
7556
+ return tracks.length + 1;
7557
+ });
7558
+ pushContentTrack(end => end === undefined);
7559
+ const groupEnd = tracks.length + 1;
7560
+ const getLine = (value: number) => lines[getTop(value)];
7561
+ slots.forEach((slot, index) => {
7562
+ const end = ends[index];
7563
+ gridRows.push(\`\${getLine(slot.top)} / \${end === undefined ? groupEnd : getLine(end)}\`);
7564
+ });
7565
+ }
7566
+ return { tracks, gridRows };
7567
+ }
7568
+
7569
+ function getGridMediaAspect(media: GridMedia): number | undefined {
7570
+ if (isEmbedMedia(media)) return getEmbedAspect(media);
7571
+ return media.width && media.height && media.width > 0 && media.height > 0 ? media.width / media.height : undefined;
7572
+ }
7573
+
7574
+ /**
7575
+ * Where each entry stands, given the height it takes; the CMS grid builder places its blocks the same way.
7576
+ * A block keeps its drawn distance to the blocks above it in its group; a block with none above it starts at
7577
+ * its drawn top in the group, or, with masonry on, the vertical gap below whatever earlier group reaches
7578
+ * lowest in its columns.
7579
+ */
7580
+ function placeCustomGridEntries(layout: CustomGridLayout, slots: CustomGridSlot[], heights: number[]) {
7581
+ const groupSize = layout.blocks.length;
7582
+ const verticalGap = getCustomGridVerticalGap(layout);
7583
+ const isMasonry = layout.masonry === 'on';
7584
+ const tops: number[] = [];
7585
+ const placed: { column: number; span: number; bottom: number; group: number }[] = [];
7586
+ const getBottom = (items: typeof placed) => items.reduce((bottom, item) => Math.max(bottom, item.bottom), 0);
7587
+ let groupStart = 0;
7588
+ for (let start = 0; start < slots.length; start += groupSize) {
7589
+ const group = start / groupSize;
7590
+ const entries = Array.from({ length: Math.min(groupSize, slots.length - start) }, (_, index) => start + index)
7591
+ .sort((a, b) => slots[a].top - slots[b].top || a - b);
7592
+ for (const entry of entries) {
7593
+ const slot = slots[entry];
7594
+ const sharesColumns = (other: { column: number; span: number }) => other.column < slot.column + slot.span
7595
+ && slot.column < other.column + other.span;
7596
+ const above = entries.filter(other => other !== entry && tops[other] !== undefined && sharesColumns(slots[other])
7597
+ && slots[other].top + slots[other].height <= slot.top + EDGE_TOLERANCE);
7598
+ const earlier = isMasonry ? placed.filter(item => item.group < group && sharesColumns(item)) : [];
7599
+ const candidates = above.map(other => tops[other] + heights[other] + slot.top - (slots[other].top + slots[other].height));
7600
+ if (earlier.length > 0) candidates.push(getBottom(earlier) + verticalGap);
7601
+ if (candidates.length === 0) candidates.push(groupStart + slot.top);
7602
+ tops[entry] = Math.max(...candidates);
7603
+ placed.push({ column: slot.column, span: slot.span, bottom: tops[entry] + heights[entry], group });
7604
+ }
7605
+ groupStart = getBottom(placed) + verticalGap;
7606
+ }
7607
+ return { tops, bottom: getBottom(placed) };
7608
+ }
7609
+
7303
7610
  export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, metadata, activeEvent, layoutId, portalId }: GridProps) {
7304
7611
  const { prefix: P } = useScopedStyles();
7305
7612
  const {
7306
7613
  type = 'a',
7307
7614
  gridLayout,
7615
+ customGrid,
7308
7616
  textBoxWidth = 100,
7309
7617
  verticalGap,
7310
7618
  entriesCount,
@@ -7352,62 +7660,69 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7352
7660
  hover = 'none',
7353
7661
  alignEntries = 'off',
7354
7662
  align = 'top',
7663
+ textGrowth = 'inside',
7355
7664
  } = settings;
7356
7665
 
7357
- const resolvedTitleTextStyle: TextStyles = {
7358
- fontSettings: {
7359
- fontFamily: titleFontFamily,
7360
- fontWeight: titleFontSettings?.fontWeight ?? 400,
7361
- fontStyle: titleFontSettings?.fontStyle ?? 'normal',
7362
- },
7363
- fontSize: titleFontSize ?? 0.01,
7364
- lineHeight: titleLineHeight,
7365
- letterSpacing: titleLetterSpacing ?? 0,
7366
- wordSpacing: titleWordSpacing ?? 0,
7367
- textAppearance: titleTextAppearance,
7368
- color: titleColor,
7369
- };
7370
- const titleTypographyCss = omitTextColors(textStylesToCss(resolvedTitleTextStyle, isEditor));
7371
- const titleFieldCss = {
7372
- ...titleTypographyCss,
7373
- } as React.CSSProperties;
7666
+ const titleTextStyle = useMemo(() => ({
7667
+ ...omitTextColors(textStylesToCss({
7668
+ fontSettings: {
7669
+ fontFamily: titleFontFamily,
7670
+ fontWeight: titleFontSettings?.fontWeight ?? 400,
7671
+ fontStyle: titleFontSettings?.fontStyle ?? 'normal',
7672
+ },
7673
+ fontSize: titleFontSize ?? 0.01,
7674
+ lineHeight: titleLineHeight,
7675
+ letterSpacing: titleLetterSpacing ?? 0,
7676
+ wordSpacing: titleWordSpacing ?? 0,
7677
+ textAppearance: titleTextAppearance,
7678
+ color: titleColor,
7679
+ }, isEditor)),
7680
+ ...getGridTextLeadingVars(titleFontSize, titleLineHeight, P, isEditor),
7681
+ } as React.CSSProperties), [
7682
+ titleFontFamily, titleFontSettings, titleFontSize, titleLineHeight, titleLetterSpacing,
7683
+ titleWordSpacing, titleTextAppearance, titleColor, isEditor, P,
7684
+ ]);
7374
7685
 
7375
- const resolvedSubtitleTextStyle: TextStyles = {
7376
- fontSettings: {
7377
- fontFamily: subtitleFontFamily,
7378
- fontWeight: subtitleFontSettings?.fontWeight ?? 400,
7379
- fontStyle: subtitleFontSettings?.fontStyle ?? 'normal',
7380
- },
7381
- fontSize: subtitleFontSize ?? 0.01,
7382
- lineHeight: subtitleLineHeight,
7383
- letterSpacing: subtitleLetterSpacing ?? 0,
7384
- wordSpacing: subtitleWordSpacing ?? 0,
7385
- textAppearance: subtitleTextAppearance,
7386
- color: subtitleColor,
7387
- };
7388
- const subtitleTypographyCss = omitTextColors(textStylesToCss(resolvedSubtitleTextStyle, isEditor));
7389
- const subtitleFieldCss = {
7390
- ...subtitleTypographyCss,
7391
- } as React.CSSProperties;
7686
+ const subtitleTextStyle = useMemo(() => ({
7687
+ ...omitTextColors(textStylesToCss({
7688
+ fontSettings: {
7689
+ fontFamily: subtitleFontFamily,
7690
+ fontWeight: subtitleFontSettings?.fontWeight ?? 400,
7691
+ fontStyle: subtitleFontSettings?.fontStyle ?? 'normal',
7692
+ },
7693
+ fontSize: subtitleFontSize ?? 0.01,
7694
+ lineHeight: subtitleLineHeight,
7695
+ letterSpacing: subtitleLetterSpacing ?? 0,
7696
+ wordSpacing: subtitleWordSpacing ?? 0,
7697
+ textAppearance: subtitleTextAppearance,
7698
+ color: subtitleColor,
7699
+ }, isEditor)),
7700
+ ...getGridTextLeadingVars(subtitleFontSize, subtitleLineHeight, P, isEditor),
7701
+ } as React.CSSProperties), [
7702
+ subtitleFontFamily, subtitleFontSettings, subtitleFontSize, subtitleLineHeight, subtitleLetterSpacing,
7703
+ subtitleWordSpacing, subtitleTextAppearance, subtitleColor, isEditor, P,
7704
+ ]);
7392
7705
 
7393
- const resolvedLightboxCounterTextStyle: TextStyles = {
7394
- fontSettings: {
7395
- fontFamily: lightboxCounterFontFamily,
7396
- fontWeight: lightboxCounterFontSettings?.fontWeight ?? 400,
7397
- fontStyle: lightboxCounterFontSettings?.fontStyle ?? 'normal',
7398
- },
7399
- fontSize: lightboxCounterFontSize ?? 0.01,
7400
- lineHeight: lightboxCounterLineHeight,
7401
- letterSpacing: lightboxCounterLetterSpacing ?? 0,
7402
- wordSpacing: lightboxCounterWordSpacing ?? 0,
7403
- textAppearance: lightboxCounterTextAppearance,
7404
- color: lightboxCounterColor,
7405
- };
7406
- const lightboxCounterTypographyCss = omitTextColors(textStylesToCss(resolvedLightboxCounterTextStyle, isEditor));
7407
- const lightboxCounterFieldCss = {
7408
- ...lightboxCounterTypographyCss,
7706
+ const lightboxCounterFieldCss = useMemo(() => ({
7707
+ ...omitTextColors(textStylesToCss({
7708
+ fontSettings: {
7709
+ fontFamily: lightboxCounterFontFamily,
7710
+ fontWeight: lightboxCounterFontSettings?.fontWeight ?? 400,
7711
+ fontStyle: lightboxCounterFontSettings?.fontStyle ?? 'normal',
7712
+ },
7713
+ fontSize: lightboxCounterFontSize ?? 0.01,
7714
+ lineHeight: lightboxCounterLineHeight,
7715
+ letterSpacing: lightboxCounterLetterSpacing ?? 0,
7716
+ wordSpacing: lightboxCounterWordSpacing ?? 0,
7717
+ textAppearance: lightboxCounterTextAppearance,
7718
+ color: lightboxCounterColor,
7719
+ }, isEditor)),
7409
7720
  ...getGridTextLeadingVars(lightboxCounterFontSize, lightboxCounterLineHeight, P, isEditor),
7410
- } as React.CSSProperties;
7721
+ } as React.CSSProperties), [
7722
+ lightboxCounterFontFamily, lightboxCounterFontSettings, lightboxCounterFontSize, lightboxCounterLineHeight,
7723
+ lightboxCounterLetterSpacing, lightboxCounterWordSpacing, lightboxCounterTextAppearance, lightboxCounterColor,
7724
+ isEditor, P,
7725
+ ]);
7411
7726
 
7412
7727
  const titleTextClassName = getGridTextClassName(
7413
7728
  titleFontSize,
@@ -7421,8 +7736,6 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7421
7736
  \`\${P}-item-subtitle\`,
7422
7737
  \`\${P}-text-tight-leading\`,
7423
7738
  );
7424
- const titleTextLeadingVars = getGridTextLeadingVars(titleFontSize, titleLineHeight, P, isEditor);
7425
- const subtitleTextLeadingVars = getGridTextLeadingVars(subtitleFontSize, subtitleLineHeight, P, isEditor);
7426
7739
  const lightboxCounterClassName = getGridTextClassName(
7427
7740
  lightboxCounterFontSize,
7428
7741
  lightboxCounterLineHeight,
@@ -7430,42 +7743,59 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7430
7743
  \`\${P}-text-tight-leading\`,
7431
7744
  );
7432
7745
 
7433
- const colorVars = buildColorVars(P, {
7746
+ const colorVars = useMemo(() => buildColorVars(P, {
7434
7747
  titleColor,
7435
7748
  subtitleColor,
7436
7749
  lightboxCounterColor,
7437
- }, COLOR_VAR_MAP, STATE_KEYS);
7750
+ }, COLOR_VAR_MAP, STATE_KEYS), [P, titleColor, subtitleColor, lightboxCounterColor]);
7438
7751
 
7439
7752
  const stateClass = activeEvent && activeEvent !== 'default' ? \`\${P}-state-\${activeEvent}\` : '';
7440
7753
  const showTextOnHover = showText === 'on hover' && (!isEditor || isPreviewMode);
7441
7754
  const hoverEffectClass = hover !== 'none' && (!isEditor || isPreviewMode) ? \` \${P}-hover-\${hover}\` : '';
7442
7755
  const wrapperStateClasses = \`\${stateClass}\${showTextOnHover ? \` \${P}-show-text-hover\` : ''}\${hoverEffectClass}\`.trim();
7443
7756
 
7444
- const resEntriesCount = entriesCount === 0 ? Infinity : entriesCount;
7757
+ const customLayout = customGrid && Array.isArray(customGrid.blocks) && customGrid.blocks.length > 0 ? customGrid : undefined;
7758
+ const resEntriesCount = customLayout || entriesCount === 0 ? Infinity : entriesCount;
7759
+ const isTextOutside = !!customLayout && textGrowth === 'outside';
7760
+ const isAutoHeight = customLayout?.cellHeight === 'auto';
7761
+ // entries stand where placeCustomGridEntries puts them rather than on grid rows
7762
+ const isPlacedLayout = isAutoHeight || customLayout?.masonry === 'on';
7763
+ const itemInnerRefs = useRef<(HTMLDivElement | null)[]>([]);
7764
+ const [customEntryHeights, setCustomEntryHeights] = useState<number[]>([]);
7445
7765
 
7446
- const cropContent = (content ?? []).slice(0, resEntriesCount);
7766
+ const cropContent = useMemo<any[]>(() => (content ?? []).slice(0, resEntriesCount), [content, resEntriesCount]);
7447
7767
  const lightboxMediaToPreload = useMemo(
7448
7768
  () => (lightbox === 'on' ? collectGridLightboxMedia(cropContent) : []),
7449
7769
  [cropContent, lightbox],
7450
7770
  );
7451
-
7452
- const size = gridLayout.entryWidth ?? 0.2;
7453
-
7454
- const isCover = imageDisplay?.display === 'cover';
7455
- const ratioValue = imageDisplay?.ratioValue ?? '1:1';
7456
- const ratioReversed = imageDisplay?.reversed ?? false;
7771
+ const entriesMedia = useMemo(() => cropContent.map((item: any) => {
7772
+ const displayItems = getGridDisplayItems(item.gallery);
7773
+ const lightboxItemsForEntry = displayItems
7774
+ .filter(entry => entry.lightboxMedia)
7775
+ .map(entry => entry.lightboxMedia!);
7776
+ const lightboxIndexes = displayItems.map(({ lightboxMedia }) => (lightboxMedia
7777
+ ? lightboxItemsForEntry.findIndex(media => media.assetId === lightboxMedia.assetId)
7778
+ : -1));
7779
+ return { displayItems, lightboxItemsForEntry, lightboxIndexes };
7780
+ }), [cropContent]);
7781
+
7782
+ const size = gridLayout?.entryWidth ?? 0.2;
7783
+
7784
+ const imageDisplaySettings = typeof imageDisplay === 'string' ? { display: imageDisplay } : imageDisplay;
7785
+ const isCover = imageDisplaySettings?.display === 'cover';
7786
+ const ratioValue = imageDisplaySettings?.ratioValue ?? '1:1';
7787
+ const ratioReversed = imageDisplaySettings?.reversed ?? false;
7457
7788
  const [rW, rH] = ratioValue.split(':').map(Number);
7458
7789
  const effW = ratioReversed ? rH : rW;
7459
7790
  const effH = ratioReversed ? rW : rH;
7460
7791
  const aspectRatio = \`\${effW} / \${effH}\`;
7461
7792
 
7462
- const columnsCount = gridLayout.columnsCount;
7793
+ const columnsCount = gridLayout?.columnsCount ?? 1;
7463
7794
  const entryWidthScaled = scalingValue(size ?? 0, isEditor);
7464
- const imageWrapperWidth = entryWidthScaled;
7465
- const isFitSlider = !isCover && slider !== 'off';
7795
+ const isFitSlider = slider !== 'off' && (customLayout ? isAutoHeight : !isCover);
7466
7796
 
7467
7797
  const itemsInLastRow = cropContent.length % columnsCount || columnsCount;
7468
- const isPartialLastRow = itemsInLastRow < columnsCount && cropContent.length > 0;
7798
+ const isPartialLastRow = !customLayout && itemsInLastRow < columnsCount && cropContent.length > 0;
7469
7799
  const lastRowStartIndex = cropContent.length - itemsInLastRow;
7470
7800
  const lastRowStartColumn = isPartialLastRow
7471
7801
  ? Math.floor((columnsCount - itemsInLastRow) / 2) + 1
@@ -7473,24 +7803,47 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7473
7803
 
7474
7804
  const imageBorderRadius = imageCorners ? scalingValue(imageCorners, isEditor) : undefined;
7475
7805
 
7476
- const imageWrapperStyle: React.CSSProperties = {
7477
- width: imageWrapperWidth,
7478
- ...(isCover
7479
- ? { aspectRatio, height: 'auto', overflow: 'hidden' }
7480
- : { height: 'auto' }),
7806
+ const getImageWrapperStyle = (
7807
+ entryWidth: string,
7808
+ slot?: CustomGridSlot,
7809
+ media?: { aspect?: number; isEmpty: boolean },
7810
+ ): React.CSSProperties => ({
7811
+ width: entryWidth,
7812
+ ...(slot && isAutoHeight
7813
+ ? {
7814
+ // an entry with no media keeps the drawn height, so it can still be seen and filled
7815
+ height: media?.isEmpty ? scalingValue(slot.height, isEditor) : 'auto',
7816
+ flexShrink: 0,
7817
+ overflow: 'hidden',
7818
+ ...(media?.aspect && !isFitSlider ? { aspectRatio: \`\${media.aspect}\` } : {}),
7819
+ }
7820
+ : slot
7821
+ ? isTextOutside
7822
+ ? { height: scalingValue(slot.height, isEditor), flexShrink: 0, overflow: 'hidden' }
7823
+ : { flex: '1 1 0%', minHeight: 0, overflow: 'hidden' }
7824
+ : isCover
7825
+ ? { aspectRatio, height: 'auto', overflow: 'hidden' }
7826
+ : { height: 'auto' }),
7481
7827
  ...(imageBorderRadius ? { borderRadius: imageBorderRadius, overflow: 'hidden' } : {}),
7482
- };
7828
+ });
7483
7829
 
7484
7830
  const imageWrapperClassName = \`\${P}-item-image-wrapper\${isFitSlider ? \` \${P}-item-image-wrapper-fit-slider\` : ''}\`.trim();
7485
7831
  const isTextBeforeImage = type === 'd' || type === 'e' || type === 'f';
7486
- const shouldAlignEntries = alignEntries === 'on';
7487
- const textBoxWidthStyle = \`calc(\${scalingValue(size ?? 0, isEditor)} * (\${textBoxWidth} / 100))\`;
7488
- const controlWidthStyle = scalingValue(size * textBoxWidth / 100, isEditor);
7832
+ const shouldAlignEntries = !customLayout && alignEntries === 'on';
7489
7833
 
7490
7834
  const imageRadiusStyle = imageBorderRadius
7491
7835
  ? { borderRadius: imageBorderRadius, [MEDIA_RADIUS_VAR]: imageBorderRadius } as React.CSSProperties
7492
7836
  : {};
7493
- const imageStyle: React.CSSProperties = isCover
7837
+ const imageStyle: React.CSSProperties = isAutoHeight
7838
+ ? {
7839
+ objectFit: isFitSlider && !isCover ? 'contain' : 'cover',
7840
+ pointerEvents: 'auto',
7841
+ width: '100%',
7842
+ height: '100%',
7843
+ maxWidth: '100%',
7844
+ ...imageRadiusStyle,
7845
+ }
7846
+ : isCover
7494
7847
  ? {
7495
7848
  objectFit: 'cover',
7496
7849
  pointerEvents: 'auto',
@@ -7505,31 +7858,94 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7505
7858
  width: 'auto',
7506
7859
  height: 'auto',
7507
7860
  maxWidth: '100%',
7861
+ ...(customLayout ? { maxHeight: '100%' } : {}),
7508
7862
  ...imageRadiusStyle,
7509
7863
  };
7510
7864
 
7511
- const [containerWidth, setContainerWidth] = useState(0);
7512
- const containerRef = useRef<HTMLDivElement>(null);
7513
-
7514
- const resolvedSplideDirection = transition === 'fade'
7515
- ? 'ltr'
7516
- : direction === 'horizontal'
7517
- ? 'ltr'
7518
- : direction === 'vertical'
7519
- ? 'ttb'
7520
- : 'ltr';
7521
-
7522
- useEffect(() => {
7523
- const el = containerRef.current;
7524
- if (!el) return;
7525
- const ro = new ResizeObserver((entries) => {
7526
- setContainerWidth(Math.round(entries[0].contentRect.width));
7527
- });
7528
- ro.observe(el);
7865
+ const shouldMeasureEntries = (customLayout?.beat ?? 0) > 0 || isPlacedLayout;
7866
+ const customGridWidth = customLayout ? getCustomGridSpanWidth(customLayout, customLayout.columnsCount) : 0;
7867
+ useLayoutEffect(() => {
7868
+ if (!shouldMeasureEntries) {
7869
+ setCustomEntryHeights(prev => (prev.length > 0 ? [] : prev));
7870
+ return;
7871
+ }
7872
+ const wrapper = containerRef.current;
7873
+ const inners = itemInnerRefs.current.slice(0, cropContent.length);
7874
+ const measure = () => {
7875
+ const unit = wrapper && customGridWidth > 0 ? wrapper.offsetWidth / customGridWidth : 0;
7876
+ if (unit <= 0) return;
7877
+ const heights = inners.map(inner => (inner ? inner.offsetHeight / unit : 0));
7878
+ setCustomEntryHeights(prev => (
7879
+ prev.length === heights.length && prev.every((height, index) => Math.abs(height - heights[index]) < 1e-5)
7880
+ ? prev
7881
+ : heights
7882
+ ));
7883
+ };
7884
+ measure();
7885
+ const ro = new ResizeObserver(measure);
7886
+ if (wrapper) ro.observe(wrapper);
7887
+ inners.forEach(inner => inner && ro.observe(inner));
7529
7888
  return () => ro.disconnect();
7530
- }, []);
7889
+ }, [shouldMeasureEntries, cropContent.length, customGridWidth, P]);
7890
+ const measuredEntryHeights = shouldMeasureEntries && customEntryHeights.length === cropContent.length
7891
+ ? customEntryHeights
7892
+ : undefined;
7893
+ const customRows = useMemo(() => {
7894
+ if (!customLayout) return undefined;
7895
+ const rows = getCustomGridRows(customLayout, cropContent.length, measuredEntryHeights);
7896
+ return {
7897
+ gridRows: rows.gridRows,
7898
+ gridTemplateRows: rows.tracks.length
7899
+ ? rows.tracks.map(track => (track === 'auto' ? 'auto' : scalingValue(track, isEditor))).join(' ')
7900
+ : 'auto',
7901
+ };
7902
+ }, [customLayout, cropContent.length, measuredEntryHeights, isEditor]);
7903
+ const customSlots = useMemo(
7904
+ () => (customLayout ? cropContent.map((_, index) => getCustomGridSlot(customLayout, index)) : undefined),
7905
+ [customLayout, cropContent.length],
7906
+ );
7907
+ // the aspect a single media keeps when the cell takes its height
7908
+ const entryMediaAspects = useMemo(
7909
+ () => entriesMedia.map(({ displayItems }) => (
7910
+ isAutoHeight && displayItems.length > 0 ? getGridMediaAspect(displayItems[0].displayMedia) : undefined
7911
+ )),
7912
+ [entriesMedia, isAutoHeight],
7913
+ );
7914
+ const customPlacement = useMemo(() => {
7915
+ if (!customLayout || !customSlots || !isPlacedLayout) return undefined;
7916
+ const beat = customLayout.beat ?? 0;
7917
+ const heights = customSlots.map((slot, index) => {
7918
+ // until the entries are measured, a media that tells its size gives the height it will take
7919
+ const aspects = entriesMedia[index].displayItems.map(({ displayMedia }) => getGridMediaAspect(displayMedia));
7920
+ const known = aspects.filter((aspect): aspect is number => aspect !== undefined);
7921
+ const estimate = isAutoHeight && known.length > 0 ? Math.max(...known.map(aspect => slot.width / aspect)) : slot.height;
7922
+ const height = measuredEntryHeights?.[index] ?? estimate;
7923
+ return beat > 0 ? Math.ceil(height / beat - 1e-3) * beat : height;
7924
+ });
7925
+ return placeCustomGridEntries(customLayout, customSlots, heights);
7926
+ }, [customLayout, customSlots, isPlacedLayout, isAutoHeight, entriesMedia, measuredEntryHeights]);
7927
+ const wrapperLayoutStyle: React.CSSProperties = customLayout
7928
+ ? {
7929
+ gridTemplateColumns: \`repeat(\${customLayout.columnsCount}, \${scalingValue(customLayout.columnWidth, isEditor)})\`,
7930
+ gridTemplateRows: customRows?.gridTemplateRows ?? 'auto',
7931
+ rowGap: 0,
7932
+ columnGap: scalingValue(customLayout.gutterWidth, isEditor),
7933
+ width: scalingValue(getCustomGridSpanWidth(customLayout, customLayout.columnsCount), isEditor),
7934
+ ...(customPlacement ? { position: 'relative', height: scalingValue(customPlacement.bottom, isEditor) } : {}),
7935
+ }
7936
+ : {
7937
+ gridTemplateColumns: \`repeat(\${columnsCount}, \${entryWidthScaled})\`,
7938
+ rowGap: shouldAlignEntries ? 0 : scalingValue(verticalGap ?? 0, isEditor),
7939
+ columnGap: scalingValue(gridLayout?.horizontalGap ?? 0, isEditor),
7940
+ width: scalingValue(gridLayout?.wrapperWidth ?? 0, isEditor),
7941
+ ...(shouldAlignEntries
7942
+ ? { [\`--\${P}-align-entries-row-gap\`]: scalingValue(verticalGap ?? 0, isEditor) }
7943
+ : {}),
7944
+ };
7531
7945
 
7532
- const lightboxPortalStyle = (() => {
7946
+ const containerRef = useRef<HTMLDivElement>(null);
7947
+
7948
+ const getLightboxPortalStyle = (): React.CSSProperties => {
7533
7949
  const style: Record<string, string> = { ...(colorVars as Record<string, string>) };
7534
7950
  const articleWidth = containerRef.current
7535
7951
  ? getComputedStyle(containerRef.current).getPropertyValue('--cntrl-article-width').trim()
@@ -7538,7 +7954,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7538
7954
  style['--cntrl-article-width'] = articleWidth;
7539
7955
  }
7540
7956
  return style as React.CSSProperties;
7541
- })();
7957
+ };
7542
7958
 
7543
7959
  const [lightboxOpen, setLightboxOpen] = useState(false);
7544
7960
  const [lightboxItems, setLightboxItems] = useState<GridMedia[]>([]);
@@ -7577,16 +7993,8 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7577
7993
  <div style={colorVars}>
7578
7994
  <div
7579
7995
  ref={containerRef}
7580
- className={\`\${P}-wrapper \${P}-type-\${type}\${shouldAlignEntries ? \` \${P}-align-entries\` : ''} \${P}-image-align-\${align} \${wrapperStateClasses}\`.trim()}
7581
- style={{
7582
- gridTemplateColumns: \`repeat(\${columnsCount}, \${entryWidthScaled})\`,
7583
- rowGap: shouldAlignEntries ? 0 : scalingValue(verticalGap ?? 0, isEditor),
7584
- columnGap: scalingValue(gridLayout.horizontalGap ?? 0, isEditor),
7585
- width: scalingValue(gridLayout.wrapperWidth ?? 0, isEditor),
7586
- ...(shouldAlignEntries
7587
- ? { [\`--\${P}-align-entries-row-gap\`]: scalingValue(verticalGap ?? 0, isEditor) }
7588
- : {}),
7589
- }}>
7996
+ 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()}
7997
+ style={wrapperLayoutStyle}>
7590
7998
  {cropContent.map((item: any, index: number) => {
7591
7999
  const hasTitle = hasText(item.title);
7592
8000
  const hasSubtitle = hasText(item.subtitle);
@@ -7596,11 +8004,40 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7596
8004
  const gridColumn = isPartialLastRow && index >= lastRowStartIndex
7597
8005
  ? \`\${lastRowStartColumn + (index - lastRowStartIndex)}\`
7598
8006
  : undefined;
8007
+ const customSlot = customSlots?.[index];
8008
+ const itemSize = customSlot?.width ?? size;
8009
+ const itemWidthScaled = scalingValue(itemSize, isEditor);
8010
+ const textBoxWidthStyle = \`calc(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`;
8011
+ const controlWidthStyle = scalingValue(itemSize * textBoxWidth / 100, isEditor);
8012
+ const { displayItems, lightboxItemsForEntry, lightboxIndexes } = entriesMedia[index];
8013
+ const mediaAspect = slider === 'off' ? entryMediaAspects[index] : undefined;
8014
+ const imageWrapperStyle = getImageWrapperStyle(
8015
+ itemWidthScaled,
8016
+ customSlot,
8017
+ { aspect: mediaAspect, isEmpty: displayItems.length === 0 },
8018
+ );
8019
+ const entryImageStyle = isAutoHeight && slider === 'off' && !mediaAspect
8020
+ ? { ...imageStyle, height: 'auto' }
8021
+ : imageStyle;
8022
+ const itemStyle: React.CSSProperties | undefined = customSlot && customLayout && customPlacement
8023
+ ? {
8024
+ position: 'absolute',
8025
+ left: scalingValue(customSlot.column * (customLayout.columnWidth + customLayout.gutterWidth), isEditor),
8026
+ top: scalingValue(customPlacement.tops[index], isEditor),
8027
+ width: itemWidthScaled,
8028
+ }
8029
+ : customSlot
8030
+ ? {
8031
+ gridColumn: customSlot.gridColumn,
8032
+ gridRow: customRows?.gridRows[index],
8033
+ alignSelf: 'start',
8034
+ }
8035
+ : gridColumn && !shouldAlignEntries ? { gridColumn } : undefined;
7599
8036
 
7600
8037
  const typeCTextBlock = isTextBeforeImage ? (
7601
8038
  <div className={\`\${P}-item-text-block\`}>
7602
8039
  {hasTitle && (
7603
- <p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleFieldCss, ...titleTextLeadingVars }}>
8040
+ <p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleTextStyle }}>
7604
8041
  {item.title}
7605
8042
  </p>
7606
8043
  )}
@@ -7615,7 +8052,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7615
8052
  />
7616
8053
  )}
7617
8054
  {hasSubtitle && (
7618
- <p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleFieldCss, ...subtitleTextLeadingVars }}>
8055
+ <p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleTextStyle }}>
7619
8056
  {item.subtitle}
7620
8057
  </p>
7621
8058
  )}
@@ -7645,7 +8082,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7645
8082
  />
7646
8083
  )}
7647
8084
  {hasTitle && (
7648
- <p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleFieldCss, ...titleTextLeadingVars }}>
8085
+ <p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleTextStyle }}>
7649
8086
  {item.title}
7650
8087
  </p>
7651
8088
  )}
@@ -7675,7 +8112,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7675
8112
  />
7676
8113
  )}
7677
8114
  {hasSubtitle && (
7678
- <p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleFieldCss, ...subtitleTextLeadingVars }}>
8115
+ <p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleTextStyle }}>
7679
8116
  {item.subtitle}
7680
8117
  </p>
7681
8118
  )}
@@ -7699,11 +8136,6 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7699
8136
  </LinkWrapper>
7700
8137
  );
7701
8138
 
7702
- const displayItems = getGridDisplayItems(item.gallery);
7703
- const lightboxItemsForEntry = displayItems
7704
- .filter(entry => entry.lightboxMedia)
7705
- .map(entry => entry.lightboxMedia!);
7706
-
7707
8139
  const imageContent = (
7708
8140
  <GridItemMediaWrapper className={imageWrapperClassName} style={imageWrapperStyle}>
7709
8141
  {displayItems.length === 0
@@ -7711,15 +8143,13 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7711
8143
  : slider === 'off'
7712
8144
  ?
7713
8145
  (() => {
7714
- const { displayMedia, lightboxMedia } = displayItems[0];
7715
- const lightboxIndex = lightboxMedia
7716
- ? lightboxItemsForEntry.findIndex(item => item.assetId === lightboxMedia.assetId)
7717
- : -1;
8146
+ const { displayMedia } = displayItems[0];
8147
+ const lightboxIndex = lightboxIndexes[0];
7718
8148
  return (
7719
8149
  <GridMediaItem
7720
8150
  media={displayMedia}
7721
8151
  className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
7722
- style={imageStyle}
8152
+ style={entryImageStyle}
7723
8153
  hasLightbox={lightbox === 'on'}
7724
8154
  onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
7725
8155
  ? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
@@ -7742,50 +8172,28 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7742
8172
  ))}
7743
8173
  </div>
7744
8174
  )}
7745
- <Splide
7746
- key={\`\${transition}-\${size}-\${direction}-\${sliderTiming}-\${containerWidth}-\${layoutId}\`}
7747
- className={\`\${P}-item-slider\`}
7748
- options={{
7749
- arrows: false,
7750
- pagination: false,
7751
- drag: false,
7752
- perPage: 1,
7753
- autoplay: true,
7754
- interval: sliderTiming * 1000,
7755
- width: '100%',
7756
- height: '100%',
7757
- speed: SLIDER_TRANSITION_MS,
7758
- type: transition === 'fade' ? 'fade' : 'loop',
7759
- rewind: transition === 'fade',
7760
- pauseOnHover: false,
7761
- pauseOnFocus: false,
7762
- direction: resolvedSplideDirection,
7763
- }}
7764
- onMoved={(splide) => {
7765
- if (direction !== 'random' || transition === 'fade') return;
7766
- handleRandomSlideMoved(splide);
7767
- }}
7768
- >
7769
- {displayItems.map(({ displayMedia, lightboxMedia }, imgIndex) => {
7770
- const lightboxIndex = lightboxMedia
7771
- ? lightboxItemsForEntry.findIndex(item => item.assetId === lightboxMedia.assetId)
7772
- : -1;
8175
+ <GridEntrySlider
8176
+ key={\`\${transition}-\${itemSize}-\${direction}-\${sliderTiming}-\${layoutId}-\${displayItems.length}\`}
8177
+ prefix={P}
8178
+ isFade={transition === 'fade'}
8179
+ direction={direction}
8180
+ intervalMs={sliderTiming * 1000}
8181
+ slides={displayItems.map(({ displayMedia }, imgIndex) => {
8182
+ const lightboxIndex = lightboxIndexes[imgIndex];
7773
8183
  return (
7774
- <SplideSlide key={imgIndex} data-slide-index={imgIndex}>
7775
- <GridMediaItem
7776
- media={displayMedia}
7777
- className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
7778
- style={imageStyle}
7779
- hasLightbox={lightbox === 'on'}
7780
- isSplideSlide
7781
- onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
7782
- ? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
7783
- : undefined}
7784
- />
7785
- </SplideSlide>
8184
+ <GridMediaItem
8185
+ media={displayMedia}
8186
+ className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
8187
+ style={imageStyle}
8188
+ hasLightbox={lightbox === 'on'}
8189
+ isSliderSlide
8190
+ onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
8191
+ ? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
8192
+ : undefined}
8193
+ />
7786
8194
  );
7787
8195
  })}
7788
- </Splide>
8196
+ />
7789
8197
  </>
7790
8198
  }
7791
8199
  </GridItemMediaWrapper>
@@ -7803,7 +8211,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7803
8211
  />
7804
8212
  <p
7805
8213
  className={titleTextClassName}
7806
- style={{ width: textBoxWidthStyle, ...titleFieldCss, ...titleTextLeadingVars }}
8214
+ style={{ width: textBoxWidthStyle, ...titleTextStyle }}
7807
8215
  >
7808
8216
  {item.title}
7809
8217
  </p>
@@ -7817,7 +8225,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7817
8225
  />
7818
8226
  <p
7819
8227
  className={subtitleTextClassName}
7820
- style={{ width: textBoxWidthStyle, ...subtitleFieldCss, ...subtitleTextLeadingVars }}
8228
+ style={{ width: textBoxWidthStyle, ...subtitleTextStyle }}
7821
8229
  >
7822
8230
  {item.subtitle}
7823
8231
  </p>
@@ -7837,16 +8245,18 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7837
8245
  <div
7838
8246
  key={index}
7839
8247
  className={\`\${P}-item\`.trim()}
7840
- style={gridColumn && !shouldAlignEntries ? { gridColumn } : undefined}
8248
+ style={itemStyle}
7841
8249
  >
7842
8250
  <div
7843
- className={\`\${isEditMode
7844
- ? \`\${P}-item-inner\`
8251
+ ref={(el) => { itemInnerRefs.current[index] = el; }}
8252
+ className={\`\${isEditMode
8253
+ ? \`\${P}-item-inner\`
7845
8254
  : \`\${P}-item-inner-hidden\`}\${shouldAlignEntries && isLastRow ? \` \${P}-item-inner-last-row\` : ''}\`.trim()}
7846
8255
  style={{
7847
8256
  width: (textBoxWidth ?? 0) > 100
7848
- ? \`calc(\${entryWidthScaled} * (\${textBoxWidth} / 100))\`
7849
- : entryWidthScaled,
8257
+ ? \`calc(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`
8258
+ : itemWidthScaled,
8259
+ ...(customSlot && !isTextOutside && !isAutoHeight ? { height: scalingValue(customSlot.height, isEditor) } : {}),
7850
8260
  ...(gridColumn && shouldAlignEntries ? { gridColumn } : {}),
7851
8261
  }}
7852
8262
  >
@@ -7892,7 +8302,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7892
8302
  {(!isEditor || isPreviewMode) && lightboxOpen && typeof document !== 'undefined' && lightbox === 'on' && (() => {
7893
8303
  const portalTarget = (portalId ? document.getElementById(portalId) : null) ?? document.body;
7894
8304
  return createPortal(
7895
- <div style={lightboxPortalStyle} data-selection="none">
8305
+ <div style={getLightboxPortalStyle()} data-selection="none">
7896
8306
  <Lightbox
7897
8307
  prefix={P}
7898
8308
  items={lightboxItems}
@@ -7929,17 +8339,38 @@ type GridLayoutConfig = {
7929
8339
  lockedParam?: 'wrapperWidth' | 'entryWidth' | 'horizontalGap' | null;
7930
8340
  };
7931
8341
 
8342
+ type CustomGridBlock = {
8343
+ column: number;
8344
+ span: number;
8345
+ top: number;
8346
+ height: number;
8347
+ };
8348
+
8349
+ type CustomGridLayout = {
8350
+ columnsCount: number;
8351
+ columnWidth: number;
8352
+ gutterWidth: number;
8353
+ maxWidth: number | null;
8354
+ verticalGap?: number;
8355
+ beat?: number;
8356
+ repeatHeight?: number;
8357
+ blocks: CustomGridBlock[];
8358
+ cellHeight?: 'manual' | 'auto';
8359
+ masonry?: 'off' | 'on';
8360
+ };
8361
+
7932
8362
  type GridSettings = {
7933
8363
  type: 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
7934
- gridLayout: GridLayoutConfig;
8364
+ gridLayout?: GridLayoutConfig;
8365
+ customGrid?: CustomGridLayout;
7935
8366
  textBoxWidth: number;
7936
- verticalGap: number;
7937
- entriesCount: number;
8367
+ verticalGap?: number;
8368
+ entriesCount?: number;
7938
8369
  lightbox: 'on' | 'off';
7939
- imageDisplay: {
8370
+ imageDisplay: 'fit' | 'cover' | {
7940
8371
  display: 'fit' | 'cover';
7941
- ratioValue: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
7942
- reversed: boolean;
8372
+ ratioValue?: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
8373
+ reversed?: boolean;
7943
8374
  };
7944
8375
  imageCorners?: number;
7945
8376
  lightboxImageDisplay?: 'fit' | 'cover' | { display?: 'fit' | 'cover' };
@@ -7949,8 +8380,9 @@ type GridSettings = {
7949
8380
  transition: 'fade' | 'slide',
7950
8381
  showText: 'always' | 'on hover';
7951
8382
  hover?: 'none' | 'zoom-in' | 'greyscale' | 'scale-down';
7952
- alignEntries: 'on' | 'off';
8383
+ alignEntries?: 'on' | 'off';
7953
8384
  align?: 'top' | 'center' | 'bottom';
8385
+ textGrowth?: 'inside' | 'outside';
7954
8386
  titleMarginTop: number;
7955
8387
  subtitleMarginTop: number;
7956
8388
  titleColor: string;
@@ -25317,4 +25749,4 @@ export function Waterfall({
25317
25749
  </>
25318
25750
  );
25319
25751
  }
25320
- `,C={[n.BurgerComponent.id]:e,[n.ChroniclesComponent.id]:t,[n.ClickGallerieComponent.id]:i,[n.FAQComponent.id]:o,[n.FormComponent.id]:r,[n.GridComponent.id]:a,[n.HelixComponent.id]:s,[n.HiveComponent.id]:l,[n.LightboxJournalComponent.id]:c,[n.LightboxStripComponent.id]:d,[n.ListComponent.id]:u,[n.MarqueeComponent.id]:g,[n.MarqueeTextComponent.id]:m,[n.MercuryComponent.id]:p,[n.OnelinerFormComponent.id]:h,[n.PretextComponent.id]:f,[n.ScaleComponent.id]:v,[n.SimpleButtonComponent.id]:P,[n.Slider20Component.id]:x,[n.TestimonialGridComponent.id]:b,[n.TestimonialSingleComponent.id]:y,[n.WaterfallComponent.id]:S};exports.componentSources=C;
25752
+ `,C={[n.BurgerComponent.id]:t,[n.ChroniclesComponent.id]:i,[n.ClickGallerieComponent.id]:o,[n.CustomGridComponent.id]:e,[n.FAQComponent.id]:r,[n.FormComponent.id]:a,[n.GridComponent.id]:e,[n.HelixComponent.id]:s,[n.HiveComponent.id]:l,[n.LightboxJournalComponent.id]:c,[n.LightboxStripComponent.id]:d,[n.ListComponent.id]:u,[n.MarqueeComponent.id]:g,[n.MarqueeTextComponent.id]:m,[n.MercuryComponent.id]:p,[n.OnelinerFormComponent.id]:h,[n.PretextComponent.id]:f,[n.ScaleComponent.id]:v,[n.SimpleButtonComponent.id]:P,[n.Slider20Component.id]:x,[n.TestimonialGridComponent.id]:b,[n.TestimonialSingleComponent.id]:y,[n.WaterfallComponent.id]:S};exports.componentSources=C;