|
| 1 | +# Atomic Prop Values |
| 2 | + |
| 3 | +<Badge type="tip" vertical="top" text="Elementor Core" /> <Badge type="warning" vertical="top" text="Advanced" /> |
| 4 | + |
| 5 | +Atomic controls often save values as a small object: a `$$type` string plus a `value` payload. The props resolver uses `$$type` to match the schema (and union members), to recurse into nested object/array props, and to pick the **transformer** that receives `value` (after nested resolution) and returns frontend-ready data. An optional `disabled` flag is passed through on the transform context. |
| 6 | + |
| 7 | +## JSON Structure |
| 8 | + |
| 9 | +```json |
| 10 | +{ |
| 11 | + "$$type": "string", |
| 12 | + "value": "Hello" |
| 13 | +} |
| 14 | +``` |
| 15 | + |
| 16 | +## JSON Values |
| 17 | + |
| 18 | +| Argument | Type | Description | |
| 19 | +|----------|------------|-------------| |
| 20 | +| `$$type` | _`string`_ | Prop kind / transformer key; must match the prop type for that control (and selects the branch for union types). | |
| 21 | +| `value` | _varies_ | Input passed to the transformer for that `$$type`; may contain further `{ $$type, value }` objects when the prop is composite. | |
| 22 | + |
| 23 | +Allowed `$$type` values and the exact shape of `value` come from each widget’s schema in code. See [atomic widgets](./atomic-widgets.md) for how `settings` use these objects, and [atomic styles](./atomic-styles.md) for the same pattern inside style `variants[].props`. |
| 24 | + |
| 25 | +## Examples by structure |
| 26 | + |
| 27 | +The snippets below are trimmed from real document data. They highlight **shape**: whether `value` is a scalar, a sparse object, a nested tree of typed nodes, a homogeneous map, or a typed array—regardless of which widget or control produced them. Resolution still walks every nested `{ "$$type", "value" }` until the tree is plain JSON (strings, numbers, booleans, or `null`). Concrete `$$type` strings always come from the control schema in code. |
| 28 | + |
| 29 | +### Composite object (mixed typed fields and plain data) |
| 30 | + |
| 31 | +`value` is an object where **named keys** carry further typed props, plain arrays, or literals. One branch might be a full `{ "$$type", "value" }` while another stays a raw array or string. |
| 32 | + |
| 33 | +```json |
| 34 | +{ |
| 35 | + "$$type": "html-v3", |
| 36 | + "value": { |
| 37 | + "content": { |
| 38 | + "$$type": "string", |
| 39 | + "value": "My title" |
| 40 | + } |
| 41 | + } |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | + |
| 46 | +### Deep nesting (typed object inside typed object) |
| 47 | + |
| 48 | +The same sparse shell can grow a **chain** of wrappers: a key inside `value` is itself a typed object whose own `value` contains more typed leaves (here, internal targets resolved as id + label). |
| 49 | + |
| 50 | +```json |
| 51 | +{ |
| 52 | + "$$type": "link", |
| 53 | + "value": { |
| 54 | + "destination": { |
| 55 | + "$$type": "query", |
| 56 | + "value": { |
| 57 | + "id": { |
| 58 | + "$$type": "number", |
| 59 | + "value": 33514 |
| 60 | + }, |
| 61 | + "label": { |
| 62 | + "$$type": "string", |
| 63 | + "value": "About Us" |
| 64 | + } |
| 65 | + } |
| 66 | + }, |
| 67 | + "isTargetBlank": null |
| 68 | + } |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | +### Typed array of primitives |
| 73 | + |
| 74 | +`value` is an array at the top level; elements are **not** wrapped again unless the schema says so. Typical case: a list of stable ids referenced elsewhere (for example keys under `styles` on the element). |
| 75 | + |
| 76 | +```json |
| 77 | +{ |
| 78 | + "$$type": "classes", |
| 79 | + "value": ["e-132b96e-91b05d4"] |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | +### Composite object with a single nested typed subtree |
| 84 | + |
| 85 | +A flat-looking object whose fields are mostly **one** nested typed prop (plus room for more keys in other saves). |
| 86 | + |
| 87 | +```json |
| 88 | +{ |
| 89 | + "$$type": "background", |
| 90 | + "value": { |
| 91 | + "color": { |
| 92 | + "$$type": "color", |
| 93 | + "value": "#e8e8e8" |
| 94 | + } |
| 95 | + } |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +### Homogeneous map (same inner shape per key) |
| 100 | + |
| 101 | +`value` behaves like a **record**: several keys share the same structural pattern (here every side resolves through the same `size` shape). |
| 102 | + |
| 103 | +```json |
| 104 | +{ |
| 105 | + "$$type": "dimensions", |
| 106 | + "value": { |
| 107 | + "block-start": { |
| 108 | + "$$type": "size", |
| 109 | + "value": { |
| 110 | + "unit": "px", |
| 111 | + "size": 15 |
| 112 | + } |
| 113 | + }, |
| 114 | + "block-end": { |
| 115 | + "$$type": "size", |
| 116 | + "value": { |
| 117 | + "unit": "px", |
| 118 | + "size": 15 |
| 119 | + } |
| 120 | + }, |
| 121 | + "inline-start": { |
| 122 | + "$$type": "size", |
| 123 | + "value": { |
| 124 | + "unit": "px", |
| 125 | + "size": 5 |
| 126 | + } |
| 127 | + }, |
| 128 | + "inline-end": { |
| 129 | + "$$type": "size", |
| 130 | + "value": { |
| 131 | + "unit": "px", |
| 132 | + "size": 5 |
| 133 | + } |
| 134 | + } |
| 135 | + } |
| 136 | +} |
| 137 | +``` |
| 138 | + |
| 139 | +### Array of composite items |
| 140 | + |
| 141 | +`value` is an array whose **items** are full typed objects again—useful for ordered lists such as shadow layers. |
| 142 | + |
| 143 | +```json |
| 144 | +{ |
| 145 | + "$$type": "box-shadow", |
| 146 | + "value": [ |
| 147 | + { |
| 148 | + "$$type": "shadow", |
| 149 | + "value": { |
| 150 | + "hOffset": { |
| 151 | + "$$type": "size", |
| 152 | + "value": { |
| 153 | + "unit": "px", |
| 154 | + "size": 0 |
| 155 | + } |
| 156 | + }, |
| 157 | + "vOffset": { |
| 158 | + "$$type": "size", |
| 159 | + "value": { |
| 160 | + "unit": "px", |
| 161 | + "size": 0 |
| 162 | + } |
| 163 | + }, |
| 164 | + "blur": { |
| 165 | + "$$type": "size", |
| 166 | + "value": { |
| 167 | + "unit": "px", |
| 168 | + "size": 10 |
| 169 | + } |
| 170 | + }, |
| 171 | + "spread": { |
| 172 | + "$$type": "size", |
| 173 | + "value": { |
| 174 | + "unit": "px", |
| 175 | + "size": 0 |
| 176 | + } |
| 177 | + }, |
| 178 | + "color": { |
| 179 | + "$$type": "color", |
| 180 | + "value": "rgba(0, 0, 0, 0.75)" |
| 181 | + }, |
| 182 | + "position": null |
| 183 | + } |
| 184 | + } |
| 185 | + ] |
| 186 | +} |
| 187 | +``` |
| 188 | + |
0 commit comments