@bemedev/mind-flow 1.3.0 → 1.4.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.
- package/lib/index.cjs.js +1 -1
- package/lib/index.es.js +721 -819
- package/lib/output.css +1 -1
- package/lib/server.cjs.js +136 -314
- package/lib/server.es.js +138 -316
- package/lib/ui/Flow.d.ts +3 -3
- package/lib/ui/Flow.d.ts.map +1 -1
- package/lib/ui/components/EditPanel.d.ts.map +1 -1
- package/lib/ui/components/FlowChart.d.ts.map +1 -1
- package/lib/ui/components/FlowChart.types.d.ts +8 -8
- package/lib/ui/components/NodeComponent.d.ts.map +1 -1
- package/lib/ui/components/Panels.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/ui/Flow.tsx +7 -28
- package/src/ui/components/EditPanel.tsx +6 -1
- package/src/ui/components/FlowChart.tsx +65 -23
- package/src/ui/components/FlowChart.types.ts +8 -8
- package/src/ui/components/NodeComponent.tsx +3 -6
- package/src/ui/components/Panels.tsx +38 -15
package/lib/server.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDefined, toArray, type } from "@bemedev/app/bemedev";
|
|
2
|
-
import { Dynamic, createComponent, escape, memo, mergeProps, ssr, ssrAttribute, ssrClassList,
|
|
2
|
+
import { Dynamic, createComponent, escape, memo, mergeProps, ssr, ssrAttribute, ssrClassList, ssrHydrationKey, ssrStyle, ssrStyleProperty } from "solid-js/web";
|
|
3
3
|
import { createState } from "@bemedev/app-solidjs";
|
|
4
|
-
import { For, Show, createComponent as createComponent$1, createContext as createContext$1, createEffect,
|
|
4
|
+
import { For, Show, createComponent as createComponent$1, createContext as createContext$1, createEffect, createSignal, on, onCleanup, onMount, useContext } from "solid-js";
|
|
5
5
|
import { createMachine, deepEqual, interpret, toArray as toArray$1 } from "@bemedev/app";
|
|
6
6
|
import { nanoid } from "nanoid";
|
|
7
7
|
import { DragDropProvider, DragDropSensors, DragOverlay, createDraggable, useDragDropContext } from "@thisbeyond/solid-dnd";
|
|
@@ -994,14 +994,14 @@ var DragBounds = () => {
|
|
|
994
994
|
};
|
|
995
995
|
//#endregion
|
|
996
996
|
//#region src/ui/components/EdgeComponent.tsx
|
|
997
|
-
var _tmpl$$
|
|
997
|
+
var _tmpl$$7 = [
|
|
998
998
|
"<path",
|
|
999
999
|
" class=\"",
|
|
1000
1000
|
"\" style=\"",
|
|
1001
1001
|
"\"",
|
|
1002
1002
|
"></path>"
|
|
1003
1003
|
];
|
|
1004
|
-
var _tmpl$2$
|
|
1004
|
+
var _tmpl$2$4 = [
|
|
1005
1005
|
"<g",
|
|
1006
1006
|
" cursor=\"pointer\" transform=\"",
|
|
1007
1007
|
"\" style=\"",
|
|
@@ -1066,19 +1066,19 @@ var EdgeComponent = (props) => {
|
|
|
1066
1066
|
get when() {
|
|
1067
1067
|
return vector();
|
|
1068
1068
|
},
|
|
1069
|
-
children: (v) => [ssr(_tmpl$$
|
|
1069
|
+
children: (v) => [ssr(_tmpl$$7, ssrHydrationKey(), `relative cursor-pointer fill-transparent ${!!props.isNew ? "stroke-[rgba(168,168,168,0.4)] stroke-3 z-200" : ""} ${selected() && !props.isNew ? "stroke-[rgba(168,168,168,1)] stroke-4 z-100" : ""} ${!selected() && !props.isNew ? "stroke-[rgba(168,168,168,0.8)] stroke-3" : ""}`, ssrStyleProperty("pointer-events:", props.isNew ? "none" : "all"), ssrAttribute("d", escape(draw(v()), true), false)), createComponent(Show, {
|
|
1070
1070
|
get when() {
|
|
1071
1071
|
return selected();
|
|
1072
1072
|
},
|
|
1073
1073
|
get children() {
|
|
1074
|
-
return ssr(_tmpl$2$
|
|
1074
|
+
return ssr(_tmpl$2$4, ssrHydrationKey(), `translate(${escape(middlePoint().x, true)}, ${escape(middlePoint().y, true)})`, ssrStyleProperty("pointer-events:", "all") + ssrStyleProperty(";z-index:", "30"));
|
|
1075
1075
|
}
|
|
1076
1076
|
})]
|
|
1077
1077
|
});
|
|
1078
1078
|
};
|
|
1079
1079
|
//#endregion
|
|
1080
1080
|
//#region src/ui/components/EdgesBoard.tsx
|
|
1081
|
-
var _tmpl$$
|
|
1081
|
+
var _tmpl$$6 = [
|
|
1082
1082
|
"<svg",
|
|
1083
1083
|
" class=\"pointer-events-none h-full w-full overflow-visible\"><!--$-->",
|
|
1084
1084
|
"<!--/--><!--$-->",
|
|
@@ -1099,7 +1099,7 @@ var EdgesBoard = () => {
|
|
|
1099
1099
|
selector: ({ context }) => Object.keys(context.edgesPositions ?? {}),
|
|
1100
1100
|
equals: (prev, next) => prev.length === next.length
|
|
1101
1101
|
});
|
|
1102
|
-
return ssr(_tmpl$$
|
|
1102
|
+
return ssr(_tmpl$$6, ssrHydrationKey(), escape(createComponent(Show, {
|
|
1103
1103
|
get when() {
|
|
1104
1104
|
return hasNewEdge();
|
|
1105
1105
|
},
|
|
@@ -1118,12 +1118,12 @@ var EdgesBoard = () => {
|
|
|
1118
1118
|
};
|
|
1119
1119
|
//#endregion
|
|
1120
1120
|
//#region src/ui/components/NodeComponent.tsx
|
|
1121
|
-
var _tmpl$$
|
|
1121
|
+
var _tmpl$$5 = [
|
|
1122
1122
|
"<svg",
|
|
1123
1123
|
" class=\"cursor-pointer overflow-visible rounded-full bg-green-500 p-0.5 text-center font-bold hover:bg-green-600\" style=\"",
|
|
1124
1124
|
"\" viewBox=\"0 0 1024 1024\" preserveAspectRatio=\"xMaxYMax\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"white\"><g id=\"background\"><path d=\"M467.40667,277.66696c-0.05948,-14.53055 5.75527,-22.95613 -8.62044,-20.90487c-112.55699,16.0607 -222.1609,112.14558 -245.06161,239.85765c-46.52056,259.43466 231.33083,443.06705 449.51209,316.97506c117.31668,-67.80002 160.95215,-190.43324 151.34416,-288.29849c-5.92276,-60.32819 -27.80273,-107.95668 -53.44246,-144.25469l59.39269,-42.05363c111.72214,156.309 73.11535,351.55635 -25.06953,459.45565c-184.18877,202.4124 -470.46624,145.52064 -592.95027,-32.92123c-156.18269,-227.53604 -27.15324,-543.64371 261.18883,-582.44416c5.0579,-0.68061 3.56556,-7.04079 3.56442,-8.58985c-0.05594,-76.3354 -0.11021,-76.7687 1.10909,-77.24589c2.06886,-0.80969 151.41433,118.4561 151.92482,118.95524c4.65592,4.55233 -0.99548,7.829 -29.07828,30.50907c-120.49369,97.31245 -120.4977,98.55675 -123.0691,97.87586c-0.43639,-0.11555 -0.80698,-0.31322 -0.74442,-66.91571Z\"></path><path d=\"M316.61562,611.03414c0.11517,-90.16257 -0.25516,-99.92912 0.64739,-101.78856c1.56486,-3.22393 131.99102,0.91032 134.6959,-1.89763c2.21336,-2.2977 -0.59362,-129.97807 1.1376,-132.37034c0.7253,-1.00225 11.10552,-0.99175 12.07474,-0.99077c104.50336,0.10564 104.90098,-0.37811 105.967,0.85765c1.56461,1.81373 0.25596,114.18436 0.67852,129.81412c0.1322,4.88975 3.22386,3.28152 99.72028,3.4563c33.0841,0.05992 36.14259,-1.40368 36.21852,4.50462c0.11713,9.11348 1.41954,110.45369 -0.40274,113.92715c-1.81106,3.45208 -130.39967,-0.42618 -134.48289,1.62075c-2.29035,1.14816 -0.36989,101.12392 -1.11542,130.51904c-0.09548,3.76459 -2.13506,3.20617 -47.84854,3.17365c-69.30253,-0.0493 -69.31099,-0.25627 -69.65762,-0.42191c-3.77927,-1.80595 0.16287,-129.33555 -2.24266,-132.58994c-1.79931,-2.43424 -124.06108,-0.29118 -132.80252,-0.97392c-3.81102,-0.29766 -2.58229,-14.8847 -2.58758,-16.8402Z\"></path></g></svg>"
|
|
1125
1125
|
];
|
|
1126
|
-
var _tmpl$2$
|
|
1126
|
+
var _tmpl$2$3 = [
|
|
1127
1127
|
"<div",
|
|
1128
1128
|
" class=\"",
|
|
1129
1129
|
"\" style=\"",
|
|
@@ -1133,17 +1133,15 @@ var _tmpl$2$4 = [
|
|
|
1133
1133
|
"\"><path d=\"M12 4c-4.419 0-8 3.582-8 8s3.581 8 8 8 8-3.582 8-8-3.581-8-8-8zm3.707 10.293a.999.999 0 11-1.414 1.414L12 13.414l-2.293 2.293a.997.997 0 01-1.414 0 .999.999 0 010-1.414L10.586 12 8.293 9.707a.999.999 0 111.414-1.414L12 10.586l2.293-2.293a.999.999 0 111.414 1.414L13.414 12l2.293 2.293z\"></path></svg><!--$-->",
|
|
1134
1134
|
"<!--/--><svg class=\"flex cursor-pointer items-center justify-center rounded-lg bg-blue-500 p-0.5 text-center font-bold text-white hover:bg-blue-600\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\" style=\"",
|
|
1135
1135
|
"\"><path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\"></path></svg></div><div>",
|
|
1136
|
-
"</div><div id=\"inputs\"
|
|
1137
|
-
" class=\"pointer-events-none absolute top-0 z-10 flex cursor-default flex-col\" style=\"",
|
|
1136
|
+
"</div><div id=\"inputs\" class=\"pointer-events-none absolute top-0 z-10 flex cursor-default flex-col\" style=\"",
|
|
1138
1137
|
"\"><div data-handle-type=\"input\"",
|
|
1139
|
-
" class=\"cursor-default rounded-full bg-[#e38b29] shadow-md transition-transform\" style=\"",
|
|
1140
|
-
"\"></div></div><div id=\"outputs\"
|
|
1141
|
-
" style=\"",
|
|
1138
|
+
" class=\"cursor-default rounded-full bg-[#e38b29] shadow-md transition-transform duration-150 ease-in-out hover:scale-150\" style=\"",
|
|
1139
|
+
"\"></div></div><div id=\"outputs\" style=\"",
|
|
1142
1140
|
"\" class=\"pointer-events-none absolute top-0 z-10 flex flex-col\"><div data-handle-type=\"output\"",
|
|
1143
|
-
" class=\"cursor-crosshair rounded-full bg-[#e38b29] shadow-md transition-transform\" style=\"",
|
|
1141
|
+
" class=\"cursor-crosshair rounded-full bg-[#e38b29] shadow-md transition-transform duration-150 ease-in-out hover:scale-150\" style=\"",
|
|
1144
1142
|
"\"></div></div></div>"
|
|
1145
1143
|
];
|
|
1146
|
-
var _tmpl$3$
|
|
1144
|
+
var _tmpl$3$1 = [
|
|
1147
1145
|
"<div",
|
|
1148
1146
|
" class=\"p-3 select-none\"><!--$-->",
|
|
1149
1147
|
"<!--/--><!--$-->",
|
|
@@ -1200,19 +1198,19 @@ var NodeComponent = (props) => {
|
|
|
1200
1198
|
if (!edges) return false;
|
|
1201
1199
|
return edges.some(({ to }) => to === props.id);
|
|
1202
1200
|
} });
|
|
1203
|
-
return ssr(_tmpl$2$
|
|
1201
|
+
return ssr(_tmpl$2$3, ssrHydrationKey(), `flex flex-col absolute cursor-grab bg-white rounded-md shadow-md select-none transition-[border,box-shadow] duration-200 ease-in-out hover:shadow-lg draggable ${selected() ? "border border-[#e38c29] z-100" : ""} ${!selected() ? "border border-[#e6d4be] z-1" : ""} group min-w-48`, ssrStyleProperty("top:", `${escape(node().y, true)}px`) + ssrStyleProperty(";left:", `${escape(node().x, true)}px`), ssrAttribute("id", escape(props.id, true), false), `pointer-events-none absolute flex items-center justify-end -top-7.5 right-0 transition-all duration-200 ease-in-out space-x-2 ${selected() ? "w-full opacity-100" : ""} ${!selected() ? "w-0 -right-3 opacity-0 overflow-hidden" : ""}`, ssrStyleProperty("overflow:", "visible") + ssrStyleProperty(";pointer-events:", "all") + ssrStyleProperty(";width:", `${escape(12, true) * 2}px`) + ssrStyleProperty(";height:", `${escape(12, true) * 2}px`), escape(createComponent(Show, {
|
|
1204
1202
|
get when() {
|
|
1205
1203
|
return hasParent();
|
|
1206
1204
|
},
|
|
1207
1205
|
get children() {
|
|
1208
|
-
return ssr(_tmpl$$
|
|
1206
|
+
return ssr(_tmpl$$5, ssrHydrationKey(), ssrStyleProperty("pointer-events:", "all") + ssrStyleProperty(";fill-rule:", "evenodd") + ssrStyleProperty(";clip-rule:", "evenodd") + ssrStyleProperty(";stroke-linejoin:", "round") + ssrStyleProperty(";stroke-miterlimit:", "2") + ssrStyleProperty(";width:", `${escape(12, true) * 2}px`) + ssrStyleProperty(";height:", `${escape(12, true) * 2}px`));
|
|
1209
1207
|
}
|
|
1210
1208
|
})), ssrStyleProperty("pointer-events:", "all") + ssrStyleProperty(";width:", `${escape(12, true) * 2}px`) + ssrStyleProperty(";height:", `${escape(12, true) * 2}px`), escape(createComponent(Show, {
|
|
1211
1209
|
get when() {
|
|
1212
1210
|
return props.children;
|
|
1213
1211
|
},
|
|
1214
1212
|
get fallback() {
|
|
1215
|
-
return ssr(_tmpl$3$
|
|
1213
|
+
return ssr(_tmpl$3$1, ssrHydrationKey(), escape(createComponent(Show, {
|
|
1216
1214
|
get when() {
|
|
1217
1215
|
return node().data.label;
|
|
1218
1216
|
},
|
|
@@ -1243,26 +1241,57 @@ var NodeComponent = (props) => {
|
|
|
1243
1241
|
return props.children;
|
|
1244
1242
|
} }, () => node().data));
|
|
1245
1243
|
}
|
|
1246
|
-
})),
|
|
1244
|
+
})), ssrStyleProperty("left:", `-${escape(18, true)}px`), ssrAttribute("data-node-id", escape(props.id, true), false), ssrStyleProperty("width:", `${escape(12, true)}px`) + ssrStyleProperty(";height:", `${escape(12, true)}px`) + ssrStyleProperty(";margin-top:", `${escape(12, true)}px`) + ssrStyleProperty(";pointer-events:", "all"), ssrStyleProperty("right:", `-${escape(18, true)}px`), ssrAttribute("data-node-id", escape(props.id, true), false), ssrStyleProperty("width:", `${escape(12, true)}px`) + ssrStyleProperty(";height:", `${escape(12, true)}px`) + ssrStyleProperty(";margin-top:", `${escape(12, true)}px`) + ssrStyleProperty(";pointer-events:", "all"));
|
|
1247
1245
|
};
|
|
1248
1246
|
//#endregion
|
|
1247
|
+
//#region src/ui/utils.ts
|
|
1248
|
+
/**
|
|
1249
|
+
* Merges conditional CSS class names using `clsx` and resolves Tailwind CSS class
|
|
1250
|
+
* conflicts with `twMerge`.
|
|
1251
|
+
*
|
|
1252
|
+
* @param inputs - Variable list of class values, objects, or arrays.
|
|
1253
|
+
*
|
|
1254
|
+
* @returns The resolved single class name string.
|
|
1255
|
+
*/
|
|
1256
|
+
function cn(...inputs) {
|
|
1257
|
+
return twMerge(clsx(inputs));
|
|
1258
|
+
}
|
|
1259
|
+
//#endregion
|
|
1249
1260
|
//#region src/ui/components/Panels.tsx
|
|
1250
|
-
var _tmpl$$
|
|
1251
|
-
"<div",
|
|
1252
|
-
" class=\"absolute top-4 left-4 z-50\">",
|
|
1253
|
-
"</div>"
|
|
1254
|
-
];
|
|
1255
|
-
var _tmpl$2$3 = [
|
|
1261
|
+
var _tmpl$$4 = [
|
|
1256
1262
|
"<div",
|
|
1257
|
-
" class=\"
|
|
1263
|
+
" class=\"",
|
|
1264
|
+
"\">",
|
|
1258
1265
|
"</div>"
|
|
1259
1266
|
];
|
|
1260
|
-
var _tmpl$
|
|
1267
|
+
var _tmpl$2$2 = [
|
|
1261
1268
|
"<div",
|
|
1262
|
-
" class=\"
|
|
1263
|
-
"
|
|
1269
|
+
" class=\"pointer-events-none absolute inset-0\"><!--$-->",
|
|
1270
|
+
"<!--/--><!--$-->",
|
|
1271
|
+
"<!--/--><!--$-->",
|
|
1272
|
+
"<!--/--></div>"
|
|
1264
1273
|
];
|
|
1265
1274
|
/**
|
|
1275
|
+
* Overlay slot component rendering an optional panel component with z-index
|
|
1276
|
+
* positioning.
|
|
1277
|
+
*
|
|
1278
|
+
* @param props - Panel properties of type {@linkcode PanelProps}.
|
|
1279
|
+
*
|
|
1280
|
+
* @returns The rendered panel container element or fallback.
|
|
1281
|
+
*
|
|
1282
|
+
* @see {@linkcode cn}
|
|
1283
|
+
*/
|
|
1284
|
+
var Panel = (props) => {
|
|
1285
|
+
const exists = isDefined(props.children);
|
|
1286
|
+
return createComponent(Show, {
|
|
1287
|
+
get when() {
|
|
1288
|
+
return props.children;
|
|
1289
|
+
},
|
|
1290
|
+
keyed: true,
|
|
1291
|
+
children: (Children) => ssr(_tmpl$$4, ssrHydrationKey(), `${escape(cn(props.class) || "", true)} ${exists ? "z-50" : ""}`, escape(createComponent(Children, {})))
|
|
1292
|
+
});
|
|
1293
|
+
};
|
|
1294
|
+
/**
|
|
1266
1295
|
* Overlay container rendering custom panel slots positioned around the flowchart
|
|
1267
1296
|
* canvas.
|
|
1268
1297
|
*
|
|
@@ -1271,33 +1300,26 @@ var _tmpl$3$1 = [
|
|
|
1271
1300
|
* @returns Rendered overlay panels JSX elements.
|
|
1272
1301
|
*/
|
|
1273
1302
|
var Panels = (props) => {
|
|
1274
|
-
return
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
get when() {
|
|
1291
|
-
return props.bottomLeft;
|
|
1292
|
-
},
|
|
1293
|
-
keyed: true,
|
|
1294
|
-
children: (Panel) => ssr(_tmpl$3$1, ssrHydrationKey(), escape(createComponent(Panel, {})))
|
|
1295
|
-
})
|
|
1296
|
-
];
|
|
1303
|
+
return ssr(_tmpl$2$2, ssrHydrationKey(), escape(createComponent(Panel, {
|
|
1304
|
+
get children() {
|
|
1305
|
+
return props.topLeft;
|
|
1306
|
+
},
|
|
1307
|
+
"class": "absolute top-4 left-4"
|
|
1308
|
+
})), escape(createComponent(Panel, {
|
|
1309
|
+
get children() {
|
|
1310
|
+
return props.topRight;
|
|
1311
|
+
},
|
|
1312
|
+
"class": "absolute top-4 right-4"
|
|
1313
|
+
})), escape(createComponent(Panel, {
|
|
1314
|
+
get children() {
|
|
1315
|
+
return props.bottomLeft;
|
|
1316
|
+
},
|
|
1317
|
+
"class": "absolute bottom-4 left-4"
|
|
1318
|
+
})));
|
|
1297
1319
|
};
|
|
1298
1320
|
//#endregion
|
|
1299
1321
|
//#region src/ui/components/NodesBoard.tsx
|
|
1300
|
-
var _tmpl$$
|
|
1322
|
+
var _tmpl$$3 = [
|
|
1301
1323
|
"<div",
|
|
1302
1324
|
" class=\"relative h-full w-full overflow-auto\"><!--$-->",
|
|
1303
1325
|
"<!--/--><div class=\"",
|
|
@@ -1308,7 +1330,7 @@ var _tmpl$$6 = [
|
|
|
1308
1330
|
"<!--/--><!--$-->",
|
|
1309
1331
|
"<!--/--></div></div></div>"
|
|
1310
1332
|
];
|
|
1311
|
-
var _tmpl$2$
|
|
1333
|
+
var _tmpl$2$1 = [
|
|
1312
1334
|
"<div",
|
|
1313
1335
|
" class=\"absolute right-4 bottom-4 z-50 flex items-center gap-2 rounded-xl border border-gray-200 bg-white/90 p-2 shadow-lg backdrop-blur-md\"><button type=\"button\" class=\"flex size-9 cursor-pointer items-center justify-center rounded-lg bg-gray-100 text-lg font-bold text-gray-700 shadow-sm transition-all duration-150 hover:bg-gray-200 active:scale-95\" title=\"Zoom out\" aria-label=\"Zoom out\">-</button><button type=\"button\" class=\"h-9 cursor-pointer rounded-lg px-2 text-xs font-semibold text-gray-700 transition-colors hover:bg-gray-100\" title=\"Reset zoom\" aria-label=\"Reset zoom\"><!--$-->",
|
|
1314
1336
|
"<!--/-->%</button><button type=\"button\" class=\"flex size-9 cursor-pointer items-center justify-center rounded-lg bg-gray-100 text-lg font-bold text-gray-700 shadow-sm transition-all duration-150 hover:bg-gray-200 active:scale-95\" title=\"Zoom in\" aria-label=\"Zoom in\">+</button><div class=\"h-5 w-px bg-gray-300\"></div><button type=\"button\" class=\"flex size-9 cursor-pointer items-center justify-center rounded-lg bg-blue-600 text-white shadow transition-all duration-150 hover:bg-blue-700 active:scale-95\" title=\"Add parent node\" aria-label=\"Add parent node\"><svg class=\"size-5\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\"></path></svg></button></div>"
|
|
@@ -1455,7 +1477,7 @@ var NodesBoard = (props) => {
|
|
|
1455
1477
|
},
|
|
1456
1478
|
get children() {
|
|
1457
1479
|
return [
|
|
1458
|
-
ssr(_tmpl$$
|
|
1480
|
+
ssr(_tmpl$$3, ssrHydrationKey(), escape(createComponent(DragDropSensors, {})), `relative cursor-crosshair overflow-hidden ${isPanning() ? "cursor-grabbing" : ""}`, ssrStyleProperty("height:", escape(cHeight(), true)) + ssrStyleProperty(";width:", escape(cWidth(), true)), ssrStyleProperty("scale:", escape(zoom(), true)) + ssrStyleProperty(";transform-origin:", "top left"), escape(createComponent(DragBounds, {})), escape(createComponent(EdgesBoard, {})), escape(createComponent(For, {
|
|
1459
1481
|
get each() {
|
|
1460
1482
|
return nodeIds();
|
|
1461
1483
|
},
|
|
@@ -1467,7 +1489,7 @@ var NodesBoard = (props) => {
|
|
|
1467
1489
|
})
|
|
1468
1490
|
}))),
|
|
1469
1491
|
createComponent(Panels, mergeProps(() => props.panels)),
|
|
1470
|
-
ssr(_tmpl$2$
|
|
1492
|
+
ssr(_tmpl$2$1, ssrHydrationKey(), escape(Math.round(zoom() * 100))),
|
|
1471
1493
|
createComponent(Show, {
|
|
1472
1494
|
get when() {
|
|
1473
1495
|
return !selectedId();
|
|
@@ -1482,7 +1504,7 @@ var NodesBoard = (props) => {
|
|
|
1482
1504
|
};
|
|
1483
1505
|
//#endregion
|
|
1484
1506
|
//#region src/ui/components/FlowChart.tsx
|
|
1485
|
-
var _tmpl$$
|
|
1507
|
+
var _tmpl$$2 = [
|
|
1486
1508
|
"<div",
|
|
1487
1509
|
" class=\"relative h-full w-full\"><div class=\"h-full w-full\" style=\"",
|
|
1488
1510
|
"\">",
|
|
@@ -1506,7 +1528,7 @@ var FlowChart = (props) => {
|
|
|
1506
1528
|
const primaryNodes = props.config?.nodes ?? DEFAULT_NODES;
|
|
1507
1529
|
const primaryEdges = props.config?.edges;
|
|
1508
1530
|
const service = useFlow();
|
|
1509
|
-
const
|
|
1531
|
+
const fromSignal = createState(service, { selector: (s) => s.context.newEdge?.from });
|
|
1510
1532
|
onCleanup(service.pause);
|
|
1511
1533
|
onMount(() => {
|
|
1512
1534
|
service.resume();
|
|
@@ -1519,39 +1541,59 @@ var FlowChart = (props) => {
|
|
|
1519
1541
|
}
|
|
1520
1542
|
});
|
|
1521
1543
|
});
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
if (targetId && targetId !== from) service.send({
|
|
1538
|
-
type: "ADD_EDGE",
|
|
1539
|
-
payload: {
|
|
1540
|
-
from,
|
|
1541
|
-
to: targetId
|
|
1542
|
-
}
|
|
1543
|
-
});
|
|
1544
|
+
let added = false;
|
|
1545
|
+
let activeHandle = null;
|
|
1546
|
+
const clearActiveHandle = () => {
|
|
1547
|
+
if (activeHandle) {
|
|
1548
|
+
activeHandle.classList.remove("scale-150");
|
|
1549
|
+
activeHandle = null;
|
|
1550
|
+
added = false;
|
|
1551
|
+
}
|
|
1552
|
+
};
|
|
1553
|
+
const handlePointerMove = (e) => {
|
|
1554
|
+
service.send({
|
|
1555
|
+
type: "MOVE_NEW_EDGE",
|
|
1556
|
+
payload: {
|
|
1557
|
+
x: e.clientX,
|
|
1558
|
+
y: e.clientY
|
|
1544
1559
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1560
|
+
});
|
|
1561
|
+
const inputHandle = document.elementsFromPoint(e.clientX, e.clientY).map((el) => el.closest(".rounded-full[data-handle-type=\"input\"]")).find((handle) => Boolean(handle && handle.id !== "inputs"));
|
|
1562
|
+
if (activeHandle && activeHandle !== inputHandle) clearActiveHandle();
|
|
1563
|
+
if (inputHandle) {
|
|
1564
|
+
if (activeHandle !== inputHandle) {
|
|
1565
|
+
inputHandle.classList.add("scale-150");
|
|
1566
|
+
activeHandle = inputHandle;
|
|
1567
|
+
added = true;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
};
|
|
1571
|
+
const createHandlePointerUp = (from) => (e) => {
|
|
1572
|
+
const inputHandle = document.elementsFromPoint(e.clientX, e.clientY).map((el) => el.closest(".rounded-full[data-handle-type=\"input\"]")).find((handle) => Boolean(handle && handle.id !== "inputs"));
|
|
1573
|
+
const to = inputHandle?.getAttribute("data-node-id");
|
|
1574
|
+
if (inputHandle && to) service.send({
|
|
1575
|
+
type: "ADD_EDGE",
|
|
1576
|
+
payload: {
|
|
1577
|
+
from,
|
|
1578
|
+
to
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
clearActiveHandle();
|
|
1582
|
+
service.send("CLEAR_NEW_EDGE");
|
|
1583
|
+
};
|
|
1584
|
+
createEffect(() => {
|
|
1585
|
+
const from = fromSignal();
|
|
1586
|
+
if (!from || added) return;
|
|
1587
|
+
const handlePointerUp = createHandlePointerUp(from);
|
|
1547
1588
|
window.addEventListener("pointermove", handlePointerMove);
|
|
1548
1589
|
window.addEventListener("pointerup", handlePointerUp);
|
|
1549
1590
|
onCleanup(() => {
|
|
1591
|
+
clearActiveHandle();
|
|
1550
1592
|
window.removeEventListener("pointermove", handlePointerMove);
|
|
1551
1593
|
window.removeEventListener("pointerup", handlePointerUp);
|
|
1552
1594
|
});
|
|
1553
1595
|
});
|
|
1554
|
-
return ssr(_tmpl$$
|
|
1596
|
+
return ssr(_tmpl$$2, ssrHydrationKey(), ssrStyleProperty("cursor:", fromSignal() ? "inherit" : "crosshair"), escape(createComponent(NodesBoard, {
|
|
1555
1597
|
get panels() {
|
|
1556
1598
|
return props.panels;
|
|
1557
1599
|
},
|
|
@@ -1561,207 +1603,6 @@ var FlowChart = (props) => {
|
|
|
1561
1603
|
})));
|
|
1562
1604
|
};
|
|
1563
1605
|
//#endregion
|
|
1564
|
-
//#region src/ui/utils.ts
|
|
1565
|
-
/**
|
|
1566
|
-
* Merges conditional CSS class names using `clsx` and resolves Tailwind CSS class
|
|
1567
|
-
* conflicts with `twMerge`.
|
|
1568
|
-
*
|
|
1569
|
-
* @param inputs - Variable list of class values, objects, or arrays.
|
|
1570
|
-
*
|
|
1571
|
-
* @returns The resolved single class name string.
|
|
1572
|
-
*/
|
|
1573
|
-
function cn(...inputs) {
|
|
1574
|
-
return twMerge(clsx(inputs));
|
|
1575
|
-
}
|
|
1576
|
-
//#endregion
|
|
1577
|
-
//#region src/ui/globals/helpers/espace.ts
|
|
1578
|
-
/**
|
|
1579
|
-
* Returns a zero-width space if string is empty, preserving layout flow.
|
|
1580
|
-
*
|
|
1581
|
-
* @param newText - The input text string.
|
|
1582
|
-
*
|
|
1583
|
-
* @returns The input text or zero-width visible space placeholder.
|
|
1584
|
-
*/
|
|
1585
|
-
var espace = (newText) => {
|
|
1586
|
-
if (newText === "") return "";
|
|
1587
|
-
return newText;
|
|
1588
|
-
};
|
|
1589
|
-
//#endregion
|
|
1590
|
-
//#region src/ui/globals/signals/createTyping.ts
|
|
1591
|
-
/**
|
|
1592
|
-
* Creates a reactive typewriter effect signal with oscillatory typing delay and
|
|
1593
|
-
* optional rewind.
|
|
1594
|
-
*
|
|
1595
|
-
* @param props - Configuration properties of type {@linkcode Props}.
|
|
1596
|
-
*
|
|
1597
|
-
* @returns An object containing the current text signal, type trigger, and text
|
|
1598
|
-
* setter.
|
|
1599
|
-
*/
|
|
1600
|
-
var createTyping = ({ content, min, ...props }) => {
|
|
1601
|
-
const rewind = props.rewind ?? false;
|
|
1602
|
-
const rewindDelay = props.rewindDelay ?? 500;
|
|
1603
|
-
const OSCILLATION = Math.min(min / 10 + content.length / 10, 10);
|
|
1604
|
-
const [text, setText] = createSignal("");
|
|
1605
|
-
let timeoutId;
|
|
1606
|
-
let index = 0;
|
|
1607
|
-
let isTyping = true;
|
|
1608
|
-
const max = min + OSCILLATION;
|
|
1609
|
-
let interval = min;
|
|
1610
|
-
let intervalDirection = 1;
|
|
1611
|
-
const type = () => {
|
|
1612
|
-
if (isTyping) {
|
|
1613
|
-
if (index < content.length) {
|
|
1614
|
-
setText((prev) => prev + content[index]);
|
|
1615
|
-
index++;
|
|
1616
|
-
timeoutId = setTimeout(type, interval);
|
|
1617
|
-
} else if (rewind) {
|
|
1618
|
-
isTyping = false;
|
|
1619
|
-
intervalDirection = 1;
|
|
1620
|
-
timeoutId = setTimeout(type, rewindDelay);
|
|
1621
|
-
}
|
|
1622
|
-
} else if (index > 0) {
|
|
1623
|
-
index--;
|
|
1624
|
-
setText(espace(content.substring(0, index)));
|
|
1625
|
-
timeoutId = setTimeout(type, interval);
|
|
1626
|
-
} else {
|
|
1627
|
-
isTyping = true;
|
|
1628
|
-
intervalDirection = 1;
|
|
1629
|
-
timeoutId = setTimeout(type, rewindDelay);
|
|
1630
|
-
}
|
|
1631
|
-
interval += intervalDirection;
|
|
1632
|
-
if (interval >= max) intervalDirection = -1;
|
|
1633
|
-
else if (interval <= min) intervalDirection = 1;
|
|
1634
|
-
};
|
|
1635
|
-
onCleanup(() => {
|
|
1636
|
-
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1637
|
-
});
|
|
1638
|
-
return {
|
|
1639
|
-
text,
|
|
1640
|
-
type,
|
|
1641
|
-
setText
|
|
1642
|
-
};
|
|
1643
|
-
};
|
|
1644
|
-
//#endregion
|
|
1645
|
-
//#region src/ui/globals/components/atoms/TypingText.tsx
|
|
1646
|
-
var _tmpl$$4 = [
|
|
1647
|
-
"<div",
|
|
1648
|
-
">",
|
|
1649
|
-
"</div>"
|
|
1650
|
-
];
|
|
1651
|
-
/**
|
|
1652
|
-
* Renders animated text with a typewriter keystroke animation effect.
|
|
1653
|
-
*
|
|
1654
|
-
* @param props - Component configuration properties of type {@linkcode Props}.
|
|
1655
|
-
*
|
|
1656
|
-
* @returns Rendered animated typing text JSX container.
|
|
1657
|
-
*/
|
|
1658
|
-
var TypingText = (props) => {
|
|
1659
|
-
const min = props.interval ?? 62;
|
|
1660
|
-
const rewind = props.rewind ?? false;
|
|
1661
|
-
const rewindDelay = props.rewindDelay ?? 500;
|
|
1662
|
-
const content = props.children;
|
|
1663
|
-
const disabled = createMemo(() => props.disabled ? props.disabled() : false, false);
|
|
1664
|
-
const { text, type, setText } = createTyping({
|
|
1665
|
-
content,
|
|
1666
|
-
min,
|
|
1667
|
-
rewind,
|
|
1668
|
-
rewindDelay
|
|
1669
|
-
});
|
|
1670
|
-
createEffect(on(disabled, () => setText("")));
|
|
1671
|
-
createEffect(() => {
|
|
1672
|
-
if (disabled()) setText(content);
|
|
1673
|
-
else type();
|
|
1674
|
-
});
|
|
1675
|
-
return ssr(_tmpl$$4, ssrHydrationKey() + ssrAttribute("class", escape(props.class, true), false), escape(text()));
|
|
1676
|
-
};
|
|
1677
|
-
//#endregion
|
|
1678
|
-
//#region src/ui/globals/components/molecules/FadingDots.tsx
|
|
1679
|
-
var _tmpl$$3 = [
|
|
1680
|
-
"<div",
|
|
1681
|
-
" class=\"mt-4 flex items-center justify-center space-x-4\">",
|
|
1682
|
-
"</div>"
|
|
1683
|
-
];
|
|
1684
|
-
/**
|
|
1685
|
-
* Loading animation component displaying animated pulsing dots.
|
|
1686
|
-
*
|
|
1687
|
-
* @param props - Fading dots configuration properties.
|
|
1688
|
-
* @param props.count - The number of dots to display.
|
|
1689
|
-
* @param props.duration - Animation duration in milliseconds. Defaults to 500.
|
|
1690
|
-
* @param props.innerProps - Additional properties and CSS styles applied to dot
|
|
1691
|
-
* elements.
|
|
1692
|
-
*
|
|
1693
|
-
* @returns Rendered animated dots container JSX element.
|
|
1694
|
-
*/
|
|
1695
|
-
var FadingDots = ({ count: length, innerProps = {}, duration = 500 }) => {
|
|
1696
|
-
const [local, rest] = splitProps(innerProps, ["class", "style"]);
|
|
1697
|
-
return ssr(_tmpl$$3, ssrHydrationKey(), escape(Array.from({ length }, (_, i) => ssrElement("span", mergeProps({
|
|
1698
|
-
get ["class"]() {
|
|
1699
|
-
return cn("rounded-full animate-out direction-alternate repeat-infinite fade-out-5 size-4 bg-gray-600", local.class);
|
|
1700
|
-
},
|
|
1701
|
-
get style() {
|
|
1702
|
-
return {
|
|
1703
|
-
...local.style,
|
|
1704
|
-
"animation-duration": `${duration}ms`,
|
|
1705
|
-
"animation-delay": `${duration / i}ms`
|
|
1706
|
-
};
|
|
1707
|
-
},
|
|
1708
|
-
"aria-hidden": "true"
|
|
1709
|
-
}, rest), void 0, true))));
|
|
1710
|
-
};
|
|
1711
|
-
//#endregion
|
|
1712
|
-
//#region src/ui/globals/components/organisms/LoadingFallback.tsx
|
|
1713
|
-
var _tmpl$$2 = [
|
|
1714
|
-
"<div",
|
|
1715
|
-
" role=\"status\" aria-live=\"polite\" aria-label=\"Chargement en cours\"><div class=\"relative\"><div",
|
|
1716
|
-
" aria-hidden=\"true\"></div><div",
|
|
1717
|
-
" aria-hidden=\"true\"></div></div><div class=\"text-center\"",
|
|
1718
|
-
"><!--$-->",
|
|
1719
|
-
"<!--/--><!--$-->",
|
|
1720
|
-
"<!--/--></div></div>"
|
|
1721
|
-
];
|
|
1722
|
-
/**
|
|
1723
|
-
* Fallback loading screen component displaying an animated spinner and typewriter
|
|
1724
|
-
* text.
|
|
1725
|
-
*
|
|
1726
|
-
* @example
|
|
1727
|
-
* ```tsx
|
|
1728
|
-
* <Show when={data()} fallback={<LoadingFallback />}>
|
|
1729
|
-
* <DataComponent data={data()!} />
|
|
1730
|
-
* </Show>;
|
|
1731
|
-
* ```;
|
|
1732
|
-
*
|
|
1733
|
-
* @param props - Loading fallback properties of type
|
|
1734
|
-
* {@linkcode LoadingFallbackProps}.
|
|
1735
|
-
*
|
|
1736
|
-
* @returns Rendered full-screen loading fallback JSX element.
|
|
1737
|
-
*/
|
|
1738
|
-
var LoadingFallback = (props) => {
|
|
1739
|
-
const message = props.message ?? "Chargement en cours...";
|
|
1740
|
-
const spinnerSizes = {
|
|
1741
|
-
sm: "w-8 h-8",
|
|
1742
|
-
md: "w-12 h-12",
|
|
1743
|
-
lg: "w-16 h-16",
|
|
1744
|
-
xl: "w-24 h-24"
|
|
1745
|
-
};
|
|
1746
|
-
const size = props.size ?? "lg";
|
|
1747
|
-
return ssr(_tmpl$$2, ssrHydrationKey() + ssrAttribute("class", escape(cn("flex flex-col items-center justify-center gap-6", "h-screen w-screen overflow-hidden p-4", props.class), true), false), ssrAttribute("class", escape(cn(spinnerSizes[size], "rounded-full border-4 border-[#4B9CAD]/20", "animate-spin", "border-t-[#4B9CAD]"), true), false), ssrAttribute("class", escape(cn("absolute inset-2", "rounded-full border-4 border-transparent", "border-b-[#4B9CAD]/40", "animate-spin", "animation-duration-[1.5s]", "direction-[reverse]"), true), false), ssrAttribute("aria-label", escape(message, true), false), escape(createComponent(TypingText, {
|
|
1748
|
-
"class": "text-lg font-medium text-gray-700 md:text-xl dark:text-gray-300",
|
|
1749
|
-
get interval() {
|
|
1750
|
-
return props.interval ?? 80;
|
|
1751
|
-
},
|
|
1752
|
-
get rewind() {
|
|
1753
|
-
return props.rewind ?? true;
|
|
1754
|
-
},
|
|
1755
|
-
get rewindDelay() {
|
|
1756
|
-
return props.rewindDelay ?? 2e3;
|
|
1757
|
-
},
|
|
1758
|
-
children: message
|
|
1759
|
-
})), escape(createComponent(FadingDots, {
|
|
1760
|
-
count: 5,
|
|
1761
|
-
innerProps: { class: "bg-[#3d8091]" }
|
|
1762
|
-
})));
|
|
1763
|
-
};
|
|
1764
|
-
//#endregion
|
|
1765
1606
|
//#region src/ui/Flow.tsx
|
|
1766
1607
|
var _tmpl$$1 = [
|
|
1767
1608
|
"<div",
|
|
@@ -1769,47 +1610,24 @@ var _tmpl$$1 = [
|
|
|
1769
1610
|
"\" class=\"relative flex h-full w-full rounded-lg border-2 border-gray-600 bg-white bg-size-[30px_30px]\">",
|
|
1770
1611
|
"</div>"
|
|
1771
1612
|
];
|
|
1772
|
-
var _tmpl$2$1 = [
|
|
1773
|
-
"<div",
|
|
1774
|
-
" class=\"relative flex flex-1 items-center justify-center\">",
|
|
1775
|
-
"</div>"
|
|
1776
|
-
];
|
|
1777
1613
|
/**
|
|
1778
1614
|
* Root Flow component wrapping the {@linkcode FlowChart} inside the flow context
|
|
1779
1615
|
* provider.
|
|
1780
1616
|
*
|
|
1781
|
-
* @template | {@linkcode NodeData} `D` - Custom node data dictionary type
|
|
1782
|
-
* {@linkcode NodeData}.
|
|
1617
|
+
* @template | Type {@linkcode NodeData} `D` - Custom node data dictionary type
|
|
1618
|
+
* extending type {@linkcode NodeData}.
|
|
1783
1619
|
*
|
|
1784
1620
|
* @param props - Flow chart configuration and callbacks of type
|
|
1785
1621
|
* {@linkcode FlowProps}.
|
|
1786
1622
|
*
|
|
1787
1623
|
* @returns The rendered Solid component.
|
|
1788
1624
|
*
|
|
1789
|
-
* @see {@linkcode Provider}
|
|
1625
|
+
* @see {@linkcode Provider}
|
|
1790
1626
|
*/
|
|
1791
1627
|
var Flow = (props) => {
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
get when() {
|
|
1796
|
-
return isMounted();
|
|
1797
|
-
},
|
|
1798
|
-
keyed: true,
|
|
1799
|
-
get fallback() {
|
|
1800
|
-
return ssr(_tmpl$2$1, ssrHydrationKey(), escape(createComponent(LoadingFallback, {
|
|
1801
|
-
message: "Chart is loading...",
|
|
1802
|
-
interval: 35,
|
|
1803
|
-
rewind: true,
|
|
1804
|
-
rewindDelay: 1e3
|
|
1805
|
-
})));
|
|
1806
|
-
},
|
|
1807
|
-
get children() {
|
|
1808
|
-
return createComponent(Provider, { get children() {
|
|
1809
|
-
return createComponent(FlowChart, props);
|
|
1810
|
-
} });
|
|
1811
|
-
}
|
|
1812
|
-
})));
|
|
1628
|
+
return ssr(_tmpl$$1, ssrHydrationKey(), ssrStyleProperty("background-image:", "radial-gradient(circle, #b8b8b8bf 1px, rgba(0, 0, 0, 0) 1px)"), escape(createComponent(Provider, { get children() {
|
|
1629
|
+
return createComponent(FlowChart, props);
|
|
1630
|
+
} })));
|
|
1813
1631
|
};
|
|
1814
1632
|
//#endregion
|
|
1815
1633
|
//#region src/ui/globals/directives/clickOutside.ts
|
|
@@ -2045,7 +1863,11 @@ var EditPanel = (props) => {
|
|
|
2045
1863
|
get when() {
|
|
2046
1864
|
return hooks.editing();
|
|
2047
1865
|
},
|
|
2048
|
-
children: (node) => ssr(_tmpl$, ssrHydrationKey(), `${escape(cn(`w-80 cursor-default rounded-2xl border border-gray-200 bg-white/95 p-4 shadow-xl backdrop-blur-md transition-all ${props.class ?? ""}`) || "", true)} ${escape(ssrClassList(
|
|
1866
|
+
children: (node) => ssr(_tmpl$, ssrHydrationKey(), `${escape(cn(`w-80 cursor-default rounded-2xl border border-gray-200 bg-white/95 p-4 shadow-xl backdrop-blur-md transition-all ${props.class ?? ""}`) || "", true)} ${escape(ssrClassList({
|
|
1867
|
+
...classList(),
|
|
1868
|
+
"pointer-events-none! -z-10": !hooks.editing(),
|
|
1869
|
+
"pointer-events-all! z-50": !!hooks.editing()
|
|
1870
|
+
}) || "", true)}`, ssrStyle(props.style), escape(createComponent(Show, {
|
|
2049
1871
|
get when() {
|
|
2050
1872
|
return props.header;
|
|
2051
1873
|
},
|
package/lib/ui/Flow.d.ts
CHANGED
|
@@ -5,15 +5,15 @@ import { FlowProps } from './components/FlowChart.types';
|
|
|
5
5
|
* Root Flow component wrapping the {@linkcode FlowChart} inside the flow context
|
|
6
6
|
* provider.
|
|
7
7
|
*
|
|
8
|
-
* @template | {@linkcode NodeData} `D` - Custom node data dictionary type
|
|
9
|
-
* {@linkcode NodeData}.
|
|
8
|
+
* @template | Type {@linkcode NodeData} `D` - Custom node data dictionary type
|
|
9
|
+
* extending type {@linkcode NodeData}.
|
|
10
10
|
*
|
|
11
11
|
* @param props - Flow chart configuration and callbacks of type
|
|
12
12
|
* {@linkcode FlowProps}.
|
|
13
13
|
*
|
|
14
14
|
* @returns The rendered Solid component.
|
|
15
15
|
*
|
|
16
|
-
* @see {@linkcode Provider}
|
|
16
|
+
* @see {@linkcode Provider}
|
|
17
17
|
*/
|
|
18
18
|
export declare const Flow: <D extends NodeData = NodeData>(props: FlowProps<D>) => JSX.Element;
|
|
19
19
|
//# sourceMappingURL=Flow.d.ts.map
|