@json-render/react-native 0.5.1 → 0.6.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/README.md CHANGED
@@ -141,6 +141,10 @@ function App({ spec }) {
141
141
  | `ListItem` | List row with title, subtitle, accessory |
142
142
  | `Modal` | Bottom sheet modal |
143
143
 
144
+ ## Visibility Conditions
145
+
146
+ Elements can use `visible` to show/hide based on state. Same syntax as [@json-render/react](../react/README.md#visibility-conditions): `{ "$state": "/path" }`, `{ "$state": "/path", "eq": value }`, `{ "$state": "/path", "not": true }`, or `[ cond1, cond2 ]` for AND.
147
+
144
148
  ## Pressable Component
145
149
 
146
150
  The `Pressable` component wraps children and triggers an action on press. It's essential for building interactive UIs like tab bars:
@@ -150,7 +154,7 @@ The `Pressable` component wraps children and triggers an action on press. It's e
150
154
  "type": "Pressable",
151
155
  "props": {
152
156
  "action": "setState",
153
- "actionParams": { "path": "/activeTab", "value": "home" }
157
+ "actionParams": { "statePath": "/activeTab", "value": "home" }
154
158
  },
155
159
  "children": ["home-tab-icon", "home-tab-label"]
156
160
  }
@@ -163,7 +167,7 @@ The `setState` action is handled automatically by `ActionProvider`. It updates t
163
167
  ```json
164
168
  {
165
169
  "action": "setState",
166
- "actionParams": { "path": "/activeTab", "value": "home" }
170
+ "actionParams": { "statePath": "/activeTab", "value": "home" }
167
171
  }
168
172
  ```
169
173
 
@@ -176,12 +180,12 @@ Any prop value can be a dynamic expression resolved at render time:
176
180
  "type": "Icon",
177
181
  "props": {
178
182
  "name": {
179
- "$cond": { "eq": [{ "path": "/activeTab" }, "home"] },
183
+ "$cond": { "$state": "/activeTab", "eq": "home" },
180
184
  "$then": "home",
181
185
  "$else": "home-outline"
182
186
  },
183
187
  "color": {
184
- "$cond": { "eq": [{ "path": "/activeTab" }, "home"] },
188
+ "$cond": { "$state": "/activeTab", "eq": "home" },
185
189
  "$then": "#007AFF",
186
190
  "$else": "#8E8E93"
187
191
  }
@@ -195,9 +199,9 @@ See [@json-render/core](../core/README.md) for full expression syntax.
195
199
 
196
200
  Combine `Pressable`, `setState`, visibility conditions, and dynamic props for functional tabs:
197
201
 
198
- 1. Each tab button is a `Pressable` with `action: "setState"` and `actionParams: { path: "/activeTab", value: "tabName" }`
202
+ 1. Each tab button is a `Pressable` with `action: "setState"` and `actionParams: { statePath: "/activeTab", value: "tabName" }`
199
203
  2. Tab icons/labels use `$cond` dynamic props for active/inactive styling
200
- 3. Tab content sections use `visible` conditions: `{ "eq": [{ "path": "/activeTab" }, "tabName"] }`
204
+ 3. Tab content sections use `visible` conditions: `{ "$state": "/activeTab", "eq": "tabName" }`
201
205
 
202
206
  ## AI Prompt Generation
203
207
 
@@ -214,8 +218,8 @@ const systemPrompt = catalog.prompt({
214
218
 
215
219
  | Hook | Purpose |
216
220
  |------|---------|
217
- | `useStateStore()` | Access data context (`data`, `get`, `set`) |
218
- | `useStateValue(path)` | Get single value from data |
221
+ | `useStateStore()` | Access state context (`state`, `get`, `set`, `update`) |
222
+ | `useStateValue(path)` | Get single value from state |
219
223
  | `useStateBinding(path)` | Two-way data binding (returns `[value, setValue]`) |
220
224
  | `useVisibility()` | Access visibility evaluation |
221
225
  | `useIsVisible(condition)` | Check if condition is met |
@@ -19,6 +19,10 @@ declare const standardComponentDefinitions: {
19
19
  }, z.core.$strip>;
20
20
  slots: string[];
21
21
  description: string;
22
+ example: {
23
+ padding: number;
24
+ backgroundColor: string;
25
+ };
22
26
  };
23
27
  Row: {
24
28
  props: z.ZodObject<{
@@ -47,6 +51,10 @@ declare const standardComponentDefinitions: {
47
51
  }, z.core.$strip>;
48
52
  slots: string[];
49
53
  description: string;
54
+ example: {
55
+ gap: number;
56
+ alignItems: string;
57
+ };
50
58
  };
51
59
  Column: {
52
60
  props: z.ZodObject<{
@@ -71,6 +79,10 @@ declare const standardComponentDefinitions: {
71
79
  }, z.core.$strip>;
72
80
  slots: string[];
73
81
  description: string;
82
+ example: {
83
+ gap: number;
84
+ padding: number;
85
+ };
74
86
  };
75
87
  ScrollContainer: {
76
88
  props: z.ZodObject<{
@@ -134,6 +146,10 @@ declare const standardComponentDefinitions: {
134
146
  }, z.core.$strip>;
135
147
  slots: never[];
136
148
  description: string;
149
+ example: {
150
+ text: string;
151
+ level: string;
152
+ };
137
153
  };
138
154
  Paragraph: {
139
155
  props: z.ZodObject<{
@@ -149,6 +165,9 @@ declare const standardComponentDefinitions: {
149
165
  }, z.core.$strip>;
150
166
  slots: never[];
151
167
  description: string;
168
+ example: {
169
+ text: string;
170
+ };
152
171
  };
153
172
  Label: {
154
173
  props: z.ZodObject<{
@@ -163,6 +182,10 @@ declare const standardComponentDefinitions: {
163
182
  }, z.core.$strip>;
164
183
  slots: never[];
165
184
  description: string;
185
+ example: {
186
+ text: string;
187
+ size: string;
188
+ };
166
189
  };
167
190
  Image: {
168
191
  props: z.ZodObject<{
@@ -180,6 +203,12 @@ declare const standardComponentDefinitions: {
180
203
  }, z.core.$strip>;
181
204
  slots: never[];
182
205
  description: string;
206
+ example: {
207
+ src: string;
208
+ alt: string;
209
+ width: number;
210
+ height: number;
211
+ };
183
212
  };
184
213
  Avatar: {
185
214
  props: z.ZodObject<{
@@ -195,6 +224,10 @@ declare const standardComponentDefinitions: {
195
224
  }, z.core.$strip>;
196
225
  slots: never[];
197
226
  description: string;
227
+ example: {
228
+ initials: string;
229
+ size: string;
230
+ };
198
231
  };
199
232
  Badge: {
200
233
  props: z.ZodObject<{
@@ -209,6 +242,10 @@ declare const standardComponentDefinitions: {
209
242
  }, z.core.$strip>;
210
243
  slots: never[];
211
244
  description: string;
245
+ example: {
246
+ label: string;
247
+ variant: string;
248
+ };
212
249
  };
213
250
  Chip: {
214
251
  props: z.ZodObject<{
@@ -241,12 +278,15 @@ declare const standardComponentDefinitions: {
241
278
  events: string[];
242
279
  slots: never[];
243
280
  description: string;
281
+ example: {
282
+ label: string;
283
+ variant: string;
284
+ };
244
285
  };
245
286
  TextInput: {
246
287
  props: z.ZodObject<{
247
288
  placeholder: z.ZodNullable<z.ZodString>;
248
289
  value: z.ZodNullable<z.ZodString>;
249
- statePath: z.ZodNullable<z.ZodString>;
250
290
  secureTextEntry: z.ZodNullable<z.ZodBoolean>;
251
291
  keyboardType: z.ZodNullable<z.ZodEnum<{
252
292
  default: "default";
@@ -263,11 +303,14 @@ declare const standardComponentDefinitions: {
263
303
  events: string[];
264
304
  slots: never[];
265
305
  description: string;
306
+ example: {
307
+ placeholder: string;
308
+ label: string;
309
+ };
266
310
  };
267
311
  Switch: {
268
312
  props: z.ZodObject<{
269
- value: z.ZodNullable<z.ZodBoolean>;
270
- statePath: z.ZodNullable<z.ZodString>;
313
+ checked: z.ZodNullable<z.ZodBoolean>;
271
314
  label: z.ZodNullable<z.ZodString>;
272
315
  disabled: z.ZodNullable<z.ZodBoolean>;
273
316
  }, z.core.$strip>;
@@ -278,7 +321,6 @@ declare const standardComponentDefinitions: {
278
321
  Checkbox: {
279
322
  props: z.ZodObject<{
280
323
  checked: z.ZodNullable<z.ZodBoolean>;
281
- statePath: z.ZodNullable<z.ZodString>;
282
324
  label: z.ZodNullable<z.ZodString>;
283
325
  disabled: z.ZodNullable<z.ZodBoolean>;
284
326
  }, z.core.$strip>;
@@ -292,7 +334,6 @@ declare const standardComponentDefinitions: {
292
334
  max: z.ZodNullable<z.ZodNumber>;
293
335
  step: z.ZodNullable<z.ZodNumber>;
294
336
  value: z.ZodNullable<z.ZodNumber>;
295
- statePath: z.ZodNullable<z.ZodString>;
296
337
  label: z.ZodNullable<z.ZodString>;
297
338
  color: z.ZodNullable<z.ZodString>;
298
339
  }, z.core.$strip>;
@@ -303,7 +344,6 @@ declare const standardComponentDefinitions: {
303
344
  props: z.ZodObject<{
304
345
  placeholder: z.ZodNullable<z.ZodString>;
305
346
  value: z.ZodNullable<z.ZodString>;
306
- statePath: z.ZodNullable<z.ZodString>;
307
347
  }, z.core.$strip>;
308
348
  events: string[];
309
349
  slots: never[];
@@ -341,6 +381,11 @@ declare const standardComponentDefinitions: {
341
381
  }, z.core.$strip>;
342
382
  slots: string[];
343
383
  description: string;
384
+ example: {
385
+ title: string;
386
+ padding: number;
387
+ elevated: boolean;
388
+ };
344
389
  };
345
390
  ListItem: {
346
391
  props: z.ZodObject<{
@@ -353,6 +398,11 @@ declare const standardComponentDefinitions: {
353
398
  events: string[];
354
399
  slots: never[];
355
400
  description: string;
401
+ example: {
402
+ title: string;
403
+ subtitle: string;
404
+ showChevron: boolean;
405
+ };
356
406
  };
357
407
  Modal: {
358
408
  props: z.ZodObject<{
@@ -363,7 +413,6 @@ declare const standardComponentDefinitions: {
363
413
  fade: "fade";
364
414
  none: "none";
365
415
  }>>;
366
- statePath: z.ZodNullable<z.ZodString>;
367
416
  }, z.core.$strip>;
368
417
  slots: string[];
369
418
  description: string;
@@ -419,22 +468,22 @@ declare const standardActionDefinitions: {
419
468
  };
420
469
  setState: {
421
470
  params: z.ZodObject<{
422
- path: z.ZodString;
471
+ statePath: z.ZodString;
423
472
  value: z.ZodUnknown;
424
473
  }, z.core.$strip>;
425
474
  description: string;
426
475
  };
427
476
  pushState: {
428
477
  params: z.ZodObject<{
429
- path: z.ZodString;
478
+ statePath: z.ZodString;
430
479
  value: z.ZodUnknown;
431
- clearPath: z.ZodOptional<z.ZodString>;
480
+ clearStatePath: z.ZodOptional<z.ZodString>;
432
481
  }, z.core.$strip>;
433
482
  description: string;
434
483
  };
435
484
  removeState: {
436
485
  params: z.ZodObject<{
437
- path: z.ZodString;
486
+ statePath: z.ZodString;
438
487
  index: z.ZodNumber;
439
488
  }, z.core.$strip>;
440
489
  description: string;
package/dist/catalog.d.ts CHANGED
@@ -19,6 +19,10 @@ declare const standardComponentDefinitions: {
19
19
  }, z.core.$strip>;
20
20
  slots: string[];
21
21
  description: string;
22
+ example: {
23
+ padding: number;
24
+ backgroundColor: string;
25
+ };
22
26
  };
23
27
  Row: {
24
28
  props: z.ZodObject<{
@@ -47,6 +51,10 @@ declare const standardComponentDefinitions: {
47
51
  }, z.core.$strip>;
48
52
  slots: string[];
49
53
  description: string;
54
+ example: {
55
+ gap: number;
56
+ alignItems: string;
57
+ };
50
58
  };
51
59
  Column: {
52
60
  props: z.ZodObject<{
@@ -71,6 +79,10 @@ declare const standardComponentDefinitions: {
71
79
  }, z.core.$strip>;
72
80
  slots: string[];
73
81
  description: string;
82
+ example: {
83
+ gap: number;
84
+ padding: number;
85
+ };
74
86
  };
75
87
  ScrollContainer: {
76
88
  props: z.ZodObject<{
@@ -134,6 +146,10 @@ declare const standardComponentDefinitions: {
134
146
  }, z.core.$strip>;
135
147
  slots: never[];
136
148
  description: string;
149
+ example: {
150
+ text: string;
151
+ level: string;
152
+ };
137
153
  };
138
154
  Paragraph: {
139
155
  props: z.ZodObject<{
@@ -149,6 +165,9 @@ declare const standardComponentDefinitions: {
149
165
  }, z.core.$strip>;
150
166
  slots: never[];
151
167
  description: string;
168
+ example: {
169
+ text: string;
170
+ };
152
171
  };
153
172
  Label: {
154
173
  props: z.ZodObject<{
@@ -163,6 +182,10 @@ declare const standardComponentDefinitions: {
163
182
  }, z.core.$strip>;
164
183
  slots: never[];
165
184
  description: string;
185
+ example: {
186
+ text: string;
187
+ size: string;
188
+ };
166
189
  };
167
190
  Image: {
168
191
  props: z.ZodObject<{
@@ -180,6 +203,12 @@ declare const standardComponentDefinitions: {
180
203
  }, z.core.$strip>;
181
204
  slots: never[];
182
205
  description: string;
206
+ example: {
207
+ src: string;
208
+ alt: string;
209
+ width: number;
210
+ height: number;
211
+ };
183
212
  };
184
213
  Avatar: {
185
214
  props: z.ZodObject<{
@@ -195,6 +224,10 @@ declare const standardComponentDefinitions: {
195
224
  }, z.core.$strip>;
196
225
  slots: never[];
197
226
  description: string;
227
+ example: {
228
+ initials: string;
229
+ size: string;
230
+ };
198
231
  };
199
232
  Badge: {
200
233
  props: z.ZodObject<{
@@ -209,6 +242,10 @@ declare const standardComponentDefinitions: {
209
242
  }, z.core.$strip>;
210
243
  slots: never[];
211
244
  description: string;
245
+ example: {
246
+ label: string;
247
+ variant: string;
248
+ };
212
249
  };
213
250
  Chip: {
214
251
  props: z.ZodObject<{
@@ -241,12 +278,15 @@ declare const standardComponentDefinitions: {
241
278
  events: string[];
242
279
  slots: never[];
243
280
  description: string;
281
+ example: {
282
+ label: string;
283
+ variant: string;
284
+ };
244
285
  };
245
286
  TextInput: {
246
287
  props: z.ZodObject<{
247
288
  placeholder: z.ZodNullable<z.ZodString>;
248
289
  value: z.ZodNullable<z.ZodString>;
249
- statePath: z.ZodNullable<z.ZodString>;
250
290
  secureTextEntry: z.ZodNullable<z.ZodBoolean>;
251
291
  keyboardType: z.ZodNullable<z.ZodEnum<{
252
292
  default: "default";
@@ -263,11 +303,14 @@ declare const standardComponentDefinitions: {
263
303
  events: string[];
264
304
  slots: never[];
265
305
  description: string;
306
+ example: {
307
+ placeholder: string;
308
+ label: string;
309
+ };
266
310
  };
267
311
  Switch: {
268
312
  props: z.ZodObject<{
269
- value: z.ZodNullable<z.ZodBoolean>;
270
- statePath: z.ZodNullable<z.ZodString>;
313
+ checked: z.ZodNullable<z.ZodBoolean>;
271
314
  label: z.ZodNullable<z.ZodString>;
272
315
  disabled: z.ZodNullable<z.ZodBoolean>;
273
316
  }, z.core.$strip>;
@@ -278,7 +321,6 @@ declare const standardComponentDefinitions: {
278
321
  Checkbox: {
279
322
  props: z.ZodObject<{
280
323
  checked: z.ZodNullable<z.ZodBoolean>;
281
- statePath: z.ZodNullable<z.ZodString>;
282
324
  label: z.ZodNullable<z.ZodString>;
283
325
  disabled: z.ZodNullable<z.ZodBoolean>;
284
326
  }, z.core.$strip>;
@@ -292,7 +334,6 @@ declare const standardComponentDefinitions: {
292
334
  max: z.ZodNullable<z.ZodNumber>;
293
335
  step: z.ZodNullable<z.ZodNumber>;
294
336
  value: z.ZodNullable<z.ZodNumber>;
295
- statePath: z.ZodNullable<z.ZodString>;
296
337
  label: z.ZodNullable<z.ZodString>;
297
338
  color: z.ZodNullable<z.ZodString>;
298
339
  }, z.core.$strip>;
@@ -303,7 +344,6 @@ declare const standardComponentDefinitions: {
303
344
  props: z.ZodObject<{
304
345
  placeholder: z.ZodNullable<z.ZodString>;
305
346
  value: z.ZodNullable<z.ZodString>;
306
- statePath: z.ZodNullable<z.ZodString>;
307
347
  }, z.core.$strip>;
308
348
  events: string[];
309
349
  slots: never[];
@@ -341,6 +381,11 @@ declare const standardComponentDefinitions: {
341
381
  }, z.core.$strip>;
342
382
  slots: string[];
343
383
  description: string;
384
+ example: {
385
+ title: string;
386
+ padding: number;
387
+ elevated: boolean;
388
+ };
344
389
  };
345
390
  ListItem: {
346
391
  props: z.ZodObject<{
@@ -353,6 +398,11 @@ declare const standardComponentDefinitions: {
353
398
  events: string[];
354
399
  slots: never[];
355
400
  description: string;
401
+ example: {
402
+ title: string;
403
+ subtitle: string;
404
+ showChevron: boolean;
405
+ };
356
406
  };
357
407
  Modal: {
358
408
  props: z.ZodObject<{
@@ -363,7 +413,6 @@ declare const standardComponentDefinitions: {
363
413
  fade: "fade";
364
414
  none: "none";
365
415
  }>>;
366
- statePath: z.ZodNullable<z.ZodString>;
367
416
  }, z.core.$strip>;
368
417
  slots: string[];
369
418
  description: string;
@@ -419,22 +468,22 @@ declare const standardActionDefinitions: {
419
468
  };
420
469
  setState: {
421
470
  params: z.ZodObject<{
422
- path: z.ZodString;
471
+ statePath: z.ZodString;
423
472
  value: z.ZodUnknown;
424
473
  }, z.core.$strip>;
425
474
  description: string;
426
475
  };
427
476
  pushState: {
428
477
  params: z.ZodObject<{
429
- path: z.ZodString;
478
+ statePath: z.ZodString;
430
479
  value: z.ZodUnknown;
431
- clearPath: z.ZodOptional<z.ZodString>;
480
+ clearStatePath: z.ZodOptional<z.ZodString>;
432
481
  }, z.core.$strip>;
433
482
  description: string;
434
483
  };
435
484
  removeState: {
436
485
  params: z.ZodObject<{
437
- path: z.ZodString;
486
+ statePath: z.ZodString;
438
487
  index: z.ZodNumber;
439
488
  }, z.core.$strip>;
440
489
  description: string;