@cratis/event-models 0.317.1 → 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/dist/screen-editor/BindingExpressionPropertyEditor-BCLo-6E0.js +455 -0
- package/dist/screen-editor/ScreenEditor/Binding/bindingExpressionModel.d.ts +1 -0
- package/dist/screen-editor/ScreenEditor/Binding/bindingSources.d.ts +5 -0
- package/dist/screen-editor/ScreenEditor/Inspector/ScreenEditorStrings.d.ts +1 -0
- package/dist/screen-editor/{defaultStructuredEditorStrings-Ch1I0Lci.js → defaultStructuredEditorStrings-BPl2XP8A.js} +40 -33
- package/dist/screen-editor/index.js +1093 -1086
- package/package.json +3 -3
- package/dist/screen-editor/BindingExpressionPropertyEditor-BrDWFHcH.js +0 -430
|
@@ -0,0 +1,455 @@
|
|
|
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-BPl2XP8A.js";
|
|
2
|
+
import { c as j } from "./structuredValue-vqCZttsk.js";
|
|
3
|
+
import { t as D } from "./StructuredValueEditor-DUSATTWd.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 = j(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(D, {
|
|
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
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BindingMode, BindingNullBehavior, BindingSourceKind, PropertyValueType, type BindingExpression, type InspectedProperty } from '@cratis/scene.model';
|
|
2
2
|
export declare const allBindingSourceKinds: BindingSourceKind[];
|
|
3
|
+
export declare const defaultAcceptedBindingKinds: BindingSourceKind[];
|
|
3
4
|
export declare const bindingModes: BindingMode[];
|
|
4
5
|
export declare const bindingNullBehaviors: BindingNullBehavior[];
|
|
5
6
|
export declare const expectedValueTypes: PropertyValueType[];
|
|
@@ -9,8 +9,13 @@ export interface ComponentOutputSource {
|
|
|
9
9
|
type: string;
|
|
10
10
|
}[];
|
|
11
11
|
}
|
|
12
|
+
export interface CommandResponseSource {
|
|
13
|
+
command: string;
|
|
14
|
+
paths: string[];
|
|
15
|
+
}
|
|
12
16
|
export interface BindingSourceInventory {
|
|
13
17
|
dataContextPaths: string[];
|
|
18
|
+
commandResponse?: CommandResponseSource;
|
|
14
19
|
queryResults: {
|
|
15
20
|
id: string;
|
|
16
21
|
name: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BindingMode as p, BindingNullBehavior as c, BindingSourceKind as
|
|
1
|
+
import { BindingMode as p, BindingNullBehavior as c, BindingSourceKind as a, PropertyValueType as i } from "@cratis/scene.model";
|
|
2
2
|
import { elementNodeId as f, inspect as y, isCanvas as g, isExternalComponent as h, isPanel as $ } from "@cratis/scene.engine";
|
|
3
3
|
function u(e) {
|
|
4
4
|
return $(e) ? e.children : h(e) ? Object.values(e.slots).flat() : [];
|
|
@@ -15,7 +15,7 @@ function b(e, t) {
|
|
|
15
15
|
}
|
|
16
16
|
function v(e, t) {
|
|
17
17
|
for (const n of e) {
|
|
18
|
-
if (u(n).some((
|
|
18
|
+
if (u(n).some((d) => d.id === t)) return n;
|
|
19
19
|
const o = v(u(n), t);
|
|
20
20
|
if (o) return o;
|
|
21
21
|
}
|
|
@@ -24,42 +24,48 @@ function B(e, t) {
|
|
|
24
24
|
const n = v(e, t);
|
|
25
25
|
return n !== void 0 && g(n);
|
|
26
26
|
}
|
|
27
|
-
function M(e, t, n, o,
|
|
28
|
-
const
|
|
27
|
+
function M(e, t, n, o, d) {
|
|
28
|
+
const s = m(t).map((r) => C(e, r, n)).filter((r) => !!r && r.outputs.length > 0);
|
|
29
29
|
return {
|
|
30
30
|
dataContextPaths: Object.keys(o).sort((r, l) => r.localeCompare(l)),
|
|
31
|
-
queryResults:
|
|
31
|
+
queryResults: d.map((r) => ({
|
|
32
32
|
id: r.id,
|
|
33
33
|
name: r.name,
|
|
34
34
|
fields: r.resultFields.map((l) => l.name)
|
|
35
35
|
})),
|
|
36
|
-
componentOutputs:
|
|
36
|
+
componentOutputs: s
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
function C(e, t, n) {
|
|
40
40
|
const o = y(e, f(t), n);
|
|
41
41
|
if (!o) return;
|
|
42
|
-
const
|
|
43
|
-
path:
|
|
44
|
-
label:
|
|
45
|
-
type: String(
|
|
42
|
+
const d = o.properties.filter((s) => s.descriptor.output === !0).map((s) => ({
|
|
43
|
+
path: s.descriptor.path,
|
|
44
|
+
label: s.descriptor.label,
|
|
45
|
+
type: String(s.descriptor.valueType)
|
|
46
46
|
}));
|
|
47
47
|
return {
|
|
48
48
|
componentId: t,
|
|
49
49
|
label: o.label,
|
|
50
|
-
outputs:
|
|
50
|
+
outputs: d
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
var E = [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
a.DataContext,
|
|
55
|
+
a.QueryResult,
|
|
56
|
+
a.ComponentProperty,
|
|
57
|
+
a.Literal,
|
|
58
|
+
a.CommandResponse
|
|
59
|
+
], S = [
|
|
60
|
+
a.DataContext,
|
|
61
|
+
a.QueryResult,
|
|
62
|
+
a.ComponentProperty,
|
|
63
|
+
a.Literal
|
|
64
|
+
], N = [p.OneWay, p.TwoWay], R = [
|
|
59
65
|
c.Propagate,
|
|
60
66
|
c.Clear,
|
|
61
67
|
c.Preserve
|
|
62
|
-
],
|
|
68
|
+
], D = [
|
|
63
69
|
i.String,
|
|
64
70
|
i.Number,
|
|
65
71
|
i.Boolean,
|
|
@@ -75,18 +81,18 @@ function T(e) {
|
|
|
75
81
|
const t = e;
|
|
76
82
|
return !!t && typeof t == "object" && typeof t.path == "string" && (t.kind === void 0 || E.includes(t.kind));
|
|
77
83
|
}
|
|
78
|
-
function
|
|
84
|
+
function O(e) {
|
|
79
85
|
return (e.descriptor.acceptedBindingKinds?.length ?? 0) > 0 || T(e.effectiveValue);
|
|
80
86
|
}
|
|
81
87
|
function P(e) {
|
|
82
88
|
return {
|
|
83
|
-
kind: e.descriptor.acceptedBindingKinds?.[0] ??
|
|
89
|
+
kind: e.descriptor.acceptedBindingKinds?.[0] ?? a.DataContext,
|
|
84
90
|
path: "",
|
|
85
91
|
mode: e.descriptor.bindingMode,
|
|
86
92
|
expectedValueType: e.descriptor.valueType
|
|
87
93
|
};
|
|
88
94
|
}
|
|
89
|
-
var
|
|
95
|
+
var L = {
|
|
90
96
|
unset: "Not set",
|
|
91
97
|
item: "Item",
|
|
92
98
|
itemTitle: (e, t) => `${e} ${t}`,
|
|
@@ -120,18 +126,19 @@ var R = {
|
|
|
120
126
|
noEditor: (e) => `'${e}' has no editor: nothing describes what it holds, so it cannot be edited here.`
|
|
121
127
|
};
|
|
122
128
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
S as a,
|
|
130
|
+
T as c,
|
|
131
|
+
u as d,
|
|
132
|
+
m as f,
|
|
133
|
+
v as h,
|
|
134
|
+
R as i,
|
|
135
|
+
O as l,
|
|
136
|
+
B as m,
|
|
130
137
|
E as n,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
u
|
|
138
|
+
P as o,
|
|
139
|
+
b as p,
|
|
140
|
+
N as r,
|
|
141
|
+
D as s,
|
|
142
|
+
L as t,
|
|
143
|
+
M as u
|
|
137
144
|
};
|