@cntrl-site/components 1.0.118-alpha.2 → 1.0.118-alpha.3
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/{ChroniclesComponent--pzhQXVD.js → ChroniclesComponent-BMbUwzk6.js} +1 -1
- package/dist/{ChroniclesComponent-Ds59v_47.mjs → ChroniclesComponent-DD3tqNNm.mjs} +1 -1
- package/dist/{ControlSlider-DqKfaKMG.mjs → ControlSlider-BBAXRDLP.mjs} +2 -3
- package/dist/ControlSlider-BCkVFl4w.js +1 -0
- package/dist/Grid-CUaVUaRa.js +441 -0
- package/dist/Grid-D19xZ_mh.mjs +1800 -0
- package/dist/{components-MVf3iei3.mjs → components-BwAmTGJp.mjs} +2 -2
- package/dist/{components-tuVRZ0WY.js → components-D8RelPGE.js} +1 -1
- package/dist/components.css +1 -1
- package/dist/elements.js +1 -1
- package/dist/elements.mjs +3 -3
- 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 +351 -272
- package/dist/sources.mjs +355 -276
- package/package.json +1 -1
- package/dist/ControlSlider-C8ckUIDm.js +0 -1
- package/dist/Grid-B0NOfgEm.mjs +0 -1713
- package/dist/Grid-DNaBgqZo.js +0 -415
package/dist/sources.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-DD3tqNNm.mjs";
|
|
2
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';
|
|
@@ -5642,9 +5642,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
|
|
|
5642
5642
|
};
|
|
5643
5643
|
|
|
5644
5644
|
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
5645
|
-
`, n = `import {
|
|
5646
|
-
import '@splidejs/react-splide/css/core';
|
|
5647
|
-
import { CommonComponentProps } from '../props';
|
|
5645
|
+
`, n = `import { CommonComponentProps } from '../props';
|
|
5648
5646
|
import { EmbedMediaFrame, getEmbedAspect, getEmbedPlayback, isEmbedMedia } from '../utils/index';
|
|
5649
5647
|
import {
|
|
5650
5648
|
buildColorVars,
|
|
@@ -5654,7 +5652,7 @@ import {
|
|
|
5654
5652
|
useLazyVideos,
|
|
5655
5653
|
useScopedStyles,
|
|
5656
5654
|
} from '../utils/index';
|
|
5657
|
-
import { useCallback, useEffect, useLayoutEffect, useRef, useState, useMemo } from 'react';
|
|
5655
|
+
import { memo, useCallback, useEffect, useLayoutEffect, useRef, useState, useMemo } from 'react';
|
|
5658
5656
|
import { createPortal } from 'react-dom';
|
|
5659
5657
|
import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss';
|
|
5660
5658
|
import { SvgImage } from '../helpers/SvgImage/SvgImage';
|
|
@@ -5771,9 +5769,6 @@ function getCSS(P: string): string {
|
|
|
5771
5769
|
width: 100%;
|
|
5772
5770
|
overflow: hidden;
|
|
5773
5771
|
}
|
|
5774
|
-
.\${P}-item-slider .splide__track {
|
|
5775
|
-
overflow: hidden;
|
|
5776
|
-
}
|
|
5777
5772
|
.\${P}-item-image-link {
|
|
5778
5773
|
width: 100%;
|
|
5779
5774
|
display: flex;
|
|
@@ -5807,18 +5802,47 @@ function getCSS(P: string): string {
|
|
|
5807
5802
|
display: block;
|
|
5808
5803
|
max-width: 100%;
|
|
5809
5804
|
}
|
|
5810
|
-
.\${P}-item-slider
|
|
5811
|
-
|
|
5812
|
-
.\${P}-item-slider .splide__list,
|
|
5813
|
-
.\${P}-item-slider .splide__slide {
|
|
5805
|
+
.\${P}-item-slider {
|
|
5806
|
+
position: relative;
|
|
5814
5807
|
width: 100%;
|
|
5815
5808
|
height: 100%;
|
|
5809
|
+
overflow: hidden;
|
|
5816
5810
|
}
|
|
5817
|
-
.\${P}-item-slider
|
|
5811
|
+
.\${P}-item-slider-list {
|
|
5812
|
+
position: relative;
|
|
5813
|
+
display: flex;
|
|
5814
|
+
flex-direction: row;
|
|
5815
|
+
width: 100%;
|
|
5816
|
+
height: 100%;
|
|
5817
|
+
will-change: transform;
|
|
5818
|
+
}
|
|
5819
|
+
.\${P}-item-slider-list-vertical {
|
|
5820
|
+
flex-direction: column;
|
|
5821
|
+
}
|
|
5822
|
+
.\${P}-item-slider-list-fade {
|
|
5823
|
+
display: block;
|
|
5824
|
+
will-change: auto;
|
|
5825
|
+
}
|
|
5826
|
+
.\${P}-item-slide {
|
|
5827
|
+
position: relative;
|
|
5828
|
+
flex: 0 0 100%;
|
|
5829
|
+
width: 100%;
|
|
5830
|
+
height: 100%;
|
|
5818
5831
|
display: flex;
|
|
5819
5832
|
justify-content: center;
|
|
5820
5833
|
align-items: center;
|
|
5821
5834
|
}
|
|
5835
|
+
.\${P}-item-slider-list-fade .\${P}-item-slide {
|
|
5836
|
+
position: absolute;
|
|
5837
|
+
top: 0;
|
|
5838
|
+
left: 0;
|
|
5839
|
+
opacity: 0;
|
|
5840
|
+
transition: opacity \${SLIDER_TRANSITION_MS}ms \${SLIDER_EASING};
|
|
5841
|
+
}
|
|
5842
|
+
.\${P}-item-slider-list-fade .\${P}-item-slide-active {
|
|
5843
|
+
opacity: 1;
|
|
5844
|
+
z-index: 1;
|
|
5845
|
+
}
|
|
5822
5846
|
.\${P}-item-title {
|
|
5823
5847
|
white-space: normal;
|
|
5824
5848
|
overflow-wrap: anywhere;
|
|
@@ -5965,13 +5989,13 @@ function getCSS(P: string): string {
|
|
|
5965
5989
|
.\${P}-image-align-bottom .\${P}-item-image-wrapper:not(.\${P}-item-image-wrapper-fit-slider) {
|
|
5966
5990
|
align-items: flex-end;
|
|
5967
5991
|
}
|
|
5968
|
-
.\${P}-image-align-top .\${P}-item-slider
|
|
5992
|
+
.\${P}-image-align-top .\${P}-item-slider .\${P}-item-slide {
|
|
5969
5993
|
align-items: flex-start;
|
|
5970
5994
|
}
|
|
5971
|
-
.\${P}-image-align-center .\${P}-item-slider
|
|
5995
|
+
.\${P}-image-align-center .\${P}-item-slider .\${P}-item-slide {
|
|
5972
5996
|
align-items: center;
|
|
5973
5997
|
}
|
|
5974
|
-
.\${P}-image-align-bottom .\${P}-item-slider
|
|
5998
|
+
.\${P}-image-align-bottom .\${P}-item-slider .\${P}-item-slide {
|
|
5975
5999
|
align-items: flex-end;
|
|
5976
6000
|
}
|
|
5977
6001
|
.\${P}-align-entries .\${P}-item {
|
|
@@ -6052,13 +6076,13 @@ function getCSS(P: string): string {
|
|
|
6052
6076
|
.\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-image-wrapper:not(.\${P}-item-image-wrapper-fit-slider) {
|
|
6053
6077
|
align-items: flex-end;
|
|
6054
6078
|
}
|
|
6055
|
-
.\${P}-image-align-top.\${P}-align-entries .\${P}-item-slider
|
|
6079
|
+
.\${P}-image-align-top.\${P}-align-entries .\${P}-item-slider .\${P}-item-slide {
|
|
6056
6080
|
align-items: flex-start;
|
|
6057
6081
|
}
|
|
6058
|
-
.\${P}-image-align-center.\${P}-align-entries .\${P}-item-slider
|
|
6082
|
+
.\${P}-image-align-center.\${P}-align-entries .\${P}-item-slider .\${P}-item-slide {
|
|
6059
6083
|
align-items: center;
|
|
6060
6084
|
}
|
|
6061
|
-
.\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-slider
|
|
6085
|
+
.\${P}-image-align-bottom.\${P}-align-entries .\${P}-item-slider .\${P}-item-slide {
|
|
6062
6086
|
align-items: flex-end;
|
|
6063
6087
|
}
|
|
6064
6088
|
.\${P}-image-align-top.\${P}-align-entries .\${P}-item-image-link {
|
|
@@ -6126,27 +6150,9 @@ function pickRandomSlideDirection(): 'ltr' | 'ttb' {
|
|
|
6126
6150
|
return Math.random() < 0.5 ? 'ltr' : 'ttb';
|
|
6127
6151
|
}
|
|
6128
6152
|
|
|
6129
|
-
function
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
autoplay.pause(false);
|
|
6133
|
-
autoplay.play();
|
|
6134
|
-
}
|
|
6135
|
-
|
|
6136
|
-
function handleRandomSlideMoved(splide: {
|
|
6137
|
-
options: { direction?: string };
|
|
6138
|
-
Components: { Autoplay?: { pause: (stop?: boolean) => void; play: () => void } };
|
|
6139
|
-
}) {
|
|
6140
|
-
const next = pickRandomSlideDirection();
|
|
6141
|
-
if (splide.options.direction !== next) {
|
|
6142
|
-
splide.options = { ...splide.options, direction: next };
|
|
6143
|
-
}
|
|
6144
|
-
|
|
6145
|
-
requestAnimationFrame(() => {
|
|
6146
|
-
requestAnimationFrame(() => {
|
|
6147
|
-
resumeSplideAutoplay(splide);
|
|
6148
|
-
});
|
|
6149
|
-
});
|
|
6153
|
+
function wrapSlideIndex(index: number, count: number): number {
|
|
6154
|
+
if (count <= 0) return 0;
|
|
6155
|
+
return ((index % count) + count) % count;
|
|
6150
6156
|
}
|
|
6151
6157
|
|
|
6152
6158
|
type GridProps = {
|
|
@@ -6186,6 +6192,8 @@ type LightboxProps = {
|
|
|
6186
6192
|
|
|
6187
6193
|
const LIGHTBOX_ANIM_MS = 500;
|
|
6188
6194
|
const SLIDER_TRANSITION_MS = 750;
|
|
6195
|
+
const SLIDER_EASING = 'cubic-bezier(0.25, 1, 0.5, 1)';
|
|
6196
|
+
const SLIDER_DEFAULT_INTERVAL_MS = 5000;
|
|
6189
6197
|
const LIGHTBOX_EASING = 'cubic-bezier(0.22, 1, 0.36, 1)';
|
|
6190
6198
|
const SWIPE_CLOSE_THRESHOLD = 72;
|
|
6191
6199
|
const SWIPE_NAV_THRESHOLD = 50;
|
|
@@ -6275,7 +6283,7 @@ function collectGridLightboxMedia(content: any[]): GridMedia[] {
|
|
|
6275
6283
|
return result;
|
|
6276
6284
|
}
|
|
6277
6285
|
|
|
6278
|
-
function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
|
|
6286
|
+
const LightboxMediaPreloadPool = memo(function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
|
|
6279
6287
|
const [pool, setPool] = useState<HTMLDivElement | null>(null);
|
|
6280
6288
|
useLazyVideos(pool, { preload: 'metadata' });
|
|
6281
6289
|
// an embed's player is only ever framed where it shows
|
|
@@ -6314,7 +6322,7 @@ function LightboxMediaPreloadPool({ mediaList }: { mediaList: GridMedia[] }) {
|
|
|
6314
6322
|
))}
|
|
6315
6323
|
</div>
|
|
6316
6324
|
);
|
|
6317
|
-
}
|
|
6325
|
+
});
|
|
6318
6326
|
|
|
6319
6327
|
function unloadVideoElement(video: HTMLVideoElement) {
|
|
6320
6328
|
video.pause();
|
|
@@ -6322,15 +6330,121 @@ function unloadVideoElement(video: HTMLVideoElement) {
|
|
|
6322
6330
|
video.load();
|
|
6323
6331
|
}
|
|
6324
6332
|
|
|
6325
|
-
const
|
|
6333
|
+
const GRID_SLIDE_CLASS = 'cntrl-grid-slide';
|
|
6334
|
+
const GRID_SLIDE_PLAYING_CLASS = 'cntrl-grid-slide-playing';
|
|
6335
|
+
const GRID_SLIDE_VIDEOS = \`.\${GRID_SLIDE_CLASS} video\`;
|
|
6326
6336
|
|
|
6327
6337
|
function shouldPlaySlideVideo(video: HTMLVideoElement): boolean {
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6338
|
+
return video.closest(\`.\${GRID_SLIDE_PLAYING_CLASS}\`) !== null;
|
|
6339
|
+
}
|
|
6340
|
+
|
|
6341
|
+
type GridEntrySliderProps = {
|
|
6342
|
+
prefix: string;
|
|
6343
|
+
slides: React.ReactNode[];
|
|
6344
|
+
isFade: boolean;
|
|
6345
|
+
direction: GridSettings['direction'];
|
|
6346
|
+
intervalMs: number;
|
|
6347
|
+
};
|
|
6348
|
+
|
|
6349
|
+
function GridEntrySlider({ prefix: P, slides, isFade, direction, intervalMs }: GridEntrySliderProps) {
|
|
6350
|
+
const count = slides.length;
|
|
6351
|
+
const hasClones = !isFade && count > 1;
|
|
6352
|
+
const isRandom = !isFade && direction === 'random';
|
|
6353
|
+
const delayMs = Number.isFinite(intervalMs) && intervalMs > 0 ? intervalMs : SLIDER_DEFAULT_INTERVAL_MS;
|
|
6354
|
+
const [position, setPosition] = useState(hasClones ? 1 : 0);
|
|
6355
|
+
const [axis, setAxis] = useState<'ltr' | 'ttb'>(!isFade && direction === 'vertical' ? 'ttb' : 'ltr');
|
|
6356
|
+
const [isMoving, setIsMoving] = useState(false);
|
|
6357
|
+
const [skipTransition, setSkipTransition] = useState(false);
|
|
6358
|
+
const [cycle, setCycle] = useState(0);
|
|
6359
|
+
const isMovingRef = useRef(false);
|
|
6360
|
+
|
|
6361
|
+
useEffect(() => {
|
|
6362
|
+
if (count < 2) return;
|
|
6363
|
+
const timeoutId = window.setTimeout(() => {
|
|
6364
|
+
if (isMovingRef.current) {
|
|
6365
|
+
setCycle(prev => prev + 1);
|
|
6366
|
+
return;
|
|
6367
|
+
}
|
|
6368
|
+
isMovingRef.current = true;
|
|
6369
|
+
setIsMoving(true);
|
|
6370
|
+
setSkipTransition(false);
|
|
6371
|
+
setPosition(prev => (hasClones ? prev + 1 : wrapSlideIndex(prev + 1, count)));
|
|
6372
|
+
if (!isRandom) setCycle(prev => prev + 1);
|
|
6373
|
+
}, delayMs);
|
|
6374
|
+
return () => window.clearTimeout(timeoutId);
|
|
6375
|
+
}, [count, cycle, delayMs, hasClones, isRandom]);
|
|
6376
|
+
|
|
6377
|
+
useEffect(() => {
|
|
6378
|
+
if (!isMoving) return;
|
|
6379
|
+
const timeoutId = window.setTimeout(() => {
|
|
6380
|
+
const isOnClone = hasClones && position === count + 1;
|
|
6381
|
+
const nextAxis = isRandom ? pickRandomSlideDirection() : axis;
|
|
6382
|
+
if (isOnClone || nextAxis !== axis) {
|
|
6383
|
+
setSkipTransition(true);
|
|
6384
|
+
if (isOnClone) setPosition(1);
|
|
6385
|
+
setAxis(nextAxis);
|
|
6386
|
+
}
|
|
6387
|
+
isMovingRef.current = false;
|
|
6388
|
+
setIsMoving(false);
|
|
6389
|
+
if (isRandom) setCycle(prev => prev + 1);
|
|
6390
|
+
}, SLIDER_TRANSITION_MS);
|
|
6391
|
+
return () => window.clearTimeout(timeoutId);
|
|
6392
|
+
}, [axis, count, hasClones, isMoving, isRandom, position]);
|
|
6393
|
+
|
|
6394
|
+
useEffect(() => {
|
|
6395
|
+
if (!skipTransition) return;
|
|
6396
|
+
let innerId = 0;
|
|
6397
|
+
const outerId = requestAnimationFrame(() => {
|
|
6398
|
+
innerId = requestAnimationFrame(() => setSkipTransition(false));
|
|
6399
|
+
});
|
|
6400
|
+
return () => {
|
|
6401
|
+
cancelAnimationFrame(outerId);
|
|
6402
|
+
cancelAnimationFrame(innerId);
|
|
6403
|
+
};
|
|
6404
|
+
}, [skipTransition]);
|
|
6405
|
+
|
|
6406
|
+
const slotsCount = hasClones ? count + 2 : count;
|
|
6407
|
+
const getItemIndex = (slot: number) => (hasClones ? wrapSlideIndex(slot - 1, count) : slot);
|
|
6408
|
+
const isCloneSlot = (slot: number) => hasClones && (slot === 0 || slot === count + 1);
|
|
6409
|
+
const activeIndex = getItemIndex(position);
|
|
6410
|
+
const nextSlot = position + 1 < slotsCount ? position + 1 : -1;
|
|
6411
|
+
const isPlayingSlot = (slot: number) => isFade
|
|
6412
|
+
|| (slot === position && !isCloneSlot(slot))
|
|
6413
|
+
|| slot === nextSlot
|
|
6414
|
+
|| (nextSlot >= 0 && !isCloneSlot(slot) && getItemIndex(slot) === getItemIndex(nextSlot));
|
|
6415
|
+
const isVertical = !isFade && axis === 'ttb';
|
|
6416
|
+
const listStyle: React.CSSProperties | undefined = isFade
|
|
6417
|
+
? undefined
|
|
6418
|
+
: {
|
|
6419
|
+
transform: isVertical
|
|
6420
|
+
? \`translate3d(0, \${-position * 100}%, 0)\`
|
|
6421
|
+
: \`translate3d(\${-position * 100}%, 0, 0)\`,
|
|
6422
|
+
transition: skipTransition ? 'none' : \`transform \${SLIDER_TRANSITION_MS}ms \${SLIDER_EASING}\`,
|
|
6423
|
+
};
|
|
6424
|
+
|
|
6425
|
+
return (
|
|
6426
|
+
<div className={\`\${P}-item-slider\`}>
|
|
6427
|
+
<div
|
|
6428
|
+
className={\`\${P}-item-slider-list\${isFade ? \` \${P}-item-slider-list-fade\` : ''}\${isVertical ? \` \${P}-item-slider-list-vertical\` : ''}\`}
|
|
6429
|
+
style={listStyle}
|
|
6430
|
+
>
|
|
6431
|
+
{Array.from({ length: slotsCount }, (_, slot) => {
|
|
6432
|
+
const itemIndex = getItemIndex(slot);
|
|
6433
|
+
const isClone = isCloneSlot(slot);
|
|
6434
|
+
const isShown = isFade ? itemIndex === activeIndex : slot === position;
|
|
6435
|
+
return (
|
|
6436
|
+
<div
|
|
6437
|
+
key={isClone ? \`clone-\${slot === 0 ? 'start' : 'end'}\` : \`slide-\${itemIndex}\`}
|
|
6438
|
+
className={\`\${P}-item-slide \${GRID_SLIDE_CLASS}\${isFade && isShown ? \` \${P}-item-slide-active\` : ''}\${isPlayingSlot(slot) ? \` \${GRID_SLIDE_PLAYING_CLASS}\` : ''}\`}
|
|
6439
|
+
aria-hidden={isShown ? undefined : true}
|
|
6440
|
+
>
|
|
6441
|
+
{slides[itemIndex]}
|
|
6442
|
+
</div>
|
|
6443
|
+
);
|
|
6444
|
+
})}
|
|
6445
|
+
</div>
|
|
6446
|
+
</div>
|
|
6447
|
+
);
|
|
6334
6448
|
}
|
|
6335
6449
|
|
|
6336
6450
|
function GridMediaItem({
|
|
@@ -6338,7 +6452,7 @@ function GridMediaItem({
|
|
|
6338
6452
|
className,
|
|
6339
6453
|
style,
|
|
6340
6454
|
hasLightbox,
|
|
6341
|
-
|
|
6455
|
+
isSliderSlide = false,
|
|
6342
6456
|
onMediaClick,
|
|
6343
6457
|
}: {
|
|
6344
6458
|
media: GridMedia;
|
|
@@ -6346,7 +6460,7 @@ function GridMediaItem({
|
|
|
6346
6460
|
style: React.CSSProperties;
|
|
6347
6461
|
/** An embed then plays here as a silent loop, and as it was set to in the lightbox. */
|
|
6348
6462
|
hasLightbox: boolean;
|
|
6349
|
-
|
|
6463
|
+
isSliderSlide?: boolean;
|
|
6350
6464
|
onMediaClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
6351
6465
|
}) {
|
|
6352
6466
|
if (isEmbedMedia(media)) {
|
|
@@ -6378,7 +6492,7 @@ function GridMediaItem({
|
|
|
6378
6492
|
playsInline: true,
|
|
6379
6493
|
onClick: onMediaClick,
|
|
6380
6494
|
};
|
|
6381
|
-
return
|
|
6495
|
+
return isSliderSlide
|
|
6382
6496
|
? <video {...videoProps} preload='none' />
|
|
6383
6497
|
: <LazyVideo {...videoProps} autoPlay />;
|
|
6384
6498
|
}
|
|
@@ -6407,7 +6521,7 @@ function GridItemMediaWrapper({
|
|
|
6407
6521
|
children: React.ReactNode;
|
|
6408
6522
|
}) {
|
|
6409
6523
|
const [wrapper, setWrapper] = useState<HTMLDivElement | null>(null);
|
|
6410
|
-
useLazyVideos(wrapper, { autoPlay: true, selector:
|
|
6524
|
+
useLazyVideos(wrapper, { autoPlay: true, selector: GRID_SLIDE_VIDEOS, shouldPlay: shouldPlaySlideVideo });
|
|
6411
6525
|
|
|
6412
6526
|
return (
|
|
6413
6527
|
<div ref={setWrapper} className={className} style={style}>
|
|
@@ -7313,14 +7427,12 @@ function getCustomGridSpanWidth(layout: CustomGridLayout, span: number): number
|
|
|
7313
7427
|
}
|
|
7314
7428
|
|
|
7315
7429
|
type CustomGridSlot = {
|
|
7316
|
-
// first column the entry covers and how many, kept in the layout's columns
|
|
7317
7430
|
column: number;
|
|
7318
7431
|
span: number;
|
|
7319
7432
|
width: number;
|
|
7320
7433
|
top: number;
|
|
7321
7434
|
height: number;
|
|
7322
7435
|
gridColumn: string;
|
|
7323
|
-
gridRow: string;
|
|
7324
7436
|
};
|
|
7325
7437
|
|
|
7326
7438
|
function getCustomGridBlocksBottom(layout: CustomGridLayout): number {
|
|
@@ -7332,7 +7444,6 @@ function getCustomGridVerticalGap(layout: CustomGridLayout): number {
|
|
|
7332
7444
|
return Math.max(0, (layout.repeatHeight ?? 0) - getCustomGridBlocksBottom(layout));
|
|
7333
7445
|
}
|
|
7334
7446
|
|
|
7335
|
-
// entries fill the layout's blocks in order, one group after another
|
|
7336
7447
|
function getCustomGridSlot(layout: CustomGridLayout, index: number): CustomGridSlot {
|
|
7337
7448
|
const block = layout.blocks[index % layout.blocks.length];
|
|
7338
7449
|
const span = Math.min(Math.max(1, Math.round(block.span)), layout.columnsCount);
|
|
@@ -7344,50 +7455,67 @@ function getCustomGridSlot(layout: CustomGridLayout, index: number): CustomGridS
|
|
|
7344
7455
|
top: Math.max(0, block.top),
|
|
7345
7456
|
height: Math.max(0, block.height),
|
|
7346
7457
|
gridColumn: \`\${column + 1} / span \${span}\`,
|
|
7347
|
-
gridRow: \`\${Math.floor(index / layout.blocks.length) + 1}\`,
|
|
7348
7458
|
};
|
|
7349
7459
|
}
|
|
7350
7460
|
|
|
7351
|
-
|
|
7352
|
-
|
|
7461
|
+
const EDGE_TOLERANCE = 1e-6;
|
|
7462
|
+
|
|
7463
|
+
function getCustomGridRows(layout: CustomGridLayout, entriesCount: number, entryHeights?: number[]) {
|
|
7353
7464
|
const beat = layout.beat ?? 0;
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
.sort((a, b) => a
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7465
|
+
const onBeats = beat > 0 && !!entryHeights;
|
|
7466
|
+
const snapUp = (value: number) => Math.ceil(value / beat - 1e-3) * beat;
|
|
7467
|
+
const tracks: (number | 'auto')[] = [];
|
|
7468
|
+
const gridRows: string[] = [];
|
|
7469
|
+
const verticalGap = getCustomGridVerticalGap(layout);
|
|
7470
|
+
for (let groupStart = 0; groupStart < entriesCount; groupStart += layout.blocks.length) {
|
|
7471
|
+
if (groupStart > 0 && verticalGap > 0) tracks.push(verticalGap);
|
|
7472
|
+
const slots = Array.from(
|
|
7473
|
+
{ length: Math.min(layout.blocks.length, entriesCount - groupStart) },
|
|
7474
|
+
(_, index) => getCustomGridSlot(layout, groupStart + index),
|
|
7475
|
+
);
|
|
7476
|
+
const ends = slots.map((slot) => {
|
|
7477
|
+
const under = slots.filter(other => other.column < slot.column + slot.span
|
|
7478
|
+
&& slot.column < other.column + other.span
|
|
7479
|
+
&& other.top >= slot.top + slot.height - EDGE_TOLERANCE);
|
|
7480
|
+
return under.length > 0 ? Math.min(...under.map(other => other.top)) : undefined;
|
|
7481
|
+
});
|
|
7482
|
+
const tops = [0, ...slots.map(slot => slot.top)]
|
|
7483
|
+
.sort((a, b) => a - b)
|
|
7484
|
+
.filter((top, index, sorted) => index === 0 || top - sorted[index - 1] > EDGE_TOLERANCE);
|
|
7485
|
+
const isSame = (a: number, b: number) => Math.abs(a - b) <= EDGE_TOLERANCE;
|
|
7486
|
+
const getTop = (value: number) => tops.findIndex(top => isSame(top, value));
|
|
7487
|
+
const positions: number[] = [];
|
|
7488
|
+
let position = 0;
|
|
7489
|
+
const pushContentTrack = (isEnding: (end: number | undefined) => boolean) => {
|
|
7490
|
+
const ending = slots.flatMap((slot, index) => (isEnding(ends[index]) ? [{ slot, entry: groupStart + index }] : []));
|
|
7491
|
+
if (ending.length === 0) return;
|
|
7492
|
+
if (!onBeats) {
|
|
7493
|
+
tracks.push('auto');
|
|
7494
|
+
return;
|
|
7384
7495
|
}
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7496
|
+
const needed = Math.max(...ending.map(({ slot, entry }) => positions[getTop(slot.top)] + (entryHeights[entry] ?? 0)));
|
|
7497
|
+
const track = Math.max(0, snapUp(needed) - position);
|
|
7498
|
+
tracks.push(track);
|
|
7499
|
+
position += track;
|
|
7500
|
+
};
|
|
7501
|
+
const lines = tops.map((top, index) => {
|
|
7502
|
+
if (index > 0) {
|
|
7503
|
+
tracks.push(top - tops[index - 1]);
|
|
7504
|
+
position += top - tops[index - 1];
|
|
7505
|
+
}
|
|
7506
|
+
pushContentTrack(end => end !== undefined && isSame(end, top));
|
|
7507
|
+
positions.push(position);
|
|
7508
|
+
return tracks.length + 1;
|
|
7509
|
+
});
|
|
7510
|
+
pushContentTrack(end => end === undefined);
|
|
7511
|
+
const groupEnd = tracks.length + 1;
|
|
7512
|
+
const getLine = (value: number) => lines[getTop(value)];
|
|
7513
|
+
slots.forEach((slot, index) => {
|
|
7514
|
+
const end = ends[index];
|
|
7515
|
+
gridRows.push(\`\${getLine(slot.top)} / \${end === undefined ? groupEnd : getLine(end)}\`);
|
|
7516
|
+
});
|
|
7389
7517
|
}
|
|
7390
|
-
return {
|
|
7518
|
+
return { tracks, gridRows };
|
|
7391
7519
|
}
|
|
7392
7520
|
|
|
7393
7521
|
export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, metadata, activeEvent, layoutId, portalId }: GridProps) {
|
|
@@ -7446,60 +7574,66 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7446
7574
|
textGrowth = 'inside',
|
|
7447
7575
|
} = settings;
|
|
7448
7576
|
|
|
7449
|
-
const
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7577
|
+
const titleTextStyle = useMemo(() => ({
|
|
7578
|
+
...omitTextColors(textStylesToCss({
|
|
7579
|
+
fontSettings: {
|
|
7580
|
+
fontFamily: titleFontFamily,
|
|
7581
|
+
fontWeight: titleFontSettings?.fontWeight ?? 400,
|
|
7582
|
+
fontStyle: titleFontSettings?.fontStyle ?? 'normal',
|
|
7583
|
+
},
|
|
7584
|
+
fontSize: titleFontSize ?? 0.01,
|
|
7585
|
+
lineHeight: titleLineHeight,
|
|
7586
|
+
letterSpacing: titleLetterSpacing ?? 0,
|
|
7587
|
+
wordSpacing: titleWordSpacing ?? 0,
|
|
7588
|
+
textAppearance: titleTextAppearance,
|
|
7589
|
+
color: titleColor,
|
|
7590
|
+
}, isEditor)),
|
|
7591
|
+
...getGridTextLeadingVars(titleFontSize, titleLineHeight, P, isEditor),
|
|
7592
|
+
} as React.CSSProperties), [
|
|
7593
|
+
titleFontFamily, titleFontSettings, titleFontSize, titleLineHeight, titleLetterSpacing,
|
|
7594
|
+
titleWordSpacing, titleTextAppearance, titleColor, isEditor, P,
|
|
7595
|
+
]);
|
|
7466
7596
|
|
|
7467
|
-
const
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7597
|
+
const subtitleTextStyle = useMemo(() => ({
|
|
7598
|
+
...omitTextColors(textStylesToCss({
|
|
7599
|
+
fontSettings: {
|
|
7600
|
+
fontFamily: subtitleFontFamily,
|
|
7601
|
+
fontWeight: subtitleFontSettings?.fontWeight ?? 400,
|
|
7602
|
+
fontStyle: subtitleFontSettings?.fontStyle ?? 'normal',
|
|
7603
|
+
},
|
|
7604
|
+
fontSize: subtitleFontSize ?? 0.01,
|
|
7605
|
+
lineHeight: subtitleLineHeight,
|
|
7606
|
+
letterSpacing: subtitleLetterSpacing ?? 0,
|
|
7607
|
+
wordSpacing: subtitleWordSpacing ?? 0,
|
|
7608
|
+
textAppearance: subtitleTextAppearance,
|
|
7609
|
+
color: subtitleColor,
|
|
7610
|
+
}, isEditor)),
|
|
7611
|
+
...getGridTextLeadingVars(subtitleFontSize, subtitleLineHeight, P, isEditor),
|
|
7612
|
+
} as React.CSSProperties), [
|
|
7613
|
+
subtitleFontFamily, subtitleFontSettings, subtitleFontSize, subtitleLineHeight, subtitleLetterSpacing,
|
|
7614
|
+
subtitleWordSpacing, subtitleTextAppearance, subtitleColor, isEditor, P,
|
|
7615
|
+
]);
|
|
7484
7616
|
|
|
7485
|
-
const
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
const lightboxCounterFieldCss = {
|
|
7500
|
-
...lightboxCounterTypographyCss,
|
|
7617
|
+
const lightboxCounterFieldCss = useMemo(() => ({
|
|
7618
|
+
...omitTextColors(textStylesToCss({
|
|
7619
|
+
fontSettings: {
|
|
7620
|
+
fontFamily: lightboxCounterFontFamily,
|
|
7621
|
+
fontWeight: lightboxCounterFontSettings?.fontWeight ?? 400,
|
|
7622
|
+
fontStyle: lightboxCounterFontSettings?.fontStyle ?? 'normal',
|
|
7623
|
+
},
|
|
7624
|
+
fontSize: lightboxCounterFontSize ?? 0.01,
|
|
7625
|
+
lineHeight: lightboxCounterLineHeight,
|
|
7626
|
+
letterSpacing: lightboxCounterLetterSpacing ?? 0,
|
|
7627
|
+
wordSpacing: lightboxCounterWordSpacing ?? 0,
|
|
7628
|
+
textAppearance: lightboxCounterTextAppearance,
|
|
7629
|
+
color: lightboxCounterColor,
|
|
7630
|
+
}, isEditor)),
|
|
7501
7631
|
...getGridTextLeadingVars(lightboxCounterFontSize, lightboxCounterLineHeight, P, isEditor),
|
|
7502
|
-
} as React.CSSProperties
|
|
7632
|
+
} as React.CSSProperties), [
|
|
7633
|
+
lightboxCounterFontFamily, lightboxCounterFontSettings, lightboxCounterFontSize, lightboxCounterLineHeight,
|
|
7634
|
+
lightboxCounterLetterSpacing, lightboxCounterWordSpacing, lightboxCounterTextAppearance, lightboxCounterColor,
|
|
7635
|
+
isEditor, P,
|
|
7636
|
+
]);
|
|
7503
7637
|
|
|
7504
7638
|
const titleTextClassName = getGridTextClassName(
|
|
7505
7639
|
titleFontSize,
|
|
@@ -7513,8 +7647,6 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7513
7647
|
\`\${P}-item-subtitle\`,
|
|
7514
7648
|
\`\${P}-text-tight-leading\`,
|
|
7515
7649
|
);
|
|
7516
|
-
const titleTextLeadingVars = getGridTextLeadingVars(titleFontSize, titleLineHeight, P, isEditor);
|
|
7517
|
-
const subtitleTextLeadingVars = getGridTextLeadingVars(subtitleFontSize, subtitleLineHeight, P, isEditor);
|
|
7518
7650
|
const lightboxCounterClassName = getGridTextClassName(
|
|
7519
7651
|
lightboxCounterFontSize,
|
|
7520
7652
|
lightboxCounterLineHeight,
|
|
@@ -7522,33 +7654,38 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7522
7654
|
\`\${P}-text-tight-leading\`,
|
|
7523
7655
|
);
|
|
7524
7656
|
|
|
7525
|
-
const colorVars = buildColorVars(P, {
|
|
7657
|
+
const colorVars = useMemo(() => buildColorVars(P, {
|
|
7526
7658
|
titleColor,
|
|
7527
7659
|
subtitleColor,
|
|
7528
7660
|
lightboxCounterColor,
|
|
7529
|
-
}, COLOR_VAR_MAP, STATE_KEYS);
|
|
7661
|
+
}, COLOR_VAR_MAP, STATE_KEYS), [P, titleColor, subtitleColor, lightboxCounterColor]);
|
|
7530
7662
|
|
|
7531
7663
|
const stateClass = activeEvent && activeEvent !== 'default' ? \`\${P}-state-\${activeEvent}\` : '';
|
|
7532
7664
|
const showTextOnHover = showText === 'on hover' && (!isEditor || isPreviewMode);
|
|
7533
7665
|
const hoverEffectClass = hover !== 'none' && (!isEditor || isPreviewMode) ? \` \${P}-hover-\${hover}\` : '';
|
|
7534
7666
|
const wrapperStateClasses = \`\${stateClass}\${showTextOnHover ? \` \${P}-show-text-hover\` : ''}\${hoverEffectClass}\`.trim();
|
|
7535
7667
|
|
|
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
7668
|
const customLayout = customGrid && Array.isArray(customGrid.blocks) && customGrid.blocks.length > 0 ? customGrid : undefined;
|
|
7540
7669
|
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
7670
|
const isTextOutside = !!customLayout && textGrowth === 'outside';
|
|
7544
7671
|
const itemInnerRefs = useRef<(HTMLDivElement | null)[]>([]);
|
|
7545
|
-
const [
|
|
7672
|
+
const [customEntryHeights, setCustomEntryHeights] = useState<number[]>([]);
|
|
7546
7673
|
|
|
7547
|
-
const cropContent = (content ?? []).slice(0, resEntriesCount);
|
|
7674
|
+
const cropContent = useMemo<any[]>(() => (content ?? []).slice(0, resEntriesCount), [content, resEntriesCount]);
|
|
7548
7675
|
const lightboxMediaToPreload = useMemo(
|
|
7549
7676
|
() => (lightbox === 'on' ? collectGridLightboxMedia(cropContent) : []),
|
|
7550
7677
|
[cropContent, lightbox],
|
|
7551
7678
|
);
|
|
7679
|
+
const entriesMedia = useMemo(() => cropContent.map((item: any) => {
|
|
7680
|
+
const displayItems = getGridDisplayItems(item.gallery);
|
|
7681
|
+
const lightboxItemsForEntry = displayItems
|
|
7682
|
+
.filter(entry => entry.lightboxMedia)
|
|
7683
|
+
.map(entry => entry.lightboxMedia!);
|
|
7684
|
+
const lightboxIndexes = displayItems.map(({ lightboxMedia }) => (lightboxMedia
|
|
7685
|
+
? lightboxItemsForEntry.findIndex(media => media.assetId === lightboxMedia.assetId)
|
|
7686
|
+
: -1));
|
|
7687
|
+
return { displayItems, lightboxItemsForEntry, lightboxIndexes };
|
|
7688
|
+
}), [cropContent]);
|
|
7552
7689
|
|
|
7553
7690
|
const size = gridLayout?.entryWidth ?? 0.2;
|
|
7554
7691
|
|
|
@@ -7563,7 +7700,6 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7563
7700
|
|
|
7564
7701
|
const columnsCount = gridLayout?.columnsCount ?? 1;
|
|
7565
7702
|
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
7703
|
const isFitSlider = !customLayout && !isCover && slider !== 'off';
|
|
7568
7704
|
|
|
7569
7705
|
const itemsInLastRow = cropContent.length % columnsCount || columnsCount;
|
|
@@ -7577,8 +7713,6 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7577
7713
|
|
|
7578
7714
|
const getImageWrapperStyle = (entryWidth: string, slot?: CustomGridSlot): React.CSSProperties => ({
|
|
7579
7715
|
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
7716
|
...(slot
|
|
7583
7717
|
? isTextOutside
|
|
7584
7718
|
? { height: scalingValue(slot.height, isEditor), flexShrink: 0, overflow: 'hidden' }
|
|
@@ -7615,23 +7749,20 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7615
7749
|
...imageRadiusStyle,
|
|
7616
7750
|
};
|
|
7617
7751
|
|
|
7618
|
-
|
|
7619
|
-
// layout units, the layout's whole width taken as the wrapper's
|
|
7752
|
+
const shouldMeasureEntries = (customLayout?.beat ?? 0) > 0;
|
|
7620
7753
|
const customGridWidth = customLayout ? getCustomGridSpanWidth(customLayout, customLayout.columnsCount) : 0;
|
|
7621
7754
|
useLayoutEffect(() => {
|
|
7622
|
-
if (!
|
|
7623
|
-
|
|
7755
|
+
if (!shouldMeasureEntries) {
|
|
7756
|
+
setCustomEntryHeights(prev => (prev.length > 0 ? [] : prev));
|
|
7624
7757
|
return;
|
|
7625
7758
|
}
|
|
7626
7759
|
const wrapper = containerRef.current;
|
|
7627
7760
|
const inners = itemInnerRefs.current.slice(0, cropContent.length);
|
|
7628
7761
|
const measure = () => {
|
|
7629
7762
|
const unit = wrapper && customGridWidth > 0 ? wrapper.offsetWidth / customGridWidth : 0;
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
});
|
|
7634
|
-
setCustomTextHeights(prev => (
|
|
7763
|
+
if (unit <= 0) return;
|
|
7764
|
+
const heights = inners.map(inner => (inner ? inner.offsetHeight / unit : 0));
|
|
7765
|
+
setCustomEntryHeights(prev => (
|
|
7635
7766
|
prev.length === heights.length && prev.every((height, index) => Math.abs(height - heights[index]) < 1e-5)
|
|
7636
7767
|
? prev
|
|
7637
7768
|
: heights
|
|
@@ -7642,24 +7773,29 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7642
7773
|
if (wrapper) ro.observe(wrapper);
|
|
7643
7774
|
inners.forEach(inner => inner && ro.observe(inner));
|
|
7644
7775
|
return () => ro.disconnect();
|
|
7645
|
-
}, [
|
|
7646
|
-
const
|
|
7647
|
-
?
|
|
7776
|
+
}, [shouldMeasureEntries, cropContent.length, customGridWidth, P]);
|
|
7777
|
+
const measuredEntryHeights = shouldMeasureEntries && customEntryHeights.length === cropContent.length
|
|
7778
|
+
? customEntryHeights
|
|
7648
7779
|
: undefined;
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7780
|
+
const customRows = useMemo(() => {
|
|
7781
|
+
if (!customLayout) return undefined;
|
|
7782
|
+
const rows = getCustomGridRows(customLayout, cropContent.length, measuredEntryHeights);
|
|
7783
|
+
return {
|
|
7784
|
+
gridRows: rows.gridRows,
|
|
7785
|
+
gridTemplateRows: rows.tracks.length
|
|
7786
|
+
? rows.tracks.map(track => (track === 'auto' ? 'auto' : scalingValue(track, isEditor))).join(' ')
|
|
7787
|
+
: 'auto',
|
|
7788
|
+
};
|
|
7789
|
+
}, [customLayout, cropContent.length, measuredEntryHeights, isEditor]);
|
|
7790
|
+
const customSlots = useMemo(
|
|
7791
|
+
() => (customLayout ? cropContent.map((_, index) => getCustomGridSlot(customLayout, index)) : undefined),
|
|
7792
|
+
[customLayout, cropContent.length],
|
|
7793
|
+
);
|
|
7652
7794
|
const wrapperLayoutStyle: React.CSSProperties = customLayout
|
|
7653
7795
|
? {
|
|
7654
7796
|
gridTemplateColumns: \`repeat(\${customLayout.columnsCount}, \${scalingValue(customLayout.columnWidth, isEditor)})\`,
|
|
7655
|
-
|
|
7656
|
-
|
|
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),
|
|
7797
|
+
gridTemplateRows: customRows?.gridTemplateRows ?? 'auto',
|
|
7798
|
+
rowGap: 0,
|
|
7663
7799
|
columnGap: scalingValue(customLayout.gutterWidth, isEditor),
|
|
7664
7800
|
width: scalingValue(getCustomGridSpanWidth(customLayout, customLayout.columnsCount), isEditor),
|
|
7665
7801
|
}
|
|
@@ -7673,28 +7809,9 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7673
7809
|
: {}),
|
|
7674
7810
|
};
|
|
7675
7811
|
|
|
7676
|
-
const [containerWidth, setContainerWidth] = useState(0);
|
|
7677
7812
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
7678
7813
|
|
|
7679
|
-
const
|
|
7680
|
-
? 'ltr'
|
|
7681
|
-
: direction === 'horizontal'
|
|
7682
|
-
? 'ltr'
|
|
7683
|
-
: direction === 'vertical'
|
|
7684
|
-
? 'ttb'
|
|
7685
|
-
: 'ltr';
|
|
7686
|
-
|
|
7687
|
-
useEffect(() => {
|
|
7688
|
-
const el = containerRef.current;
|
|
7689
|
-
if (!el) return;
|
|
7690
|
-
const ro = new ResizeObserver((entries) => {
|
|
7691
|
-
setContainerWidth(Math.round(entries[0].contentRect.width));
|
|
7692
|
-
});
|
|
7693
|
-
ro.observe(el);
|
|
7694
|
-
return () => ro.disconnect();
|
|
7695
|
-
}, []);
|
|
7696
|
-
|
|
7697
|
-
const lightboxPortalStyle = (() => {
|
|
7814
|
+
const getLightboxPortalStyle = (): React.CSSProperties => {
|
|
7698
7815
|
const style: Record<string, string> = { ...(colorVars as Record<string, string>) };
|
|
7699
7816
|
const articleWidth = containerRef.current
|
|
7700
7817
|
? getComputedStyle(containerRef.current).getPropertyValue('--cntrl-article-width').trim()
|
|
@@ -7703,7 +7820,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7703
7820
|
style['--cntrl-article-width'] = articleWidth;
|
|
7704
7821
|
}
|
|
7705
7822
|
return style as React.CSSProperties;
|
|
7706
|
-
}
|
|
7823
|
+
};
|
|
7707
7824
|
|
|
7708
7825
|
const [lightboxOpen, setLightboxOpen] = useState(false);
|
|
7709
7826
|
const [lightboxItems, setLightboxItems] = useState<GridMedia[]>([]);
|
|
@@ -7753,7 +7870,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7753
7870
|
const gridColumn = isPartialLastRow && index >= lastRowStartIndex
|
|
7754
7871
|
? \`\${lastRowStartColumn + (index - lastRowStartIndex)}\`
|
|
7755
7872
|
: undefined;
|
|
7756
|
-
const customSlot =
|
|
7873
|
+
const customSlot = customSlots?.[index];
|
|
7757
7874
|
const itemSize = customSlot?.width ?? size;
|
|
7758
7875
|
const itemWidthScaled = scalingValue(itemSize, isEditor);
|
|
7759
7876
|
const textBoxWidthStyle = \`calc(\${itemWidthScaled} * (\${textBoxWidth} / 100))\`;
|
|
@@ -7762,16 +7879,15 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7762
7879
|
const itemStyle: React.CSSProperties | undefined = customSlot
|
|
7763
7880
|
? {
|
|
7764
7881
|
gridColumn: customSlot.gridColumn,
|
|
7765
|
-
gridRow:
|
|
7882
|
+
gridRow: customRows?.gridRows[index],
|
|
7766
7883
|
alignSelf: 'start',
|
|
7767
|
-
marginTop: scalingValue(customOutsideText?.tops[index] ?? customSlot.top, isEditor),
|
|
7768
7884
|
}
|
|
7769
7885
|
: gridColumn && !shouldAlignEntries ? { gridColumn } : undefined;
|
|
7770
7886
|
|
|
7771
7887
|
const typeCTextBlock = isTextBeforeImage ? (
|
|
7772
7888
|
<div className={\`\${P}-item-text-block\`}>
|
|
7773
7889
|
{hasTitle && (
|
|
7774
|
-
<p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...
|
|
7890
|
+
<p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleTextStyle }}>
|
|
7775
7891
|
{item.title}
|
|
7776
7892
|
</p>
|
|
7777
7893
|
)}
|
|
@@ -7786,7 +7902,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7786
7902
|
/>
|
|
7787
7903
|
)}
|
|
7788
7904
|
{hasSubtitle && (
|
|
7789
|
-
<p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...
|
|
7905
|
+
<p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleTextStyle }}>
|
|
7790
7906
|
{item.subtitle}
|
|
7791
7907
|
</p>
|
|
7792
7908
|
)}
|
|
@@ -7816,7 +7932,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7816
7932
|
/>
|
|
7817
7933
|
)}
|
|
7818
7934
|
{hasTitle && (
|
|
7819
|
-
<p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...
|
|
7935
|
+
<p className={titleTextClassName} style={{ width: textBoxWidthStyle, ...titleTextStyle }}>
|
|
7820
7936
|
{item.title}
|
|
7821
7937
|
</p>
|
|
7822
7938
|
)}
|
|
@@ -7846,7 +7962,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7846
7962
|
/>
|
|
7847
7963
|
)}
|
|
7848
7964
|
{hasSubtitle && (
|
|
7849
|
-
<p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...
|
|
7965
|
+
<p className={subtitleTextClassName} style={{ width: textBoxWidthStyle, ...subtitleTextStyle }}>
|
|
7850
7966
|
{item.subtitle}
|
|
7851
7967
|
</p>
|
|
7852
7968
|
)}
|
|
@@ -7870,10 +7986,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7870
7986
|
</LinkWrapper>
|
|
7871
7987
|
);
|
|
7872
7988
|
|
|
7873
|
-
const displayItems =
|
|
7874
|
-
const lightboxItemsForEntry = displayItems
|
|
7875
|
-
.filter(entry => entry.lightboxMedia)
|
|
7876
|
-
.map(entry => entry.lightboxMedia!);
|
|
7989
|
+
const { displayItems, lightboxItemsForEntry, lightboxIndexes } = entriesMedia[index];
|
|
7877
7990
|
|
|
7878
7991
|
const imageContent = (
|
|
7879
7992
|
<GridItemMediaWrapper className={imageWrapperClassName} style={imageWrapperStyle}>
|
|
@@ -7882,10 +7995,8 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7882
7995
|
: slider === 'off'
|
|
7883
7996
|
?
|
|
7884
7997
|
(() => {
|
|
7885
|
-
const { displayMedia
|
|
7886
|
-
const lightboxIndex =
|
|
7887
|
-
? lightboxItemsForEntry.findIndex(item => item.assetId === lightboxMedia.assetId)
|
|
7888
|
-
: -1;
|
|
7998
|
+
const { displayMedia } = displayItems[0];
|
|
7999
|
+
const lightboxIndex = lightboxIndexes[0];
|
|
7889
8000
|
return (
|
|
7890
8001
|
<GridMediaItem
|
|
7891
8002
|
media={displayMedia}
|
|
@@ -7913,50 +8024,28 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7913
8024
|
))}
|
|
7914
8025
|
</div>
|
|
7915
8026
|
)}
|
|
7916
|
-
<
|
|
7917
|
-
key={\`\${transition}-\${itemSize}-\${direction}-\${sliderTiming}-\${
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
autoplay: true,
|
|
7925
|
-
interval: sliderTiming * 1000,
|
|
7926
|
-
width: '100%',
|
|
7927
|
-
height: '100%',
|
|
7928
|
-
speed: SLIDER_TRANSITION_MS,
|
|
7929
|
-
type: transition === 'fade' ? 'fade' : 'loop',
|
|
7930
|
-
rewind: transition === 'fade',
|
|
7931
|
-
pauseOnHover: false,
|
|
7932
|
-
pauseOnFocus: false,
|
|
7933
|
-
direction: resolvedSplideDirection,
|
|
7934
|
-
}}
|
|
7935
|
-
onMoved={(splide) => {
|
|
7936
|
-
if (direction !== 'random' || transition === 'fade') return;
|
|
7937
|
-
handleRandomSlideMoved(splide);
|
|
7938
|
-
}}
|
|
7939
|
-
>
|
|
7940
|
-
{displayItems.map(({ displayMedia, lightboxMedia }, imgIndex) => {
|
|
7941
|
-
const lightboxIndex = lightboxMedia
|
|
7942
|
-
? lightboxItemsForEntry.findIndex(item => item.assetId === lightboxMedia.assetId)
|
|
7943
|
-
: -1;
|
|
8027
|
+
<GridEntrySlider
|
|
8028
|
+
key={\`\${transition}-\${itemSize}-\${direction}-\${sliderTiming}-\${layoutId}-\${displayItems.length}\`}
|
|
8029
|
+
prefix={P}
|
|
8030
|
+
isFade={transition === 'fade'}
|
|
8031
|
+
direction={direction}
|
|
8032
|
+
intervalMs={sliderTiming * 1000}
|
|
8033
|
+
slides={displayItems.map(({ displayMedia }, imgIndex) => {
|
|
8034
|
+
const lightboxIndex = lightboxIndexes[imgIndex];
|
|
7944
8035
|
return (
|
|
7945
|
-
<
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
/>
|
|
7956
|
-
</SplideSlide>
|
|
8036
|
+
<GridMediaItem
|
|
8037
|
+
media={displayMedia}
|
|
8038
|
+
className={\`\${P}-item-\${isVideoMedia(displayMedia) ? 'video' : 'image'}\`.trim()}
|
|
8039
|
+
style={imageStyle}
|
|
8040
|
+
hasLightbox={lightbox === 'on'}
|
|
8041
|
+
isSliderSlide
|
|
8042
|
+
onMediaClick={canOpenLightboxMedia && lightboxIndex >= 0
|
|
8043
|
+
? () => openLightbox(lightboxItemsForEntry, lightboxIndex)
|
|
8044
|
+
: undefined}
|
|
8045
|
+
/>
|
|
7957
8046
|
);
|
|
7958
8047
|
})}
|
|
7959
|
-
|
|
8048
|
+
/>
|
|
7960
8049
|
</>
|
|
7961
8050
|
}
|
|
7962
8051
|
</GridItemMediaWrapper>
|
|
@@ -7974,7 +8063,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7974
8063
|
/>
|
|
7975
8064
|
<p
|
|
7976
8065
|
className={titleTextClassName}
|
|
7977
|
-
style={{ width: textBoxWidthStyle, ...
|
|
8066
|
+
style={{ width: textBoxWidthStyle, ...titleTextStyle }}
|
|
7978
8067
|
>
|
|
7979
8068
|
{item.title}
|
|
7980
8069
|
</p>
|
|
@@ -7988,7 +8077,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
7988
8077
|
/>
|
|
7989
8078
|
<p
|
|
7990
8079
|
className={subtitleTextClassName}
|
|
7991
|
-
style={{ width: textBoxWidthStyle, ...
|
|
8080
|
+
style={{ width: textBoxWidthStyle, ...subtitleTextStyle }}
|
|
7992
8081
|
>
|
|
7993
8082
|
{item.subtitle}
|
|
7994
8083
|
</p>
|
|
@@ -8065,7 +8154,7 @@ export function Grid({ settings, content, isEditor, isPreviewMode, isEditMode, m
|
|
|
8065
8154
|
{(!isEditor || isPreviewMode) && lightboxOpen && typeof document !== 'undefined' && lightbox === 'on' && (() => {
|
|
8066
8155
|
const portalTarget = (portalId ? document.getElementById(portalId) : null) ?? document.body;
|
|
8067
8156
|
return createPortal(
|
|
8068
|
-
<div style={
|
|
8157
|
+
<div style={getLightboxPortalStyle()} data-selection="none">
|
|
8069
8158
|
<Lightbox
|
|
8070
8159
|
prefix={P}
|
|
8071
8160
|
items={lightboxItems}
|
|
@@ -8103,34 +8192,25 @@ type GridLayoutConfig = {
|
|
|
8103
8192
|
};
|
|
8104
8193
|
|
|
8105
8194
|
type CustomGridBlock = {
|
|
8106
|
-
// first column the block covers, from 0
|
|
8107
8195
|
column: number;
|
|
8108
8196
|
span: number;
|
|
8109
|
-
// offset from the top of its group
|
|
8110
8197
|
top: number;
|
|
8111
|
-
// height of the whole entry: its media fills what the text leaves
|
|
8112
8198
|
height: number;
|
|
8113
8199
|
};
|
|
8114
8200
|
|
|
8115
|
-
// lengths are fractions of the layout width, like the article grid's
|
|
8116
8201
|
type CustomGridLayout = {
|
|
8117
8202
|
columnsCount: number;
|
|
8118
8203
|
columnWidth: number;
|
|
8119
8204
|
gutterWidth: number;
|
|
8120
8205
|
maxWidth: number | null;
|
|
8121
|
-
// space between one group of blocks and the next
|
|
8122
8206
|
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
8207
|
beat?: number;
|
|
8126
|
-
// layouts saved before the vertical gap kept the height of a whole group instead
|
|
8127
8208
|
repeatHeight?: number;
|
|
8128
8209
|
blocks: CustomGridBlock[];
|
|
8129
8210
|
};
|
|
8130
8211
|
|
|
8131
8212
|
type GridSettings = {
|
|
8132
8213
|
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
8214
|
gridLayout?: GridLayoutConfig;
|
|
8135
8215
|
customGrid?: CustomGridLayout;
|
|
8136
8216
|
textBoxWidth: number;
|
|
@@ -8152,7 +8232,6 @@ type GridSettings = {
|
|
|
8152
8232
|
hover?: 'none' | 'zoom-in' | 'greyscale' | 'scale-down';
|
|
8153
8233
|
alignEntries?: 'on' | 'off';
|
|
8154
8234
|
align?: 'top' | 'center' | 'bottom';
|
|
8155
|
-
// with a custom layout: whether a block holds the entry's text or only its media
|
|
8156
8235
|
textGrowth?: 'inside' | 'outside';
|
|
8157
8236
|
titleMarginTop: number;
|
|
8158
8237
|
subtitleMarginTop: number;
|
|
@@ -20579,7 +20658,7 @@ const COLOR_VAR_MAP: Record<OnelinerColorKeys, string> = {
|
|
|
20579
20658
|
};
|
|
20580
20659
|
|
|
20581
20660
|
const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
|
|
20582
|
-
`,
|
|
20661
|
+
`, F = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
20583
20662
|
import type React from 'react';
|
|
20584
20663
|
import { CommonComponentProps } from '../props';
|
|
20585
20664
|
import { scalingValue, useScopedStyles } from '../utils/index';
|
|
@@ -21418,7 +21497,7 @@ export function Pretext({ settings, content, isEditor, isPreviewMode, isEditMode
|
|
|
21418
21497
|
</>
|
|
21419
21498
|
);
|
|
21420
21499
|
}
|
|
21421
|
-
`,
|
|
21500
|
+
`, W = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
21422
21501
|
import cn from 'classnames';
|
|
21423
21502
|
import { CommonComponentProps } from '../props';
|
|
21424
21503
|
import { useScopedStyles } from '../utils/useScopedStyles';
|
|
@@ -25537,8 +25616,8 @@ export function Waterfall({
|
|
|
25537
25616
|
[d.id]: H,
|
|
25538
25617
|
[c.id]: O,
|
|
25539
25618
|
[l.id]: _,
|
|
25540
|
-
[s.id]:
|
|
25541
|
-
[a.id]:
|
|
25619
|
+
[s.id]: F,
|
|
25620
|
+
[a.id]: W,
|
|
25542
25621
|
[r.id]: D,
|
|
25543
25622
|
[o.id]: B,
|
|
25544
25623
|
[i.id]: z,
|