@cratis/stage.runtime 0.0.0 → 4.157.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 +21 -0
- package/README.md +11 -1
- package/dist/src/App.d.ts +65 -0
- package/dist/src/StageChrome.d.ts +44 -0
- package/dist/src/StageCommandForm.d.ts +18 -0
- package/dist/src/StageCommandOutcome.d.ts +11 -0
- package/dist/src/StageGuardedAction.d.ts +20 -0
- package/dist/src/StageShellSettings.d.ts +15 -0
- package/dist/src/app.css +2 -0
- package/dist/src/blueprint.d.ts +48 -0
- package/dist/src/commandExecutor.d.ts +11 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +1897 -0
- package/dist/src/navigationTree.d.ts +69 -0
- package/dist/src/stageComponents.d.ts +31 -0
- package/dist/src/stageData.d.ts +72 -0
- package/dist/src/stageDataSources.d.ts +17 -0
- package/dist/src/stageGuards.d.ts +88 -0
- package/dist/src/stageNavigation.d.ts +33 -0
- package/dist/src/stageNavigationModel.d.ts +22 -0
- package/dist/src/stageRoutes.d.ts +24 -0
- package/dist/src/stageRowInteractions.d.ts +26 -0
- package/dist/src/stageShell.d.ts +55 -0
- package/dist/src/stageSlices.d.ts +21 -0
- package/dist/src/stageSource.d.ts +33 -0
- package/dist/src/stageTheme.d.ts +19 -0
- package/dist/src/useStrings.d.ts +21 -0
- package/dist/styledPrimeReact.d.ts +23 -0
- package/dist/styledPrimeReact.js +30 -0
- package/package.json +62 -3
|
@@ -0,0 +1,1897 @@
|
|
|
1
|
+
import "./app.css";
|
|
2
|
+
import { createContext as e, createElement as t, useCallback as n, useContext as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
3
|
+
import { ColorScheme as c, DestinationKind as l, FormGenerationMode as u, FormWidthUnit as d, InteractionTriggerKind as f } from "@cratis/scene.model";
|
|
4
|
+
import { ShellDiagnosticCode as p, ShellOrigin as m, createBindingResolver as h, resolveArgumentSource as g, resolveBehaviors as _, resolveStringsInElement as v, runBindings as y, validateBindingExpression as b } from "@cratis/scene.engine";
|
|
5
|
+
import { CoreToolbarItem as x, InteractionScope as ee, SceneElementView as S, SceneNavigationContextInternal as te, SliceCommandFieldsProvider as C, SliceInvokerProvider as ne, attachmentFor as re, coreComponents as w, createBrowserDispatcher as T, createHashSceneHistory as E, useInteractionScope as D, useSceneNavigation as ie, useSceneOutlets as ae, useSceneTheme as O } from "@cratis/scene.react";
|
|
6
|
+
import { ApplicationHost as oe, ColorScheme as k, ComponentName as A, LayoutThemeProvider as se, SlotName as j, blueprintPackageCatalog as ce, composeApplicationScreen as le, defaultBlueprintComponents as ue, defaultBlueprintName as de, defaultBlueprintThemes as fe, effectiveShellOf as pe, externalComponent as M, galleryScreenTemplates as me, layoutModes as he, menuThemes as ge, navigationElement as _e, previewComponents as ve, previewProfile as ye, useLayoutConfig as be } from "@cratis/scene.blueprint.default";
|
|
7
|
+
import "@cratis/scene.blueprint.default/styles.css";
|
|
8
|
+
import { jsx as N, jsxs as P } from "react/jsx-runtime";
|
|
9
|
+
import { Button as F } from "primereact/button";
|
|
10
|
+
import { PrimeDialog as xe, PrimeMessage as Se, primeReactComponents as Ce, primeReactPackageManifest as we } from "@cratis/scene.primereact";
|
|
11
|
+
import { ArcContext as Te } from "@cratis/arc.react";
|
|
12
|
+
import { Command as Ee } from "@cratis/arc/commands";
|
|
13
|
+
import { resolveCommand as De } from "@cratis/scene.components";
|
|
14
|
+
import { CommandForm as Oe } from "@cratis/arc.react/commands";
|
|
15
|
+
import { CalendarField as ke, CheckboxField as Ae, InputTextField as je, NumberField as Me } from "@cratis/components/CommandForm";
|
|
16
|
+
import Ne from "@primeuix/themes/lara";
|
|
17
|
+
//#region src/stageSource.ts
|
|
18
|
+
function Pe(e) {
|
|
19
|
+
return {
|
|
20
|
+
scene: async () => e.scene,
|
|
21
|
+
routes: async () => e.routes,
|
|
22
|
+
locales: async () => Object.keys(e.strings),
|
|
23
|
+
strings: async (t) => e.strings[t] ?? {}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var Fe = {
|
|
27
|
+
scene: "stage/scene",
|
|
28
|
+
routes: "stage/routes",
|
|
29
|
+
locales: "stage/locales",
|
|
30
|
+
strings: (e) => `stage/strings/${encodeURIComponent(e)}`
|
|
31
|
+
}, Ie = e(void 0);
|
|
32
|
+
function Le({ source: e, children: n }) {
|
|
33
|
+
return t(Ie.Provider, { value: e }, n);
|
|
34
|
+
}
|
|
35
|
+
function I() {
|
|
36
|
+
let e = r(Ie);
|
|
37
|
+
if (!e) throw Error("A StageSourceProvider is required to render a Stage application.");
|
|
38
|
+
return e;
|
|
39
|
+
}
|
|
40
|
+
Fe.routes;
|
|
41
|
+
function Re() {
|
|
42
|
+
let e = I(), [t, n] = s({
|
|
43
|
+
routes: void 0,
|
|
44
|
+
ready: !1
|
|
45
|
+
});
|
|
46
|
+
return i(() => {
|
|
47
|
+
let t = new AbortController();
|
|
48
|
+
return e.routes(t.signal).then((e) => {
|
|
49
|
+
t.signal.aborted || n({
|
|
50
|
+
routes: e,
|
|
51
|
+
ready: !0
|
|
52
|
+
});
|
|
53
|
+
}).catch(() => {
|
|
54
|
+
t.signal.aborted || n({
|
|
55
|
+
routes: void 0,
|
|
56
|
+
ready: !0
|
|
57
|
+
});
|
|
58
|
+
}), () => t.abort();
|
|
59
|
+
}, [e]), t;
|
|
60
|
+
}
|
|
61
|
+
function ze(e) {
|
|
62
|
+
if (L(e)) return typeof e.subject == "string" ? e.subject : typeof e.path == "string" ? e.path : void 0;
|
|
63
|
+
}
|
|
64
|
+
var Be = "STAGE-SCENE-ACTION-001", Ve = "item.";
|
|
65
|
+
function L(e) {
|
|
66
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
67
|
+
}
|
|
68
|
+
function He(e, t) {
|
|
69
|
+
let n = e;
|
|
70
|
+
for (let e of t.split(".").filter(Boolean)) {
|
|
71
|
+
if (!L(n)) return;
|
|
72
|
+
n = n[e];
|
|
73
|
+
}
|
|
74
|
+
return n;
|
|
75
|
+
}
|
|
76
|
+
function Ue(e) {
|
|
77
|
+
return e === null || [
|
|
78
|
+
"string",
|
|
79
|
+
"number",
|
|
80
|
+
"boolean"
|
|
81
|
+
].includes(typeof e);
|
|
82
|
+
}
|
|
83
|
+
function We(e, t) {
|
|
84
|
+
if (typeof e == "number") return t[e];
|
|
85
|
+
if (typeof e == "string") return t.find((t) => t.toLowerCase() === e.toLowerCase());
|
|
86
|
+
}
|
|
87
|
+
function Ge(e, t, n, r) {
|
|
88
|
+
if (r !== void 0 && (t === "Equal" || t === "NotEqual")) {
|
|
89
|
+
let i = We(e, r), a = typeof n == "string" ? r.find((e) => e.toLowerCase() === n.toLowerCase()) : void 0;
|
|
90
|
+
return i === void 0 || a === void 0 ? !1 : t === "Equal" ? i === a : i !== a;
|
|
91
|
+
}
|
|
92
|
+
switch (t) {
|
|
93
|
+
case "Equal": return e != null && e === n;
|
|
94
|
+
case "NotEqual": return e != null && e !== n;
|
|
95
|
+
case "GreaterThan": return typeof e == "number" && typeof n == "number" && e > n;
|
|
96
|
+
case "GreaterThanOrEqual": return typeof e == "number" && typeof n == "number" && e >= n;
|
|
97
|
+
case "LessThan": return typeof e == "number" && typeof n == "number" && e < n;
|
|
98
|
+
case "LessThanOrEqual": return typeof e == "number" && typeof n == "number" && e <= n;
|
|
99
|
+
case "Contains": return typeof n == "string" && (typeof e == "string" || Array.isArray(e)) && e.includes(n);
|
|
100
|
+
case "StartsWith": return typeof e == "string" && typeof n == "string" && e.startsWith(n);
|
|
101
|
+
default: return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function R(e, t) {
|
|
105
|
+
if (L(e)) {
|
|
106
|
+
if (e.kind === "comparison") {
|
|
107
|
+
let n = ze(e.left);
|
|
108
|
+
if (typeof n != "string" || !n.startsWith(Ve) || typeof e.operator != "string" || !Ue(e.right)) return;
|
|
109
|
+
let r = Array.isArray(e.enumeration) && e.enumeration.every((e) => typeof e == "string") ? e.enumeration : void 0;
|
|
110
|
+
return Ge(He(t, n.slice(5)), e.operator, e.right, r);
|
|
111
|
+
}
|
|
112
|
+
if (e.kind === "logical") {
|
|
113
|
+
let n = R(e.left, t), r = R(e.right, t);
|
|
114
|
+
return n === void 0 || r === void 0 ? void 0 : e.operator === "And" ? n && r : e.operator === "Or" ? n || r : void 0;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function Ke(e) {
|
|
119
|
+
return e.every((e) => R(e, {}) !== void 0);
|
|
120
|
+
}
|
|
121
|
+
function qe(e, t) {
|
|
122
|
+
if (Ke(e)) return e.findIndex((e) => R(e, t) === !0);
|
|
123
|
+
}
|
|
124
|
+
function Je(e, t) {
|
|
125
|
+
if (!L(e) || !Array.isArray(e.alternatives) || !L(t)) return;
|
|
126
|
+
let n = qe(e.alternatives, t);
|
|
127
|
+
if (n !== void 0) {
|
|
128
|
+
if (e.kind === "firstMatch" && typeof e.index == "number") return n === e.index;
|
|
129
|
+
if (e.kind === "otherwise") return n === -1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function z(e, t) {
|
|
133
|
+
if (e.startsWith(Ve) && L(t)) return He(t, e.slice(5));
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/stageData.tsx
|
|
137
|
+
var B = "cratis.stage.data-changed", Ye = e({
|
|
138
|
+
locale: "",
|
|
139
|
+
locales: [],
|
|
140
|
+
screen: "",
|
|
141
|
+
routes: void 0,
|
|
142
|
+
routesReady: !0,
|
|
143
|
+
parameters: {},
|
|
144
|
+
queries: {},
|
|
145
|
+
selected: void 0,
|
|
146
|
+
selections: {},
|
|
147
|
+
selectRow: () => void 0,
|
|
148
|
+
clearSelection: () => void 0,
|
|
149
|
+
setState: () => void 0,
|
|
150
|
+
setComponentOutput: () => void 0,
|
|
151
|
+
refreshQuery: () => void 0,
|
|
152
|
+
refreshAfterCommand: () => void 0,
|
|
153
|
+
resolveBinding: () => void 0,
|
|
154
|
+
resolveArgument: () => void 0,
|
|
155
|
+
registerQueryResult: () => void 0,
|
|
156
|
+
refreshVersion: 0
|
|
157
|
+
}), Xe = [
|
|
158
|
+
500,
|
|
159
|
+
1500,
|
|
160
|
+
3e3
|
|
161
|
+
], Ze = {};
|
|
162
|
+
function Qe({ routes: e, routesReady: t = !0, parameters: r = Ze, locale: c, locales: l, screen: u, children: d }) {
|
|
163
|
+
let [f, p] = s({}), [m, _] = s({}), [v, y] = s(), [x, ee] = s({}), [S, te] = s({}), [C, ne] = s({ version: 0 }), re = n((e, t) => {
|
|
164
|
+
p((n) => {
|
|
165
|
+
if (!t) {
|
|
166
|
+
let { [e]: t, ...r } = n;
|
|
167
|
+
return r;
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
...n,
|
|
171
|
+
[e]: t
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}, []), w = n((e, t) => {
|
|
175
|
+
_((n) => ({
|
|
176
|
+
...n,
|
|
177
|
+
[e]: t
|
|
178
|
+
})), y(t ? e : (t) => t === e ? void 0 : t);
|
|
179
|
+
}, []), T = n((e) => {
|
|
180
|
+
_((t) => ({
|
|
181
|
+
...t,
|
|
182
|
+
[e]: void 0
|
|
183
|
+
})), y((t) => t === e ? void 0 : t);
|
|
184
|
+
}, []), E = n((e, t, n) => {
|
|
185
|
+
te((r) => {
|
|
186
|
+
let i = W(r[e]) ? r[e] : {};
|
|
187
|
+
return {
|
|
188
|
+
...r,
|
|
189
|
+
[e]: rt(i, t.split(".").filter(Boolean), n)
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
}, []), D = n((e) => ne((t) => ({
|
|
193
|
+
query: e,
|
|
194
|
+
version: t.version + 1
|
|
195
|
+
})), []), ie = o([]), ae = n(() => {
|
|
196
|
+
D();
|
|
197
|
+
for (let e of Xe) ie.current.push(setTimeout(() => D(), e));
|
|
198
|
+
}, [D]);
|
|
199
|
+
i(() => () => ie.current.forEach(clearTimeout), []), i(() => {
|
|
200
|
+
let e = () => D(), t = (e) => D(e.detail?.query);
|
|
201
|
+
return globalThis.addEventListener(B, e), globalThis.addEventListener("cratis.scene.refresh", t), () => {
|
|
202
|
+
globalThis.removeEventListener(B, e), globalThis.removeEventListener("cratis.scene.refresh", t);
|
|
203
|
+
};
|
|
204
|
+
}, [D]);
|
|
205
|
+
let O = v ? m[v] : void 0, oe = n((e) => {
|
|
206
|
+
if (e === void 0 || typeof e != "string" && e.path === "$guard") return;
|
|
207
|
+
if (typeof e == "string") return it(e, O, m, f, x, r, u, c, l);
|
|
208
|
+
if (!e.kind) return it(e.path, O, m, f, x, r, u, c, l);
|
|
209
|
+
let t = et(O, f, x, S, m), n = b(e, t);
|
|
210
|
+
return n.length > 0 && console.warn(`Scene binding could not be resolved: ${n.map((e) => `${e.code}:${e.message}`).join("; ")}`), h(t)(e);
|
|
211
|
+
}, [
|
|
212
|
+
S,
|
|
213
|
+
c,
|
|
214
|
+
l,
|
|
215
|
+
x,
|
|
216
|
+
r,
|
|
217
|
+
f,
|
|
218
|
+
u,
|
|
219
|
+
O,
|
|
220
|
+
m
|
|
221
|
+
]), k = n((e) => e ? g(e, et(O, f, x, S, m)) : void 0, [
|
|
222
|
+
S,
|
|
223
|
+
x,
|
|
224
|
+
f,
|
|
225
|
+
O,
|
|
226
|
+
m
|
|
227
|
+
]), A = a(() => ({
|
|
228
|
+
locale: c,
|
|
229
|
+
locales: l,
|
|
230
|
+
screen: u,
|
|
231
|
+
routes: e,
|
|
232
|
+
routesReady: t,
|
|
233
|
+
parameters: r,
|
|
234
|
+
queries: f,
|
|
235
|
+
selected: O,
|
|
236
|
+
selections: m,
|
|
237
|
+
selectRow: w,
|
|
238
|
+
clearSelection: T,
|
|
239
|
+
setState: (e, t) => ee((n) => rt(n, e.split(".").filter(Boolean), t)),
|
|
240
|
+
setComponentOutput: E,
|
|
241
|
+
refreshQuery: D,
|
|
242
|
+
refreshAfterCommand: ae,
|
|
243
|
+
resolveBinding: oe,
|
|
244
|
+
resolveArgument: k,
|
|
245
|
+
registerQueryResult: re,
|
|
246
|
+
refreshVersion: C.version,
|
|
247
|
+
refreshQueryName: C.query
|
|
248
|
+
}), [
|
|
249
|
+
T,
|
|
250
|
+
c,
|
|
251
|
+
l,
|
|
252
|
+
f,
|
|
253
|
+
ae,
|
|
254
|
+
D,
|
|
255
|
+
C.query,
|
|
256
|
+
C.version,
|
|
257
|
+
re,
|
|
258
|
+
k,
|
|
259
|
+
oe,
|
|
260
|
+
e,
|
|
261
|
+
t,
|
|
262
|
+
r,
|
|
263
|
+
u,
|
|
264
|
+
w,
|
|
265
|
+
O,
|
|
266
|
+
m,
|
|
267
|
+
E
|
|
268
|
+
]);
|
|
269
|
+
return /* @__PURE__ */ N(Ye.Provider, {
|
|
270
|
+
value: A,
|
|
271
|
+
children: d
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
var V = () => r(Ye);
|
|
275
|
+
function H(e) {
|
|
276
|
+
let { refreshQueryName: t, refreshVersion: r, registerQueryResult: a } = V(), c = e.publish !== !1, l = n((e, t) => {
|
|
277
|
+
c && a(e, t);
|
|
278
|
+
}, [c, a]), [u, d] = s([]), [f, p] = s(""), [m, h] = s(!1), [g, _] = s(0), v = o(0), y = e.ready ?? !0, b = !!e.route && y, x = JSON.stringify(e.arguments ?? {});
|
|
279
|
+
return i(() => {
|
|
280
|
+
if (!b || !e.route) {
|
|
281
|
+
v.current += 1, d([]), p(""), h(!1), l(e.scope, void 0);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
let t = v.current + 1;
|
|
285
|
+
v.current = t;
|
|
286
|
+
let n = new AbortController(), r = JSON.parse(x), i = st(e.route, r);
|
|
287
|
+
return h(!0), p(""), fetch(i, {
|
|
288
|
+
headers: { Accept: "application/json" },
|
|
289
|
+
signal: n.signal
|
|
290
|
+
}).then(async (e) => {
|
|
291
|
+
if (!e.ok) throw Error(`The query answered ${e.status}.`);
|
|
292
|
+
return e.json();
|
|
293
|
+
}).then((e) => {
|
|
294
|
+
v.current !== t || n.signal.aborted || (d(ct(e)), p(""));
|
|
295
|
+
}).catch((e) => {
|
|
296
|
+
v.current !== t || n.signal.aborted || (d([]), p(e instanceof Error ? e.message : String(e)));
|
|
297
|
+
}).finally(() => {
|
|
298
|
+
v.current === t && !n.signal.aborted && h(!1);
|
|
299
|
+
}), () => n.abort();
|
|
300
|
+
}, [
|
|
301
|
+
b,
|
|
302
|
+
x,
|
|
303
|
+
g,
|
|
304
|
+
l,
|
|
305
|
+
e.name,
|
|
306
|
+
e.route,
|
|
307
|
+
e.scope
|
|
308
|
+
]), i(() => {
|
|
309
|
+
r !== 0 && (t && t !== e.name && t !== e.scope || _((e) => e + 1));
|
|
310
|
+
}, [
|
|
311
|
+
t,
|
|
312
|
+
r,
|
|
313
|
+
e.name,
|
|
314
|
+
e.scope
|
|
315
|
+
]), i(() => {
|
|
316
|
+
if (!b || !e.route) {
|
|
317
|
+
l(e.scope, void 0);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
l(e.scope, {
|
|
321
|
+
name: e.name,
|
|
322
|
+
route: e.route,
|
|
323
|
+
rows: u,
|
|
324
|
+
loading: m,
|
|
325
|
+
error: f,
|
|
326
|
+
arguments: JSON.parse(x)
|
|
327
|
+
});
|
|
328
|
+
}, [
|
|
329
|
+
b,
|
|
330
|
+
x,
|
|
331
|
+
f,
|
|
332
|
+
m,
|
|
333
|
+
l,
|
|
334
|
+
e.name,
|
|
335
|
+
e.route,
|
|
336
|
+
e.scope,
|
|
337
|
+
u
|
|
338
|
+
]), {
|
|
339
|
+
rows: u,
|
|
340
|
+
loading: m,
|
|
341
|
+
error: f,
|
|
342
|
+
refresh: () => _((e) => e + 1)
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function $e() {
|
|
346
|
+
globalThis.dispatchEvent(new CustomEvent(B));
|
|
347
|
+
}
|
|
348
|
+
function et(e, t, n, r, i) {
|
|
349
|
+
return {
|
|
350
|
+
dataContext: e,
|
|
351
|
+
queryResults: Object.fromEntries(Object.entries(t).flatMap(([e, t]) => [[e, tt(t.rows)], ...t.name ? [[t.name, tt(t.rows)]] : []])),
|
|
352
|
+
componentOutputs: nt(r, i),
|
|
353
|
+
state: n
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function tt(e) {
|
|
357
|
+
return e.length === 1 ? e[0] : e;
|
|
358
|
+
}
|
|
359
|
+
function nt(e, t) {
|
|
360
|
+
let n = { ...e };
|
|
361
|
+
for (let [e, r] of Object.entries(t)) r && (n[e] = {
|
|
362
|
+
...r,
|
|
363
|
+
...n[e] ?? {}
|
|
364
|
+
});
|
|
365
|
+
return n;
|
|
366
|
+
}
|
|
367
|
+
function rt(e, t, n) {
|
|
368
|
+
let [r, ...i] = t;
|
|
369
|
+
return r ? i.length === 0 ? {
|
|
370
|
+
...e,
|
|
371
|
+
[r]: n
|
|
372
|
+
} : {
|
|
373
|
+
...e,
|
|
374
|
+
[r]: rt(W(e[r]) ? e[r] : {}, i, n)
|
|
375
|
+
} : e;
|
|
376
|
+
}
|
|
377
|
+
function it(e, t, n, r, i, a, o, s, c) {
|
|
378
|
+
if (!e) return;
|
|
379
|
+
let l = e.replace(/^\$\.?/, "").split(".").filter(Boolean);
|
|
380
|
+
if (l.length !== 0) return l[0] === "screen" ? l.length === 1 ? { name: o } : U({ name: o }, l.slice(1)) : l[0] === "locale" ? s : l[0] === "locales" ? c : l[0] === "query" ? ot(r, l[1], l.slice(2).join(".")) : l[0] === "data" || l[0] === "selected" || l[0] === "current" ? at(l.slice(1).join("."), t, n) : l[0] === "state" ? U(i, l.slice(1)) : l[0] === "parameters" ? l.length === 1 ? a : a[l[1]] : U(t, l) ?? ot(r, void 0, l.join(".")) ?? U(i, l);
|
|
381
|
+
}
|
|
382
|
+
function at(e, t, n) {
|
|
383
|
+
let r = e?.split(".").filter(Boolean) ?? [];
|
|
384
|
+
return r.length > 0 && Object.hasOwn(n, r[0]) ? U(n[r[0]], r.slice(1)) : r.length === 0 ? t : U(t, r);
|
|
385
|
+
}
|
|
386
|
+
function ot(e, t, n) {
|
|
387
|
+
let r = Object.entries(e).filter(([e, n]) => !t || n.name === t || e === t).map(([, e]) => e.rows);
|
|
388
|
+
if (r.length === 0) return;
|
|
389
|
+
let i = r.flat(), a = n?.split(".").filter(Boolean) ?? [];
|
|
390
|
+
return a.length === 0 ? i : i.length === 1 ? U(i[0], a) : i.map((e) => U(e, a));
|
|
391
|
+
}
|
|
392
|
+
function st(e, t) {
|
|
393
|
+
let [n, r = ""] = e.replace(/^\//, "").split("?"), i = new URLSearchParams(r);
|
|
394
|
+
for (let [e, n] of Object.entries(t)) n != null && n !== "" && i.set(e, String(n));
|
|
395
|
+
let a = i.toString();
|
|
396
|
+
return a ? `${n}?${a}` : n;
|
|
397
|
+
}
|
|
398
|
+
function ct(e) {
|
|
399
|
+
let t = W(e) && "data" in e ? e.data : e;
|
|
400
|
+
return Array.isArray(t) ? t.filter(W) : W(t) ? [t] : [];
|
|
401
|
+
}
|
|
402
|
+
function U(e, t) {
|
|
403
|
+
let n = e;
|
|
404
|
+
for (let e of t) {
|
|
405
|
+
if (!W(n)) return;
|
|
406
|
+
n = n[e];
|
|
407
|
+
}
|
|
408
|
+
return n;
|
|
409
|
+
}
|
|
410
|
+
function W(e) {
|
|
411
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
412
|
+
}
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/commandExecutor.ts
|
|
415
|
+
function G(e, t, n) {
|
|
416
|
+
for (let r of [
|
|
417
|
+
t,
|
|
418
|
+
n?.replace(/^\//, ""),
|
|
419
|
+
e
|
|
420
|
+
]) {
|
|
421
|
+
if (!r) continue;
|
|
422
|
+
let t = De(r);
|
|
423
|
+
if (lt(t) && !(r === e && n && new t().route.replace(/^\//, "") !== n.replace(/^\//, ""))) return t;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function lt(e) {
|
|
427
|
+
return typeof e == "function" && e.prototype instanceof Ee;
|
|
428
|
+
}
|
|
429
|
+
async function ut(e, t, n) {
|
|
430
|
+
let r = G(e);
|
|
431
|
+
if (!r) return {
|
|
432
|
+
isSuccess: !1,
|
|
433
|
+
validationErrors: [],
|
|
434
|
+
messages: [`The modeled command “${e}” is not registered by this Stage.`]
|
|
435
|
+
};
|
|
436
|
+
let i = new r();
|
|
437
|
+
i.setMicroservice(n.microservice), i.setApiBasePath(n.apiBasePath ?? ""), i.setOrigin(n.origin ?? ""), i.setHttpHeadersCallback(n.httpHeadersCallback ?? (() => ({})));
|
|
438
|
+
for (let e of i.propertyDescriptors) Object.prototype.hasOwnProperty.call(t, e.name) && Reflect.set(i, e.name, t[e.name]);
|
|
439
|
+
return dt(e, await i.execute());
|
|
440
|
+
}
|
|
441
|
+
function dt(e, t) {
|
|
442
|
+
let n = t.isSuccess && t.isAuthorized && t.isValid && !t.hasExceptions, r = t.isValid ? [] : t.validationResults.flatMap((e) => (e.members.length > 0 ? e.members : [""]).map((t) => ({
|
|
443
|
+
member: t,
|
|
444
|
+
message: e.message
|
|
445
|
+
}))), i = n ? [] : [
|
|
446
|
+
...t.validationResults.map((e) => e.message),
|
|
447
|
+
...t.exceptionMessages,
|
|
448
|
+
...t.isAuthorized ? [] : [t.authorizationFailureReason || `“${e}” was not accepted.`]
|
|
449
|
+
];
|
|
450
|
+
return {
|
|
451
|
+
isSuccess: n,
|
|
452
|
+
response: n ? t.response : void 0,
|
|
453
|
+
validationErrors: r,
|
|
454
|
+
messages: n || i.length > 0 ? i : [`“${e}” was not accepted.`]
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
function ft() {
|
|
458
|
+
let e = r(Te);
|
|
459
|
+
return n((t, n) => ut(t, n, e), [e]);
|
|
460
|
+
}
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/StageCommandForm.tsx
|
|
463
|
+
function pt({ element: e }) {
|
|
464
|
+
let t = V(), n = a(() => ht(e), [e]), r = a(() => jt(e), [e]), i = typeof e.properties.schema == "string", o = a(() => n ? gt(n, r) : [], [n, r]), c = n ? G(n.command, q(e, "typeName"), q(e, "route")) : void 0, l = bt(e, o, t.resolveArgument), u = a(() => yt(o, t.parameters), [o, t.parameters]), d = a(() => n ? _t(n, o, r) : void 0, [
|
|
465
|
+
n,
|
|
466
|
+
o,
|
|
467
|
+
r
|
|
468
|
+
]), f = a(() => n ? kt(o, r) : [], [
|
|
469
|
+
n,
|
|
470
|
+
o,
|
|
471
|
+
r
|
|
472
|
+
]), p = a(() => n ? At(n.layout, o) : [], [n, o]), [m, h] = s([]);
|
|
473
|
+
return n ? !c && !t.routesReady ? /* @__PURE__ */ P("p", {
|
|
474
|
+
className: "stage-note",
|
|
475
|
+
children: [
|
|
476
|
+
"The modeled command “",
|
|
477
|
+
n.command,
|
|
478
|
+
"” is waiting for Stage routes."
|
|
479
|
+
]
|
|
480
|
+
}) : c ? o.length === 0 && !i && e.properties.parameterless !== !0 ? /* @__PURE__ */ N(mt, {
|
|
481
|
+
form: n,
|
|
482
|
+
messages: [`The modeled command “${n.command}” has no form fields or schema metadata, so Stage will not submit an empty command body.`]
|
|
483
|
+
}) : f.length > 0 ? /* @__PURE__ */ N(mt, {
|
|
484
|
+
form: n,
|
|
485
|
+
messages: f
|
|
486
|
+
}) : /* @__PURE__ */ N("section", {
|
|
487
|
+
className: "stage-command-form",
|
|
488
|
+
"data-command": n.command,
|
|
489
|
+
"data-generation-mode": n.generationMode,
|
|
490
|
+
children: /* @__PURE__ */ P(Oe, {
|
|
491
|
+
command: c,
|
|
492
|
+
initialValues: u,
|
|
493
|
+
currentValues: l,
|
|
494
|
+
validateOn: "both",
|
|
495
|
+
validateAllFieldsOnChange: !0,
|
|
496
|
+
onFieldValidate: (e, t, n, i) => Ot(o, r, t, i),
|
|
497
|
+
onValidationFailure: (e) => h(e.map((e) => e.message)),
|
|
498
|
+
onException: (e) => h(e),
|
|
499
|
+
onFailed: (e) => h(dt(n.command, e).messages),
|
|
500
|
+
onSuccess: () => {
|
|
501
|
+
h([]), t.refreshAfterCommand();
|
|
502
|
+
},
|
|
503
|
+
children: [
|
|
504
|
+
p.map((e) => /* @__PURE__ */ N("p", {
|
|
505
|
+
role: "alert",
|
|
506
|
+
className: "stage-form-error",
|
|
507
|
+
children: e
|
|
508
|
+
}, e)),
|
|
509
|
+
d,
|
|
510
|
+
m.map((e) => /* @__PURE__ */ N("p", {
|
|
511
|
+
role: "alert",
|
|
512
|
+
className: "stage-form-error",
|
|
513
|
+
children: e
|
|
514
|
+
}, e)),
|
|
515
|
+
/* @__PURE__ */ P("button", {
|
|
516
|
+
type: "submit",
|
|
517
|
+
children: ["Execute ", n.label]
|
|
518
|
+
})
|
|
519
|
+
]
|
|
520
|
+
})
|
|
521
|
+
}) : /* @__PURE__ */ P("p", {
|
|
522
|
+
className: "stage-note",
|
|
523
|
+
children: [
|
|
524
|
+
"The modeled command “",
|
|
525
|
+
n.command,
|
|
526
|
+
"” is not registered by this Stage."
|
|
527
|
+
]
|
|
528
|
+
}) : /* @__PURE__ */ N("p", {
|
|
529
|
+
className: "stage-note",
|
|
530
|
+
children: "This form is missing its command metadata."
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
function mt({ form: e, messages: t }) {
|
|
534
|
+
return /* @__PURE__ */ N("section", {
|
|
535
|
+
className: "stage-command-form",
|
|
536
|
+
"data-command": e.command,
|
|
537
|
+
"data-generation-mode": e.generationMode,
|
|
538
|
+
children: t.map((e) => /* @__PURE__ */ N("p", {
|
|
539
|
+
role: "alert",
|
|
540
|
+
className: "stage-form-error",
|
|
541
|
+
children: e
|
|
542
|
+
}, e))
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
function ht(e) {
|
|
546
|
+
let t = q(e, "command");
|
|
547
|
+
if (!t) return;
|
|
548
|
+
let n = Array.isArray(e.properties.fields) ? e.properties.fields.filter(J) : [];
|
|
549
|
+
return {
|
|
550
|
+
command: t,
|
|
551
|
+
label: q(e, "label", t),
|
|
552
|
+
fields: n,
|
|
553
|
+
generationMode: St(e.properties.generationMode),
|
|
554
|
+
layout: Ct(e.properties.layout)
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
function gt(e, t) {
|
|
558
|
+
return e.generationMode === u.Manual || e.fields.length > 0 ? e.fields : t.filter((e) => !e.unsupportedReason).map((e) => ({
|
|
559
|
+
name: e.name,
|
|
560
|
+
label: e.name
|
|
561
|
+
}));
|
|
562
|
+
}
|
|
563
|
+
function _t(e, t, n) {
|
|
564
|
+
let r = e.layout, i = r ? wt(r, t) : [];
|
|
565
|
+
if (!r || r.columns.length === 0 && i.length === 0) return t.map((e) => vt(e, n));
|
|
566
|
+
let a = new Map(t.map((e) => [e.name, e])), o = Tt(r, i), s = {
|
|
567
|
+
gridTemplateColumns: Array.from({ length: o }, (e, t) => Et(t + 1, r.columns)).join(" "),
|
|
568
|
+
columnGap: K(r.columnGap),
|
|
569
|
+
rowGap: K(r.rowGap)
|
|
570
|
+
}, c = /* @__PURE__ */ new Set();
|
|
571
|
+
return /* @__PURE__ */ P("div", {
|
|
572
|
+
className: "stage-command-form__layout",
|
|
573
|
+
style: s,
|
|
574
|
+
children: [i.map((e) => {
|
|
575
|
+
let t = a.get(e.field);
|
|
576
|
+
return t ? (c.add(t.name), vt(t, n, e)) : null;
|
|
577
|
+
}), t.filter((e) => !c.has(e.name)).map((e) => vt(e, n))]
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
function vt(e, t, n) {
|
|
581
|
+
let r = e.sourceProperty ?? e.name, i = t.find((e) => e.name === r), a = e.label ?? e.name, o = (e) => e[r], s = i?.required ?? !0, c = (() => {
|
|
582
|
+
switch (i?.type ?? "text") {
|
|
583
|
+
case "number": return /* @__PURE__ */ N(Me, {
|
|
584
|
+
value: o,
|
|
585
|
+
fieldName: r,
|
|
586
|
+
title: a,
|
|
587
|
+
required: s
|
|
588
|
+
});
|
|
589
|
+
case "boolean": return /* @__PURE__ */ N(Ae, {
|
|
590
|
+
value: o,
|
|
591
|
+
fieldName: r,
|
|
592
|
+
label: a,
|
|
593
|
+
required: s
|
|
594
|
+
});
|
|
595
|
+
case "date": return /* @__PURE__ */ N(ke, {
|
|
596
|
+
value: o,
|
|
597
|
+
fieldName: r,
|
|
598
|
+
title: a,
|
|
599
|
+
required: s,
|
|
600
|
+
showIcon: !0
|
|
601
|
+
});
|
|
602
|
+
default: return /* @__PURE__ */ N(je, {
|
|
603
|
+
value: o,
|
|
604
|
+
fieldName: r,
|
|
605
|
+
title: a,
|
|
606
|
+
required: s
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
})(), l = Dt(n);
|
|
610
|
+
return /* @__PURE__ */ N("span", {
|
|
611
|
+
className: "stage-command-form__field",
|
|
612
|
+
"data-field": e.name,
|
|
613
|
+
"data-row": n?.row,
|
|
614
|
+
"data-column": n?.column,
|
|
615
|
+
"data-width-unit": n?.width?.unit,
|
|
616
|
+
style: l,
|
|
617
|
+
children: c
|
|
618
|
+
}, e.name);
|
|
619
|
+
}
|
|
620
|
+
function yt(e, t) {
|
|
621
|
+
let n = {};
|
|
622
|
+
for (let r of e) {
|
|
623
|
+
let e = r.sourceProperty ?? r.name, i = t[e];
|
|
624
|
+
i !== void 0 && i !== "" && (n[e] = i);
|
|
625
|
+
}
|
|
626
|
+
return n;
|
|
627
|
+
}
|
|
628
|
+
function bt(e, t, n) {
|
|
629
|
+
let r = a(() => xt(e, t), [e, t]), i = r.map((e) => n(e.source)), o = JSON.stringify(i);
|
|
630
|
+
return a(() => {
|
|
631
|
+
let e = Object.fromEntries(r.map((e, t) => [e.name, i[t]]).filter(([, e]) => e != null && e !== ""));
|
|
632
|
+
return Object.keys(e).length > 0 ? e : void 0;
|
|
633
|
+
}, [r, o]);
|
|
634
|
+
}
|
|
635
|
+
function xt(e, t) {
|
|
636
|
+
let n = e.properties.arguments;
|
|
637
|
+
if (!Array.isArray(n)) return [];
|
|
638
|
+
let r = new Set(t.map((e) => e.sourceProperty ?? e.name));
|
|
639
|
+
return n.filter((e) => typeof e == "object" && !!e && typeof e.name == "string" && typeof e.source == "string" && r.has(e.name));
|
|
640
|
+
}
|
|
641
|
+
function St(e) {
|
|
642
|
+
return e === u.Manual ? u.Manual : u.Auto;
|
|
643
|
+
}
|
|
644
|
+
function Ct(e) {
|
|
645
|
+
if (!J(e)) return;
|
|
646
|
+
let t = e;
|
|
647
|
+
return {
|
|
648
|
+
columns: Array.isArray(t.columns) ? t.columns.filter(Pt) : [],
|
|
649
|
+
placements: Array.isArray(t.placements) ? t.placements.filter(Ft) : [],
|
|
650
|
+
columnGap: It(t.columnGap) ? t.columnGap : void 0,
|
|
651
|
+
rowGap: It(t.rowGap) ? t.rowGap : void 0
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
function wt(e, t) {
|
|
655
|
+
let n = new Map(e.placements.map((e) => [e.field, e]));
|
|
656
|
+
for (let e of t) !n.has(e.name) && Ft(e.placement) && n.set(e.name, e.placement);
|
|
657
|
+
return [...n.values()].sort((e, t) => e.row - t.row || e.column - t.column || e.field.localeCompare(t.field));
|
|
658
|
+
}
|
|
659
|
+
function Tt(e, t) {
|
|
660
|
+
return Math.max(1, ...e.columns.map((e) => e.index), ...t.map((e) => e.column + (e.columnSpan ?? 1) - 1));
|
|
661
|
+
}
|
|
662
|
+
function Et(e, t) {
|
|
663
|
+
let n = t.find((t) => t.index === e), r = K(n?.width), i = K(n?.minWidth), a = K(n?.maxWidth);
|
|
664
|
+
return n?.width?.unit === d.Fraction && a ? `minmax(${i ?? "0"}, ${r ?? "1fr"})` : i || a ? `minmax(${i ?? "0"}, ${a && r ? `min(${r}, ${a})` : a ?? r ?? "1fr"})` : r ?? "1fr";
|
|
665
|
+
}
|
|
666
|
+
function Dt(e) {
|
|
667
|
+
if (e) return {
|
|
668
|
+
gridColumn: `${e.column} / span ${e.columnSpan ?? 1}`,
|
|
669
|
+
gridRow: `${e.row} / span ${e.rowSpan ?? 1}`,
|
|
670
|
+
width: e.width?.unit === d.Fraction ? void 0 : K(e.width)
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
function K(e) {
|
|
674
|
+
if (e) switch (e.unit) {
|
|
675
|
+
case d.Fraction: return `${e.value ?? 1}fr`;
|
|
676
|
+
case d.Pixels: return `${e.value ?? 0}px`;
|
|
677
|
+
case d.Percent: return `${e.value ?? 100}%`;
|
|
678
|
+
case d.Auto: return "auto";
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function Ot(e, t, n, r) {
|
|
682
|
+
let i = e.find((e) => (e.sourceProperty ?? e.name) === n);
|
|
683
|
+
if ((t.find((e) => e.name === n)?.required ?? !0) && (r == null || r === "")) return `${i?.label ?? n} is required`;
|
|
684
|
+
}
|
|
685
|
+
function kt(e, t) {
|
|
686
|
+
let n = new Map(t.map((e) => [e.name, e]));
|
|
687
|
+
return e.flatMap((e) => {
|
|
688
|
+
let t = n.get(e.sourceProperty ?? e.name);
|
|
689
|
+
return t?.unsupportedReason ? [`The field “${e.label ?? e.name}” uses unsupported schema metadata: ${t.unsupportedReason}.`] : [];
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
function At(e, t) {
|
|
693
|
+
if (!e) return [];
|
|
694
|
+
let n = wt(e, t).filter((e) => e.width?.unit === d.Fraction).map((e) => `The field “${e.field}” uses a fractional field width, which cannot be applied to an individual form control.`), r = e.columns.filter((e) => e.width?.unit === d.Fraction && !!e.maxWidth).map((e) => `Column ${e.index} combines a fractional width with maxWidth; Stage keeps the fractional track and ignores maxWidth for that column.`);
|
|
695
|
+
return [...n, ...r];
|
|
696
|
+
}
|
|
697
|
+
function jt(e) {
|
|
698
|
+
return Mt(q(e, "schema"));
|
|
699
|
+
}
|
|
700
|
+
function Mt(e) {
|
|
701
|
+
if (!e) return [];
|
|
702
|
+
try {
|
|
703
|
+
let t = JSON.parse(e), n = Object.prototype.hasOwnProperty.call(t, "required"), r = Array.isArray(t.required) ? new Set(t.required.filter((e) => typeof e == "string")) : /* @__PURE__ */ new Set();
|
|
704
|
+
return Object.entries(t.properties ?? {}).map(([e, t]) => {
|
|
705
|
+
let i = Nt(t);
|
|
706
|
+
return {
|
|
707
|
+
name: e,
|
|
708
|
+
type: i.type,
|
|
709
|
+
unsupportedReason: i.unsupportedReason,
|
|
710
|
+
required: !n || r.has(e)
|
|
711
|
+
};
|
|
712
|
+
});
|
|
713
|
+
} catch {
|
|
714
|
+
return [];
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
function Nt(e) {
|
|
718
|
+
let t = e?.type;
|
|
719
|
+
if (Array.isArray(t)) {
|
|
720
|
+
let n = t.filter((e) => e !== "null");
|
|
721
|
+
return n.length === 1 ? Nt({
|
|
722
|
+
...e,
|
|
723
|
+
type: n[0]
|
|
724
|
+
}) : { unsupportedReason: `union type ${JSON.stringify(t)}` };
|
|
725
|
+
}
|
|
726
|
+
return t === "integer" || t === "number" ? { type: "number" } : t === "boolean" ? { type: "boolean" } : e?.format === "date" || e?.format === "date-time" ? { type: "date" } : t === "array" || t === "object" ? { unsupportedReason: `${t} fields are not supported by the native Stage command form` } : t === void 0 || t === "string" ? { type: "text" } : { unsupportedReason: `type ${String(t)}` };
|
|
727
|
+
}
|
|
728
|
+
function q(e, t, n = "") {
|
|
729
|
+
let r = e.properties[t];
|
|
730
|
+
return typeof r == "string" ? r : n;
|
|
731
|
+
}
|
|
732
|
+
function Pt(e) {
|
|
733
|
+
return J(e) && typeof e.index == "number" && Number.isInteger(e.index) && e.index > 0;
|
|
734
|
+
}
|
|
735
|
+
function Ft(e) {
|
|
736
|
+
return J(e) && typeof e.field == "string" && typeof e.row == "number" && typeof e.column == "number" && e.row > 0 && e.column > 0;
|
|
737
|
+
}
|
|
738
|
+
function It(e) {
|
|
739
|
+
return J(e) && Object.values(d).includes(e.unit);
|
|
740
|
+
}
|
|
741
|
+
function J(e) {
|
|
742
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
743
|
+
}
|
|
744
|
+
//#endregion
|
|
745
|
+
//#region src/stageNavigation.ts
|
|
746
|
+
function Lt(e, t = {}) {
|
|
747
|
+
let n = new URLSearchParams(Object.entries(t).filter(([, e]) => e !== "")).toString();
|
|
748
|
+
return n ? `#/${encodeURIComponent(e)}?${n}` : `#/${encodeURIComponent(e)}`;
|
|
749
|
+
}
|
|
750
|
+
function Y(e, t = {}) {
|
|
751
|
+
if (!globalThis.location) return;
|
|
752
|
+
let n = Lt(e, t);
|
|
753
|
+
globalThis.location.hash !== n && (globalThis.location.hash = n);
|
|
754
|
+
}
|
|
755
|
+
function Rt(e) {
|
|
756
|
+
return Object.fromEntries(Object.entries(e ?? {}).filter(([, e]) => e != null && e !== "" && typeof e != "object").map(([e, t]) => [e, String(t)]));
|
|
757
|
+
}
|
|
758
|
+
//#endregion
|
|
759
|
+
//#region src/StageGuardedAction.tsx
|
|
760
|
+
function zt(e) {
|
|
761
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
762
|
+
}
|
|
763
|
+
function X(e, t) {
|
|
764
|
+
let n = e.properties[t];
|
|
765
|
+
return typeof n == "string" ? n : "";
|
|
766
|
+
}
|
|
767
|
+
function Bt(e) {
|
|
768
|
+
return e.componentName === "core:action" && (Array.isArray(e.properties.alternatives) || e.properties.otherwise !== void 0);
|
|
769
|
+
}
|
|
770
|
+
function Vt(e) {
|
|
771
|
+
let t = V(), n = X(e, "itemQuery"), r = (n ? t.routes?.queries[n] : void 0) ?? X(e, "itemRoute"), i = zt(e.properties.itemArguments) ? e.properties.itemArguments : {}, a = {}, o = !0;
|
|
772
|
+
for (let [e, n] of Object.entries(i)) {
|
|
773
|
+
let r = zt(n) ? t.resolveBinding(n) : n;
|
|
774
|
+
a[e] = r, (r == null || r === "") && (o = !1);
|
|
775
|
+
}
|
|
776
|
+
let s = H({
|
|
777
|
+
scope: `${e.id}:item`,
|
|
778
|
+
name: n || void 0,
|
|
779
|
+
route: r || void 0,
|
|
780
|
+
arguments: a,
|
|
781
|
+
ready: o,
|
|
782
|
+
publish: !1
|
|
783
|
+
});
|
|
784
|
+
return {
|
|
785
|
+
hasSource: !!n || !!r,
|
|
786
|
+
item: s.rows.length === 1 ? s.rows[0] : void 0
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
function Ht(e, t) {
|
|
790
|
+
return Object.fromEntries(Object.entries(e.arguments ?? {}).map(([e, n]) => [e, z(ze(n) ?? "", t)]));
|
|
791
|
+
}
|
|
792
|
+
function Ut({ element: e, interactions: t }) {
|
|
793
|
+
let n = V(), r = Vt(e), i = ft(), [o, c] = s([]), [l, u] = s(!1), d = X(e, "label"), f = a(() => Array.isArray(e.properties.alternatives) ? e.properties.alternatives : [], [e]), p = zt(e.properties.otherwise) ? e.properties.otherwise : void 0, m = f.map((e) => e.condition), h = !p || p.outcome === "Hidden" || p.outcome === "Execute" && !!p.command;
|
|
794
|
+
if (!Ke(m) || !h || !r.hasSource) {
|
|
795
|
+
let n = r.hasSource ? `${Be}: “${d}” has a guard this Stage cannot evaluate, so it stays unavailable.` : `${Be}: “${d}” has no data subject to evaluate its guard against.`;
|
|
796
|
+
return /* @__PURE__ */ P("div", {
|
|
797
|
+
className: "stage-guarded-action",
|
|
798
|
+
"data-scene-id": e.id,
|
|
799
|
+
children: [/* @__PURE__ */ N(F, {
|
|
800
|
+
type: "button",
|
|
801
|
+
disabled: !0,
|
|
802
|
+
title: n,
|
|
803
|
+
...t,
|
|
804
|
+
children: d
|
|
805
|
+
}), /* @__PURE__ */ N("p", {
|
|
806
|
+
role: "alert",
|
|
807
|
+
className: "stage-form-error",
|
|
808
|
+
children: n
|
|
809
|
+
})]
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
if (!r.item) return null;
|
|
813
|
+
let g = qe(m, r.item), _ = g !== void 0 && g >= 0 ? f[g] : p?.outcome === "Execute" ? p : void 0;
|
|
814
|
+
if (!_?.command) return null;
|
|
815
|
+
let v = _.command, y = G(v), b = r.item, x = async () => {
|
|
816
|
+
if (!y) return;
|
|
817
|
+
u(!0);
|
|
818
|
+
let t = await i(v, Ht(_, b));
|
|
819
|
+
if (u(!1), c(t.messages), !t.isSuccess) return;
|
|
820
|
+
n.refreshAfterCommand();
|
|
821
|
+
let r = X(e, "navigateToScreen"), a = X(e, "navigateByParameter"), o = a ? z(`item.${a}`, b) : void 0;
|
|
822
|
+
r && Y(r, a && o != null ? { [a]: String(o) } : {});
|
|
823
|
+
};
|
|
824
|
+
return /* @__PURE__ */ P("div", {
|
|
825
|
+
className: "stage-guarded-action",
|
|
826
|
+
"data-scene-id": e.id,
|
|
827
|
+
"data-command": v,
|
|
828
|
+
children: [/* @__PURE__ */ N(F, {
|
|
829
|
+
...t,
|
|
830
|
+
type: "button",
|
|
831
|
+
disabled: !y || l,
|
|
832
|
+
title: y ? void 0 : "This command is not exposed as an API yet",
|
|
833
|
+
onClick: () => void x(),
|
|
834
|
+
children: d
|
|
835
|
+
}), o.map((e) => /* @__PURE__ */ N("p", {
|
|
836
|
+
role: "alert",
|
|
837
|
+
className: "stage-form-error",
|
|
838
|
+
children: e
|
|
839
|
+
}, e))]
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
function Wt(e) {
|
|
843
|
+
let t = D(), r = o(void 0), s = a(() => _(re(e.id, e.behaviors), f.DoubleClick), [e.behaviors, e.id]);
|
|
844
|
+
i(() => () => clearTimeout(r.current), []);
|
|
845
|
+
let c = n((e) => {
|
|
846
|
+
if (clearTimeout(r.current), r.current = void 0, !t) return;
|
|
847
|
+
let n = (n) => n.path === "$guard" ? Je(n.value, e) : n.path?.startsWith("item.") ? z(n.path, e) : t.context.resolve(n);
|
|
848
|
+
y(s, t.dispatcher, {
|
|
849
|
+
...t.context,
|
|
850
|
+
resolve: n
|
|
851
|
+
}).then((e) => {
|
|
852
|
+
e.findings.length > 0 && t.onFindings?.(e.findings);
|
|
853
|
+
});
|
|
854
|
+
}, [s, t]);
|
|
855
|
+
return {
|
|
856
|
+
click: n((e, t) => {
|
|
857
|
+
if (s.length === 0) {
|
|
858
|
+
t();
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
clearTimeout(r.current), r.current = setTimeout(() => {
|
|
862
|
+
r.current = void 0, t();
|
|
863
|
+
}, 250);
|
|
864
|
+
}, [s.length]),
|
|
865
|
+
doubleClick: s.length > 0 ? c : void 0
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
//#endregion
|
|
869
|
+
//#region src/stageComponents.tsx
|
|
870
|
+
var Gt = "Stage:commandForm";
|
|
871
|
+
function Kt(e, t, n = {}) {
|
|
872
|
+
return {
|
|
873
|
+
id: e,
|
|
874
|
+
componentName: "",
|
|
875
|
+
properties: t,
|
|
876
|
+
slots: n
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
function Z(e, t, n = "") {
|
|
880
|
+
let r = e.properties[t];
|
|
881
|
+
return typeof r == "string" ? r : n;
|
|
882
|
+
}
|
|
883
|
+
function qt(e, t) {
|
|
884
|
+
let n = e.properties.queryArguments;
|
|
885
|
+
if (!Zt(n)) return {
|
|
886
|
+
values: {},
|
|
887
|
+
ready: !0
|
|
888
|
+
};
|
|
889
|
+
let r = {}, i = !0;
|
|
890
|
+
for (let [e, a] of Object.entries(n)) {
|
|
891
|
+
let n = Xt(a) ? t.resolveBinding(a) : a;
|
|
892
|
+
r[e] = n, (n == null || n === "") && (i = !1);
|
|
893
|
+
}
|
|
894
|
+
return {
|
|
895
|
+
values: r,
|
|
896
|
+
ready: i
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
function Jt(e, t) {
|
|
900
|
+
let n = (e.slots.columns ?? []).map((e) => {
|
|
901
|
+
let t = e.properties;
|
|
902
|
+
return {
|
|
903
|
+
property: typeof t.property == "string" ? t.property : "",
|
|
904
|
+
label: typeof t.label == "string" ? t.label : ""
|
|
905
|
+
};
|
|
906
|
+
}).filter((e) => e.property.length > 0), r = [...new Set(t.flatMap((e) => Object.keys(e)))].map((e) => ({
|
|
907
|
+
property: e,
|
|
908
|
+
label: e
|
|
909
|
+
}));
|
|
910
|
+
return n.length > 0 ? n : r;
|
|
911
|
+
}
|
|
912
|
+
function Q(e, t) {
|
|
913
|
+
return e[t] ?? e.id ?? e.key;
|
|
914
|
+
}
|
|
915
|
+
function Yt({ element: e, slots: t }) {
|
|
916
|
+
let n = V(), r = Z(e, "query", Z(e, "typeName", e.id)), o = (Z(e, "query") ? n.routes?.queries[Z(e, "query")] : void 0) ?? Z(e, "route"), s = a(() => qt(e, n), [n, e]), { rows: c, error: l, loading: u } = H({
|
|
917
|
+
scope: e.id,
|
|
918
|
+
name: r,
|
|
919
|
+
route: o || void 0,
|
|
920
|
+
arguments: s.values,
|
|
921
|
+
ready: s.ready
|
|
922
|
+
}), d = Jt(e, c), f = Z(e, "navigateOnRowClickToScreen"), p = Z(e, "navigateOnRowClickByParameter"), m = Z(e, "dataKey") || p || "id", h = n.selections[e.id], g = p ? n.parameters[p] : void 0, _ = Wt(e);
|
|
923
|
+
i(() => {
|
|
924
|
+
if (!h) return;
|
|
925
|
+
let t = Q(h, m), r = t === void 0 ? void 0 : c.find((e) => Q(e, m) === t);
|
|
926
|
+
if (r && r !== h) {
|
|
927
|
+
n.selectRow(e.id, r);
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
!r && t !== void 0 && !u && n.clearSelection(e.id);
|
|
931
|
+
}, [
|
|
932
|
+
n,
|
|
933
|
+
m,
|
|
934
|
+
e.id,
|
|
935
|
+
u,
|
|
936
|
+
c,
|
|
937
|
+
h
|
|
938
|
+
]), i(() => {
|
|
939
|
+
if (!p) return;
|
|
940
|
+
if (g === void 0) {
|
|
941
|
+
h && n.clearSelection(e.id);
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
if (h && String(Q(h, m)) === g) return;
|
|
945
|
+
let t = c.find((e) => String(Q(e, m)) === g);
|
|
946
|
+
t && n.selectRow(e.id, t);
|
|
947
|
+
}, [
|
|
948
|
+
n,
|
|
949
|
+
m,
|
|
950
|
+
e.id,
|
|
951
|
+
g,
|
|
952
|
+
p,
|
|
953
|
+
c,
|
|
954
|
+
h
|
|
955
|
+
]);
|
|
956
|
+
let v = (t) => {
|
|
957
|
+
let r = Q(t, m);
|
|
958
|
+
if (p && r != null) {
|
|
959
|
+
let i = {
|
|
960
|
+
...f && f !== n.screen ? {} : n.parameters,
|
|
961
|
+
[p]: String(r)
|
|
962
|
+
};
|
|
963
|
+
(!f || f === n.screen) && n.selectRow(e.id, t), Y(f || n.screen, i);
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
n.selectRow(e.id, t);
|
|
967
|
+
};
|
|
968
|
+
return o ? /* @__PURE__ */ P("section", {
|
|
969
|
+
className: "stage-table",
|
|
970
|
+
"data-scene-id": e.id,
|
|
971
|
+
children: [
|
|
972
|
+
u && /* @__PURE__ */ N(Se, {
|
|
973
|
+
element: Kt(`${e.id}-loading`, {
|
|
974
|
+
severity: "info",
|
|
975
|
+
text: "Loading…"
|
|
976
|
+
}),
|
|
977
|
+
slots: {}
|
|
978
|
+
}),
|
|
979
|
+
l && /* @__PURE__ */ N(Se, {
|
|
980
|
+
element: Kt(`${e.id}-error`, {
|
|
981
|
+
severity: "error",
|
|
982
|
+
text: l
|
|
983
|
+
}),
|
|
984
|
+
slots: {}
|
|
985
|
+
}),
|
|
986
|
+
h && /* @__PURE__ */ N(F, {
|
|
987
|
+
type: "button",
|
|
988
|
+
size: "small",
|
|
989
|
+
onClick: () => {
|
|
990
|
+
if (n.clearSelection(e.id), !p || n.parameters[p] === void 0) return;
|
|
991
|
+
let { [p]: t, ...r } = n.parameters;
|
|
992
|
+
Y(n.screen, r);
|
|
993
|
+
},
|
|
994
|
+
children: "Clear selection"
|
|
995
|
+
}),
|
|
996
|
+
/* @__PURE__ */ P("table", {
|
|
997
|
+
"aria-label": Z(e, "label", Z(e, "typeName", "Results")),
|
|
998
|
+
children: [/* @__PURE__ */ N("thead", { children: /* @__PURE__ */ N("tr", { children: d.map((e) => /* @__PURE__ */ N("th", {
|
|
999
|
+
scope: "col",
|
|
1000
|
+
children: e.label
|
|
1001
|
+
}, e.property)) }) }), /* @__PURE__ */ P("tbody", { children: [c.map((e, t) => /* @__PURE__ */ N("tr", {
|
|
1002
|
+
"aria-selected": h === e,
|
|
1003
|
+
tabIndex: 0,
|
|
1004
|
+
onClick: () => _.click(e, () => v(e)),
|
|
1005
|
+
onDoubleClick: _.doubleClick ? () => _.doubleClick?.(e) : void 0,
|
|
1006
|
+
onKeyDown: (t) => {
|
|
1007
|
+
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), v(e));
|
|
1008
|
+
},
|
|
1009
|
+
children: d.map((t) => /* @__PURE__ */ N("td", { children: String(e[t.property] ?? "") }, t.property))
|
|
1010
|
+
}, String(Q(e, m) ?? t))), c.length === 0 && !u && /* @__PURE__ */ N("tr", { children: /* @__PURE__ */ N("td", {
|
|
1011
|
+
colSpan: Math.max(d.length, 1),
|
|
1012
|
+
children: "No records found"
|
|
1013
|
+
}) })] })]
|
|
1014
|
+
})
|
|
1015
|
+
]
|
|
1016
|
+
}) : /* @__PURE__ */ P("section", {
|
|
1017
|
+
className: "stage-table",
|
|
1018
|
+
"data-scene-id": e.id,
|
|
1019
|
+
children: [/* @__PURE__ */ P("p", {
|
|
1020
|
+
className: "stage-note",
|
|
1021
|
+
children: [
|
|
1022
|
+
"No query is exposed for ",
|
|
1023
|
+
Z(e, "typeName", "this read model"),
|
|
1024
|
+
" yet."
|
|
1025
|
+
]
|
|
1026
|
+
}), t.columns]
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
function Xt(e) {
|
|
1030
|
+
return Zt(e) && (typeof e.path == "string" || typeof e.kind == "string");
|
|
1031
|
+
}
|
|
1032
|
+
function Zt(e) {
|
|
1033
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1034
|
+
}
|
|
1035
|
+
function Qt({ element: e, interactions: t, slots: n }) {
|
|
1036
|
+
return Bt(e) ? /* @__PURE__ */ N(Ut, {
|
|
1037
|
+
element: e,
|
|
1038
|
+
interactions: t
|
|
1039
|
+
}) : /* @__PURE__ */ N($t, {
|
|
1040
|
+
element: e,
|
|
1041
|
+
interactions: t,
|
|
1042
|
+
slots: n
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
function $t({ element: e, interactions: t }) {
|
|
1046
|
+
let n = Z(e, "label", Z(e, "command"));
|
|
1047
|
+
if (!G(Z(e, "command"), Z(e, "typeName"), Z(e, "route"))) return /* @__PURE__ */ N(F, {
|
|
1048
|
+
type: "button",
|
|
1049
|
+
"data-scene-id": e.id,
|
|
1050
|
+
disabled: !0,
|
|
1051
|
+
title: "This command is not exposed as an API yet",
|
|
1052
|
+
...t,
|
|
1053
|
+
children: n
|
|
1054
|
+
});
|
|
1055
|
+
let r = /* @__PURE__ */ N(pt, { element: e });
|
|
1056
|
+
return /* @__PURE__ */ N("div", {
|
|
1057
|
+
className: "stage-action",
|
|
1058
|
+
"data-scene-id": e.id,
|
|
1059
|
+
children: /* @__PURE__ */ N(xe, {
|
|
1060
|
+
element: Kt(e.id, {
|
|
1061
|
+
visible: !1,
|
|
1062
|
+
header: n,
|
|
1063
|
+
triggerLabel: n
|
|
1064
|
+
}),
|
|
1065
|
+
slots: { content: [r] }
|
|
1066
|
+
})
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
function en(e) {
|
|
1070
|
+
let { element: t } = e;
|
|
1071
|
+
if (Z(t, "kind").toLowerCase() !== "action" || Z(t, "slice") !== "") return /* @__PURE__ */ N(x, { ...e });
|
|
1072
|
+
let n = Z(t, "name", t.id), r = {
|
|
1073
|
+
...t,
|
|
1074
|
+
componentName: "core:action",
|
|
1075
|
+
properties: {
|
|
1076
|
+
command: Z(t, "target"),
|
|
1077
|
+
label: Z(t, "label", n)
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
return /* @__PURE__ */ N("span", {
|
|
1081
|
+
className: "stage-toolbar-action",
|
|
1082
|
+
"data-scene-toolbar-item": n,
|
|
1083
|
+
children: /* @__PURE__ */ N(Qt, {
|
|
1084
|
+
element: r,
|
|
1085
|
+
interactions: e.interactions,
|
|
1086
|
+
slots: e.slots
|
|
1087
|
+
})
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
var tn = {
|
|
1091
|
+
...w,
|
|
1092
|
+
"core:table": Yt,
|
|
1093
|
+
"core:action": Qt,
|
|
1094
|
+
"core:toolbarItem": en,
|
|
1095
|
+
[Gt]: pt
|
|
1096
|
+
};
|
|
1097
|
+
//#endregion
|
|
1098
|
+
//#region src/useStrings.ts
|
|
1099
|
+
function nn() {
|
|
1100
|
+
let e = I(), [t, n] = s([]), [r, a] = s(""), [o, c] = s({});
|
|
1101
|
+
return i(() => {
|
|
1102
|
+
let t = new AbortController();
|
|
1103
|
+
return e.locales(t.signal).then((e) => {
|
|
1104
|
+
n(e), a((t) => t || e[0] || "");
|
|
1105
|
+
}).catch(() => {}), () => t.abort();
|
|
1106
|
+
}, [e]), i(() => {
|
|
1107
|
+
if (!r) return;
|
|
1108
|
+
let t = new AbortController();
|
|
1109
|
+
return e.strings(r, t.signal).then(c).catch(() => c({})), () => t.abort();
|
|
1110
|
+
}, [r, e]), {
|
|
1111
|
+
locales: t,
|
|
1112
|
+
locale: r,
|
|
1113
|
+
setLocale: a,
|
|
1114
|
+
dictionary: o
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
function rn(e) {
|
|
1118
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
1119
|
+
for (let r of e) for (let e of r.contributions ?? []) {
|
|
1120
|
+
if (e.contributionPointName !== "Navigation") continue;
|
|
1121
|
+
let r = e.content?.properties ?? {}, i = r.label, a = r.targetScreen;
|
|
1122
|
+
if (typeof i != "string" || typeof a != "string") continue;
|
|
1123
|
+
let o = Array.isArray(r.hierarchy) ? r.hierarchy.filter((e) => typeof e == "string") : [], s = JSON.stringify([
|
|
1124
|
+
o,
|
|
1125
|
+
a,
|
|
1126
|
+
i
|
|
1127
|
+
]);
|
|
1128
|
+
if (t.has(s)) continue;
|
|
1129
|
+
t.add(s);
|
|
1130
|
+
let c = e.order ?? (typeof r.order == "number" ? r.order : void 0), l = sn(r.destination) ? r.destination : void 0;
|
|
1131
|
+
n.push({
|
|
1132
|
+
label: i,
|
|
1133
|
+
targetScreen: a,
|
|
1134
|
+
hierarchy: o,
|
|
1135
|
+
order: c,
|
|
1136
|
+
...typeof r.icon == "string" ? { icon: r.icon } : {},
|
|
1137
|
+
...typeof r.presentation == "string" ? { presentation: r.presentation } : {},
|
|
1138
|
+
...l && cn(l) ? { destination: l } : {}
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
return n.map((e, t) => ({
|
|
1142
|
+
entry: e,
|
|
1143
|
+
index: t
|
|
1144
|
+
})).sort((e, t) => (e.entry.order ?? 2 ** 53 - 1) - (t.entry.order ?? 2 ** 53 - 1) || e.index - t.index).map(({ entry: e }) => e);
|
|
1145
|
+
}
|
|
1146
|
+
function an(e) {
|
|
1147
|
+
let t = {
|
|
1148
|
+
label: "",
|
|
1149
|
+
children: []
|
|
1150
|
+
};
|
|
1151
|
+
for (let n of e) {
|
|
1152
|
+
let e = t;
|
|
1153
|
+
for (let t of n.hierarchy) {
|
|
1154
|
+
let n = e.children.find((e) => e.screen === void 0 && e.label === t);
|
|
1155
|
+
n || (n = {
|
|
1156
|
+
label: t,
|
|
1157
|
+
children: []
|
|
1158
|
+
}, e.children.push(n)), e = n;
|
|
1159
|
+
}
|
|
1160
|
+
e.children.push({
|
|
1161
|
+
label: n.label,
|
|
1162
|
+
screen: n.targetScreen,
|
|
1163
|
+
...n.icon ? { icon: n.icon } : {},
|
|
1164
|
+
...n.presentation ? { presentation: n.presentation } : {},
|
|
1165
|
+
...n.destination ? { destination: n.destination } : {},
|
|
1166
|
+
children: []
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
return t.children;
|
|
1170
|
+
}
|
|
1171
|
+
function on(e, t) {
|
|
1172
|
+
for (let n of e) {
|
|
1173
|
+
if (n.screen === t) return [n.label];
|
|
1174
|
+
let e = on(n.children, t);
|
|
1175
|
+
if (e.length > 0) return [n.label, ...e];
|
|
1176
|
+
}
|
|
1177
|
+
return [];
|
|
1178
|
+
}
|
|
1179
|
+
function sn(e) {
|
|
1180
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1181
|
+
}
|
|
1182
|
+
function cn(e) {
|
|
1183
|
+
return e.outlet !== void 0 || e.dialog !== void 0 || e.kind === "external" || e.kind === "dialog";
|
|
1184
|
+
}
|
|
1185
|
+
function ln(e, t, n) {
|
|
1186
|
+
return e.filter((e) => !t.has(e.name)).map((e) => ({
|
|
1187
|
+
label: e.name,
|
|
1188
|
+
targetScreen: e.name,
|
|
1189
|
+
hierarchy: e.path && e.path.length > 0 ? [...e.path] : [n]
|
|
1190
|
+
}));
|
|
1191
|
+
}
|
|
1192
|
+
//#endregion
|
|
1193
|
+
//#region src/blueprint.ts
|
|
1194
|
+
var un = "Stage:locale";
|
|
1195
|
+
function dn(e) {
|
|
1196
|
+
let t = ye(e), n = t.packages.filter((e) => e !== "PrimeReact");
|
|
1197
|
+
return n.splice(Math.max(n.indexOf(de), 0), 0, "PrimeReact"), {
|
|
1198
|
+
...t,
|
|
1199
|
+
name: e?.length ? t.name : "Stage",
|
|
1200
|
+
packages: n
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
var fn = {
|
|
1204
|
+
...ce,
|
|
1205
|
+
PrimeReact: we.components
|
|
1206
|
+
};
|
|
1207
|
+
function pn(e) {
|
|
1208
|
+
return {
|
|
1209
|
+
...w,
|
|
1210
|
+
...Ce,
|
|
1211
|
+
...ue,
|
|
1212
|
+
...ve,
|
|
1213
|
+
...e
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
function mn(e) {
|
|
1217
|
+
return e ? {
|
|
1218
|
+
...e,
|
|
1219
|
+
...fn
|
|
1220
|
+
} : fn;
|
|
1221
|
+
}
|
|
1222
|
+
var hn = "Stage:navigationTree";
|
|
1223
|
+
function gn(e, t, n) {
|
|
1224
|
+
return M(e, A.Logo, {
|
|
1225
|
+
label: t,
|
|
1226
|
+
initials: t.slice(0, 1).toUpperCase() || "S",
|
|
1227
|
+
targetScreen: "",
|
|
1228
|
+
...n ? { lightImageUrl: n } : {}
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
function _n(e, t, n, r, i, a = !1, o = !0) {
|
|
1232
|
+
let s = e[0]?.name ?? "", c = i?.title ?? "Cratis Stage", l = rn(e), u = ln(e, new Set(l.map((e) => e.targetScreen)), "Other screens"), d = an([...l, ...l.length > 0 ? u : []]), f = e.map((e, n) => _e({
|
|
1233
|
+
label: e.name,
|
|
1234
|
+
targetScreen: e.name,
|
|
1235
|
+
icon: "pi pi-table",
|
|
1236
|
+
group: "Screens",
|
|
1237
|
+
order: n
|
|
1238
|
+
}, t)), p = on(an(l), t), m = e.find((e) => e.name === t)?.path?.length ? on(d, t) : [], h = p.length > 0 ? p : m, g = l.length > 0 ? M("menu-hierarchy", hn, {
|
|
1239
|
+
nodes: d,
|
|
1240
|
+
activeScreen: t
|
|
1241
|
+
}) : M("menu-screens", A.Menu, {
|
|
1242
|
+
title: "Screens",
|
|
1243
|
+
label: "Screens"
|
|
1244
|
+
}, { items: f }), _ = [];
|
|
1245
|
+
n.length > 1 && _.push(M("topbar-locale", un, {
|
|
1246
|
+
locales: n,
|
|
1247
|
+
locale: r
|
|
1248
|
+
})), _.push(M("topbar-theme", A.ThemeSwitcher, { label: "Theme" }));
|
|
1249
|
+
let v = { regionNavigation: a };
|
|
1250
|
+
return {
|
|
1251
|
+
[j.Topbar]: [M("topbar", A.Topbar, v, {
|
|
1252
|
+
logo: [gn("topbar-logo", c, i?.image)],
|
|
1253
|
+
end: _
|
|
1254
|
+
})],
|
|
1255
|
+
[j.Sidebar]: [M("sidebar", A.Sidebar, v, { logo: [gn("sidebar-logo", c, i?.image)] })],
|
|
1256
|
+
...a ? {} : { [j.Menu]: [g] },
|
|
1257
|
+
[j.Breadcrumb]: [M("breadcrumb", A.Breadcrumb, {
|
|
1258
|
+
homeTargetScreen: s,
|
|
1259
|
+
items: (h.length > 0 ? h : [t]).map((e) => ({ label: e }))
|
|
1260
|
+
})],
|
|
1261
|
+
...o ? { [j.Footer]: [M("footer", A.Footer, { text: `${c} · rendered from your model` })] } : {},
|
|
1262
|
+
[j.ConfigPanel]: [M(A.ConfigPanel, A.ConfigPanel, {
|
|
1263
|
+
title: "Settings",
|
|
1264
|
+
themes: fe.map((e) => ({
|
|
1265
|
+
name: e.name,
|
|
1266
|
+
label: e.name,
|
|
1267
|
+
isDark: e.isDark ?? !1
|
|
1268
|
+
}))
|
|
1269
|
+
})]
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
function vn(e) {
|
|
1273
|
+
return `#/${encodeURIComponent(e)}`;
|
|
1274
|
+
}
|
|
1275
|
+
//#endregion
|
|
1276
|
+
//#region src/StageChrome.tsx
|
|
1277
|
+
var yn = e({
|
|
1278
|
+
locales: [],
|
|
1279
|
+
locale: "",
|
|
1280
|
+
setLocale: () => void 0,
|
|
1281
|
+
activity: ""
|
|
1282
|
+
});
|
|
1283
|
+
function bn({ state: e, children: t }) {
|
|
1284
|
+
return /* @__PURE__ */ N(yn.Provider, {
|
|
1285
|
+
value: e,
|
|
1286
|
+
children: t
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
var xn = "Stage:activity";
|
|
1290
|
+
function Sn() {
|
|
1291
|
+
let { locales: e, locale: t, setLocale: n } = r(yn);
|
|
1292
|
+
return e.length < 2 ? null : /* @__PURE__ */ N("select", {
|
|
1293
|
+
className: "stage-locale",
|
|
1294
|
+
"aria-label": "Locale",
|
|
1295
|
+
value: t,
|
|
1296
|
+
onChange: (e) => n(e.target.value),
|
|
1297
|
+
children: e.map((e) => /* @__PURE__ */ N("option", {
|
|
1298
|
+
value: e,
|
|
1299
|
+
children: e
|
|
1300
|
+
}, e))
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
function Cn({ element: e }) {
|
|
1304
|
+
let t = e.properties ?? {};
|
|
1305
|
+
return /* @__PURE__ */ N("nav", {
|
|
1306
|
+
className: "stage-navigation-tree",
|
|
1307
|
+
"aria-label": "Navigation",
|
|
1308
|
+
"data-scene-id": e.id,
|
|
1309
|
+
children: /* @__PURE__ */ N(wn, {
|
|
1310
|
+
nodes: t.nodes ?? [],
|
|
1311
|
+
activeScreen: t.activeScreen
|
|
1312
|
+
})
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
function wn({ nodes: e, activeScreen: t }) {
|
|
1316
|
+
return /* @__PURE__ */ N("ul", {
|
|
1317
|
+
role: "tree",
|
|
1318
|
+
children: e.map((e) => e.screen === void 0 ? /* @__PURE__ */ P("li", {
|
|
1319
|
+
role: "treeitem",
|
|
1320
|
+
"aria-expanded": "true",
|
|
1321
|
+
children: [/* @__PURE__ */ N("span", {
|
|
1322
|
+
className: "stage-navigation-group",
|
|
1323
|
+
children: e.label
|
|
1324
|
+
}), /* @__PURE__ */ N(wn, {
|
|
1325
|
+
nodes: e.children,
|
|
1326
|
+
activeScreen: t
|
|
1327
|
+
})]
|
|
1328
|
+
}, e.label) : /* @__PURE__ */ N("li", {
|
|
1329
|
+
role: "treeitem",
|
|
1330
|
+
children: /* @__PURE__ */ N(Tn, {
|
|
1331
|
+
node: e,
|
|
1332
|
+
screen: e.screen,
|
|
1333
|
+
activeScreen: t
|
|
1334
|
+
})
|
|
1335
|
+
}, `${e.screen}:${e.label}`))
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
function Tn({ node: e, screen: t, activeScreen: n }) {
|
|
1339
|
+
let i = r(te), a = e.presentation === "icon" || e.presentation === "text" ? e.presentation : "both", o = e.destination, s = o?.kind === "external" && o.route !== void 0, c = o && i && !s && cn(o) ? (e) => {
|
|
1340
|
+
e.preventDefault(), i.navigate(o);
|
|
1341
|
+
} : void 0;
|
|
1342
|
+
return /* @__PURE__ */ P("a", {
|
|
1343
|
+
href: s ? o.route : vn(t),
|
|
1344
|
+
rel: s ? "noreferrer" : void 0,
|
|
1345
|
+
"aria-current": t === n ? "page" : void 0,
|
|
1346
|
+
"aria-label": a === "icon" ? e.label : void 0,
|
|
1347
|
+
"data-presentation": e.presentation,
|
|
1348
|
+
"data-icon": e.icon,
|
|
1349
|
+
onClick: c,
|
|
1350
|
+
children: [a !== "text" && e.icon && /* @__PURE__ */ N("span", {
|
|
1351
|
+
className: "stage-navigation-icon",
|
|
1352
|
+
"aria-hidden": "true",
|
|
1353
|
+
"data-icon-name": e.icon
|
|
1354
|
+
}), a !== "icon" && e.label]
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
function En({ element: e }) {
|
|
1358
|
+
let t = typeof e.properties.name == "string" ? e.properties.name : "", n = r(te), i = ae(), a = V(), o = n?.outlets[t], s = o && i ? i.screens[o] : void 0, c = e.properties.closable === !0;
|
|
1359
|
+
return /* @__PURE__ */ P("div", {
|
|
1360
|
+
"data-scene-outlet": t,
|
|
1361
|
+
"data-scene-outlet-screen": o,
|
|
1362
|
+
children: [c && o && /* @__PURE__ */ N("div", {
|
|
1363
|
+
className: "scene-outlet-bar",
|
|
1364
|
+
children: /* @__PURE__ */ N("button", {
|
|
1365
|
+
type: "button",
|
|
1366
|
+
className: "scene-outlet-close",
|
|
1367
|
+
"aria-label": "Close",
|
|
1368
|
+
onClick: () => n?.closeOutlet(t),
|
|
1369
|
+
children: "Close"
|
|
1370
|
+
})
|
|
1371
|
+
}), s && i && /* @__PURE__ */ N(S, {
|
|
1372
|
+
element: s,
|
|
1373
|
+
registry: i.registry,
|
|
1374
|
+
resolveBinding: a.resolveBinding
|
|
1375
|
+
})]
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
function Dn() {
|
|
1379
|
+
let { activity: e } = r(yn);
|
|
1380
|
+
return e ? /* @__PURE__ */ N("p", {
|
|
1381
|
+
className: "stage-activity",
|
|
1382
|
+
role: "status",
|
|
1383
|
+
children: e
|
|
1384
|
+
}) : null;
|
|
1385
|
+
}
|
|
1386
|
+
function On() {
|
|
1387
|
+
let e = O(), t = e?.tokens?.["surface.background"], n = e?.tokens?.["text.color"];
|
|
1388
|
+
return i(() => {
|
|
1389
|
+
let r = e?.isDark ? "dark" : "light";
|
|
1390
|
+
document.documentElement.setAttribute("data-scene-color-scheme", r), document.body.setAttribute("data-scene-color-scheme", r), document.body.style.backgroundColor = t ?? "", document.body.style.color = n ?? "";
|
|
1391
|
+
}, [
|
|
1392
|
+
e?.isDark,
|
|
1393
|
+
t,
|
|
1394
|
+
n
|
|
1395
|
+
]), null;
|
|
1396
|
+
}
|
|
1397
|
+
var kn = {
|
|
1398
|
+
[un]: Sn,
|
|
1399
|
+
[hn]: Cn,
|
|
1400
|
+
[xn]: Dn,
|
|
1401
|
+
"core:outlet": En
|
|
1402
|
+
}, An = [
|
|
1403
|
+
"navigationMode",
|
|
1404
|
+
"menuTheme",
|
|
1405
|
+
"showFooter"
|
|
1406
|
+
], jn = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
1407
|
+
function Mn(e, t, n = !1) {
|
|
1408
|
+
let r = [], i = t.options ?? {}, a = {
|
|
1409
|
+
showFooter: !0,
|
|
1410
|
+
followsSystem: !1,
|
|
1411
|
+
problems: r
|
|
1412
|
+
};
|
|
1413
|
+
for (let [e, n] of Object.entries(i)) {
|
|
1414
|
+
if (!An.includes(e)) {
|
|
1415
|
+
r.push(`The shell '${t.name}' has no option '${e}'; the options it understands are ${An.join(", ")}.`);
|
|
1416
|
+
continue;
|
|
1417
|
+
}
|
|
1418
|
+
if (e === "navigationMode") {
|
|
1419
|
+
let e = he.find((e) => e === n);
|
|
1420
|
+
e ? a.mode = e : r.push(`Option 'navigationMode' is '${String(n)}'; expected one of ${he.join(", ")}.`);
|
|
1421
|
+
} else if (e === "menuTheme") {
|
|
1422
|
+
let e = ge.find((e) => e === n);
|
|
1423
|
+
e ? a.menuTheme = e : r.push(`Option 'menuTheme' is '${String(n)}'; expected one of ${ge.join(", ")}.`);
|
|
1424
|
+
} else typeof n == "boolean" ? a.showFooter = n : r.push(`Option 'showFooter' is '${String(n)}'; expected true or false.`);
|
|
1425
|
+
}
|
|
1426
|
+
let o = e?.appearance;
|
|
1427
|
+
if (o?.colorScheme !== void 0) {
|
|
1428
|
+
a.followsSystem = o.colorScheme === c.System;
|
|
1429
|
+
let e = a.followsSystem ? n : o.colorScheme === c.Dark;
|
|
1430
|
+
a.colorScheme = e ? k.Dark : k.Light, a.themeName = fe.find((t) => (t.isDark ?? !1) === e)?.name;
|
|
1431
|
+
}
|
|
1432
|
+
return o?.accent !== void 0 && (jn.test(o.accent) ? a.accent = o.accent : r.push(`The accent '${o.accent}' is not a colour written as #rgb or #rrggbb.`)), a;
|
|
1433
|
+
}
|
|
1434
|
+
function Nn(e, t) {
|
|
1435
|
+
if (e?.root === void 0) return [];
|
|
1436
|
+
let n = /* @__PURE__ */ new Set([
|
|
1437
|
+
p.RootTemplateUnknown,
|
|
1438
|
+
p.RootTemplateVersionNotSatisfied,
|
|
1439
|
+
p.RootTemplateNotApplicable,
|
|
1440
|
+
p.RootTemplateMissingContentSlot,
|
|
1441
|
+
p.RootTemplateCycle,
|
|
1442
|
+
p.RootTemplateBlueprintNotInstalled
|
|
1443
|
+
]), r = t.diagnostics.filter((e) => n.has(e.code)).map((e) => e.message);
|
|
1444
|
+
return r.length === 0 && t.origin !== m.Root && r.push(`The root template '${e.root.template.id}' did not resolve, so the application would not start in the shell it names.`), r;
|
|
1445
|
+
}
|
|
1446
|
+
function Pn(e) {
|
|
1447
|
+
let t = e.length === 4 ? [...e.slice(1)].map((e) => e + e).join("") : e.slice(1), [n, r, i] = [
|
|
1448
|
+
0,
|
|
1449
|
+
2,
|
|
1450
|
+
4
|
|
1451
|
+
].map((e) => parseInt(t.slice(e, e + 2), 16));
|
|
1452
|
+
return (n * 299 + r * 587 + i * 114) / 1e3 >= 150 ? "#111827" : "#ffffff";
|
|
1453
|
+
}
|
|
1454
|
+
function Fn(e, t) {
|
|
1455
|
+
if (t === void 0) return e;
|
|
1456
|
+
let n = t.length === 4 ? [...t.slice(1)].map((e) => e + e).join("") : t.slice(1), [r, i, a] = [
|
|
1457
|
+
0,
|
|
1458
|
+
2,
|
|
1459
|
+
4
|
|
1460
|
+
].map((e) => parseInt(n.slice(e, e + 2), 16));
|
|
1461
|
+
return e.map((e) => ({
|
|
1462
|
+
...e,
|
|
1463
|
+
tokens: {
|
|
1464
|
+
...e.tokens,
|
|
1465
|
+
"primary.color": t,
|
|
1466
|
+
"primary.contrastColor": Pn(t),
|
|
1467
|
+
"focus.ring": `0 0 0 2px rgb(${r} ${i} ${a} / 0.4)`
|
|
1468
|
+
}
|
|
1469
|
+
}));
|
|
1470
|
+
}
|
|
1471
|
+
//#endregion
|
|
1472
|
+
//#region src/StageShellSettings.tsx
|
|
1473
|
+
var In = "(prefers-color-scheme: dark)";
|
|
1474
|
+
function Ln() {
|
|
1475
|
+
return globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches ?? !1;
|
|
1476
|
+
}
|
|
1477
|
+
function Rn({ settings: e, onSystemSchemeChange: t }) {
|
|
1478
|
+
let n = o(be());
|
|
1479
|
+
n.current = be();
|
|
1480
|
+
let { mode: r, menuTheme: a, colorScheme: s, themeName: c } = e;
|
|
1481
|
+
return i(() => {
|
|
1482
|
+
let { setMode: e, setMenuTheme: t, setColorScheme: i, setThemeName: o } = n.current;
|
|
1483
|
+
r !== void 0 && e(r), a !== void 0 && t(a), s !== void 0 && i(s), c !== void 0 && o(c);
|
|
1484
|
+
}, [
|
|
1485
|
+
r,
|
|
1486
|
+
a,
|
|
1487
|
+
s,
|
|
1488
|
+
c
|
|
1489
|
+
]), i(() => {
|
|
1490
|
+
if (!e.followsSystem || !globalThis.matchMedia || !t) return;
|
|
1491
|
+
let n = globalThis.matchMedia(In), r = (e) => t(e.matches);
|
|
1492
|
+
return n.addEventListener("change", r), () => n.removeEventListener("change", r);
|
|
1493
|
+
}, [e.followsSystem, t]), null;
|
|
1494
|
+
}
|
|
1495
|
+
//#endregion
|
|
1496
|
+
//#region src/stageNavigationModel.ts
|
|
1497
|
+
function zn(e) {
|
|
1498
|
+
return (e?.application.regions.length ?? 0) > 0 || (e?.modules.length ?? 0) > 0;
|
|
1499
|
+
}
|
|
1500
|
+
function Bn(e) {
|
|
1501
|
+
let t = /* @__PURE__ */ new Map();
|
|
1502
|
+
for (let n of e) {
|
|
1503
|
+
let e = (n.path ?? []).join(".");
|
|
1504
|
+
e.length > 0 && !t.has(e) && t.set(e, n.name);
|
|
1505
|
+
}
|
|
1506
|
+
return (n) => {
|
|
1507
|
+
let r = n.target?.resolvedFeature;
|
|
1508
|
+
if (r === void 0) return;
|
|
1509
|
+
let i = e.find((e) => (e.path ?? []).join(".").startsWith(`${r}.`))?.name;
|
|
1510
|
+
return t.get(r) ?? i ?? (e.some((e) => e.name === r) ? r : void 0);
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
function Vn(e) {
|
|
1514
|
+
return (t) => e.find((e) => e.name === t)?.path?.[0];
|
|
1515
|
+
}
|
|
1516
|
+
function Hn(e, t) {
|
|
1517
|
+
return {
|
|
1518
|
+
structure: e.structure ?? { modules: [] },
|
|
1519
|
+
navigation: e.navigation ?? {
|
|
1520
|
+
application: { regions: [] },
|
|
1521
|
+
modules: []
|
|
1522
|
+
},
|
|
1523
|
+
screenFor: Bn(e.screens),
|
|
1524
|
+
moduleOf: Vn(e.screens),
|
|
1525
|
+
...t ? { isVisible: t } : {}
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
var Un = /* @__PURE__ */ new Set(["core:table"]);
|
|
1529
|
+
function Wn(e) {
|
|
1530
|
+
return Gn(e, /* @__PURE__ */ new Map(), void 0);
|
|
1531
|
+
}
|
|
1532
|
+
function Gn(e, t, n) {
|
|
1533
|
+
let r = e;
|
|
1534
|
+
if (!r.slots) return e;
|
|
1535
|
+
let i = !1, a = {};
|
|
1536
|
+
for (let [e, o] of Object.entries(r.slots)) {
|
|
1537
|
+
let r = new Map(t), s = n;
|
|
1538
|
+
a[e] = o.map((e) => {
|
|
1539
|
+
let t = e, n = $(t, "typeName");
|
|
1540
|
+
t.componentName === "core:data" && n && (r.set(n, t), s = t);
|
|
1541
|
+
let a = Gn(qn(Kn(t, r), s), r, s);
|
|
1542
|
+
return a !== e && (i = !0), a;
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
return i ? {
|
|
1546
|
+
...r,
|
|
1547
|
+
slots: a
|
|
1548
|
+
} : e;
|
|
1549
|
+
}
|
|
1550
|
+
function Kn(e, t) {
|
|
1551
|
+
if (!Un.has(e.componentName)) return e;
|
|
1552
|
+
let n = $(e, "typeName"), r = n ? t.get(n) : void 0;
|
|
1553
|
+
if (!r || e.properties.queryArguments !== void 0) return e;
|
|
1554
|
+
let i = $(r, "by"), a = { ...e.properties }, o = $(r, "query");
|
|
1555
|
+
return o && (a.query = o), !$(e, "route") && $(r, "route") && (a.route = r.properties.route), i && (a.by = i, a.queryArguments = { [i]: { path: `parameters.${i}` } }), {
|
|
1556
|
+
...e,
|
|
1557
|
+
properties: a
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
function qn(e, t) {
|
|
1561
|
+
if (e.componentName !== "core:action" || !Array.isArray(e.properties?.alternatives) || !t || t.properties?.isCollection === !0 || e.properties.itemQuery !== void 0) return e;
|
|
1562
|
+
let n = { ...e.properties }, r = $(t, "query"), i = $(t, "by");
|
|
1563
|
+
return r && (n.itemQuery = r), $(t, "route") && (n.itemRoute = t.properties.route), n.itemArguments = i ? { [i]: { path: `parameters.${i}` } } : {}, {
|
|
1564
|
+
...e,
|
|
1565
|
+
properties: n
|
|
1566
|
+
};
|
|
1567
|
+
}
|
|
1568
|
+
function $(e, t) {
|
|
1569
|
+
let n = e.properties?.[t];
|
|
1570
|
+
return typeof n == "string" && n.length > 0 ? n : void 0;
|
|
1571
|
+
}
|
|
1572
|
+
//#endregion
|
|
1573
|
+
//#region src/stageSlices.ts
|
|
1574
|
+
function Jn(e) {
|
|
1575
|
+
return (t) => Mt(e?.[t] ?? "").filter((e) => e.unsupportedReason === void 0).map((e) => ({
|
|
1576
|
+
name: e.name,
|
|
1577
|
+
type: e.type === "text" || e.type === void 0 ? "string" : e.type,
|
|
1578
|
+
label: Yn(e.name),
|
|
1579
|
+
required: e.required
|
|
1580
|
+
}));
|
|
1581
|
+
}
|
|
1582
|
+
function Yn(e) {
|
|
1583
|
+
return e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/^./, (e) => e.toUpperCase());
|
|
1584
|
+
}
|
|
1585
|
+
function Xn(e, t, n) {
|
|
1586
|
+
return { invoke: async (r, i, a) => {
|
|
1587
|
+
let o = a ?? r.slice(r.lastIndexOf(".") + 1);
|
|
1588
|
+
if (!G(o)) return {
|
|
1589
|
+
succeeded: !1,
|
|
1590
|
+
message: t ? `The modeled command “${o}” is not registered by this Stage.` : `The modeled command “${o}” is waiting for Stage routes.`
|
|
1591
|
+
};
|
|
1592
|
+
let s = await e(o, i);
|
|
1593
|
+
return s.isSuccess && n(), {
|
|
1594
|
+
succeeded: s.isSuccess,
|
|
1595
|
+
...s.validationErrors.length > 0 ? { validationErrors: s.validationErrors.map((e) => ({
|
|
1596
|
+
field: e.member || void 0,
|
|
1597
|
+
message: e.message
|
|
1598
|
+
})) } : {},
|
|
1599
|
+
...s.messages.length > 0 ? { message: s.messages.join(" ") } : {},
|
|
1600
|
+
...s.isSuccess ? { value: s.response } : {}
|
|
1601
|
+
};
|
|
1602
|
+
} };
|
|
1603
|
+
}
|
|
1604
|
+
//#endregion
|
|
1605
|
+
//#region src/App.tsx
|
|
1606
|
+
function Zn(e = {}) {
|
|
1607
|
+
return pn({
|
|
1608
|
+
...e,
|
|
1609
|
+
...tn,
|
|
1610
|
+
...kn
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
function Qn(e, t) {
|
|
1614
|
+
return M(`form-${e}-${t.name}`, Gt, {
|
|
1615
|
+
command: t.forCommand,
|
|
1616
|
+
label: t.name,
|
|
1617
|
+
generationMode: t.generationMode,
|
|
1618
|
+
layout: t.layout,
|
|
1619
|
+
fields: t.fields
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
function $n(e, t) {
|
|
1623
|
+
let n = e.screens[0];
|
|
1624
|
+
return pe(e, n, {
|
|
1625
|
+
profile: dn(e.uiProfiles),
|
|
1626
|
+
blueprintTemplates: t?.length ? [...me, ...t] : void 0
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
function er(e, t, n, r, i, a, o = !0) {
|
|
1630
|
+
let s = zn(e.navigation), c = e.navigation?.application.logo ? {
|
|
1631
|
+
title: e.navigation.application.logo.title,
|
|
1632
|
+
image: e.navigation.application.logo.image || void 0
|
|
1633
|
+
} : void 0;
|
|
1634
|
+
return {
|
|
1635
|
+
profile: dn(e.uiProfiles),
|
|
1636
|
+
catalog: mn(r),
|
|
1637
|
+
blueprintTemplates: a?.length ? [...me, ...a] : void 0,
|
|
1638
|
+
chrome: (r, i) => i === A.FullPageShell ? { [j.ConfigPanel]: _n(e.screens, r.name, t, n, c, s, o)[j.ConfigPanel] } : _n(e.screens, r.name, t, n, c, s, o),
|
|
1639
|
+
form: Qn,
|
|
1640
|
+
trailing: [M("activity", xn)],
|
|
1641
|
+
decorate: (e) => {
|
|
1642
|
+
let t = Wn(e);
|
|
1643
|
+
return i ? v(t, i) : t;
|
|
1644
|
+
}
|
|
1645
|
+
};
|
|
1646
|
+
}
|
|
1647
|
+
function tr(e, t, n, r, i, a) {
|
|
1648
|
+
return le(e, t, er(e, n, r, i, void 0, a)).element;
|
|
1649
|
+
}
|
|
1650
|
+
function nr() {
|
|
1651
|
+
try {
|
|
1652
|
+
return globalThis.localStorage ?? null;
|
|
1653
|
+
} catch {
|
|
1654
|
+
return null;
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
function rr({ components: e, packageCatalog: t, screenTemplates: n, dialogTemplates: r, isVisible: o } = {}) {
|
|
1658
|
+
let c = I(), l = a(() => Zn(e), [e]), [u, d] = s(), [f, p] = s(""), m = Re(), h = nn();
|
|
1659
|
+
return i(() => {
|
|
1660
|
+
let e = new AbortController();
|
|
1661
|
+
return c.scene(e.signal).then((e) => d(r?.length ? {
|
|
1662
|
+
...e,
|
|
1663
|
+
dialogTemplates: [...e.dialogTemplates ?? [], ...r.filter((t) => !e.dialogTemplates?.some((e) => e.name === t.name))]
|
|
1664
|
+
} : e)).catch((t) => {
|
|
1665
|
+
e.signal.aborted || p(t instanceof Error ? t.message : String(t));
|
|
1666
|
+
}), () => e.abort();
|
|
1667
|
+
}, [c, r]), f ? /* @__PURE__ */ P("main", {
|
|
1668
|
+
className: "stage-message",
|
|
1669
|
+
children: [/* @__PURE__ */ N("h1", { children: "Unable to render this Stage" }), /* @__PURE__ */ N("p", { children: f })]
|
|
1670
|
+
}) : u ? /* @__PURE__ */ N(ir, {
|
|
1671
|
+
scene: u,
|
|
1672
|
+
registry: l,
|
|
1673
|
+
routeState: m,
|
|
1674
|
+
strings: h,
|
|
1675
|
+
packageCatalog: t,
|
|
1676
|
+
screenTemplates: n,
|
|
1677
|
+
isVisible: o
|
|
1678
|
+
}) : /* @__PURE__ */ N("main", {
|
|
1679
|
+
className: "stage-message",
|
|
1680
|
+
children: /* @__PURE__ */ N("h1", { children: "Preparing the Stage" })
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
function ir({ scene: e, registry: t, routeState: r, strings: i, packageCatalog: o, screenTemplates: c, isVisible: l }) {
|
|
1684
|
+
let u = a(() => E(), []), [d, f] = s(Ln), p = e.screens[0]?.name ?? "", m = a(() => dn(e.uiProfiles), [e]), h = a(() => p ? $n(e, c) : void 0, [
|
|
1685
|
+
e,
|
|
1686
|
+
c,
|
|
1687
|
+
p
|
|
1688
|
+
]), g = a(() => h ? Nn(m, h) : [], [m, h]), _ = a(() => h ? Mn(m, h, d) : void 0, [
|
|
1689
|
+
m,
|
|
1690
|
+
h,
|
|
1691
|
+
d
|
|
1692
|
+
]), v = a(() => Fn(fe, _?.accent), [_?.accent]), y = _?.showFooter ?? !0, b = a(() => er(e, i.locales, i.locale, o, i.dictionary, c, y), [
|
|
1693
|
+
e,
|
|
1694
|
+
i.locales,
|
|
1695
|
+
i.locale,
|
|
1696
|
+
i.dictionary,
|
|
1697
|
+
o,
|
|
1698
|
+
c,
|
|
1699
|
+
y
|
|
1700
|
+
]), x = n((e) => f(e), []), ee = a(() => Hn(e, l), [e, l]), S = e;
|
|
1701
|
+
return p ? g.length > 0 ? /* @__PURE__ */ P("main", {
|
|
1702
|
+
className: "stage-message",
|
|
1703
|
+
role: "alert",
|
|
1704
|
+
"data-stage-startup-problem": "root-template",
|
|
1705
|
+
children: [
|
|
1706
|
+
/* @__PURE__ */ N("h1", { children: "Unable to start this Stage" }),
|
|
1707
|
+
/* @__PURE__ */ N("p", { children: "The ui profile's root template cannot be the application's shell." }),
|
|
1708
|
+
/* @__PURE__ */ N("ul", { children: g.map((e) => /* @__PURE__ */ N("li", { children: e }, e)) })
|
|
1709
|
+
]
|
|
1710
|
+
}) : /* @__PURE__ */ N(oe, {
|
|
1711
|
+
application: S,
|
|
1712
|
+
composition: b,
|
|
1713
|
+
navigationModel: ee,
|
|
1714
|
+
registry: t,
|
|
1715
|
+
initialScreen: p,
|
|
1716
|
+
history: u,
|
|
1717
|
+
layoutConfigStorage: nr(),
|
|
1718
|
+
scope: (t, n) => /* @__PURE__ */ N(ar, {
|
|
1719
|
+
scene: e,
|
|
1720
|
+
routeState: r,
|
|
1721
|
+
strings: i,
|
|
1722
|
+
navigation: t,
|
|
1723
|
+
themes: v,
|
|
1724
|
+
shellSettings: _,
|
|
1725
|
+
onSystemSchemeChange: x,
|
|
1726
|
+
children: n
|
|
1727
|
+
}),
|
|
1728
|
+
renderScreen: (e, n) => /* @__PURE__ */ N(sr, {
|
|
1729
|
+
element: e,
|
|
1730
|
+
configuration: n,
|
|
1731
|
+
registry: t
|
|
1732
|
+
}),
|
|
1733
|
+
renderDialogTemplate: (e, n, r) => /* @__PURE__ */ N(cr, {
|
|
1734
|
+
template: e,
|
|
1735
|
+
content: n,
|
|
1736
|
+
registry: t,
|
|
1737
|
+
strings: i,
|
|
1738
|
+
close: () => r.closeDialog()
|
|
1739
|
+
})
|
|
1740
|
+
}) : /* @__PURE__ */ P("main", {
|
|
1741
|
+
className: "stage-message",
|
|
1742
|
+
children: [/* @__PURE__ */ N("h1", { children: "Nothing to show yet" }), /* @__PURE__ */ N("p", { children: "This model has no slice carrying a command or a read model, so there is no screen to render." })]
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
function ar({ scene: e, routeState: t, strings: n, navigation: r, themes: a, shellSettings: o, onSystemSchemeChange: c, children: u }) {
|
|
1746
|
+
let [d, f] = s(""), { navigate: p } = r;
|
|
1747
|
+
return i(() => f(""), [r.currentScreen, r.currentDialog]), i(() => {
|
|
1748
|
+
let e = (e) => {
|
|
1749
|
+
let t = e.detail;
|
|
1750
|
+
f(`The modeled command “${t.command}” is ready for input.`);
|
|
1751
|
+
};
|
|
1752
|
+
return globalThis.addEventListener("cratis.scene.command", e), () => globalThis.removeEventListener("cratis.scene.command", e);
|
|
1753
|
+
}, []), i(() => {
|
|
1754
|
+
let t = (t) => {
|
|
1755
|
+
let n = t.detail, r = n.destination ?? (n.dialog ? {
|
|
1756
|
+
kind: l.Dialog,
|
|
1757
|
+
dialog: n.dialog
|
|
1758
|
+
} : n.targetScreen ? { screen: n.targetScreen } : void 0);
|
|
1759
|
+
r && (r.dialog === void 0 ? r.screen !== void 0 && !e.screens.some((e) => e.name === r.screen) ? f(`The modeled screen “${r.screen}” is not available.`) : p(r) : e.dialogTemplates?.some((e) => e.name === r.dialog) ? p(r) : f(`The modeled dialog “${r.dialog}” is not available in this Stage runtime.`));
|
|
1760
|
+
};
|
|
1761
|
+
return globalThis.addEventListener("cratis.scene.navigate", t), () => globalThis.removeEventListener("cratis.scene.navigate", t);
|
|
1762
|
+
}, [p, e]), /* @__PURE__ */ P(se, {
|
|
1763
|
+
themes: a,
|
|
1764
|
+
children: [
|
|
1765
|
+
o && /* @__PURE__ */ N(Rn, {
|
|
1766
|
+
settings: o,
|
|
1767
|
+
onSystemSchemeChange: c
|
|
1768
|
+
}),
|
|
1769
|
+
/* @__PURE__ */ N(On, {}),
|
|
1770
|
+
/* @__PURE__ */ N(Qe, {
|
|
1771
|
+
routes: t.routes,
|
|
1772
|
+
routesReady: t.ready,
|
|
1773
|
+
parameters: r.currentParameters,
|
|
1774
|
+
locale: n.locale,
|
|
1775
|
+
locales: n.locales,
|
|
1776
|
+
screen: r.primaryScreen ?? e.screens[0]?.name ?? "",
|
|
1777
|
+
children: /* @__PURE__ */ N(or, {
|
|
1778
|
+
activity: d,
|
|
1779
|
+
routesReady: t.ready,
|
|
1780
|
+
scene: e,
|
|
1781
|
+
setActivity: f,
|
|
1782
|
+
strings: n,
|
|
1783
|
+
children: u
|
|
1784
|
+
})
|
|
1785
|
+
})
|
|
1786
|
+
]
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
function or({ activity: e, routesReady: t, scene: n, setActivity: r, strings: i, children: o }) {
|
|
1790
|
+
let s = V(), c = ie(), u = ft(), d = a(() => Xn(u, t, s.refreshAfterCommand), [
|
|
1791
|
+
u,
|
|
1792
|
+
t,
|
|
1793
|
+
s.refreshAfterCommand
|
|
1794
|
+
]), f = a(() => Jn(n.commandSchemas), [n.commandSchemas]), p = T({
|
|
1795
|
+
executeCommand: async (e, n) => {
|
|
1796
|
+
let i = G(e);
|
|
1797
|
+
if (!i && !t) return r(`The modeled command “${e}” is waiting for Stage routes.`), {
|
|
1798
|
+
isSuccess: !1,
|
|
1799
|
+
validationErrors: []
|
|
1800
|
+
};
|
|
1801
|
+
if (!i) return r(`The modeled command “${e}” is not registered by this Stage.`), {
|
|
1802
|
+
isSuccess: !1,
|
|
1803
|
+
validationErrors: []
|
|
1804
|
+
};
|
|
1805
|
+
let a = await u(e, n);
|
|
1806
|
+
return a.messages.length > 0 && r(a.messages.join(" ")), a.isSuccess && s.refreshAfterCommand(), {
|
|
1807
|
+
isSuccess: a.isSuccess,
|
|
1808
|
+
validationErrors: a.validationErrors,
|
|
1809
|
+
response: a.response
|
|
1810
|
+
};
|
|
1811
|
+
},
|
|
1812
|
+
navigate: (e, t) => {
|
|
1813
|
+
n.screens.some((t) => t.name === e) ? Y(e, Rt(t)) : r(`The modeled screen “${e}” is not available.`);
|
|
1814
|
+
},
|
|
1815
|
+
navigateBack: () => globalThis.history?.back(),
|
|
1816
|
+
openDialog: async (e) => {
|
|
1817
|
+
let t = n.dialogTemplates?.find((t) => t.name === e);
|
|
1818
|
+
return t ? (c.navigate({
|
|
1819
|
+
kind: l.Dialog,
|
|
1820
|
+
dialog: t.name
|
|
1821
|
+
}), { isConfirmed: !0 }) : (r(`The modeled dialog “${e}” is not available in this Stage runtime.`), { isConfirmed: !1 });
|
|
1822
|
+
},
|
|
1823
|
+
closeDialog: () => c.closeDialog(),
|
|
1824
|
+
confirm: async (e) => globalThis.confirm(e),
|
|
1825
|
+
setState: (e, t) => s.setState(e, t),
|
|
1826
|
+
notify: (e, t) => r(`${e}: ${t}`),
|
|
1827
|
+
refreshQuery: async (e) => s.refreshQuery(e),
|
|
1828
|
+
raise: async (e) => r(`The modeled trigger “${e}” is not available in this Stage runtime.`)
|
|
1829
|
+
});
|
|
1830
|
+
return /* @__PURE__ */ N(bn, {
|
|
1831
|
+
state: {
|
|
1832
|
+
locales: i.locales,
|
|
1833
|
+
locale: i.locale,
|
|
1834
|
+
setLocale: i.setLocale,
|
|
1835
|
+
activity: e
|
|
1836
|
+
},
|
|
1837
|
+
children: /* @__PURE__ */ N(ne, {
|
|
1838
|
+
invoker: d,
|
|
1839
|
+
children: /* @__PURE__ */ N(C, {
|
|
1840
|
+
fieldsFor: f,
|
|
1841
|
+
children: /* @__PURE__ */ N(ee, {
|
|
1842
|
+
dispatcher: p,
|
|
1843
|
+
context: {
|
|
1844
|
+
resolve: s.resolveBinding,
|
|
1845
|
+
localize: (e) => i.dictionary[e] ?? e
|
|
1846
|
+
},
|
|
1847
|
+
attachments: [],
|
|
1848
|
+
onFindings: (e) => r(e.map((e) => e.detail).join(" ")),
|
|
1849
|
+
children: o
|
|
1850
|
+
})
|
|
1851
|
+
})
|
|
1852
|
+
})
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
function sr({ element: e, configuration: t, registry: n }) {
|
|
1856
|
+
let r = V();
|
|
1857
|
+
return /* @__PURE__ */ N(S, {
|
|
1858
|
+
element: e,
|
|
1859
|
+
registry: n,
|
|
1860
|
+
resolveBinding: r.resolveBinding,
|
|
1861
|
+
configuration: t
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
function cr({ template: e, content: t, registry: n, strings: r, close: a }) {
|
|
1865
|
+
let o = V(), s = v(t, r.dictionary);
|
|
1866
|
+
return i(() => {
|
|
1867
|
+
let e = (e) => {
|
|
1868
|
+
e.key === "Escape" && a();
|
|
1869
|
+
};
|
|
1870
|
+
return globalThis.addEventListener("keydown", e), () => globalThis.removeEventListener("keydown", e);
|
|
1871
|
+
}, [a]), /* @__PURE__ */ N("div", {
|
|
1872
|
+
className: "stage-dialog-backdrop",
|
|
1873
|
+
children: /* @__PURE__ */ P("section", {
|
|
1874
|
+
role: "dialog",
|
|
1875
|
+
"aria-modal": "true",
|
|
1876
|
+
"aria-label": e.displayName ?? e.name,
|
|
1877
|
+
className: "stage-dialog",
|
|
1878
|
+
children: [/* @__PURE__ */ N("button", {
|
|
1879
|
+
type: "button",
|
|
1880
|
+
onClick: a,
|
|
1881
|
+
children: "Close"
|
|
1882
|
+
}), /* @__PURE__ */ N(S, {
|
|
1883
|
+
element: s,
|
|
1884
|
+
registry: n,
|
|
1885
|
+
resolveBinding: o.resolveBinding
|
|
1886
|
+
})]
|
|
1887
|
+
})
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
//#endregion
|
|
1891
|
+
//#region src/stageTheme.ts
|
|
1892
|
+
var lr = "[data-scene-color-scheme='dark']", ur = {
|
|
1893
|
+
preset: Ne,
|
|
1894
|
+
options: { darkModeSelector: lr }
|
|
1895
|
+
};
|
|
1896
|
+
//#endregion
|
|
1897
|
+
export { rr as App, rr as StageApplication, pt as StageCommandForm, Qe as StageDataProvider, Ut as StageGuardedAction, Le as StageSourceProvider, tr as composeStageScreen, Xn as createStageSliceInvoker, $e as dataChanged, ut as executeRegisteredCommand, G as registeredCommand, Jn as sliceFieldsFrom, Zn as stageApplicationRegistry, er as stageComposition, lr as stageDarkSelector, Fe as stageEndpoints, $n as stageShellOf, ur as stageTheme, Pe as staticStageSource, ft as useStageCommandExecutor, V as useStageData, H as useStageQuery, I as useStageSource };
|