@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/{Burger-C8JIQQwm.mjs → Burger-BkVgNMGU.mjs} +307 -330
- package/dist/Burger-C3yVbQcq.js +669 -0
- package/dist/ChroniclesComponent--pzhQXVD.js +1 -0
- package/dist/{ChroniclesComponent-kkKhL_qt.mjs → ChroniclesComponent-Ds59v_47.mjs} +512 -442
- package/dist/Components/Burger/Burger.d.ts +2 -4
- package/dist/Components/Grid/CustomGridComponent.d.ts +41 -0
- package/dist/Components/Grid/Grid.d.ts +25 -7
- package/dist/Grid-B0NOfgEm.mjs +1713 -0
- package/dist/Grid-DNaBgqZo.js +415 -0
- package/dist/{components-BLyOKMdK.mjs → components-MVf3iei3.mjs} +13 -12
- package/dist/{components-CVetdKi7.js → components-tuVRZ0WY.js} +1 -1
- package/dist/elements.js +1 -1
- package/dist/elements.mjs +8 -7
- package/dist/elements.node.js +1 -1
- package/dist/elements.node.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +2 -2
- package/dist/sources.js +258 -101
- package/dist/sources.mjs +298 -140
- package/package.json +1 -1
- package/dist/Burger-C_SjPZWp.js +0 -669
- package/dist/ChroniclesComponent-DkG1aICD.js +0 -1
- package/dist/Grid-C4hO8KCr.js +0 -408
- package/dist/Grid-Dud7PLS9.mjs +0 -1622
package/dist/sources.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./ChroniclesComponent
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./ChroniclesComponent--pzhQXVD.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,12 +27,11 @@ 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';
|
|
31
31
|
value?: string;
|
|
32
32
|
target?: string;
|
|
33
33
|
anchor?: string;
|
|
34
34
|
url?: string;
|
|
35
|
-
download?: string;
|
|
36
35
|
};
|
|
37
36
|
mode?: 'page' | 'url';
|
|
38
37
|
page?: string;
|
|
@@ -257,11 +256,10 @@ function isBlankTarget(target?: string): boolean {
|
|
|
257
256
|
}
|
|
258
257
|
|
|
259
258
|
function getBurgerDest(item: BurgerLink): {
|
|
260
|
-
type: 'url' | 'page' | 'anchor'
|
|
259
|
+
type: 'url' | 'page' | 'anchor';
|
|
261
260
|
value: string;
|
|
262
261
|
target?: '_blank';
|
|
263
262
|
anchor?: string;
|
|
264
|
-
download?: string;
|
|
265
263
|
} {
|
|
266
264
|
const dest = item.link;
|
|
267
265
|
if (dest && typeof dest === 'object') {
|
|
@@ -275,12 +273,8 @@ function getBurgerDest(item: BurgerLink): {
|
|
|
275
273
|
if (dest.type === 'page') {
|
|
276
274
|
return { type: 'page', value: dest.value ?? '', target, anchor: dest.anchor };
|
|
277
275
|
}
|
|
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
|
|
282
276
|
if (typeof dest.url === 'string') {
|
|
283
|
-
return { type: 'url', value: dest.url, target
|
|
277
|
+
return { type: 'url', value: dest.url, target };
|
|
284
278
|
}
|
|
285
279
|
}
|
|
286
280
|
const target = isBlankTarget(item.openIn) ? '_blank' : undefined;
|
|
@@ -301,17 +295,12 @@ function resolveBurgerLink(item: BurgerLink, pages?: BurgerPageRef[]): {
|
|
|
301
295
|
label: string;
|
|
302
296
|
href: string;
|
|
303
297
|
target?: '_blank';
|
|
304
|
-
download?: string;
|
|
305
298
|
} {
|
|
306
299
|
const label = item.label || 'Link';
|
|
307
300
|
const dest = getBurgerDest(item);
|
|
308
301
|
|
|
309
302
|
if (dest.type === 'url') {
|
|
310
|
-
return { label, href: dest.value, target: dest.target
|
|
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' };
|
|
303
|
+
return { label, href: dest.value, target: dest.target };
|
|
315
304
|
}
|
|
316
305
|
if (dest.type === 'anchor') {
|
|
317
306
|
const anchor = dest.value.replace(/^#/, '');
|
|
@@ -923,11 +912,10 @@ function renderTextPaddingControls(
|
|
|
923
912
|
type ColorKeys = 'iconColor' | 'closeButtonColor' | 'linkColor' | 'openLinkColor' | 'compactIconColor' | 'compactLinkColor' | 'compactLogoColor' | 'compactBackgroundColor' | 'openLogoColor' | 'menuBackgroundColor' | 'overlayColor' | 'backgroundColor' | 'logoColor';
|
|
924
913
|
|
|
925
914
|
export type BurgerLinkNavigateEvent = {
|
|
926
|
-
mode: 'page' | 'url'
|
|
915
|
+
mode: 'page' | 'url';
|
|
927
916
|
href: string;
|
|
928
917
|
page?: string;
|
|
929
918
|
url?: string;
|
|
930
|
-
file?: string;
|
|
931
919
|
anchor?: string;
|
|
932
920
|
target?: '_blank';
|
|
933
921
|
};
|
|
@@ -1779,28 +1767,6 @@ function findAnchorTarget(hash: string): HTMLElement | null {
|
|
|
1779
1767
|
return target instanceof HTMLElement ? target : null;
|
|
1780
1768
|
}
|
|
1781
1769
|
|
|
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
|
-
|
|
1804
1770
|
function scrollToAnchor(hash: string): boolean {
|
|
1805
1771
|
const target = findAnchorTarget(hash);
|
|
1806
1772
|
if (!target) return false;
|
|
@@ -1834,11 +1800,10 @@ function handleLinkClick(
|
|
|
1834
1800
|
const resolved = resolveBurgerLink(item, pages);
|
|
1835
1801
|
const dest = getBurgerDest(item);
|
|
1836
1802
|
const navigateEvent: BurgerLinkNavigateEvent = {
|
|
1837
|
-
mode: dest.type === 'url'
|
|
1803
|
+
mode: dest.type === 'url' ? 'url' : 'page',
|
|
1838
1804
|
href: resolved.href || href,
|
|
1839
1805
|
page: dest.type === 'page' ? dest.value : undefined,
|
|
1840
1806
|
url: dest.type === 'url' ? dest.value : undefined,
|
|
1841
|
-
file: dest.type === 'file' ? dest.value : undefined,
|
|
1842
1807
|
anchor: dest.type === 'anchor'
|
|
1843
1808
|
? dest.value.replace(/^#/, '')
|
|
1844
1809
|
: (dest.anchor ?? '').replace(/^#/, ''),
|
|
@@ -1860,14 +1825,6 @@ function handleLinkClick(
|
|
|
1860
1825
|
return;
|
|
1861
1826
|
}
|
|
1862
1827
|
|
|
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
|
-
|
|
1871
1828
|
if (!opensInNewTab && hash && isSameDocumentHref(href) && findAnchorTarget(hash)) {
|
|
1872
1829
|
event.preventDefault();
|
|
1873
1830
|
runAfterClose(() => scrollToAnchor(hash));
|
|
@@ -2473,13 +2430,12 @@ export function Burger({
|
|
|
2473
2430
|
const showOpenNavControls = showControls && isOpen;
|
|
2474
2431
|
|
|
2475
2432
|
const renderOpenNavItems = (linkClassName: string) => items.filter((item) => isVisibleInOpenNav(item, layoutId)).map((item, index) => {
|
|
2476
|
-
const { label, href, target
|
|
2433
|
+
const { label, href, target } = resolveBurgerLink(item, pages);
|
|
2477
2434
|
const linkNode = href ? (
|
|
2478
2435
|
<a
|
|
2479
2436
|
href={href}
|
|
2480
2437
|
target={target}
|
|
2481
2438
|
rel={target === '_blank' ? 'noopener noreferrer' : undefined}
|
|
2482
|
-
download={download}
|
|
2483
2439
|
className={\`\${linkClassName} \${P}-has-href\`}
|
|
2484
2440
|
onClick={(event) => onNavLinkClick(event, item)}
|
|
2485
2441
|
>
|
|
@@ -2591,7 +2547,7 @@ export function Burger({
|
|
|
2591
2547
|
};
|
|
2592
2548
|
|
|
2593
2549
|
const renderNavLink = (item: BurgerLink, index: number) => {
|
|
2594
|
-
const { label, href, target
|
|
2550
|
+
const { label, href, target } = resolveBurgerLink(item, pages);
|
|
2595
2551
|
const textContent = (
|
|
2596
2552
|
<span className={navLinkTextClassName} style={navLinkTextStyle}>
|
|
2597
2553
|
{renderMultilineText(label)}
|
|
@@ -2610,7 +2566,6 @@ export function Burger({
|
|
|
2610
2566
|
href={href}
|
|
2611
2567
|
target={target}
|
|
2612
2568
|
rel={target === '_blank' ? 'noopener noreferrer' : undefined}
|
|
2613
|
-
download={download}
|
|
2614
2569
|
className={\`\${P}-nav-link \${P}-has-href\`}
|
|
2615
2570
|
onClick={(event) => onNavLinkClick(event, item)}
|
|
2616
2571
|
>
|
|
@@ -2728,7 +2683,7 @@ export function Burger({
|
|
|
2728
2683
|
</div>
|
|
2729
2684
|
);
|
|
2730
2685
|
}
|
|
2731
|
-
`,
|
|
2686
|
+
`,i=`import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
|
|
2732
2687
|
import { createPortal } from 'react-dom';
|
|
2733
2688
|
import cn from 'classnames';
|
|
2734
2689
|
import { CommonComponentProps } from '../props';
|
|
@@ -3775,7 +3730,7 @@ export function Chronicles({
|
|
|
3775
3730
|
</>
|
|
3776
3731
|
);
|
|
3777
3732
|
}
|
|
3778
|
-
`,
|
|
3733
|
+
`,o=`import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3779
3734
|
import { CommonComponentProps } from '../props';
|
|
3780
3735
|
import { LinkWrapper, useScopedStyles, type ContentLink } from '../utils/index';
|
|
3781
3736
|
|
|
@@ -4304,7 +4259,7 @@ export function ClickGallerie({ settings, content = [], isEditor }: ClickGalleri
|
|
|
4304
4259
|
</>
|
|
4305
4260
|
);
|
|
4306
4261
|
}
|
|
4307
|
-
`,
|
|
4262
|
+
`,r=`import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4308
4263
|
import cn from 'classnames';
|
|
4309
4264
|
import { CommonComponentProps } from '../props';
|
|
4310
4265
|
import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index';
|
|
@@ -5048,7 +5003,7 @@ export function FAQ({ settings, content, isEditor, isPreviewMode, isEditMode, ac
|
|
|
5048
5003
|
</>
|
|
5049
5004
|
);
|
|
5050
5005
|
}
|
|
5051
|
-
`,
|
|
5006
|
+
`,a=`import React, { useMemo, useState } from 'react';
|
|
5052
5007
|
import { CommonComponentProps } from '../props';
|
|
5053
5008
|
import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
|
|
5054
5009
|
import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
|
|
@@ -5686,7 +5641,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
|
|
|
5686
5641
|
};
|
|
5687
5642
|
|
|
5688
5643
|
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
5689
|
-
`,
|
|
5644
|
+
`,e=`import { Splide, SplideSlide } from '@splidejs/react-splide';
|
|
5690
5645
|
import '@splidejs/react-splide/css/core';
|
|
5691
5646
|
import { CommonComponentProps } from '../props';
|
|
5692
5647
|
import { EmbedMediaFrame, getEmbedAspect, getEmbedPlayback, isEmbedMedia } from '../utils/index';
|
|
@@ -5824,6 +5779,13 @@ function getCSS(P: string): string {
|
|
|
5824
5779
|
flex-direction: column;
|
|
5825
5780
|
align-items: center;
|
|
5826
5781
|
}
|
|
5782
|
+
.\${P}-custom-layout .\${P}-item-image-link {
|
|
5783
|
+
flex: 1 1 0%;
|
|
5784
|
+
min-height: 0;
|
|
5785
|
+
}
|
|
5786
|
+
.\${P}-custom-layout.\${P}-text-outside .\${P}-item-image-link {
|
|
5787
|
+
flex: none;
|
|
5788
|
+
}
|
|
5827
5789
|
.\${P}-item-text-link {
|
|
5828
5790
|
display: flex;
|
|
5829
5791
|
flex-direction: column;
|
|
@@ -7345,11 +7307,94 @@ function resolveLightboxImageDisplay(
|
|
|
7345
7307
|
return value?.display === 'cover' ? 'cover' : 'fit';
|
|
7346
7308
|
}
|
|
7347
7309
|
|
|
7310
|
+
function getCustomGridSpanWidth(layout: CustomGridLayout, span: number): number {
|
|
7311
|
+
return layout.columnWidth * span + layout.gutterWidth * Math.max(0, span - 1);
|
|
7312
|
+
}
|
|
7313
|
+
|
|
7314
|
+
type CustomGridSlot = {
|
|
7315
|
+
// first column the entry covers and how many, kept in the layout's columns
|
|
7316
|
+
column: number;
|
|
7317
|
+
span: number;
|
|
7318
|
+
width: number;
|
|
7319
|
+
top: number;
|
|
7320
|
+
height: number;
|
|
7321
|
+
gridColumn: string;
|
|
7322
|
+
gridRow: string;
|
|
7323
|
+
};
|
|
7324
|
+
|
|
7325
|
+
function getCustomGridBlocksBottom(layout: CustomGridLayout): number {
|
|
7326
|
+
return layout.blocks.reduce((bottom, block) => Math.max(bottom, Math.max(0, block.top) + Math.max(0, block.height)), 0);
|
|
7327
|
+
}
|
|
7328
|
+
|
|
7329
|
+
function getCustomGridVerticalGap(layout: CustomGridLayout): number {
|
|
7330
|
+
if (typeof layout.verticalGap === 'number') return Math.max(0, layout.verticalGap);
|
|
7331
|
+
return Math.max(0, (layout.repeatHeight ?? 0) - getCustomGridBlocksBottom(layout));
|
|
7332
|
+
}
|
|
7333
|
+
|
|
7334
|
+
// entries fill the layout's blocks in order, one group after another
|
|
7335
|
+
function getCustomGridSlot(layout: CustomGridLayout, index: number): CustomGridSlot {
|
|
7336
|
+
const block = layout.blocks[index % layout.blocks.length];
|
|
7337
|
+
const span = Math.min(Math.max(1, Math.round(block.span)), layout.columnsCount);
|
|
7338
|
+
const column = Math.min(Math.max(0, Math.round(block.column)), layout.columnsCount - span);
|
|
7339
|
+
return {
|
|
7340
|
+
column,
|
|
7341
|
+
span,
|
|
7342
|
+
width: getCustomGridSpanWidth(layout, span),
|
|
7343
|
+
top: Math.max(0, block.top),
|
|
7344
|
+
height: Math.max(0, block.height),
|
|
7345
|
+
gridColumn: \`\${column + 1} / span \${span}\`,
|
|
7346
|
+
gridRow: \`\${Math.floor(index / layout.blocks.length) + 1}\`,
|
|
7347
|
+
};
|
|
7348
|
+
}
|
|
7349
|
+
|
|
7350
|
+
// the first of the grid's beats at or under \`value\`, from the top of the group
|
|
7351
|
+
function snapDownToCustomGridBeat(layout: CustomGridLayout, value: number): number {
|
|
7352
|
+
const beat = layout.beat ?? 0;
|
|
7353
|
+
return beat > 0 ? Math.ceil(value / beat - 1e-6) * beat : value;
|
|
7354
|
+
}
|
|
7355
|
+
|
|
7356
|
+
/**
|
|
7357
|
+
* With the text outside the blocks, every entry's text takes room under its block: an entry of its
|
|
7358
|
+
* group under it in the same columns keeps where it is drawn, moved along with the entry above,
|
|
7359
|
+
* unless that text reaches it, and then goes onto the first beat under the text. The group grows to
|
|
7360
|
+
* the first beat under its lowest text. Text heights, tops and group heights are in layout units,
|
|
7361
|
+
* like the blocks'.
|
|
7362
|
+
*/
|
|
7363
|
+
function getCustomGridOutsideTextPlacement(layout: CustomGridLayout, textHeights: number[]) {
|
|
7364
|
+
const slots = textHeights.map((_, index) => getCustomGridSlot(layout, index));
|
|
7365
|
+
const tops = slots.map(slot => slot.top);
|
|
7366
|
+
const groupHeights: number[] = [];
|
|
7367
|
+
for (let groupStart = 0; groupStart < slots.length; groupStart += layout.blocks.length) {
|
|
7368
|
+
const group = slots
|
|
7369
|
+
.map((slot, index) => ({ slot, index }))
|
|
7370
|
+
.slice(groupStart, groupStart + layout.blocks.length)
|
|
7371
|
+
.sort((a, b) => a.slot.top - b.slot.top);
|
|
7372
|
+
let bottom = getCustomGridBlocksBottom(layout);
|
|
7373
|
+
for (const { slot, index } of group) {
|
|
7374
|
+
let top = slot.top;
|
|
7375
|
+
for (const { slot: above, index: aboveIndex } of group) {
|
|
7376
|
+
const isAbove = above.top + above.height <= slot.top + 1e-6 && aboveIndex !== index;
|
|
7377
|
+
const sharesColumns = above.column < slot.column + slot.span && slot.column < above.column + above.span;
|
|
7378
|
+
if (isAbove && sharesColumns) {
|
|
7379
|
+
const textBottom = tops[aboveIndex] + above.height + textHeights[aboveIndex];
|
|
7380
|
+
const drawnTop = slot.top + tops[aboveIndex] - above.top;
|
|
7381
|
+
top = Math.max(top, drawnTop >= textBottom - 1e-6 ? drawnTop : snapDownToCustomGridBeat(layout, textBottom));
|
|
7382
|
+
}
|
|
7383
|
+
}
|
|
7384
|
+
tops[index] = top;
|
|
7385
|
+
bottom = Math.max(bottom, tops[index] + slot.height + textHeights[index]);
|
|
7386
|
+
}
|
|
7387
|
+
groupHeights.push(snapDownToCustomGridBeat(layout, bottom));
|
|
7388
|
+
}
|
|
7389
|
+
return { tops, groupHeights };
|
|
7390
|
+
}
|
|
7391
|
+
|
|
7348
7392
|
export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, metadata, activeEvent, layoutId, portalId }: GridProps) {
|
|
7349
7393
|
const { prefix: P } = useScopedStyles();
|
|
7350
7394
|
const {
|
|
7351
7395
|
type = 'a',
|
|
7352
7396
|
gridLayout,
|
|
7397
|
+
customGrid,
|
|
7353
7398
|
textBoxWidth = 100,
|
|
7354
7399
|
verticalGap,
|
|
7355
7400
|
entriesCount,
|
|
@@ -7397,6 +7442,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7397
7442
|
hover = 'none',
|
|
7398
7443
|
alignEntries = 'off',
|
|
7399
7444
|
align = 'top',
|
|
7445
|
+
textGrowth = 'inside',
|
|
7400
7446
|
} = settings;
|
|
7401
7447
|
|
|
7402
7448
|
const resolvedTitleTextStyle: TextStyles = {
|
|
@@ -7486,7 +7532,16 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7486
7532
|
const hoverEffectClass = hover !== 'none' && (!isEditor || isPreviewMode) ? \` \${P}-hover-\${hover}\` : '';
|
|
7487
7533
|
const wrapperStateClasses = \`\${stateClass}\${showTextOnHover ? \` \${P}-show-text-hover\` : ''}\${hoverEffectClass}\`.trim();
|
|
7488
7534
|
|
|
7489
|
-
|
|
7535
|
+
// a custom layout places entries itself, in place of the columns, gap and entries count: its
|
|
7536
|
+
// group of blocks repeats for as many entries as there are. Stored, it is only the preset it is
|
|
7537
|
+
// linked to; the CMS and the site put the blocks in before it gets here
|
|
7538
|
+
const customLayout = customGrid && Array.isArray(customGrid.blocks) && customGrid.blocks.length > 0 ? customGrid : undefined;
|
|
7539
|
+
const resEntriesCount = customLayout || entriesCount === 0 ? Infinity : entriesCount;
|
|
7540
|
+
// outside, the media fills the block and the text takes room of its own beyond it: below the
|
|
7541
|
+
// media, or above it when the type puts the text first, moving the entries under it down
|
|
7542
|
+
const isTextOutside = !!customLayout && textGrowth === 'outside';
|
|
7543
|
+
const itemInnerRefs = useRef<(HTMLDivElement | null)[]>([]);
|
|
7544
|
+
const [customTextHeights, setCustomTextHeights] = useState<number[]>([]);
|
|
7490
7545
|
|
|
7491
7546
|
const cropContent = (content ?? []).slice(0, resEntriesCount);
|
|
7492
7547
|
const lightboxMediaToPreload = useMemo(
|
|
@@ -7494,23 +7549,24 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7494
7549
|
[cropContent, lightbox],
|
|
7495
7550
|
);
|
|
7496
7551
|
|
|
7497
|
-
const size = gridLayout
|
|
7552
|
+
const size = gridLayout?.entryWidth ?? 0.2;
|
|
7498
7553
|
|
|
7499
|
-
const
|
|
7500
|
-
const
|
|
7501
|
-
const
|
|
7554
|
+
const imageDisplaySettings = typeof imageDisplay === 'string' ? { display: imageDisplay } : imageDisplay;
|
|
7555
|
+
const isCover = imageDisplaySettings?.display === 'cover';
|
|
7556
|
+
const ratioValue = imageDisplaySettings?.ratioValue ?? '1:1';
|
|
7557
|
+
const ratioReversed = imageDisplaySettings?.reversed ?? false;
|
|
7502
7558
|
const [rW, rH] = ratioValue.split(':').map(Number);
|
|
7503
7559
|
const effW = ratioReversed ? rH : rW;
|
|
7504
7560
|
const effH = ratioReversed ? rW : rH;
|
|
7505
7561
|
const aspectRatio = \`\${effW} / \${effH}\`;
|
|
7506
7562
|
|
|
7507
|
-
const columnsCount = gridLayout
|
|
7563
|
+
const columnsCount = gridLayout?.columnsCount ?? 1;
|
|
7508
7564
|
const entryWidthScaled = scalingValue(size ?? 0, isEditor);
|
|
7509
|
-
|
|
7510
|
-
const isFitSlider = !isCover && slider !== 'off';
|
|
7565
|
+
// a custom block sets the entry's height, so the fit slider has nothing to size it by
|
|
7566
|
+
const isFitSlider = !customLayout && !isCover && slider !== 'off';
|
|
7511
7567
|
|
|
7512
7568
|
const itemsInLastRow = cropContent.length % columnsCount || columnsCount;
|
|
7513
|
-
const isPartialLastRow = itemsInLastRow < columnsCount && cropContent.length > 0;
|
|
7569
|
+
const isPartialLastRow = !customLayout && itemsInLastRow < columnsCount && cropContent.length > 0;
|
|
7514
7570
|
const lastRowStartIndex = cropContent.length - itemsInLastRow;
|
|
7515
7571
|
const lastRowStartColumn = isPartialLastRow
|
|
7516
7572
|
? Math.floor((columnsCount - itemsInLastRow) / 2) + 1
|
|
@@ -7518,19 +7574,23 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7518
7574
|
|
|
7519
7575
|
const imageBorderRadius = imageCorners ? scalingValue(imageCorners, isEditor) : undefined;
|
|
7520
7576
|
|
|
7521
|
-
const
|
|
7522
|
-
width:
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7577
|
+
const getImageWrapperStyle = (entryWidth: string, slot?: CustomGridSlot): React.CSSProperties => ({
|
|
7578
|
+
width: entryWidth,
|
|
7579
|
+
// in a custom block the media takes whatever the entry's text leaves of the block's height,
|
|
7580
|
+
// or the whole block when the text goes outside it
|
|
7581
|
+
...(slot
|
|
7582
|
+
? isTextOutside
|
|
7583
|
+
? { height: scalingValue(slot.height, isEditor), flexShrink: 0, overflow: 'hidden' }
|
|
7584
|
+
: { flex: '1 1 0%', minHeight: 0, overflow: 'hidden' }
|
|
7585
|
+
: isCover
|
|
7586
|
+
? { aspectRatio, height: 'auto', overflow: 'hidden' }
|
|
7587
|
+
: { height: 'auto' }),
|
|
7526
7588
|
...(imageBorderRadius ? { borderRadius: imageBorderRadius, overflow: 'hidden' } : {}),
|
|
7527
|
-
};
|
|
7589
|
+
});
|
|
7528
7590
|
|
|
7529
7591
|
const imageWrapperClassName = \`\${P}-item-image-wrapper\${isFitSlider ? \` \${P}-item-image-wrapper-fit-slider\` : ''}\`.trim();
|
|
7530
7592
|
const isTextBeforeImage = type === 'd' || type === 'e' || type === 'f';
|
|
7531
|
-
const shouldAlignEntries = alignEntries === 'on';
|
|
7532
|
-
const textBoxWidthStyle = \`calc(\${scalingValue(size ?? 0, isEditor)} * (\${textBoxWidth} / 100))\`;
|
|
7533
|
-
const controlWidthStyle = scalingValue(size * textBoxWidth / 100, isEditor);
|
|
7593
|
+
const shouldAlignEntries = !customLayout && alignEntries === 'on';
|
|
7534
7594
|
|
|
7535
7595
|
const imageRadiusStyle = imageBorderRadius
|
|
7536
7596
|
? { borderRadius: imageBorderRadius, [MEDIA_RADIUS_VAR]: imageBorderRadius } as React.CSSProperties
|
|
@@ -7550,9 +7610,68 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7550
7610
|
width: 'auto',
|
|
7551
7611
|
height: 'auto',
|
|
7552
7612
|
maxWidth: '100%',
|
|
7613
|
+
...(customLayout ? { maxHeight: '100%' } : {}),
|
|
7553
7614
|
...imageRadiusStyle,
|
|
7554
7615
|
};
|
|
7555
7616
|
|
|
7617
|
+
// the text's height is only known once laid out: what an entry measures beyond its media, in
|
|
7618
|
+
// layout units, the layout's whole width taken as the wrapper's
|
|
7619
|
+
const customGridWidth = customLayout ? getCustomGridSpanWidth(customLayout, customLayout.columnsCount) : 0;
|
|
7620
|
+
useLayoutEffect(() => {
|
|
7621
|
+
if (!isTextOutside) {
|
|
7622
|
+
setCustomTextHeights(prev => (prev.length > 0 ? [] : prev));
|
|
7623
|
+
return;
|
|
7624
|
+
}
|
|
7625
|
+
const wrapper = containerRef.current;
|
|
7626
|
+
const inners = itemInnerRefs.current.slice(0, cropContent.length);
|
|
7627
|
+
const measure = () => {
|
|
7628
|
+
const unit = wrapper && customGridWidth > 0 ? wrapper.offsetWidth / customGridWidth : 0;
|
|
7629
|
+
const heights = inners.map((inner) => {
|
|
7630
|
+
const media = inner?.querySelector<HTMLElement>(\`.\${P}-item-image-wrapper\`);
|
|
7631
|
+
return inner && media && unit > 0 ? Math.max(0, inner.offsetHeight - media.offsetHeight) / unit : 0;
|
|
7632
|
+
});
|
|
7633
|
+
setCustomTextHeights(prev => (
|
|
7634
|
+
prev.length === heights.length && prev.every((height, index) => Math.abs(height - heights[index]) < 1e-5)
|
|
7635
|
+
? prev
|
|
7636
|
+
: heights
|
|
7637
|
+
));
|
|
7638
|
+
};
|
|
7639
|
+
measure();
|
|
7640
|
+
const ro = new ResizeObserver(measure);
|
|
7641
|
+
if (wrapper) ro.observe(wrapper);
|
|
7642
|
+
inners.forEach(inner => inner && ro.observe(inner));
|
|
7643
|
+
return () => ro.disconnect();
|
|
7644
|
+
}, [isTextOutside, cropContent.length, customGridWidth, P]);
|
|
7645
|
+
const customOutsideText = customLayout && isTextOutside
|
|
7646
|
+
? getCustomGridOutsideTextPlacement(customLayout, cropContent.map((_: unknown, index: number) => customTextHeights[index] ?? 0))
|
|
7647
|
+
: undefined;
|
|
7648
|
+
|
|
7649
|
+
const customRowsCount = customLayout ? Math.ceil(cropContent.length / customLayout.blocks.length) : 0;
|
|
7650
|
+
const customGroupHeight = customLayout ? scalingValue(getCustomGridBlocksBottom(customLayout), isEditor) : '';
|
|
7651
|
+
const wrapperLayoutStyle: React.CSSProperties = customLayout
|
|
7652
|
+
? {
|
|
7653
|
+
gridTemplateColumns: \`repeat(\${customLayout.columnsCount}, \${scalingValue(customLayout.columnWidth, isEditor)})\`,
|
|
7654
|
+
// every group keeps the height of its blocks, or of the beats its text outside them takes,
|
|
7655
|
+
// but the last, which ends where its entries do
|
|
7656
|
+
gridTemplateRows: customRowsCount > 1
|
|
7657
|
+
? customOutsideText
|
|
7658
|
+
? \`\${customOutsideText.groupHeights.slice(0, -1).map(height => \`minmax(\${scalingValue(height, isEditor)}, auto)\`).join(' ')} auto\`
|
|
7659
|
+
: \`repeat(\${customRowsCount - 1}, minmax(\${customGroupHeight}, auto)) auto\`
|
|
7660
|
+
: 'auto',
|
|
7661
|
+
rowGap: scalingValue(getCustomGridVerticalGap(customLayout), isEditor),
|
|
7662
|
+
columnGap: scalingValue(customLayout.gutterWidth, isEditor),
|
|
7663
|
+
width: scalingValue(getCustomGridSpanWidth(customLayout, customLayout.columnsCount), isEditor),
|
|
7664
|
+
}
|
|
7665
|
+
: {
|
|
7666
|
+
gridTemplateColumns: \`repeat(\${columnsCount}, \${entryWidthScaled})\`,
|
|
7667
|
+
rowGap: shouldAlignEntries ? 0 : scalingValue(verticalGap ?? 0, isEditor),
|
|
7668
|
+
columnGap: scalingValue(gridLayout?.horizontalGap ?? 0, isEditor),
|
|
7669
|
+
width: scalingValue(gridLayout?.wrapperWidth ?? 0, isEditor),
|
|
7670
|
+
...(shouldAlignEntries
|
|
7671
|
+
? { [\`--\${P}-align-entries-row-gap\`]: scalingValue(verticalGap ?? 0, isEditor) }
|
|
7672
|
+
: {}),
|
|
7673
|
+
};
|
|
7674
|
+
|
|
7556
7675
|
const [containerWidth, setContainerWidth] = useState(0);
|
|
7557
7676
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
7558
7677
|
|
|
@@ -7622,16 +7741,8 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7622
7741
|
<div style={colorVars}>
|
|
7623
7742
|
<div
|
|
7624
7743
|
ref={containerRef}
|
|
7625
|
-
className={\`\${P}-wrapper \${P}-type-\${type}\${shouldAlignEntries ? \` \${P}-align-entries\` : ''} \${P}-image-align-\${align} \${wrapperStateClasses}\`.trim()}
|
|
7626
|
-
style={
|
|
7627
|
-
gridTemplateColumns: \`repeat(\${columnsCount}, \${entryWidthScaled})\`,
|
|
7628
|
-
rowGap: shouldAlignEntries ? 0 : scalingValue(verticalGap ?? 0, isEditor),
|
|
7629
|
-
columnGap: scalingValue(gridLayout.horizontalGap ?? 0, isEditor),
|
|
7630
|
-
width: scalingValue(gridLayout.wrapperWidth ?? 0, isEditor),
|
|
7631
|
-
...(shouldAlignEntries
|
|
7632
|
-
? { [\`--\${P}-align-entries-row-gap\`]: scalingValue(verticalGap ?? 0, isEditor) }
|
|
7633
|
-
: {}),
|
|
7634
|
-
}}>
|
|
7744
|
+
className={\`\${P}-wrapper \${P}-type-\${type}\${shouldAlignEntries ? \` \${P}-align-entries\` : ''}\${customLayout ? \` \${P}-custom-layout\` : ''}\${isTextOutside ? \` \${P}-text-outside\` : ''} \${P}-image-align-\${align} \${wrapperStateClasses}\`.trim()}
|
|
7745
|
+
style={wrapperLayoutStyle}>
|
|
7635
7746
|
{cropContent.map((item: any, index: number) => {
|
|
7636
7747
|
const hasTitle = hasText(item.title);
|
|
7637
7748
|
const hasSubtitle = hasText(item.subtitle);
|
|
@@ -7641,6 +7752,20 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7641
7752
|
const gridColumn = isPartialLastRow && index >= lastRowStartIndex
|
|
7642
7753
|
? \`\${lastRowStartColumn + (index - lastRowStartIndex)}\`
|
|
7643
7754
|
: undefined;
|
|
7755
|
+
const customSlot = customLayout ? getCustomGridSlot(customLayout, index) : undefined;
|
|
7756
|
+
const itemSize = customSlot?.width ?? size;
|
|
7757
|
+
const itemWidthScaled = scalingValue(itemSize, isEditor);
|
|
7758
|
+
const textBoxWidthStyle = \`calc(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`;
|
|
7759
|
+
const controlWidthStyle = scalingValue(itemSize * textBoxWidth / 100, isEditor);
|
|
7760
|
+
const imageWrapperStyle = getImageWrapperStyle(itemWidthScaled, customSlot);
|
|
7761
|
+
const itemStyle: React.CSSProperties | undefined = customSlot
|
|
7762
|
+
? {
|
|
7763
|
+
gridColumn: customSlot.gridColumn,
|
|
7764
|
+
gridRow: customSlot.gridRow,
|
|
7765
|
+
alignSelf: 'start',
|
|
7766
|
+
marginTop: scalingValue(customOutsideText?.tops[index] ?? customSlot.top, isEditor),
|
|
7767
|
+
}
|
|
7768
|
+
: gridColumn && !shouldAlignEntries ? { gridColumn } : undefined;
|
|
7644
7769
|
|
|
7645
7770
|
const typeCTextBlock = isTextBeforeImage ? (
|
|
7646
7771
|
<div className={\`\${P}-item-text-block\`}>
|
|
@@ -7788,7 +7913,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7788
7913
|
</div>
|
|
7789
7914
|
)}
|
|
7790
7915
|
<Splide
|
|
7791
|
-
key={\`\${transition}-\${
|
|
7916
|
+
key={\`\${transition}-\${itemSize}-\${direction}-\${sliderTiming}-\${containerWidth}-\${layoutId}\`}
|
|
7792
7917
|
className={\`\${P}-item-slider\`}
|
|
7793
7918
|
options={{
|
|
7794
7919
|
arrows: false,
|
|
@@ -7882,16 +8007,18 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7882
8007
|
<div
|
|
7883
8008
|
key={index}
|
|
7884
8009
|
className={\`\${P}-item\`.trim()}
|
|
7885
|
-
style={
|
|
8010
|
+
style={itemStyle}
|
|
7886
8011
|
>
|
|
7887
8012
|
<div
|
|
7888
|
-
|
|
7889
|
-
|
|
8013
|
+
ref={(el) => { itemInnerRefs.current[index] = el; }}
|
|
8014
|
+
className={\`\${isEditMode
|
|
8015
|
+
? \`\${P}-item-inner\`
|
|
7890
8016
|
: \`\${P}-item-inner-hidden\`}\${shouldAlignEntries && isLastRow ? \` \${P}-item-inner-last-row\` : ''}\`.trim()}
|
|
7891
8017
|
style={{
|
|
7892
8018
|
width: (textBoxWidth ?? 0) > 100
|
|
7893
|
-
? \`calc(\${
|
|
7894
|
-
:
|
|
8019
|
+
? \`calc(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`
|
|
8020
|
+
: itemWidthScaled,
|
|
8021
|
+
...(customSlot && !isTextOutside ? { height: scalingValue(customSlot.height, isEditor) } : {}),
|
|
7895
8022
|
...(gridColumn && shouldAlignEntries ? { gridColumn } : {}),
|
|
7896
8023
|
}}
|
|
7897
8024
|
>
|
|
@@ -7974,17 +8101,45 @@ type GridLayoutConfig = {
|
|
|
7974
8101
|
lockedParam?: 'wrapperWidth' | 'entryWidth' | 'horizontalGap' | null;
|
|
7975
8102
|
};
|
|
7976
8103
|
|
|
8104
|
+
type CustomGridBlock = {
|
|
8105
|
+
// first column the block covers, from 0
|
|
8106
|
+
column: number;
|
|
8107
|
+
span: number;
|
|
8108
|
+
// offset from the top of its group
|
|
8109
|
+
top: number;
|
|
8110
|
+
// height of the whole entry: its media fills what the text leaves
|
|
8111
|
+
height: number;
|
|
8112
|
+
};
|
|
8113
|
+
|
|
8114
|
+
// lengths are fractions of the layout width, like the article grid's
|
|
8115
|
+
type CustomGridLayout = {
|
|
8116
|
+
columnsCount: number;
|
|
8117
|
+
columnWidth: number;
|
|
8118
|
+
gutterWidth: number;
|
|
8119
|
+
maxWidth: number | null;
|
|
8120
|
+
// space between one group of blocks and the next
|
|
8121
|
+
verticalGap?: number;
|
|
8122
|
+
// the article grid's beat: entries the text outside the blocks pushes down land on it; 0, or
|
|
8123
|
+
// missing from layouts resolved before it, when there is none
|
|
8124
|
+
beat?: number;
|
|
8125
|
+
// layouts saved before the vertical gap kept the height of a whole group instead
|
|
8126
|
+
repeatHeight?: number;
|
|
8127
|
+
blocks: CustomGridBlock[];
|
|
8128
|
+
};
|
|
8129
|
+
|
|
7977
8130
|
type GridSettings = {
|
|
7978
8131
|
type: 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
|
|
7979
|
-
|
|
8132
|
+
// one of the two places entries: Neptune's columns, or a layout drawn in the custom grid builder
|
|
8133
|
+
gridLayout?: GridLayoutConfig;
|
|
8134
|
+
customGrid?: CustomGridLayout;
|
|
7980
8135
|
textBoxWidth: number;
|
|
7981
|
-
verticalGap
|
|
7982
|
-
entriesCount
|
|
8136
|
+
verticalGap?: number;
|
|
8137
|
+
entriesCount?: number;
|
|
7983
8138
|
lightbox: 'on' | 'off';
|
|
7984
|
-
imageDisplay: {
|
|
8139
|
+
imageDisplay: 'fit' | 'cover' | {
|
|
7985
8140
|
display: 'fit' | 'cover';
|
|
7986
|
-
ratioValue
|
|
7987
|
-
reversed
|
|
8141
|
+
ratioValue?: '1:1' | '2:3' | '3:4' | '4:5' | '16:9';
|
|
8142
|
+
reversed?: boolean;
|
|
7988
8143
|
};
|
|
7989
8144
|
imageCorners?: number;
|
|
7990
8145
|
lightboxImageDisplay?: 'fit' | 'cover' | { display?: 'fit' | 'cover' };
|
|
@@ -7994,8 +8149,10 @@ type GridSettings = {
|
|
|
7994
8149
|
transition: 'fade' | 'slide',
|
|
7995
8150
|
showText: 'always' | 'on hover';
|
|
7996
8151
|
hover?: 'none' | 'zoom-in' | 'greyscale' | 'scale-down';
|
|
7997
|
-
alignEntries
|
|
8152
|
+
alignEntries?: 'on' | 'off';
|
|
7998
8153
|
align?: 'top' | 'center' | 'bottom';
|
|
8154
|
+
// with a custom layout: whether a block holds the entry's text or only its media
|
|
8155
|
+
textGrowth?: 'inside' | 'outside';
|
|
7999
8156
|
titleMarginTop: number;
|
|
8000
8157
|
subtitleMarginTop: number;
|
|
8001
8158
|
titleColor: string;
|
|
@@ -25362,4 +25519,4 @@ export function Waterfall({
|
|
|
25362
25519
|
</>
|
|
25363
25520
|
);
|
|
25364
25521
|
}
|
|
25365
|
-
`,
|
|
25522
|
+
`,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;
|