@majapisoftwares/ui 6.3.0 → 6.4.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/AGENTS.md +27 -27
- package/README.md +79 -79
- package/THIRD_PARTY_NOTICES.md +39 -39
- package/components.json +25 -25
- package/docs/MIGRATION-0.2.md +20 -20
- package/docs/MIGRATION-6.0.md +33 -33
- package/docs/NEXT-STARTER-VALIDATION.md +14 -14
- package/docs/STANDARDS.md +65 -51
- package/docs/VALIDATION.md +11 -11
- package/docs/VERSIONING.md +32 -28
- package/docs/validation/preference-titles.md +22 -22
- package/package.json +91 -89
- package/scripts/check-standards.mjs +41 -41
- package/src/components/ui/accordion.tsx +82 -82
- package/src/components/ui/alert-dialog.tsx +187 -187
- package/src/components/ui/alert.tsx +77 -77
- package/src/components/ui/attachment.tsx +209 -0
- package/src/components/ui/avatar.tsx +108 -108
- package/src/components/ui/badge.tsx +55 -55
- package/src/components/ui/breadcrumb.tsx +125 -125
- package/src/components/ui/bubble.tsx +129 -0
- package/src/components/ui/button-group.tsx +89 -89
- package/src/components/ui/button.tsx +59 -59
- package/src/components/ui/card.tsx +101 -101
- package/src/components/ui/checkbox.tsx +27 -27
- package/src/components/ui/collapsible.tsx +21 -21
- package/src/components/ui/context-menu.tsx +271 -271
- package/src/components/ui/dialog.tsx +161 -161
- package/src/components/ui/dropdown-menu.tsx +271 -271
- package/src/components/ui/empty.tsx +105 -105
- package/src/components/ui/field.tsx +238 -238
- package/src/components/ui/hover-card.tsx +50 -50
- package/src/components/ui/input-group.tsx +155 -155
- package/src/components/ui/input.tsx +21 -21
- package/src/components/ui/item.tsx +203 -0
- package/src/components/ui/kbd.tsx +28 -28
- package/src/components/ui/label.tsx +19 -19
- package/src/components/ui/message-scroller.tsx +166 -0
- package/src/components/ui/message.tsx +93 -0
- package/src/components/ui/orb.css +1002 -1002
- package/src/components/ui/orb.tsx +752 -752
- package/src/components/ui/popover.tsx +89 -89
- package/src/components/ui/progress.tsx +82 -82
- package/src/components/ui/radio-group.tsx +37 -37
- package/src/components/ui/scroll-area.tsx +54 -54
- package/src/components/ui/select.tsx +204 -204
- package/src/components/ui/separator.tsx +24 -24
- package/src/components/ui/sheet.tsx +139 -139
- package/src/components/ui/sidebar.tsx +1048 -1048
- package/src/components/ui/skeleton.tsx +15 -15
- package/src/components/ui/slider.tsx +53 -53
- package/src/components/ui/sonner.tsx +44 -44
- package/src/components/ui/spinner.tsx +32 -32
- package/src/components/ui/switch.tsx +31 -31
- package/src/components/ui/table.tsx +121 -121
- package/src/components/ui/tabs.tsx +81 -81
- package/src/components/ui/textarea.tsx +19 -19
- package/src/components/ui/toggle-group.tsx +89 -89
- package/src/components/ui/toggle.tsx +44 -44
- package/src/components/ui/tooltip.tsx +65 -65
- package/src/components/ui/trace.tsx +163 -0
- package/src/hooks/use-mobile.ts +20 -20
- package/src/hooks/use-streamed-text.ts +64 -0
- package/src/lib/i18n.tsx +151 -109
- package/src/lib/utils.ts +1 -1
- package/src/patterns/app-shell.tsx +237 -237
- package/src/patterns/chat-markdown.tsx +72 -0
- package/src/patterns/chat-trace.tsx +200 -0
- package/src/patterns/chat.tsx +317 -0
- package/src/patterns/data-table.tsx +2492 -2492
- package/src/patterns/filter-tabs.tsx +53 -53
- package/src/patterns/majapi-logo.tsx +32 -32
- package/src/patterns/page-header.tsx +62 -62
- package/src/patterns/prompt-input.tsx +364 -0
- package/src/patterns/status-badge.tsx +24 -24
- package/src/patterns/user-menu.tsx +218 -218
- package/src/patterns/workspace-switcher.tsx +176 -176
- package/src/styles.css +170 -165
- package/src/templates/admin-dashboard.tsx +44 -44
- package/src/templates/auth-layout.tsx +30 -30
- package/src/templates/signup-form.tsx +177 -177
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Collapsible,
|
|
8
|
+
CollapsibleContent,
|
|
9
|
+
CollapsibleTrigger,
|
|
10
|
+
} from "./collapsible";
|
|
11
|
+
import { ChevronRightIcon } from "lucide-react";
|
|
12
|
+
|
|
13
|
+
function Trace({ className, ...props }: React.ComponentProps<"div">) {
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
data-slot="trace"
|
|
17
|
+
className={cn(
|
|
18
|
+
"flex w-full min-w-0 flex-col gap-3 *:has-[>[data-slot=trace-line]]:flex *:has-[>[data-slot=trace-line]]:w-fit *:has-[>[data-slot=trace-line]]:max-w-full *:has-[>[data-slot=trace-line]]:min-w-0 *:has-[>[data-slot=trace-line]]:rounded-lg *:has-[>[data-slot=trace-line]]:text-left *:has-[>[data-slot=trace-line]]:outline-none *:has-[>[data-slot=trace-line]]:focus-visible:ring-3 *:has-[>[data-slot=trace-line]]:focus-visible:ring-ring/30",
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function TraceLine({
|
|
27
|
+
className,
|
|
28
|
+
status,
|
|
29
|
+
...props
|
|
30
|
+
}: React.ComponentProps<"span"> & {
|
|
31
|
+
status?: "running" | "error" | "pending";
|
|
32
|
+
}) {
|
|
33
|
+
return (
|
|
34
|
+
<span
|
|
35
|
+
data-slot="trace-line"
|
|
36
|
+
data-status={status}
|
|
37
|
+
className={cn(
|
|
38
|
+
"flex w-fit max-w-full min-w-0 items-center gap-2 text-sm text-muted-foreground transition-colors in-[a,button]:cursor-pointer in-[a:hover,button:hover]:text-foreground data-[status=error]:text-destructive data-[status=error]:in-[a:hover,button:hover]:text-destructive data-[status=pending]:opacity-60 data-[status=running]:*:data-[slot=trace-title]:shimmer",
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function TraceIcon({ className, ...props }: React.ComponentProps<"span">) {
|
|
47
|
+
return (
|
|
48
|
+
<span
|
|
49
|
+
data-slot="trace-icon"
|
|
50
|
+
aria-hidden="true"
|
|
51
|
+
className={cn(
|
|
52
|
+
"flex size-4 shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [[data-slot=trace-title]~&]:-ml-1",
|
|
53
|
+
className,
|
|
54
|
+
)}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function TraceTitle({ className, ...props }: React.ComponentProps<"span">) {
|
|
61
|
+
return (
|
|
62
|
+
<span
|
|
63
|
+
data-slot="trace-title"
|
|
64
|
+
className={cn("min-w-0 truncate motion-reduce:shimmer-none", className)}
|
|
65
|
+
{...props}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function TraceDescription({
|
|
71
|
+
className,
|
|
72
|
+
...props
|
|
73
|
+
}: React.ComponentProps<"span">) {
|
|
74
|
+
return (
|
|
75
|
+
<span
|
|
76
|
+
data-slot="trace-description"
|
|
77
|
+
className={cn(
|
|
78
|
+
"shrink-0 text-muted-foreground/70 tabular-nums",
|
|
79
|
+
className,
|
|
80
|
+
)}
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function TraceCollapsible({
|
|
87
|
+
className,
|
|
88
|
+
...props
|
|
89
|
+
}: Omit<React.ComponentProps<typeof Collapsible>, "open"> &
|
|
90
|
+
(
|
|
91
|
+
| { open?: undefined }
|
|
92
|
+
| {
|
|
93
|
+
open: boolean;
|
|
94
|
+
onOpenChange: NonNullable<
|
|
95
|
+
React.ComponentProps<typeof Collapsible>["onOpenChange"]
|
|
96
|
+
>;
|
|
97
|
+
}
|
|
98
|
+
)) {
|
|
99
|
+
return (
|
|
100
|
+
<Collapsible
|
|
101
|
+
data-slot="trace-collapsible"
|
|
102
|
+
className={cn("flex w-full min-w-0 flex-col", className)}
|
|
103
|
+
{...props}
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function TraceCollapsibleTrigger({
|
|
109
|
+
className,
|
|
110
|
+
children,
|
|
111
|
+
...props
|
|
112
|
+
}: React.ComponentProps<typeof CollapsibleTrigger>) {
|
|
113
|
+
return (
|
|
114
|
+
<CollapsibleTrigger
|
|
115
|
+
data-slot="trace-collapsible-trigger"
|
|
116
|
+
className={cn(
|
|
117
|
+
"group/trace-collapsible-trigger flex w-fit max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-lg text-left text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30 has-[[data-status=error]]:text-destructive",
|
|
118
|
+
className,
|
|
119
|
+
)}
|
|
120
|
+
{...props}
|
|
121
|
+
>
|
|
122
|
+
{children}
|
|
123
|
+
<TraceIcon className="transition-transform group-aria-expanded/trace-collapsible-trigger:rotate-90">
|
|
124
|
+
<ChevronRightIcon />
|
|
125
|
+
</TraceIcon>
|
|
126
|
+
</CollapsibleTrigger>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function TraceCollapsibleContent({
|
|
131
|
+
className,
|
|
132
|
+
children,
|
|
133
|
+
...props
|
|
134
|
+
}: React.ComponentProps<typeof CollapsibleContent>) {
|
|
135
|
+
return (
|
|
136
|
+
<CollapsibleContent
|
|
137
|
+
data-slot="trace-collapsible-content"
|
|
138
|
+
className="h-(--collapsible-panel-height) min-w-0 overflow-hidden transition-[height] duration-200 data-ending-style:h-0 data-starting-style:h-0"
|
|
139
|
+
{...props}
|
|
140
|
+
>
|
|
141
|
+
<div
|
|
142
|
+
data-slot="trace-collapsible-content-inner"
|
|
143
|
+
className={cn(
|
|
144
|
+
"mt-2.5 mb-1 ml-[calc(--spacing(2)-1px)] min-w-0 border-l pr-1 pl-4 leading-relaxed wrap-break-word text-muted-foreground",
|
|
145
|
+
className,
|
|
146
|
+
)}
|
|
147
|
+
>
|
|
148
|
+
{children}
|
|
149
|
+
</div>
|
|
150
|
+
</CollapsibleContent>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
Trace,
|
|
156
|
+
TraceLine,
|
|
157
|
+
TraceIcon,
|
|
158
|
+
TraceTitle,
|
|
159
|
+
TraceDescription,
|
|
160
|
+
TraceCollapsible,
|
|
161
|
+
TraceCollapsibleTrigger,
|
|
162
|
+
TraceCollapsibleContent,
|
|
163
|
+
};
|
package/src/hooks/use-mobile.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
const MOBILE_BREAKPOINT = 768;
|
|
6
|
-
const query = `(max-width: ${MOBILE_BREAKPOINT - 1}px)`;
|
|
7
|
-
|
|
8
|
-
function subscribe(onChange: () => void) {
|
|
9
|
-
const mql = window.matchMedia(query);
|
|
10
|
-
mql.addEventListener("change", onChange);
|
|
11
|
-
return () => mql.removeEventListener("change", onChange);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function useIsMobile() {
|
|
15
|
-
return React.useSyncExternalStore(
|
|
16
|
-
subscribe,
|
|
17
|
-
() => window.matchMedia(query).matches,
|
|
18
|
-
() => false,
|
|
19
|
-
);
|
|
20
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
const MOBILE_BREAKPOINT = 768;
|
|
6
|
+
const query = `(max-width: ${MOBILE_BREAKPOINT - 1}px)`;
|
|
7
|
+
|
|
8
|
+
function subscribe(onChange: () => void) {
|
|
9
|
+
const mql = window.matchMedia(query);
|
|
10
|
+
mql.addEventListener("change", onChange);
|
|
11
|
+
return () => mql.removeEventListener("change", onChange);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function useIsMobile() {
|
|
15
|
+
return React.useSyncExternalStore(
|
|
16
|
+
subscribe,
|
|
17
|
+
() => window.matchMedia(query).matches,
|
|
18
|
+
() => false,
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useEffectEvent, useMemo, useState } from "react";
|
|
4
|
+
|
|
5
|
+
const INTERVAL_MS = 24;
|
|
6
|
+
const MIN_DURATION_MS = 480;
|
|
7
|
+
const MAX_DURATION_MS = 2400;
|
|
8
|
+
const MS_PER_CHARACTER = 6;
|
|
9
|
+
|
|
10
|
+
export interface UseStreamedTextOptions {
|
|
11
|
+
/** Reveals the text progressively. When false the full text is returned. */
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
/** Called once the whole text is visible. */
|
|
14
|
+
onComplete?: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Reveals a complete reply progressively, for backends that return the whole
|
|
19
|
+
* message at once (from Numa). Short replies take ~0.5s and long ones at most
|
|
20
|
+
* ~2.4s. Respects prefers-reduced-motion by showing the text immediately.
|
|
21
|
+
*/
|
|
22
|
+
export function useStreamedText(
|
|
23
|
+
text: string,
|
|
24
|
+
{ enabled, onComplete }: UseStreamedTextOptions,
|
|
25
|
+
) {
|
|
26
|
+
const characters = useMemo(() => Array.from(text), [text]);
|
|
27
|
+
const [state, setState] = useState(() => ({
|
|
28
|
+
text,
|
|
29
|
+
visible: enabled ? Math.min(1, characters.length) : characters.length,
|
|
30
|
+
}));
|
|
31
|
+
const complete = useEffectEvent(() => onComplete?.());
|
|
32
|
+
// A new text restarts the reveal.
|
|
33
|
+
const visible = state.text === text ? state.visible : enabled ? 0 : characters.length;
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!enabled) return;
|
|
37
|
+
const total = characters.length;
|
|
38
|
+
if (total <= 1 || matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
39
|
+
const timeout = setTimeout(() => {
|
|
40
|
+
setState({ text, visible: total });
|
|
41
|
+
complete();
|
|
42
|
+
}, 0);
|
|
43
|
+
return () => clearTimeout(timeout);
|
|
44
|
+
}
|
|
45
|
+
const duration = Math.min(
|
|
46
|
+
MAX_DURATION_MS,
|
|
47
|
+
Math.max(MIN_DURATION_MS, total * MS_PER_CHARACTER),
|
|
48
|
+
);
|
|
49
|
+
const step = Math.max(1, Math.ceil(total / Math.ceil(duration / INTERVAL_MS)));
|
|
50
|
+
let next = Math.min(1, total);
|
|
51
|
+
const interval = setInterval(() => {
|
|
52
|
+
next = Math.min(total, next + step);
|
|
53
|
+
setState({ text, visible: next });
|
|
54
|
+
if (next === total) {
|
|
55
|
+
clearInterval(interval);
|
|
56
|
+
complete();
|
|
57
|
+
}
|
|
58
|
+
}, INTERVAL_MS);
|
|
59
|
+
return () => clearInterval(interval);
|
|
60
|
+
}, [characters, enabled, text]);
|
|
61
|
+
|
|
62
|
+
if (!enabled) return text;
|
|
63
|
+
return characters.slice(0, visible).join("");
|
|
64
|
+
}
|
package/src/lib/i18n.tsx
CHANGED
|
@@ -1,109 +1,151 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { createContext, useContext, type ReactNode } from "react";
|
|
4
|
-
|
|
5
|
-
export const locales = ["en", "pt-BR"] as const;
|
|
6
|
-
export type Locale = (typeof locales)[number];
|
|
7
|
-
export type Messages<T> = Record<Locale, T>;
|
|
8
|
-
|
|
9
|
-
/** Declares a message catalog; every locale must provide every key. */
|
|
10
|
-
export function defineMessages<T>(messages: Messages<T>) {
|
|
11
|
-
return messages;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const LocaleContext = createContext<Locale>("en");
|
|
15
|
-
|
|
16
|
-
export function LocaleProvider({
|
|
17
|
-
locale,
|
|
18
|
-
children,
|
|
19
|
-
}: {
|
|
20
|
-
locale: Locale;
|
|
21
|
-
children: ReactNode;
|
|
22
|
-
}) {
|
|
23
|
-
return (
|
|
24
|
-
<LocaleContext.Provider value={locale}>{children}</LocaleContext.Provider>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function useLocale() {
|
|
29
|
-
return useContext(LocaleContext);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function useMessages<T>(messages: Messages<T>): T {
|
|
33
|
-
return messages[useLocale()];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** Picks the supported locale that best matches a list such as navigator.languages. */
|
|
37
|
-
export function matchLocale(preferred: readonly string[]): Locale {
|
|
38
|
-
for (const tag of preferred) {
|
|
39
|
-
const lower = tag.toLowerCase();
|
|
40
|
-
if (lower.startsWith("pt")) return "pt-BR";
|
|
41
|
-
if (lower.startsWith("en")) return "en";
|
|
42
|
-
}
|
|
43
|
-
return "en";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const uiMessages = defineMessages({
|
|
47
|
-
en: {
|
|
48
|
-
sidebar: "Sidebar",
|
|
49
|
-
toggleSidebar: "Toggle sidebar",
|
|
50
|
-
collapseSidebar: "Collapse sidebar",
|
|
51
|
-
expandSidebar: "Expand sidebar",
|
|
52
|
-
resizeSidebar: "Resize sidebar",
|
|
53
|
-
modeOpen: "Expanded",
|
|
54
|
-
modeCompact: "Compact",
|
|
55
|
-
modeClosed: "Hidden",
|
|
56
|
-
sidebarHint: (shortcut: string) =>
|
|
57
|
-
`Right-click for options · ${shortcut} hides`,
|
|
58
|
-
search: "Search",
|
|
59
|
-
noResults: "No results",
|
|
60
|
-
noData: "Nothing here yet",
|
|
61
|
-
clearSearch: "Clear search",
|
|
62
|
-
retry: "Retry",
|
|
63
|
-
loadFailed: "Couldn't load data",
|
|
64
|
-
staleData: "Showing data from the last successful load",
|
|
65
|
-
previous: "Previous",
|
|
66
|
-
next: "Next",
|
|
67
|
-
open: "Open",
|
|
68
|
-
page: (page: number, total: number) => `Page ${page} of ${total}`,
|
|
69
|
-
rows: (count: number) => `${count} ${count === 1 ? "row" : "rows"}`,
|
|
70
|
-
close: "Close",
|
|
71
|
-
language: "Language",
|
|
72
|
-
toggleTheme: "Toggle theme",
|
|
73
|
-
more: "More",
|
|
74
|
-
loading: "Loading",
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, type ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
export const locales = ["en", "pt-BR"] as const;
|
|
6
|
+
export type Locale = (typeof locales)[number];
|
|
7
|
+
export type Messages<T> = Record<Locale, T>;
|
|
8
|
+
|
|
9
|
+
/** Declares a message catalog; every locale must provide every key. */
|
|
10
|
+
export function defineMessages<T>(messages: Messages<T>) {
|
|
11
|
+
return messages;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const LocaleContext = createContext<Locale>("en");
|
|
15
|
+
|
|
16
|
+
export function LocaleProvider({
|
|
17
|
+
locale,
|
|
18
|
+
children,
|
|
19
|
+
}: {
|
|
20
|
+
locale: Locale;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}) {
|
|
23
|
+
return (
|
|
24
|
+
<LocaleContext.Provider value={locale}>{children}</LocaleContext.Provider>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function useLocale() {
|
|
29
|
+
return useContext(LocaleContext);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function useMessages<T>(messages: Messages<T>): T {
|
|
33
|
+
return messages[useLocale()];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Picks the supported locale that best matches a list such as navigator.languages. */
|
|
37
|
+
export function matchLocale(preferred: readonly string[]): Locale {
|
|
38
|
+
for (const tag of preferred) {
|
|
39
|
+
const lower = tag.toLowerCase();
|
|
40
|
+
if (lower.startsWith("pt")) return "pt-BR";
|
|
41
|
+
if (lower.startsWith("en")) return "en";
|
|
42
|
+
}
|
|
43
|
+
return "en";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const uiMessages = defineMessages({
|
|
47
|
+
en: {
|
|
48
|
+
sidebar: "Sidebar",
|
|
49
|
+
toggleSidebar: "Toggle sidebar",
|
|
50
|
+
collapseSidebar: "Collapse sidebar",
|
|
51
|
+
expandSidebar: "Expand sidebar",
|
|
52
|
+
resizeSidebar: "Resize sidebar",
|
|
53
|
+
modeOpen: "Expanded",
|
|
54
|
+
modeCompact: "Compact",
|
|
55
|
+
modeClosed: "Hidden",
|
|
56
|
+
sidebarHint: (shortcut: string) =>
|
|
57
|
+
`Right-click for options · ${shortcut} hides`,
|
|
58
|
+
search: "Search",
|
|
59
|
+
noResults: "No results",
|
|
60
|
+
noData: "Nothing here yet",
|
|
61
|
+
clearSearch: "Clear search",
|
|
62
|
+
retry: "Retry",
|
|
63
|
+
loadFailed: "Couldn't load data",
|
|
64
|
+
staleData: "Showing data from the last successful load",
|
|
65
|
+
previous: "Previous",
|
|
66
|
+
next: "Next",
|
|
67
|
+
open: "Open",
|
|
68
|
+
page: (page: number, total: number) => `Page ${page} of ${total}`,
|
|
69
|
+
rows: (count: number) => `${count} ${count === 1 ? "row" : "rows"}`,
|
|
70
|
+
close: "Close",
|
|
71
|
+
language: "Language",
|
|
72
|
+
toggleTheme: "Toggle theme",
|
|
73
|
+
more: "More",
|
|
74
|
+
loading: "Loading",
|
|
75
|
+
messages: "Messages",
|
|
76
|
+
scrollToEnd: "Scroll to latest",
|
|
77
|
+
scrollToStart: "Scroll to start",
|
|
78
|
+
promptPlaceholder: "Ask anything",
|
|
79
|
+
prompt: "Message",
|
|
80
|
+
send: "Send",
|
|
81
|
+
stop: "Stop",
|
|
82
|
+
attachFiles: "Attach files",
|
|
83
|
+
removeAttachment: (name: string) => `Remove ${name}`,
|
|
84
|
+
attachments: "Attachments",
|
|
85
|
+
responding: "Responding",
|
|
86
|
+
copy: "Copy",
|
|
87
|
+
copied: "Copied",
|
|
88
|
+
goodResponse: "Good response",
|
|
89
|
+
badResponse: "Bad response",
|
|
90
|
+
thinking: "Thinking",
|
|
91
|
+
thought: "Thought",
|
|
92
|
+
thoughtFor: (seconds: number) => `Thought for ${seconds}s`,
|
|
93
|
+
approve: "Approve",
|
|
94
|
+
deny: "Deny",
|
|
95
|
+
suggestions: "Suggestions",
|
|
96
|
+
},
|
|
97
|
+
"pt-BR": {
|
|
98
|
+
sidebar: "Barra lateral",
|
|
99
|
+
toggleSidebar: "Alternar barra lateral",
|
|
100
|
+
collapseSidebar: "Recolher barra lateral",
|
|
101
|
+
expandSidebar: "Expandir barra lateral",
|
|
102
|
+
resizeSidebar: "Redimensionar barra lateral",
|
|
103
|
+
modeOpen: "Expandida",
|
|
104
|
+
modeCompact: "Compacta",
|
|
105
|
+
modeClosed: "Escondida",
|
|
106
|
+
sidebarHint: (shortcut: string) =>
|
|
107
|
+
`Clique direito para opções · ${shortcut} esconde`,
|
|
108
|
+
search: "Buscar",
|
|
109
|
+
noResults: "Nenhum resultado",
|
|
110
|
+
noData: "Nada por aqui ainda",
|
|
111
|
+
clearSearch: "Limpar busca",
|
|
112
|
+
retry: "Tentar novamente",
|
|
113
|
+
loadFailed: "Não foi possível carregar os dados",
|
|
114
|
+
staleData: "Exibindo dados do último carregamento",
|
|
115
|
+
previous: "Anterior",
|
|
116
|
+
next: "Próxima",
|
|
117
|
+
open: "Abrir",
|
|
118
|
+
page: (page: number, total: number) => `Página ${page} de ${total}`,
|
|
119
|
+
rows: (count: number) => `${count} ${count === 1 ? "linha" : "linhas"}`,
|
|
120
|
+
close: "Fechar",
|
|
121
|
+
language: "Idioma",
|
|
122
|
+
toggleTheme: "Alternar tema",
|
|
123
|
+
more: "Mais",
|
|
124
|
+
loading: "Carregando",
|
|
125
|
+
messages: "Mensagens",
|
|
126
|
+
scrollToEnd: "Ir para as mais recentes",
|
|
127
|
+
scrollToStart: "Ir para o início",
|
|
128
|
+
promptPlaceholder: "Pergunte qualquer coisa",
|
|
129
|
+
prompt: "Mensagem",
|
|
130
|
+
send: "Enviar",
|
|
131
|
+
stop: "Parar",
|
|
132
|
+
attachFiles: "Anexar arquivos",
|
|
133
|
+
removeAttachment: (name: string) => `Remover ${name}`,
|
|
134
|
+
attachments: "Anexos",
|
|
135
|
+
responding: "Respondendo",
|
|
136
|
+
copy: "Copiar",
|
|
137
|
+
copied: "Copiado",
|
|
138
|
+
goodResponse: "Boa resposta",
|
|
139
|
+
badResponse: "Resposta ruim",
|
|
140
|
+
thinking: "Pensando",
|
|
141
|
+
thought: "Pensou",
|
|
142
|
+
thoughtFor: (seconds: number) => `Pensou por ${seconds}s`,
|
|
143
|
+
approve: "Aprovar",
|
|
144
|
+
deny: "Negar",
|
|
145
|
+
suggestions: "Sugestões",
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
export function useUiMessages() {
|
|
150
|
+
return useMessages(uiMessages);
|
|
151
|
+
}
|
package/src/lib/utils.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { cn } from "cn";
|
|
1
|
+
export { cn } from "cn";
|