@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,294 @@
1
+ import * as React from 'react';
2
+ import type {
3
+ DivIconOptions,
4
+ LatLngBoundsExpression,
5
+ LatLngExpression,
6
+ Map as LeafletMap,
7
+ MapOptions,
8
+ TileLayerOptions,
9
+ } from 'leaflet';
10
+ import 'leaflet/dist/leaflet.css';
11
+ // Relative, unlike the `@rise-x/ui/...` self-references elsewhere in the
12
+ // package: the exports map appends `.tsx` to `./components/*`, and this
13
+ // stylesheet is internal — nothing outside the package imports it. It must
14
+ // come after leaflet.css; the overrides win on source order.
15
+ import './map.css';
16
+
17
+ import { cn } from '@rise-x/ui/lib/utils';
18
+
19
+ /*
20
+ * A Leaflet map and nothing else — no markers, no popups, no legend. Every
21
+ * Rise-X map draws different things on top (vessels and voyage legs, telecom
22
+ * sites and coverage, procurement lots), so the shared piece is the part they
23
+ * all rebuilt identically: the container, the basemap, and the embedding.
24
+ *
25
+ * Named MapView, not Map: the barrel is flat, so `import { Map }` would shadow
26
+ * the global Map in the importing module.
27
+ *
28
+ * Leaflet itself is loaded with a dynamic import. `@rise-x/ui` is bundled whole
29
+ * by both hosts (the shell and the classic app provide it through the module
30
+ * federation share scope), so a static import would put ~112 kB gzipped of
31
+ * mapping code in every EOP page load. The stylesheet is imported statically:
32
+ * at ~4 kB gzipped it is cheap enough to ride along with the design system's
33
+ * CSS, where it is already in place rather than arriving with the chunk.
34
+ *
35
+ * Everything past "show me a basemap" is done through the Leaflet instance,
36
+ * handed over by `onReady` (or a ref). That is deliberate: layers, markers and
37
+ * fly-to choreography are app decisions, and wrapping them in props would mean
38
+ * re-inventing Leaflet's API one prop at a time.
39
+ */
40
+
41
+ type MapTilePreset = 'light' | 'dark' | 'streets' | 'satellite';
42
+
43
+ type MapTileSpec = TileLayerOptions & { url: string };
44
+
45
+ /* Exported so apps can start from a preset and tweak it, e.g.
46
+ * `tiles={{ ...MAP_TILES.light, maxZoom: 12 }}`. */
47
+ const MAP_TILES: Record<MapTilePreset, MapTileSpec> = {
48
+ light: {
49
+ url: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png',
50
+ attribution: '&copy; OpenStreetMap, &copy; CARTO',
51
+ subdomains: 'abcd',
52
+ maxZoom: 20,
53
+ },
54
+ dark: {
55
+ url: 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png',
56
+ attribution: '&copy; OpenStreetMap, &copy; CARTO',
57
+ subdomains: 'abcd',
58
+ maxZoom: 20,
59
+ },
60
+ streets: {
61
+ url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
62
+ attribution: '&copy; OpenStreetMap',
63
+ maxZoom: 19,
64
+ },
65
+ satellite: {
66
+ url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
67
+ attribution: '&copy; Esri',
68
+ maxZoom: 19,
69
+ },
70
+ };
71
+
72
+ type MapPinTone = 'default' | 'brand' | 'success' | 'warning' | 'error' | 'info';
73
+
74
+ type MapPinOptions = { tone?: MapPinTone; selected?: boolean };
75
+
76
+ /*
77
+ * The design system's marker: `L.marker(pos, { icon: L.divIcon(mapPin()) })`.
78
+ * It returns divIcon OPTIONS rather than an icon so describing a pin needs no
79
+ * Leaflet instance in scope — and MapView installs it as Leaflet's DEFAULT
80
+ * marker icon, so a plain `L.marker(pos)` is already on brand (and no longer
81
+ * reaches for the bundled blue PNG, which bundlers routinely fail to resolve).
82
+ */
83
+ function mapPin({ tone = 'default', selected = false }: MapPinOptions = {}): DivIconOptions {
84
+ return {
85
+ className: selected ? 'rx-map-pin is-selected' : 'rx-map-pin',
86
+ html: `<span class="rx-map-pin-dot" data-tone="${tone}"></span>`,
87
+ iconSize: [18, 18],
88
+ iconAnchor: [9, 9],
89
+ popupAnchor: [0, -11],
90
+ tooltipAnchor: [0, -11],
91
+ };
92
+ }
93
+
94
+ type MapViewProps = React.ComponentProps<'div'> & {
95
+ /* Initial view. Not tracked afterwards — later changes are the app's call to
96
+ * make on the instance (`map.flyTo(...)`), so a re-render can't yank the map
97
+ * out from under someone who is panning. */
98
+ center?: LatLngExpression;
99
+ zoom?: number;
100
+ /* Initial view by extent instead. Wins over center/zoom when set. */
101
+ bounds?: LatLngBoundsExpression;
102
+ boundsPadding?: number;
103
+ /* 'auto' follows the design system's theme — the light basemap normally, the
104
+ * dark one whenever a `.dark` ancestor is present, switching live with it.
105
+ * Otherwise a preset name, a custom tile layer, or null for no basemap at all
106
+ * (apps that bring their own WMS or offline tile source). */
107
+ tiles?: 'auto' | MapTilePreset | MapTileSpec | null;
108
+ /* false locks the map down to a static picture — for cards, list rows and
109
+ * previews where a map that pans and zooms would fight the page. */
110
+ interactive?: boolean;
111
+ /* Raw Leaflet options, merged last. */
112
+ options?: MapOptions;
113
+ /* Handed the map and the Leaflet module it was built from. Passing `L` back
114
+ * matters: it is the host's single copy, so apps add layers without taking
115
+ * their own leaflet dependency and without a second copy of the library
116
+ * meeting the first one at `map.addLayer`. */
117
+ onReady?: (map: LeafletMap, leaflet: typeof import('leaflet')) => void;
118
+ };
119
+
120
+ let defaultPinInstalled = false;
121
+
122
+ const MapView = React.forwardRef<LeafletMap | null, MapViewProps>(function MapView(
123
+ {
124
+ className,
125
+ children,
126
+ center = [20, 0],
127
+ zoom = 2,
128
+ bounds,
129
+ boundsPadding = 32,
130
+ tiles = 'auto',
131
+ interactive = true,
132
+ options,
133
+ onReady,
134
+ ...props
135
+ },
136
+ ref,
137
+ ) {
138
+ const containerRef = React.useRef<HTMLDivElement>(null);
139
+ const leafletRef = React.useRef<typeof import('leaflet') | null>(null);
140
+ const [map, setMap] = React.useState<LeafletMap | null>(null);
141
+
142
+ /* Read by the init effect, which must run exactly once — re-creating the map
143
+ * because a parent re-rendered would drop every layer the app has added. */
144
+ const initRef = React.useRef({
145
+ center,
146
+ zoom,
147
+ bounds,
148
+ boundsPadding,
149
+ interactive,
150
+ options,
151
+ onReady,
152
+ });
153
+ initRef.current = { center, zoom, bounds, boundsPadding, interactive, options, onReady };
154
+
155
+ /* Explicit generics: inference narrows T to LeafletMap and then rejects the
156
+ * null the handle legitimately holds until the chunk lands. */
157
+ React.useImperativeHandle<LeafletMap | null, LeafletMap | null>(ref, () => map, [map]);
158
+
159
+ React.useEffect(() => {
160
+ const container = containerRef.current;
161
+ if (!container) return;
162
+
163
+ let disposed = false;
164
+ let instance: LeafletMap | null = null;
165
+ let observer: ResizeObserver | null = null;
166
+ let frame = 0;
167
+
168
+ void import('leaflet').then(({ default: L }) => {
169
+ // StrictMode's double mount (and any fast unmount) resolves here after
170
+ // cleanup already ran; creating the map now would leak it and leave the
171
+ // container tagged, so the next L.map() throws "already initialized".
172
+ if (disposed) return;
173
+
174
+ // Once per Leaflet copy, on the host's single shared instance: markers
175
+ // made without an explicit icon get the design system's pin instead of
176
+ // Leaflet's blue teardrop. Apps that pass their own `icon` are untouched.
177
+ if (!defaultPinInstalled) {
178
+ L.Marker.prototype.options.icon = L.divIcon(mapPin());
179
+ defaultPinInstalled = true;
180
+ }
181
+
182
+ const init = initRef.current;
183
+ const fit = init.bounds;
184
+ instance = L.map(container, {
185
+ center: init.center,
186
+ zoom: init.zoom,
187
+ ...(init.interactive
188
+ ? {}
189
+ : {
190
+ dragging: false,
191
+ touchZoom: false,
192
+ doubleClickZoom: false,
193
+ scrollWheelZoom: false,
194
+ boxZoom: false,
195
+ keyboard: false,
196
+ zoomControl: false,
197
+ }),
198
+ ...init.options,
199
+ });
200
+ if (fit) instance.fitBounds(fit, { padding: [init.boundsPadding, init.boundsPadding] });
201
+
202
+ // The embedding fix. Leaflet sizes its panes once and then trusts that
203
+ // number, so a map inside anything that resizes — a detail panel sliding
204
+ // open, a resizable split, a window resize — renders at its stale size
205
+ // and leaves grey gutters. Coalesced into a frame so a width transition
206
+ // drives it smoothly rather than 60 relayouts.
207
+ let fitted = !fit;
208
+ observer = new ResizeObserver(() => {
209
+ cancelAnimationFrame(frame);
210
+ frame = requestAnimationFrame(() => {
211
+ if (!instance) return;
212
+ instance.invalidateSize({ animate: false });
213
+ // Mounted hidden (an inactive tab, a collapsed panel) the initial fit
214
+ // ran against a 0x0 viewport. Redo it once the box is real.
215
+ if (!fitted && fit && container.clientWidth > 0 && container.clientHeight > 0) {
216
+ fitted = true;
217
+ instance.fitBounds(fit, { padding: [init.boundsPadding, init.boundsPadding] });
218
+ }
219
+ });
220
+ });
221
+ observer.observe(container);
222
+
223
+ leafletRef.current = L;
224
+ setMap(instance);
225
+ init.onReady?.(instance, L);
226
+ });
227
+
228
+ return () => {
229
+ disposed = true;
230
+ cancelAnimationFrame(frame);
231
+ observer?.disconnect();
232
+ instance?.remove();
233
+ leafletRef.current = null;
234
+ setMap(null);
235
+ };
236
+ }, []);
237
+
238
+ /* Theme-following basemap. The tokens do the work for the map's own chrome
239
+ * (it is all var(--card) / var(--foreground)), but tiles are images on a
240
+ * server — a light basemap under a dark UI is the one part that cannot
241
+ * follow by cascade, so watch the class the shell's ThemeProvider toggles. */
242
+ const [dark, setDark] = React.useState(false);
243
+
244
+ React.useEffect(() => {
245
+ if (tiles !== 'auto') return;
246
+ const read = () => setDark(!!containerRef.current?.closest('.dark'));
247
+ read();
248
+ const observer = new MutationObserver(read);
249
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
250
+ return () => observer.disconnect();
251
+ }, [tiles]);
252
+
253
+ const resolved = tiles === 'auto' ? (dark ? 'dark' : 'light') : tiles;
254
+
255
+ /* Serialised so an inline `tiles={{ url: ... }}` doesn't re-add the layer on
256
+ * every render, and so switching preset (light -> satellite) swaps it. */
257
+ const tileKey = JSON.stringify(
258
+ typeof resolved === 'string' ? MAP_TILES[resolved] : (resolved ?? null),
259
+ );
260
+
261
+ React.useEffect(() => {
262
+ const L = leafletRef.current;
263
+ const spec = JSON.parse(tileKey) as MapTileSpec | null;
264
+ if (!map || !L || !spec) return;
265
+ const { url, ...tileOptions } = spec;
266
+ const layer = L.tileLayer(url, tileOptions).addTo(map);
267
+ return () => {
268
+ layer.remove();
269
+ };
270
+ }, [map, tileKey]);
271
+
272
+ return (
273
+ <div
274
+ data-slot="map"
275
+ /* `isolate`: Leaflet's panes and controls climb to z-index 1000, which is
276
+ * high enough to paint over dialogs, dropdowns and the shell's own
277
+ * chrome. A stacking context keeps that ladder inside the map's box.
278
+ * Fills its parent by default — give the parent a height, or override
279
+ * with a height class. */
280
+ className={cn('relative isolate h-full w-full overflow-hidden', className)}
281
+ {...props}
282
+ >
283
+ {/* Surface and typeface are set in map.css, not here: Leaflet's own
284
+ * .leaflet-container rules are unlayered and outrank any utility. */}
285
+ <div ref={containerRef} data-slot="map-canvas" className="absolute inset-0" />
286
+ {/* Overlays — legends, counters, toolbars. Position them absolutely; the
287
+ * map's panes sit at z-index 400-700 and its controls at 800-1000. */}
288
+ {children}
289
+ </div>
290
+ );
291
+ });
292
+
293
+ export { MapView, MAP_TILES, mapPin };
294
+ export type { MapViewProps, MapTilePreset, MapTileSpec, MapPinOptions, MapPinTone };
@@ -0,0 +1,171 @@
1
+ import * as React from 'react';
2
+
3
+ import { cn } from '@rise-x/ui/lib/utils';
4
+ import { FileCard } from '@rise-x/ui/components/file-upload';
5
+
6
+ /*
7
+ * Chat message. Structure follows shadcn's Message primitive:
8
+ * MessageGroup > Message > [MessageAvatar, MessageHeader/Bubble/Footer]
9
+ *
10
+ * GRID, not flex. The avatar has to bottom-align to the BUBBLE row and stay
11
+ * clear of the footer actions; a flex row with align-items:flex-end sinks it
12
+ * past the footer instead.
13
+ *
14
+ * THE ASYMMETRY IS THE POINT. A user turn is a bubble — short, quotable, and it
15
+ * needs to be visibly *theirs*. An assistant turn is NOT: AI answers run long,
16
+ * and a tinted block the height of the viewport is a wall. So `variant="ai"`
17
+ * strips the bubble entirely — no background, no border, no padding — and caps
18
+ * the measure at 68ch so it reads as prose. Colour on an AI turn marks
19
+ * *activity* (see ai.tsx), never the finished answer.
20
+ */
21
+ function MessageGroup({ className, ...props }: React.ComponentProps<'div'>) {
22
+ return (
23
+ <div data-slot="message-group" className={cn('flex flex-col gap-3.5', className)} {...props} />
24
+ );
25
+ }
26
+
27
+ function Message({
28
+ className,
29
+ align = 'start',
30
+ ...props
31
+ }: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
32
+ return (
33
+ <div
34
+ data-slot="message"
35
+ data-align={align}
36
+ className={cn(
37
+ 'grid grid-cols-[26px_minmax(0,1fr)] gap-x-[9px] gap-y-[5px]',
38
+ align === 'end' && 'grid-cols-[minmax(0,1fr)_26px]',
39
+ className,
40
+ )}
41
+ {...props}
42
+ />
43
+ );
44
+ }
45
+
46
+ /* Row 2, bottom-aligned — sits level with the bubble, not the footer. */
47
+ function MessageAvatar({
48
+ className,
49
+ align = 'start',
50
+ ...props
51
+ }: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
52
+ return (
53
+ <div
54
+ data-slot="message-avatar"
55
+ className={cn(
56
+ 'col-start-1 row-start-2 self-end',
57
+ align === 'end' && 'col-start-2',
58
+ className,
59
+ )}
60
+ {...props}
61
+ />
62
+ );
63
+ }
64
+
65
+ function MessageHeader({
66
+ className,
67
+ align = 'start',
68
+ ...props
69
+ }: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
70
+ return (
71
+ <div
72
+ data-slot="message-header"
73
+ className={cn(
74
+ 'col-start-2 row-start-1 flex items-center gap-[7px] text-micro text-subtle [&>b]:font-medium [&>b]:text-muted-foreground',
75
+ align === 'end' && 'col-start-1 justify-self-start',
76
+ className,
77
+ )}
78
+ {...props}
79
+ />
80
+ );
81
+ }
82
+
83
+ function MessageBody({
84
+ className,
85
+ align = 'start',
86
+ ...props
87
+ }: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
88
+ return (
89
+ <div
90
+ data-slot="message-body"
91
+ className={cn(
92
+ 'col-start-2 row-start-2 flex min-w-0 flex-col items-start gap-1.5',
93
+ align === 'end' && 'col-start-1 items-end',
94
+ className,
95
+ )}
96
+ {...props}
97
+ />
98
+ );
99
+ }
100
+
101
+ function MessageBubble({
102
+ className,
103
+ variant = 'default',
104
+ ...props
105
+ }: React.ComponentProps<'div'> & { variant?: 'default' | 'user' | 'ai' }) {
106
+ return (
107
+ <div
108
+ data-slot="message-bubble"
109
+ data-variant={variant}
110
+ className={cn(
111
+ 'w-fit max-w-full text-ui leading-[1.55]',
112
+ variant === 'default' && 'rounded-xl bg-fill-1 px-3 py-[9px]',
113
+ variant === 'user' && 'rounded-xl bg-primary px-3 py-[9px] text-primary-foreground',
114
+ // no bubble at all — see the note at the top of this file
115
+ variant === 'ai' && 'max-w-[68ch] border-0 bg-transparent px-0 pt-px pb-0',
116
+ className,
117
+ )}
118
+ {...props}
119
+ />
120
+ );
121
+ }
122
+
123
+ function MessageFooter({
124
+ className,
125
+ align = 'start',
126
+ ...props
127
+ }: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
128
+ return (
129
+ <div
130
+ data-slot="message-footer"
131
+ className={cn(
132
+ 'col-start-2 row-start-3 flex items-center gap-0.5 text-micro text-subtle',
133
+ align === 'end' && 'col-start-1 justify-self-end',
134
+ className,
135
+ )}
136
+ {...props}
137
+ />
138
+ );
139
+ }
140
+
141
+ function MessageAttachments({ className, ...props }: React.ComponentProps<'div'>) {
142
+ return (
143
+ <div
144
+ data-slot="message-attachments"
145
+ className={cn('flex flex-wrap gap-1.5', className)}
146
+ {...props}
147
+ />
148
+ );
149
+ }
150
+
151
+ /* An attachment IS a FileCard — same glyph/name/meta/action anatomy, and the
152
+ * reasoning for it lives in file-upload.tsx. Only the minimum width differs: in
153
+ * a chat the cards sit in a wrapping row and need a floor, in an upload list
154
+ * they fill the column. */
155
+ function MessageAttachment({ className, ...props }: React.ComponentProps<typeof FileCard>) {
156
+ return (
157
+ <FileCard data-slot="message-attachment" className={cn('min-w-52', className)} {...props} />
158
+ );
159
+ }
160
+
161
+ export {
162
+ MessageGroup,
163
+ Message,
164
+ MessageAvatar,
165
+ MessageHeader,
166
+ MessageBody,
167
+ MessageBubble,
168
+ MessageFooter,
169
+ MessageAttachments,
170
+ MessageAttachment,
171
+ };
@@ -0,0 +1,113 @@
1
+ import * as React from 'react';
2
+
3
+ import { cn } from '@rise-x/ui/lib/utils';
4
+
5
+ /*
6
+ * Sidebar navigation. A borderless list, not a panel: the active item is a fill
7
+ * plus a brand-tinted icon, with NO left rail. A rail is a one-sided border, and
8
+ * a one-sided border reads as something stuck to the row rather than part of it —
9
+ * the same reason status cards use a glyph instead of an edge stripe.
10
+ *
11
+ * Brand appears on the active icon only. In single-select navigation there is
12
+ * exactly one at a time, so it cannot swamp the view the way brand-as-selection
13
+ * does in a multi-select table.
14
+ */
15
+ function Nav({ className, ...props }: React.ComponentProps<'nav'>) {
16
+ return <nav data-slot="nav" className={cn('flex flex-col gap-px', className)} {...props} />;
17
+ }
18
+
19
+ function NavItem({
20
+ className,
21
+ current,
22
+ ...props
23
+ }: React.ComponentProps<'button'> & { current?: boolean }) {
24
+ return (
25
+ <button
26
+ type="button"
27
+ data-slot="nav-item"
28
+ aria-current={current ? 'page' : undefined}
29
+ className={cn(
30
+ 'flex h-[30px] w-full cursor-pointer items-center gap-2 rounded-md border-0 bg-transparent px-2 text-left text-ui text-muted-foreground transition-colors duration-150 ease-decelerate',
31
+ 'hover:bg-muted hover:text-foreground',
32
+ 'aria-[current=page]:bg-muted aria-[current=page]:font-medium aria-[current=page]:text-foreground',
33
+ '[&>svg]:size-[15px] [&>svg]:shrink-0 [&>svg]:opacity-85',
34
+ 'aria-[current=page]:[&>svg]:text-brand-text aria-[current=page]:[&>svg]:opacity-100',
35
+ '[&>[data-slot=badge]]:ml-auto',
36
+ className,
37
+ )}
38
+ {...props}
39
+ />
40
+ );
41
+ }
42
+
43
+ function NavSection({ className, ...props }: React.ComponentProps<'div'>) {
44
+ return (
45
+ <div
46
+ data-slot="nav-section"
47
+ className={cn(
48
+ 'px-2 pt-3.5 pb-1 text-micro tracking-[0.04em] text-subtle uppercase',
49
+ className,
50
+ )}
51
+ {...props}
52
+ />
53
+ );
54
+ }
55
+
56
+ /*
57
+ * SIDEBAR PANEL — the detail pane beside a list. Floats with a margin rather
58
+ * than butting against the window edge, so the page background shows through on
59
+ * all four sides and the panel reads as a separate object.
60
+ */
61
+ function Panel({ className, ...props }: React.ComponentProps<'aside'>) {
62
+ return (
63
+ <aside
64
+ data-slot="panel"
65
+ className={cn(
66
+ 'flex w-[262px] shrink-0 flex-col overflow-hidden rounded-2xl bg-card shadow-card',
67
+ className,
68
+ )}
69
+ {...props}
70
+ />
71
+ );
72
+ }
73
+
74
+ function PanelHeader({ className, ...props }: React.ComponentProps<'div'>) {
75
+ return (
76
+ <div
77
+ data-slot="panel-header"
78
+ className={cn(
79
+ 'flex items-center gap-2 border-b border-border-subtle px-3.5 py-3 [&>[data-slot=button]:last-child]:ml-auto',
80
+ className,
81
+ )}
82
+ {...props}
83
+ />
84
+ );
85
+ }
86
+
87
+ function PanelTitle({ className, ...props }: React.ComponentProps<'div'>) {
88
+ return (
89
+ <div data-slot="panel-title" className={cn('text-ui font-medium', className)} {...props} />
90
+ );
91
+ }
92
+
93
+ function PanelBody({ className, ...props }: React.ComponentProps<'div'>) {
94
+ return (
95
+ <div
96
+ data-slot="panel-body"
97
+ className={cn('flex-1 overflow-y-auto p-3.5', className)}
98
+ {...props}
99
+ />
100
+ );
101
+ }
102
+
103
+ function PanelFooter({ className, ...props }: React.ComponentProps<'div'>) {
104
+ return (
105
+ <div
106
+ data-slot="panel-footer"
107
+ className={cn('flex gap-2 border-t border-border-subtle p-3.5', className)}
108
+ {...props}
109
+ />
110
+ );
111
+ }
112
+
113
+ export { Nav, NavItem, NavSection, Panel, PanelHeader, PanelTitle, PanelBody, PanelFooter };