@rise-x/apps-sdk 0.9.0 → 0.11.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.
- package/README.md +117 -32
- package/build/rsbuild/index.d.ts +6 -1
- package/build/rsbuild/index.js +24 -3
- package/build/ui/classes.json +209 -0
- package/build/ui/components/ai.d.ts +33 -1
- package/build/ui/components/app-frame.d.ts +16 -10
- package/build/ui/components/chat-input.d.ts +28 -0
- package/build/ui/components/message-scroller.d.ts +34 -10
- package/build/ui/components/sheet.d.ts +10 -0
- package/build/ui/components/thinking-rings.d.ts +4 -0
- package/build/ui/demo.html +26794 -0
- package/build/ui/index.d.ts +2 -0
- package/build/ui/standalone.js +60 -58
- package/build/ui/styles.css +1 -1
- package/package.json +4 -3
- package/template/AGENTS.md +3 -3
- package/template/README.md +5 -5
- package/template/package.json +8 -9
- package/template/rsbuild.config.mts +17 -0
- package/template/src/App.tsx +4 -1
- package/template/tsconfig.json +3 -1
- package/build/ui/reference/README.md +0 -11
- package/build/ui/reference/components/accordion.tsx +0 -85
- package/build/ui/reference/components/ai.tsx +0 -293
- package/build/ui/reference/components/alert-dialog.tsx +0 -207
- package/build/ui/reference/components/alert.tsx +0 -112
- package/build/ui/reference/components/app-frame.tsx +0 -71
- package/build/ui/reference/components/aspect-ratio.tsx +0 -28
- package/build/ui/reference/components/avatar.tsx +0 -158
- package/build/ui/reference/components/badge.tsx +0 -160
- package/build/ui/reference/components/button-group.tsx +0 -77
- package/build/ui/reference/components/button.tsx +0 -109
- package/build/ui/reference/components/calendar.tsx +0 -119
- package/build/ui/reference/components/card.tsx +0 -144
- package/build/ui/reference/components/carousel.tsx +0 -248
- package/build/ui/reference/components/chart.tsx +0 -704
- package/build/ui/reference/components/checkbox.tsx +0 -44
- package/build/ui/reference/components/collapsible.tsx +0 -43
- package/build/ui/reference/components/combobox.tsx +0 -146
- package/build/ui/reference/components/command.tsx +0 -181
- package/build/ui/reference/components/context-menu.tsx +0 -243
- package/build/ui/reference/components/data-table.tsx +0 -650
- package/build/ui/reference/components/date-picker.tsx +0 -218
- package/build/ui/reference/components/dialog.tsx +0 -172
- package/build/ui/reference/components/direction.tsx +0 -22
- package/build/ui/reference/components/dropdown-menu.tsx +0 -245
- package/build/ui/reference/components/empty-state.tsx +0 -63
- package/build/ui/reference/components/field.tsx +0 -252
- package/build/ui/reference/components/file-upload.tsx +0 -116
- package/build/ui/reference/components/hover-card.tsx +0 -64
- package/build/ui/reference/components/input-group.tsx +0 -157
- package/build/ui/reference/components/input-otp.tsx +0 -106
- package/build/ui/reference/components/input.tsx +0 -86
- package/build/ui/reference/components/item.tsx +0 -188
- package/build/ui/reference/components/kbd.tsx +0 -43
- package/build/ui/reference/components/label.tsx +0 -19
- package/build/ui/reference/components/list.tsx +0 -191
- package/build/ui/reference/components/map.css +0 -251
- package/build/ui/reference/components/map.tsx +0 -294
- package/build/ui/reference/components/menubar.tsx +0 -275
- package/build/ui/reference/components/message-scroller.tsx +0 -141
- package/build/ui/reference/components/message.tsx +0 -177
- package/build/ui/reference/components/nav.tsx +0 -127
- package/build/ui/reference/components/navigation-menu.tsx +0 -191
- package/build/ui/reference/components/page-header.tsx +0 -245
- package/build/ui/reference/components/popover.tsx +0 -76
- package/build/ui/reference/components/progress.tsx +0 -31
- package/build/ui/reference/components/radio.tsx +0 -65
- package/build/ui/reference/components/resizable.tsx +0 -40
- package/build/ui/reference/components/scroll-area.tsx +0 -55
- package/build/ui/reference/components/segmented.tsx +0 -45
- package/build/ui/reference/components/select.tsx +0 -188
- package/build/ui/reference/components/separator.tsx +0 -26
- package/build/ui/reference/components/sheet.tsx +0 -184
- package/build/ui/reference/components/skeleton.tsx +0 -15
- package/build/ui/reference/components/slider.tsx +0 -161
- package/build/ui/reference/components/snackbar.tsx +0 -27
- package/build/ui/reference/components/sonner.tsx +0 -43
- package/build/ui/reference/components/spinner.tsx +0 -27
- package/build/ui/reference/components/statistic.tsx +0 -122
- package/build/ui/reference/components/stepper.tsx +0 -138
- package/build/ui/reference/components/switch.tsx +0 -47
- package/build/ui/reference/components/table.tsx +0 -246
- package/build/ui/reference/components/textarea.tsx +0 -28
- package/build/ui/reference/components/timeline.tsx +0 -101
- package/build/ui/reference/components/toggle-group.tsx +0 -86
- package/build/ui/reference/components/toggle.tsx +0 -46
- package/build/ui/reference/components/tooltip.tsx +0 -53
- package/build/ui/reference/index.ts +0 -69
- package/build/ui/reference/lib/utils.ts +0 -34
- package/template/webpack.config.js +0 -112
- package/template/webpack.local.config.js +0 -68
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rise-x/apps-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "SDK for building federated apps on top of the Rise-X Diana shell. Includes a CLI for scaffolding new apps.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Rise-X",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"./rsbuild": {
|
|
48
48
|
"types": "./build/rsbuild/index.d.ts",
|
|
49
49
|
"default": "./build/rsbuild/index.js"
|
|
50
|
-
}
|
|
50
|
+
},
|
|
51
|
+
"./package.json": "./package.json"
|
|
51
52
|
},
|
|
52
53
|
"files": [
|
|
53
54
|
"build",
|
|
@@ -64,7 +65,7 @@
|
|
|
64
65
|
"scripts": {
|
|
65
66
|
"clean": "shx rm -rf build",
|
|
66
67
|
"test": "jest",
|
|
67
|
-
"build:package": "pnpm clean && tsc -p tsconfig.package.json && tsc -p tsconfig.ui.json && node scripts/build-ui.js && shx chmod +x build/cli/index.js",
|
|
68
|
+
"build:package": "pnpm clean && tsc -p tsconfig.package.json && tsc -p tsconfig.ui.json && node scripts/build-ui.js && node scripts/build-classes.js && node scripts/prerender-demo.js && shx chmod +x build/cli/index.js",
|
|
68
69
|
"build": "pnpm build:package",
|
|
69
70
|
"start:package": "tsc-watch -p ./tsconfig.package.json",
|
|
70
71
|
"prepack": "pnpm --filter @rise-x/ui build && pnpm build:package"
|
package/template/AGENTS.md
CHANGED
|
@@ -20,7 +20,7 @@ Rise-X host (the Diana app):
|
|
|
20
20
|
(`onInstall` / `onUpdate` / `onUninstall`) best-effort.
|
|
21
21
|
- `react`, `react-dom`, and the `@rise-x/ui` design-system runtime come
|
|
22
22
|
**from the host** via the MF share scope. Never bundle your own copies —
|
|
23
|
-
the `shared` block
|
|
23
|
+
the `shared` block the preset builds is load-bearing; don't override the
|
|
24
24
|
react-family or `@rise-x/ui` entries.
|
|
25
25
|
- **The host's React wins at runtime, and hosts run React 18 or 19**
|
|
26
26
|
depending on their generation — the same bundle must work on both. Author
|
|
@@ -30,7 +30,7 @@ Rise-X host (the Diana app):
|
|
|
30
30
|
- In a pnpm-workspace checkout, icon/UI deps (lucide-react, radix-ui, sonner)
|
|
31
31
|
may nest their own `react@19` / `@types/react@19` copies alongside the
|
|
32
32
|
workspace's hoisted `react@18`. The scaffold pins both to the app's own
|
|
33
|
-
copy — `tsconfig.json`'s `paths` for types,
|
|
33
|
+
copy — `tsconfig.json`'s `paths` for types, the preset's standalone
|
|
34
34
|
`resolve.alias` for the runtime — don't remove those pins.
|
|
35
35
|
- All platform access goes through `@rise-x/apps-sdk`: shell hooks/accessors,
|
|
36
36
|
typed connectors (`@rise-x/apps-sdk/connectors`), cached react-query hooks
|
|
@@ -55,7 +55,7 @@ Rise-X host (the Diana app):
|
|
|
55
55
|
|
|
56
56
|
## Stack
|
|
57
57
|
|
|
58
|
-
- TypeScript + React (host-provided at runtime),
|
|
58
|
+
- TypeScript + React (host-provided at runtime), Rspack Module Federation
|
|
59
59
|
- `@rise-x/apps-sdk` — shell bridge, connectors, query layer, design system
|
|
60
60
|
- `@tanstack/react-query` v5 — shared singleton with the host
|
|
61
61
|
|
package/template/README.md
CHANGED
|
@@ -22,10 +22,10 @@ Rise-X federated app scaffolded from `@rise-x/apps-sdk`.
|
|
|
22
22
|
## Run standalone
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
pnpm start # standalone dev server on port __APP_PORT__
|
|
25
|
+
pnpm start # standalone dev server on port __APP_PORT__ — open it yourself
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
Uses `
|
|
28
|
+
Uses the preset's standalone branch (`rsbuild dev --env-mode standalone`): bundles React directly (no Module Federation) and installs `createMockShell()` via `src/bootstrap.tsx` so shell hooks resolve against the mock. The design system renders for real here too — `@rise-x/ui` is aliased to the SDK's compiled standalone bundle (self-contained, CSS injected); `getShellApi` / `getShellApiV4` still throw with no host behind them — run `pnpm start:federated` alongside a host for backend access.
|
|
29
29
|
|
|
30
30
|
## Build for the shell
|
|
31
31
|
|
|
@@ -57,7 +57,7 @@ import { useFlows, useWorkRows, useSubmitWork } from '@rise-x/apps-sdk/query';
|
|
|
57
57
|
|
|
58
58
|
The query hooks need **no provider**: inside the shell they use the per-app
|
|
59
59
|
`QueryClient` the shell mounts around this app; standalone they fall back to
|
|
60
|
-
the SDK's own client.
|
|
60
|
+
the SDK's own client. The `@tanstack/react-query` share lives in the SDK's
|
|
61
61
|
`shared` block (already configured) so the shell-managed client can reach the
|
|
62
62
|
app.
|
|
63
63
|
|
|
@@ -75,8 +75,8 @@ import { Button, Input, Dialog, cn } from '@rise-x/apps-sdk/ui';
|
|
|
75
75
|
|
|
76
76
|
The Rise-X design system. Typings come from the SDK. Federated, the runtime
|
|
77
77
|
is the host's copy, delivered via the Module Federation share scope
|
|
78
|
-
(`@rise-x/ui`
|
|
79
|
-
host provides it. Standalone (`pnpm start`),
|
|
78
|
+
(`@rise-x/ui` is shared by the preset, already wired) — the Diana
|
|
79
|
+
host provides it. Standalone (`pnpm start`), the preset
|
|
80
80
|
aliases `@rise-x/ui` to the SDK's compiled bundle instead — a self-contained
|
|
81
81
|
snapshot with its own CSS injected, so components render for real without a
|
|
82
82
|
host. It's a snapshot, not the source of truth: verify in a host (or
|
package/template/package.json
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "0.1.0",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
7
|
-
"start": "
|
|
8
|
-
"start:federated": "
|
|
6
|
+
"build": "rsbuild build",
|
|
7
|
+
"start": "rsbuild dev --env-mode standalone",
|
|
8
|
+
"start:federated": "rsbuild dev",
|
|
9
|
+
"typecheck": "tsc --noEmit"
|
|
9
10
|
},
|
|
10
11
|
"dependencies": {
|
|
11
12
|
"@rise-x/apps-sdk": "__SDK_VERSION__",
|
|
@@ -15,17 +16,15 @@
|
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@commitlint/cli": "^21.2.1",
|
|
17
18
|
"@commitlint/config-conventional": "^21.2.0",
|
|
19
|
+
"@rsbuild/core": "^1.7.6",
|
|
20
|
+
"@rsbuild/plugin-react": "^1.4.6",
|
|
21
|
+
"@rsbuild/plugin-type-check": "^1.3.6",
|
|
18
22
|
"@types/react": "^18.2.0",
|
|
19
23
|
"@types/react-dom": "^18.2.0",
|
|
20
24
|
"axios": "^1.7.7",
|
|
21
|
-
"html-webpack-plugin": "^5.5.3",
|
|
22
25
|
"react": "^18.2.0",
|
|
23
26
|
"react-dom": "^18.2.0",
|
|
24
27
|
"react-router-dom": "^6.19.0",
|
|
25
|
-
"
|
|
26
|
-
"typescript": "^5.3.0",
|
|
27
|
-
"webpack": "^5.90.0",
|
|
28
|
-
"webpack-cli": "^5.1.4",
|
|
29
|
-
"webpack-dev-server": "^4.15.1"
|
|
28
|
+
"typescript": "^5.3.0"
|
|
30
29
|
}
|
|
31
30
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from '@rsbuild/core';
|
|
2
|
+
import { defineAppConfig } from '@rise-x/apps-sdk/rsbuild';
|
|
3
|
+
import pkg from './package.json';
|
|
4
|
+
|
|
5
|
+
// The Module Federation contract with the shell lives in the preset, not here —
|
|
6
|
+
// you upgrade it by upgrading the SDK.
|
|
7
|
+
//
|
|
8
|
+
// pnpm build federated bundle for the shell -> dist/
|
|
9
|
+
// pnpm start:federated same, served for a host to load
|
|
10
|
+
// pnpm start standalone dev, no shell -> dist-local/
|
|
11
|
+
//
|
|
12
|
+
// `--env-mode local` is rejected by Rsbuild; standalone uses `standalone`.
|
|
13
|
+
// .mts, not .ts: it marks the file ESM, which a plain .ts warns about on every
|
|
14
|
+
// build. Do not use "type": "module" instead — it breaks commitlint.config.js.
|
|
15
|
+
export default defineConfig(({ envMode }) =>
|
|
16
|
+
defineAppConfig({ pkg, port: __APP_PORT__, standalone: envMode === 'standalone' }),
|
|
17
|
+
);
|
package/template/src/App.tsx
CHANGED
|
@@ -35,6 +35,9 @@ import {
|
|
|
35
35
|
* the left while AppContent owns the scroll and slides under the host's
|
|
36
36
|
* floating top bar (they pad by the host-published --topbar-h variable —
|
|
37
37
|
* never hardcode a bar height, and never add another page scroller).
|
|
38
|
+
* · mobileNav="tabs" turns the rail into a bottom tab bar once the frame is
|
|
39
|
+
* narrow — the native phone pattern. Past five destinations it keeps four
|
|
40
|
+
* and folds the rest behind More on its own. Never hand-roll a tab bar.
|
|
38
41
|
* · App navigation is the LEFT RAIL (AppRail + Nav primitives), sitting
|
|
39
42
|
* directly on the page background — never wrapped in a Card or Panel.
|
|
40
43
|
* Cards are for content, not chrome.
|
|
@@ -79,7 +82,7 @@ function Shell() {
|
|
|
79
82
|
// region. NOTE: the host ships only the utility classes used inside the
|
|
80
83
|
// design system itself; app-specific values go in inline styles or your
|
|
81
84
|
// own CSS — the AppFrame primitives carry their own classes.
|
|
82
|
-
<AppFrame>
|
|
85
|
+
<AppFrame mobileNav="tabs">
|
|
83
86
|
{/* Left rail: a borderless list on the page background — NOT a Card. */}
|
|
84
87
|
<AppRail>
|
|
85
88
|
<Nav>
|
package/template/tsconfig.json
CHANGED
|
@@ -27,5 +27,7 @@
|
|
|
27
27
|
"react-dom": ["./node_modules/@types/react-dom", "../../node_modules/@types/react-dom"]
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
|
|
30
|
+
// rsbuild.config.mts is included so `pnpm typecheck` covers it — a wrong
|
|
31
|
+
// defineAppConfig option would otherwise only surface on a real build.
|
|
32
|
+
"include": ["src", "rsbuild.config.mts"]
|
|
31
33
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Reference only — NOT runtime code.
|
|
2
|
-
|
|
3
|
-
These are the @rise-x/ui design-system sources, shipped so agents and tools
|
|
4
|
-
can read component APIs, variants, and markup/class strings — e.g. to build
|
|
5
|
-
static single-file HTML design mocks: inline ../styles.css (the compiled
|
|
6
|
-
design-system stylesheet, Inter font embedded) and reuse the markup from
|
|
7
|
-
these sources. The canonical app layout (left-rail chrome, screen
|
|
8
|
-
composition) lives in the scaffold template: <package>/template/src/App.tsx.
|
|
9
|
-
|
|
10
|
-
At runtime the components come from the HOST's Module Federation share scope
|
|
11
|
-
via @rise-x/apps-sdk/ui — never import these files from app code.
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { Accordion as AccordionPrimitive } from 'radix-ui';
|
|
5
|
-
import { ChevronDownIcon } from 'lucide-react';
|
|
6
|
-
|
|
7
|
-
import { cn } from '@rise-x/ui/lib/utils';
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
* Progressive disclosure for a list of sections. The trigger is the whole row —
|
|
11
|
-
* a chevron you have to hit is a target the size of a full stop.
|
|
12
|
-
*
|
|
13
|
-
* THE CONTAINER OWNS THE DIVIDERS, drawn between items rather than as a border
|
|
14
|
-
* on every row: a top-and-bottom border doubles up at every seam. Same rule as
|
|
15
|
-
* List, and the same reason.
|
|
16
|
-
*
|
|
17
|
-
* NO SURFACE OF ITS OWN by default. An accordion inside a card is already on a
|
|
18
|
-
* surface, and wrapping each item in another one produces a box in a box. Pass
|
|
19
|
-
* `bordered` for the standalone case where the group needs to read as one object.
|
|
20
|
-
*/
|
|
21
|
-
function Accordion({ className, ...props }: React.ComponentProps<typeof AccordionPrimitive.Root>) {
|
|
22
|
-
return <AccordionPrimitive.Root data-slot="accordion" className={cn(className)} {...props} />;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function AccordionItem({
|
|
26
|
-
className,
|
|
27
|
-
...props
|
|
28
|
-
}: React.ComponentProps<typeof AccordionPrimitive.Item>) {
|
|
29
|
-
return (
|
|
30
|
-
<AccordionPrimitive.Item
|
|
31
|
-
data-slot="accordion-item"
|
|
32
|
-
className={cn('border-t border-border-subtle first:border-t-0', className)}
|
|
33
|
-
{...props}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function AccordionTrigger({
|
|
39
|
-
className,
|
|
40
|
-
children,
|
|
41
|
-
...props
|
|
42
|
-
}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
|
|
43
|
-
return (
|
|
44
|
-
<AccordionPrimitive.Header className="flex">
|
|
45
|
-
<AccordionPrimitive.Trigger
|
|
46
|
-
data-slot="accordion-trigger"
|
|
47
|
-
className={cn(
|
|
48
|
-
'flex flex-1 cursor-pointer items-center gap-2.5 border-0 bg-transparent py-3 text-left text-ui font-medium outline-none transition-colors duration-150 ease-decelerate',
|
|
49
|
-
'hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring-control/35',
|
|
50
|
-
// the chevron turns rather than swapping glyph: one mark, one meaning
|
|
51
|
-
'[&>svg]:size-3.5 [&>svg]:shrink-0 [&>svg]:text-muted-foreground [&>svg]:transition-transform [&>svg]:duration-200 [&>svg]:ease-decelerate',
|
|
52
|
-
'data-open:[&>svg]:rotate-180',
|
|
53
|
-
className,
|
|
54
|
-
)}
|
|
55
|
-
{...props}
|
|
56
|
-
>
|
|
57
|
-
<span className="min-w-0 flex-1">{children}</span>
|
|
58
|
-
<ChevronDownIcon aria-hidden />
|
|
59
|
-
</AccordionPrimitive.Trigger>
|
|
60
|
-
</AccordionPrimitive.Header>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function AccordionContent({
|
|
65
|
-
className,
|
|
66
|
-
children,
|
|
67
|
-
...props
|
|
68
|
-
}: React.ComponentProps<typeof AccordionPrimitive.Content>) {
|
|
69
|
-
return (
|
|
70
|
-
<AccordionPrimitive.Content
|
|
71
|
-
data-slot="accordion-content"
|
|
72
|
-
className={cn(
|
|
73
|
-
'overflow-hidden text-xs text-muted-foreground',
|
|
74
|
-
'data-open:animate-accordion-down data-closed:animate-accordion-up',
|
|
75
|
-
)}
|
|
76
|
-
{...props}
|
|
77
|
-
>
|
|
78
|
-
{/* padding on an inner element, not the animated one — animating a box
|
|
79
|
-
whose own padding is part of the measured height stutters at both ends */}
|
|
80
|
-
<div className={cn('pb-3', className)}>{children}</div>
|
|
81
|
-
</AccordionPrimitive.Content>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@rise-x/ui/lib/utils';
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* THE AI LAYER. One rule governs everything here:
|
|
10
|
-
*
|
|
11
|
-
* BERRY MARKS ACTIVITY, NOT AUTHORSHIP.
|
|
12
|
-
*
|
|
13
|
-
* Colour appears while Diana is *doing* something — thinking, inferring,
|
|
14
|
-
* proposing — and the gradient is what carries that. Flat berry marks
|
|
15
|
-
* provenance ("this value came from Diana"). A FINISHED ANSWER GETS NOTHING:
|
|
16
|
-
* no bubble, no tint, no border. AI answers are long, and a tinted block the
|
|
17
|
-
* height of the viewport is a wall, not an accent. The four tiers:
|
|
18
|
-
*
|
|
19
|
-
* gradient pill → working / thinking (AiWorking)
|
|
20
|
-
* gradient sweep → a value being computed (AiShimmer)
|
|
21
|
-
* flat berry → provenance, already settled (AiMark, AiNote, AiRow)
|
|
22
|
-
* no colour → the finished answer itself (MessageBubble variant="ai")
|
|
23
|
-
*
|
|
24
|
-
* Berry is also absent from the chart ramp for the same reason: a colour cannot
|
|
25
|
-
* mean "Diana did this" and "held records" in the same product.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/* ---- provenance ---------------------------------------------------------- */
|
|
29
|
-
|
|
30
|
-
function AiMark({ className, ...props }: React.ComponentProps<'span'>) {
|
|
31
|
-
return (
|
|
32
|
-
<span
|
|
33
|
-
data-slot="ai-mark"
|
|
34
|
-
aria-hidden
|
|
35
|
-
className={cn(
|
|
36
|
-
'inline-grid size-[15px] shrink-0 place-items-center text-ai-text [&_svg]:size-[15px]',
|
|
37
|
-
className,
|
|
38
|
-
)}
|
|
39
|
-
{...props}
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Secondary label, e.g. "AI matched". Sits beside the data, never on it. */
|
|
45
|
-
function AiNote({ className, ...props }: React.ComponentProps<'span'>) {
|
|
46
|
-
return (
|
|
47
|
-
<span
|
|
48
|
-
data-slot="ai-note"
|
|
49
|
-
className={cn(
|
|
50
|
-
'inline-flex items-center gap-1.5 text-micro text-ai-text [&>svg]:size-3',
|
|
51
|
-
className,
|
|
52
|
-
)}
|
|
53
|
-
{...props}
|
|
54
|
-
/>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Wash for a row or card Diana touched. 2.5% — enough to group the row once the
|
|
60
|
-
* glyph and label are present, and deliberately not enough to compete with the
|
|
61
|
-
* data. No edge stripe: an edge reads as something stuck on the row.
|
|
62
|
-
*/
|
|
63
|
-
function AiRow({ className, ...props }: React.ComponentProps<'div'>) {
|
|
64
|
-
return <div data-slot="ai-row" className={cn('bg-ai-wash', className)} {...props} />;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/* ---- activity ------------------------------------------------------------ */
|
|
68
|
-
|
|
69
|
-
/** Diana is working. The gradient is the signal; it stops when the work does. */
|
|
70
|
-
function AiWorking({ className, children, ...props }: React.ComponentProps<'span'>) {
|
|
71
|
-
return (
|
|
72
|
-
<span
|
|
73
|
-
data-slot="ai-working"
|
|
74
|
-
className={cn(
|
|
75
|
-
// gap-1.5 is the icon-to-text step used by AiNote / AiExplainSummary;
|
|
76
|
-
// the dots keep their own tighter gap-1 below.
|
|
77
|
-
'inline-flex items-center gap-1.5 rounded-full bg-ai/9 px-[11px] py-2 text-ui text-ai-text',
|
|
78
|
-
className,
|
|
79
|
-
)}
|
|
80
|
-
{...props}
|
|
81
|
-
>
|
|
82
|
-
<span aria-hidden className="flex gap-1">
|
|
83
|
-
{[0, 1, 2].map((i) => (
|
|
84
|
-
<i
|
|
85
|
-
key={i}
|
|
86
|
-
className="size-[5px] rounded-full bg-[image:var(--ai-grad)] motion-safe:animate-[aiBlip_1.1s_ease-in-out_infinite]"
|
|
87
|
-
style={{ animationDelay: `${i * 0.15}s` }}
|
|
88
|
-
/>
|
|
89
|
-
))}
|
|
90
|
-
</span>
|
|
91
|
-
{children}
|
|
92
|
-
</span>
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* A value being computed. Replaces the text entirely — a half-rendered number
|
|
98
|
-
* is worse than no number — and stops the moment there is a value.
|
|
99
|
-
* `prefers-reduced-motion` freezes the sweep rather than looping it.
|
|
100
|
-
*/
|
|
101
|
-
function AiShimmer({ className, children, ...props }: React.ComponentProps<'span'>) {
|
|
102
|
-
return (
|
|
103
|
-
<span
|
|
104
|
-
data-slot="ai-shimmer"
|
|
105
|
-
aria-busy
|
|
106
|
-
className={cn(
|
|
107
|
-
'relative inline-block overflow-hidden rounded-sm bg-fill-1 text-transparent!',
|
|
108
|
-
'after:absolute after:inset-0 after:bg-[linear-gradient(90deg,transparent_0%,color-mix(in_srgb,var(--berry)_26%,transparent)_42%,color-mix(in_srgb,var(--blue)_22%,transparent)_62%,transparent_100%)] after:motion-safe:animate-[aiSweep_1.5s_var(--ease)_infinite]',
|
|
109
|
-
className,
|
|
110
|
-
)}
|
|
111
|
-
{...props}
|
|
112
|
-
>
|
|
113
|
-
{children}
|
|
114
|
-
</span>
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/* ---- confidence --------------------------------------------------------- */
|
|
119
|
-
|
|
120
|
-
const confidenceVariants = cva(
|
|
121
|
-
'inline-flex h-5 items-center gap-1.5 rounded-sm border border-transparent px-[7px] text-micro font-medium',
|
|
122
|
-
{
|
|
123
|
-
variants: {
|
|
124
|
-
level: {
|
|
125
|
-
high: 'bg-success/13 text-success-text',
|
|
126
|
-
medium: 'bg-warning/15 text-warning-text',
|
|
127
|
-
low: 'bg-error/12 text-error-text',
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
defaultVariants: { level: 'high' },
|
|
131
|
-
},
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const SEGMENTS = { high: 3, medium: 2, low: 1 } as const;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* A THREE-SEGMENT METER plus the number, in a tinted pill — signal-bars, not a
|
|
138
|
-
* continuous progress bar. Two reasons: the segments are legible at a glance
|
|
139
|
-
* from across a table where a 52px bar is not, and a continuous bar invites
|
|
140
|
-
* comparison of 73% against 71% when the underlying score does not support that
|
|
141
|
-
* precision.
|
|
142
|
-
*
|
|
143
|
-
* Whenever there IS a figure the word ships with it, because "Medium" alone
|
|
144
|
-
* tells a reviewer nothing actionable. But a run may report only a level — no
|
|
145
|
-
* percentage is invented to fill the gap: omit `value` and the label reads
|
|
146
|
-
* "Medium confidence", segments unchanged.
|
|
147
|
-
*/
|
|
148
|
-
function AiConfidence({
|
|
149
|
-
className,
|
|
150
|
-
level = 'high',
|
|
151
|
-
value,
|
|
152
|
-
showLabel = true,
|
|
153
|
-
...props
|
|
154
|
-
}: React.ComponentProps<'span'> &
|
|
155
|
-
VariantProps<typeof confidenceVariants> & { value?: number; showLabel?: boolean }) {
|
|
156
|
-
const lit = SEGMENTS[level ?? 'high'];
|
|
157
|
-
const word = level === 'high' ? 'High' : level === 'medium' ? 'Medium' : 'Low';
|
|
158
|
-
return (
|
|
159
|
-
<span
|
|
160
|
-
data-slot="ai-confidence"
|
|
161
|
-
data-level={level}
|
|
162
|
-
className={cn(confidenceVariants({ level }), className)}
|
|
163
|
-
{...props}
|
|
164
|
-
>
|
|
165
|
-
<span aria-hidden className="inline-flex gap-[2px]">
|
|
166
|
-
{[0, 1, 2].map((i) => (
|
|
167
|
-
<b
|
|
168
|
-
key={i}
|
|
169
|
-
className={cn(
|
|
170
|
-
'h-[9px] w-[3px] rounded-[1.5px] bg-current',
|
|
171
|
-
i < lit ? 'opacity-100' : 'opacity-[0.22]',
|
|
172
|
-
)}
|
|
173
|
-
/>
|
|
174
|
-
))}
|
|
175
|
-
</span>
|
|
176
|
-
<span className="tabular-nums">
|
|
177
|
-
{/* No figure → the word carries the whole label, so `showLabel` has
|
|
178
|
-
* nothing left to hide. */}
|
|
179
|
-
{value === undefined ? `${word} confidence` : `${showLabel ? `${word} · ` : ''}${value}%`}
|
|
180
|
-
</span>
|
|
181
|
-
</span>
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/* ---- validation result -------------------------------------------------- */
|
|
186
|
-
|
|
187
|
-
const validationVariants = cva(
|
|
188
|
-
'grid size-4 shrink-0 place-items-center rounded-sm [&_svg]:size-[11px]',
|
|
189
|
-
{
|
|
190
|
-
variants: {
|
|
191
|
-
result: {
|
|
192
|
-
passed: 'bg-success/13 text-success-text',
|
|
193
|
-
warning: 'bg-warning/16 text-warning-text',
|
|
194
|
-
failed: 'bg-error/14 text-error-text',
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
defaultVariants: { result: 'passed' },
|
|
198
|
-
},
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
/* A small tinted glyph, not a coloured badge — three stacked badges turn a
|
|
202
|
-
* detail region into confetti. */
|
|
203
|
-
function AiValidation({
|
|
204
|
-
className,
|
|
205
|
-
result = 'passed',
|
|
206
|
-
...props
|
|
207
|
-
}: React.ComponentProps<'span'> & VariantProps<typeof validationVariants>) {
|
|
208
|
-
return (
|
|
209
|
-
<span
|
|
210
|
-
data-slot="ai-validation"
|
|
211
|
-
data-result={result}
|
|
212
|
-
className={cn(validationVariants({ result }), className)}
|
|
213
|
-
{...props}
|
|
214
|
-
/>
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/* ---- suggested action --------------------------------------------------- */
|
|
219
|
-
|
|
220
|
-
function AiSuggestion({ className, ...props }: React.ComponentProps<'div'>) {
|
|
221
|
-
return (
|
|
222
|
-
<div
|
|
223
|
-
data-slot="ai-suggestion"
|
|
224
|
-
className={cn(
|
|
225
|
-
// Diana is proposing — activity, so the gradient edge is allowed
|
|
226
|
-
'flex items-start gap-2.5 rounded-lg border border-ai-edge bg-ai-tint p-3 text-xs [&>svg]:mt-px [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-ai-text',
|
|
227
|
-
className,
|
|
228
|
-
)}
|
|
229
|
-
{...props}
|
|
230
|
-
/>
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/* ---- explain affordance ------------------------------------------------- */
|
|
235
|
-
|
|
236
|
-
/** Reasoning stays collapsed by default: an explanation nobody asked for is
|
|
237
|
-
* noise, and one nobody can find is a black box. */
|
|
238
|
-
function AiExplain({ className, ...props }: React.ComponentProps<'details'>) {
|
|
239
|
-
return (
|
|
240
|
-
<details data-slot="ai-explain" className={cn('group/explain text-xs', className)} {...props} />
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function AiExplainSummary({ className, children, ...props }: React.ComponentProps<'summary'>) {
|
|
245
|
-
return (
|
|
246
|
-
<summary
|
|
247
|
-
data-slot="ai-explain-summary"
|
|
248
|
-
className={cn(
|
|
249
|
-
'flex cursor-pointer list-none items-center gap-1.5 rounded-md py-1 text-micro text-muted-foreground transition-colors marker:content-none hover:text-foreground [&::-webkit-details-marker]:hidden',
|
|
250
|
-
className,
|
|
251
|
-
)}
|
|
252
|
-
{...props}
|
|
253
|
-
>
|
|
254
|
-
{children}
|
|
255
|
-
<svg
|
|
256
|
-
aria-hidden
|
|
257
|
-
viewBox="0 0 24 24"
|
|
258
|
-
fill="none"
|
|
259
|
-
stroke="currentColor"
|
|
260
|
-
strokeWidth={2.5}
|
|
261
|
-
className="size-3 transition-transform duration-150 ease-decelerate group-open/explain:rotate-90"
|
|
262
|
-
>
|
|
263
|
-
<path d="M9 6l6 6-6 6" strokeLinecap="round" />
|
|
264
|
-
</svg>
|
|
265
|
-
</summary>
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function AiExplainBody({ className, ...props }: React.ComponentProps<'div'>) {
|
|
270
|
-
return (
|
|
271
|
-
<div
|
|
272
|
-
data-slot="ai-explain-body"
|
|
273
|
-
className={cn('mt-1.5 flex flex-col gap-1.5 text-xs text-muted-foreground', className)}
|
|
274
|
-
{...props}
|
|
275
|
-
/>
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export {
|
|
280
|
-
AiMark,
|
|
281
|
-
AiNote,
|
|
282
|
-
AiRow,
|
|
283
|
-
AiWorking,
|
|
284
|
-
AiShimmer,
|
|
285
|
-
AiConfidence,
|
|
286
|
-
AiValidation,
|
|
287
|
-
AiSuggestion,
|
|
288
|
-
AiExplain,
|
|
289
|
-
AiExplainSummary,
|
|
290
|
-
AiExplainBody,
|
|
291
|
-
confidenceVariants,
|
|
292
|
-
validationVariants,
|
|
293
|
-
};
|