@lettuceai/crisp 1.0.0 → 1.1.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 +22 -0
- package/dist/components/Citation.d.ts +23 -0
- package/dist/components/DatePicker.d.ts +1 -1
- package/dist/components/Diff.d.ts +9 -0
- package/dist/components/EmptyState.d.ts +1 -1
- package/dist/components/FeedbackAction.d.ts +27 -0
- package/dist/components/OtpInput.d.ts +23 -0
- package/dist/components/PromptSuggestions.d.ts +29 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3224 -2676
- package/dist/index.js.map +1 -1
- package/dist/lib/format.d.ts +6 -6
- package/dist/lib/ref.d.ts +10 -0
- package/dist/lib/strings.d.ts +221 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -105,6 +105,28 @@ The provider exposes six presets through `presets`: Midnight, Ink, Vellum, Paper
|
|
|
105
105
|
|
|
106
106
|
Text, fill, border, and elevated surface colors are derived from the theme palette. For custom integrations, `themeToVars()` returns the CSS variables and `applyTheme()` applies a theme to an HTML element. The [theme definitions](src/theme/theme.ts) document the available values.
|
|
107
107
|
|
|
108
|
+
## Translating crisp
|
|
109
|
+
|
|
110
|
+
Every string crisp renders on its own (aria-labels, default prop text, status lines) lives in one typed object, `CrispStrings`. Wrap the app in `CrispStringsProvider` and pass only the strings you translate; the rest stay English. Entries that need values are functions.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { CrispStringsProvider } from "@lettuceai/crisp";
|
|
114
|
+
|
|
115
|
+
<CrispStringsProvider
|
|
116
|
+
locale="de"
|
|
117
|
+
strings={{
|
|
118
|
+
alertDismiss: "Schließen",
|
|
119
|
+
paginationPage: (page) => `Seite ${page}`,
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<App />
|
|
123
|
+
</CrispStringsProvider>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`locale` is a BCP 47 tag. It drives every `Intl` call, including `DatePicker`, and the format helpers. Props that already take text (`placeholder`, `backLabel`, `emptyMessage`, …) still win over the provider. Without a provider everything is English and `"en"`. `englishStrings` lists every key, and `useCrispStrings()` returns the active `{ strings, locale }` for your own components.
|
|
127
|
+
|
|
128
|
+
`relativeTime()`, `compactNumber()` and `fileSize()` take an optional trailing `locale`. English keeps its compact house style ("4 min ago", "1.2k", "1.5 MB"); other locales use `Intl.RelativeTimeFormat` and `Intl.NumberFormat`, so they need no extra strings.
|
|
129
|
+
|
|
108
130
|
## Utilities
|
|
109
131
|
|
|
110
132
|
- `cn()` merges conditional class names and resolves Tailwind class conflicts.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface CitationProps {
|
|
2
|
+
/** Numeric position or brief source tag: 1, 2, "arXiv", "docs". */
|
|
3
|
+
index: number | string;
|
|
4
|
+
/** Full document title or webpage header. */
|
|
5
|
+
title: string;
|
|
6
|
+
/** Direct URL to the source. */
|
|
7
|
+
url?: string;
|
|
8
|
+
/** Key excerpt or snippet used for model grounding. */
|
|
9
|
+
snippet?: string;
|
|
10
|
+
/** Domain name (e.g. "wikipedia.org") or publisher. */
|
|
11
|
+
domain?: string;
|
|
12
|
+
/** Optional custom icon or favicon URL. */
|
|
13
|
+
favicon?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* An inline citation for retrieved context and RAG sources.
|
|
18
|
+
* Reveals a hover card on desktop and opens a bottom sheet on mobile.
|
|
19
|
+
*/
|
|
20
|
+
export declare function Citation({ index, title, url, snippet, domain, favicon, className }: CitationProps): import("react").JSX.Element;
|
|
21
|
+
export declare namespace Citation {
|
|
22
|
+
var displayName: string;
|
|
23
|
+
}
|
|
@@ -9,7 +9,7 @@ export interface CalendarProps {
|
|
|
9
9
|
className?: string;
|
|
10
10
|
}
|
|
11
11
|
/** The month grid. Uses Intl for day and month names, so it follows the app's 20 locales. */
|
|
12
|
-
export declare function Calendar({ value, onChange, min, max, weekStartsOn, locale, className }: CalendarProps): import("react").JSX.Element;
|
|
12
|
+
export declare function Calendar({ value, onChange, min, max, weekStartsOn, locale: localeProp, className }: CalendarProps): import("react").JSX.Element;
|
|
13
13
|
export interface DatePickerProps extends Omit<CalendarProps, "className"> {
|
|
14
14
|
/** Shown when nothing is chosen. */
|
|
15
15
|
placeholder?: string;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export type Op = "same" | "add" | "remove";
|
|
2
|
+
export interface Line {
|
|
3
|
+
op: Op;
|
|
4
|
+
text: string;
|
|
5
|
+
a?: number;
|
|
6
|
+
b?: number;
|
|
7
|
+
}
|
|
8
|
+
/** Longest common subsequence, line-wise. Enough for settings and character fields. */
|
|
9
|
+
export declare function diffLines(before: string, after: string): Line[];
|
|
1
10
|
export interface DiffProps {
|
|
2
11
|
before: string;
|
|
3
12
|
after: string;
|
|
@@ -21,4 +21,4 @@ export interface ErrorStateProps {
|
|
|
21
21
|
className?: string;
|
|
22
22
|
}
|
|
23
23
|
/** Something failed to load. Says what, and offers the one thing that might fix it. */
|
|
24
|
-
export declare function ErrorState({ title, description, onRetry, retryLabel, size, className }: ErrorStateProps): import("react").JSX.Element;
|
|
24
|
+
export declare function ErrorState({ title: titleProp, description, onRetry, retryLabel, size, className }: ErrorStateProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type FeedbackSentiment = "like" | "dislike" | null;
|
|
3
|
+
export interface FeedbackActionProps {
|
|
4
|
+
/** Active feedback state. */
|
|
5
|
+
sentiment?: FeedbackSentiment;
|
|
6
|
+
/** Triggered when the like/thumbs-up button is tapped. */
|
|
7
|
+
onLike?: () => void;
|
|
8
|
+
/** Triggered when the dislike/thumbs-down button is tapped. */
|
|
9
|
+
onDislike?: () => void;
|
|
10
|
+
/** Custom handler for copying message text. */
|
|
11
|
+
onCopy?: () => void;
|
|
12
|
+
/** Text to copy to clipboard if onCopy is not provided. */
|
|
13
|
+
copyText?: string;
|
|
14
|
+
/** Triggered when asking the model to regenerate the response. */
|
|
15
|
+
onRetry?: () => void;
|
|
16
|
+
/** Additional action items to display inline (e.g. share or edit). */
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* An action bar for AI responses: like, dislike, copy, and regenerate.
|
|
22
|
+
* Placed at the bottom of messages to collect evaluation feedback.
|
|
23
|
+
*/
|
|
24
|
+
export declare function FeedbackAction({ sentiment, onLike, onDislike, onCopy, copyText, onRetry, children, className, }: FeedbackActionProps): import("react").JSX.Element;
|
|
25
|
+
export declare namespace FeedbackAction {
|
|
26
|
+
var displayName: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface OtpInputProps {
|
|
2
|
+
/** Total number of PIN digits/cells. Default 6. */
|
|
3
|
+
length?: number;
|
|
4
|
+
/** Current combined string value. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** Callback fired whenever the value changes. */
|
|
7
|
+
onChange: (value: string) => void;
|
|
8
|
+
/** Callback fired when all digits have been entered. */
|
|
9
|
+
onComplete?: (value: string) => void;
|
|
10
|
+
/** Numeric (digits only) or alphanumeric. Default "number". */
|
|
11
|
+
type?: "number" | "text";
|
|
12
|
+
/** Mask characters like password dots. */
|
|
13
|
+
mask?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
autoFocus?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
id?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Segmented PIN / OTP verification code input.
|
|
21
|
+
* Supports auto-advancing focus, backspace navigation, and multi-digit paste splitting.
|
|
22
|
+
*/
|
|
23
|
+
export declare const OtpInput: import("react").ForwardRefExoticComponent<OtpInputProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface PromptSuggestionItem {
|
|
3
|
+
id: string;
|
|
4
|
+
/** Short headline shown prominently, e.g. "Summarize PDF", "Draft reply". */
|
|
5
|
+
title: string;
|
|
6
|
+
/** Complete prompt string passed to composer/model. */
|
|
7
|
+
prompt: string;
|
|
8
|
+
/** Supporting subtitle or description. */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Icon shown at top-left. */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** Category badge, e.g. "Creative", "Code", "Analysis". */
|
|
13
|
+
badge?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PromptSuggestionsProps {
|
|
16
|
+
prompts: readonly PromptSuggestionItem[];
|
|
17
|
+
onSelect: (prompt: string, item: PromptSuggestionItem) => void;
|
|
18
|
+
title?: ReactNode;
|
|
19
|
+
columns?: 1 | 2 | 3 | 4;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Suggested prompt starter cards for empty chat states and onboarding.
|
|
24
|
+
* Helps users discover model capabilities without staring at an empty input.
|
|
25
|
+
*/
|
|
26
|
+
export declare function PromptSuggestions({ prompts, onSelect, title, columns, className, }: PromptSuggestionsProps): import("react").JSX.Element;
|
|
27
|
+
export declare namespace PromptSuggestions {
|
|
28
|
+
var displayName: string;
|
|
29
|
+
}
|
|
@@ -101,3 +101,7 @@ export * from "./ReorderableList";
|
|
|
101
101
|
export * from "./AvatarPicker";
|
|
102
102
|
export * from "./Page";
|
|
103
103
|
export * from "./ModelSelect";
|
|
104
|
+
export * from "./Citation";
|
|
105
|
+
export * from "./FeedbackAction";
|
|
106
|
+
export * from "./PromptSuggestions";
|
|
107
|
+
export * from "./OtpInput";
|
package/dist/index.d.ts
CHANGED
|
@@ -13,3 +13,6 @@ export { tintFromName } from "./lib/tint";
|
|
|
13
13
|
export { hexToRgb, normaliseHex, luminance, contrastRatio, isLight, readableOn, mixHex } from "./lib/color";
|
|
14
14
|
export type { PolymorphicProps, PolymorphicRef, PolymorphicComponent } from "./lib/polymorphic";
|
|
15
15
|
export { relativeTime, compactNumber, fileSize } from "./lib/format";
|
|
16
|
+
export { mergeRefs, getElementRef } from "./lib/ref";
|
|
17
|
+
export { englishStrings, CrispStringsProvider, useCrispStrings } from "./lib/strings";
|
|
18
|
+
export type { CrispStrings, CrispStringsProviderProps } from "./lib/strings";
|