@particle-academy/react-fancy 3.0.1 → 3.2.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/README.md +11 -0
- package/dist/index.cjs +1283 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +430 -2
- package/dist/index.d.ts +430 -2
- package/dist/index.js +1274 -3
- package/dist/index.js.map +1 -1
- package/docs/ChatDrawer.md +75 -0
- package/docs/InputTag.md +155 -0
- package/docs/MagicWand.md +65 -0
- package/docs/MoodMeter.md +63 -0
- package/docs/PromptInput.md +70 -0
- package/docs/ReasonTag.md +63 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, HTMLAttributes, ComponentType, ReactElement, RefObject } from 'react';
|
|
2
|
+
import { ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, HTMLAttributes, ComponentType, ReactElement, RefObject, CSSProperties } from 'react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ClassValue } from 'clsx';
|
|
5
5
|
|
|
@@ -2385,4 +2385,432 @@ interface UseNodeRegistryReturn {
|
|
|
2385
2385
|
}
|
|
2386
2386
|
declare function useNodeRegistry(): UseNodeRegistryReturn;
|
|
2387
2387
|
|
|
2388
|
-
|
|
2388
|
+
/**
|
|
2389
|
+
* ReasonTag — wraps any value with a small affordance that reveals the
|
|
2390
|
+
* agent's reasoning, sources, and confidence on hover or click.
|
|
2391
|
+
*
|
|
2392
|
+
* <ReasonTag
|
|
2393
|
+
* value="$1.4M"
|
|
2394
|
+
* reason="Projected Q3 ARR after stacking renewals."
|
|
2395
|
+
* confidence={0.91}
|
|
2396
|
+
* sources={[{ label: "Q2 actuals · CRM export" }]}
|
|
2397
|
+
* by="Forecaster"
|
|
2398
|
+
* />
|
|
2399
|
+
*
|
|
2400
|
+
* Three visual styles:
|
|
2401
|
+
* • "dot" — value with a tiny coloured dot (default, subtle)
|
|
2402
|
+
* • "underline" — dotted underline + trailing "?"
|
|
2403
|
+
* • "chip" — full coloured pill (loud)
|
|
2404
|
+
*
|
|
2405
|
+
* Confidence drives the colour via three tiers (high / medium / low),
|
|
2406
|
+
* so a quick visual scan tells the human which suggestions deserve a
|
|
2407
|
+
* second look without opening any tooltips.
|
|
2408
|
+
*
|
|
2409
|
+
* `pinned` swaps the popover for an inline annotation slot — useful
|
|
2410
|
+
* when explainability should always be visible, not buried in a hover.
|
|
2411
|
+
*/
|
|
2412
|
+
type ReasonTagSource = {
|
|
2413
|
+
label: string;
|
|
2414
|
+
href?: string;
|
|
2415
|
+
};
|
|
2416
|
+
type ReasonTagTheme = "dot" | "underline" | "chip";
|
|
2417
|
+
interface ReasonTagProps {
|
|
2418
|
+
/** The value the tag wraps — usually a number, label, or short phrase. */
|
|
2419
|
+
value: React.ReactNode;
|
|
2420
|
+
/** Free-text rationale shown in the popover / inline annotation. */
|
|
2421
|
+
reason: string;
|
|
2422
|
+
/** 0..1 confidence. Drives the tier colour. Defaults to 1. */
|
|
2423
|
+
confidence?: number;
|
|
2424
|
+
/** Optional list of sources (label + optional href). */
|
|
2425
|
+
sources?: ReasonTagSource[];
|
|
2426
|
+
/** Optional author / agent name shown in the popover header. */
|
|
2427
|
+
by?: string;
|
|
2428
|
+
/** Visual treatment for the trigger. */
|
|
2429
|
+
theme?: ReasonTagTheme;
|
|
2430
|
+
/**
|
|
2431
|
+
* When true, the popover is replaced with an always-visible inline
|
|
2432
|
+
* annotation below the value.
|
|
2433
|
+
*/
|
|
2434
|
+
pinned?: boolean;
|
|
2435
|
+
/** Called when the user hits the "ask follow-up" action. */
|
|
2436
|
+
onFollowUp?: () => void;
|
|
2437
|
+
/** Optional className applied to the trigger element. */
|
|
2438
|
+
className?: string;
|
|
2439
|
+
}
|
|
2440
|
+
declare function ReasonTag({ value, reason, confidence, sources, by, theme, pinned, onFollowUp, className, }: ReasonTagProps): react_jsx_runtime.JSX.Element;
|
|
2441
|
+
|
|
2442
|
+
/**
|
|
2443
|
+
* MoodMeter — a 2D draggable pad that captures a value AND the
|
|
2444
|
+
* confidence in that value on the same handle.
|
|
2445
|
+
*
|
|
2446
|
+
* <MoodMeter
|
|
2447
|
+
* min={0} max={1}
|
|
2448
|
+
* value={value} confidence={confidence}
|
|
2449
|
+
* onChange={(v, c) => { setValue(v); setConfidence(c); }}
|
|
2450
|
+
* />
|
|
2451
|
+
*
|
|
2452
|
+
* • x-axis maps to [min..max]
|
|
2453
|
+
* • y-axis maps to [0..1] confidence (top = sure)
|
|
2454
|
+
* • the halo around the handle scales inversely with confidence —
|
|
2455
|
+
* uncertain readings literally look fuzzier
|
|
2456
|
+
*
|
|
2457
|
+
* Why pair them in one control? When AIs post a number, humans
|
|
2458
|
+
* immediately ask "how sure are you?". Making confidence an explicit
|
|
2459
|
+
* sibling of value — and letting the user drag either independently —
|
|
2460
|
+
* turns vague "AI suggestion" UX into something you can argue with
|
|
2461
|
+
* precisely.
|
|
2462
|
+
*
|
|
2463
|
+
* The agent's posted value/confidence renders as a dashed ghost
|
|
2464
|
+
* handle alongside the live user handle, so the human can see where
|
|
2465
|
+
* the agent landed and how far they've drifted.
|
|
2466
|
+
*/
|
|
2467
|
+
interface MoodMeterProps {
|
|
2468
|
+
/** Range minimum. */
|
|
2469
|
+
min: number;
|
|
2470
|
+
/** Range maximum. */
|
|
2471
|
+
max: number;
|
|
2472
|
+
/** Step for value snapping. Defaults to (max-min)/100. */
|
|
2473
|
+
step?: number;
|
|
2474
|
+
/** Current value (controlled). */
|
|
2475
|
+
value: number;
|
|
2476
|
+
/** Current confidence 0..1 (controlled). */
|
|
2477
|
+
confidence: number;
|
|
2478
|
+
/** Called with (value, confidence) on drag / pointer events. */
|
|
2479
|
+
onChange: (value: number, confidence: number) => void;
|
|
2480
|
+
/** Optional agent post — renders as a dashed ghost handle. */
|
|
2481
|
+
posted?: {
|
|
2482
|
+
value: number;
|
|
2483
|
+
confidence: number;
|
|
2484
|
+
};
|
|
2485
|
+
/** Pixel width of the pad. Defaults to 320. */
|
|
2486
|
+
width?: number;
|
|
2487
|
+
/** Pixel height of the pad. Defaults to 220. */
|
|
2488
|
+
height?: number;
|
|
2489
|
+
/** Show the grid + axis labels. Defaults to true. */
|
|
2490
|
+
showGrid?: boolean;
|
|
2491
|
+
/** Color of the user handle. Defaults to sky blue. */
|
|
2492
|
+
color?: string;
|
|
2493
|
+
/** Color of the posted-ghost handle. Defaults to violet. */
|
|
2494
|
+
postedColor?: string;
|
|
2495
|
+
/** Optional prefix for the value label (e.g. "$"). */
|
|
2496
|
+
prefix?: string;
|
|
2497
|
+
/** Optional suffix for the value label (e.g. "k", "%"). */
|
|
2498
|
+
suffix?: string;
|
|
2499
|
+
/** Optional label text override. Falls back to formatted value. */
|
|
2500
|
+
formatValue?: (v: number) => string;
|
|
2501
|
+
/** Optional className applied to the outer pad. */
|
|
2502
|
+
className?: string;
|
|
2503
|
+
}
|
|
2504
|
+
declare function MoodMeter({ min, max, step, value, confidence, onChange, posted, width, height, showGrid, color, postedColor, prefix, suffix, formatValue, className, }: MoodMeterProps): react_jsx_runtime.JSX.Element;
|
|
2505
|
+
|
|
2506
|
+
/**
|
|
2507
|
+
* PromptInput — the chat composer every AI app rebuilds. Auto-growing
|
|
2508
|
+
* multi-line input with:
|
|
2509
|
+
*
|
|
2510
|
+
* • slash-command picker (`/` triggers a filtered command palette,
|
|
2511
|
+
* ↑/↓ navigate, Enter inserts)
|
|
2512
|
+
* • mention picker (`@` triggers, filtered against `mentions`)
|
|
2513
|
+
* • drop-to-attach (drag files anywhere on the surface) + chip bar
|
|
2514
|
+
* • submit on ⌘/Ctrl+Enter (plain Enter inserts a newline)
|
|
2515
|
+
* • live token-budget meter (green → amber → red as headroom drops)
|
|
2516
|
+
*
|
|
2517
|
+
* Wire it up:
|
|
2518
|
+
*
|
|
2519
|
+
* <PromptInput
|
|
2520
|
+
* budgetTokens={32000}
|
|
2521
|
+
* commands={[{ name: "/rewrite", hint: "rewrite the selection" }]}
|
|
2522
|
+
* mentions={[{ id: "ada", name: "Ada", kind: "person" }]}
|
|
2523
|
+
* onSubmit={(text, attachments) => sendToAgent(text, attachments)}
|
|
2524
|
+
* />
|
|
2525
|
+
*/
|
|
2526
|
+
type PromptCmd = {
|
|
2527
|
+
name: string;
|
|
2528
|
+
hint: string;
|
|
2529
|
+
};
|
|
2530
|
+
type PromptMention = {
|
|
2531
|
+
id: string;
|
|
2532
|
+
name: string;
|
|
2533
|
+
kind: "agent" | "file" | "person" | string;
|
|
2534
|
+
};
|
|
2535
|
+
type PromptAttachment = {
|
|
2536
|
+
id: string;
|
|
2537
|
+
name: string;
|
|
2538
|
+
bytes: number;
|
|
2539
|
+
};
|
|
2540
|
+
interface PromptInputProps {
|
|
2541
|
+
/** Token budget for the meter. */
|
|
2542
|
+
budgetTokens: number;
|
|
2543
|
+
/** Slash-commands. Names must start with `/`. */
|
|
2544
|
+
commands?: PromptCmd[];
|
|
2545
|
+
/** @-mentions. */
|
|
2546
|
+
mentions?: PromptMention[];
|
|
2547
|
+
/** Show the keyboard hint ("⌘ + Enter to send"). */
|
|
2548
|
+
showHint?: boolean;
|
|
2549
|
+
/** Called on ⌘/Ctrl+Enter or send button. */
|
|
2550
|
+
onSubmit: (text: string, attachments: PromptAttachment[]) => void;
|
|
2551
|
+
/** Placeholder text. */
|
|
2552
|
+
placeholder?: string;
|
|
2553
|
+
/** Rough estimator: chars-per-token. Defaults to 4. */
|
|
2554
|
+
charsPerToken?: number;
|
|
2555
|
+
/** Color → CSS chip mapping for mention kinds. */
|
|
2556
|
+
mentionColor?: Record<string, string>;
|
|
2557
|
+
/** Optional max textarea height in px. Defaults to 280. */
|
|
2558
|
+
maxHeight?: number;
|
|
2559
|
+
/**
|
|
2560
|
+
* Rendered INSIDE the rounded shell, ABOVE the attachments bar and
|
|
2561
|
+
* textarea. Use this slot for a drawer of tools/files/prompts/etc. so
|
|
2562
|
+
* the drawer and composer share one visual panel. See {@link ChatDrawer}.
|
|
2563
|
+
*/
|
|
2564
|
+
aboveInput?: ReactNode;
|
|
2565
|
+
}
|
|
2566
|
+
declare function PromptInput({ budgetTokens, commands, mentions, showHint, onSubmit, placeholder, charsPerToken, mentionColor, maxHeight, aboveInput, }: PromptInputProps): react_jsx_runtime.JSX.Element;
|
|
2567
|
+
|
|
2568
|
+
/**
|
|
2569
|
+
* ChatDrawer — tabbed, collapsible panel that sits *above* a `PromptInput`
|
|
2570
|
+
* (via the input's `aboveInput` slot) so the drawer and composer share one
|
|
2571
|
+
* rounded shell. Each tab gets a numbered chip and a content panel; only
|
|
2572
|
+
* one panel renders at a time.
|
|
2573
|
+
*
|
|
2574
|
+
* <PromptInput
|
|
2575
|
+
* aboveInput={
|
|
2576
|
+
* <ChatDrawer
|
|
2577
|
+
* tabs={[
|
|
2578
|
+
* { id: "files", label: "Files" },
|
|
2579
|
+
* { id: "tools", label: "Chat Tools" },
|
|
2580
|
+
* { id: "prompts", label: "Chat Prompts" },
|
|
2581
|
+
* { id: "deal", label: "IBM Analytics Platform" },
|
|
2582
|
+
* ]}
|
|
2583
|
+
* activeTabId={tab}
|
|
2584
|
+
* onTabChange={setTab}
|
|
2585
|
+
* open={open}
|
|
2586
|
+
* onToggle={setOpen}
|
|
2587
|
+
* >
|
|
2588
|
+
* {tab === "tools" && <ToolsGrid />}
|
|
2589
|
+
* {tab === "deal" && <DealCard />}
|
|
2590
|
+
* </ChatDrawer>
|
|
2591
|
+
* }
|
|
2592
|
+
* budgetTokens={200_000}
|
|
2593
|
+
* onSubmit={(text) => send(text)}
|
|
2594
|
+
* />
|
|
2595
|
+
*
|
|
2596
|
+
* The drawer is purely presentational and slot-driven — you decide what
|
|
2597
|
+
* each tab shows. Tab order in the numbered chips is the order you pass.
|
|
2598
|
+
*/
|
|
2599
|
+
type ChatDrawerTab = {
|
|
2600
|
+
/** Stable id — used as the React key and as `activeTabId`. */
|
|
2601
|
+
id: string;
|
|
2602
|
+
/** Human label rendered on the chip. */
|
|
2603
|
+
label: string;
|
|
2604
|
+
/**
|
|
2605
|
+
* Optional override for the numbered prefix (defaults to position +1).
|
|
2606
|
+
* Set to `null` to hide the number entirely (e.g. for a context-specific
|
|
2607
|
+
* tab like the deal one in the screenshots).
|
|
2608
|
+
*/
|
|
2609
|
+
number?: number | null;
|
|
2610
|
+
};
|
|
2611
|
+
interface ChatDrawerProps {
|
|
2612
|
+
tabs: ChatDrawerTab[];
|
|
2613
|
+
activeTabId: string;
|
|
2614
|
+
onTabChange: (id: string) => void;
|
|
2615
|
+
/** Body open/closed. Default true. */
|
|
2616
|
+
open?: boolean;
|
|
2617
|
+
/** Called when the chevron is clicked. */
|
|
2618
|
+
onToggle?: (open: boolean) => void;
|
|
2619
|
+
/** Body content for the active tab. */
|
|
2620
|
+
children?: ReactNode;
|
|
2621
|
+
/** Min height of the body when open, in px. Default 140. */
|
|
2622
|
+
minBodyHeight?: number;
|
|
2623
|
+
className?: string;
|
|
2624
|
+
}
|
|
2625
|
+
declare function ChatDrawer({ tabs, activeTabId, onTabChange, open, onToggle, children, minBodyHeight, className, }: ChatDrawerProps): react_jsx_runtime.JSX.Element;
|
|
2626
|
+
|
|
2627
|
+
/**
|
|
2628
|
+
* InputTag — attach a `/`-style or `@`-style autocomplete picker to *any*
|
|
2629
|
+
* text surface (a `<textarea>`, an `<input>`, a `contenteditable`, a code
|
|
2630
|
+
* editor, a sheet cell editor, a whiteboard sticky note…) via an adapter
|
|
2631
|
+
* that abstracts the surface's read/write/caret API.
|
|
2632
|
+
*
|
|
2633
|
+
* The component is "headless" in the sense that it has no input of its
|
|
2634
|
+
* own — it floats a small picker menu near the surface and writes back
|
|
2635
|
+
* through the adapter when the user picks an item.
|
|
2636
|
+
*
|
|
2637
|
+
* <textarea ref={ref} value={text} onChange={...} />
|
|
2638
|
+
* <InputTag
|
|
2639
|
+
* adapter={textareaAdapter(ref)}
|
|
2640
|
+
* triggers={{
|
|
2641
|
+
* "/": { items: commands, insert: (c) => `${c.name} ` },
|
|
2642
|
+
* "@": { items: mentions, insert: (m) => `@${m.name} ` },
|
|
2643
|
+
* }}
|
|
2644
|
+
* />
|
|
2645
|
+
*
|
|
2646
|
+
* For non-DOM surfaces, write a small adapter that conforms to
|
|
2647
|
+
* {@link InputTagAdapter}. Adapters typically run 20–40 lines.
|
|
2648
|
+
*/
|
|
2649
|
+
/** What the surface tells the picker on every text/caret change. */
|
|
2650
|
+
type InputTagAdapterState = {
|
|
2651
|
+
text: string;
|
|
2652
|
+
caretIndex: number;
|
|
2653
|
+
};
|
|
2654
|
+
/**
|
|
2655
|
+
* The contract every input surface implements. The picker subscribes to
|
|
2656
|
+
* state changes, anchors itself using `getAnchorRect`, intercepts
|
|
2657
|
+
* navigation keys via `onKey`, and writes the selected item back through
|
|
2658
|
+
* `replaceRange`.
|
|
2659
|
+
*/
|
|
2660
|
+
type InputTagAdapter = {
|
|
2661
|
+
/** Push current state whenever text or caret changes. Returns an unsubscribe. */
|
|
2662
|
+
subscribe: (fn: (state: InputTagAdapterState) => void) => () => void;
|
|
2663
|
+
/** Replace text in `[start, end)` with `replacement`. The adapter is
|
|
2664
|
+
* responsible for moving the caret to the end of the inserted text. */
|
|
2665
|
+
replaceRange: (start: number, end: number, replacement: string) => void;
|
|
2666
|
+
/** Screen-space rect to anchor the picker against. Usually the surface's
|
|
2667
|
+
* bounding rect; for editors that can compute caret-precise coordinates,
|
|
2668
|
+
* return a small rect there instead. */
|
|
2669
|
+
getAnchorRect: () => DOMRect | null;
|
|
2670
|
+
/** Subscribe to keydown events on the surface. The handler may return
|
|
2671
|
+
* `true` to consume the event (the adapter then calls
|
|
2672
|
+
* `preventDefault` / `stopPropagation`). Returns an unsubscribe. */
|
|
2673
|
+
onKey: (handler: (e: KeyboardEvent) => boolean) => () => void;
|
|
2674
|
+
};
|
|
2675
|
+
/**
|
|
2676
|
+
* Per-trigger configuration. `T` is the item shape — typically a
|
|
2677
|
+
* `{ id, name, ... }` object, but any shape works as long as `keyOf` /
|
|
2678
|
+
* `insert` know how to handle it.
|
|
2679
|
+
*/
|
|
2680
|
+
type InputTagTrigger<T> = {
|
|
2681
|
+
/** The pool the picker filters against. */
|
|
2682
|
+
items: T[];
|
|
2683
|
+
/** Text inserted in place of `<triggerChar><query>`. */
|
|
2684
|
+
insert: (item: T, query: string) => string;
|
|
2685
|
+
/** Custom filter. Default: case-insensitive prefix match against
|
|
2686
|
+
* `String(keyOf(item))`. Pass `() => true` to disable filtering and
|
|
2687
|
+
* rely on `items` being pre-filtered (e.g. from an async source). */
|
|
2688
|
+
filter?: (item: T, query: string) => boolean;
|
|
2689
|
+
/** How to render each row. Default renders the result of `keyOf(item)`. */
|
|
2690
|
+
render?: (item: T, active: boolean) => ReactNode;
|
|
2691
|
+
/** How to derive a stable key + default label for each item. Default
|
|
2692
|
+
* reads `item.name` then `item.id` then `String(item)`. */
|
|
2693
|
+
keyOf?: (item: T) => string;
|
|
2694
|
+
/** Optional header label shown above the list. */
|
|
2695
|
+
label?: string;
|
|
2696
|
+
};
|
|
2697
|
+
type InputTagTriggers = Record<string, InputTagTrigger<any>>;
|
|
2698
|
+
interface InputTagProps {
|
|
2699
|
+
adapter: InputTagAdapter;
|
|
2700
|
+
triggers: InputTagTriggers;
|
|
2701
|
+
/** Max rows shown. Default 8. */
|
|
2702
|
+
maxItems?: number;
|
|
2703
|
+
/** Where the picker anchors relative to the surface. Default `"bottom-left"`. */
|
|
2704
|
+
placement?: "bottom-left" | "bottom-right" | "top-left" | "top-right";
|
|
2705
|
+
/** Custom class for the popover container. */
|
|
2706
|
+
className?: string;
|
|
2707
|
+
/** Inline style for the popover container. */
|
|
2708
|
+
style?: CSSProperties;
|
|
2709
|
+
/** Fires whenever an item is picked. */
|
|
2710
|
+
onPick?: (info: {
|
|
2711
|
+
triggerChar: string;
|
|
2712
|
+
query: string;
|
|
2713
|
+
item: unknown;
|
|
2714
|
+
}) => void;
|
|
2715
|
+
}
|
|
2716
|
+
declare function InputTag({ adapter, triggers, maxItems, placement, className, style, onPick, }: InputTagProps): react_jsx_runtime.JSX.Element | null;
|
|
2717
|
+
|
|
2718
|
+
/**
|
|
2719
|
+
* Adapter for a DOM `<textarea>`. Works whether the consumer manages
|
|
2720
|
+
* `value` via React state (controlled) or lets the DOM hold it
|
|
2721
|
+
* (uncontrolled) — `replaceRange` uses React's native value setter and
|
|
2722
|
+
* dispatches a native `input` event so the upstream onChange fires.
|
|
2723
|
+
*/
|
|
2724
|
+
declare function textareaAdapter(ref: RefObject<HTMLTextAreaElement | null>): InputTagAdapter;
|
|
2725
|
+
/** Adapter for a DOM `<input type="text|search|...">`. */
|
|
2726
|
+
declare function inputAdapter(ref: RefObject<HTMLInputElement | null>): InputTagAdapter;
|
|
2727
|
+
/**
|
|
2728
|
+
* Adapter for any `contenteditable` element. Operates on the element's
|
|
2729
|
+
* `textContent`; rich-text editors with their own internal model should
|
|
2730
|
+
* write a custom adapter that talks to that model instead.
|
|
2731
|
+
*/
|
|
2732
|
+
declare function contentEditableAdapter(ref: RefObject<HTMLElement | null>): InputTagAdapter;
|
|
2733
|
+
/**
|
|
2734
|
+
* Adapter for hosts that fully control the text state themselves. Use
|
|
2735
|
+
* this when you can't (or don't want to) let the DOM be the source of
|
|
2736
|
+
* truth — for code editors with internal state, sheet cell editors, or
|
|
2737
|
+
* any host that already has `value` + `onChange` and wants to reach the
|
|
2738
|
+
* picker programmatically.
|
|
2739
|
+
*
|
|
2740
|
+
* The host calls `notify({ text, caretIndex })` after every text or
|
|
2741
|
+
* caret change. `<InputTag>` calls `onReplaceRange` to write back.
|
|
2742
|
+
*/
|
|
2743
|
+
type ControlledAdapterHandle = InputTagAdapter & {
|
|
2744
|
+
/** Push the latest text + caret to the picker. */
|
|
2745
|
+
notify: (state: {
|
|
2746
|
+
text: string;
|
|
2747
|
+
caretIndex: number;
|
|
2748
|
+
}) => void;
|
|
2749
|
+
};
|
|
2750
|
+
declare function controlledAdapter(opts: {
|
|
2751
|
+
/** Element used as anchor + key target. Usually the visible input. */
|
|
2752
|
+
anchorRef: RefObject<HTMLElement | null>;
|
|
2753
|
+
/** Called when the picker writes back an insertion. */
|
|
2754
|
+
onReplaceRange: (start: number, end: number, replacement: string) => void;
|
|
2755
|
+
}): ControlledAdapterHandle;
|
|
2756
|
+
|
|
2757
|
+
/**
|
|
2758
|
+
* MagicWand — selection-anchored floating toolbar for text inputs.
|
|
2759
|
+
*
|
|
2760
|
+
* When the user highlights text inside the wrapped <Textarea>, a small
|
|
2761
|
+
* pill of AI quick-actions floats above the selection. Clicking an
|
|
2762
|
+
* action invokes the host callback with the selected substring + range;
|
|
2763
|
+
* the host returns a replacement string and MagicWand swaps it in-place.
|
|
2764
|
+
*
|
|
2765
|
+
* <MagicWand
|
|
2766
|
+
* value={body}
|
|
2767
|
+
* onValueChange={setBody}
|
|
2768
|
+
* actions={[
|
|
2769
|
+
* { id: "rephrase", label: "Rephrase", hint: "same meaning, different words",
|
|
2770
|
+
* run: async (s) => await ai.rephrase(s) },
|
|
2771
|
+
* …
|
|
2772
|
+
* ]}
|
|
2773
|
+
* />
|
|
2774
|
+
*
|
|
2775
|
+
* Two appearances: `"floating"` (default — full labels) and `"pill"`
|
|
2776
|
+
* (icon-only, compact). Auto-hides on click-away or scroll by default.
|
|
2777
|
+
*/
|
|
2778
|
+
type MagicWandSelection = {
|
|
2779
|
+
start: number;
|
|
2780
|
+
end: number;
|
|
2781
|
+
text: string;
|
|
2782
|
+
};
|
|
2783
|
+
type MagicWandAction = {
|
|
2784
|
+
/** Stable id, also shown as the busy-state key. */
|
|
2785
|
+
id: string;
|
|
2786
|
+
/** Display label (first character used in `pill` mode). */
|
|
2787
|
+
label: string;
|
|
2788
|
+
/** Tooltip body. */
|
|
2789
|
+
hint?: string;
|
|
2790
|
+
/** Optional kind chip rendered next to the label. */
|
|
2791
|
+
tag?: string;
|
|
2792
|
+
/** Returns the replacement text for the selection. */
|
|
2793
|
+
run: (selection: string, range: MagicWandSelection) => Promise<string> | string;
|
|
2794
|
+
};
|
|
2795
|
+
type MagicWandAppearance = "pill" | "floating";
|
|
2796
|
+
interface MagicWandProps {
|
|
2797
|
+
/** Controlled textarea value. */
|
|
2798
|
+
value: string;
|
|
2799
|
+
/** Called on every edit. */
|
|
2800
|
+
onValueChange: (v: string) => void;
|
|
2801
|
+
/** Action list. */
|
|
2802
|
+
actions: MagicWandAction[];
|
|
2803
|
+
/** Visual treatment. Defaults to "floating". */
|
|
2804
|
+
appearance?: MagicWandAppearance;
|
|
2805
|
+
/** Auto-hide the wand on click-away or scroll. Defaults to true. */
|
|
2806
|
+
autoHide?: boolean;
|
|
2807
|
+
/** Textarea rows. */
|
|
2808
|
+
rows?: number;
|
|
2809
|
+
/** Placeholder. */
|
|
2810
|
+
placeholder?: string;
|
|
2811
|
+
/** Called after an action runs successfully. */
|
|
2812
|
+
onAction?: (action: MagicWandAction, selection: MagicWandSelection, replacement: string) => void;
|
|
2813
|
+
}
|
|
2814
|
+
declare function MagicWand({ value, onValueChange, actions, appearance, autoHide, rows, placeholder, onAction, }: MagicWandProps): react_jsx_runtime.JSX.Element;
|
|
2815
|
+
|
|
2816
|
+
export { Accordion, type AccordionContentProps, type AccordionContextValue, type AccordionItemProps, type AccordionOrientation, AccordionPanel, AccordionPanelContent, type AccordionPanelContentProps, type AccordionPanelProps, AccordionPanelSection, type AccordionPanelSectionProps, AccordionPanelTrigger, type AccordionPanelTriggerProps, type AccordionProps, type AccordionTriggerProps, Action, type ActionColor, type ActionProps, type AffixPosition, Autocomplete, type AutocompleteOption, type AutocompleteProps, Avatar, type AvatarProps, Badge, type BadgeProps, Brand, type BrandProps, Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, Calendar, type CalendarMode, type CalendarProps, Callout, type CalloutProps, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardProps, Carousel, type CarouselContextValue, type CarouselControlsProps, type CarouselPanelsProps, type CarouselProps, type CarouselSlideProps, type CarouselStepsProps, type CarouselVariant, Chart, type ChartAreaProps, type ChartBarData, type ChartBarProps, type ChartCommonProps, type ChartDonutData, type ChartDonutProps, type ChartHorizontalBarProps, type ChartLineProps, type ChartPieData, type ChartPieProps, type ChartSeries, type ChartSparklineProps, type ChartStackedBarProps, ChatDrawer, type ChatDrawerProps, type ChatDrawerTab, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type Color, ColorPicker, type ColorPickerProps, Command, type CommandContextValue, type CommandEmptyProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, Composer, type ComposerProps, ContentRenderer, type ContentRendererProps, ContextMenu, type ContextMenuContentProps, type ContextMenuContextValue, type ContextMenuItemProps, type ContextMenuProps, type ContextMenuSeparatorProps, type ContextMenuTriggerProps, type ControlledAdapterHandle, DatePicker, type DatePickerProps, type DateRange, type DropPosition, Dropdown, type DropdownContextValue, type DropdownItemProps, type DropdownItemsProps, type DropdownProps, type DropdownSeparatorProps, type DropdownTriggerProps, EMOJI_CATEGORY_ORDER, EMOJI_DATA, EMOJI_ENTRIES, Editor, type EditorAction, type EditorContentProps, type EditorContextValue, type EditorProps, type EditorToolbarProps, Emoji, type EmojiCategory, type EmojiCategoryKey, type EmojiEntry, type EmojiFlatEntry, type EmojiProps, EmojiSelect, type EmojiSelectProps, Field, type FieldProps, FileUpload, type FileUploadContextValue, type FileUploadDropzoneProps, type FileUploadListProps, type FileUploadProps, Heading, type HeadingProps, Icon, type IconProps, type IconSet, Input, type InputAffixProps, type InputBaseProps, type InputOption, type InputOptionGroup, type InputProps, InputTag, type InputTagAdapter, type InputTagAdapterState, type InputTagProps, type InputTagTrigger, type InputTagTriggers, Kanban, type KanbanCardMoveHandler, type KanbanCardProps, type KanbanColumnHandleProps, type KanbanColumnMoveHandler, type KanbanColumnProps, type KanbanContextValue, type KanbanProps, MagicWand, type MagicWandAction, type MagicWandAppearance, type MagicWandProps, type MagicWandSelection, Menu, type MenuContextValue, type MenuGroupProps, type MenuItemProps, type MenuOrientation, type MenuProps, type MenuSubmenuProps, MobileMenu, type MobileMenuBottomBarProps, type MobileMenuContextValue, type MobileMenuFlyoutProps, type MobileMenuItemProps, type MobileMenuSide, type MobileMenuVariant, Modal, type ModalBodyProps, type ModalContextValue, type ModalFooterProps, type ModalHeaderProps, type ModalProps, MoodMeter, type MoodMeterProps, MultiSwitch, type MultiSwitchProps, Navbar, type NavbarBrandProps, type NavbarContextValue, type NavbarItemProps, type NavbarItemsProps, type NavbarProps, type NavbarToggleProps, type NodeRect, OtpInput, type OtpInputProps, Pagination, type PaginationProps, Pillbox, type PillboxProps, type Placement, Popover, type PopoverContentProps, type PopoverContextValue, type PopoverProps, type PopoverTriggerProps, Portal, type PortalProps, Profile, type ProfileProps, Progress, type ProgressProps, type PromptAttachment, type PromptCmd, PromptInput, type PromptInputProps, type PromptMention, RadioGroup, type RadioGroupProps, ReasonTag, type ReasonTagProps, type ReasonTagSource, type ReasonTagTheme, type RenderExtension, type RenderExtensionProps, SKIN_TONES, type SectionRenderState, type SectionRenderable, Select, type SelectProps, Separator, type SeparatorProps, Sidebar, type SidebarCollapseMode, type SidebarContextValue, type SidebarGroupProps, type SidebarItemProps, type SidebarProps, type SidebarSubmenuProps, type SidebarToggleProps, type Size, Skeleton, type SkeletonProps, type SkinTone, Slider, type SliderProps, Switch, type SwitchProps, Table, type TableBodyProps, type TableCellProps, type TableColumnProps, type TableHeadProps, type TablePaginationProps, type TableProps, type TableRowProps, type TableRowTrayProps, type TableSearchProps, type TableTrayProps, Tabs, type TabsContextValue, type TabsListProps, type TabsPanelProps, type TabsPanelsProps, type TabsProps, type TabsTabProps, type TabsVariant, Text, type TextProps, Textarea, type TextareaProps, TimePicker, type TimePickerProps, Timeline, type TimelineBlockProps, type TimelineEvent, type TimelineItemProps, type TimelineOrientation, type TimelineProps, type TimelineVariant, Toast, type ToastContextValue, type ToastData, type ToastPosition, type ToastProviderProps, type ToastVariant, Tooltip, type TooltipProps, TreeNav, type TreeNavContextValue, type TreeNavProps, type TreeNodeData, type TreeNodeProps, type Variant, applyTone, cn, configureIcons, contentEditableAdapter, controlledAdapter, find, hasSkinTones, inputAdapter, registerExtension, registerExtensions, registerIconSet, registerIcons, resolve, sanitizeHref, sanitizeHtml, search, skinTones, textareaAdapter, useAccordion, useAccordionPanel, useAccordionSection, useAnimation, useCarousel, useCommand, useContextMenu, useControllableState, useDropdown, useEditor, useEscapeKey, useFileUpload, useFloatingPosition, useFocusTrap, useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|