@cntrl-site/components 1.0.120 → 1.0.121

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.
Files changed (30) hide show
  1. package/dist/{Burger-C8JIQQwm.mjs → Burger-BKeZH3HS.mjs} +1 -1
  2. package/dist/{Burger-C_SjPZWp.js → Burger-DxjmS1t5.js} +1 -1
  3. package/dist/{Chronicles-BNvvaFYY.mjs → Chronicles-BXfNFANB.mjs} +1 -1
  4. package/dist/{Chronicles-Dj1gvNjE.js → Chronicles-mir8oCdq.js} +1 -1
  5. package/dist/{ChroniclesComponent-8lhIeord.mjs → ChroniclesComponent-CH-c7QBm.mjs} +18 -35
  6. package/dist/{ChroniclesComponent-5ZbqHNpi.js → ChroniclesComponent-D425pM5e.js} +1 -1
  7. package/dist/Components/Slider20/Slider20.d.ts +1 -2
  8. package/dist/{LightboxJournal-BDUs6T0B.mjs → LightboxJournal-By2sN-Ix.mjs} +1 -1
  9. package/dist/{LightboxJournal-Bf_rZzmz.js → LightboxJournal-DEQXz8wX.js} +1 -1
  10. package/dist/{LightboxStrip-Cuhb2fIR.mjs → LightboxStrip-GwaY8uLD.mjs} +1 -1
  11. package/dist/{LightboxStrip-RA4ABUC-.js → LightboxStrip-XbD9uQKr.js} +1 -1
  12. package/dist/Slider20-BOmjDRf2.js +272 -0
  13. package/dist/Slider20-DUi6qwnd.mjs +851 -0
  14. package/dist/{components-CBJ6asBX.mjs → components-BN4QKcJm.mjs} +1 -1
  15. package/dist/{components-BHB4G3ma.js → components-QZW1MaQM.js} +1 -1
  16. package/dist/elements.js +1 -1
  17. package/dist/elements.mjs +5 -5
  18. package/dist/elements.node.js +1 -1
  19. package/dist/elements.node.mjs +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/index.mjs +2 -2
  22. package/dist/sources.js +168 -213
  23. package/dist/sources.mjs +167 -212
  24. package/dist/useLightboxScrollLock-CjSZPvqJ.mjs +18 -0
  25. package/dist/useLightboxScrollLock-CmwKl-Vu.js +1 -0
  26. package/package.json +1 -1
  27. package/dist/Slider20-C2o_EB1I.mjs +0 -872
  28. package/dist/Slider20-DzxWCTg-.js +0 -273
  29. package/dist/useLightboxScrollLock-Hf16Eq4g.js +0 -1
  30. package/dist/useLightboxScrollLock-VQ07s7EJ.mjs +0 -18
package/dist/sources.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { W as n, b as e, T as t, g as i, f as o, S as r, P as a, O as s, h as l, a as d, M as c, L as u, d as g, e as m, H as p, i as h, G as f, F as v, c as P, C as x, j as b, B as y } from "./ChroniclesComponent-8lhIeord.mjs";
1
+ import { W as n, b as e, T as t, g as i, f as o, S as r, P as a, O as s, h as l, a as c, M as d, L as u, d as g, e as m, H as p, i as h, G as f, F as v, c as P, C as x, j as b, B as y } from "./ChroniclesComponent-CH-c7QBm.mjs";
2
2
  const S = `import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
3
3
  import { CommonComponentProps } from '../props';
4
4
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
@@ -22599,6 +22599,7 @@ type Slider20Item = {
22599
22599
  image: {
22600
22600
  assetId: string;
22601
22601
  name?: string;
22602
+ objectFit?: 'cover' | 'contain';
22602
22603
  };
22603
22604
  imageCaption: any[];
22604
22605
  };
@@ -22620,7 +22621,6 @@ type Slider20Settings = {
22620
22621
  trigger?: Slider20Trigger;
22621
22622
  direction?: Slider20Direction;
22622
22623
  transition?: Slider20Transition;
22623
- transitionSpeed?: number;
22624
22624
  nav?: Slider20Nav;
22625
22625
  navSize?: Slider20NavSize;
22626
22626
  navUnit?: number;
@@ -22651,7 +22651,6 @@ type Slider20Settings = {
22651
22651
  fontVariant?: 'normal' | 'small-caps';
22652
22652
  };
22653
22653
  captionMarginTop?: number;
22654
- imageCorners?: number;
22655
22654
  };
22656
22655
 
22657
22656
  type Slider20Props = {
@@ -22663,7 +22662,6 @@ type Slider20Props = {
22663
22662
  } & CommonComponentProps;
22664
22663
 
22665
22664
  type Offset = { x: number; y: number };
22666
- type TransitionLayer = { index: number; key: number; isAnimated: boolean };
22667
22665
  type Point = { x: number; y: number };
22668
22666
  type LocalAxes = { ex: Point; ey: Point; det: number };
22669
22667
 
@@ -22681,11 +22679,9 @@ type DragState = {
22681
22679
  };
22682
22680
 
22683
22681
  const TRANSITION_DURATION_MS = 500;
22684
- const DEFAULT_TRANSITION_SPEED = 1;
22685
22682
  const TRANSITION_EASING = 'cubic-bezier(0.25, 1, 0.5, 1)';
22686
22683
  const TRANSITION_BACKGROUND_COLOR: string | null = null;
22687
22684
  const DOT_ANIMATION_MS = 300;
22688
- const MAX_TRANSITION_LAYERS = 40;
22689
22685
  const DRAG_START_THRESHOLD_PX = 5;
22690
22686
  const DRAG_DISTANCE_RATIO = 0.15;
22691
22687
  const DRAG_FLICK_VELOCITY = 0.4;
@@ -22787,24 +22783,23 @@ function wrapIndex(index: number, count: number): number {
22787
22783
  return ((index % count) + count) % count;
22788
22784
  }
22789
22785
 
22790
- // Slide mode renders the items three times; shifting the track by one copy is invisible.
22791
- const TRACK_COPIES = 3;
22792
-
22793
- function getTrackTranslate(position: number, offsetPx: number, isHorizontal: boolean): string {
22794
- return isHorizontal
22795
- ? \`translate3d(calc(\${-position * 100}% + \${offsetPx}px), 0, 0)\`
22796
- : \`translate3d(0, calc(\${-position * 100}% + \${offsetPx}px), 0)\`;
22797
- }
22798
-
22799
- // Shift (a multiple of count) that moves a position into the middle copy.
22800
- function getMiddleCopyShift(position: number, count: number): number {
22801
- return (Math.floor(position / count) - 1) * count;
22802
- }
22803
-
22804
- // Untransformed, unrounded size of one slide (offsetWidth rounds, the canvas zoom scales rects).
22805
- function readSlideSizePx(element: HTMLElement, isHorizontal: boolean): number {
22806
- const style = window.getComputedStyle(element);
22807
- return parseFloat(isHorizontal ? style.width : style.height) || 0;
22786
+ function advanceTrackPosition(
22787
+ prev: number,
22788
+ step: 1 | -1,
22789
+ count: number,
22790
+ hasClones: boolean,
22791
+ ): { position: number; hitBoundary: boolean } {
22792
+ if (!hasClones) {
22793
+ return { position: wrapIndex(prev + step, count), hitBoundary: false };
22794
+ }
22795
+ const next = prev + step;
22796
+ if (next >= 0 && next <= count + 1) {
22797
+ return { position: next, hitBoundary: false };
22798
+ }
22799
+ return {
22800
+ position: step > 0 ? count + 1 : 0,
22801
+ hitBoundary: true,
22802
+ };
22808
22803
  }
22809
22804
 
22810
22805
  function readTrackTranslatePx(element: HTMLElement, isHorizontal: boolean): number {
@@ -22846,13 +22841,7 @@ function toLocalDelta(axes: LocalAxes, dx: number, dy: number): Point {
22846
22841
  };
22847
22842
  }
22848
22843
 
22849
- // Speed 0..2 maps to 2000ms..125ms on a log scale; speed 1 keeps the base 500ms.
22850
- function getTransitionDurationMs(speed: number): number {
22851
- const clamped = Math.min(Math.max(speed, 0), 2);
22852
- return Math.round(TRANSITION_DURATION_MS * Math.pow(4, 1 - clamped));
22853
- }
22854
-
22855
- function getCSS(P: string, transitionDurationMs: number, isEditor?: boolean): string {
22844
+ function getCSS(P: string, isEditor?: boolean): string {
22856
22845
  return \`
22857
22846
  .\${P}-wrapper {
22858
22847
  position: relative;
@@ -22913,8 +22902,6 @@ function getCSS(P: string, transitionDurationMs: number, isEditor?: boolean): st
22913
22902
  }
22914
22903
  .\${P}-list-fade {
22915
22904
  display: block;
22916
- /* Keeps the transition layers' z-index below the arrows, dots and click overlay. */
22917
- isolation: isolate;
22918
22905
  }
22919
22906
  .\${P}-slide {
22920
22907
  position: relative;
@@ -22927,9 +22914,11 @@ function getCSS(P: string, transitionDurationMs: number, isEditor?: boolean): st
22927
22914
  top: 0;
22928
22915
  left: 0;
22929
22916
  opacity: 0;
22917
+ transition: opacity \${TRANSITION_DURATION_MS}ms \${TRANSITION_EASING};
22930
22918
  }
22931
- .\${P}-list-fade .\${P}-slide.\${P}-is-layer {
22919
+ .\${P}-list-fade .\${P}-slide.\${P}-is-active {
22932
22920
  opacity: 1;
22921
+ z-index: 1;
22933
22922
  }
22934
22923
  .\${P}-slider-item {
22935
22924
  width: 100%;
@@ -23104,18 +23093,17 @@ function getCSS(P: string, transitionDurationMs: number, isEditor?: boolean): st
23104
23093
  cursor: pointer;
23105
23094
  z-index: 2;
23106
23095
  }
23107
- .\${P}-transition-fade .\${P}-slide.\${P}-is-animated .\${P}-slider-image {
23108
- animation: \${P}-fade-in \${transitionDurationMs}ms \${TRANSITION_EASING};
23096
+ .\${P}-contain {
23097
+ object-fit: contain;
23109
23098
  }
23110
- .\${P}-transition-reveal .\${P}-slide.\${P}-is-animated .\${P}-slider-image {
23111
- animation: \${P}-reveal-horizontal \${transitionDurationMs}ms ease;
23099
+ .\${P}-cover {
23100
+ object-fit: cover;
23112
23101
  }
23113
- .\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-animated .\${P}-slider-image {
23114
- animation: \${P}-reveal-vertical \${transitionDurationMs}ms ease;
23102
+ .\${P}-transition-reveal .\${P}-slide.\${P}-is-active .\${P}-slider-image {
23103
+ animation: \${P}-reveal-horizontal \${TRANSITION_DURATION_MS}ms ease;
23115
23104
  }
23116
- @keyframes \${P}-fade-in {
23117
- from { opacity: 0; }
23118
- to { opacity: 1; }
23105
+ .\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-active .\${P}-slider-image {
23106
+ animation: \${P}-reveal-vertical \${TRANSITION_DURATION_MS}ms ease;
23119
23107
  }
23120
23108
  @keyframes \${P}-reveal-horizontal {
23121
23109
  from { clip-path: inset(0 100% 0 0); }
@@ -23138,8 +23126,6 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23138
23126
  const autoPlayIntervalS = trigger.value ?? DEFAULT_TRIGGER.value;
23139
23127
  const direction: Slider20Direction = settings?.direction ?? 'horizontal';
23140
23128
  const transition: Slider20Transition = settings?.transition ?? 'slide';
23141
- const transitionSpeed = typeof settings?.transitionSpeed === 'number' ? settings.transitionSpeed : DEFAULT_TRANSITION_SPEED;
23142
- const transitionDurationMs = getTransitionDurationMs(transitionSpeed);
23143
23129
  const nav: Slider20Nav = settings?.nav ?? 'classic';
23144
23130
  const navSize: Slider20NavSize = settings?.navSize ?? 'm';
23145
23131
  const navSizeValues = NAV_SIZES[navSize];
@@ -23157,21 +23143,12 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23157
23143
  const navBackgroundColor = settings?.navBackgroundColor ?? PAGINATION.colors.background;
23158
23144
  const linkColor = settings?.linkColor ?? IMAGE_CAPTION.linkColor;
23159
23145
  const captionMarginTop = typeof settings?.captionMarginTop === 'number' ? settings.captionMarginTop : 0;
23160
- const imageCorners = typeof settings?.imageCorners === 'number' ? settings.imageCorners : 0;
23161
- // Rounding the track (not each image) keeps the corners steady while slides move under it.
23162
- // isolation makes Safari clip the transformed list to the radius.
23163
- const trackRadiusStyle: React.CSSProperties | undefined = imageCorners > 0
23164
- ? { borderRadius: scalingValue(imageCorners, isEditor), isolation: 'isolate' }
23165
- : undefined;
23166
23146
  const isHorizontal = direction === 'horizontal';
23167
23147
  const isClickTrigger = triggerType === 'click';
23168
23148
  const isDragTrigger = triggerType === 'drag';
23169
23149
  const isAutoPlaying = triggerType === 'auto' && (!isEditor || Boolean(isPreviewMode));
23170
23150
  const pauseAutoOnHover = !isEditor;
23171
23151
  const isSlideTransition = transition === 'slide';
23172
- const isReveal = transition === 'reveal';
23173
- // Fade and reveal draw each new slide as a layer over the previous ones.
23174
- const isLayered = !isSlideTransition;
23175
23152
  const showClassicNav = nav === 'classic';
23176
23153
  const showControls = controlsShow !== 'never' && controlsMaxWidth > 0;
23177
23154
  const isControlsOnHover = controlsShow === 'on hover';
@@ -23184,39 +23161,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23184
23161
 
23185
23162
  const hasClones = isSlideTransition && count > 1;
23186
23163
  const [activeIndex, setActiveIndex] = useState(0);
23187
- // Layers stack bottom to top: each new slide fades or reveals over the ones still animating,
23188
- // which keep their own animation. The same slide can sit in the stack more than once.
23189
- // The first slide is shown as is on load, without a transition.
23190
- const [transitionLayers, setTransitionLayers] = useState<TransitionLayer[]>([
23191
- { index: activeIndex, key: 0, isAnimated: false },
23192
- ]);
23193
- const topLayer = transitionLayers[transitionLayers.length - 1];
23194
- if (isLayered && topLayer.index !== activeIndex) {
23195
- // Over the limit, drop the oldest layer still animating, never the fully shown bottom one.
23196
- const kept = transitionLayers.length >= MAX_TRANSITION_LAYERS
23197
- ? [transitionLayers[0], ...transitionLayers.slice(2)]
23198
- : transitionLayers;
23199
- setTransitionLayers([...kept, { index: activeIndex, key: topLayer.key + 1, isAnimated: true }]);
23200
- }
23201
- const handleLayerEnd = (key: number) => {
23202
- // A fully shown layer covers everything under it, so those layers are dropped.
23203
- setTransitionLayers((layers) => {
23204
- const position = layers.findIndex((layer) => layer.key === key);
23205
- return position > 0 ? layers.slice(position) : layers;
23206
- });
23207
- };
23208
- const renderSlideItem = (item: Slider20Item | undefined) => item && (
23209
- <div className={\`\${P}-slider-item\`}>
23210
- <div className={\`\${P}-img-wrapper\`}>
23211
- <img
23212
- className={\`\${P}-slider-image\`}
23213
- src={item.image.assetId} alt={item.image.name ?? ''}
23214
- draggable={false}
23215
- />
23216
- </div>
23217
- </div>
23218
- );
23219
- const [trackPosition, setTrackPosition] = useState(hasClones ? count : 0);
23164
+ const [trackPosition, setTrackPosition] = useState(hasClones ? 1 : 0);
23220
23165
  const [isMoving, setIsMoving] = useState(false);
23221
23166
  const [skipTransition, setSkipTransition] = useState(false);
23222
23167
  const [isDragging, setIsDragging] = useState(false);
@@ -23226,100 +23171,73 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23226
23171
  const isMovingRef = useRef(false);
23227
23172
  const trackPositionRef = useRef(trackPosition);
23228
23173
  trackPositionRef.current = trackPosition;
23174
+ const pendingAnimatedPositionRef = useRef<number | null>(null);
23175
+ const pendingStepsRef = useRef(0);
23229
23176
  const trackRef = useRef<HTMLDivElement | null>(null);
23230
23177
  const listRef = useRef<HTMLDivElement | null>(null);
23231
23178
  const dragRef = useRef<DragState | null>(null);
23232
23179
  const activePointerIdRef = useRef<number | null>(null);
23233
23180
 
23234
- const activeIndexRef = useRef(activeIndex);
23235
- activeIndexRef.current = activeIndex;
23236
- const revealTargetRef = useRef(activeIndex);
23237
- const revealTimerRef = useRef<number | null>(null);
23238
-
23239
23181
  const setMoving = useCallback((value: boolean) => {
23240
23182
  isMovingRef.current = value;
23241
23183
  setIsMoving(value);
23242
23184
  }, []);
23243
23185
 
23244
- // Reveal starts a new layer at most every half transition, so quick clicks never run more
23245
- // than two reveals at once, evenly spaced. Clicks in between only move the pending target,
23246
- // which is shown when the next slot opens.
23247
- const changeLayeredIndex = useCallback((getTarget: (current: number) => number) => {
23248
- if (!isReveal) {
23249
- setActiveIndex((prev) => wrapIndex(getTarget(prev), count));
23186
+ const goBySteps = useCallback((steps: number) => {
23187
+ if (count < 2 || steps === 0) return;
23188
+ const direction = steps > 0 ? 1 : -1;
23189
+ const total = Math.abs(steps);
23190
+ setAnimateDots(true);
23191
+ setMoving(true);
23192
+ if (!isSlideTransition) {
23193
+ setActiveIndex((prev) => wrapIndex(prev + steps, count));
23250
23194
  return;
23251
23195
  }
23252
- const isWaiting = revealTimerRef.current !== null;
23253
- const base = isWaiting ? revealTargetRef.current : activeIndexRef.current;
23254
- revealTargetRef.current = wrapIndex(getTarget(base), count);
23255
- if (isWaiting) return;
23256
- const startReveal = (index: number) => {
23257
- activeIndexRef.current = index;
23258
- setActiveIndex(index);
23259
- revealTimerRef.current = window.setTimeout(() => {
23260
- revealTimerRef.current = null;
23261
- if (revealTargetRef.current !== activeIndexRef.current) startReveal(revealTargetRef.current);
23262
- }, transitionDurationMs / 2);
23263
- };
23264
- startReveal(revealTargetRef.current);
23265
- }, [count, isReveal, transitionDurationMs]);
23266
23196
 
23267
- useEffect(() => () => {
23268
- if (revealTimerRef.current !== null) window.clearTimeout(revealTimerRef.current);
23269
- }, []);
23197
+ let position = trackPositionRef.current;
23198
+ const isOnClone = hasClones && (position === 0 || position === count + 1);
23199
+ const cloneSnapPosition = isOnClone ? activeIndex + 1 : null;
23270
23200
 
23271
- // Where the track is on screen right now, mid-transition included, in slide units.
23272
- const readVisualPosition = useCallback((): number => {
23273
- const list = listRef.current;
23274
- const size = list ? readSlideSizePx(list, isHorizontal) : 0;
23275
- if (!list || size <= 0) return trackPositionRef.current;
23276
- // Rounded so a settled track reads as a whole position.
23277
- return Math.round((-readTrackTranslatePx(list, isHorizontal) / size) * 1000) / 1000;
23278
- }, [isHorizontal]);
23279
-
23280
- // Moves the track to \`target\` from wherever it is now. When the visual position is outside
23281
- // the middle copy, it is first teleported by a whole copy (no visible change), so rapid
23282
- // navigation never runs off the rendered slides and never snaps mid-animation.
23283
- const moveTrack = useCallback((getTarget: (visual: number, shift: number) => number) => {
23284
- const visual = readVisualPosition();
23285
- const shift = getMiddleCopyShift(visual, count);
23286
- const target = getTarget(visual - shift, shift);
23287
- const list = listRef.current;
23288
- if (shift !== 0 && list) {
23289
- const transitionValue = list.style.transition;
23290
- list.style.transition = 'none';
23291
- list.style.transform = getTrackTranslate(visual - shift, 0, isHorizontal);
23292
- void list.offsetWidth;
23293
- list.style.transition = transitionValue && transitionValue !== 'none'
23294
- ? transitionValue
23295
- : \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`;
23296
- list.style.transform = getTrackTranslate(target, 0, isHorizontal);
23201
+ if (isOnClone) {
23202
+ position = activeIndex + 1;
23297
23203
  }
23298
- trackPositionRef.current = target;
23299
- setActiveIndex(wrapIndex(target, count));
23300
- setSkipTransition(false);
23301
- setTrackPosition(target);
23302
- }, [count, isHorizontal, readVisualPosition, transitionDurationMs]);
23303
23204
 
23304
- const goBySteps = useCallback((steps: number) => {
23305
- if (count < 2 || steps === 0) return;
23306
- setAnimateDots(true);
23307
- setMoving(true);
23308
- if (!isSlideTransition) {
23309
- changeLayeredIndex((current) => current + steps);
23205
+ let remaining = total;
23206
+ while (remaining > 0) {
23207
+ const result = advanceTrackPosition(position, direction, count, hasClones);
23208
+ position = result.position;
23209
+ remaining -= 1;
23210
+ if (result.hitBoundary) {
23211
+ pendingStepsRef.current = remaining * direction;
23212
+ break;
23213
+ }
23214
+ }
23215
+
23216
+ const appliedSteps = total - remaining;
23217
+ if (appliedSteps > 0) {
23218
+ setActiveIndex((prev) => wrapIndex(prev + appliedSteps * direction, count));
23219
+ }
23220
+
23221
+ trackPositionRef.current = position;
23222
+
23223
+ if (cloneSnapPosition !== null) {
23224
+ trackPositionRef.current = cloneSnapPosition;
23225
+ if (position === cloneSnapPosition) {
23226
+ setSkipTransition(true);
23227
+ setTrackPosition(position);
23228
+ return;
23229
+ }
23230
+ pendingAnimatedPositionRef.current = position;
23231
+ setSkipTransition(true);
23232
+ setTrackPosition(cloneSnapPosition);
23310
23233
  return;
23311
23234
  }
23312
- moveTrack((visual, shift) => {
23313
- // Continue from the previous target so quick clicks add up, but never get more than
23314
- // count - 1 slides away from what is on screen, which keeps the target inside the copies.
23315
- const previousTarget = trackPositionRef.current - shift;
23316
- const base = Math.abs(previousTarget - visual) < count ? previousTarget : Math.round(visual);
23317
- const maxDistance = count - 1;
23318
- return Math.min(Math.max(base + steps, Math.ceil(visual - maxDistance)), Math.floor(visual + maxDistance));
23319
- });
23320
- }, [changeLayeredIndex, count, isSlideTransition, moveTrack, setMoving]);
23321
23235
 
23322
- const goBy =useCallback((step: 1 | -1) => {
23236
+ setSkipTransition(false);
23237
+ setTrackPosition(position);
23238
+ }, [activeIndex, count, hasClones, isSlideTransition, setMoving]);
23239
+
23240
+ const goBy = useCallback((step: 1 | -1) => {
23323
23241
  goBySteps(step);
23324
23242
  }, [goBySteps]);
23325
23243
 
@@ -23329,37 +23247,58 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23329
23247
  if (target === activeIndex && !isMovingRef.current) return;
23330
23248
  setAnimateDots(true);
23331
23249
  setMoving(true);
23332
- if (!isSlideTransition) {
23333
- changeLayeredIndex(() => target);
23334
- return;
23250
+ setActiveIndex(target);
23251
+ if (isSlideTransition) {
23252
+ const position = target + (hasClones ? 1 : 0);
23253
+ pendingAnimatedPositionRef.current = null;
23254
+ pendingStepsRef.current = 0;
23255
+ trackPositionRef.current = position;
23256
+ setSkipTransition(false);
23257
+ setTrackPosition(position);
23335
23258
  }
23336
- moveTrack(() => count + target);
23337
- }, [activeIndex, changeLayeredIndex, count, isSlideTransition, moveTrack, setMoving]);
23259
+ }, [activeIndex, count, hasClones, isSlideTransition, setMoving]);
23338
23260
 
23339
23261
  useEffect(() => {
23340
23262
  if (!isMoving) return;
23341
23263
  const timeoutId = window.setTimeout(() => {
23264
+ if (hasClones && (trackPosition === 0 || trackPosition === count + 1)) {
23265
+ pendingAnimatedPositionRef.current = null;
23266
+ setSkipTransition(true);
23267
+ setTrackPosition(activeIndex + 1);
23268
+ return;
23269
+ }
23342
23270
  setMoving(false);
23343
- if (!hasClones) return;
23344
- const shift = getMiddleCopyShift(trackPosition, count);
23345
- if (shift === 0) return;
23346
- setSkipTransition(true);
23347
- setTrackPosition(trackPosition - shift);
23348
- }, transitionDurationMs);
23271
+ }, TRANSITION_DURATION_MS);
23349
23272
  return () => window.clearTimeout(timeoutId);
23350
- }, [count, hasClones, isMoving, setMoving, trackPosition, transitionDurationMs]);
23273
+ }, [activeIndex, count, hasClones, isMoving, setMoving, trackPosition]);
23351
23274
 
23352
23275
  useEffect(() => {
23353
23276
  if (!skipTransition) return;
23354
23277
  let innerId = 0;
23355
23278
  const outerId = requestAnimationFrame(() => {
23356
- innerId = requestAnimationFrame(() => setSkipTransition(false));
23279
+ innerId = requestAnimationFrame(() => {
23280
+ const pendingPosition = pendingAnimatedPositionRef.current;
23281
+ pendingAnimatedPositionRef.current = null;
23282
+ const pendingSteps = pendingStepsRef.current;
23283
+ pendingStepsRef.current = 0;
23284
+ setSkipTransition(false);
23285
+ if (pendingPosition !== null) {
23286
+ trackPositionRef.current = pendingPosition;
23287
+ setTrackPosition(pendingPosition);
23288
+ return;
23289
+ }
23290
+ if (pendingSteps !== 0) {
23291
+ goBySteps(pendingSteps);
23292
+ return;
23293
+ }
23294
+ setMoving(false);
23295
+ });
23357
23296
  });
23358
23297
  return () => {
23359
23298
  cancelAnimationFrame(outerId);
23360
23299
  cancelAnimationFrame(innerId);
23361
23300
  };
23362
- }, [skipTransition]);
23301
+ }, [goBySteps, setMoving, skipTransition]);
23363
23302
 
23364
23303
  const structureKey = \`\${hasClones}:\${count}\`;
23365
23304
  const prevStructureKeyRef = useRef(structureKey);
@@ -23373,7 +23312,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23373
23312
  setDragOffset(0);
23374
23313
  setActiveIndex(nextIndex);
23375
23314
  setSkipTransition(true);
23376
- setTrackPosition(nextIndex + (hasClones ? count : 0));
23315
+ setTrackPosition(nextIndex + (hasClones ? 1 : 0));
23377
23316
  }, [activeIndex, count, hasClones, structureKey]);
23378
23317
 
23379
23318
  useEffect(() => {
@@ -23452,23 +23391,31 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23452
23391
  if (!isDragTrigger || count < 2 || !track) return;
23453
23392
  if (event.pointerType === 'mouse' && event.button !== 0) return;
23454
23393
 
23394
+ pendingAnimatedPositionRef.current = null;
23395
+ pendingStepsRef.current = 0;
23396
+
23455
23397
  if (isMovingRef.current) {
23456
23398
  setMoving(false);
23457
23399
  }
23458
23400
 
23459
- // Freeze the track where it is on screen and drag from there.
23460
23401
  let baseOffset = 0;
23461
23402
  const list = listRef.current;
23462
23403
  if (isSlideTransition && list) {
23463
- const size = readSlideSizePx(list, isHorizontal);
23404
+ const size = isHorizontal ? list.offsetWidth : list.offsetHeight;
23464
23405
  if (size > 0) {
23465
- const visual = readVisualPosition();
23466
- const middleVisual = hasClones ? visual - getMiddleCopyShift(visual, count) : visual;
23467
- const basePosition = Math.round(middleVisual);
23468
- baseOffset = (basePosition - middleVisual) * size;
23469
- trackPositionRef.current = basePosition;
23470
- setSkipTransition(true);
23471
- setTrackPosition(basePosition);
23406
+ const currentPx = readTrackTranslatePx(list, isHorizontal);
23407
+ let syncedPosition = trackPositionRef.current;
23408
+ const isOnClone = hasClones && (syncedPosition === 0 || syncedPosition === count + 1);
23409
+
23410
+ if (isOnClone) {
23411
+ syncedPosition = activeIndex + 1;
23412
+ trackPositionRef.current = syncedPosition;
23413
+ setSkipTransition(true);
23414
+ setTrackPosition(syncedPosition);
23415
+ baseOffset = 0;
23416
+ } else {
23417
+ baseOffset = currentPx + syncedPosition * size;
23418
+ }
23472
23419
  setDragOffset(baseOffset);
23473
23420
  }
23474
23421
  }
@@ -23534,19 +23481,19 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23534
23481
  finishDrag(event);
23535
23482
  };
23536
23483
 
23537
- const trackTranslate = getTrackTranslate(trackPosition, dragOffset, isHorizontal);
23538
- const slides = hasClones ? Array.from({ length: TRACK_COPIES }, () => items).flat() : items;
23484
+ const trackTranslate = isHorizontal
23485
+ ? \`translate3d(calc(\${-trackPosition * 100}% + \${dragOffset}px), 0, 0)\`
23486
+ : \`translate3d(0, calc(\${-trackPosition * 100}% + \${dragOffset}px), 0)\`;
23487
+ const slides = hasClones ? [items[count - 1], ...items, items[0]] : items;
23539
23488
 
23540
23489
  return (
23541
23490
  <>
23542
- <style dangerouslySetInnerHTML={{ __html: getCSS(P, transitionDurationMs, isEditor) }} />
23491
+ <style dangerouslySetInnerHTML={{ __html: getCSS(P, isEditor) }} />
23543
23492
  <div
23544
23493
  className={cn(\`\${P}-wrapper\`, {
23545
- [\`\${P}-transition-fade\`]: transition === 'fade in',
23546
- [\`\${P}-transition-reveal\`]: isReveal,
23547
- [\`\${P}-transition-reveal-vertical\`]: isReveal && !isHorizontal,
23494
+ [\`\${P}-transition-reveal\`]: transition === 'reveal',
23495
+ [\`\${P}-transition-reveal-vertical\`]: transition === 'reveal' && !isHorizontal,
23548
23496
  })}
23549
- data-active-index={activeIndex}
23550
23497
  onMouseEnter={() => setIsHovered(true)}
23551
23498
  onMouseLeave={() => setIsHovered(false)}
23552
23499
  >
@@ -23562,7 +23509,6 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23562
23509
  [\`\${P}-track-draggable\`]: isDragTrigger,
23563
23510
  [\`\${P}-track-draggable-vertical\`]: isDragTrigger && !isHorizontal,
23564
23511
  })}
23565
- style={trackRadiusStyle}
23566
23512
  onPointerDown={handlePointerDown}
23567
23513
  onPointerMove={handlePointerMove}
23568
23514
  onPointerUp={handlePointerUp}
@@ -23585,29 +23531,38 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23585
23531
  transform: trackTranslate,
23586
23532
  transition: isDragging || skipTransition
23587
23533
  ? 'none'
23588
- : \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`,
23534
+ : \`transform \${TRANSITION_DURATION_MS}ms \${TRANSITION_EASING}\`,
23589
23535
  }
23590
23536
  : undefined}
23591
23537
  >
23592
23538
  {slides.map((item, slideIndex) => {
23593
- const itemIndex = wrapIndex(slideIndex, count);
23594
- const key = \`slide-\${Math.floor(slideIndex / count)}-\${itemIndex}\`;
23539
+ const itemIndex = hasClones ? wrapIndex(slideIndex - 1, count) : slideIndex;
23540
+ const isClone = hasClones && (slideIndex === 0 || slideIndex === count + 1);
23541
+ const key = isClone
23542
+ ? \`clone-\${slideIndex === 0 ? 'start' : 'end'}\`
23543
+ : \`slide-\${itemIndex}\`;
23595
23544
  return (
23596
- <div key={key} className={\`\${P}-slide\`}>
23597
- {renderSlideItem(item)}
23545
+ <div
23546
+ key={key}
23547
+ className={cn(\`\${P}-slide\`, {
23548
+ [\`\${P}-is-active\`]: !isSlideTransition && itemIndex === activeIndex,
23549
+ })}
23550
+ >
23551
+ <div className={\`\${P}-slider-item\`}>
23552
+ <div className={\`\${P}-img-wrapper\`}>
23553
+ <img
23554
+ className={cn(\`\${P}-slider-image\`, {
23555
+ [\`\${P}-contain\`]: item.image.objectFit === 'contain',
23556
+ [\`\${P}-cover\`]: item.image.objectFit === 'cover'
23557
+ })}
23558
+ src={item.image.assetId} alt={item.image.name ?? ''}
23559
+ draggable={false}
23560
+ />
23561
+ </div>
23562
+ </div>
23598
23563
  </div>
23599
23564
  );
23600
23565
  })}
23601
- {isLayered && transitionLayers.map((layer, layerPosition) => (
23602
- <div
23603
- key={\`layer-\${layer.key}\`}
23604
- className={cn(\`\${P}-slide\`, \`\${P}-is-layer\`, { [\`\${P}-is-animated\`]: layer.isAnimated })}
23605
- style={{ zIndex: layerPosition + 1 }}
23606
- onAnimationEnd={() => handleLayerEnd(layer.key)}
23607
- >
23608
- {renderSlideItem(items[layer.index])}
23609
- </div>
23610
- ))}
23611
23566
  </div>
23612
23567
  {isClickTrigger && (
23613
23568
  <div
@@ -23779,7 +23734,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23779
23734
  style={{
23780
23735
  ...titleStyle,
23781
23736
  width: TITLE_WIDTH_SETTINGS.sizing === 'auto' ? 'max-content' : scalingValue(TITLE_WIDTH_SETTINGS.width, isEditor),
23782
- transitionDuration: \`\${Math.round(transitionDurationMs / 2)}ms\`,
23737
+ transitionDuration: \`\${Math.round(TRANSITION_DURATION_MS / 2)}ms\`,
23783
23738
  }}
23784
23739
  >
23785
23740
  <div
@@ -25485,8 +25440,8 @@ export function Waterfall({
25485
25440
  [m.id]: M,
25486
25441
  [g.id]: L,
25487
25442
  [u.id]: k,
25488
- [c.id]: A,
25489
- [d.id]: N,
25443
+ [d.id]: A,
25444
+ [c.id]: N,
25490
25445
  [l.id]: H,
25491
25446
  [s.id]: O,
25492
25447
  [a.id]: _,
@@ -0,0 +1,18 @@
1
+ import { useEffect as c } from "react";
2
+ const s = "[data-lightbox-scrollable]", m = (e = !0) => {
3
+ c(() => {
4
+ if (!e) return;
5
+ const l = document.body.style.overflow, r = document.documentElement.style.overflow;
6
+ document.body.style.overflow = "hidden", document.documentElement.style.overflow = "hidden";
7
+ const o = (t) => {
8
+ const n = t.target;
9
+ n instanceof Element && n.closest(s) || t.preventDefault();
10
+ };
11
+ return document.addEventListener("touchmove", o, { passive: !1 }), () => {
12
+ document.removeEventListener("touchmove", o), document.body.style.overflow = l, document.documentElement.style.overflow = r;
13
+ };
14
+ }, [e]);
15
+ };
16
+ export {
17
+ m as u
18
+ };
@@ -0,0 +1 @@
1
+ "use strict";const c=require("react"),s="[data-lightbox-scrollable]",u=(e=!0)=>{c.useEffect(()=>{if(!e)return;const l=document.body.style.overflow,r=document.documentElement.style.overflow;document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden";const o=t=>{const n=t.target;n instanceof Element&&n.closest(s)||t.preventDefault()};return document.addEventListener("touchmove",o,{passive:!1}),()=>{document.removeEventListener("touchmove",o),document.body.style.overflow=l,document.documentElement.style.overflow=r}},[e])};exports.useLightboxScrollLock=u;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "1.0.120",
3
+ "version": "1.0.121",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",