@genesislcap/ai-assistant 15.71.0-FUI-2650.1 → 15.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-assistant.api.json +0 -97
- package/dist/ai-assistant.d.ts +0 -65
- package/dist/chat-driver.cjs +0 -18031
- package/dist/chat-driver.cjs.map +4 -4
- package/dist/chat-driver.mjs +0 -18024
- package/dist/chat-driver.mjs.map +4 -4
- package/dist/custom-elements.json +6856 -9696
- package/dist/dts/chat-driver-node.d.ts +0 -2
- package/dist/dts/chat-driver-node.d.ts.map +1 -1
- package/dist/dts/index.d.ts +0 -1
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/react.d.ts +0 -10
- package/dist/esm/chat-driver-node.js +0 -6
- package/dist/esm/index.js +0 -3
- package/dist/react.cjs +0 -7
- package/dist/react.mjs +0 -6
- package/package.json +17 -24
- package/scripts/smoke-chat-driver-node.mjs +0 -15
- package/dist/dts/code-review/code-review.types.d.ts +0 -76
- package/dist/dts/code-review/code-review.types.d.ts.map +0 -1
- package/dist/dts/code-review/code-reviewer.agent.d.ts +0 -77
- package/dist/dts/code-review/code-reviewer.agent.d.ts.map +0 -1
- package/dist/dts/code-review/code-reviewer.prompt.d.ts +0 -23
- package/dist/dts/code-review/code-reviewer.prompt.d.ts.map +0 -1
- package/dist/dts/code-review/gate.d.ts +0 -44
- package/dist/dts/code-review/gate.d.ts.map +0 -1
- package/dist/dts/code-review/index.d.ts +0 -27
- package/dist/dts/code-review/index.d.ts.map +0 -1
- package/dist/dts/code-review/review-changes.d.ts +0 -70
- package/dist/dts/code-review/review-changes.d.ts.map +0 -1
- package/dist/dts/code-review/rules/context-trigger-map.d.ts +0 -6
- package/dist/dts/code-review/rules/context-trigger-map.d.ts.map +0 -1
- package/dist/dts/code-review/rules/context.registry.d.ts +0 -123
- package/dist/dts/code-review/rules/context.registry.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-ai-extensions.d.ts +0 -13
- package/dist/dts/code-review/rules/fui-ai-extensions.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-blotter.d.ts +0 -16
- package/dist/dts/code-review/rules/fui-blotter.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-chart.d.ts +0 -20
- package/dist/dts/code-review/rules/fui-chart.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-column-defs.d.ts +0 -21
- package/dist/dts/code-review/rules/fui-column-defs.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-components.d.ts +0 -9
- package/dist/dts/code-review/rules/fui-components.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-criteria.d.ts +0 -32
- package/dist/dts/code-review/rules/fui-criteria.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-custom-renderer.d.ts +0 -15
- package/dist/dts/code-review/rules/fui-custom-renderer.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-dashboard.d.ts +0 -19
- package/dist/dts/code-review/rules/fui-dashboard.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-dialogs.d.ts +0 -19
- package/dist/dts/code-review/rules/fui-dialogs.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-entity-management.d.ts +0 -19
- package/dist/dts/code-review/rules/fui-entity-management.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-error-boundary.d.ts +0 -9
- package/dist/dts/code-review/rules/fui-error-boundary.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-eventing.d.ts +0 -8
- package/dist/dts/code-review/rules/fui-eventing.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-flexlayout.d.ts +0 -17
- package/dist/dts/code-review/rules/fui-flexlayout.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-flyout-panel.d.ts +0 -10
- package/dist/dts/code-review/rules/fui-flyout-panel.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-form-component.d.ts +0 -9
- package/dist/dts/code-review/rules/fui-form-component.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-formatters.d.ts +0 -12
- package/dist/dts/code-review/rules/fui-formatters.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-foundation-comms.d.ts +0 -10
- package/dist/dts/code-review/rules/fui-foundation-comms.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-global-filters.d.ts +0 -33
- package/dist/dts/code-review/rules/fui-global-filters.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-import-surface.d.ts +0 -37
- package/dist/dts/code-review/rules/fui-import-surface.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-inline-editing.d.ts +0 -10
- package/dist/dts/code-review/rules/fui-inline-editing.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-layout.d.ts +0 -7
- package/dist/dts/code-review/rules/fui-layout.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-notifications.d.ts +0 -12
- package/dist/dts/code-review/rules/fui-notifications.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-primitives.d.ts +0 -26
- package/dist/dts/code-review/rules/fui-primitives.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts +0 -18
- package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-redux-store.d.ts +0 -8
- package/dist/dts/code-review/rules/fui-redux-store.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-reporting.d.ts +0 -19
- package/dist/dts/code-review/rules/fui-reporting.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-styling.d.ts +0 -15
- package/dist/dts/code-review/rules/fui-styling.d.ts.map +0 -1
- package/dist/dts/code-review/rules/fui-trade-form.d.ts +0 -13
- package/dist/dts/code-review/rules/fui-trade-form.d.ts.map +0 -1
- package/dist/dts/code-review/submit-code-review.tool.d.ts +0 -12
- package/dist/dts/code-review/submit-code-review.tool.d.ts.map +0 -1
- package/dist/dts/code-review/unified-diff.d.ts +0 -7
- package/dist/dts/code-review/unified-diff.d.ts.map +0 -1
- package/dist/dts/code-review/verdict.d.ts +0 -23
- package/dist/dts/code-review/verdict.d.ts.map +0 -1
- package/dist/dts/components/code-review-result/code-review-result.d.ts +0 -26
- package/dist/dts/components/code-review-result/code-review-result.d.ts.map +0 -1
- package/dist/esm/code-review/code-review.types.js +0 -6
- package/dist/esm/code-review/code-reviewer.agent.js +0 -167
- package/dist/esm/code-review/code-reviewer.prompt.js +0 -103
- package/dist/esm/code-review/gate.js +0 -93
- package/dist/esm/code-review/index.js +0 -28
- package/dist/esm/code-review/review-changes.js +0 -123
- package/dist/esm/code-review/rules/context-trigger-map.js +0 -20
- package/dist/esm/code-review/rules/context.registry.js +0 -772
- package/dist/esm/code-review/rules/fui-ai-extensions.js +0 -306
- package/dist/esm/code-review/rules/fui-blotter.js +0 -596
- package/dist/esm/code-review/rules/fui-chart.js +0 -669
- package/dist/esm/code-review/rules/fui-column-defs.js +0 -862
- package/dist/esm/code-review/rules/fui-components.js +0 -245
- package/dist/esm/code-review/rules/fui-criteria.js +0 -538
- package/dist/esm/code-review/rules/fui-custom-renderer.js +0 -612
- package/dist/esm/code-review/rules/fui-dashboard.js +0 -604
- package/dist/esm/code-review/rules/fui-dialogs.js +0 -588
- package/dist/esm/code-review/rules/fui-entity-management.js +0 -1014
- package/dist/esm/code-review/rules/fui-error-boundary.js +0 -244
- package/dist/esm/code-review/rules/fui-eventing.js +0 -628
- package/dist/esm/code-review/rules/fui-flexlayout.js +0 -860
- package/dist/esm/code-review/rules/fui-flyout-panel.js +0 -432
- package/dist/esm/code-review/rules/fui-form-component.js +0 -898
- package/dist/esm/code-review/rules/fui-formatters.js +0 -415
- package/dist/esm/code-review/rules/fui-foundation-comms.js +0 -518
- package/dist/esm/code-review/rules/fui-global-filters.js +0 -778
- package/dist/esm/code-review/rules/fui-import-surface.js +0 -452
- package/dist/esm/code-review/rules/fui-inline-editing.js +0 -445
- package/dist/esm/code-review/rules/fui-layout.js +0 -431
- package/dist/esm/code-review/rules/fui-notifications.js +0 -439
- package/dist/esm/code-review/rules/fui-primitives.js +0 -1216
- package/dist/esm/code-review/rules/fui-rapid-grid-pro.js +0 -650
- package/dist/esm/code-review/rules/fui-redux-store.js +0 -522
- package/dist/esm/code-review/rules/fui-reporting.js +0 -506
- package/dist/esm/code-review/rules/fui-styling.js +0 -1229
- package/dist/esm/code-review/rules/fui-trade-form.js +0 -618
- package/dist/esm/code-review/submit-code-review.tool.js +0 -43
- package/dist/esm/code-review/unified-diff.js +0 -96
- package/dist/esm/code-review/verdict.js +0 -24
- package/dist/esm/components/code-review-result/code-review-result.js +0 -89
- package/docs/code-review.md +0 -137
|
@@ -1,604 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context: multi-tile dashboard composition — KPI cards, charts, grids, shared filters.
|
|
3
|
-
*
|
|
4
|
-
* Sources verified against:
|
|
5
|
-
* - showcase react-client/src/pages/FlexLayout/FlexLayout.tsx (primary real usage)
|
|
6
|
-
* - fui-chart.ts (G2PlotChart API — see that module for full chart reference)
|
|
7
|
-
* - fui-flexlayout.ts (Layout / Model / factory pattern)
|
|
8
|
-
* - sales-trader-hub/client/src/layouts/ and /pages/
|
|
9
|
-
*
|
|
10
|
-
* DANGEROUS PATTERNS ported from the old module and corrected:
|
|
11
|
-
* - Wrong G2PlotChart import package
|
|
12
|
-
* - Wrong ChartConfiguration type name
|
|
13
|
-
* - KPI cards placed inside componentMap
|
|
14
|
-
* - Missing style={{ height: '100%' }} on tiles inside Layout
|
|
15
|
-
*/
|
|
16
|
-
export const FUI_DASHBOARD_TAGS = [
|
|
17
|
-
// Non-developer intent phrases
|
|
18
|
-
'dashboard',
|
|
19
|
-
'overview',
|
|
20
|
-
'overview page',
|
|
21
|
-
'summary page',
|
|
22
|
-
'summary view',
|
|
23
|
-
'kpi',
|
|
24
|
-
'kpi card',
|
|
25
|
-
'kpi strip',
|
|
26
|
-
'metric card',
|
|
27
|
-
'stats card',
|
|
28
|
-
'stat tile',
|
|
29
|
-
'stats',
|
|
30
|
-
'statistics',
|
|
31
|
-
'metrics',
|
|
32
|
-
'home page',
|
|
33
|
-
'landing page',
|
|
34
|
-
'chart dashboard',
|
|
35
|
-
'chart panel',
|
|
36
|
-
'chart tile',
|
|
37
|
-
'multi-tile',
|
|
38
|
-
'multi tile',
|
|
39
|
-
'tile layout',
|
|
40
|
-
'mixed layout',
|
|
41
|
-
'mixed tile',
|
|
42
|
-
'mixed panel',
|
|
43
|
-
'portfolio overview',
|
|
44
|
-
'risk overview',
|
|
45
|
-
'risk dashboard',
|
|
46
|
-
'pnl dashboard',
|
|
47
|
-
'shared filter',
|
|
48
|
-
'cross tile filter',
|
|
49
|
-
'cross-tile filter',
|
|
50
|
-
'global filter',
|
|
51
|
-
'filter dashboard',
|
|
52
|
-
// Technical
|
|
53
|
-
'dashboard page',
|
|
54
|
-
'DashboardPage',
|
|
55
|
-
'KpiCard',
|
|
56
|
-
'flexlayout dashboard',
|
|
57
|
-
'layout model',
|
|
58
|
-
'componentMap',
|
|
59
|
-
];
|
|
60
|
-
export const FUI_DASHBOARD_DEPS = [
|
|
61
|
-
// fui-styling FIRST: resolveContextDependencies fills this list in order and stops at
|
|
62
|
-
// MAX_DEPENDENCY_CONTEXT_CHARS, so whichever entry is last is the one a future content
|
|
63
|
-
// growth in ANY of the three silently drops into `omitted` (GENC-1560 — measured: adding
|
|
64
|
-
// ~8.7k chars to fui-styling for the GENC-1560 rules pushed it over budget when it was
|
|
65
|
-
// listed last, deleting the exact fui-dashboard -> fui-styling edge this change exists to
|
|
66
|
-
// create). fui-styling is the one dependency here that must never be silently dropped —
|
|
67
|
-
// it carries the LAYERING rules for the filter-row/KPI-strip-over-FlexLayout shape that
|
|
68
|
-
// triggers the z-index stacking-context bug, and the card-chrome token rules dashboards
|
|
69
|
-
// need for every KPI card. fui-chart and fui-flexlayout are large reference material that
|
|
70
|
-
// degrades gracefully if the model has to read_context them itself instead.
|
|
71
|
-
'fui-styling',
|
|
72
|
-
'fui-chart',
|
|
73
|
-
'fui-flexlayout',
|
|
74
|
-
];
|
|
75
|
-
export const FUI_DASHBOARD_CONTEXT = `
|
|
76
|
-
## DASHBOARD / OVERVIEW PAGES — PATTERNS
|
|
77
|
-
|
|
78
|
-
A dashboard page displays a mix of resizable tiles: KPI cards, charts, grids, and optional
|
|
79
|
-
shared filters. Common use cases: portfolio overview, risk dashboard, P&L summary, position overview.
|
|
80
|
-
|
|
81
|
-
> This module covers composition patterns. For the full chart API see \`fui-chart\`.
|
|
82
|
-
> For the FlexLayout/Model/factory wiring see \`fui-flexlayout\`.
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
### Typical dashboard architecture
|
|
87
|
-
|
|
88
|
-
\`\`\`
|
|
89
|
-
┌──────────────────────────────────────────────────────────┐
|
|
90
|
-
│ KPI Cards strip (OUTSIDE FlexLayout — fixed height) │
|
|
91
|
-
├──────────────────┬───────────────────┬───────────────────┤
|
|
92
|
-
│ Chart tile A │ Chart tile B │ Summary grid │
|
|
93
|
-
│ (G2PlotChart) │ (G2PlotChart) │ (RapidGridPro) │
|
|
94
|
-
└──────────────────┴───────────────────┴───────────────────┘
|
|
95
|
-
\`\`\`
|
|
96
|
-
|
|
97
|
-
**Rule:** KPI cards go OUTSIDE the FlexLayout \`componentMap\`. They are a fixed header strip, not
|
|
98
|
-
user-resizable panels. Place them in the route JSX above the layout container div.
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
### Imports
|
|
103
|
-
|
|
104
|
-
\`\`\`tsx
|
|
105
|
-
// Chart components — verified import path
|
|
106
|
-
import { G2PlotChart, ChartDatasource } from '@genesislcap/g2plot-chart/react';
|
|
107
|
-
import type { ChartConfig } from '@genesislcap/g2plot-chart';
|
|
108
|
-
|
|
109
|
-
// FlexLayout — verified from showcase FlexLayout.tsx
|
|
110
|
-
import { Layout, Model, TabNode } from 'flexlayout-react';
|
|
111
|
-
import 'flexlayout-react/style/dark.css';
|
|
112
|
-
|
|
113
|
-
// Grid (optional tile)
|
|
114
|
-
import { RapidGridPro } from '@genesislcap/rapid-grid-pro/react';
|
|
115
|
-
// GridProGenesisDatasource + GridProColumn live in @genesislcap/grid-pro/react, NOT rapid-grid-pro/react
|
|
116
|
-
import { GridProGenesisDatasource, GridProColumn } from '@genesislcap/grid-pro/react';
|
|
117
|
-
import type { GridProColumnRef } from '@genesislcap/grid-pro/react';
|
|
118
|
-
|
|
119
|
-
import React, { useRef, useState, useEffect } from 'react';
|
|
120
|
-
\`\`\`
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
### KPI card component pattern
|
|
125
|
-
|
|
126
|
-
There is no KPI-SPECIFIC card component — but \`Card\` exists and IS the surface to build one on.
|
|
127
|
-
Compose the KPI out of \`Card\`; do NOT hand-roll the surface as a bordered \`<div>\`. \`Card\` brings
|
|
128
|
-
the theme's background, corner radius and elevation, so the tile matches every other surface in
|
|
129
|
-
the app for free.
|
|
130
|
-
|
|
131
|
-
\`\`\`tsx
|
|
132
|
-
import { Card } from '@genesislcap/rapid-design-system/react';
|
|
133
|
-
|
|
134
|
-
interface KpiCardProps {
|
|
135
|
-
label: string;
|
|
136
|
-
value: string | number;
|
|
137
|
-
delta?: string; // e.g. "+2.4%"
|
|
138
|
-
positive?: boolean; // true = green delta, false = red
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const KpiCard: React.FC<KpiCardProps> = ({ label, value, delta, positive }) => (
|
|
142
|
-
<Card className="kpi-card">
|
|
143
|
-
<span className="kpi-card__label">{label}</span>
|
|
144
|
-
<span className="kpi-card__value">{value}</span>
|
|
145
|
-
{delta && (
|
|
146
|
-
<span className={\`kpi-card__delta kpi-card__delta--\${positive ? 'up' : 'down'}\`}>
|
|
147
|
-
{delta}
|
|
148
|
-
</span>
|
|
149
|
-
)}
|
|
150
|
-
</Card>
|
|
151
|
-
);
|
|
152
|
-
\`\`\`
|
|
153
|
-
|
|
154
|
-
\`\`\`css
|
|
155
|
-
/* Dashboard.css — token names verified in fui-styling (note the hyphen in minus-1/plus-2) */
|
|
156
|
-
/* Card already supplies background, border, corner radius and elevation — style LAYOUT only.
|
|
157
|
-
No 'background', no 'border', no 'border-radius': re-declaring any of them from this outer-tree
|
|
158
|
-
class beats Card's own :host rule and the tile stops matching every other surface in the app.
|
|
159
|
-
In particular do NOT "restore" the radius with calc(var(--control-corner-radius) * 1px) — that
|
|
160
|
-
is the CONTROL radius and it is 0 in the default theme, so it squares the card off. */
|
|
161
|
-
.kpi-card {
|
|
162
|
-
display: flex;
|
|
163
|
-
flex-direction: column;
|
|
164
|
-
gap: calc(var(--design-unit) * 1px);
|
|
165
|
-
padding: calc(var(--design-unit) * 3px) calc(var(--design-unit) * 4px);
|
|
166
|
-
min-width: 140px;
|
|
167
|
-
}
|
|
168
|
-
.kpi-card__label {
|
|
169
|
-
font-size: var(--type-ramp-minus-1-font-size);
|
|
170
|
-
color: var(--neutral-foreground-hint);
|
|
171
|
-
}
|
|
172
|
-
.kpi-card__value {
|
|
173
|
-
font-size: var(--type-ramp-plus-2-font-size);
|
|
174
|
-
font-weight: 600;
|
|
175
|
-
}
|
|
176
|
-
.kpi-card__delta--up { color: var(--success-color); } /* green — matches buy/positive P&L */
|
|
177
|
-
.kpi-card__delta--down { color: var(--error-color); } /* red — matches sell/negative P&L */
|
|
178
|
-
\`\`\`
|
|
179
|
-
|
|
180
|
-
Load \`fui-styling\` context before writing any CSS — design token names must be exact.
|
|
181
|
-
When the card is a page's FOCAL figure rather than one of many, upgrade \`.kpi-card__value\` to the
|
|
182
|
-
sanctioned display-figure recipe in \`fui-styling\` (Typography tokens) — plus-2 stays right for a strip.
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
### FlexLayout model for a 3-tile dashboard
|
|
187
|
-
|
|
188
|
-
\`\`\`ts
|
|
189
|
-
const STORAGE_KEY = 'dashboard-layout-v1';
|
|
190
|
-
|
|
191
|
-
const defaultLayout = {
|
|
192
|
-
global: { tabEnableRenderOnDemand: false, tabEnableClose: false },
|
|
193
|
-
layout: {
|
|
194
|
-
type: 'row',
|
|
195
|
-
children: [
|
|
196
|
-
{
|
|
197
|
-
type: 'tabset',
|
|
198
|
-
weight: 40,
|
|
199
|
-
children: [{ type: 'tab', name: 'P&L Chart', component: 'pnlChart' }],
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
type: 'tabset',
|
|
203
|
-
weight: 30,
|
|
204
|
-
children: [{ type: 'tab', name: 'Risk Chart', component: 'riskChart' }],
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
type: 'tabset',
|
|
208
|
-
weight: 30,
|
|
209
|
-
children: [{ type: 'tab', name: 'Top Positions', component: 'topPositions' }],
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
},
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
function loadModel(): Model {
|
|
216
|
-
const saved = localStorage.getItem(STORAGE_KEY);
|
|
217
|
-
if (saved) {
|
|
218
|
-
try { return Model.fromJson(JSON.parse(saved)); } catch {}
|
|
219
|
-
}
|
|
220
|
-
return Model.fromJson(defaultLayout);
|
|
221
|
-
}
|
|
222
|
-
\`\`\`
|
|
223
|
-
|
|
224
|
-
**Set \`tabEnableRenderOnDemand: false\`** at the global level so ALL tiles mount (and subscribe)
|
|
225
|
-
up front. The default (\`true\`) defers a hidden tab's FIRST render until it is selected — the user
|
|
226
|
-
sees a loading grid/chart on first click. (Once rendered, tabs stay mounted either way.)
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
### Chart tile components
|
|
231
|
-
|
|
232
|
-
\`\`\`tsx
|
|
233
|
-
// Verified API — from @genesislcap/g2plot-chart/react and showcase FlexLayout.tsx
|
|
234
|
-
const pnlConfig: ChartConfig = { xField: 'groupBy', yField: 'value' };
|
|
235
|
-
const riskConfig: ChartConfig = {
|
|
236
|
-
angleField: 'value',
|
|
237
|
-
colorField: 'groupBy',
|
|
238
|
-
radius: 0.75,
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
// Live server chart tile — must set style={{ height: '100%' }} for FlexLayout tiles
|
|
242
|
-
const PnlChartTile: React.FC = () => (
|
|
243
|
-
<G2PlotChart type="line" config={pnlConfig} style={{ height: '100%' }}>
|
|
244
|
-
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE NOTIONAL" />
|
|
245
|
-
</G2PlotChart>
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
const RiskChartTile: React.FC = () => (
|
|
249
|
-
<G2PlotChart type="pie" config={riskConfig} style={{ height: '100%' }}>
|
|
250
|
-
<ChartDatasource resourceName="ALL_POSITIONS" serverFields="INSTRUMENT_NAME VALUE" />
|
|
251
|
-
</G2PlotChart>
|
|
252
|
-
);
|
|
253
|
-
\`\`\`
|
|
254
|
-
|
|
255
|
-
---
|
|
256
|
-
|
|
257
|
-
### Read-only grid tile (summary, not blotter)
|
|
258
|
-
|
|
259
|
-
Dashboard grids are almost always read-only snapshots with no action columns. Column defs are
|
|
260
|
-
supplied as \`GridProColumn\` children (there is NO \`columnDefs\` prop on RapidGridPro — see
|
|
261
|
-
\`fui-rapid-grid-pro\` for the full pattern):
|
|
262
|
-
|
|
263
|
-
\`\`\`tsx
|
|
264
|
-
import { RapidGridPro } from '@genesislcap/rapid-grid-pro/react';
|
|
265
|
-
// GridProGenesisDatasource + GridProColumn are in @genesislcap/grid-pro/react, NOT rapid-grid-pro/react
|
|
266
|
-
import { GridProGenesisDatasource, GridProColumn } from '@genesislcap/grid-pro/react';
|
|
267
|
-
import type { GridProColumnRef } from '@genesislcap/grid-pro/react';
|
|
268
|
-
import type { ColDef } from '@ag-grid-community/core';
|
|
269
|
-
|
|
270
|
-
const positionColumns: ColDef[] = [
|
|
271
|
-
{ field: 'INSTRUMENT_NAME', headerName: 'Instrument', width: 180 },
|
|
272
|
-
{ field: 'QUANTITY', headerName: 'Qty', width: 120, type: 'numericColumn' },
|
|
273
|
-
{ field: 'NOTIONAL', headerName: 'Notional', width: 140, type: 'numericColumn' },
|
|
274
|
-
];
|
|
275
|
-
|
|
276
|
-
const TopPositionsTile: React.FC = () => (
|
|
277
|
-
<RapidGridPro onlyTemplateColDefs style={{ height: '100%' }}>
|
|
278
|
-
<GridProGenesisDatasource resourceName="ALL_POSITIONS" isSnapshot />
|
|
279
|
-
{positionColumns.map((col) => (
|
|
280
|
-
<GridProColumn
|
|
281
|
-
key={col.field}
|
|
282
|
-
ref={(el: GridProColumnRef | null) => {
|
|
283
|
-
if (el) el.definition = col;
|
|
284
|
-
}}
|
|
285
|
-
/>
|
|
286
|
-
))}
|
|
287
|
-
</RapidGridPro>
|
|
288
|
-
);
|
|
289
|
-
\`\`\`
|
|
290
|
-
|
|
291
|
-
---
|
|
292
|
-
|
|
293
|
-
### componentMap and factory (wiring tiles into FlexLayout)
|
|
294
|
-
|
|
295
|
-
\`\`\`tsx
|
|
296
|
-
// Map component string names (from layout JSON) to React components
|
|
297
|
-
const componentMap: Record<string, React.FC> = {
|
|
298
|
-
pnlChart: PnlChartTile,
|
|
299
|
-
riskChart: RiskChartTile,
|
|
300
|
-
topPositions: TopPositionsTile,
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
// factory is called by FlexLayout for each tab node
|
|
304
|
-
const factory = (node: TabNode) => {
|
|
305
|
-
const Component = componentMap[node.getComponent() ?? ''];
|
|
306
|
-
return Component ? <Component /> : null;
|
|
307
|
-
};
|
|
308
|
-
\`\`\`
|
|
309
|
-
|
|
310
|
-
---
|
|
311
|
-
|
|
312
|
-
### Full dashboard page (KPI strip + FlexLayout)
|
|
313
|
-
|
|
314
|
-
\`\`\`tsx
|
|
315
|
-
// Dashboard.css — required flex shell
|
|
316
|
-
/*
|
|
317
|
-
.dashboard-page {
|
|
318
|
-
display: flex;
|
|
319
|
-
flex-direction: column;
|
|
320
|
-
height: 100%; // or calc(100vh - <nav-height>)
|
|
321
|
-
}
|
|
322
|
-
.dashboard-filters { // any row holding Select / DatePicker / Multiselect
|
|
323
|
-
position: relative; // ONLY element in the shell with a z-index (see LAYERING below)
|
|
324
|
-
z-index: 200;
|
|
325
|
-
display: flex;
|
|
326
|
-
align-items: flex-end;
|
|
327
|
-
gap: calc(var(--design-unit) * 4px);
|
|
328
|
-
padding: calc(var(--design-unit) * 3px) calc(var(--design-unit) * 4px);
|
|
329
|
-
flex-shrink: 0;
|
|
330
|
-
}
|
|
331
|
-
.dashboard-kpi-strip { // NO position, NO z-index, NO sticky
|
|
332
|
-
display: flex;
|
|
333
|
-
gap: calc(var(--design-unit) * 4px);
|
|
334
|
-
padding: calc(var(--design-unit) * 3px) calc(var(--design-unit) * 4px);
|
|
335
|
-
flex-shrink: 0;
|
|
336
|
-
}
|
|
337
|
-
.dashboard-layout-container {
|
|
338
|
-
flex: 1;
|
|
339
|
-
position: relative; // required for FlexLayout internals; NO z-index
|
|
340
|
-
min-height: 0; // critical — allows flex child to shrink
|
|
341
|
-
}
|
|
342
|
-
*/
|
|
343
|
-
|
|
344
|
-
export default function DashboardPage() {
|
|
345
|
-
const modelRef = useRef<Model>(loadModel());
|
|
346
|
-
const kpis = useDashboardKpis(); // see "Data loading for KPI cards" below
|
|
347
|
-
|
|
348
|
-
const onModelChange = (model: Model) => {
|
|
349
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(model.toJson()));
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
return (
|
|
353
|
-
<section className="dashboard-page">
|
|
354
|
-
{/* Filter row (if the dashboard has one) — carries the shell's only z-index so its
|
|
355
|
-
Select/DatePicker popups paint over the KPI strip and the tiles below */}
|
|
356
|
-
<div className="dashboard-filters">
|
|
357
|
-
<DashboardFilters />
|
|
358
|
-
</div>
|
|
359
|
-
|
|
360
|
-
{/* KPI strip — rendered OUTSIDE the FlexLayout, not in componentMap */}
|
|
361
|
-
<div className="dashboard-kpi-strip">
|
|
362
|
-
<KpiCard label="Total P&L" value={\`$\${kpis.totalPnl.toLocaleString()}\`} delta="+3.4%" positive />
|
|
363
|
-
<KpiCard label="Open Positions" value={kpis.openPositions} />
|
|
364
|
-
</div>
|
|
365
|
-
|
|
366
|
-
{/* FlexLayout container — min-height: 0 is critical */}
|
|
367
|
-
<div className="dashboard-layout-container">
|
|
368
|
-
<Layout
|
|
369
|
-
model={modelRef.current}
|
|
370
|
-
factory={factory}
|
|
371
|
-
onModelChange={onModelChange}
|
|
372
|
-
/>
|
|
373
|
-
</div>
|
|
374
|
-
</section>
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
\`\`\`
|
|
378
|
-
|
|
379
|
-
---
|
|
380
|
-
|
|
381
|
-
### Shared filter / cross-tile criteria
|
|
382
|
-
|
|
383
|
-
Pass a shared \`criteria\` string as state to chart datasources and grids:
|
|
384
|
-
|
|
385
|
-
\`\`\`tsx
|
|
386
|
-
const [criteria, setCriteria] = useState('');
|
|
387
|
-
|
|
388
|
-
// In each tile that accepts a filter:
|
|
389
|
-
const FilteredPnlTile: React.FC<{ criteria: string }> = ({ criteria }) => (
|
|
390
|
-
<G2PlotChart type="line" config={pnlConfig} style={{ height: '100%' }}>
|
|
391
|
-
<ChartDatasource
|
|
392
|
-
resourceName="ALL_TRADES"
|
|
393
|
-
serverFields="TRADE_DATE NOTIONAL"
|
|
394
|
-
criteria={criteria}
|
|
395
|
-
/>
|
|
396
|
-
</G2PlotChart>
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
// Pass criteria from the page via componentMap closure or React Context
|
|
400
|
-
\`\`\`
|
|
401
|
-
|
|
402
|
-
For more complex cross-tile eventing (broadcast, pub/sub between tiles), see \`fui-eventing\`.
|
|
403
|
-
|
|
404
|
-
---
|
|
405
|
-
|
|
406
|
-
### Data loading for KPI cards (Connect request pattern)
|
|
407
|
-
|
|
408
|
-
Never raw-\`fetch\` Genesis endpoints — use \`getConnect()\` (authenticated socket, correct message
|
|
409
|
-
shapes). \`request()\` for \`REQ_*\` Request Server resources (fields in a \`REQUEST\` wrapper, rows in
|
|
410
|
-
\`REPLY\`); \`snapshot()\` for Data Server queries (rows in \`ROW\`). Full API: \`fui-foundation-comms\`.
|
|
411
|
-
|
|
412
|
-
\`\`\`tsx
|
|
413
|
-
import { getConnect } from '@genesislcap/foundation-comms';
|
|
414
|
-
|
|
415
|
-
function useDashboardKpis() {
|
|
416
|
-
const [kpis, setKpis] = useState({ totalPnl: 0, openPositions: 0 });
|
|
417
|
-
const [error, setError] = useState<string | null>(null);
|
|
418
|
-
|
|
419
|
-
useEffect(() => {
|
|
420
|
-
let mounted = true;
|
|
421
|
-
(async () => {
|
|
422
|
-
const connect = getConnect();
|
|
423
|
-
// GATE on the socket. request()/snapshot() on a closed socket REJECT with
|
|
424
|
-
// 'WebSocket connection is closed' — on a cold load that is the normal state, not an edge
|
|
425
|
-
// case, and an ungated call leaves every tile showing its initial zeros forever.
|
|
426
|
-
if (!(connect.isConnected || (await connect.connect()))) return;
|
|
427
|
-
try {
|
|
428
|
-
const res = await connect.request('REQ_DASHBOARD_SUMMARY', { REQUEST: {} });
|
|
429
|
-
const row = res?.REPLY?.[0]; // REPLY rows carry backend field names
|
|
430
|
-
if (row && mounted) {
|
|
431
|
-
setKpis({ totalPnl: row.TOTAL_PNL ?? 0, openPositions: row.OPEN_POSITIONS ?? 0 });
|
|
432
|
-
}
|
|
433
|
-
} catch (e) {
|
|
434
|
-
// NEVER swallow this. A tile stuck on 0 is indistinguishable from a real zero, so the
|
|
435
|
-
// dashboard looks fine while showing nothing true.
|
|
436
|
-
if (mounted) setError(e instanceof Error ? e.message : 'Failed to load');
|
|
437
|
-
}
|
|
438
|
-
})();
|
|
439
|
-
return () => { mounted = false; };
|
|
440
|
-
}, []);
|
|
441
|
-
|
|
442
|
-
return { kpis, error };
|
|
443
|
-
}
|
|
444
|
-
\`\`\`
|
|
445
|
-
|
|
446
|
-
---
|
|
447
|
-
|
|
448
|
-
### Related contexts to load for a dashboard page
|
|
449
|
-
|
|
450
|
-
| Context | When needed |
|
|
451
|
-
|---|---|
|
|
452
|
-
| \`fui-flexlayout\` | Always — FlexLayout Model/factory/tile lifecycle reference |
|
|
453
|
-
| \`fui-chart\` | Always — full G2PlotChart API reference (props, config, field mapping) |
|
|
454
|
-
| \`fui-styling\` | Always — design tokens for KPI card CSS, and the LAYERING rules (z-index / stacking contexts) whenever the page has a filter row above the KPI strip |
|
|
455
|
-
| \`fui-foundation-comms\` | When fetching KPI values via Connect request/snapshot |
|
|
456
|
-
| \`fui-rapid-grid-pro\` | When any tile is a read-only or editable grid |
|
|
457
|
-
| \`fui-column-defs\` | When configuring grid tile column definitions |
|
|
458
|
-
| \`fui-eventing\` | When tiles communicate via broadcast / cross-tile events |
|
|
459
|
-
|
|
460
|
-
---
|
|
461
|
-
|
|
462
|
-
### DANGEROUS PATTERNS
|
|
463
|
-
|
|
464
|
-
#### DP-1: Wrong import package for G2PlotChart (CRITICAL)
|
|
465
|
-
|
|
466
|
-
\`\`\`tsx
|
|
467
|
-
// WRONG — G2PlotChart is NOT in rapid-design-system; ChartConfiguration does NOT exist:
|
|
468
|
-
import { G2PlotChart } from '@genesislcap/rapid-design-system/react';
|
|
469
|
-
import type { ChartConfiguration } from '@genesislcap/g2plot-chart';
|
|
470
|
-
|
|
471
|
-
const chartConfig: ChartConfiguration = { // TypeScript error — type does not exist
|
|
472
|
-
type: 'Line',
|
|
473
|
-
options: { data: [], xField: 'DATE', yField: 'VALUE' },
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
// CORRECT — verified from showcase FlexLayout.tsx:
|
|
477
|
-
import { G2PlotChart, ChartDatasource } from '@genesislcap/g2plot-chart/react';
|
|
478
|
-
import type { ChartConfig } from '@genesislcap/g2plot-chart';
|
|
479
|
-
|
|
480
|
-
const lineConfig: ChartConfig = { xField: 'groupBy', yField: 'value' };
|
|
481
|
-
// Pass chart type as the \`type\` prop, lowercase — not inside config:
|
|
482
|
-
<G2PlotChart type="line" config={lineConfig} style={{ height: '100%' }}>
|
|
483
|
-
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE NOTIONAL" />
|
|
484
|
-
</G2PlotChart>
|
|
485
|
-
\`\`\`
|
|
486
|
-
|
|
487
|
-
#### DP-2: Placing KPI cards inside the FlexLayout componentMap
|
|
488
|
-
|
|
489
|
-
\`\`\`tsx
|
|
490
|
-
// WRONG — KPI cards become user-resizable panels instead of a fixed header strip:
|
|
491
|
-
const componentMap = {
|
|
492
|
-
kpiTotalPnl: () => <KpiCard label="Total P&L" value="$1.2M" />, // don't do this
|
|
493
|
-
pnlChart: PnlChartTile,
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
// CORRECT — render KPI strip directly in page JSX, ABOVE the layout container:
|
|
497
|
-
<section className="dashboard-page">
|
|
498
|
-
<div className="dashboard-kpi-strip">
|
|
499
|
-
<KpiCard label="Total P&L" value="$1.2M" delta="+3.4%" positive />
|
|
500
|
-
</div>
|
|
501
|
-
<div className="dashboard-layout-container">
|
|
502
|
-
<Layout model={modelRef.current} factory={factory} onModelChange={onModelChange} />
|
|
503
|
-
</div>
|
|
504
|
-
</section>
|
|
505
|
-
\`\`\`
|
|
506
|
-
|
|
507
|
-
#### DP-3: Chart/grid tile renders with 0px height inside FlexLayout
|
|
508
|
-
|
|
509
|
-
\`\`\`tsx
|
|
510
|
-
// WRONG — tile has no height and collapses to 0px inside a FlexLayout panel:
|
|
511
|
-
const PnlChartTile: React.FC = () => (
|
|
512
|
-
<G2PlotChart type="line" config={lineConfig}>
|
|
513
|
-
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE NOTIONAL" />
|
|
514
|
-
</G2PlotChart>
|
|
515
|
-
);
|
|
516
|
-
|
|
517
|
-
// CORRECT — always set style={{ height: '100%' }} for all tiles inside FlexLayout:
|
|
518
|
-
const PnlChartTile: React.FC = () => (
|
|
519
|
-
<G2PlotChart type="line" config={lineConfig} style={{ height: '100%' }}>
|
|
520
|
-
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE NOTIONAL" />
|
|
521
|
-
</G2PlotChart>
|
|
522
|
-
);
|
|
523
|
-
\`\`\`
|
|
524
|
-
|
|
525
|
-
#### DP-4: FlexLayout layout container missing min-height: 0
|
|
526
|
-
|
|
527
|
-
\`\`\`css
|
|
528
|
-
/* WRONG — without min-height: 0 the layout container overflows its flex parent: */
|
|
529
|
-
.dashboard-layout-container {
|
|
530
|
-
flex: 1;
|
|
531
|
-
position: relative;
|
|
532
|
-
/* missing min-height: 0 */
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
/* CORRECT: */
|
|
536
|
-
.dashboard-layout-container {
|
|
537
|
-
flex: 1;
|
|
538
|
-
position: relative;
|
|
539
|
-
min-height: 0; /* critical — allows flex child to shrink below content size */
|
|
540
|
-
}
|
|
541
|
-
\`\`\`
|
|
542
|
-
|
|
543
|
-
#### DP-5: Leaving tabEnableRenderOnDemand at its default — hidden tabs load lazily
|
|
544
|
-
|
|
545
|
-
\`\`\`ts
|
|
546
|
-
// DEFAULT (true) — a hidden tab's tile does not mount (or subscribe) until first selected,
|
|
547
|
-
// so the user sees an empty/loading grid or chart on first click. Once rendered, tabs stay
|
|
548
|
-
// mounted either way — this is about deferred FIRST render, not remount-per-switch:
|
|
549
|
-
const defaultLayout = {
|
|
550
|
-
global: {}, // tabEnableRenderOnDemand defaults to true
|
|
551
|
-
layout: { ... },
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
// CORRECT for dashboards — render all tiles up front so every datasource is live immediately:
|
|
555
|
-
const defaultLayout = {
|
|
556
|
-
global: { tabEnableRenderOnDemand: false },
|
|
557
|
-
layout: { ... },
|
|
558
|
-
};
|
|
559
|
-
\`\`\`
|
|
560
|
-
|
|
561
|
-
#### DP-6: Using raw backend field names in chart config
|
|
562
|
-
|
|
563
|
-
\`\`\`tsx
|
|
564
|
-
// WRONG — config must reference chart field names, not backend field names:
|
|
565
|
-
const config: ChartConfig = {
|
|
566
|
-
xField: 'TRADE_DATE', // raw server field — will not match datasource output
|
|
567
|
-
yField: 'NOTIONAL',
|
|
568
|
-
};
|
|
569
|
-
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE NOTIONAL" />
|
|
570
|
-
|
|
571
|
-
// CORRECT — ChartDatasource maps server fields to 'groupBy' / 'value' by position:
|
|
572
|
-
const config: ChartConfig = {
|
|
573
|
-
xField: 'groupBy', // chart field name that datasource maps TRADE_DATE to
|
|
574
|
-
yField: 'value', // chart field name that datasource maps NOTIONAL to
|
|
575
|
-
};
|
|
576
|
-
<ChartDatasource resourceName="ALL_TRADES" serverFields="TRADE_DATE NOTIONAL" />
|
|
577
|
-
\`\`\`
|
|
578
|
-
|
|
579
|
-
#### DP-7: Sticky filter row + sticky KPI strip — the DatePicker calendar paints behind the cards
|
|
580
|
-
|
|
581
|
-
The most common dashboard layering bug. A filter row above a KPI strip, both made
|
|
582
|
-
\`position: sticky\` with the same \`z-index\`, hides every popup the filter row opens:
|
|
583
|
-
|
|
584
|
-
\`\`\`css
|
|
585
|
-
/* WRONG — \`sticky\` creates a stacking context even though nothing on this page scrolls, so the
|
|
586
|
-
DatePicker's internal z-index: 999 is trapped at "10". The KPI strip is also "10" and comes
|
|
587
|
-
later in the DOM, so it wins: the calendar's month header and the first Select options are
|
|
588
|
-
covered AND unclickable. */
|
|
589
|
-
.dashboard-filters { position: sticky; top: 0; z-index: 10; }
|
|
590
|
-
.dashboard-kpi-strip { position: sticky; top: 0; z-index: 10; }
|
|
591
|
-
|
|
592
|
-
/* ALSO WRONG — removing both is not enough: the popups then fall below
|
|
593
|
-
.dashboard-layout-container (position: relative) and the FlexLayout tiles cover them. */
|
|
594
|
-
|
|
595
|
-
/* CORRECT — the filter row is the shell's only layered element: */
|
|
596
|
-
.dashboard-filters { position: relative; z-index: 200; }
|
|
597
|
-
.dashboard-kpi-strip { /* no position, no z-index */ }
|
|
598
|
-
\`\`\`
|
|
599
|
-
|
|
600
|
-
Load \`fui-styling\` (LAYERING section) before writing page-shell CSS that mixes a filter row, a
|
|
601
|
-
KPI strip and a FlexLayout container. Also emit each container's rule in ONE stylesheet only —
|
|
602
|
-
duplicating \`.dashboard-kpi-strip\` in both the page CSS and the KPI component's own CSS means a
|
|
603
|
-
later-loaded copy silently overrides the fix.
|
|
604
|
-
`.trim();
|