@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.
Files changed (139) hide show
  1. package/dist/ai-assistant.api.json +0 -97
  2. package/dist/ai-assistant.d.ts +0 -65
  3. package/dist/chat-driver.cjs +0 -18031
  4. package/dist/chat-driver.cjs.map +4 -4
  5. package/dist/chat-driver.mjs +0 -18024
  6. package/dist/chat-driver.mjs.map +4 -4
  7. package/dist/custom-elements.json +6856 -9696
  8. package/dist/dts/chat-driver-node.d.ts +0 -2
  9. package/dist/dts/chat-driver-node.d.ts.map +1 -1
  10. package/dist/dts/index.d.ts +0 -1
  11. package/dist/dts/index.d.ts.map +1 -1
  12. package/dist/dts/react.d.ts +0 -10
  13. package/dist/esm/chat-driver-node.js +0 -6
  14. package/dist/esm/index.js +0 -3
  15. package/dist/react.cjs +0 -7
  16. package/dist/react.mjs +0 -6
  17. package/package.json +17 -24
  18. package/scripts/smoke-chat-driver-node.mjs +0 -15
  19. package/dist/dts/code-review/code-review.types.d.ts +0 -76
  20. package/dist/dts/code-review/code-review.types.d.ts.map +0 -1
  21. package/dist/dts/code-review/code-reviewer.agent.d.ts +0 -77
  22. package/dist/dts/code-review/code-reviewer.agent.d.ts.map +0 -1
  23. package/dist/dts/code-review/code-reviewer.prompt.d.ts +0 -23
  24. package/dist/dts/code-review/code-reviewer.prompt.d.ts.map +0 -1
  25. package/dist/dts/code-review/gate.d.ts +0 -44
  26. package/dist/dts/code-review/gate.d.ts.map +0 -1
  27. package/dist/dts/code-review/index.d.ts +0 -27
  28. package/dist/dts/code-review/index.d.ts.map +0 -1
  29. package/dist/dts/code-review/review-changes.d.ts +0 -70
  30. package/dist/dts/code-review/review-changes.d.ts.map +0 -1
  31. package/dist/dts/code-review/rules/context-trigger-map.d.ts +0 -6
  32. package/dist/dts/code-review/rules/context-trigger-map.d.ts.map +0 -1
  33. package/dist/dts/code-review/rules/context.registry.d.ts +0 -123
  34. package/dist/dts/code-review/rules/context.registry.d.ts.map +0 -1
  35. package/dist/dts/code-review/rules/fui-ai-extensions.d.ts +0 -13
  36. package/dist/dts/code-review/rules/fui-ai-extensions.d.ts.map +0 -1
  37. package/dist/dts/code-review/rules/fui-blotter.d.ts +0 -16
  38. package/dist/dts/code-review/rules/fui-blotter.d.ts.map +0 -1
  39. package/dist/dts/code-review/rules/fui-chart.d.ts +0 -20
  40. package/dist/dts/code-review/rules/fui-chart.d.ts.map +0 -1
  41. package/dist/dts/code-review/rules/fui-column-defs.d.ts +0 -21
  42. package/dist/dts/code-review/rules/fui-column-defs.d.ts.map +0 -1
  43. package/dist/dts/code-review/rules/fui-components.d.ts +0 -9
  44. package/dist/dts/code-review/rules/fui-components.d.ts.map +0 -1
  45. package/dist/dts/code-review/rules/fui-criteria.d.ts +0 -32
  46. package/dist/dts/code-review/rules/fui-criteria.d.ts.map +0 -1
  47. package/dist/dts/code-review/rules/fui-custom-renderer.d.ts +0 -15
  48. package/dist/dts/code-review/rules/fui-custom-renderer.d.ts.map +0 -1
  49. package/dist/dts/code-review/rules/fui-dashboard.d.ts +0 -19
  50. package/dist/dts/code-review/rules/fui-dashboard.d.ts.map +0 -1
  51. package/dist/dts/code-review/rules/fui-dialogs.d.ts +0 -19
  52. package/dist/dts/code-review/rules/fui-dialogs.d.ts.map +0 -1
  53. package/dist/dts/code-review/rules/fui-entity-management.d.ts +0 -19
  54. package/dist/dts/code-review/rules/fui-entity-management.d.ts.map +0 -1
  55. package/dist/dts/code-review/rules/fui-error-boundary.d.ts +0 -9
  56. package/dist/dts/code-review/rules/fui-error-boundary.d.ts.map +0 -1
  57. package/dist/dts/code-review/rules/fui-eventing.d.ts +0 -8
  58. package/dist/dts/code-review/rules/fui-eventing.d.ts.map +0 -1
  59. package/dist/dts/code-review/rules/fui-flexlayout.d.ts +0 -17
  60. package/dist/dts/code-review/rules/fui-flexlayout.d.ts.map +0 -1
  61. package/dist/dts/code-review/rules/fui-flyout-panel.d.ts +0 -10
  62. package/dist/dts/code-review/rules/fui-flyout-panel.d.ts.map +0 -1
  63. package/dist/dts/code-review/rules/fui-form-component.d.ts +0 -9
  64. package/dist/dts/code-review/rules/fui-form-component.d.ts.map +0 -1
  65. package/dist/dts/code-review/rules/fui-formatters.d.ts +0 -12
  66. package/dist/dts/code-review/rules/fui-formatters.d.ts.map +0 -1
  67. package/dist/dts/code-review/rules/fui-foundation-comms.d.ts +0 -10
  68. package/dist/dts/code-review/rules/fui-foundation-comms.d.ts.map +0 -1
  69. package/dist/dts/code-review/rules/fui-global-filters.d.ts +0 -33
  70. package/dist/dts/code-review/rules/fui-global-filters.d.ts.map +0 -1
  71. package/dist/dts/code-review/rules/fui-import-surface.d.ts +0 -37
  72. package/dist/dts/code-review/rules/fui-import-surface.d.ts.map +0 -1
  73. package/dist/dts/code-review/rules/fui-inline-editing.d.ts +0 -10
  74. package/dist/dts/code-review/rules/fui-inline-editing.d.ts.map +0 -1
  75. package/dist/dts/code-review/rules/fui-layout.d.ts +0 -7
  76. package/dist/dts/code-review/rules/fui-layout.d.ts.map +0 -1
  77. package/dist/dts/code-review/rules/fui-notifications.d.ts +0 -12
  78. package/dist/dts/code-review/rules/fui-notifications.d.ts.map +0 -1
  79. package/dist/dts/code-review/rules/fui-primitives.d.ts +0 -26
  80. package/dist/dts/code-review/rules/fui-primitives.d.ts.map +0 -1
  81. package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts +0 -18
  82. package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts.map +0 -1
  83. package/dist/dts/code-review/rules/fui-redux-store.d.ts +0 -8
  84. package/dist/dts/code-review/rules/fui-redux-store.d.ts.map +0 -1
  85. package/dist/dts/code-review/rules/fui-reporting.d.ts +0 -19
  86. package/dist/dts/code-review/rules/fui-reporting.d.ts.map +0 -1
  87. package/dist/dts/code-review/rules/fui-styling.d.ts +0 -15
  88. package/dist/dts/code-review/rules/fui-styling.d.ts.map +0 -1
  89. package/dist/dts/code-review/rules/fui-trade-form.d.ts +0 -13
  90. package/dist/dts/code-review/rules/fui-trade-form.d.ts.map +0 -1
  91. package/dist/dts/code-review/submit-code-review.tool.d.ts +0 -12
  92. package/dist/dts/code-review/submit-code-review.tool.d.ts.map +0 -1
  93. package/dist/dts/code-review/unified-diff.d.ts +0 -7
  94. package/dist/dts/code-review/unified-diff.d.ts.map +0 -1
  95. package/dist/dts/code-review/verdict.d.ts +0 -23
  96. package/dist/dts/code-review/verdict.d.ts.map +0 -1
  97. package/dist/dts/components/code-review-result/code-review-result.d.ts +0 -26
  98. package/dist/dts/components/code-review-result/code-review-result.d.ts.map +0 -1
  99. package/dist/esm/code-review/code-review.types.js +0 -6
  100. package/dist/esm/code-review/code-reviewer.agent.js +0 -167
  101. package/dist/esm/code-review/code-reviewer.prompt.js +0 -103
  102. package/dist/esm/code-review/gate.js +0 -93
  103. package/dist/esm/code-review/index.js +0 -28
  104. package/dist/esm/code-review/review-changes.js +0 -123
  105. package/dist/esm/code-review/rules/context-trigger-map.js +0 -20
  106. package/dist/esm/code-review/rules/context.registry.js +0 -772
  107. package/dist/esm/code-review/rules/fui-ai-extensions.js +0 -306
  108. package/dist/esm/code-review/rules/fui-blotter.js +0 -596
  109. package/dist/esm/code-review/rules/fui-chart.js +0 -669
  110. package/dist/esm/code-review/rules/fui-column-defs.js +0 -862
  111. package/dist/esm/code-review/rules/fui-components.js +0 -245
  112. package/dist/esm/code-review/rules/fui-criteria.js +0 -538
  113. package/dist/esm/code-review/rules/fui-custom-renderer.js +0 -612
  114. package/dist/esm/code-review/rules/fui-dashboard.js +0 -604
  115. package/dist/esm/code-review/rules/fui-dialogs.js +0 -588
  116. package/dist/esm/code-review/rules/fui-entity-management.js +0 -1014
  117. package/dist/esm/code-review/rules/fui-error-boundary.js +0 -244
  118. package/dist/esm/code-review/rules/fui-eventing.js +0 -628
  119. package/dist/esm/code-review/rules/fui-flexlayout.js +0 -860
  120. package/dist/esm/code-review/rules/fui-flyout-panel.js +0 -432
  121. package/dist/esm/code-review/rules/fui-form-component.js +0 -898
  122. package/dist/esm/code-review/rules/fui-formatters.js +0 -415
  123. package/dist/esm/code-review/rules/fui-foundation-comms.js +0 -518
  124. package/dist/esm/code-review/rules/fui-global-filters.js +0 -778
  125. package/dist/esm/code-review/rules/fui-import-surface.js +0 -452
  126. package/dist/esm/code-review/rules/fui-inline-editing.js +0 -445
  127. package/dist/esm/code-review/rules/fui-layout.js +0 -431
  128. package/dist/esm/code-review/rules/fui-notifications.js +0 -439
  129. package/dist/esm/code-review/rules/fui-primitives.js +0 -1216
  130. package/dist/esm/code-review/rules/fui-rapid-grid-pro.js +0 -650
  131. package/dist/esm/code-review/rules/fui-redux-store.js +0 -522
  132. package/dist/esm/code-review/rules/fui-reporting.js +0 -506
  133. package/dist/esm/code-review/rules/fui-styling.js +0 -1229
  134. package/dist/esm/code-review/rules/fui-trade-form.js +0 -618
  135. package/dist/esm/code-review/submit-code-review.tool.js +0 -43
  136. package/dist/esm/code-review/unified-diff.js +0 -96
  137. package/dist/esm/code-review/verdict.js +0 -24
  138. package/dist/esm/components/code-review-result/code-review-result.js +0 -89
  139. package/docs/code-review.md +0 -137
@@ -1,860 +0,0 @@
1
- /**
2
- * Context module for the UI Builder — flexlayout-react multi-panel layout.
3
- *
4
- * This app uses flexlayout-react (caplin/FlexLayout) for all multi-panel, resizable,
5
- * drag-and-drop layouts. foundation-layout is OUT OF SCOPE — never use it.
6
- *
7
- * API surface verified against:
8
- * - flexlayout-react@0.8.19 types (node_modules: model/IJsonModel.d.ts, model/Actions.d.ts,
9
- * model/Model.d.ts, view/Layout.d.ts, DockLocation.d.ts)
10
- * - @genesislcap/rapid-design-system dist/dts/flexlayout-react-theme (platform-owned theme)
11
- * - GENERATED-APP GROUND TRUTH: preview client src/pages/Home/Home.tsx + Home.css,
12
- * src/utils/layout.ts (getFlexLayoutStorageKey), src/components/error-boundary/ErrorBoundary.tsx
13
- * (TileErrorBoundary), src/main.tsx (installRapidFlexLayoutReactStyles)
14
- */
15
- export const FUI_FLEXLAYOUT_TAGS = [
16
- // Non-technical / intent phrases
17
- 'multi panel',
18
- 'multi-panel',
19
- 'split panel',
20
- 'split layout',
21
- 'resizable panels',
22
- 'draggable tabs',
23
- 'drag and drop panels',
24
- 'dockable panels',
25
- 'side by side panels',
26
- 'stacked panels',
27
- 'panels on top and bottom',
28
- 'rearrange layout',
29
- 'reorganize layout',
30
- '50/50 split',
31
- 'dashboard layout',
32
- 'tile layout',
33
- 'tabbed layout',
34
- 'tabbed panels',
35
- 'panel layout',
36
- 'resizable layout',
37
- 'flexible layout',
38
- 'grid of panels',
39
- 'layout with tabs',
40
- 'tabs with panels',
41
- 'multi pane',
42
- 'multi-pane',
43
- 'dock panel',
44
- 'docked panel',
45
- 'move panels',
46
- 'arrange panels',
47
- 'resize panels',
48
- 'panel grid',
49
- 'panel manager',
50
- 'workspace layout',
51
- 'apply layout',
52
- 'restructure layout',
53
- 'redesign page',
54
- 'tile',
55
- 'tiles',
56
- // Technical terms
57
- 'flexlayout',
58
- 'flexlayout-react',
59
- 'FlexLayout',
60
- 'Layout',
61
- 'Model',
62
- 'TabNode',
63
- 'TabSetNode',
64
- 'DockLocation',
65
- 'Actions',
66
- 'IJsonModel',
67
- 'rootOrientationVertical',
68
- 'factory function',
69
- 'tabEnableRenderOnDemand',
70
- 'onModelChange',
71
- 'addNode',
72
- 'deleteTab',
73
- 'doAction',
74
- 'getActiveTabset',
75
- 'getNodeById',
76
- 'Model.fromJson',
77
- 'componentMap',
78
- 'TileErrorBoundary',
79
- 'getFlexLayoutStorageKey',
80
- 'storage key',
81
- ];
82
- // No foundation-ui package deps — flexlayout-react is a standalone npm package.
83
- // (The flexlayout theme ships inside @genesislcap/rapid-design-system and is installed
84
- // once at app bootstrap; pages never import it.)
85
- // export const FUI_FLEXLAYOUT_DEPS = [];
86
- export const FUI_FLEXLAYOUT_CONTEXT = `
87
- ## FLEXLAYOUT-REACT — Multi-Panel Layout
88
-
89
- > **This app uses \`flexlayout-react\` for all multi-panel / dockable / resizable layouts.**
90
- > Do NOT use \`foundation-layout\` — it is out of scope for this project.
91
-
92
- ### Imports (verified — flexlayout-react@0.8.19)
93
-
94
- \`\`\`ts
95
- // All public API comes from the same package root:
96
- import { Actions, DockLocation, Layout, Model, TabNode } from 'flexlayout-react';
97
- import type { IJsonModel, IJsonTabNode } from 'flexlayout-react';
98
- \`\`\`
99
-
100
- **Theme is PLATFORM-OWNED — do NOT import any stylesheet.** \`main.tsx\` already calls
101
- \`installRapidFlexLayoutReactStyles()\` from \`@genesislcap/rapid-design-system\` once at
102
- bootstrap; it installs the complete flexlayout theme wired to rapid design tokens.
103
- NEVER \`import 'flexlayout-react/style/*.css'\` and NEVER hand-write \`.flexlayout__*\`
104
- CSS-variable overrides in page CSS — both double-theme the layout (see DP-9).
105
-
106
- ### Core concepts
107
-
108
- | Concept | Description |
109
- |---|---|
110
- | **Model** | Immutable tree of nodes. Never mutate directly — use \`model.doAction(action)\`. Create with \`Model.fromJson(json)\`. Persist with \`model.toJson()\`. |
111
- | **Layout** | The single React component that renders the whole panel structure. Takes \`model\`, \`factory\`, and \`onModelChange\`. |
112
- | **factory** | \`(node: TabNode) => React.ReactNode\` — maps a tab's \`component\` string to the React element to render inside it. In this app: look up \`componentMap[node.getComponent()]\` and wrap in \`TileErrorBoundary\` (see page anatomy below). |
113
- | **Actions** | Static factory class for all model mutations: \`Actions.addNode\`, \`Actions.deleteTab\`, \`Actions.selectTab\`, etc. |
114
- | **DockLocation** | Enum-like class: \`DockLocation.CENTER\`, \`TOP\`, \`BOTTOM\`, \`LEFT\`, \`RIGHT\`. |
115
- | **tabEnableRenderOnDemand** | Global flag (default \`true\`). Controls ONLY the FIRST render of a tab: with the default \`true\`, an off-screen tab is not rendered until it is first shown; with \`false\`, every tab renders at page load. Either way, once a tab has rendered it stays MOUNTED (hidden via \`display:none\`) on tab switch — switching tabs never unmounts a rendered tile. Set \`false\` so off-screen FUI tiles subscribe and paint up front instead of on first reveal. |
116
-
117
- ### Layout component props (verified — ILayoutProps)
118
-
119
- | Prop | Type | Required | Description |
120
- |---|---|---|---|
121
- | \`model\` | \`Model\` | YES | The layout model |
122
- | \`factory\` | \`(node: TabNode) => React.ReactNode\` | YES | Renders content for each tab |
123
- | \`onModelChange\` | \`(model: Model, action: Action) => void\` | no | Called after every model change (use for persistence) |
124
- | \`onAction\` | \`(action: Action) => Action | undefined\` | no | Intercept actions before dispatch; return \`undefined\` to cancel |
125
- | \`onRenderTab\` | \`(node: TabNode, renderValues: ITabRenderValues) => void\` | no | Customise tab button content |
126
- | \`onRenderTabSet\` | \`(node: TabSetNode | BorderNode, renderValues: ITabSetRenderValues) => void\` | no | Add buttons to tabset header |
127
- | \`realtimeResize\` | \`boolean\` | no | Resize during splitter drag (may be choppy) |
128
- | \`classNameMapper\` | \`(defaultClassName: string) => string\` | no | CSS modules support |
129
- | \`icons\` | \`IIcons\` | no | Override close/maximize/etc icons |
130
-
131
- ### Putting a panel's action button IN the tabset header (\`onRenderTabSet\`)
132
-
133
- A tile action — "+ New RFQ", a refresh, a view toggle — belongs on the panel's HEADER LINE, to the
134
- right of the tab names. It does NOT belong in a strip above the grid: the tabset already draws a
135
- header bar, so a second strip below it produces a band of dead space between the tab names and the
136
- grid header, with the button floating in it. That band is a REPORTED visual defect, and it is the
137
- shape the agent reaches for when it does not know this hook exists.
138
-
139
- \`onRenderTabSet\` is that hook. It is called while the tabset header renders and you MUTATE the
140
- \`renderValues\` object it hands you — it returns \`void\`, so pushing is the whole API:
141
-
142
- \`\`\`tsx
143
- import { Layout, Model, TabNode, TabSetNode, BorderNode, ITabSetRenderValues } from 'flexlayout-react';
144
- import { Button } from '@genesislcap/rapid-design-system/react';
145
-
146
- <Layout
147
- model={model}
148
- factory={factory}
149
- onRenderTabSet={(node: TabSetNode | BorderNode, renderValues: ITabSetRenderValues) => {
150
- // BorderNode has no tabs of ours; only decorate real tabsets.
151
- if (!(node instanceof TabSetNode)) return;
152
- // Only the tabset whose ACTIVE tab is the one this action belongs to.
153
- const active = node.getSelectedNode() as TabNode | undefined;
154
- if (active?.getComponent() !== 'MainTradingRfQsManager') return;
155
- renderValues.stickyButtons.push(
156
- <Button key="new-rfq" appearance="primary" onClick={() => setNewRfqOpen(true)}>
157
- + New RFQ
158
- </Button>,
159
- );
160
- }}
161
- />
162
- \`\`\`
163
-
164
- \`ITabSetRenderValues\` has three slots: \`leading\` (a single node BEFORE the tabs), \`stickyButtons\`
165
- (an array added AFTER the tabs — the right-hand side, which is where a panel action goes) and
166
- \`buttons\` (an array at the very end of the tabset, after the overflow control). Prefer
167
- \`stickyButtons\`; \`buttons\` sits outside the overflow boundary and can be pushed off-screen.
168
-
169
- Two things that make this go wrong:
170
- - **Guard on the node.** The callback fires for BORDER nodes too, and for every tabset in the
171
- layout. Without the \`getSelectedNode()\` check the same button appears on every panel.
172
- - **Give every pushed element a \`key\`.** They land in an array React reconciles on each render.
173
-
174
- This is also why a tile component should NOT render its own action strip: if the tile draws the
175
- button, the tile cannot reach the header, and you get the dead band. Push from the page that owns
176
- the \`<Layout>\`, and keep the tile as content only.
177
-
178
- ### JSON model structure (IJsonModel)
179
-
180
- \`\`\`ts
181
- interface IJsonModel {
182
- global?: IGlobalAttributes; // defaults for all tabs/tabsets
183
- layout: IJsonRowNode; // root row
184
- borders?: IJsonBorderNode[]; // optional dockable borders (top/bottom/left/right)
185
- }
186
-
187
- // Row: contains tabsets or other rows
188
- interface IJsonRowNode {
189
- type?: 'row'; // implied
190
- weight?: number; // relative size in parent (default 100)
191
- id?: string;
192
- children: (IJsonRowNode | IJsonTabSetNode)[];
193
- }
194
-
195
- // Tabset: a container with a tab bar
196
- interface IJsonTabSetNode {
197
- type?: 'tabset'; // implied
198
- id?: string; // assign explicitly for programmatic targeting
199
- weight?: number; // SHARE of the parent's space — never a size. See "Sizing a panel" below.
200
- minHeight?: number; // px, a HARD floor the weight cannot go under
201
- maxHeight?: number; // px, a HARD cap the weight cannot exceed (default: global tabSetMaxHeight, 99999)
202
- minWidth?: number; // px
203
- maxWidth?: number; // px
204
- children: IJsonTabNode[];
205
- enableTabStrip?: boolean; // false = no tab bar (single-panel mode)
206
- }
207
- \`\`\`
208
-
209
- ### Sizing a panel — \`weight\` alone always leaves dead space
210
-
211
- \`weight\` is a SHARE, not a size: two tabsets at \`weight: 50\` each take half the viewport no matter
212
- what is inside them. That is right for a grid that should grow, and wrong for anything whose content
213
- is short and fixed — a KPI strip, an order-book ladder, a five-row blotter. Those stretch to their
214
- share and leave a large empty area under the last row, which is the single most common reason a
215
- generated screen looks unfinished next to a design.
216
-
217
- Cap those with \`maxHeight\` (px) — but only inside a VERTICAL row. \`RowNode\` sums children's
218
- \`maxHeight\` in a vertical row and takes their MINIMUM in a horizontal one, so a cap inside a
219
- horizontal row applies to the whole row. In a vertical row the space you free genuinely goes to the
220
- siblings:
221
-
222
- \`\`\`ts
223
- {
224
- type: 'row',
225
- children: [
226
- // A KPI strip: fixed content, so cap it — without maxHeight it would claim ~30% of the viewport.
227
- { type: 'tabset', weight: 20, maxHeight: 132, enableTabStrip: false, children: [kpiTile] },
228
- // The blotter is the thing that should absorb the remaining space.
229
- { type: 'tabset', weight: 80, minHeight: 240, children: [blotterTile] },
230
- ],
231
- }
232
- \`\`\`
233
-
234
- Defaults come from the global attributes \`tabSetMaxHeight\` (99999) and \`tabSetMinHeight\` (0), so a
235
- tabset is unconstrained until you say otherwise. Set the cap on the TABSET — a \`row\` computes its
236
- own min/max from its children and has no settable equivalent.
237
-
238
- \`\`\`ts
239
- // Tab: leaf node — renders via factory(node)
240
- interface IJsonTabNode {
241
- type?: 'tab'; // implied
242
- id?: string; // assign explicitly to enable Actions.deleteTab(id) later
243
- name: string; // tab label
244
- component?: string; // key passed to factory — MUST match a componentMap key
245
- enableClose?: boolean;
246
- enableDrag?: boolean;
247
- enableRename?: boolean;
248
- }
249
- \`\`\`
250
-
251
- ### Key global attributes (IGlobalAttributes — commonly used)
252
-
253
- | Attribute | Default | Notes |
254
- |---|---|---|
255
- | \`tabEnableRenderOnDemand\` | \`true\` | \`false\` = render every tab up front instead of deferring the first render until a tab is shown. (Tabs stay mounted on switch in BOTH modes — this flag only affects first render, not re-subscription.) |
256
- | \`tabEnableClose\` | \`true\` | Set \`false\` to hide close buttons on all tabs (generated pages do this) |
257
- | \`tabEnableRename\` | \`true\` | Set \`false\` to prevent double-click rename |
258
- | \`splitterSize\` | \`8\` | Splitter width in px |
259
- | \`tabSetEnableMaximize\` | \`true\` | Allow maximize button on tabsets |
260
- | \`rootOrientationVertical\` | \`false\` | \`true\` makes the ROOT row stack vertically (top→bottom) instead of horizontally |
261
-
262
- ---
263
-
264
- ### Orientation — there is NO \`column\` type (read this before writing a layout)
265
-
266
- flexlayout-react has only FOUR node types: \`row\`, \`tabset\`, \`tab\`, \`border\`. **\`type: 'column'\` does NOT exist** — writing it produces a broken layout. This is the #1 mistake: do NOT borrow CSS-flexbox \`column\`.
267
-
268
- Direction comes from **nesting depth**, not a type:
269
- - The **root \`layout\` row lays out HORIZONTALLY** — children sit side by side (left→right); \`weight\` = relative width.
270
- - **Every nested \`row\` FLIPS orientation**: a \`row\` inside the (horizontal) root lays out VERTICALLY — children stack top→bottom, \`weight\` = relative height. A row inside that is horizontal again, and so on.
271
- - To make the ROOT itself stack vertically, set \`global.rootOrientationVertical: true\`.
272
-
273
- **So: to stack panels top/bottom, wrap them in a nested \`row\` (or set \`rootOrientationVertical: true\`). To place panels side by side, put the tabsets directly in the root row.**
274
-
275
- ### Layout recipes (user intent → JSON)
276
-
277
- Swap the \`component\`/\`name\` strings for your real tile keys. Two \`weight: 50\`s = equal split.
278
-
279
- **A) Two panels side by side (left | right)** — tabsets directly in the (horizontal) root row:
280
- \`\`\`ts
281
- layout: { type: 'row', children: [
282
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Left', component: 'left' }] },
283
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Right', component: 'right' }] },
284
- ]}
285
- \`\`\`
286
-
287
- **B) Two panels stacked (top / bottom)** — flip the root vertical:
288
- \`\`\`ts
289
- global: { rootOrientationVertical: true },
290
- layout: { type: 'row', children: [
291
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Top', component: 'top' }] },
292
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Bottom', component: 'bottom' }] },
293
- ]}
294
- \`\`\`
295
-
296
- **C) One on top, a tab group below — top/bottom 50/50** (the common "X on top, Y and Z below in tabs" request). Root is horizontal, so wrap everything in ONE nested \`row\` to get vertical stacking; the bottom tabset holds multiple tabs:
297
- \`\`\`ts
298
- layout: { type: 'row', children: [
299
- { type: 'row', weight: 100, children: [
300
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Trade Blotter', component: 'tradingDashboardTradeBlotterManager' }] },
301
- { type: 'tabset', weight: 50, children: [
302
- { type: 'tab', name: 'Instruments', component: 'tradingDashboardInstrumentsManager' },
303
- { type: 'tab', name: 'Counterparties', component: 'tradingDashboardCounterpartiesManager' },
304
- ]},
305
- ]},
306
- ]}
307
- \`\`\`
308
-
309
- **D) One on the left, two stacked on the right** — left tabset + a nested (vertical) row on the right:
310
- \`\`\`ts
311
- layout: { type: 'row', children: [
312
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Main', component: 'main' }] },
313
- { type: 'row', weight: 50, children: [
314
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Top Right', component: 'topRight' }] },
315
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Bottom Right', component: 'bottomRight' }] },
316
- ]},
317
- ]}
318
- \`\`\`
319
-
320
- **E) 2×2 grid** — root (horizontal) → two nested (vertical) rows (\`weight: 50\` each), each with two \`weight: 50\` tabsets.
321
-
322
- **F) Several panels as tabs in ONE area** — a single tabset with multiple tabs:
323
- \`\`\`ts
324
- layout: { type: 'row', children: [
325
- { type: 'tabset', weight: 100, children: [
326
- { type: 'tab', name: 'Tab 1', component: 'one' },
327
- { type: 'tab', name: 'Tab 2', component: 'two' },
328
- ]},
329
- ]}
330
- \`\`\`
331
-
332
- **G) Adding a panel "next to" an EXISTING named panel — an EDIT, not a fresh layout.** This is a
333
- different problem from A–F: the target is somewhere in an ALREADY-BUILT tree, not the root. MEASURED
334
- (GENC-1560, a real production session, ~$110 of the cost was this one step): asked to "add an Order
335
- Book Depth panel next to the Live Bond Axes grid" on a page whose root row already held
336
- \`[tabset: Axes] [tabset: RFQs, Orders]\`, the agent appended Order Book Depth as a third top-level
337
- sibling with a FULL EQUAL \`weight\` — giving one order-book ladder the same visual billing as the
338
- entire RFQs+Orders section, when it was meant to share the Axes grid's space, not compete with a
339
- whole tab group:
340
- \`\`\`ts
341
- // WRONG — measured: three EQUAL weights, so Order Book Depth's share is taken from EVERY
342
- // sibling at once instead of carved out of the Axes grid's own 50
343
- layout: { type: 'row', children: [
344
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Axes', component: 'axesGrid' }] },
345
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Order Book Depth', component: 'orderBookDepth' }] },
346
- { type: 'tabset', weight: 50, children: [
347
- { type: 'tab', name: 'RFQs', component: 'rfQsManager' },
348
- { type: 'tab', name: 'Orders', component: 'ordersManager' },
349
- ]},
350
- ]}
351
- \`\`\`
352
- "Next to X" means the new panel joins X SPECIFICALLY, taking its space out of X's OWN share — and
353
- the right edit depends on which way X's immediate parent row already runs (root = horizontal
354
- unless \`rootOrientationVertical\`; each nesting level flips — see the orientation rule above):
355
-
356
- - **Parent row already runs the requested direction** → insert the new tabset as a SIBLING of X in
357
- that same row, re-splitting X's weight between the two. NO nested row — nesting here would flip
358
- orientation and stack the pair the wrong way. That is this case: "next to" is horizontal and
359
- X's parent is the horizontal root:
360
- \`\`\`ts
361
- // CORRECT — Order Book Depth takes its share out of the Axes grid's 50 (→ 30/20);
362
- // RFQs/Orders keeps the 50 it already had
363
- layout: { type: 'row', children: [
364
- { type: 'tabset', weight: 30, children: [{ type: 'tab', name: 'Axes', component: 'axesGrid' }] },
365
- { type: 'tabset', weight: 20, children: [{ type: 'tab', name: 'Order Book Depth', component: 'orderBookDepth' }] },
366
- { type: 'tabset', weight: 50, children: [
367
- { type: 'tab', name: 'RFQs', component: 'rfQsManager' },
368
- { type: 'tab', name: 'Orders', component: 'ordersManager' },
369
- ]},
370
- ]}
371
- \`\`\`
372
- - **Requested direction is PERPENDICULAR to the parent row** → wrap X's tabset (not the whole row)
373
- in a nested \`row\` alongside the new tabset; the nested row flips orientation and inherits X's
374
- old weight. Had the request been "add Order Book Depth BELOW the Axes grid":
375
- \`\`\`ts
376
- // CORRECT for "below" — the nested row is VERTICAL (its parent, the root, is horizontal),
377
- // so the pair stacks; the row takes Axes' old 50 and RFQs/Orders is untouched
378
- layout: { type: 'row', children: [
379
- { type: 'row', weight: 50, children: [
380
- { type: 'tabset', weight: 60, children: [{ type: 'tab', name: 'Axes', component: 'axesGrid' }] },
381
- { type: 'tabset', weight: 40, children: [{ type: 'tab', name: 'Order Book Depth', component: 'orderBookDepth' }] },
382
- ]},
383
- { type: 'tabset', weight: 50, children: [
384
- { type: 'tab', name: 'RFQs', component: 'rfQsManager' },
385
- { type: 'tab', name: 'Orders', component: 'ordersManager' },
386
- ]},
387
- ]}
388
- \`\`\`
389
- Either way every OTHER existing sibling keeps exactly the weight it had — only X's own share is
390
- divided with the newcomer.
391
-
392
- **Mapping the words:** "side by side / left / right" → tabsets in the root row · "above / below / top / bottom / stacked" → a nested \`row\` (or \`rootOrientationVertical\`) · "in tabs / tabbed" → multiple \`tab\`s in one \`tabset\` · "next to / beside [an EXISTING named panel]" on an already-built page → give THAT panel a neighbour out of its OWN weight — a sibling in its parent row when the row already runs that way, a nested \`row\` only when perpendicular (recipe G); never a full-weight share stolen from every sibling. When applying a mockup: each mockup region → one tabset; region size as % of the content area → \`weight\`.
393
-
394
- ---
395
-
396
- ### ANATOMY OF A GENESIS FLEXLAYOUT PAGE (the canonical shape — mirror it exactly)
397
-
398
- Every generated page is this exact skeleton. When restructuring a layout (e.g. applying a
399
- picked design option), EDIT this skeleton — change \`defaultLayout\`, add/remove tiles in
400
- \`componentMap\`, bump the storage id — never replace it with static markup (DP-10).
401
-
402
- \`\`\`tsx
403
- // src/pages/Trading/Trading.tsx
404
- import React, { useRef } from 'react';
405
- import { Layout, Model, TabNode } from 'flexlayout-react';
406
- import { getFlexLayoutStorageKey } from '../../utils/layout';
407
- import { TileErrorBoundary } from '../../components/error-boundary/ErrorBoundary';
408
- import { TradingTradeBlotterManager } from './TradeBlotterManager';
409
- import { TradingPositionsManager } from './PositionsManager';
410
- import { TradingMarketPricesManager } from './MarketPricesManager';
411
- import { TradingPnlChart } from './PnlChart';
412
- import './Trading.css';
413
-
414
- // Version-suffixed id — BUMP the suffix every time defaultLayout changes (see below).
415
- const STORAGE_KEY = getFlexLayoutStorageKey('Trading_v1');
416
-
417
- const defaultLayout = {
418
- global: { tabEnableClose: false, tabEnableRenderOnDemand: false },
419
- layout: {
420
- type: 'row',
421
- children: [
422
- // Left 65% — nested row = vertical stack: blotter (60%) over a tabbed group (40%)
423
- { type: 'row', weight: 65, children: [
424
- { type: 'tabset', weight: 60, children: [
425
- { type: 'tab', name: 'Trade Blotter', component: 'tradingTradeBlotterManager' },
426
- ]},
427
- { type: 'tabset', weight: 40, children: [
428
- { type: 'tab', name: 'Positions', component: 'tradingPositionsManager' },
429
- { type: 'tab', name: 'P&L Breakdown', component: 'tradingPnlChart' },
430
- ]},
431
- ]},
432
- // Right 35% — live market prices
433
- { type: 'tabset', weight: 35, children: [
434
- { type: 'tab', name: 'Market Prices (Live)', component: 'tradingMarketPricesManager' },
435
- ]},
436
- ],
437
- },
438
- };
439
-
440
- // EVERY tile is a self-contained React.FC registered here.
441
- // Each tab's 'component' string MUST match a key in this map — an unregistered key renders an empty tile.
442
- const componentMap: Record<string, React.FC> = {
443
- tradingTradeBlotterManager: TradingTradeBlotterManager,
444
- tradingPositionsManager: TradingPositionsManager,
445
- tradingMarketPricesManager: TradingMarketPricesManager,
446
- tradingPnlChart: TradingPnlChart,
447
- };
448
-
449
- function loadModel(): Model {
450
- if (STORAGE_KEY) { // null in dev → persistence disabled; always guard
451
- const saved = localStorage.getItem(STORAGE_KEY);
452
- if (saved) {
453
- try { return Model.fromJson(JSON.parse(saved)); } catch {}
454
- }
455
- }
456
- return Model.fromJson(defaultLayout);
457
- }
458
-
459
- const Trading = () => {
460
- const modelRef = useRef<Model>(loadModel());
461
-
462
- // Factory: componentMap lookup + TileErrorBoundary wrap — a crashing tile shows
463
- // diagnostics in-place instead of taking down the page. ALWAYS wrap tiles this way.
464
- const factory = (node: TabNode) => {
465
- const Component = componentMap[node.getComponent() ?? ''];
466
- return Component ? (
467
- <TileErrorBoundary
468
- title={node.getName() ?? node.getComponent() ?? ''}
469
- tileRegistration={node.getComponent() ?? ''}
470
- >
471
- <Component />
472
- </TileErrorBoundary>
473
- ) : null;
474
- };
475
-
476
- const onModelChange = (model: Model) => {
477
- if (STORAGE_KEY) localStorage.setItem(STORAGE_KEY, JSON.stringify(model.toJson()));
478
- };
479
-
480
- return (
481
- <section className="trading-page">
482
- <Layout model={modelRef.current} factory={factory} onModelChange={onModelChange} />
483
- </section>
484
- );
485
- };
486
-
487
- export default Trading;
488
- \`\`\`
489
-
490
- \`\`\`css
491
- /* Trading.css — the page container MUST have a resolved height (48px = app header). */
492
- .trading-page {
493
- height: calc(100vh - 48px);
494
- position: relative;
495
- }
496
- \`\`\`
497
-
498
- ### Layout persistence — getFlexLayoutStorageKey + version bump
499
-
500
- - \`getFlexLayoutStorageKey(id)\` lives in \`src/utils/layout.ts\` and returns
501
- \`'flexlayout_' + id\` — or **\`null\` in dev** (unless \`package.json\` sets
502
- \`config.PERSIST_LAYOUT_IN_DEV: true\`). Every read/write MUST be null-guarded.
503
- - **BUMP the id's version suffix whenever \`defaultLayout\` changes** (\`'Home_v2'\` →
504
- \`'Home_v3'\`): a layout already saved in localStorage always wins over the new default,
505
- so without a bump the restructured layout NEVER appears (DP-8).
506
- - Reuse the helper — never hand-roll raw \`localStorage\` keys for layouts.
507
-
508
- ### Tile sizing — the height chain
509
-
510
- flexlayout-react gives each tab an absolute-positioned container; nothing stretches
511
- automatically. Two rules:
512
-
513
- 1. **A tile whose content is ONE component**: give that component \`height: '100%'\`
514
- (grids/charts collapse to their natural height otherwise).
515
- 2. **A tile whose grid needs an action button**: it is NOT a two-element stack. Pass the action to
516
- the grid and the tile stays a single \`height: '100%'\` root:
517
-
518
- \`\`\`tsx
519
- import { CrudMenuPosition, type CustomAction } from '@genesislcap/foundation-entity-management';
520
-
521
- export const TradingTradeBlotterManager: React.FC = () => {
522
- const customActions: CustomAction[] = [{
523
- name: 'Add Trade',
524
- position: CrudMenuPosition.Top, // omit it and you get a PER-ROW button, not a toolbar
525
- requiresSelection: false,
526
- appearance: 'primary',
527
- action: { type: 'callback', callback: onAdd },
528
- }];
529
- return (
530
- <EntityManagement prefix="rapid" resourceName="TRADE_VIEW_QUERY" columns={columnDefs}
531
- customActions={customActions} style={{ height: '100%' }} />
532
- );
533
- };
534
- \`\`\`
535
-
536
- 3. **A tile stacking a genuine non-action strip ABOVE a grid or chart** — a filter row, a heading,
537
- or a toolbar over a hand-built RapidGridPro grid — needs the flex column chain:
538
-
539
- \`\`\`tsx
540
- export const TradingTradeBlotterPanel: React.FC = () => (
541
- <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
542
- {/* flex: '0 0 auto' pins the strip to its natural height; justifyContent + gap + padding are
543
- what stop the button being clamped to the left edge (fui-styling → "Toolbar above a hand-built grid") */}
544
- <div style={{ flex: '0 0 auto', display: 'flex', alignItems: 'center', justifyContent: 'flex-end',
545
- gap: 'calc(var(--design-unit) * 2px)', padding: 'calc(var(--design-unit) * 2px)' }}>
546
- <Button appearance="primary" onClick={onAdd}>Add Trade</Button>
547
- </div>
548
- {/* minHeight: 0 is REQUIRED — without it the flex item refuses to shrink and the grid overflows the tile */}
549
- <div style={{ flex: 1, minHeight: 0 }}>
550
- <RapidGridPro rowData={rows} gridOptions={{ columnDefs }} style={{ height: '100%' }} />
551
- </div>
552
- </div>
553
- );
554
- \`\`\`
555
-
556
- ---
557
-
558
- ### Programmatic add / remove (Actions API)
559
-
560
- \`\`\`tsx
561
- import { Actions, DockLocation } from 'flexlayout-react';
562
-
563
- // Add a tab — target the active tabset, falling back to a KNOWN tabset id from the JSON:
564
- const addPanel = (key: string, name: string) => {
565
- const target =
566
- modelRef.current.getActiveTabset() ?? // TabSetNode | undefined
567
- modelRef.current.getNodeById('main-tabset'); // requires explicit id in the JSON
568
- if (!target) return;
569
- modelRef.current.doAction(
570
- Actions.addNode(
571
- { type: 'tab', id: \`panel-\${key}\`, name, component: key }, // deterministic id
572
- target.getId(),
573
- DockLocation.CENTER,
574
- -1, // index (-1 = append)
575
- true, // select the new tab
576
- ),
577
- );
578
- };
579
-
580
- // Remove by the deterministic id you assigned:
581
- modelRef.current.doAction(Actions.deleteTab(\`panel-\${key}\`));
582
- // Other verified statics: Actions.selectTab(id), Actions.renameTab(id, text),
583
- // Actions.moveNode(fromId, toId, location, index), Actions.deleteTabset(id),
584
- // Actions.updateNodeAttributes(id, attrs), Actions.maximizeToggle(tabsetId)
585
- \`\`\`
586
-
587
- ---
588
-
589
- ### Key rules
590
-
591
- 1. **Always use \`useRef\` for the Model** — \`const modelRef = useRef<Model>(loadModel())\`. Do NOT put the model in \`useState\`; flexlayout-react manages re-renders internally via \`onModelChange\`.
592
- 2. **Never mutate the model directly** — always call \`model.doAction(Actions.*)\`.
593
- 3. **Set \`tabEnableRenderOnDemand: false\` in \`global\`** when panels contain FUI datasource components (grids, charts). This makes every off-screen tile render (subscribe + paint) at page load instead of only on first reveal, so a background tab already holds live data the moment the user switches to it. (Switching tabs does NOT unmount a rendered tile in either mode — flexlayout keeps hidden tabs mounted via \`display:none\` — so this is about eager first render, not preventing re-subscription.)
594
- 4. **Every tab's \`component\` string must be registered in \`componentMap\`**, and the factory must wrap tiles in \`TileErrorBoundary\` (title = tab name, tileRegistration = component key).
595
- 5. **Respect the height chain** — page container \`height: calc(100vh - 48px); position: relative\`; tile roots \`height: '100%'\`. A tile that needs an action button on its grid should NOT be wrapped in a flex column with a sibling toolbar div — pass the action via \`<EntityManagement customActions={[{ name, position: CrudMenuPosition.Top, action: { type: 'callback', callback } }]}>\` instead, so the grid stays the tile's only element and needs only \`height: '100%'\`. The flex column with \`flex: 1; minHeight: 0\` is for a genuine non-action strip above a hand-built grid.
596
- 6. **Assign explicit \`id\`s to tabs and tabsets** that you need to programmatically target later (e.g. via \`Actions.deleteTab(id)\` or \`model.getNodeById(id)\`). Without an explicit ID, flexlayout-react assigns a UUID that changes if the tab is deleted and re-added.
597
- 7. **Persist via \`getFlexLayoutStorageKey\`** (null-guarded) in \`onModelChange\`, load in a \`loadModel()\` with try/catch — and **bump the storage id whenever \`defaultLayout\` changes**.
598
- 8. **When restructuring an existing page's layout, keep every existing tile reachable** — its own tabset or a tab alongside another tile — unless the change explicitly replaces its function.
599
-
600
- ---
601
-
602
- ### DANGEROUS PATTERNS
603
-
604
- #### DP-1: Putting the Model in useState
605
-
606
- \`\`\`tsx
607
- // WRONG — React will re-render the whole tree on every drag/resize, and
608
- // setState is async so the model may lag behind user actions:
609
- const [model, setModel] = useState<Model>(() => Model.fromJson(defaultLayout));
610
- <Layout model={model} onModelChange={(m) => setModel(m)} ... />
611
-
612
- // CORRECT — keep the model in a ref; onModelChange is only needed for persistence:
613
- const modelRef = useRef<Model>(loadModel());
614
- <Layout model={modelRef.current} onModelChange={onModelChange} ... />
615
- \`\`\`
616
-
617
- #### DP-2: Forgetting tabEnableRenderOnDemand: false for FUI components
618
-
619
- \`\`\`tsx
620
- // SUBOPTIMAL — default is true, so an off-screen tab is not rendered until the user
621
- // first selects it. Its grid/chart only then mounts and subscribes, so the first switch
622
- // to that tab shows an empty tile that pops in once its datasource connects:
623
- const defaultLayout = {
624
- layout: { type: 'row', children: [/* tabs with grids/charts */] },
625
- // global omitted → tabEnableRenderOnDemand defaults to true
626
- };
627
-
628
- // PREFERRED — set false so every tile renders and subscribes at page load; a background
629
- // tab already holds live data the instant the user switches to it:
630
- const defaultLayout = {
631
- global: { tabEnableClose: false, tabEnableRenderOnDemand: false },
632
- layout: { type: 'row', children: [/* ... */] },
633
- };
634
- \`\`\`
635
-
636
- > **Note (verified — flexlayout-react@0.8.19):** this flag affects ONLY the first render.
637
- > Once a tab has rendered, flexlayout keeps it MOUNTED and merely hides it with
638
- > \`display:none\` on switch (\`renderTab = child.isRendered() || selected || !enableRenderOnDemand\`).
639
- > Switching tabs does NOT unmount a rendered tile, so its datasource is NOT re-created and
640
- > filter/scroll state is NOT lost — regardless of this flag. The only effect of \`false\` is
641
- > eager first render of off-screen tiles, not preventing re-subscription.
642
-
643
- #### DP-3: Broken tile height chain — the grid disappears when you add a toolbar above it
644
-
645
- \`\`\`tsx
646
- // WRONG (1) — no height at all: the grid renders at its natural height inside the
647
- // absolute-positioned tab container, appearing tiny or overflowing:
648
- case 'tradeGrid':
649
- return <EntityManagement prefix="rapid" resourceName="TRADE_VIEW_QUERY" columns={columnDefs} />;
650
-
651
- // WRONG (2) — the MEASURED failure, and wrong at TWO levels. "Add a button above the grid" does not
652
- // mean hand-rolling a flex wrapper with a sibling <Button>: EntityManagement takes its own
653
- // customActions prop. (The immediate crash here is the missing minHeight: 0 — a flex item defaults
654
- // to min-height: auto, refuses to shrink below its content, and the grid VANISHES — but fixing only
655
- // that leaves the wrong shape in place.)
656
- case 'tradeGrid':
657
- return (
658
- <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
659
- <div><Button onClick={onAdd}>Add Trade</Button></div>
660
- <div>
661
- <EntityManagement prefix="rapid" resourceName="TRADE_VIEW_QUERY"
662
- columns={columnDefs} style={{ height: '100%' }} />
663
- </div>
664
- </div>
665
- );
666
-
667
- // CORRECT — single-component tile: give that component height: '100%' and nothing else.
668
- case 'tradeGrid':
669
- return <EntityManagement prefix="rapid" resourceName="TRADE_VIEW_QUERY"
670
- columns={columnDefs} style={{ height: '100%' }} />;
671
-
672
- // CORRECT — a grid with an action button: use EntityManagement's own customActions, not a
673
- // hand-rolled wrapper. No flex column, no minHeight: 0 — the grid stays the tile's only element:
674
- case 'tradeGrid': {
675
- const customActions: CustomAction[] = [{
676
- name: 'Add Trade',
677
- position: CrudMenuPosition.Top,
678
- requiresSelection: false,
679
- action: { type: 'callback', callback: onAdd },
680
- }];
681
- return <EntityManagement prefix="rapid" resourceName="TRADE_VIEW_QUERY"
682
- columns={columnDefs} customActions={customActions} style={{ height: '100%' }} />;
683
- }
684
-
685
- // CORRECT — a genuine non-action strip above a grid: BOTH wrapper styles are required, neither is
686
- // optional. Note what is IN the strip: filter widgets. A <Button> here would be a grid ACTION, and
687
- // belongs in customActions above, not in this wrapper — do not reuse this shape to hold one.
688
- case 'filteredGrid':
689
- return (
690
- <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
691
- <div style={{ flex: '0 0 auto', display: 'flex', gap: 'calc(var(--design-unit) * 2px)' }}>
692
- <Combobox value={status} onChange={onStatusChange}>
693
- <ListboxOption value="">All</ListboxOption>
694
- <ListboxOption value="LIVE">Live</ListboxOption>
695
- </Combobox>
696
- </div>
697
- <div style={{ flex: 1, minHeight: 0 }}>
698
- <RapidGridPro rowData={rows} gridOptions={{ columnDefs }} style={{ height: '100%' }} />
699
- </div>
700
- </div>
701
- );
702
- \`\`\`
703
-
704
- A button on a grid does not need a hand-rolled toolbar strip at all — pass it as an
705
- \`EntityManagement\` \`customActions\` entry with \`position: CrudMenuPosition.Top\`
706
- (see \`fui-entity-management\` → "A button above the grid"); the platform renders and aligns it, so
707
- there is no flex-wrapper recipe to get right. A genuine non-action strip still needs its own
708
- alignment and spacing — see \`fui-styling\` → "Toolbar above a hand-built grid".
709
-
710
- #### DP-4: Page container without a resolved height
711
-
712
- \`\`\`tsx
713
- // WRONG — Layout renders with zero height because no ancestor has a defined height:
714
- <section>
715
- <Layout model={modelRef.current} factory={factory} />
716
- </section>
717
-
718
- // CORRECT — the generated-page pattern: a page class with explicit height + position:
719
- <section className="trading-page">
720
- <Layout model={modelRef.current} factory={factory} onModelChange={onModelChange} />
721
- </section>
722
- // .trading-page { height: calc(100vh - 48px); position: relative; }
723
- \`\`\`
724
-
725
- #### DP-5: Targeting a tab/tabset without an explicit ID
726
-
727
- \`\`\`tsx
728
- // WRONG — no id field; flexlayout-react auto-generates a UUID which changes
729
- // if the tab is deleted and recreated, making programmatic removal unreliable:
730
- Actions.addNode({ type: 'tab', name: 'My Panel', component: 'myPanel' }, target.getId(), DockLocation.CENTER, -1, true)
731
- // Later: how do you call Actions.deleteTab(???) ?
732
-
733
- // CORRECT — always pass a deterministic id when you need to remove the tab later:
734
- Actions.addNode({ type: 'tab', id: 'panel-my', name: 'My Panel', component: 'myPanel' }, target.getId(), DockLocation.CENTER, -1, true)
735
- // Later: Actions.deleteTab('panel-my') works reliably
736
- \`\`\`
737
-
738
- #### DP-0: Using \`type: 'column'\` to stack panels vertically
739
-
740
- \`\`\`ts
741
- // WRONG — flexlayout-react has NO 'column' type; this renders broken:
742
- layout: { type: 'column', children: [
743
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Top', component: 'top' }] },
744
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Bottom', component: 'bottom' }] },
745
- ]}
746
-
747
- // CORRECT — the root row is horizontal; wrap in a nested row to stack vertically
748
- // (a nested row flips orientation), OR set global.rootOrientationVertical: true:
749
- layout: { type: 'row', children: [
750
- { type: 'row', weight: 100, children: [
751
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Top', component: 'top' }] },
752
- { type: 'tabset', weight: 50, children: [{ type: 'tab', name: 'Bottom', component: 'bottom' }] },
753
- ]},
754
- ]}
755
- \`\`\`
756
-
757
- #### DP-6: Using foundation-layout instead of flexlayout-react
758
-
759
- \`\`\`tsx
760
- // WRONG — foundation-layout is out of scope for this project:
761
- import { FoundationLayout } from '@genesislcap/foundation-layout';
762
- // or
763
- import '@genesislcap/foundation-layout/react';
764
-
765
- // CORRECT — use flexlayout-react:
766
- import { Layout, Model, TabNode, Actions, DockLocation } from 'flexlayout-react';
767
- \`\`\`
768
-
769
- #### DP-7: Calling model.doAction on an undefined target
770
-
771
- \`\`\`tsx
772
- // WRONG — getActiveTabset() returns undefined if no tabset is focused:
773
- modelRef.current.doAction(
774
- Actions.addNode(json, modelRef.current.getActiveTabset().getId(), ...) // TypeError
775
- );
776
-
777
- // CORRECT — fall back to a named tabset:
778
- const target =
779
- modelRef.current.getActiveTabset() ??
780
- modelRef.current.getNodeById('fallback-tabset');
781
- if (!target) return; // guard if no tabset exists yet
782
- modelRef.current.doAction(Actions.addNode(json, target.getId(), ...));
783
- \`\`\`
784
-
785
- #### DP-8: Changing defaultLayout without bumping the storage id
786
-
787
- \`\`\`tsx
788
- // WRONG — defaultLayout was restructured but the storage id stayed the same:
789
- const STORAGE_KEY = getFlexLayoutStorageKey('Home_v2'); // unchanged
790
- const defaultLayout = { /* NEW restructured layout */ };
791
- // loadModel() finds the OLD saved model under 'flexlayout_Home_v2' and uses it —
792
- // the new layout NEVER appears, for the user or in preview screenshots.
793
-
794
- // CORRECT — bump the version suffix together with ANY defaultLayout change:
795
- const STORAGE_KEY = getFlexLayoutStorageKey('Home_v3');
796
- \`\`\`
797
-
798
- #### DP-9: Importing flexlayout stylesheets or copying theme CSS
799
-
800
- \`\`\`tsx
801
- // WRONG — the platform owns the flexlayout theme; these double-theme the layout:
802
- import 'flexlayout-react/style/dark.css';
803
- // ...or hand-written .flexlayout__* CSS-variable overrides in a page CSS file.
804
-
805
- // CORRECT — nothing to add in pages. main.tsx already runs, once, app-wide:
806
- import { installRapidFlexLayoutReactStyles } from '@genesislcap/rapid-design-system';
807
- installRapidFlexLayoutReactStyles();
808
- \`\`\`
809
-
810
- #### DP-10: Replacing the FlexLayout page with static markup
811
-
812
- \`\`\`tsx
813
- // WRONG — "applying a mockup" by swapping <Layout> for plain divs/cards:
814
- return (
815
- <section className="home-page">
816
- <div className="kpi-row">...</div>
817
- <div className="two-col">...</div>
818
- </section>
819
- );
820
- // This kills resize/drag/tab behavior, per-tile error isolation (TileErrorBoundary),
821
- // and layout persistence — wrong even if it visually matches the mockup.
822
-
823
- // CORRECT — keep <Layout>. Restructure defaultLayout (mockup regions → tabsets,
824
- // region sizes → weights), register each NEW region as its own tile component in
825
- // componentMap, wrap via the factory, and bump the storage id (DP-8).
826
- \`\`\`
827
-
828
- #### DP-11: Expecting a Select/DatePicker popup to overflow its tile
829
-
830
- \`.flexlayout__tab\` is \`overflow: hidden\`. A \`Select\`, \`Multiselect\`, \`Combobox\` or \`DatePicker\`
831
- renders its popup inside its own shadow root as an absolutely-positioned div, so a popup taller than
832
- the space left below its field is **clipped at the tile edge** — the hidden options are not just
833
- covered, they are unreachable. There is no stacking context between tile content and the root, so
834
- **z-index does not help here**; this is clipping, not stacking.
835
-
836
- Scope note: that "z-index does not help" applies to these **absolutely-positioned shadow popups**.
837
- A \`Dialog\` in a tile is the OPPOSITE problem — it is \`position: fixed\`, so it is never clipped, and
838
- since FUI 15.7.2 it defaults to \`z-index: 1001\`, which clears the tiles around it. Reach for
839
- \`Modal\` there because you want modal SEMANTICS (backdrop, focus trap, Esc) and top-layer immunity,
840
- not because the dialog is buried — see \`fui-dialogs\` DANGEROUS PATTERN 6.
841
-
842
- \`\`\`tsx
843
- // WRONG — filter field at the bottom of a tile: its dropdown opens into the tile's hidden overflow
844
- <div style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
845
- <div style={{ flex: 1, minHeight: 0 }}><EntityManagement style={{ height: '100%' }} ... /></div>
846
- <Select ...>{/* options below the fold are clipped away */}</Select>
847
- </div>
848
-
849
- // CORRECT — popup-opening fields go at the TOP of the tile so the dropdown opens into tile space
850
- <div style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
851
- <div style={{ flex: '0 0 auto' }}><Select ...>...</Select></div>
852
- <div style={{ flex: 1, minHeight: 0 }}><EntityManagement style={{ height: '100%' }} ... /></div>
853
- </div>
854
- \`\`\`
855
-
856
- For a long option list, or a filter bar that drives several tiles, put the filter row in the **page
857
- shell above \`<Layout>\`** instead and give it \`position: relative; z-index: 200\` (see
858
- \`fui-styling\` → LAYERING, and \`fui-global-filters\` for the wrapping-card
859
- \`overflow: visible; contain: none\` escape).
860
- `.trim();