@cratis/scene 0.223.0 → 0.223.1

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,6 +1,6 @@
1
1
  import { UIElement } from './UIElement';
2
2
  import type { ComponentState, IComponent, PrototypeComponentConstructor } from './IComponent';
3
- import type { PrototypeSurfaceElement } from './Prototypes/Editor/editorTypes';
3
+ import type { PrototypeSurfaceElement } from './Prototypes/prototypeTypes';
4
4
  declare global {
5
5
  interface Window {
6
6
  __cratisPrototypeComponents?: Record<string, Record<string, PrototypeComponentConstructor>>;
@@ -1,2 +1,2 @@
1
1
  export * from './Rendering';
2
- export * from './Editor/editorTypes';
2
+ export * from './prototypeTypes';
@@ -1,9 +1,8 @@
1
- import { c as $, f as l, k as ut } from "../Scene-DaQtzf1e.js";
2
- import { a as M, i as G, n as ft, r as U, t as bt } from "../renderPrototypeElement-Xm7OIVPs.js";
3
- import { createContext as S, useContext as j, useEffect as V } from "react";
4
- import { Fragment as A, jsx as n, jsxs as E } from "react/jsx-runtime";
5
- import { createPortal as q } from "react-dom";
6
- var L = {
1
+ import { c as L, f as h, k as ft } from "../Scene-DaQtzf1e.js";
2
+ import { createContext as U, useContext as S, useEffect as j } from "react";
3
+ import { Fragment as D, jsx as a, jsxs as T } from "react/jsx-runtime";
4
+ import { createPortal as V } from "react-dom";
5
+ var R = {
7
6
  prototypeThumbnail: {
8
7
  openEditor: "Open prototype editor",
9
8
  windowTitle: "Prototype",
@@ -13,26 +12,26 @@ var L = {
13
12
  title: "Prototype preview",
14
13
  close: "Close preview"
15
14
  }
16
- }, D = S(L), k = () => j(D), Ht = ({ messages: t, children: e }) => /* @__PURE__ */ n(D.Provider, {
17
- value: t,
18
- children: e
19
- }), J = [
15
+ }, k = U(R), F = () => S(k), Tt = ({ messages: e, children: t }) => /* @__PURE__ */ a(k.Provider, {
16
+ value: e,
17
+ children: t
18
+ }), q = [
20
19
  "#f66",
21
20
  "#fa0",
22
21
  "#3c3"
23
- ], K = ({ size: t }) => /* @__PURE__ */ n(A, { children: J.map((e, i) => /* @__PURE__ */ n("div", {
22
+ ], J = ({ size: e }) => /* @__PURE__ */ a(D, { children: q.map((t, o) => /* @__PURE__ */ a("div", {
24
23
  className: "prototype-window-traffic-light",
25
24
  style: {
26
- border: `${t ? Math.max(1, t / 8) : 1.5}px solid ${e}`,
27
- ...t ? {
28
- width: t,
29
- height: t
25
+ border: `${e ? Math.max(1, e / 8) : 1.5}px solid ${t}`,
26
+ ...e ? {
27
+ width: e,
28
+ height: e
30
29
  } : {}
31
30
  }
32
- }, i)) }), W = 16, Q = 8, X = {
31
+ }, o)) }), M = 16, K = 8, Q = {
33
32
  width: 180,
34
33
  height: 36
35
- }, Y = {
34
+ }, X = {
36
35
  dataTable: {
37
36
  width: 360,
38
37
  height: 120
@@ -49,32 +48,68 @@ var L = {
49
48
  width: 300,
50
49
  height: 150
51
50
  }
52
- }, Z = (t) => !(t.width > 0) || !(t.height > 0);
53
- function z(t, e) {
54
- let i = W;
55
- return t.map((o) => {
56
- if (!o.native || !Z(o.size)) return {
57
- position: o.position,
58
- size: o.size
51
+ }, Y = (e) => !(e.width > 0) || !(e.height > 0);
52
+ function Z(e, t) {
53
+ let o = M;
54
+ return e.map((r) => {
55
+ if (!r.native || !Y(r.size)) return {
56
+ position: r.position,
57
+ size: r.size
59
58
  };
60
- const a = Y[o.name] ?? X;
61
- if (!e) return {
62
- position: o.position,
63
- size: a
59
+ const i = X[r.name] ?? Q;
60
+ if (!t) return {
61
+ position: r.position,
62
+ size: i
64
63
  };
65
64
  const s = {
66
- x: W,
67
- y: i
65
+ x: M,
66
+ y: o
68
67
  };
69
- return i += a.height + Q, {
68
+ return o += i.height + K, {
70
69
  position: s,
71
- size: a
70
+ size: i
72
71
  };
73
72
  });
74
73
  }
75
- var tt = (t) => {
76
- switch (t) {
77
- case l.flexRow:
74
+ var z = (e) => {
75
+ const t = e;
76
+ if (t.position && typeof t.position.x == "number") return {
77
+ x: t.position.x,
78
+ y: t.position.y ?? 0
79
+ };
80
+ const o = t.properties?.canvas ?? {};
81
+ return {
82
+ x: o.x ?? 0,
83
+ y: o.y ?? 0
84
+ };
85
+ }, tt = (e) => {
86
+ const t = e;
87
+ return t.size && typeof t.size.width == "number" ? {
88
+ width: t.size.width,
89
+ height: t.size.height ?? 0
90
+ } : {
91
+ width: t.width ?? 0,
92
+ height: t.height ?? 0
93
+ };
94
+ }, E = (e) => {
95
+ const t = e;
96
+ if (typeof t.componentName != "string" || t.componentName.includes(".")) return;
97
+ const o = t.properties && typeof t.properties == "object" ? t.properties : {}, r = [
98
+ o.label,
99
+ o.text,
100
+ o.title,
101
+ t.componentName
102
+ ].find((i) => typeof i == "string" && i.length > 0);
103
+ return typeof r == "string" ? {
104
+ type: t.componentName,
105
+ label: r
106
+ } : void 0;
107
+ }, W = (e) => {
108
+ const t = e, o = [t.name, t.componentName].find((r) => typeof r == "string" && r.length > 0);
109
+ return typeof o == "string" ? o : "";
110
+ }, et = (e) => {
111
+ switch (e) {
112
+ case h.flexRow:
78
113
  return {
79
114
  display: "flex",
80
115
  flexDirection: "row",
@@ -83,14 +118,14 @@ var tt = (t) => {
83
118
  padding: 12,
84
119
  alignContent: "flex-start"
85
120
  };
86
- case l.flexColumn:
121
+ case h.flexColumn:
87
122
  return {
88
123
  display: "flex",
89
124
  flexDirection: "column",
90
125
  gap: 12,
91
126
  padding: 12
92
127
  };
93
- case l.grid:
128
+ case h.grid:
94
129
  return {
95
130
  display: "grid",
96
131
  gridTemplateColumns: "repeat(auto-fill, minmax(180px, 1fr))",
@@ -101,158 +136,170 @@ var tt = (t) => {
101
136
  default:
102
137
  return {};
103
138
  }
104
- }, et = 900, ot = 640, rt = 40, it = 150, at = 16, nt = ({ elements: t, windowSize: e, layout: i = l.absolute, onClick: o, width: a = it, titleBarHeight: s = at, openTitle: c }) => {
105
- const h = k().prototypeThumbnail, w = e && e.width > 0 ? e.width : et, v = e && e.height > 0 ? e.height : ot, p = i !== l.absolute, d = i === l.grid, m = t.filter(Boolean).map($), F = z(m.map((r) => ({
106
- native: M(r) !== void 0,
107
- name: String(r.componentName ?? ""),
108
- position: U(r),
109
- size: G(r)
110
- })), !p), f = w, x = Math.max(1, v - rt), b = a / f, R = Math.round(f * b), B = Math.round(x * b), C = m.map((r, g) => ({
111
- element: r,
112
- ...F[g]
113
- })), H = /* @__PURE__ */ E(A, { children: [/* @__PURE__ */ E("div", {
139
+ }, ot = 900, rt = 640, it = 40, nt = 150, at = 16, st = ({ elements: e, windowSize: t, layout: o = h.absolute, onClick: r, width: i = nt, titleBarHeight: s = at, openTitle: c }) => {
140
+ const p = F().prototypeThumbnail, f = t && t.width > 0 ? t.width : ot, m = t && t.height > 0 ? t.height : rt, d = o !== h.absolute, l = o === h.grid, y = e.filter(Boolean).map(L), B = Z(y.map((n) => ({
141
+ native: E(n) !== void 0,
142
+ name: String(n.componentName ?? ""),
143
+ position: z(n),
144
+ size: tt(n)
145
+ })), !d), w = f, H = Math.max(1, m - it), b = i / w, C = Math.round(w * b), O = Math.round(H * b), $ = y.map((n, v) => ({
146
+ element: n,
147
+ ...B[v]
148
+ })), P = /* @__PURE__ */ T(D, { children: [/* @__PURE__ */ T("div", {
114
149
  className: "prototype-thumbnail-title-bar",
115
150
  style: { height: s },
116
- children: [/* @__PURE__ */ n(K, { size: Math.round(s * 0.375) }), /* @__PURE__ */ n("span", {
151
+ children: [/* @__PURE__ */ a(J, { size: Math.round(s * 0.375) }), /* @__PURE__ */ a("span", {
117
152
  className: "prototype-thumbnail-title",
118
- children: h.windowTitle
153
+ children: p.windowTitle
119
154
  })]
120
- }), /* @__PURE__ */ n("div", {
155
+ }), /* @__PURE__ */ a("div", {
121
156
  className: "prototype-thumbnail-body",
122
157
  inert: !0,
123
- children: /* @__PURE__ */ n("div", {
158
+ children: /* @__PURE__ */ a("div", {
124
159
  className: "prototype-thumbnail-canvas-scaler",
125
160
  style: {
126
- width: f,
127
- height: x,
161
+ width: w,
162
+ height: H,
128
163
  transform: `scale(${b})`,
129
164
  transformOrigin: "top left",
130
- ...tt(i)
165
+ ...et(o)
131
166
  },
132
- children: C.map(({ element: r, position: g, size: y }) => {
133
- const I = String(r.id), P = p ? {
167
+ children: $.map(({ element: n, position: v, size: g }) => {
168
+ const I = String(n.id), N = d ? {
134
169
  position: "relative",
135
- width: d ? "100%" : y.width,
136
- height: y.height,
170
+ width: l ? "100%" : g.width,
171
+ height: g.height,
137
172
  flexShrink: 0
138
173
  } : {
139
174
  position: "absolute",
140
- left: g.x,
141
- top: g.y,
142
- width: y.width,
143
- height: y.height
175
+ left: v.x,
176
+ top: v.y,
177
+ width: g.width,
178
+ height: g.height
144
179
  };
145
- if ("RenderPrototype" in r && typeof r.RenderPrototype == "function") return /* @__PURE__ */ n("div", {
180
+ if ("RenderPrototype" in n && typeof n.RenderPrototype == "function") return /* @__PURE__ */ a("div", {
146
181
  style: {
147
- ...P,
182
+ ...N,
148
183
  pointerEvents: "none",
149
184
  overflow: "hidden"
150
185
  },
151
- children: r.RenderPrototype({
152
- component: r,
153
- label: r.label
186
+ children: n.RenderPrototype({
187
+ component: n,
188
+ label: n.label
154
189
  })
155
190
  }, I);
156
- const T = M(r), O = T ? " prototype-thumbnail-element--native" : "type" in r && typeof r.type == "string" ? ` prototype-thumbnail-element--${r.type}` : "";
157
- return /* @__PURE__ */ n("div", {
158
- className: `prototype-thumbnail-element${O}`,
159
- style: P,
160
- children: T && /* @__PURE__ */ n("span", {
191
+ const x = E(n), G = x ? " prototype-thumbnail-element--native" : "type" in n && typeof n.type == "string" ? ` prototype-thumbnail-element--${n.type}` : "";
192
+ return /* @__PURE__ */ a("div", {
193
+ className: `prototype-thumbnail-element${G}`,
194
+ style: N,
195
+ children: x && /* @__PURE__ */ a("span", {
161
196
  className: "prototype-thumbnail-element__label",
162
- children: T.label
197
+ children: x.label
163
198
  })
164
199
  }, I);
165
200
  })
166
201
  })
167
202
  })] }), _ = {
168
- width: R,
169
- height: s + B
203
+ width: C,
204
+ height: s + O
170
205
  };
171
- return o ? /* @__PURE__ */ n("button", {
206
+ return r ? /* @__PURE__ */ a("button", {
172
207
  className: "prototype-thumbnail",
173
- onClick: o,
174
- title: c ?? h.openEditor,
208
+ onClick: r,
209
+ title: c ?? p.openEditor,
175
210
  style: _,
176
- children: H
177
- }) : /* @__PURE__ */ n("div", {
211
+ children: P
212
+ }) : /* @__PURE__ */ a("div", {
178
213
  className: "prototype-thumbnail",
179
214
  role: "img",
180
- "aria-label": h.windowTitle,
215
+ "aria-label": p.windowTitle,
181
216
  style: _,
182
- children: H
217
+ children: P
183
218
  });
184
- }, st = 900, ht = 640, N = 40, lt = 24, dt = 0.9, pt = 0.85, ct = (t, e) => {
185
- const i = t && t.width > 0 ? t.width : st, o = t && t.height > 0 ? t.height : ht, a = Math.max(0.1, Math.min(1, e.width * dt / i, e.height * pt / o)), s = Math.round(i * a);
219
+ }, pt = 900, ht = 640, A = 40, lt = 24, dt = 0.9, ct = 0.85, mt = (e, t) => {
220
+ const o = e && e.width > 0 ? e.width : pt, r = e && e.height > 0 ? e.height : ht, i = Math.max(0.1, Math.min(1, t.width * dt / o, t.height * ct / r)), s = Math.round(o * i);
186
221
  return {
187
222
  width: s,
188
- canvasHeight: Math.round(Math.max(1, o - N) * (s / i)),
189
- titleBarHeight: Math.max(lt, Math.round(N * a))
223
+ canvasHeight: Math.round(Math.max(1, r - A) * (s / o)),
224
+ titleBarHeight: Math.max(lt, Math.round(A * i))
190
225
  };
191
- }, vt = () => typeof window > "u" ? {
226
+ }, yt = () => typeof window > "u" ? {
192
227
  width: 1280,
193
228
  height: 800
194
229
  } : {
195
230
  width: window.innerWidth,
196
231
  height: window.innerHeight
197
- }, mt = (t, e, i, o) => {
198
- if (!t || t.width <= 0) return;
199
- const a = (o.width - e) / 2, s = (o.height - i) / 2;
200
- return `translate(${Math.round(t.left - a)}px, ${Math.round(t.top - s)}px) scale(${(t.width / e).toFixed(4)})`;
201
- }, u = (t) => t.stopPropagation(), _t = ({ elements: t, windowSize: e, layout: i = l.absolute, sourceRect: o, onClose: a }) => {
202
- const s = k().prototypePreview ?? L.prototypePreview;
203
- V(() => {
204
- const d = (m) => {
205
- m.key === "Escape" && a();
232
+ }, vt = (e, t, o, r) => {
233
+ if (!e || e.width <= 0) return;
234
+ const i = (r.width - t) / 2, s = (r.height - o) / 2;
235
+ return `translate(${Math.round(e.left - i)}px, ${Math.round(e.top - s)}px) scale(${(e.width / t).toFixed(4)})`;
236
+ }, u = (e) => e.stopPropagation(), Et = ({ elements: e, windowSize: t, layout: o = h.absolute, sourceRect: r, onClose: i }) => {
237
+ const s = F().prototypePreview ?? R.prototypePreview;
238
+ j(() => {
239
+ const l = (y) => {
240
+ y.key === "Escape" && i();
206
241
  };
207
- return window.addEventListener("keydown", d), () => window.removeEventListener("keydown", d);
208
- }, [a]);
209
- const c = vt(), h = ct(e, c), w = h.titleBarHeight + h.canvasHeight, v = mt(o, h.width, w, c), p = /* @__PURE__ */ n("div", {
242
+ return window.addEventListener("keydown", l), () => window.removeEventListener("keydown", l);
243
+ }, [i]);
244
+ const c = yt(), p = mt(t, c), f = p.titleBarHeight + p.canvasHeight, m = vt(r, p.width, f, c), d = /* @__PURE__ */ a("div", {
210
245
  className: "prototype-preview-backdrop",
211
246
  role: "dialog",
212
247
  "aria-modal": "true",
213
248
  "aria-label": s.title,
214
- onClick: a,
249
+ onClick: i,
215
250
  onPointerDown: u,
216
251
  onMouseDown: u,
217
252
  onWheel: u,
218
253
  onDoubleClick: u,
219
- children: /* @__PURE__ */ E("div", {
254
+ children: /* @__PURE__ */ T("div", {
220
255
  className: "prototype-preview-window",
221
- style: v ? { "--prototype-preview-from": v } : void 0,
222
- onClick: (d) => d.stopPropagation(),
223
- children: [/* @__PURE__ */ n(nt, {
224
- elements: t,
225
- windowSize: e,
226
- layout: i,
227
- width: h.width,
228
- titleBarHeight: h.titleBarHeight
229
- }), /* @__PURE__ */ n("button", {
256
+ style: m ? { "--prototype-preview-from": m } : void 0,
257
+ onClick: (l) => l.stopPropagation(),
258
+ children: [/* @__PURE__ */ a(st, {
259
+ elements: e,
260
+ windowSize: t,
261
+ layout: o,
262
+ width: p.width,
263
+ titleBarHeight: p.titleBarHeight
264
+ }), /* @__PURE__ */ a("button", {
230
265
  type: "button",
231
266
  className: "prototype-preview-close",
232
267
  "aria-label": s.close,
233
268
  title: s.close,
234
- onClick: a,
269
+ onClick: i,
235
270
  children: "×"
236
271
  })]
237
272
  })
238
273
  });
239
- return typeof document > "u" ? p : q(p, document.body);
240
- }, It = 15;
274
+ return typeof document > "u" ? d : V(d, document.body);
275
+ }, Ht = (e) => {
276
+ const t = L(e);
277
+ if ("RenderPrototype" in t && typeof t.RenderPrototype == "function") return t.RenderPrototype({
278
+ component: t,
279
+ label: t.label ?? W(t)
280
+ });
281
+ const o = E(t);
282
+ return /* @__PURE__ */ a("div", {
283
+ className: "prototype-unrendered-element",
284
+ "data-prototype-element": o?.type,
285
+ children: o?.label ?? W(t)
286
+ });
287
+ }, Pt = 15;
241
288
  export {
242
- ut as AnchorEdges,
243
- l as PrototypeLayout,
244
- _t as PrototypePreview,
245
- nt as PrototypeThumbnail,
246
- D as SceneMessagesContext,
247
- Ht as SceneMessagesProvider,
248
- K as TrafficLights,
249
- It as allAnchorEdgesForEditor,
250
- L as defaultSceneMessages,
251
- ft as elementCaption,
252
- U as elementPosition,
253
- G as elementSize,
254
- ct as fitPrototypePreview,
255
- M as nativePreview,
256
- bt as renderPrototypeElement,
257
- k as useSceneMessages
289
+ ft as AnchorEdges,
290
+ h as PrototypeLayout,
291
+ Et as PrototypePreview,
292
+ st as PrototypeThumbnail,
293
+ k as SceneMessagesContext,
294
+ Tt as SceneMessagesProvider,
295
+ J as TrafficLights,
296
+ Pt as allAnchorEdgesForEditor,
297
+ R as defaultSceneMessages,
298
+ W as elementCaption,
299
+ z as elementPosition,
300
+ tt as elementSize,
301
+ mt as fitPrototypePreview,
302
+ E as nativePreview,
303
+ Ht as renderPrototypeElement,
304
+ F as useSceneMessages
258
305
  };
@@ -1,6 +1,6 @@
1
- import { AnchorEdges } from '../../AnchorEdges';
2
- import { PrototypeLayout } from '../../Layout/PrototypeLayout';
3
- import type { IComponent } from '../../IComponent';
1
+ import { AnchorEdges } from '../AnchorEdges';
2
+ import { PrototypeLayout } from '../Layout/PrototypeLayout';
3
+ import type { IComponent } from '../IComponent';
4
4
  export type ResizeHandle = 'n' | 's' | 'e' | 'w' | 'nw' | 'ne' | 'sw' | 'se';
5
5
  export type PrototypeSurfaceElementType = string;
6
6
  export type PrototypeElementType = PrototypeSurfaceElementType;
package/dist/scene.css CHANGED
@@ -1,2 +1,2 @@
1
- .prototype-unrendered-element{box-sizing:border-box;border:1px solid var(--cratis-surface-border,var(--surface-300));border-radius:var(--cratis-border-radius,4px);background:var(--cratis-surface-hover,var(--surface-200));min-height:28px;color:var(--cratis-text-secondary-color,var(--text-color-secondary));text-overflow:ellipsis;white-space:nowrap;padding:4px 8px;font-size:12px;overflow:hidden}.prototype-window-traffic-light{box-sizing:border-box;background:0 0;border-radius:50%;width:12px;height:12px}.prototype-thumbnail{cursor:default;box-sizing:border-box;background:var(--surface-card);border:none;flex-direction:column;flex-shrink:0;padding:0;display:flex;position:relative;overflow:hidden}.prototype-thumbnail:is(button){cursor:pointer}.prototype-thumbnail-title-bar{border-bottom:1px solid var(--surface-200);background:var(--surface-50);flex-shrink:0;align-items:center;gap:3px;padding:0 5px;display:flex;position:relative}.prototype-thumbnail-title{text-align:center;color:var(--text-color-secondary);pointer-events:none;font-family:system-ui,sans-serif;font-size:8px;position:absolute;left:0;right:0}.prototype-thumbnail-body{background:var(--surface-ground);flex:1;position:relative;overflow:hidden}.prototype-thumbnail-canvas-scaler{position:absolute;top:0;left:0}.prototype-thumbnail-element{box-sizing:border-box;background:var(--surface-200);border:1px solid var(--surface-300);border-radius:2px;position:absolute}.prototype-thumbnail-element--button,.prototype-thumbnail-element--button-hot{background:var(--surface-200);border:1px solid var(--surface-300)}.prototype-thumbnail-element--button-hot{background:var(--primary-color);border-color:var(--primary-color);opacity:.7}.prototype-thumbnail-element--native{color:var(--text-color);text-align:center;justify-content:center;align-items:center;padding:2px 6px;font-family:system-ui,sans-serif;font-size:12px;display:flex;overflow:hidden}.prototype-thumbnail-element__label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.prototype-thumbnail-element--text-input{background:var(--surface-0);border:1px solid var(--surface-300)}.prototype-thumbnail-element--label{border-bottom:1px solid var(--surface-300);background:0 0}.prototype-thumbnail-element--checkbox,.prototype-thumbnail-element--radio,.prototype-thumbnail-element--dropdown{background:var(--surface-0);border:1px solid var(--surface-300)}.prototype-thumbnail-element--image{background:var(--surface-100);border:1px dashed var(--surface-300)}.prototype-thumbnail-element--panel{background:var(--surface-50);border:1px solid var(--surface-200)}.prototype-thumbnail-element--data-table{background:var(--surface-0);border:1px solid var(--surface-300)}.prototype-thumbnail-element--toolbar{background:var(--surface-100);border:1px solid var(--surface-200)}.prototype-thumbnail-element--kpi-card{background:var(--surface-100);border:1px solid var(--primary-300,var(--surface-300));border-radius:3px}.prototype-thumbnail-element--bar-chart{background:var(--surface-0);border:1px solid var(--surface-300);background-image:repeating-linear-gradient(to top, var(--primary-400,#7c6fe0) 0px, var(--primary-400,#7c6fe0) 60%, transparent 60%, transparent 100%);background-position:10% 0,35% 0,60% 0,85% 0;background-repeat:no-repeat;background-size:20% 100%}.prototype-thumbnail-element--line-chart{background:var(--surface-0);border:1px solid var(--surface-300)}.prototype-thumbnail-element--pie-chart{background:var(--surface-0);border:1px solid var(--surface-300);border-radius:50%}.prototype-thumbnail-element--progress-bar{background:var(--surface-100);border:1px solid var(--surface-300);background-image:linear-gradient(to right, var(--primary-400,#7c6fe0) 0%, var(--primary-400,#7c6fe0) 55%, transparent 55%)}.prototype-thumbnail-element--activity-feed{background:var(--surface-0);border:1px solid var(--surface-300);background-image:repeating-linear-gradient(to bottom, transparent 0px, transparent 3px, var(--surface-200) 3px, var(--surface-200) 4px);background-size:100% 8px}.prototype-thumbnail-element--nav-topbar{background:var(--surface-100);border:1px solid var(--surface-200);border-radius:2px 2px 0 0}.prototype-thumbnail-element--nav-footer{background:var(--surface-100);border:1px solid var(--surface-200);border-radius:0 0 2px 2px}.prototype-thumbnail-element--nav-sidebar{background:var(--surface-50);border:1px solid var(--surface-200);border-radius:2px 0 0 2px}.prototype-thumbnail-element--content-area{background:var(--surface-ground);border:1.5px dashed var(--surface-300)}.prototype-thumbnail-element--command-form{background:var(--surface-0);border:1px solid var(--surface-300);background-image:repeating-linear-gradient(to bottom, transparent 0px, transparent 5px, var(--surface-100) 5px, var(--surface-100) 8px);background-position:0 4px;background-size:100% 12px}.prototype-preview-backdrop{z-index:1000;cursor:default;background:#00000073;justify-content:center;align-items:center;animation:.16s ease-out prototype-preview-fade;display:flex;position:fixed;inset:0}.prototype-preview-window{border:1px solid var(--surface-300);transform-origin:0 0;border-radius:8px;animation:.22s cubic-bezier(.2,.8,.2,1) prototype-preview-zoom;position:relative;overflow:hidden;box-shadow:0 24px 64px #00000073}.prototype-preview-window .prototype-thumbnail-title{font-size:13px}.prototype-preview-window .prototype-thumbnail-title-bar{gap:8px;padding:0 12px}.prototype-preview-close{z-index:1;width:28px;height:28px;color:var(--text-color-secondary);cursor:pointer;background:0 0;border:none;border-radius:50%;font-size:18px;line-height:1;position:absolute;top:6px;right:8px}.prototype-preview-close:hover{background:var(--surface-200);color:var(--text-color)}@keyframes prototype-preview-zoom{0%{transform:var(--prototype-preview-from,scale(.9));opacity:.4}to{opacity:1;transform:none}}@keyframes prototype-preview-fade{0%{background:0 0}to{background:#00000073}}@media (prefers-reduced-motion:reduce){.prototype-preview-backdrop,.prototype-preview-window{animation:none}}.prototype-editor-overlay-backdrop{z-index:50;opacity:0;pointer-events:auto;background:#0000008c;justify-content:center;align-items:center;transition:opacity .28s;display:flex;position:fixed;inset:0}.prototype-editor-overlay-backdrop--visible{opacity:1}.prototype-editor-overlay-content{opacity:0;border-radius:10px;flex-direction:column;transition:transform .28s cubic-bezier(.4,0,.2,1),opacity .28s;display:flex;position:fixed;top:50%;left:50%;overflow:hidden;transform:scale(.08);box-shadow:0 24px 80px #0000008c}.prototype-editor-overlay-content--visible{opacity:1;transform:scale(1)}.prototype-editor-overlay-content--closing{opacity:0;transform:scale(.08)}.prototype-editor-overlay-resize{z-index:10;position:absolute}.prototype-editor-overlay-resize--n{cursor:ns-resize;height:6px;top:0;left:8px;right:8px}.prototype-editor-overlay-resize--s{cursor:ns-resize;height:6px;bottom:0;left:8px;right:8px}.prototype-editor-overlay-resize--e{cursor:ew-resize;width:6px;top:8px;bottom:8px;right:0}.prototype-editor-overlay-resize--w{cursor:ew-resize;width:6px;top:8px;bottom:8px;left:0}.prototype-editor-overlay-resize--ne{cursor:nesw-resize;width:12px;height:12px;top:0;right:0}.prototype-editor-overlay-resize--nw{cursor:nwse-resize;width:12px;height:12px;top:0;left:0}.prototype-editor-overlay-resize--se{cursor:nwse-resize;width:12px;height:12px;bottom:0;right:0}.prototype-editor-overlay-resize--sw{cursor:nesw-resize;width:12px;height:12px;bottom:0;left:0}.prototype-editor-overlay-inspector{background:var(--cratis-surface-card);color:var(--cratis-text-color);border-left:1px solid var(--cratis-surface-border);box-shadow:var(--cratis-shadow-overlay);z-index:12;flex-direction:column;transition:transform .24s cubic-bezier(.4,0,.2,1);display:flex;position:fixed;top:0;bottom:0;right:0;transform:translate(100%)}.prototype-editor-overlay-inspector--open{transform:translate(0)}.prototype-layout-container{box-sizing:border-box;border:1px dashed var(--cratis-surface-border);border-radius:var(--cratis-border-radius);background:color-mix(in srgb, var(--cratis-surface-card) 60%, transparent);width:100%;height:100%;padding:8px;overflow:hidden}.prototype-layout-container--drag-over{border:2px dashed var(--cratis-primary-color)}.prototype-layout-container__item{box-sizing:border-box;flex:none}.prototype-layout-container__empty{border-radius:var(--cratis-border-radius);background:repeating-linear-gradient(45deg, transparent, transparent 6px, var(--cratis-surface-hover) 6px, var(--cratis-surface-hover) 12px);pointer-events:none;flex:auto;min-height:32px}
1
+ .prototype-window-traffic-light{box-sizing:border-box;background:0 0;border-radius:50%;width:12px;height:12px}.prototype-thumbnail{cursor:default;box-sizing:border-box;background:var(--surface-card);border:none;flex-direction:column;flex-shrink:0;padding:0;display:flex;position:relative;overflow:hidden}.prototype-thumbnail:is(button){cursor:pointer}.prototype-thumbnail-title-bar{border-bottom:1px solid var(--surface-200);background:var(--surface-50);flex-shrink:0;align-items:center;gap:3px;padding:0 5px;display:flex;position:relative}.prototype-thumbnail-title{text-align:center;color:var(--text-color-secondary);pointer-events:none;font-family:system-ui,sans-serif;font-size:8px;position:absolute;left:0;right:0}.prototype-thumbnail-body{background:var(--surface-ground);flex:1;position:relative;overflow:hidden}.prototype-thumbnail-canvas-scaler{position:absolute;top:0;left:0}.prototype-thumbnail-element{box-sizing:border-box;background:var(--surface-200);border:1px solid var(--surface-300);border-radius:2px;position:absolute}.prototype-thumbnail-element--button,.prototype-thumbnail-element--button-hot{background:var(--surface-200);border:1px solid var(--surface-300)}.prototype-thumbnail-element--button-hot{background:var(--primary-color);border-color:var(--primary-color);opacity:.7}.prototype-thumbnail-element--native{color:var(--text-color);text-align:center;justify-content:center;align-items:center;padding:2px 6px;font-family:system-ui,sans-serif;font-size:12px;display:flex;overflow:hidden}.prototype-thumbnail-element__label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.prototype-thumbnail-element--text-input{background:var(--surface-0);border:1px solid var(--surface-300)}.prototype-thumbnail-element--label{border-bottom:1px solid var(--surface-300);background:0 0}.prototype-thumbnail-element--checkbox,.prototype-thumbnail-element--radio,.prototype-thumbnail-element--dropdown{background:var(--surface-0);border:1px solid var(--surface-300)}.prototype-thumbnail-element--image{background:var(--surface-100);border:1px dashed var(--surface-300)}.prototype-thumbnail-element--panel{background:var(--surface-50);border:1px solid var(--surface-200)}.prototype-thumbnail-element--data-table{background:var(--surface-0);border:1px solid var(--surface-300)}.prototype-thumbnail-element--toolbar{background:var(--surface-100);border:1px solid var(--surface-200)}.prototype-thumbnail-element--kpi-card{background:var(--surface-100);border:1px solid var(--primary-300,var(--surface-300));border-radius:3px}.prototype-thumbnail-element--bar-chart{background:var(--surface-0);border:1px solid var(--surface-300);background-image:repeating-linear-gradient(to top, var(--primary-400,#7c6fe0) 0px, var(--primary-400,#7c6fe0) 60%, transparent 60%, transparent 100%);background-position:10% 0,35% 0,60% 0,85% 0;background-repeat:no-repeat;background-size:20% 100%}.prototype-thumbnail-element--line-chart{background:var(--surface-0);border:1px solid var(--surface-300)}.prototype-thumbnail-element--pie-chart{background:var(--surface-0);border:1px solid var(--surface-300);border-radius:50%}.prototype-thumbnail-element--progress-bar{background:var(--surface-100);border:1px solid var(--surface-300);background-image:linear-gradient(to right, var(--primary-400,#7c6fe0) 0%, var(--primary-400,#7c6fe0) 55%, transparent 55%)}.prototype-thumbnail-element--activity-feed{background:var(--surface-0);border:1px solid var(--surface-300);background-image:repeating-linear-gradient(to bottom, transparent 0px, transparent 3px, var(--surface-200) 3px, var(--surface-200) 4px);background-size:100% 8px}.prototype-thumbnail-element--nav-topbar{background:var(--surface-100);border:1px solid var(--surface-200);border-radius:2px 2px 0 0}.prototype-thumbnail-element--nav-footer{background:var(--surface-100);border:1px solid var(--surface-200);border-radius:0 0 2px 2px}.prototype-thumbnail-element--nav-sidebar{background:var(--surface-50);border:1px solid var(--surface-200);border-radius:2px 0 0 2px}.prototype-thumbnail-element--content-area{background:var(--surface-ground);border:1.5px dashed var(--surface-300)}.prototype-thumbnail-element--command-form{background:var(--surface-0);border:1px solid var(--surface-300);background-image:repeating-linear-gradient(to bottom, transparent 0px, transparent 5px, var(--surface-100) 5px, var(--surface-100) 8px);background-position:0 4px;background-size:100% 12px}.prototype-preview-backdrop{z-index:1000;cursor:default;background:#00000073;justify-content:center;align-items:center;animation:.16s ease-out prototype-preview-fade;display:flex;position:fixed;inset:0}.prototype-preview-window{border:1px solid var(--surface-300);transform-origin:0 0;border-radius:8px;animation:.22s cubic-bezier(.2,.8,.2,1) prototype-preview-zoom;position:relative;overflow:hidden;box-shadow:0 24px 64px #00000073}.prototype-preview-window .prototype-thumbnail-title{font-size:13px}.prototype-preview-window .prototype-thumbnail-title-bar{gap:8px;padding:0 12px}.prototype-preview-close{z-index:1;width:28px;height:28px;color:var(--text-color-secondary);cursor:pointer;background:0 0;border:none;border-radius:50%;font-size:18px;line-height:1;position:absolute;top:6px;right:8px}.prototype-preview-close:hover{background:var(--surface-200);color:var(--text-color)}@keyframes prototype-preview-zoom{0%{transform:var(--prototype-preview-from,scale(.9));opacity:.4}to{opacity:1;transform:none}}@keyframes prototype-preview-fade{0%{background:0 0}to{background:#00000073}}@media (prefers-reduced-motion:reduce){.prototype-preview-backdrop,.prototype-preview-window{animation:none}}.prototype-unrendered-element{box-sizing:border-box;border:1px solid var(--cratis-surface-border,var(--surface-300));border-radius:var(--cratis-border-radius,4px);background:var(--cratis-surface-hover,var(--surface-200));min-height:28px;color:var(--cratis-text-secondary-color,var(--text-color-secondary));text-overflow:ellipsis;white-space:nowrap;padding:4px 8px;font-size:12px;overflow:hidden}
2
2
  /*$vite$:1*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/scene",
3
- "version": "0.223.0",
3
+ "version": "0.223.1",
4
4
  "description": "Cratis Scene: renders Studio prototypes as thumbnails and previews.",
5
5
  "license": "MIT",
6
6
  "author": "Cratis",
@@ -9,14 +9,11 @@
9
9
  "main": "./dist/index.js",
10
10
  "types": "./dist/index.d.ts",
11
11
  "scripts": {
12
- "dev": "yarn g:dev",
13
- "build": "yarn g:build",
14
12
  "lint": "yarn g:lint",
15
13
  "lint:ci": "yarn g:lint:ci",
16
14
  "test": "yarn g:test",
17
15
  "test:watch": "yarn g:test:watch",
18
16
  "compile": "yarn g:compile",
19
- "preview": "yarn g:preview",
20
17
  "up": "yarn g:up",
21
18
  "dev:storybook": "yarn g:dev:storybook --port 6010",
22
19
  "build-storybook": "yarn g:build:storybook",
@@ -32,10 +29,6 @@
32
29
  "types": "./dist/Prototypes/index.d.ts",
33
30
  "import": "./dist/Prototypes/index.js"
34
31
  },
35
- "./ScreenEditor": {
36
- "types": "./dist/ScreenEditor/index.d.ts",
37
- "import": "./dist/ScreenEditor/index.js"
38
- },
39
32
  "./styles": "./dist/scene.css"
40
33
  },
41
34
  "files": [
@@ -54,10 +47,6 @@
54
47
  "types": "./dist/Prototypes/index.d.ts",
55
48
  "import": "./dist/Prototypes/index.js"
56
49
  },
57
- "./ScreenEditor": {
58
- "types": "./dist/ScreenEditor/index.d.ts",
59
- "import": "./dist/ScreenEditor/index.js"
60
- },
61
50
  "./styles": "./dist/scene.css"
62
51
  }
63
52
  },
@@ -1,23 +0,0 @@
1
- import React, { type ReactNode } from 'react';
2
- export declare const inspectorWidth = 360;
3
- export interface OverlaySize {
4
- width: number;
5
- height: number;
6
- }
7
- export interface PrototypeOverlayFrameState {
8
- size: OverlaySize;
9
- setSize: (size: OverlaySize) => void;
10
- isInspectorOpen: boolean;
11
- toggleInspector: () => void;
12
- close: () => void;
13
- }
14
- export interface PrototypeOverlayFrameProps {
15
- sourceRect: DOMRect;
16
- initialSize?: OverlaySize;
17
- centerOffsetX?: number;
18
- children: (state: PrototypeOverlayFrameState) => ReactNode;
19
- renderInspector?: (state: PrototypeOverlayFrameState) => ReactNode;
20
- canClose?: (size: OverlaySize) => Promise<boolean>;
21
- onClosed: (size: OverlaySize) => void;
22
- }
23
- export declare const PrototypeOverlayFrame: ({ sourceRect, initialSize, centerOffsetX, children, renderInspector, canClose, onClosed }: PrototypeOverlayFrameProps) => React.JSX.Element;
@@ -1,14 +0,0 @@
1
- export interface OverlayViewport {
2
- width: number;
3
- height: number;
4
- }
5
- export interface FittedOverlay {
6
- width: number;
7
- height: number;
8
- offsetX: number;
9
- }
10
- export declare const overlayMargin = 8;
11
- export declare function fitOverlay(size: {
12
- width: number;
13
- height: number;
14
- }, viewport: OverlayViewport, requestedOffsetX: number): FittedOverlay;
@@ -1,8 +0,0 @@
1
- export declare enum LayoutArrangement {
2
- Row = "row",
3
- Column = "column",
4
- Grid = "grid",
5
- Wrap = "wrap",
6
- Freeform = "freeform",
7
- Grouping = "grouping"
8
- }
@@ -1,10 +0,0 @@
1
- import type { ComponentType } from 'react';
2
- import type { LayoutArrangement } from './LayoutArrangement';
3
- export interface LayoutContainerDescriptor {
4
- type: string;
5
- name: string;
6
- arrangement: LayoutArrangement;
7
- icon?: ComponentType<{
8
- className?: string;
9
- }>;
10
- }
@@ -1,7 +0,0 @@
1
- import type { PrototypeComponentRenderProps } from '../../../IComponent';
2
- import { LayoutArrangement } from './LayoutArrangement';
3
- export interface LayoutContainerSurfaceProps extends PrototypeComponentRenderProps {
4
- arrangement: LayoutArrangement;
5
- }
6
- export declare const LayoutContainerSurface: ({ component, arrangement, isDragOver }: LayoutContainerSurfaceProps) => import("react").JSX.Element;
7
- export { LayoutArrangement };
@@ -1,4 +0,0 @@
1
- import type { CSSProperties } from 'react';
2
- import { LayoutArrangement } from './LayoutArrangement';
3
- export declare const arrangementStyle: (arrangement: LayoutArrangement) => CSSProperties;
4
- export declare const isFlowArrangement: (arrangement: LayoutArrangement) => boolean;
@@ -1,5 +0,0 @@
1
- import type { PrototypeComponentConstructor } from '../../../IComponent';
2
- import type { LayoutContainerDescriptor } from './LayoutContainerDescriptor';
3
- export declare const layoutContainerLibrary = "StudioLayout";
4
- export declare const layoutContainerCategory = "Layout";
5
- export declare const createLayoutContainerComponent: (descriptor: LayoutContainerDescriptor) => PrototypeComponentConstructor;
@@ -1,5 +0,0 @@
1
- export * from './LayoutArrangement';
2
- export * from './LayoutContainerDescriptor';
3
- export * from './arrangementStyle';
4
- export * from './createLayoutContainerComponent';
5
- export * from './registerLayoutContainers';
@@ -1,3 +0,0 @@
1
- import type { PrototypeComponentLibraryDefinition } from '../editorTypes';
2
- import type { LayoutContainerDescriptor } from './LayoutContainerDescriptor';
3
- export declare const registerLayoutContainers: (descriptors: LayoutContainerDescriptor[]) => PrototypeComponentLibraryDefinition;
@@ -1,2 +0,0 @@
1
- export * from '../Prototypes/Editor/PrototypeOverlayFrame';
2
- export * from '../Prototypes/Editor/layoutContainers';
@@ -1,235 +0,0 @@
1
- import { c as J, u as K, x as Q } from "../Scene-DaQtzf1e.js";
2
- import { i as Z, r as tt, t as et } from "../renderPrototypeElement-Xm7OIVPs.js";
3
- import { useCallback as f, useEffect as X, useRef as E, useState as v } from "react";
4
- import { jsx as w, jsxs as z } from "react/jsx-runtime";
5
- function ot(t, r, n) {
6
- const i = Math.max(1, Math.min(t.width, r.width - 16)), h = Math.max(1, Math.min(t.height, r.height - 16)), a = Math.max(0, (r.width - i) / 2 - 8);
7
- return {
8
- width: i,
9
- height: h,
10
- offsetX: Math.min(a, Math.max(-a, n))
11
- };
12
- }
13
- var L = 900, $ = 640, rt = 320, nt = 300, yt = 360, it = (t) => t ? {
14
- width: t.width > 0 ? t.width : L,
15
- height: t.height > 0 ? t.height : $
16
- } : {
17
- width: L,
18
- height: $
19
- }, at = [
20
- "n",
21
- "s",
22
- "e",
23
- "w",
24
- "ne",
25
- "nw",
26
- "se",
27
- "sw"
28
- ], gt = ({ sourceRect: t, initialSize: r, centerOffsetX: n = 0, children: i, renderInspector: h, canClose: a, onClosed: l }) => {
29
- const [s, y] = v("entering"), [p, H] = v(() => it(r)), C = E(p);
30
- C.current = p;
31
- const [g, k] = v(!1), [P, _] = v(() => ({
32
- width: window.innerWidth,
33
- height: window.innerHeight
34
- }));
35
- X(() => {
36
- const e = () => _({
37
- width: window.innerWidth,
38
- height: window.innerHeight
39
- });
40
- return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
41
- }, []);
42
- const O = f(() => k((e) => !e), []), b = E(null);
43
- X(() => {
44
- const e = requestAnimationFrame(() => y("visible"));
45
- return () => cancelAnimationFrame(e);
46
- }, []);
47
- const I = f(async () => {
48
- a && !await a(C.current) || (y("closing"), setTimeout(() => l(C.current), 300));
49
- }, [a, l]), Y = (e, o) => {
50
- o.stopPropagation(), o.preventDefault(), b.current = {
51
- direction: e,
52
- startX: o.clientX,
53
- startY: o.clientY,
54
- startWidth: p.width,
55
- startHeight: p.height
56
- }, o.target.setPointerCapture(o.pointerId);
57
- }, G = f((e) => {
58
- const o = b.current;
59
- if (!o) return;
60
- const { direction: m } = o;
61
- let F = o.startWidth, T = o.startHeight;
62
- if (m.includes("e") || m.includes("w")) {
63
- const M = m.includes("e") ? e.clientX - o.startX : o.startX - e.clientX;
64
- F = Math.max(rt, o.startWidth + M * 2);
65
- }
66
- if (m.includes("s") || m.includes("n")) {
67
- const M = m.includes("s") ? e.clientY - o.startY : o.startY - e.clientY;
68
- T = Math.max(nt, o.startHeight + M * 2);
69
- }
70
- H({
71
- width: F,
72
- height: T
73
- });
74
- }, []), N = f(() => {
75
- b.current = null;
76
- }, []), c = ot(p, P, n - (g ? 360 / 2 : 0)), S = c.offsetX, W = {
77
- size: p,
78
- setSize: H,
79
- isInspectorOpen: g,
80
- toggleInspector: O,
81
- close: () => {
82
- I();
83
- }
84
- }, R = t.left + t.width / 2, j = t.top + t.height / 2, U = P.width / 2 + S - c.width / 2, B = P.height / 2 - c.height / 2, q = `${R - U}px ${j - B}px`, A = [
85
- "prototype-editor-overlay-content",
86
- s === "visible" ? "prototype-editor-overlay-content--visible" : "",
87
- s === "closing" ? "prototype-editor-overlay-content--closing" : ""
88
- ].join(" "), V = ["prototype-editor-overlay-backdrop", s === "visible" ? "prototype-editor-overlay-backdrop--visible" : ""].join(" ");
89
- return /* @__PURE__ */ z("div", {
90
- className: V,
91
- "data-testid": "studio-screen-editor-backdrop",
92
- onClick: I,
93
- children: [/* @__PURE__ */ z("div", {
94
- className: A,
95
- "data-testid": "studio-screen-editor-frame",
96
- style: {
97
- transformOrigin: q,
98
- width: c.width,
99
- height: c.height,
100
- marginLeft: -(c.width / 2) + S,
101
- marginTop: -(c.height / 2)
102
- },
103
- onClick: (e) => e.stopPropagation(),
104
- onPointerDown: (e) => e.stopPropagation(),
105
- children: [s === "visible" && at.map((e) => /* @__PURE__ */ w("div", {
106
- className: `prototype-editor-overlay-resize prototype-editor-overlay-resize--${e}`,
107
- onPointerDown: (o) => Y(e, o),
108
- onPointerMove: G,
109
- onPointerUp: N,
110
- onPointerCancel: N
111
- }, e)), i(W)]
112
- }), h && /* @__PURE__ */ w("aside", {
113
- className: `prototype-editor-overlay-inspector${g && s === "visible" ? " prototype-editor-overlay-inspector--open" : ""}`,
114
- style: { width: 360 },
115
- "aria-hidden": !g,
116
- inert: !g,
117
- onClick: (e) => e.stopPropagation(),
118
- onPointerDown: (e) => e.stopPropagation(),
119
- children: h(W)
120
- })]
121
- });
122
- }, d = /* @__PURE__ */ (function(t) {
123
- return t.Row = "row", t.Column = "column", t.Grid = "grid", t.Wrap = "wrap", t.Freeform = "freeform", t.Grouping = "grouping", t;
124
- })({}), x = 8, st = (t) => {
125
- switch (t) {
126
- case d.Row:
127
- return {
128
- display: "flex",
129
- flexDirection: "row",
130
- gap: x
131
- };
132
- case d.Wrap:
133
- return {
134
- display: "flex",
135
- flexDirection: "row",
136
- flexWrap: "wrap",
137
- gap: x
138
- };
139
- case d.Grid:
140
- return {
141
- display: "grid",
142
- gridTemplateColumns: "repeat(auto-fill, minmax(120px, 1fr))",
143
- gap: x
144
- };
145
- case d.Freeform:
146
- return { position: "relative" };
147
- case d.Column:
148
- case d.Grouping:
149
- return {
150
- display: "flex",
151
- flexDirection: "column",
152
- gap: x
153
- };
154
- }
155
- }, lt = (t) => t !== d.Freeform, ct = ({ component: t, arrangement: r, isDragOver: n }) => {
156
- const i = (t.children ?? []).filter(Boolean).map(J), h = lt(r);
157
- return /* @__PURE__ */ z("div", {
158
- className: `prototype-layout-container${n ? " prototype-layout-container--drag-over" : ""}`,
159
- "data-layout-arrangement": r,
160
- style: st(r),
161
- children: [i.length === 0 && /* @__PURE__ */ w("div", {
162
- className: "prototype-layout-container__empty",
163
- "aria-hidden": "true"
164
- }), i.map((a) => {
165
- const l = Z(a), s = tt(a), y = {
166
- width: l.width > 0 ? l.width : void 0,
167
- height: l.height > 0 ? l.height : void 0
168
- };
169
- return /* @__PURE__ */ w("div", {
170
- className: "prototype-layout-container__item",
171
- style: h ? y : {
172
- position: "absolute",
173
- left: s.x,
174
- top: s.y,
175
- ...y
176
- },
177
- children: et(a)
178
- }, String(a.id));
179
- })]
180
- });
181
- }, u = "StudioLayout", D = "Layout", dt = (t) => {
182
- class r extends Q {
183
- componentName = t.type;
184
- category = D;
185
- library = u;
186
- initialSize = {
187
- width: 260,
188
- height: 140
189
- };
190
- resizeBehavior = "both";
191
- acceptsChildren = !0;
192
- get toolbarIcon() {
193
- return t.icon;
194
- }
195
- RenderPrototype(i) {
196
- return /* @__PURE__ */ w(ct, {
197
- ...i,
198
- arrangement: t.arrangement
199
- });
200
- }
201
- }
202
- return r;
203
- }, wt = (t) => {
204
- const r = {};
205
- for (const n of t) {
206
- const i = dt(n);
207
- r[n.type] = i, r[`${u}.${n.type}`] = i;
208
- }
209
- return K(u, r), {
210
- name: u,
211
- bundlePath: "",
212
- categories: [{
213
- name: D,
214
- components: t.map((n) => ({
215
- name: n.name,
216
- category: D,
217
- library: u,
218
- bundlePath: "",
219
- type: `${u}.${n.type}`,
220
- component: new r[n.type]()
221
- }))
222
- }]
223
- };
224
- };
225
- export {
226
- d as LayoutArrangement,
227
- gt as PrototypeOverlayFrame,
228
- st as arrangementStyle,
229
- dt as createLayoutContainerComponent,
230
- yt as inspectorWidth,
231
- lt as isFlowArrangement,
232
- D as layoutContainerCategory,
233
- u as layoutContainerLibrary,
234
- wt as registerLayoutContainers
235
- };
@@ -1,58 +0,0 @@
1
- import { c as p } from "./Scene-DaQtzf1e.js";
2
- import { jsx as s } from "react/jsx-runtime";
3
- var y = (n) => {
4
- const e = n;
5
- if (e.position && typeof e.position.x == "number") return {
6
- x: e.position.x,
7
- y: e.position.y ?? 0
8
- };
9
- const t = e.properties?.canvas ?? {};
10
- return {
11
- x: t.x ?? 0,
12
- y: t.y ?? 0
13
- };
14
- }, d = (n) => {
15
- const e = n;
16
- return e.size && typeof e.size.width == "number" ? {
17
- width: e.size.width,
18
- height: e.size.height ?? 0
19
- } : {
20
- width: e.width ?? 0,
21
- height: e.height ?? 0
22
- };
23
- }, a = (n) => {
24
- const e = n;
25
- if (typeof e.componentName != "string" || e.componentName.includes(".")) return;
26
- const t = e.properties && typeof e.properties == "object" ? e.properties : {}, o = [
27
- t.label,
28
- t.text,
29
- t.title,
30
- e.componentName
31
- ].find((r) => typeof r == "string" && r.length > 0);
32
- return typeof o == "string" ? {
33
- type: e.componentName,
34
- label: o
35
- } : void 0;
36
- }, i = (n) => {
37
- const e = n, t = [e.name, e.componentName].find((o) => typeof o == "string" && o.length > 0);
38
- return typeof t == "string" ? t : "";
39
- }, l = (n) => {
40
- const e = p(n);
41
- if ("RenderPrototype" in e && typeof e.RenderPrototype == "function") return e.RenderPrototype({
42
- component: e,
43
- label: e.label ?? i(e)
44
- });
45
- const t = a(e);
46
- return /* @__PURE__ */ s("div", {
47
- className: "prototype-unrendered-element",
48
- "data-prototype-element": t?.type,
49
- children: t?.label ?? i(e)
50
- });
51
- };
52
- export {
53
- a,
54
- d as i,
55
- i as n,
56
- y as r,
57
- l as t
58
- };