@json-render/react-native 0.9.0 → 0.9.1
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/dist/index.d.mts +66 -3
- package/dist/index.d.ts +66 -3
- package/dist/index.js +304 -185
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +267 -142
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -7,45 +7,170 @@ import {
|
|
|
7
7
|
schema
|
|
8
8
|
} from "./chunk-T27PQA6P.mjs";
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// ../react-state/dist/index.mjs
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
createContext,
|
|
13
|
+
useContext,
|
|
14
|
+
useCallback,
|
|
15
|
+
useEffect,
|
|
16
|
+
useMemo,
|
|
17
|
+
useRef,
|
|
18
|
+
useSyncExternalStore
|
|
19
|
+
} from "react";
|
|
20
|
+
import {
|
|
21
|
+
getByPath,
|
|
22
|
+
createStateStore
|
|
23
|
+
} from "@json-render/core";
|
|
24
|
+
import { flattenToPointers } from "@json-render/core/store-utils";
|
|
25
|
+
import { jsx } from "react/jsx-runtime";
|
|
26
|
+
var StateContext = createContext(null);
|
|
27
|
+
function computeInitialFlat(isControlled, initialState) {
|
|
28
|
+
if (isControlled) return null;
|
|
29
|
+
if (Object.keys(initialState).length === 0) return {};
|
|
30
|
+
return flattenToPointers(initialState);
|
|
31
|
+
}
|
|
32
|
+
function StateProvider({
|
|
33
|
+
store: externalStore,
|
|
34
|
+
initialState = {},
|
|
35
|
+
onStateChange,
|
|
36
|
+
children
|
|
37
|
+
}) {
|
|
38
|
+
const internalStoreRef = useRef(void 0);
|
|
39
|
+
if (!externalStore && !internalStoreRef.current) {
|
|
40
|
+
internalStoreRef.current = createStateStore(initialState);
|
|
41
|
+
}
|
|
42
|
+
const store = externalStore ?? internalStoreRef.current;
|
|
43
|
+
const storeRef = useRef(store);
|
|
44
|
+
storeRef.current = store;
|
|
45
|
+
const isControlledRef = useRef(!!externalStore);
|
|
46
|
+
isControlledRef.current = !!externalStore;
|
|
47
|
+
const initialModeRef = useRef(externalStore ? "controlled" : "uncontrolled");
|
|
48
|
+
const modeWarnedRef = useRef(false);
|
|
49
|
+
if (process.env.NODE_ENV !== "production") {
|
|
50
|
+
const currentMode = externalStore ? "controlled" : "uncontrolled";
|
|
51
|
+
if (currentMode !== initialModeRef.current && !modeWarnedRef.current) {
|
|
52
|
+
modeWarnedRef.current = true;
|
|
53
|
+
console.warn(
|
|
54
|
+
`StateProvider: switching from ${initialModeRef.current} to ${currentMode} mode is not supported.`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const prevInitialStateRef = useRef(initialState);
|
|
59
|
+
const prevFlatRef = useRef(
|
|
60
|
+
computeInitialFlat(!!externalStore, initialState)
|
|
61
|
+
);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (externalStore) return;
|
|
64
|
+
if (initialState === prevInitialStateRef.current) return;
|
|
65
|
+
prevInitialStateRef.current = initialState;
|
|
66
|
+
const nextFlat = initialState && Object.keys(initialState).length > 0 ? flattenToPointers(initialState) : {};
|
|
67
|
+
const prevFlat = prevFlatRef.current ?? {};
|
|
68
|
+
const allKeys = /* @__PURE__ */ new Set([
|
|
69
|
+
...Object.keys(prevFlat),
|
|
70
|
+
...Object.keys(nextFlat)
|
|
71
|
+
]);
|
|
72
|
+
const updates = {};
|
|
73
|
+
for (const key of allKeys) {
|
|
74
|
+
if (prevFlat[key] !== nextFlat[key]) {
|
|
75
|
+
updates[key] = key in nextFlat ? nextFlat[key] : void 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
prevFlatRef.current = nextFlat;
|
|
79
|
+
if (Object.keys(updates).length > 0) {
|
|
80
|
+
store.update(updates);
|
|
81
|
+
}
|
|
82
|
+
}, [externalStore, initialState, store]);
|
|
83
|
+
const state = useSyncExternalStore(
|
|
84
|
+
store.subscribe,
|
|
85
|
+
store.getSnapshot,
|
|
86
|
+
store.getServerSnapshot ?? store.getSnapshot
|
|
87
|
+
);
|
|
88
|
+
const onStateChangeRef = useRef(onStateChange);
|
|
89
|
+
onStateChangeRef.current = onStateChange;
|
|
90
|
+
const set = useCallback((path, value2) => {
|
|
91
|
+
const s = storeRef.current;
|
|
92
|
+
const prev = s.getSnapshot();
|
|
93
|
+
s.set(path, value2);
|
|
94
|
+
if (!isControlledRef.current && s.getSnapshot() !== prev) {
|
|
95
|
+
onStateChangeRef.current?.([{ path, value: value2 }]);
|
|
96
|
+
}
|
|
97
|
+
}, []);
|
|
98
|
+
const update = useCallback((updates) => {
|
|
99
|
+
const s = storeRef.current;
|
|
100
|
+
const prev = s.getSnapshot();
|
|
101
|
+
s.update(updates);
|
|
102
|
+
if (!isControlledRef.current && s.getSnapshot() !== prev) {
|
|
103
|
+
const changes = [];
|
|
104
|
+
for (const [path, value2] of Object.entries(updates)) {
|
|
105
|
+
if (getByPath(prev, path) !== value2) {
|
|
106
|
+
changes.push({ path, value: value2 });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (changes.length > 0) {
|
|
110
|
+
onStateChangeRef.current?.(changes);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, []);
|
|
114
|
+
const get = useCallback((path) => storeRef.current.get(path), []);
|
|
115
|
+
const getSnapshot = useCallback(() => storeRef.current.getSnapshot(), []);
|
|
116
|
+
const value = useMemo(
|
|
117
|
+
() => ({ state, get, set, update, getSnapshot }),
|
|
118
|
+
[state, get, set, update, getSnapshot]
|
|
119
|
+
);
|
|
120
|
+
return /* @__PURE__ */ jsx(StateContext.Provider, { value, children });
|
|
121
|
+
}
|
|
122
|
+
function useStateStore() {
|
|
123
|
+
const ctx = useContext(StateContext);
|
|
124
|
+
if (!ctx) {
|
|
125
|
+
throw new Error("useStateStore must be used within a StateProvider");
|
|
126
|
+
}
|
|
127
|
+
return ctx;
|
|
128
|
+
}
|
|
129
|
+
function useStateValue(path) {
|
|
130
|
+
const { state } = useStateStore();
|
|
131
|
+
return getByPath(state, path);
|
|
132
|
+
}
|
|
133
|
+
function useStateBinding(path) {
|
|
134
|
+
const { state, set } = useStateStore();
|
|
135
|
+
const value = getByPath(state, path);
|
|
136
|
+
const setValue = useCallback(
|
|
137
|
+
(newValue) => set(path, newValue),
|
|
138
|
+
[path, set]
|
|
139
|
+
);
|
|
140
|
+
return [value, setValue];
|
|
141
|
+
}
|
|
17
142
|
|
|
18
143
|
// src/contexts/visibility.tsx
|
|
19
144
|
import {
|
|
20
|
-
createContext,
|
|
21
|
-
useContext,
|
|
22
|
-
useMemo
|
|
145
|
+
createContext as createContext2,
|
|
146
|
+
useContext as useContext2,
|
|
147
|
+
useMemo as useMemo2
|
|
23
148
|
} from "react";
|
|
24
149
|
import {
|
|
25
150
|
evaluateVisibility
|
|
26
151
|
} from "@json-render/core";
|
|
27
|
-
import { jsx } from "react/jsx-runtime";
|
|
28
|
-
var VisibilityContext =
|
|
152
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
153
|
+
var VisibilityContext = createContext2(null);
|
|
29
154
|
function VisibilityProvider({ children }) {
|
|
30
155
|
const { state } = useStateStore();
|
|
31
|
-
const ctx =
|
|
156
|
+
const ctx = useMemo2(
|
|
32
157
|
() => ({
|
|
33
158
|
stateModel: state
|
|
34
159
|
}),
|
|
35
160
|
[state]
|
|
36
161
|
);
|
|
37
|
-
const isVisible =
|
|
162
|
+
const isVisible = useMemo2(
|
|
38
163
|
() => (condition) => evaluateVisibility(condition, ctx),
|
|
39
164
|
[ctx]
|
|
40
165
|
);
|
|
41
|
-
const value =
|
|
166
|
+
const value = useMemo2(
|
|
42
167
|
() => ({ isVisible, ctx }),
|
|
43
168
|
[isVisible, ctx]
|
|
44
169
|
);
|
|
45
|
-
return /* @__PURE__ */
|
|
170
|
+
return /* @__PURE__ */ jsx2(VisibilityContext.Provider, { value, children });
|
|
46
171
|
}
|
|
47
172
|
function useVisibility() {
|
|
48
|
-
const ctx =
|
|
173
|
+
const ctx = useContext2(VisibilityContext);
|
|
49
174
|
if (!ctx) {
|
|
50
175
|
throw new Error("useVisibility must be used within a VisibilityProvider");
|
|
51
176
|
}
|
|
@@ -58,18 +183,18 @@ function useIsVisible(condition) {
|
|
|
58
183
|
|
|
59
184
|
// src/contexts/actions.tsx
|
|
60
185
|
import {
|
|
61
|
-
createContext as
|
|
62
|
-
useContext as
|
|
186
|
+
createContext as createContext3,
|
|
187
|
+
useContext as useContext3,
|
|
63
188
|
useState,
|
|
64
|
-
useCallback,
|
|
65
|
-
useMemo as
|
|
189
|
+
useCallback as useCallback2,
|
|
190
|
+
useMemo as useMemo3
|
|
66
191
|
} from "react";
|
|
67
192
|
import { Modal, View, Text, Pressable, StyleSheet } from "react-native";
|
|
68
193
|
import {
|
|
69
194
|
resolveAction,
|
|
70
195
|
executeAction
|
|
71
196
|
} from "@json-render/core";
|
|
72
|
-
import { jsx as
|
|
197
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
73
198
|
var idCounter = 0;
|
|
74
199
|
function generateUniqueId() {
|
|
75
200
|
idCounter += 1;
|
|
@@ -102,7 +227,7 @@ function deepResolveValue(value, get) {
|
|
|
102
227
|
}
|
|
103
228
|
return value;
|
|
104
229
|
}
|
|
105
|
-
var ActionContext =
|
|
230
|
+
var ActionContext = createContext3(null);
|
|
106
231
|
function ActionProvider({
|
|
107
232
|
handlers: initialHandlers = {},
|
|
108
233
|
navigate,
|
|
@@ -112,13 +237,13 @@ function ActionProvider({
|
|
|
112
237
|
const [handlers, setHandlers] = useState(initialHandlers);
|
|
113
238
|
const [loadingActions, setLoadingActions] = useState(/* @__PURE__ */ new Set());
|
|
114
239
|
const [pendingConfirmation, setPendingConfirmation] = useState(null);
|
|
115
|
-
const registerHandler =
|
|
240
|
+
const registerHandler = useCallback2(
|
|
116
241
|
(name, handler) => {
|
|
117
242
|
setHandlers((prev) => ({ ...prev, [name]: handler }));
|
|
118
243
|
},
|
|
119
244
|
[]
|
|
120
245
|
);
|
|
121
|
-
const execute =
|
|
246
|
+
const execute = useCallback2(
|
|
122
247
|
async (binding) => {
|
|
123
248
|
const resolved = resolveAction(binding, getSnapshot());
|
|
124
249
|
if (resolved.action === "setState" && resolved.params) {
|
|
@@ -245,13 +370,13 @@ function ActionProvider({
|
|
|
245
370
|
},
|
|
246
371
|
[handlers, get, set, getSnapshot, navigate]
|
|
247
372
|
);
|
|
248
|
-
const confirm =
|
|
373
|
+
const confirm = useCallback2(() => {
|
|
249
374
|
pendingConfirmation?.resolve();
|
|
250
375
|
}, [pendingConfirmation]);
|
|
251
|
-
const cancel =
|
|
376
|
+
const cancel = useCallback2(() => {
|
|
252
377
|
pendingConfirmation?.reject();
|
|
253
378
|
}, [pendingConfirmation]);
|
|
254
|
-
const value =
|
|
379
|
+
const value = useMemo3(
|
|
255
380
|
() => ({
|
|
256
381
|
handlers,
|
|
257
382
|
loadingActions,
|
|
@@ -271,10 +396,10 @@ function ActionProvider({
|
|
|
271
396
|
registerHandler
|
|
272
397
|
]
|
|
273
398
|
);
|
|
274
|
-
return /* @__PURE__ */
|
|
399
|
+
return /* @__PURE__ */ jsx3(ActionContext.Provider, { value, children });
|
|
275
400
|
}
|
|
276
401
|
function useActions() {
|
|
277
|
-
const ctx =
|
|
402
|
+
const ctx = useContext3(ActionContext);
|
|
278
403
|
if (!ctx) {
|
|
279
404
|
throw new Error("useActions must be used within an ActionProvider");
|
|
280
405
|
}
|
|
@@ -283,7 +408,7 @@ function useActions() {
|
|
|
283
408
|
function useAction(binding) {
|
|
284
409
|
const { execute, loadingActions } = useActions();
|
|
285
410
|
const isLoading = loadingActions.has(binding.action);
|
|
286
|
-
const executeAction2 =
|
|
411
|
+
const executeAction2 = useCallback2(() => execute(binding), [execute, binding]);
|
|
287
412
|
return { execute: executeAction2, isLoading };
|
|
288
413
|
}
|
|
289
414
|
function ConfirmDialog({
|
|
@@ -292,13 +417,13 @@ function ConfirmDialog({
|
|
|
292
417
|
onCancel
|
|
293
418
|
}) {
|
|
294
419
|
const isDanger = confirm.variant === "danger";
|
|
295
|
-
return /* @__PURE__ */
|
|
420
|
+
return /* @__PURE__ */ jsx3(Modal, { transparent: true, animationType: "fade", visible: true, onRequestClose: onCancel, children: /* @__PURE__ */ jsx3(Pressable, { style: styles.overlay, onPress: onCancel, children: /* @__PURE__ */ jsxs(Pressable, { style: styles.dialog, onPress: () => {
|
|
296
421
|
}, children: [
|
|
297
|
-
/* @__PURE__ */
|
|
298
|
-
/* @__PURE__ */
|
|
422
|
+
/* @__PURE__ */ jsx3(Text, { style: styles.title, children: confirm.title }),
|
|
423
|
+
/* @__PURE__ */ jsx3(Text, { style: styles.message, children: confirm.message }),
|
|
299
424
|
/* @__PURE__ */ jsxs(View, { style: styles.buttons, children: [
|
|
300
|
-
/* @__PURE__ */
|
|
301
|
-
/* @__PURE__ */
|
|
425
|
+
/* @__PURE__ */ jsx3(Pressable, { style: styles.cancelButton, onPress: onCancel, children: /* @__PURE__ */ jsx3(Text, { style: styles.cancelButtonText, children: confirm.cancelLabel ?? "Cancel" }) }),
|
|
426
|
+
/* @__PURE__ */ jsx3(
|
|
302
427
|
Pressable,
|
|
303
428
|
{
|
|
304
429
|
style: [
|
|
@@ -306,7 +431,7 @@ function ConfirmDialog({
|
|
|
306
431
|
isDanger && styles.confirmButtonDanger
|
|
307
432
|
],
|
|
308
433
|
onPress: onConfirm,
|
|
309
|
-
children: /* @__PURE__ */
|
|
434
|
+
children: /* @__PURE__ */ jsx3(Text, { style: styles.confirmButtonText, children: confirm.confirmLabel ?? "Confirm" })
|
|
310
435
|
}
|
|
311
436
|
)
|
|
312
437
|
] })
|
|
@@ -375,17 +500,17 @@ var styles = StyleSheet.create({
|
|
|
375
500
|
|
|
376
501
|
// src/contexts/validation.tsx
|
|
377
502
|
import React3, {
|
|
378
|
-
createContext as
|
|
379
|
-
useContext as
|
|
503
|
+
createContext as createContext4,
|
|
504
|
+
useContext as useContext4,
|
|
380
505
|
useState as useState2,
|
|
381
|
-
useCallback as
|
|
382
|
-
useMemo as
|
|
506
|
+
useCallback as useCallback3,
|
|
507
|
+
useMemo as useMemo4
|
|
383
508
|
} from "react";
|
|
384
509
|
import {
|
|
385
510
|
runValidation
|
|
386
511
|
} from "@json-render/core";
|
|
387
|
-
import { jsx as
|
|
388
|
-
var ValidationContext =
|
|
512
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
513
|
+
var ValidationContext = createContext4(null);
|
|
389
514
|
function dynamicArgsEqual(a, b) {
|
|
390
515
|
if (a === b) return true;
|
|
391
516
|
if (!a || !b) return false;
|
|
@@ -427,7 +552,7 @@ function ValidationProvider({
|
|
|
427
552
|
const { state } = useStateStore();
|
|
428
553
|
const [fieldStates, setFieldStates] = useState2({});
|
|
429
554
|
const [fieldConfigs, setFieldConfigs] = useState2({});
|
|
430
|
-
const registerField =
|
|
555
|
+
const registerField = useCallback3(
|
|
431
556
|
(path, config) => {
|
|
432
557
|
setFieldConfigs((prev) => {
|
|
433
558
|
const existing = prev[path];
|
|
@@ -439,7 +564,7 @@ function ValidationProvider({
|
|
|
439
564
|
},
|
|
440
565
|
[]
|
|
441
566
|
);
|
|
442
|
-
const validate =
|
|
567
|
+
const validate = useCallback3(
|
|
443
568
|
(path, config) => {
|
|
444
569
|
const segments = path.split("/").filter(Boolean);
|
|
445
570
|
let value2 = state;
|
|
@@ -468,7 +593,7 @@ function ValidationProvider({
|
|
|
468
593
|
},
|
|
469
594
|
[state, customFunctions]
|
|
470
595
|
);
|
|
471
|
-
const touch =
|
|
596
|
+
const touch = useCallback3((path) => {
|
|
472
597
|
setFieldStates((prev) => ({
|
|
473
598
|
...prev,
|
|
474
599
|
[path]: {
|
|
@@ -479,13 +604,13 @@ function ValidationProvider({
|
|
|
479
604
|
}
|
|
480
605
|
}));
|
|
481
606
|
}, []);
|
|
482
|
-
const clear =
|
|
607
|
+
const clear = useCallback3((path) => {
|
|
483
608
|
setFieldStates((prev) => {
|
|
484
609
|
const { [path]: _, ...rest } = prev;
|
|
485
610
|
return rest;
|
|
486
611
|
});
|
|
487
612
|
}, []);
|
|
488
|
-
const validateAll =
|
|
613
|
+
const validateAll = useCallback3(() => {
|
|
489
614
|
let allValid = true;
|
|
490
615
|
for (const [path, config] of Object.entries(fieldConfigs)) {
|
|
491
616
|
const result = validate(path, config);
|
|
@@ -495,7 +620,7 @@ function ValidationProvider({
|
|
|
495
620
|
}
|
|
496
621
|
return allValid;
|
|
497
622
|
}, [fieldConfigs, validate]);
|
|
498
|
-
const value =
|
|
623
|
+
const value = useMemo4(
|
|
499
624
|
() => ({
|
|
500
625
|
customFunctions,
|
|
501
626
|
fieldStates,
|
|
@@ -515,10 +640,10 @@ function ValidationProvider({
|
|
|
515
640
|
registerField
|
|
516
641
|
]
|
|
517
642
|
);
|
|
518
|
-
return /* @__PURE__ */
|
|
643
|
+
return /* @__PURE__ */ jsx4(ValidationContext.Provider, { value, children });
|
|
519
644
|
}
|
|
520
645
|
function useValidation() {
|
|
521
|
-
const ctx =
|
|
646
|
+
const ctx = useContext4(ValidationContext);
|
|
522
647
|
if (!ctx) {
|
|
523
648
|
throw new Error("useValidation must be used within a ValidationProvider");
|
|
524
649
|
}
|
|
@@ -542,12 +667,12 @@ function useFieldValidation(path, config) {
|
|
|
542
667
|
validated: false,
|
|
543
668
|
result: null
|
|
544
669
|
};
|
|
545
|
-
const validate =
|
|
670
|
+
const validate = useCallback3(
|
|
546
671
|
() => validateField(path, config ?? { checks: [] }),
|
|
547
672
|
[path, config, validateField]
|
|
548
673
|
);
|
|
549
|
-
const touch =
|
|
550
|
-
const clear =
|
|
674
|
+
const touch = useCallback3(() => touchField(path), [path, touchField]);
|
|
675
|
+
const clear = useCallback3(() => clearField(path), [path, clearField]);
|
|
551
676
|
return {
|
|
552
677
|
state,
|
|
553
678
|
validate,
|
|
@@ -559,35 +684,35 @@ function useFieldValidation(path, config) {
|
|
|
559
684
|
}
|
|
560
685
|
|
|
561
686
|
// src/contexts/repeat-scope.tsx
|
|
562
|
-
import { createContext as
|
|
563
|
-
import { jsx as
|
|
564
|
-
var RepeatScopeContext =
|
|
687
|
+
import { createContext as createContext5, useContext as useContext5 } from "react";
|
|
688
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
689
|
+
var RepeatScopeContext = createContext5(null);
|
|
565
690
|
function RepeatScopeProvider({
|
|
566
691
|
item,
|
|
567
692
|
index,
|
|
568
693
|
basePath,
|
|
569
694
|
children
|
|
570
695
|
}) {
|
|
571
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ jsx5(RepeatScopeContext.Provider, { value: { item, index, basePath }, children });
|
|
572
697
|
}
|
|
573
698
|
function useRepeatScope() {
|
|
574
|
-
return
|
|
699
|
+
return useContext5(RepeatScopeContext);
|
|
575
700
|
}
|
|
576
701
|
|
|
577
702
|
// src/index.ts
|
|
578
|
-
import { createStateStore } from "@json-render/core";
|
|
703
|
+
import { createStateStore as createStateStore2 } from "@json-render/core";
|
|
579
704
|
|
|
580
705
|
// src/renderer.tsx
|
|
581
706
|
import React5, {
|
|
582
|
-
useCallback as
|
|
583
|
-
useMemo as
|
|
707
|
+
useCallback as useCallback5,
|
|
708
|
+
useMemo as useMemo5
|
|
584
709
|
} from "react";
|
|
585
710
|
import {
|
|
586
711
|
resolveElementProps,
|
|
587
712
|
resolveBindings,
|
|
588
713
|
resolveActionParam,
|
|
589
714
|
evaluateVisibility as evaluateVisibility2,
|
|
590
|
-
getByPath as
|
|
715
|
+
getByPath as getByPath3
|
|
591
716
|
} from "@json-render/core";
|
|
592
717
|
|
|
593
718
|
// src/components/standard.tsx
|
|
@@ -609,10 +734,10 @@ import {
|
|
|
609
734
|
} from "react-native";
|
|
610
735
|
|
|
611
736
|
// src/hooks.ts
|
|
612
|
-
import { useState as useState3, useCallback as
|
|
737
|
+
import { useState as useState3, useCallback as useCallback4, useRef as useRef2, useEffect as useEffect2 } from "react";
|
|
613
738
|
import {
|
|
614
739
|
setByPath,
|
|
615
|
-
getByPath,
|
|
740
|
+
getByPath as getByPath2,
|
|
616
741
|
removeByPath,
|
|
617
742
|
validateSpec,
|
|
618
743
|
autoFixSpec,
|
|
@@ -620,7 +745,7 @@ import {
|
|
|
620
745
|
} from "@json-render/core";
|
|
621
746
|
function useBoundProp(propValue, bindingPath) {
|
|
622
747
|
const { set } = useStateStore();
|
|
623
|
-
const setValue =
|
|
748
|
+
const setValue = useCallback4(
|
|
624
749
|
(value) => {
|
|
625
750
|
if (bindingPath) set(bindingPath, value);
|
|
626
751
|
},
|
|
@@ -731,7 +856,7 @@ function removeSpecValue(newSpec, path) {
|
|
|
731
856
|
}
|
|
732
857
|
function getSpecValue(spec, path) {
|
|
733
858
|
if (path === "/root") return spec.root;
|
|
734
|
-
return
|
|
859
|
+
return getByPath2(spec, path);
|
|
735
860
|
}
|
|
736
861
|
function applyPatch(spec, patch) {
|
|
737
862
|
const newSpec = { ...spec, elements: { ...spec.elements } };
|
|
@@ -776,18 +901,18 @@ function useUIStream({
|
|
|
776
901
|
const [isStreaming, setIsStreaming] = useState3(false);
|
|
777
902
|
const [error, setError] = useState3(null);
|
|
778
903
|
const [rawLines, setRawLines] = useState3([]);
|
|
779
|
-
const abortControllerRef =
|
|
780
|
-
const stop =
|
|
904
|
+
const abortControllerRef = useRef2(null);
|
|
905
|
+
const stop = useCallback4(() => {
|
|
781
906
|
abortControllerRef.current?.abort();
|
|
782
907
|
abortControllerRef.current = null;
|
|
783
908
|
setIsStreaming(false);
|
|
784
909
|
}, []);
|
|
785
|
-
const clear =
|
|
910
|
+
const clear = useCallback4(() => {
|
|
786
911
|
setSpec(null);
|
|
787
912
|
setError(null);
|
|
788
913
|
setRawLines([]);
|
|
789
914
|
}, []);
|
|
790
|
-
const streamRequest =
|
|
915
|
+
const streamRequest = useCallback4(
|
|
791
916
|
async (prompt, context, initialSpec, abortOnMalformed) => {
|
|
792
917
|
let currentSpec = initialSpec;
|
|
793
918
|
setSpec(currentSpec);
|
|
@@ -868,7 +993,7 @@ function useUIStream({
|
|
|
868
993
|
},
|
|
869
994
|
[api, fetchFn]
|
|
870
995
|
);
|
|
871
|
-
const send =
|
|
996
|
+
const send = useCallback4(
|
|
872
997
|
async (prompt, context) => {
|
|
873
998
|
abortControllerRef.current?.abort();
|
|
874
999
|
abortControllerRef.current = new AbortController();
|
|
@@ -949,7 +1074,7 @@ The current spec state is provided. Continue generating from where you left off.
|
|
|
949
1074
|
streamRequest
|
|
950
1075
|
]
|
|
951
1076
|
);
|
|
952
|
-
|
|
1077
|
+
useEffect2(() => {
|
|
953
1078
|
return () => {
|
|
954
1079
|
abortControllerRef.current?.abort();
|
|
955
1080
|
};
|
|
@@ -992,10 +1117,10 @@ function flatToTree(elements) {
|
|
|
992
1117
|
}
|
|
993
1118
|
|
|
994
1119
|
// src/components/standard.tsx
|
|
995
|
-
import { jsx as
|
|
1120
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
996
1121
|
function ContainerComponent({ element, children }) {
|
|
997
1122
|
const p = element.props;
|
|
998
|
-
return /* @__PURE__ */
|
|
1123
|
+
return /* @__PURE__ */ jsx6(
|
|
999
1124
|
View2,
|
|
1000
1125
|
{
|
|
1001
1126
|
style: {
|
|
@@ -1013,7 +1138,7 @@ function ContainerComponent({ element, children }) {
|
|
|
1013
1138
|
}
|
|
1014
1139
|
function RowComponent({ element, children }) {
|
|
1015
1140
|
const p = element.props;
|
|
1016
|
-
return /* @__PURE__ */
|
|
1141
|
+
return /* @__PURE__ */ jsx6(
|
|
1017
1142
|
View2,
|
|
1018
1143
|
{
|
|
1019
1144
|
style: {
|
|
@@ -1031,7 +1156,7 @@ function RowComponent({ element, children }) {
|
|
|
1031
1156
|
}
|
|
1032
1157
|
function ColumnComponent({ element, children }) {
|
|
1033
1158
|
const p = element.props;
|
|
1034
|
-
return /* @__PURE__ */
|
|
1159
|
+
return /* @__PURE__ */ jsx6(
|
|
1035
1160
|
View2,
|
|
1036
1161
|
{
|
|
1037
1162
|
style: {
|
|
@@ -1048,7 +1173,7 @@ function ColumnComponent({ element, children }) {
|
|
|
1048
1173
|
}
|
|
1049
1174
|
function ScrollContainerComponent({ element, children }) {
|
|
1050
1175
|
const p = element.props;
|
|
1051
|
-
return /* @__PURE__ */
|
|
1176
|
+
return /* @__PURE__ */ jsx6(
|
|
1052
1177
|
ScrollView,
|
|
1053
1178
|
{
|
|
1054
1179
|
horizontal: p.horizontal ?? false,
|
|
@@ -1067,7 +1192,7 @@ function ScrollContainerComponent({ element, children }) {
|
|
|
1067
1192
|
}
|
|
1068
1193
|
function SafeAreaComponent({ element, children }) {
|
|
1069
1194
|
const p = element.props;
|
|
1070
|
-
return /* @__PURE__ */
|
|
1195
|
+
return /* @__PURE__ */ jsx6(
|
|
1071
1196
|
SafeAreaView,
|
|
1072
1197
|
{
|
|
1073
1198
|
style: {
|
|
@@ -1080,7 +1205,7 @@ function SafeAreaComponent({ element, children }) {
|
|
|
1080
1205
|
}
|
|
1081
1206
|
function SpacerComponent({ element }) {
|
|
1082
1207
|
const p = element.props;
|
|
1083
|
-
return /* @__PURE__ */
|
|
1208
|
+
return /* @__PURE__ */ jsx6(
|
|
1084
1209
|
View2,
|
|
1085
1210
|
{
|
|
1086
1211
|
style: {
|
|
@@ -1092,7 +1217,7 @@ function SpacerComponent({ element }) {
|
|
|
1092
1217
|
);
|
|
1093
1218
|
}
|
|
1094
1219
|
function PressableComponent({ children, emit }) {
|
|
1095
|
-
return /* @__PURE__ */
|
|
1220
|
+
return /* @__PURE__ */ jsx6(
|
|
1096
1221
|
Pressable2,
|
|
1097
1222
|
{
|
|
1098
1223
|
onPress: () => emit("press"),
|
|
@@ -1109,7 +1234,7 @@ function DividerComponent({ element }) {
|
|
|
1109
1234
|
const isVertical = p.direction === "vertical";
|
|
1110
1235
|
const thickness = p.thickness ?? 1;
|
|
1111
1236
|
const color = p.color ?? "#e5e7eb";
|
|
1112
|
-
return /* @__PURE__ */
|
|
1237
|
+
return /* @__PURE__ */ jsx6(
|
|
1113
1238
|
View2,
|
|
1114
1239
|
{
|
|
1115
1240
|
style: {
|
|
@@ -1131,7 +1256,7 @@ var headingSizes = {
|
|
|
1131
1256
|
function HeadingComponent({ element }) {
|
|
1132
1257
|
const p = element.props;
|
|
1133
1258
|
const level = p.level ?? "h2";
|
|
1134
|
-
return /* @__PURE__ */
|
|
1259
|
+
return /* @__PURE__ */ jsx6(
|
|
1135
1260
|
Text2,
|
|
1136
1261
|
{
|
|
1137
1262
|
style: {
|
|
@@ -1146,7 +1271,7 @@ function HeadingComponent({ element }) {
|
|
|
1146
1271
|
}
|
|
1147
1272
|
function ParagraphComponent({ element }) {
|
|
1148
1273
|
const p = element.props;
|
|
1149
|
-
return /* @__PURE__ */
|
|
1274
|
+
return /* @__PURE__ */ jsx6(
|
|
1150
1275
|
Text2,
|
|
1151
1276
|
{
|
|
1152
1277
|
numberOfLines: p.numberOfLines ?? void 0,
|
|
@@ -1167,7 +1292,7 @@ var labelSizes = {
|
|
|
1167
1292
|
};
|
|
1168
1293
|
function LabelComponent({ element }) {
|
|
1169
1294
|
const p = element.props;
|
|
1170
|
-
return /* @__PURE__ */
|
|
1295
|
+
return /* @__PURE__ */ jsx6(
|
|
1171
1296
|
Text2,
|
|
1172
1297
|
{
|
|
1173
1298
|
style: {
|
|
@@ -1181,7 +1306,7 @@ function LabelComponent({ element }) {
|
|
|
1181
1306
|
}
|
|
1182
1307
|
function ImageComponent({ element }) {
|
|
1183
1308
|
const p = element.props;
|
|
1184
|
-
return /* @__PURE__ */
|
|
1309
|
+
return /* @__PURE__ */ jsx6(
|
|
1185
1310
|
RNImage,
|
|
1186
1311
|
{
|
|
1187
1312
|
source: { uri: p.src },
|
|
@@ -1206,7 +1331,7 @@ function AvatarComponent({ element }) {
|
|
|
1206
1331
|
const size = avatarSizeMap[p.size ?? "md"];
|
|
1207
1332
|
const bgColor = p.backgroundColor ?? "#6366f1";
|
|
1208
1333
|
if (p.src) {
|
|
1209
|
-
return /* @__PURE__ */
|
|
1334
|
+
return /* @__PURE__ */ jsx6(
|
|
1210
1335
|
RNImage,
|
|
1211
1336
|
{
|
|
1212
1337
|
source: { uri: p.src },
|
|
@@ -1219,7 +1344,7 @@ function AvatarComponent({ element }) {
|
|
|
1219
1344
|
}
|
|
1220
1345
|
);
|
|
1221
1346
|
}
|
|
1222
|
-
return /* @__PURE__ */
|
|
1347
|
+
return /* @__PURE__ */ jsx6(
|
|
1223
1348
|
View2,
|
|
1224
1349
|
{
|
|
1225
1350
|
style: {
|
|
@@ -1230,7 +1355,7 @@ function AvatarComponent({ element }) {
|
|
|
1230
1355
|
alignItems: "center",
|
|
1231
1356
|
justifyContent: "center"
|
|
1232
1357
|
},
|
|
1233
|
-
children: /* @__PURE__ */
|
|
1358
|
+
children: /* @__PURE__ */ jsx6(
|
|
1234
1359
|
Text2,
|
|
1235
1360
|
{
|
|
1236
1361
|
style: {
|
|
@@ -1257,7 +1382,7 @@ function BadgeComponent({ element }) {
|
|
|
1257
1382
|
bg: "#e5e7eb",
|
|
1258
1383
|
text: "#374151"
|
|
1259
1384
|
};
|
|
1260
|
-
return /* @__PURE__ */
|
|
1385
|
+
return /* @__PURE__ */ jsx6(
|
|
1261
1386
|
View2,
|
|
1262
1387
|
{
|
|
1263
1388
|
style: {
|
|
@@ -1267,7 +1392,7 @@ function BadgeComponent({ element }) {
|
|
|
1267
1392
|
borderRadius: 9999,
|
|
1268
1393
|
alignSelf: "flex-start"
|
|
1269
1394
|
},
|
|
1270
|
-
children: /* @__PURE__ */
|
|
1395
|
+
children: /* @__PURE__ */ jsx6(
|
|
1271
1396
|
Text2,
|
|
1272
1397
|
{
|
|
1273
1398
|
style: {
|
|
@@ -1300,8 +1425,8 @@ function ChipComponent({ element, emit }) {
|
|
|
1300
1425
|
alignSelf: "flex-start"
|
|
1301
1426
|
},
|
|
1302
1427
|
children: [
|
|
1303
|
-
/* @__PURE__ */
|
|
1304
|
-
hasRemove && /* @__PURE__ */
|
|
1428
|
+
/* @__PURE__ */ jsx6(Text2, { style: { fontSize: 14, color: textColor }, children: p.label }),
|
|
1429
|
+
hasRemove && /* @__PURE__ */ jsx6(Pressable2, { onPress: () => emit("remove"), style: { marginLeft: 4 }, children: /* @__PURE__ */ jsx6(Text2, { style: { fontSize: 14, color: textColor, fontWeight: "700" }, children: "x" }) })
|
|
1305
1430
|
]
|
|
1306
1431
|
}
|
|
1307
1432
|
);
|
|
@@ -1349,7 +1474,7 @@ function ButtonComponent({ element, emit }) {
|
|
|
1349
1474
|
alignSelf: "flex-start"
|
|
1350
1475
|
}),
|
|
1351
1476
|
children: [
|
|
1352
|
-
p.loading && /* @__PURE__ */
|
|
1477
|
+
p.loading && /* @__PURE__ */ jsx6(
|
|
1353
1478
|
ActivityIndicator,
|
|
1354
1479
|
{
|
|
1355
1480
|
size: "small",
|
|
@@ -1357,7 +1482,7 @@ function ButtonComponent({ element, emit }) {
|
|
|
1357
1482
|
style: { marginRight: 8 }
|
|
1358
1483
|
}
|
|
1359
1484
|
),
|
|
1360
|
-
/* @__PURE__ */
|
|
1485
|
+
/* @__PURE__ */ jsx6(
|
|
1361
1486
|
Text2,
|
|
1362
1487
|
{
|
|
1363
1488
|
style: {
|
|
@@ -1380,8 +1505,8 @@ function TextInputComponent({ element, bindings }) {
|
|
|
1380
1505
|
);
|
|
1381
1506
|
const displayValue = boundValue ?? "";
|
|
1382
1507
|
return /* @__PURE__ */ jsxs2(View2, { style: p.flex != null ? { flex: p.flex } : void 0, children: [
|
|
1383
|
-
p.label && /* @__PURE__ */
|
|
1384
|
-
/* @__PURE__ */
|
|
1508
|
+
p.label && /* @__PURE__ */ jsx6(Text2, { style: inputStyles.label, children: p.label }),
|
|
1509
|
+
/* @__PURE__ */ jsx6(
|
|
1385
1510
|
RNTextInput,
|
|
1386
1511
|
{
|
|
1387
1512
|
placeholder: p.placeholder ?? void 0,
|
|
@@ -1410,7 +1535,7 @@ function SwitchComponent({ element, bindings }) {
|
|
|
1410
1535
|
);
|
|
1411
1536
|
const displayValue = checked ?? false;
|
|
1412
1537
|
return /* @__PURE__ */ jsxs2(View2, { style: { flexDirection: "row", alignItems: "center", gap: 8 }, children: [
|
|
1413
|
-
/* @__PURE__ */
|
|
1538
|
+
/* @__PURE__ */ jsx6(
|
|
1414
1539
|
RNSwitch,
|
|
1415
1540
|
{
|
|
1416
1541
|
value: displayValue,
|
|
@@ -1418,7 +1543,7 @@ function SwitchComponent({ element, bindings }) {
|
|
|
1418
1543
|
disabled: p.disabled ?? false
|
|
1419
1544
|
}
|
|
1420
1545
|
),
|
|
1421
|
-
p.label && /* @__PURE__ */
|
|
1546
|
+
p.label && /* @__PURE__ */ jsx6(Text2, { style: { fontSize: 16, color: "#374151" }, children: p.label })
|
|
1422
1547
|
] });
|
|
1423
1548
|
}
|
|
1424
1549
|
function CheckboxComponent({ element, bindings }) {
|
|
@@ -1444,7 +1569,7 @@ function CheckboxComponent({ element, bindings }) {
|
|
|
1444
1569
|
opacity: p.disabled ? 0.5 : 1
|
|
1445
1570
|
},
|
|
1446
1571
|
children: [
|
|
1447
|
-
/* @__PURE__ */
|
|
1572
|
+
/* @__PURE__ */ jsx6(
|
|
1448
1573
|
View2,
|
|
1449
1574
|
{
|
|
1450
1575
|
style: {
|
|
@@ -1457,10 +1582,10 @@ function CheckboxComponent({ element, bindings }) {
|
|
|
1457
1582
|
alignItems: "center",
|
|
1458
1583
|
justifyContent: "center"
|
|
1459
1584
|
},
|
|
1460
|
-
children: isChecked && /* @__PURE__ */
|
|
1585
|
+
children: isChecked && /* @__PURE__ */ jsx6(Text2, { style: { color: "#ffffff", fontSize: 12, fontWeight: "700" }, children: "\u2713" })
|
|
1461
1586
|
}
|
|
1462
1587
|
),
|
|
1463
|
-
p.label && /* @__PURE__ */
|
|
1588
|
+
p.label && /* @__PURE__ */ jsx6(Text2, { style: { fontSize: 16, color: "#374151" }, children: p.label })
|
|
1464
1589
|
]
|
|
1465
1590
|
}
|
|
1466
1591
|
);
|
|
@@ -1482,12 +1607,12 @@ function SliderComponent({ element }) {
|
|
|
1482
1607
|
marginBottom: 4
|
|
1483
1608
|
},
|
|
1484
1609
|
children: [
|
|
1485
|
-
/* @__PURE__ */
|
|
1486
|
-
/* @__PURE__ */
|
|
1610
|
+
/* @__PURE__ */ jsx6(Text2, { style: { fontSize: 14, color: "#374151" }, children: p.label }),
|
|
1611
|
+
/* @__PURE__ */ jsx6(Text2, { style: { fontSize: 14, color: "#6b7280" }, children: value })
|
|
1487
1612
|
]
|
|
1488
1613
|
}
|
|
1489
1614
|
),
|
|
1490
|
-
/* @__PURE__ */
|
|
1615
|
+
/* @__PURE__ */ jsx6(
|
|
1491
1616
|
View2,
|
|
1492
1617
|
{
|
|
1493
1618
|
style: {
|
|
@@ -1496,7 +1621,7 @@ function SliderComponent({ element }) {
|
|
|
1496
1621
|
borderRadius: 3,
|
|
1497
1622
|
overflow: "hidden"
|
|
1498
1623
|
},
|
|
1499
|
-
children: /* @__PURE__ */
|
|
1624
|
+
children: /* @__PURE__ */ jsx6(
|
|
1500
1625
|
View2,
|
|
1501
1626
|
{
|
|
1502
1627
|
style: {
|
|
@@ -1524,8 +1649,8 @@ function SearchBarComponent({ element, emit }) {
|
|
|
1524
1649
|
paddingHorizontal: 12
|
|
1525
1650
|
},
|
|
1526
1651
|
children: [
|
|
1527
|
-
/* @__PURE__ */
|
|
1528
|
-
/* @__PURE__ */
|
|
1652
|
+
/* @__PURE__ */ jsx6(Text2, { style: { fontSize: 16, color: "#9ca3af", marginRight: 8 }, children: "Search" }),
|
|
1653
|
+
/* @__PURE__ */ jsx6(
|
|
1529
1654
|
RNTextInput,
|
|
1530
1655
|
{
|
|
1531
1656
|
placeholder: p.placeholder ?? "Search...",
|
|
@@ -1546,13 +1671,13 @@ function SearchBarComponent({ element, emit }) {
|
|
|
1546
1671
|
}
|
|
1547
1672
|
function SpinnerComponent({ element }) {
|
|
1548
1673
|
const p = element.props;
|
|
1549
|
-
return /* @__PURE__ */
|
|
1674
|
+
return /* @__PURE__ */ jsx6(ActivityIndicator, { size: p.size ?? "small", color: p.color ?? "#3b82f6" });
|
|
1550
1675
|
}
|
|
1551
1676
|
function ProgressBarComponent({ element }) {
|
|
1552
1677
|
const p = element.props;
|
|
1553
1678
|
const height = p.height ?? 6;
|
|
1554
1679
|
const progress = Math.min(Math.max(p.progress, 0), 1);
|
|
1555
|
-
return /* @__PURE__ */
|
|
1680
|
+
return /* @__PURE__ */ jsx6(
|
|
1556
1681
|
View2,
|
|
1557
1682
|
{
|
|
1558
1683
|
style: {
|
|
@@ -1561,7 +1686,7 @@ function ProgressBarComponent({ element }) {
|
|
|
1561
1686
|
borderRadius: height / 2,
|
|
1562
1687
|
overflow: "hidden"
|
|
1563
1688
|
},
|
|
1564
|
-
children: /* @__PURE__ */
|
|
1689
|
+
children: /* @__PURE__ */ jsx6(
|
|
1565
1690
|
View2,
|
|
1566
1691
|
{
|
|
1567
1692
|
style: {
|
|
@@ -1597,7 +1722,7 @@ function CardComponent({ element, children }) {
|
|
|
1597
1722
|
}
|
|
1598
1723
|
],
|
|
1599
1724
|
children: [
|
|
1600
|
-
p.title && /* @__PURE__ */
|
|
1725
|
+
p.title && /* @__PURE__ */ jsx6(
|
|
1601
1726
|
Text2,
|
|
1602
1727
|
{
|
|
1603
1728
|
style: {
|
|
@@ -1609,7 +1734,7 @@ function CardComponent({ element, children }) {
|
|
|
1609
1734
|
children: p.title
|
|
1610
1735
|
}
|
|
1611
1736
|
),
|
|
1612
|
-
p.subtitle && /* @__PURE__ */
|
|
1737
|
+
p.subtitle && /* @__PURE__ */ jsx6(
|
|
1613
1738
|
Text2,
|
|
1614
1739
|
{
|
|
1615
1740
|
style: {
|
|
@@ -1638,7 +1763,7 @@ function ListItemComponent({ element, emit }) {
|
|
|
1638
1763
|
paddingHorizontal: 16
|
|
1639
1764
|
},
|
|
1640
1765
|
children: [
|
|
1641
|
-
p.leading && /* @__PURE__ */
|
|
1766
|
+
p.leading && /* @__PURE__ */ jsx6(
|
|
1642
1767
|
Text2,
|
|
1643
1768
|
{
|
|
1644
1769
|
style: {
|
|
@@ -1652,16 +1777,16 @@ function ListItemComponent({ element, emit }) {
|
|
|
1652
1777
|
}
|
|
1653
1778
|
),
|
|
1654
1779
|
/* @__PURE__ */ jsxs2(View2, { style: { flex: 1 }, children: [
|
|
1655
|
-
/* @__PURE__ */
|
|
1656
|
-
p.subtitle && /* @__PURE__ */
|
|
1780
|
+
/* @__PURE__ */ jsx6(Text2, { style: { fontSize: 16, color: "#111827" }, children: p.title }),
|
|
1781
|
+
p.subtitle && /* @__PURE__ */ jsx6(Text2, { style: { fontSize: 14, color: "#6b7280", marginTop: 2 }, children: p.subtitle })
|
|
1657
1782
|
] }),
|
|
1658
|
-
p.trailing && /* @__PURE__ */
|
|
1659
|
-
p.showChevron && /* @__PURE__ */
|
|
1783
|
+
p.trailing && /* @__PURE__ */ jsx6(Text2, { style: { fontSize: 14, color: "#6b7280", marginLeft: 8 }, children: p.trailing }),
|
|
1784
|
+
p.showChevron && /* @__PURE__ */ jsx6(Text2, { style: { fontSize: 16, color: "#9ca3af", marginLeft: 8 }, children: ">" })
|
|
1660
1785
|
]
|
|
1661
1786
|
}
|
|
1662
1787
|
);
|
|
1663
1788
|
if (hasPress) {
|
|
1664
|
-
return /* @__PURE__ */
|
|
1789
|
+
return /* @__PURE__ */ jsx6(
|
|
1665
1790
|
Pressable2,
|
|
1666
1791
|
{
|
|
1667
1792
|
onPress: () => emit("press"),
|
|
@@ -1677,14 +1802,14 @@ function ListItemComponent({ element, emit }) {
|
|
|
1677
1802
|
}
|
|
1678
1803
|
function ModalComponent({ element, children }) {
|
|
1679
1804
|
const p = element.props;
|
|
1680
|
-
return /* @__PURE__ */
|
|
1805
|
+
return /* @__PURE__ */ jsx6(
|
|
1681
1806
|
RNModal,
|
|
1682
1807
|
{
|
|
1683
1808
|
visible: p.visible,
|
|
1684
1809
|
animationType: p.animationType ?? "slide",
|
|
1685
1810
|
transparent: true,
|
|
1686
|
-
children: /* @__PURE__ */
|
|
1687
|
-
p.title && /* @__PURE__ */
|
|
1811
|
+
children: /* @__PURE__ */ jsx6(View2, { style: modalStyles.overlay, children: /* @__PURE__ */ jsxs2(View2, { style: modalStyles.content, children: [
|
|
1812
|
+
p.title && /* @__PURE__ */ jsx6(Text2, { style: modalStyles.title, children: p.title }),
|
|
1688
1813
|
children
|
|
1689
1814
|
] }) })
|
|
1690
1815
|
}
|
|
@@ -1807,7 +1932,7 @@ var modalStyles = StyleSheet2.create({
|
|
|
1807
1932
|
});
|
|
1808
1933
|
|
|
1809
1934
|
// src/renderer.tsx
|
|
1810
|
-
import { Fragment, jsx as
|
|
1935
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1811
1936
|
var ElementErrorBoundary = class extends React5.Component {
|
|
1812
1937
|
constructor(props) {
|
|
1813
1938
|
super(props);
|
|
@@ -1841,7 +1966,7 @@ var ElementRenderer = React5.memo(function ElementRenderer2({
|
|
|
1841
1966
|
const { ctx } = useVisibility();
|
|
1842
1967
|
const { execute } = useActions();
|
|
1843
1968
|
const { getSnapshot } = useStateStore();
|
|
1844
|
-
const fullCtx =
|
|
1969
|
+
const fullCtx = useMemo5(
|
|
1845
1970
|
() => repeatScope ? {
|
|
1846
1971
|
...ctx,
|
|
1847
1972
|
repeatItem: repeatScope.item,
|
|
@@ -1852,7 +1977,7 @@ var ElementRenderer = React5.memo(function ElementRenderer2({
|
|
|
1852
1977
|
);
|
|
1853
1978
|
const isVisible = element.visible === void 0 ? true : evaluateVisibility2(element.visible, fullCtx);
|
|
1854
1979
|
const onBindings = element.on;
|
|
1855
|
-
const emit =
|
|
1980
|
+
const emit = useCallback5(
|
|
1856
1981
|
async (eventName) => {
|
|
1857
1982
|
const binding = onBindings?.[eventName];
|
|
1858
1983
|
if (!binding) return;
|
|
@@ -1887,7 +2012,7 @@ var ElementRenderer = React5.memo(function ElementRenderer2({
|
|
|
1887
2012
|
console.warn(`No renderer for component type: ${resolvedElement.type}`);
|
|
1888
2013
|
return null;
|
|
1889
2014
|
}
|
|
1890
|
-
const children = resolvedElement.repeat ? /* @__PURE__ */
|
|
2015
|
+
const children = resolvedElement.repeat ? /* @__PURE__ */ jsx7(
|
|
1891
2016
|
RepeatChildren,
|
|
1892
2017
|
{
|
|
1893
2018
|
element: resolvedElement,
|
|
@@ -1906,7 +2031,7 @@ var ElementRenderer = React5.memo(function ElementRenderer2({
|
|
|
1906
2031
|
}
|
|
1907
2032
|
return null;
|
|
1908
2033
|
}
|
|
1909
|
-
return /* @__PURE__ */
|
|
2034
|
+
return /* @__PURE__ */ jsx7(
|
|
1910
2035
|
ElementRenderer2,
|
|
1911
2036
|
{
|
|
1912
2037
|
element: childElement,
|
|
@@ -1918,7 +2043,7 @@ var ElementRenderer = React5.memo(function ElementRenderer2({
|
|
|
1918
2043
|
childKey
|
|
1919
2044
|
);
|
|
1920
2045
|
});
|
|
1921
|
-
return /* @__PURE__ */
|
|
2046
|
+
return /* @__PURE__ */ jsx7(ElementErrorBoundary, { elementType: resolvedElement.type, children: /* @__PURE__ */ jsx7(
|
|
1922
2047
|
Component,
|
|
1923
2048
|
{
|
|
1924
2049
|
element: resolvedElement,
|
|
@@ -1939,12 +2064,12 @@ function RepeatChildren({
|
|
|
1939
2064
|
const { state } = useStateStore();
|
|
1940
2065
|
const repeat = element.repeat;
|
|
1941
2066
|
const statePath = repeat.statePath;
|
|
1942
|
-
const items =
|
|
1943
|
-
return /* @__PURE__ */
|
|
2067
|
+
const items = getByPath3(state, statePath) ?? [];
|
|
2068
|
+
return /* @__PURE__ */ jsx7(Fragment, { children: items.map((itemValue, index) => {
|
|
1944
2069
|
const key = repeat.key && typeof itemValue === "object" && itemValue !== null ? String(
|
|
1945
2070
|
itemValue[repeat.key] ?? index
|
|
1946
2071
|
) : String(index);
|
|
1947
|
-
return /* @__PURE__ */
|
|
2072
|
+
return /* @__PURE__ */ jsx7(
|
|
1948
2073
|
RepeatScopeProvider,
|
|
1949
2074
|
{
|
|
1950
2075
|
item: itemValue,
|
|
@@ -1960,7 +2085,7 @@ function RepeatChildren({
|
|
|
1960
2085
|
}
|
|
1961
2086
|
return null;
|
|
1962
2087
|
}
|
|
1963
|
-
return /* @__PURE__ */
|
|
2088
|
+
return /* @__PURE__ */ jsx7(
|
|
1964
2089
|
ElementRenderer,
|
|
1965
2090
|
{
|
|
1966
2091
|
element: childElement,
|
|
@@ -1984,7 +2109,7 @@ function Renderer({
|
|
|
1984
2109
|
loading,
|
|
1985
2110
|
fallback
|
|
1986
2111
|
}) {
|
|
1987
|
-
const registry =
|
|
2112
|
+
const registry = useMemo5(
|
|
1988
2113
|
() => ({
|
|
1989
2114
|
...includeStandard ? standardComponents : {},
|
|
1990
2115
|
...customRegistry
|
|
@@ -1998,7 +2123,7 @@ function Renderer({
|
|
|
1998
2123
|
if (!rootElement) {
|
|
1999
2124
|
return null;
|
|
2000
2125
|
}
|
|
2001
|
-
return /* @__PURE__ */
|
|
2126
|
+
return /* @__PURE__ */ jsx7(
|
|
2002
2127
|
ElementRenderer,
|
|
2003
2128
|
{
|
|
2004
2129
|
element: rootElement,
|
|
@@ -2019,15 +2144,15 @@ function JSONUIProvider({
|
|
|
2019
2144
|
onStateChange,
|
|
2020
2145
|
children
|
|
2021
2146
|
}) {
|
|
2022
|
-
return /* @__PURE__ */
|
|
2147
|
+
return /* @__PURE__ */ jsx7(
|
|
2023
2148
|
StateProvider,
|
|
2024
2149
|
{
|
|
2025
2150
|
store,
|
|
2026
2151
|
initialState,
|
|
2027
2152
|
onStateChange,
|
|
2028
|
-
children: /* @__PURE__ */
|
|
2153
|
+
children: /* @__PURE__ */ jsx7(VisibilityProvider, { children: /* @__PURE__ */ jsx7(ActionProvider, { handlers, navigate, children: /* @__PURE__ */ jsxs3(ValidationProvider, { customFunctions: validationFunctions, children: [
|
|
2029
2154
|
children,
|
|
2030
|
-
/* @__PURE__ */
|
|
2155
|
+
/* @__PURE__ */ jsx7(ConfirmationDialogManager, {})
|
|
2031
2156
|
] }) }) })
|
|
2032
2157
|
}
|
|
2033
2158
|
);
|
|
@@ -2037,7 +2162,7 @@ function ConfirmationDialogManager() {
|
|
|
2037
2162
|
if (!pendingConfirmation?.action.confirm) {
|
|
2038
2163
|
return null;
|
|
2039
2164
|
}
|
|
2040
|
-
return /* @__PURE__ */
|
|
2165
|
+
return /* @__PURE__ */ jsx7(
|
|
2041
2166
|
ConfirmDialog,
|
|
2042
2167
|
{
|
|
2043
2168
|
confirm: pendingConfirmation.action.confirm,
|
|
@@ -2111,14 +2236,14 @@ function createRenderer(catalog, components) {
|
|
|
2111
2236
|
has: () => true
|
|
2112
2237
|
}
|
|
2113
2238
|
) : void 0;
|
|
2114
|
-
return /* @__PURE__ */
|
|
2239
|
+
return /* @__PURE__ */ jsx7(
|
|
2115
2240
|
StateProvider,
|
|
2116
2241
|
{
|
|
2117
2242
|
store,
|
|
2118
2243
|
initialState: state,
|
|
2119
2244
|
onStateChange,
|
|
2120
|
-
children: /* @__PURE__ */
|
|
2121
|
-
/* @__PURE__ */
|
|
2245
|
+
children: /* @__PURE__ */ jsx7(VisibilityProvider, { children: /* @__PURE__ */ jsx7(ActionProvider, { handlers: actionHandlers, children: /* @__PURE__ */ jsxs3(ValidationProvider, { children: [
|
|
2246
|
+
/* @__PURE__ */ jsx7(
|
|
2122
2247
|
Renderer,
|
|
2123
2248
|
{
|
|
2124
2249
|
spec,
|
|
@@ -2127,7 +2252,7 @@ function createRenderer(catalog, components) {
|
|
|
2127
2252
|
fallback
|
|
2128
2253
|
}
|
|
2129
2254
|
),
|
|
2130
|
-
/* @__PURE__ */
|
|
2255
|
+
/* @__PURE__ */ jsx7(ConfirmationDialogManager, {})
|
|
2131
2256
|
] }) }) })
|
|
2132
2257
|
}
|
|
2133
2258
|
);
|
|
@@ -2144,7 +2269,7 @@ export {
|
|
|
2144
2269
|
VisibilityProvider,
|
|
2145
2270
|
createRenderer,
|
|
2146
2271
|
createStandardActionHandlers,
|
|
2147
|
-
createStateStore,
|
|
2272
|
+
createStateStore2 as createStateStore,
|
|
2148
2273
|
defineRegistry,
|
|
2149
2274
|
elementTreeSchema,
|
|
2150
2275
|
flatToTree,
|