@cntrl-site/components 1.0.118-alpha.1 → 1.0.118-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 c, M as d, 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-kkKhL_qt.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-Ds59v_47.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';
@@ -28,12 +28,11 @@ type BurgerShowInValue = string | Record<string, string>;
28
28
 
29
29
  type BurgerLink = {
30
30
  link?: {
31
- type?: 'url' | 'page' | 'anchor' | 'file';
31
+ type?: 'url' | 'page' | 'anchor';
32
32
  value?: string;
33
33
  target?: string;
34
34
  anchor?: string;
35
35
  url?: string;
36
- download?: string;
37
36
  };
38
37
  mode?: 'page' | 'url';
39
38
  page?: string;
@@ -258,11 +257,10 @@ function isBlankTarget(target?: string): boolean {
258
257
  }
259
258
 
260
259
  function getBurgerDest(item: BurgerLink): {
261
- type: 'url' | 'page' | 'anchor' | 'file';
260
+ type: 'url' | 'page' | 'anchor';
262
261
  value: string;
263
262
  target?: '_blank';
264
263
  anchor?: string;
265
- download?: string;
266
264
  } {
267
265
  const dest = item.link;
268
266
  if (dest && typeof dest === 'object') {
@@ -276,12 +274,8 @@ function getBurgerDest(item: BurgerLink): {
276
274
  if (dest.type === 'page') {
277
275
  return { type: 'page', value: dest.value ?? '', target, anchor: dest.anchor };
278
276
  }
279
- if (dest.type === 'file') {
280
- return { type: 'file', value: dest.value ?? '' };
281
- }
282
- // a published file link comes as its file's url, with the name to download it under
283
277
  if (typeof dest.url === 'string') {
284
- return { type: 'url', value: dest.url, target, download: typeof dest.download === 'string' ? dest.download : undefined };
278
+ return { type: 'url', value: dest.url, target };
285
279
  }
286
280
  }
287
281
  const target = isBlankTarget(item.openIn) ? '_blank' : undefined;
@@ -302,17 +296,12 @@ function resolveBurgerLink(item: BurgerLink, pages?: BurgerPageRef[]): {
302
296
  label: string;
303
297
  href: string;
304
298
  target?: '_blank';
305
- download?: string;
306
299
  } {
307
300
  const label = item.label || 'Link';
308
301
  const dest = getBurgerDest(item);
309
302
 
310
303
  if (dest.type === 'url') {
311
- return { label, href: dest.value, target: dest.target, download: dest.download };
312
- }
313
- if (dest.type === 'file') {
314
- // only the editor sees a file by its id, and downloads it through onLinkNavigate, right on the click
315
- return { label, href: dest.value ? '#' : '', target: '_blank' };
304
+ return { label, href: dest.value, target: dest.target };
316
305
  }
317
306
  if (dest.type === 'anchor') {
318
307
  const anchor = dest.value.replace(/^#/, '');
@@ -924,11 +913,10 @@ function renderTextPaddingControls(
924
913
  type ColorKeys = 'iconColor' | 'closeButtonColor' | 'linkColor' | 'openLinkColor' | 'compactIconColor' | 'compactLinkColor' | 'compactLogoColor' | 'compactBackgroundColor' | 'openLogoColor' | 'menuBackgroundColor' | 'overlayColor' | 'backgroundColor' | 'logoColor';
925
914
 
926
915
  export type BurgerLinkNavigateEvent = {
927
- mode: 'page' | 'url' | 'file';
916
+ mode: 'page' | 'url';
928
917
  href: string;
929
918
  page?: string;
930
919
  url?: string;
931
- file?: string;
932
920
  anchor?: string;
933
921
  target?: '_blank';
934
922
  };
@@ -1780,28 +1768,6 @@ function findAnchorTarget(hash: string): HTMLElement | null {
1780
1768
  return target instanceof HTMLElement ? target : null;
1781
1769
  }
1782
1770
 
1783
- // the file is on the cdn, another origin, where the download attribute alone opens it instead
1784
- function downloadFile(url: string, name: string) {
1785
- fetch(url)
1786
- .then((response) => {
1787
- if (!response.ok) throw new Error(\`Could not download \${url}: \${response.status}\`);
1788
- return response.blob();
1789
- })
1790
- .then((blob) => {
1791
- const objectUrl = URL.createObjectURL(blob);
1792
- const link = document.createElement('a');
1793
- link.href = objectUrl;
1794
- link.download = name || decodeURIComponent(url.split('?')[0].split('/').pop() ?? '');
1795
- document.body.appendChild(link);
1796
- link.click();
1797
- link.remove();
1798
- window.setTimeout(() => URL.revokeObjectURL(objectUrl), 0);
1799
- })
1800
- .catch(() => {
1801
- window.location.assign(url);
1802
- });
1803
- }
1804
-
1805
1771
  function scrollToAnchor(hash: string): boolean {
1806
1772
  const target = findAnchorTarget(hash);
1807
1773
  if (!target) return false;
@@ -1835,11 +1801,10 @@ function handleLinkClick(
1835
1801
  const resolved = resolveBurgerLink(item, pages);
1836
1802
  const dest = getBurgerDest(item);
1837
1803
  const navigateEvent: BurgerLinkNavigateEvent = {
1838
- mode: dest.type === 'url' || dest.type === 'file' ? dest.type : 'page',
1804
+ mode: dest.type === 'url' ? 'url' : 'page',
1839
1805
  href: resolved.href || href,
1840
1806
  page: dest.type === 'page' ? dest.value : undefined,
1841
1807
  url: dest.type === 'url' ? dest.value : undefined,
1842
- file: dest.type === 'file' ? dest.value : undefined,
1843
1808
  anchor: dest.type === 'anchor'
1844
1809
  ? dest.value.replace(/^#/, '')
1845
1810
  : (dest.anchor ?? '').replace(/^#/, ''),
@@ -1861,14 +1826,6 @@ function handleLinkClick(
1861
1826
  return;
1862
1827
  }
1863
1828
 
1864
- const download = item ? getBurgerDest(item).download : undefined;
1865
- if (download !== undefined && href && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey) {
1866
- event.preventDefault();
1867
- downloadFile(href, download);
1868
- onClose();
1869
- return;
1870
- }
1871
-
1872
1829
  if (!opensInNewTab && hash && isSameDocumentHref(href) && findAnchorTarget(hash)) {
1873
1830
  event.preventDefault();
1874
1831
  runAfterClose(() => scrollToAnchor(hash));
@@ -2474,13 +2431,12 @@ export function Burger({
2474
2431
  const showOpenNavControls = showControls && isOpen;
2475
2432
 
2476
2433
  const renderOpenNavItems = (linkClassName: string) => items.filter((item) => isVisibleInOpenNav(item, layoutId)).map((item, index) => {
2477
- const { label, href, target, download } = resolveBurgerLink(item, pages);
2434
+ const { label, href, target } = resolveBurgerLink(item, pages);
2478
2435
  const linkNode = href ? (
2479
2436
  <a
2480
2437
  href={href}
2481
2438
  target={target}
2482
2439
  rel={target === '_blank' ? 'noopener noreferrer' : undefined}
2483
- download={download}
2484
2440
  className={\`\${linkClassName} \${P}-has-href\`}
2485
2441
  onClick={(event) => onNavLinkClick(event, item)}
2486
2442
  >
@@ -2592,7 +2548,7 @@ export function Burger({
2592
2548
  };
2593
2549
 
2594
2550
  const renderNavLink = (item: BurgerLink, index: number) => {
2595
- const { label, href, target, download } = resolveBurgerLink(item, pages);
2551
+ const { label, href, target } = resolveBurgerLink(item, pages);
2596
2552
  const textContent = (
2597
2553
  <span className={navLinkTextClassName} style={navLinkTextStyle}>
2598
2554
  {renderMultilineText(label)}
@@ -2611,7 +2567,6 @@ export function Burger({
2611
2567
  href={href}
2612
2568
  target={target}
2613
2569
  rel={target === '_blank' ? 'noopener noreferrer' : undefined}
2614
- download={download}
2615
2570
  className={\`\${P}-nav-link \${P}-has-href\`}
2616
2571
  onClick={(event) => onNavLinkClick(event, item)}
2617
2572
  >
@@ -2729,7 +2684,7 @@ export function Burger({
2729
2684
  </div>
2730
2685
  );
2731
2686
  }
2732
- `, w = `import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
2687
+ `, $ = `import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
2733
2688
  import { createPortal } from 'react-dom';
2734
2689
  import cn from 'classnames';
2735
2690
  import { CommonComponentProps } from '../props';
@@ -3776,7 +3731,7 @@ export function Chronicles({
3776
3731
  </>
3777
3732
  );
3778
3733
  }
3779
- `, C = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3734
+ `, I = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3780
3735
  import { CommonComponentProps } from '../props';
3781
3736
  import { LinkWrapper, useScopedStyles, type ContentLink } from '../utils/index';
3782
3737
 
@@ -4305,7 +4260,7 @@ export function ClickGallerie({ settings, content = [], isEditor }: ClickGalleri
4305
4260
  </>
4306
4261
  );
4307
4262
  }
4308
- `, $ = `import { useCallback, useEffect, useMemo, useState } from 'react';
4263
+ `, E = `import { useCallback, useEffect, useMemo, useState } from 'react';
4309
4264
  import cn from 'classnames';
4310
4265
  import { CommonComponentProps } from '../props';
4311
4266
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index';
@@ -5049,7 +5004,7 @@ export function FAQ({ settings, content, isEditor, isPreviewMode, isEditMode, ac
5049
5004
  </>
5050
5005
  );
5051
5006
  }
5052
- `, I = `import React, { useMemo, useState } from 'react';
5007
+ `, T = `import React, { useMemo, useState } from 'react';
5053
5008
  import { CommonComponentProps } from '../props';
5054
5009
  import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
5055
5010
  import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
@@ -5687,7 +5642,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
5687
5642
  };
5688
5643
 
5689
5644
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
5690
- `, E = `import { Splide, SplideSlide } from '@splidejs/react-splide';
5645
+ `, n = `import { Splide, SplideSlide } from '@splidejs/react-splide';
5691
5646
  import '@splidejs/react-splide/css/core';
5692
5647
  import { CommonComponentProps } from '../props';
5693
5648
  import { EmbedMediaFrame, getEmbedAspect, getEmbedPlayback, isEmbedMedia } from '../utils/index';
@@ -5825,6 +5780,13 @@ function getCSS(P: string): string {
5825
5780
  flex-direction: column;
5826
5781
  align-items: center;
5827
5782
  }
5783
+ .\${P}-custom-layout .\${P}-item-image-link {
5784
+ flex: 1 1 0%;
5785
+ min-height: 0;
5786
+ }
5787
+ .\${P}-custom-layout.\${P}-text-outside .\${P}-item-image-link {
5788
+ flex: none;
5789
+ }
5828
5790
  .\${P}-item-text-link {
5829
5791
  display: flex;
5830
5792
  flex-direction: column;
@@ -7346,11 +7308,94 @@ function resolveLightboxImageDisplay(
7346
7308
  return value?.display === 'cover' ? 'cover' : 'fit';
7347
7309
  }
7348
7310
 
7311
+ function getCustomGridSpanWidth(layout: CustomGridLayout, span: number): number {
7312
+ return layout.columnWidth * span + layout.gutterWidth * Math.max(0, span - 1);
7313
+ }
7314
+
7315
+ type CustomGridSlot = {
7316
+ // first column the entry covers and how many, kept in the layout's columns
7317
+ column: number;
7318
+ span: number;
7319
+ width: number;
7320
+ top: number;
7321
+ height: number;
7322
+ gridColumn: string;
7323
+ gridRow: string;
7324
+ };
7325
+
7326
+ function getCustomGridBlocksBottom(layout: CustomGridLayout): number {
7327
+ return layout.blocks.reduce((bottom, block) => Math.max(bottom, Math.max(0, block.top) + Math.max(0, block.height)), 0);
7328
+ }
7329
+
7330
+ function getCustomGridVerticalGap(layout: CustomGridLayout): number {
7331
+ if (typeof layout.verticalGap === 'number') return Math.max(0, layout.verticalGap);
7332
+ return Math.max(0, (layout.repeatHeight ?? 0) - getCustomGridBlocksBottom(layout));
7333
+ }
7334
+
7335
+ // entries fill the layout's blocks in order, one group after another
7336
+ function getCustomGridSlot(layout: CustomGridLayout, index: number): CustomGridSlot {
7337
+ const block = layout.blocks[index % layout.blocks.length];
7338
+ const span = Math.min(Math.max(1, Math.round(block.span)), layout.columnsCount);
7339
+ const column = Math.min(Math.max(0, Math.round(block.column)), layout.columnsCount - span);
7340
+ return {
7341
+ column,
7342
+ span,
7343
+ width: getCustomGridSpanWidth(layout, span),
7344
+ top: Math.max(0, block.top),
7345
+ height: Math.max(0, block.height),
7346
+ gridColumn: \`\${column + 1} / span \${span}\`,
7347
+ gridRow: \`\${Math.floor(index / layout.blocks.length) + 1}\`,
7348
+ };
7349
+ }
7350
+
7351
+ // the first of the grid's beats at or under \`value\`, from the top of the group
7352
+ function snapDownToCustomGridBeat(layout: CustomGridLayout, value: number): number {
7353
+ const beat = layout.beat ?? 0;
7354
+ return beat > 0 ? Math.ceil(value / beat - 1e-6) * beat : value;
7355
+ }
7356
+
7357
+ /**
7358
+ * With the text outside the blocks, every entry's text takes room under its block: an entry of its
7359
+ * group under it in the same columns keeps where it is drawn, moved along with the entry above,
7360
+ * unless that text reaches it, and then goes onto the first beat under the text. The group grows to
7361
+ * the first beat under its lowest text. Text heights, tops and group heights are in layout units,
7362
+ * like the blocks'.
7363
+ */
7364
+ function getCustomGridOutsideTextPlacement(layout: CustomGridLayout, textHeights: number[]) {
7365
+ const slots = textHeights.map((_, index) => getCustomGridSlot(layout, index));
7366
+ const tops = slots.map(slot => slot.top);
7367
+ const groupHeights: number[] = [];
7368
+ for (let groupStart = 0; groupStart < slots.length; groupStart += layout.blocks.length) {
7369
+ const group = slots
7370
+ .map((slot, index) => ({ slot, index }))
7371
+ .slice(groupStart, groupStart + layout.blocks.length)
7372
+ .sort((a, b) => a.slot.top - b.slot.top);
7373
+ let bottom = getCustomGridBlocksBottom(layout);
7374
+ for (const { slot, index } of group) {
7375
+ let top = slot.top;
7376
+ for (const { slot: above, index: aboveIndex } of group) {
7377
+ const isAbove = above.top + above.height <= slot.top + 1e-6 && aboveIndex !== index;
7378
+ const sharesColumns = above.column < slot.column + slot.span && slot.column < above.column + above.span;
7379
+ if (isAbove && sharesColumns) {
7380
+ const textBottom = tops[aboveIndex] + above.height + textHeights[aboveIndex];
7381
+ const drawnTop = slot.top + tops[aboveIndex] - above.top;
7382
+ top = Math.max(top, drawnTop >= textBottom - 1e-6 ? drawnTop : snapDownToCustomGridBeat(layout, textBottom));
7383
+ }
7384
+ }
7385
+ tops[index] = top;
7386
+ bottom = Math.max(bottom, tops[index] + slot.height + textHeights[index]);
7387
+ }
7388
+ groupHeights.push(snapDownToCustomGridBeat(layout, bottom));
7389
+ }
7390
+ return { tops, groupHeights };
7391
+ }
7392
+
7349
7393
  export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, metadata, activeEvent, layoutId, portalId }: GridProps) {
7350
7394
  const { prefix: P } = useScopedStyles();
7351
7395
  const {
7352
7396
  type = 'a',
7353
7397
  gridLayout,
7398
+ customGrid,
7354
7399
  textBoxWidth = 100,
7355
7400
  verticalGap,
7356
7401
  entriesCount,
@@ -7398,6 +7443,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7398
7443
  hover = 'none',
7399
7444
  alignEntries = 'off',
7400
7445
  align = 'top',
7446
+ textGrowth = 'inside',
7401
7447
  } = settings;
7402
7448
 
7403
7449
  const resolvedTitleTextStyle: TextStyles = {
@@ -7487,7 +7533,16 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7487
7533
  const hoverEffectClass = hover !== 'none' && (!isEditor || isPreviewMode) ? \` \${P}-hover-\${hover}\` : '';
7488
7534
  const wrapperStateClasses = \`\${stateClass}\${showTextOnHover ? \` \${P}-show-text-hover\` : ''}\${hoverEffectClass}\`.trim();
7489
7535
 
7490
- const resEntriesCount = entriesCount === 0 ? Infinity : entriesCount;
7536
+ // a custom layout places entries itself, in place of the columns, gap and entries count: its
7537
+ // group of blocks repeats for as many entries as there are. Stored, it is only the preset it is
7538
+ // linked to; the CMS and the site put the blocks in before it gets here
7539
+ const customLayout = customGrid && Array.isArray(customGrid.blocks) && customGrid.blocks.length > 0 ? customGrid : undefined;
7540
+ const resEntriesCount = customLayout || entriesCount === 0 ? Infinity : entriesCount;
7541
+ // outside, the media fills the block and the text takes room of its own beyond it: below the
7542
+ // media, or above it when the type puts the text first, moving the entries under it down
7543
+ const isTextOutside = !!customLayout && textGrowth === 'outside';
7544
+ const itemInnerRefs = useRef<(HTMLDivElement | null)[]>([]);
7545
+ const [customTextHeights, setCustomTextHeights] = useState<number[]>([]);
7491
7546
 
7492
7547
  const cropContent = (content ?? []).slice(0, resEntriesCount);
7493
7548
  const lightboxMediaToPreload = useMemo(
@@ -7495,23 +7550,24 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7495
7550
  [cropContent, lightbox],
7496
7551
  );
7497
7552
 
7498
- const size = gridLayout.entryWidth ?? 0.2;
7553
+ const size = gridLayout?.entryWidth ?? 0.2;
7499
7554
 
7500
- const isCover = imageDisplay?.display === 'cover';
7501
- const ratioValue = imageDisplay?.ratioValue ?? '1:1';
7502
- const ratioReversed = imageDisplay?.reversed ?? false;
7555
+ const imageDisplaySettings = typeof imageDisplay === 'string' ? { display: imageDisplay } : imageDisplay;
7556
+ const isCover = imageDisplaySettings?.display === 'cover';
7557
+ const ratioValue = imageDisplaySettings?.ratioValue ?? '1:1';
7558
+ const ratioReversed = imageDisplaySettings?.reversed ?? false;
7503
7559
  const [rW, rH] = ratioValue.split(':').map(Number);
7504
7560
  const effW = ratioReversed ? rH : rW;
7505
7561
  const effH = ratioReversed ? rW : rH;
7506
7562
  const aspectRatio = \`\${effW} / \${effH}\`;
7507
7563
 
7508
- const columnsCount = gridLayout.columnsCount;
7564
+ const columnsCount = gridLayout?.columnsCount ?? 1;
7509
7565
  const entryWidthScaled = scalingValue(size ?? 0, isEditor);
7510
- const imageWrapperWidth = entryWidthScaled;
7511
- const isFitSlider = !isCover && slider !== 'off';
7566
+ // a custom block sets the entry's height, so the fit slider has nothing to size it by
7567
+ const isFitSlider = !customLayout && !isCover && slider !== 'off';
7512
7568
 
7513
7569
  const itemsInLastRow = cropContent.length % columnsCount || columnsCount;
7514
- const isPartialLastRow = itemsInLastRow < columnsCount && cropContent.length > 0;
7570
+ const isPartialLastRow = !customLayout && itemsInLastRow < columnsCount && cropContent.length > 0;
7515
7571
  const lastRowStartIndex = cropContent.length - itemsInLastRow;
7516
7572
  const lastRowStartColumn = isPartialLastRow
7517
7573
  ? Math.floor((columnsCount - itemsInLastRow) / 2) + 1
@@ -7519,19 +7575,23 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7519
7575
 
7520
7576
  const imageBorderRadius = imageCorners ? scalingValue(imageCorners, isEditor) : undefined;
7521
7577
 
7522
- const imageWrapperStyle: React.CSSProperties = {
7523
- width: imageWrapperWidth,
7524
- ...(isCover
7525
- ? { aspectRatio, height: 'auto', overflow: 'hidden' }
7526
- : { height: 'auto' }),
7578
+ const getImageWrapperStyle = (entryWidth: string, slot?: CustomGridSlot): React.CSSProperties => ({
7579
+ width: entryWidth,
7580
+ // in a custom block the media takes whatever the entry's text leaves of the block's height,
7581
+ // or the whole block when the text goes outside it
7582
+ ...(slot
7583
+ ? isTextOutside
7584
+ ? { height: scalingValue(slot.height, isEditor), flexShrink: 0, overflow: 'hidden' }
7585
+ : { flex: '1 1 0%', minHeight: 0, overflow: 'hidden' }
7586
+ : isCover
7587
+ ? { aspectRatio, height: 'auto', overflow: 'hidden' }
7588
+ : { height: 'auto' }),
7527
7589
  ...(imageBorderRadius ? { borderRadius: imageBorderRadius, overflow: 'hidden' } : {}),
7528
- };
7590
+ });
7529
7591
 
7530
7592
  const imageWrapperClassName = \`\${P}-item-image-wrapper\${isFitSlider ? \` \${P}-item-image-wrapper-fit-slider\` : ''}\`.trim();
7531
7593
  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);
7594
+ const shouldAlignEntries = !customLayout && alignEntries === 'on';
7535
7595
 
7536
7596
  const imageRadiusStyle = imageBorderRadius
7537
7597
  ? { borderRadius: imageBorderRadius, [MEDIA_RADIUS_VAR]: imageBorderRadius } as React.CSSProperties
@@ -7551,9 +7611,68 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7551
7611
  width: 'auto',
7552
7612
  height: 'auto',
7553
7613
  maxWidth: '100%',
7614
+ ...(customLayout ? { maxHeight: '100%' } : {}),
7554
7615
  ...imageRadiusStyle,
7555
7616
  };
7556
7617
 
7618
+ // the text's height is only known once laid out: what an entry measures beyond its media, in
7619
+ // layout units, the layout's whole width taken as the wrapper's
7620
+ const customGridWidth = customLayout ? getCustomGridSpanWidth(customLayout, customLayout.columnsCount) : 0;
7621
+ useLayoutEffect(() => {
7622
+ if (!isTextOutside) {
7623
+ setCustomTextHeights(prev => (prev.length > 0 ? [] : prev));
7624
+ return;
7625
+ }
7626
+ const wrapper = containerRef.current;
7627
+ const inners = itemInnerRefs.current.slice(0, cropContent.length);
7628
+ const measure = () => {
7629
+ const unit = wrapper && customGridWidth > 0 ? wrapper.offsetWidth / customGridWidth : 0;
7630
+ const heights = inners.map((inner) => {
7631
+ const media = inner?.querySelector<HTMLElement>(\`.\${P}-item-image-wrapper\`);
7632
+ return inner && media && unit > 0 ? Math.max(0, inner.offsetHeight - media.offsetHeight) / unit : 0;
7633
+ });
7634
+ setCustomTextHeights(prev => (
7635
+ prev.length === heights.length && prev.every((height, index) => Math.abs(height - heights[index]) < 1e-5)
7636
+ ? prev
7637
+ : heights
7638
+ ));
7639
+ };
7640
+ measure();
7641
+ const ro = new ResizeObserver(measure);
7642
+ if (wrapper) ro.observe(wrapper);
7643
+ inners.forEach(inner => inner && ro.observe(inner));
7644
+ return () => ro.disconnect();
7645
+ }, [isTextOutside, cropContent.length, customGridWidth, P]);
7646
+ const customOutsideText = customLayout && isTextOutside
7647
+ ? getCustomGridOutsideTextPlacement(customLayout, cropContent.map((_: unknown, index: number) => customTextHeights[index] ?? 0))
7648
+ : undefined;
7649
+
7650
+ const customRowsCount = customLayout ? Math.ceil(cropContent.length / customLayout.blocks.length) : 0;
7651
+ const customGroupHeight = customLayout ? scalingValue(getCustomGridBlocksBottom(customLayout), isEditor) : '';
7652
+ const wrapperLayoutStyle: React.CSSProperties = customLayout
7653
+ ? {
7654
+ gridTemplateColumns: \`repeat(\${customLayout.columnsCount}, \${scalingValue(customLayout.columnWidth, isEditor)})\`,
7655
+ // every group keeps the height of its blocks, or of the beats its text outside them takes,
7656
+ // but the last, which ends where its entries do
7657
+ gridTemplateRows: customRowsCount > 1
7658
+ ? customOutsideText
7659
+ ? \`\${customOutsideText.groupHeights.slice(0, -1).map(height => \`minmax(\${scalingValue(height, isEditor)}, auto)\`).join(' ')} auto\`
7660
+ : \`repeat(\${customRowsCount - 1}, minmax(\${customGroupHeight}, auto)) auto\`
7661
+ : 'auto',
7662
+ rowGap: scalingValue(getCustomGridVerticalGap(customLayout), isEditor),
7663
+ columnGap: scalingValue(customLayout.gutterWidth, isEditor),
7664
+ width: scalingValue(getCustomGridSpanWidth(customLayout, customLayout.columnsCount), isEditor),
7665
+ }
7666
+ : {
7667
+ gridTemplateColumns: \`repeat(\${columnsCount}, \${entryWidthScaled})\`,
7668
+ rowGap: shouldAlignEntries ? 0 : scalingValue(verticalGap ?? 0, isEditor),
7669
+ columnGap: scalingValue(gridLayout?.horizontalGap ?? 0, isEditor),
7670
+ width: scalingValue(gridLayout?.wrapperWidth ?? 0, isEditor),
7671
+ ...(shouldAlignEntries
7672
+ ? { [\`--\${P}-align-entries-row-gap\`]: scalingValue(verticalGap ?? 0, isEditor) }
7673
+ : {}),
7674
+ };
7675
+
7557
7676
  const [containerWidth, setContainerWidth] = useState(0);
7558
7677
  const containerRef = useRef<HTMLDivElement>(null);
7559
7678
 
@@ -7623,16 +7742,8 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7623
7742
  <div style={colorVars}>
7624
7743
  <div
7625
7744
  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
- }}>
7745
+ className={\`\${P}-wrapper \${P}-type-\${type}\${shouldAlignEntries ? \` \${P}-align-entries\` : ''}\${customLayout ? \` \${P}-custom-layout\` : ''}\${isTextOutside ? \` \${P}-text-outside\` : ''} \${P}-image-align-\${align} \${wrapperStateClasses}\`.trim()}
7746
+ style={wrapperLayoutStyle}>
7636
7747
  {cropContent.map((item: any, index: number) => {
7637
7748
  const hasTitle = hasText(item.title);
7638
7749
  const hasSubtitle = hasText(item.subtitle);
@@ -7642,6 +7753,20 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7642
7753
  const gridColumn = isPartialLastRow && index >= lastRowStartIndex
7643
7754
  ? \`\${lastRowStartColumn + (index - lastRowStartIndex)}\`
7644
7755
  : undefined;
7756
+ const customSlot = customLayout ? getCustomGridSlot(customLayout, index) : undefined;
7757
+ const itemSize = customSlot?.width ?? size;
7758
+ const itemWidthScaled = scalingValue(itemSize, isEditor);
7759
+ const textBoxWidthStyle = \`calc(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`;
7760
+ const controlWidthStyle = scalingValue(itemSize * textBoxWidth / 100, isEditor);
7761
+ const imageWrapperStyle = getImageWrapperStyle(itemWidthScaled, customSlot);
7762
+ const itemStyle: React.CSSProperties | undefined = customSlot
7763
+ ? {
7764
+ gridColumn: customSlot.gridColumn,
7765
+ gridRow: customSlot.gridRow,
7766
+ alignSelf: 'start',
7767
+ marginTop: scalingValue(customOutsideText?.tops[index] ?? customSlot.top, isEditor),
7768
+ }
7769
+ : gridColumn && !shouldAlignEntries ? { gridColumn } : undefined;
7645
7770
 
7646
7771
  const typeCTextBlock = isTextBeforeImage ? (
7647
7772
  <div className={\`\${P}-item-text-block\`}>
@@ -7789,7 +7914,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7789
7914
  </div>
7790
7915
  )}
7791
7916
  <Splide
7792
- key={\`\${transition}-\${size}-\${direction}-\${sliderTiming}-\${containerWidth}-\${layoutId}\`}
7917
+ key={\`\${transition}-\${itemSize}-\${direction}-\${sliderTiming}-\${containerWidth}-\${layoutId}\`}
7793
7918
  className={\`\${P}-item-slider\`}
7794
7919
  options={{
7795
7920
  arrows: false,
@@ -7883,16 +8008,18 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7883
8008
  <div
7884
8009
  key={index}
7885
8010
  className={\`\${P}-item\`.trim()}
7886
- style={gridColumn && !shouldAlignEntries ? { gridColumn } : undefined}
8011
+ style={itemStyle}
7887
8012
  >
7888
8013
  <div
7889
- className={\`\${isEditMode
7890
- ? \`\${P}-item-inner\`
8014
+ ref={(el) => { itemInnerRefs.current[index] = el; }}
8015
+ className={\`\${isEditMode
8016
+ ? \`\${P}-item-inner\`
7891
8017
  : \`\${P}-item-inner-hidden\`}\${shouldAlignEntries && isLastRow ? \` \${P}-item-inner-last-row\` : ''}\`.trim()}
7892
8018
  style={{
7893
8019
  width: (textBoxWidth ?? 0) > 100
7894
- ? \`calc(\${entryWidthScaled} * (\${textBoxWidth} / 100))\`
7895
- : entryWidthScaled,
8020
+ ? \`calc(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`
8021
+ : itemWidthScaled,
8022
+ ...(customSlot && !isTextOutside ? { height: scalingValue(customSlot.height, isEditor) } : {}),
7896
8023
  ...(gridColumn && shouldAlignEntries ? { gridColumn } : {}),
7897
8024
  }}
7898
8025
  >
@@ -7975,17 +8102,45 @@ type GridLayoutConfig = {
7975
8102
  lockedParam?: 'wrapperWidth' | 'entryWidth' | 'horizontalGap' | null;
7976
8103
  };
7977
8104
 
8105
+ type CustomGridBlock = {
8106
+ // first column the block covers, from 0
8107
+ column: number;
8108
+ span: number;
8109
+ // offset from the top of its group
8110
+ top: number;
8111
+ // height of the whole entry: its media fills what the text leaves
8112
+ height: number;
8113
+ };
8114
+
8115
+ // lengths are fractions of the layout width, like the article grid's
8116
+ type CustomGridLayout = {
8117
+ columnsCount: number;
8118
+ columnWidth: number;
8119
+ gutterWidth: number;
8120
+ maxWidth: number | null;
8121
+ // space between one group of blocks and the next
8122
+ verticalGap?: number;
8123
+ // the article grid's beat: entries the text outside the blocks pushes down land on it; 0, or
8124
+ // missing from layouts resolved before it, when there is none
8125
+ beat?: number;
8126
+ // layouts saved before the vertical gap kept the height of a whole group instead
8127
+ repeatHeight?: number;
8128
+ blocks: CustomGridBlock[];
8129
+ };
8130
+
7978
8131
  type GridSettings = {
7979
8132
  type: 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
7980
- gridLayout: GridLayoutConfig;
8133
+ // one of the two places entries: Neptune's columns, or a layout drawn in the custom grid builder
8134
+ gridLayout?: GridLayoutConfig;
8135
+ customGrid?: CustomGridLayout;
7981
8136
  textBoxWidth: number;
7982
- verticalGap: number;
7983
- entriesCount: number;
8137
+ verticalGap?: number;
8138
+ entriesCount?: number;
7984
8139
  lightbox: 'on' | 'off';
7985
- imageDisplay: {
8140
+ imageDisplay: 'fit' | 'cover' | {
7986
8141
  display: 'fit' | 'cover';
7987
- ratioValue: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
7988
- reversed: boolean;
8142
+ ratioValue?: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
8143
+ reversed?: boolean;
7989
8144
  };
7990
8145
  imageCorners?: number;
7991
8146
  lightboxImageDisplay?: 'fit' | 'cover' | { display?: 'fit' | 'cover' };
@@ -7995,8 +8150,10 @@ type GridSettings = {
7995
8150
  transition: 'fade' | 'slide',
7996
8151
  showText: 'always' | 'on hover';
7997
8152
  hover?: 'none' | 'zoom-in' | 'greyscale' | 'scale-down';
7998
- alignEntries: 'on' | 'off';
8153
+ alignEntries?: 'on' | 'off';
7999
8154
  align?: 'top' | 'center' | 'bottom';
8155
+ // with a custom layout: whether a block holds the entry's text or only its media
8156
+ textGrowth?: 'inside' | 'outside';
8000
8157
  titleMarginTop: number;
8001
8158
  subtitleMarginTop: number;
8002
8159
  titleColor: string;
@@ -8043,7 +8200,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
8043
8200
  };
8044
8201
 
8045
8202
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
8046
- `, T = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
8203
+ `, R = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
8047
8204
  import { CommonComponentProps } from '../props';
8048
8205
  import { scalingValue } from '../utils/scalingValue';
8049
8206
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -8616,7 +8773,7 @@ export function Helix({
8616
8773
  </>
8617
8774
  );
8618
8775
  }
8619
- `, R = `import { CommonComponentProps } from '../props';
8776
+ `, M = `import { CommonComponentProps } from '../props';
8620
8777
  import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, scalingValue, useLazyVideos, useScopedStyles } from '../utils/index';
8621
8778
  import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
8622
8779
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
@@ -11068,7 +11225,7 @@ export function Hive({
11068
11225
  </>
11069
11226
  );
11070
11227
  }
11071
- `, M = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
11228
+ `, L = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
11072
11229
  import { createPortal } from 'react-dom';
11073
11230
  import { CommonComponentProps } from '../props';
11074
11231
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -11871,7 +12028,7 @@ export type LightboxJournalSettings = {
11871
12028
  closeIconColor: string;
11872
12029
  closeIconHoverColor: string;
11873
12030
  };
11874
- `, L = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
12031
+ `, k = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
11875
12032
  import { createPortal } from 'react-dom';
11876
12033
  import { CommonComponentProps } from '../props';
11877
12034
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -12455,7 +12612,7 @@ export const LightboxStrip = ({ settings, content, isEditor, isEditMode, isPrevi
12455
12612
  </>
12456
12613
  );
12457
12614
  };
12458
- `, k = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
12615
+ `, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
12459
12616
  import { createPortal } from 'react-dom';
12460
12617
  import { CommonComponentProps } from '../props';
12461
12618
  import { buildColorVars, EmbedMediaFrame, isEmbedMedia, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -15560,7 +15717,7 @@ export function List({ settings, content, isEditor, isPreviewMode, isEditMode, a
15560
15717
  </>
15561
15718
  );
15562
15719
  }
15563
- `, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
15720
+ `, N = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
15564
15721
  import cn from 'classnames';
15565
15722
  import { CommonComponentProps } from '../props';
15566
15723
  import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -16418,7 +16575,7 @@ type MarqueeProps = {
16418
16575
  isPreviewMode?: boolean;
16419
16576
  isEditMode?: boolean;
16420
16577
  } & CommonComponentProps;
16421
- `, N = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
16578
+ `, H = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
16422
16579
  import cn from 'classnames';
16423
16580
  import { CommonComponentProps } from '../props';
16424
16581
  import { LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -17361,7 +17518,7 @@ type MarqueeTextProps = {
17361
17518
  isPreviewMode?: boolean;
17362
17519
  isEditMode?: boolean;
17363
17520
  } & CommonComponentProps;
17364
- `, H = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
17521
+ `, O = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
17365
17522
  import { createPortal } from 'react-dom';
17366
17523
  import type React from 'react';
17367
17524
  import { CommonComponentProps } from '../props';
@@ -19843,7 +20000,7 @@ export function Mercury({
19843
20000
  </>
19844
20001
  );
19845
20002
  }
19846
- `, O = `import React, { useMemo, useState } from 'react';
20003
+ `, _ = `import React, { useMemo, useState } from 'react';
19847
20004
  import { CommonComponentProps } from '../props';
19848
20005
  import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
19849
20006
  import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
@@ -20422,7 +20579,7 @@ const COLOR_VAR_MAP: Record<OnelinerColorKeys, string> = {
20422
20579
  };
20423
20580
 
20424
20581
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
20425
- `, _ = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
20582
+ `, W = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
20426
20583
  import type React from 'react';
20427
20584
  import { CommonComponentProps } from '../props';
20428
20585
  import { scalingValue, useScopedStyles } from '../utils/index';
@@ -21889,7 +22046,7 @@ export function Scale({ settings, content, isEditor, isPreviewMode }: ScaleProps
21889
22046
  </>
21890
22047
  );
21891
22048
  }
21892
- `, W = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
22049
+ `, D = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
21893
22050
  import { SvgImage } from '../helpers/SvgImage/SvgImage';
21894
22051
  import { CommonComponentProps } from '../props';
21895
22052
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
@@ -22521,7 +22678,7 @@ export function SimpleButton({ settings, isEditor, isPreviewMode, activeEvent, h
22521
22678
  </>
22522
22679
  );
22523
22680
  }
22524
- `, D = `import React, { useCallback, useEffect, useRef, useState } from 'react';
22681
+ `, B = `import React, { useCallback, useEffect, useRef, useState } from 'react';
22525
22682
  import cn from 'classnames';
22526
22683
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
22527
22684
  import { scalingValue } from '../utils/scalingValue';
@@ -23703,7 +23860,7 @@ function ArrowIcon({ color, className }: { color: string, className: string }) {
23703
23860
  </svg>
23704
23861
  );
23705
23862
  }
23706
- `, B = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
23863
+ `, z = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
23707
23864
  import cn from 'classnames';
23708
23865
  import { CommonComponentProps } from '../props';
23709
23866
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
@@ -24334,7 +24491,7 @@ type TestimonialsSettings = {
24334
24491
  logoHeight: number;
24335
24492
  captionMarginTop: number;
24336
24493
  };
24337
- `, z = `import cn from 'classnames';
24494
+ `, V = `import cn from 'classnames';
24338
24495
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
24339
24496
  import { CommonComponentProps } from '../props';
24340
24497
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
@@ -24830,7 +24987,7 @@ type TestimonialsSettings = {
24830
24987
  icon?: string | null;
24831
24988
  };
24832
24989
  };
24833
- `, V = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
24990
+ `, G = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
24834
24991
  import type React from 'react';
24835
24992
  import { createPortal } from 'react-dom';
24836
24993
  import { CommonComponentProps } from '../props';
@@ -25363,30 +25520,31 @@ export function Waterfall({
25363
25520
  </>
25364
25521
  );
25365
25522
  }
25366
- `, U = {
25367
- [y.id]: S,
25368
- [b.id]: w,
25369
- [x.id]: C,
25370
- [P.id]: $,
25371
- [v.id]: I,
25372
- [f.id]: E,
25373
- [h.id]: T,
25374
- [p.id]: R,
25375
- [m.id]: M,
25376
- [g.id]: L,
25377
- [u.id]: k,
25378
- [d.id]: A,
25379
- [c.id]: N,
25380
- [l.id]: H,
25381
- [s.id]: O,
25382
- [a.id]: _,
25383
- [r.id]: F,
25384
- [o.id]: W,
25385
- [i.id]: D,
25386
- [t.id]: B,
25387
- [e.id]: z,
25388
- [n.id]: V
25523
+ `, K = {
25524
+ [C.id]: w,
25525
+ [S.id]: $,
25526
+ [y.id]: I,
25527
+ [b.id]: n,
25528
+ [x.id]: E,
25529
+ [P.id]: T,
25530
+ [v.id]: n,
25531
+ [f.id]: R,
25532
+ [h.id]: M,
25533
+ [p.id]: L,
25534
+ [m.id]: k,
25535
+ [g.id]: A,
25536
+ [u.id]: N,
25537
+ [d.id]: H,
25538
+ [c.id]: O,
25539
+ [l.id]: _,
25540
+ [s.id]: W,
25541
+ [a.id]: F,
25542
+ [r.id]: D,
25543
+ [o.id]: B,
25544
+ [i.id]: z,
25545
+ [t.id]: V,
25546
+ [e.id]: G
25389
25547
  };
25390
25548
  export {
25391
- U as componentSources
25549
+ K as componentSources
25392
25550
  };