@kitn.ai/ui
Version:
Framework-agnostic, Shadow-DOM web components for building AI chat interfaces — works in React, Vue, Angular, Svelte, or plain HTML. Authored in SolidJS.
106 lines (105 loc) • 5.31 kB
TypeScript
import { JSX, Accessor } from 'solid-js';
export interface ChainOfThoughtItemProps extends JSX.HTMLAttributes<HTMLDivElement> {
children: JSX.Element;
}
declare function ChainOfThoughtItem(props: ChainOfThoughtItemProps): JSX.Element;
export interface ChainOfThoughtTriggerProps {
children: JSX.Element;
class?: string;
leftIcon?: JSX.Element;
swapIconOnHover?: boolean;
}
declare function ChainOfThoughtTrigger(props: ChainOfThoughtTriggerProps): JSX.Element;
export interface ChainOfThoughtContentProps {
children: JSX.Element;
class?: string;
}
declare function ChainOfThoughtContent(props: ChainOfThoughtContentProps): JSX.Element;
export interface ChainOfThoughtProps {
children: JSX.Element;
class?: string;
}
declare function ChainOfThought(props: ChainOfThoughtProps): JSX.Element;
export interface ChainOfThoughtStepProps {
children: JSX.Element;
class?: string;
isLast?: boolean;
/** Controlled open state. When provided, the step's Collapsible is driven by
* this value (the parent owns it — used by the Accordion model below). When
* OMITTED the step stays uncontrolled, preserving the original behaviour
* (every step independently toggleable, starting closed). */
open?: boolean;
/** Called with the desired next open state when the user clicks the trigger.
* Only meaningful when `open` is also provided (controlled mode); the parent
* Accordion routes this through its open-set handler. */
onOpenChange?: (open: boolean) => void;
}
declare function ChainOfThoughtStep(props: ChainOfThoughtStepProps): JSX.Element;
/** Open-mode: `multiple` (any number of steps open at once — the historical
* default) or `single` (at most one open; opening a step closes the others). */
export type ChainOfThoughtType = 'single' | 'multiple';
/**
* A reasoning step descriptor. `id` is an OPTIONAL stable key — the Accordion's
* open-set keys use `step.id` when present, else `String(index)`. So a consumer
* who wants to drive `value`/`defaultValue` (or read `kai-value-change`) by a
* meaningful key should set `id`; otherwise the step's position is its key.
*/
export interface ChainOfThoughtStepData {
/** The step's heading (the always-visible trigger). */
label: string;
/** Optional expandable detail. */
content?: string;
/** Optional stable key for the open-set/value model (defaults to the index). */
id?: string;
}
/**
* Imperative handle exposed via `controllerRef` so the `<kai-chain-of-thought>`
* facade can drive/observe the Accordion's open set. Index-based to match the
* `expand(index?)`/`collapse(index?)`/`toggle(index?)` method signatures; the
* controller resolves the index → step key internally. All setters flow through
* the same open-set mutate path as user clicks, so they all emit
* `kai-value-change` via `onValueChange`.
*/
export interface ChainOfThoughtController {
/** Current open keys, normalised per `type` (string in single, string[] in multiple). */
value: Accessor<string | string[]>;
/** Open one step by index, or ALL steps when `index` is omitted. */
expand: (index?: number) => void;
/** Close one step by index, or ALL steps when `index` is omitted. */
collapse: (index?: number) => void;
/** Flip one step's open state by index. */
toggle: (index?: number) => void;
}
export interface ChainOfThoughtAccordionProps {
/** The reasoning steps to render. */
steps: ChainOfThoughtStepData[];
/** Open mode. Default `multiple` (the historical behaviour). */
type?: ChainOfThoughtType;
/** Controlled open step key(s). When provided it WINS over internal state. */
value?: string | string[];
/** Uncontrolled initial open step key(s). Seeds the internal open-set. */
defaultValue?: string | string[];
/** Fired whenever the open set changes (user click OR a controller method).
* The single emit point — the facade turns this into `kai-value-change`. The
* payload is a string in `single` mode, a string[] in `multiple` mode. */
onValueChange?: (value: string | string[]) => void;
/** Receive the imperative controller once set up (Pattern C). */
controllerRef?: (api: ChainOfThoughtController) => void;
class?: string;
}
/**
* The full Accordion-model root used by `<kai-chain-of-thought>`. Lifts each
* step's open state into a controlled/uncontrolled open-set:
* - seeded from `defaultValue` (normalised string|string[] → Set);
* - when `value` is provided it WINS (controlled);
* - a trigger click updates the set respecting `single` vs `multiple` and emits
* via `onValueChange` — in single mode opening a step closes the others;
* - each step's Collapsible is driven (controlled) by its membership in the set.
*
* With NO new props (type defaults to `multiple`, no value/defaultValue), every
* step starts closed and is independently toggleable — identical to the old
* behaviour, just with the open state lifted here so methods/events can observe
* and drive it.
*/
declare function ChainOfThoughtAccordion(props: ChainOfThoughtAccordionProps): JSX.Element;
export { ChainOfThought, ChainOfThoughtStep, ChainOfThoughtTrigger, ChainOfThoughtContent, ChainOfThoughtItem, ChainOfThoughtAccordion, };