You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`componentMap`|`Record<string, AngularComponentRenderer>`| An object mapping type name strings to Angular component classes |
23
+
|`componentMap`|`Record<string, AngularComponentRenderer \| RenderViewEntry>`| An object mapping type name strings to Angular component classes, or to `{ component, fallback? }` objects|
24
24
25
-
`AngularComponentRenderer` is defined as `Type<unknown>` -- any Angular component class.
25
+
`AngularComponentRenderer` is defined as `Type<unknown>` -- any Angular component class. Each entry can be a bare component class or a `RenderViewEntry` object:
26
+
27
+
```typescript
28
+
interfaceRenderViewEntry {
29
+
component:AngularComponentRenderer;
30
+
fallback?:AngularComponentRenderer;
31
+
}
32
+
```
33
+
34
+
Use the object form to configure a custom per-entry fallback (see [Per-Component Fallbacks](#per-component-fallbacks) below). A bare component class is shorthand for `{ component }` paired with the library's default fallback.
26
35
27
36
### Returns
28
37
@@ -118,15 +127,33 @@ An entry that omits `fallback` -- including every bare-component entry like `Tex
118
127
119
128
## Internal Behavior
120
129
121
-
The function converts the input object to an internal `Map<string, AngularComponentRenderer>` for O(1) lookups:
130
+
The function normalizes each input entry into a `{ component, fallback }` pair and stores them in an internal `Map` for O(1) lookups. A bare component class is paired with `DefaultFallbackComponent`; an object entry keeps its own `fallback` or falls back to the default:
122
131
123
132
```typescript
133
+
function normalize(
134
+
entry:AngularComponentRenderer|RenderViewEntry,
135
+
):NormalizedEntry {
136
+
// Bare Type — register with the default fallback.
Copy file name to clipboardExpand all lines: apps/website/content/docs/render/getting-started/introduction.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ The library resolves `Text` from your component registry, evaluates the `$state`
29
29
30
30
## How It Relates to @json-render/core
31
31
32
-
`@json-render/core` provides the spec format and the evaluation engine -- it resolves prop expressions (`$state`, `$item`, `$index`, `$bindState`, `$fn`), evaluates visibility conditions, and resolves bindings. It is framework-agnostic and has no Angular dependency.
32
+
`@json-render/core` provides the spec format and the evaluation engine -- it resolves prop expressions (`$state`, `$item`, `$index`, `$bindState`, `$computed`), evaluates visibility conditions, and resolves bindings. It is framework-agnostic and has no Angular dependency.
33
33
34
34
`@threadplane/render` is the Angular adapter layer. It provides:
Copy file name to clipboardExpand all lines: apps/website/content/docs/render/guides/specs.mdx
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,22 +110,20 @@ props: {
110
110
}
111
111
```
112
112
113
-
### $fn -- Computed Function
113
+
### $computed -- Computed Function
114
114
115
115
Calls a registered computed function with the given arguments:
116
116
117
117
```typescript
118
118
props: {
119
119
label: {
120
-
$fn: {
121
-
name: 'uppercase',
122
-
args: { text: { $state: '/name' } }
123
-
}
120
+
$computed: 'uppercase',
121
+
args: { text: { $state: '/name' } }
124
122
},
125
123
}
126
124
```
127
125
128
-
The `name` references a function you register in a `functions` map. Each function is a `ComputedFunction` from `@json-render/core` -- `(args: Record<string, unknown>) => unknown`. The `args` object is resolved first (so `{ $state: '/name' }` becomes the current value at `/name`), then passed to your function:
126
+
The `$computed` value names a function you register in a `functions` map. Each function is a `ComputedFunction` from `@json-render/core` -- `(args: Record<string, unknown>) => unknown`. The `args` object is resolved first (so `{ $state: '/name' }` becomes the current value at `/name`), then passed to your function:
With either wiring, the `$fn` expression above resolves `label` to the uppercased value of `/name`. The input takes priority over the `provideRender()` config when both are present.
155
+
With either wiring, the `$computed` expression above resolves `label` to the uppercased value of `/name`. The input takes priority over the `provideRender()` config when both are present.
0 commit comments