@openwarelabs/ui 0.15.0 → 0.16.1

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.
Files changed (59) hide show
  1. package/README.md +8 -8
  2. package/dist/components/ActivityHeatmap/ActivityHeatmap.d.cts +8 -0
  3. package/dist/components/ActivityHeatmap/ActivityHeatmap.d.ts +8 -0
  4. package/dist/components/ActivityHeatmap/ActivityHeatmap.types.d.cts +73 -0
  5. package/dist/components/ActivityHeatmap/ActivityHeatmap.types.d.ts +73 -0
  6. package/dist/components/DiffViewer/DiffViewer.d.cts +8 -0
  7. package/dist/components/DiffViewer/DiffViewer.d.ts +8 -0
  8. package/dist/components/DiffViewer/DiffViewer.types.d.cts +131 -0
  9. package/dist/components/DiffViewer/DiffViewer.types.d.ts +131 -0
  10. package/dist/components/DiffViewer/diff.d.cts +10 -0
  11. package/dist/components/DiffViewer/diff.d.ts +10 -0
  12. package/dist/components/Markdown/Markdown.d.cts +8 -0
  13. package/dist/components/Markdown/Markdown.d.ts +8 -0
  14. package/dist/components/Markdown/Markdown.types.d.cts +59 -0
  15. package/dist/components/Markdown/Markdown.types.d.ts +59 -0
  16. package/dist/components/MediaPlayer/MediaPlayer.d.cts +8 -0
  17. package/dist/components/MediaPlayer/MediaPlayer.d.ts +8 -0
  18. package/dist/components/MediaPlayer/MediaPlayer.types.d.cts +109 -0
  19. package/dist/components/MediaPlayer/MediaPlayer.types.d.ts +109 -0
  20. package/dist/components/MentionInput/MentionInput.d.cts +9 -0
  21. package/dist/components/MentionInput/MentionInput.d.ts +9 -0
  22. package/dist/components/MentionInput/MentionInput.types.d.cts +125 -0
  23. package/dist/components/MentionInput/MentionInput.types.d.ts +125 -0
  24. package/dist/components/MentionInput/useMentions.d.cts +8 -0
  25. package/dist/components/MentionInput/useMentions.d.ts +8 -0
  26. package/dist/components/NotificationCenter/NotificationCenter.d.cts +12 -0
  27. package/dist/components/NotificationCenter/NotificationCenter.d.ts +12 -0
  28. package/dist/components/NotificationCenter/NotificationCenter.types.d.cts +129 -0
  29. package/dist/components/NotificationCenter/NotificationCenter.types.d.ts +129 -0
  30. package/dist/components/QRCode/QRCode.d.cts +18 -0
  31. package/dist/components/QRCode/QRCode.d.ts +18 -0
  32. package/dist/components/QRCode/QRCode.types.d.cts +53 -0
  33. package/dist/components/QRCode/QRCode.types.d.ts +53 -0
  34. package/dist/components/QRCode/qr.d.cts +8 -0
  35. package/dist/components/QRCode/qr.d.ts +8 -0
  36. package/dist/components/SignaturePad/SignaturePad.d.cts +8 -0
  37. package/dist/components/SignaturePad/SignaturePad.d.ts +8 -0
  38. package/dist/components/SignaturePad/SignaturePad.types.d.cts +102 -0
  39. package/dist/components/SignaturePad/SignaturePad.types.d.ts +102 -0
  40. package/dist/components/TransferList/TransferList.d.cts +7 -0
  41. package/dist/components/TransferList/TransferList.d.ts +7 -0
  42. package/dist/components/TransferList/TransferList.types.d.cts +75 -0
  43. package/dist/components/TransferList/TransferList.types.d.ts +75 -0
  44. package/dist/components/UploadList/UploadList.d.cts +9 -0
  45. package/dist/components/UploadList/UploadList.d.ts +9 -0
  46. package/dist/components/UploadList/UploadList.types.d.cts +113 -0
  47. package/dist/components/UploadList/UploadList.types.d.ts +113 -0
  48. package/dist/components/UploadList/useUploadQueue.d.cts +8 -0
  49. package/dist/components/UploadList/useUploadQueue.d.ts +8 -0
  50. package/dist/components.css +1194 -104
  51. package/dist/index.cjs +5489 -2267
  52. package/dist/index.cjs.map +4 -4
  53. package/dist/index.d.cts +20 -0
  54. package/dist/index.d.ts +20 -0
  55. package/dist/index.js +5518 -2280
  56. package/dist/index.js.map +4 -4
  57. package/dist/openware-ui.iife.js +24 -9
  58. package/dist/styles.css +1194 -104
  59. package/package.json +1 -1
package/README.md CHANGED
@@ -54,24 +54,24 @@ import { Button, Field, Input, Toaster, toast } from "@openwarelabs/ui";
54
54
 
55
55
  ## Components
56
56
 
57
- 106 components, each with a page in the docs.
57
+ 121 components, each with a page in the docs.
58
58
 
59
59
  | Group | Components |
60
60
  | --- | --- |
61
61
  | Typography | `Text` (each style on the Typography page as a variant: hero to caption, code and kbd; tones, `truncate`, `as`), `Link`, `Kbd`, `Code`, `CodeBlock`, `Snippet`, `Prose` (styles rendered Markdown or HTML, at chat or article size), `InlineEdit` (text you click to edit in place; Enter saves, Escape cancels, async saves) |
62
62
  | Actions | `Button` (primary, secondary, ghost, danger; sm, md, lg; `loading`; `shape="pill"`), `buttonClassName()` for links, `ButtonGroup`, `CloseButton`, `CopyButton`, `ToggleButton`, `SegmentedControl`, `ToggleButtonGroup` (one or several on), `Toolbar` + `ToolbarSeparator` (arrow keys across its controls) |
63
- | Inputs | `Form` (the browser's checks, your own and the server's errors, under each field; `useFormStatus`), `Field`, `Fieldset`, `Input` (start and end content), `Textarea` (`autoGrow`), `NumberField`, `SearchField`, `InputOTP`, `ColorField`, `DateField` and `TimeField` (typed in segments, in the locale's order), `TagInput` (several values as tags, typed or picked from suggestions), `PasswordInput` (show and hide, a strength meter, a checklist of rules; `passwordStrength()`) |
64
- | Choices | `Checkbox`, `CheckboxGroup`, `RadioGroup` (plain or cards), `Switch`, `Select`, `Combobox`, `Slider` (one value or a range), `Rating` (pick a score or show one), `ChoiceCard`, `ListBox` (one or many, on the page), `TreeView` (rows that open, select or check, with children loaded on demand) |
65
- | Pickers | `Calendar`, `DatePicker`, `RangeCalendar`, `DateRangePicker` (with presets), `ColorPicker`, `ColorArea`, `ColorSlider`, `ColorSwatchPicker`, `FileDropZone` |
63
+ | Inputs | `Form` (the browser's checks, your own and the server's errors, under each field; `useFormStatus`), `Field`, `Fieldset`, `Input` (start and end content), `Textarea` (`autoGrow`), `NumberField`, `SearchField`, `InputOTP`, `ColorField`, `DateField` and `TimeField` (typed in segments, in the locale's order), `TagInput` (several values as tags, typed or picked from suggestions), `PasswordInput` (show and hide, a strength meter, a checklist of rules; `passwordStrength()`), `MentionInput` (`@` mentions and `/` commands in a list at the caret; `useMentions` for any text box), `SignaturePad` (sign with a mouse, finger or pen, or type instead; sent with a Form) |
64
+ | Choices | `Checkbox`, `CheckboxGroup`, `RadioGroup` (plain or cards), `Switch`, `Select`, `Combobox`, `Slider` (one value or a range), `Rating` (pick a score or show one), `ChoiceCard`, `ListBox` (one or many, on the page), `TreeView` (rows that open, select or check, with children loaded on demand), `TransferList` (two lists with buttons to move items between them, searchable and orderable) |
65
+ | Pickers | `Calendar`, `DatePicker`, `RangeCalendar`, `DateRangePicker` (with presets), `ColorPicker`, `ColorArea`, `ColorSlider`, `ColorSwatchPicker`, `FileDropZone`, `UploadList` (files uploading with progress, retry, cancel and remove; `useUploadQueue`) |
66
66
  | Feedback | `Alert`, `Badge`, `ProgressBar`, `ProgressCircle`, `Meter` (an amount in a range, toned by thresholds), `Spinner`, `Skeleton`, `SkeletonRows`, `Toaster` + `toast()` (sonner: stacked, swipeable, with actions and promises), `Tooltip`, `Banner` (an announcement bar across the top, dismissible and remembered) |
67
- | Overlays | `Dialog`, `ConfirmDialog`, `Drawer`, `Popover`, `HoverCard` (a preview when the pointer rests on a link), `Menu` + `MenuItem`, `CommandPalette`, `ContextMenu` (right-click, long press or Shift+F10, with the same items), `Tour` (steps that point at parts of the page, with an optional spotlight) + `Coachmark`, `NavigationMenu` + `NavigationMenuItem` + `NavigationMenuLink` (a site's top nav with dropdown panels and mega-menus) |
67
+ | Overlays | `Dialog`, `ConfirmDialog`, `Drawer`, `Popover`, `HoverCard` (a preview when the pointer rests on a link), `Menu` + `MenuItem`, `CommandPalette`, `ContextMenu` (right-click, long press or Shift+F10, with the same items), `Tour` (steps that point at parts of the page, with an optional spotlight) + `Coachmark`, `NavigationMenu` + `NavigationMenuItem` + `NavigationMenuLink` (a site's top nav with dropdown panels and mega-menus), `NotificationCenter` (a bell with an unread count that opens a popover inbox) + `NotificationList` |
68
68
  | Navigation | `Tabs`, `Accordion`, `Disclosure`, `Breadcrumbs`, `Pagination`, `Steps`, `NavList` + `NavItem` |
69
- | Data display | `Table` (sorting, selection), `Stat`, `FileTree`, `EmptyState`, `Tag`, `ColorSwatch`, `Avatar`, `AvatarGroup`, `User`, `Image` (a placeholder while it loads, a fallback if it fails, `ratio`, `caption`), `Timeline` + `TimelineItem`, `DescriptionList` + `DescriptionItem`, `Carousel` + `CarouselSlide` (scroll-snap, arrows, dots, autoplay), `SortableList` (reorder by dragging or with the keyboard) |
70
- | AI | `PromptInput` (attachments, stop while streaming) + `PromptSuggestion`, `ChatConversation` (follows the newest message, jump to latest), `ChatMessage` + `ChatMessageActions`, `ChatLoader`, `ChatTool` (a tool call with its status, input, output and approval), `ChainOfThought`, `ChatSource` + `ChatSources`, `TextShimmer` |
69
+ | Data display | `Table` (sorting, selection), `Stat`, `FileTree`, `EmptyState`, `Tag`, `ColorSwatch`, `Avatar`, `AvatarGroup`, `User`, `Image` (a placeholder while it loads, a fallback if it fails, `ratio`, `caption`), `Timeline` + `TimelineItem`, `DescriptionList` + `DescriptionItem`, `Carousel` + `CarouselSlide` (scroll-snap, arrows, dots, autoplay), `SortableList` (reorder by dragging or with the keyboard), `DiffViewer` (code diffs, unified or side by side, from two strings or a patch), `ActivityHeatmap` (a calendar of daily counts in shaded squares), `MediaPlayer` (audio and video with the library's own controls), `QRCode` (drawn as one SVG path, with its own encoder; `encodeQR()`) |
70
+ | AI | `PromptInput` (attachments, stop while streaming) + `PromptSuggestion`, `ChatConversation` (follows the newest message, jump to latest), `ChatMessage` + `ChatMessageActions`, `ChatLoader`, `ChatTool` (a tool call with its status, input, output and approval), `ChainOfThought`, `ChatSource` + `ChatSources`, `TextShimmer`, `Markdown` (a safe renderer for answers as they stream, code in CodeBlock) |
71
71
  | Layout | `Card`, `SettingsRow`, `Stack`, `Separator`, `ScrollShadow`, `VisuallyHidden`, `AspectRatio`, `Splitter` + `SplitterPanel` + `SplitterHandle` (panels you resize by dragging or with the arrow keys, collapsible, remembered), `VirtualList` (renders only the rows in view, for 10,000 rows, logs and infinite feeds) |
72
72
  | Marketing | `SiteHeader`, `SectionHeading`, `Chip`, `DotGrid` |
73
73
 
74
- Hooks for your own components: `useControllableState`, `useFloating` (top-layer positioning that flips), `usePresence` (keeps a layer mounted while it animates out), `useDismiss`, `useModalDialog`, `useMenuKeyboard`. Every prop is typed and described, so your editor explains it on hover.
74
+ Hooks for your own components: `useControllableState`, `useFloating` (top-layer positioning that flips), `usePresence` (keeps a layer mounted while it animates out), `useDismiss`, `useModalDialog`, `useMenuKeyboard`, `useVirtualizer` (the windowing behind VirtualList). Every prop is typed and described, so your editor explains it on hover.
75
75
 
76
76
  ## Blocks as components
77
77
 
@@ -0,0 +1,8 @@
1
+ import type { ActivityHeatmapProps } from "./ActivityHeatmap.types.cjs";
2
+ export type { ActivityHeatmapDay, ActivityHeatmapLabels, ActivityHeatmapProps } from "./ActivityHeatmap.types.cjs";
3
+ /**
4
+ * A GitHub-style calendar of daily counts: a column per week, a row per weekday, each day shaded by its count.
5
+ * It's a grid with one focusable day: the arrow keys move by day and week, and each day is read out in full,
6
+ * with a tooltip showing the number. It scrolls sideways inside itself, starting at the latest week.
7
+ */
8
+ export declare function ActivityHeatmap({ data, label, start, end, weekStartsOn, levels, thresholds, color, locale, formatTooltip, onDayClick, cellSize, showLegend, labels: labelsProp, className, }: ActivityHeatmapProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { ActivityHeatmapProps } from "./ActivityHeatmap.types.js";
2
+ export type { ActivityHeatmapDay, ActivityHeatmapLabels, ActivityHeatmapProps } from "./ActivityHeatmap.types.js";
3
+ /**
4
+ * A GitHub-style calendar of daily counts: a column per week, a row per weekday, each day shaded by its count.
5
+ * It's a grid with one focusable day: the arrow keys move by day and week, and each day is read out in full,
6
+ * with a tooltip showing the number. It scrolls sideways inside itself, starting at the latest week.
7
+ */
8
+ export declare function ActivityHeatmap({ data, label, start, end, weekStartsOn, levels, thresholds, color, locale, formatTooltip, onDayClick, cellSize, showLegend, labels: labelsProp, className, }: ActivityHeatmapProps): import("react").JSX.Element;
@@ -0,0 +1,73 @@
1
+ import type { ReactNode } from "react";
2
+ import type { ISODate } from "../Calendar/dates.cjs";
3
+ import type { ChartColor } from "../Chart/Chart.types.cjs";
4
+ /** One day's number: `{ date: "2026-03-03", count: 12 }`. */
5
+ export interface ActivityHeatmapDay {
6
+ /** The day, as "YYYY-MM-DD". */
7
+ date: ISODate;
8
+ /** How many things happened that day. Days left out count as 0. */
9
+ count: number;
10
+ }
11
+ export interface ActivityHeatmapLabels {
12
+ /** A day's number in words, in the tooltip, the cell's name and the summary.
13
+ * @default (count) => "No contributions", "1 contribution", "12 contributions" */
14
+ count?(count: number): string;
15
+ /** A cell's name for screen readers, from its count in words and its full date.
16
+ * @default (count, date) => `${count} on ${date}`, e.g. "12 contributions on Tuesday, 3 March 2026" */
17
+ day?(count: string, date: string): string;
18
+ /** What a screen reader hears before the grid: the total, and the busiest day when there is one.
19
+ * @default "1,204 contributions in total. The busiest day was Tuesday, 3 March 2026, with 42 contributions." */
20
+ summary?(total: string, busiest?: {
21
+ date: string;
22
+ count: string;
23
+ }): string;
24
+ /** The word before the legend's swatches. @default "Less" */
25
+ less?: string;
26
+ /** The word after them. @default "More" */
27
+ more?: string;
28
+ }
29
+ export interface ActivityHeatmapProps {
30
+ /** The numbers, one entry per day, in any order. Days with no entry show as empty; two entries for a day add up. */
31
+ data: ActivityHeatmapDay[];
32
+ /** What it shows, e.g. "Commits in the last year". It names the grid for screen readers. */
33
+ label: string;
34
+ /** The first day shown, "YYYY-MM-DD". @default 52 weeks before `end` */
35
+ start?: ISODate;
36
+ /** The last day shown, "YYYY-MM-DD". @default today */
37
+ end?: ISODate;
38
+ /** 1 starts each column on Monday, 0 on Sunday. @default the locale's first day of the week */
39
+ weekStartsOn?: 0 | 1;
40
+ /** How many shades, counting the empty one: 5 is empty and four steps up to the busiest day. Ignored with `thresholds`.
41
+ * @default 5 */
42
+ levels?: number;
43
+ /**
44
+ * The lowest count for each shade above empty, rising, e.g. `[1, 5, 10, 20]`: 1–4 is the lightest, 20 and over the
45
+ * darkest. @default `levels - 1` equal steps up to the busiest day
46
+ */
47
+ thresholds?: number[];
48
+ /** A chart palette slot (1–8) or any CSS colour, such as `"var(--ow-primary)"`. The shades are mixed from it and the
49
+ * empty colour, so they follow the theme. @default 1 */
50
+ color?: ChartColor;
51
+ /** Month and weekday names, dates and numbers follow this locale, e.g. "en-IE". @default the browser's */
52
+ locale?: string;
53
+ /** The tooltip for the hovered or focused day. @default its count and date, e.g. "12 contributions on Tue, 3 Mar 2026" */
54
+ formatTooltip?(day: ActivityHeatmapDay): ReactNode;
55
+ /** Makes each day a button: called with the day when it's clicked, or Enter or Space is pressed on it. */
56
+ onDayClick?(day: ActivityHeatmapDay): void;
57
+ /** The side of each square in pixels; the gap between them is a quarter of it. @default 12 */
58
+ cellSize?: number;
59
+ /** Shows "Less ▢▢▢▢▢ More" under the grid. @default true */
60
+ showLegend?: boolean;
61
+ /** The words it uses, for other languages. */
62
+ labels?: ActivityHeatmapLabels;
63
+ className?: string;
64
+ }
65
+ /** What `Intl.Locale` says about a locale's week, where the browser supports it: 1 is Monday … 7 is Sunday. Internal. */
66
+ export interface LocaleWeekInfo {
67
+ getWeekInfo?(): {
68
+ firstDay: number;
69
+ };
70
+ weekInfo?: {
71
+ firstDay: number;
72
+ };
73
+ }
@@ -0,0 +1,73 @@
1
+ import type { ReactNode } from "react";
2
+ import type { ISODate } from "../Calendar/dates.js";
3
+ import type { ChartColor } from "../Chart/Chart.types.js";
4
+ /** One day's number: `{ date: "2026-03-03", count: 12 }`. */
5
+ export interface ActivityHeatmapDay {
6
+ /** The day, as "YYYY-MM-DD". */
7
+ date: ISODate;
8
+ /** How many things happened that day. Days left out count as 0. */
9
+ count: number;
10
+ }
11
+ export interface ActivityHeatmapLabels {
12
+ /** A day's number in words, in the tooltip, the cell's name and the summary.
13
+ * @default (count) => "No contributions", "1 contribution", "12 contributions" */
14
+ count?(count: number): string;
15
+ /** A cell's name for screen readers, from its count in words and its full date.
16
+ * @default (count, date) => `${count} on ${date}`, e.g. "12 contributions on Tuesday, 3 March 2026" */
17
+ day?(count: string, date: string): string;
18
+ /** What a screen reader hears before the grid: the total, and the busiest day when there is one.
19
+ * @default "1,204 contributions in total. The busiest day was Tuesday, 3 March 2026, with 42 contributions." */
20
+ summary?(total: string, busiest?: {
21
+ date: string;
22
+ count: string;
23
+ }): string;
24
+ /** The word before the legend's swatches. @default "Less" */
25
+ less?: string;
26
+ /** The word after them. @default "More" */
27
+ more?: string;
28
+ }
29
+ export interface ActivityHeatmapProps {
30
+ /** The numbers, one entry per day, in any order. Days with no entry show as empty; two entries for a day add up. */
31
+ data: ActivityHeatmapDay[];
32
+ /** What it shows, e.g. "Commits in the last year". It names the grid for screen readers. */
33
+ label: string;
34
+ /** The first day shown, "YYYY-MM-DD". @default 52 weeks before `end` */
35
+ start?: ISODate;
36
+ /** The last day shown, "YYYY-MM-DD". @default today */
37
+ end?: ISODate;
38
+ /** 1 starts each column on Monday, 0 on Sunday. @default the locale's first day of the week */
39
+ weekStartsOn?: 0 | 1;
40
+ /** How many shades, counting the empty one: 5 is empty and four steps up to the busiest day. Ignored with `thresholds`.
41
+ * @default 5 */
42
+ levels?: number;
43
+ /**
44
+ * The lowest count for each shade above empty, rising, e.g. `[1, 5, 10, 20]`: 1–4 is the lightest, 20 and over the
45
+ * darkest. @default `levels - 1` equal steps up to the busiest day
46
+ */
47
+ thresholds?: number[];
48
+ /** A chart palette slot (1–8) or any CSS colour, such as `"var(--ow-primary)"`. The shades are mixed from it and the
49
+ * empty colour, so they follow the theme. @default 1 */
50
+ color?: ChartColor;
51
+ /** Month and weekday names, dates and numbers follow this locale, e.g. "en-IE". @default the browser's */
52
+ locale?: string;
53
+ /** The tooltip for the hovered or focused day. @default its count and date, e.g. "12 contributions on Tue, 3 Mar 2026" */
54
+ formatTooltip?(day: ActivityHeatmapDay): ReactNode;
55
+ /** Makes each day a button: called with the day when it's clicked, or Enter or Space is pressed on it. */
56
+ onDayClick?(day: ActivityHeatmapDay): void;
57
+ /** The side of each square in pixels; the gap between them is a quarter of it. @default 12 */
58
+ cellSize?: number;
59
+ /** Shows "Less ▢▢▢▢▢ More" under the grid. @default true */
60
+ showLegend?: boolean;
61
+ /** The words it uses, for other languages. */
62
+ labels?: ActivityHeatmapLabels;
63
+ className?: string;
64
+ }
65
+ /** What `Intl.Locale` says about a locale's week, where the browser supports it: 1 is Monday … 7 is Sunday. Internal. */
66
+ export interface LocaleWeekInfo {
67
+ getWeekInfo?(): {
68
+ firstDay: number;
69
+ };
70
+ weekInfo?: {
71
+ firstDay: number;
72
+ };
73
+ }
@@ -0,0 +1,8 @@
1
+ import type { DiffViewerProps } from "./DiffViewer.types.cjs";
2
+ export type { DiffViewerLabels, DiffViewerProps } from "./DiffViewer.types.cjs";
3
+ /**
4
+ * A code diff on the code block's night ground: from two versions of a text or from a unified patch, shown unified or
5
+ * side by side. Changed lines are tinted green or red with a "+" or "−" and read out as "Added" or "Removed"; the
6
+ * words that changed within them are marked; long runs of unchanged lines fold into buttons that show them.
7
+ */
8
+ export declare function DiffViewer({ oldValue, newValue, patch, view, splitMinWidth, language, filename, oldFilename, context, wrap, showLineNumbers, wordDiff, copyable, maxHeight, labels: labelsProp, className, ...props }: DiffViewerProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { DiffViewerProps } from "./DiffViewer.types.js";
2
+ export type { DiffViewerLabels, DiffViewerProps } from "./DiffViewer.types.js";
3
+ /**
4
+ * A code diff on the code block's night ground: from two versions of a text or from a unified patch, shown unified or
5
+ * side by side. Changed lines are tinted green or red with a "+" or "−" and read out as "Added" or "Removed"; the
6
+ * words that changed within them are marked; long runs of unchanged lines fold into buttons that show them.
7
+ */
8
+ export declare function DiffViewer({ oldValue, newValue, patch, view, splitMinWidth, language, filename, oldFilename, context, wrap, showLineNumbers, wordDiff, copyable, maxHeight, labels: labelsProp, className, ...props }: DiffViewerProps): import("react").JSX.Element;
@@ -0,0 +1,131 @@
1
+ import type { HTMLAttributes } from "react";
2
+ export interface DiffViewerLabels {
3
+ /** Read before each added line, which is otherwise only green with a "+".
4
+ * @default "Added" */
5
+ added?: string;
6
+ /** Read before each removed line.
7
+ * @default "Removed" */
8
+ removed?: string;
9
+ /** The header of the old line numbers' column, read by screen readers as they move through the table.
10
+ * @default "Old line" */
11
+ oldLine?: string;
12
+ /** The header of the new line numbers' column.
13
+ * @default "New line" */
14
+ newLine?: string;
15
+ /** The header of the lines' column in the unified view.
16
+ * @default "Line" */
17
+ line?: string;
18
+ /** The header of the old version's column in the split view.
19
+ * @default "Before" */
20
+ before?: string;
21
+ /** The header of the new version's column in the split view.
22
+ * @default "After" */
23
+ after?: string;
24
+ /** Names the table with the counts that show as "+3 −1".
25
+ * @default (added, removed) => `${added} lines added, ${removed} removed` */
26
+ summary?(added: number, removed: number): string;
27
+ /** The button that shows a collapsed run of unchanged lines.
28
+ * @default (count) => `Show ${count} unchanged lines` */
29
+ expand?(count: number): string;
30
+ /** The copy button's label.
31
+ * @default "Copy" */
32
+ copy?: string;
33
+ /** Shown when the two versions are the same.
34
+ * @default "No changes" */
35
+ noChanges?: string;
36
+ /** Read between the old and new name of a renamed file, for the "→" between them.
37
+ * @default "renamed to" */
38
+ renamed?: string;
39
+ }
40
+ export interface DiffViewerProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
41
+ /** The text before the change. Pass it with `newValue`, and the diff is worked out line by line. */
42
+ oldValue?: string;
43
+ /** The text after the change. */
44
+ newValue?: string;
45
+ /** A unified diff instead, as `git diff` prints it: its hunks and `@@` headers, and one file or several. */
46
+ patch?: string;
47
+ /** `unified` shows the lines one above the other; `split` puts the old version beside the new one, and wraps long
48
+ * lines so the two sides stay level.
49
+ * @default "unified" */
50
+ view?: "unified" | "split";
51
+ /** Below this width (pixels) a split view shows unified, as there isn't room for two columns. 0 keeps it split.
52
+ * @default 500 */
53
+ splitMinWidth?: number;
54
+ /** Shown on the right of the header, e.g. "tsx". */
55
+ language?: string;
56
+ /** The file's name in the header. With a `patch`, it's read from the patch unless you set it. */
57
+ filename?: string;
58
+ /** The name it had before, for a renamed file: shown as "old → new". */
59
+ oldFilename?: string;
60
+ /** How many unchanged lines show around each change. Longer runs of unchanged lines collapse to a button that
61
+ * shows them. `Infinity` shows every line.
62
+ * @default 3 */
63
+ context?: number;
64
+ /** Wraps long lines in the unified view instead of scrolling sideways. The split view always wraps.
65
+ * @default false */
66
+ wrap?: boolean;
67
+ /** @default true */
68
+ showLineNumbers?: boolean;
69
+ /** Marks the words that changed within a changed line.
70
+ * @default true */
71
+ wordDiff?: boolean;
72
+ /** Shows a copy button in the header. It copies `newValue`, or the file's part of the `patch`.
73
+ * @default true */
74
+ copyable?: boolean;
75
+ /** Scrolls each file past this height (pixels). */
76
+ maxHeight?: number;
77
+ /** The words it uses, for other languages. */
78
+ labels?: DiffViewerLabels;
79
+ }
80
+ /** A run of text within a changed line, and whether it's one of the words that changed. Internal. */
81
+ export interface DiffSegment {
82
+ text: string;
83
+ changed: boolean;
84
+ }
85
+ /** One line of a diff: unchanged, added, removed, or a patch's `@@` hunk header. Internal. */
86
+ export interface DiffLine {
87
+ type: "same" | "add" | "del" | "hunk";
88
+ text: string;
89
+ /** Its number in the old version, if it's in it. */
90
+ oldNo?: number;
91
+ /** Its number in the new version, if it's in it. */
92
+ newNo?: number;
93
+ /** The words that changed, when it pairs with a line on the other side. */
94
+ words?: DiffSegment[];
95
+ }
96
+ /** One file of a diff, worked out from two strings or read from a patch. Internal. */
97
+ export interface DiffFile {
98
+ oldName?: string;
99
+ newName?: string;
100
+ lines: DiffLine[];
101
+ /** What the copy button copies. */
102
+ text: string;
103
+ }
104
+ /** What a diff shows, row by row: a line, a run of unchanged lines collapsed to a button (`gap` is the first one's
105
+ * index), or in a split view a pair of lines side by side. Internal. */
106
+ export type DiffRow = {
107
+ kind: "line";
108
+ line: DiffLine;
109
+ reveal?: number;
110
+ } | {
111
+ kind: "gap";
112
+ gap: number;
113
+ count: number;
114
+ } | {
115
+ kind: "pair";
116
+ left?: DiffLine;
117
+ right?: DiffLine;
118
+ reveal?: number;
119
+ };
120
+ /** What each file's table is given. Internal. */
121
+ export interface DiffTableProps {
122
+ file: DiffFile;
123
+ split: boolean;
124
+ context: number;
125
+ wrap: boolean;
126
+ showLineNumbers: boolean;
127
+ copyable: boolean;
128
+ language?: string;
129
+ maxHeight?: number;
130
+ labels: Required<DiffViewerLabels>;
131
+ }
@@ -0,0 +1,131 @@
1
+ import type { HTMLAttributes } from "react";
2
+ export interface DiffViewerLabels {
3
+ /** Read before each added line, which is otherwise only green with a "+".
4
+ * @default "Added" */
5
+ added?: string;
6
+ /** Read before each removed line.
7
+ * @default "Removed" */
8
+ removed?: string;
9
+ /** The header of the old line numbers' column, read by screen readers as they move through the table.
10
+ * @default "Old line" */
11
+ oldLine?: string;
12
+ /** The header of the new line numbers' column.
13
+ * @default "New line" */
14
+ newLine?: string;
15
+ /** The header of the lines' column in the unified view.
16
+ * @default "Line" */
17
+ line?: string;
18
+ /** The header of the old version's column in the split view.
19
+ * @default "Before" */
20
+ before?: string;
21
+ /** The header of the new version's column in the split view.
22
+ * @default "After" */
23
+ after?: string;
24
+ /** Names the table with the counts that show as "+3 −1".
25
+ * @default (added, removed) => `${added} lines added, ${removed} removed` */
26
+ summary?(added: number, removed: number): string;
27
+ /** The button that shows a collapsed run of unchanged lines.
28
+ * @default (count) => `Show ${count} unchanged lines` */
29
+ expand?(count: number): string;
30
+ /** The copy button's label.
31
+ * @default "Copy" */
32
+ copy?: string;
33
+ /** Shown when the two versions are the same.
34
+ * @default "No changes" */
35
+ noChanges?: string;
36
+ /** Read between the old and new name of a renamed file, for the "→" between them.
37
+ * @default "renamed to" */
38
+ renamed?: string;
39
+ }
40
+ export interface DiffViewerProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
41
+ /** The text before the change. Pass it with `newValue`, and the diff is worked out line by line. */
42
+ oldValue?: string;
43
+ /** The text after the change. */
44
+ newValue?: string;
45
+ /** A unified diff instead, as `git diff` prints it: its hunks and `@@` headers, and one file or several. */
46
+ patch?: string;
47
+ /** `unified` shows the lines one above the other; `split` puts the old version beside the new one, and wraps long
48
+ * lines so the two sides stay level.
49
+ * @default "unified" */
50
+ view?: "unified" | "split";
51
+ /** Below this width (pixels) a split view shows unified, as there isn't room for two columns. 0 keeps it split.
52
+ * @default 500 */
53
+ splitMinWidth?: number;
54
+ /** Shown on the right of the header, e.g. "tsx". */
55
+ language?: string;
56
+ /** The file's name in the header. With a `patch`, it's read from the patch unless you set it. */
57
+ filename?: string;
58
+ /** The name it had before, for a renamed file: shown as "old → new". */
59
+ oldFilename?: string;
60
+ /** How many unchanged lines show around each change. Longer runs of unchanged lines collapse to a button that
61
+ * shows them. `Infinity` shows every line.
62
+ * @default 3 */
63
+ context?: number;
64
+ /** Wraps long lines in the unified view instead of scrolling sideways. The split view always wraps.
65
+ * @default false */
66
+ wrap?: boolean;
67
+ /** @default true */
68
+ showLineNumbers?: boolean;
69
+ /** Marks the words that changed within a changed line.
70
+ * @default true */
71
+ wordDiff?: boolean;
72
+ /** Shows a copy button in the header. It copies `newValue`, or the file's part of the `patch`.
73
+ * @default true */
74
+ copyable?: boolean;
75
+ /** Scrolls each file past this height (pixels). */
76
+ maxHeight?: number;
77
+ /** The words it uses, for other languages. */
78
+ labels?: DiffViewerLabels;
79
+ }
80
+ /** A run of text within a changed line, and whether it's one of the words that changed. Internal. */
81
+ export interface DiffSegment {
82
+ text: string;
83
+ changed: boolean;
84
+ }
85
+ /** One line of a diff: unchanged, added, removed, or a patch's `@@` hunk header. Internal. */
86
+ export interface DiffLine {
87
+ type: "same" | "add" | "del" | "hunk";
88
+ text: string;
89
+ /** Its number in the old version, if it's in it. */
90
+ oldNo?: number;
91
+ /** Its number in the new version, if it's in it. */
92
+ newNo?: number;
93
+ /** The words that changed, when it pairs with a line on the other side. */
94
+ words?: DiffSegment[];
95
+ }
96
+ /** One file of a diff, worked out from two strings or read from a patch. Internal. */
97
+ export interface DiffFile {
98
+ oldName?: string;
99
+ newName?: string;
100
+ lines: DiffLine[];
101
+ /** What the copy button copies. */
102
+ text: string;
103
+ }
104
+ /** What a diff shows, row by row: a line, a run of unchanged lines collapsed to a button (`gap` is the first one's
105
+ * index), or in a split view a pair of lines side by side. Internal. */
106
+ export type DiffRow = {
107
+ kind: "line";
108
+ line: DiffLine;
109
+ reveal?: number;
110
+ } | {
111
+ kind: "gap";
112
+ gap: number;
113
+ count: number;
114
+ } | {
115
+ kind: "pair";
116
+ left?: DiffLine;
117
+ right?: DiffLine;
118
+ reveal?: number;
119
+ };
120
+ /** What each file's table is given. Internal. */
121
+ export interface DiffTableProps {
122
+ file: DiffFile;
123
+ split: boolean;
124
+ context: number;
125
+ wrap: boolean;
126
+ showLineNumbers: boolean;
127
+ copyable: boolean;
128
+ language?: string;
129
+ maxHeight?: number;
130
+ labels: Required<DiffViewerLabels>;
131
+ }
@@ -0,0 +1,10 @@
1
+ import type { DiffFile, DiffLine, DiffRow } from "./DiffViewer.types.cjs";
2
+ /** The line-by-line diff of two texts. */
3
+ export declare function diffText(oldValue: string, newValue: string, words: boolean): DiffLine[];
4
+ /** Reads a unified diff: its files, their hunks and lines. Anything else (a commit message, index lines) is skipped. */
5
+ export declare function parsePatch(patch: string, words: boolean): DiffFile[];
6
+ /**
7
+ * The rows a file shows: its lines, with runs of unchanged lines beyond `context` of a change folded into a gap,
8
+ * unless that gap was opened. A file's first and last runs only keep the lines next to a change.
9
+ */
10
+ export declare function toRows(lines: DiffLine[], context: number, opened: number[], split: boolean): DiffRow[];
@@ -0,0 +1,10 @@
1
+ import type { DiffFile, DiffLine, DiffRow } from "./DiffViewer.types.js";
2
+ /** The line-by-line diff of two texts. */
3
+ export declare function diffText(oldValue: string, newValue: string, words: boolean): DiffLine[];
4
+ /** Reads a unified diff: its files, their hunks and lines. Anything else (a commit message, index lines) is skipped. */
5
+ export declare function parsePatch(patch: string, words: boolean): DiffFile[];
6
+ /**
7
+ * The rows a file shows: its lines, with runs of unchanged lines beyond `context` of a change folded into a gap,
8
+ * unless that gap was opened. A file's first and last runs only keep the lines next to a change.
9
+ */
10
+ export declare function toRows(lines: DiffLine[], context: number, opened: number[], split: boolean): DiffRow[];
@@ -0,0 +1,8 @@
1
+ import type { MarkdownProps } from "./Markdown.types.cjs";
2
+ export type { MarkdownCodeBlockProps, MarkdownComponents, MarkdownProps, MarkdownTag } from "./Markdown.types.cjs";
3
+ /**
4
+ * Renders Markdown safely, as React elements in Prose: no HTML is ever injected, raw HTML shows as text and only http,
5
+ * https, mailto and relative links are followed. It's built for an agent's answer as it streams: the unfinished end
6
+ * never flashes raw syntax, and the blocks above it aren't rendered again.
7
+ */
8
+ export declare function Markdown({ children, content, streaming, caret, size, allowImages, headingOffset, components, onLinkClick, className, ...props }: MarkdownProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { MarkdownProps } from "./Markdown.types.js";
2
+ export type { MarkdownCodeBlockProps, MarkdownComponents, MarkdownProps, MarkdownTag } from "./Markdown.types.js";
3
+ /**
4
+ * Renders Markdown safely, as React elements in Prose: no HTML is ever injected, raw HTML shows as text and only http,
5
+ * https, mailto and relative links are followed. It's built for an agent's answer as it streams: the unfinished end
6
+ * never flashes raw syntax, and the blocks above it aren't rendered again.
7
+ */
8
+ export declare function Markdown({ children, content, streaming, caret, size, allowImages, headingOffset, components, onLinkClick, className, ...props }: MarkdownProps): import("react").JSX.Element;
@@ -0,0 +1,59 @@
1
+ import type { ComponentType, ElementType, MouseEvent } from "react";
2
+ import type { ProseProps } from "../Prose/Prose.types.cjs";
3
+ /** The elements Markdown draws, each of which `components` can replace. */
4
+ export type MarkdownTag = "a" | "blockquote" | "code" | "del" | "em" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "hr" | "img" | "li" | "ol" | "p" | "strong" | "table" | "td" | "th" | "ul";
5
+ /** What a fenced code block's renderer gets. */
6
+ export interface MarkdownCodeBlockProps {
7
+ /** The code, without the fences. */
8
+ code: string;
9
+ /** The word after the opening fence, such as "tsx". */
10
+ language?: string;
11
+ }
12
+ /** Your own renderers, by element: a router's Link for `a`, say. Each gets the element's props and children. */
13
+ export type MarkdownComponents = Partial<Record<MarkdownTag, ElementType>> & {
14
+ /** Renders fenced code. Defaults to the library's CodeBlock. */
15
+ codeBlock?: ComponentType<MarkdownCodeBlockProps>;
16
+ };
17
+ export interface MarkdownProps extends Omit<ProseProps, "size" | "children"> {
18
+ /** The Markdown, as a string. */
19
+ children?: string;
20
+ /** The Markdown, if you'd rather not pass it as children. It wins over children. */
21
+ content?: string;
22
+ /** While the text is still arriving. An unfinished construct at the end (an open code fence, half a `**bold`, a link
23
+ * without its URL yet, half a table row) shows as what it's becoming, never as raw syntax, and the finished blocks
24
+ * above it aren't rendered again. The element is aria-busy meanwhile.
25
+ * @default false */
26
+ streaming?: boolean;
27
+ /** Blinks a caret after the last character while it streams; it holds still for reduced motion. Leave it off inside
28
+ * a streaming ChatMessage, which draws its own.
29
+ * @default false */
30
+ caret?: boolean;
31
+ /** chat sets 14px text with a tight rhythm, for answers in a conversation; article the prose style, for documents.
32
+ * @default "chat" */
33
+ size?: "chat" | "article";
34
+ /** Shows images. Off, an image shows as a link to it, named by its alt text.
35
+ * @default false */
36
+ allowImages?: boolean;
37
+ /** Moves every heading down this many levels, so `#` under a page's own h1 and h2 can be an h3.
38
+ * @default 0 */
39
+ headingOffset?: number;
40
+ /** Replaces the elements it draws with your own renderers. Keep the object stable (outside the component or memoised)
41
+ * so finished blocks aren't rendered again. */
42
+ components?: MarkdownComponents;
43
+ /** Called when a link is clicked, before it's followed; call `event.preventDefault()` to handle it yourself. */
44
+ onLinkClick?(event: MouseEvent<HTMLAnchorElement>, href: string): void;
45
+ }
46
+ /** What every block's renderer reads. Internal. */
47
+ export interface MarkdownContext {
48
+ components: MarkdownComponents | undefined;
49
+ allowImages: boolean;
50
+ headingOffset: number;
51
+ caret: boolean;
52
+ click(event: MouseEvent<HTMLAnchorElement>, href: string): void;
53
+ }
54
+ /** One top-level block, rendered again only when its source or whether it's the streaming end changes. Internal. */
55
+ export interface MarkdownBlockProps {
56
+ source: string;
57
+ context: MarkdownContext;
58
+ tail: boolean;
59
+ }