import type { ExampleUsage, StoryUsage } from './types'; /** * API Design Session with Restore Points — two checkpoints between three * exchanges. Clicking a checkpoint fires `kc-select` (no detail) — the app * is responsible for slicing the message list back to that point. * * API notes (confirmed in src/elements/checkpoint.tsx): * - `label` — optional visible text beside the icon. * - `tooltip` — optional hover text. * - `variant` — 'ghost' | 'default' | 'outline' (default 'ghost'). * - `size` — 'sm' | 'md' | 'lg' | 'icon' | 'icon-sm' (default 'sm'). * - `kc-select` fires with NO detail payload — identify the checkpoint by * which handler you wired, not from the event. * - There is NO `icon` prop on `` (planned gap). For a custom * trigger icon, compose the SolidJS `CheckpointTrigger` with custom children. */ const defaultStory: StoryUsage = { intro: 'Mark a restore point between exchanges. `` draws the icon and a clickable trigger labelled by `label`, with a `tooltip` on hover, and fires `kc-select` (no detail payload) when clicked — react to it by slicing your message list back to that checkpoint. **"Restoring" is your responsibility; the element just emits an event.** There is no `icon` prop on the WC — compose the SolidJS `CheckpointTrigger` with custom children for a custom icon (see the Solid tab).', snippets: { html: ` `, react: `import { Checkpoint } from '@kitn.ai/chat/react'; export function RestorePoint() { return ( { restoreTo('API structure defined'); // roll back to this checkpoint }} /> ); }`, vue: ` `, svelte: ` `, angular: `// main.ts: import '@kitn.ai/chat/elements' before bootstrapApplication, // and add CUSTOM_ELEMENTS_SCHEMA to the component/module. import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; @Component({ selector: 'app-restore-point', standalone: true, schemas: [CUSTOM_ELEMENTS_SCHEMA], template: \` \`, }) export class RestorePointComponent { onSelect() { this.restoreTo('API structure defined'); // roll back to this checkpoint } }`, solid: `import { createSignal } from 'solid-js'; import { Checkpoint, CheckpointIcon, CheckpointTrigger } from '@kitn.ai/chat'; import { RotateCcw } from 'lucide-solid'; export function RestorePoint() { const [restoredTo, setRestoredTo] = createSignal(null); return ( // Composing the primitives lets you put a custom icon inside the trigger. setRestoredTo('API structure defined')} >
API structure defined
); }`, }, }; /** * Example: Checkpoint & Restore — mark a restore point in a conversation. The * story renders a session with two checkpoints between exchanges; clicking one * fires `kc-select` — the app slices its message list to that point. Per-story: * the Usage tab shows the snippet for the story you're on; the example-level * fields below are the fallback. * * Key gotchas: * - `kc-select` carries no detail — identify which checkpoint by which handler. * - Restoring is your state management; the element just emits the event. * - No `icon` prop on the WC; compose SolidJS primitives for custom icons. */ const checkpointRestore: ExampleUsage = { title: 'Examples/Checkpoint & Restore', ...defaultStory, // example-level fallback = the primary story stories: { 'API Design Session with Restore Points': defaultStory, }, }; export default checkpointRestore;