@thedatagrid/docs-kit 0.2.2 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @thedatagrid/docs-kit
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 48356c6: New `/showcase` subpath, for live demos on marketing pages that play by themselves and can be taken over.
8
+
9
+ - `AutomatedDemo`: runs a script that drives the live component with a fake cursor while it is in view. The first real interaction hands control to the visitor, and a "replay" pill starts the show again. It does not start on touch devices, small viewports or with reduced motion.
10
+ - The scripted cursor toolkit: `createScriptedCursor` (`moveTo`, `moveToElement`, `hover`, `click`, `drag`, `setLabel`), `sleep`, `waitFor`, `tween`, `fling`, `dispatchClickSequence`, `dispatchHover`. Everything is cancelled through one `AbortSignal`.
11
+ - `LazyShowcase`: a poster first, then the live demo, imported when its container is near the viewport and the page is idle.
12
+ - Hooks: `useInView`, `usePageVisible`, `usePrefersReducedMotion`, `useMediaQuery`.
13
+ - Styles in `@thedatagrid/docs-kit/showcase/styles.css`, themed with `--showcase-*` custom properties.
14
+
15
+ It only depends on React, and a test keeps it from importing anything else.
16
+
3
17
  ## 0.2.2
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -10,7 +10,9 @@ documentation sites:
10
10
  the product library and React;
11
11
  - **editable demos**: CodeMirror plus an in-browser esbuild-wasm rebuild of the
12
12
  demo's own files (or a remote compile server);
13
- - **CodeSandbox forks** that keep the demo's folder structure.
13
+ - **CodeSandbox forks** that keep the demo's folder structure;
14
+ - **showcase demos** for marketing pages: a scripted cursor that drives a live
15
+ component until the visitor takes over, and a poster-first lazy loader.
14
16
 
15
17
  One package, with subpath exports:
16
18
 
@@ -23,6 +25,8 @@ One package, with subpath exports:
23
25
  | `/react` | `Demo` (server component), `DemoShell` (client card), `createDemoComponents` |
24
26
  | `/react/styles.css` | the card styles (CSS custom properties) |
25
27
  | `/fork` | CodeSandbox define-API payloads |
28
+ | `/showcase` | `AutomatedDemo`, `LazyShowcase`, the scripted cursor toolkit and its hooks |
29
+ | `/showcase/styles.css` | the cursor, pill and poster styles (CSS custom properties) |
26
30
 
27
31
  ## Fences
28
32
 
@@ -219,6 +223,59 @@ with unscoped `!important` rules on `.cm-*` classes, such as
219
223
  `.cm-gutters { … !important }` written for another editor, still overrides
220
224
  them. Scope those rules to their own editor (e.g. `.sp-wrapper .cm-gutters`).
221
225
 
226
+ ## Showcase demos
227
+
228
+ `/showcase` is for a live demo on a marketing page that plays by itself and
229
+ can be taken over. It knows nothing about the product: it only needs React.
230
+ Import `@thedatagrid/docs-kit/showcase/styles.css` once.
231
+
232
+ ```tsx
233
+ 'use client';
234
+ import { AutomatedDemo, sleep, type ShowcaseScriptContext } from '@thedatagrid/docs-kit/showcase';
235
+ import '@thedatagrid/docs-kit/showcase/styles.css';
236
+
237
+ async function run({ root, cursor, signal }: ShowcaseScriptContext) {
238
+ const header = root.querySelector<HTMLElement>('[data-column="price"]')!;
239
+ await cursor.moveToElement(header, signal);
240
+ await cursor.click(signal, header); // dispatches a real pointer + click sequence
241
+ await sleep(2000, signal);
242
+ }
243
+
244
+ <AutomatedDemo ready={gridIsReady} run={run} reset={resetDemoState} waitForSelector=".grid-cell">
245
+ <LiveGrid />
246
+ </AutomatedDemo>;
247
+ ```
248
+
249
+ - `AutomatedDemo` runs `run` in a loop while the demo is in view and the tab
250
+ is visible, calling `reset` before each pass. The first real interaction
251
+ (pointer, wheel, touch or key) stops the script and leaves the demo as it
252
+ is; a "replay" pill starts it again. It never starts on touch devices, under
253
+ `minViewportWidth` (768 by default) or with reduced motion.
254
+ - Every helper takes the `signal` and throws `ScriptCancelled` when the show is
255
+ stopped, so a script needs no cleanup code. A script that throws anything
256
+ else ends the show quietly.
257
+ - The cursor: `moveTo`, `moveToElement`, `hover`, `click`, `drag`, `setLabel`.
258
+ Also exported: `sleep`, `waitFor`, `tween`, `fling` (an inertial scroll),
259
+ `dispatchClickSequence`, `dispatchHover`, and the hooks `useInView`,
260
+ `usePageVisible`, `usePrefersReducedMotion`, `useMediaQuery`.
261
+ - `LazyShowcase` paints a `poster` first, imports the live demo when its
262
+ container is near the viewport and the page is idle, and cross-fades to it
263
+ once the demo calls `onReady`. Give it a `height` (or a className that sets
264
+ one) so nothing shifts.
265
+
266
+ ```tsx
267
+ <LazyShowcase
268
+ load={() => import('./HeroDemo')}
269
+ props={{ autoplay: true }}
270
+ poster={<img src="/hero-poster.webp" alt="" />}
271
+ height={640}
272
+ />
273
+ ```
274
+
275
+ Theme it with `--showcase-accent`, `--showcase-pill-bg`, `--showcase-pill-fg`,
276
+ `--showcase-pill-border` and `--showcase-z` (the base z-index of the cursor
277
+ layer).
278
+
222
279
  ## Editor extension (VS Code, Cursor)
223
280
 
224
281
  The package includes a small extension, **docs-kit links**. In a docs page, Cmd/Ctrl+click
@@ -0,0 +1,46 @@
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
+ import { type ScriptedCursor } from './scripted.ts';
3
+ export type AutomatedDemoStatus =
4
+ /** Not animating: offscreen, before ready, or unsupported device. */
5
+ 'idle'
6
+ /** The show is running (fake cursor visible). */
7
+ | 'running'
8
+ /** The user interacted — the demo is theirs until they hit replay. */
9
+ | 'user';
10
+ export type ShowcaseScriptContext = {
11
+ /** Wrapper element containing the live demo (and its in-demo portals). */
12
+ root: HTMLElement;
13
+ cursor: ScriptedCursor;
14
+ signal: AbortSignal;
15
+ };
16
+ export type AutomatedDemoProps = {
17
+ children: ReactNode;
18
+ /** The product demo is mounted and can be driven. */
19
+ ready: boolean;
20
+ /** One full pass of the show. Must honour `signal` (use the toolkit helpers). */
21
+ run: (context: ShowcaseScriptContext) => Promise<void>;
22
+ /** Put the demo back to its initial state; called before every pass. */
23
+ reset?: (context: ShowcaseScriptContext) => void | Promise<void>;
24
+ /** Wait for this selector inside the root before the first pass. */
25
+ waitForSelector?: string;
26
+ /** Pause between passes, in ms. */
27
+ loopPause?: number;
28
+ /** No show below this viewport width (and never on touch / reduced motion). */
29
+ minViewportWidth?: number;
30
+ /** IntersectionObserver threshold for "in view". */
31
+ threshold?: number;
32
+ runningLabel?: ReactNode;
33
+ userLabel?: ReactNode;
34
+ className?: string;
35
+ style?: CSSProperties;
36
+ onStatusChange?: (status: AutomatedDemoStatus) => void;
37
+ };
38
+ /**
39
+ * Wraps a live demo in an automated show: a scripted cursor drives the LIVE
40
+ * component while it's in view, and the first real interaction (click /
41
+ * wheel / touch / key) hands control to the user instantly, leaving the demo
42
+ * where the script left it. A broken script ends quietly — it must never
43
+ * break the page.
44
+ */
45
+ export declare function AutomatedDemo({ children, ready, run, reset, waitForSelector, loopPause, minViewportWidth, threshold, runningLabel, userLabel, className, style, onStatusChange, }: AutomatedDemoProps): import("react").JSX.Element;
46
+ //# sourceMappingURL=AutomatedDemo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutomatedDemo.d.ts","sourceRoot":"","sources":["../../src/showcase/AutomatedDemo.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,mBAAmB;AAC7B,qEAAqE;AACnE,MAAM;AACR,iDAAiD;GAC/C,SAAS;AACX,sEAAsE;GACpE,MAAM,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAAG;IAClC,0EAA0E;IAC1E,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,qDAAqD;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,iFAAiF;IACjF,GAAG,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,wEAAwE;IACxE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,oEAAoE;IACpE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACxD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,KAAK,EACL,GAAG,EACH,KAAK,EACL,eAAe,EACf,SAAgB,EAChB,gBAAsB,EACtB,SAAgB,EAChB,YAAwD,EACxD,SAA+C,EAC/C,SAAS,EACT,KAAK,EACL,cAAc,GACf,EAAE,kBAAkB,+BA0LpB"}
@@ -0,0 +1,169 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useRef, useState, } from 'react';
4
+ import { canRunScriptedShow } from "./hooks.js";
5
+ import { createScriptedCursor, ScriptCancelled, sleep, waitFor, } from "./scripted.js";
6
+ /**
7
+ * Wraps a live demo in an automated show: a scripted cursor drives the LIVE
8
+ * component while it's in view, and the first real interaction (click /
9
+ * wheel / touch / key) hands control to the user instantly, leaving the demo
10
+ * where the script left it. A broken script ends quietly — it must never
11
+ * break the page.
12
+ */
13
+ export function AutomatedDemo({ children, ready, run, reset, waitForSelector, loopPause = 2600, minViewportWidth = 768, threshold = 0.35, runningLabel = 'live demo — click anywhere to take over', userLabel = 'you’re in control — replay demo ↻', className, style, onStatusChange, }) {
14
+ const wrapperRef = useRef(null);
15
+ const overlayRef = useRef(null);
16
+ const cursorRef = useRef(null);
17
+ const abortRef = useRef(null);
18
+ const intersectingRef = useRef(false);
19
+ const readyRef = useRef(ready);
20
+ const statusRef = useRef('idle');
21
+ const [status, setStatusState] = useState('idle');
22
+ // latest callbacks without restarting the observers
23
+ const runRef = useRef(run);
24
+ const resetRef = useRef(reset);
25
+ const onStatusChangeRef = useRef(onStatusChange);
26
+ runRef.current = run;
27
+ resetRef.current = reset;
28
+ onStatusChangeRef.current = onStatusChange;
29
+ const setStatus = useCallback((next) => {
30
+ statusRef.current = next;
31
+ setStatusState(next);
32
+ onStatusChangeRef.current?.(next);
33
+ }, []);
34
+ const stop = useCallback((next) => {
35
+ abortRef.current?.abort();
36
+ abortRef.current = null;
37
+ cursorRef.current?.hide();
38
+ setStatus(next);
39
+ }, [setStatus]);
40
+ const tryStart = useCallback(() => {
41
+ if (statusRef.current !== 'idle')
42
+ return;
43
+ if (!intersectingRef.current || !readyRef.current)
44
+ return;
45
+ if (document.visibilityState === 'hidden')
46
+ return;
47
+ const root = wrapperRef.current;
48
+ const overlay = overlayRef.current;
49
+ if (!root || !overlay)
50
+ return;
51
+ // the show is pointless (and annoying) on touch / small / reduced-motion
52
+ if (!canRunScriptedShow(minViewportWidth))
53
+ return;
54
+ if (!cursorRef.current)
55
+ cursorRef.current = createScriptedCursor(overlay);
56
+ const cursor = cursorRef.current;
57
+ const controller = new AbortController();
58
+ abortRef.current = controller;
59
+ setStatus('running');
60
+ void (async () => {
61
+ const { signal } = controller;
62
+ const context = { root, cursor, signal };
63
+ try {
64
+ if (waitForSelector) {
65
+ const found = await waitFor(() => root.querySelector(waitForSelector), signal, {
66
+ timeout: 20000,
67
+ });
68
+ if (!found)
69
+ throw new ScriptCancelled();
70
+ }
71
+ for (;;) {
72
+ await resetRef.current?.(context);
73
+ await sleep(700, signal);
74
+ await runRef.current(context);
75
+ cursor.hide();
76
+ await sleep(loopPause, signal);
77
+ }
78
+ }
79
+ catch (error) {
80
+ cursor.hide();
81
+ if (!(error instanceof ScriptCancelled)) {
82
+ // a broken show must never break the page — just end it quietly
83
+ console.warn('[automated-demo]', error);
84
+ if (statusRef.current === 'running')
85
+ stop('user');
86
+ }
87
+ }
88
+ })();
89
+ }, [loopPause, minViewportWidth, setStatus, stop, waitForSelector]);
90
+ useEffect(() => {
91
+ readyRef.current = ready;
92
+ if (ready)
93
+ tryStart();
94
+ else if (statusRef.current === 'running')
95
+ stop('idle');
96
+ }, [ready, tryStart, stop]);
97
+ // start/pause with viewport visibility
98
+ useEffect(() => {
99
+ const root = wrapperRef.current;
100
+ if (!root)
101
+ return;
102
+ const observer = new IntersectionObserver((entries) => {
103
+ const isIntersecting = entries.some((entry) => entry.isIntersecting);
104
+ intersectingRef.current = isIntersecting;
105
+ if (isIntersecting)
106
+ tryStart();
107
+ else if (statusRef.current === 'running')
108
+ stop('idle');
109
+ }, { threshold });
110
+ observer.observe(root);
111
+ return () => observer.disconnect();
112
+ }, [threshold, tryStart, stop]);
113
+ // a hidden tab is as good as off-screen
114
+ useEffect(() => {
115
+ const onVisibility = () => {
116
+ if (document.visibilityState === 'hidden') {
117
+ if (statusRef.current === 'running')
118
+ stop('idle');
119
+ }
120
+ else {
121
+ tryStart();
122
+ }
123
+ };
124
+ document.addEventListener('visibilitychange', onVisibility);
125
+ return () => document.removeEventListener('visibilitychange', onVisibility);
126
+ }, [tryStart, stop]);
127
+ // first REAL interaction anywhere on the demo = takeover. The script's own
128
+ // dispatched events are untrusted, which is how we tell them apart.
129
+ useEffect(() => {
130
+ const root = wrapperRef.current;
131
+ if (!root)
132
+ return;
133
+ const onInteract = (event) => {
134
+ if (!event.isTrusted)
135
+ return;
136
+ if (statusRef.current === 'running')
137
+ stop('user');
138
+ // touched before the show got going: don't start it under the user
139
+ else if (statusRef.current === 'idle' &&
140
+ canRunScriptedShow(minViewportWidth)) {
141
+ stop('user');
142
+ }
143
+ };
144
+ const events = ['pointerdown', 'wheel', 'touchstart', 'keydown'];
145
+ for (const type of events) {
146
+ root.addEventListener(type, onInteract, { capture: true, passive: true });
147
+ }
148
+ return () => {
149
+ for (const type of events)
150
+ root.removeEventListener(type, onInteract, { capture: true });
151
+ };
152
+ }, [stop, minViewportWidth]);
153
+ useEffect(() => {
154
+ return () => {
155
+ abortRef.current?.abort();
156
+ cursorRef.current?.destroy();
157
+ cursorRef.current = null;
158
+ };
159
+ }, []);
160
+ const replay = useCallback(() => {
161
+ if (statusRef.current === 'running')
162
+ return;
163
+ setStatus('idle');
164
+ // let the status flip settle before the loop re-checks it
165
+ requestAnimationFrame(() => tryStart());
166
+ }, [setStatus, tryStart]);
167
+ return (_jsxs("div", { ref: wrapperRef, className: ['showcase-demo', className].filter(Boolean).join(' '), "data-showcase-status": status, style: style, children: [children, _jsx("div", { ref: overlayRef, "aria-hidden": true, className: "showcase-demo__overlay" }), status === 'running' ? (_jsxs("div", { className: "showcase-pill showcase-pill--running", role: "status", children: [_jsx("span", { className: "showcase-pill__dot" }), runningLabel] })) : null, status === 'user' ? (_jsx("button", { type: "button", onClick: replay, className: "showcase-pill showcase-pill--user", children: userLabel })) : null] }));
168
+ }
169
+ //# sourceMappingURL=AutomatedDemo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutomatedDemo.js","sourceRoot":"","sources":["../../src/showcase/AutomatedDemo.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,KAAK,EACL,OAAO,GAER,MAAM,eAAe,CAAC;AAwCvB;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,KAAK,EACL,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IAEP,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,SAAS,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO;QAC5C,SAAS,CAAC,MAAM,CAAC,CAAC;QAClB,0DAA0D;QAC1D,qBAAqB,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE1B,OAAO,CACL,eACE,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,0BAC3C,MAAM,EAC5B,KAAK,EAAE,KAAK,aAEX,QAAQ,EAET,cAAK,GAAG,EAAE,UAAU,uBAAc,SAAS,EAAC,wBAAwB,GAAG,EACtE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CACtB,eAAK,SAAS,EAAC,sCAAsC,EAAC,IAAI,EAAC,QAAQ,aACjE,eAAM,SAAS,EAAC,oBAAoB,GAAG,EACtC,YAAY,IACT,CACP,CAAC,CAAC,CAAC,IAAI,EACP,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CACnB,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,MAAM,EACf,SAAS,EAAC,mCAAmC,YAE5C,SAAS,GACH,CACV,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { type ComponentType, type CSSProperties, type ReactNode } from 'react';
2
+ export type LazyShowcaseLoadedProps = {
3
+ /** Call once the live demo has painted its real content. */
4
+ onReady?: () => void;
5
+ };
6
+ export type LazyShowcaseProps<P extends object> = {
7
+ /** Dynamic import of the live demo, e.g. `() => import('./HeroDemo')`. */
8
+ load: () => Promise<{
9
+ default: ComponentType<P & LazyShowcaseLoadedProps>;
10
+ }>;
11
+ props: P;
12
+ /** Static first paint (an <img> screenshot, a skeleton…). Fades out once live. */
13
+ poster: ReactNode;
14
+ /**
15
+ * Fixed height, so swapping poster → live never shifts layout. Omit it when
16
+ * `className` sets a (responsive) height instead.
17
+ */
18
+ height?: number | string;
19
+ /** Start loading this far before the container scrolls into view. */
20
+ rootMargin?: string;
21
+ className?: string;
22
+ style?: CSSProperties;
23
+ };
24
+ /**
25
+ * Poster first, live demo later: the import starts when the container is
26
+ * near the viewport AND the main thread is idle, and the live demo cross-fades
27
+ * in over the poster once it reports `onReady`. Height is fixed up front, so
28
+ * there is no layout shift.
29
+ */
30
+ export declare function LazyShowcase<P extends object>({ load, props, poster, height, rootMargin, className, style, }: LazyShowcaseProps<P>): import("react").JSX.Element;
31
+ //# sourceMappingURL=LazyShowcase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LazyShowcase.d.ts","sourceRoot":"","sources":["../../src/showcase/LazyShowcase.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,uBAAuB,GAAG;IACpC,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,MAAM,IAAI;IAChD,0EAA0E;IAC1E,IAAI,EAAE,MAAM,OAAO,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAA;KAAE,CAAC,CAAC;IAC7E,KAAK,EAAE,CAAC,CAAC;IACT,kFAAkF;IAClF,MAAM,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,EAC7C,IAAI,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EACN,UAAoB,EACpB,SAAS,EACT,KAAK,GACN,EAAE,iBAAiB,CAAC,CAAC,CAAC,+BA6DtB"}
@@ -0,0 +1,51 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState, } from 'react';
4
+ import { whenIdle } from "./hooks.js";
5
+ /**
6
+ * Poster first, live demo later: the import starts when the container is
7
+ * near the viewport AND the main thread is idle, and the live demo cross-fades
8
+ * in over the poster once it reports `onReady`. Height is fixed up front, so
9
+ * there is no layout shift.
10
+ */
11
+ export function LazyShowcase({ load, props, poster, height, rootMargin = '200px', className, style, }) {
12
+ const ref = useRef(null);
13
+ const loadRef = useRef(load);
14
+ loadRef.current = load;
15
+ const [Live, setLive] = useState(null);
16
+ const [ready, setReady] = useState(false);
17
+ const [failed, setFailed] = useState(false);
18
+ useEffect(() => {
19
+ const node = ref.current;
20
+ if (!node)
21
+ return;
22
+ let cancelIdle;
23
+ let disposed = false;
24
+ const observer = new IntersectionObserver((entries) => {
25
+ if (!entries.some((entry) => entry.isIntersecting))
26
+ return;
27
+ observer.disconnect();
28
+ cancelIdle = whenIdle(() => {
29
+ loadRef
30
+ .current()
31
+ .then((mod) => {
32
+ if (!disposed)
33
+ setLive(() => mod.default);
34
+ })
35
+ .catch((error) => {
36
+ console.warn('[lazy-showcase] failed to load the live demo', error);
37
+ if (!disposed)
38
+ setFailed(true);
39
+ });
40
+ });
41
+ }, { rootMargin });
42
+ observer.observe(node);
43
+ return () => {
44
+ disposed = true;
45
+ observer.disconnect();
46
+ cancelIdle?.();
47
+ };
48
+ }, [rootMargin]);
49
+ return (_jsxs("div", { ref: ref, className: ['showcase-lazy', className].filter(Boolean).join(' '), style: { height, ...style }, "data-showcase-ready": ready ? 'true' : 'false', children: [_jsx("div", { className: "showcase-lazy__poster", "aria-hidden": ready, children: poster }), Live && !failed ? (_jsx("div", { className: "showcase-lazy__live", children: _jsx(Live, { ...props, onReady: () => setReady(true) }) })) : null] }));
50
+ }
51
+ //# sourceMappingURL=LazyShowcase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LazyShowcase.js","sourceRoot":"","sources":["../../src/showcase/LazyShowcase.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,SAAS,EACT,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAwBtC;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAmB,EAC7C,IAAI,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EACN,UAAU,GAAG,OAAO,EACpB,SAAS,EACT,KAAK,GACgB;IACrB,MAAM,GAAG,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAEtB,IAAI,CAAC,CAAC;IAChB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC;QACzB,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,IAAI,UAAoC,CAAC;QACzC,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,CAAC,OAAO,EAAE,EAAE;YACV,IAAI,CAAC,OAAO,CAAC,IAAI,CAA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qBAAqB,YAClC,KAAC,IAAI,OAAK,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAI,GAC9C,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type RefObject } from 'react';
2
+ /** Subscribes to a media query; `false` during SSR. */
3
+ export declare function useMediaQuery(query: string): boolean;
4
+ export declare function usePrefersReducedMotion(): boolean;
5
+ /** `true` while the document is visible (tab focused / not minimized). */
6
+ export declare function usePageVisible(): boolean;
7
+ /** `true` while any part of the element (by `threshold`) is in the viewport. */
8
+ export declare function useInView(ref: RefObject<Element | null>, { threshold, rootMargin, }?: {
9
+ threshold?: number;
10
+ rootMargin?: string;
11
+ }): boolean;
12
+ /**
13
+ * Should a scripted show run on this device at all? Not on touch-only
14
+ * devices, small viewports, or with reduced motion.
15
+ */
16
+ export declare function canRunScriptedShow(minViewportWidth?: number): boolean;
17
+ /** requestIdleCallback with a timeout fallback (Safari has no rIC). */
18
+ export declare function whenIdle(callback: () => void, timeout?: number): () => void;
19
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/showcase/hooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,WAU1C;AAED,wBAAgB,uBAAuB,YAEtC;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,YAS7B;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CACvB,GAAG,EAAE,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,EAC9B,EACE,SAAa,EACb,UAAkB,GACnB,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,WAcpD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,gBAAgB,SAAM,WAOxD;AAED,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,SAAO,cAc5D"}
@@ -0,0 +1,63 @@
1
+ 'use client';
2
+ import { useEffect, useState } from 'react';
3
+ /** Subscribes to a media query; `false` during SSR. */
4
+ export function useMediaQuery(query) {
5
+ const [matches, setMatches] = useState(false);
6
+ useEffect(() => {
7
+ const mql = window.matchMedia(query);
8
+ const update = () => setMatches(mql.matches);
9
+ update();
10
+ mql.addEventListener('change', update);
11
+ return () => mql.removeEventListener('change', update);
12
+ }, [query]);
13
+ return matches;
14
+ }
15
+ export function usePrefersReducedMotion() {
16
+ return useMediaQuery('(prefers-reduced-motion: reduce)');
17
+ }
18
+ /** `true` while the document is visible (tab focused / not minimized). */
19
+ export function usePageVisible() {
20
+ const [visible, setVisible] = useState(true);
21
+ useEffect(() => {
22
+ const update = () => setVisible(document.visibilityState !== 'hidden');
23
+ update();
24
+ document.addEventListener('visibilitychange', update);
25
+ return () => document.removeEventListener('visibilitychange', update);
26
+ }, []);
27
+ return visible;
28
+ }
29
+ /** `true` while any part of the element (by `threshold`) is in the viewport. */
30
+ export function useInView(ref, { threshold = 0, rootMargin = '0px', } = {}) {
31
+ const [inView, setInView] = useState(false);
32
+ useEffect(() => {
33
+ const node = ref.current;
34
+ if (!node)
35
+ return;
36
+ const observer = new IntersectionObserver((entries) => setInView(entries.some((entry) => entry.isIntersecting)), { threshold, rootMargin });
37
+ observer.observe(node);
38
+ return () => observer.disconnect();
39
+ }, [ref, threshold, rootMargin]);
40
+ return inView;
41
+ }
42
+ /**
43
+ * Should a scripted show run on this device at all? Not on touch-only
44
+ * devices, small viewports, or with reduced motion.
45
+ */
46
+ export function canRunScriptedShow(minViewportWidth = 768) {
47
+ if (typeof window === 'undefined')
48
+ return false;
49
+ return (window.matchMedia('(pointer: fine)').matches &&
50
+ !window.matchMedia('(prefers-reduced-motion: reduce)').matches &&
51
+ window.innerWidth >= minViewportWidth);
52
+ }
53
+ /** requestIdleCallback with a timeout fallback (Safari has no rIC). */
54
+ export function whenIdle(callback, timeout = 1500) {
55
+ const w = window;
56
+ if (w.requestIdleCallback) {
57
+ const id = w.requestIdleCallback(callback, { timeout });
58
+ return () => w.cancelIdleCallback?.(id);
59
+ }
60
+ const id = window.setTimeout(callback, Math.min(timeout, 300));
61
+ return () => window.clearTimeout(id);
62
+ }
63
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/showcase/hooks.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAE5D,uDAAuD;AACvD,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7C,MAAM,EAAE,CAAC;QACT,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACvC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,OAAO,aAAa,CAAC,kCAAkC,CAAC,CAAC;AAC3D,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,cAAc;IAC5B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC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;IACvD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IAChD,OAAO,CACL,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,OAAO;QAC5C,CAAC,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO;QAC9D,MAAM,CAAC,UAAU,IAAI,gBAAgB,CACtC,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,QAAQ,CAAC,QAAoB,EAAE,OAAO,GAAG,IAAI;IAC3D,MAAM,CAAC,GAAG,MAMT,CAAC;IACF,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;QAC1B,MAAM,EAAE,GAAG,CAAC,CAAC,mBAAmB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACxD,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/D,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Showcase kit: product-agnostic building blocks for live, scripted
3
+ * marketing demos — a fake cursor toolkit, the automated "take over" shell,
4
+ * and a poster-first lazy loader.
5
+ *
6
+ * BOUNDARY RULE: nothing in this folder may import product code or the rest
7
+ * of the kit — only React and sibling files (test/showcase.test.ts checks it).
8
+ *
9
+ * Styles: import `@thedatagrid/docs-kit/showcase/styles.css` once.
10
+ */
11
+ export * from './scripted.ts';
12
+ export * from './hooks.ts';
13
+ export { AutomatedDemo } from './AutomatedDemo.tsx';
14
+ export type { AutomatedDemoProps, AutomatedDemoStatus, ShowcaseScriptContext, } from './AutomatedDemo.tsx';
15
+ export { LazyShowcase } from './LazyShowcase.tsx';
16
+ export type { LazyShowcaseProps, LazyShowcaseLoadedProps, } from './LazyShowcase.tsx';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/showcase/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EACV,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Showcase kit: product-agnostic building blocks for live, scripted
3
+ * marketing demos — a fake cursor toolkit, the automated "take over" shell,
4
+ * and a poster-first lazy loader.
5
+ *
6
+ * BOUNDARY RULE: nothing in this folder may import product code or the rest
7
+ * of the kit — only React and sibling files (test/showcase.test.ts checks it).
8
+ *
9
+ * Styles: import `@thedatagrid/docs-kit/showcase/styles.css` once.
10
+ */
11
+ export * from "./scripted.js";
12
+ export * from "./hooks.js";
13
+ export { AutomatedDemo } from "./AutomatedDemo.js";
14
+ export { LazyShowcase } from "./LazyShowcase.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/showcase/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AAMpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAoB,CAAC"}