@json-render/react 0.0.1 → 0.2.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/LICENSE +201 -0
- package/README.md +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +42 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Vercel Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -145,7 +145,7 @@ interface ConfirmDialogProps {
|
|
|
145
145
|
/**
|
|
146
146
|
* Default confirmation dialog component
|
|
147
147
|
*/
|
|
148
|
-
declare function ConfirmDialog({ confirm, onConfirm, onCancel }: ConfirmDialogProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
declare function ConfirmDialog({ confirm, onConfirm, onCancel, }: ConfirmDialogProps): react_jsx_runtime.JSX.Element;
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
151
|
* Field validation state
|
|
@@ -273,7 +273,7 @@ declare function JSONUIProvider({ registry, initialData, authState, actionHandle
|
|
|
273
273
|
/**
|
|
274
274
|
* Helper to create a renderer component from a catalog
|
|
275
275
|
*/
|
|
276
|
-
declare function createRendererFromCatalog<C extends Catalog<Record<string, ComponentDefinition>>>(_catalog: C, registry: ComponentRegistry): ComponentType<Omit<RendererProps,
|
|
276
|
+
declare function createRendererFromCatalog<C extends Catalog<Record<string, ComponentDefinition>>>(_catalog: C, registry: ComponentRegistry): ComponentType<Omit<RendererProps, "registry">>;
|
|
277
277
|
|
|
278
278
|
/**
|
|
279
279
|
* Options for useUIStream
|
package/dist/index.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ interface ConfirmDialogProps {
|
|
|
145
145
|
/**
|
|
146
146
|
* Default confirmation dialog component
|
|
147
147
|
*/
|
|
148
|
-
declare function ConfirmDialog({ confirm, onConfirm, onCancel }: ConfirmDialogProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
declare function ConfirmDialog({ confirm, onConfirm, onCancel, }: ConfirmDialogProps): react_jsx_runtime.JSX.Element;
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
151
|
* Field validation state
|
|
@@ -273,7 +273,7 @@ declare function JSONUIProvider({ registry, initialData, authState, actionHandle
|
|
|
273
273
|
/**
|
|
274
274
|
* Helper to create a renderer component from a catalog
|
|
275
275
|
*/
|
|
276
|
-
declare function createRendererFromCatalog<C extends Catalog<Record<string, ComponentDefinition>>>(_catalog: C, registry: ComponentRegistry): ComponentType<Omit<RendererProps,
|
|
276
|
+
declare function createRendererFromCatalog<C extends Catalog<Record<string, ComponentDefinition>>>(_catalog: C, registry: ComponentRegistry): ComponentType<Omit<RendererProps, "registry">>;
|
|
277
277
|
|
|
278
278
|
/**
|
|
279
279
|
* Options for useUIStream
|
package/dist/index.js
CHANGED
|
@@ -64,10 +64,7 @@ function DataProvider({
|
|
|
64
64
|
children
|
|
65
65
|
}) {
|
|
66
66
|
const [data, setData] = (0, import_react.useState)(initialData);
|
|
67
|
-
const get = (0, import_react.useCallback)(
|
|
68
|
-
(path) => (0, import_core.getByPath)(data, path),
|
|
69
|
-
[data]
|
|
70
|
-
);
|
|
67
|
+
const get = (0, import_react.useCallback)((path) => (0, import_core.getByPath)(data, path), [data]);
|
|
71
68
|
const set = (0, import_react.useCallback)(
|
|
72
69
|
(path, value2) => {
|
|
73
70
|
setData((prev) => {
|
|
@@ -175,9 +172,12 @@ function ActionProvider({
|
|
|
175
172
|
const [handlers, setHandlers] = (0, import_react3.useState)(initialHandlers);
|
|
176
173
|
const [loadingActions, setLoadingActions] = (0, import_react3.useState)(/* @__PURE__ */ new Set());
|
|
177
174
|
const [pendingConfirmation, setPendingConfirmation] = (0, import_react3.useState)(null);
|
|
178
|
-
const registerHandler = (0, import_react3.useCallback)(
|
|
179
|
-
|
|
180
|
-
|
|
175
|
+
const registerHandler = (0, import_react3.useCallback)(
|
|
176
|
+
(name, handler) => {
|
|
177
|
+
setHandlers((prev) => ({ ...prev, [name]: handler }));
|
|
178
|
+
},
|
|
179
|
+
[]
|
|
180
|
+
);
|
|
181
181
|
const execute = (0, import_react3.useCallback)(
|
|
182
182
|
async (action) => {
|
|
183
183
|
const resolved = (0, import_core3.resolveAction)(action, data);
|
|
@@ -260,7 +260,15 @@ function ActionProvider({
|
|
|
260
260
|
cancel,
|
|
261
261
|
registerHandler
|
|
262
262
|
}),
|
|
263
|
-
[
|
|
263
|
+
[
|
|
264
|
+
handlers,
|
|
265
|
+
loadingActions,
|
|
266
|
+
pendingConfirmation,
|
|
267
|
+
execute,
|
|
268
|
+
confirm,
|
|
269
|
+
cancel,
|
|
270
|
+
registerHandler
|
|
271
|
+
]
|
|
264
272
|
);
|
|
265
273
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ActionContext.Provider, { value, children });
|
|
266
274
|
}
|
|
@@ -277,7 +285,11 @@ function useAction(action) {
|
|
|
277
285
|
const executeAction2 = (0, import_react3.useCallback)(() => execute(action), [execute, action]);
|
|
278
286
|
return { execute: executeAction2, isLoading };
|
|
279
287
|
}
|
|
280
|
-
function ConfirmDialog({
|
|
288
|
+
function ConfirmDialog({
|
|
289
|
+
confirm,
|
|
290
|
+
onConfirm,
|
|
291
|
+
onCancel
|
|
292
|
+
}) {
|
|
281
293
|
const isDanger = confirm.variant === "danger";
|
|
282
294
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
283
295
|
"div",
|
|
@@ -386,9 +398,12 @@ function ValidationProvider({
|
|
|
386
398
|
const { data, authState } = useData();
|
|
387
399
|
const [fieldStates, setFieldStates] = (0, import_react4.useState)({});
|
|
388
400
|
const [fieldConfigs, setFieldConfigs] = (0, import_react4.useState)({});
|
|
389
|
-
const registerField = (0, import_react4.useCallback)(
|
|
390
|
-
|
|
391
|
-
|
|
401
|
+
const registerField = (0, import_react4.useCallback)(
|
|
402
|
+
(path, config) => {
|
|
403
|
+
setFieldConfigs((prev) => ({ ...prev, [path]: config }));
|
|
404
|
+
},
|
|
405
|
+
[]
|
|
406
|
+
);
|
|
392
407
|
const validate = (0, import_react4.useCallback)(
|
|
393
408
|
(path, config) => {
|
|
394
409
|
const value2 = data[path.split("/").filter(Boolean).join(".")];
|
|
@@ -447,7 +462,15 @@ function ValidationProvider({
|
|
|
447
462
|
validateAll,
|
|
448
463
|
registerField
|
|
449
464
|
}),
|
|
450
|
-
[
|
|
465
|
+
[
|
|
466
|
+
customFunctions,
|
|
467
|
+
fieldStates,
|
|
468
|
+
validate,
|
|
469
|
+
touch,
|
|
470
|
+
clear,
|
|
471
|
+
validateAll,
|
|
472
|
+
registerField
|
|
473
|
+
]
|
|
451
474
|
);
|
|
452
475
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ValidationContext.Provider, { value, children });
|
|
453
476
|
}
|
|
@@ -528,15 +551,7 @@ function ElementRenderer({
|
|
|
528
551
|
childKey
|
|
529
552
|
);
|
|
530
553
|
});
|
|
531
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
532
|
-
Component,
|
|
533
|
-
{
|
|
534
|
-
element,
|
|
535
|
-
onAction: execute,
|
|
536
|
-
loading,
|
|
537
|
-
children
|
|
538
|
-
}
|
|
539
|
-
);
|
|
554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Component, { element, onAction: execute, loading, children });
|
|
540
555
|
}
|
|
541
556
|
function Renderer({ tree, registry, loading, fallback }) {
|
|
542
557
|
if (!tree || !tree.root) {
|
|
@@ -635,7 +650,11 @@ function applyPatch(tree, patch) {
|
|
|
635
650
|
if (element) {
|
|
636
651
|
const propPath = "/" + pathParts.slice(1).join("/");
|
|
637
652
|
const newElement = { ...element };
|
|
638
|
-
(0, import_core5.setByPath)(
|
|
653
|
+
(0, import_core5.setByPath)(
|
|
654
|
+
newElement,
|
|
655
|
+
propPath,
|
|
656
|
+
patch.value
|
|
657
|
+
);
|
|
639
658
|
newTree.elements[elementKey] = newElement;
|
|
640
659
|
}
|
|
641
660
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/contexts/data.tsx","../src/contexts/visibility.tsx","../src/contexts/actions.tsx","../src/contexts/validation.tsx","../src/renderer.tsx","../src/hooks.ts"],"sourcesContent":["// Contexts\nexport {\n DataProvider,\n useData,\n useDataValue,\n useDataBinding,\n type DataContextValue,\n type DataProviderProps,\n} from './contexts/data';\n\nexport {\n VisibilityProvider,\n useVisibility,\n useIsVisible,\n type VisibilityContextValue,\n type VisibilityProviderProps,\n} from './contexts/visibility';\n\nexport {\n ActionProvider,\n useActions,\n useAction,\n ConfirmDialog,\n type ActionContextValue,\n type ActionProviderProps,\n type PendingConfirmation,\n type ConfirmDialogProps,\n} from './contexts/actions';\n\nexport {\n ValidationProvider,\n useValidation,\n useFieldValidation,\n type ValidationContextValue,\n type ValidationProviderProps,\n type FieldValidationState,\n} from './contexts/validation';\n\n// Renderer\nexport {\n Renderer,\n JSONUIProvider,\n createRendererFromCatalog,\n type ComponentRenderProps,\n type ComponentRenderer,\n type ComponentRegistry,\n type RendererProps,\n type JSONUIProviderProps,\n} from './renderer';\n\n// Hooks\nexport {\n useUIStream,\n flatToTree,\n type UseUIStreamOptions,\n type UseUIStreamReturn,\n} from './hooks';\n","'use client';\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from 'react';\nimport {\n getByPath,\n setByPath,\n type DataModel,\n type AuthState,\n} from '@json-render/core';\n\n/**\n * Data context value\n */\nexport interface DataContextValue {\n /** The current data model */\n data: DataModel;\n /** Auth state for visibility evaluation */\n authState?: AuthState;\n /** Get a value by path */\n get: (path: string) => unknown;\n /** Set a value by path */\n set: (path: string, value: unknown) => void;\n /** Update multiple values at once */\n update: (updates: Record<string, unknown>) => void;\n}\n\nconst DataContext = createContext<DataContextValue | null>(null);\n\n/**\n * Props for DataProvider\n */\nexport interface DataProviderProps {\n /** Initial data model */\n initialData?: DataModel;\n /** Auth state */\n authState?: AuthState;\n /** Callback when data changes */\n onDataChange?: (path: string, value: unknown) => void;\n children: ReactNode;\n}\n\n/**\n * Provider for data model context\n */\nexport function DataProvider({\n initialData = {},\n authState,\n onDataChange,\n children,\n}: DataProviderProps) {\n const [data, setData] = useState<DataModel>(initialData);\n\n const get = useCallback(\n (path: string) => getByPath(data, path),\n [data]\n );\n\n const set = useCallback(\n (path: string, value: unknown) => {\n setData((prev) => {\n const next = { ...prev };\n setByPath(next, path, value);\n return next;\n });\n onDataChange?.(path, value);\n },\n [onDataChange]\n );\n\n const update = useCallback(\n (updates: Record<string, unknown>) => {\n setData((prev) => {\n const next = { ...prev };\n for (const [path, value] of Object.entries(updates)) {\n setByPath(next, path, value);\n onDataChange?.(path, value);\n }\n return next;\n });\n },\n [onDataChange]\n );\n\n const value = useMemo<DataContextValue>(\n () => ({\n data,\n authState,\n get,\n set,\n update,\n }),\n [data, authState, get, set, update]\n );\n\n return <DataContext.Provider value={value}>{children}</DataContext.Provider>;\n}\n\n/**\n * Hook to access the data context\n */\nexport function useData(): DataContextValue {\n const ctx = useContext(DataContext);\n if (!ctx) {\n throw new Error('useData must be used within a DataProvider');\n }\n return ctx;\n}\n\n/**\n * Hook to get a value from the data model\n */\nexport function useDataValue<T>(path: string): T | undefined {\n const { get } = useData();\n return get(path) as T | undefined;\n}\n\n/**\n * Hook to get and set a value from the data model (like useState)\n */\nexport function useDataBinding<T>(\n path: string\n): [T | undefined, (value: T) => void] {\n const { get, set } = useData();\n const value = get(path) as T | undefined;\n const setValue = useCallback(\n (newValue: T) => set(path, newValue),\n [path, set]\n );\n return [value, setValue];\n}\n","'use client';\n\nimport React, { createContext, useContext, useMemo, type ReactNode } from 'react';\nimport {\n evaluateVisibility,\n type VisibilityCondition,\n type VisibilityContext as CoreVisibilityContext,\n} from '@json-render/core';\nimport { useData } from './data';\n\n/**\n * Visibility context value\n */\nexport interface VisibilityContextValue {\n /** Evaluate a visibility condition */\n isVisible: (condition: VisibilityCondition | undefined) => boolean;\n /** The underlying visibility context */\n ctx: CoreVisibilityContext;\n}\n\nconst VisibilityContext = createContext<VisibilityContextValue | null>(null);\n\n/**\n * Props for VisibilityProvider\n */\nexport interface VisibilityProviderProps {\n children: ReactNode;\n}\n\n/**\n * Provider for visibility evaluation\n */\nexport function VisibilityProvider({ children }: VisibilityProviderProps) {\n const { data, authState } = useData();\n\n const ctx: CoreVisibilityContext = useMemo(\n () => ({\n dataModel: data,\n authState,\n }),\n [data, authState]\n );\n\n const isVisible = useMemo(\n () => (condition: VisibilityCondition | undefined) =>\n evaluateVisibility(condition, ctx),\n [ctx]\n );\n\n const value = useMemo<VisibilityContextValue>(\n () => ({ isVisible, ctx }),\n [isVisible, ctx]\n );\n\n return (\n <VisibilityContext.Provider value={value}>\n {children}\n </VisibilityContext.Provider>\n );\n}\n\n/**\n * Hook to access visibility evaluation\n */\nexport function useVisibility(): VisibilityContextValue {\n const ctx = useContext(VisibilityContext);\n if (!ctx) {\n throw new Error('useVisibility must be used within a VisibilityProvider');\n }\n return ctx;\n}\n\n/**\n * Hook to check if a condition is visible\n */\nexport function useIsVisible(condition: VisibilityCondition | undefined): boolean {\n const { isVisible } = useVisibility();\n return isVisible(condition);\n}\n","'use client';\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from 'react';\nimport {\n resolveAction,\n executeAction,\n type Action,\n type ActionHandler,\n type ActionConfirm,\n type ResolvedAction,\n} from '@json-render/core';\nimport { useData } from './data';\n\n/**\n * Pending confirmation state\n */\nexport interface PendingConfirmation {\n /** The resolved action */\n action: ResolvedAction;\n /** The action handler */\n handler: ActionHandler;\n /** Resolve callback */\n resolve: () => void;\n /** Reject callback */\n reject: () => void;\n}\n\n/**\n * Action context value\n */\nexport interface ActionContextValue {\n /** Registered action handlers */\n handlers: Record<string, ActionHandler>;\n /** Currently loading action names */\n loadingActions: Set<string>;\n /** Pending confirmation dialog */\n pendingConfirmation: PendingConfirmation | null;\n /** Execute an action */\n execute: (action: Action) => Promise<void>;\n /** Confirm the pending action */\n confirm: () => void;\n /** Cancel the pending action */\n cancel: () => void;\n /** Register an action handler */\n registerHandler: (name: string, handler: ActionHandler) => void;\n}\n\nconst ActionContext = createContext<ActionContextValue | null>(null);\n\n/**\n * Props for ActionProvider\n */\nexport interface ActionProviderProps {\n /** Initial action handlers */\n handlers?: Record<string, ActionHandler>;\n /** Navigation function */\n navigate?: (path: string) => void;\n children: ReactNode;\n}\n\n/**\n * Provider for action execution\n */\nexport function ActionProvider({\n handlers: initialHandlers = {},\n navigate,\n children,\n}: ActionProviderProps) {\n const { data, set } = useData();\n const [handlers, setHandlers] = useState<Record<string, ActionHandler>>(initialHandlers);\n const [loadingActions, setLoadingActions] = useState<Set<string>>(new Set());\n const [pendingConfirmation, setPendingConfirmation] = useState<PendingConfirmation | null>(null);\n\n const registerHandler = useCallback((name: string, handler: ActionHandler) => {\n setHandlers((prev) => ({ ...prev, [name]: handler }));\n }, []);\n\n const execute = useCallback(\n async (action: Action) => {\n const resolved = resolveAction(action, data);\n const handler = handlers[resolved.name];\n\n if (!handler) {\n console.warn(`No handler registered for action: ${resolved.name}`);\n return;\n }\n\n // If confirmation is required, show dialog\n if (resolved.confirm) {\n return new Promise<void>((resolve, reject) => {\n setPendingConfirmation({\n action: resolved,\n handler,\n resolve: () => {\n setPendingConfirmation(null);\n resolve();\n },\n reject: () => {\n setPendingConfirmation(null);\n reject(new Error('Action cancelled'));\n },\n });\n }).then(async () => {\n setLoadingActions((prev) => new Set(prev).add(resolved.name));\n try {\n await executeAction({\n action: resolved,\n handler,\n setData: set,\n navigate,\n executeAction: async (name) => {\n const subAction: Action = { name };\n await execute(subAction);\n },\n });\n } finally {\n setLoadingActions((prev) => {\n const next = new Set(prev);\n next.delete(resolved.name);\n return next;\n });\n }\n });\n }\n\n // Execute immediately\n setLoadingActions((prev) => new Set(prev).add(resolved.name));\n try {\n await executeAction({\n action: resolved,\n handler,\n setData: set,\n navigate,\n executeAction: async (name) => {\n const subAction: Action = { name };\n await execute(subAction);\n },\n });\n } finally {\n setLoadingActions((prev) => {\n const next = new Set(prev);\n next.delete(resolved.name);\n return next;\n });\n }\n },\n [data, handlers, set, navigate]\n );\n\n const confirm = useCallback(() => {\n pendingConfirmation?.resolve();\n }, [pendingConfirmation]);\n\n const cancel = useCallback(() => {\n pendingConfirmation?.reject();\n }, [pendingConfirmation]);\n\n const value = useMemo<ActionContextValue>(\n () => ({\n handlers,\n loadingActions,\n pendingConfirmation,\n execute,\n confirm,\n cancel,\n registerHandler,\n }),\n [handlers, loadingActions, pendingConfirmation, execute, confirm, cancel, registerHandler]\n );\n\n return (\n <ActionContext.Provider value={value}>{children}</ActionContext.Provider>\n );\n}\n\n/**\n * Hook to access action context\n */\nexport function useActions(): ActionContextValue {\n const ctx = useContext(ActionContext);\n if (!ctx) {\n throw new Error('useActions must be used within an ActionProvider');\n }\n return ctx;\n}\n\n/**\n * Hook to execute an action\n */\nexport function useAction(action: Action): {\n execute: () => Promise<void>;\n isLoading: boolean;\n} {\n const { execute, loadingActions } = useActions();\n const isLoading = loadingActions.has(action.name);\n\n const executeAction = useCallback(() => execute(action), [execute, action]);\n\n return { execute: executeAction, isLoading };\n}\n\n/**\n * Props for ConfirmDialog component\n */\nexport interface ConfirmDialogProps {\n /** The confirmation config */\n confirm: ActionConfirm;\n /** Called when confirmed */\n onConfirm: () => void;\n /** Called when cancelled */\n onCancel: () => void;\n}\n\n/**\n * Default confirmation dialog component\n */\nexport function ConfirmDialog({ confirm, onConfirm, onCancel }: ConfirmDialogProps) {\n const isDanger = confirm.variant === 'danger';\n\n return (\n <div\n style={{\n position: 'fixed',\n inset: 0,\n backgroundColor: 'rgba(0, 0, 0, 0.5)',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n zIndex: 50,\n }}\n onClick={onCancel}\n >\n <div\n style={{\n backgroundColor: 'white',\n borderRadius: '8px',\n padding: '24px',\n maxWidth: '400px',\n width: '100%',\n boxShadow: '0 20px 25px -5px rgba(0, 0, 0, 0.1)',\n }}\n onClick={(e) => e.stopPropagation()}\n >\n <h3\n style={{\n margin: '0 0 8px 0',\n fontSize: '18px',\n fontWeight: 600,\n }}\n >\n {confirm.title}\n </h3>\n <p\n style={{\n margin: '0 0 24px 0',\n color: '#6b7280',\n }}\n >\n {confirm.message}\n </p>\n <div\n style={{\n display: 'flex',\n gap: '12px',\n justifyContent: 'flex-end',\n }}\n >\n <button\n onClick={onCancel}\n style={{\n padding: '8px 16px',\n borderRadius: '6px',\n border: '1px solid #d1d5db',\n backgroundColor: 'white',\n cursor: 'pointer',\n }}\n >\n {confirm.cancelLabel ?? 'Cancel'}\n </button>\n <button\n onClick={onConfirm}\n style={{\n padding: '8px 16px',\n borderRadius: '6px',\n border: 'none',\n backgroundColor: isDanger ? '#dc2626' : '#3b82f6',\n color: 'white',\n cursor: 'pointer',\n }}\n >\n {confirm.confirmLabel ?? 'Confirm'}\n </button>\n </div>\n </div>\n </div>\n );\n}\n","'use client';\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from 'react';\nimport {\n runValidation,\n type ValidationConfig,\n type ValidationFunction,\n type ValidationResult,\n} from '@json-render/core';\nimport { useData } from './data';\n\n/**\n * Field validation state\n */\nexport interface FieldValidationState {\n /** Whether the field has been touched */\n touched: boolean;\n /** Whether the field has been validated */\n validated: boolean;\n /** Validation result */\n result: ValidationResult | null;\n}\n\n/**\n * Validation context value\n */\nexport interface ValidationContextValue {\n /** Custom validation functions from catalog */\n customFunctions: Record<string, ValidationFunction>;\n /** Validation state by field path */\n fieldStates: Record<string, FieldValidationState>;\n /** Validate a field */\n validate: (path: string, config: ValidationConfig) => ValidationResult;\n /** Mark field as touched */\n touch: (path: string) => void;\n /** Clear validation for a field */\n clear: (path: string) => void;\n /** Validate all fields */\n validateAll: () => boolean;\n /** Register field config */\n registerField: (path: string, config: ValidationConfig) => void;\n}\n\nconst ValidationContext = createContext<ValidationContextValue | null>(null);\n\n/**\n * Props for ValidationProvider\n */\nexport interface ValidationProviderProps {\n /** Custom validation functions from catalog */\n customFunctions?: Record<string, ValidationFunction>;\n children: ReactNode;\n}\n\n/**\n * Provider for validation\n */\nexport function ValidationProvider({\n customFunctions = {},\n children,\n}: ValidationProviderProps) {\n const { data, authState } = useData();\n const [fieldStates, setFieldStates] = useState<Record<string, FieldValidationState>>({});\n const [fieldConfigs, setFieldConfigs] = useState<Record<string, ValidationConfig>>({});\n\n const registerField = useCallback((path: string, config: ValidationConfig) => {\n setFieldConfigs((prev) => ({ ...prev, [path]: config }));\n }, []);\n\n const validate = useCallback(\n (path: string, config: ValidationConfig): ValidationResult => {\n const value = data[path.split('/').filter(Boolean).join('.')];\n const result = runValidation(config, {\n value,\n dataModel: data,\n customFunctions,\n authState,\n });\n\n setFieldStates((prev) => ({\n ...prev,\n [path]: {\n touched: prev[path]?.touched ?? true,\n validated: true,\n result,\n },\n }));\n\n return result;\n },\n [data, customFunctions, authState]\n );\n\n const touch = useCallback((path: string) => {\n setFieldStates((prev) => ({\n ...prev,\n [path]: {\n ...prev[path],\n touched: true,\n validated: prev[path]?.validated ?? false,\n result: prev[path]?.result ?? null,\n },\n }));\n }, []);\n\n const clear = useCallback((path: string) => {\n setFieldStates((prev) => {\n const { [path]: _, ...rest } = prev;\n return rest;\n });\n }, []);\n\n const validateAll = useCallback(() => {\n let allValid = true;\n\n for (const [path, config] of Object.entries(fieldConfigs)) {\n const result = validate(path, config);\n if (!result.valid) {\n allValid = false;\n }\n }\n\n return allValid;\n }, [fieldConfigs, validate]);\n\n const value = useMemo<ValidationContextValue>(\n () => ({\n customFunctions,\n fieldStates,\n validate,\n touch,\n clear,\n validateAll,\n registerField,\n }),\n [customFunctions, fieldStates, validate, touch, clear, validateAll, registerField]\n );\n\n return (\n <ValidationContext.Provider value={value}>\n {children}\n </ValidationContext.Provider>\n );\n}\n\n/**\n * Hook to access validation context\n */\nexport function useValidation(): ValidationContextValue {\n const ctx = useContext(ValidationContext);\n if (!ctx) {\n throw new Error('useValidation must be used within a ValidationProvider');\n }\n return ctx;\n}\n\n/**\n * Hook to get validation state for a field\n */\nexport function useFieldValidation(\n path: string,\n config?: ValidationConfig\n): {\n state: FieldValidationState;\n validate: () => ValidationResult;\n touch: () => void;\n clear: () => void;\n errors: string[];\n isValid: boolean;\n} {\n const {\n fieldStates,\n validate: validateField,\n touch: touchField,\n clear: clearField,\n registerField,\n } = useValidation();\n\n // Register field on mount\n React.useEffect(() => {\n if (config) {\n registerField(path, config);\n }\n }, [path, config, registerField]);\n\n const state = fieldStates[path] ?? {\n touched: false,\n validated: false,\n result: null,\n };\n\n const validate = useCallback(\n () => validateField(path, config ?? { checks: [] }),\n [path, config, validateField]\n );\n\n const touch = useCallback(() => touchField(path), [path, touchField]);\n const clear = useCallback(() => clearField(path), [path, clearField]);\n\n return {\n state,\n validate,\n touch,\n clear,\n errors: state.result?.errors ?? [],\n isValid: state.result?.valid ?? true,\n };\n}\n","'use client';\n\nimport React, { type ComponentType, type ReactNode, useMemo } from 'react';\nimport type { UIElement, UITree, Action, Catalog, ComponentDefinition } from '@json-render/core';\nimport { useIsVisible } from './contexts/visibility';\nimport { useActions } from './contexts/actions';\nimport { useData } from './contexts/data';\n\n/**\n * Props passed to component renderers\n */\nexport interface ComponentRenderProps<P = Record<string, unknown>> {\n /** The element being rendered */\n element: UIElement<string, P>;\n /** Rendered children */\n children?: ReactNode;\n /** Execute an action */\n onAction?: (action: Action) => void;\n /** Whether the parent is loading */\n loading?: boolean;\n}\n\n/**\n * Component renderer type\n */\nexport type ComponentRenderer<P = Record<string, unknown>> = ComponentType<ComponentRenderProps<P>>;\n\n/**\n * Registry of component renderers\n */\nexport type ComponentRegistry = Record<string, ComponentRenderer<any>>;\n\n/**\n * Props for the Renderer component\n */\nexport interface RendererProps {\n /** The UI tree to render */\n tree: UITree | null;\n /** Component registry */\n registry: ComponentRegistry;\n /** Whether the tree is currently loading/streaming */\n loading?: boolean;\n /** Fallback component for unknown types */\n fallback?: ComponentRenderer;\n}\n\n/**\n * Element renderer component\n */\nfunction ElementRenderer({\n element,\n tree,\n registry,\n loading,\n fallback,\n}: {\n element: UIElement;\n tree: UITree;\n registry: ComponentRegistry;\n loading?: boolean;\n fallback?: ComponentRenderer;\n}) {\n const isVisible = useIsVisible(element.visible);\n const { execute } = useActions();\n\n // Don't render if not visible\n if (!isVisible) {\n return null;\n }\n\n // Get the component renderer\n const Component = registry[element.type] ?? fallback;\n\n if (!Component) {\n console.warn(`No renderer for component type: ${element.type}`);\n return null;\n }\n\n // Render children\n const children = element.children?.map((childKey) => {\n const childElement = tree.elements[childKey];\n if (!childElement) {\n return null;\n }\n return (\n <ElementRenderer\n key={childKey}\n element={childElement}\n tree={tree}\n registry={registry}\n loading={loading}\n fallback={fallback}\n />\n );\n });\n\n return (\n <Component\n element={element}\n onAction={execute}\n loading={loading}\n >\n {children}\n </Component>\n );\n}\n\n/**\n * Main renderer component\n */\nexport function Renderer({ tree, registry, loading, fallback }: RendererProps) {\n if (!tree || !tree.root) {\n return null;\n }\n\n const rootElement = tree.elements[tree.root];\n if (!rootElement) {\n return null;\n }\n\n return (\n <ElementRenderer\n element={rootElement}\n tree={tree}\n registry={registry}\n loading={loading}\n fallback={fallback}\n />\n );\n}\n\n/**\n * Props for JSONUIProvider\n */\nexport interface JSONUIProviderProps {\n /** Component registry */\n registry: ComponentRegistry;\n /** Initial data model */\n initialData?: Record<string, unknown>;\n /** Auth state */\n authState?: { isSignedIn: boolean; user?: Record<string, unknown> };\n /** Action handlers */\n actionHandlers?: Record<string, (params: Record<string, unknown>) => Promise<unknown> | unknown>;\n /** Navigation function */\n navigate?: (path: string) => void;\n /** Custom validation functions */\n validationFunctions?: Record<string, (value: unknown, args?: Record<string, unknown>) => boolean>;\n /** Callback when data changes */\n onDataChange?: (path: string, value: unknown) => void;\n children: ReactNode;\n}\n\n// Import the providers\nimport { DataProvider } from './contexts/data';\nimport { VisibilityProvider } from './contexts/visibility';\nimport { ActionProvider } from './contexts/actions';\nimport { ValidationProvider } from './contexts/validation';\nimport { ConfirmDialog } from './contexts/actions';\n\n/**\n * Combined provider for all JSONUI contexts\n */\nexport function JSONUIProvider({\n registry,\n initialData,\n authState,\n actionHandlers,\n navigate,\n validationFunctions,\n onDataChange,\n children,\n}: JSONUIProviderProps) {\n return (\n <DataProvider\n initialData={initialData}\n authState={authState}\n onDataChange={onDataChange}\n >\n <VisibilityProvider>\n <ActionProvider handlers={actionHandlers} navigate={navigate}>\n <ValidationProvider customFunctions={validationFunctions}>\n {children}\n <ConfirmationDialogManager />\n </ValidationProvider>\n </ActionProvider>\n </VisibilityProvider>\n </DataProvider>\n );\n}\n\n/**\n * Renders the confirmation dialog when needed\n */\nfunction ConfirmationDialogManager() {\n const { pendingConfirmation, confirm, cancel } = useActions();\n\n if (!pendingConfirmation?.action.confirm) {\n return null;\n }\n\n return (\n <ConfirmDialog\n confirm={pendingConfirmation.action.confirm}\n onConfirm={confirm}\n onCancel={cancel}\n />\n );\n}\n\n/**\n * Helper to create a renderer component from a catalog\n */\nexport function createRendererFromCatalog<\n C extends Catalog<Record<string, ComponentDefinition>>\n>(\n _catalog: C,\n registry: ComponentRegistry\n): ComponentType<Omit<RendererProps, 'registry'>> {\n return function CatalogRenderer(props: Omit<RendererProps, 'registry'>) {\n return <Renderer {...props} registry={registry} />;\n };\n}\n","'use client';\n\nimport { useState, useCallback, useRef, useEffect } from 'react';\nimport type { UITree, UIElement, JsonPatch } from '@json-render/core';\nimport { setByPath } from '@json-render/core';\n\n/**\n * Parse a single JSON patch line\n */\nfunction parsePatchLine(line: string): JsonPatch | null {\n try {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('//')) {\n return null;\n }\n return JSON.parse(trimmed) as JsonPatch;\n } catch {\n return null;\n }\n}\n\n/**\n * Apply a JSON patch to the current tree\n */\nfunction applyPatch(tree: UITree, patch: JsonPatch): UITree {\n const newTree = { ...tree, elements: { ...tree.elements } };\n\n switch (patch.op) {\n case 'set':\n case 'add':\n case 'replace': {\n // Handle root path\n if (patch.path === '/root') {\n newTree.root = patch.value as string;\n return newTree;\n }\n\n // Handle elements paths\n if (patch.path.startsWith('/elements/')) {\n const pathParts = patch.path.slice('/elements/'.length).split('/');\n const elementKey = pathParts[0];\n\n if (!elementKey) return newTree;\n\n if (pathParts.length === 1) {\n // Setting entire element\n newTree.elements[elementKey] = patch.value as UIElement;\n } else {\n // Setting property of element\n const element = newTree.elements[elementKey];\n if (element) {\n const propPath = '/' + pathParts.slice(1).join('/');\n const newElement = { ...element };\n setByPath(newElement as unknown as Record<string, unknown>, propPath, patch.value);\n newTree.elements[elementKey] = newElement;\n }\n }\n }\n break;\n }\n case 'remove': {\n if (patch.path.startsWith('/elements/')) {\n const elementKey = patch.path.slice('/elements/'.length).split('/')[0];\n if (elementKey) {\n const { [elementKey]: _, ...rest } = newTree.elements;\n newTree.elements = rest;\n }\n }\n break;\n }\n }\n\n return newTree;\n}\n\n/**\n * Options for useUIStream\n */\nexport interface UseUIStreamOptions {\n /** API endpoint */\n api: string;\n /** Callback when complete */\n onComplete?: (tree: UITree) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n}\n\n/**\n * Return type for useUIStream\n */\nexport interface UseUIStreamReturn {\n /** Current UI tree */\n tree: UITree | null;\n /** Whether currently streaming */\n isStreaming: boolean;\n /** Error if any */\n error: Error | null;\n /** Send a prompt to generate UI */\n send: (prompt: string, context?: Record<string, unknown>) => Promise<void>;\n /** Clear the current tree */\n clear: () => void;\n}\n\n/**\n * Hook for streaming UI generation\n */\nexport function useUIStream({\n api,\n onComplete,\n onError,\n}: UseUIStreamOptions): UseUIStreamReturn {\n const [tree, setTree] = useState<UITree | null>(null);\n const [isStreaming, setIsStreaming] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const clear = useCallback(() => {\n setTree(null);\n setError(null);\n }, []);\n\n const send = useCallback(\n async (prompt: string, context?: Record<string, unknown>) => {\n // Abort any existing request\n abortControllerRef.current?.abort();\n abortControllerRef.current = new AbortController();\n\n setIsStreaming(true);\n setError(null);\n\n // Start with an empty tree\n let currentTree: UITree = { root: '', elements: {} };\n setTree(currentTree);\n\n try {\n const response = await fetch(api, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n prompt,\n context,\n currentTree,\n }),\n signal: abortControllerRef.current.signal,\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error: ${response.status}`);\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error('No response body');\n }\n\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n\n // Process complete lines\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n const patch = parsePatchLine(line);\n if (patch) {\n currentTree = applyPatch(currentTree, patch);\n setTree({ ...currentTree });\n }\n }\n }\n\n // Process any remaining buffer\n if (buffer.trim()) {\n const patch = parsePatchLine(buffer);\n if (patch) {\n currentTree = applyPatch(currentTree, patch);\n setTree({ ...currentTree });\n }\n }\n\n onComplete?.(currentTree);\n } catch (err) {\n if ((err as Error).name === 'AbortError') {\n return;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n setError(error);\n onError?.(error);\n } finally {\n setIsStreaming(false);\n }\n },\n [api, onComplete, onError]\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n abortControllerRef.current?.abort();\n };\n }, []);\n\n return {\n tree,\n isStreaming,\n error,\n send,\n clear,\n };\n}\n\n/**\n * Convert a flat element list to a UITree\n */\nexport function flatToTree(\n elements: Array<UIElement & { parentKey?: string | null }>\n): UITree {\n const elementMap: Record<string, UIElement> = {};\n let root = '';\n\n // First pass: add all elements to map\n for (const element of elements) {\n elementMap[element.key] = {\n key: element.key,\n type: element.type,\n props: element.props,\n children: [],\n visible: element.visible,\n };\n }\n\n // Second pass: build parent-child relationships\n for (const element of elements) {\n if (element.parentKey) {\n const parent = elementMap[element.parentKey];\n if (parent) {\n if (!parent.children) {\n parent.children = [];\n }\n parent.children.push(element.key);\n }\n } else {\n root = element.key;\n }\n }\n\n return { root, elements: elementMap };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAOO;AACP,kBAKO;AAsFE;AApET,IAAM,kBAAc,4BAAuC,IAAI;AAkBxD,SAAS,aAAa;AAAA,EAC3B,cAAc,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AACF,GAAsB;AACpB,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAoB,WAAW;AAEvD,QAAM,UAAM;AAAA,IACV,CAAC,aAAiB,uBAAU,MAAM,IAAI;AAAA,IACtC,CAAC,IAAI;AAAA,EACP;AAEA,QAAM,UAAM;AAAA,IACV,CAAC,MAAcA,WAAmB;AAChC,cAAQ,CAAC,SAAS;AAChB,cAAM,OAAO,EAAE,GAAG,KAAK;AACvB,mCAAU,MAAM,MAAMA,MAAK;AAC3B,eAAO;AAAA,MACT,CAAC;AACD,qBAAe,MAAMA,MAAK;AAAA,IAC5B;AAAA,IACA,CAAC,YAAY;AAAA,EACf;AAEA,QAAM,aAAS;AAAA,IACb,CA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AA,QACrB;AACA,eAAO,SAAS,KAAK,QAAQ,GAAG;AAAA,MAClC;AAAA,IACF,OAAO;AACL,aAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AAEA,SAAO,EAAE,MAAM,UAAU,WAAW;AACtC;","names":["value","import_react","import_core","import_jsx_runtime","import_react","import_core","import_jsx_runtime","executeAction","import_react","import_core","import_jsx_runtime","value","React","import_jsx_runtime","import_react","import_core","error"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/contexts/data.tsx","../src/contexts/visibility.tsx","../src/contexts/actions.tsx","../src/contexts/validation.tsx","../src/renderer.tsx","../src/hooks.ts"],"sourcesContent":["// Contexts\nexport {\n DataProvider,\n useData,\n useDataValue,\n useDataBinding,\n type DataContextValue,\n type DataProviderProps,\n} from \"./contexts/data\";\n\nexport {\n VisibilityProvider,\n useVisibility,\n useIsVisible,\n type VisibilityContextValue,\n type VisibilityProviderProps,\n} from \"./contexts/visibility\";\n\nexport {\n ActionProvider,\n useActions,\n useAction,\n ConfirmDialog,\n type ActionContextValue,\n type ActionProviderProps,\n type PendingConfirmation,\n type ConfirmDialogProps,\n} from \"./contexts/actions\";\n\nexport {\n ValidationProvider,\n useValidation,\n useFieldValidation,\n type ValidationContextValue,\n type ValidationProviderProps,\n type FieldValidationState,\n} from \"./contexts/validation\";\n\n// Renderer\nexport {\n Renderer,\n JSONUIProvider,\n createRendererFromCatalog,\n type ComponentRenderProps,\n type ComponentRenderer,\n type ComponentRegistry,\n type RendererProps,\n type JSONUIProviderProps,\n} from \"./renderer\";\n\n// Hooks\nexport {\n useUIStream,\n flatToTree,\n type UseUIStreamOptions,\n type UseUIStreamReturn,\n} from \"./hooks\";\n","\"use client\";\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport {\n getByPath,\n setByPath,\n type DataModel,\n type AuthState,\n} from \"@json-render/core\";\n\n/**\n * Data context value\n */\nexport interface DataContextValue {\n /** The current data model */\n data: DataModel;\n /** Auth state for visibility evaluation */\n authState?: AuthState;\n /** Get a value by path */\n get: (path: string) => unknown;\n /** Set a value by path */\n set: (path: string, value: unknown) => void;\n /** Update multiple values at once */\n update: (updates: Record<string, unknown>) => void;\n}\n\nconst DataContext = createContext<DataContextValue | null>(null);\n\n/**\n * Props for DataProvider\n */\nexport interface DataProviderProps {\n /** Initial data model */\n initialData?: DataModel;\n /** Auth state */\n authState?: AuthState;\n /** Callback when data changes */\n onDataChange?: (path: string, value: unknown) => void;\n children: ReactNode;\n}\n\n/**\n * Provider for data model context\n */\nexport function DataProvider({\n initialData = {},\n authState,\n onDataChange,\n children,\n}: DataProviderProps) {\n const [data, setData] = useState<DataModel>(initialData);\n\n const get = useCallback((path: string) => getByPath(data, path), [data]);\n\n const set = useCallback(\n (path: string, value: unknown) => {\n setData((prev) => {\n const next = { ...prev };\n setByPath(next, path, value);\n return next;\n });\n onDataChange?.(path, value);\n },\n [onDataChange],\n );\n\n const update = useCallback(\n (updates: Record<string, unknown>) => {\n setData((prev) => {\n const next = { ...prev };\n for (const [path, value] of Object.entries(updates)) {\n setByPath(next, path, value);\n onDataChange?.(path, value);\n }\n return next;\n });\n },\n [onDataChange],\n );\n\n const value = useMemo<DataContextValue>(\n () => ({\n data,\n authState,\n get,\n set,\n update,\n }),\n [data, authState, get, set, update],\n );\n\n return <DataContext.Provider value={value}>{children}</DataContext.Provider>;\n}\n\n/**\n * Hook to access the data context\n */\nexport function useData(): DataContextValue {\n const ctx = useContext(DataContext);\n if (!ctx) {\n throw new Error(\"useData must be used within a DataProvider\");\n }\n return ctx;\n}\n\n/**\n * Hook to get a value from the data model\n */\nexport function useDataValue<T>(path: string): T | undefined {\n const { get } = useData();\n return get(path) as T | undefined;\n}\n\n/**\n * Hook to get and set a value from the data model (like useState)\n */\nexport function useDataBinding<T>(\n path: string,\n): [T | undefined, (value: T) => void] {\n const { get, set } = useData();\n const value = get(path) as T | undefined;\n const setValue = useCallback(\n (newValue: T) => set(path, newValue),\n [path, set],\n );\n return [value, setValue];\n}\n","\"use client\";\n\nimport React, {\n createContext,\n useContext,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport {\n evaluateVisibility,\n type VisibilityCondition,\n type VisibilityContext as CoreVisibilityContext,\n} from \"@json-render/core\";\nimport { useData } from \"./data\";\n\n/**\n * Visibility context value\n */\nexport interface VisibilityContextValue {\n /** Evaluate a visibility condition */\n isVisible: (condition: VisibilityCondition | undefined) => boolean;\n /** The underlying visibility context */\n ctx: CoreVisibilityContext;\n}\n\nconst VisibilityContext = createContext<VisibilityContextValue | null>(null);\n\n/**\n * Props for VisibilityProvider\n */\nexport interface VisibilityProviderProps {\n children: ReactNode;\n}\n\n/**\n * Provider for visibility evaluation\n */\nexport function VisibilityProvider({ children }: VisibilityProviderProps) {\n const { data, authState } = useData();\n\n const ctx: CoreVisibilityContext = useMemo(\n () => ({\n dataModel: data,\n authState,\n }),\n [data, authState],\n );\n\n const isVisible = useMemo(\n () => (condition: VisibilityCondition | undefined) =>\n evaluateVisibility(condition, ctx),\n [ctx],\n );\n\n const value = useMemo<VisibilityContextValue>(\n () => ({ isVisible, ctx }),\n [isVisible, ctx],\n );\n\n return (\n <VisibilityContext.Provider value={value}>\n {children}\n </VisibilityContext.Provider>\n );\n}\n\n/**\n * Hook to access visibility evaluation\n */\nexport function useVisibility(): VisibilityContextValue {\n const ctx = useContext(VisibilityContext);\n if (!ctx) {\n throw new Error(\"useVisibility must be used within a VisibilityProvider\");\n }\n return ctx;\n}\n\n/**\n * Hook to check if a condition is visible\n */\nexport function useIsVisible(\n condition: VisibilityCondition | undefined,\n): boolean {\n const { isVisible } = useVisibility();\n return isVisible(condition);\n}\n","\"use client\";\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport {\n resolveAction,\n executeAction,\n type Action,\n type ActionHandler,\n type ActionConfirm,\n type ResolvedAction,\n} from \"@json-render/core\";\nimport { useData } from \"./data\";\n\n/**\n * Pending confirmation state\n */\nexport interface PendingConfirmation {\n /** The resolved action */\n action: ResolvedAction;\n /** The action handler */\n handler: ActionHandler;\n /** Resolve callback */\n resolve: () => void;\n /** Reject callback */\n reject: () => void;\n}\n\n/**\n * Action context value\n */\nexport interface ActionContextValue {\n /** Registered action handlers */\n handlers: Record<string, ActionHandler>;\n /** Currently loading action names */\n loadingActions: Set<string>;\n /** Pending confirmation dialog */\n pendingConfirmation: PendingConfirmation | null;\n /** Execute an action */\n execute: (action: Action) => Promise<void>;\n /** Confirm the pending action */\n confirm: () => void;\n /** Cancel the pending action */\n cancel: () => void;\n /** Register an action handler */\n registerHandler: (name: string, handler: ActionHandler) => void;\n}\n\nconst ActionContext = createContext<ActionContextValue | null>(null);\n\n/**\n * Props for ActionProvider\n */\nexport interface ActionProviderProps {\n /** Initial action handlers */\n handlers?: Record<string, ActionHandler>;\n /** Navigation function */\n navigate?: (path: string) => void;\n children: ReactNode;\n}\n\n/**\n * Provider for action execution\n */\nexport function ActionProvider({\n handlers: initialHandlers = {},\n navigate,\n children,\n}: ActionProviderProps) {\n const { data, set } = useData();\n const [handlers, setHandlers] =\n useState<Record<string, ActionHandler>>(initialHandlers);\n const [loadingActions, setLoadingActions] = useState<Set<string>>(new Set());\n const [pendingConfirmation, setPendingConfirmation] =\n useState<PendingConfirmation | null>(null);\n\n const registerHandler = useCallback(\n (name: string, handler: ActionHandler) => {\n setHandlers((prev) => ({ ...prev, [name]: handler }));\n },\n [],\n );\n\n const execute = useCallback(\n async (action: Action) => {\n const resolved = resolveAction(action, data);\n const handler = handlers[resolved.name];\n\n if (!handler) {\n console.warn(`No handler registered for action: ${resolved.name}`);\n return;\n }\n\n // If confirmation is required, show dialog\n if (resolved.confirm) {\n return new Promise<void>((resolve, reject) => {\n setPendingConfirmation({\n action: resolved,\n handler,\n resolve: () => {\n setPendingConfirmation(null);\n resolve();\n },\n reject: () => {\n setPendingConfirmation(null);\n reject(new Error(\"Action cancelled\"));\n },\n });\n }).then(async () => {\n setLoadingActions((prev) => new Set(prev).add(resolved.name));\n try {\n await executeAction({\n action: resolved,\n handler,\n setData: set,\n navigate,\n executeAction: async (name) => {\n const subAction: Action = { name };\n await execute(subAction);\n },\n });\n } finally {\n setLoadingActions((prev) => {\n const next = new Set(prev);\n next.delete(resolved.name);\n return next;\n });\n }\n });\n }\n\n // Execute immediately\n setLoadingActions((prev) => new Set(prev).add(resolved.name));\n try {\n await executeAction({\n action: resolved,\n handler,\n setData: set,\n navigate,\n executeAction: async (name) => {\n const subAction: Action = { name };\n await execute(subAction);\n },\n });\n } finally {\n setLoadingActions((prev) => {\n const next = new Set(prev);\n next.delete(resolved.name);\n return next;\n });\n }\n },\n [data, handlers, set, navigate],\n );\n\n const confirm = useCallback(() => {\n pendingConfirmation?.resolve();\n }, [pendingConfirmation]);\n\n const cancel = useCallback(() => {\n pendingConfirmation?.reject();\n }, [pendingConfirmation]);\n\n const value = useMemo<ActionContextValue>(\n () => ({\n handlers,\n loadingActions,\n pendingConfirmation,\n execute,\n confirm,\n cancel,\n registerHandler,\n }),\n [\n handlers,\n loadingActions,\n pendingConfirmation,\n execute,\n confirm,\n cancel,\n registerHandler,\n ],\n );\n\n return (\n <ActionContext.Provider value={value}>{children}</ActionContext.Provider>\n );\n}\n\n/**\n * Hook to access action context\n */\nexport function useActions(): ActionContextValue {\n const ctx = useContext(ActionContext);\n if (!ctx) {\n throw new Error(\"useActions must be used within an ActionProvider\");\n }\n return ctx;\n}\n\n/**\n * Hook to execute an action\n */\nexport function useAction(action: Action): {\n execute: () => Promise<void>;\n isLoading: boolean;\n} {\n const { execute, loadingActions } = useActions();\n const isLoading = loadingActions.has(action.name);\n\n const executeAction = useCallback(() => execute(action), [execute, action]);\n\n return { execute: executeAction, isLoading };\n}\n\n/**\n * Props for ConfirmDialog component\n */\nexport interface ConfirmDialogProps {\n /** The confirmation config */\n confirm: ActionConfirm;\n /** Called when confirmed */\n onConfirm: () => void;\n /** Called when cancelled */\n onCancel: () => void;\n}\n\n/**\n * Default confirmation dialog component\n */\nexport function ConfirmDialog({\n confirm,\n onConfirm,\n onCancel,\n}: ConfirmDialogProps) {\n const isDanger = confirm.variant === \"danger\";\n\n return (\n <div\n style={{\n position: \"fixed\",\n inset: 0,\n backgroundColor: \"rgba(0, 0, 0, 0.5)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n zIndex: 50,\n }}\n onClick={onCancel}\n >\n <div\n style={{\n backgroundColor: \"white\",\n borderRadius: \"8px\",\n padding: \"24px\",\n maxWidth: \"400px\",\n width: \"100%\",\n boxShadow: \"0 20px 25px -5px rgba(0, 0, 0, 0.1)\",\n }}\n onClick={(e) => e.stopPropagation()}\n >\n <h3\n style={{\n margin: \"0 0 8px 0\",\n fontSize: \"18px\",\n fontWeight: 600,\n }}\n >\n {confirm.title}\n </h3>\n <p\n style={{\n margin: \"0 0 24px 0\",\n color: \"#6b7280\",\n }}\n >\n {confirm.message}\n </p>\n <div\n style={{\n display: \"flex\",\n gap: \"12px\",\n justifyContent: \"flex-end\",\n }}\n >\n <button\n onClick={onCancel}\n style={{\n padding: \"8px 16px\",\n borderRadius: \"6px\",\n border: \"1px solid #d1d5db\",\n backgroundColor: \"white\",\n cursor: \"pointer\",\n }}\n >\n {confirm.cancelLabel ?? \"Cancel\"}\n </button>\n <button\n onClick={onConfirm}\n style={{\n padding: \"8px 16px\",\n borderRadius: \"6px\",\n border: \"none\",\n backgroundColor: isDanger ? \"#dc2626\" : \"#3b82f6\",\n color: \"white\",\n cursor: \"pointer\",\n }}\n >\n {confirm.confirmLabel ?? \"Confirm\"}\n </button>\n </div>\n </div>\n </div>\n );\n}\n","\"use client\";\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport {\n runValidation,\n type ValidationConfig,\n type ValidationFunction,\n type ValidationResult,\n} from \"@json-render/core\";\nimport { useData } from \"./data\";\n\n/**\n * Field validation state\n */\nexport interface FieldValidationState {\n /** Whether the field has been touched */\n touched: boolean;\n /** Whether the field has been validated */\n validated: boolean;\n /** Validation result */\n result: ValidationResult | null;\n}\n\n/**\n * Validation context value\n */\nexport interface ValidationContextValue {\n /** Custom validation functions from catalog */\n customFunctions: Record<string, ValidationFunction>;\n /** Validation state by field path */\n fieldStates: Record<string, FieldValidationState>;\n /** Validate a field */\n validate: (path: string, config: ValidationConfig) => ValidationResult;\n /** Mark field as touched */\n touch: (path: string) => void;\n /** Clear validation for a field */\n clear: (path: string) => void;\n /** Validate all fields */\n validateAll: () => boolean;\n /** Register field config */\n registerField: (path: string, config: ValidationConfig) => void;\n}\n\nconst ValidationContext = createContext<ValidationContextValue | null>(null);\n\n/**\n * Props for ValidationProvider\n */\nexport interface ValidationProviderProps {\n /** Custom validation functions from catalog */\n customFunctions?: Record<string, ValidationFunction>;\n children: ReactNode;\n}\n\n/**\n * Provider for validation\n */\nexport function ValidationProvider({\n customFunctions = {},\n children,\n}: ValidationProviderProps) {\n const { data, authState } = useData();\n const [fieldStates, setFieldStates] = useState<\n Record<string, FieldValidationState>\n >({});\n const [fieldConfigs, setFieldConfigs] = useState<\n Record<string, ValidationConfig>\n >({});\n\n const registerField = useCallback(\n (path: string, config: ValidationConfig) => {\n setFieldConfigs((prev) => ({ ...prev, [path]: config }));\n },\n [],\n );\n\n const validate = useCallback(\n (path: string, config: ValidationConfig): ValidationResult => {\n const value = data[path.split(\"/\").filter(Boolean).join(\".\")];\n const result = runValidation(config, {\n value,\n dataModel: data,\n customFunctions,\n authState,\n });\n\n setFieldStates((prev) => ({\n ...prev,\n [path]: {\n touched: prev[path]?.touched ?? true,\n validated: true,\n result,\n },\n }));\n\n return result;\n },\n [data, customFunctions, authState],\n );\n\n const touch = useCallback((path: string) => {\n setFieldStates((prev) => ({\n ...prev,\n [path]: {\n ...prev[path],\n touched: true,\n validated: prev[path]?.validated ?? false,\n result: prev[path]?.result ?? null,\n },\n }));\n }, []);\n\n const clear = useCallback((path: string) => {\n setFieldStates((prev) => {\n const { [path]: _, ...rest } = prev;\n return rest;\n });\n }, []);\n\n const validateAll = useCallback(() => {\n let allValid = true;\n\n for (const [path, config] of Object.entries(fieldConfigs)) {\n const result = validate(path, config);\n if (!result.valid) {\n allValid = false;\n }\n }\n\n return allValid;\n }, [fieldConfigs, validate]);\n\n const value = useMemo<ValidationContextValue>(\n () => ({\n customFunctions,\n fieldStates,\n validate,\n touch,\n clear,\n validateAll,\n registerField,\n }),\n [\n customFunctions,\n fieldStates,\n validate,\n touch,\n clear,\n validateAll,\n registerField,\n ],\n );\n\n return (\n <ValidationContext.Provider value={value}>\n {children}\n </ValidationContext.Provider>\n );\n}\n\n/**\n * Hook to access validation context\n */\nexport function useValidation(): ValidationContextValue {\n const ctx = useContext(ValidationContext);\n if (!ctx) {\n throw new Error(\"useValidation must be used within a ValidationProvider\");\n }\n return ctx;\n}\n\n/**\n * Hook to get validation state for a field\n */\nexport function useFieldValidation(\n path: string,\n config?: ValidationConfig,\n): {\n state: FieldValidationState;\n validate: () => ValidationResult;\n touch: () => void;\n clear: () => void;\n errors: string[];\n isValid: boolean;\n} {\n const {\n fieldStates,\n validate: validateField,\n touch: touchField,\n clear: clearField,\n registerField,\n } = useValidation();\n\n // Register field on mount\n React.useEffect(() => {\n if (config) {\n registerField(path, config);\n }\n }, [path, config, registerField]);\n\n const state = fieldStates[path] ?? {\n touched: false,\n validated: false,\n result: null,\n };\n\n const validate = useCallback(\n () => validateField(path, config ?? { checks: [] }),\n [path, config, validateField],\n );\n\n const touch = useCallback(() => touchField(path), [path, touchField]);\n const clear = useCallback(() => clearField(path), [path, clearField]);\n\n return {\n state,\n validate,\n touch,\n clear,\n errors: state.result?.errors ?? [],\n isValid: state.result?.valid ?? true,\n };\n}\n","\"use client\";\n\nimport React, { type ComponentType, type ReactNode, useMemo } from \"react\";\nimport type {\n UIElement,\n UITree,\n Action,\n Catalog,\n ComponentDefinition,\n} from \"@json-render/core\";\nimport { useIsVisible } from \"./contexts/visibility\";\nimport { useActions } from \"./contexts/actions\";\nimport { useData } from \"./contexts/data\";\n\n/**\n * Props passed to component renderers\n */\nexport interface ComponentRenderProps<P = Record<string, unknown>> {\n /** The element being rendered */\n element: UIElement<string, P>;\n /** Rendered children */\n children?: ReactNode;\n /** Execute an action */\n onAction?: (action: Action) => void;\n /** Whether the parent is loading */\n loading?: boolean;\n}\n\n/**\n * Component renderer type\n */\nexport type ComponentRenderer<P = Record<string, unknown>> = ComponentType<\n ComponentRenderProps<P>\n>;\n\n/**\n * Registry of component renderers\n */\nexport type ComponentRegistry = Record<string, ComponentRenderer<any>>;\n\n/**\n * Props for the Renderer component\n */\nexport interface RendererProps {\n /** The UI tree to render */\n tree: UITree | null;\n /** Component registry */\n registry: ComponentRegistry;\n /** Whether the tree is currently loading/streaming */\n loading?: boolean;\n /** Fallback component for unknown types */\n fallback?: ComponentRenderer;\n}\n\n/**\n * Element renderer component\n */\nfunction ElementRenderer({\n element,\n tree,\n registry,\n loading,\n fallback,\n}: {\n element: UIElement;\n tree: UITree;\n registry: ComponentRegistry;\n loading?: boolean;\n fallback?: ComponentRenderer;\n}) {\n const isVisible = useIsVisible(element.visible);\n const { execute } = useActions();\n\n // Don't render if not visible\n if (!isVisible) {\n return null;\n }\n\n // Get the component renderer\n const Component = registry[element.type] ?? fallback;\n\n if (!Component) {\n console.warn(`No renderer for component type: ${element.type}`);\n return null;\n }\n\n // Render children\n const children = element.children?.map((childKey) => {\n const childElement = tree.elements[childKey];\n if (!childElement) {\n return null;\n }\n return (\n <ElementRenderer\n key={childKey}\n element={childElement}\n tree={tree}\n registry={registry}\n loading={loading}\n fallback={fallback}\n />\n );\n });\n\n return (\n <Component element={element} onAction={execute} loading={loading}>\n {children}\n </Component>\n );\n}\n\n/**\n * Main renderer component\n */\nexport function Renderer({ tree, registry, loading, fallback }: RendererProps) {\n if (!tree || !tree.root) {\n return null;\n }\n\n const rootElement = tree.elements[tree.root];\n if (!rootElement) {\n return null;\n }\n\n return (\n <ElementRenderer\n element={rootElement}\n tree={tree}\n registry={registry}\n loading={loading}\n fallback={fallback}\n />\n );\n}\n\n/**\n * Props for JSONUIProvider\n */\nexport interface JSONUIProviderProps {\n /** Component registry */\n registry: ComponentRegistry;\n /** Initial data model */\n initialData?: Record<string, unknown>;\n /** Auth state */\n authState?: { isSignedIn: boolean; user?: Record<string, unknown> };\n /** Action handlers */\n actionHandlers?: Record<\n string,\n (params: Record<string, unknown>) => Promise<unknown> | unknown\n >;\n /** Navigation function */\n navigate?: (path: string) => void;\n /** Custom validation functions */\n validationFunctions?: Record<\n string,\n (value: unknown, args?: Record<string, unknown>) => boolean\n >;\n /** Callback when data changes */\n onDataChange?: (path: string, value: unknown) => void;\n children: ReactNode;\n}\n\n// Import the providers\nimport { DataProvider } from \"./contexts/data\";\nimport { VisibilityProvider } from \"./contexts/visibility\";\nimport { ActionProvider } from \"./contexts/actions\";\nimport { ValidationProvider } from \"./contexts/validation\";\nimport { ConfirmDialog } from \"./contexts/actions\";\n\n/**\n * Combined provider for all JSONUI contexts\n */\nexport function JSONUIProvider({\n registry,\n initialData,\n authState,\n actionHandlers,\n navigate,\n validationFunctions,\n onDataChange,\n children,\n}: JSONUIProviderProps) {\n return (\n <DataProvider\n initialData={initialData}\n authState={authState}\n onDataChange={onDataChange}\n >\n <VisibilityProvider>\n <ActionProvider handlers={actionHandlers} navigate={navigate}>\n <ValidationProvider customFunctions={validationFunctions}>\n {children}\n <ConfirmationDialogManager />\n </ValidationProvider>\n </ActionProvider>\n </VisibilityProvider>\n </DataProvider>\n );\n}\n\n/**\n * Renders the confirmation dialog when needed\n */\nfunction ConfirmationDialogManager() {\n const { pendingConfirmation, confirm, cancel } = useActions();\n\n if (!pendingConfirmation?.action.confirm) {\n return null;\n }\n\n return (\n <ConfirmDialog\n confirm={pendingConfirmation.action.confirm}\n onConfirm={confirm}\n onCancel={cancel}\n />\n );\n}\n\n/**\n * Helper to create a renderer component from a catalog\n */\nexport function createRendererFromCatalog<\n C extends Catalog<Record<string, ComponentDefinition>>,\n>(\n _catalog: C,\n registry: ComponentRegistry,\n): ComponentType<Omit<RendererProps, \"registry\">> {\n return function CatalogRenderer(props: Omit<RendererProps, \"registry\">) {\n return <Renderer {...props} registry={registry} />;\n };\n}\n","\"use client\";\n\nimport { useState, useCallback, useRef, useEffect } from \"react\";\nimport type { UITree, UIElement, JsonPatch } from \"@json-render/core\";\nimport { setByPath } from \"@json-render/core\";\n\n/**\n * Parse a single JSON patch line\n */\nfunction parsePatchLine(line: string): JsonPatch | null {\n try {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"//\")) {\n return null;\n }\n return JSON.parse(trimmed) as JsonPatch;\n } catch {\n return null;\n }\n}\n\n/**\n * Apply a JSON patch to the current tree\n */\nfunction applyPatch(tree: UITree, patch: JsonPatch): UITree {\n const newTree = { ...tree, elements: { ...tree.elements } };\n\n switch (patch.op) {\n case \"set\":\n case \"add\":\n case \"replace\": {\n // Handle root path\n if (patch.path === \"/root\") {\n newTree.root = patch.value as string;\n return newTree;\n }\n\n // Handle elements paths\n if (patch.path.startsWith(\"/elements/\")) {\n const pathParts = patch.path.slice(\"/elements/\".length).split(\"/\");\n const elementKey = pathParts[0];\n\n if (!elementKey) return newTree;\n\n if (pathParts.length === 1) {\n // Setting entire element\n newTree.elements[elementKey] = patch.value as UIElement;\n } else {\n // Setting property of element\n const element = newTree.elements[elementKey];\n if (element) {\n const propPath = \"/\" + pathParts.slice(1).join(\"/\");\n const newElement = { ...element };\n setByPath(\n newElement as unknown as Record<string, unknown>,\n propPath,\n patch.value,\n );\n newTree.elements[elementKey] = newElement;\n }\n }\n }\n break;\n }\n case \"remove\": {\n if (patch.path.startsWith(\"/elements/\")) {\n const elementKey = patch.path.slice(\"/elements/\".length).split(\"/\")[0];\n if (elementKey) {\n const { [elementKey]: _, ...rest } = newTree.elements;\n newTree.elements = rest;\n }\n }\n break;\n }\n }\n\n return newTree;\n}\n\n/**\n * Options for useUIStream\n */\nexport interface UseUIStreamOptions {\n /** API endpoint */\n api: string;\n /** Callback when complete */\n onComplete?: (tree: UITree) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n}\n\n/**\n * Return type for useUIStream\n */\nexport interface UseUIStreamReturn {\n /** Current UI tree */\n tree: UITree | null;\n /** Whether currently streaming */\n isStreaming: boolean;\n /** Error if any */\n error: Error | null;\n /** Send a prompt to generate UI */\n send: (prompt: string, context?: Record<string, unknown>) => Promise<void>;\n /** Clear the current tree */\n clear: () => void;\n}\n\n/**\n * Hook for streaming UI generation\n */\nexport function useUIStream({\n api,\n onComplete,\n onError,\n}: UseUIStreamOptions): UseUIStreamReturn {\n const [tree, setTree] = useState<UITree | null>(null);\n const [isStreaming, setIsStreaming] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const clear = useCallback(() => {\n setTree(null);\n setError(null);\n }, []);\n\n const send = useCallback(\n async (prompt: string, context?: Record<string, unknown>) => {\n // Abort any existing request\n abortControllerRef.current?.abort();\n abortControllerRef.current = new AbortController();\n\n setIsStreaming(true);\n setError(null);\n\n // Start with an empty tree\n let currentTree: UITree = { root: \"\", elements: {} };\n setTree(currentTree);\n\n try {\n const response = await fetch(api, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n prompt,\n context,\n currentTree,\n }),\n signal: abortControllerRef.current.signal,\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error: ${response.status}`);\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"No response body\");\n }\n\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n\n // Process complete lines\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n\n for (const line of lines) {\n const patch = parsePatchLine(line);\n if (patch) {\n currentTree = applyPatch(currentTree, patch);\n setTree({ ...currentTree });\n }\n }\n }\n\n // Process any remaining buffer\n if (buffer.trim()) {\n const patch = parsePatchLine(buffer);\n if (patch) {\n currentTree = applyPatch(currentTree, patch);\n setTree({ ...currentTree });\n }\n }\n\n onComplete?.(currentTree);\n } catch (err) {\n if ((err as Error).name === \"AbortError\") {\n return;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n setError(error);\n onError?.(error);\n } finally {\n setIsStreaming(false);\n }\n },\n [api, onComplete, onError],\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n abortControllerRef.current?.abort();\n };\n }, []);\n\n return {\n tree,\n isStreaming,\n error,\n send,\n clear,\n };\n}\n\n/**\n * Convert a flat element list to a UITree\n */\nexport function flatToTree(\n elements: Array<UIElement & { parentKey?: string | null }>,\n): UITree {\n const elementMap: Record<string, UIElement> = {};\n let root = \"\";\n\n // First pass: add all elements to map\n for (const element of elements) {\n elementMap[element.key] = {\n key: element.key,\n type: element.type,\n props: element.props,\n children: [],\n visible: element.visible,\n };\n }\n\n // Second pass: build parent-child relationships\n for (const element of elements) {\n if (element.parentKey) {\n const parent = elementMap[element.parentKey];\n if (parent) {\n if (!parent.children) {\n parent.children = [];\n }\n parent.children.push(element.key);\n }\n } else {\n root = element.key;\n }\n }\n\n return { root, elements: elementMap };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAOO;AACP,kBAKO;AAmFE;AAjET,IAAM,kBAAc,4BAAuC,IAAI;AAkBxD,SAAS,aAAa;AAAA,EAC3B,cAAc,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AACF,GAAsB;AACpB,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAoB,WAAW;AAEvD,QAAM,UAAM,0BAAY,CAAC,aAAiB,uBAAU,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC;AA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WAAW,UAAU;AAC9B,eAAW,QAAQ,GAAG,IAAI;AAAA,MACxB,KAAK,QAAQ;AAAA,MACb,MAAM,QAAQ;AAAA,MACd,OAAO,QAAQ;AAAA,MACf,UAAU,CAAC;AAAA,MACX,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF;AAGA,aAAW,WAAW,UAAU;AAC9B,QAAI,QAAQ,WAAW;AACrB,YAAM,SAAS,WAAW,QAAQ,SAAS;AAC3C,UAAI,QAAQ;AACV,YAAI,CAAC,OAAO,UAAU;AACpB,iBAAO,WAAW,CAAC;AAAA,QACrB;AACA,eAAO,SAAS,KAAK,QAAQ,GAAG;AAAA,MAClC;AAAA,IACF,OAAO;AACL,aAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AAEA,SAAO,EAAE,MAAM,UAAU,WAAW;AACtC;","names":["value","import_react","import_core","import_jsx_runtime","import_react","import_core","import_jsx_runtime","executeAction","import_react","import_core","import_jsx_runtime","value","React","import_jsx_runtime","import_react","import_core","error"]}
|
package/dist/index.mjs
CHANGED
|
@@ -19,10 +19,7 @@ function DataProvider({
|
|
|
19
19
|
children
|
|
20
20
|
}) {
|
|
21
21
|
const [data, setData] = useState(initialData);
|
|
22
|
-
const get = useCallback(
|
|
23
|
-
(path) => getByPath(data, path),
|
|
24
|
-
[data]
|
|
25
|
-
);
|
|
22
|
+
const get = useCallback((path) => getByPath(data, path), [data]);
|
|
26
23
|
const set = useCallback(
|
|
27
24
|
(path, value2) => {
|
|
28
25
|
setData((prev) => {
|
|
@@ -81,7 +78,11 @@ function useDataBinding(path) {
|
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
// src/contexts/visibility.tsx
|
|
84
|
-
import {
|
|
81
|
+
import {
|
|
82
|
+
createContext as createContext2,
|
|
83
|
+
useContext as useContext2,
|
|
84
|
+
useMemo as useMemo2
|
|
85
|
+
} from "react";
|
|
85
86
|
import {
|
|
86
87
|
evaluateVisibility
|
|
87
88
|
} from "@json-render/core";
|
|
@@ -141,9 +142,12 @@ function ActionProvider({
|
|
|
141
142
|
const [handlers, setHandlers] = useState2(initialHandlers);
|
|
142
143
|
const [loadingActions, setLoadingActions] = useState2(/* @__PURE__ */ new Set());
|
|
143
144
|
const [pendingConfirmation, setPendingConfirmation] = useState2(null);
|
|
144
|
-
const registerHandler = useCallback2(
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
const registerHandler = useCallback2(
|
|
146
|
+
(name, handler) => {
|
|
147
|
+
setHandlers((prev) => ({ ...prev, [name]: handler }));
|
|
148
|
+
},
|
|
149
|
+
[]
|
|
150
|
+
);
|
|
147
151
|
const execute = useCallback2(
|
|
148
152
|
async (action) => {
|
|
149
153
|
const resolved = resolveAction(action, data);
|
|
@@ -226,7 +230,15 @@ function ActionProvider({
|
|
|
226
230
|
cancel,
|
|
227
231
|
registerHandler
|
|
228
232
|
}),
|
|
229
|
-
[
|
|
233
|
+
[
|
|
234
|
+
handlers,
|
|
235
|
+
loadingActions,
|
|
236
|
+
pendingConfirmation,
|
|
237
|
+
execute,
|
|
238
|
+
confirm,
|
|
239
|
+
cancel,
|
|
240
|
+
registerHandler
|
|
241
|
+
]
|
|
230
242
|
);
|
|
231
243
|
return /* @__PURE__ */ jsx3(ActionContext.Provider, { value, children });
|
|
232
244
|
}
|
|
@@ -243,7 +255,11 @@ function useAction(action) {
|
|
|
243
255
|
const executeAction2 = useCallback2(() => execute(action), [execute, action]);
|
|
244
256
|
return { execute: executeAction2, isLoading };
|
|
245
257
|
}
|
|
246
|
-
function ConfirmDialog({
|
|
258
|
+
function ConfirmDialog({
|
|
259
|
+
confirm,
|
|
260
|
+
onConfirm,
|
|
261
|
+
onCancel
|
|
262
|
+
}) {
|
|
247
263
|
const isDanger = confirm.variant === "danger";
|
|
248
264
|
return /* @__PURE__ */ jsx3(
|
|
249
265
|
"div",
|
|
@@ -360,9 +376,12 @@ function ValidationProvider({
|
|
|
360
376
|
const { data, authState } = useData();
|
|
361
377
|
const [fieldStates, setFieldStates] = useState3({});
|
|
362
378
|
const [fieldConfigs, setFieldConfigs] = useState3({});
|
|
363
|
-
const registerField = useCallback3(
|
|
364
|
-
|
|
365
|
-
|
|
379
|
+
const registerField = useCallback3(
|
|
380
|
+
(path, config) => {
|
|
381
|
+
setFieldConfigs((prev) => ({ ...prev, [path]: config }));
|
|
382
|
+
},
|
|
383
|
+
[]
|
|
384
|
+
);
|
|
366
385
|
const validate = useCallback3(
|
|
367
386
|
(path, config) => {
|
|
368
387
|
const value2 = data[path.split("/").filter(Boolean).join(".")];
|
|
@@ -421,7 +440,15 @@ function ValidationProvider({
|
|
|
421
440
|
validateAll,
|
|
422
441
|
registerField
|
|
423
442
|
}),
|
|
424
|
-
[
|
|
443
|
+
[
|
|
444
|
+
customFunctions,
|
|
445
|
+
fieldStates,
|
|
446
|
+
validate,
|
|
447
|
+
touch,
|
|
448
|
+
clear,
|
|
449
|
+
validateAll,
|
|
450
|
+
registerField
|
|
451
|
+
]
|
|
425
452
|
);
|
|
426
453
|
return /* @__PURE__ */ jsx4(ValidationContext.Provider, { value, children });
|
|
427
454
|
}
|
|
@@ -502,15 +529,7 @@ function ElementRenderer({
|
|
|
502
529
|
childKey
|
|
503
530
|
);
|
|
504
531
|
});
|
|
505
|
-
return /* @__PURE__ */ jsx5(
|
|
506
|
-
Component,
|
|
507
|
-
{
|
|
508
|
-
element,
|
|
509
|
-
onAction: execute,
|
|
510
|
-
loading,
|
|
511
|
-
children
|
|
512
|
-
}
|
|
513
|
-
);
|
|
532
|
+
return /* @__PURE__ */ jsx5(Component, { element, onAction: execute, loading, children });
|
|
514
533
|
}
|
|
515
534
|
function Renderer({ tree, registry, loading, fallback }) {
|
|
516
535
|
if (!tree || !tree.root) {
|
|
@@ -609,7 +628,11 @@ function applyPatch(tree, patch) {
|
|
|
609
628
|
if (element) {
|
|
610
629
|
const propPath = "/" + pathParts.slice(1).join("/");
|
|
611
630
|
const newElement = { ...element };
|
|
612
|
-
setByPath2(
|
|
631
|
+
setByPath2(
|
|
632
|
+
newElement,
|
|
633
|
+
propPath,
|
|
634
|
+
patch.value
|
|
635
|
+
);
|
|
613
636
|
newTree.elements[elementKey] = newElement;
|
|
614
637
|
}
|
|
615
638
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contexts/data.tsx","../src/contexts/visibility.tsx","../src/contexts/actions.tsx","../src/contexts/validation.tsx","../src/renderer.tsx","../src/hooks.ts"],"sourcesContent":["'use client';\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from 'react';\nimport {\n getByPath,\n setByPath,\n type DataModel,\n type AuthState,\n} from '@json-render/core';\n\n/**\n * Data context value\n */\nexport interface DataContextValue {\n /** The current data model */\n data: DataModel;\n /** Auth state for visibility evaluation */\n authState?: AuthState;\n /** Get a value by path */\n get: (path: string) => unknown;\n /** Set a value by path */\n set: (path: string, value: unknown) => void;\n /** Update multiple values at once */\n update: (updates: Record<string, unknown>) => void;\n}\n\nconst DataContext = createContext<DataContextValue | null>(null);\n\n/**\n * Props for DataProvider\n */\nexport interface DataProviderProps {\n /** Initial data model */\n initialData?: DataModel;\n /** Auth state */\n authState?: AuthState;\n /** Callback when data changes */\n onDataChange?: (path: string, value: unknown) => void;\n children: ReactNode;\n}\n\n/**\n * Provider for data model context\n */\nexport function DataProvider({\n initialData = {},\n authState,\n onDataChange,\n children,\n}: DataProviderProps) {\n const [data, setData] = useState<DataModel>(initialData);\n\n const get = useCallback(\n (path: string) => getByPath(data, path),\n [data]\n );\n\n const set = useCallback(\n (path: string, value: unknown) => {\n setData((prev) => {\n const next = { ...prev };\n setByPath(next, path, value);\n return next;\n });\n onDataChange?.(path, value);\n },\n [onDataChange]\n );\n\n const update = useCallback(\n (updates: Record<string, unknown>) => {\n setData((prev) => {\n const next = { ...prev };\n for (const [path, value] of Object.entries(updates)) {\n setByPath(next, path, value);\n onDataChange?.(path, value);\n }\n return next;\n });\n },\n [onDataChange]\n );\n\n const value = useMemo<DataContextValue>(\n () => ({\n data,\n authState,\n get,\n set,\n update,\n }),\n [data, authState, get, set, update]\n );\n\n return <DataContext.Provider value={value}>{children}</DataContext.Provider>;\n}\n\n/**\n * Hook to access the data context\n */\nexport function useData(): DataContextValue {\n const ctx = useContext(DataContext);\n if (!ctx) {\n throw new Error('useData must be used within a DataProvider');\n }\n return ctx;\n}\n\n/**\n * Hook to get a value from the data model\n */\nexport function useDataValue<T>(path: string): T | undefined {\n const { get } = useData();\n return get(path) as T | undefined;\n}\n\n/**\n * Hook to get and set a value from the data model (like useState)\n */\nexport function useDataBinding<T>(\n path: string\n): [T | undefined, (value: T) => void] {\n const { get, set } = useData();\n const value = get(path) as T | undefined;\n const setValue = useCallback(\n (newValue: T) => set(path, newValue),\n [path, set]\n );\n return [value, setValue];\n}\n","'use client';\n\nimport React, { createContext, useContext, useMemo, type ReactNode } from 'react';\nimport {\n evaluateVisibility,\n type VisibilityCondition,\n type VisibilityContext as CoreVisibilityContext,\n} from '@json-render/core';\nimport { useData } from './data';\n\n/**\n * Visibility context value\n */\nexport interface VisibilityContextValue {\n /** Evaluate a visibility condition */\n isVisible: (condition: VisibilityCondition | undefined) => boolean;\n /** The underlying visibility context */\n ctx: CoreVisibilityContext;\n}\n\nconst VisibilityContext = createContext<VisibilityContextValue | null>(null);\n\n/**\n * Props for VisibilityProvider\n */\nexport interface VisibilityProviderProps {\n children: ReactNode;\n}\n\n/**\n * Provider for visibility evaluation\n */\nexport function VisibilityProvider({ children }: VisibilityProviderProps) {\n const { data, authState } = useData();\n\n const ctx: CoreVisibilityContext = useMemo(\n () => ({\n dataModel: data,\n authState,\n }),\n [data, authState]\n );\n\n const isVisible = useMemo(\n () => (condition: VisibilityCondition | undefined) =>\n evaluateVisibility(condition, ctx),\n [ctx]\n );\n\n const value = useMemo<VisibilityContextValue>(\n () => ({ isVisible, ctx }),\n [isVisible, ctx]\n );\n\n return (\n <VisibilityContext.Provider value={value}>\n {children}\n </VisibilityContext.Provider>\n );\n}\n\n/**\n * Hook to access visibility evaluation\n */\nexport function useVisibility(): VisibilityContextValue {\n const ctx = useContext(VisibilityContext);\n if (!ctx) {\n throw new Error('useVisibility must be used within a VisibilityProvider');\n }\n return ctx;\n}\n\n/**\n * Hook to check if a condition is visible\n */\nexport function useIsVisible(condition: VisibilityCondition | undefined): boolean {\n const { isVisible } = useVisibility();\n return isVisible(condition);\n}\n","'use client';\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from 'react';\nimport {\n resolveAction,\n executeAction,\n type Action,\n type ActionHandler,\n type ActionConfirm,\n type ResolvedAction,\n} from '@json-render/core';\nimport { useData } from './data';\n\n/**\n * Pending confirmation state\n */\nexport interface PendingConfirmation {\n /** The resolved action */\n action: ResolvedAction;\n /** The action handler */\n handler: ActionHandler;\n /** Resolve callback */\n resolve: () => void;\n /** Reject callback */\n reject: () => void;\n}\n\n/**\n * Action context value\n */\nexport interface ActionContextValue {\n /** Registered action handlers */\n handlers: Record<string, ActionHandler>;\n /** Currently loading action names */\n loadingActions: Set<string>;\n /** Pending confirmation dialog */\n pendingConfirmation: PendingConfirmation | null;\n /** Execute an action */\n execute: (action: Action) => Promise<void>;\n /** Confirm the pending action */\n confirm: () => void;\n /** Cancel the pending action */\n cancel: () => void;\n /** Register an action handler */\n registerHandler: (name: string, handler: ActionHandler) => void;\n}\n\nconst ActionContext = createContext<ActionContextValue | null>(null);\n\n/**\n * Props for ActionProvider\n */\nexport interface ActionProviderProps {\n /** Initial action handlers */\n handlers?: Record<string, ActionHandler>;\n /** Navigation function */\n navigate?: (path: string) => void;\n children: ReactNode;\n}\n\n/**\n * Provider for action execution\n */\nexport function ActionProvider({\n handlers: initialHandlers = {},\n navigate,\n children,\n}: ActionProviderProps) {\n const { data, set } = useData();\n const [handlers, setHandlers] = useState<Record<string, ActionHandler>>(initialHandlers);\n const [loadingActions, setLoadingActions] = useState<Set<string>>(new Set());\n const [pendingConfirmation, setPendingConfirmation] = useState<PendingConfirmation | null>(null);\n\n const registerHandler = useCallback((name: string, handler: ActionHandler) => {\n setHandlers((prev) => ({ ...prev, [name]: handler }));\n }, []);\n\n const execute = useCallback(\n async (action: Action) => {\n const resolved = resolveAction(action, data);\n const handler = handlers[resolved.name];\n\n if (!handler) {\n console.warn(`No handler registered for action: ${resolved.name}`);\n return;\n }\n\n // If confirmation is required, show dialog\n if (resolved.confirm) {\n return new Promise<void>((resolve, reject) => {\n setPendingConfirmation({\n action: resolved,\n handler,\n resolve: () => {\n setPendingConfirmation(null);\n resolve();\n },\n reject: () => {\n setPendingConfirmation(null);\n reject(new Error('Action cancelled'));\n },\n });\n }).then(async () => {\n setLoadingActions((prev) => new Set(prev).add(resolved.name));\n try {\n await executeAction({\n action: resolved,\n handler,\n setData: set,\n navigate,\n executeAction: async (name) => {\n const subAction: Action = { name };\n await execute(subAction);\n },\n });\n } finally {\n setLoadingActions((prev) => {\n const next = new Set(prev);\n next.delete(resolved.name);\n return next;\n });\n }\n });\n }\n\n // Execute immediately\n setLoadingActions((prev) => new Set(prev).add(resolved.name));\n try {\n await executeAction({\n action: resolved,\n handler,\n setData: set,\n navigate,\n executeAction: async (name) => {\n const subAction: Action = { name };\n await execute(subAction);\n },\n });\n } finally {\n setLoadingActions((prev) => {\n const next = new Set(prev);\n next.delete(resolved.name);\n return next;\n });\n }\n },\n [data, handlers, set, navigate]\n );\n\n const confirm = useCallback(() => {\n pendingConfirmation?.resolve();\n }, [pendingConfirmation]);\n\n const cancel = useCallback(() => {\n pendingConfirmation?.reject();\n }, [pendingConfirmation]);\n\n const value = useMemo<ActionContextValue>(\n () => ({\n handlers,\n loadingActions,\n pendingConfirmation,\n execute,\n confirm,\n cancel,\n registerHandler,\n }),\n [handlers, loadingActions, pendingConfirmation, execute, confirm, cancel, registerHandler]\n );\n\n return (\n <ActionContext.Provider value={value}>{children}</ActionContext.Provider>\n );\n}\n\n/**\n * Hook to access action context\n */\nexport function useActions(): ActionContextValue {\n const ctx = useContext(ActionContext);\n if (!ctx) {\n throw new Error('useActions must be used within an ActionProvider');\n }\n return ctx;\n}\n\n/**\n * Hook to execute an action\n */\nexport function useAction(action: Action): {\n execute: () => Promise<void>;\n isLoading: boolean;\n} {\n const { execute, loadingActions } = useActions();\n const isLoading = loadingActions.has(action.name);\n\n const executeAction = useCallback(() => execute(action), [execute, action]);\n\n return { execute: executeAction, isLoading };\n}\n\n/**\n * Props for ConfirmDialog component\n */\nexport interface ConfirmDialogProps {\n /** The confirmation config */\n confirm: ActionConfirm;\n /** Called when confirmed */\n onConfirm: () => void;\n /** Called when cancelled */\n onCancel: () => void;\n}\n\n/**\n * Default confirmation dialog component\n */\nexport function ConfirmDialog({ confirm, onConfirm, onCancel }: ConfirmDialogProps) {\n const isDanger = confirm.variant === 'danger';\n\n return (\n <div\n style={{\n position: 'fixed',\n inset: 0,\n backgroundColor: 'rgba(0, 0, 0, 0.5)',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n zIndex: 50,\n }}\n onClick={onCancel}\n >\n <div\n style={{\n backgroundColor: 'white',\n borderRadius: '8px',\n padding: '24px',\n maxWidth: '400px',\n width: '100%',\n boxShadow: '0 20px 25px -5px rgba(0, 0, 0, 0.1)',\n }}\n onClick={(e) => e.stopPropagation()}\n >\n <h3\n style={{\n margin: '0 0 8px 0',\n fontSize: '18px',\n fontWeight: 600,\n }}\n >\n {confirm.title}\n </h3>\n <p\n style={{\n margin: '0 0 24px 0',\n color: '#6b7280',\n }}\n >\n {confirm.message}\n </p>\n <div\n style={{\n display: 'flex',\n gap: '12px',\n justifyContent: 'flex-end',\n }}\n >\n <button\n onClick={onCancel}\n style={{\n padding: '8px 16px',\n borderRadius: '6px',\n border: '1px solid #d1d5db',\n backgroundColor: 'white',\n cursor: 'pointer',\n }}\n >\n {confirm.cancelLabel ?? 'Cancel'}\n </button>\n <button\n onClick={onConfirm}\n style={{\n padding: '8px 16px',\n borderRadius: '6px',\n border: 'none',\n backgroundColor: isDanger ? '#dc2626' : '#3b82f6',\n color: 'white',\n cursor: 'pointer',\n }}\n >\n {confirm.confirmLabel ?? 'Confirm'}\n </button>\n </div>\n </div>\n </div>\n );\n}\n","'use client';\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from 'react';\nimport {\n runValidation,\n type ValidationConfig,\n type ValidationFunction,\n type ValidationResult,\n} from '@json-render/core';\nimport { useData } from './data';\n\n/**\n * Field validation state\n */\nexport interface FieldValidationState {\n /** Whether the field has been touched */\n touched: boolean;\n /** Whether the field has been validated */\n validated: boolean;\n /** Validation result */\n result: ValidationResult | null;\n}\n\n/**\n * Validation context value\n */\nexport interface ValidationContextValue {\n /** Custom validation functions from catalog */\n customFunctions: Record<string, ValidationFunction>;\n /** Validation state by field path */\n fieldStates: Record<string, FieldValidationState>;\n /** Validate a field */\n validate: (path: string, config: ValidationConfig) => ValidationResult;\n /** Mark field as touched */\n touch: (path: string) => void;\n /** Clear validation for a field */\n clear: (path: string) => void;\n /** Validate all fields */\n validateAll: () => boolean;\n /** Register field config */\n registerField: (path: string, config: ValidationConfig) => void;\n}\n\nconst ValidationContext = createContext<ValidationContextValue | null>(null);\n\n/**\n * Props for ValidationProvider\n */\nexport interface ValidationProviderProps {\n /** Custom validation functions from catalog */\n customFunctions?: Record<string, ValidationFunction>;\n children: ReactNode;\n}\n\n/**\n * Provider for validation\n */\nexport function ValidationProvider({\n customFunctions = {},\n children,\n}: ValidationProviderProps) {\n const { data, authState } = useData();\n const [fieldStates, setFieldStates] = useState<Record<string, FieldValidationState>>({});\n const [fieldConfigs, setFieldConfigs] = useState<Record<string, ValidationConfig>>({});\n\n const registerField = useCallback((path: string, config: ValidationConfig) => {\n setFieldConfigs((prev) => ({ ...prev, [path]: config }));\n }, []);\n\n const validate = useCallback(\n (path: string, config: ValidationConfig): ValidationResult => {\n const value = data[path.split('/').filter(Boolean).join('.')];\n const result = runValidation(config, {\n value,\n dataModel: data,\n customFunctions,\n authState,\n });\n\n setFieldStates((prev) => ({\n ...prev,\n [path]: {\n touched: prev[path]?.touched ?? true,\n validated: true,\n result,\n },\n }));\n\n return result;\n },\n [data, customFunctions, authState]\n );\n\n const touch = useCallback((path: string) => {\n setFieldStates((prev) => ({\n ...prev,\n [path]: {\n ...prev[path],\n touched: true,\n validated: prev[path]?.validated ?? false,\n result: prev[path]?.result ?? null,\n },\n }));\n }, []);\n\n const clear = useCallback((path: string) => {\n setFieldStates((prev) => {\n const { [path]: _, ...rest } = prev;\n return rest;\n });\n }, []);\n\n const validateAll = useCallback(() => {\n let allValid = true;\n\n for (const [path, config] of Object.entries(fieldConfigs)) {\n const result = validate(path, config);\n if (!result.valid) {\n allValid = false;\n }\n }\n\n return allValid;\n }, [fieldConfigs, validate]);\n\n const value = useMemo<ValidationContextValue>(\n () => ({\n customFunctions,\n fieldStates,\n validate,\n touch,\n clear,\n validateAll,\n registerField,\n }),\n [customFunctions, fieldStates, validate, touch, clear, validateAll, registerField]\n );\n\n return (\n <ValidationContext.Provider value={value}>\n {children}\n </ValidationContext.Provider>\n );\n}\n\n/**\n * Hook to access validation context\n */\nexport function useValidation(): ValidationContextValue {\n const ctx = useContext(ValidationContext);\n if (!ctx) {\n throw new Error('useValidation must be used within a ValidationProvider');\n }\n return ctx;\n}\n\n/**\n * Hook to get validation state for a field\n */\nexport function useFieldValidation(\n path: string,\n config?: ValidationConfig\n): {\n state: FieldValidationState;\n validate: () => ValidationResult;\n touch: () => void;\n clear: () => void;\n errors: string[];\n isValid: boolean;\n} {\n const {\n fieldStates,\n validate: validateField,\n touch: touchField,\n clear: clearField,\n registerField,\n } = useValidation();\n\n // Register field on mount\n React.useEffect(() => {\n if (config) {\n registerField(path, config);\n }\n }, [path, config, registerField]);\n\n const state = fieldStates[path] ?? {\n touched: false,\n validated: false,\n result: null,\n };\n\n const validate = useCallback(\n () => validateField(path, config ?? { checks: [] }),\n [path, config, validateField]\n );\n\n const touch = useCallback(() => touchField(path), [path, touchField]);\n const clear = useCallback(() => clearField(path), [path, clearField]);\n\n return {\n state,\n validate,\n touch,\n clear,\n errors: state.result?.errors ?? [],\n isValid: state.result?.valid ?? true,\n };\n}\n","'use client';\n\nimport React, { type ComponentType, type ReactNode, useMemo } from 'react';\nimport type { UIElement, UITree, Action, Catalog, ComponentDefinition } from '@json-render/core';\nimport { useIsVisible } from './contexts/visibility';\nimport { useActions } from './contexts/actions';\nimport { useData } from './contexts/data';\n\n/**\n * Props passed to component renderers\n */\nexport interface ComponentRenderProps<P = Record<string, unknown>> {\n /** The element being rendered */\n element: UIElement<string, P>;\n /** Rendered children */\n children?: ReactNode;\n /** Execute an action */\n onAction?: (action: Action) => void;\n /** Whether the parent is loading */\n loading?: boolean;\n}\n\n/**\n * Component renderer type\n */\nexport type ComponentRenderer<P = Record<string, unknown>> = ComponentType<ComponentRenderProps<P>>;\n\n/**\n * Registry of component renderers\n */\nexport type ComponentRegistry = Record<string, ComponentRenderer<any>>;\n\n/**\n * Props for the Renderer component\n */\nexport interface RendererProps {\n /** The UI tree to render */\n tree: UITree | null;\n /** Component registry */\n registry: ComponentRegistry;\n /** Whether the tree is currently loading/streaming */\n loading?: boolean;\n /** Fallback component for unknown types */\n fallback?: ComponentRenderer;\n}\n\n/**\n * Element renderer component\n */\nfunction ElementRenderer({\n element,\n tree,\n registry,\n loading,\n fallback,\n}: {\n element: UIElement;\n tree: UITree;\n registry: ComponentRegistry;\n loading?: boolean;\n fallback?: ComponentRenderer;\n}) {\n const isVisible = useIsVisible(element.visible);\n const { execute } = useActions();\n\n // Don't render if not visible\n if (!isVisible) {\n return null;\n }\n\n // Get the component renderer\n const Component = registry[element.type] ?? fallback;\n\n if (!Component) {\n console.warn(`No renderer for component type: ${element.type}`);\n return null;\n }\n\n // Render children\n const children = element.children?.map((childKey) => {\n const childElement = tree.elements[childKey];\n if (!childElement) {\n return null;\n }\n return (\n <ElementRenderer\n key={childKey}\n element={childElement}\n tree={tree}\n registry={registry}\n loading={loading}\n fallback={fallback}\n />\n );\n });\n\n return (\n <Component\n element={element}\n onAction={execute}\n loading={loading}\n >\n {children}\n </Component>\n );\n}\n\n/**\n * Main renderer component\n */\nexport function Renderer({ tree, registry, loading, fallback }: RendererProps) {\n if (!tree || !tree.root) {\n return null;\n }\n\n const rootElement = tree.elements[tree.root];\n if (!rootElement) {\n return null;\n }\n\n return (\n <ElementRenderer\n element={rootElement}\n tree={tree}\n registry={registry}\n loading={loading}\n fallback={fallback}\n />\n );\n}\n\n/**\n * Props for JSONUIProvider\n */\nexport interface JSONUIProviderProps {\n /** Component registry */\n registry: ComponentRegistry;\n /** Initial data model */\n initialData?: Record<string, unknown>;\n /** Auth state */\n authState?: { isSignedIn: boolean; user?: Record<string, unknown> };\n /** Action handlers */\n actionHandlers?: Record<string, (params: Record<string, unknown>) => Promise<unknown> | unknown>;\n /** Navigation function */\n navigate?: (path: string) => void;\n /** Custom validation functions */\n validationFunctions?: Record<string, (value: unknown, args?: Record<string, unknown>) => boolean>;\n /** Callback when data changes */\n onDataChange?: (path: string, value: unknown) => void;\n children: ReactNode;\n}\n\n// Import the providers\nimport { DataProvider } from './contexts/data';\nimport { VisibilityProvider } from './contexts/visibility';\nimport { ActionProvider } from './contexts/actions';\nimport { ValidationProvider } from './contexts/validation';\nimport { ConfirmDialog } from './contexts/actions';\n\n/**\n * Combined provider for all JSONUI contexts\n */\nexport function JSONUIProvider({\n registry,\n initialData,\n authState,\n actionHandlers,\n navigate,\n validationFunctions,\n onDataChange,\n children,\n}: JSONUIProviderProps) {\n return (\n <DataProvider\n initialData={initialData}\n authState={authState}\n onDataChange={onDataChange}\n >\n <VisibilityProvider>\n <ActionProvider handlers={actionHandlers} navigate={navigate}>\n <ValidationProvider customFunctions={validationFunctions}>\n {children}\n <ConfirmationDialogManager />\n </ValidationProvider>\n </ActionProvider>\n </VisibilityProvider>\n </DataProvider>\n );\n}\n\n/**\n * Renders the confirmation dialog when needed\n */\nfunction ConfirmationDialogManager() {\n const { pendingConfirmation, confirm, cancel } = useActions();\n\n if (!pendingConfirmation?.action.confirm) {\n return null;\n }\n\n return (\n <ConfirmDialog\n confirm={pendingConfirmation.action.confirm}\n onConfirm={confirm}\n onCancel={cancel}\n />\n );\n}\n\n/**\n * Helper to create a renderer component from a catalog\n */\nexport function createRendererFromCatalog<\n C extends Catalog<Record<string, ComponentDefinition>>\n>(\n _catalog: C,\n registry: ComponentRegistry\n): ComponentType<Omit<RendererProps, 'registry'>> {\n return function CatalogRenderer(props: Omit<RendererProps, 'registry'>) {\n return <Renderer {...props} registry={registry} />;\n };\n}\n","'use client';\n\nimport { useState, useCallback, useRef, useEffect } from 'react';\nimport type { UITree, UIElement, JsonPatch } from '@json-render/core';\nimport { setByPath } from '@json-render/core';\n\n/**\n * Parse a single JSON patch line\n */\nfunction parsePatchLine(line: string): JsonPatch | null {\n try {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('//')) {\n return null;\n }\n return JSON.parse(trimmed) as JsonPatch;\n } catch {\n return null;\n }\n}\n\n/**\n * Apply a JSON patch to the current tree\n */\nfunction applyPatch(tree: UITree, patch: JsonPatch): UITree {\n const newTree = { ...tree, elements: { ...tree.elements } };\n\n switch (patch.op) {\n case 'set':\n case 'add':\n case 'replace': {\n // Handle root path\n if (patch.path === '/root') {\n newTree.root = patch.value as string;\n return newTree;\n }\n\n // Handle elements paths\n if (patch.path.startsWith('/elements/')) {\n const pathParts = patch.path.slice('/elements/'.length).split('/');\n const elementKey = pathParts[0];\n\n if (!elementKey) return newTree;\n\n if (pathParts.length === 1) {\n // Setting entire element\n newTree.elements[elementKey] = patch.value as UIElement;\n } else {\n // Setting property of element\n const element = newTree.elements[elementKey];\n if (element) {\n const propPath = '/' + pathParts.slice(1).join('/');\n const newElement = { ...element };\n setByPath(newElement as unknown as Record<string, unknown>, propPath, patch.value);\n newTree.elements[elementKey] = newElement;\n }\n }\n }\n break;\n }\n case 'remove': {\n if (patch.path.startsWith('/elements/')) {\n const elementKey = patch.path.slice('/elements/'.length).split('/')[0];\n if (elementKey) {\n const { [elementKey]: _, ...rest } = newTree.elements;\n newTree.elements = rest;\n }\n }\n break;\n }\n }\n\n return newTree;\n}\n\n/**\n * Options for useUIStream\n */\nexport interface UseUIStreamOptions {\n /** API endpoint */\n api: string;\n /** Callback when complete */\n onComplete?: (tree: UITree) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n}\n\n/**\n * Return type for useUIStream\n */\nexport interface UseUIStreamReturn {\n /** Current UI tree */\n tree: UITree | null;\n /** Whether currently streaming */\n isStreaming: boolean;\n /** Error if any */\n error: Error | null;\n /** Send a prompt to generate UI */\n send: (prompt: string, context?: Record<string, unknown>) => Promise<void>;\n /** Clear the current tree */\n clear: () => void;\n}\n\n/**\n * Hook for streaming UI generation\n */\nexport function useUIStream({\n api,\n onComplete,\n onError,\n}: UseUIStreamOptions): UseUIStreamReturn {\n const [tree, setTree] = useState<UITree | null>(null);\n const [isStreaming, setIsStreaming] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const clear = useCallback(() => {\n setTree(null);\n setError(null);\n }, []);\n\n const send = useCallback(\n async (prompt: string, context?: Record<string, unknown>) => {\n // Abort any existing request\n abortControllerRef.current?.abort();\n abortControllerRef.current = new AbortController();\n\n setIsStreaming(true);\n setError(null);\n\n // Start with an empty tree\n let currentTree: UITree = { root: '', elements: {} };\n setTree(currentTree);\n\n try {\n const response = await fetch(api, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n prompt,\n context,\n currentTree,\n }),\n signal: abortControllerRef.current.signal,\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error: ${response.status}`);\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error('No response body');\n }\n\n const decoder = new TextDecoder();\n let buffer = '';\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n\n // Process complete lines\n const lines = buffer.split('\\n');\n buffer = lines.pop() ?? '';\n\n for (const line of lines) {\n const patch = parsePatchLine(line);\n if (patch) {\n currentTree = applyPatch(currentTree, patch);\n setTree({ ...currentTree });\n }\n }\n }\n\n // Process any remaining buffer\n if (buffer.trim()) {\n const patch = parsePatchLine(buffer);\n if (patch) {\n currentTree = applyPatch(currentTree, patch);\n setTree({ ...currentTree });\n }\n }\n\n onComplete?.(currentTree);\n } catch (err) {\n if ((err as Error).name === 'AbortError') {\n return;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n setError(error);\n onError?.(error);\n } finally {\n setIsStreaming(false);\n }\n },\n [api, onComplete, onError]\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n abortControllerRef.current?.abort();\n };\n }, []);\n\n return {\n tree,\n isStreaming,\n error,\n send,\n clear,\n };\n}\n\n/**\n * Convert a flat element list to a UITree\n */\nexport function flatToTree(\n elements: Array<UIElement & { parentKey?: string | null }>\n): UITree {\n const elementMap: Record<string, UIElement> = {};\n let root = '';\n\n // First pass: add all elements to map\n for (const element of elements) {\n elementMap[element.key] = {\n key: element.key,\n type: element.type,\n props: element.props,\n children: [],\n visible: element.visible,\n };\n }\n\n // Second pass: build parent-child relationships\n for (const element of elements) {\n if (element.parentKey) {\n const parent = elementMap[element.parentKey];\n if (parent) {\n if (!parent.children) {\n parent.children = [];\n }\n parent.children.push(element.key);\n }\n } else {\n root = element.key;\n }\n }\n\n return { root, elements: elementMap };\n}\n"],"mappings":";AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAsFE;AApET,IAAM,cAAc,cAAuC,IAAI;AAkBxD,SAAS,aAAa;AAAA,EAC3B,cAAc,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AACF,GAAsB;AACpB,QAAM,CAAC,MAAM,OAAO,IAAI,SAAoB,WAAW;AAEvD,QAAM,MAAM;AAAA,IACV,CAAC,SAAiB,UAAU,MAAM,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M,OAAO,GAAG,CAAC;AAChE,iBAASA,MAAK;AACd,kBAAUA,MAAK;AAAA,MACjB,UAAE;AACA,uBAAe,KAAK;AAAA,MACtB;AAAA,IACF;AAAA,IACA,CAAC,KAAK,YAAY,OAAO;AAAA,EAC3B;AAGA,YAAU,MAAM;AACd,WAAO,MAAM;AACX,yBAAmB,SAAS,MAAM;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAKO,SAAS,WACd,UACQ;AACR,QAAM,aAAwC,CAAC;AAC/C,MAAI,OAAO;AAGX,aAAW,WAAW,UAAU;AAC9B,eAAW,QAAQ,GAAG,IAAI;AAAA,MACxB,KAAK,QAAQ;AAAA,MACb,MAAM,QAAQ;AAAA,MACd,OAAO,QAAQ;AAAA,MACf,UAAU,CAAC;AAAA,MACX,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF;AAGA,aAAW,WAAW,UAAU;AAC9B,QAAI,QAAQ,WAAW;AACrB,YAAM,SAAS,WAAW,QAAQ,SAAS;AAC3C,UAAI,QAAQ;AACV,YAAI,CAAC,OAAO,UAAU;AACpB,iBAAO,WAAW,CAAC;AAAA,QACrB;AACA,eAAO,SAAS,KAAK,QAAQ,GAAG;AAAA,MAClC;AAAA,IACF,OAAO;AACL,aAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AAEA,SAAO,EAAE,MAAM,UAAU,WAAW;AACtC;","names":["value","createContext","useContext","useMemo","jsx","createContext","useMemo","useContext","createContext","useContext","useState","useCallback","useMemo","jsx","createContext","useState","useCallback","useMemo","useContext","executeAction","React","createContext","useContext","useState","useCallback","useMemo","jsx","createContext","useState","useCallback","value","useMemo","useContext","React","jsx","jsxs","useState","useCallback","setByPath","error"]}
|
|
1
|
+
{"version":3,"sources":["../src/contexts/data.tsx","../src/contexts/visibility.tsx","../src/contexts/actions.tsx","../src/contexts/validation.tsx","../src/renderer.tsx","../src/hooks.ts"],"sourcesContent":["\"use client\";\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport {\n getByPath,\n setByPath,\n type DataModel,\n type AuthState,\n} from \"@json-render/core\";\n\n/**\n * Data context value\n */\nexport interface DataContextValue {\n /** The current data model */\n data: DataModel;\n /** Auth state for visibility evaluation */\n authState?: AuthState;\n /** Get a value by path */\n get: (path: string) => unknown;\n /** Set a value by path */\n set: (path: string, value: unknown) => void;\n /** Update multiple values at once */\n update: (updates: Record<string, unknown>) => void;\n}\n\nconst DataContext = createContext<DataContextValue | null>(null);\n\n/**\n * Props for DataProvider\n */\nexport interface DataProviderProps {\n /** Initial data model */\n initialData?: DataModel;\n /** Auth state */\n authState?: AuthState;\n /** Callback when data changes */\n onDataChange?: (path: string, value: unknown) => void;\n children: ReactNode;\n}\n\n/**\n * Provider for data model context\n */\nexport function DataProvider({\n initialData = {},\n authState,\n onDataChange,\n children,\n}: DataProviderProps) {\n const [data, setData] = useState<DataModel>(initialData);\n\n const get = useCallback((path: string) => getByPath(data, path), [data]);\n\n const set = useCallback(\n (path: string, value: unknown) => {\n setData((prev) => {\n const next = { ...prev };\n setByPath(next, path, value);\n return next;\n });\n onDataChange?.(path, value);\n },\n [onDataChange],\n );\n\n const update = useCallback(\n (updates: Record<string, unknown>) => {\n setData((prev) => {\n const next = { ...prev };\n for (const [path, value] of Object.entries(updates)) {\n setByPath(next, path, value);\n onDataChange?.(path, value);\n }\n return next;\n });\n },\n [onDataChange],\n );\n\n const value = useMemo<DataContextValue>(\n () => ({\n data,\n authState,\n get,\n set,\n update,\n }),\n [data, authState, get, set, update],\n );\n\n return <DataContext.Provider value={value}>{children}</DataContext.Provider>;\n}\n\n/**\n * Hook to access the data context\n */\nexport function useData(): DataContextValue {\n const ctx = useContext(DataContext);\n if (!ctx) {\n throw new Error(\"useData must be used within a DataProvider\");\n }\n return ctx;\n}\n\n/**\n * Hook to get a value from the data model\n */\nexport function useDataValue<T>(path: string): T | undefined {\n const { get } = useData();\n return get(path) as T | undefined;\n}\n\n/**\n * Hook to get and set a value from the data model (like useState)\n */\nexport function useDataBinding<T>(\n path: string,\n): [T | undefined, (value: T) => void] {\n const { get, set } = useData();\n const value = get(path) as T | undefined;\n const setValue = useCallback(\n (newValue: T) => set(path, newValue),\n [path, set],\n );\n return [value, setValue];\n}\n","\"use client\";\n\nimport React, {\n createContext,\n useContext,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport {\n evaluateVisibility,\n type VisibilityCondition,\n type VisibilityContext as CoreVisibilityContext,\n} from \"@json-render/core\";\nimport { useData } from \"./data\";\n\n/**\n * Visibility context value\n */\nexport interface VisibilityContextValue {\n /** Evaluate a visibility condition */\n isVisible: (condition: VisibilityCondition | undefined) => boolean;\n /** The underlying visibility context */\n ctx: CoreVisibilityContext;\n}\n\nconst VisibilityContext = createContext<VisibilityContextValue | null>(null);\n\n/**\n * Props for VisibilityProvider\n */\nexport interface VisibilityProviderProps {\n children: ReactNode;\n}\n\n/**\n * Provider for visibility evaluation\n */\nexport function VisibilityProvider({ children }: VisibilityProviderProps) {\n const { data, authState } = useData();\n\n const ctx: CoreVisibilityContext = useMemo(\n () => ({\n dataModel: data,\n authState,\n }),\n [data, authState],\n );\n\n const isVisible = useMemo(\n () => (condition: VisibilityCondition | undefined) =>\n evaluateVisibility(condition, ctx),\n [ctx],\n );\n\n const value = useMemo<VisibilityContextValue>(\n () => ({ isVisible, ctx }),\n [isVisible, ctx],\n );\n\n return (\n <VisibilityContext.Provider value={value}>\n {children}\n </VisibilityContext.Provider>\n );\n}\n\n/**\n * Hook to access visibility evaluation\n */\nexport function useVisibility(): VisibilityContextValue {\n const ctx = useContext(VisibilityContext);\n if (!ctx) {\n throw new Error(\"useVisibility must be used within a VisibilityProvider\");\n }\n return ctx;\n}\n\n/**\n * Hook to check if a condition is visible\n */\nexport function useIsVisible(\n condition: VisibilityCondition | undefined,\n): boolean {\n const { isVisible } = useVisibility();\n return isVisible(condition);\n}\n","\"use client\";\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport {\n resolveAction,\n executeAction,\n type Action,\n type ActionHandler,\n type ActionConfirm,\n type ResolvedAction,\n} from \"@json-render/core\";\nimport { useData } from \"./data\";\n\n/**\n * Pending confirmation state\n */\nexport interface PendingConfirmation {\n /** The resolved action */\n action: ResolvedAction;\n /** The action handler */\n handler: ActionHandler;\n /** Resolve callback */\n resolve: () => void;\n /** Reject callback */\n reject: () => void;\n}\n\n/**\n * Action context value\n */\nexport interface ActionContextValue {\n /** Registered action handlers */\n handlers: Record<string, ActionHandler>;\n /** Currently loading action names */\n loadingActions: Set<string>;\n /** Pending confirmation dialog */\n pendingConfirmation: PendingConfirmation | null;\n /** Execute an action */\n execute: (action: Action) => Promise<void>;\n /** Confirm the pending action */\n confirm: () => void;\n /** Cancel the pending action */\n cancel: () => void;\n /** Register an action handler */\n registerHandler: (name: string, handler: ActionHandler) => void;\n}\n\nconst ActionContext = createContext<ActionContextValue | null>(null);\n\n/**\n * Props for ActionProvider\n */\nexport interface ActionProviderProps {\n /** Initial action handlers */\n handlers?: Record<string, ActionHandler>;\n /** Navigation function */\n navigate?: (path: string) => void;\n children: ReactNode;\n}\n\n/**\n * Provider for action execution\n */\nexport function ActionProvider({\n handlers: initialHandlers = {},\n navigate,\n children,\n}: ActionProviderProps) {\n const { data, set } = useData();\n const [handlers, setHandlers] =\n useState<Record<string, ActionHandler>>(initialHandlers);\n const [loadingActions, setLoadingActions] = useState<Set<string>>(new Set());\n const [pendingConfirmation, setPendingConfirmation] =\n useState<PendingConfirmation | null>(null);\n\n const registerHandler = useCallback(\n (name: string, handler: ActionHandler) => {\n setHandlers((prev) => ({ ...prev, [name]: handler }));\n },\n [],\n );\n\n const execute = useCallback(\n async (action: Action) => {\n const resolved = resolveAction(action, data);\n const handler = handlers[resolved.name];\n\n if (!handler) {\n console.warn(`No handler registered for action: ${resolved.name}`);\n return;\n }\n\n // If confirmation is required, show dialog\n if (resolved.confirm) {\n return new Promise<void>((resolve, reject) => {\n setPendingConfirmation({\n action: resolved,\n handler,\n resolve: () => {\n setPendingConfirmation(null);\n resolve();\n },\n reject: () => {\n setPendingConfirmation(null);\n reject(new Error(\"Action cancelled\"));\n },\n });\n }).then(async () => {\n setLoadingActions((prev) => new Set(prev).add(resolved.name));\n try {\n await executeAction({\n action: resolved,\n handler,\n setData: set,\n navigate,\n executeAction: async (name) => {\n const subAction: Action = { name };\n await execute(subAction);\n },\n });\n } finally {\n setLoadingActions((prev) => {\n const next = new Set(prev);\n next.delete(resolved.name);\n return next;\n });\n }\n });\n }\n\n // Execute immediately\n setLoadingActions((prev) => new Set(prev).add(resolved.name));\n try {\n await executeAction({\n action: resolved,\n handler,\n setData: set,\n navigate,\n executeAction: async (name) => {\n const subAction: Action = { name };\n await execute(subAction);\n },\n });\n } finally {\n setLoadingActions((prev) => {\n const next = new Set(prev);\n next.delete(resolved.name);\n return next;\n });\n }\n },\n [data, handlers, set, navigate],\n );\n\n const confirm = useCallback(() => {\n pendingConfirmation?.resolve();\n }, [pendingConfirmation]);\n\n const cancel = useCallback(() => {\n pendingConfirmation?.reject();\n }, [pendingConfirmation]);\n\n const value = useMemo<ActionContextValue>(\n () => ({\n handlers,\n loadingActions,\n pendingConfirmation,\n execute,\n confirm,\n cancel,\n registerHandler,\n }),\n [\n handlers,\n loadingActions,\n pendingConfirmation,\n execute,\n confirm,\n cancel,\n registerHandler,\n ],\n );\n\n return (\n <ActionContext.Provider value={value}>{children}</ActionContext.Provider>\n );\n}\n\n/**\n * Hook to access action context\n */\nexport function useActions(): ActionContextValue {\n const ctx = useContext(ActionContext);\n if (!ctx) {\n throw new Error(\"useActions must be used within an ActionProvider\");\n }\n return ctx;\n}\n\n/**\n * Hook to execute an action\n */\nexport function useAction(action: Action): {\n execute: () => Promise<void>;\n isLoading: boolean;\n} {\n const { execute, loadingActions } = useActions();\n const isLoading = loadingActions.has(action.name);\n\n const executeAction = useCallback(() => execute(action), [execute, action]);\n\n return { execute: executeAction, isLoading };\n}\n\n/**\n * Props for ConfirmDialog component\n */\nexport interface ConfirmDialogProps {\n /** The confirmation config */\n confirm: ActionConfirm;\n /** Called when confirmed */\n onConfirm: () => void;\n /** Called when cancelled */\n onCancel: () => void;\n}\n\n/**\n * Default confirmation dialog component\n */\nexport function ConfirmDialog({\n confirm,\n onConfirm,\n onCancel,\n}: ConfirmDialogProps) {\n const isDanger = confirm.variant === \"danger\";\n\n return (\n <div\n style={{\n position: \"fixed\",\n inset: 0,\n backgroundColor: \"rgba(0, 0, 0, 0.5)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n zIndex: 50,\n }}\n onClick={onCancel}\n >\n <div\n style={{\n backgroundColor: \"white\",\n borderRadius: \"8px\",\n padding: \"24px\",\n maxWidth: \"400px\",\n width: \"100%\",\n boxShadow: \"0 20px 25px -5px rgba(0, 0, 0, 0.1)\",\n }}\n onClick={(e) => e.stopPropagation()}\n >\n <h3\n style={{\n margin: \"0 0 8px 0\",\n fontSize: \"18px\",\n fontWeight: 600,\n }}\n >\n {confirm.title}\n </h3>\n <p\n style={{\n margin: \"0 0 24px 0\",\n color: \"#6b7280\",\n }}\n >\n {confirm.message}\n </p>\n <div\n style={{\n display: \"flex\",\n gap: \"12px\",\n justifyContent: \"flex-end\",\n }}\n >\n <button\n onClick={onCancel}\n style={{\n padding: \"8px 16px\",\n borderRadius: \"6px\",\n border: \"1px solid #d1d5db\",\n backgroundColor: \"white\",\n cursor: \"pointer\",\n }}\n >\n {confirm.cancelLabel ?? \"Cancel\"}\n </button>\n <button\n onClick={onConfirm}\n style={{\n padding: \"8px 16px\",\n borderRadius: \"6px\",\n border: \"none\",\n backgroundColor: isDanger ? \"#dc2626\" : \"#3b82f6\",\n color: \"white\",\n cursor: \"pointer\",\n }}\n >\n {confirm.confirmLabel ?? \"Confirm\"}\n </button>\n </div>\n </div>\n </div>\n );\n}\n","\"use client\";\n\nimport React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport {\n runValidation,\n type ValidationConfig,\n type ValidationFunction,\n type ValidationResult,\n} from \"@json-render/core\";\nimport { useData } from \"./data\";\n\n/**\n * Field validation state\n */\nexport interface FieldValidationState {\n /** Whether the field has been touched */\n touched: boolean;\n /** Whether the field has been validated */\n validated: boolean;\n /** Validation result */\n result: ValidationResult | null;\n}\n\n/**\n * Validation context value\n */\nexport interface ValidationContextValue {\n /** Custom validation functions from catalog */\n customFunctions: Record<string, ValidationFunction>;\n /** Validation state by field path */\n fieldStates: Record<string, FieldValidationState>;\n /** Validate a field */\n validate: (path: string, config: ValidationConfig) => ValidationResult;\n /** Mark field as touched */\n touch: (path: string) => void;\n /** Clear validation for a field */\n clear: (path: string) => void;\n /** Validate all fields */\n validateAll: () => boolean;\n /** Register field config */\n registerField: (path: string, config: ValidationConfig) => void;\n}\n\nconst ValidationContext = createContext<ValidationContextValue | null>(null);\n\n/**\n * Props for ValidationProvider\n */\nexport interface ValidationProviderProps {\n /** Custom validation functions from catalog */\n customFunctions?: Record<string, ValidationFunction>;\n children: ReactNode;\n}\n\n/**\n * Provider for validation\n */\nexport function ValidationProvider({\n customFunctions = {},\n children,\n}: ValidationProviderProps) {\n const { data, authState } = useData();\n const [fieldStates, setFieldStates] = useState<\n Record<string, FieldValidationState>\n >({});\n const [fieldConfigs, setFieldConfigs] = useState<\n Record<string, ValidationConfig>\n >({});\n\n const registerField = useCallback(\n (path: string, config: ValidationConfig) => {\n setFieldConfigs((prev) => ({ ...prev, [path]: config }));\n },\n [],\n );\n\n const validate = useCallback(\n (path: string, config: ValidationConfig): ValidationResult => {\n const value = data[path.split(\"/\").filter(Boolean).join(\".\")];\n const result = runValidation(config, {\n value,\n dataModel: data,\n customFunctions,\n authState,\n });\n\n setFieldStates((prev) => ({\n ...prev,\n [path]: {\n touched: prev[path]?.touched ?? true,\n validated: true,\n result,\n },\n }));\n\n return result;\n },\n [data, customFunctions, authState],\n );\n\n const touch = useCallback((path: string) => {\n setFieldStates((prev) => ({\n ...prev,\n [path]: {\n ...prev[path],\n touched: true,\n validated: prev[path]?.validated ?? false,\n result: prev[path]?.result ?? null,\n },\n }));\n }, []);\n\n const clear = useCallback((path: string) => {\n setFieldStates((prev) => {\n const { [path]: _, ...rest } = prev;\n return rest;\n });\n }, []);\n\n const validateAll = useCallback(() => {\n let allValid = true;\n\n for (const [path, config] of Object.entries(fieldConfigs)) {\n const result = validate(path, config);\n if (!result.valid) {\n allValid = false;\n }\n }\n\n return allValid;\n }, [fieldConfigs, validate]);\n\n const value = useMemo<ValidationContextValue>(\n () => ({\n customFunctions,\n fieldStates,\n validate,\n touch,\n clear,\n validateAll,\n registerField,\n }),\n [\n customFunctions,\n fieldStates,\n validate,\n touch,\n clear,\n validateAll,\n registerField,\n ],\n );\n\n return (\n <ValidationContext.Provider value={value}>\n {children}\n </ValidationContext.Provider>\n );\n}\n\n/**\n * Hook to access validation context\n */\nexport function useValidation(): ValidationContextValue {\n const ctx = useContext(ValidationContext);\n if (!ctx) {\n throw new Error(\"useValidation must be used within a ValidationProvider\");\n }\n return ctx;\n}\n\n/**\n * Hook to get validation state for a field\n */\nexport function useFieldValidation(\n path: string,\n config?: ValidationConfig,\n): {\n state: FieldValidationState;\n validate: () => ValidationResult;\n touch: () => void;\n clear: () => void;\n errors: string[];\n isValid: boolean;\n} {\n const {\n fieldStates,\n validate: validateField,\n touch: touchField,\n clear: clearField,\n registerField,\n } = useValidation();\n\n // Register field on mount\n React.useEffect(() => {\n if (config) {\n registerField(path, config);\n }\n }, [path, config, registerField]);\n\n const state = fieldStates[path] ?? {\n touched: false,\n validated: false,\n result: null,\n };\n\n const validate = useCallback(\n () => validateField(path, config ?? { checks: [] }),\n [path, config, validateField],\n );\n\n const touch = useCallback(() => touchField(path), [path, touchField]);\n const clear = useCallback(() => clearField(path), [path, clearField]);\n\n return {\n state,\n validate,\n touch,\n clear,\n errors: state.result?.errors ?? [],\n isValid: state.result?.valid ?? true,\n };\n}\n","\"use client\";\n\nimport React, { type ComponentType, type ReactNode, useMemo } from \"react\";\nimport type {\n UIElement,\n UITree,\n Action,\n Catalog,\n ComponentDefinition,\n} from \"@json-render/core\";\nimport { useIsVisible } from \"./contexts/visibility\";\nimport { useActions } from \"./contexts/actions\";\nimport { useData } from \"./contexts/data\";\n\n/**\n * Props passed to component renderers\n */\nexport interface ComponentRenderProps<P = Record<string, unknown>> {\n /** The element being rendered */\n element: UIElement<string, P>;\n /** Rendered children */\n children?: ReactNode;\n /** Execute an action */\n onAction?: (action: Action) => void;\n /** Whether the parent is loading */\n loading?: boolean;\n}\n\n/**\n * Component renderer type\n */\nexport type ComponentRenderer<P = Record<string, unknown>> = ComponentType<\n ComponentRenderProps<P>\n>;\n\n/**\n * Registry of component renderers\n */\nexport type ComponentRegistry = Record<string, ComponentRenderer<any>>;\n\n/**\n * Props for the Renderer component\n */\nexport interface RendererProps {\n /** The UI tree to render */\n tree: UITree | null;\n /** Component registry */\n registry: ComponentRegistry;\n /** Whether the tree is currently loading/streaming */\n loading?: boolean;\n /** Fallback component for unknown types */\n fallback?: ComponentRenderer;\n}\n\n/**\n * Element renderer component\n */\nfunction ElementRenderer({\n element,\n tree,\n registry,\n loading,\n fallback,\n}: {\n element: UIElement;\n tree: UITree;\n registry: ComponentRegistry;\n loading?: boolean;\n fallback?: ComponentRenderer;\n}) {\n const isVisible = useIsVisible(element.visible);\n const { execute } = useActions();\n\n // Don't render if not visible\n if (!isVisible) {\n return null;\n }\n\n // Get the component renderer\n const Component = registry[element.type] ?? fallback;\n\n if (!Component) {\n console.warn(`No renderer for component type: ${element.type}`);\n return null;\n }\n\n // Render children\n const children = element.children?.map((childKey) => {\n const childElement = tree.elements[childKey];\n if (!childElement) {\n return null;\n }\n return (\n <ElementRenderer\n key={childKey}\n element={childElement}\n tree={tree}\n registry={registry}\n loading={loading}\n fallback={fallback}\n />\n );\n });\n\n return (\n <Component element={element} onAction={execute} loading={loading}>\n {children}\n </Component>\n );\n}\n\n/**\n * Main renderer component\n */\nexport function Renderer({ tree, registry, loading, fallback }: RendererProps) {\n if (!tree || !tree.root) {\n return null;\n }\n\n const rootElement = tree.elements[tree.root];\n if (!rootElement) {\n return null;\n }\n\n return (\n <ElementRenderer\n element={rootElement}\n tree={tree}\n registry={registry}\n loading={loading}\n fallback={fallback}\n />\n );\n}\n\n/**\n * Props for JSONUIProvider\n */\nexport interface JSONUIProviderProps {\n /** Component registry */\n registry: ComponentRegistry;\n /** Initial data model */\n initialData?: Record<string, unknown>;\n /** Auth state */\n authState?: { isSignedIn: boolean; user?: Record<string, unknown> };\n /** Action handlers */\n actionHandlers?: Record<\n string,\n (params: Record<string, unknown>) => Promise<unknown> | unknown\n >;\n /** Navigation function */\n navigate?: (path: string) => void;\n /** Custom validation functions */\n validationFunctions?: Record<\n string,\n (value: unknown, args?: Record<string, unknown>) => boolean\n >;\n /** Callback when data changes */\n onDataChange?: (path: string, value: unknown) => void;\n children: ReactNode;\n}\n\n// Import the providers\nimport { DataProvider } from \"./contexts/data\";\nimport { VisibilityProvider } from \"./contexts/visibility\";\nimport { ActionProvider } from \"./contexts/actions\";\nimport { ValidationProvider } from \"./contexts/validation\";\nimport { ConfirmDialog } from \"./contexts/actions\";\n\n/**\n * Combined provider for all JSONUI contexts\n */\nexport function JSONUIProvider({\n registry,\n initialData,\n authState,\n actionHandlers,\n navigate,\n validationFunctions,\n onDataChange,\n children,\n}: JSONUIProviderProps) {\n return (\n <DataProvider\n initialData={initialData}\n authState={authState}\n onDataChange={onDataChange}\n >\n <VisibilityProvider>\n <ActionProvider handlers={actionHandlers} navigate={navigate}>\n <ValidationProvider customFunctions={validationFunctions}>\n {children}\n <ConfirmationDialogManager />\n </ValidationProvider>\n </ActionProvider>\n </VisibilityProvider>\n </DataProvider>\n );\n}\n\n/**\n * Renders the confirmation dialog when needed\n */\nfunction ConfirmationDialogManager() {\n const { pendingConfirmation, confirm, cancel } = useActions();\n\n if (!pendingConfirmation?.action.confirm) {\n return null;\n }\n\n return (\n <ConfirmDialog\n confirm={pendingConfirmation.action.confirm}\n onConfirm={confirm}\n onCancel={cancel}\n />\n );\n}\n\n/**\n * Helper to create a renderer component from a catalog\n */\nexport function createRendererFromCatalog<\n C extends Catalog<Record<string, ComponentDefinition>>,\n>(\n _catalog: C,\n registry: ComponentRegistry,\n): ComponentType<Omit<RendererProps, \"registry\">> {\n return function CatalogRenderer(props: Omit<RendererProps, \"registry\">) {\n return <Renderer {...props} registry={registry} />;\n };\n}\n","\"use client\";\n\nimport { useState, useCallback, useRef, useEffect } from \"react\";\nimport type { UITree, UIElement, JsonPatch } from \"@json-render/core\";\nimport { setByPath } from \"@json-render/core\";\n\n/**\n * Parse a single JSON patch line\n */\nfunction parsePatchLine(line: string): JsonPatch | null {\n try {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"//\")) {\n return null;\n }\n return JSON.parse(trimmed) as JsonPatch;\n } catch {\n return null;\n }\n}\n\n/**\n * Apply a JSON patch to the current tree\n */\nfunction applyPatch(tree: UITree, patch: JsonPatch): UITree {\n const newTree = { ...tree, elements: { ...tree.elements } };\n\n switch (patch.op) {\n case \"set\":\n case \"add\":\n case \"replace\": {\n // Handle root path\n if (patch.path === \"/root\") {\n newTree.root = patch.value as string;\n return newTree;\n }\n\n // Handle elements paths\n if (patch.path.startsWith(\"/elements/\")) {\n const pathParts = patch.path.slice(\"/elements/\".length).split(\"/\");\n const elementKey = pathParts[0];\n\n if (!elementKey) return newTree;\n\n if (pathParts.length === 1) {\n // Setting entire element\n newTree.elements[elementKey] = patch.value as UIElement;\n } else {\n // Setting property of element\n const element = newTree.elements[elementKey];\n if (element) {\n const propPath = \"/\" + pathParts.slice(1).join(\"/\");\n const newElement = { ...element };\n setByPath(\n newElement as unknown as Record<string, unknown>,\n propPath,\n patch.value,\n );\n newTree.elements[elementKey] = newElement;\n }\n }\n }\n break;\n }\n case \"remove\": {\n if (patch.path.startsWith(\"/elements/\")) {\n const elementKey = patch.path.slice(\"/elements/\".length).split(\"/\")[0];\n if (elementKey) {\n const { [elementKey]: _, ...rest } = newTree.elements;\n newTree.elements = rest;\n }\n }\n break;\n }\n }\n\n return newTree;\n}\n\n/**\n * Options for useUIStream\n */\nexport interface UseUIStreamOptions {\n /** API endpoint */\n api: string;\n /** Callback when complete */\n onComplete?: (tree: UITree) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n}\n\n/**\n * Return type for useUIStream\n */\nexport interface UseUIStreamReturn {\n /** Current UI tree */\n tree: UITree | null;\n /** Whether currently streaming */\n isStreaming: boolean;\n /** Error if any */\n error: Error | null;\n /** Send a prompt to generate UI */\n send: (prompt: string, context?: Record<string, unknown>) => Promise<void>;\n /** Clear the current tree */\n clear: () => void;\n}\n\n/**\n * Hook for streaming UI generation\n */\nexport function useUIStream({\n api,\n onComplete,\n onError,\n}: UseUIStreamOptions): UseUIStreamReturn {\n const [tree, setTree] = useState<UITree | null>(null);\n const [isStreaming, setIsStreaming] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const clear = useCallback(() => {\n setTree(null);\n setError(null);\n }, []);\n\n const send = useCallback(\n async (prompt: string, context?: Record<string, unknown>) => {\n // Abort any existing request\n abortControllerRef.current?.abort();\n abortControllerRef.current = new AbortController();\n\n setIsStreaming(true);\n setError(null);\n\n // Start with an empty tree\n let currentTree: UITree = { root: \"\", elements: {} };\n setTree(currentTree);\n\n try {\n const response = await fetch(api, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n prompt,\n context,\n currentTree,\n }),\n signal: abortControllerRef.current.signal,\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error: ${response.status}`);\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"No response body\");\n }\n\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n\n // Process complete lines\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n\n for (const line of lines) {\n const patch = parsePatchLine(line);\n if (patch) {\n currentTree = applyPatch(currentTree, patch);\n setTree({ ...currentTree });\n }\n }\n }\n\n // Process any remaining buffer\n if (buffer.trim()) {\n const patch = parsePatchLine(buffer);\n if (patch) {\n currentTree = applyPatch(currentTree, patch);\n setTree({ ...currentTree });\n }\n }\n\n onComplete?.(currentTree);\n } catch (err) {\n if ((err as Error).name === \"AbortError\") {\n return;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n setError(error);\n onError?.(error);\n } finally {\n setIsStreaming(false);\n }\n },\n [api, onComplete, onError],\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n abortControllerRef.current?.abort();\n };\n }, []);\n\n return {\n tree,\n isStreaming,\n error,\n send,\n clear,\n };\n}\n\n/**\n * Convert a flat element list to a UITree\n */\nexport function flatToTree(\n elements: Array<UIElement & { parentKey?: string | null }>,\n): UITree {\n const elementMap: Record<string, UIElement> = {};\n let root = \"\";\n\n // First pass: add all elements to map\n for (const element of elements) {\n elementMap[element.key] = {\n key: element.key,\n type: element.type,\n props: element.props,\n children: [],\n visible: element.visible,\n };\n }\n\n // Second pass: build parent-child relationships\n for (const element of elements) {\n if (element.parentKey) {\n const parent = elementMap[element.parentKey];\n if (parent) {\n if (!parent.children) {\n parent.children = [];\n }\n parent.children.push(element.key);\n }\n } else {\n root = element.key;\n }\n }\n\n return { root, elements: elementMap };\n}\n"],"mappings":";AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAmFE;AAjET,IAAM,cAAc,cAAuC,IAAI;AAkBxD,SAAS,aAAa;AAAA,EAC3B,cAAc,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AACF,GAAsB;AACpB,QA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AG,YAAY,CAAC;AAAA,UAC5B;AAAA,QACF;AAEA,qBAAa,WAAW;AAAA,MAC1B,SAAS,KAAK;AACZ,YAAK,IAAc,SAAS,cAAc;AACxC;AAAA,QACF;AACA,cAAME,SAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;AAChE,iBAASA,MAAK;AACd,kBAAUA,MAAK;AAAA,MACjB,UAAE;AACA,uBAAe,KAAK;AAAA,MACtB;AAAA,IACF;AAAA,IACA,CAAC,KAAK,YAAY,OAAO;AAAA,EAC3B;AAGA,YAAU,MAAM;AACd,WAAO,MAAM;AACX,yBAAmB,SAAS,MAAM;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAKO,SAAS,WACd,UACQ;AACR,QAAM,aAAwC,CAAC;AAC/C,MAAI,OAAO;AAGX,aAAW,WAAW,UAAU;AAC9B,eAAW,QAAQ,GAAG,IAAI;AAAA,MACxB,KAAK,QAAQ;AAAA,MACb,MAAM,QAAQ;AAAA,MACd,OAAO,QAAQ;AAAA,MACf,UAAU,CAAC;AAAA,MACX,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF;AAGA,aAAW,WAAW,UAAU;AAC9B,QAAI,QAAQ,WAAW;AACrB,YAAM,SAAS,WAAW,QAAQ,SAAS;AAC3C,UAAI,QAAQ;AACV,YAAI,CAAC,OAAO,UAAU;AACpB,iBAAO,WAAW,CAAC;AAAA,QACrB;AACA,eAAO,SAAS,KAAK,QAAQ,GAAG;AAAA,MAClC;AAAA,IACF,OAAO;AACL,aAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AAEA,SAAO,EAAE,MAAM,UAAU,WAAW;AACtC;","names":["value","createContext","useContext","useMemo","jsx","createContext","useMemo","useContext","createContext","useContext","useState","useCallback","useMemo","jsx","createContext","useState","useCallback","useMemo","useContext","executeAction","React","createContext","useContext","useState","useCallback","useMemo","jsx","createContext","useState","useCallback","value","useMemo","useContext","React","jsx","jsxs","useState","useCallback","setByPath","error"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@json-render/react",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "React renderer for @json-render/core. JSON becomes React components.",
|
|
6
6
|
"keywords": [
|
|
@@ -39,21 +39,21 @@
|
|
|
39
39
|
"files": [
|
|
40
40
|
"dist"
|
|
41
41
|
],
|
|
42
|
-
"scripts": {
|
|
43
|
-
"build": "tsup",
|
|
44
|
-
"dev": "tsup --watch",
|
|
45
|
-
"typecheck": "tsc --noEmit"
|
|
46
|
-
},
|
|
47
42
|
"dependencies": {
|
|
48
|
-
"@json-render/core": "
|
|
43
|
+
"@json-render/core": "0.2.0"
|
|
49
44
|
},
|
|
50
45
|
"devDependencies": {
|
|
51
|
-
"@repo/typescript-config": "workspace:*",
|
|
52
46
|
"@types/react": "19.2.3",
|
|
53
47
|
"tsup": "^8.0.2",
|
|
54
|
-
"typescript": "^5.4.5"
|
|
48
|
+
"typescript": "^5.4.5",
|
|
49
|
+
"@repo/typescript-config": "0.0.0"
|
|
55
50
|
},
|
|
56
51
|
"peerDependencies": {
|
|
57
52
|
"react": "^19.0.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsup",
|
|
56
|
+
"dev": "tsup --watch",
|
|
57
|
+
"typecheck": "tsc --noEmit"
|
|
58
58
|
}
|
|
59
|
-
}
|
|
59
|
+
}
|