@xmachines/play-vue 1.0.0-beta.2 → 1.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +214 -84
- package/dist/PlayRenderer.js +7 -0
- package/dist/PlayRenderer.js.map +1 -0
- package/dist/PlayRenderer.vue_vue_type_script_lang.js +57 -0
- package/dist/PlayRenderer.vue_vue_type_script_lang.js.map +1 -0
- package/dist/define-registry.d.ts +79 -0
- package/dist/define-registry.d.ts.map +1 -0
- package/dist/define-registry.js +21 -0
- package/dist/define-registry.js.map +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/node_modules/@json-render/core/dist/chunk-AFLK3Q4T.js +111 -0
- package/dist/node_modules/@json-render/core/dist/chunk-AFLK3Q4T.js.map +1 -0
- package/dist/node_modules/@json-render/core/dist/index.js +956 -0
- package/dist/node_modules/@json-render/core/dist/index.js.map +1 -0
- package/dist/node_modules/@json-render/core/dist/store-utils.js +1 -0
- package/dist/node_modules/@json-render/vue/dist/chunk-WIPZLAF7.js +57 -0
- package/dist/node_modules/@json-render/vue/dist/chunk-WIPZLAF7.js.map +1 -0
- package/dist/node_modules/@json-render/vue/dist/index.js +796 -0
- package/dist/node_modules/@json-render/vue/dist/index.js.map +1 -0
- package/dist/node_modules/@json-render/xstate/dist/index.js +20 -0
- package/dist/node_modules/@json-render/xstate/dist/index.js.map +1 -0
- package/dist/node_modules/@xstate/store/dist/store-69e7e2d5.esm.js +227 -0
- package/dist/node_modules/@xstate/store/dist/store-69e7e2d5.esm.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/errors.js +25 -0
- package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/iso.js +33 -0
- package/dist/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/parse.js +8 -0
- package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/classic/schemas.js +362 -0
- package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/api.js +530 -0
- package/dist/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/zod/v4/core/checks.js +285 -0
- package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/zod/v4/core/core.js +46 -0
- package/dist/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/zod/v4/core/doc.js +25 -0
- package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/zod/v4/core/errors.js +43 -0
- package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +183 -0
- package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +1 -0
- package/dist/node_modules/zod/v4/core/parse.js +70 -0
- package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/zod/v4/core/regexes.js +27 -0
- package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/zod/v4/core/registries.js +42 -0
- package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/zod/v4/core/schemas.js +823 -0
- package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js +224 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
- package/dist/node_modules/zod/v4/core/util.js +268 -0
- package/dist/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/zod/v4/core/versions.js +10 -0
- package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/types.d.ts +31 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/useActor.d.ts +35 -0
- package/dist/useActor.d.ts.map +1 -0
- package/dist/useActor.js +15 -0
- package/dist/useActor.js.map +1 -0
- package/package.json +31 -23
- package/dist/PlayRenderer.vue.js +0 -8
- package/dist/PlayRenderer.vue.js.map +0 -1
- package/dist/PlayRenderer.vue2.js +0 -48
- package/dist/PlayRenderer.vue2.js.map +0 -1
- package/dist/_virtual/_plugin-vue_export-helper.js +0 -10
- package/dist/_virtual/_plugin-vue_export-helper.js.map +0 -1
- package/dist/index.css +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,796 @@
|
|
|
1
|
+
import { createStateStore as e, flattenToPointers as t, getByPath as n } from "../../core/dist/chunk-AFLK3Q4T.js";
|
|
2
|
+
import { evaluateVisibility as r, executeAction as i, resolveAction as a, resolveActionParam as o, resolveBindings as s, resolveElementProps as c, runValidation as l } from "../../core/dist/index.js";
|
|
3
|
+
import "./chunk-WIPZLAF7.js";
|
|
4
|
+
import "../../core/dist/store-utils.js";
|
|
5
|
+
import { computed as u, defineComponent as d, h as f, inject as p, onErrorCaptured as m, onUnmounted as h, provide as g, ref as _, shallowRef as v, watch as y } from "vue";
|
|
6
|
+
//#region ../../node_modules/@json-render/vue/dist/index.mjs
|
|
7
|
+
var b = /* @__PURE__ */ Symbol("json-render:state"), x = d({
|
|
8
|
+
name: "StateProvider",
|
|
9
|
+
props: {
|
|
10
|
+
store: {
|
|
11
|
+
type: Object,
|
|
12
|
+
default: void 0
|
|
13
|
+
},
|
|
14
|
+
initialState: {
|
|
15
|
+
type: Object,
|
|
16
|
+
default: void 0
|
|
17
|
+
},
|
|
18
|
+
onStateChange: {
|
|
19
|
+
type: Function,
|
|
20
|
+
default: void 0
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
setup(r, { slots: i }) {
|
|
24
|
+
let a = !!r.store, o = a ? null : e(r.initialState ?? {}), s = r.store ?? o, c = v(s.getSnapshot());
|
|
25
|
+
if (h(s.subscribe(() => {
|
|
26
|
+
c.value = s.getSnapshot();
|
|
27
|
+
})), !a) {
|
|
28
|
+
let e = r.initialState && Object.keys(r.initialState).length > 0 ? t(r.initialState) : {};
|
|
29
|
+
y(() => r.initialState, (n) => {
|
|
30
|
+
if (!n) return;
|
|
31
|
+
let r = Object.keys(n).length > 0 ? t(n) : {}, i = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(r)]), a = {};
|
|
32
|
+
for (let t of i) e[t] !== r[t] && (a[t] = t in r ? r[t] : void 0);
|
|
33
|
+
e = r, Object.keys(a).length > 0 && s.update(a);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
let l = _(r.onStateChange);
|
|
37
|
+
return y(() => r.onStateChange, (e) => {
|
|
38
|
+
l.value = e;
|
|
39
|
+
}), g(b, {
|
|
40
|
+
state: c,
|
|
41
|
+
get: (e) => s.get(e),
|
|
42
|
+
set: (e, t) => {
|
|
43
|
+
let n = s.getSnapshot();
|
|
44
|
+
s.set(e, t), !a && s.getSnapshot() !== n && l.value?.([{
|
|
45
|
+
path: e,
|
|
46
|
+
value: t
|
|
47
|
+
}]);
|
|
48
|
+
},
|
|
49
|
+
update: (e) => {
|
|
50
|
+
let t = s.getSnapshot();
|
|
51
|
+
if (s.update(e), !a && s.getSnapshot() !== t) {
|
|
52
|
+
let r = [];
|
|
53
|
+
for (let [i, a] of Object.entries(e)) n(t, i) !== a && r.push({
|
|
54
|
+
path: i,
|
|
55
|
+
value: a
|
|
56
|
+
});
|
|
57
|
+
r.length > 0 && l.value?.(r);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
getSnapshot: () => s.getSnapshot()
|
|
61
|
+
}), () => i.default?.();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
function S() {
|
|
65
|
+
let e = p(b);
|
|
66
|
+
if (!e) throw Error("useStateStore must be used within a StateProvider");
|
|
67
|
+
return e;
|
|
68
|
+
}
|
|
69
|
+
function C(e) {
|
|
70
|
+
let { state: t, set: r } = S();
|
|
71
|
+
return [u(() => n(t.value, e)), (t) => r(e, t)];
|
|
72
|
+
}
|
|
73
|
+
var w = /* @__PURE__ */ Symbol("json-render:visibility"), T = d({
|
|
74
|
+
name: "VisibilityProvider",
|
|
75
|
+
setup(e, { slots: t }) {
|
|
76
|
+
let { state: n } = S(), i = u(() => ({ stateModel: n.value }));
|
|
77
|
+
return g(w, {
|
|
78
|
+
isVisible: (e) => r(e, i.value),
|
|
79
|
+
ctx: i
|
|
80
|
+
}), () => t.default?.();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
function E() {
|
|
84
|
+
let e = p(w);
|
|
85
|
+
if (!e) throw Error("useVisibility must be used within a VisibilityProvider");
|
|
86
|
+
return e;
|
|
87
|
+
}
|
|
88
|
+
var D = /* @__PURE__ */ Symbol("json-render:validation");
|
|
89
|
+
function O(e, t) {
|
|
90
|
+
if (e === t) return !0;
|
|
91
|
+
if (!e || !t) return !1;
|
|
92
|
+
let n = Object.keys(e), r = Object.keys(t);
|
|
93
|
+
if (n.length !== r.length) return !1;
|
|
94
|
+
for (let r of n) {
|
|
95
|
+
let n = e[r], i = t[r];
|
|
96
|
+
if (n !== i) {
|
|
97
|
+
if (typeof n == "object" && n && typeof i == "object" && i) {
|
|
98
|
+
let e = n.$state, t = i.$state;
|
|
99
|
+
if (typeof e == "string" && e === t) continue;
|
|
100
|
+
}
|
|
101
|
+
return !1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return !0;
|
|
105
|
+
}
|
|
106
|
+
function k(e, t) {
|
|
107
|
+
if (e === t) return !0;
|
|
108
|
+
if (e.validateOn !== t.validateOn) return !1;
|
|
109
|
+
let n = e.checks ?? [], r = t.checks ?? [];
|
|
110
|
+
if (n.length !== r.length) return !1;
|
|
111
|
+
for (let e = 0; e < n.length; e++) {
|
|
112
|
+
let t = n[e], i = r[e];
|
|
113
|
+
if (t.type !== i.type || t.message !== i.message || !O(t.args, i.args)) return !1;
|
|
114
|
+
}
|
|
115
|
+
return !0;
|
|
116
|
+
}
|
|
117
|
+
var A = d({
|
|
118
|
+
name: "ValidationProvider",
|
|
119
|
+
props: { customFunctions: {
|
|
120
|
+
type: Object,
|
|
121
|
+
default: () => ({})
|
|
122
|
+
} },
|
|
123
|
+
setup(e, { slots: t }) {
|
|
124
|
+
let { state: n } = S(), r = _({}), i = _({}), a = (e, t) => {
|
|
125
|
+
let n = i.value[e];
|
|
126
|
+
n && k(n, t) || (i.value = {
|
|
127
|
+
...i.value,
|
|
128
|
+
[e]: t
|
|
129
|
+
});
|
|
130
|
+
}, o = (t, i) => {
|
|
131
|
+
let a = n.value, o = t.split("/").filter(Boolean), s = a;
|
|
132
|
+
for (let e of o) if (typeof s == "object" && s) s = s[e];
|
|
133
|
+
else {
|
|
134
|
+
s = void 0;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
let c = l(i, {
|
|
138
|
+
value: s,
|
|
139
|
+
stateModel: a,
|
|
140
|
+
customFunctions: e.customFunctions
|
|
141
|
+
});
|
|
142
|
+
return r.value = {
|
|
143
|
+
...r.value,
|
|
144
|
+
[t]: {
|
|
145
|
+
touched: r.value[t]?.touched ?? !0,
|
|
146
|
+
validated: !0,
|
|
147
|
+
result: c
|
|
148
|
+
}
|
|
149
|
+
}, c;
|
|
150
|
+
};
|
|
151
|
+
return g(D, {
|
|
152
|
+
get customFunctions() {
|
|
153
|
+
return e.customFunctions;
|
|
154
|
+
},
|
|
155
|
+
get fieldStates() {
|
|
156
|
+
return r.value;
|
|
157
|
+
},
|
|
158
|
+
validate: o,
|
|
159
|
+
touch: (e) => {
|
|
160
|
+
r.value = {
|
|
161
|
+
...r.value,
|
|
162
|
+
[e]: {
|
|
163
|
+
...r.value[e],
|
|
164
|
+
touched: !0,
|
|
165
|
+
validated: r.value[e]?.validated ?? !1,
|
|
166
|
+
result: r.value[e]?.result ?? null
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
},
|
|
170
|
+
clear: (e) => {
|
|
171
|
+
let { [e]: t, ...n } = r.value;
|
|
172
|
+
r.value = n;
|
|
173
|
+
},
|
|
174
|
+
validateAll: () => {
|
|
175
|
+
let e = !0;
|
|
176
|
+
for (let [t, n] of Object.entries(i.value)) o(t, n).valid || (e = !1);
|
|
177
|
+
return e;
|
|
178
|
+
},
|
|
179
|
+
registerField: a
|
|
180
|
+
}), () => t.default?.();
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
function j() {
|
|
184
|
+
return p(D, null) ?? null;
|
|
185
|
+
}
|
|
186
|
+
var M = 0;
|
|
187
|
+
function N() {
|
|
188
|
+
return M += 1, `${Date.now()}-${M}`;
|
|
189
|
+
}
|
|
190
|
+
function P(e, t) {
|
|
191
|
+
if (e == null) return e;
|
|
192
|
+
if (e === "$id") return N();
|
|
193
|
+
if (typeof e == "object" && !Array.isArray(e)) {
|
|
194
|
+
let n = e, r = Object.keys(n);
|
|
195
|
+
if (r.length === 1 && typeof n.$state == "string") return t(n.$state);
|
|
196
|
+
if (r.length === 1 && "$id" in n) return N();
|
|
197
|
+
}
|
|
198
|
+
if (Array.isArray(e)) return e.map((e) => P(e, t));
|
|
199
|
+
if (typeof e == "object") {
|
|
200
|
+
let n = {};
|
|
201
|
+
for (let [r, i] of Object.entries(e)) n[r] = P(i, t);
|
|
202
|
+
return n;
|
|
203
|
+
}
|
|
204
|
+
return e;
|
|
205
|
+
}
|
|
206
|
+
var F = /* @__PURE__ */ Symbol("json-render:actions"), I = d({
|
|
207
|
+
name: "ActionProvider",
|
|
208
|
+
props: {
|
|
209
|
+
handlers: {
|
|
210
|
+
type: Object,
|
|
211
|
+
default: () => ({})
|
|
212
|
+
},
|
|
213
|
+
navigate: {
|
|
214
|
+
type: Function,
|
|
215
|
+
default: void 0
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
setup(e, { slots: t }) {
|
|
219
|
+
let { get: n, set: r, getSnapshot: o } = S(), s = j(), c = _(e.handlers ?? {}), l = _(/* @__PURE__ */ new Set()), u = _(null);
|
|
220
|
+
y(() => e.handlers, (e) => {
|
|
221
|
+
e && (c.value = e);
|
|
222
|
+
});
|
|
223
|
+
let d = (e, t) => {
|
|
224
|
+
c.value = {
|
|
225
|
+
...c.value,
|
|
226
|
+
[e]: t
|
|
227
|
+
};
|
|
228
|
+
}, f = async (t) => {
|
|
229
|
+
let d = a(t, o());
|
|
230
|
+
if (d.action === "setState" && d.params) {
|
|
231
|
+
let e = d.params.statePath, t = d.params.value;
|
|
232
|
+
e && r(e, t);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (d.action === "pushState" && d.params) {
|
|
236
|
+
let e = d.params.statePath, t = d.params.value;
|
|
237
|
+
if (e) {
|
|
238
|
+
let i = P(t, n);
|
|
239
|
+
r(e, [...n(e) ?? [], i]);
|
|
240
|
+
let a = d.params.clearStatePath;
|
|
241
|
+
a && r(a, "");
|
|
242
|
+
}
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (d.action === "removeState" && d.params) {
|
|
246
|
+
let e = d.params.statePath, t = d.params.index;
|
|
247
|
+
e !== void 0 && t !== void 0 && r(e, (n(e) ?? []).filter((e, n) => n !== t));
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (d.action === "validateForm") {
|
|
251
|
+
let e = s?.validateAll;
|
|
252
|
+
if (!e) {
|
|
253
|
+
console.warn("validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.");
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
let t = e(), n = {};
|
|
257
|
+
for (let [e, t] of Object.entries(s.fieldStates)) t.result && !t.result.valid && (n[e] = t.result.errors);
|
|
258
|
+
r(d.params?.statePath || "/formValidation", {
|
|
259
|
+
valid: t,
|
|
260
|
+
errors: n
|
|
261
|
+
});
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (d.action === "push" && d.params) {
|
|
265
|
+
let e = d.params.screen;
|
|
266
|
+
if (e) {
|
|
267
|
+
let t = n("/currentScreen"), i = n("/navStack") ?? [];
|
|
268
|
+
t ? r("/navStack", [...i, t]) : r("/navStack", [...i, ""]), r("/currentScreen", e);
|
|
269
|
+
}
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (d.action === "pop") {
|
|
273
|
+
let e = n("/navStack") ?? [];
|
|
274
|
+
if (e.length > 0) {
|
|
275
|
+
let t = e[e.length - 1];
|
|
276
|
+
r("/navStack", e.slice(0, -1)), t ? r("/currentScreen", t) : r("/currentScreen", void 0);
|
|
277
|
+
}
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
let p = c.value[d.action];
|
|
281
|
+
if (!p) {
|
|
282
|
+
console.warn(`No handler registered for action: ${d.action}`);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (d.confirm) {
|
|
286
|
+
await new Promise((e, t) => {
|
|
287
|
+
u.value = {
|
|
288
|
+
action: d,
|
|
289
|
+
handler: p,
|
|
290
|
+
resolve: () => {
|
|
291
|
+
u.value = null, e();
|
|
292
|
+
},
|
|
293
|
+
reject: () => {
|
|
294
|
+
u.value = null, t(/* @__PURE__ */ Error("Action cancelled"));
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
});
|
|
298
|
+
let t = new Set(l.value);
|
|
299
|
+
t.add(d.action), l.value = t;
|
|
300
|
+
try {
|
|
301
|
+
await i({
|
|
302
|
+
action: d,
|
|
303
|
+
handler: p,
|
|
304
|
+
setState: r,
|
|
305
|
+
navigate: e.navigate,
|
|
306
|
+
executeAction: async (e) => {
|
|
307
|
+
await f({ action: e });
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
} finally {
|
|
311
|
+
let e = new Set(l.value);
|
|
312
|
+
e.delete(d.action), l.value = e;
|
|
313
|
+
}
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
let m = new Set(l.value);
|
|
317
|
+
m.add(d.action), l.value = m;
|
|
318
|
+
try {
|
|
319
|
+
await i({
|
|
320
|
+
action: d,
|
|
321
|
+
handler: p,
|
|
322
|
+
setState: r,
|
|
323
|
+
navigate: e.navigate,
|
|
324
|
+
executeAction: async (e) => {
|
|
325
|
+
await f({ action: e });
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
} finally {
|
|
329
|
+
let e = new Set(l.value);
|
|
330
|
+
e.delete(d.action), l.value = e;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
return g(F, {
|
|
334
|
+
get handlers() {
|
|
335
|
+
return c.value;
|
|
336
|
+
},
|
|
337
|
+
get loadingActions() {
|
|
338
|
+
return l.value;
|
|
339
|
+
},
|
|
340
|
+
get pendingConfirmation() {
|
|
341
|
+
return u.value;
|
|
342
|
+
},
|
|
343
|
+
execute: f,
|
|
344
|
+
confirm: () => u.value?.resolve(),
|
|
345
|
+
cancel: () => u.value?.reject(),
|
|
346
|
+
registerHandler: d
|
|
347
|
+
}), () => t.default?.();
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
function L() {
|
|
351
|
+
let e = p(F);
|
|
352
|
+
if (!e) throw Error("useActions must be used within an ActionProvider");
|
|
353
|
+
return e;
|
|
354
|
+
}
|
|
355
|
+
var R = d({
|
|
356
|
+
name: "ConfirmDialog",
|
|
357
|
+
props: {
|
|
358
|
+
confirm: {
|
|
359
|
+
type: Object,
|
|
360
|
+
required: !0
|
|
361
|
+
},
|
|
362
|
+
onConfirm: {
|
|
363
|
+
type: Function,
|
|
364
|
+
required: !0
|
|
365
|
+
},
|
|
366
|
+
onCancel: {
|
|
367
|
+
type: Function,
|
|
368
|
+
required: !0
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
setup(e) {
|
|
372
|
+
return () => {
|
|
373
|
+
let t = e.confirm.variant === "danger";
|
|
374
|
+
return f("div", {
|
|
375
|
+
style: {
|
|
376
|
+
position: "fixed",
|
|
377
|
+
inset: "0",
|
|
378
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
379
|
+
display: "flex",
|
|
380
|
+
alignItems: "center",
|
|
381
|
+
justifyContent: "center",
|
|
382
|
+
zIndex: "50"
|
|
383
|
+
},
|
|
384
|
+
onClick: e.onCancel
|
|
385
|
+
}, [f("div", {
|
|
386
|
+
style: {
|
|
387
|
+
backgroundColor: "white",
|
|
388
|
+
borderRadius: "8px",
|
|
389
|
+
padding: "24px",
|
|
390
|
+
maxWidth: "400px",
|
|
391
|
+
width: "100%",
|
|
392
|
+
boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1)"
|
|
393
|
+
},
|
|
394
|
+
onClick: (e) => e.stopPropagation()
|
|
395
|
+
}, [
|
|
396
|
+
f("h3", { style: {
|
|
397
|
+
margin: "0 0 8px 0",
|
|
398
|
+
fontSize: "18px",
|
|
399
|
+
fontWeight: "600"
|
|
400
|
+
} }, e.confirm.title),
|
|
401
|
+
f("p", { style: {
|
|
402
|
+
margin: "0 0 24px 0",
|
|
403
|
+
color: "#6b7280"
|
|
404
|
+
} }, e.confirm.message),
|
|
405
|
+
f("div", { style: {
|
|
406
|
+
display: "flex",
|
|
407
|
+
gap: "12px",
|
|
408
|
+
justifyContent: "flex-end"
|
|
409
|
+
} }, [f("button", {
|
|
410
|
+
style: {
|
|
411
|
+
padding: "8px 16px",
|
|
412
|
+
borderRadius: "6px",
|
|
413
|
+
border: "1px solid #d1d5db",
|
|
414
|
+
backgroundColor: "white",
|
|
415
|
+
cursor: "pointer"
|
|
416
|
+
},
|
|
417
|
+
onClick: e.onCancel
|
|
418
|
+
}, e.confirm.cancelLabel ?? "Cancel"), f("button", {
|
|
419
|
+
style: {
|
|
420
|
+
padding: "8px 16px",
|
|
421
|
+
borderRadius: "6px",
|
|
422
|
+
border: "none",
|
|
423
|
+
backgroundColor: t ? "#dc2626" : "#3b82f6",
|
|
424
|
+
color: "white",
|
|
425
|
+
cursor: "pointer"
|
|
426
|
+
},
|
|
427
|
+
onClick: e.onConfirm
|
|
428
|
+
}, e.confirm.confirmLabel ?? "Confirm")])
|
|
429
|
+
])]);
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
}), z = /* @__PURE__ */ Symbol("json-render:repeat-scope"), B = d({
|
|
433
|
+
name: "RepeatScopeProvider",
|
|
434
|
+
props: {
|
|
435
|
+
item: { required: !0 },
|
|
436
|
+
index: {
|
|
437
|
+
type: Number,
|
|
438
|
+
required: !0
|
|
439
|
+
},
|
|
440
|
+
basePath: {
|
|
441
|
+
type: String,
|
|
442
|
+
required: !0
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
setup(e, { slots: t }) {
|
|
446
|
+
return g(z, e), () => t.default?.();
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
function V() {
|
|
450
|
+
return p(z, null) ?? null;
|
|
451
|
+
}
|
|
452
|
+
var H = {}, U = /* @__PURE__ */ Symbol("json-render:functions"), W = d({
|
|
453
|
+
name: "FunctionsProvider",
|
|
454
|
+
props: { functions: {
|
|
455
|
+
type: Object,
|
|
456
|
+
default: void 0
|
|
457
|
+
} },
|
|
458
|
+
setup(e, { slots: t }) {
|
|
459
|
+
return g(U, u(() => e.functions ?? H)), () => t.default?.();
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
function G() {
|
|
463
|
+
return p(U, u(() => H));
|
|
464
|
+
}
|
|
465
|
+
var K = d({
|
|
466
|
+
name: "ElementErrorBoundary",
|
|
467
|
+
props: { elementType: {
|
|
468
|
+
type: String,
|
|
469
|
+
required: !0
|
|
470
|
+
} },
|
|
471
|
+
setup(e, { slots: t }) {
|
|
472
|
+
let n = _(!1);
|
|
473
|
+
return m((t) => (console.error(`[json-render] Rendering error in <${e.elementType}>:`, t), n.value = !0, !1)), () => n.value ? null : t.default?.();
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
async function q(e, t, n, r, i) {
|
|
477
|
+
for (let a of e) {
|
|
478
|
+
if (i?.()) break;
|
|
479
|
+
if (!a.params) {
|
|
480
|
+
if (await r(a), i?.()) break;
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
let e = {
|
|
484
|
+
...t,
|
|
485
|
+
stateModel: n()
|
|
486
|
+
}, s = {};
|
|
487
|
+
for (let [t, n] of Object.entries(a.params)) s[t] = o(n, e);
|
|
488
|
+
if (await r({
|
|
489
|
+
...a,
|
|
490
|
+
params: s
|
|
491
|
+
}), i?.()) break;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
var J = d({
|
|
495
|
+
name: "JsonRenderElement",
|
|
496
|
+
props: {
|
|
497
|
+
element: {
|
|
498
|
+
type: Object,
|
|
499
|
+
required: !0
|
|
500
|
+
},
|
|
501
|
+
spec: {
|
|
502
|
+
type: Object,
|
|
503
|
+
required: !0
|
|
504
|
+
},
|
|
505
|
+
registry: {
|
|
506
|
+
type: Object,
|
|
507
|
+
required: !0
|
|
508
|
+
},
|
|
509
|
+
loading: {
|
|
510
|
+
type: Boolean,
|
|
511
|
+
default: void 0
|
|
512
|
+
},
|
|
513
|
+
fallback: {
|
|
514
|
+
type: Object,
|
|
515
|
+
default: void 0
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
setup(e) {
|
|
519
|
+
let t = V(), { ctx: i } = E(), { execute: a } = L(), { getSnapshot: o, state: l } = S(), d = G(), p = u(() => {
|
|
520
|
+
let e = t ? {
|
|
521
|
+
...i.value,
|
|
522
|
+
repeatItem: t.item,
|
|
523
|
+
repeatIndex: t.index,
|
|
524
|
+
repeatBasePath: t.basePath
|
|
525
|
+
} : { ...i.value };
|
|
526
|
+
return e.functions = d.value, e;
|
|
527
|
+
}), m = async (t) => {
|
|
528
|
+
let n = e.element.on?.[t];
|
|
529
|
+
n && await q(Array.isArray(n) ? n : [n], p.value, o, a);
|
|
530
|
+
}, h = (t) => {
|
|
531
|
+
let n = e.element.on?.[t];
|
|
532
|
+
return n ? {
|
|
533
|
+
emit: () => {
|
|
534
|
+
m(t);
|
|
535
|
+
},
|
|
536
|
+
shouldPreventDefault: (Array.isArray(n) ? n : [n]).some((e) => e.preventDefault),
|
|
537
|
+
bound: !0
|
|
538
|
+
} : {
|
|
539
|
+
emit: () => {},
|
|
540
|
+
shouldPreventDefault: !1,
|
|
541
|
+
bound: !1
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
return y(u(() => {
|
|
545
|
+
let t = e.element.watch;
|
|
546
|
+
if (!t) return;
|
|
547
|
+
let r = {};
|
|
548
|
+
for (let e of Object.keys(t)) r[e] = n(l.value, e);
|
|
549
|
+
return r;
|
|
550
|
+
}), (t, n, r) => {
|
|
551
|
+
let i = e.element.watch;
|
|
552
|
+
if (!i || !t) return;
|
|
553
|
+
let s = !1;
|
|
554
|
+
r(() => {
|
|
555
|
+
s = !0;
|
|
556
|
+
});
|
|
557
|
+
let c = Object.keys(i);
|
|
558
|
+
(async () => {
|
|
559
|
+
for (let e of c) {
|
|
560
|
+
if (s) break;
|
|
561
|
+
if (n && t[e] === n[e]) continue;
|
|
562
|
+
let r = i[e];
|
|
563
|
+
r && await q(Array.isArray(r) ? r : [r], p.value, o, a, () => s);
|
|
564
|
+
}
|
|
565
|
+
})().catch(console.error);
|
|
566
|
+
}, { deep: !0 }), () => {
|
|
567
|
+
let t = p.value;
|
|
568
|
+
if (!(e.element.visible === void 0 || r(e.element.visible, t))) return null;
|
|
569
|
+
let n = e.element.props, i = s(n, t), a = c(n, t), o = a === e.element.props ? e.element : {
|
|
570
|
+
...e.element,
|
|
571
|
+
props: a
|
|
572
|
+
}, l = e.registry[o.type] ?? e.fallback;
|
|
573
|
+
if (!l) return console.warn(`[json-render] No renderer for component type: ${o.type}`), null;
|
|
574
|
+
let u = o.repeat ? f(Y, {
|
|
575
|
+
element: o,
|
|
576
|
+
spec: e.spec,
|
|
577
|
+
registry: e.registry,
|
|
578
|
+
loading: e.loading,
|
|
579
|
+
fallback: e.fallback
|
|
580
|
+
}) : o.children?.map((t) => {
|
|
581
|
+
let n = e.spec.elements[t];
|
|
582
|
+
return n ? f(J, {
|
|
583
|
+
key: t,
|
|
584
|
+
element: n,
|
|
585
|
+
spec: e.spec,
|
|
586
|
+
registry: e.registry,
|
|
587
|
+
loading: e.loading,
|
|
588
|
+
fallback: e.fallback
|
|
589
|
+
}) : (e.loading || console.warn(`[json-render] Missing element "${t}" referenced as child of "${o.type}". This element will not render.`), null);
|
|
590
|
+
}).filter((e) => e !== null) ?? void 0;
|
|
591
|
+
return f(K, { elementType: o.type }, { default: () => f(l, {
|
|
592
|
+
element: o,
|
|
593
|
+
emit: m,
|
|
594
|
+
on: h,
|
|
595
|
+
bindings: i,
|
|
596
|
+
loading: e.loading
|
|
597
|
+
}, { default: () => u }) });
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
}), Y = d({
|
|
601
|
+
name: "JsonRenderRepeatChildren",
|
|
602
|
+
props: {
|
|
603
|
+
element: {
|
|
604
|
+
type: Object,
|
|
605
|
+
required: !0
|
|
606
|
+
},
|
|
607
|
+
spec: {
|
|
608
|
+
type: Object,
|
|
609
|
+
required: !0
|
|
610
|
+
},
|
|
611
|
+
registry: {
|
|
612
|
+
type: Object,
|
|
613
|
+
required: !0
|
|
614
|
+
},
|
|
615
|
+
loading: {
|
|
616
|
+
type: Boolean,
|
|
617
|
+
default: void 0
|
|
618
|
+
},
|
|
619
|
+
fallback: {
|
|
620
|
+
type: Object,
|
|
621
|
+
default: void 0
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
setup(e) {
|
|
625
|
+
let { state: t } = S();
|
|
626
|
+
return () => {
|
|
627
|
+
let r = e.element.repeat;
|
|
628
|
+
if (!r?.statePath) return null;
|
|
629
|
+
let i = r.statePath, a = n(t.value, i);
|
|
630
|
+
return (Array.isArray(a) ? a : []).map((t, n) => f(B, {
|
|
631
|
+
key: r.key && typeof t == "object" && t ? String(t[r.key] ?? n) : String(n),
|
|
632
|
+
item: t,
|
|
633
|
+
index: n,
|
|
634
|
+
basePath: `${i}/${n}`
|
|
635
|
+
}, { default: () => e.element.children?.map((t) => {
|
|
636
|
+
let n = e.spec.elements[t];
|
|
637
|
+
return n ? f(J, {
|
|
638
|
+
key: t,
|
|
639
|
+
element: n,
|
|
640
|
+
spec: e.spec,
|
|
641
|
+
registry: e.registry,
|
|
642
|
+
loading: e.loading,
|
|
643
|
+
fallback: e.fallback
|
|
644
|
+
}) : (e.loading || console.warn(`[json-render] Missing element "${t}" referenced as child of "${e.element.type}" (repeat). This element will not render.`), null);
|
|
645
|
+
}).filter((e) => e !== null) ?? null }));
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
}), X = d({
|
|
649
|
+
name: "JsonRenderer",
|
|
650
|
+
props: {
|
|
651
|
+
spec: {
|
|
652
|
+
type: Object,
|
|
653
|
+
default: null
|
|
654
|
+
},
|
|
655
|
+
registry: {
|
|
656
|
+
type: Object,
|
|
657
|
+
required: !0
|
|
658
|
+
},
|
|
659
|
+
loading: {
|
|
660
|
+
type: Boolean,
|
|
661
|
+
default: void 0
|
|
662
|
+
},
|
|
663
|
+
fallback: {
|
|
664
|
+
type: Object,
|
|
665
|
+
default: void 0
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
setup(e) {
|
|
669
|
+
return () => {
|
|
670
|
+
if (!e.spec?.root) return null;
|
|
671
|
+
let t = e.spec.elements[e.spec.root];
|
|
672
|
+
return t ? f(J, {
|
|
673
|
+
element: t,
|
|
674
|
+
spec: e.spec,
|
|
675
|
+
registry: e.registry,
|
|
676
|
+
loading: e.loading,
|
|
677
|
+
fallback: e.fallback
|
|
678
|
+
}) : null;
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
}), Z = d({
|
|
682
|
+
name: "ConfirmationDialogManager",
|
|
683
|
+
setup() {
|
|
684
|
+
let { pendingConfirmation: e, confirm: t, cancel: n } = L();
|
|
685
|
+
return () => e?.action.confirm ? f(R, {
|
|
686
|
+
confirm: e.action.confirm,
|
|
687
|
+
onConfirm: t,
|
|
688
|
+
onCancel: n
|
|
689
|
+
}) : null;
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
d({
|
|
693
|
+
name: "JSONUIProvider",
|
|
694
|
+
props: {
|
|
695
|
+
registry: {
|
|
696
|
+
type: Object,
|
|
697
|
+
required: !0
|
|
698
|
+
},
|
|
699
|
+
store: {
|
|
700
|
+
type: Object,
|
|
701
|
+
default: void 0
|
|
702
|
+
},
|
|
703
|
+
initialState: {
|
|
704
|
+
type: Object,
|
|
705
|
+
default: void 0
|
|
706
|
+
},
|
|
707
|
+
handlers: {
|
|
708
|
+
type: Object,
|
|
709
|
+
default: void 0
|
|
710
|
+
},
|
|
711
|
+
navigate: {
|
|
712
|
+
type: Function,
|
|
713
|
+
default: void 0
|
|
714
|
+
},
|
|
715
|
+
validationFunctions: {
|
|
716
|
+
type: Object,
|
|
717
|
+
default: void 0
|
|
718
|
+
},
|
|
719
|
+
functions: {
|
|
720
|
+
type: Object,
|
|
721
|
+
default: void 0
|
|
722
|
+
},
|
|
723
|
+
onStateChange: {
|
|
724
|
+
type: Function,
|
|
725
|
+
default: void 0
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
setup(e, { slots: t }) {
|
|
729
|
+
return () => f(x, {
|
|
730
|
+
store: e.store,
|
|
731
|
+
initialState: e.initialState,
|
|
732
|
+
onStateChange: e.onStateChange
|
|
733
|
+
}, { default: () => f(T, null, { default: () => f(A, { customFunctions: e.validationFunctions }, { default: () => f(I, {
|
|
734
|
+
handlers: e.handlers,
|
|
735
|
+
navigate: e.navigate
|
|
736
|
+
}, { default: () => f(W, { functions: e.functions }, { default: () => [t.default?.(), f(Z)] }) }) }) }) });
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
function Q(e, t) {
|
|
740
|
+
let n = {};
|
|
741
|
+
if (t.components) for (let [e, r] of Object.entries(t.components)) n[e] = d({
|
|
742
|
+
name: `JsonRenderRegistry_${e}`,
|
|
743
|
+
props: {
|
|
744
|
+
element: {
|
|
745
|
+
type: Object,
|
|
746
|
+
required: !0
|
|
747
|
+
},
|
|
748
|
+
emit: {
|
|
749
|
+
type: Function,
|
|
750
|
+
required: !0
|
|
751
|
+
},
|
|
752
|
+
on: {
|
|
753
|
+
type: Function,
|
|
754
|
+
required: !0
|
|
755
|
+
},
|
|
756
|
+
bindings: {
|
|
757
|
+
type: Object,
|
|
758
|
+
default: void 0
|
|
759
|
+
},
|
|
760
|
+
loading: {
|
|
761
|
+
type: Boolean,
|
|
762
|
+
default: void 0
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
setup(e, { slots: t }) {
|
|
766
|
+
return () => r({
|
|
767
|
+
props: e.element.props,
|
|
768
|
+
children: t.default?.(),
|
|
769
|
+
emit: e.emit,
|
|
770
|
+
on: e.on,
|
|
771
|
+
bindings: e.bindings,
|
|
772
|
+
loading: e.loading
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
let r = t.actions ? Object.entries(t.actions) : [];
|
|
777
|
+
return {
|
|
778
|
+
registry: n,
|
|
779
|
+
handlers: (e, t) => {
|
|
780
|
+
let n = {};
|
|
781
|
+
for (let [i, a] of r) n[i] = async (n) => {
|
|
782
|
+
let r = e(), i = t();
|
|
783
|
+
r && await a(n, r, i);
|
|
784
|
+
};
|
|
785
|
+
return n;
|
|
786
|
+
},
|
|
787
|
+
executeAction: async (e, t, n, i = {}) => {
|
|
788
|
+
let a = r.find(([t]) => t === e);
|
|
789
|
+
a ? await a[1](t, n, i) : console.warn(`Unknown action: ${e}`);
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
//#endregion
|
|
794
|
+
export { I as ActionProvider, X as Renderer, x as StateProvider, T as VisibilityProvider, Q as defineRegistry, C as useStateBinding };
|
|
795
|
+
|
|
796
|
+
//# sourceMappingURL=index.js.map
|