@flamingo-stack/openframe-frontend-core 0.0.694 → 0.0.695-2521.7724.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/{chunk-42LIHMRA.js → chunk-2JUABY7O.js} +2 -2
- package/dist/{chunk-HBMGSGZY.js → chunk-2PTRTB2W.js} +3 -3
- package/dist/{chunk-ZUGAHQDB.cjs → chunk-36B4UDXK.cjs} +5 -5
- package/dist/{chunk-ZUGAHQDB.cjs.map → chunk-36B4UDXK.cjs.map} +1 -1
- package/dist/{chunk-C27F6GBZ.cjs → chunk-3EFJUMTA.cjs} +17 -8
- package/dist/chunk-3EFJUMTA.cjs.map +1 -0
- package/dist/{chunk-ZCPMWXIB.cjs → chunk-47DUFE2T.cjs} +15 -15
- package/dist/{chunk-ZCPMWXIB.cjs.map → chunk-47DUFE2T.cjs.map} +1 -1
- package/dist/{chunk-KJHIFF6H.cjs → chunk-5FLFT5VL.cjs} +10 -10
- package/dist/{chunk-KJHIFF6H.cjs.map → chunk-5FLFT5VL.cjs.map} +1 -1
- package/dist/{chunk-TXSQLORA.js → chunk-5T7T3YU6.js} +3 -3
- package/dist/{chunk-SJFB4Z4L.cjs → chunk-AHT6QH7C.cjs} +71 -71
- package/dist/{chunk-SJFB4Z4L.cjs.map → chunk-AHT6QH7C.cjs.map} +1 -1
- package/dist/{chunk-HJZ3UTUE.cjs → chunk-AOT6BM3U.cjs} +45 -45
- package/dist/{chunk-HJZ3UTUE.cjs.map → chunk-AOT6BM3U.cjs.map} +1 -1
- package/dist/{chunk-JB25CCOB.cjs → chunk-BEXXDGFW.cjs} +33 -33
- package/dist/{chunk-JB25CCOB.cjs.map → chunk-BEXXDGFW.cjs.map} +1 -1
- package/dist/{chunk-SYLLPIGU.cjs → chunk-BISBFWN6.cjs} +26 -26
- package/dist/{chunk-SYLLPIGU.cjs.map → chunk-BISBFWN6.cjs.map} +1 -1
- package/dist/{chunk-BW6YBATM.js → chunk-DGK3HNK4.js} +17 -8
- package/dist/{chunk-BW6YBATM.js.map → chunk-DGK3HNK4.js.map} +1 -1
- package/dist/{chunk-TBR3UTFY.js → chunk-DTUKKJ3Q.js} +3 -3
- package/dist/{chunk-K5K2FRQK.cjs → chunk-GWVGEWHE.cjs} +10 -10
- package/dist/{chunk-K5K2FRQK.cjs.map → chunk-GWVGEWHE.cjs.map} +1 -1
- package/dist/{chunk-7VO6NC67.js → chunk-HJPXPC5M.js} +3 -3
- package/dist/{chunk-2EQED5SZ.cjs → chunk-HLAI4MHS.cjs} +22 -22
- package/dist/{chunk-2EQED5SZ.cjs.map → chunk-HLAI4MHS.cjs.map} +1 -1
- package/dist/{chunk-Q2B2MGFU.cjs → chunk-HVVKD5ZB.cjs} +3 -3
- package/dist/{chunk-Q2B2MGFU.cjs.map → chunk-HVVKD5ZB.cjs.map} +1 -1
- package/dist/{chunk-KBSL4FCL.cjs → chunk-IBKZNBUW.cjs} +4 -4
- package/dist/{chunk-KBSL4FCL.cjs.map → chunk-IBKZNBUW.cjs.map} +1 -1
- package/dist/{chunk-6ZSDKDOV.js → chunk-JTKKHAA4.js} +5 -5
- package/dist/{chunk-NOMECDMA.js → chunk-K3ZY4AX5.js} +4 -4
- package/dist/{chunk-O4RDXDVS.js → chunk-K4I6SEQF.js} +6 -6
- package/dist/{chunk-N7HFUBOV.js → chunk-K5LZ3NW4.js} +2 -2
- package/dist/{chunk-K5GSLGV2.cjs → chunk-KI6HWNDP.cjs} +10 -10
- package/dist/{chunk-K5GSLGV2.cjs.map → chunk-KI6HWNDP.cjs.map} +1 -1
- package/dist/{chunk-GWQCUC53.js → chunk-LX447YPY.js} +2 -2
- package/dist/{chunk-QP54LMXJ.js → chunk-MHJW573B.js} +2 -2
- package/dist/{chunk-TV5SZJ3N.js → chunk-NUM3RTPC.js} +5 -5
- package/dist/{chunk-JISKS7RJ.cjs → chunk-RBYFF6YE.cjs} +22 -22
- package/dist/{chunk-JISKS7RJ.cjs.map → chunk-RBYFF6YE.cjs.map} +1 -1
- package/dist/{chunk-LPFU6U7O.cjs → chunk-STUKV3BX.cjs} +3 -3
- package/dist/{chunk-LPFU6U7O.cjs.map → chunk-STUKV3BX.cjs.map} +1 -1
- package/dist/{chunk-LHYOESIQ.js → chunk-UIQSRBFW.js} +3 -3
- package/dist/{chunk-FNGX5WZM.cjs → chunk-VW4X7B52.cjs} +339 -339
- package/dist/{chunk-FNGX5WZM.cjs.map → chunk-VW4X7B52.cjs.map} +1 -1
- package/dist/{chunk-UCXZRJIE.js → chunk-VXPVKBXG.js} +5 -5
- package/dist/{chunk-33L2IR62.js → chunk-Y2ULUMLP.js} +2 -2
- package/dist/components/case-studies/index.cjs +14 -14
- package/dist/components/case-studies/index.js +3 -3
- package/dist/components/chat/index.cjs +2 -2
- package/dist/components/chat/index.js +1 -1
- package/dist/components/contact/index.cjs +4 -4
- package/dist/components/contact/index.js +3 -3
- package/dist/components/docs/index.cjs +7 -7
- package/dist/components/docs/index.js +6 -6
- package/dist/components/embeds/index.cjs +4 -4
- package/dist/components/embeds/index.js +3 -3
- package/dist/components/faq/index.cjs +4 -4
- package/dist/components/faq/index.js +3 -3
- package/dist/components/features/cards-strip.d.ts +5 -0
- package/dist/components/features/cards-strip.d.ts.map +1 -1
- package/dist/components/features/index.cjs +3 -3
- package/dist/components/features/index.js +2 -2
- package/dist/components/help-center-pages/index.cjs +73 -73
- package/dist/components/help-center-pages/index.js +14 -14
- package/dist/components/index.cjs +40 -40
- package/dist/components/index.js +13 -13
- package/dist/components/meeting-scheduler/index.cjs +25 -25
- package/dist/components/meeting-scheduler/index.js +2 -2
- package/dist/components/navigation/index.cjs +6 -6
- package/dist/components/navigation/index.js +5 -5
- package/dist/components/onboarding-guides/index.cjs +6 -6
- package/dist/components/onboarding-guides/index.js +5 -5
- package/dist/components/tickets/index.cjs +7 -7
- package/dist/components/tickets/index.js +6 -6
- package/dist/components/ui/index.cjs +3 -3
- package/dist/components/ui/index.js +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.js +6 -6
- package/package.json +1 -1
- package/src/components/features/__tests__/cards-strip-reverse.test.tsx +127 -0
- package/src/components/features/cards-strip.tsx +29 -7
- package/dist/chunk-C27F6GBZ.cjs.map +0 -1
- /package/dist/{chunk-42LIHMRA.js.map → chunk-2JUABY7O.js.map} +0 -0
- /package/dist/{chunk-HBMGSGZY.js.map → chunk-2PTRTB2W.js.map} +0 -0
- /package/dist/{chunk-TXSQLORA.js.map → chunk-5T7T3YU6.js.map} +0 -0
- /package/dist/{chunk-TBR3UTFY.js.map → chunk-DTUKKJ3Q.js.map} +0 -0
- /package/dist/{chunk-7VO6NC67.js.map → chunk-HJPXPC5M.js.map} +0 -0
- /package/dist/{chunk-6ZSDKDOV.js.map → chunk-JTKKHAA4.js.map} +0 -0
- /package/dist/{chunk-NOMECDMA.js.map → chunk-K3ZY4AX5.js.map} +0 -0
- /package/dist/{chunk-O4RDXDVS.js.map → chunk-K4I6SEQF.js.map} +0 -0
- /package/dist/{chunk-N7HFUBOV.js.map → chunk-K5LZ3NW4.js.map} +0 -0
- /package/dist/{chunk-GWQCUC53.js.map → chunk-LX447YPY.js.map} +0 -0
- /package/dist/{chunk-QP54LMXJ.js.map → chunk-MHJW573B.js.map} +0 -0
- /package/dist/{chunk-TV5SZJ3N.js.map → chunk-NUM3RTPC.js.map} +0 -0
- /package/dist/{chunk-LHYOESIQ.js.map → chunk-UIQSRBFW.js.map} +0 -0
- /package/dist/{chunk-UCXZRJIE.js.map → chunk-VXPVKBXG.js.map} +0 -0
- /package/dist/{chunk-33L2IR62.js.map → chunk-Y2ULUMLP.js.map} +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { act, render } from '@testing-library/react';
|
|
2
|
+
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { CardsStrip } from '../cards-strip';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `reverse` flips the DIRECTION the marquee travels and nothing else. jsdom has
|
|
7
|
+
* no layout, so the strip is given one: a 500px viewport over a track whose
|
|
8
|
+
* single copy is 2000px wide, which makes it overflow and mount the marquee.
|
|
9
|
+
* Frames are driven by fake timers; the assertion reads the positions the
|
|
10
|
+
* engine WRITES to `scrollLeft` (recorded by the setter below), so the test
|
|
11
|
+
* needs no handle on the scroller element.
|
|
12
|
+
*/
|
|
13
|
+
const VIEWPORT = 500;
|
|
14
|
+
const COPY = 2000;
|
|
15
|
+
const GAP = 16;
|
|
16
|
+
|
|
17
|
+
/** Every value written to an element's `scrollLeft`, in order. */
|
|
18
|
+
let writes: number[] = [];
|
|
19
|
+
const stored = new WeakMap<object, number>();
|
|
20
|
+
|
|
21
|
+
beforeAll(() => {
|
|
22
|
+
globalThis.ResizeObserver = class {
|
|
23
|
+
observe() {}
|
|
24
|
+
unobserve() {}
|
|
25
|
+
disconnect() {}
|
|
26
|
+
};
|
|
27
|
+
globalThis.IntersectionObserver = class {
|
|
28
|
+
observe() {}
|
|
29
|
+
unobserve() {}
|
|
30
|
+
disconnect() {}
|
|
31
|
+
takeRecords() {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
root = null;
|
|
35
|
+
rootMargin = '';
|
|
36
|
+
thresholds = [];
|
|
37
|
+
};
|
|
38
|
+
window.matchMedia = (query: string) => ({
|
|
39
|
+
matches: false,
|
|
40
|
+
media: query,
|
|
41
|
+
onchange: null,
|
|
42
|
+
addEventListener: () => {},
|
|
43
|
+
removeEventListener: () => {},
|
|
44
|
+
addListener: () => {},
|
|
45
|
+
removeListener: () => {},
|
|
46
|
+
dispatchEvent: () => false,
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(HTMLElement.prototype, 'clientWidth', { configurable: true, get: () => VIEWPORT });
|
|
49
|
+
Object.defineProperty(HTMLElement.prototype, 'scrollLeft', {
|
|
50
|
+
configurable: true,
|
|
51
|
+
get(this: HTMLElement) {
|
|
52
|
+
return stored.get(this) ?? 0;
|
|
53
|
+
},
|
|
54
|
+
set(this: HTMLElement, value: number) {
|
|
55
|
+
stored.set(this, value);
|
|
56
|
+
writes.push(value);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(HTMLElement.prototype, 'scrollWidth', {
|
|
60
|
+
configurable: true,
|
|
61
|
+
get(this: HTMLElement) {
|
|
62
|
+
// The track reports one copy, or two copies joined by one gap once cloned.
|
|
63
|
+
return this.dataset.copies === '2' ? COPY * 2 - GAP : COPY;
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
beforeEach(() => {
|
|
69
|
+
writes = [];
|
|
70
|
+
vi.useFakeTimers({
|
|
71
|
+
toFake: ['requestAnimationFrame', 'cancelAnimationFrame', 'performance', 'setTimeout', 'clearTimeout'],
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
afterEach(() => {
|
|
76
|
+
vi.useRealTimers();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/** Mount a strip, run its marquee for `ms`, and return the positions it wrote. */
|
|
80
|
+
function travel(reverse: boolean, ms: number): number[] {
|
|
81
|
+
render(
|
|
82
|
+
<CardsStrip showTitle={false} reverse={reverse} pauseOnHover={false}>
|
|
83
|
+
{Array.from({ length: 8 }, (_, i) => (
|
|
84
|
+
<div key={i}>card {i}</div>
|
|
85
|
+
))}
|
|
86
|
+
</CardsStrip>,
|
|
87
|
+
);
|
|
88
|
+
for (let elapsed = 0; elapsed < ms; elapsed += 16) {
|
|
89
|
+
act(() => {
|
|
90
|
+
vi.advanceTimersByTime(16);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return writes;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** +1 when the positions only grow, -1 when they only shrink, 0 otherwise (seam wraps ignored). */
|
|
97
|
+
function direction(positions: number[]): number {
|
|
98
|
+
const steps = positions
|
|
99
|
+
.slice(1)
|
|
100
|
+
.map((p, i) => p - positions[i])
|
|
101
|
+
.filter(d => d !== 0 && Math.abs(d) < COPY / 2);
|
|
102
|
+
if (steps.length === 0) return 0;
|
|
103
|
+
if (steps.every(d => d > 0)) return 1;
|
|
104
|
+
if (steps.every(d => d < 0)) return -1;
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
describe('<CardsStrip reverse>', () => {
|
|
109
|
+
it('travels forward by default: scrollLeft grows', () => {
|
|
110
|
+
const positions = travel(false, 1500);
|
|
111
|
+
expect(positions.length).toBeGreaterThan(10);
|
|
112
|
+
expect(direction(positions)).toBe(1);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('travels the other way when reversed: scrollLeft shrinks', () => {
|
|
116
|
+
const positions = travel(true, 1500);
|
|
117
|
+
expect(positions.length).toBeGreaterThan(10);
|
|
118
|
+
expect(direction(positions)).toBe(-1);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('keeps a reversed strip inside the range a forward strip uses', () => {
|
|
122
|
+
for (const p of travel(true, 3000)) {
|
|
123
|
+
expect(p).toBeGreaterThanOrEqual(0);
|
|
124
|
+
expect(p).toBeLessThanOrEqual(COPY * 2);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -94,6 +94,11 @@ interface CardsStripEngineProps {
|
|
|
94
94
|
* default around 100px/s; 60 keeps drift lively while cards stay easy to
|
|
95
95
|
* hover-target. 60px/s ≈ 1px per 60Hz frame, the smoothest integer step. */
|
|
96
96
|
autoScrollSpeed?: number;
|
|
97
|
+
/** Reverse the marquee: the cards travel RIGHT instead of left. For a strip
|
|
98
|
+
* stacked under another one, so the two rows drift in opposite directions.
|
|
99
|
+
* Only the auto-scroll direction changes: chevrons, wheel, drag, the seam
|
|
100
|
+
* wrap and reduced motion behave exactly as on a forward strip. */
|
|
101
|
+
reverse?: boolean;
|
|
97
102
|
/** Pause the marquee while a CARD is hovered (resumes as soon as the
|
|
98
103
|
* pointer leaves the card — strip whitespace/heading never pauses). */
|
|
99
104
|
pauseOnHover?: boolean;
|
|
@@ -221,6 +226,7 @@ export function CardsStrip<T = unknown>(props: CardsStripProps<T>): React.ReactE
|
|
|
221
226
|
headerSlot,
|
|
222
227
|
autoScroll = true,
|
|
223
228
|
autoScrollSpeed = 60,
|
|
229
|
+
reverse = false,
|
|
224
230
|
pauseOnHover = true,
|
|
225
231
|
showChevrons = true,
|
|
226
232
|
prevLabel = 'Previous items',
|
|
@@ -484,6 +490,20 @@ export function CardsStrip<T = unknown>(props: CardsStripProps<T>): React.ReactE
|
|
|
484
490
|
return Math.max(0, Math.min(200, half / 4, half - viewport - TRACK_GAP_PX - 1));
|
|
485
491
|
}, []);
|
|
486
492
|
|
|
493
|
+
// Engine position <-> scrollLeft. Forward they are the same number. Reversed,
|
|
494
|
+
// the engine still counts UP (it only knows one direction) while the scroller
|
|
495
|
+
// counts DOWN: `scrollLeft = 2*min + size - pos`, the mirror of the position
|
|
496
|
+
// inside the wrap range [min, min + size). The mirror is its own inverse, so
|
|
497
|
+
// the same function reads the scroller back into engine space.
|
|
498
|
+
const mirror = useCallback(
|
|
499
|
+
(value: number) => {
|
|
500
|
+
if (!reverse) return value;
|
|
501
|
+
const size = singleCopyWidthRef.current;
|
|
502
|
+
return size > 0 ? 2 * seamBuffer() + size - value : value;
|
|
503
|
+
},
|
|
504
|
+
[reverse, seamBuffer],
|
|
505
|
+
);
|
|
506
|
+
|
|
487
507
|
const { posRef: marqueePosRef, glideBy } = useMarqueeEngine({
|
|
488
508
|
// Viewport gates `active` (the rAF fully stops off-screen — a paused
|
|
489
509
|
// engine would keep scheduling frames forever), same treatment as
|
|
@@ -498,9 +518,9 @@ export function CardsStrip<T = unknown>(props: CardsStripProps<T>): React.ReactE
|
|
|
498
518
|
getWrapMin: seamBuffer,
|
|
499
519
|
apply: pos => {
|
|
500
520
|
const scroller = scrollerRef.current;
|
|
501
|
-
if (scroller) scroller.scrollLeft = pos;
|
|
521
|
+
if (scroller) scroller.scrollLeft = mirror(pos);
|
|
502
522
|
},
|
|
503
|
-
readBack: () => scrollerRef.current?.scrollLeft ?? 0,
|
|
523
|
+
readBack: () => mirror(scrollerRef.current?.scrollLeft ?? 0),
|
|
504
524
|
onAfterFrame: syncHoverIfScrolled,
|
|
505
525
|
});
|
|
506
526
|
|
|
@@ -596,13 +616,15 @@ export function CardsStrip<T = unknown>(props: CardsStripProps<T>): React.ReactE
|
|
|
596
616
|
if (marqueeActiveRef.current) {
|
|
597
617
|
// Wrap-aware glide via the rAF engine (see engine comment) — clicks
|
|
598
618
|
// accumulate distance instead of racing browser smooth-scroll targets.
|
|
599
|
-
|
|
619
|
+
// The glide is in ENGINE space: on a reversed strip "next" (scroller
|
|
620
|
+
// moves right) is a step BACK along the engine's axis.
|
|
621
|
+
glideBy((reverse ? -dir : dir) * step);
|
|
600
622
|
} else {
|
|
601
623
|
// No clones/seam without the marquee — native smooth scroll is safe.
|
|
602
624
|
scroller.scrollBy({ left: dir * step, behavior: 'smooth' });
|
|
603
625
|
}
|
|
604
626
|
},
|
|
605
|
-
[glideBy],
|
|
627
|
+
[glideBy, reverse],
|
|
606
628
|
);
|
|
607
629
|
|
|
608
630
|
const onUserScrollIntent = useCallback(() => {
|
|
@@ -651,13 +673,13 @@ export function CardsStrip<T = unknown>(props: CardsStripProps<T>): React.ReactE
|
|
|
651
673
|
if (sl >= half + buffer) {
|
|
652
674
|
sl -= half;
|
|
653
675
|
scroller.scrollLeft = sl;
|
|
654
|
-
marqueePosRef.current = sl;
|
|
676
|
+
marqueePosRef.current = mirror(sl);
|
|
655
677
|
} else if (sl < buffer) {
|
|
656
678
|
sl += half;
|
|
657
679
|
scroller.scrollLeft = sl;
|
|
658
|
-
marqueePosRef.current = sl;
|
|
680
|
+
marqueePosRef.current = mirror(sl);
|
|
659
681
|
}
|
|
660
|
-
}, [syncHoverIfScrolled, seamBuffer, marqueePosRef]);
|
|
682
|
+
}, [syncHoverIfScrolled, seamBuffer, marqueePosRef, mirror]);
|
|
661
683
|
|
|
662
684
|
// ---- render ----------------------------------------------------------------
|
|
663
685
|
|