@cratis/event-models 0.317.0 → 0.318.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/event-models",
3
- "version": "0.317.0",
3
+ "version": "0.318.0",
4
4
  "description": "The Cratis event model board as a configurable React component.",
5
5
  "license": "MIT",
6
6
  "author": "Cratis",
@@ -76,7 +76,7 @@
76
76
  "peerDependencies": {
77
77
  "@cratis/components": "^4.35.0",
78
78
  "@cratis/fundamentals": "^7.22.0",
79
- "@cratis/scene": "^0.317.0",
79
+ "@cratis/scene": "^0.318.0",
80
80
  "@cratis/scene.blueprint.approvals": "^4.12.0",
81
81
  "@cratis/scene.blueprint.bookings": "^4.12.0",
82
82
  "@cratis/scene.blueprint.catalog": "^4.12.0",
@@ -112,7 +112,7 @@
112
112
  "devDependencies": {
113
113
  "@cratis/components": "^4.38.0",
114
114
  "@cratis/fundamentals": "^7.27.0",
115
- "@cratis/scene": "0.317.0",
115
+ "@cratis/scene": "0.318.0",
116
116
  "@cratis/scene.blueprint.approvals": "4.86.0",
117
117
  "@cratis/scene.blueprint.bookings": "4.86.0",
118
118
  "@cratis/scene.blueprint.catalog": "4.86.0",
@@ -1,430 +0,0 @@
1
- import { a as V, i as _, l as R, n as I, o as J, r as O, s as Q, t as j } from "./defaultStructuredEditorStrings-Ch1I0Lci.js";
2
- import { c as w } from "./structuredValue-vqCZttsk.js";
3
- import { t as D } from "./StructuredValueEditor-DUSATTWd.js";
4
- import { useEffect as K, useRef as E, useState as F } from "react";
5
- import { Fragment as x, jsx as t, jsxs as i } from "react/jsx-runtime";
6
- import { BindingSourceKind as c, PropertyValueType as P } from "@cratis/scene.model";
7
- var u = /* @__PURE__ */ (function(e) {
8
- return e.String = "string", e.Number = "number", e.Boolean = "boolean", e.Null = "null", e.Json = "json", e;
9
- })(u || {}), $ = ({ property: e, sources: l, strings: s, disabled: d, onChange: p }) => {
10
- const r = s.properties.binding, h = Q(e.effectiveValue) ? e.effectiveValue : void 0, m = h ? void 0 : T(e.effectiveValue), f = V(e), o = h ?? f, y = L(o, e.descriptor.acceptedBindingKinds?.length ? e.descriptor.acceptedBindingKinds : I, l, r), b = o.query ? l.queryResults.find((n) => n.id === o.query || n.name === o.query) : void 0, v = o.componentId ? l.componentOutputs.find((n) => n.componentId === o.componentId) : void 0, a = (n) => p(A({
11
- ...o,
12
- ...n
13
- })), C = () => p(void 0);
14
- return m !== void 0 ? /* @__PURE__ */ i("fieldset", {
15
- className: "studio-editor-binding",
16
- disabled: d,
17
- children: [
18
- /* @__PURE__ */ t("legend", { children: e.descriptor.label }),
19
- /* @__PURE__ */ i("div", {
20
- className: "studio-editor-binding__missing",
21
- role: "alert",
22
- children: [/* @__PURE__ */ t("p", { children: r.unsupportedValue }), /* @__PURE__ */ t("pre", { children: JSON.stringify(m, void 0, 2) ?? "" })]
23
- }),
24
- /* @__PURE__ */ i("div", {
25
- className: "studio-editor-binding__row",
26
- children: [/* @__PURE__ */ t("button", {
27
- type: "button",
28
- onClick: () => p(f),
29
- children: r.replaceUnsupported
30
- }), /* @__PURE__ */ t("button", {
31
- type: "button",
32
- onClick: C,
33
- children: r.clear
34
- })]
35
- })
36
- ]
37
- }) : /* @__PURE__ */ i("fieldset", {
38
- className: "studio-editor-binding",
39
- disabled: d,
40
- children: [
41
- /* @__PURE__ */ t("legend", { children: e.descriptor.label }),
42
- /* @__PURE__ */ i("div", {
43
- className: "studio-editor-binding__row",
44
- children: [
45
- /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: r.source }), /* @__PURE__ */ t("select", {
46
- value: o.kind ?? c.DataContext,
47
- onChange: (n) => a(M(n.target.value, o)),
48
- children: y.map((n) => /* @__PURE__ */ t("option", {
49
- value: n.kind,
50
- disabled: n.disabled,
51
- children: n.label
52
- }, n.kind))
53
- })] }),
54
- /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: r.mode }), /* @__PURE__ */ i("select", {
55
- value: o.mode ?? "",
56
- onChange: (n) => a({ mode: n.target.value === "" ? void 0 : n.target.value }),
57
- children: [/* @__PURE__ */ t("option", {
58
- value: "",
59
- children: r.inheritedMode
60
- }), O.map((n) => /* @__PURE__ */ t("option", {
61
- value: n,
62
- children: n
63
- }, n))]
64
- })] }),
65
- /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: r.nullBehavior }), /* @__PURE__ */ i("select", {
66
- value: o.nullBehavior ?? "",
67
- onChange: (n) => a({ nullBehavior: n.target.value === "" ? void 0 : n.target.value }),
68
- children: [/* @__PURE__ */ t("option", {
69
- value: "",
70
- children: r.defaultNullBehavior
71
- }), _.map((n) => /* @__PURE__ */ t("option", {
72
- value: n,
73
- children: n
74
- }, n))]
75
- })] }),
76
- /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: r.expectedType }), /* @__PURE__ */ i("select", {
77
- value: o.expectedValueType ?? "",
78
- onChange: (n) => a({ expectedValueType: n.target.value === "" ? void 0 : n.target.value }),
79
- children: [/* @__PURE__ */ t("option", {
80
- value: "",
81
- children: r.inferType
82
- }), J.map((n) => /* @__PURE__ */ t("option", {
83
- value: n,
84
- children: n
85
- }, n))]
86
- })] })
87
- ]
88
- }),
89
- y.filter((n) => n.disabled && n.reason).map((n) => /* @__PURE__ */ i("p", {
90
- className: "studio-editor-binding__missing",
91
- children: [
92
- n.label,
93
- ": ",
94
- n.reason
95
- ]
96
- }, `${n.kind}:reason`)),
97
- g(o) === c.DataContext && /* @__PURE__ */ t(S, {
98
- id: `${e.descriptor.path}-data-context-paths`,
99
- label: r.path,
100
- value: o.path,
101
- options: l.dataContextPaths,
102
- onChange: (n) => a({ path: n })
103
- }),
104
- g(o) === c.QueryResult && /* @__PURE__ */ i(x, { children: [
105
- /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: r.query }), /* @__PURE__ */ i("select", {
106
- value: o.query ?? "",
107
- onChange: (n) => a({
108
- query: n.target.value,
109
- path: ""
110
- }),
111
- children: [
112
- /* @__PURE__ */ t("option", {
113
- value: "",
114
- children: r.noSource
115
- }),
116
- o.query && !b && /* @__PURE__ */ t("option", {
117
- value: o.query,
118
- children: r.missingQuery(o.query)
119
- }),
120
- l.queryResults.map((n) => /* @__PURE__ */ t("option", {
121
- value: n.id,
122
- children: n.name
123
- }, n.id))
124
- ]
125
- })] }),
126
- /* @__PURE__ */ t(S, {
127
- id: `${e.descriptor.path}-query-paths`,
128
- label: r.path,
129
- value: o.path,
130
- options: b?.fields ?? [],
131
- onChange: (n) => a({ path: n })
132
- }),
133
- o.query && !b && /* @__PURE__ */ t("p", {
134
- className: "studio-editor-binding__missing",
135
- role: "alert",
136
- children: r.missingQuery(o.query)
137
- })
138
- ] }),
139
- g(o) === c.ComponentProperty && /* @__PURE__ */ i(x, { children: [
140
- /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: r.component }), /* @__PURE__ */ i("select", {
141
- value: o.componentId ?? "",
142
- onChange: (n) => a({
143
- componentId: n.target.value,
144
- componentPropertyPath: "",
145
- path: ""
146
- }),
147
- children: [
148
- /* @__PURE__ */ t("option", {
149
- value: "",
150
- children: r.noSource
151
- }),
152
- o.componentId && !v && /* @__PURE__ */ t("option", {
153
- value: o.componentId,
154
- children: r.missingComponent(o.componentId)
155
- }),
156
- l.componentOutputs.map((n) => /* @__PURE__ */ i("option", {
157
- value: n.componentId,
158
- children: [
159
- n.label,
160
- " (",
161
- n.componentId,
162
- ")"
163
- ]
164
- }, n.componentId))
165
- ]
166
- })] }),
167
- /* @__PURE__ */ t(S, {
168
- id: `${e.descriptor.path}-component-paths`,
169
- label: r.componentProperty,
170
- value: o.componentPropertyPath ?? o.path,
171
- options: v?.outputs.map((n) => n.path) ?? [],
172
- onChange: (n) => a({
173
- componentPropertyPath: n,
174
- path: n
175
- })
176
- }),
177
- o.componentId && !v && /* @__PURE__ */ t("p", {
178
- className: "studio-editor-binding__missing",
179
- role: "alert",
180
- children: r.missingComponent(o.componentId)
181
- })
182
- ] }),
183
- g(o) === c.Literal && /* @__PURE__ */ t(k, {
184
- value: o.value,
185
- descriptor: e.descriptor,
186
- targetType: o.expectedValueType ?? e.descriptor.valueType,
187
- strings: r,
188
- structured: s.properties.structured ?? j,
189
- onChange: (n) => a({
190
- value: n,
191
- path: ""
192
- })
193
- }, N(o.value, o.expectedValueType ?? e.descriptor.valueType)),
194
- h && /* @__PURE__ */ t("button", {
195
- type: "button",
196
- onClick: C,
197
- children: r.clear
198
- })
199
- ]
200
- });
201
- }, S = ({ id: e, label: l, value: s, options: d, onChange: p }) => /* @__PURE__ */ i("label", { children: [
202
- /* @__PURE__ */ t("span", { children: l }),
203
- /* @__PURE__ */ t("input", {
204
- list: e,
205
- value: s,
206
- onChange: (r) => p(r.target.value)
207
- }),
208
- /* @__PURE__ */ t("datalist", {
209
- id: e,
210
- children: d.map((r) => /* @__PURE__ */ t("option", { value: r }, r))
211
- })
212
- ] }), k = ({ value: e, descriptor: l, targetType: s, strings: d, structured: p, onChange: r }) => {
213
- const h = q(e, s), m = N(e, s), f = E(m), [o, y] = F(h);
214
- K(() => {
215
- const a = N(e, s);
216
- a !== f.current && (f.current = a, y(q(e, s)));
217
- }, [e, s]);
218
- const b = (a) => {
219
- y(a);
220
- const C = B(a);
221
- f.current = N(C, s), r(C);
222
- }, v = w(l);
223
- return /* @__PURE__ */ i("div", {
224
- className: "studio-editor-binding__literal",
225
- children: [
226
- /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: d.literalType }), /* @__PURE__ */ i("select", {
227
- value: o,
228
- onChange: (a) => b(a.target.value),
229
- children: [
230
- /* @__PURE__ */ t("option", {
231
- value: u.String,
232
- children: "String"
233
- }),
234
- /* @__PURE__ */ t("option", {
235
- value: u.Number,
236
- children: "Number"
237
- }),
238
- /* @__PURE__ */ t("option", {
239
- value: u.Boolean,
240
- children: "Boolean"
241
- }),
242
- /* @__PURE__ */ t("option", {
243
- value: u.Null,
244
- children: "Null"
245
- }),
246
- (v || o === u.Json) && /* @__PURE__ */ t("option", {
247
- value: u.Json,
248
- children: d.literalStructured
249
- })
250
- ]
251
- })] }),
252
- o === u.String && /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: d.literalValue }), /* @__PURE__ */ t("input", {
253
- value: typeof e == "string" ? e : "",
254
- onChange: (a) => r(a.target.value)
255
- })] }),
256
- o === u.Number && /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: d.literalValue }), /* @__PURE__ */ t("input", {
257
- type: "number",
258
- value: typeof e == "number" ? String(e) : "",
259
- onChange: (a) => r(a.target.value === "" ? void 0 : Number(a.target.value))
260
- })] }),
261
- o === u.Boolean && /* @__PURE__ */ i("label", { children: [/* @__PURE__ */ t("span", { children: d.literalValue }), /* @__PURE__ */ i("select", {
262
- value: e === !0 ? "true" : "false",
263
- onChange: (a) => r(a.target.value === "true"),
264
- children: [/* @__PURE__ */ t("option", {
265
- value: "true",
266
- children: "true"
267
- }), /* @__PURE__ */ t("option", {
268
- value: "false",
269
- children: "false"
270
- })]
271
- })] }),
272
- o === u.Null && /* @__PURE__ */ t("p", { children: d.literalNull }),
273
- o === u.Json && v && /* @__PURE__ */ t(D, {
274
- descriptor: l,
275
- value: e,
276
- idPrefix: "literal",
277
- strings: p,
278
- disabled: !1,
279
- onChange: (a) => r(a ?? B(u.Json))
280
- }),
281
- o === u.Json && !v && /* @__PURE__ */ t("p", {
282
- className: "studio-editor-binding__missing",
283
- role: "alert",
284
- children: d.literalNoEditor
285
- })
286
- ]
287
- });
288
- };
289
- function L(e, l, s, d) {
290
- const p = g(e);
291
- return I.map((r) => {
292
- const h = l.includes(r), m = r === c.QueryResult && s.queryResults.length === 0 || r === c.ComponentProperty && s.componentOutputs.length === 0;
293
- return {
294
- kind: r,
295
- label: z(r, d.sources),
296
- disabled: r !== p && (!h || m),
297
- reason: h ? m ? d.unavailableSource : void 0 : d.incompatibleSource
298
- };
299
- });
300
- }
301
- function g(e) {
302
- return e.kind ?? c.DataContext;
303
- }
304
- function T(e) {
305
- if (!(!e || typeof e != "object" || Array.isArray(e)))
306
- return [
307
- "kind",
308
- "path",
309
- "query",
310
- "componentId",
311
- "componentPropertyPath",
312
- "value"
313
- ].some((l) => l in e) ? e : void 0;
314
- }
315
- function A(e) {
316
- switch (g(e)) {
317
- case c.Literal:
318
- return {
319
- ...e,
320
- path: "",
321
- query: void 0,
322
- componentId: void 0,
323
- componentPropertyPath: void 0
324
- };
325
- case c.QueryResult:
326
- return {
327
- ...e,
328
- componentId: void 0,
329
- componentPropertyPath: void 0,
330
- value: void 0
331
- };
332
- case c.ComponentProperty:
333
- return {
334
- ...e,
335
- query: void 0,
336
- value: void 0,
337
- path: e.componentPropertyPath ?? e.path
338
- };
339
- case c.DataContext:
340
- case c.CommandResponse:
341
- return {
342
- ...e,
343
- query: void 0,
344
- componentId: void 0,
345
- componentPropertyPath: void 0,
346
- value: void 0
347
- };
348
- }
349
- }
350
- function M(e, l) {
351
- switch (e) {
352
- case c.Literal:
353
- return {
354
- kind: e,
355
- path: "",
356
- value: l.value ?? ""
357
- };
358
- case c.QueryResult:
359
- return {
360
- kind: e,
361
- query: l.query,
362
- path: l.path
363
- };
364
- case c.ComponentProperty:
365
- return {
366
- kind: e,
367
- componentId: l.componentId,
368
- componentPropertyPath: l.componentPropertyPath ?? l.path,
369
- path: l.componentPropertyPath ?? l.path
370
- };
371
- case c.DataContext:
372
- case c.CommandResponse:
373
- return {
374
- kind: e,
375
- path: l.path
376
- };
377
- }
378
- }
379
- function q(e, l) {
380
- return e === null ? u.Null : typeof e == "number" ? u.Number : typeof e == "boolean" ? u.Boolean : typeof e == "object" ? u.Json : l === P.Number ? u.Number : l === P.Boolean ? u.Boolean : l === P.Object || l === P.Collection || l === P.Json ? u.Json : u.String;
381
- }
382
- function N(e, l) {
383
- return JSON.stringify({
384
- kind: q(e, l),
385
- value: e
386
- }) ?? "undefined";
387
- }
388
- function B(e) {
389
- switch (e) {
390
- case u.String:
391
- return "";
392
- case u.Number:
393
- return 0;
394
- case u.Boolean:
395
- return !1;
396
- case u.Null:
397
- return null;
398
- case u.Json:
399
- return {};
400
- }
401
- }
402
- function z(e, l) {
403
- switch (e) {
404
- case c.DataContext:
405
- return l.dataContext;
406
- case c.QueryResult:
407
- return l.queryResult;
408
- case c.ComponentProperty:
409
- return l.componentProperty;
410
- case c.Literal:
411
- return l.literal;
412
- case c.CommandResponse:
413
- return l.commandResponse;
414
- }
415
- }
416
- var Z = ({ onChange: e, context: l, disabled: s }) => {
417
- const { session: d } = l;
418
- if (!d) return null;
419
- const { controller: p, environment: r } = d, h = R(p.document, p.composition.roots, p.context, r.availableSources, r.queryCandidates);
420
- return /* @__PURE__ */ t($, {
421
- property: d.property,
422
- sources: h,
423
- strings: d.screenStrings,
424
- disabled: s === !0,
425
- onChange: e
426
- });
427
- };
428
- export {
429
- Z as BindingExpressionPropertyEditor
430
- };