@ai-matrx/design-system 0.1.0 → 0.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.
@@ -0,0 +1,415 @@
1
+ import * as class_variance_authority_types from 'class-variance-authority/types';
2
+ import { VariantProps } from 'class-variance-authority';
3
+ import * as React from 'react';
4
+ import React__default, { ComponentType, ReactNode } from 'react';
5
+ import { ClassValue } from 'clsx';
6
+ import * as LabelPrimitive from '@radix-ui/react-label';
7
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
8
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
9
+ import * as SheetPrimitive from '@radix-ui/react-dialog';
10
+
11
+ declare const badgeVariants: (props?: ({
12
+ variant?: "default" | "secondary" | "destructive" | "outline" | "success" | "warning" | "info" | "error" | "neutral" | null | undefined;
13
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
14
+ interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeVariants> {
15
+ }
16
+ declare function Badge({ className, variant, ...props }: BadgeProps): React.JSX.Element;
17
+
18
+ interface BottomSheetProps {
19
+ open: boolean;
20
+ onOpenChange: (open: boolean) => void;
21
+ title?: string;
22
+ /**
23
+ * `adaptive` (default) — the sheet sizes to its content between 60dvh and
24
+ * 90dvh. Correct for a single short list.
25
+ *
26
+ * `full` — ONE fixed height (92dvh) that never changes as content changes.
27
+ * Use it for any sheet whose body varies (multi-level navigation, tabs,
28
+ * search results): an adaptive sheet there resizes under the user's thumb
29
+ * on every keystroke and every drill-in, which reads as the panel jumping.
30
+ */
31
+ size?: "adaptive" | "full";
32
+ /** Visual treatment for the panel. Solid is intended for dense, long-lived surfaces. */
33
+ surface?: "glass" | "solid";
34
+ /** Merged onto the sheet panel. */
35
+ contentClassName?: string;
36
+ children: React.ReactNode;
37
+ }
38
+ declare function BottomSheet({ open, onOpenChange, title, size, surface, contentClassName, children, }: BottomSheetProps): React.JSX.Element;
39
+ interface BottomSheetHeaderProps {
40
+ title: string;
41
+ showBack?: boolean;
42
+ onBack?: () => void;
43
+ trailing?: React.ReactNode;
44
+ }
45
+ declare function BottomSheetHeader({ title, showBack, onBack, trailing, }: BottomSheetHeaderProps): React.JSX.Element;
46
+ interface BottomSheetBodyProps {
47
+ children: React.ReactNode;
48
+ className?: string;
49
+ }
50
+ declare function BottomSheetBody({ children, className }: BottomSheetBodyProps): React.JSX.Element;
51
+ interface BottomSheetFooterProps {
52
+ children: React.ReactNode;
53
+ className?: string;
54
+ }
55
+ declare function BottomSheetFooter({ children, className, }: BottomSheetFooterProps): React.JSX.Element;
56
+
57
+ declare const buttonVariants: (props?: ({
58
+ variant?: "default" | "secondary" | "destructive" | "outline" | "link" | "ghost" | "subtle" | null | undefined;
59
+ size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | null | undefined;
60
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
61
+ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
62
+ asChild?: boolean;
63
+ }
64
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
65
+
66
+ declare function cn(...inputs: ClassValue[]): string;
67
+
68
+ type EditableLabelCommitMode = "optimistic" | "await";
69
+ type EditableLabelActivation = "click" | "doubleClick" | "controlled";
70
+ interface EditableLabelProps {
71
+ value: string;
72
+ /**
73
+ * Commit handler. optimistic (default): edit mode exits immediately, the
74
+ * promise is fire-and-forget (owners do optimistic update + revert + toast).
75
+ * await: input disables with a spinner until the promise resolves; a
76
+ * rejection keeps edit mode open to retry.
77
+ */
78
+ onCommit: (next: string) => void | Promise<void>;
79
+ commitMode?: EditableLabelCommitMode;
80
+ /** Return an error message to block the commit (shown under the input). */
81
+ validate?: (next: string) => string | null;
82
+ /** Used when the trimmed draft is empty. Undefined → empty cancels. */
83
+ emptyFallback?: string;
84
+ maxLength?: number;
85
+ /**
86
+ * "click"/"doubleClick" — internal edit state (headers). "controlled" — host
87
+ * owns `editing`; EditableLabel renders ONLY the input when editing.
88
+ */
89
+ activation?: EditableLabelActivation;
90
+ editing?: boolean;
91
+ /** Edit-state notifications. Controlled mode: the ONLY state channel.
92
+ * Uncontrolled modes: fired as a notification (layout hooks etc.). */
93
+ onEditingChange?: (editing: boolean) => void;
94
+ selectOnEdit?: boolean;
95
+ placeholder?: string;
96
+ /** Accessible name, e.g. "Session title". Default "Name". */
97
+ ariaLabel?: string;
98
+ truncate?: boolean;
99
+ className?: string;
100
+ displayClassName?: string;
101
+ inputClassName?: string;
102
+ }
103
+ declare function EditableLabel({ value, onCommit, commitMode, validate, emptyFallback, maxLength, activation, editing: editingProp, onEditingChange, selectOnEdit, placeholder, ariaLabel, truncate, className, displayClassName, inputClassName, }: EditableLabelProps): React.JSX.Element | null;
104
+
105
+ /**
106
+ * Input family — ported verbatim from matrx-frontend `components/ui/input.tsx`.
107
+ *
108
+ * Seam inversions:
109
+ * - `MatrxVariant` (host `components/ui/types`) becomes the structural
110
+ * `InputVariant` union with the identical members, so host call sites are
111
+ * drop-in compatible.
112
+ * - The host file's `CopyInput` / `FancyInput` / `DeleteInput` are
113
+ * deliberately NOT absorbed (C8 split-out law): they carry a `motion/react`
114
+ * dependency (and clipboard behavior) that plain-Input consumers must not
115
+ * pay for. They stay host-owned until sanctioned separately.
116
+ */
117
+
118
+ type InputVariant = "default" | "destructive" | "success" | "outline" | "secondary" | "ghost" | "link" | "primary";
119
+ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
120
+ variant?: InputVariant;
121
+ }
122
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
123
+ interface EnterInputProps extends InputProps {
124
+ onEnter?: () => void;
125
+ }
126
+ declare const EnterInput: React.ForwardRefExoticComponent<EnterInputProps & React.RefAttributes<HTMLInputElement>>;
127
+ declare const BasicInput: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
128
+ interface InputWithPrefixProps extends Omit<InputProps, "prefix"> {
129
+ prefix?: React.ReactNode;
130
+ wrapperClassName?: string;
131
+ }
132
+ declare const InputWithPrefix: React.ForwardRefExoticComponent<InputWithPrefixProps & React.RefAttributes<HTMLInputElement>>;
133
+
134
+ declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
135
+
136
+ /**
137
+ * OverflowToolbar — a horizontal row of consistent, compact action buttons
138
+ * that collapses the buttons that don't fit into a single "more" (…) menu.
139
+ * Ported verbatim from matrx-frontend
140
+ * `components/official/toolbar/OverflowToolbar.tsx` (S20).
141
+ *
142
+ * ┌───────────────────────────────────────────────┐
143
+ * │ [leading] [Btn] [Btn] [Btn] [ … ] │
144
+ * └───────────────────────────────────────────────┘
145
+ *
146
+ * Design rules (the primitive enforces them so callers can't drift):
147
+ * - Every button is the same height (h-7), padding, text size, icon size.
148
+ * - `hideLabel` renders an icon-only button with a tooltip — use it for
149
+ * "obvious" actions (Find, Source, …).
150
+ * - `tone: "primary"` colors a button without changing its size, so the
151
+ * primary action is NOT visually larger than the rest.
152
+ * - When the row is too narrow, the LAST actions collapse into the overflow
153
+ * menu first. Order your actions most-important-first.
154
+ *
155
+ * Measurement is done with a hidden "ghost" row (always renders every action
156
+ * + the kebab) read via a ResizeObserver, so the visible row never reflows
157
+ * mid-frame.
158
+ *
159
+ * Seam inversions (host-shaped chrome becomes injected):
160
+ * - `icon: LucideIcon` → the structural `ToolbarIcon`
161
+ * (`ComponentType<{ className?: string }>`) — any SVG component fits.
162
+ * - The host Tooltip wrapper → `renderTooltip` prop. Without it, icon-only
163
+ * buttons render bare (they always carry `aria-label`); hosts inject their
164
+ * tooltip system for the original hover behavior.
165
+ * - The host ItemMenu overflow menu → `renderOverflowMenu` prop (required):
166
+ * the host receives the collapsed actions plus the ready-made kebab trigger
167
+ * and renders them with its own menu system.
168
+ */
169
+
170
+ type ToolbarActionTone = "default" | "primary" | "destructive";
171
+ /** Structural icon contract (a lucide icon satisfies it, so does any SVG component). */
172
+ type ToolbarIcon = React__default.ComponentType<{
173
+ className?: string;
174
+ }>;
175
+ interface ToolbarAction {
176
+ id: string;
177
+ label: string;
178
+ icon: ToolbarIcon;
179
+ /** Click handler. Ignored when `href` is set. */
180
+ onSelect?: () => void;
181
+ /** Renders an anchor instead of a button. */
182
+ href?: string;
183
+ target?: "_blank";
184
+ disabled?: boolean;
185
+ /** Swaps the icon for a spinner and (optionally) shows `runningLabel`. */
186
+ running?: boolean;
187
+ runningLabel?: string;
188
+ tone?: ToolbarActionTone;
189
+ /** Icon-only button (tooltip carries the label). For obvious actions. */
190
+ hideLabel?: boolean;
191
+ /** Drop the action entirely. */
192
+ hidden?: boolean;
193
+ }
194
+ interface OverflowToolbarProps {
195
+ actions: ToolbarAction[];
196
+ /**
197
+ * Optional element pinned at the start of the row — never collapsed, never
198
+ * measured into the action budget except as a fixed prefix (e.g. a surface
199
+ * switcher / context chip cluster).
200
+ */
201
+ leading?: React__default.ReactNode;
202
+ /** Accessible label for the overflow trigger. */
203
+ overflowAriaLabel?: string;
204
+ className?: string;
205
+ /**
206
+ * Injected overflow-menu seam: render the collapsed actions with the host's
207
+ * menu system, using `trigger` (the ready-made kebab button) as the menu
208
+ * trigger element.
209
+ */
210
+ renderOverflowMenu: (args: {
211
+ actions: ToolbarAction[];
212
+ trigger: React__default.ReactNode;
213
+ }) => React__default.ReactNode;
214
+ /**
215
+ * Injected tooltip seam for icon-only buttons (their label lives nowhere
216
+ * else on screen). Omitted → the bare control renders (aria-label intact).
217
+ */
218
+ renderTooltip?: (control: React__default.ReactElement, label: string) => React__default.ReactNode;
219
+ }
220
+ declare function OverflowToolbar({ actions, leading, overflowAriaLabel, className, renderOverflowMenu, renderTooltip, }: OverflowToolbarProps): React__default.JSX.Element;
221
+
222
+ /**
223
+ * Popover — ported verbatim from matrx-frontend `components/ui/popover.tsx`.
224
+ *
225
+ * Seam inversion: the host's `useNestedPortalContainer` (dialog/popout aware)
226
+ * becomes the injected `PortalContainerProvider` seam (`portal-container.tsx`);
227
+ * the explicit `container` prop keeps top priority, exactly as before.
228
+ *
229
+ * THE ROOT RENDERS UNCONDITIONALLY — no mount gate. This wrapper used to defer
230
+ * rendering until after hydration ("Radix generates dynamic aria-controls ids
231
+ * that differ between SSR and client"), and that justification was false:
232
+ * Radix ids come from React's SSR-stable `useId` (verified against
233
+ * @radix-ui/react-popover 1.1.17 / react-id 1.1.2). The gate was actively
234
+ * harmful — the Trigger wraps ALWAYS-VISIBLE content, so `return null`
235
+ * deleted it from SSR and the first client paint.
236
+ */
237
+
238
+ declare const Popover: React.FC<PopoverPrimitive.PopoverProps>;
239
+ declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
240
+ declare const PopoverAnchor: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverAnchorProps & React.RefAttributes<HTMLDivElement>>;
241
+ declare const PopoverContent: React.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
242
+ container?: HTMLElement | null;
243
+ } & React.RefAttributes<HTMLDivElement>>;
244
+
245
+ /**
246
+ * Injected portal-container seam.
247
+ *
248
+ * The matrx-frontend original resolved nested portal targets through
249
+ * `useNestedPortalContainer` (explicit prop > dialog content > popout body >
250
+ * document.body) — a host-shaped hook wired to that app's dialog and
251
+ * window-panel systems. The package inverts the seam: hosts provide the
252
+ * resolved container through `PortalContainerProvider`; an explicit
253
+ * `container` prop on a component still wins, and with neither the portal
254
+ * falls through to `document.body` (Radix default). Priority semantics are
255
+ * unchanged from the original.
256
+ */
257
+
258
+ interface PortalContainerProviderProps {
259
+ /** Where nested Radix portals (Popover, etc.) should mount. `null`/`undefined` → document.body. */
260
+ container: HTMLElement | null | undefined;
261
+ children: React.ReactNode;
262
+ }
263
+ declare function PortalContainerProvider({ container, children, }: PortalContainerProviderProps): React.JSX.Element;
264
+ /**
265
+ * Resolve a portal target: explicit prop (including an explicit `null`,
266
+ * meaning "the default body") beats the injected container.
267
+ */
268
+ declare function usePortalContainer(explicit?: HTMLElement | null): HTMLElement | undefined;
269
+
270
+ /**
271
+ * Ported verbatim from matrx-frontend `components/ui/radix-dialog-modal-context.tsx`.
272
+ * Shared by the Sheet and BottomSheet families (and available to hosts that
273
+ * compose their own Radix Dialog-derived wrappers around these primitives).
274
+ */
275
+
276
+ interface RadixDialogModalProviderProps {
277
+ children: React.ReactNode;
278
+ modal: boolean;
279
+ }
280
+ /**
281
+ * Keeps our Radix-based content wrappers aligned with the owning Root's
282
+ * modality so ARIA semantics cannot drift from focus/pointer behavior.
283
+ */
284
+ declare function RadixDialogModalProvider({ children, modal, }: RadixDialogModalProviderProps): React.JSX.Element;
285
+ /** Returns whether the nearest Radix Dialog-derived root is modal. */
286
+ declare function useRadixDialogModal(): boolean;
287
+
288
+ /**
289
+ * ScoreRing — SVG progress ring + the shared score→color threshold semantics.
290
+ * Ported verbatim from matrx-frontend `components/official/ScoreRing.tsx`
291
+ * (S18). The thresholds ARE the product: green at/above `good`, orange
292
+ * at/above `warning`, red below, muted for null. No seams.
293
+ */
294
+
295
+ interface ScoreThresholds {
296
+ /** Scores at or above this value are green. */
297
+ good: number;
298
+ /** Scores at or above this value (but below good) are orange. */
299
+ warning: number;
300
+ }
301
+ declare const DEFAULT_SCORE_THRESHOLDS: ScoreThresholds;
302
+ /** Semantic score color shared by ring and accent consumers. */
303
+ declare function scoreRingColorClasses(pct: number | null, thresholds?: ScoreThresholds): string;
304
+ /** Solid-background twin of `scoreRingColorClasses`. */
305
+ declare function scoreAccentBgClasses(pct: number | null, thresholds?: ScoreThresholds): string;
306
+ interface ScoreRingProps {
307
+ pct: number | null;
308
+ size?: number;
309
+ strokeWidth?: number;
310
+ label?: string;
311
+ valueClassName?: string;
312
+ className?: string;
313
+ thresholds?: ScoreThresholds;
314
+ /** Visible suffix; study keeps `%`, while Lighthouse convention omits it. */
315
+ suffix?: string;
316
+ }
317
+ /**
318
+ * Shared SVG score ring. `pct` is 0–100; threshold semantics are supplied by
319
+ * the domain (for example Lighthouse uses 90/50 while study uses 75/50).
320
+ */
321
+ declare function ScoreRing({ pct, size, strokeWidth, label, valueClassName, className, thresholds, suffix, }: ScoreRingProps): React.JSX.Element;
322
+
323
+ /**
324
+ * SegmentedControl — sized accessible segmented toggle.
325
+ * Ported verbatim from matrx-frontend `components/ui/segmented-control.tsx`
326
+ * (S17). No seams: pure markup over host semantic tokens. The option/prop
327
+ * interfaces are exported here (the original kept them file-local).
328
+ */
329
+
330
+ interface SegmentOption {
331
+ value: string;
332
+ label: React.ReactNode;
333
+ disabled?: boolean;
334
+ }
335
+ interface SegmentedControlProps {
336
+ value: string;
337
+ onValueChange: (value: string) => void;
338
+ data: SegmentOption[];
339
+ name?: string;
340
+ className?: string;
341
+ fullWidth?: boolean;
342
+ size?: "sm" | "md" | "lg";
343
+ }
344
+ declare function SegmentedControl({ value, onValueChange, data, name: _name, className, fullWidth, size, }: SegmentedControlProps): React.JSX.Element;
345
+
346
+ declare const Separator: React.ForwardRefExoticComponent<Omit<SeparatorPrimitive.SeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
347
+
348
+ declare const Sheet: React.ForwardRefExoticComponent<SheetPrimitive.DialogProps & React.RefAttributes<never>>;
349
+ declare const SheetTrigger: React.ForwardRefExoticComponent<SheetPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
350
+ declare const SheetClose: React.ForwardRefExoticComponent<SheetPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
351
+ declare const SheetPortal: React.FC<SheetPrimitive.DialogPortalProps>;
352
+ declare const SheetOverlay: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
353
+ declare const sheetVariants: (props?: ({
354
+ side?: "center" | "bottom" | "left" | "right" | "top" | null | undefined;
355
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
356
+ interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>, VariantProps<typeof sheetVariants> {
357
+ hideCloseButton?: boolean;
358
+ /** Skip the dimming overlay — for non-modal side panels (e.g. chat canvas). */
359
+ hideOverlay?: boolean;
360
+ /** Optional className for the overlay when shown. */
361
+ overlayClassName?: string;
362
+ }
363
+ declare const SheetDescription: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
364
+ declare const SheetContent: React.ForwardRefExoticComponent<SheetContentProps & React.RefAttributes<HTMLDivElement>>;
365
+ declare const SheetHeader: {
366
+ ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
367
+ displayName: string;
368
+ };
369
+ declare const SheetFooter: {
370
+ ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
371
+ displayName: string;
372
+ };
373
+ declare const SheetTitle: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
374
+
375
+ /**
376
+ * Skeleton — ported verbatim from matrx-frontend `components/ui/skeleton.tsx`.
377
+ * No seams: pure markup over host semantic tokens.
378
+ */
379
+
380
+ declare function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
381
+
382
+ interface TabbedBottomSheetTab {
383
+ id: string;
384
+ label: string;
385
+ icon?: ComponentType<{
386
+ className?: string;
387
+ }>;
388
+ /** Optional trailing badge / dot shown on the index row. */
389
+ trailing?: ReactNode;
390
+ content: ReactNode;
391
+ }
392
+ interface TabbedBottomSheetProps {
393
+ open: boolean;
394
+ onOpenChange: (open: boolean) => void;
395
+ title: string;
396
+ tabs: TabbedBottomSheetTab[];
397
+ }
398
+ declare function TabbedBottomSheet({ open, onOpenChange, title, tabs, }: TabbedBottomSheetProps): React.JSX.Element;
399
+
400
+ interface ScrollFadeState {
401
+ top: boolean;
402
+ bottom: boolean;
403
+ }
404
+ interface UseScrollFadeResult {
405
+ ref: (node: HTMLElement | null) => void;
406
+ fadeProps: {
407
+ "data-fade-top": "" | undefined;
408
+ "data-fade-bottom": "" | undefined;
409
+ className: string;
410
+ };
411
+ state: ScrollFadeState;
412
+ }
413
+ declare function useScrollFade(): UseScrollFadeResult;
414
+
415
+ export { Badge, type BadgeProps, BasicInput, BottomSheet, BottomSheetBody, type BottomSheetBodyProps, BottomSheetFooter, type BottomSheetFooterProps, BottomSheetHeader, type BottomSheetHeaderProps, type BottomSheetProps, Button, type ButtonProps, DEFAULT_SCORE_THRESHOLDS, EditableLabel, type EditableLabelActivation, type EditableLabelCommitMode, type EditableLabelProps, EnterInput, type EnterInputProps, Input, type InputProps, type InputVariant, InputWithPrefix, type InputWithPrefixProps, Label, OverflowToolbar, type OverflowToolbarProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PortalContainerProvider, type PortalContainerProviderProps, RadixDialogModalProvider, type RadixDialogModalProviderProps, ScoreRing, type ScoreRingProps, type ScoreThresholds, type ScrollFadeState, type SegmentOption, SegmentedControl, type SegmentedControlProps, Separator, Sheet, SheetClose, SheetContent, type SheetContentProps, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Skeleton, TabbedBottomSheet, type TabbedBottomSheetProps, type TabbedBottomSheetTab, type ToolbarAction, type ToolbarActionTone, type ToolbarIcon, type UseScrollFadeResult, badgeVariants, buttonVariants, cn, scoreAccentBgClasses, scoreRingColorClasses, sheetVariants, usePortalContainer, useRadixDialogModal, useScrollFade };