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