@floegence/floe-webapp-core 0.36.1 → 0.36.3

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,8 +1,16 @@
1
1
  import { type JSX } from 'solid-js';
2
- import type { WorkbenchWidgetDefinition, WorkbenchWidgetItem } from './types';
2
+ import type { WorkbenchWidgetDefinition, WorkbenchWidgetItem, WorkbenchWidgetType } from './types';
3
3
  export interface WorkbenchWidgetProps {
4
4
  definition: WorkbenchWidgetDefinition;
5
- item: WorkbenchWidgetItem;
5
+ widgetId: string;
6
+ widgetTitle: string;
7
+ widgetType: WorkbenchWidgetType;
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ zIndex: number;
13
+ itemSnapshot: () => WorkbenchWidgetItem;
6
14
  selected: boolean;
7
15
  optimisticFront: boolean;
8
16
  topZIndex: number;
@@ -1,35 +1,35 @@
1
- import { insert as m, createComponent as f, memo as B, effect as G, setAttribute as N, setStyleProperty as v, template as A, delegateEvents as O } from "solid-js/web";
2
- import { createSignal as R, onCleanup as T, untrack as I, createMemo as H } from "solid-js";
1
+ import { insert as u, createComponent as v, memo as E, effect as B, setAttribute as G, setStyleProperty as m, template as A, delegateEvents as N } from "solid-js/web";
2
+ import { createSignal as R, onCleanup as O, untrack as I, createMemo as H } from "solid-js";
3
3
  import { startHotInteraction as P } from "../../utils/hotInteraction.js";
4
4
  import { GripVertical as q, X as V } from "../icons/index.js";
5
- var Z = /* @__PURE__ */ A('<article class=workbench-widget><header class=workbench-widget__header><button type=button class=workbench-widget__drag aria-label="Drag widget"data-floe-canvas-interactive=true></button><div class=workbench-widget__title-area><span class=workbench-widget__title></span></div><button type=button class=workbench-widget__close aria-label="Remove widget"data-floe-canvas-interactive=true></button></header><div class=workbench-widget__body data-floe-canvas-interactive=true>'), j = /* @__PURE__ */ A('<div class=workbench-widget__resize aria-label="Resize widget"data-floe-canvas-interactive=true><svg class=workbench-widget__resize-glyph viewBox="0 0 12 12"aria-hidden=true><path d="M12 0 L0 12"></path><path d="M12 4 L4 12"></path><path d="M12 8 L8 12">');
5
+ var Z = /* @__PURE__ */ A('<article class=workbench-widget data-floe-dialog-surface-host=true><header class=workbench-widget__header><button type=button class=workbench-widget__drag aria-label="Drag widget"data-floe-canvas-interactive=true></button><div class=workbench-widget__title-area><span class=workbench-widget__title></span></div><button type=button class=workbench-widget__close aria-label="Remove widget"data-floe-canvas-interactive=true></button></header><div class=workbench-widget__body data-floe-canvas-interactive=true>'), j = /* @__PURE__ */ A('<div class=workbench-widget__resize aria-label="Resize widget"data-floe-canvas-interactive=true><svg class=workbench-widget__resize-glyph viewBox="0 0 12 12"aria-hidden=true><path d="M12 0 L0 12"></path><path d="M12 4 L4 12"></path><path d="M12 8 L8 12">');
6
6
  const J = 220, K = 160;
7
7
  function et(e) {
8
- const [u, x] = R(null), [b, C] = R(null);
9
- let g, w;
10
- T(() => {
11
- g?.abort(), g = void 0, w?.abort(), w = void 0, I(u)?.stopInteraction(), I(b)?.stopInteraction();
8
+ const [b, x] = R(null), [f, C] = R(null);
9
+ let h, w;
10
+ O(() => {
11
+ h?.abort(), h = void 0, w?.abort(), w = void 0, I(b)?.stopInteraction(), I(f)?.stopInteraction();
12
12
  });
13
- const M = () => u() !== null, _ = () => b() !== null, k = H(() => {
14
- const i = u();
13
+ const M = () => b() !== null, k = () => f() !== null, y = H(() => {
14
+ const i = b();
15
15
  return i ? {
16
16
  x: i.worldX,
17
17
  y: i.worldY
18
18
  } : {
19
- x: e.item.x,
20
- y: e.item.y
19
+ x: e.x,
20
+ y: e.y
21
21
  };
22
- }), y = H(() => {
23
- const i = b();
22
+ }), _ = H(() => {
23
+ const i = f();
24
24
  return i ? {
25
25
  width: i.width,
26
26
  height: i.height
27
27
  } : {
28
- width: e.item.width,
29
- height: e.item.height
28
+ width: e.width,
29
+ height: e.height
30
30
  };
31
31
  }), $ = (i) => {
32
- const o = I(u);
32
+ const o = I(b);
33
33
  if (!o) return;
34
34
  const a = {
35
35
  x: o.worldX,
@@ -37,11 +37,11 @@ function et(e) {
37
37
  }, r = {
38
38
  x: o.startWorldX,
39
39
  y: o.startWorldY
40
- }, d = i && (Math.abs(a.x - r.x) > 1 || Math.abs(a.y - r.y) > 1);
41
- e.onCommitFront(e.item.id), d && e.onCommitMove(e.item.id, a), o.stopInteraction(), x(null), g?.abort(), g = void 0;
40
+ }, l = i && (Math.abs(a.x - r.x) > 1 || Math.abs(a.y - r.y) > 1);
41
+ e.onCommitFront(e.widgetId), l && e.onCommitMove(e.widgetId, a), o.stopInteraction(), x(null), h?.abort(), h = void 0;
42
42
  }, F = (i) => {
43
43
  if (i.button !== 0 || e.locked) return;
44
- i.preventDefault(), i.stopPropagation(), g?.abort(), e.onStartOptimisticFront(e.item.id);
44
+ i.preventDefault(), i.stopPropagation(), h?.abort(), e.onStartOptimisticFront(e.widgetId);
45
45
  const o = P({
46
46
  kind: "drag",
47
47
  cursor: "grabbing"
@@ -50,10 +50,10 @@ function et(e) {
50
50
  pointerId: i.pointerId,
51
51
  startClientX: i.clientX,
52
52
  startClientY: i.clientY,
53
- startWorldX: e.item.x,
54
- startWorldY: e.item.y,
55
- worldX: e.item.x,
56
- worldY: e.item.y,
53
+ startWorldX: e.x,
54
+ startWorldY: e.y,
55
+ worldX: e.x,
56
+ worldY: e.y,
57
57
  moved: !1,
58
58
  scale: a,
59
59
  stopInteraction: o
@@ -61,39 +61,39 @@ function et(e) {
61
61
  const r = (t) => {
62
62
  x((n) => {
63
63
  if (!n || n.pointerId !== t.pointerId) return n;
64
- const c = n.startWorldX + (t.clientX - n.startClientX) / n.scale, h = n.startWorldY + (t.clientY - n.startClientY) / n.scale;
64
+ const c = n.startWorldX + (t.clientX - n.startClientX) / n.scale, g = n.startWorldY + (t.clientY - n.startClientY) / n.scale;
65
65
  return {
66
66
  ...n,
67
67
  worldX: c,
68
- worldY: h,
69
- moved: n.moved || Math.abs(c - n.startWorldX) > 2 || Math.abs(h - n.startWorldY) > 2
68
+ worldY: g,
69
+ moved: n.moved || Math.abs(c - n.startWorldX) > 2 || Math.abs(g - n.startWorldY) > 2
70
70
  };
71
71
  });
72
- }, d = (t) => {
72
+ }, l = (t) => {
73
73
  t.pointerId === i.pointerId && $(!0);
74
74
  }, s = (t) => {
75
75
  t.pointerId === i.pointerId && $(!1);
76
- }, l = new AbortController();
77
- g = l, window.addEventListener("pointermove", r, {
78
- signal: l.signal
79
- }), window.addEventListener("pointerup", d, {
76
+ }, d = new AbortController();
77
+ h = d, window.addEventListener("pointermove", r, {
78
+ signal: d.signal
79
+ }), window.addEventListener("pointerup", l, {
80
80
  once: !0,
81
- signal: l.signal
81
+ signal: d.signal
82
82
  }), window.addEventListener("pointercancel", s, {
83
83
  once: !0,
84
- signal: l.signal
84
+ signal: d.signal
85
85
  });
86
- }, X = (i) => {
87
- const o = I(b);
86
+ }, S = (i) => {
87
+ const o = I(f);
88
88
  if (!o) return;
89
89
  const a = {
90
90
  width: o.width,
91
91
  height: o.height
92
92
  }, r = Math.abs(o.width - o.startWidth) > 1 || Math.abs(o.height - o.startHeight) > 1;
93
- i && r && e.onCommitResize(e.item.id, a), o.stopInteraction(), C(null), w?.abort(), w = void 0;
94
- }, E = (i) => {
93
+ i && r && e.onCommitResize(e.widgetId, a), o.stopInteraction(), C(null), w?.abort(), w = void 0;
94
+ }, T = (i) => {
95
95
  if (i.button !== 0 || e.locked) return;
96
- i.preventDefault(), i.stopPropagation(), w?.abort(), e.onStartOptimisticFront(e.item.id);
96
+ i.preventDefault(), i.stopPropagation(), w?.abort(), e.onStartOptimisticFront(e.widgetId);
97
97
  const o = P({
98
98
  kind: "drag",
99
99
  cursor: "nwse-resize"
@@ -102,77 +102,77 @@ function et(e) {
102
102
  pointerId: i.pointerId,
103
103
  startClientX: i.clientX,
104
104
  startClientY: i.clientY,
105
- startWidth: e.item.width,
106
- startHeight: e.item.height,
107
- width: e.item.width,
108
- height: e.item.height,
105
+ startWidth: e.width,
106
+ startHeight: e.height,
107
+ width: e.width,
108
+ height: e.height,
109
109
  scale: a,
110
110
  stopInteraction: o
111
111
  });
112
112
  const r = (t) => {
113
113
  C((n) => {
114
114
  if (!n || n.pointerId !== t.pointerId) return n;
115
- const c = Math.max(J, n.startWidth + (t.clientX - n.startClientX) / n.scale), h = Math.max(K, n.startHeight + (t.clientY - n.startClientY) / n.scale);
115
+ const c = Math.max(J, n.startWidth + (t.clientX - n.startClientX) / n.scale), g = Math.max(K, n.startHeight + (t.clientY - n.startClientY) / n.scale);
116
116
  return {
117
117
  ...n,
118
118
  width: c,
119
- height: h
119
+ height: g
120
120
  };
121
121
  });
122
- }, d = (t) => {
123
- t.pointerId === i.pointerId && X(!0);
122
+ }, l = (t) => {
123
+ t.pointerId === i.pointerId && S(!0);
124
124
  }, s = (t) => {
125
- t.pointerId === i.pointerId && X(!1);
126
- }, l = new AbortController();
127
- w = l, window.addEventListener("pointermove", r, {
128
- signal: l.signal
129
- }), window.addEventListener("pointerup", d, {
125
+ t.pointerId === i.pointerId && S(!1);
126
+ }, d = new AbortController();
127
+ w = d, window.addEventListener("pointermove", r, {
128
+ signal: d.signal
129
+ }), window.addEventListener("pointerup", l, {
130
130
  once: !0,
131
- signal: l.signal
131
+ signal: d.signal
132
132
  }), window.addEventListener("pointercancel", s, {
133
133
  once: !0,
134
- signal: l.signal
134
+ signal: d.signal
135
135
  });
136
136
  };
137
137
  return (() => {
138
- var i = Z(), o = i.firstChild, a = o.firstChild, r = a.nextSibling, d = r.firstChild, s = r.nextSibling, l = o.nextSibling;
138
+ var i = Z(), o = i.firstChild, a = o.firstChild, r = a.nextSibling, l = r.firstChild, s = r.nextSibling, d = o.nextSibling;
139
139
  return i.$$click = () => {
140
- e.onSelect(e.item.id), e.onCommitFront(e.item.id);
140
+ e.onSelect(e.widgetId), e.onCommitFront(e.widgetId);
141
141
  }, i.$$contextmenu = (t) => {
142
- t.preventDefault(), t.stopPropagation(), e.onContextMenu(t, e.item);
143
- }, a.$$pointerdown = F, m(a, f(q, {
142
+ t.preventDefault(), t.stopPropagation(), e.onContextMenu(t, e.itemSnapshot());
143
+ }, a.$$pointerdown = F, u(a, v(q, {
144
144
  class: "w-3.5 h-3.5"
145
- })), m(r, () => {
145
+ })), u(r, () => {
146
146
  const t = e.definition.icon;
147
- return f(t, {
147
+ return v(t, {
148
148
  class: "w-3.5 h-3.5"
149
149
  });
150
- }, d), m(d, () => e.item.title), s.$$click = (t) => {
151
- t.stopPropagation(), t.preventDefault(), e.onRequestDelete(e.item.id);
152
- }, s.$$pointerdown = (t) => t.stopPropagation(), m(s, f(V, {
150
+ }, l), u(l, () => e.widgetTitle), s.$$click = (t) => {
151
+ t.stopPropagation(), t.preventDefault(), e.onRequestDelete(e.widgetId);
152
+ }, s.$$pointerdown = (t) => t.stopPropagation(), u(s, v(V, {
153
153
  class: "w-3 h-3"
154
- })), m(l, () => {
154
+ })), u(d, () => {
155
155
  const t = e.definition.body;
156
- return f(t, {
156
+ return v(t, {
157
157
  get widgetId() {
158
- return e.item.id;
158
+ return e.widgetId;
159
159
  },
160
160
  get title() {
161
- return e.item.title;
161
+ return e.widgetTitle;
162
162
  },
163
163
  get type() {
164
- return e.item.type;
164
+ return e.widgetType;
165
165
  }
166
166
  });
167
- }), m(i, (() => {
168
- var t = B(() => !!e.locked);
167
+ }), u(i, (() => {
168
+ var t = E(() => !!e.locked);
169
169
  return () => t() ? null : (() => {
170
170
  var n = j();
171
- return n.$$pointerdown = E, n;
171
+ return n.$$pointerdown = T, n;
172
172
  })();
173
- })(), null), G((t) => {
174
- var n = !!e.selected, c = !!M(), h = !!_(), z = !!e.filtered, S = e.item.id, Y = `translate(${k().x}px, ${k().y}px)`, W = `${y().width}px`, L = `${y().height}px`, D = M() || _() || e.optimisticFront ? `${e.topZIndex + 1}` : `${e.item.z_index}`;
175
- return n !== t.e && i.classList.toggle("is-selected", t.e = n), c !== t.t && i.classList.toggle("is-dragging", t.t = c), h !== t.a && i.classList.toggle("is-resizing", t.a = h), z !== t.o && i.classList.toggle("is-filtered-out", t.o = z), S !== t.i && N(i, "data-floe-workbench-widget-id", t.i = S), Y !== t.n && v(i, "transform", t.n = Y), W !== t.s && v(i, "width", t.s = W), L !== t.h && v(i, "height", t.h = L), D !== t.r && v(i, "z-index", t.r = D), t;
173
+ })(), null), B((t) => {
174
+ var n = !!e.selected, c = !!M(), g = !!k(), X = !!e.filtered, z = e.widgetId, Y = `translate(${y().x}px, ${y().y}px)`, W = `${_().width}px`, L = `${_().height}px`, D = M() || k() || e.optimisticFront ? `${e.topZIndex + 1}` : `${e.zIndex}`;
175
+ return n !== t.e && i.classList.toggle("is-selected", t.e = n), c !== t.t && i.classList.toggle("is-dragging", t.t = c), g !== t.a && i.classList.toggle("is-resizing", t.a = g), X !== t.o && i.classList.toggle("is-filtered-out", t.o = X), z !== t.i && G(i, "data-floe-workbench-widget-id", t.i = z), Y !== t.n && m(i, "transform", t.n = Y), W !== t.s && m(i, "width", t.s = W), L !== t.h && m(i, "height", t.h = L), D !== t.r && m(i, "z-index", t.r = D), t;
176
176
  }, {
177
177
  e: void 0,
178
178
  t: void 0,
@@ -186,7 +186,7 @@ function et(e) {
186
186
  }), i;
187
187
  })();
188
188
  }
189
- O(["contextmenu", "click", "pointerdown"]);
189
+ N(["contextmenu", "click", "pointerdown"]);
190
190
  export {
191
191
  et as WorkbenchWidget
192
192
  };