@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,898 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context: Form component + UiSchema renderer catalog from @genesislcap/foundation-forms/react
|
|
3
|
-
*
|
|
4
|
-
* Tags for selective context injection — loaded when the conversation mentions these keywords.
|
|
5
|
-
*/
|
|
6
|
-
export const FUI_FORM_COMPONENT_TAGS = [
|
|
7
|
-
'form',
|
|
8
|
-
'Foundation Form',
|
|
9
|
-
'foundation-forms',
|
|
10
|
-
'UiSchema',
|
|
11
|
-
'uischema',
|
|
12
|
-
'ui schema',
|
|
13
|
-
'JSONForms',
|
|
14
|
-
'json forms',
|
|
15
|
-
'form schema',
|
|
16
|
-
'formschema',
|
|
17
|
-
'JsonSchema',
|
|
18
|
-
'Categorization',
|
|
19
|
-
'VerticalLayout',
|
|
20
|
-
'HorizontalLayout',
|
|
21
|
-
'childElements',
|
|
22
|
-
'Control',
|
|
23
|
-
'LayoutVertical2Columns',
|
|
24
|
-
'FormGridLayout',
|
|
25
|
-
'Stepper',
|
|
26
|
-
'Group',
|
|
27
|
-
'data entry',
|
|
28
|
-
'input form',
|
|
29
|
-
'form submission',
|
|
30
|
-
'create form',
|
|
31
|
-
'insert form',
|
|
32
|
-
'add record',
|
|
33
|
-
'bulk insert',
|
|
34
|
-
'connected lookup',
|
|
35
|
-
'combobox lookup',
|
|
36
|
-
'connected combobox',
|
|
37
|
-
'multiselect form',
|
|
38
|
-
'dropdown in form',
|
|
39
|
-
'form with tabs',
|
|
40
|
-
'tabbed form',
|
|
41
|
-
'wizard form',
|
|
42
|
-
'multi-step form',
|
|
43
|
-
'form validation',
|
|
44
|
-
'form renderer',
|
|
45
|
-
'custom renderer',
|
|
46
|
-
'react renderer',
|
|
47
|
-
'createReactRenderer',
|
|
48
|
-
'renderersWithReact',
|
|
49
|
-
'react slot',
|
|
50
|
-
'options.render',
|
|
51
|
-
'radio group form',
|
|
52
|
-
'segmented control form',
|
|
53
|
-
'array renderer',
|
|
54
|
-
'form read only',
|
|
55
|
-
'readonly form',
|
|
56
|
-
'hide submit',
|
|
57
|
-
'approval message',
|
|
58
|
-
'confirmation before submit',
|
|
59
|
-
];
|
|
60
|
-
export const FUI_FORM_COMPONENT_DEPS = ['fui-formatters'];
|
|
61
|
-
export const FUI_FORM_COMPONENT_CONTEXT = `
|
|
62
|
-
## FORM — \`@genesislcap/foundation-forms/react\`
|
|
63
|
-
|
|
64
|
-
### WHEN TO USE \`<Form>\` VS COMMITTING AN EVENT YOURSELF
|
|
65
|
-
|
|
66
|
-
**The test is whether the user types anything.**
|
|
67
|
-
|
|
68
|
-
| The interaction | Build it as |
|
|
69
|
-
|---|---|
|
|
70
|
-
| The user FILLS IN FIELDS and submits (create, edit, amend, book, respond-with-values) | \`<Form>\` |
|
|
71
|
-
| A FIELDLESS action on something already selected (cancel trade, approve, reject, delete, enable) | a confirm + \`commitEvent\`/\`commitGenesisEvent\`, no Form |
|
|
72
|
-
|
|
73
|
-
This mirrors how the platform's own apps decide it: a grid action declares
|
|
74
|
-
\`hasForm: true\` and opens a \`<Form>\` bound to the event, or \`hasForm: false\` and fires the event
|
|
75
|
-
directly. **Fields → Form. No fields → commit.**
|
|
76
|
-
|
|
77
|
-
**Do NOT assemble a data-entry form by hand** from \`TextField\`/\`NumberField\`/\`Select\` +
|
|
78
|
-
\`useState\` + a submit handler. Those primitives are for STANDALONE controls (a filter bar, a search
|
|
79
|
-
box, a toolbar field). Hand-assembling a form silently gives up, among others:
|
|
80
|
-
|
|
81
|
-
- schema fetched from the server (so it can't drift from the DAO), \`$ref\` resolved
|
|
82
|
-
- validation (required / min / max / pattern / enum / cross-field \`anyOf\`) with error display
|
|
83
|
-
- **server NACK errors mapped back onto the offending field**, and cleared when the user edits it
|
|
84
|
-
- errors held back until blur/submit rather than flashing while typing
|
|
85
|
-
- connected dropdowns (\`allOptionsResourceName\`) — no fetch/map code at all
|
|
86
|
-
- layouts (VerticalLayout, Group, Categorization, Stepper, 2-column, form-grid)
|
|
87
|
-
- conditional fields via \`rule\` + \`RuleEffect\`, \`readonly\`/\`hidden\` per field
|
|
88
|
-
- number/date/BigDecimal formatting, the confirmation dialog, the approval-message workflow
|
|
89
|
-
|
|
90
|
-
**\`<Form>\` and typed events are NOT alternatives.** \`<Form>\` submits by calling
|
|
91
|
-
\`connect.commitEvent(resourceName, { DETAILS: data })\` internally — \`resourceName\` IS the event
|
|
92
|
-
name. Typed generated event classes (\`commitGenesisEvent\`) are how you make a **fieldless** commit
|
|
93
|
-
type-safe. Choosing \`<Form>\` does not mean giving up typing, and using a typed event does not mean
|
|
94
|
-
you should have hand-built the form.
|
|
95
|
-
|
|
96
|
-
**Read react.d.ts BEFORE use:** VFS key \`@genesislcap/foundation-forms/react.d.ts\`
|
|
97
|
-
**Read types.d.ts for complex props:** VFS key \`@genesislcap/foundation-forms/types.d.ts\`
|
|
98
|
-
|
|
99
|
-
### Import paths (verified)
|
|
100
|
-
|
|
101
|
-
\`\`\`ts
|
|
102
|
-
// React wrapper — the component you render in JSX
|
|
103
|
-
import { Form } from '@genesislcap/foundation-forms/react';
|
|
104
|
-
|
|
105
|
-
// Types only — import from the base package root, NOT /react
|
|
106
|
-
import type { UiSchema, UiSchemaElement, RendererEntry } from '@genesislcap/foundation-forms';
|
|
107
|
-
|
|
108
|
-
// renderers export (default renderer array) — from base root
|
|
109
|
-
import { renderers } from '@genesislcap/foundation-forms';
|
|
110
|
-
|
|
111
|
-
// React-extras: opt-in renderersWithReact + ReactSlotRendererOptions
|
|
112
|
-
// Only import if you use options.render (React component inside UiSchema)
|
|
113
|
-
import {
|
|
114
|
-
renderersWithReact,
|
|
115
|
-
type ReactSlotRendererOptions,
|
|
116
|
-
type ReactSlotRenderContext,
|
|
117
|
-
} from '@genesislcap/foundation-forms/react-extras';
|
|
118
|
-
|
|
119
|
-
// JSON Schema type for jsonSchema prop
|
|
120
|
-
import type { JSONSchema7 } from 'json-schema';
|
|
121
|
-
\`\`\`
|
|
122
|
-
|
|
123
|
-
> **For FORM controls, prefer \`options.render\`.** \`@genesislcap/foundation-react-utils\` IS
|
|
124
|
-
> installed (this was previously documented as unavailable, which was wrong — it is a direct
|
|
125
|
-
> dependency and the generated scaffold imports its \`/router\` helpers), and it is the right tool
|
|
126
|
-
> for a GRID cell renderer via \`createGridProCellRenderer\`. For custom/interactive form controls use
|
|
127
|
-
> \`options.render\` + \`renderersWithReact\` (react-extras) instead — its \`handleChange\` context
|
|
128
|
-
> covers two-way controls (see DP-6).
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
### Form props (source-verified from form.ts + react.d.ts)
|
|
133
|
-
|
|
134
|
-
| Prop | Type | Default | Notes |
|
|
135
|
-
|------|------|---------|-------|
|
|
136
|
-
| \`prefix\` | \`string\` | \`'rapid'\` | Design-system prefix for internal renderers — always set to \`'rapid'\` |
|
|
137
|
-
| \`resourceName\` | \`string\` | — | Backend event/query name. Form fetches JSON schema from server + submits to this resource |
|
|
138
|
-
| \`uischema\` | \`UiSchema\` | auto-generated | Layout + field config. If omitted the form renders all fields from JSON schema |
|
|
139
|
-
| \`jsonSchema\` | \`JSONSchema7\` | — | Hard-coded client-side schema. Alternative to \`resourceName\` for static forms |
|
|
140
|
-
| \`data\` | \`any\` | \`{}\` | Initial form data (controlled). Pass React state and update via \`onDataChange\` |
|
|
141
|
-
| \`renderers\` | \`RendererEntry[]\` | built-in | Override the full renderer list. Use \`renderersWithReact\` when using \`options.render\` |
|
|
142
|
-
| \`additionalRenderers\` | \`RendererEntry[]\` | \`[]\` | Extend built-in renderers without replacing them. Preferred for adding custom renderers |
|
|
143
|
-
| \`readonly\` | \`boolean\` | \`false\` | Disables all inputs and hides the submit button |
|
|
144
|
-
| \`hideSubmit\` | \`boolean\` | \`false\` | Hides the submit button (attribute: \`hide-submit-button\`) |
|
|
145
|
-
| \`showReset\` | \`boolean\` | \`false\` | Shows a Reset button that clears form data |
|
|
146
|
-
| \`confirmationMessage\` | \`string\` | — | If set, shows a confirmation dialog before submit |
|
|
147
|
-
| \`setApprovalMessage\` | \`boolean\` | \`false\` | Adds APPROVAL_MESSAGE field to schema; sent at root level alongside DETAILS |
|
|
148
|
-
| \`approvalMessageLabel\` | \`string\` | \`'Approval Message'\` | Label for the approval message field |
|
|
149
|
-
| \`bulkInsert\` | \`boolean\` | \`false\` | Enables bulk insert mode (array of rows) |
|
|
150
|
-
| \`bulkInsertMinItems\` | \`number\` | \`1\` | Minimum rows in bulk insert mode |
|
|
151
|
-
| \`bulkInsertMaxItems\` | \`number\` | — | Maximum rows in bulk insert mode |
|
|
152
|
-
|
|
153
|
-
### Form events (source-verified from react.d.ts + form.ts)
|
|
154
|
-
|
|
155
|
-
| Event prop | Fires when |
|
|
156
|
-
|-----------|-----------|
|
|
157
|
-
| \`onDataChange\` | Any field changes — \`e.detail: { data, path, errors, additionalErrors }\` |
|
|
158
|
-
| \`onSubmitSuccess\` | Server returns success — \`e.detail: { payload, response }\` |
|
|
159
|
-
| \`onSubmitFailure\` | Server returns error — \`e.detail: { payload, errors }\` |
|
|
160
|
-
| \`onSubmitPartialSuccess\` | Bulk: some rows succeeded, some failed |
|
|
161
|
-
| \`onBulkSubmitComplete\` | Bulk: all rows attempted — \`e.detail: { successful, failed }\` |
|
|
162
|
-
| \`onRowStatusChanged\` | Bulk: row status updated — \`e.detail: { statuses, index, status }\` |
|
|
163
|
-
| \`onRowSubmitSuccess\` | Bulk: individual row succeeded |
|
|
164
|
-
| \`onRowSubmitFailure\` | Bulk: individual row failed |
|
|
165
|
-
| \`onResetClicked\` | Reset button clicked (when \`showReset\`) |
|
|
166
|
-
| \`onCsvImported\` | CSV import succeeded |
|
|
167
|
-
| \`onCsvParseError\` | CSV parse error |
|
|
168
|
-
| \`onCsvTemplateDownloaded\` / \`onCsvTemplateError\` | Bulk CSV template download outcome |
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
### Example 1 — server-driven form (most common)
|
|
173
|
-
|
|
174
|
-
The form fetches JSON schema from \`resourceName\` and auto-generates field renderers.
|
|
175
|
-
Provide a \`uischema\` to control layout, ordering, and options.
|
|
176
|
-
|
|
177
|
-
\`\`\`tsx
|
|
178
|
-
import { Form } from '@genesislcap/foundation-forms/react';
|
|
179
|
-
import type { UiSchema } from '@genesislcap/foundation-forms';
|
|
180
|
-
|
|
181
|
-
const uischema: UiSchema = {
|
|
182
|
-
type: 'VerticalLayout',
|
|
183
|
-
elements: [
|
|
184
|
-
{ type: 'Control', scope: '#/properties/INSTRUMENT_ID', label: 'Instrument' },
|
|
185
|
-
{ type: 'Control', scope: '#/properties/QUANTITY', label: 'Quantity' },
|
|
186
|
-
{ type: 'Control', scope: '#/properties/SIDE', label: 'Side' },
|
|
187
|
-
],
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
export default function TradeForm() {
|
|
191
|
-
return (
|
|
192
|
-
<Form
|
|
193
|
-
prefix="rapid"
|
|
194
|
-
resourceName="EVENT_TRADE_INSERT"
|
|
195
|
-
uischema={uischema}
|
|
196
|
-
/>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
\`\`\`
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
### Example 2 — controlled form with onDataChange + onSubmitSuccess
|
|
204
|
-
|
|
205
|
-
\`\`\`tsx
|
|
206
|
-
import { useCallback, useState } from 'react';
|
|
207
|
-
import { Form } from '@genesislcap/foundation-forms/react';
|
|
208
|
-
import type { UiSchema } from '@genesislcap/foundation-forms';
|
|
209
|
-
|
|
210
|
-
const uischema: UiSchema = {
|
|
211
|
-
type: 'VerticalLayout',
|
|
212
|
-
elements: [
|
|
213
|
-
{ type: 'Control', scope: '#/properties/INSTRUMENT_ID', label: 'Instrument' },
|
|
214
|
-
{ type: 'Control', scope: '#/properties/QUANTITY', label: 'Quantity' },
|
|
215
|
-
],
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
export default function TradeEntryForm() {
|
|
219
|
-
const [formData, setFormData] = useState<Record<string, any>>({});
|
|
220
|
-
|
|
221
|
-
const handleDataChange = useCallback((e: CustomEvent) => {
|
|
222
|
-
setFormData(e.detail.data);
|
|
223
|
-
}, []);
|
|
224
|
-
|
|
225
|
-
const handleSubmitSuccess = useCallback((e: CustomEvent) => {
|
|
226
|
-
const { payload, response } = e.detail;
|
|
227
|
-
console.log('Submitted:', payload, response);
|
|
228
|
-
}, []);
|
|
229
|
-
|
|
230
|
-
const handleSubmitFailure = useCallback((e: CustomEvent) => {
|
|
231
|
-
const errors = e.detail.errors?.map((err: any) => err.TEXT).join('; ') ?? 'Unknown error';
|
|
232
|
-
console.error('Submit failed:', errors);
|
|
233
|
-
}, []);
|
|
234
|
-
|
|
235
|
-
return (
|
|
236
|
-
<Form
|
|
237
|
-
prefix="rapid"
|
|
238
|
-
resourceName="EVENT_TRADE_INSERT"
|
|
239
|
-
uischema={uischema}
|
|
240
|
-
data={formData}
|
|
241
|
-
onDataChange={handleDataChange}
|
|
242
|
-
onSubmitSuccess={handleSubmitSuccess}
|
|
243
|
-
onSubmitFailure={handleSubmitFailure}
|
|
244
|
-
showReset
|
|
245
|
-
/>
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
\`\`\`
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
### Example 3 — static client-side schema (no server metadata)
|
|
253
|
-
|
|
254
|
-
Use \`jsonSchema\` + \`uischema\` together when you don't want to fetch metadata from the server.
|
|
255
|
-
|
|
256
|
-
\`\`\`tsx
|
|
257
|
-
import { Form } from '@genesislcap/foundation-forms/react';
|
|
258
|
-
import type { UiSchema } from '@genesislcap/foundation-forms';
|
|
259
|
-
import type { JSONSchema7 } from 'json-schema';
|
|
260
|
-
|
|
261
|
-
const JSON_SCHEMA: JSONSchema7 = {
|
|
262
|
-
type: 'object',
|
|
263
|
-
properties: {
|
|
264
|
-
PRICE: { type: 'number' },
|
|
265
|
-
QUANTITY: { type: 'number' },
|
|
266
|
-
NOTES: { type: 'string' },
|
|
267
|
-
},
|
|
268
|
-
required: ['PRICE', 'QUANTITY'],
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
const UI_SCHEMA: UiSchema = {
|
|
272
|
-
type: 'VerticalLayout',
|
|
273
|
-
elements: [
|
|
274
|
-
{ type: 'Control', label: 'Price', scope: '#/properties/PRICE',
|
|
275
|
-
options: { prefix: '$' } },
|
|
276
|
-
{ type: 'Control', label: 'Quantity', scope: '#/properties/QUANTITY' },
|
|
277
|
-
{ type: 'Control', label: 'Notes', scope: '#/properties/NOTES',
|
|
278
|
-
options: { textarea: true } },
|
|
279
|
-
],
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
export default function StaticForm() {
|
|
283
|
-
return (
|
|
284
|
-
<Form
|
|
285
|
-
prefix="rapid"
|
|
286
|
-
jsonSchema={JSON_SCHEMA}
|
|
287
|
-
uischema={UI_SCHEMA}
|
|
288
|
-
hideSubmit
|
|
289
|
-
/>
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
\`\`\`
|
|
293
|
-
|
|
294
|
-
---
|
|
295
|
-
|
|
296
|
-
### Critical UiSchema structure rule
|
|
297
|
-
|
|
298
|
-
The root \`UiSchema\` always has \`type\` + \`elements\`. The shape of \`elements\` differs by renderer type:
|
|
299
|
-
|
|
300
|
-
**Layout renderers** — children go directly in \`elements\`, no scope needed on the container:
|
|
301
|
-
- \`VerticalLayout\`, \`HorizontalLayout\`, \`LayoutVertical2Columns\`, \`FormGridLayout\`
|
|
302
|
-
|
|
303
|
-
**Field control** — \`Control\` has no children; it binds a field via \`scope\`:
|
|
304
|
-
- \`Control\` (no \`elements\`, no \`childElements\`)
|
|
305
|
-
|
|
306
|
-
**Composite section renderers** — each section is a \`Control\` item in \`elements\` that scopes to an object property; the section's form content goes in that Control's \`options.childElements\`:
|
|
307
|
-
- \`Categorization\` — one \`Control\` per tab; each tab scopes an object property
|
|
308
|
-
- \`Stepper\` — one \`Control\` per step; each step scopes an object property
|
|
309
|
-
- \`Group\` (used inside another layout) — the \`Group\` element itself has \`options.childElements\`
|
|
310
|
-
|
|
311
|
-
**The critical mistake to avoid:**
|
|
312
|
-
\`childElements\` always goes on the **element's own \`options\`**, never on the root \`UiSchema.options\`.
|
|
313
|
-
The root \`options\` is only for top-level renderer config (\`layout\`/\`activeCategory\` for Categorization, \`orientation\` for Stepper, \`labelPlacement\` for VerticalLayout).
|
|
314
|
-
|
|
315
|
-
---
|
|
316
|
-
|
|
317
|
-
### Renderer structure examples
|
|
318
|
-
|
|
319
|
-
\`\`\`ts
|
|
320
|
-
// ── Standard layout nesting: use \`elements\` ──────────────────────────────
|
|
321
|
-
const simpleLayout: UiSchema = {
|
|
322
|
-
type: 'VerticalLayout',
|
|
323
|
-
elements: [
|
|
324
|
-
{
|
|
325
|
-
type: 'Control',
|
|
326
|
-
scope: '#/properties/CLIENT_ID',
|
|
327
|
-
label: 'Client Id',
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
type: 'HorizontalLayout',
|
|
331
|
-
scope: '', // REQUIRED on a nested layout — see the rule below; '' is inert, not a real scope
|
|
332
|
-
elements: [
|
|
333
|
-
{ type: 'Control', scope: '#/properties/EMAIL', label: 'Email' },
|
|
334
|
-
{ type: 'Control', scope: '#/properties/COUNTRY', label: 'Country' },
|
|
335
|
-
],
|
|
336
|
-
},
|
|
337
|
-
],
|
|
338
|
-
};
|
|
339
|
-
\`\`\`
|
|
340
|
-
|
|
341
|
-
\`\`\`ts
|
|
342
|
-
// ── Categorization: root elements = one Control per tab ──────────────────
|
|
343
|
-
// Root options holds only the layout flag (horizontal/vertical), NOT childElements.
|
|
344
|
-
// childElements lives on each tab Control's own options.
|
|
345
|
-
const categorizedForm: UiSchema = {
|
|
346
|
-
type: 'Categorization',
|
|
347
|
-
elements: [
|
|
348
|
-
{
|
|
349
|
-
type: 'Control',
|
|
350
|
-
scope: '#/properties/basic', // scopes this tab to the 'basic' object
|
|
351
|
-
label: 'Information', // tab label shown in the tab bar
|
|
352
|
-
options: {
|
|
353
|
-
childElements: [ // ← content of this tab; use normal layout nesting here
|
|
354
|
-
{
|
|
355
|
-
type: 'HorizontalLayout',
|
|
356
|
-
elements: [
|
|
357
|
-
{ type: 'Control', scope: '#/properties/basic/properties/CLIENT_ID', label: 'Client Id' },
|
|
358
|
-
{ type: 'Control', scope: '#/properties/basic/properties/EMAIL', label: 'Email' },
|
|
359
|
-
],
|
|
360
|
-
},
|
|
361
|
-
],
|
|
362
|
-
},
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
type: 'Control',
|
|
366
|
-
scope: '#/properties/additional',
|
|
367
|
-
label: 'Additional Information',
|
|
368
|
-
options: {
|
|
369
|
-
childElements: [
|
|
370
|
-
{
|
|
371
|
-
type: 'VerticalLayout',
|
|
372
|
-
elements: [
|
|
373
|
-
{ type: 'Control', scope: '#/properties/additional/properties/NOTES', label: 'Notes' },
|
|
374
|
-
],
|
|
375
|
-
},
|
|
376
|
-
],
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
],
|
|
380
|
-
options: {
|
|
381
|
-
layout: 'horizontal', // ← root options: layout config only, no childElements here
|
|
382
|
-
},
|
|
383
|
-
};
|
|
384
|
-
\`\`\`
|
|
385
|
-
|
|
386
|
-
\`\`\`ts
|
|
387
|
-
// ── Categorization with vertical + fixed height (from sales-trader-hub) ──
|
|
388
|
-
const verticalCategorization: UiSchema = {
|
|
389
|
-
type: 'Categorization',
|
|
390
|
-
options: { layout: { type: 'vertical', height: '250px' } },
|
|
391
|
-
elements: [
|
|
392
|
-
{
|
|
393
|
-
type: 'Control',
|
|
394
|
-
scope: '#/properties/tab1',
|
|
395
|
-
label: 'Tab 1',
|
|
396
|
-
options: {
|
|
397
|
-
childElements: [
|
|
398
|
-
{ type: 'VerticalLayout', elements: [
|
|
399
|
-
{ type: 'Control', scope: '#/properties/tab1/properties/FIELD_A', label: 'Field A' },
|
|
400
|
-
]},
|
|
401
|
-
],
|
|
402
|
-
},
|
|
403
|
-
},
|
|
404
|
-
],
|
|
405
|
-
};
|
|
406
|
-
\`\`\`
|
|
407
|
-
|
|
408
|
-
\`\`\`ts
|
|
409
|
-
// ── Stepper (order-ticket wizard): root elements = one Control per step ──
|
|
410
|
-
// Same pattern as Categorization: each step is a Control scoped to an object property.
|
|
411
|
-
// The step's scope is REQUIRED (the stepper reads it for per-step validation).
|
|
412
|
-
// Root options holds only the orientation flag, NOT childElements.
|
|
413
|
-
const orderTicketStepper: UiSchema = {
|
|
414
|
-
type: 'Stepper',
|
|
415
|
-
elements: [
|
|
416
|
-
{
|
|
417
|
-
type: 'Control',
|
|
418
|
-
scope: '#/properties/order', // scopes this step to the 'order' object
|
|
419
|
-
label: 'Order', // step label
|
|
420
|
-
options: {
|
|
421
|
-
childElements: [
|
|
422
|
-
{
|
|
423
|
-
type: 'HorizontalLayout',
|
|
424
|
-
elements: [
|
|
425
|
-
{ type: 'Control', scope: '#/properties/order/properties/INSTRUMENT_ID' },
|
|
426
|
-
{ type: 'Control', scope: '#/properties/order/properties/QUANTITY' },
|
|
427
|
-
{ type: 'Control', scope: '#/properties/order/properties/SIDE' },
|
|
428
|
-
],
|
|
429
|
-
},
|
|
430
|
-
],
|
|
431
|
-
},
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
type: 'Control',
|
|
435
|
-
scope: '#/properties/allocation',
|
|
436
|
-
label: 'Allocation',
|
|
437
|
-
options: {
|
|
438
|
-
childElements: [
|
|
439
|
-
{
|
|
440
|
-
type: 'VerticalLayout',
|
|
441
|
-
elements: [
|
|
442
|
-
{ type: 'Control', scope: '#/properties/allocation/properties/ACCOUNT_ID' },
|
|
443
|
-
{ type: 'Control', scope: '#/properties/allocation/properties/BROKER_ID' },
|
|
444
|
-
],
|
|
445
|
-
},
|
|
446
|
-
],
|
|
447
|
-
},
|
|
448
|
-
},
|
|
449
|
-
],
|
|
450
|
-
options: {
|
|
451
|
-
orientation: 'horizontal', // ← root options: orientation only, no childElements here
|
|
452
|
-
},
|
|
453
|
-
};
|
|
454
|
-
\`\`\`
|
|
455
|
-
|
|
456
|
-
\`\`\`ts
|
|
457
|
-
// ── Group: placed inside another layout; Group element owns childElements ─
|
|
458
|
-
const groupedSection: UiSchema = {
|
|
459
|
-
type: 'VerticalLayout',
|
|
460
|
-
elements: [
|
|
461
|
-
{
|
|
462
|
-
type: 'Group',
|
|
463
|
-
label: 'Settlement',
|
|
464
|
-
scope: '#/properties/settlement', // scopes controls within the group
|
|
465
|
-
options: {
|
|
466
|
-
childElements: [ // ← content of the group box
|
|
467
|
-
{
|
|
468
|
-
type: 'LayoutVertical2Columns',
|
|
469
|
-
elements: [
|
|
470
|
-
{ type: 'Control', scope: '#/properties/settlement/properties/SETTLEMENT_DATE', label: 'Settle Date' },
|
|
471
|
-
{ type: 'Control', scope: '#/properties/settlement/properties/SETTLEMENT_CCY', label: 'Settle Ccy' },
|
|
472
|
-
],
|
|
473
|
-
},
|
|
474
|
-
],
|
|
475
|
-
},
|
|
476
|
-
},
|
|
477
|
-
],
|
|
478
|
-
};
|
|
479
|
-
\`\`\`
|
|
480
|
-
|
|
481
|
-
---
|
|
482
|
-
|
|
483
|
-
### Available renderer/layout types (summary)
|
|
484
|
-
|
|
485
|
-
| Type | Has \`elements\` | Has \`options.childElements\` | Notes |
|
|
486
|
-
|---|---|---|---|
|
|
487
|
-
| \`VerticalLayout\` | ✓ | — | standard vertical stack |
|
|
488
|
-
| \`HorizontalLayout\` | ✓ | — | standard horizontal row |
|
|
489
|
-
| \`LayoutVertical2Columns\` | ✓ | — | two-column vertical grid |
|
|
490
|
-
| \`FormGridLayout\` | ✓ | — | CSS-grid-based layout |
|
|
491
|
-
| \`Control\` | — | — | leaf node; binds a field via \`scope\` |
|
|
492
|
-
| \`Categorization\` | ✓ (Control items) | — (root opts = \`layout\`/\`activeCategory\`) | one Control per tab |
|
|
493
|
-
| \`Stepper\` | ✓ (Control items) | — (root opts = \`orientation\` only) | one Control per step |
|
|
494
|
-
| \`Group\` | — | ✓ | section box; nested inside another layout |
|
|
495
|
-
|
|
496
|
-
### Root-level options per renderer type (source-verified from types.d.ts)
|
|
497
|
-
|
|
498
|
-
- **\`Categorization\`**: \`layout: 'horizontal' | 'vertical' | { type: 'vertical'; height?: string }\`,
|
|
499
|
-
\`activeCategory?: number\` (zero-based tab to open on first render; out-of-bounds → 0)
|
|
500
|
-
- **\`Stepper\`**: \`orientation: 'vertical' | 'horizontal'\`
|
|
501
|
-
- **\`VerticalLayout\` / \`HorizontalLayout\`**: \`labelPlacement?: 'top' | 'left'\`
|
|
502
|
-
- **\`LayoutVertical2Columns\` / \`FormGridLayout\`**: no special root options
|
|
503
|
-
|
|
504
|
-
Every element also accepts \`label\`, \`placeholder\`, and an optional JSONForms \`rule\`
|
|
505
|
-
(\`{ effect, condition }\`) for show/hide/enable logic.
|
|
506
|
-
|
|
507
|
-
### Element-level options (source-verified from types.d.ts)
|
|
508
|
-
|
|
509
|
-
**Standard** (applicable to all renderers via \`StandardRendererOptions\`):
|
|
510
|
-
\`readonly\`, \`hidden\`, \`tooltip\`, \`tabIndex\`, \`validateFn\`, \`i18n\`,
|
|
511
|
-
\`className\` (string or \`(formData) => string\` — on a Categorization tab Control it styles the tab header)
|
|
512
|
-
|
|
513
|
-
**String control** (\`StringRendererOptions\`):
|
|
514
|
-
\`isPassword\`, \`textarea\`, \`autocomplete\`, \`textTransform\`, \`prefix\`, \`suffix\`, \`hideAffixFromScreenReader\`, \`changeOnInput\`
|
|
515
|
-
|
|
516
|
-
**Number control** (\`NumberRendererOptions\`):
|
|
517
|
-
\`withoutFormatting\`, \`formatOptions\`, \`autocomplete\`, \`prefix\`, \`suffix\`, \`hideAffixFromScreenReader\`, \`changeOnInput\`
|
|
518
|
-
|
|
519
|
-
**Connected lookup / combobox / multiselect** (\`ConnectedRenderersOptions\`):
|
|
520
|
-
\`allOptionsResourceName\`, \`datasourceConfig\`, \`valueField\`, \`labelField\`, \`data\`, \`async\`, \`allowCustomOptions\`, \`filterMode\`, \`labelRowFormatter\`, \`delimiter\`
|
|
521
|
-
|
|
522
|
-
**Multicolumn dropdown** (\`MulticolumnDropdownRendererOptions\`):
|
|
523
|
-
\`columnDefinitions\` (activates this renderer), \`allOptionsResourceName\`, \`valueField\`, \`labelField\`, \`searchKey\`, \`request\`, \`baseCriteria\`, \`advancedSearchReq\`, \`dropdownPlacement\`, \`dropdownWidth\`
|
|
524
|
-
|
|
525
|
-
**Array control** (\`ArrayRendererOptions\`):
|
|
526
|
-
\`childUiSchema\` (a \`UiSchema\`, or \`(index, rowData, formData) => UiSchema\` for per-row schemas),
|
|
527
|
-
\`addLabel\`, \`deleteLabel\`, \`border\`, \`canDelete\`, \`canAdd\`, \`gridView\`, \`showRowStatusIndicator\`
|
|
528
|
-
|
|
529
|
-
**Radio-group** (activated by \`radio: true\`, type \`RadioGroupRendererOptions\`):
|
|
530
|
-
\`radio: true\`, \`data: RadioOption[]\`, \`orientation\`
|
|
531
|
-
|
|
532
|
-
**Segmented** (activated by \`segmented: true\`, type \`SegmentedRendererOptions\`):
|
|
533
|
-
\`segmented: true\`, \`data: { value, label, color? }[]\`
|
|
534
|
-
|
|
535
|
-
**Categorization / Stepper / Group** element (\`CategorizationRendererOptions / StepperRendererOptions / GroupRendererOptions\`):
|
|
536
|
-
\`childElements: UiSchema[]\`
|
|
537
|
-
|
|
538
|
-
**React slot** (activated by \`options.render\` — requires \`renderersWithReact\`):
|
|
539
|
-
\`render: (formData, context) => ReactNode\` — full form data + \`{ controlData, path, handleChange }\`
|
|
540
|
-
|
|
541
|
-
---
|
|
542
|
-
|
|
543
|
-
### Connected lookup (combobox/multiselect) in a form
|
|
544
|
-
|
|
545
|
-
\`\`\`ts
|
|
546
|
-
const uischema: UiSchema = {
|
|
547
|
-
type: 'VerticalLayout',
|
|
548
|
-
elements: [
|
|
549
|
-
{
|
|
550
|
-
type: 'Control',
|
|
551
|
-
scope: '#/properties/INSTRUMENT_ID',
|
|
552
|
-
label: 'Instrument',
|
|
553
|
-
options: {
|
|
554
|
-
allOptionsResourceName: 'ALL_INSTRUMENTS', // verify resource name first
|
|
555
|
-
valueField: 'INSTRUMENT_ID',
|
|
556
|
-
labelField: 'INSTRUMENT_NAME',
|
|
557
|
-
async: true,
|
|
558
|
-
allowCustomOptions: false,
|
|
559
|
-
},
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
type: 'Control',
|
|
563
|
-
scope: '#/properties/COUNTERPARTY_IDS',
|
|
564
|
-
label: 'Counterparties',
|
|
565
|
-
options: {
|
|
566
|
-
allOptionsResourceName: 'ALL_COUNTERPARTYS',
|
|
567
|
-
valueField: 'COUNTERPARTY_ID',
|
|
568
|
-
labelField: 'NAME',
|
|
569
|
-
async: true,
|
|
570
|
-
},
|
|
571
|
-
},
|
|
572
|
-
],
|
|
573
|
-
};
|
|
574
|
-
\`\`\`
|
|
575
|
-
|
|
576
|
-
---
|
|
577
|
-
|
|
578
|
-
### React renderer via options.render (react-extras)
|
|
579
|
-
|
|
580
|
-
For read-only or display-only controls, use \`options.render\` to embed a React component inline without registering a custom renderer entry:
|
|
581
|
-
|
|
582
|
-
\`\`\`tsx
|
|
583
|
-
import { Form } from '@genesislcap/foundation-forms/react';
|
|
584
|
-
import type { UiSchema } from '@genesislcap/foundation-forms';
|
|
585
|
-
import { renderersWithReact } from '@genesislcap/foundation-forms/react-extras';
|
|
586
|
-
import type { JSONSchema7 } from 'json-schema';
|
|
587
|
-
|
|
588
|
-
const JSON_SCHEMA: JSONSchema7 = {
|
|
589
|
-
type: 'object',
|
|
590
|
-
properties: {
|
|
591
|
-
PRICE: { type: 'number' },
|
|
592
|
-
QUANTITY: { type: 'number' },
|
|
593
|
-
TOTAL: { type: 'number' },
|
|
594
|
-
},
|
|
595
|
-
};
|
|
596
|
-
|
|
597
|
-
function TotalDisplay({ formData }: { formData: any }) {
|
|
598
|
-
const total = (formData?.PRICE ?? 0) * (formData?.QUANTITY ?? 0);
|
|
599
|
-
return <div style={{ fontWeight: 700 }}>Total: {total}</div>;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
const UI_SCHEMA: UiSchema = {
|
|
603
|
-
type: 'VerticalLayout',
|
|
604
|
-
elements: [
|
|
605
|
-
{ type: 'Control', label: 'Price', scope: '#/properties/PRICE' },
|
|
606
|
-
{ type: 'Control', label: 'Quantity', scope: '#/properties/QUANTITY' },
|
|
607
|
-
{
|
|
608
|
-
type: 'Control',
|
|
609
|
-
label: 'Calculated total',
|
|
610
|
-
scope: '#/properties/TOTAL',
|
|
611
|
-
options: {
|
|
612
|
-
render: (formData) => <TotalDisplay formData={formData} />,
|
|
613
|
-
},
|
|
614
|
-
},
|
|
615
|
-
],
|
|
616
|
-
};
|
|
617
|
-
|
|
618
|
-
// IMPORTANT: pass renderersWithReact (not the default renderers) when using options.render
|
|
619
|
-
export default function OrderForm() {
|
|
620
|
-
return (
|
|
621
|
-
<Form
|
|
622
|
-
prefix="rapid"
|
|
623
|
-
jsonSchema={JSON_SCHEMA}
|
|
624
|
-
uischema={UI_SCHEMA}
|
|
625
|
-
renderers={renderersWithReact}
|
|
626
|
-
hideSubmit
|
|
627
|
-
/>
|
|
628
|
-
);
|
|
629
|
-
}
|
|
630
|
-
\`\`\`
|
|
631
|
-
|
|
632
|
-
---
|
|
633
|
-
|
|
634
|
-
### Interactive custom control via options.render (two-way)
|
|
635
|
-
|
|
636
|
-
The render context provides \`handleChange\` — a fully interactive custom control needs NO
|
|
637
|
-
renderer-entry registration. **Important:** React's synthetic events don't cross shadow DOM
|
|
638
|
-
boundaries — attach native listeners in \`useEffect\` for \`rapid-*\` web components
|
|
639
|
-
(plain HTML elements / React components inside \`render\` use normal JSX \`onChange\`).
|
|
640
|
-
|
|
641
|
-
\`\`\`tsx
|
|
642
|
-
import { useEffect, useRef } from 'react';
|
|
643
|
-
import { Form } from '@genesislcap/foundation-forms/react';
|
|
644
|
-
import {
|
|
645
|
-
renderersWithReact,
|
|
646
|
-
type ReactSlotRenderContext,
|
|
647
|
-
} from '@genesislcap/foundation-forms/react-extras';
|
|
648
|
-
import type { UiSchema } from '@genesislcap/foundation-forms';
|
|
649
|
-
import type { JSONSchema7 } from 'json-schema';
|
|
650
|
-
|
|
651
|
-
function LimitPriceControl({ ctx }: { ctx: ReactSlotRenderContext }) {
|
|
652
|
-
const ref = useRef<HTMLElement>(null);
|
|
653
|
-
|
|
654
|
-
useEffect(() => {
|
|
655
|
-
const el = ref.current as any;
|
|
656
|
-
if (!el) return;
|
|
657
|
-
const onChange = (e: Event) => {
|
|
658
|
-
const val = (e.target as any).value;
|
|
659
|
-
ctx.handleChange(ctx.path, val === '' ? undefined : Number(val));
|
|
660
|
-
};
|
|
661
|
-
el.addEventListener('change', onChange);
|
|
662
|
-
return () => el.removeEventListener('change', onChange);
|
|
663
|
-
}, [ctx.path, ctx.handleChange]);
|
|
664
|
-
|
|
665
|
-
return (
|
|
666
|
-
<rapid-number-field
|
|
667
|
-
ref={ref}
|
|
668
|
-
value={(ctx.controlData as number | undefined) ?? ''}
|
|
669
|
-
style={{ width: '100%' }}
|
|
670
|
-
/>
|
|
671
|
-
);
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
const JSON_SCHEMA: JSONSchema7 = {
|
|
675
|
-
type: 'object',
|
|
676
|
-
properties: { PRICE: { type: 'number' }, QUANTITY: { type: 'number' } },
|
|
677
|
-
required: ['PRICE'],
|
|
678
|
-
};
|
|
679
|
-
|
|
680
|
-
const UI_SCHEMA: UiSchema = {
|
|
681
|
-
type: 'VerticalLayout',
|
|
682
|
-
elements: [
|
|
683
|
-
{
|
|
684
|
-
type: 'Control',
|
|
685
|
-
label: 'Limit Price',
|
|
686
|
-
scope: '#/properties/PRICE',
|
|
687
|
-
options: { render: (formData, ctx) => <LimitPriceControl ctx={ctx} /> },
|
|
688
|
-
},
|
|
689
|
-
{ type: 'Control', label: 'Quantity', scope: '#/properties/QUANTITY' },
|
|
690
|
-
],
|
|
691
|
-
};
|
|
692
|
-
|
|
693
|
-
export default function OrderTicketForm() {
|
|
694
|
-
return (
|
|
695
|
-
<Form
|
|
696
|
-
prefix="rapid"
|
|
697
|
-
jsonSchema={JSON_SCHEMA}
|
|
698
|
-
uischema={UI_SCHEMA}
|
|
699
|
-
renderers={renderersWithReact} // ← react slot renderer wins over defaults (rank 100)
|
|
700
|
-
/>
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
\`\`\`
|
|
704
|
-
|
|
705
|
-
---
|
|
706
|
-
|
|
707
|
-
### Rules for AI when generating form schemas
|
|
708
|
-
|
|
709
|
-
- Always type schemas as \`UiSchema\`.
|
|
710
|
-
- Always import \`UiSchema\` from \`@genesislcap/foundation-forms\`, not from \`/react\`.
|
|
711
|
-
- Always set \`prefix="rapid"\` on \`<Form>\`.
|
|
712
|
-
- For \`Categorization\` and \`Stepper\`: root \`elements\` must contain \`Control\` items (not layout containers). Each Control scopes an object property and declares the section content in its own \`options.childElements\`.
|
|
713
|
-
- **Never** put \`childElements\` on the root \`UiSchema.options\` — it belongs on each section element's \`options\`.
|
|
714
|
-
- For \`Group\`: the \`Group\` element (inside a parent layout's \`elements\`) owns \`options.childElements\`.
|
|
715
|
-
- Inside each \`childElements\` array, use normal layout renderers (\`VerticalLayout\`, \`HorizontalLayout\`, etc.) with their own \`elements\`.
|
|
716
|
-
- Never put a REAL \`#/properties/…\` scope on pure layout containers (\`VerticalLayout\`,
|
|
717
|
-
\`HorizontalLayout\`, \`LayoutVertical2Columns\`, \`FormGridLayout\`) — that is the DP-2 error.
|
|
718
|
-
But a layout NESTED inside another layout's \`elements\` array must still carry \`scope: ''\`:
|
|
719
|
-
items of \`elements\` are typed \`UiSchemaElement\`, whose \`scope\` is REQUIRED, not optional
|
|
720
|
-
(foundation-forms \`types.ts\`), so omitting it fails the build with TS2741. An empty scope is
|
|
721
|
-
inert — the dispatch renderer drops falsy class parts with \`.filter(Boolean)\` — so the DOM is
|
|
722
|
-
identical. Only the ROOT \`UiSchema\` may omit \`scope\` entirely.
|
|
723
|
-
- Prefer explicit labels and scopes like \`#/properties/FIELD_NAME\` or \`#/properties/objectProp/properties/FIELD_NAME\`.
|
|
724
|
-
- When using \`options.render\` for React inline components, import and pass \`renderersWithReact\` as the \`renderers\` prop.
|
|
725
|
-
- When adding custom renderer entries, use \`additionalRenderers\` (not \`renderers\`) to avoid wiping the built-in renderer list.
|
|
726
|
-
- For FORM controls prefer \`options.render\` — it covers custom controls with less machinery. (\`@genesislcap/foundation-react-utils\` IS installed and importable; the earlier claim that it was not was incorrect. It is the correct tool for a GRID cell renderer — \`createGridProCellRenderer\` — not for form controls.)
|
|
727
|
-
- For connected lookups: verify the resource name with existing \`resourceName\` / \`allOptionsResourceName\` usages in the codebase — do not guess.
|
|
728
|
-
- If the correct renderer shape is uncertain, read the form package types/docs first instead of inventing structure.
|
|
729
|
-
|
|
730
|
-
---
|
|
731
|
-
|
|
732
|
-
### DANGEROUS PATTERNS
|
|
733
|
-
|
|
734
|
-
#### DP-1: Putting \`childElements\` on the root \`UiSchema.options\`
|
|
735
|
-
|
|
736
|
-
\`\`\`ts
|
|
737
|
-
// WRONG — childElements on the root schema's options does nothing:
|
|
738
|
-
const schema: UiSchema = {
|
|
739
|
-
type: 'Categorization',
|
|
740
|
-
elements: [ { type: 'Control', scope: '#/properties/tab1', label: 'Tab 1' } ],
|
|
741
|
-
options: {
|
|
742
|
-
childElements: [ // ← WRONG: ignored at root level
|
|
743
|
-
{ type: 'VerticalLayout', elements: [...] },
|
|
744
|
-
],
|
|
745
|
-
layout: 'horizontal',
|
|
746
|
-
},
|
|
747
|
-
};
|
|
748
|
-
|
|
749
|
-
// CORRECT — childElements belongs on each section element's own options:
|
|
750
|
-
const schema: UiSchema = {
|
|
751
|
-
type: 'Categorization',
|
|
752
|
-
elements: [
|
|
753
|
-
{
|
|
754
|
-
type: 'Control',
|
|
755
|
-
scope: '#/properties/tab1',
|
|
756
|
-
label: 'Tab 1',
|
|
757
|
-
options: {
|
|
758
|
-
childElements: [ // ← CORRECT: on the Control element
|
|
759
|
-
{ type: 'VerticalLayout', elements: [...] },
|
|
760
|
-
],
|
|
761
|
-
},
|
|
762
|
-
},
|
|
763
|
-
],
|
|
764
|
-
options: { layout: 'horizontal' }, // ← root opts: layout config only
|
|
765
|
-
};
|
|
766
|
-
\`\`\`
|
|
767
|
-
|
|
768
|
-
#### DP-2: Putting \`scope\` on layout containers
|
|
769
|
-
|
|
770
|
-
\`\`\`ts
|
|
771
|
-
// WRONG — layout containers (VerticalLayout, HorizontalLayout etc.) must NOT have scope:
|
|
772
|
-
{
|
|
773
|
-
type: 'VerticalLayout',
|
|
774
|
-
scope: '#/properties/address', // ← WRONG: scope on a layout, not a Control
|
|
775
|
-
elements: [...]
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
// CORRECT — only Control elements use scope:
|
|
779
|
-
{
|
|
780
|
-
type: 'VerticalLayout',
|
|
781
|
-
elements: [
|
|
782
|
-
{ type: 'Control', scope: '#/properties/ADDRESS_LINE_1', label: 'Address Line 1' },
|
|
783
|
-
]
|
|
784
|
-
}
|
|
785
|
-
\`\`\`
|
|
786
|
-
|
|
787
|
-
#### DP-3: Using options.render without renderersWithReact
|
|
788
|
-
|
|
789
|
-
\`\`\`tsx
|
|
790
|
-
// WRONG — using options.render with the default renderer list; the React slot renderer
|
|
791
|
-
// is not included in the default renderers, so the control renders nothing:
|
|
792
|
-
<Form
|
|
793
|
-
prefix="rapid"
|
|
794
|
-
uischema={{ ..., elements: [{ type: 'Control', options: { render: () => <MyComp /> } }] }}
|
|
795
|
-
// renderers not set — defaults to built-ins, which don't include the react slot renderer
|
|
796
|
-
/>
|
|
797
|
-
|
|
798
|
-
// CORRECT — import renderersWithReact and pass as the renderers prop:
|
|
799
|
-
import { renderersWithReact } from '@genesislcap/foundation-forms/react-extras';
|
|
800
|
-
|
|
801
|
-
<Form
|
|
802
|
-
prefix="rapid"
|
|
803
|
-
uischema={{ ..., elements: [{ type: 'Control', options: { render: () => <MyComp /> } }] }}
|
|
804
|
-
renderers={renderersWithReact} // ← includes the React slot renderer
|
|
805
|
-
/>
|
|
806
|
-
\`\`\`
|
|
807
|
-
|
|
808
|
-
#### DP-4: Using additionalRenderers to pass renderersWithReact (wrong prop)
|
|
809
|
-
|
|
810
|
-
\`\`\`tsx
|
|
811
|
-
// WRONG — renderersWithReact is a full replacement list; passing it as additionalRenderers
|
|
812
|
-
// creates duplicate renderer entries (built-ins + built-ins + react slot):
|
|
813
|
-
import { renderersWithReact } from '@genesislcap/foundation-forms/react-extras';
|
|
814
|
-
|
|
815
|
-
<Form
|
|
816
|
-
prefix="rapid"
|
|
817
|
-
additionalRenderers={renderersWithReact} // ← WRONG: use renderers prop instead
|
|
818
|
-
/>
|
|
819
|
-
|
|
820
|
-
// CORRECT — use the renderers prop to replace the default list:
|
|
821
|
-
<Form
|
|
822
|
-
prefix="rapid"
|
|
823
|
-
renderers={renderersWithReact} // ← CORRECT
|
|
824
|
-
/>
|
|
825
|
-
// If you only need to ADD a react slot entry without replacing everything:
|
|
826
|
-
import { ReactSlotControlRendererEntry } from '@genesislcap/foundation-forms/react-extras';
|
|
827
|
-
<Form
|
|
828
|
-
prefix="rapid"
|
|
829
|
-
additionalRenderers={[ReactSlotControlRendererEntry]}
|
|
830
|
-
/>
|
|
831
|
-
\`\`\`
|
|
832
|
-
|
|
833
|
-
#### DP-5: Using JSX onChange on platform web components inside options.render
|
|
834
|
-
|
|
835
|
-
\`\`\`tsx
|
|
836
|
-
// WRONG — React synthetic events don't cross shadow DOM boundaries; onChange never fires:
|
|
837
|
-
function MyControl({ ctx }: { ctx: ReactSlotRenderContext }) {
|
|
838
|
-
return (
|
|
839
|
-
<rapid-text-field
|
|
840
|
-
value={(ctx.controlData as string | undefined) ?? ''}
|
|
841
|
-
onChange={(e: any) => ctx.handleChange(ctx.path, e.target.value)} // ← WRONG: never fires
|
|
842
|
-
/>
|
|
843
|
-
);
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
// CORRECT — attach the native event listener inside useEffect:
|
|
847
|
-
function MyControl({ ctx }: { ctx: ReactSlotRenderContext }) {
|
|
848
|
-
const ref = useRef<HTMLElement>(null);
|
|
849
|
-
useEffect(() => {
|
|
850
|
-
const el = ref.current as any;
|
|
851
|
-
if (!el) return;
|
|
852
|
-
const handler = (e: Event) => ctx.handleChange(ctx.path, (e.target as any).value);
|
|
853
|
-
el.addEventListener('change', handler);
|
|
854
|
-
return () => el.removeEventListener('change', handler);
|
|
855
|
-
}, [ctx.path, ctx.handleChange]);
|
|
856
|
-
|
|
857
|
-
return <rapid-text-field ref={ref} value={(ctx.controlData as string | undefined) ?? ''} />;
|
|
858
|
-
}
|
|
859
|
-
\`\`\`
|
|
860
|
-
|
|
861
|
-
#### DP-6: Reaching for createReactRenderer when options.render is the form API
|
|
862
|
-
|
|
863
|
-
\`\`\`tsx
|
|
864
|
-
// WRONG for a FORM CONTROL — not because the package is missing (it IS installed, and an earlier
|
|
865
|
-
// version of this note wrongly said otherwise), but because the form's own extension point is
|
|
866
|
-
// options.render. Use createReactRenderer's sibling, createGridProCellRenderer, for GRID cells:
|
|
867
|
-
import { createReactRenderer, type RendererControlProps } from '@genesislcap/foundation-react-utils';
|
|
868
|
-
|
|
869
|
-
// CORRECT — custom form controls use options.render + renderersWithReact (react-extras):
|
|
870
|
-
import {
|
|
871
|
-
renderersWithReact,
|
|
872
|
-
type ReactSlotRenderContext,
|
|
873
|
-
} from '@genesislcap/foundation-forms/react-extras';
|
|
874
|
-
// options: { render: (formData, ctx) => <MyControl ctx={ctx} /> } on the Control element,
|
|
875
|
-
// renderers={renderersWithReact} on the <Form>.
|
|
876
|
-
\`\`\`
|
|
877
|
-
|
|
878
|
-
#### DP-7: Importing UiSchema from /react instead of the base package
|
|
879
|
-
|
|
880
|
-
\`\`\`ts
|
|
881
|
-
// WRONG — UiSchema is a type export from the base root, not the React wrapper:
|
|
882
|
-
import type { UiSchema } from '@genesislcap/foundation-forms/react'; // module has no UiSchema
|
|
883
|
-
|
|
884
|
-
// CORRECT — types always import from the base package:
|
|
885
|
-
import type { UiSchema } from '@genesislcap/foundation-forms';
|
|
886
|
-
\`\`\`
|
|
887
|
-
|
|
888
|
-
#### DP-8: Omitting prefix="rapid"
|
|
889
|
-
|
|
890
|
-
\`\`\`tsx
|
|
891
|
-
// WRONG — without prefix, internal renderers default to "rapid" but the design-system-prefix
|
|
892
|
-
// attr is unset, which may cause renderer prefix mismatches in some environments:
|
|
893
|
-
<Form resourceName="EVENT_TRADE_INSERT" uischema={uischema} />
|
|
894
|
-
|
|
895
|
-
// CORRECT — always set prefix explicitly:
|
|
896
|
-
<Form prefix="rapid" resourceName="EVENT_TRADE_INSERT" uischema={uischema} />
|
|
897
|
-
\`\`\`
|
|
898
|
-
`.trim();
|