@stackmango/graff 0.1.10 → 0.1.11

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/js/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as v from "react";
2
- import $, { useMemo as En, useCallback as Mt, createContext as Ya, isValidElement as ga, PureComponent as Ka, Component as Ga, cloneElement as _i, Children as yO, forwardRef as vO, useContext as mx, useRef as vo, useState as xO, useEffect as Fn, useLayoutEffect as wO, useReducer as xo } from "react";
2
+ import $, { useMemo as En, useCallback as Mt, createContext as Ya, isValidElement as ga, PureComponent as Ka, Component as Ga, cloneElement as _i, Children as yO, forwardRef as vO, useContext as mx, useRef as vo, useReducer as xo, useEffect as Fn, useState as xO, useLayoutEffect as wO } from "react";
3
3
  import * as SO from "react-dom";
4
4
  import vi from "react-dom";
5
5
  import { useSearchParams as OO } from "react-router-dom";
@@ -41839,7 +41839,7 @@ Ol.extend(lz);
41839
41839
  Ol.extend(nz);
41840
41840
  Ol.extend(pz);
41841
41841
  Ol.extend(bz);
41842
- const Zz = {
41842
+ const Jz = {
41843
41843
  dropdown: {
41844
41844
  component: bx,
41845
41845
  reducer: vk
@@ -42061,229 +42061,7 @@ const Zz = {
42061
42061
  }
42062
42062
  ) : null
42063
42063
  ] }) });
42064
- }, xz = Ya(null), Jz = (e) => {
42065
- const t = vo(null), [n, r] = xO(!1), a = vo(null), [i, s] = OO(), { assets: l, view: c, interaction: u, config: d } = En(() => e.state, [e.state]), f = vo(null), h = Mt((T) => {
42066
- t.current = T;
42067
- }, []), b = Mt((T, I) => {
42068
- f.current = setInterval(() => {
42069
- c?.dispatch?.({
42070
- type: "move-document",
42071
- payload: {
42072
- speed: 3.5,
42073
- direction: ot.getScaledVector(T, -1)
42074
- }
42075
- }), I.type == "node" && c.dispatch({
42076
- type: "move-node",
42077
- payload: {
42078
- nodeId: I.id,
42079
- motionVector: ot.getScaledVector(T, 3.5)
42080
- }
42081
- });
42082
- }, 8);
42083
- }, []), m = Mt(() => {
42084
- f.current && (clearInterval(f.current), f.current = null);
42085
- }, []), p = Mt((T) => {
42086
- if (T.detail && T.detail.dragElement) {
42087
- const I = a.current?.getBoundingClientRect(), F = T.detail.currentDragPosition.x > d.data.documentBoundaryThickness && T.detail.currentDragPosition.x < I.width - d.data.documentBoundaryThickness && T.detail.currentDragPosition.y > d.data.documentBoundaryThickness && T.detail.currentDragPosition.y < I.height - d.data.documentBoundaryThickness;
42088
- !F && !f.current ? b(T.detail.dragVector, T.detail.dragElement) : F && f.current && m();
42089
- }
42090
- }, [d.data.documentBoundaryThickness, d.data.documentDimension]), g = Mt((T) => {
42091
- T.detail && T.detail.dragElement && (console.log("Moving Node"), T.detail.dragElement.type == "node" && (c.dispatch({
42092
- type: "move-node",
42093
- payload: {
42094
- nodeId: T.detail.dragElement.id,
42095
- motionVector: T.detail.dragVector
42096
- }
42097
- }), Object.keys(l.data.connections).forEach((I) => {
42098
- const F = l.data.connections[I].from.split("/")[0], P = l.data.connections[I].to.split("/")[0];
42099
- F == T.detail.dragElement.id && c.dispatch({
42100
- type: "move-connectiontip",
42101
- payload: {
42102
- connectionId: I,
42103
- type: "from",
42104
- offset: T.detail.dragVector
42105
- }
42106
- }), P == T.detail.dragElement.id && c.dispatch({
42107
- type: "move-connectiontip",
42108
- payload: {
42109
- connectionId: I,
42110
- type: "to",
42111
- offset: T.detail.dragVector
42112
- }
42113
- });
42114
- })));
42115
- }, [l.data.connections, e.id]), x = Mt((T) => {
42116
- if (T.detail && T.detail.dragElement && T.detail.dragElement.type == "port") {
42117
- const I = T.detail.dragElement.id.split("/"), F = Ua(), P = { workspace: { x: c.data.documentPosition.x, y: c.data.documentPosition.y }, viewspace: ot.ORIGIN, viewport: c.data.viewportPosition }, y = ba.shiftPosition({ type: "viewport", position: T.detail.currentDragPosition }, "workspace", P);
42118
- console.log("Port Positions", P, y), u.dispatch({
42119
- type: "add-connection-byId",
42120
- payload: {
42121
- id: F,
42122
- skeleton: {
42123
- from: I[1] == "output" ? T.detail.dragElement.id : "",
42124
- to: I[1] == "input" ? T.detail.dragElement.id : ""
42125
- },
42126
- design: {
42127
- from: { position: y },
42128
- to: { position: y }
42129
- }
42130
- }
42131
- }), h({
42132
- startPosition: T.detail.currentDragPosition,
42133
- elementDragged: {
42134
- type: "connection-tip",
42135
- id: F + "/" + (I[1] == "input" ? "from" : "to")
42136
- },
42137
- currentPosition: T.detail.currentDragPosition
42138
- });
42139
- }
42140
- }, [c.data.documentPosition, c.data.viewportPosition]), w = Mt((T) => {
42141
- if (T.detail && T.detail.dragElement && T.detail.dragElement.type == "connection-tip") {
42142
- let I = T.detail.dragElement.id.split("/");
42143
- Object.keys(l.data.connections).find((F) => F == I[0]) ? c.dispatch({
42144
- type: "move-connectiontip",
42145
- payload: {
42146
- connectionId: I[0],
42147
- offset: T.detail.dragVector,
42148
- type: I[1]
42149
- }
42150
- }) : Object.keys(u.data.connections).find((F) => F == I[0]) && u.dispatch({
42151
- type: "move-connectiontip",
42152
- payload: {
42153
- connectionId: I[0],
42154
- offset: T.detail.dragVector,
42155
- type: I[1]
42156
- }
42157
- });
42158
- }
42159
- }, [l.data.connections, u.data.connections]), S = Mt((T) => {
42160
- if (console.log("Selection Area Drag", T.detail), T.detail?.dragElement?.type == "document") {
42161
- const I = { workspace: { x: c.data.documentPosition.x, y: c.data.documentPosition.y }, viewspace: ot.ORIGIN, viewport: c.data.viewportPosition };
42162
- u.dispatch?.({
42163
- type: "set-selection_area",
42164
- payload: {
42165
- start: ba.shiftPosition({ type: "viewport", position: T.detail.initialDragPosition }, "workspace", I),
42166
- end: ba.shiftPosition({ type: "viewport", position: T.detail.currentDragPosition }, "workspace", I)
42167
- }
42168
- });
42169
- }
42170
- }, []), E = Mt(() => {
42171
- u.dispatch({
42172
- type: "remove-connections",
42173
- payload: {
42174
- connectionId: Object.keys(u.data.connections)
42175
- }
42176
- }), m();
42177
- }, [u.data.connections]), O = Mt((T) => {
42178
- if (T.detail.dragElement?.type == "connection-tip") {
42179
- let I = { workspace: ot.ORIGIN, viewspace: { x: -c.data.documentPosition.x, y: -c.data.documentPosition.y }, viewport: c.data.viewportPosition }, F = ba.shiftPosition({ type: "viewport", position: T.detail.currentDragPosition }, "workspace", I), P = T.detail.dragElement.id.split("/"), y = u.data.connections[P[0]], _ = P[1] == "from" ? y.skeleton.to : y.skeleton.from, D = Ua();
42180
- Object.keys(l.data.nodes).filter((j) => j != _.split("/")[0]).forEach((j) => {
42181
- let A = gz.getAllPortsPositions(
42182
- {
42183
- position: c.data.nodes[j]?.position,
42184
- dimensions: d.data.nodeDimensions
42185
- },
42186
- {
42187
- input: Object.keys(l.data.nodes[j].ports.input),
42188
- output: Object.keys(l.data.nodes[j].ports.output),
42189
- dimensions: { portRadius: d.data.portRadius, slabHeight: d.data.portSlabHeight }
42190
- }
42191
- );
42192
- console.log("Port Positions", A), A.outputPorts.forEach((z) => {
42193
- P[1] == "from" && F.x > z.position.x - d.data.portRadius && F.x < z.position.x + d.data.portRadius && F.y > z.position.y - d.data.portRadius && F.y < z.position.y + d.data.portRadius && (u.dispatch({
42194
- type: "remove-connection",
42195
- payload: {
42196
- connectionId: P[0]
42197
- }
42198
- }), l.dispatch({
42199
- type: "add-connection-byId",
42200
- payload: {
42201
- id: D,
42202
- from: j + "/output/" + z.key,
42203
- to: _
42204
- }
42205
- }), c.dispatch({
42206
- type: "init-connection",
42207
- payload: {
42208
- connectionId: D,
42209
- from: z.position,
42210
- to: y.design.to.position
42211
- }
42212
- }), h(null));
42213
- }), A.inputPorts.forEach((z) => {
42214
- P[1] == "to" && F.x > z.position.x - d.data.portRadius && F.x < z.position.x + d.data.portRadius && F.y > z.position.y - d.data.portRadius && F.y < z.position.y + d.data.portRadius && (u.dispatch({
42215
- type: "remove-connection",
42216
- payload: {
42217
- connectionId: P[0]
42218
- }
42219
- }), l.dispatch({
42220
- type: "add-connection-byId",
42221
- payload: {
42222
- id: D,
42223
- from: _,
42224
- to: j + "/input/" + z.key
42225
- }
42226
- }), c.dispatch({
42227
- type: "init-connection",
42228
- payload: {
42229
- connectionId: D,
42230
- from: y.design.from.position,
42231
- to: z.position
42232
- }
42233
- }), h(null));
42234
- });
42235
- });
42236
- }
42237
- }, [c.data.documentPosition, c.data.viewportPosition, l.data.nodes, l.data.connections, u.data.connections]), k = Mt(() => {
42238
- if (r(!1), a.current) {
42239
- let T = a.current?.getBoundingClientRect();
42240
- T && (c.dispatch({
42241
- type: "set-viewport-position",
42242
- payload: { x: -T.x, y: -T.y }
42243
- }), r(!0));
42244
- }
42245
- }, []);
42246
- Fn(() => (window.addEventListener("ondrag-" + e.id, O), () => window.removeEventListener("ondrag-" + e.id, O)), [O]), Fn(() => (window.addEventListener("ondrag-" + e.id, S), () => window.removeEventListener("ondrag-" + e.id, S)), [S]), Fn(() => (window.addEventListener("ondrag-" + e.id, g), () => window.removeEventListener("ondrag-" + e.id, g)), [g]), Fn(() => (window.addEventListener("ondrag-" + e.id, x), () => window.removeEventListener("ondrag-" + e.id, x)), [x]), Fn(() => (window.addEventListener("ondrag-" + e.id, w), () => window.removeEventListener("ondrag-" + e.id, w)), [w]), Fn(() => (window.addEventListener("ondrag-" + e.id, p), () => window.removeEventListener("ondrag-" + e.id, p)), [p]), Fn(() => (window.addEventListener("dragstop-" + e.id, E), () => window.removeEventListener("dragstop-" + e.id, E)), [E]), Fn(() => {
42247
- k();
42248
- }, []), wO(() => {
42249
- const T = a.current;
42250
- if (!T) return;
42251
- const I = new ResizeObserver(() => {
42252
- k();
42253
- });
42254
- return I.observe(T), () => I.disconnect();
42255
- }, []);
42256
- const N = Mt((T) => {
42257
- T.target == T.currentTarget && (i.delete("node_form"), s(i));
42258
- }, [i]);
42259
- return /* @__PURE__ */ Pe.jsx(xz.Provider, { value: {
42260
- assets: l,
42261
- view: c,
42262
- config: d,
42263
- interaction: u,
42264
- dragSession: {
42265
- data: t,
42266
- dispatch: h
42267
- }
42268
- }, children: /* @__PURE__ */ Pe.jsxs("div", { ref: a, className: "fullwidth fullheight", style: { position: "relative" }, children: [
42269
- n ? /* @__PURE__ */ Pe.jsxs("div", { className: "fullwidth fullheight flexbox-row flexbox-center", children: [
42270
- /* @__PURE__ */ Pe.jsx("div", { className: "fullwidth fullheight absolute", style: { top: c.data.documentPosition.y, left: c.data.documentPosition.x }, children: /* @__PURE__ */ Pe.jsx(
42271
- vz,
42272
- {
42273
- id: e.id,
42274
- config: e.config.document
42275
- }
42276
- ) }),
42277
- i.get("node_form") ? /* @__PURE__ */ Pe.jsx("div", { className: "absolute fullwidth fullheight", style: { zIndex: 200, backgroundColor: "rgba(0,0,0,0.1)" }, children: /* @__PURE__ */ Pe.jsx("div", { onClick: N, className: "fullwidth fullheight", style: { position: "relative" }, children: /* @__PURE__ */ Pe.jsx("div", { className: "absolute white-bg curve padding", style: { width: "80%", height: "80%", bottom: 50, left: "50%", top: "50%", transform: "translate(-50%,-50%)", boxShadow: "0px 0px 30px rgba(0,0,0,0.1)" } }) }) }) : null
42278
- ] }) : /* @__PURE__ */ Pe.jsx("div", { className: "fullwidth fullheight flexbox-row flexbox-center", children: /* @__PURE__ */ Pe.jsx("div", { className: "fullwidth fullheight flexbox-column flexbox-center", children: /* @__PURE__ */ Pe.jsx("span", { children: "Loading Document" }) }) }),
42279
- /* @__PURE__ */ Pe.jsxs("div", { children: [
42280
- /* @__PURE__ */ Pe.jsx("div", { className: "absolute fullheight", style: { backgroundColor: "rgba(0,0,0,0.1)", width: d?.data?.documentBoundaryThickness, left: 0, top: 0 } }),
42281
- /* @__PURE__ */ Pe.jsx("div", { className: "absolute fullheight", style: { backgroundColor: "rgba(0,0,0,0.1)", width: d?.data?.documentBoundaryThickness, right: 0, top: 0 } }),
42282
- /* @__PURE__ */ Pe.jsx("div", { className: "absolute fullwidth", style: { backgroundColor: "rgba(0,0,0,0.1)", height: d?.data?.documentBoundaryThickness, left: 0, top: 0 } }),
42283
- /* @__PURE__ */ Pe.jsx("div", { className: "absolute fullwidth", style: { backgroundColor: "rgba(0,0,0,0.1)", height: d?.data?.documentBoundaryThickness, left: 0, bottom: 0 } })
42284
- ] })
42285
- ] }) });
42286
- }, Qz = (e) => /* @__PURE__ */ Pe.jsx(
42064
+ }, xz = Ya(null), wz = (e) => /* @__PURE__ */ Pe.jsx(
42287
42065
  "div",
42288
42066
  {
42289
42067
  id: e.id,
@@ -42306,7 +42084,7 @@ const Zz = {
42306
42084
  style: e.style,
42307
42085
  children: e.children
42308
42086
  }
42309
- ), gO = Ya(null), wz = () => mx(gO), Sz = (e, t) => {
42087
+ ), gO = Ya(null), Sz = () => mx(gO), Oz = (e, t) => {
42310
42088
  const n = { ...e };
42311
42089
  switch (t.type) {
42312
42090
  case "set-field":
@@ -42319,7 +42097,7 @@ const Zz = {
42319
42097
  break;
42320
42098
  }
42321
42099
  return n;
42322
- }, Oz = (e, t) => {
42100
+ }, kz = (e, t) => {
42323
42101
  const n = { ...e };
42324
42102
  switch (t.type) {
42325
42103
  case "set-field":
@@ -42332,7 +42110,7 @@ const Zz = {
42332
42110
  break;
42333
42111
  }
42334
42112
  return n;
42335
- }, kz = (e, t) => {
42113
+ }, Ez = (e, t) => {
42336
42114
  const n = { ...e };
42337
42115
  switch (t.type) {
42338
42116
  case "set-field":
@@ -42345,8 +42123,8 @@ const Zz = {
42345
42123
  break;
42346
42124
  }
42347
42125
  return n;
42348
- }, e6 = (e) => {
42349
- const [t, n] = xo(Sz, e.formDefination.initialState), [r] = xo(Oz, e.formDefination.view), [a, i] = xo(kz, {
42126
+ }, Qz = (e) => {
42127
+ const [t, n] = xo(Oz, e.formDefination.initialState), [r] = xo(kz, e.formDefination.view), [a, i] = xo(Ez, {
42350
42128
  form: {},
42351
42129
  fields: {}
42352
42130
  });
@@ -42362,14 +42140,14 @@ const Zz = {
42362
42140
  uiElementsRegistry: e.uiElementsRegistry
42363
42141
  }, children: /* @__PURE__ */ Pe.jsx("div", { className: "fullwidth fullheight flexbox-column gap scroll", children: Object.keys(e.formDefination.schema).map(
42364
42142
  (s) => /* @__PURE__ */ Pe.jsx(
42365
- Ez,
42143
+ Cz,
42366
42144
  {
42367
42145
  id: s
42368
42146
  }
42369
42147
  )
42370
42148
  ) }) });
42371
- }, Ez = (e) => {
42372
- const { asset: t, view: n, preference: r, config: a, schema: i, uiElementsRegistry: s } = wz() ?? {}, l = En(() => n?.data ? s?.[n?.data?.fields?.[e.id]?.component] : null, [s, n, e.id]), c = Mt((u, d) => {
42149
+ }, Cz = (e) => {
42150
+ const { asset: t, view: n, preference: r, config: a, schema: i, uiElementsRegistry: s } = Sz() ?? {}, l = En(() => n?.data ? s?.[n?.data?.fields?.[e.id]?.component] : null, [s, n, e.id]), c = Mt((u, d) => {
42373
42151
  const f = {}, h = e.id + d.type;
42374
42152
  let b = [];
42375
42153
  const m = a?.data?.form?.adapters?.intent?.[h];
@@ -42395,7 +42173,7 @@ const Zz = {
42395
42173
  }
42396
42174
  ) : null
42397
42175
  ] });
42398
- }, t6 = (e) => {
42176
+ }, e6 = (e) => {
42399
42177
  const { config: t, dragSession: n } = e.config.stateFetcher() ?? {}, r = En(() => !(e.skeleton.from && e.skeleton.to), [e.skeleton.from, e.skeleton.to]), a = En(() => {
42400
42178
  const i = e.design.from.position, s = e.design.to.position, l = s.x - i.x, c = { x: i.x + l * 0.5, y: i.y }, u = { x: s.x - l * 0.5, y: s.y };
42401
42179
  return `
@@ -42462,12 +42240,12 @@ const Zz = {
42462
42240
  function Rp(e) {
42463
42241
  return `Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `;
42464
42242
  }
42465
- var Ud = () => Math.random().toString(36).substring(7).split("").join("."), Cz = {
42243
+ var Ud = () => Math.random().toString(36).substring(7).split("").join("."), Tz = {
42466
42244
  INIT: `@@redux/INIT${/* @__PURE__ */ Ud()}`,
42467
42245
  REPLACE: `@@redux/REPLACE${/* @__PURE__ */ Ud()}`,
42468
42246
  PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${Ud()}`
42469
- }, Ta = Cz;
42470
- function Tz(e) {
42247
+ }, Ta = Tz;
42248
+ function Dz(e) {
42471
42249
  if (typeof e != "object" || e === null)
42472
42250
  return !1;
42473
42251
  let t = e;
@@ -42475,7 +42253,7 @@ function Tz(e) {
42475
42253
  t = Object.getPrototypeOf(t);
42476
42254
  return Object.getPrototypeOf(e) === t || Object.getPrototypeOf(e) === null;
42477
42255
  }
42478
- function Dz(e) {
42256
+ function jz(e) {
42479
42257
  if (e === void 0)
42480
42258
  return "undefined";
42481
42259
  if (e === null)
@@ -42491,11 +42269,11 @@ function Dz(e) {
42491
42269
  }
42492
42270
  if (Array.isArray(e))
42493
42271
  return "array";
42494
- if (Mz(e))
42272
+ if (Rz(e))
42495
42273
  return "date";
42496
- if (Pz(e))
42274
+ if (Mz(e))
42497
42275
  return "error";
42498
- const n = jz(e);
42276
+ const n = Pz(e);
42499
42277
  switch (n) {
42500
42278
  case "Symbol":
42501
42279
  case "Promise":
@@ -42507,18 +42285,18 @@ function Dz(e) {
42507
42285
  }
42508
42286
  return Object.prototype.toString.call(e).slice(8, -1).toLowerCase().replace(/\s/g, "");
42509
42287
  }
42510
- function jz(e) {
42288
+ function Pz(e) {
42511
42289
  return typeof e.constructor == "function" ? e.constructor.name : null;
42512
42290
  }
42513
- function Pz(e) {
42291
+ function Mz(e) {
42514
42292
  return e instanceof Error || typeof e.message == "string" && e.constructor && typeof e.constructor.stackTraceLimit == "number";
42515
42293
  }
42516
- function Mz(e) {
42294
+ function Rz(e) {
42517
42295
  return e instanceof Date ? !0 : typeof e.toDateString == "function" && typeof e.getDate == "function" && typeof e.setDate == "function";
42518
42296
  }
42519
- function Rz(e) {
42297
+ function Nz(e) {
42520
42298
  let t = typeof e;
42521
- return process.env.NODE_ENV !== "production" && (t = Dz(e)), t;
42299
+ return process.env.NODE_ENV !== "production" && (t = jz(e)), t;
42522
42300
  }
42523
42301
  function hx(e) {
42524
42302
  typeof console < "u" && typeof console.error == "function" && console.error(e);
@@ -42527,19 +42305,19 @@ function hx(e) {
42527
42305
  } catch {
42528
42306
  }
42529
42307
  }
42530
- function Nz(e, t, n, r) {
42308
+ function Iz(e, t, n, r) {
42531
42309
  const a = Object.keys(t), i = n && n.type === Ta.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
42532
42310
  if (a.length === 0)
42533
42311
  return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
42534
- if (!Tz(e))
42535
- return `The ${i} has unexpected type of "${Rz(e)}". Expected argument to be an object with the following keys: "${a.join('", "')}"`;
42312
+ if (!Dz(e))
42313
+ return `The ${i} has unexpected type of "${Nz(e)}". Expected argument to be an object with the following keys: "${a.join('", "')}"`;
42536
42314
  const s = Object.keys(e).filter((l) => !t.hasOwnProperty(l) && !r[l]);
42537
42315
  if (s.forEach((l) => {
42538
42316
  r[l] = !0;
42539
42317
  }), !(n && n.type === Ta.REPLACE) && s.length > 0)
42540
42318
  return `Unexpected ${s.length > 1 ? "keys" : "key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${a.join('", "')}". Unexpected keys will be ignored.`;
42541
42319
  }
42542
- function Iz(e) {
42320
+ function Az(e) {
42543
42321
  Object.keys(e).forEach((t) => {
42544
42322
  const n = e[t];
42545
42323
  if (typeof n(void 0, {
@@ -42563,7 +42341,7 @@ function Hh(e) {
42563
42341
  process.env.NODE_ENV !== "production" && (a = {});
42564
42342
  let i;
42565
42343
  try {
42566
- Iz(n);
42344
+ Az(n);
42567
42345
  } catch (s) {
42568
42346
  i = s;
42569
42347
  }
@@ -42571,7 +42349,7 @@ function Hh(e) {
42571
42349
  if (i)
42572
42350
  throw i;
42573
42351
  if (process.env.NODE_ENV !== "production") {
42574
- const f = Nz(l, n, c, a);
42352
+ const f = Iz(l, n, c, a);
42575
42353
  f && hx(f);
42576
42354
  }
42577
42355
  let u = !1;
@@ -42587,7 +42365,7 @@ function Hh(e) {
42587
42365
  return u = u || r.length !== Object.keys(l).length, u ? d : l;
42588
42366
  };
42589
42367
  }
42590
- const Az = (e, t) => {
42368
+ const _z = (e, t) => {
42591
42369
  const n = e ? { ...e } : null;
42592
42370
  switch (t.type) {
42593
42371
  case "set-selection_area":
@@ -42596,7 +42374,7 @@ const Az = (e, t) => {
42596
42374
  return null;
42597
42375
  }
42598
42376
  return n;
42599
- }, _z = (e, t) => {
42377
+ }, Fz = (e, t) => {
42600
42378
  const n = e ? { ...e } : { node: [], connection: [] };
42601
42379
  switch (t.type) {
42602
42380
  case "set-selectedItems":
@@ -42615,7 +42393,7 @@ const Az = (e, t) => {
42615
42393
  break;
42616
42394
  }
42617
42395
  return n;
42618
- }, Fz = (e = {}, t) => {
42396
+ }, $z = (e = {}, t) => {
42619
42397
  const n = { ...e };
42620
42398
  switch (t.type) {
42621
42399
  case "add-node":
@@ -42657,7 +42435,7 @@ const Az = (e, t) => {
42657
42435
  break;
42658
42436
  }
42659
42437
  return n;
42660
- }, $z = (e = {}, t) => {
42438
+ }, Vz = (e = {}, t) => {
42661
42439
  const n = { ...e };
42662
42440
  switch (t.type) {
42663
42441
  case "init-node-view":
@@ -42671,7 +42449,7 @@ const Az = (e, t) => {
42671
42449
  break;
42672
42450
  }
42673
42451
  return n;
42674
- }, Vz = (e = {}, t) => {
42452
+ }, Bz = (e = {}, t) => {
42675
42453
  const n = { ...e };
42676
42454
  switch (t.type) {
42677
42455
  case "add-connection":
@@ -42689,7 +42467,7 @@ const Az = (e, t) => {
42689
42467
  break;
42690
42468
  }
42691
42469
  return n;
42692
- }, Bz = (e = {}, t) => {
42470
+ }, Lz = (e = {}, t) => {
42693
42471
  const n = { ...e };
42694
42472
  switch (t.type) {
42695
42473
  case "init-connection":
@@ -42714,7 +42492,7 @@ const Az = (e, t) => {
42714
42492
  break;
42715
42493
  }
42716
42494
  return n;
42717
- }, Lz = (e, t) => {
42495
+ }, zz = (e, t) => {
42718
42496
  const n = { ...e };
42719
42497
  switch (t.type) {
42720
42498
  case "add-connection":
@@ -42758,7 +42536,7 @@ const Az = (e, t) => {
42758
42536
  break;
42759
42537
  }
42760
42538
  return n;
42761
- }, zz = (e, t) => {
42539
+ }, Hz = (e, t) => {
42762
42540
  let n = { ...e };
42763
42541
  switch (t.type) {
42764
42542
  case "set-document-position":
@@ -42769,22 +42547,22 @@ const Az = (e, t) => {
42769
42547
  break;
42770
42548
  }
42771
42549
  return n;
42772
- }, Hz = (e, t) => {
42550
+ }, Wz = (e, t) => {
42773
42551
  let n = { ...e };
42774
42552
  return t.type === "set-viewport-position" && (n = t.payload), n;
42775
- }, n6 = Hh({
42776
- nodes: Fz,
42777
- connections: Vz
42778
- }), r6 = Hh({
42553
+ }, t6 = Hh({
42779
42554
  nodes: $z,
42780
- connections: Bz,
42781
- viewportPosition: Hz,
42782
- documentPosition: zz
42783
- }), o6 = Hh({
42555
+ connections: Bz
42556
+ }), n6 = Hh({
42557
+ nodes: Vz,
42784
42558
  connections: Lz,
42785
- selection: Az,
42786
- selectedItems: _z
42787
- }), a6 = (e) => ({
42559
+ viewportPosition: Wz,
42560
+ documentPosition: Hz
42561
+ }), r6 = Hh({
42562
+ connections: zz,
42563
+ selection: _z,
42564
+ selectedItems: Fz
42565
+ }), o6 = (e) => ({
42788
42566
  type: "dummy",
42789
42567
  ports: {
42790
42568
  input: {
@@ -42816,7 +42594,7 @@ const Az = (e, t) => {
42816
42594
  ouput: !1
42817
42595
  }
42818
42596
  }
42819
- }), i6 = (e) => {
42597
+ }), a6 = (e) => {
42820
42598
  const [t, n] = xo(e.Assets.reducer, e.Assets.initialState), [r, a] = xo(e.View.reducer, e.View.initialState), [i, s] = xo(e.Interaction.reducer, e.Interaction.initialState), l = vo(e.Config.initialState).current;
42821
42599
  return {
42822
42600
  assets: {
@@ -42880,7 +42658,7 @@ const Az = (e, t) => {
42880
42658
  component: "toggle",
42881
42659
  reducer: Ja
42882
42660
  }
42883
- }, Wz = {
42661
+ }, qz = {
42884
42662
  // examples: {
42885
42663
  // type: "array",
42886
42664
  // title: "Examples",
@@ -43036,7 +42814,7 @@ const Az = (e, t) => {
43036
42814
  // title: "Not",
43037
42815
  // description: "Negated schema"
43038
42816
  // }
43039
- }, qz = {
42817
+ }, Uz = {
43040
42818
  minimum: {
43041
42819
  schema: {
43042
42820
  type: "number",
@@ -43072,7 +42850,7 @@ const Az = (e, t) => {
43072
42850
  config: { dataType: "integer" },
43073
42851
  reducer: Et
43074
42852
  }
43075
- }, Uz = {
42853
+ }, Yz = {
43076
42854
  minItems: {
43077
42855
  schema: {
43078
42856
  type: "number",
@@ -43108,7 +42886,7 @@ const Az = (e, t) => {
43108
42886
  config: { dataType: "integer" },
43109
42887
  reducer: Et
43110
42888
  }
43111
- }, Yz = {
42889
+ }, Kz = {
43112
42890
  items: {
43113
42891
  schema: {
43114
42892
  type: "number",
@@ -43134,30 +42912,252 @@ const Az = (e, t) => {
43134
42912
  component: "toggle",
43135
42913
  reducer: Ja
43136
42914
  }
43137
- }, s6 = {
43138
- string: { ...sa, ...Wz },
43139
- number: { ...sa, ...qz },
42915
+ }, i6 = {
42916
+ string: { ...sa, ...qz },
42917
+ number: { ...sa, ...Uz },
43140
42918
  boolean: sa,
43141
- array: { ...sa, ...Uz },
43142
- object: { ...sa, ...Yz }
42919
+ array: { ...sa, ...Yz },
42920
+ object: { ...sa, ...Kz }
42921
+ }, s6 = (e) => {
42922
+ const t = vo(null), [n, r] = xO(!1), a = vo(null), [i, s] = OO(), { assets: l, view: c, interaction: u, config: d } = En(() => e.state, [e.state]), f = vo(null), h = Mt((T) => {
42923
+ t.current = T;
42924
+ }, []), b = Mt((T, I) => {
42925
+ f.current = setInterval(() => {
42926
+ c?.dispatch?.({
42927
+ type: "move-document",
42928
+ payload: {
42929
+ speed: 3.5,
42930
+ direction: ot.getScaledVector(T, -1)
42931
+ }
42932
+ }), I.type == "node" && c.dispatch({
42933
+ type: "move-node",
42934
+ payload: {
42935
+ nodeId: I.id,
42936
+ motionVector: ot.getScaledVector(T, 3.5)
42937
+ }
42938
+ });
42939
+ }, 8);
42940
+ }, []), m = Mt(() => {
42941
+ f.current && (clearInterval(f.current), f.current = null);
42942
+ }, []), p = Mt((T) => {
42943
+ if (T.detail && T.detail.dragElement) {
42944
+ const I = a.current?.getBoundingClientRect(), F = T.detail.currentDragPosition.x > d.data.documentBoundaryThickness && T.detail.currentDragPosition.x < I.width - d.data.documentBoundaryThickness && T.detail.currentDragPosition.y > d.data.documentBoundaryThickness && T.detail.currentDragPosition.y < I.height - d.data.documentBoundaryThickness;
42945
+ !F && !f.current ? b(T.detail.dragVector, T.detail.dragElement) : F && f.current && m();
42946
+ }
42947
+ }, [d.data.documentBoundaryThickness, d.data.documentDimension]), g = Mt((T) => {
42948
+ T.detail && T.detail.dragElement && (console.log("Moving Node"), T.detail.dragElement.type == "node" && (c.dispatch({
42949
+ type: "move-node",
42950
+ payload: {
42951
+ nodeId: T.detail.dragElement.id,
42952
+ motionVector: T.detail.dragVector
42953
+ }
42954
+ }), Object.keys(l.data.connections).forEach((I) => {
42955
+ const F = l.data.connections[I].from.split("/")[0], P = l.data.connections[I].to.split("/")[0];
42956
+ F == T.detail.dragElement.id && c.dispatch({
42957
+ type: "move-connectiontip",
42958
+ payload: {
42959
+ connectionId: I,
42960
+ type: "from",
42961
+ offset: T.detail.dragVector
42962
+ }
42963
+ }), P == T.detail.dragElement.id && c.dispatch({
42964
+ type: "move-connectiontip",
42965
+ payload: {
42966
+ connectionId: I,
42967
+ type: "to",
42968
+ offset: T.detail.dragVector
42969
+ }
42970
+ });
42971
+ })));
42972
+ }, [l.data.connections, e.id]), x = Mt((T) => {
42973
+ if (T.detail && T.detail.dragElement && T.detail.dragElement.type == "port") {
42974
+ const I = T.detail.dragElement.id.split("/"), F = Ua(), P = { workspace: { x: c.data.documentPosition.x, y: c.data.documentPosition.y }, viewspace: ot.ORIGIN, viewport: c.data.viewportPosition }, y = ba.shiftPosition({ type: "viewport", position: T.detail.currentDragPosition }, "workspace", P);
42975
+ console.log("Port Positions", P, y), u.dispatch({
42976
+ type: "add-connection-byId",
42977
+ payload: {
42978
+ id: F,
42979
+ skeleton: {
42980
+ from: I[1] == "output" ? T.detail.dragElement.id : "",
42981
+ to: I[1] == "input" ? T.detail.dragElement.id : ""
42982
+ },
42983
+ design: {
42984
+ from: { position: y },
42985
+ to: { position: y }
42986
+ }
42987
+ }
42988
+ }), h({
42989
+ startPosition: T.detail.currentDragPosition,
42990
+ elementDragged: {
42991
+ type: "connection-tip",
42992
+ id: F + "/" + (I[1] == "input" ? "from" : "to")
42993
+ },
42994
+ currentPosition: T.detail.currentDragPosition
42995
+ });
42996
+ }
42997
+ }, [c.data.documentPosition, c.data.viewportPosition]), w = Mt((T) => {
42998
+ if (T.detail && T.detail.dragElement && T.detail.dragElement.type == "connection-tip") {
42999
+ let I = T.detail.dragElement.id.split("/");
43000
+ Object.keys(l.data.connections).find((F) => F == I[0]) ? c.dispatch({
43001
+ type: "move-connectiontip",
43002
+ payload: {
43003
+ connectionId: I[0],
43004
+ offset: T.detail.dragVector,
43005
+ type: I[1]
43006
+ }
43007
+ }) : Object.keys(u.data.connections).find((F) => F == I[0]) && u.dispatch({
43008
+ type: "move-connectiontip",
43009
+ payload: {
43010
+ connectionId: I[0],
43011
+ offset: T.detail.dragVector,
43012
+ type: I[1]
43013
+ }
43014
+ });
43015
+ }
43016
+ }, [l.data.connections, u.data.connections]), S = Mt((T) => {
43017
+ if (console.log("Selection Area Drag", T.detail), T.detail?.dragElement?.type == "document") {
43018
+ const I = { workspace: { x: c.data.documentPosition.x, y: c.data.documentPosition.y }, viewspace: ot.ORIGIN, viewport: c.data.viewportPosition };
43019
+ u.dispatch?.({
43020
+ type: "set-selection_area",
43021
+ payload: {
43022
+ start: ba.shiftPosition({ type: "viewport", position: T.detail.initialDragPosition }, "workspace", I),
43023
+ end: ba.shiftPosition({ type: "viewport", position: T.detail.currentDragPosition }, "workspace", I)
43024
+ }
43025
+ });
43026
+ }
43027
+ }, []), E = Mt(() => {
43028
+ u.dispatch({
43029
+ type: "remove-connections",
43030
+ payload: {
43031
+ connectionId: Object.keys(u.data.connections)
43032
+ }
43033
+ }), m();
43034
+ }, [u.data.connections]), O = Mt((T) => {
43035
+ if (T.detail.dragElement?.type == "connection-tip") {
43036
+ let I = { workspace: ot.ORIGIN, viewspace: { x: -c.data.documentPosition.x, y: -c.data.documentPosition.y }, viewport: c.data.viewportPosition }, F = ba.shiftPosition({ type: "viewport", position: T.detail.currentDragPosition }, "workspace", I), P = T.detail.dragElement.id.split("/"), y = u.data.connections[P[0]], _ = P[1] == "from" ? y.skeleton.to : y.skeleton.from, D = Ua();
43037
+ Object.keys(l.data.nodes).filter((j) => j != _.split("/")[0]).forEach((j) => {
43038
+ let A = gz.getAllPortsPositions(
43039
+ {
43040
+ position: c.data.nodes[j]?.position,
43041
+ dimensions: d.data.nodeDimensions
43042
+ },
43043
+ {
43044
+ input: Object.keys(l.data.nodes[j].ports.input),
43045
+ output: Object.keys(l.data.nodes[j].ports.output),
43046
+ dimensions: { portRadius: d.data.portRadius, slabHeight: d.data.portSlabHeight }
43047
+ }
43048
+ );
43049
+ console.log("Port Positions", A), A.outputPorts.forEach((z) => {
43050
+ P[1] == "from" && F.x > z.position.x - d.data.portRadius && F.x < z.position.x + d.data.portRadius && F.y > z.position.y - d.data.portRadius && F.y < z.position.y + d.data.portRadius && (u.dispatch({
43051
+ type: "remove-connection",
43052
+ payload: {
43053
+ connectionId: P[0]
43054
+ }
43055
+ }), l.dispatch({
43056
+ type: "add-connection-byId",
43057
+ payload: {
43058
+ id: D,
43059
+ from: j + "/output/" + z.key,
43060
+ to: _
43061
+ }
43062
+ }), c.dispatch({
43063
+ type: "init-connection",
43064
+ payload: {
43065
+ connectionId: D,
43066
+ from: z.position,
43067
+ to: y.design.to.position
43068
+ }
43069
+ }), h(null));
43070
+ }), A.inputPorts.forEach((z) => {
43071
+ P[1] == "to" && F.x > z.position.x - d.data.portRadius && F.x < z.position.x + d.data.portRadius && F.y > z.position.y - d.data.portRadius && F.y < z.position.y + d.data.portRadius && (u.dispatch({
43072
+ type: "remove-connection",
43073
+ payload: {
43074
+ connectionId: P[0]
43075
+ }
43076
+ }), l.dispatch({
43077
+ type: "add-connection-byId",
43078
+ payload: {
43079
+ id: D,
43080
+ from: _,
43081
+ to: j + "/input/" + z.key
43082
+ }
43083
+ }), c.dispatch({
43084
+ type: "init-connection",
43085
+ payload: {
43086
+ connectionId: D,
43087
+ from: y.design.from.position,
43088
+ to: z.position
43089
+ }
43090
+ }), h(null));
43091
+ });
43092
+ });
43093
+ }
43094
+ }, [c.data.documentPosition, c.data.viewportPosition, l.data.nodes, l.data.connections, u.data.connections]), k = Mt(() => {
43095
+ if (r(!1), a.current) {
43096
+ let T = a.current?.getBoundingClientRect();
43097
+ T && (c.dispatch({
43098
+ type: "set-viewport-position",
43099
+ payload: { x: -T.x, y: -T.y }
43100
+ }), r(!0));
43101
+ }
43102
+ }, []);
43103
+ Fn(() => (window.addEventListener("ondrag-" + e.id, O), () => window.removeEventListener("ondrag-" + e.id, O)), [O]), Fn(() => (window.addEventListener("ondrag-" + e.id, S), () => window.removeEventListener("ondrag-" + e.id, S)), [S]), Fn(() => (window.addEventListener("ondrag-" + e.id, g), () => window.removeEventListener("ondrag-" + e.id, g)), [g]), Fn(() => (window.addEventListener("ondrag-" + e.id, x), () => window.removeEventListener("ondrag-" + e.id, x)), [x]), Fn(() => (window.addEventListener("ondrag-" + e.id, w), () => window.removeEventListener("ondrag-" + e.id, w)), [w]), Fn(() => (window.addEventListener("ondrag-" + e.id, p), () => window.removeEventListener("ondrag-" + e.id, p)), [p]), Fn(() => (window.addEventListener("dragstop-" + e.id, E), () => window.removeEventListener("dragstop-" + e.id, E)), [E]), Fn(() => {
43104
+ k();
43105
+ }, []), wO(() => {
43106
+ const T = a.current;
43107
+ if (!T) return;
43108
+ const I = new ResizeObserver(() => {
43109
+ k();
43110
+ });
43111
+ return I.observe(T), () => I.disconnect();
43112
+ }, []);
43113
+ const N = Mt((T) => {
43114
+ T.target == T.currentTarget && (i.delete("node_form"), s(i));
43115
+ }, [i]);
43116
+ return /* @__PURE__ */ Pe.jsx(xz.Provider, { value: {
43117
+ assets: l,
43118
+ view: c,
43119
+ config: d,
43120
+ interaction: u,
43121
+ dragSession: {
43122
+ data: t,
43123
+ dispatch: h
43124
+ }
43125
+ }, children: /* @__PURE__ */ Pe.jsxs("div", { ref: a, className: "fullwidth fullheight", style: { position: "relative" }, children: [
43126
+ n ? /* @__PURE__ */ Pe.jsxs("div", { className: "fullwidth fullheight flexbox-row flexbox-center", children: [
43127
+ /* @__PURE__ */ Pe.jsx(wz, { id: "document-drag_wrapper", dragItem: { type: "document", id: e.id }, dragSetter: h, class: "fullwidth fullheight absolute", style: { top: c.data.documentPosition.y, left: c.data.documentPosition.x }, children: /* @__PURE__ */ Pe.jsx(
43128
+ vz,
43129
+ {
43130
+ id: e.id,
43131
+ config: e.config.document
43132
+ }
43133
+ ) }),
43134
+ i.get("node_form") ? /* @__PURE__ */ Pe.jsx("div", { className: "absolute fullwidth fullheight", style: { zIndex: 200, backgroundColor: "rgba(0,0,0,0.1)" }, children: /* @__PURE__ */ Pe.jsx("div", { onClick: N, className: "fullwidth fullheight", style: { position: "relative" }, children: /* @__PURE__ */ Pe.jsx("div", { className: "absolute white-bg curve padding", style: { width: "80%", height: "80%", bottom: 50, left: "50%", top: "50%", transform: "translate(-50%,-50%)", boxShadow: "0px 0px 30px rgba(0,0,0,0.1)" } }) }) }) : null
43135
+ ] }) : /* @__PURE__ */ Pe.jsx("div", { className: "fullwidth fullheight flexbox-row flexbox-center", children: /* @__PURE__ */ Pe.jsx("div", { className: "fullwidth fullheight flexbox-column flexbox-center", children: /* @__PURE__ */ Pe.jsx("span", { children: "Loading Document" }) }) }),
43136
+ /* @__PURE__ */ Pe.jsxs("div", { children: [
43137
+ /* @__PURE__ */ Pe.jsx("div", { className: "absolute fullheight", style: { backgroundColor: "rgba(0,0,0,0.1)", width: d?.data?.documentBoundaryThickness, left: 0, top: 0 } }),
43138
+ /* @__PURE__ */ Pe.jsx("div", { className: "absolute fullheight", style: { backgroundColor: "rgba(0,0,0,0.1)", width: d?.data?.documentBoundaryThickness, right: 0, top: 0 } }),
43139
+ /* @__PURE__ */ Pe.jsx("div", { className: "absolute fullwidth", style: { backgroundColor: "rgba(0,0,0,0.1)", height: d?.data?.documentBoundaryThickness, left: 0, top: 0 } }),
43140
+ /* @__PURE__ */ Pe.jsx("div", { className: "absolute fullwidth", style: { backgroundColor: "rgba(0,0,0,0.1)", height: d?.data?.documentBoundaryThickness, left: 0, bottom: 0 } })
43141
+ ] })
43142
+ ] }) });
43143
43143
  }, l6 = { Dropdown: bx, Textbox: gx, Toggle: yx };
43144
43144
  export {
43145
- n6 as AssetsReducer,
43146
- t6 as Connection,
43145
+ t6 as AssetsReducer,
43146
+ e6 as Connection,
43147
43147
  xz as Context_Workspace,
43148
43148
  vz as Document,
43149
- Qz as Draggable,
43150
- e6 as Form,
43149
+ wz as Draggable,
43150
+ Qz as Form,
43151
43151
  l6 as FormInputElements,
43152
- o6 as InteractionReducer,
43153
- s6 as JSONForms,
43152
+ r6 as InteractionReducer,
43153
+ i6 as JSONForms,
43154
43154
  gz as NodeUtils,
43155
43155
  Ua as UIDCreator,
43156
- Zz as UiElementsRegistry_Standard,
43156
+ Jz as UiElementsRegistry_Standard,
43157
43157
  ot as VectorApi,
43158
- r6 as ViewReducer,
43159
- Jz as Workspace,
43160
- a6 as getSchemaNode,
43158
+ n6 as ViewReducer,
43159
+ s6 as Workspace,
43160
+ o6 as getSchemaNode,
43161
43161
  yz as schemaNodeExporter,
43162
- i6 as useWorkspace
43162
+ a6 as useWorkspace
43163
43163
  };