@cratis/event-models 0.350.3 → 0.351.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.
@@ -1,5 +1,5 @@
1
1
  import { a as V, c as O, i as J, n as K, o as T, r as w, s as F, t as j, u as D } from "./defaultStructuredEditorStrings-Bwbw58wD.js";
2
- import { t as Q } from "./StructuredValueEditor-DUSATTWd.js";
2
+ import { t as Q } from "./StructuredValueEditor-DZbDHWDg.js";
3
3
  import { c as E } from "./structuredValue-vqCZttsk.js";
4
4
  import { useEffect as L, useRef as $, useState as A } from "react";
5
5
  import { Fragment as q, jsx as t, jsxs as u } from "react/jsx-runtime";
@@ -1,6 +1,6 @@
1
1
  import { n as T, t as A } from "./allowedIconChoices-KSkQ6blx.js";
2
2
  import { a as u, i as D, r as P, t as $ } from "./iconDiagnostics-BZq0t8-V.js";
3
- import { StructuredPropertyEditor as U } from "./StructuredPropertyEditor-Bd-8GBgK.js";
3
+ import { StructuredPropertyEditor as U } from "./StructuredPropertyEditor-CdG5bfkx.js";
4
4
  import { jsx as n, jsxs as c } from "react/jsx-runtime";
5
5
  import { CollectionOperation as C, DestinationKind as v, PropertyValueType as L, SceneEditKind as S } from "@cratis/scene.model";
6
6
  import { OrderedItemEditor as F } from "@cratis/components/ConfigurationEditor";
@@ -7,7 +7,7 @@ export interface SceneScreenDraftReviewProps {
7
7
  controller: ScreenEditorController;
8
8
  environment: ScreenEditorEnvironment;
9
9
  agent: SceneScreenDraftAgent;
10
- onPreview?: (document: SceneDocument) => void;
10
+ onPreview?: (document: SceneDocument, fitsDialog: boolean) => void;
11
11
  strings?: SceneScreenDraftStrings;
12
12
  previewing?: boolean;
13
13
  }
@@ -10,7 +10,7 @@ export interface SceneScreenDraftToolbarProps {
10
10
  agent?: SceneScreenDraftAgent;
11
11
  readOnly: boolean;
12
12
  authoringTemplate?: string;
13
- onPreview?: (document: SceneDocument) => void;
13
+ onPreview?: (document: SceneDocument, fitsDialog: boolean) => void;
14
14
  previewing?: boolean;
15
15
  }
16
16
  export declare const SceneScreenDraftToolbar: ({ controller, environment, strings, agent, readOnly, authoringTemplate, onPreview, previewing }: SceneScreenDraftToolbarProps) => import("react").JSX.Element | null;
@@ -25,7 +25,7 @@ export interface ScreenEditorOverlayProps {
25
25
  onClose: (result: ScreenEditorResult) => void;
26
26
  onBeforeClose?: (result: ScreenEditorResult) => Promise<string | undefined>;
27
27
  onDismiss?: () => void;
28
- onPreview?: (document: SceneDocument) => void;
28
+ onPreview?: (document: SceneDocument, fitsDialog: boolean) => void;
29
29
  previewing?: boolean;
30
30
  readOnly?: boolean;
31
31
  draftAgent?: SceneScreenDraftAgent;
@@ -30,7 +30,7 @@ export interface ScreenEditorWindowProps {
30
30
  saveFailure?: string;
31
31
  onKeepEditing?: () => void;
32
32
  onDiscard?: () => void;
33
- onPreview?: (document: SceneDocument) => void;
33
+ onPreview?: (document: SceneDocument, fitsDialog: boolean) => void;
34
34
  readOnly?: boolean;
35
35
  toolbarActions?: ReactNode;
36
36
  renderControls?: (controls: ReactNode) => ReactNode;
@@ -0,0 +1,2 @@
1
+ import { type PropertyDescriptor } from '@cratis/scene.model';
2
+ export declare function withIconReferences(descriptor: PropertyDescriptor, value: unknown): unknown;
@@ -8,4 +8,7 @@ export interface DesignTimePointerDecision {
8
8
  export declare function decideDesignTimePointer(type: string, target: EventTarget | null, button?: number): DesignTimePointerDecision;
9
9
  export declare function elementIdAt(target: EventTarget | null): string | undefined;
10
10
  export declare const itemHitSelector = "[data-scene-item], [data-scene-nav-item], [data-scene-outlet-item]";
11
- export declare function itemIdAt(target: EventTarget | null): string | undefined;
11
+ export declare function itemIdAt(target: EventTarget | null, point?: {
12
+ x: number;
13
+ y: number;
14
+ }): string | undefined;
@@ -1,4 +1,4 @@
1
- import { t as s } from "./StructuredValueEditor-DUSATTWd.js";
1
+ import { t as s } from "./StructuredValueEditor-DZbDHWDg.js";
2
2
  import { jsx as u } from "react/jsx-runtime";
3
3
  var p = ({ value: r, onChange: t, descriptor: e, context: i, disabled: d, id: o }) => /* @__PURE__ */ u(s, {
4
4
  descriptor: e,
@@ -0,0 +1,349 @@
1
+ import { a as E, d as O, f as j, g as $, h as K, i as F, l as N, n as P, o as _, r as V, s as D, t as g, u as M, v as T, y as w } from "./structuredValue-vqCZttsk.js";
2
+ import { jsx as t, jsxs as m } from "react/jsx-runtime";
3
+ import { PropertyValueType as y } from "@cratis/scene.model";
4
+ var I = ({ descriptor: e, value: l, id: b, strings: a, disabled: n, onChange: o }) => {
5
+ const c = e.editorKind === O, r = g(l), u = (s) => o(s.length === 0 ? void 0 : s);
6
+ return /* @__PURE__ */ m("fieldset", {
7
+ className: "studio-editor-structured__list",
8
+ disabled: n,
9
+ children: [
10
+ /* @__PURE__ */ t("legend", { children: e.label }),
11
+ r.map((s, d) => /* @__PURE__ */ m("div", {
12
+ className: "studio-editor-structured__entry",
13
+ children: [
14
+ /* @__PURE__ */ t("input", {
15
+ id: `${b}-${d}`,
16
+ "aria-label": a.entry(d + 1),
17
+ type: c ? "number" : "text",
18
+ value: c ? typeof s == "number" ? String(s) : "" : typeof s == "string" ? s : "",
19
+ onChange: (i) => o(T(r, d, c ? i.target.value === "" ? 0 : Number(i.target.value) : i.target.value))
20
+ }),
21
+ /* @__PURE__ */ t("button", {
22
+ type: "button",
23
+ "aria-label": a.moveEntryUp(d + 1),
24
+ disabled: d === 0,
25
+ onClick: () => o(N(r, d, -1)),
26
+ children: a.moveUpText
27
+ }),
28
+ /* @__PURE__ */ t("button", {
29
+ type: "button",
30
+ "aria-label": a.moveEntryDown(d + 1),
31
+ disabled: d === r.length - 1,
32
+ onClick: () => o(N(r, d, 1)),
33
+ children: a.moveDownText
34
+ }),
35
+ /* @__PURE__ */ t("button", {
36
+ type: "button",
37
+ "aria-label": a.removeEntry(d + 1),
38
+ onClick: () => u(w(r, d)),
39
+ children: a.removeText
40
+ })
41
+ ]
42
+ }, d)),
43
+ /* @__PURE__ */ t("button", {
44
+ type: "button",
45
+ onClick: () => o([...r, c ? 0 : ""]),
46
+ children: a.addEntry
47
+ })
48
+ ]
49
+ });
50
+ }, U = (e) => typeof e == "number" ? "number" : typeof e == "boolean" ? "flag" : "text", L = ({ label: e, value: l, id: b, strings: a, disabled: n, onChange: o }) => {
51
+ const c = U(l), r = (u) => {
52
+ u !== c && o(u === "number" ? typeof l == "string" && l.trim() !== "" && Number.isFinite(Number(l)) ? Number(l) : 0 : u === "flag" ? l === !0 || l === "true" : l === void 0 ? void 0 : String(l));
53
+ };
54
+ return /* @__PURE__ */ m("div", {
55
+ className: "studio-editor-structured__scalar",
56
+ children: [/* @__PURE__ */ m("select", {
57
+ "aria-label": `${e} ${a.scalarType}`,
58
+ disabled: n,
59
+ value: c,
60
+ onChange: (u) => r(u.target.value),
61
+ children: [
62
+ /* @__PURE__ */ t("option", {
63
+ value: "text",
64
+ children: a.scalarText
65
+ }),
66
+ /* @__PURE__ */ t("option", {
67
+ value: "number",
68
+ children: a.scalarNumber
69
+ }),
70
+ /* @__PURE__ */ t("option", {
71
+ value: "flag",
72
+ children: a.scalarFlag
73
+ })
74
+ ]
75
+ }), c === "flag" ? /* @__PURE__ */ m("label", { children: [/* @__PURE__ */ t("input", {
76
+ id: b,
77
+ type: "checkbox",
78
+ disabled: n,
79
+ checked: l === !0,
80
+ onChange: (u) => o(u.target.checked)
81
+ }), /* @__PURE__ */ t("span", { children: a.scalarFlagOn })] }) : /* @__PURE__ */ t("input", {
82
+ id: b,
83
+ "aria-label": e,
84
+ type: c === "number" ? "number" : "text",
85
+ disabled: n,
86
+ value: l === void 0 ? "" : String(l),
87
+ onChange: (u) => o(u.target.value === "" ? void 0 : c === "number" ? Number(u.target.value) : u.target.value)
88
+ })]
89
+ });
90
+ }, A = (e) => [
91
+ "string",
92
+ "number",
93
+ "boolean"
94
+ ].includes(typeof e), B = ({ descriptor: e, value: l, id: b, strings: a, disabled: n, onChange: o }) => {
95
+ const c = _(l) ? l : {}, r = Object.entries(c), u = (i) => o(i.length === 0 ? void 0 : Object.fromEntries(i)), s = (i, f) => {
96
+ const p = f.trim();
97
+ p === "" || p === r[i][0] || r.some(([h], v) => v !== i && h === p) || u(r.map(([h, v], k) => k === i ? [p, v] : [h, v]));
98
+ }, d = () => {
99
+ let i = r.length + 1;
100
+ for (; `value${i}` in c; ) i++;
101
+ u([...r, [`value${i}`, ""]]);
102
+ };
103
+ return /* @__PURE__ */ m("fieldset", {
104
+ className: "studio-editor-structured__list",
105
+ disabled: n,
106
+ children: [
107
+ /* @__PURE__ */ t("legend", { children: e.label }),
108
+ r.map(([i, f], p) => /* @__PURE__ */ m("div", {
109
+ className: "studio-editor-structured__entry",
110
+ children: [
111
+ /* @__PURE__ */ t("input", {
112
+ "aria-label": a.mapName(p + 1),
113
+ defaultValue: i,
114
+ onBlur: (h) => {
115
+ s(p, h.target.value), h.target.value = i;
116
+ }
117
+ }),
118
+ A(f) ? /* @__PURE__ */ t(L, {
119
+ label: a.mapValue(i),
120
+ value: f,
121
+ id: `${b}-${p}`,
122
+ strings: a,
123
+ disabled: n,
124
+ onChange: (h) => u(r.map(([v, k]) => v === i ? [v, h === void 0 ? "" : h] : [v, k]))
125
+ }) : /* @__PURE__ */ t("span", { children: a.keptValue }),
126
+ /* @__PURE__ */ t("button", {
127
+ type: "button",
128
+ "aria-label": a.removeMapEntry(i),
129
+ onClick: () => u(r.filter(([h]) => h !== i)),
130
+ children: a.removeText
131
+ })
132
+ ]
133
+ }, i)),
134
+ /* @__PURE__ */ t("button", {
135
+ type: "button",
136
+ onClick: d,
137
+ children: a.addMapEntry
138
+ })
139
+ ]
140
+ });
141
+ }, C = ({ descriptor: e, value: l, id: b, strings: a, disabled: n, onChange: o }) => Array.isArray(l) ? /* @__PURE__ */ m("div", {
142
+ className: "studio-editor-structured__either",
143
+ children: [/* @__PURE__ */ t(I, {
144
+ descriptor: e,
145
+ value: l,
146
+ id: b,
147
+ strings: a,
148
+ disabled: n,
149
+ onChange: o
150
+ }), /* @__PURE__ */ t("button", {
151
+ type: "button",
152
+ disabled: n,
153
+ onClick: () => o(typeof l[0] == "string" && l[0] !== "" ? l[0] : void 0),
154
+ children: `${e.label}: ${a.useSingle}`
155
+ })]
156
+ }) : /* @__PURE__ */ m("div", {
157
+ className: "studio-editor-structured__either",
158
+ children: [/* @__PURE__ */ m("label", {
159
+ className: "studio-editor-structured__field",
160
+ children: [/* @__PURE__ */ t("span", { children: e.label }), /* @__PURE__ */ t("input", {
161
+ id: b,
162
+ disabled: n,
163
+ value: typeof l == "string" ? l : "",
164
+ onChange: (c) => o(c.target.value === "" ? void 0 : c.target.value)
165
+ })]
166
+ }), /* @__PURE__ */ t("button", {
167
+ type: "button",
168
+ disabled: n,
169
+ onClick: () => o(typeof l == "string" && l !== "" ? [l] : [""]),
170
+ children: `${e.label}: ${a.useList}`
171
+ })]
172
+ }), S = ({ descriptor: e, value: l, idPrefix: b, strings: a, disabled: n, onChange: o }) => {
173
+ const c = `${b}-${e.path}`;
174
+ switch (e.valueType) {
175
+ case y.String:
176
+ return /* @__PURE__ */ m("label", {
177
+ className: "studio-editor-structured__field",
178
+ children: [/* @__PURE__ */ t("span", { children: e.label }), /* @__PURE__ */ t("input", {
179
+ id: c,
180
+ disabled: n,
181
+ value: typeof l == "string" ? l : "",
182
+ onChange: (r) => o(r.target.value === "" ? void 0 : r.target.value)
183
+ })]
184
+ });
185
+ case y.Icon:
186
+ if (l === void 0 || typeof l == "string") return /* @__PURE__ */ m("label", {
187
+ className: "studio-editor-structured__field",
188
+ children: [/* @__PURE__ */ t("span", { children: e.label }), /* @__PURE__ */ t("input", {
189
+ id: c,
190
+ disabled: n,
191
+ placeholder: "Cratis.Icons.Lucide#plus",
192
+ value: l ?? "",
193
+ onChange: (r) => o(r.target.value === "" ? void 0 : r.target.value)
194
+ })]
195
+ });
196
+ break;
197
+ case y.Number:
198
+ return /* @__PURE__ */ m("label", {
199
+ className: "studio-editor-structured__field",
200
+ children: [/* @__PURE__ */ t("span", { children: e.label }), /* @__PURE__ */ t("input", {
201
+ id: c,
202
+ type: "number",
203
+ disabled: n,
204
+ value: typeof l == "number" ? String(l) : "",
205
+ onChange: (r) => o(r.target.value === "" ? void 0 : Number(r.target.value))
206
+ })]
207
+ });
208
+ case y.Boolean:
209
+ return /* @__PURE__ */ m("label", {
210
+ className: "studio-editor-structured__field studio-editor-structured__field--flag",
211
+ children: [/* @__PURE__ */ t("input", {
212
+ id: c,
213
+ type: "checkbox",
214
+ disabled: n,
215
+ checked: l === !0,
216
+ onChange: (r) => o(r.target.checked)
217
+ }), /* @__PURE__ */ t("span", { children: e.label })]
218
+ });
219
+ case y.Enum: {
220
+ const r = e.choices ?? [], u = r.findIndex((s) => s.value === l);
221
+ return /* @__PURE__ */ m("label", {
222
+ className: "studio-editor-structured__field",
223
+ children: [/* @__PURE__ */ t("span", { children: e.label }), /* @__PURE__ */ m("select", {
224
+ id: c,
225
+ disabled: n,
226
+ value: u < 0 ? "" : String(u),
227
+ onChange: (s) => o(s.target.value === "" ? void 0 : r[Number(s.target.value)]?.value),
228
+ children: [/* @__PURE__ */ t("option", {
229
+ value: "",
230
+ children: a.unset
231
+ }), r.map((s, d) => /* @__PURE__ */ t("option", {
232
+ value: String(d),
233
+ children: s.label
234
+ }, d))]
235
+ })]
236
+ });
237
+ }
238
+ }
239
+ if (E(e) && e.editorKind === j) return /* @__PURE__ */ m("label", {
240
+ className: "studio-editor-structured__field",
241
+ children: [/* @__PURE__ */ t("span", { children: e.label }), /* @__PURE__ */ t(L, {
242
+ label: e.label,
243
+ value: l,
244
+ id: c,
245
+ strings: a,
246
+ disabled: n,
247
+ onChange: o
248
+ })]
249
+ });
250
+ if (E(e) && e.editorKind === K) return /* @__PURE__ */ t(C, {
251
+ descriptor: e,
252
+ value: l,
253
+ id: c,
254
+ strings: a,
255
+ disabled: n,
256
+ onChange: o
257
+ });
258
+ if (D(e)) return /* @__PURE__ */ t(B, {
259
+ descriptor: e,
260
+ value: l,
261
+ id: c,
262
+ strings: a,
263
+ disabled: n,
264
+ onChange: o
265
+ });
266
+ if (E(e)) return /* @__PURE__ */ t(I, {
267
+ descriptor: e,
268
+ value: l,
269
+ id: c,
270
+ strings: a,
271
+ disabled: n,
272
+ onChange: o
273
+ });
274
+ if (F(e)) return /* @__PURE__ */ m("fieldset", {
275
+ className: "studio-editor-structured__object",
276
+ disabled: n,
277
+ children: [/* @__PURE__ */ t("legend", { children: e.label }), e.properties.map((r) => /* @__PURE__ */ t(S, {
278
+ descriptor: r,
279
+ value: _(l) ? l[r.path] : void 0,
280
+ idPrefix: c,
281
+ strings: a,
282
+ disabled: n,
283
+ onChange: (u) => o($(l, r.path, u))
284
+ }, r.path))]
285
+ });
286
+ if (V(e)) {
287
+ const r = g(l), u = e.item.label ?? a.item, s = e.item.positional === !0;
288
+ return /* @__PURE__ */ m("fieldset", {
289
+ className: "studio-editor-structured__collection",
290
+ disabled: n,
291
+ children: [
292
+ /* @__PURE__ */ t("legend", { children: e.label }),
293
+ r.map((d, i) => /* @__PURE__ */ m("fieldset", {
294
+ className: "studio-editor-structured__item",
295
+ children: [
296
+ /* @__PURE__ */ t("legend", { children: a.itemTitle(u, i + 1) }),
297
+ e.item.properties.map((f) => /* @__PURE__ */ t(S, {
298
+ descriptor: f,
299
+ value: _(d) ? d[f.path] : void 0,
300
+ idPrefix: `${c}-${i}`,
301
+ strings: a,
302
+ disabled: n,
303
+ onChange: (p) => o(T(r, i, $(P(d, s), f.path, p) ?? {}))
304
+ }, f.path)),
305
+ /* @__PURE__ */ m("div", {
306
+ className: "studio-editor-structured__actions",
307
+ children: [
308
+ /* @__PURE__ */ t("button", {
309
+ type: "button",
310
+ "aria-label": a.moveUp(u, i + 1),
311
+ disabled: i === 0,
312
+ onClick: () => o(N(r, i, -1)),
313
+ children: a.moveUpText
314
+ }),
315
+ /* @__PURE__ */ t("button", {
316
+ type: "button",
317
+ "aria-label": a.moveDown(u, i + 1),
318
+ disabled: i === r.length - 1,
319
+ onClick: () => o(N(r, i, 1)),
320
+ children: a.moveDownText
321
+ }),
322
+ /* @__PURE__ */ t("button", {
323
+ type: "button",
324
+ "aria-label": a.remove(u, i + 1),
325
+ onClick: () => o(w(r, i)),
326
+ children: a.removeText
327
+ })
328
+ ]
329
+ })
330
+ ]
331
+ }, !s && _(d) && typeof d.id == "string" ? d.id : i)),
332
+ /* @__PURE__ */ t("button", {
333
+ type: "button",
334
+ disabled: e.constraints?.maximumItems !== void 0 && r.length >= e.constraints.maximumItems,
335
+ onClick: () => o([...r, M(s)]),
336
+ children: a.add(u)
337
+ })
338
+ ]
339
+ });
340
+ }
341
+ return /* @__PURE__ */ t("p", {
342
+ className: "studio-editor-structured__undescribed",
343
+ role: "alert",
344
+ children: a.noEditor(e.label)
345
+ });
346
+ };
347
+ export {
348
+ S as t
349
+ };