@cntrl-site/components 1.0.118-alpha.2 → 1.0.118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sources.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { W as e, b as t, T as i, h as o, g as r, S as a, P as s, O as l, i as c, a as d, M as u, L as g, e as m, f as p, H as h, j as f, G as v, F as P, d as x, c as b, C as y, k as S, B as C } from "./ChroniclesComponent-Ds59v_47.mjs";
2
- const w = `import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
1
+ import { W as n, b as e, T as t, g as i, f as o, S as r, P as a, O as s, h as l, a as 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';
3
3
  import { CommonComponentProps } from '../props';
4
4
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
5
5
  import { useLightboxScrollLock } from '../utils/useLightboxScrollLock';
@@ -28,11 +28,12 @@ type BurgerShowInValue = string | Record<string, string>;
28
28
 
29
29
  type BurgerLink = {
30
30
  link?: {
31
- type?: 'url' | 'page' | 'anchor';
31
+ type?: 'url' | 'page' | 'anchor' | 'file';
32
32
  value?: string;
33
33
  target?: string;
34
34
  anchor?: string;
35
35
  url?: string;
36
+ download?: string;
36
37
  };
37
38
  mode?: 'page' | 'url';
38
39
  page?: string;
@@ -257,10 +258,11 @@ function isBlankTarget(target?: string): boolean {
257
258
  }
258
259
 
259
260
  function getBurgerDest(item: BurgerLink): {
260
- type: 'url' | 'page' | 'anchor';
261
+ type: 'url' | 'page' | 'anchor' | 'file';
261
262
  value: string;
262
263
  target?: '_blank';
263
264
  anchor?: string;
265
+ download?: string;
264
266
  } {
265
267
  const dest = item.link;
266
268
  if (dest && typeof dest === 'object') {
@@ -274,8 +276,12 @@ function getBurgerDest(item: BurgerLink): {
274
276
  if (dest.type === 'page') {
275
277
  return { type: 'page', value: dest.value ?? '', target, anchor: dest.anchor };
276
278
  }
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
277
283
  if (typeof dest.url === 'string') {
278
- return { type: 'url', value: dest.url, target };
284
+ return { type: 'url', value: dest.url, target, download: typeof dest.download === 'string' ? dest.download : undefined };
279
285
  }
280
286
  }
281
287
  const target = isBlankTarget(item.openIn) ? '_blank' : undefined;
@@ -296,12 +302,17 @@ function resolveBurgerLink(item: BurgerLink, pages?: BurgerPageRef[]): {
296
302
  label: string;
297
303
  href: string;
298
304
  target?: '_blank';
305
+ download?: string;
299
306
  } {
300
307
  const label = item.label || 'Link';
301
308
  const dest = getBurgerDest(item);
302
309
 
303
310
  if (dest.type === 'url') {
304
- return { label, href: dest.value, target: dest.target };
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' };
305
316
  }
306
317
  if (dest.type === 'anchor') {
307
318
  const anchor = dest.value.replace(/^#/, '');
@@ -913,10 +924,11 @@ function renderTextPaddingControls(
913
924
  type ColorKeys = 'iconColor' | 'closeButtonColor' | 'linkColor' | 'openLinkColor' | 'compactIconColor' | 'compactLinkColor' | 'compactLogoColor' | 'compactBackgroundColor' | 'openLogoColor' | 'menuBackgroundColor' | 'overlayColor' | 'backgroundColor' | 'logoColor';
914
925
 
915
926
  export type BurgerLinkNavigateEvent = {
916
- mode: 'page' | 'url';
927
+ mode: 'page' | 'url' | 'file';
917
928
  href: string;
918
929
  page?: string;
919
930
  url?: string;
931
+ file?: string;
920
932
  anchor?: string;
921
933
  target?: '_blank';
922
934
  };
@@ -1768,6 +1780,28 @@ function findAnchorTarget(hash: string): HTMLElement | null {
1768
1780
  return target instanceof HTMLElement ? target : null;
1769
1781
  }
1770
1782
 
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
+
1771
1805
  function scrollToAnchor(hash: string): boolean {
1772
1806
  const target = findAnchorTarget(hash);
1773
1807
  if (!target) return false;
@@ -1801,10 +1835,11 @@ function handleLinkClick(
1801
1835
  const resolved = resolveBurgerLink(item, pages);
1802
1836
  const dest = getBurgerDest(item);
1803
1837
  const navigateEvent: BurgerLinkNavigateEvent = {
1804
- mode: dest.type === 'url' ? 'url' : 'page',
1838
+ mode: dest.type === 'url' || dest.type === 'file' ? dest.type : 'page',
1805
1839
  href: resolved.href || href,
1806
1840
  page: dest.type === 'page' ? dest.value : undefined,
1807
1841
  url: dest.type === 'url' ? dest.value : undefined,
1842
+ file: dest.type === 'file' ? dest.value : undefined,
1808
1843
  anchor: dest.type === 'anchor'
1809
1844
  ? dest.value.replace(/^#/, '')
1810
1845
  : (dest.anchor ?? '').replace(/^#/, ''),
@@ -1826,6 +1861,14 @@ function handleLinkClick(
1826
1861
  return;
1827
1862
  }
1828
1863
 
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
+
1829
1872
  if (!opensInNewTab && hash && isSameDocumentHref(href) && findAnchorTarget(hash)) {
1830
1873
  event.preventDefault();
1831
1874
  runAfterClose(() => scrollToAnchor(hash));
@@ -2431,12 +2474,13 @@ export function Burger({
2431
2474
  const showOpenNavControls = showControls && isOpen;
2432
2475
 
2433
2476
  const renderOpenNavItems = (linkClassName: string) => items.filter((item) => isVisibleInOpenNav(item, layoutId)).map((item, index) => {
2434
- const { label, href, target } = resolveBurgerLink(item, pages);
2477
+ const { label, href, target, download } = resolveBurgerLink(item, pages);
2435
2478
  const linkNode = href ? (
2436
2479
  <a
2437
2480
  href={href}
2438
2481
  target={target}
2439
2482
  rel={target === '_blank' ? 'noopener noreferrer' : undefined}
2483
+ download={download}
2440
2484
  className={\`\${linkClassName} \${P}-has-href\`}
2441
2485
  onClick={(event) => onNavLinkClick(event, item)}
2442
2486
  >
@@ -2548,7 +2592,7 @@ export function Burger({
2548
2592
  };
2549
2593
 
2550
2594
  const renderNavLink = (item: BurgerLink, index: number) => {
2551
- const { label, href, target } = resolveBurgerLink(item, pages);
2595
+ const { label, href, target, download } = resolveBurgerLink(item, pages);
2552
2596
  const textContent = (
2553
2597
  <span className={navLinkTextClassName} style={navLinkTextStyle}>
2554
2598
  {renderMultilineText(label)}
@@ -2567,6 +2611,7 @@ export function Burger({
2567
2611
  href={href}
2568
2612
  target={target}
2569
2613
  rel={target === '_blank' ? 'noopener noreferrer' : undefined}
2614
+ download={download}
2570
2615
  className={\`\${P}-nav-link \${P}-has-href\`}
2571
2616
  onClick={(event) => onNavLinkClick(event, item)}
2572
2617
  >
@@ -2684,7 +2729,7 @@ export function Burger({
2684
2729
  </div>
2685
2730
  );
2686
2731
  }
2687
- `, $ = `import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
2732
+ `, w = `import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
2688
2733
  import { createPortal } from 'react-dom';
2689
2734
  import cn from 'classnames';
2690
2735
  import { CommonComponentProps } from '../props';
@@ -3731,7 +3776,7 @@ export function Chronicles({
3731
3776
  </>
3732
3777
  );
3733
3778
  }
3734
- `, I = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3779
+ `, C = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3735
3780
  import { CommonComponentProps } from '../props';
3736
3781
  import { LinkWrapper, useScopedStyles, type ContentLink } from '../utils/index';
3737
3782
 
@@ -4260,7 +4305,7 @@ export function ClickGallerie({ settings, content = [], isEditor }: ClickGalleri
4260
4305
  </>
4261
4306
  );
4262
4307
  }
4263
- `, E = `import { useCallback, useEffect, useMemo, useState } from 'react';
4308
+ `, $ = `import { useCallback, useEffect, useMemo, useState } from 'react';
4264
4309
  import cn from 'classnames';
4265
4310
  import { CommonComponentProps } from '../props';
4266
4311
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index';
@@ -5004,7 +5049,7 @@ export function FAQ({ settings, content, isEditor, isPreviewMode, isEditMode, ac
5004
5049
  </>
5005
5050
  );
5006
5051
  }
5007
- `, T = `import React, { useMemo, useState } from 'react';
5052
+ `, I = `import React, { useMemo, useState } from 'react';
5008
5053
  import { CommonComponentProps } from '../props';
5009
5054
  import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
5010
5055
  import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
@@ -5642,7 +5687,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
5642
5687
  };
5643
5688
 
5644
5689
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
5645
- `, n = `import { Splide, SplideSlide } from '@splidejs/react-splide';
5690
+ `, E = `import { Splide, SplideSlide } from '@splidejs/react-splide';
5646
5691
  import '@splidejs/react-splide/css/core';
5647
5692
  import { CommonComponentProps } from '../props';
5648
5693
  import { EmbedMediaFrame, getEmbedAspect, getEmbedPlayback, isEmbedMedia } from '../utils/index';
@@ -5780,13 +5825,6 @@ function getCSS(P: string): string {
5780
5825
  flex-direction: column;
5781
5826
  align-items: center;
5782
5827
  }
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
- }
5790
5828
  .\${P}-item-text-link {
5791
5829
  display: flex;
5792
5830
  flex-direction: column;
@@ -7308,94 +7346,11 @@ function resolveLightboxImageDisplay(
7308
7346
  return value?.display === 'cover' ? 'cover' : 'fit';
7309
7347
  }
7310
7348
 
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
-
7393
7349
  export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, metadata, activeEvent, layoutId, portalId }: GridProps) {
7394
7350
  const { prefix: P } = useScopedStyles();
7395
7351
  const {
7396
7352
  type = 'a',
7397
7353
  gridLayout,
7398
- customGrid,
7399
7354
  textBoxWidth = 100,
7400
7355
  verticalGap,
7401
7356
  entriesCount,
@@ -7443,7 +7398,6 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7443
7398
  hover = 'none',
7444
7399
  alignEntries = 'off',
7445
7400
  align = 'top',
7446
- textGrowth = 'inside',
7447
7401
  } = settings;
7448
7402
 
7449
7403
  const resolvedTitleTextStyle: TextStyles = {
@@ -7533,16 +7487,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7533
7487
  const hoverEffectClass = hover !== 'none' && (!isEditor || isPreviewMode) ? \` \${P}-hover-\${hover}\` : '';
7534
7488
  const wrapperStateClasses = \`\${stateClass}\${showTextOnHover ? \` \${P}-show-text-hover\` : ''}\${hoverEffectClass}\`.trim();
7535
7489
 
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[]>([]);
7490
+ const resEntriesCount = entriesCount === 0 ? Infinity : entriesCount;
7546
7491
 
7547
7492
  const cropContent = (content ?? []).slice(0, resEntriesCount);
7548
7493
  const lightboxMediaToPreload = useMemo(
@@ -7550,24 +7495,23 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7550
7495
  [cropContent, lightbox],
7551
7496
  );
7552
7497
 
7553
- const size = gridLayout?.entryWidth ?? 0.2;
7498
+ const size = gridLayout.entryWidth ?? 0.2;
7554
7499
 
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;
7500
+ const isCover = imageDisplay?.display === 'cover';
7501
+ const ratioValue = imageDisplay?.ratioValue ?? '1:1';
7502
+ const ratioReversed = imageDisplay?.reversed ?? false;
7559
7503
  const [rW, rH] = ratioValue.split(':').map(Number);
7560
7504
  const effW = ratioReversed ? rH : rW;
7561
7505
  const effH = ratioReversed ? rW : rH;
7562
7506
  const aspectRatio = \`\${effW} / \${effH}\`;
7563
7507
 
7564
- const columnsCount = gridLayout?.columnsCount ?? 1;
7508
+ const columnsCount = gridLayout.columnsCount;
7565
7509
  const entryWidthScaled = scalingValue(size ?? 0, isEditor);
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';
7510
+ const imageWrapperWidth = entryWidthScaled;
7511
+ const isFitSlider = !isCover && slider !== 'off';
7568
7512
 
7569
7513
  const itemsInLastRow = cropContent.length % columnsCount || columnsCount;
7570
- const isPartialLastRow = !customLayout && itemsInLastRow < columnsCount && cropContent.length > 0;
7514
+ const isPartialLastRow = itemsInLastRow < columnsCount && cropContent.length > 0;
7571
7515
  const lastRowStartIndex = cropContent.length - itemsInLastRow;
7572
7516
  const lastRowStartColumn = isPartialLastRow
7573
7517
  ? Math.floor((columnsCount - itemsInLastRow) / 2) + 1
@@ -7575,23 +7519,19 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7575
7519
 
7576
7520
  const imageBorderRadius = imageCorners ? scalingValue(imageCorners, isEditor) : undefined;
7577
7521
 
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' }),
7522
+ const imageWrapperStyle: React.CSSProperties = {
7523
+ width: imageWrapperWidth,
7524
+ ...(isCover
7525
+ ? { aspectRatio, height: 'auto', overflow: 'hidden' }
7526
+ : { height: 'auto' }),
7589
7527
  ...(imageBorderRadius ? { borderRadius: imageBorderRadius, overflow: 'hidden' } : {}),
7590
- });
7528
+ };
7591
7529
 
7592
7530
  const imageWrapperClassName = \`\${P}-item-image-wrapper\${isFitSlider ? \` \${P}-item-image-wrapper-fit-slider\` : ''}\`.trim();
7593
7531
  const isTextBeforeImage = type === 'd' || type === 'e' || type === 'f';
7594
- const shouldAlignEntries = !customLayout && alignEntries === 'on';
7532
+ const shouldAlignEntries = alignEntries === 'on';
7533
+ const textBoxWidthStyle = \`calc(\${scalingValue(size ?? 0, isEditor)} * (\${textBoxWidth} / 100))\`;
7534
+ const controlWidthStyle = scalingValue(size * textBoxWidth / 100, isEditor);
7595
7535
 
7596
7536
  const imageRadiusStyle = imageBorderRadius
7597
7537
  ? { borderRadius: imageBorderRadius, [MEDIA_RADIUS_VAR]: imageBorderRadius } as React.CSSProperties
@@ -7611,68 +7551,9 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7611
7551
  width: 'auto',
7612
7552
  height: 'auto',
7613
7553
  maxWidth: '100%',
7614
- ...(customLayout ? { maxHeight: '100%' } : {}),
7615
7554
  ...imageRadiusStyle,
7616
7555
  };
7617
7556
 
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
-
7676
7557
  const [containerWidth, setContainerWidth] = useState(0);
7677
7558
  const containerRef = useRef<HTMLDivElement>(null);
7678
7559
 
@@ -7742,8 +7623,16 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7742
7623
  <div style={colorVars}>
7743
7624
  <div
7744
7625
  ref={containerRef}
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}>
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
+ }}>
7747
7636
  {cropContent.map((item: any, index: number) => {
7748
7637
  const hasTitle = hasText(item.title);
7749
7638
  const hasSubtitle = hasText(item.subtitle);
@@ -7753,20 +7642,6 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7753
7642
  const gridColumn = isPartialLastRow && index >= lastRowStartIndex
7754
7643
  ? \`\${lastRowStartColumn + (index - lastRowStartIndex)}\`
7755
7644
  : 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;
7770
7645
 
7771
7646
  const typeCTextBlock = isTextBeforeImage ? (
7772
7647
  <div className={\`\${P}-item-text-block\`}>
@@ -7914,7 +7789,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
7914
7789
  </div>
7915
7790
  )}
7916
7791
  <Splide
7917
- key={\`\${transition}-\${itemSize}-\${direction}-\${sliderTiming}-\${containerWidth}-\${layoutId}\`}
7792
+ key={\`\${transition}-\${size}-\${direction}-\${sliderTiming}-\${containerWidth}-\${layoutId}\`}
7918
7793
  className={\`\${P}-item-slider\`}
7919
7794
  options={{
7920
7795
  arrows: false,
@@ -8008,18 +7883,16 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
8008
7883
  <div
8009
7884
  key={index}
8010
7885
  className={\`\${P}-item\`.trim()}
8011
- style={itemStyle}
7886
+ style={gridColumn && !shouldAlignEntries ? { gridColumn } : undefined}
8012
7887
  >
8013
7888
  <div
8014
- ref={(el) => { itemInnerRefs.current[index] = el; }}
8015
- className={\`\${isEditMode
8016
- ? \`\${P}-item-inner\`
7889
+ className={\`\${isEditMode
7890
+ ? \`\${P}-item-inner\`
8017
7891
  : \`\${P}-item-inner-hidden\`}\${shouldAlignEntries && isLastRow ? \` \${P}-item-inner-last-row\` : ''}\`.trim()}
8018
7892
  style={{
8019
7893
  width: (textBoxWidth ?? 0) > 100
8020
- ? \`calc(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`
8021
- : itemWidthScaled,
8022
- ...(customSlot && !isTextOutside ? { height: scalingValue(customSlot.height, isEditor) } : {}),
7894
+ ? \`calc(\${entryWidthScaled} * (\${textBoxWidth} / 100))\`
7895
+ : entryWidthScaled,
8023
7896
  ...(gridColumn && shouldAlignEntries ? { gridColumn } : {}),
8024
7897
  }}
8025
7898
  >
@@ -8102,45 +7975,17 @@ type GridLayoutConfig = {
8102
7975
  lockedParam?: 'wrapperWidth' | 'entryWidth' | 'horizontalGap' | null;
8103
7976
  };
8104
7977
 
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
-
8131
7978
  type GridSettings = {
8132
7979
  type: 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
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;
7980
+ gridLayout: GridLayoutConfig;
8136
7981
  textBoxWidth: number;
8137
- verticalGap?: number;
8138
- entriesCount?: number;
7982
+ verticalGap: number;
7983
+ entriesCount: number;
8139
7984
  lightbox: 'on' | 'off';
8140
- imageDisplay: 'fit' | 'cover' | {
7985
+ imageDisplay: {
8141
7986
  display: 'fit' | 'cover';
8142
- ratioValue?: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
8143
- reversed?: boolean;
7987
+ ratioValue: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
7988
+ reversed: boolean;
8144
7989
  };
8145
7990
  imageCorners?: number;
8146
7991
  lightboxImageDisplay?: 'fit' | 'cover' | { display?: 'fit' | 'cover' };
@@ -8150,10 +7995,8 @@ type GridSettings = {
8150
7995
  transition: 'fade' | 'slide',
8151
7996
  showText: 'always' | 'on hover';
8152
7997
  hover?: 'none' | 'zoom-in' | 'greyscale' | 'scale-down';
8153
- alignEntries?: 'on' | 'off';
7998
+ alignEntries: 'on' | 'off';
8154
7999
  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';
8157
8000
  titleMarginTop: number;
8158
8001
  subtitleMarginTop: number;
8159
8002
  titleColor: string;
@@ -8200,7 +8043,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
8200
8043
  };
8201
8044
 
8202
8045
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
8203
- `, R = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
8046
+ `, T = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
8204
8047
  import { CommonComponentProps } from '../props';
8205
8048
  import { scalingValue } from '../utils/scalingValue';
8206
8049
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -8773,7 +8616,7 @@ export function Helix({
8773
8616
  </>
8774
8617
  );
8775
8618
  }
8776
- `, M = `import { CommonComponentProps } from '../props';
8619
+ `, R = `import { CommonComponentProps } from '../props';
8777
8620
  import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, scalingValue, useLazyVideos, useScopedStyles } from '../utils/index';
8778
8621
  import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
8779
8622
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
@@ -11225,7 +11068,7 @@ export function Hive({
11225
11068
  </>
11226
11069
  );
11227
11070
  }
11228
- `, L = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
11071
+ `, M = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
11229
11072
  import { createPortal } from 'react-dom';
11230
11073
  import { CommonComponentProps } from '../props';
11231
11074
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -12028,7 +11871,7 @@ export type LightboxJournalSettings = {
12028
11871
  closeIconColor: string;
12029
11872
  closeIconHoverColor: string;
12030
11873
  };
12031
- `, k = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
11874
+ `, L = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
12032
11875
  import { createPortal } from 'react-dom';
12033
11876
  import { CommonComponentProps } from '../props';
12034
11877
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -12612,7 +12455,7 @@ export const LightboxStrip = ({ settings, content, isEditor, isEditMode, isPrevi
12612
12455
  </>
12613
12456
  );
12614
12457
  };
12615
- `, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
12458
+ `, k = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
12616
12459
  import { createPortal } from 'react-dom';
12617
12460
  import { CommonComponentProps } from '../props';
12618
12461
  import { buildColorVars, EmbedMediaFrame, isEmbedMedia, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -15717,7 +15560,7 @@ export function List({ settings, content, isEditor, isPreviewMode, isEditMode, a
15717
15560
  </>
15718
15561
  );
15719
15562
  }
15720
- `, N = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
15563
+ `, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
15721
15564
  import cn from 'classnames';
15722
15565
  import { CommonComponentProps } from '../props';
15723
15566
  import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -16575,7 +16418,7 @@ type MarqueeProps = {
16575
16418
  isPreviewMode?: boolean;
16576
16419
  isEditMode?: boolean;
16577
16420
  } & CommonComponentProps;
16578
- `, H = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
16421
+ `, N = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
16579
16422
  import cn from 'classnames';
16580
16423
  import { CommonComponentProps } from '../props';
16581
16424
  import { LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -17518,7 +17361,7 @@ type MarqueeTextProps = {
17518
17361
  isPreviewMode?: boolean;
17519
17362
  isEditMode?: boolean;
17520
17363
  } & CommonComponentProps;
17521
- `, O = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
17364
+ `, H = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
17522
17365
  import { createPortal } from 'react-dom';
17523
17366
  import type React from 'react';
17524
17367
  import { CommonComponentProps } from '../props';
@@ -20000,7 +19843,7 @@ export function Mercury({
20000
19843
  </>
20001
19844
  );
20002
19845
  }
20003
- `, _ = `import React, { useMemo, useState } from 'react';
19846
+ `, O = `import React, { useMemo, useState } from 'react';
20004
19847
  import { CommonComponentProps } from '../props';
20005
19848
  import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
20006
19849
  import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
@@ -20579,7 +20422,7 @@ const COLOR_VAR_MAP: Record<OnelinerColorKeys, string> = {
20579
20422
  };
20580
20423
 
20581
20424
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
20582
- `, W = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
20425
+ `, _ = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
20583
20426
  import type React from 'react';
20584
20427
  import { CommonComponentProps } from '../props';
20585
20428
  import { scalingValue, useScopedStyles } from '../utils/index';
@@ -22046,7 +21889,7 @@ export function Scale({ settings, content, isEditor, isPreviewMode }: ScaleProps
22046
21889
  </>
22047
21890
  );
22048
21891
  }
22049
- `, D = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
21892
+ `, W = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
22050
21893
  import { SvgImage } from '../helpers/SvgImage/SvgImage';
22051
21894
  import { CommonComponentProps } from '../props';
22052
21895
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
@@ -22678,7 +22521,7 @@ export function SimpleButton({ settings, isEditor, isPreviewMode, activeEvent, h
22678
22521
  </>
22679
22522
  );
22680
22523
  }
22681
- `, B = `import React, { useCallback, useEffect, useRef, useState } from 'react';
22524
+ `, D = `import React, { useCallback, useEffect, useRef, useState } from 'react';
22682
22525
  import cn from 'classnames';
22683
22526
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
22684
22527
  import { scalingValue } from '../utils/scalingValue';
@@ -23860,7 +23703,7 @@ function ArrowIcon({ color, className }: { color: string, className: string }) {
23860
23703
  </svg>
23861
23704
  );
23862
23705
  }
23863
- `, z = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
23706
+ `, B = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
23864
23707
  import cn from 'classnames';
23865
23708
  import { CommonComponentProps } from '../props';
23866
23709
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
@@ -24491,7 +24334,7 @@ type TestimonialsSettings = {
24491
24334
  logoHeight: number;
24492
24335
  captionMarginTop: number;
24493
24336
  };
24494
- `, V = `import cn from 'classnames';
24337
+ `, z = `import cn from 'classnames';
24495
24338
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
24496
24339
  import { CommonComponentProps } from '../props';
24497
24340
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
@@ -24987,7 +24830,7 @@ type TestimonialsSettings = {
24987
24830
  icon?: string | null;
24988
24831
  };
24989
24832
  };
24990
- `, G = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
24833
+ `, V = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
24991
24834
  import type React from 'react';
24992
24835
  import { createPortal } from 'react-dom';
24993
24836
  import { CommonComponentProps } from '../props';
@@ -25520,31 +25363,30 @@ export function Waterfall({
25520
25363
  </>
25521
25364
  );
25522
25365
  }
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
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
25547
25389
  };
25548
25390
  export {
25549
- K as componentSources
25391
+ U as componentSources
25550
25392
  };