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