@rise-x/apps-sdk 0.6.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.
Files changed (185) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +553 -0
  3. package/build/_internal.d.ts +2 -0
  4. package/build/_internal.js +23 -0
  5. package/build/accessors.d.ts +8 -0
  6. package/build/accessors.js +40 -0
  7. package/build/cli/index.d.ts +13 -0
  8. package/build/cli/index.js +54 -0
  9. package/build/cli/init.d.ts +6 -0
  10. package/build/cli/init.js +179 -0
  11. package/build/cli/templating.d.ts +2 -0
  12. package/build/cli/templating.js +84 -0
  13. package/build/connectors/agents.d.ts +85 -0
  14. package/build/connectors/agents.js +404 -0
  15. package/build/connectors/assets.d.ts +76 -0
  16. package/build/connectors/assets.js +204 -0
  17. package/build/connectors/deps.d.ts +4 -0
  18. package/build/connectors/deps.js +2 -0
  19. package/build/connectors/errors.d.ts +11 -0
  20. package/build/connectors/errors.js +67 -0
  21. package/build/connectors/flows.d.ts +37 -0
  22. package/build/connectors/flows.js +191 -0
  23. package/build/connectors/index.d.ts +8 -0
  24. package/build/connectors/index.js +50 -0
  25. package/build/connectors/sse.d.ts +12 -0
  26. package/build/connectors/sse.js +157 -0
  27. package/build/connectors/types.d.ts +285 -0
  28. package/build/connectors/types.js +419 -0
  29. package/build/connectors/work.d.ts +84 -0
  30. package/build/connectors/work.js +224 -0
  31. package/build/hooks.d.ts +4 -0
  32. package/build/hooks.js +28 -0
  33. package/build/index.d.ts +6 -0
  34. package/build/index.js +34 -0
  35. package/build/lifecycle.d.ts +23 -0
  36. package/build/lifecycle.js +6 -0
  37. package/build/mockShell.d.ts +10 -0
  38. package/build/mockShell.js +55 -0
  39. package/build/query/agents.d.ts +80 -0
  40. package/build/query/agents.js +143 -0
  41. package/build/query/assets.d.ts +73 -0
  42. package/build/query/assets.js +152 -0
  43. package/build/query/client.d.ts +5 -0
  44. package/build/query/client.js +68 -0
  45. package/build/query/context.d.ts +2 -0
  46. package/build/query/context.js +34 -0
  47. package/build/query/flows.d.ts +54 -0
  48. package/build/query/flows.js +81 -0
  49. package/build/query/index.d.ts +10 -0
  50. package/build/query/index.js +85 -0
  51. package/build/query/keys.d.ts +51 -0
  52. package/build/query/keys.js +79 -0
  53. package/build/query/layer.d.ts +175 -0
  54. package/build/query/layer.js +35 -0
  55. package/build/query/shared.d.ts +43 -0
  56. package/build/query/shared.js +116 -0
  57. package/build/query/work.d.ts +75 -0
  58. package/build/query/work.js +172 -0
  59. package/build/shell/index.d.ts +1 -0
  60. package/build/shell/index.js +6 -0
  61. package/build/shell/installShellBridge.d.ts +11 -0
  62. package/build/shell/installShellBridge.js +104 -0
  63. package/build/shellBridge.d.ts +36 -0
  64. package/build/shellBridge.js +10 -0
  65. package/build/topBar.d.ts +25 -0
  66. package/build/topBar.js +17 -0
  67. package/build/ui/components/ai.d.ts +49 -0
  68. package/build/ui/components/alert-dialog.d.ts +27 -0
  69. package/build/ui/components/alert.d.ts +14 -0
  70. package/build/ui/components/avatar.d.ts +17 -0
  71. package/build/ui/components/badge.d.ts +19 -0
  72. package/build/ui/components/button.d.ts +13 -0
  73. package/build/ui/components/calendar.d.ts +21 -0
  74. package/build/ui/components/card.d.ts +16 -0
  75. package/build/ui/components/chart.d.ts +124 -0
  76. package/build/ui/components/checkbox.d.ts +4 -0
  77. package/build/ui/components/data-table.d.ts +70 -0
  78. package/build/ui/components/dialog.d.ts +17 -0
  79. package/build/ui/components/dropdown-menu.d.ts +29 -0
  80. package/build/ui/components/empty-state.d.ts +7 -0
  81. package/build/ui/components/file-upload.d.ts +17 -0
  82. package/build/ui/components/input.d.ts +8 -0
  83. package/build/ui/components/label.d.ts +4 -0
  84. package/build/ui/components/list.d.ts +24 -0
  85. package/build/ui/components/map.d.ts +26 -0
  86. package/build/ui/components/message.d.ts +24 -0
  87. package/build/ui/components/nav.d.ts +12 -0
  88. package/build/ui/components/page-header.d.ts +27 -0
  89. package/build/ui/components/popover.d.ts +10 -0
  90. package/build/ui/components/progress.d.ts +4 -0
  91. package/build/ui/components/radio.d.ts +6 -0
  92. package/build/ui/components/resizable.d.ts +7 -0
  93. package/build/ui/components/scroll-area.d.ts +5 -0
  94. package/build/ui/components/segmented.d.ts +6 -0
  95. package/build/ui/components/select.d.ts +15 -0
  96. package/build/ui/components/separator.d.ts +4 -0
  97. package/build/ui/components/sheet.d.ts +14 -0
  98. package/build/ui/components/skeleton.d.ts +3 -0
  99. package/build/ui/components/slider.d.ts +15 -0
  100. package/build/ui/components/snackbar.d.ts +3 -0
  101. package/build/ui/components/sonner.d.ts +4 -0
  102. package/build/ui/components/spinner.d.ts +5 -0
  103. package/build/ui/components/statistic.d.ts +19 -0
  104. package/build/ui/components/stepper.d.ts +12 -0
  105. package/build/ui/components/switch.d.ts +6 -0
  106. package/build/ui/components/table.d.ts +24 -0
  107. package/build/ui/components/textarea.d.ts +3 -0
  108. package/build/ui/components/timeline.d.ts +15 -0
  109. package/build/ui/components/toggle-group.d.ts +10 -0
  110. package/build/ui/components/toggle.d.ts +9 -0
  111. package/build/ui/components/tooltip.d.ts +7 -0
  112. package/build/ui/index.d.ts +46 -0
  113. package/build/ui/index.js +8 -0
  114. package/build/ui/lib/utils.d.ts +2 -0
  115. package/build/ui/reference/README.md +11 -0
  116. package/build/ui/reference/components/ai.tsx +291 -0
  117. package/build/ui/reference/components/alert-dialog.tsx +208 -0
  118. package/build/ui/reference/components/alert.tsx +112 -0
  119. package/build/ui/reference/components/avatar.tsx +158 -0
  120. package/build/ui/reference/components/badge.tsx +160 -0
  121. package/build/ui/reference/components/button.tsx +100 -0
  122. package/build/ui/reference/components/calendar.tsx +119 -0
  123. package/build/ui/reference/components/card.tsx +144 -0
  124. package/build/ui/reference/components/chart.tsx +1394 -0
  125. package/build/ui/reference/components/checkbox.tsx +44 -0
  126. package/build/ui/reference/components/data-table.tsx +480 -0
  127. package/build/ui/reference/components/dialog.tsx +172 -0
  128. package/build/ui/reference/components/dropdown-menu.tsx +245 -0
  129. package/build/ui/reference/components/empty-state.tsx +63 -0
  130. package/build/ui/reference/components/file-upload.tsx +116 -0
  131. package/build/ui/reference/components/input.tsx +114 -0
  132. package/build/ui/reference/components/label.tsx +19 -0
  133. package/build/ui/reference/components/list.tsx +191 -0
  134. package/build/ui/reference/components/map.css +251 -0
  135. package/build/ui/reference/components/map.tsx +294 -0
  136. package/build/ui/reference/components/message.tsx +171 -0
  137. package/build/ui/reference/components/nav.tsx +113 -0
  138. package/build/ui/reference/components/page-header.tsx +213 -0
  139. package/build/ui/reference/components/popover.tsx +76 -0
  140. package/build/ui/reference/components/progress.tsx +31 -0
  141. package/build/ui/reference/components/radio.tsx +65 -0
  142. package/build/ui/reference/components/resizable.tsx +40 -0
  143. package/build/ui/reference/components/scroll-area.tsx +55 -0
  144. package/build/ui/reference/components/segmented.tsx +45 -0
  145. package/build/ui/reference/components/select.tsx +185 -0
  146. package/build/ui/reference/components/separator.tsx +26 -0
  147. package/build/ui/reference/components/sheet.tsx +173 -0
  148. package/build/ui/reference/components/skeleton.tsx +15 -0
  149. package/build/ui/reference/components/slider.tsx +161 -0
  150. package/build/ui/reference/components/snackbar.tsx +27 -0
  151. package/build/ui/reference/components/sonner.tsx +43 -0
  152. package/build/ui/reference/components/spinner.tsx +27 -0
  153. package/build/ui/reference/components/statistic.tsx +122 -0
  154. package/build/ui/reference/components/stepper.tsx +138 -0
  155. package/build/ui/reference/components/switch.tsx +47 -0
  156. package/build/ui/reference/components/table.tsx +233 -0
  157. package/build/ui/reference/components/textarea.tsx +28 -0
  158. package/build/ui/reference/components/timeline.tsx +94 -0
  159. package/build/ui/reference/components/toggle-group.tsx +86 -0
  160. package/build/ui/reference/components/toggle.tsx +46 -0
  161. package/build/ui/reference/components/tooltip.tsx +53 -0
  162. package/build/ui/reference/index.ts +49 -0
  163. package/build/ui/reference/lib/utils.ts +34 -0
  164. package/build/ui/standalone-stub.js +5 -0
  165. package/build/ui/standalone.js +135 -0
  166. package/build/ui/styles.css +3 -0
  167. package/connectors/package.json +8 -0
  168. package/package.json +114 -0
  169. package/query/package.json +8 -0
  170. package/shell/package.json +8 -0
  171. package/template/AGENTS.md +70 -0
  172. package/template/CLAUDE.md +4 -0
  173. package/template/README.md +102 -0
  174. package/template/_gitignore +6 -0
  175. package/template/commitlint.config.js +12 -0
  176. package/template/package.json +31 -0
  177. package/template/public/index.html +13 -0
  178. package/template/src/App.tsx +171 -0
  179. package/template/src/bootstrap.tsx +13 -0
  180. package/template/src/index.tsx +1 -0
  181. package/template/src/lifecycle.ts +20 -0
  182. package/template/tsconfig.json +31 -0
  183. package/template/webpack.config.js +112 -0
  184. package/template/webpack.local.config.js +68 -0
  185. package/ui/package.json +8 -0
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ declare function Table({ className, ...props }: React.ComponentProps<'table'>): React.JSX.Element;
3
+ declare function TableWrap({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
4
+ declare function TableHeader({ className, ...props }: React.ComponentProps<'thead'>): React.JSX.Element;
5
+ declare function TableBody({ className, ...props }: React.ComponentProps<'tbody'>): React.JSX.Element;
6
+ declare function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>): React.JSX.Element;
7
+ declare function TableRow({ className, expanded, ...props }: React.ComponentProps<'tr'> & {
8
+ /** This row is showing its own TableExpandedRow beneath it. Drops the
9
+ * hairline underneath so the pair reads as one uninterrupted surface. */
10
+ expanded?: boolean;
11
+ }): React.JSX.Element;
12
+ declare function TableGroupRow({ className, children, colSpan, cellClassName, ...props }: React.ComponentProps<'tr'> & {
13
+ colSpan?: number;
14
+ /** Merged onto the inner cell — the band's own size, case and padding live
15
+ * there, not on the row. */
16
+ cellClassName?: string;
17
+ }): React.JSX.Element;
18
+ declare function TableExpandedRow({ className, ...props }: React.ComponentProps<'tr'>): React.JSX.Element;
19
+ declare function TableHead({ className, ...props }: React.ComponentProps<'th'>): React.JSX.Element;
20
+ declare function TableCell({ className, ...props }: React.ComponentProps<'td'>): React.JSX.Element;
21
+ declare function TableCaption({ className, ...props }: React.ComponentProps<'caption'>): React.JSX.Element;
22
+ declare function TableCellStack({ className, ...props }: React.ComponentProps<'span'>): React.JSX.Element;
23
+ declare function TableLazySentinel({ className, children, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
24
+ export { Table, TableWrap, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableGroupRow, TableExpandedRow, TableCell, TableCellStack, TableCaption, TableLazySentinel, };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ declare const Textarea: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
3
+ export { Textarea };
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { type VariantProps } from 'class-variance-authority';
3
+ declare function Timeline({ className, ...props }: React.ComponentProps<'ol'>): React.JSX.Element;
4
+ declare const nodeVariants: (props?: ({
5
+ tone?: "warning" | "neutral" | "success" | "error" | "info" | "ai" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ declare function TimelineItem({ className, tone, glyph, children, last, ...props }: React.ComponentProps<'li'> & VariantProps<typeof nodeVariants> & {
8
+ glyph?: React.ReactNode;
9
+ /** Suppresses the connecting rail below the node. */
10
+ last?: boolean;
11
+ }): React.JSX.Element;
12
+ declare function TimelineTitle({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
13
+ declare function TimelineMeta({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
14
+ declare function TimelineBody({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
15
+ export { Timeline, TimelineItem, TimelineTitle, TimelineMeta, TimelineBody, nodeVariants };
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { type VariantProps } from 'class-variance-authority';
3
+ import { ToggleGroup as ToggleGroupPrimitive } from 'radix-ui';
4
+ import { toggleVariants } from './toggle';
5
+ declare function ToggleGroup({ className, variant, size, spacing, orientation, children, ...props }: React.ComponentProps<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants> & {
6
+ spacing?: number;
7
+ orientation?: 'horizontal' | 'vertical';
8
+ }): React.JSX.Element;
9
+ declare function ToggleGroupItem({ className, children, variant, size, ...props }: React.ComponentProps<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>): React.JSX.Element;
10
+ export { ToggleGroup, ToggleGroupItem };
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { type VariantProps } from 'class-variance-authority';
3
+ import { Toggle as TogglePrimitive } from 'radix-ui';
4
+ declare const toggleVariants: (props?: ({
5
+ variant?: "default" | "outline" | null | undefined;
6
+ size?: "default" | "sm" | "lg" | null | undefined;
7
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
+ declare function Toggle({ className, variant, size, ...props }: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>): React.JSX.Element;
9
+ export { Toggle, toggleVariants };
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { Tooltip as TooltipPrimitive } from 'radix-ui';
3
+ declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): React.JSX.Element;
4
+ declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): React.JSX.Element;
5
+ declare function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): React.JSX.Element;
6
+ declare function TooltipContent({ className, sideOffset, children, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content>): React.JSX.Element;
7
+ export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
@@ -0,0 +1,46 @@
1
+ export * from './components/ai';
2
+ export * from './components/alert';
3
+ export * from './components/alert-dialog';
4
+ export * from './components/avatar';
5
+ export * from './components/badge';
6
+ export * from './components/button';
7
+ export * from './components/calendar';
8
+ export * from './components/card';
9
+ export * from './components/chart';
10
+ export * from './components/checkbox';
11
+ export * from './components/data-table';
12
+ export * from './components/dialog';
13
+ export * from './components/dropdown-menu';
14
+ export * from './components/empty-state';
15
+ export * from './components/file-upload';
16
+ export * from './components/input';
17
+ export * from './components/label';
18
+ export * from './components/list';
19
+ export * from './components/map';
20
+ export * from './components/message';
21
+ export * from './components/nav';
22
+ export * from './components/page-header';
23
+ export * from './components/popover';
24
+ export * from './components/progress';
25
+ export * from './components/radio';
26
+ export * from './components/resizable';
27
+ export * from './components/scroll-area';
28
+ export * from './components/segmented';
29
+ export * from './components/select';
30
+ export * from './components/separator';
31
+ export * from './components/sheet';
32
+ export * from './components/skeleton';
33
+ export * from './components/slider';
34
+ export * from './components/snackbar';
35
+ export * from './components/sonner';
36
+ export * from './components/spinner';
37
+ export * from './components/statistic';
38
+ export * from './components/stepper';
39
+ export * from './components/switch';
40
+ export * from './components/table';
41
+ export * from './components/textarea';
42
+ export * from './components/timeline';
43
+ export * from './components/toggle';
44
+ export * from './components/toggle-group';
45
+ export * from './components/tooltip';
46
+ export { cn } from './lib/utils';
@@ -0,0 +1,8 @@
1
+ // Runtime for @rise-x/apps-sdk/ui. '@rise-x/ui' resolves from the HOST's
2
+ // Module Federation share scope (both the Rise shell and the classic Diana
3
+ // app provide it) — the app's webpack config must list it in shared with
4
+ // { singleton: true, import: false } (see the app template). There is
5
+ // intentionally no node_modules fallback: only the host's copy is styled
6
+ // by the host's compiled Tailwind CSS.
7
+ "use strict";
8
+ module.exports = require("@rise-x/ui");
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from 'clsx';
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1,11 @@
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.
@@ -0,0 +1,291 @@
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
+ 'inline-flex items-center gap-1 rounded-full bg-ai/9 px-[11px] py-2 text-ui text-ai-text',
76
+ className,
77
+ )}
78
+ {...props}
79
+ >
80
+ <span aria-hidden className="flex gap-1">
81
+ {[0, 1, 2].map((i) => (
82
+ <i
83
+ key={i}
84
+ className="size-[5px] rounded-full bg-[image:var(--ai-grad)] motion-safe:animate-[aiBlip_1.1s_ease-in-out_infinite]"
85
+ style={{ animationDelay: `${i * 0.15}s` }}
86
+ />
87
+ ))}
88
+ </span>
89
+ {children}
90
+ </span>
91
+ );
92
+ }
93
+
94
+ /**
95
+ * A value being computed. Replaces the text entirely — a half-rendered number
96
+ * is worse than no number — and stops the moment there is a value.
97
+ * `prefers-reduced-motion` freezes the sweep rather than looping it.
98
+ */
99
+ function AiShimmer({ className, children, ...props }: React.ComponentProps<'span'>) {
100
+ return (
101
+ <span
102
+ data-slot="ai-shimmer"
103
+ aria-busy
104
+ className={cn(
105
+ 'relative inline-block overflow-hidden rounded-sm bg-fill-1 text-transparent!',
106
+ '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]',
107
+ className,
108
+ )}
109
+ {...props}
110
+ >
111
+ {children}
112
+ </span>
113
+ );
114
+ }
115
+
116
+ /* ---- confidence --------------------------------------------------------- */
117
+
118
+ const confidenceVariants = cva(
119
+ 'inline-flex h-5 items-center gap-1.5 rounded-sm border border-transparent px-[7px] text-micro font-medium',
120
+ {
121
+ variants: {
122
+ level: {
123
+ high: 'bg-success/13 text-success-text',
124
+ medium: 'bg-warning/15 text-warning-text',
125
+ low: 'bg-error/12 text-error-text',
126
+ },
127
+ },
128
+ defaultVariants: { level: 'high' },
129
+ },
130
+ );
131
+
132
+ const SEGMENTS = { high: 3, medium: 2, low: 1 } as const;
133
+
134
+ /**
135
+ * A THREE-SEGMENT METER plus the number, in a tinted pill — signal-bars, not a
136
+ * continuous progress bar. Two reasons: the segments are legible at a glance
137
+ * from across a table where a 52px bar is not, and a continuous bar invites
138
+ * comparison of 73% against 71% when the underlying score does not support that
139
+ * precision.
140
+ *
141
+ * Whenever there IS a figure the word ships with it, because "Medium" alone
142
+ * tells a reviewer nothing actionable. But a run may report only a level — no
143
+ * percentage is invented to fill the gap: omit `value` and the label reads
144
+ * "Medium confidence", segments unchanged.
145
+ */
146
+ function AiConfidence({
147
+ className,
148
+ level = 'high',
149
+ value,
150
+ showLabel = true,
151
+ ...props
152
+ }: React.ComponentProps<'span'> &
153
+ VariantProps<typeof confidenceVariants> & { value?: number; showLabel?: boolean }) {
154
+ const lit = SEGMENTS[level ?? 'high'];
155
+ const word = level === 'high' ? 'High' : level === 'medium' ? 'Medium' : 'Low';
156
+ return (
157
+ <span
158
+ data-slot="ai-confidence"
159
+ data-level={level}
160
+ className={cn(confidenceVariants({ level }), className)}
161
+ {...props}
162
+ >
163
+ <span aria-hidden className="inline-flex gap-[2px]">
164
+ {[0, 1, 2].map((i) => (
165
+ <b
166
+ key={i}
167
+ className={cn(
168
+ 'h-[9px] w-[3px] rounded-[1.5px] bg-current',
169
+ i < lit ? 'opacity-100' : 'opacity-[0.22]',
170
+ )}
171
+ />
172
+ ))}
173
+ </span>
174
+ <span className="tabular-nums">
175
+ {/* No figure → the word carries the whole label, so `showLabel` has
176
+ * nothing left to hide. */}
177
+ {value === undefined ? `${word} confidence` : `${showLabel ? `${word} · ` : ''}${value}%`}
178
+ </span>
179
+ </span>
180
+ );
181
+ }
182
+
183
+ /* ---- validation result -------------------------------------------------- */
184
+
185
+ const validationVariants = cva(
186
+ 'grid size-4 shrink-0 place-items-center rounded-sm [&_svg]:size-[11px]',
187
+ {
188
+ variants: {
189
+ result: {
190
+ passed: 'bg-success/13 text-success-text',
191
+ warning: 'bg-warning/16 text-warning-text',
192
+ failed: 'bg-error/14 text-error-text',
193
+ },
194
+ },
195
+ defaultVariants: { result: 'passed' },
196
+ },
197
+ );
198
+
199
+ /* A small tinted glyph, not a coloured badge — three stacked badges turn a
200
+ * detail region into confetti. */
201
+ function AiValidation({
202
+ className,
203
+ result = 'passed',
204
+ ...props
205
+ }: React.ComponentProps<'span'> & VariantProps<typeof validationVariants>) {
206
+ return (
207
+ <span
208
+ data-slot="ai-validation"
209
+ data-result={result}
210
+ className={cn(validationVariants({ result }), className)}
211
+ {...props}
212
+ />
213
+ );
214
+ }
215
+
216
+ /* ---- suggested action --------------------------------------------------- */
217
+
218
+ function AiSuggestion({ className, ...props }: React.ComponentProps<'div'>) {
219
+ return (
220
+ <div
221
+ data-slot="ai-suggestion"
222
+ className={cn(
223
+ // Diana is proposing — activity, so the gradient edge is allowed
224
+ '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',
225
+ className,
226
+ )}
227
+ {...props}
228
+ />
229
+ );
230
+ }
231
+
232
+ /* ---- explain affordance ------------------------------------------------- */
233
+
234
+ /** Reasoning stays collapsed by default: an explanation nobody asked for is
235
+ * noise, and one nobody can find is a black box. */
236
+ function AiExplain({ className, ...props }: React.ComponentProps<'details'>) {
237
+ return (
238
+ <details data-slot="ai-explain" className={cn('group/explain text-xs', className)} {...props} />
239
+ );
240
+ }
241
+
242
+ function AiExplainSummary({ className, children, ...props }: React.ComponentProps<'summary'>) {
243
+ return (
244
+ <summary
245
+ data-slot="ai-explain-summary"
246
+ className={cn(
247
+ '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',
248
+ className,
249
+ )}
250
+ {...props}
251
+ >
252
+ {children}
253
+ <svg
254
+ aria-hidden
255
+ viewBox="0 0 24 24"
256
+ fill="none"
257
+ stroke="currentColor"
258
+ strokeWidth={2.5}
259
+ className="size-3 transition-transform duration-150 ease-decelerate group-open/explain:rotate-90"
260
+ >
261
+ <path d="M9 6l6 6-6 6" strokeLinecap="round" />
262
+ </svg>
263
+ </summary>
264
+ );
265
+ }
266
+
267
+ function AiExplainBody({ className, ...props }: React.ComponentProps<'div'>) {
268
+ return (
269
+ <div
270
+ data-slot="ai-explain-body"
271
+ className={cn('mt-1.5 flex flex-col gap-1.5 text-xs text-muted-foreground', className)}
272
+ {...props}
273
+ />
274
+ );
275
+ }
276
+
277
+ export {
278
+ AiMark,
279
+ AiNote,
280
+ AiRow,
281
+ AiWorking,
282
+ AiShimmer,
283
+ AiConfidence,
284
+ AiValidation,
285
+ AiSuggestion,
286
+ AiExplain,
287
+ AiExplainSummary,
288
+ AiExplainBody,
289
+ confidenceVariants,
290
+ validationVariants,
291
+ };
@@ -0,0 +1,208 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { AlertDialog as AlertDialogPrimitive } from 'radix-ui';
5
+
6
+ import { cn } from '@rise-x/ui/lib/utils';
7
+ import { Button } from '@rise-x/ui/components/button';
8
+
9
+ /*
10
+ * forwardRef throughout, for the same reason button.tsx uses it (see the comment
11
+ * there): the classic React 18 host renders these components too, and React 18
12
+ * strips `ref` from a plain function component instead of passing it as a prop.
13
+ *
14
+ * This is not only about refs a caller passes. Radix refs the overlay ITSELF:
15
+ * AlertDialogContent puts <AlertDialogOverlay /> inside the portal, and radix's
16
+ * Portal wraps each child in Presence + `Primitive.div asChild`, whose Slot
17
+ * hands the child a composed ref. Under React 18 a plain-function overlay drops
18
+ * it, so Presence never sees the overlay node and closes it without its
19
+ * exit animation — plus a "Function components cannot be given refs" warning on
20
+ * every open. Only AlertDialog (Root) and AlertDialogPortal are left as plain
21
+ * functions: neither renders a DOM node, and radix's own are plain too.
22
+ */
23
+
24
+ function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
25
+ return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />;
26
+ }
27
+
28
+ const AlertDialogTrigger = React.forwardRef<
29
+ HTMLButtonElement,
30
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Trigger>
31
+ >(function AlertDialogTrigger({ ...props }, ref) {
32
+ return <AlertDialogPrimitive.Trigger ref={ref} data-slot="alert-dialog-trigger" {...props} />;
33
+ });
34
+
35
+ function AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
36
+ return <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />;
37
+ }
38
+
39
+ const AlertDialogOverlay = React.forwardRef<
40
+ HTMLDivElement,
41
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
42
+ >(function AlertDialogOverlay({ className, ...props }, ref) {
43
+ return (
44
+ <AlertDialogPrimitive.Overlay
45
+ ref={ref}
46
+ data-slot="alert-dialog-overlay"
47
+ className={cn(
48
+ 'fixed inset-0 z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',
49
+ className,
50
+ )}
51
+ {...props}
52
+ />
53
+ );
54
+ });
55
+
56
+ const AlertDialogContent = React.forwardRef<
57
+ HTMLDivElement,
58
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content> & {
59
+ size?: 'default' | 'sm';
60
+ }
61
+ >(function AlertDialogContent({ className, size = 'default', ...props }, ref) {
62
+ return (
63
+ <AlertDialogPortal>
64
+ <AlertDialogOverlay />
65
+ <AlertDialogPrimitive.Content
66
+ ref={ref}
67
+ data-slot="alert-dialog-content"
68
+ data-size={size}
69
+ className={cn(
70
+ 'group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-2xl bg-popover p-6 text-popover-foreground shadow-pop duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-md dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
71
+ className,
72
+ )}
73
+ {...props}
74
+ />
75
+ </AlertDialogPortal>
76
+ );
77
+ });
78
+
79
+ const AlertDialogHeader = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>(
80
+ function AlertDialogHeader({ className, ...props }, ref) {
81
+ return (
82
+ <div
83
+ ref={ref}
84
+ data-slot="alert-dialog-header"
85
+ className={cn(
86
+ 'grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]',
87
+ className,
88
+ )}
89
+ {...props}
90
+ />
91
+ );
92
+ },
93
+ );
94
+
95
+ const AlertDialogFooter = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>(
96
+ function AlertDialogFooter({ className, ...props }, ref) {
97
+ return (
98
+ <div
99
+ ref={ref}
100
+ data-slot="alert-dialog-footer"
101
+ className={cn(
102
+ 'flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end',
103
+ className,
104
+ )}
105
+ {...props}
106
+ />
107
+ );
108
+ },
109
+ );
110
+
111
+ const AlertDialogMedia = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>(
112
+ function AlertDialogMedia({ className, ...props }, ref) {
113
+ return (
114
+ <div
115
+ ref={ref}
116
+ data-slot="alert-dialog-media"
117
+ className={cn(
118
+ "mb-2 inline-flex size-16 items-center justify-center rounded-full bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-8",
119
+ className,
120
+ )}
121
+ {...props}
122
+ />
123
+ );
124
+ },
125
+ );
126
+
127
+ const AlertDialogTitle = React.forwardRef<
128
+ HTMLHeadingElement,
129
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
130
+ >(function AlertDialogTitle({ className, ...props }, ref) {
131
+ return (
132
+ <AlertDialogPrimitive.Title
133
+ ref={ref}
134
+ data-slot="alert-dialog-title"
135
+ className={cn(
136
+ 'font-heading text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2',
137
+ className,
138
+ )}
139
+ {...props}
140
+ />
141
+ );
142
+ });
143
+
144
+ const AlertDialogDescription = React.forwardRef<
145
+ HTMLParagraphElement,
146
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
147
+ >(function AlertDialogDescription({ className, ...props }, ref) {
148
+ return (
149
+ <AlertDialogPrimitive.Description
150
+ ref={ref}
151
+ data-slot="alert-dialog-description"
152
+ className={cn(
153
+ 'text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground',
154
+ className,
155
+ )}
156
+ {...props}
157
+ />
158
+ );
159
+ });
160
+
161
+ const AlertDialogAction = React.forwardRef<
162
+ HTMLButtonElement,
163
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action> &
164
+ Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>
165
+ >(function AlertDialogAction({ className, variant = 'default', size = 'default', ...props }, ref) {
166
+ return (
167
+ <Button variant={variant} size={size} asChild>
168
+ <AlertDialogPrimitive.Action
169
+ ref={ref}
170
+ data-slot="alert-dialog-action"
171
+ className={cn(className)}
172
+ {...props}
173
+ />
174
+ </Button>
175
+ );
176
+ });
177
+
178
+ const AlertDialogCancel = React.forwardRef<
179
+ HTMLButtonElement,
180
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel> &
181
+ Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>
182
+ >(function AlertDialogCancel({ className, variant = 'outline', size = 'default', ...props }, ref) {
183
+ return (
184
+ <Button variant={variant} size={size} asChild>
185
+ <AlertDialogPrimitive.Cancel
186
+ ref={ref}
187
+ data-slot="alert-dialog-cancel"
188
+ className={cn(className)}
189
+ {...props}
190
+ />
191
+ </Button>
192
+ );
193
+ });
194
+
195
+ export {
196
+ AlertDialog,
197
+ AlertDialogAction,
198
+ AlertDialogCancel,
199
+ AlertDialogContent,
200
+ AlertDialogDescription,
201
+ AlertDialogFooter,
202
+ AlertDialogHeader,
203
+ AlertDialogMedia,
204
+ AlertDialogOverlay,
205
+ AlertDialogPortal,
206
+ AlertDialogTitle,
207
+ AlertDialogTrigger,
208
+ };