CnDeltaWidget
Comparison / delta card. Resolves two OpenRegister aggregates (a current and a previous window) at runtime and renders the current value plus the signed percentage change, coloured by whether the movement is "good" (goodDirection). Registered under the delta type and configured by CnDeltaWidgetForm.
Content shape
{
"label": "Revenue",
"icon": "Cash",
"format": { "style": "currency", "currency": "EUR", "decimals": 0 },
"source": {
"register": "pipelinq", "schema": "lead", "metric": "sum", "field": "value",
"goodDirection": "up",
"current": { "filter": {} },
"previous": { "filter": {} }
}
}
Endpoint binding (Wave 2, #91)
Instead of the two OpenRegister legs, the tile can read BOTH values from one app REST payload through the shared useEndpointSource engine (token-resolved params, request dedup + short-TTL cache, cn:page:refresh / cn:widget:refresh wiring). Exactly one of source | endpointSource (validator-enforced).
{
"label": "Revenue",
"format": { "style": "currency", "currency": "EUR", "decimals": 0 },
"endpointSource": {
"url": "/apps/pipelinq/api/analytics/commercial",
"params": { "period": "@workspace.datePreset?" }
},
"valueField": "revenue",
"previousField": "previousPeriod.revenue",
"goodDirection": "up"
}
valueField/previousField— dot-paths into the payload for the current / previous values (the pipelinqpreviousPeriodcontract); the delta percent is computed client-side.deltaField— a server-computed delta percent; wins overpreviousField.- In endpoint mode
goodDirectionlives at the content top level (source.goodDirectionstill wins for the OpenRegister form).
Props
| Prop | Type | Default | Description |
|---|---|---|---|
content | object | {} | The delta config blob (label, format, source with current/previous — or endpointSource + valueField/previousField/deltaField). |
translate | function | null | Translate function for the label / caption source strings. Falls back to the injected cnTranslate (identity by default). |
Notes
goodDirection('up'/'down') decides whether a rise renders as positive (green) or negative (red).- Self-contained card surface — rendered flush and centred.