@sonata-innovations/fiber-types 2.2.0 → 2.3.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.
@@ -0,0 +1,196 @@
1
+ ---
2
+ title: Flow JSON Quick Reference
3
+ applies-to:
4
+ - "@sonata-innovations/fiber-types@^2.2"
5
+ read-when: "Constructing or interpreting Flow JSON: structure, component types and value types, options, conditions, validation, widths, inline markup. For exhaustive per-property detail, use flow-schema.md instead."
6
+ ---
7
+
8
+ <!-- Generated from the Fiber repo's docs/ tree by project/scripts/sync-package-docs.mjs. Do not edit here. -->
9
+ # Flow JSON Quick Reference
10
+
11
+ A compact reference for constructing Flow JSON programmatically. The [Flow Schema](flow-schema.md) is the exhaustive per-property reference; the machine-validatable schema is [`flow-schema.json`](flow-schema.json).
12
+
13
+ ## Schema
14
+
15
+ ```
16
+ Flow
17
+ ├── uuid: string # Unique flow identifier
18
+ ├── metadata: { name?, description?, ... } # Arbitrary key-value metadata
19
+ ├── config?: FlowConfiguration # Theme, mode, navigation, controls
20
+ ├── calculations?: Calculation[] # Named formulas over component values
21
+ └── screens: FlowScreen[]
22
+ ├── uuid: string
23
+ ├── label?: string
24
+ ├── conditions?: FlowConditionConfig # Show/hide this screen
25
+ ├── nextButtonLabel?: string
26
+ ├── backButtonLabel?: string
27
+ └── components: Component[]
28
+ ├── uuid: string
29
+ ├── type: string # See type table below
30
+ ├── properties: { label?, placeholder?, options?, validation?, width?, ... }
31
+ ├── conditions?: FlowConditionConfig # Show/hide this component
32
+ └── components?: Component[] # Group / repeater children only
33
+ ```
34
+
35
+ ## FlowConfiguration
36
+
37
+ | Field | Type | Default | Description |
38
+ |-------|------|---------|-------------|
39
+ | `mode` | `FlowModeType` | `"standard"` | `"standard"` or `"conversational"` — conversational mode centers content, auto-advances on selection, and Enter-advances on text inputs |
40
+ | `theme` | `ThemeConfig` | — | `{ color?, colorScheme?, style?, background?, surface?, text?, border?, radius?, fontFamily?, error?, success?, warning? }` — visual theme settings (palette knobs + preset) |
41
+ | `navigation` | `NavigationConfig` | — | `{ transition?, allowInvalidTransition? }` — screen navigation settings |
42
+ | `controls` | `ControlsConfig` | — | `{ show?, layout?, showStepper?, stepperStyle? }` — navigation controls settings |
43
+ | `confirmation` | `ConfirmationConfig` | — | `{ show?, title?, body? }` — terminal thank-you screen (see [Confirmation Screen](@sonata-innovations/fiber-fbre/docs/integration/fbre.md#confirmation-screen)) |
44
+ | `summary` | `boolean` | `false` | Show summary screen before completion |
45
+
46
+ ## Component Type → Value Type Mapping
47
+
48
+ The registry has **30 component types**:
49
+
50
+ | Type | Category | Value in FlowData | Initial Value |
51
+ |------|----------|-------------------|---------------|
52
+ | `header` | Display | _(excluded)_ | — |
53
+ | `text` | Display | _(excluded)_ | — |
54
+ | `divider` | Display | _(excluded)_ | — |
55
+ | `callout` | Display | _(excluded)_ | — |
56
+ | `table` | Display | _(excluded)_ | — |
57
+ | `computed` | Display | `number` (derived) | `null` |
58
+ | `inputText` | Input | `string` | `null` |
59
+ | `inputTextArea` | Input | `string` | `null` |
60
+ | `inputNumber` | Input | `number` | `null` |
61
+ | `dropDown` | Selection | `string \| number` | `null` (or `defaultValue` if it matches an option) |
62
+ | `dropDownMulti` | Selection | `(string \| number)[]` | `[]` |
63
+ | `checkbox` | Selection | `(string \| number)[]` | `[]` |
64
+ | `radio` | Selection | `string \| number` | `null` (or `defaultValue` if it matches an option) |
65
+ | `cardSelect` | Selection | `string \| number` | `null` (or `defaultValue` if it matches an option) |
66
+ | `toggleSwitch` | Selection | `boolean` | `false` |
67
+ | `yesNo` | Selection | `string` | `null` (or `defaultValue` if it matches an option) |
68
+ | `confirm` | Selection | `true` when ticked; key absent after untick | `null` |
69
+ | `date` | Date/Time | `string` | `null` |
70
+ | `time` | Date/Time | `string` | `null` |
71
+ | `dateTime` | Date/Time | `string` | `null` |
72
+ | `dateRange` | Date/Time | `RangeValue` (`{ start, end }`) | `null` |
73
+ | `timeRange` | Date/Time | `RangeValue` (`{ start, end }`) | `null` |
74
+ | `dateTimeRange` | Date/Time | `RangeValue` (`{ start, end }`) | `null` |
75
+ | `fileUpload` | Interactive | `FileUploadData` | `null` |
76
+ | `rating` | Interactive | `number` | `null` |
77
+ | `slider` | Interactive | `number` | `initValue` or `min` or `0` |
78
+ | `colorPicker` | Interactive | `string` | `defaultValue` or `null` |
79
+ | `signature` | Interactive | `string` (typed name or `data:` image URL) | `null` |
80
+ | `group` | Container | container entry with nested `components[][]`; no own `value` | — |
81
+ | `repeater` | Container | container entry with nested `components[][]` (one inner array per iteration); no own `value` | — |
82
+
83
+ Notes:
84
+ - Display components and hidden (condition-suppressed) components/screens are **excluded** from FlowData; `computed` is included.
85
+ - Option-bearing types (`dropDown`, `radio`, etc.) never default to the first option — the initial value is `null` unless `properties.defaultValue` matches an option's `value`.
86
+ - Container entries (`group`, `repeater`) are emitted **with** their children nested under `components: ComponentData[][]`; the container itself carries no `value` key.
87
+
88
+ ## Options Format
89
+
90
+ Selection components (`dropDown`, `dropDownMulti`, `checkbox`, `radio`) use:
91
+
92
+ ```json
93
+ {
94
+ "properties": {
95
+ "options": [
96
+ { "label": "Display Text", "value": "stored-value" },
97
+ { "label": "Another Option", "value": "another" }
98
+ ]
99
+ }
100
+ }
101
+ ```
102
+
103
+ Options **must** be `{ label, value }` objects. Bare strings are normalized automatically but should not be used when constructing flows.
104
+
105
+ ## Conditions Format (FlowConditionConfig)
106
+
107
+ Applied to `component.conditions` or `screen.conditions`:
108
+
109
+ ```json
110
+ {
111
+ "action": "show",
112
+ "when": {
113
+ "logic": "and",
114
+ "rules": [
115
+ { "source": "other-component-uuid", "operator": "equals", "value": "yes" }
116
+ ]
117
+ }
118
+ }
119
+ ```
120
+
121
+ - `action`: `"show"` or `"hide"`
122
+ - `logic`: `"and"` (all rules must match) or `"or"` (any rule matches)
123
+ - `source`: UUID of the component whose value is tested; rules may also set `sourceType: "context"` to test a key from FBRE's `context` prop instead of a component
124
+ - **19 operators**: `equals`, `notEquals`, `contains`, `notContains`, `startsWith`, `endsWith`, `isEmpty`, `isNotEmpty`, `greaterThan`, `greaterThanOrEqual`, `lessThan`, `lessThanOrEqual`, `isOneOf`, `isNotOneOf`, `includesAny`, `includesAll`, `includesNone`, `isTrue`, `isFalse`
125
+ - `value` field: required for most operators; omitted for `isEmpty`, `isNotEmpty`, `isTrue`, `isFalse`
126
+
127
+ ## Validation Format (FlowValidationConfig)
128
+
129
+ Placed at `component.properties.validation`:
130
+
131
+ ```json
132
+ {
133
+ "validation": {
134
+ "rules": [
135
+ { "type": "required" },
136
+ { "type": "email", "message": "Custom error message" },
137
+ { "type": "minLength", "params": { "min": 5 } }
138
+ ]
139
+ }
140
+ }
141
+ ```
142
+
143
+ **17 validators:**
144
+
145
+ | Type | Params | Description |
146
+ |------|--------|-------------|
147
+ | `required` | — | Field must have a value |
148
+ | `email` | — | Valid email format |
149
+ | `phone` | — | Valid phone format |
150
+ | `url` | — | Valid URL format |
151
+ | `minLength` | `{ min: number }` | Minimum character count |
152
+ | `maxLength` | `{ max: number }` | Maximum character count |
153
+ | `exactLength` | `{ length: number }` | Exact character count |
154
+ | `minValue` | `{ min: number }` | Minimum numeric value |
155
+ | `maxValue` | `{ max: number }` | Maximum numeric value |
156
+ | `pattern` | `{ regex: string }` | Regex pattern match — the param key is `regex`, **not** `pattern` (a `pattern` key is ignored and the rule silently always passes) |
157
+ | `minSelected` | `{ min: number }` | Minimum selected options (checkbox/multi-select) |
158
+ | `maxSelected` | `{ max: number }` | Maximum selected options |
159
+ | `fileType` | `{ types: string[] }` | Allowed MIME types |
160
+ | `fileSize` | `{ max: number }` | Max file size in bytes |
161
+ | `contains` | `{ text: string }` | Must contain substring |
162
+ | `excludes` | `{ text: string }` | Must not contain substring |
163
+ | `matchesField` | `{ field: string }` | Must match another component's value (by UUID) |
164
+
165
+ ## Width Values (ComponentWidth)
166
+
167
+ Set on `component.properties.width`:
168
+
169
+ | Value | CSS Width |
170
+ |-------|-----------|
171
+ | `"full"` (default) | `100%` |
172
+ | `"half"` | `~50%` |
173
+ | `"third"` | `~33.33%` |
174
+ | `"two-thirds"` | `~66.67%` |
175
+ | `"quarter"` | `~25%` |
176
+ | `"three-quarters"` | `~75%` |
177
+
178
+ Fractional widths are gap-adjusted `calc()` values (e.g. half is `calc(50% - gap/2)`). There is no global full-width collapse breakpoint; a few controls compact themselves at narrow container widths.
179
+
180
+ ## Inline Markup
181
+
182
+ `text` components and `detail` property fields support:
183
+ - `[b]bold[/b]` → **bold**
184
+ - `[i]italic[/i]` → *italic*
185
+ - `[l href="url"]link text[/l]` → hyperlink
186
+ - `[s size="sm|lg|xl"]sized text[/s]` → font-size span (12/18/24px)
187
+ - Newlines render as line breaks
188
+
189
+ Text-bearing fields (including the confirmation screen's `title`/`body`) also resolve `${uuid}` **references** against calculation results, component values, and FBRE's `context` prop, in that order.
190
+
191
+ ## Rules for Constructed Flows
192
+
193
+ - Use `{ label, value }` objects for `options` arrays, not bare strings
194
+ - Do not set runtime-only fields (`value`, `valid`, `addedComponents`) in Flow JSON — these are managed by FBRE at runtime
195
+ - Every `uuid` must be unique within the flow; condition `source` and validation `matchesField` reference components by uuid
196
+ - Validate against [`flow-schema.json`](flow-schema.json) (`npm run validate -- <file>` in this repo)