@cntrl-site/components 1.0.119 → 1.0.120-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sources.mjs CHANGED
@@ -1,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 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-D_YAkpJZ.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 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-CQhnb---.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,7 +22599,6 @@ type Slider20Item = {
22599
22599
  image: {
22600
22600
  assetId: string;
22601
22601
  name?: string;
22602
- objectFit?: 'cover' | 'contain';
22603
22602
  };
22604
22603
  imageCaption: any[];
22605
22604
  };
@@ -22621,6 +22620,7 @@ type Slider20Settings = {
22621
22620
  trigger?: Slider20Trigger;
22622
22621
  direction?: Slider20Direction;
22623
22622
  transition?: Slider20Transition;
22623
+ transitionSpeed?: number;
22624
22624
  nav?: Slider20Nav;
22625
22625
  navSize?: Slider20NavSize;
22626
22626
  navUnit?: number;
@@ -22651,6 +22651,7 @@ type Slider20Settings = {
22651
22651
  fontVariant?: 'normal' | 'small-caps';
22652
22652
  };
22653
22653
  captionMarginTop?: number;
22654
+ imageCorners?: number;
22654
22655
  };
22655
22656
 
22656
22657
  type Slider20Props = {
@@ -22662,6 +22663,7 @@ type Slider20Props = {
22662
22663
  } & CommonComponentProps;
22663
22664
 
22664
22665
  type Offset = { x: number; y: number };
22666
+ type TransitionLayer = { index: number; key: number };
22665
22667
  type Point = { x: number; y: number };
22666
22668
  type LocalAxes = { ex: Point; ey: Point; det: number };
22667
22669
 
@@ -22679,9 +22681,11 @@ type DragState = {
22679
22681
  };
22680
22682
 
22681
22683
  const TRANSITION_DURATION_MS = 500;
22684
+ const DEFAULT_TRANSITION_SPEED = 1;
22682
22685
  const TRANSITION_EASING = 'cubic-bezier(0.25, 1, 0.5, 1)';
22683
22686
  const TRANSITION_BACKGROUND_COLOR: string | null = null;
22684
22687
  const DOT_ANIMATION_MS = 300;
22688
+ const MAX_TRANSITION_LAYERS = 40;
22685
22689
  const DRAG_START_THRESHOLD_PX = 5;
22686
22690
  const DRAG_DISTANCE_RATIO = 0.15;
22687
22691
  const DRAG_FLICK_VELOCITY = 0.4;
@@ -22783,23 +22787,24 @@ function wrapIndex(index: number, count: number): number {
22783
22787
  return ((index % count) + count) % count;
22784
22788
  }
22785
22789
 
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
- };
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;
22803
22808
  }
22804
22809
 
22805
22810
  function readTrackTranslatePx(element: HTMLElement, isHorizontal: boolean): number {
@@ -22841,7 +22846,13 @@ function toLocalDelta(axes: LocalAxes, dx: number, dy: number): Point {
22841
22846
  };
22842
22847
  }
22843
22848
 
22844
- function getCSS(P: string, isEditor?: boolean): string {
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 {
22845
22856
  return \`
22846
22857
  .\${P}-wrapper {
22847
22858
  position: relative;
@@ -22902,6 +22913,8 @@ function getCSS(P: string, isEditor?: boolean): string {
22902
22913
  }
22903
22914
  .\${P}-list-fade {
22904
22915
  display: block;
22916
+ /* Keeps the transition layers' z-index below the arrows, dots and click overlay. */
22917
+ isolation: isolate;
22905
22918
  }
22906
22919
  .\${P}-slide {
22907
22920
  position: relative;
@@ -22914,11 +22927,9 @@ function getCSS(P: string, isEditor?: boolean): string {
22914
22927
  top: 0;
22915
22928
  left: 0;
22916
22929
  opacity: 0;
22917
- transition: opacity \${TRANSITION_DURATION_MS}ms \${TRANSITION_EASING};
22918
22930
  }
22919
- .\${P}-list-fade .\${P}-slide.\${P}-is-active {
22931
+ .\${P}-list-fade .\${P}-slide.\${P}-is-layer {
22920
22932
  opacity: 1;
22921
- z-index: 1;
22922
22933
  }
22923
22934
  .\${P}-slider-item {
22924
22935
  width: 100%;
@@ -23093,17 +23104,18 @@ function getCSS(P: string, isEditor?: boolean): string {
23093
23104
  cursor: pointer;
23094
23105
  z-index: 2;
23095
23106
  }
23096
- .\${P}-contain {
23097
- object-fit: contain;
23107
+ .\${P}-transition-fade .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23108
+ animation: \${P}-fade-in \${transitionDurationMs}ms \${TRANSITION_EASING};
23098
23109
  }
23099
- .\${P}-cover {
23100
- object-fit: cover;
23110
+ .\${P}-transition-reveal .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23111
+ animation: \${P}-reveal-horizontal \${transitionDurationMs}ms ease;
23101
23112
  }
23102
- .\${P}-transition-reveal .\${P}-slide.\${P}-is-active .\${P}-slider-image {
23103
- animation: \${P}-reveal-horizontal \${TRANSITION_DURATION_MS}ms ease;
23113
+ .\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-layer .\${P}-slider-image {
23114
+ animation: \${P}-reveal-vertical \${transitionDurationMs}ms ease;
23104
23115
  }
23105
- .\${P}-transition-reveal-vertical .\${P}-slide.\${P}-is-active .\${P}-slider-image {
23106
- animation: \${P}-reveal-vertical \${TRANSITION_DURATION_MS}ms ease;
23116
+ @keyframes \${P}-fade-in {
23117
+ from { opacity: 0; }
23118
+ to { opacity: 1; }
23107
23119
  }
23108
23120
  @keyframes \${P}-reveal-horizontal {
23109
23121
  from { clip-path: inset(0 100% 0 0); }
@@ -23126,6 +23138,8 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23126
23138
  const autoPlayIntervalS = trigger.value ?? DEFAULT_TRIGGER.value;
23127
23139
  const direction: Slider20Direction = settings?.direction ?? 'horizontal';
23128
23140
  const transition: Slider20Transition = settings?.transition ?? 'slide';
23141
+ const transitionSpeed = typeof settings?.transitionSpeed === 'number' ? settings.transitionSpeed : DEFAULT_TRANSITION_SPEED;
23142
+ const transitionDurationMs = getTransitionDurationMs(transitionSpeed);
23129
23143
  const nav: Slider20Nav = settings?.nav ?? 'classic';
23130
23144
  const navSize: Slider20NavSize = settings?.navSize ?? 'm';
23131
23145
  const navSizeValues = NAV_SIZES[navSize];
@@ -23143,12 +23157,21 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23143
23157
  const navBackgroundColor = settings?.navBackgroundColor ?? PAGINATION.colors.background;
23144
23158
  const linkColor = settings?.linkColor ?? IMAGE_CAPTION.linkColor;
23145
23159
  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;
23146
23166
  const isHorizontal = direction === 'horizontal';
23147
23167
  const isClickTrigger = triggerType === 'click';
23148
23168
  const isDragTrigger = triggerType === 'drag';
23149
23169
  const isAutoPlaying = triggerType === 'auto' && (!isEditor || Boolean(isPreviewMode));
23150
23170
  const pauseAutoOnHover = !isEditor;
23151
23171
  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;
23152
23175
  const showClassicNav = nav === 'classic';
23153
23176
  const showControls = controlsShow !== 'never' && controlsMaxWidth > 0;
23154
23177
  const isControlsOnHover = controlsShow === 'on hover';
@@ -23161,7 +23184,36 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23161
23184
 
23162
23185
  const hasClones = isSlideTransition && count > 1;
23163
23186
  const [activeIndex, setActiveIndex] = useState(0);
23164
- const [trackPosition, setTrackPosition] = useState(hasClones ? 1 : 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
+ const [transitionLayers, setTransitionLayers] = useState<TransitionLayer[]>([{ index: activeIndex, key: 0 }]);
23190
+ const topLayer = transitionLayers[transitionLayers.length - 1];
23191
+ if (isLayered && topLayer.index !== activeIndex) {
23192
+ // Over the limit, drop the oldest layer still animating, never the fully shown bottom one.
23193
+ const kept = transitionLayers.length >= MAX_TRANSITION_LAYERS
23194
+ ? [transitionLayers[0], ...transitionLayers.slice(2)]
23195
+ : transitionLayers;
23196
+ setTransitionLayers([...kept, { index: activeIndex, key: topLayer.key + 1 }]);
23197
+ }
23198
+ const handleLayerEnd = (key: number) => {
23199
+ // A fully shown layer covers everything under it, so those layers are dropped.
23200
+ setTransitionLayers((layers) => {
23201
+ const position = layers.findIndex((layer) => layer.key === key);
23202
+ return position > 0 ? layers.slice(position) : layers;
23203
+ });
23204
+ };
23205
+ const renderSlideItem = (item: Slider20Item | undefined) => item && (
23206
+ <div className={\`\${P}-slider-item\`}>
23207
+ <div className={\`\${P}-img-wrapper\`}>
23208
+ <img
23209
+ className={\`\${P}-slider-image\`}
23210
+ src={item.image.assetId} alt={item.image.name ?? ''}
23211
+ draggable={false}
23212
+ />
23213
+ </div>
23214
+ </div>
23215
+ );
23216
+ const [trackPosition, setTrackPosition] = useState(hasClones ? count : 0);
23165
23217
  const [isMoving, setIsMoving] = useState(false);
23166
23218
  const [skipTransition, setSkipTransition] = useState(false);
23167
23219
  const [isDragging, setIsDragging] = useState(false);
@@ -23171,8 +23223,6 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23171
23223
  const isMovingRef = useRef(false);
23172
23224
  const trackPositionRef = useRef(trackPosition);
23173
23225
  trackPositionRef.current = trackPosition;
23174
- const pendingAnimatedPositionRef = useRef<number | null>(null);
23175
- const pendingStepsRef = useRef(0);
23176
23226
  const trackRef = useRef<HTMLDivElement | null>(null);
23177
23227
  const listRef = useRef<HTMLDivElement | null>(null);
23178
23228
  const dragRef = useRef<DragState | null>(null);
@@ -23183,59 +23233,56 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23183
23233
  setIsMoving(value);
23184
23234
  }, []);
23185
23235
 
23236
+ // Where the track is on screen right now, mid-transition included, in slide units.
23237
+ const readVisualPosition = useCallback((): number => {
23238
+ const list = listRef.current;
23239
+ const size = list ? readSlideSizePx(list, isHorizontal) : 0;
23240
+ if (!list || size <= 0) return trackPositionRef.current;
23241
+ // Rounded so a settled track reads as a whole position.
23242
+ return Math.round((-readTrackTranslatePx(list, isHorizontal) / size) * 1000) / 1000;
23243
+ }, [isHorizontal]);
23244
+
23245
+ // Moves the track to \`target\` from wherever it is now. When the visual position is outside
23246
+ // the middle copy, it is first teleported by a whole copy (no visible change), so rapid
23247
+ // navigation never runs off the rendered slides and never snaps mid-animation.
23248
+ const moveTrack = useCallback((getTarget: (visual: number, shift: number) => number) => {
23249
+ const visual = readVisualPosition();
23250
+ const shift = getMiddleCopyShift(visual, count);
23251
+ const target = getTarget(visual - shift, shift);
23252
+ const list = listRef.current;
23253
+ if (shift !== 0 && list) {
23254
+ const transitionValue = list.style.transition;
23255
+ list.style.transition = 'none';
23256
+ list.style.transform = getTrackTranslate(visual - shift, 0, isHorizontal);
23257
+ void list.offsetWidth;
23258
+ list.style.transition = transitionValue && transitionValue !== 'none'
23259
+ ? transitionValue
23260
+ : \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`;
23261
+ list.style.transform = getTrackTranslate(target, 0, isHorizontal);
23262
+ }
23263
+ trackPositionRef.current = target;
23264
+ setActiveIndex(wrapIndex(target, count));
23265
+ setSkipTransition(false);
23266
+ setTrackPosition(target);
23267
+ }, [count, isHorizontal, readVisualPosition, transitionDurationMs]);
23268
+
23186
23269
  const goBySteps = useCallback((steps: number) => {
23187
23270
  if (count < 2 || steps === 0) return;
23188
- const direction = steps > 0 ? 1 : -1;
23189
- const total = Math.abs(steps);
23190
23271
  setAnimateDots(true);
23191
23272
  setMoving(true);
23192
23273
  if (!isSlideTransition) {
23193
23274
  setActiveIndex((prev) => wrapIndex(prev + steps, count));
23194
23275
  return;
23195
23276
  }
23196
-
23197
- let position = trackPositionRef.current;
23198
- const isOnClone = hasClones && (position === 0 || position === count + 1);
23199
- const cloneSnapPosition = isOnClone ? activeIndex + 1 : null;
23200
-
23201
- if (isOnClone) {
23202
- position = activeIndex + 1;
23203
- }
23204
-
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);
23233
- return;
23234
- }
23235
-
23236
- setSkipTransition(false);
23237
- setTrackPosition(position);
23238
- }, [activeIndex, count, hasClones, isSlideTransition, setMoving]);
23277
+ moveTrack((visual, shift) => {
23278
+ // Continue from the previous target so quick clicks add up, but never get more than
23279
+ // count - 1 slides away from what is on screen, which keeps the target inside the copies.
23280
+ const previousTarget = trackPositionRef.current - shift;
23281
+ const base = Math.abs(previousTarget - visual) < count ? previousTarget : Math.round(visual);
23282
+ const maxDistance = count - 1;
23283
+ return Math.min(Math.max(base + steps, Math.ceil(visual - maxDistance)), Math.floor(visual + maxDistance));
23284
+ });
23285
+ }, [count, isSlideTransition, moveTrack, setMoving]);
23239
23286
 
23240
23287
  const goBy = useCallback((step: 1 | -1) => {
23241
23288
  goBySteps(step);
@@ -23247,58 +23294,37 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23247
23294
  if (target === activeIndex && !isMovingRef.current) return;
23248
23295
  setAnimateDots(true);
23249
23296
  setMoving(true);
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);
23297
+ if (!isSlideTransition) {
23298
+ setActiveIndex(target);
23299
+ return;
23258
23300
  }
23259
- }, [activeIndex, count, hasClones, isSlideTransition, setMoving]);
23301
+ moveTrack(() => count + target);
23302
+ }, [activeIndex, count, isSlideTransition, moveTrack, setMoving]);
23260
23303
 
23261
23304
  useEffect(() => {
23262
23305
  if (!isMoving) return;
23263
23306
  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
- }
23270
23307
  setMoving(false);
23271
- }, TRANSITION_DURATION_MS);
23308
+ if (!hasClones) return;
23309
+ const shift = getMiddleCopyShift(trackPosition, count);
23310
+ if (shift === 0) return;
23311
+ setSkipTransition(true);
23312
+ setTrackPosition(trackPosition - shift);
23313
+ }, transitionDurationMs);
23272
23314
  return () => window.clearTimeout(timeoutId);
23273
- }, [activeIndex, count, hasClones, isMoving, setMoving, trackPosition]);
23315
+ }, [count, hasClones, isMoving, setMoving, trackPosition, transitionDurationMs]);
23274
23316
 
23275
23317
  useEffect(() => {
23276
23318
  if (!skipTransition) return;
23277
23319
  let innerId = 0;
23278
23320
  const outerId = requestAnimationFrame(() => {
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
- });
23321
+ innerId = requestAnimationFrame(() => setSkipTransition(false));
23296
23322
  });
23297
23323
  return () => {
23298
23324
  cancelAnimationFrame(outerId);
23299
23325
  cancelAnimationFrame(innerId);
23300
23326
  };
23301
- }, [goBySteps, setMoving, skipTransition]);
23327
+ }, [skipTransition]);
23302
23328
 
23303
23329
  const structureKey = \`\${hasClones}:\${count}\`;
23304
23330
  const prevStructureKeyRef = useRef(structureKey);
@@ -23312,7 +23338,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23312
23338
  setDragOffset(0);
23313
23339
  setActiveIndex(nextIndex);
23314
23340
  setSkipTransition(true);
23315
- setTrackPosition(nextIndex + (hasClones ? 1 : 0));
23341
+ setTrackPosition(nextIndex + (hasClones ? count : 0));
23316
23342
  }, [activeIndex, count, hasClones, structureKey]);
23317
23343
 
23318
23344
  useEffect(() => {
@@ -23391,31 +23417,23 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23391
23417
  if (!isDragTrigger || count < 2 || !track) return;
23392
23418
  if (event.pointerType === 'mouse' && event.button !== 0) return;
23393
23419
 
23394
- pendingAnimatedPositionRef.current = null;
23395
- pendingStepsRef.current = 0;
23396
-
23397
23420
  if (isMovingRef.current) {
23398
23421
  setMoving(false);
23399
23422
  }
23400
23423
 
23424
+ // Freeze the track where it is on screen and drag from there.
23401
23425
  let baseOffset = 0;
23402
23426
  const list = listRef.current;
23403
23427
  if (isSlideTransition && list) {
23404
- const size = isHorizontal ? list.offsetWidth : list.offsetHeight;
23428
+ const size = readSlideSizePx(list, isHorizontal);
23405
23429
  if (size > 0) {
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
- }
23430
+ const visual = readVisualPosition();
23431
+ const middleVisual = hasClones ? visual - getMiddleCopyShift(visual, count) : visual;
23432
+ const basePosition = Math.round(middleVisual);
23433
+ baseOffset = (basePosition - middleVisual) * size;
23434
+ trackPositionRef.current = basePosition;
23435
+ setSkipTransition(true);
23436
+ setTrackPosition(basePosition);
23419
23437
  setDragOffset(baseOffset);
23420
23438
  }
23421
23439
  }
@@ -23481,19 +23499,19 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23481
23499
  finishDrag(event);
23482
23500
  };
23483
23501
 
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;
23502
+ const trackTranslate = getTrackTranslate(trackPosition, dragOffset, isHorizontal);
23503
+ const slides = hasClones ? Array.from({ length: TRACK_COPIES }, () => items).flat() : items;
23488
23504
 
23489
23505
  return (
23490
23506
  <>
23491
- <style dangerouslySetInnerHTML={{ __html: getCSS(P, isEditor) }} />
23507
+ <style dangerouslySetInnerHTML={{ __html: getCSS(P, transitionDurationMs, isEditor) }} />
23492
23508
  <div
23493
23509
  className={cn(\`\${P}-wrapper\`, {
23494
- [\`\${P}-transition-reveal\`]: transition === 'reveal',
23495
- [\`\${P}-transition-reveal-vertical\`]: transition === 'reveal' && !isHorizontal,
23510
+ [\`\${P}-transition-fade\`]: transition === 'fade in',
23511
+ [\`\${P}-transition-reveal\`]: isReveal,
23512
+ [\`\${P}-transition-reveal-vertical\`]: isReveal && !isHorizontal,
23496
23513
  })}
23514
+ data-active-index={activeIndex}
23497
23515
  onMouseEnter={() => setIsHovered(true)}
23498
23516
  onMouseLeave={() => setIsHovered(false)}
23499
23517
  >
@@ -23509,6 +23527,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23509
23527
  [\`\${P}-track-draggable\`]: isDragTrigger,
23510
23528
  [\`\${P}-track-draggable-vertical\`]: isDragTrigger && !isHorizontal,
23511
23529
  })}
23530
+ style={trackRadiusStyle}
23512
23531
  onPointerDown={handlePointerDown}
23513
23532
  onPointerMove={handlePointerMove}
23514
23533
  onPointerUp={handlePointerUp}
@@ -23531,38 +23550,29 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23531
23550
  transform: trackTranslate,
23532
23551
  transition: isDragging || skipTransition
23533
23552
  ? 'none'
23534
- : \`transform \${TRANSITION_DURATION_MS}ms \${TRANSITION_EASING}\`,
23553
+ : \`transform \${transitionDurationMs}ms \${TRANSITION_EASING}\`,
23535
23554
  }
23536
23555
  : undefined}
23537
23556
  >
23538
23557
  {slides.map((item, slideIndex) => {
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}\`;
23558
+ const itemIndex = wrapIndex(slideIndex, count);
23559
+ const key = \`slide-\${Math.floor(slideIndex / count)}-\${itemIndex}\`;
23544
23560
  return (
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>
23561
+ <div key={key} className={\`\${P}-slide\`}>
23562
+ {renderSlideItem(item)}
23563
23563
  </div>
23564
23564
  );
23565
23565
  })}
23566
+ {isLayered && transitionLayers.map((layer, layerPosition) => (
23567
+ <div
23568
+ key={\`layer-\${layer.key}\`}
23569
+ className={cn(\`\${P}-slide\`, \`\${P}-is-layer\`)}
23570
+ style={{ zIndex: layerPosition + 1 }}
23571
+ onAnimationEnd={() => handleLayerEnd(layer.key)}
23572
+ >
23573
+ {renderSlideItem(items[layer.index])}
23574
+ </div>
23575
+ ))}
23566
23576
  </div>
23567
23577
  {isClickTrigger && (
23568
23578
  <div
@@ -23734,7 +23744,7 @@ export function Slider20({ settings, content, isEditor, isPreviewMode, isEditMod
23734
23744
  style={{
23735
23745
  ...titleStyle,
23736
23746
  width: TITLE_WIDTH_SETTINGS.sizing === 'auto' ? 'max-content' : scalingValue(TITLE_WIDTH_SETTINGS.width, isEditor),
23737
- transitionDuration: \`\${Math.round(TRANSITION_DURATION_MS / 2)}ms\`,
23747
+ transitionDuration: \`\${Math.round(transitionDurationMs / 2)}ms\`,
23738
23748
  }}
23739
23749
  >
23740
23750
  <div
@@ -25440,8 +25450,8 @@ export function Waterfall({
25440
25450
  [m.id]: M,
25441
25451
  [g.id]: L,
25442
25452
  [u.id]: k,
25443
- [d.id]: A,
25444
- [c.id]: N,
25453
+ [c.id]: A,
25454
+ [d.id]: N,
25445
25455
  [l.id]: H,
25446
25456
  [s.id]: O,
25447
25457
  [a.id]: _,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "1.0.119",
3
+ "version": "1.0.120-alpha.1",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",