devnonla-ui 0.19.2 → 0.20.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 +11 -0
- package/package.json +1 -1
- package/src/alert/Alert.tsx +7 -7
- package/src/app/App.tsx +11 -7
- package/src/breadcrumb/Breadcrumb.tsx +80 -0
- package/src/button/Button.tsx +48 -33
- package/src/button/ButtonCopy.tsx +2 -2
- package/src/calendar/Calendar.tsx +12 -12
- package/src/card/Card.tsx +15 -10
- package/src/chat/AgentPanel.tsx +1 -1
- package/src/chat/index.ts +1 -5
- package/src/chat/message-ui/ChatError.tsx +1 -1
- package/src/chat/message-ui/ChatInput.tsx +4 -4
- package/src/chat/message-ui/ChatThinking.tsx +1 -1
- package/src/chat/message-ui/ChatUserMessage.tsx +3 -3
- package/src/chat/message-ui/ChatWelcome.tsx +2 -2
- package/src/chat/tool-ui/BackgroundTasksBar.tsx +6 -6
- package/src/chat/tool-ui/ChatToolCall.tsx +4 -4
- package/src/chat/tool-ui/ToolUiBadge.tsx +1 -1
- package/src/chat/tool-ui/ToolUiTrailing.tsx +1 -1
- package/src/chat/tool-ui/registry.ts +5 -19
- package/src/checkbox/Checkbox.tsx +12 -10
- package/src/colorpicker/ColorPicker.tsx +2 -2
- package/src/command-palette/CommandPalette.tsx +223 -0
- package/src/drawer/Drawer.tsx +1 -1
- package/src/dropdown/Dropdown.tsx +4 -3
- package/src/dropdown/menuClasses.ts +2 -2
- package/src/empty/Empty.tsx +23 -9
- package/src/form/FormItem.tsx +1 -1
- package/src/form/variants/FieldRadio.tsx +2 -2
- package/src/form/variants/FieldRepeaterItem.tsx +1 -1
- package/src/icon/Icon.tsx +14 -4
- package/src/icon/glyphs.ts +47 -38
- package/src/index.ts +8 -2
- package/src/input/EditableInput.tsx +3 -3
- package/src/input/Input.tsx +30 -13
- package/src/kbd/Kbd.tsx +32 -0
- package/src/lib/cn.ts +7 -0
- package/src/lib/markdownScale.ts +7 -5
- package/src/lib/sizes.ts +1 -1
- package/src/lib/surface.ts +2 -2
- package/src/markdown-editor/MarkdownDiff.tsx +4 -4
- package/src/markdown-editor/MarkdownPreview.tsx +1 -1
- package/src/markdown-editor/MarkdownSource.tsx +2 -2
- package/src/markdown-editor/MarkdownTable.tsx +2 -2
- package/src/markdown-editor/MermaidBlock.tsx +5 -5
- package/src/markdown-editor/ReactCodeFrame.tsx +1 -1
- package/src/menu/Menu.tsx +2 -2
- package/src/message/message.tsx +8 -8
- package/src/modal/Modal.tsx +2 -2
- package/src/page-header/PageHeader.tsx +33 -0
- package/src/pagination/Pagination.tsx +3 -3
- package/src/popconfirm/Popconfirm.tsx +3 -3
- package/src/scroll/OverlayScroll.tsx +1 -1
- package/src/segmented/Segmented.tsx +16 -7
- package/src/select/Select.tsx +76 -47
- package/src/sidebar/Sidebar.tsx +15 -4
- package/src/sortable-tree/SortableTree.tsx +1 -1
- package/src/splitter/Splitter.tsx +1 -1
- package/src/styles.css +258 -45
- package/src/switch/Switch.tsx +21 -20
- package/src/table/Table.tsx +32 -18
- package/src/tabs/Tabs.tsx +16 -13
- package/src/tag/Tag.tsx +16 -7
- package/src/theme-switcher/ThemeSwitcher.tsx +1 -1
- package/src/timepicker/TimePicker.tsx +2 -2
- package/src/tooltip/Tooltip.tsx +25 -3
- package/src/blob-shape/BlobShape.tsx +0 -337
- package/src/chat/tool-ui/GetCurrentTimeToolUI.tsx +0 -51
- package/src/chat/tool-ui/ReadSkillToolUI.tsx +0 -82
- package/src/chat/tool-ui/RunJsToolUI.tsx +0 -108
- package/src/chat/tool-ui/WebFetchToolUI.tsx +0 -64
package/src/tabs/Tabs.tsx
CHANGED
|
@@ -13,6 +13,8 @@ export type TabsItem = {
|
|
|
13
13
|
|
|
14
14
|
export type TabsProps = {
|
|
15
15
|
items: TabsItem[];
|
|
16
|
+
/** `line` (default): underline ink. `pill`: page tabs on a soft track, the active one raised (Cloudflare header style). */
|
|
17
|
+
variant?: "line" | "pill";
|
|
16
18
|
activeKey?: string;
|
|
17
19
|
defaultActiveKey?: string;
|
|
18
20
|
onChange?: (key: string) => void;
|
|
@@ -82,7 +84,7 @@ function ScrollButton({ dir, onClick }: { dir: "left" | "right"; onClick: () =>
|
|
|
82
84
|
);
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
export function Tabs({ items, activeKey, defaultActiveKey, onChange, className, style, "aria-label": ariaLabel = "Tabs" }: TabsProps) {
|
|
87
|
+
export function Tabs({ items, activeKey, defaultActiveKey, onChange, className, style, "aria-label": ariaLabel = "Tabs", variant = "line" }: TabsProps) {
|
|
86
88
|
const uid = useId();
|
|
87
89
|
|
|
88
90
|
const [inner, setInner] = useState(() => firstEnabled(items, defaultActiveKey));
|
|
@@ -252,7 +254,7 @@ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className,
|
|
|
252
254
|
return (
|
|
253
255
|
<div className={cn("w-full min-w-0", className)} style={style}>
|
|
254
256
|
<div className="relative">
|
|
255
|
-
<div aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0 h-px bg-border" />
|
|
257
|
+
{variant === "line" ? <div aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0 h-px bg-border" /> : null}
|
|
256
258
|
<div
|
|
257
259
|
ref={scrollerRef}
|
|
258
260
|
className="relative overflow-x-auto overflow-y-hidden overscroll-x-contain touch-pan-y select-none [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden [&::-webkit-scrollbar]:h-0 [&::-webkit-scrollbar]:w-0"
|
|
@@ -269,8 +271,8 @@ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className,
|
|
|
269
271
|
onPointerCancel={endDrag}
|
|
270
272
|
onClickCapture={onClickCapture}
|
|
271
273
|
>
|
|
272
|
-
<div ref={rowRef} role="tablist" aria-label={ariaLabel} aria-orientation="horizontal" className="relative flex w-max gap-3" onKeyDown={onKeyDown}>
|
|
273
|
-
{ink ? <span aria-hidden className="pointer-events-none absolute bottom-0 left-0 z-1 h-0.5 rounded-t-xs bg-
|
|
274
|
+
<div ref={rowRef} role="tablist" aria-label={ariaLabel} aria-orientation="horizontal" className={cn("relative flex w-max", variant === "pill" ? "gap-0.5 rounded-lg bg-(--nonla-pill-track) p-0.5" : "gap-3")} onKeyDown={onKeyDown}>
|
|
275
|
+
{ink && variant === "line" ? <span aria-hidden className="pointer-events-none absolute bottom-0 left-0 z-1 h-0.5 rounded-t-xs bg-selected transition-[transform,width] duration-(--nonla-dur-slow) ease-(--nonla-ease-spring) motion-reduce:transition-none" style={{ width: ink.width, transform: `translateX(${ink.left}px)` }} /> : null}
|
|
274
276
|
{items.map((item) => {
|
|
275
277
|
const selected = item.key === active;
|
|
276
278
|
return (
|
|
@@ -288,17 +290,18 @@ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className,
|
|
|
288
290
|
tabIndex={selected ? 0 : -1}
|
|
289
291
|
disabled={item.disabled}
|
|
290
292
|
className={cn(
|
|
291
|
-
"relative z-10 inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border-0 bg-transparent font-
|
|
292
|
-
"focus-visible:ring-
|
|
293
|
+
"relative z-10 inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border-0 bg-transparent font-medium transition-colors select-none",
|
|
294
|
+
"focus-visible:ring-focus-ring focus-visible:ring-2 focus-visible:outline-none focus-visible:ring-inset",
|
|
293
295
|
"disabled:cursor-not-allowed disabled:opacity-40",
|
|
294
|
-
|
|
296
|
+
variant === "pill" && "rounded-md font-medium transition-[color,background-color,box-shadow]",
|
|
297
|
+
variant === "pill" && selected && "bg-card shadow-(--nonla-pill-thumb-shadow)",
|
|
298
|
+
selected ? "text-foreground" : "text-muted-foreground hover:text-foreground",
|
|
295
299
|
)}
|
|
296
|
-
style={
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}}
|
|
300
|
+
style={
|
|
301
|
+
variant === "pill"
|
|
302
|
+
? { height: TAB_HEIGHT - 8, paddingLeft: 10, paddingRight: 10, fontSize: 14 }
|
|
303
|
+
: { height: TAB_HEIGHT, paddingLeft: 4, paddingRight: 4, fontSize: 14 }
|
|
304
|
+
}
|
|
302
305
|
onClick={() => {
|
|
303
306
|
if (!item.disabled) select(item.key);
|
|
304
307
|
}}
|
package/src/tag/Tag.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
-
import { cn } from "../lib/cn";
|
|
2
|
+
import { cn, focusRing } from "../lib/cn";
|
|
3
3
|
|
|
4
4
|
export type TagVariant = "soft" | "solid";
|
|
5
5
|
|
|
@@ -17,7 +17,7 @@ export type TagProps = {
|
|
|
17
17
|
className?: string;
|
|
18
18
|
onClose?: () => void;
|
|
19
19
|
closable?: boolean;
|
|
20
|
-
/**
|
|
20
|
+
/** Leading status dot. On by default for soft colored tags; `false` hides it, `true` forces it. */
|
|
21
21
|
dot?: boolean;
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -42,8 +42,17 @@ const NAMED_VAR: Record<string, string> = {
|
|
|
42
42
|
lime: "light-dark(#3d8f5c, #70b489)",
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const SOFT = "bg-[color-mix(in_oklab,var(--nonla-tag)_12%,transparent)] text-[color-mix(in_oklab,var(--nonla-tag)_72%,
|
|
46
|
-
const SOLID = "bg-(--nonla-tag) text-[var(--nonla-
|
|
45
|
+
const SOFT = "bg-[color-mix(in_oklab,var(--nonla-tag)_12%,transparent)] text-[color-mix(in_oklab,var(--nonla-tag)_72%,var(--nonla-text-main))]";
|
|
46
|
+
const SOLID = "bg-[var(--nonla-tag-fill,var(--nonla-tag))] text-[var(--nonla-tag-ink,light-dark(#ffffff,#141413))]";
|
|
47
|
+
|
|
48
|
+
/** Status roles: solid chips take the role fill and its label color. Presets: white in light, ink in dark (their dark tones are light). */
|
|
49
|
+
const ROLE_SOLID: Record<string, { fill: string; ink: string }> = {
|
|
50
|
+
success: { fill: "var(--nonla-success-fill)", ink: "var(--nonla-text-on-success)" },
|
|
51
|
+
error: { fill: "var(--nonla-danger-fill)", ink: "var(--nonla-text-on-danger)" },
|
|
52
|
+
warning: { fill: "var(--nonla-warn-fill)", ink: "var(--nonla-text-on-warn)" },
|
|
53
|
+
processing: { fill: "var(--nonla-link)", ink: "var(--nonla-bg)" },
|
|
54
|
+
brand: { fill: "var(--nonla-brand)", ink: "var(--nonla-text-on-brand)" },
|
|
55
|
+
};
|
|
47
56
|
|
|
48
57
|
function resolveVariant(variant: TagProps["variant"]): TagVariant {
|
|
49
58
|
if (variant === "solid") return "solid";
|
|
@@ -78,12 +87,12 @@ export function Tag({
|
|
|
78
87
|
return (
|
|
79
88
|
<span
|
|
80
89
|
className={cn(
|
|
81
|
-
"inline-flex h-5.5 max-w-full items-center gap-1.5 rounded-full px-2.5 text-
|
|
90
|
+
"inline-flex h-5.5 max-w-full items-center gap-1.5 rounded-full px-2.5 text-xs font-medium",
|
|
82
91
|
isDefault && (solid ? "bg-foreground/10 text-foreground" : "bg-muted text-muted-foreground"),
|
|
83
92
|
!isDefault && (solid ? SOLID : SOFT),
|
|
84
93
|
className,
|
|
85
94
|
)}
|
|
86
|
-
style={token ? ({ "--nonla-tag": token } as CSSProperties) : undefined}
|
|
95
|
+
style={token ? ({ "--nonla-tag": token, ...(ROLE_SOLID[color] && { "--nonla-tag-fill": ROLE_SOLID[color].fill, "--nonla-tag-ink": ROLE_SOLID[color].ink }) } as CSSProperties) : undefined}
|
|
87
96
|
>
|
|
88
97
|
{showDot ? (
|
|
89
98
|
<span
|
|
@@ -97,7 +106,7 @@ export function Tag({
|
|
|
97
106
|
{closable ? (
|
|
98
107
|
<button
|
|
99
108
|
type="button"
|
|
100
|
-
className="-mr-0.5 inline-flex size-3.5 shrink-0 items-center justify-center rounded-full text-current/55 transition-colors hover:bg-ink-hover hover:text-current"
|
|
109
|
+
className={cn("-mr-0.5 inline-flex size-3.5 shrink-0 cursor-pointer items-center justify-center rounded-full border-0 bg-transparent p-0 text-current/55 transition-colors hover:bg-ink-hover hover:text-current", focusRing, "focus-visible:ring-offset-0")}
|
|
101
110
|
aria-label="Remove"
|
|
102
111
|
onClick={onClose}
|
|
103
112
|
>
|
|
@@ -42,7 +42,7 @@ export function ThemeSwitcher({ className }: ThemeSwitcherProps) {
|
|
|
42
42
|
aria-label={option.label}
|
|
43
43
|
onClick={() => setColorPreference(option.value)}
|
|
44
44
|
className={cn(
|
|
45
|
-
"inline-flex size-5 items-center justify-center rounded-full border-0 bg-transparent p-0 cursor-pointer text-foreground
|
|
45
|
+
"inline-flex size-5 items-center justify-center rounded-full border-0 bg-transparent p-0 cursor-pointer text-muted-foreground",
|
|
46
46
|
selected ? "bg-ink-active text-foreground" : "hover:bg-ink-hover hover:text-foreground",
|
|
47
47
|
)}
|
|
48
48
|
>
|
|
@@ -297,7 +297,7 @@ function PickGrid({
|
|
|
297
297
|
type="button"
|
|
298
298
|
tabIndex={-1}
|
|
299
299
|
className={cn(
|
|
300
|
-
"flex h-11 items-center justify-center rounded-md tabular-nums text-
|
|
300
|
+
"flex h-11 items-center justify-center rounded-md tabular-nums text-sm font-normal transition-colors",
|
|
301
301
|
selected ? "bg-ink-active text-foreground" : "text-foreground hover:bg-ink-hover",
|
|
302
302
|
)}
|
|
303
303
|
onClick={() => onSelect(opt.value)}
|
|
@@ -632,7 +632,7 @@ export const TimePicker = forwardRef<HTMLInputElement, TimePickerProps>(function
|
|
|
632
632
|
onKeyDown={handleKeyDown}
|
|
633
633
|
onKeyUp={(e) => syncPartFromCaret(e.currentTarget)}
|
|
634
634
|
onClick={(e) => syncPartFromCaret(e.currentTarget)}
|
|
635
|
-
className="min-w-0 flex-1 border-0 bg-transparent p-0 text-foreground placeholder:text-
|
|
635
|
+
className="min-w-0 flex-1 border-0 bg-transparent p-0 text-foreground placeholder:text-tertiary-foreground outline-none disabled:cursor-not-allowed"
|
|
636
636
|
style={{ fontSize: fieldStyle.fontSize, lineHeight: fieldStyle.lineHeight }}
|
|
637
637
|
/>
|
|
638
638
|
{allowClear && selected && !disabled ? (
|
package/src/tooltip/Tooltip.tsx
CHANGED
|
@@ -19,7 +19,7 @@ export type TooltipProps = {
|
|
|
19
19
|
/** Extra class on the overlay panel. */
|
|
20
20
|
overlayClassName?: string;
|
|
21
21
|
getPopupContainer?: () => HTMLElement;
|
|
22
|
-
/**
|
|
22
|
+
/** Show the small arrow pointing at the trigger. Default `true`. */
|
|
23
23
|
arrow?: boolean | { pointAtCenter?: boolean };
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -34,6 +34,7 @@ export function Tooltip({
|
|
|
34
34
|
className,
|
|
35
35
|
overlayClassName,
|
|
36
36
|
getPopupContainer,
|
|
37
|
+
arrow = true,
|
|
37
38
|
}: TooltipProps) {
|
|
38
39
|
const getContainer = usePopupContainer(getPopupContainer);
|
|
39
40
|
const { side, align } = placementToRadix(placement);
|
|
@@ -46,10 +47,31 @@ export function Tooltip({
|
|
|
46
47
|
<TooltipPrimitive.Content
|
|
47
48
|
side={side}
|
|
48
49
|
align={align}
|
|
49
|
-
sideOffset={
|
|
50
|
-
className={cn(
|
|
50
|
+
sideOffset={10}
|
|
51
|
+
className={cn(
|
|
52
|
+
glassOverlayClass,
|
|
53
|
+
// Cloudflare-style bubble: 6px radius, an outline ring (in the shadow token), a medium drop.
|
|
54
|
+
"max-w-80 rounded-md border-0 px-2.5 py-1.5 text-(length:--nonla-nav-text-size) leading-[18px] shadow-(--nonla-tooltip-shadow)",
|
|
55
|
+
// Radix tooltips open as `delayed-open` / `instant-open`; scale 0.9 + fade from the trigger, out the same way.
|
|
56
|
+
"data-[state=delayed-open]:animate-[nonla-tooltip-in_var(--nonla-dur-fast)_cubic-bezier(0.4,0,0.2,1)] data-[state=instant-open]:animate-none",
|
|
57
|
+
"data-[state=closed]:animate-[nonla-tooltip-out_var(--nonla-dur-fast)_cubic-bezier(0.4,0,0.2,1)_forwards]",
|
|
58
|
+
className,
|
|
59
|
+
overlayClassName,
|
|
60
|
+
)}
|
|
51
61
|
>
|
|
52
62
|
{title}
|
|
63
|
+
{arrow ? (
|
|
64
|
+
<TooltipPrimitive.Arrow asChild width={20} height={10}>
|
|
65
|
+
{/* Soft-tipped arrow: the fill hides the ring under its base, the edge path carries the ring around the tip. */}
|
|
66
|
+
<svg viewBox="0 0 20 10" overflow="visible" aria-hidden="true">
|
|
67
|
+
<path className="fill-card" d="M9.66 6.4L4.81 2.03C4.07 1.37 3.12 1 2.13 1H0V-1H20V1H18.53C17.55 1 16.59 1.37 15.86 2.03L11 6.4C10.62 6.74 10.04 6.74 9.66 6.4Z" />
|
|
68
|
+
<path
|
|
69
|
+
className="fill-(--nonla-tooltip-arrow-edge)"
|
|
70
|
+
d="M10.33 5.65L5.48 1.28C4.56 0.46 3.37 0 2.13 0H0V1H2.13C3.12 1 4.07 1.37 4.81 2.03L9.66 6.4C10.04 6.74 10.62 6.74 11 6.4L15.86 2.03C16.59 1.37 17.55 1 18.53 1H20V0H18.53C17.3 0 16.11 0.46 15.19 1.28L10.33 5.65Z"
|
|
71
|
+
/>
|
|
72
|
+
</svg>
|
|
73
|
+
</TooltipPrimitive.Arrow>
|
|
74
|
+
) : null}
|
|
53
75
|
</TooltipPrimitive.Content>
|
|
54
76
|
</TooltipPrimitive.Portal>
|
|
55
77
|
</TooltipPrimitive.Root>
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import { type CSSProperties, type ReactNode, useId } from "react";
|
|
2
|
-
import { cn } from "../lib/cn";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* `blob`, `blob-alt`, `ring`, `orb`, `square`, `star`, `circle`, `cursor` are background decorations.
|
|
6
|
-
* `horizontal`, `fade`, `dashed`, `double`, `ornament`, `zigzag`, `wave`, `waves`, `mountain`, `vertical` are thin line dividers.
|
|
7
|
-
*/
|
|
8
|
-
export type BlobShapeVariant =
|
|
9
|
-
| "blob"
|
|
10
|
-
| "blob-alt"
|
|
11
|
-
| "ring"
|
|
12
|
-
| "orb"
|
|
13
|
-
| "square"
|
|
14
|
-
| "star"
|
|
15
|
-
| "circle"
|
|
16
|
-
| "cursor"
|
|
17
|
-
| "horizontal"
|
|
18
|
-
| "fade"
|
|
19
|
-
| "dashed"
|
|
20
|
-
| "double"
|
|
21
|
-
| "ornament"
|
|
22
|
-
| "zigzag"
|
|
23
|
-
| "wave"
|
|
24
|
-
| "waves"
|
|
25
|
-
| "mountain"
|
|
26
|
-
| "vertical";
|
|
27
|
-
|
|
28
|
-
type DividerVariant = Extract<BlobShapeVariant, "horizontal" | "fade" | "dashed" | "double" | "ornament" | "zigzag" | "wave" | "waves" | "mountain" | "vertical">;
|
|
29
|
-
|
|
30
|
-
/** How a closed shape is painted. Dividers are lines, so they ignore it. */
|
|
31
|
-
export type BlobShapeAppearance = "solid" | "outline" | "sticker";
|
|
32
|
-
|
|
33
|
-
export type BlobShapeProps = {
|
|
34
|
-
variant?: BlobShapeVariant;
|
|
35
|
-
/** Fill color, or stroke for `outline` and dividers. Any CSS color works, including `var(--nonla-*)`. Defaults to brand. */
|
|
36
|
-
color?: string;
|
|
37
|
-
/** Width in px or any CSS length. Decorations default to 320. Dividers default to `100%`, and `vertical` defaults to `1`. */
|
|
38
|
-
width?: number | string;
|
|
39
|
-
/** Explicit height. Usually omit it so the aspect ratio holds. */
|
|
40
|
-
height?: number | string;
|
|
41
|
-
/** Opacity from 0 to 1. */
|
|
42
|
-
opacity?: number;
|
|
43
|
-
/** Gaussian blur in px. Softens edges for glow-style backgrounds. */
|
|
44
|
-
blur?: number;
|
|
45
|
-
/** Mirror horizontally. */
|
|
46
|
-
flipX?: boolean;
|
|
47
|
-
/** Mirror vertically. Use it to put a divider on the top edge of a section. */
|
|
48
|
-
flipY?: boolean;
|
|
49
|
-
/** `solid` fills the shape. `outline` strokes its edge. `sticker` adds a white border and a drop shadow. Dividers ignore it. */
|
|
50
|
-
appearance?: BlobShapeAppearance;
|
|
51
|
-
className?: string;
|
|
52
|
-
style?: CSSProperties;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const DIVIDER_VARIANTS: ReadonlySet<BlobShapeVariant> = new Set<BlobShapeVariant>([
|
|
56
|
-
"horizontal",
|
|
57
|
-
"fade",
|
|
58
|
-
"dashed",
|
|
59
|
-
"double",
|
|
60
|
-
"ornament",
|
|
61
|
-
"zigzag",
|
|
62
|
-
"wave",
|
|
63
|
-
"waves",
|
|
64
|
-
"mountain",
|
|
65
|
-
"vertical",
|
|
66
|
-
]);
|
|
67
|
-
|
|
68
|
-
/** Box and default size for each divider. Lines keep their stroke in screen pixels, so they stay thin when stretched. */
|
|
69
|
-
const DIVIDER_BOX: Record<DividerVariant, { viewBox: string; width: number | string; height?: number | string }> = {
|
|
70
|
-
horizontal: { viewBox: "0 0 1440 1", width: "100%", height: 1 },
|
|
71
|
-
fade: { viewBox: "0 0 1440 1", width: "100%", height: 1 },
|
|
72
|
-
dashed: { viewBox: "0 0 1440 1", width: "100%", height: 1 },
|
|
73
|
-
double: { viewBox: "0 0 1440 5", width: "100%", height: 5 },
|
|
74
|
-
ornament: { viewBox: "0 0 1440 12", width: "100%", height: 12 },
|
|
75
|
-
zigzag: { viewBox: "0 0 1440 8", width: "100%", height: 8 },
|
|
76
|
-
wave: { viewBox: "0 0 1440 40", width: "100%" },
|
|
77
|
-
waves: { viewBox: "0 0 1440 40", width: "100%" },
|
|
78
|
-
mountain: { viewBox: "0 0 1440 40", width: "100%" },
|
|
79
|
-
vertical: { viewBox: "0 0 1 1440", width: 1, height: "100%" },
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/** Stroke width in screen pixels. */
|
|
83
|
-
const LINE_STROKE = 1;
|
|
84
|
-
const WAVE_STROKE = 2;
|
|
85
|
-
|
|
86
|
-
/** One smooth wave: four bumps across the 1440 box, centered on y = 20. */
|
|
87
|
-
const WAVE_PATH = "M0,20 C120,0 240,0 360,20 C480,40 600,40 720,20 C840,0 960,0 1080,20 C1200,40 1320,40 1440,20";
|
|
88
|
-
|
|
89
|
-
/** Front and back ridges of a mountain range, drawn as open lines in the 40-unit box. */
|
|
90
|
-
const MOUNTAIN_FRONT = "M0,36 L240,10 L400,26 L600,2 L820,28 L980,8 L1200,30 L1440,18";
|
|
91
|
-
const MOUNTAIN_BACK = "M0,26 L160,12 L300,24 L470,6 L640,22 L820,10 L1000,24 L1200,8 L1440,20";
|
|
92
|
-
|
|
93
|
-
/** Diamond ornament at the center of the `ornament` divider. */
|
|
94
|
-
const ORNAMENT_DIAMOND = "M720,1 L726,6 L720,11 L714,6 Z";
|
|
95
|
-
|
|
96
|
-
const BLOB_PATH =
|
|
97
|
-
"M44.7,-76.4C58.8,-69.2,71.8,-59.1,79.6,-45.8C87.4,-32.6,90,-16.3,88.5,-0.9C87,14.5,81.4,29,73.1,41.1C64.8,53.2,53.8,62.9,41.2,70.3C28.6,77.7,14.3,82.8,-0.5,83.7C-15.3,84.6,-30.6,81.3,-43.4,74.2C-56.2,67.1,-66.5,56,-74.8,43.2C-83.1,30.4,-89.4,15.2,-89.4,0C-89.4,-15.2,-83.1,-30.4,-74.3,-42.9C-65.5,-55.4,-54.2,-65.2,-41.4,-72.6C-28.6,-80,-14.3,-85,0.9,-86.3C16.1,-87.6,30.6,-83.6,44.7,-76.4Z";
|
|
98
|
-
|
|
99
|
-
const BLOB_ALT_PATH = "M-6,-88C48,-92,90,-40,84,8C78,54,36,90,-12,84C-58,78,-90,40,-84,-6C-78,-52,-52,-86,-6,-88Z";
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Windows-style arrow pointer: vertical left edge, 45-degree right edge, horizontal wing, slanted tail.
|
|
103
|
-
* Sharp corners, drawn on an 11 x 18 grid, scaled 8x and centered in the -100..100 box.
|
|
104
|
-
*/
|
|
105
|
-
const CURSOR_PATH = "M0,0 L0,16 L4.2,12.2 L6.9,18 L8.6,17.2 L5.9,11.2 L11,11.2 Z";
|
|
106
|
-
const CURSOR_SCALE = 8;
|
|
107
|
-
const CURSOR_TRANSFORM = "translate(-44 -72) scale(8)";
|
|
108
|
-
/** Sticker stroke width in viewBox units. */
|
|
109
|
-
const STICKER_STROKE = 8;
|
|
110
|
-
|
|
111
|
-
const STAR_PATH = "M0.0,-90.0 L23.5,-32.4 L85.6,-27.8 L38.0,12.4 L52.9,72.8 L0.0,40.0 L-52.9,72.8 L-38.0,12.4 L-85.6,-27.8 L-23.5,-32.4 Z";
|
|
112
|
-
|
|
113
|
-
const f2 = (n: number) => n.toFixed(2);
|
|
114
|
-
|
|
115
|
-
/** Open smooth line through sampled points, using Catmull-Rom curves converted to cubic Béziers. */
|
|
116
|
-
function smoothLine(points: [number, number][]): string {
|
|
117
|
-
let d = `M${f2(points[0][0])},${f2(points[0][1])}`;
|
|
118
|
-
for (let i = 0; i < points.length - 1; i++) {
|
|
119
|
-
const p0 = points[Math.max(i - 1, 0)];
|
|
120
|
-
const p1 = points[i];
|
|
121
|
-
const p2 = points[i + 1];
|
|
122
|
-
const p3 = points[Math.min(i + 2, points.length - 1)];
|
|
123
|
-
const c1x = p1[0] + (p2[0] - p0[0]) / 6;
|
|
124
|
-
const c1y = p1[1] + (p2[1] - p0[1]) / 6;
|
|
125
|
-
const c2x = p2[0] - (p3[0] - p1[0]) / 6;
|
|
126
|
-
const c2y = p2[1] - (p3[1] - p1[1]) / 6;
|
|
127
|
-
d += ` C${f2(c1x)},${f2(c1y)} ${f2(c2x)},${f2(c2y)} ${f2(p2[0])},${f2(p2[1])}`;
|
|
128
|
-
}
|
|
129
|
-
return d;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** Sine wave across the 1440 box, centered on `base`: one crest every 360 units. */
|
|
133
|
-
function sineWave(base: number, amp: number, phase: number): string {
|
|
134
|
-
const points: [number, number][] = [];
|
|
135
|
-
for (let x = 0; x <= 1440; x += 90) {
|
|
136
|
-
points.push([x, base + amp * Math.sin((2 * Math.PI * x) / 360 + phase)]);
|
|
137
|
-
}
|
|
138
|
-
return smoothLine(points);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** Zigzag across the 8-unit box: alternating top and bottom points every 24 units. */
|
|
142
|
-
function zigzagPath(): string {
|
|
143
|
-
let d = "M0,7";
|
|
144
|
-
for (let x = 24, i = 0; x <= 1440; x += 24, i++) {
|
|
145
|
-
d += ` L${x},${i % 2 === 0 ? 1 : 7}`;
|
|
146
|
-
}
|
|
147
|
-
return d;
|
|
148
|
-
}
|
|
149
|
-
const ZIGZAG_PATH = zigzagPath();
|
|
150
|
-
|
|
151
|
-
/** Three sine waves, out of phase, at decreasing opacity. */
|
|
152
|
-
const WAVES_LAYERS: { d: string; opacity: number }[] = [
|
|
153
|
-
{ d: sineWave(20, 10, 0), opacity: 1 },
|
|
154
|
-
{ d: sineWave(20, 10, 0.9), opacity: 0.55 },
|
|
155
|
-
{ d: sineWave(20, 10, 1.8), opacity: 0.25 },
|
|
156
|
-
];
|
|
157
|
-
|
|
158
|
-
/** Edge width of an `outline` shape, in viewBox units. Same as the `ring` stroke. */
|
|
159
|
-
const OUTLINE_STROKE = 3;
|
|
160
|
-
|
|
161
|
-
/** Radius of the disc used for `circle` and `orb` outline and sticker forms. */
|
|
162
|
-
const DISC_RADIUS = 88;
|
|
163
|
-
|
|
164
|
-
type ClosedVariant = Extract<BlobShapeVariant, "blob" | "blob-alt" | "ring" | "orb" | "square" | "star" | "circle" | "cursor">;
|
|
165
|
-
|
|
166
|
-
const CLOSED_VARIANTS: ReadonlySet<BlobShapeVariant> = new Set<BlobShapeVariant>(["blob", "blob-alt", "ring", "orb", "square", "star", "circle", "cursor"]);
|
|
167
|
-
|
|
168
|
-
function isClosedVariant(variant: BlobShapeVariant): variant is ClosedVariant {
|
|
169
|
-
return CLOSED_VARIANTS.has(variant);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** Fill and stroke for a closed shape. `strokeWidth` is in viewBox units. */
|
|
173
|
-
type Paint = { fill: string; stroke: string; strokeWidth: number };
|
|
174
|
-
|
|
175
|
-
const solidPaint = (color: string): Paint => ({ fill: color, stroke: "none", strokeWidth: 0 });
|
|
176
|
-
const outlinePaint = (color: string): Paint => ({ fill: "none", stroke: color, strokeWidth: OUTLINE_STROKE });
|
|
177
|
-
|
|
178
|
-
/** Draws one closed shape with the given paint. Used for the shape itself and for its sticker border. */
|
|
179
|
-
function closedShape(variant: ClosedVariant, paint: Paint): ReactNode {
|
|
180
|
-
const paintStyle: CSSProperties = { fill: paint.fill, stroke: paint.stroke };
|
|
181
|
-
switch (variant) {
|
|
182
|
-
case "blob":
|
|
183
|
-
return <path d={BLOB_PATH} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
184
|
-
case "blob-alt":
|
|
185
|
-
return <path d={BLOB_ALT_PATH} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
186
|
-
case "ring":
|
|
187
|
-
return <path d={BLOB_PATH} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
188
|
-
case "square":
|
|
189
|
-
return <rect x={-80} y={-80} width={160} height={160} rx={24} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
190
|
-
case "star":
|
|
191
|
-
return <path d={STAR_PATH} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
192
|
-
case "circle":
|
|
193
|
-
case "orb":
|
|
194
|
-
return <circle cx={0} cy={0} r={DISC_RADIUS} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
195
|
-
case "cursor":
|
|
196
|
-
// The transform scales the stroke too, so the stroke width is divided by the scale here.
|
|
197
|
-
return <path d={CURSOR_PATH} transform={CURSOR_TRANSFORM} style={paintStyle} strokeWidth={paint.strokeWidth / CURSOR_SCALE} />;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Decorative SVG shapes for landing pages.
|
|
203
|
-
* Decorations sit in a `-100 -100 200 200` box. Dividers are thin lines that span the full width or height.
|
|
204
|
-
* Position it with `className` (e.g. `absolute -z-10`). The shape ignores pointer events.
|
|
205
|
-
*/
|
|
206
|
-
export function BlobShape({ variant = "blob", color = "var(--nonla-brand)", width, height, opacity, blur, flipX, flipY, appearance = "solid", className, style }: BlobShapeProps) {
|
|
207
|
-
const rawId = useId();
|
|
208
|
-
const idKey = rawId.replace(/:/g, "");
|
|
209
|
-
const gradientId = `nonla-blob-${idKey}`;
|
|
210
|
-
const fadeId = `nonla-fade-${idKey}`;
|
|
211
|
-
const divider = DIVIDER_VARIANTS.has(variant);
|
|
212
|
-
const box = divider ? DIVIDER_BOX[variant as DividerVariant] : undefined;
|
|
213
|
-
const fill: CSSProperties = { fill: color };
|
|
214
|
-
const stroke: CSSProperties = { stroke: color };
|
|
215
|
-
const line: CSSProperties = { ...stroke, fill: "none" };
|
|
216
|
-
|
|
217
|
-
const transform = [flipX && "scaleX(-1)", flipY && "scaleY(-1)"].filter(Boolean).join(" ");
|
|
218
|
-
|
|
219
|
-
// Ring is an outline by nature. The orb glow is a gradient, so only its solid form uses it.
|
|
220
|
-
const paint = appearance === "outline" || variant === "ring" ? outlinePaint(color) : solidPaint(color);
|
|
221
|
-
let shape: ReactNode = null;
|
|
222
|
-
if (variant === "orb" && appearance === "solid") {
|
|
223
|
-
shape = (
|
|
224
|
-
<>
|
|
225
|
-
<defs>
|
|
226
|
-
<radialGradient id={gradientId}>
|
|
227
|
-
<stop offset="0%" stopOpacity={1} style={{ stopColor: color }} />
|
|
228
|
-
<stop offset="100%" stopOpacity={0} style={{ stopColor: color }} />
|
|
229
|
-
</radialGradient>
|
|
230
|
-
</defs>
|
|
231
|
-
<circle cx={0} cy={0} r={100} fill={`url(#${gradientId})`} />
|
|
232
|
-
</>
|
|
233
|
-
);
|
|
234
|
-
} else if (isClosedVariant(variant)) {
|
|
235
|
-
shape = closedShape(variant, paint);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
switch (variant) {
|
|
239
|
-
case "horizontal":
|
|
240
|
-
shape = <line x1={0} y1={0.5} x2={1440} y2={0.5} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" style={line} />;
|
|
241
|
-
break;
|
|
242
|
-
case "fade":
|
|
243
|
-
shape = (
|
|
244
|
-
<>
|
|
245
|
-
<defs>
|
|
246
|
-
<linearGradient id={fadeId} gradientUnits="userSpaceOnUse" x1={0} y1={0} x2={1440} y2={0}>
|
|
247
|
-
<stop offset="0" stopOpacity={0} style={{ stopColor: color }} />
|
|
248
|
-
<stop offset="0.5" stopOpacity={1} style={{ stopColor: color }} />
|
|
249
|
-
<stop offset="1" stopOpacity={0} style={{ stopColor: color }} />
|
|
250
|
-
</linearGradient>
|
|
251
|
-
</defs>
|
|
252
|
-
<line x1={0} y1={0.5} x2={1440} y2={0.5} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" stroke={`url(#${fadeId})`} fill="none" />
|
|
253
|
-
</>
|
|
254
|
-
);
|
|
255
|
-
break;
|
|
256
|
-
case "dashed":
|
|
257
|
-
shape = <line x1={0} y1={0.5} x2={1440} y2={0.5} strokeWidth={LINE_STROKE} strokeDasharray="6 4" vectorEffect="non-scaling-stroke" style={line} />;
|
|
258
|
-
break;
|
|
259
|
-
case "double":
|
|
260
|
-
shape = (
|
|
261
|
-
<>
|
|
262
|
-
<line x1={0} y1={0.5} x2={1440} y2={0.5} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" style={line} />
|
|
263
|
-
<line x1={0} y1={4.5} x2={1440} y2={4.5} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" style={line} />
|
|
264
|
-
</>
|
|
265
|
-
);
|
|
266
|
-
break;
|
|
267
|
-
case "ornament":
|
|
268
|
-
shape = (
|
|
269
|
-
<>
|
|
270
|
-
<line x1={0} y1={6} x2={1440} y2={6} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" style={line} />
|
|
271
|
-
<path d={ORNAMENT_DIAMOND} style={fill} />
|
|
272
|
-
</>
|
|
273
|
-
);
|
|
274
|
-
break;
|
|
275
|
-
case "zigzag":
|
|
276
|
-
shape = <path d={ZIGZAG_PATH} strokeWidth={LINE_STROKE} strokeLinejoin="round" vectorEffect="non-scaling-stroke" style={line} />;
|
|
277
|
-
break;
|
|
278
|
-
case "wave":
|
|
279
|
-
shape = <path d={WAVE_PATH} strokeWidth={WAVE_STROKE} strokeLinecap="round" vectorEffect="non-scaling-stroke" style={line} />;
|
|
280
|
-
break;
|
|
281
|
-
case "waves":
|
|
282
|
-
shape = WAVES_LAYERS.map((layer) => (
|
|
283
|
-
<path key={layer.d} d={layer.d} strokeWidth={LINE_STROKE} strokeLinecap="round" vectorEffect="non-scaling-stroke" style={{ ...line, opacity: layer.opacity }} />
|
|
284
|
-
));
|
|
285
|
-
break;
|
|
286
|
-
case "mountain":
|
|
287
|
-
shape = (
|
|
288
|
-
<>
|
|
289
|
-
<path d={MOUNTAIN_BACK} strokeWidth={LINE_STROKE} strokeLinejoin="round" vectorEffect="non-scaling-stroke" style={{ ...line, opacity: 0.4 }} />
|
|
290
|
-
<path d={MOUNTAIN_FRONT} strokeWidth={WAVE_STROKE} strokeLinejoin="round" vectorEffect="non-scaling-stroke" style={line} />
|
|
291
|
-
</>
|
|
292
|
-
);
|
|
293
|
-
break;
|
|
294
|
-
case "vertical":
|
|
295
|
-
shape = <line x1={0.5} y1={0} x2={0.5} y2={1440} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" style={line} />;
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Sticker: a white border under the shape, so only the outer edge shows, plus a soft drop shadow.
|
|
300
|
-
// Dividers have no sticker form.
|
|
301
|
-
if (appearance === "sticker" && isClosedVariant(variant)) {
|
|
302
|
-
const stickerId = `nonla-sticker-${idKey}`;
|
|
303
|
-
const border: Paint = { fill: "#ffffff", stroke: "#ffffff", strokeWidth: paint.strokeWidth + STICKER_STROKE };
|
|
304
|
-
shape = (
|
|
305
|
-
<>
|
|
306
|
-
<defs>
|
|
307
|
-
<filter id={stickerId} x="-30%" y="-30%" width="160%" height="160%">
|
|
308
|
-
<feDropShadow dx={0} dy={2} stdDeviation={2} floodColor="#000000" floodOpacity={0.2} />
|
|
309
|
-
</filter>
|
|
310
|
-
</defs>
|
|
311
|
-
<g filter={`url(#${stickerId})`}>{closedShape(variant, border)}</g>
|
|
312
|
-
{shape}
|
|
313
|
-
</>
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
return (
|
|
318
|
-
<svg
|
|
319
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
320
|
-
viewBox={box?.viewBox ?? "-100 -100 200 200"}
|
|
321
|
-
preserveAspectRatio={divider ? "none" : undefined}
|
|
322
|
-
width={width ?? box?.width ?? 320}
|
|
323
|
-
height={height ?? box?.height}
|
|
324
|
-
aria-hidden
|
|
325
|
-
focusable="false"
|
|
326
|
-
className={cn("pointer-events-none block shrink-0", className)}
|
|
327
|
-
style={{
|
|
328
|
-
opacity,
|
|
329
|
-
filter: blur ? `blur(${blur}px)` : undefined,
|
|
330
|
-
transform: transform || undefined,
|
|
331
|
-
...style,
|
|
332
|
-
}}
|
|
333
|
-
>
|
|
334
|
-
{shape}
|
|
335
|
-
</svg>
|
|
336
|
-
);
|
|
337
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Icon } from "../../icon/Icon";
|
|
2
|
-
import { Shimmer } from "../../shimmer/Shimmer";
|
|
3
|
-
import { chatRowClass, chatToolLineClass } from "../chatRhythm";
|
|
4
|
-
import { parseJsonObject } from "../common/utils";
|
|
5
|
-
import { ToolUiBadge } from "./ToolUiBadge";
|
|
6
|
-
import { ToolUiTrailing } from "./ToolUiTrailing";
|
|
7
|
-
import { isToolRunning, type ToolUIProps } from "./types";
|
|
8
|
-
|
|
9
|
-
type TimeResult = {
|
|
10
|
-
time?: string;
|
|
11
|
-
timezone?: string;
|
|
12
|
-
iso?: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function formatLabel(iso: string | undefined, timezone: string | undefined, fallback: string | undefined): string {
|
|
16
|
-
if (iso) {
|
|
17
|
-
try {
|
|
18
|
-
const d = new Date(iso);
|
|
19
|
-
if (!Number.isNaN(d.getTime())) {
|
|
20
|
-
const tz = timezone || "UTC";
|
|
21
|
-
const clock = d.toLocaleTimeString("en-US", { timeZone: tz, hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: false });
|
|
22
|
-
const date = d.toLocaleDateString("en-US", { timeZone: tz, weekday: "short", month: "short", day: "numeric" });
|
|
23
|
-
return `${clock} · ${date} · ${tz}`;
|
|
24
|
-
}
|
|
25
|
-
} catch {
|
|
26
|
-
/* fall through */
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (fallback && timezone) return `${fallback} · ${timezone}`;
|
|
30
|
-
return fallback ?? timezone ?? "—";
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function GetCurrentTimeToolUI({ msg, assistantLabel = "Assistant", assistantColor, showAvatar = false, generating = false }: ToolUIProps) {
|
|
34
|
-
const hasError = Boolean(msg.toolError);
|
|
35
|
-
const output = parseJsonObject<TimeResult>(msg.toolOutput);
|
|
36
|
-
const running = isToolRunning(msg, generating);
|
|
37
|
-
const label = formatLabel(output?.iso, output?.timezone, output?.time);
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<div className={`${chatRowClass} animate-fadeIn`}>
|
|
41
|
-
<ToolUiBadge show={showAvatar} label={assistantLabel} color={assistantColor} />
|
|
42
|
-
<div className="px-4">
|
|
43
|
-
<div className={chatToolLineClass}>
|
|
44
|
-
<Icon name="clock" size={13} className="shrink-0 text-muted-foreground" />
|
|
45
|
-
<Shimmer active={running} className="truncate font-normal tabular-nums text-muted-foreground">{hasError ? "Failed to get time" : running ? "Getting time…" : label}</Shimmer>
|
|
46
|
-
<ToolUiTrailing failed={hasError} />
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
}
|