@01.software/sdk 0.2.9-dev.260310.cf511cb → 0.2.9-dev.260311.892250f
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/README.md +21 -8
- package/dist/auth.cjs +3 -1
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +36 -3
- package/dist/auth.d.ts +36 -3
- package/dist/auth.js +3 -1
- package/dist/auth.js.map +1 -1
- package/dist/index.cjs +214 -231
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +321 -155
- package/dist/index.d.ts +321 -155
- package/dist/index.js +217 -231
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-Cq93wqIe.d.cts → payload-types-BjvBwB8Z.d.cts} +1601 -1373
- package/dist/{payload-types-Cq93wqIe.d.ts → payload-types-BjvBwB8Z.d.ts} +1601 -1373
- package/dist/ui/code-block.cjs +182 -0
- package/dist/ui/code-block.cjs.map +1 -0
- package/dist/ui/code-block.d.cts +62 -0
- package/dist/ui/code-block.d.ts +62 -0
- package/dist/ui/code-block.js +152 -0
- package/dist/ui/code-block.js.map +1 -0
- package/dist/{flow.cjs → ui/flow.cjs} +120 -96
- package/dist/ui/flow.cjs.map +1 -0
- package/dist/{flow.d.cts → ui/flow.d.cts} +27 -11
- package/dist/{flow.d.ts → ui/flow.d.ts} +27 -11
- package/dist/{flow.js → ui/flow.js} +119 -94
- package/dist/ui/flow.js.map +1 -0
- package/dist/{components.cjs → ui/form.cjs} +27 -520
- package/dist/ui/form.cjs.map +1 -0
- package/dist/ui/form.d.cts +37 -0
- package/dist/ui/form.d.ts +37 -0
- package/dist/{components.js → ui/form.js} +20 -516
- package/dist/ui/form.js.map +1 -0
- package/dist/ui/image.cjs +208 -0
- package/dist/ui/image.cjs.map +1 -0
- package/dist/ui/image.d.cts +44 -0
- package/dist/ui/image.d.ts +44 -0
- package/dist/ui/image.js +180 -0
- package/dist/ui/image.js.map +1 -0
- package/dist/ui/rich-text.cjs +258 -0
- package/dist/ui/rich-text.cjs.map +1 -0
- package/dist/ui/rich-text.d.cts +110 -0
- package/dist/ui/rich-text.d.ts +110 -0
- package/dist/ui/rich-text.js +235 -0
- package/dist/ui/rich-text.js.map +1 -0
- package/dist/{webhook-NRdVwXN7.d.cts → webhook-CszIpUKn.d.cts} +2 -2
- package/dist/{webhook-C_7s0K66.d.ts → webhook-_LdLdjGa.d.ts} +2 -2
- package/dist/webhook.d.cts +2 -2
- package/dist/webhook.d.ts +2 -2
- package/package.json +47 -12
- package/dist/auth-CVVo5UT5.d.ts +0 -298
- package/dist/auth-CqgrT1qd.d.cts +0 -298
- package/dist/components.cjs.map +0 -1
- package/dist/components.d.cts +0 -240
- package/dist/components.d.ts +0 -240
- package/dist/components.js.map +0 -1
- package/dist/flow.cjs.map +0 -1
- package/dist/flow.js.map +0 -1
|
@@ -62,9 +62,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
62
62
|
});
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
// src/
|
|
66
|
-
var
|
|
67
|
-
__export(
|
|
65
|
+
// src/ui/Flow/index.tsx
|
|
66
|
+
var Flow_exports = {};
|
|
67
|
+
__export(Flow_exports, {
|
|
68
68
|
BUILT_IN_EDGE_TYPES: () => BUILT_IN_EDGE_TYPES,
|
|
69
69
|
BUILT_IN_NODE_TYPES: () => BUILT_IN_NODE_TYPES,
|
|
70
70
|
FlowRenderer: () => FlowRenderer,
|
|
@@ -72,11 +72,11 @@ __export(FlowRenderer_exports, {
|
|
|
72
72
|
isFrameNode: () => isFrameNode,
|
|
73
73
|
useFlow: () => useFlow
|
|
74
74
|
});
|
|
75
|
-
module.exports = __toCommonJS(
|
|
75
|
+
module.exports = __toCommonJS(Flow_exports);
|
|
76
76
|
var import_react2 = __toESM(require("react"), 1);
|
|
77
77
|
var import_react3 = require("@xyflow/react");
|
|
78
78
|
|
|
79
|
-
// src/
|
|
79
|
+
// src/ui/Flow/types.ts
|
|
80
80
|
function isDynamicNode(node) {
|
|
81
81
|
return node.type === "dynamic";
|
|
82
82
|
}
|
|
@@ -84,7 +84,7 @@ function isFrameNode(node) {
|
|
|
84
84
|
return node.type === "frame";
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
// src/
|
|
87
|
+
// src/ui/Flow/built-in-node-types.ts
|
|
88
88
|
var BUILT_IN_NODE_TYPES = [
|
|
89
89
|
{
|
|
90
90
|
slug: "text",
|
|
@@ -107,68 +107,69 @@ var BUILT_IN_NODE_TYPES = [
|
|
|
107
107
|
}
|
|
108
108
|
];
|
|
109
109
|
|
|
110
|
-
// src/
|
|
110
|
+
// src/ui/Flow/built-in-edge-types.ts
|
|
111
111
|
var BUILT_IN_EDGE_TYPES = [
|
|
112
112
|
{
|
|
113
113
|
slug: "default",
|
|
114
114
|
name: "Default",
|
|
115
115
|
color: "",
|
|
116
116
|
strokeWidth: 2,
|
|
117
|
-
animated:
|
|
117
|
+
animated: false,
|
|
118
118
|
lineStyle: "default",
|
|
119
|
+
markerStart: "none",
|
|
120
|
+
markerEnd: "arrow",
|
|
119
121
|
fields: []
|
|
120
122
|
}
|
|
121
123
|
];
|
|
122
124
|
|
|
123
|
-
// src/
|
|
125
|
+
// src/ui/Flow/useFlow.ts
|
|
124
126
|
var import_react_query = require("@tanstack/react-query");
|
|
125
127
|
var import_react = require("react");
|
|
126
|
-
|
|
127
|
-
function isId(value) {
|
|
128
|
-
return UUID_RE.test(value);
|
|
129
|
-
}
|
|
130
|
-
function apiNodeTypeToNodeTypeDef(doc) {
|
|
128
|
+
function toNodeTypeDef(doc) {
|
|
131
129
|
var _a, _b, _c, _d;
|
|
132
130
|
return {
|
|
133
131
|
slug: String((_a = doc.slug) != null ? _a : ""),
|
|
134
|
-
name: String((_b = doc.
|
|
132
|
+
name: String((_b = doc.title) != null ? _b : ""),
|
|
135
133
|
color: String((_c = doc.color) != null ? _c : "#e5e7eb"),
|
|
136
134
|
defaultSize: (_d = doc.defaultSize) != null ? _d : { width: 200, height: 200 },
|
|
137
135
|
fields: Array.isArray(doc.fields) ? doc.fields : [],
|
|
138
136
|
transparentBackground: Boolean(doc.transparentBackground)
|
|
139
137
|
};
|
|
140
138
|
}
|
|
141
|
-
function
|
|
142
|
-
var _a, _b, _c, _d, _e, _f;
|
|
139
|
+
function toEdgeTypeDef(doc) {
|
|
140
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
143
141
|
return {
|
|
144
142
|
slug: String((_a = doc.slug) != null ? _a : ""),
|
|
145
143
|
name: String((_b = doc.title) != null ? _b : ""),
|
|
146
144
|
color: String((_c = doc.color) != null ? _c : ""),
|
|
147
145
|
strokeWidth: (_d = doc.strokeWidth) != null ? _d : 2,
|
|
148
|
-
animated: (_e = doc.animated) != null ? _e :
|
|
146
|
+
animated: (_e = doc.animated) != null ? _e : false,
|
|
149
147
|
lineStyle: String((_f = doc.lineStyle) != null ? _f : "default"),
|
|
148
|
+
markerStart: String((_g = doc.markerStart) != null ? _g : "none"),
|
|
149
|
+
markerEnd: String((_h = doc.markerEnd) != null ? _h : "arrow"),
|
|
150
150
|
fields: Array.isArray(doc.fields) ? doc.fields : []
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
function useFlow(
|
|
154
|
-
var _a, _b;
|
|
155
|
-
const { client, enabled = true } = options;
|
|
156
|
-
const
|
|
153
|
+
function useFlow(options) {
|
|
154
|
+
var _a, _b, _c;
|
|
155
|
+
const { client, slug, id, enabled = true } = options;
|
|
156
|
+
const hasIdentifier = !!(slug || id);
|
|
157
|
+
const identifier = (_a = id != null ? id : slug) != null ? _a : "";
|
|
157
158
|
const flowQuery = (0, import_react_query.useQuery)({
|
|
158
|
-
queryKey: ["flows",
|
|
159
|
+
queryKey: ["flows", identifier],
|
|
159
160
|
queryFn: () => __async(null, null, function* () {
|
|
160
|
-
if (
|
|
161
|
-
return client.from("flows").findById(
|
|
161
|
+
if (id) {
|
|
162
|
+
return client.from("flows").findById(id);
|
|
162
163
|
}
|
|
163
164
|
const result = yield client.from("flows").find({
|
|
164
|
-
where: { slug: { equals:
|
|
165
|
+
where: { slug: { equals: slug } },
|
|
165
166
|
limit: 1
|
|
166
167
|
});
|
|
167
168
|
const doc = result.docs[0];
|
|
168
|
-
if (!doc) throw new Error(`Flow not found: ${
|
|
169
|
+
if (!doc) throw new Error(`Flow not found: ${slug}`);
|
|
169
170
|
return doc;
|
|
170
171
|
}),
|
|
171
|
-
enabled
|
|
172
|
+
enabled: enabled && hasIdentifier
|
|
172
173
|
}, client.queryClient);
|
|
173
174
|
const nodeTypesQuery = (0, import_react_query.useQuery)({
|
|
174
175
|
queryKey: ["flow-node-types"],
|
|
@@ -188,14 +189,14 @@ function useFlow(slugOrId, options) {
|
|
|
188
189
|
}, client.queryClient);
|
|
189
190
|
const nodeTypeDefs = (0, import_react.useMemo)(() => {
|
|
190
191
|
var _a2;
|
|
191
|
-
const apiDefs = ((_a2 = nodeTypesQuery.data) != null ? _a2 : []).map(
|
|
192
|
+
const apiDefs = ((_a2 = nodeTypesQuery.data) != null ? _a2 : []).map(toNodeTypeDef);
|
|
192
193
|
const builtInSlugs = new Set(BUILT_IN_NODE_TYPES.map((t) => t.slug));
|
|
193
194
|
const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug));
|
|
194
195
|
return [...BUILT_IN_NODE_TYPES, ...customDefs];
|
|
195
196
|
}, [nodeTypesQuery.data]);
|
|
196
197
|
const edgeTypeDefs = (0, import_react.useMemo)(() => {
|
|
197
198
|
var _a2;
|
|
198
|
-
const apiDefs = ((_a2 = edgeTypesQuery.data) != null ? _a2 : []).map(
|
|
199
|
+
const apiDefs = ((_a2 = edgeTypesQuery.data) != null ? _a2 : []).map(toEdgeTypeDef);
|
|
199
200
|
const builtInSlugs = new Set(BUILT_IN_EDGE_TYPES.map((t) => t.slug));
|
|
200
201
|
const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug));
|
|
201
202
|
return [...BUILT_IN_EDGE_TYPES, ...customDefs];
|
|
@@ -208,11 +209,11 @@ function useFlow(slugOrId, options) {
|
|
|
208
209
|
edgeTypeDefs,
|
|
209
210
|
flow,
|
|
210
211
|
isLoading: flowQuery.isLoading || nodeTypesQuery.isLoading || edgeTypesQuery.isLoading,
|
|
211
|
-
error: (
|
|
212
|
+
error: (_c = (_b = flowQuery.error) != null ? _b : nodeTypesQuery.error) != null ? _c : edgeTypesQuery.error
|
|
212
213
|
};
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
// src/
|
|
216
|
+
// src/ui/Flow/index.tsx
|
|
216
217
|
function sanitizeUrl(url) {
|
|
217
218
|
if (!url) return url;
|
|
218
219
|
try {
|
|
@@ -223,6 +224,11 @@ function sanitizeUrl(url) {
|
|
|
223
224
|
return void 0;
|
|
224
225
|
}
|
|
225
226
|
}
|
|
227
|
+
function toMarkerType(value) {
|
|
228
|
+
if (value === "arrow") return import_react3.MarkerType.Arrow;
|
|
229
|
+
if (value === "arrowclosed") return import_react3.MarkerType.ArrowClosed;
|
|
230
|
+
return void 0;
|
|
231
|
+
}
|
|
226
232
|
function renderFieldValue(key, val, fieldDef) {
|
|
227
233
|
if (val == null || val === "") return null;
|
|
228
234
|
const fieldType = fieldDef == null ? void 0 : fieldDef.fieldType;
|
|
@@ -236,87 +242,58 @@ function renderFieldValue(key, val, fieldDef) {
|
|
|
236
242
|
key,
|
|
237
243
|
src: safeUrl,
|
|
238
244
|
alt: "",
|
|
239
|
-
|
|
245
|
+
draggable: false,
|
|
246
|
+
style: { flex: 1, minHeight: 0, width: "100%", objectFit: "contain" }
|
|
240
247
|
}
|
|
241
248
|
);
|
|
242
249
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
style: { display: "block", marginTop: 4, fontSize: "0.85em", color: "#3b82f6", wordBreak: "break-all" }
|
|
254
|
-
},
|
|
255
|
-
String(val)
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
if (fieldType === "color") {
|
|
259
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", { key, style: { display: "flex", alignItems: "center", gap: 6, marginTop: 4 } }, /* @__PURE__ */ import_react2.default.createElement(
|
|
260
|
-
"span",
|
|
261
|
-
{
|
|
262
|
-
style: {
|
|
263
|
-
display: "inline-block",
|
|
264
|
-
width: 14,
|
|
265
|
-
height: 14,
|
|
266
|
-
borderRadius: 3,
|
|
267
|
-
backgroundColor: String(val),
|
|
268
|
-
border: "1px solid rgba(0,0,0,0.1)",
|
|
269
|
-
flexShrink: 0
|
|
270
|
-
}
|
|
250
|
+
return /* @__PURE__ */ import_react2.default.createElement(
|
|
251
|
+
"div",
|
|
252
|
+
{
|
|
253
|
+
key,
|
|
254
|
+
style: {
|
|
255
|
+
fontSize: 11,
|
|
256
|
+
whiteSpace: "pre-wrap",
|
|
257
|
+
wordBreak: "break-word",
|
|
258
|
+
overflow: "hidden",
|
|
259
|
+
flexShrink: 0
|
|
271
260
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const isOn = val === true || val === "true";
|
|
276
|
-
return /* @__PURE__ */ import_react2.default.createElement("p", { key, style: { margin: "4px 0 0", fontSize: "0.85em" } }, isOn ? "On" : "Off");
|
|
277
|
-
}
|
|
278
|
-
return /* @__PURE__ */ import_react2.default.createElement("p", { key, style: { margin: "4px 0 0", fontSize: "0.85em", whiteSpace: "pre-wrap" } }, String(val));
|
|
261
|
+
},
|
|
262
|
+
String(val)
|
|
263
|
+
);
|
|
279
264
|
}
|
|
280
265
|
function DefaultDynamicNode({ data }) {
|
|
281
266
|
const d = data;
|
|
282
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", { style: {
|
|
267
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", { style: { width: "100%", height: "100%", display: "flex", flexDirection: "column" } }, d.fields && Object.entries(d.fields).filter(([, v]) => v != null && v !== "").map(([key, val]) => renderFieldValue(key, val)));
|
|
283
268
|
}
|
|
284
269
|
function EnhancedDynamicNode({ data, typeDef }) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
style: {
|
|
291
|
-
backgroundColor: typeDef.color,
|
|
292
|
-
padding: "4px 12px",
|
|
293
|
-
borderRadius: "6px 6px 0 0",
|
|
294
|
-
fontSize: "0.75em",
|
|
295
|
-
fontWeight: 600,
|
|
296
|
-
color: "rgba(0,0,0,0.6)"
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
typeDef.name
|
|
300
|
-
), /* @__PURE__ */ import_react2.default.createElement("div", { style: { padding: transparent ? 0 : 12 } }, /* @__PURE__ */ import_react2.default.createElement("strong", { style: { display: "block", marginBottom: 4 } }, data.label), data.fields && Object.entries(data.fields).map(([key, val]) => {
|
|
301
|
-
const fieldDef = fieldMap.get(key);
|
|
302
|
-
return renderFieldValue(key, val, fieldDef);
|
|
303
|
-
})));
|
|
270
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", { style: { width: "100%", height: "100%", display: "flex", flexDirection: "column" } }, typeDef.fields.map((f) => {
|
|
271
|
+
const val = data.fields[f.name];
|
|
272
|
+
if (val == null || val === "") return null;
|
|
273
|
+
return renderFieldValue(f.name, val, f);
|
|
274
|
+
}));
|
|
304
275
|
}
|
|
305
276
|
function DefaultFrameNode({ data }) {
|
|
306
|
-
var _a, _b;
|
|
277
|
+
var _a, _b, _c, _d;
|
|
307
278
|
const d = data;
|
|
308
|
-
const
|
|
279
|
+
const baseColor = (_a = d.color) != null ? _a : "rgba(128,128,128,0.15)";
|
|
309
280
|
const padding = (_b = d.padding) != null ? _b : 20;
|
|
281
|
+
const borderStyle = (_c = d.borderStyle) != null ? _c : "dashed";
|
|
282
|
+
const opacity = (_d = d.opacity) != null ? _d : 0.15;
|
|
283
|
+
const bgColor = (() => {
|
|
284
|
+
const m = baseColor.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
285
|
+
if (m) return `rgba(${m[1]},${m[2]},${m[3]},${opacity})`;
|
|
286
|
+
return baseColor;
|
|
287
|
+
})();
|
|
310
288
|
return /* @__PURE__ */ import_react2.default.createElement(
|
|
311
289
|
"div",
|
|
312
290
|
{
|
|
313
291
|
style: {
|
|
314
|
-
backgroundColor:
|
|
292
|
+
backgroundColor: bgColor,
|
|
315
293
|
padding,
|
|
316
294
|
width: "100%",
|
|
317
295
|
height: "100%",
|
|
318
|
-
|
|
319
|
-
border: "2px dashed rgba(128,128,128,0.3)"
|
|
296
|
+
border: borderStyle === "none" ? "none" : `2px ${borderStyle} rgba(128,128,128,0.3)`
|
|
320
297
|
}
|
|
321
298
|
},
|
|
322
299
|
/* @__PURE__ */ import_react2.default.createElement(
|
|
@@ -359,40 +336,87 @@ function createNodeTypes(nodeRenderers, nodeTypeDefsMap) {
|
|
|
359
336
|
types.frame = DefaultFrameNode;
|
|
360
337
|
return types;
|
|
361
338
|
}
|
|
339
|
+
var EDGE_TYPE_MAP = {
|
|
340
|
+
step: "step",
|
|
341
|
+
smoothstep: "smoothstep",
|
|
342
|
+
bezier: "default",
|
|
343
|
+
default: "default"
|
|
344
|
+
};
|
|
345
|
+
function applyEdgeStyles(edges, edgeTypeDefsMap) {
|
|
346
|
+
if (!(edgeTypeDefsMap == null ? void 0 : edgeTypeDefsMap.size)) return edges;
|
|
347
|
+
return edges.map((edge) => {
|
|
348
|
+
var _a;
|
|
349
|
+
const slug = edge.edgeTypeSlug;
|
|
350
|
+
if (!slug) return edge;
|
|
351
|
+
const def = edgeTypeDefsMap.get(slug);
|
|
352
|
+
if (!def) return edge;
|
|
353
|
+
const styled = __spreadValues({}, edge);
|
|
354
|
+
if (!styled.type && def.lineStyle) {
|
|
355
|
+
styled.type = (_a = EDGE_TYPE_MAP[def.lineStyle]) != null ? _a : "default";
|
|
356
|
+
}
|
|
357
|
+
styled.style = __spreadValues(__spreadValues(__spreadValues({}, def.color ? { stroke: def.color } : void 0), def.strokeWidth ? { strokeWidth: def.strokeWidth } : void 0), edge.style);
|
|
358
|
+
if (styled.animated == null && def.animated) styled.animated = true;
|
|
359
|
+
if (!styled.markerStart) {
|
|
360
|
+
const startType = toMarkerType(def.markerStart);
|
|
361
|
+
if (startType) {
|
|
362
|
+
styled.markerStart = __spreadValues({ type: startType }, def.color ? { color: def.color } : void 0);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (!styled.markerEnd) {
|
|
366
|
+
const endType = toMarkerType(def.markerEnd);
|
|
367
|
+
if (endType) {
|
|
368
|
+
styled.markerEnd = __spreadValues({ type: endType }, def.color ? { color: def.color } : void 0);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return styled;
|
|
372
|
+
});
|
|
373
|
+
}
|
|
362
374
|
function FlowRenderer({
|
|
363
375
|
data,
|
|
364
376
|
className,
|
|
365
377
|
style,
|
|
366
378
|
nodeRenderers,
|
|
367
379
|
nodeTypeDefs,
|
|
380
|
+
edgeTypeDefs,
|
|
368
381
|
background = true,
|
|
369
382
|
interactive = false,
|
|
370
383
|
fitView = true,
|
|
371
384
|
onNodeClick,
|
|
372
385
|
onEdgeClick
|
|
373
386
|
}) {
|
|
374
|
-
var _a
|
|
387
|
+
var _a;
|
|
375
388
|
const nodeTypeDefsMap = import_react2.default.useMemo(() => {
|
|
376
389
|
if (!(nodeTypeDefs == null ? void 0 : nodeTypeDefs.length)) return void 0;
|
|
377
390
|
return new Map(nodeTypeDefs.map((d) => [d.slug, d]));
|
|
378
391
|
}, [nodeTypeDefs]);
|
|
392
|
+
const edgeTypeDefsMap = import_react2.default.useMemo(() => {
|
|
393
|
+
if (!(edgeTypeDefs == null ? void 0 : edgeTypeDefs.length)) return void 0;
|
|
394
|
+
return new Map(edgeTypeDefs.map((d) => [d.slug, d]));
|
|
395
|
+
}, [edgeTypeDefs]);
|
|
379
396
|
const nodeTypes = import_react2.default.useMemo(
|
|
380
397
|
() => createNodeTypes(nodeRenderers, nodeTypeDefsMap),
|
|
381
398
|
[nodeRenderers, nodeTypeDefsMap]
|
|
382
399
|
);
|
|
400
|
+
const styledEdges = import_react2.default.useMemo(
|
|
401
|
+
() => {
|
|
402
|
+
var _a2;
|
|
403
|
+
return applyEdgeStyles((_a2 = data == null ? void 0 : data.edges) != null ? _a2 : [], edgeTypeDefsMap);
|
|
404
|
+
},
|
|
405
|
+
[data == null ? void 0 : data.edges, edgeTypeDefsMap]
|
|
406
|
+
);
|
|
383
407
|
if (!data) return null;
|
|
384
408
|
const defaultViewport = !fitView && data.viewport ? data.viewport : void 0;
|
|
385
409
|
return /* @__PURE__ */ import_react2.default.createElement(import_react3.ReactFlowProvider, null, /* @__PURE__ */ import_react2.default.createElement("div", { className, style: __spreadValues({ width: "100%", height: "100%" }, style) }, /* @__PURE__ */ import_react2.default.createElement(
|
|
386
410
|
import_react3.ReactFlow,
|
|
387
411
|
{
|
|
388
412
|
nodes: (_a = data.nodes) != null ? _a : [],
|
|
389
|
-
edges:
|
|
413
|
+
edges: styledEdges,
|
|
390
414
|
nodeTypes,
|
|
391
415
|
defaultViewport,
|
|
392
416
|
fitView,
|
|
393
417
|
onNodeClick,
|
|
394
418
|
onEdgeClick,
|
|
395
|
-
nodesDraggable: interactive,
|
|
419
|
+
nodesDraggable: interactive ? void 0 : false,
|
|
396
420
|
nodesConnectable: false,
|
|
397
421
|
elementsSelectable: interactive || !!onNodeClick || !!onEdgeClick,
|
|
398
422
|
panOnDrag: interactive,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/Flow/index.tsx","../../src/ui/Flow/types.ts","../../src/ui/Flow/built-in-node-types.ts","../../src/ui/Flow/built-in-edge-types.ts","../../src/ui/Flow/useFlow.ts"],"sourcesContent":["'use client'\n\nimport React from 'react'\nimport {\n ReactFlow,\n ReactFlowProvider,\n Background,\n MarkerType,\n type NodeTypes,\n type NodeProps,\n type Edge,\n} from '@xyflow/react'\nimport type {\n CanvasData,\n DynamicNodeData,\n DynamicNodeSlotProps,\n EdgeTypeDef,\n FlowEdge,\n FlowNode,\n FrameNodeData,\n NodeTypeDef,\n NodeTypeFieldDef,\n} from './types'\n\nexport type {\n CanvasData,\n DynamicNodeSlotProps,\n FlowNode,\n FlowEdge,\n FlowViewport,\n FlowNodePosition,\n FlowNodeData,\n DynamicNodeData,\n FrameNodeData,\n NodeTypeDef,\n NodeTypeFieldDef,\n EdgeTypeDef,\n} from './types'\nexport { isDynamicNode, isFrameNode } from './types'\nexport { BUILT_IN_NODE_TYPES } from './built-in-node-types'\nexport { BUILT_IN_EDGE_TYPES } from './built-in-edge-types'\nexport { useFlow } from './useFlow'\nexport type { SDKClient, UseFlowOptions, UseFlowResult } from './useFlow'\n\n// ── Helpers ──\n\nfunction sanitizeUrl(url: string | undefined): string | undefined {\n if (!url) return url\n try {\n const parsed = new URL(url)\n if (parsed.protocol === 'http:' || parsed.protocol === 'https:') return url\n return undefined\n } catch {\n return undefined\n }\n}\n\nfunction toMarkerType(value: string): MarkerType | undefined {\n if (value === 'arrow') return MarkerType.Arrow\n if (value === 'arrowclosed') return MarkerType.ArrowClosed\n return undefined\n}\n\n// ── Field renderer (type-aware, matching console style) ──\n\nfunction renderFieldValue(\n key: string,\n val: unknown,\n fieldDef?: NodeTypeFieldDef,\n): React.ReactNode {\n if (val == null || val === '') return null\n\n const fieldType = fieldDef?.fieldType\n\n // Image field — image only, no decoration\n if (fieldType === 'image' || (typeof val === 'object' && val !== null && 'url' in val)) {\n const imgUrl = typeof val === 'string' ? val : (val as { url?: string })?.url\n const safeUrl = sanitizeUrl(imgUrl)\n if (!safeUrl) return null\n return (\n <img\n key={key}\n src={safeUrl}\n alt=\"\"\n draggable={false}\n style={{ flex: 1, minHeight: 0, width: '100%', objectFit: 'contain' }}\n />\n )\n }\n\n // All other fields — text only\n return (\n <div\n key={key}\n style={{\n fontSize: 11,\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n overflow: 'hidden',\n flexShrink: 0,\n }}\n >\n {String(val)}\n </div>\n )\n}\n\n// ── Default dynamic node renderer (no typeDef) ──\n\nfunction DefaultDynamicNode({ data }: NodeProps) {\n const d = data as unknown as DynamicNodeData\n return (\n <div style={{ width: '100%', height: '100%', display: 'flex', flexDirection: 'column' }}>\n {d.fields &&\n Object.entries(d.fields)\n .filter(([, v]) => v != null && v !== '')\n .map(([key, val]) => renderFieldValue(key, val))}\n </div>\n )\n}\n\n// ── Enhanced dynamic node renderer (with NodeTypeDef) ──\n\nfunction EnhancedDynamicNode({ data, typeDef }: { data: DynamicNodeData; typeDef: NodeTypeDef }) {\n return (\n <div style={{ width: '100%', height: '100%', display: 'flex', flexDirection: 'column' }}>\n {typeDef.fields.map((f) => {\n const val = data.fields[f.name]\n if (val == null || val === '') return null\n return renderFieldValue(f.name, val, f)\n })}\n </div>\n )\n}\n\n// ── Default frame node renderer ──\n\nfunction DefaultFrameNode({ data }: NodeProps) {\n const d = data as unknown as FrameNodeData\n const baseColor = d.color ?? 'rgba(128,128,128,0.15)'\n const padding = d.padding ?? 20\n const borderStyle = d.borderStyle ?? 'dashed'\n const opacity = d.opacity ?? 0.15\n\n // Apply opacity to rgba colors\n const bgColor = (() => {\n const m = baseColor.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/)\n if (m) return `rgba(${m[1]},${m[2]},${m[3]},${opacity})`\n return baseColor\n })()\n\n return (\n <div\n style={{\n backgroundColor: bgColor,\n padding,\n width: '100%',\n height: '100%',\n border: borderStyle === 'none' ? 'none' : `2px ${borderStyle} rgba(128,128,128,0.3)`,\n }}\n >\n <div\n style={{\n fontSize: 11,\n fontWeight: 600,\n color: 'rgba(128,128,128,0.6)',\n userSelect: 'none',\n }}\n >\n {d.label}\n </div>\n </div>\n )\n}\n\n// ── Node types builder ──\n\nfunction createNodeTypes(\n nodeRenderers?: Record<string, React.ComponentType<DynamicNodeSlotProps>>,\n nodeTypeDefsMap?: Map<string, NodeTypeDef>,\n): NodeTypes {\n const types: NodeTypes = {} as NodeTypes\n\n // Dynamic node type\n types.dynamic = ((props: NodeProps) => {\n const d = props.data as unknown as DynamicNodeData\n const typeDef = nodeTypeDefsMap?.get(d.nodeTypeSlug)\n const CustomRenderer = nodeRenderers?.[d.nodeTypeSlug]\n if (CustomRenderer) {\n return (\n <CustomRenderer\n id={props.id}\n nodeTypeSlug={d.nodeTypeSlug}\n label={d.label}\n fields={d.fields}\n nodeTypeDef={typeDef}\n />\n )\n }\n if (typeDef) {\n return <EnhancedDynamicNode data={d} typeDef={typeDef} />\n }\n return <DefaultDynamicNode {...props} />\n }) as NodeTypes[string]\n\n // Frame node type\n types.frame = DefaultFrameNode as NodeTypes[string]\n\n return types\n}\n\n// ── Edge style resolver ──\n\nconst EDGE_TYPE_MAP: Record<string, string> = {\n step: 'step',\n smoothstep: 'smoothstep',\n bezier: 'default',\n default: 'default',\n}\n\nfunction applyEdgeStyles(\n edges: FlowEdge[],\n edgeTypeDefsMap?: Map<string, EdgeTypeDef>,\n): Edge[] {\n if (!edgeTypeDefsMap?.size) return edges as unknown as Edge[]\n\n return edges.map((edge) => {\n const slug = edge.edgeTypeSlug\n if (!slug) return edge as unknown as Edge\n\n const def = edgeTypeDefsMap.get(slug)\n if (!def) return edge as unknown as Edge\n\n const styled: Edge = { ...(edge as unknown as Edge) }\n\n // Edge type (line style) — canvas value takes precedence\n if (!styled.type && def.lineStyle) {\n styled.type = EDGE_TYPE_MAP[def.lineStyle] ?? 'default'\n }\n\n // Visual style — canvas style merged with def as fallback\n styled.style = {\n ...(def.color ? { stroke: def.color } : undefined),\n ...(def.strokeWidth ? { strokeWidth: def.strokeWidth } : undefined),\n ...edge.style,\n }\n\n // Animation — canvas value takes precedence\n if (styled.animated == null && def.animated) styled.animated = true\n\n // Markers — canvas value takes precedence over def\n if (!styled.markerStart) {\n const startType = toMarkerType(def.markerStart)\n if (startType) {\n styled.markerStart = { type: startType, ...(def.color ? { color: def.color } : undefined) }\n }\n }\n if (!styled.markerEnd) {\n const endType = toMarkerType(def.markerEnd)\n if (endType) {\n styled.markerEnd = { type: endType, ...(def.color ? { color: def.color } : undefined) }\n }\n }\n\n return styled\n })\n}\n\n// ── FlowRenderer ──\n\n/**\n * Renders a Flow canvas in read-only mode.\n *\n * Requires `@xyflow/react` peer dependency and its CSS:\n * ```ts\n * import '@xyflow/react/dist/style.css'\n * ```\n */\nexport interface FlowRendererProps {\n /** Canvas data from Flow document's `canvas` field */\n data: CanvasData\n /** Container className */\n className?: string\n /** Container style */\n style?: React.CSSProperties\n /** Custom renderers by node type slug (e.g., `{ 'product-card': MyProductCard }`) */\n nodeRenderers?: Record<string, React.ComponentType<DynamicNodeSlotProps>>\n /** Node type definitions for enhanced rendering (field-type-aware display) */\n nodeTypeDefs?: NodeTypeDef[]\n /** Edge type definitions for styled edges (color, stroke, markers, animation) */\n edgeTypeDefs?: EdgeTypeDef[]\n /** Show background pattern (default: true) */\n background?: boolean\n /** Allow user interaction - pan, zoom (default: false for read-only display) */\n interactive?: boolean\n /** Fit view on mount (default: true) */\n fitView?: boolean\n /** Called when a node is clicked */\n onNodeClick?: (event: React.MouseEvent, node: FlowNode) => void\n /** Called when an edge is clicked */\n onEdgeClick?: (event: React.MouseEvent, edge: FlowEdge) => void\n}\n\nexport function FlowRenderer({\n data,\n className,\n style,\n nodeRenderers,\n nodeTypeDefs,\n edgeTypeDefs,\n background = true,\n interactive = false,\n fitView = true,\n onNodeClick,\n onEdgeClick,\n}: FlowRendererProps) {\n const nodeTypeDefsMap = React.useMemo(() => {\n if (!nodeTypeDefs?.length) return undefined\n return new Map(nodeTypeDefs.map((d) => [d.slug, d]))\n }, [nodeTypeDefs])\n\n const edgeTypeDefsMap = React.useMemo(() => {\n if (!edgeTypeDefs?.length) return undefined\n return new Map(edgeTypeDefs.map((d) => [d.slug, d]))\n }, [edgeTypeDefs])\n\n const nodeTypes = React.useMemo(\n () => createNodeTypes(nodeRenderers, nodeTypeDefsMap),\n [nodeRenderers, nodeTypeDefsMap],\n )\n\n const styledEdges = React.useMemo(\n () => applyEdgeStyles(data?.edges ?? [], edgeTypeDefsMap),\n [data?.edges, edgeTypeDefsMap],\n )\n\n if (!data) return null\n\n const defaultViewport = !fitView && data.viewport ? data.viewport : undefined\n\n return (\n <ReactFlowProvider>\n <div className={className} style={{ width: '100%', height: '100%', ...style }}>\n <ReactFlow\n nodes={(data.nodes ?? []) as unknown as Parameters<typeof ReactFlow>[0]['nodes']}\n edges={styledEdges}\n nodeTypes={nodeTypes}\n defaultViewport={defaultViewport}\n fitView={fitView}\n onNodeClick={onNodeClick as Parameters<typeof ReactFlow>[0]['onNodeClick']}\n onEdgeClick={onEdgeClick as Parameters<typeof ReactFlow>[0]['onEdgeClick']}\n nodesDraggable={interactive ? undefined : false}\n nodesConnectable={false}\n elementsSelectable={interactive || !!onNodeClick || !!onEdgeClick}\n panOnDrag={interactive}\n zoomOnScroll={interactive}\n zoomOnPinch={interactive}\n zoomOnDoubleClick={false}\n >\n {background && <Background />}\n </ReactFlow>\n </div>\n </ReactFlowProvider>\n )\n}\n","import type React from 'react'\n\n// ── Dynamic node data ──\n\nexport interface DynamicNodeData {\n nodeTypeSlug: string\n label: string\n fields: Record<string, unknown>\n}\n\nexport type FlowNodeData = DynamicNodeData & Record<string, unknown>\n\n// ── Canvas types (mirrors @xyflow/react but standalone) ──\n\nexport interface FlowNodePosition {\n x: number\n y: number\n}\n\nexport interface FlowNode {\n id: string\n type?: string\n position: FlowNodePosition\n data: FlowNodeData\n style?: React.CSSProperties\n width?: number\n height?: number\n measured?: { width?: number; height?: number }\n draggable?: boolean\n selectable?: boolean\n [key: string]: unknown\n}\n\nexport interface FlowEdge {\n id: string\n source: string\n target: string\n sourceHandle?: string | null\n targetHandle?: string | null\n type?: string\n style?: React.CSSProperties\n animated?: boolean\n markerStart?: unknown\n markerEnd?: unknown\n edgeTypeSlug?: string\n fields?: Record<string, unknown>\n [key: string]: unknown\n}\n\nexport interface FlowViewport {\n x: number\n y: number\n zoom: number\n}\n\nexport interface CanvasData {\n nodes: FlowNode[]\n edges: FlowEdge[]\n viewport: FlowViewport\n}\n\n// ── Node type definitions (mirrors console's NodeTypeDef) ──\n\nexport interface NodeTypeFieldDef {\n name: string\n label: string\n fieldType: 'text' | 'textarea' | 'number' | 'url' | 'color' | 'image' | 'select' | 'toggle'\n options?: { label: string; value: string }[]\n defaultValue?: string\n required?: boolean\n}\n\nexport interface NodeTypeDef {\n slug: string\n name: string\n color: string\n defaultSize: { width: number; height: number }\n fields: NodeTypeFieldDef[]\n transparentBackground?: boolean\n}\n\n// ── Edge type definitions (mirrors console's EdgeTypeDef) ──\n\nexport interface EdgeTypeDef {\n slug: string\n name: string\n color: string\n strokeWidth: number\n animated: boolean\n lineStyle: string\n markerStart: string\n markerEnd: string\n fields: NodeTypeFieldDef[]\n}\n\n// ── Type guards ──\n\nexport function isDynamicNode(node: FlowNode): node is FlowNode & { data: DynamicNodeData } {\n return node.type === 'dynamic'\n}\n\nexport function isFrameNode(node: FlowNode): node is FlowNode & { data: FrameNodeData } {\n return node.type === 'frame'\n}\n\n// ── Component slot props ──\n\nexport interface DynamicNodeSlotProps {\n id: string\n nodeTypeSlug: string\n label: string\n fields: Record<string, unknown>\n nodeTypeDef?: NodeTypeDef\n}\n\n// ── Frame node data ──\n\nexport interface FrameNodeData {\n label: string\n color?: string\n padding?: number\n borderStyle?: 'dashed' | 'solid' | 'none'\n opacity?: number\n}\n","import type { NodeTypeDef } from './types'\n\nexport const BUILT_IN_NODE_TYPES: NodeTypeDef[] = [\n {\n slug: 'text',\n name: 'Text',\n color: '#e5e7eb',\n defaultSize: { width: 200, height: 200 },\n fields: [{ name: 'body', label: 'Body', fieldType: 'textarea' }],\n },\n {\n slug: 'image',\n name: 'Image',\n color: '#e5e7eb',\n transparentBackground: true,\n defaultSize: { width: 200, height: 200 },\n fields: [\n { name: 'image', label: 'Image', fieldType: 'image' },\n { name: 'alt', label: 'Alt Text', fieldType: 'text' },\n { name: 'caption', label: 'Caption', fieldType: 'text' },\n ],\n },\n]\n","import type { EdgeTypeDef } from './types'\n\nexport const BUILT_IN_EDGE_TYPES: EdgeTypeDef[] = [\n {\n slug: 'default',\n name: 'Default',\n color: '',\n strokeWidth: 2,\n animated: false,\n lineStyle: 'default',\n markerStart: 'none',\n markerEnd: 'arrow',\n fields: [],\n },\n]\n","'use client'\n\nimport { useQuery, type QueryClient } from '@tanstack/react-query'\nimport { useMemo } from 'react'\nimport type { CanvasData, NodeTypeDef, EdgeTypeDef } from './types'\nimport { BUILT_IN_NODE_TYPES } from './built-in-node-types'\nimport { BUILT_IN_EDGE_TYPES } from './built-in-edge-types'\n\n// ── Client interface ──\n// Structurally compatible with both BrowserClient and ServerClient.\n// Lists only the collections useFlow actually queries so the generic\n// `from<T extends PublicCollection>` on the real clients satisfies this.\n\ntype FlowCollection = 'flows' | 'flow-node-types' | 'flow-edge-types'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFn = (...args: any[]) => any\n\nexport interface SDKClient {\n from(collection: FlowCollection): {\n find: AnyFn\n findById: AnyFn\n }\n queryClient: QueryClient\n}\n\n// ── Options & Result ──\n\nexport interface UseFlowOptions {\n /** SDK client instance (BrowserClient or ServerClient) */\n client: SDKClient\n /** Flow slug (URL-friendly identifier) */\n slug?: string\n /** Flow document ID (UUID) */\n id?: string\n /** Enable/disable data fetching (default: true) */\n enabled?: boolean\n}\n\nexport interface UseFlowResult {\n data: CanvasData | undefined\n nodeTypeDefs: NodeTypeDef[]\n edgeTypeDefs: EdgeTypeDef[]\n flow: Record<string, unknown> | undefined\n isLoading: boolean\n error: Error | null\n}\n\n// ── Helpers ──\n\nfunction toNodeTypeDef(doc: Record<string, unknown>): NodeTypeDef {\n return {\n slug: String(doc.slug ?? ''),\n name: String(doc.title ?? ''),\n color: String(doc.color ?? '#e5e7eb'),\n defaultSize: (doc.defaultSize as NodeTypeDef['defaultSize']) ?? { width: 200, height: 200 },\n fields: Array.isArray(doc.fields)\n ? (doc.fields as NodeTypeDef['fields'])\n : [],\n transparentBackground: Boolean(doc.transparentBackground),\n }\n}\n\nfunction toEdgeTypeDef(doc: Record<string, unknown>): EdgeTypeDef {\n return {\n slug: String(doc.slug ?? ''),\n name: String(doc.title ?? ''),\n color: String(doc.color ?? ''),\n strokeWidth: (doc.strokeWidth as number) ?? 2,\n animated: (doc.animated as boolean) ?? false,\n lineStyle: String(doc.lineStyle ?? 'default'),\n markerStart: String(doc.markerStart ?? 'none'),\n markerEnd: String(doc.markerEnd ?? 'arrow'),\n fields: Array.isArray(doc.fields)\n ? (doc.fields as EdgeTypeDef['fields'])\n : [],\n }\n}\n\n// ── Hook ──\n\nexport function useFlow(options: UseFlowOptions): UseFlowResult {\n const { client, slug, id, enabled = true } = options\n const hasIdentifier = !!(slug || id)\n const identifier = (id ?? slug) ?? ''\n\n // Fetch flow document\n const flowQuery = useQuery<Record<string, unknown>>({\n queryKey: ['flows', identifier],\n queryFn: async () => {\n if (id) {\n return client.from('flows').findById(id)\n }\n const result = await client.from('flows').find({\n where: { slug: { equals: slug } },\n limit: 1,\n })\n const doc = result.docs[0]\n if (!doc) throw new Error(`Flow not found: ${slug}`)\n return doc\n },\n enabled: enabled && hasIdentifier,\n }, client.queryClient)\n\n // Fetch tenant's custom node types\n const nodeTypesQuery = useQuery<Record<string, unknown>[]>({\n queryKey: ['flow-node-types'],\n queryFn: async () => {\n const result = await client.from('flow-node-types').find({ limit: 100 })\n return result.docs\n },\n enabled,\n }, client.queryClient)\n\n // Fetch tenant's custom edge types\n const edgeTypesQuery = useQuery<Record<string, unknown>[]>({\n queryKey: ['flow-edge-types'],\n queryFn: async () => {\n const result = await client.from('flow-edge-types').find({ limit: 100 })\n return result.docs\n },\n enabled,\n }, client.queryClient)\n\n // Merge built-in + API node types\n const nodeTypeDefs = useMemo<NodeTypeDef[]>(() => {\n const apiDefs = (nodeTypesQuery.data ?? []).map(toNodeTypeDef)\n const builtInSlugs = new Set(BUILT_IN_NODE_TYPES.map((t) => t.slug))\n const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug))\n return [...BUILT_IN_NODE_TYPES, ...customDefs]\n }, [nodeTypesQuery.data])\n\n // Merge built-in + API edge types\n const edgeTypeDefs = useMemo<EdgeTypeDef[]>(() => {\n const apiDefs = (edgeTypesQuery.data ?? []).map(toEdgeTypeDef)\n const builtInSlugs = new Set(BUILT_IN_EDGE_TYPES.map((t) => t.slug))\n const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug))\n return [...BUILT_IN_EDGE_TYPES, ...customDefs]\n }, [edgeTypesQuery.data])\n\n const flow = flowQuery.data\n const canvas = flow?.canvas as CanvasData | undefined\n\n return {\n data: canvas,\n nodeTypeDefs,\n edgeTypeDefs,\n flow,\n isLoading: flowQuery.isLoading || nodeTypesQuery.isLoading || edgeTypesQuery.isLoading,\n error: (flowQuery.error as Error | null) ?? (nodeTypesQuery.error as Error | null) ?? (edgeTypesQuery.error as Error | null),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAAkB;AAClB,IAAAA,gBAQO;;;ACsFA,SAAS,cAAc,MAA8D;AAC1F,SAAO,KAAK,SAAS;AACvB;AAEO,SAAS,YAAY,MAA4D;AACtF,SAAO,KAAK,SAAS;AACvB;;;ACrGO,IAAM,sBAAqC;AAAA,EAChD;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa,EAAE,OAAO,KAAK,QAAQ,IAAI;AAAA,IACvC,QAAQ,CAAC,EAAE,MAAM,QAAQ,OAAO,QAAQ,WAAW,WAAW,CAAC;AAAA,EACjE;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,uBAAuB;AAAA,IACvB,aAAa,EAAE,OAAO,KAAK,QAAQ,IAAI;AAAA,IACvC,QAAQ;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AK,WAAW;AAEpE,SACE,8BAAAD,QAAA,cAAC,uCACC,8BAAAA,QAAA,cAAC,SAAI,WAAsB,OAAO,iBAAE,OAAO,QAAQ,QAAQ,UAAW,UACpE,8BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,QAAQ,UAAK,UAAL,YAAc,CAAC;AAAA,MACvB,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB,cAAc,SAAY;AAAA,MAC1C,kBAAkB;AAAA,MAClB,oBAAoB,eAAe,CAAC,CAAC,eAAe,CAAC,CAAC;AAAA,MACtD,WAAW;AAAA,MACX,cAAc;AAAA,MACd,aAAa;AAAA,MACb,mBAAmB;AAAA;AAAA,IAElB,cAAc,8BAAAA,QAAA,cAAC,8BAAW;AAAA,EAC7B,CACF,CACF;AAEJ;","names":["import_react","_a","React","_a"]}
|
|
@@ -24,6 +24,7 @@ interface FlowNode {
|
|
|
24
24
|
height?: number;
|
|
25
25
|
};
|
|
26
26
|
draggable?: boolean;
|
|
27
|
+
selectable?: boolean;
|
|
27
28
|
[key: string]: unknown;
|
|
28
29
|
}
|
|
29
30
|
interface FlowEdge {
|
|
@@ -34,6 +35,9 @@ interface FlowEdge {
|
|
|
34
35
|
targetHandle?: string | null;
|
|
35
36
|
type?: string;
|
|
36
37
|
style?: React.CSSProperties;
|
|
38
|
+
animated?: boolean;
|
|
39
|
+
markerStart?: unknown;
|
|
40
|
+
markerEnd?: unknown;
|
|
37
41
|
edgeTypeSlug?: string;
|
|
38
42
|
fields?: Record<string, unknown>;
|
|
39
43
|
[key: string]: unknown;
|
|
@@ -77,6 +81,8 @@ interface EdgeTypeDef {
|
|
|
77
81
|
strokeWidth: number;
|
|
78
82
|
animated: boolean;
|
|
79
83
|
lineStyle: string;
|
|
84
|
+
markerStart: string;
|
|
85
|
+
markerEnd: string;
|
|
80
86
|
fields: NodeTypeFieldDef[];
|
|
81
87
|
}
|
|
82
88
|
declare function isDynamicNode(node: FlowNode): node is FlowNode & {
|
|
@@ -96,23 +102,31 @@ interface FrameNodeData {
|
|
|
96
102
|
label: string;
|
|
97
103
|
color?: string;
|
|
98
104
|
padding?: number;
|
|
105
|
+
borderStyle?: 'dashed' | 'solid' | 'none';
|
|
106
|
+
opacity?: number;
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
declare const BUILT_IN_NODE_TYPES: NodeTypeDef[];
|
|
102
110
|
|
|
103
111
|
declare const BUILT_IN_EDGE_TYPES: EdgeTypeDef[];
|
|
104
112
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
findById
|
|
113
|
+
type FlowCollection = 'flows' | 'flow-node-types' | 'flow-edge-types';
|
|
114
|
+
type AnyFn = (...args: any[]) => any;
|
|
115
|
+
interface SDKClient {
|
|
116
|
+
from(collection: FlowCollection): {
|
|
117
|
+
find: AnyFn;
|
|
118
|
+
findById: AnyFn;
|
|
111
119
|
};
|
|
112
120
|
queryClient: QueryClient;
|
|
113
121
|
}
|
|
114
122
|
interface UseFlowOptions {
|
|
115
|
-
client
|
|
123
|
+
/** SDK client instance (BrowserClient or ServerClient) */
|
|
124
|
+
client: SDKClient;
|
|
125
|
+
/** Flow slug (URL-friendly identifier) */
|
|
126
|
+
slug?: string;
|
|
127
|
+
/** Flow document ID (UUID) */
|
|
128
|
+
id?: string;
|
|
129
|
+
/** Enable/disable data fetching (default: true) */
|
|
116
130
|
enabled?: boolean;
|
|
117
131
|
}
|
|
118
132
|
interface UseFlowResult {
|
|
@@ -123,7 +137,7 @@ interface UseFlowResult {
|
|
|
123
137
|
isLoading: boolean;
|
|
124
138
|
error: Error | null;
|
|
125
139
|
}
|
|
126
|
-
declare function useFlow(
|
|
140
|
+
declare function useFlow(options: UseFlowOptions): UseFlowResult;
|
|
127
141
|
|
|
128
142
|
/**
|
|
129
143
|
* Renders a Flow canvas in read-only mode.
|
|
@@ -142,8 +156,10 @@ interface FlowRendererProps {
|
|
|
142
156
|
style?: React.CSSProperties;
|
|
143
157
|
/** Custom renderers by node type slug (e.g., `{ 'product-card': MyProductCard }`) */
|
|
144
158
|
nodeRenderers?: Record<string, React.ComponentType<DynamicNodeSlotProps>>;
|
|
145
|
-
/** Node type definitions for enhanced rendering (
|
|
159
|
+
/** Node type definitions for enhanced rendering (field-type-aware display) */
|
|
146
160
|
nodeTypeDefs?: NodeTypeDef[];
|
|
161
|
+
/** Edge type definitions for styled edges (color, stroke, markers, animation) */
|
|
162
|
+
edgeTypeDefs?: EdgeTypeDef[];
|
|
147
163
|
/** Show background pattern (default: true) */
|
|
148
164
|
background?: boolean;
|
|
149
165
|
/** Allow user interaction - pan, zoom (default: false for read-only display) */
|
|
@@ -155,6 +171,6 @@ interface FlowRendererProps {
|
|
|
155
171
|
/** Called when an edge is clicked */
|
|
156
172
|
onEdgeClick?: (event: React.MouseEvent, edge: FlowEdge) => void;
|
|
157
173
|
}
|
|
158
|
-
declare function FlowRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, background, interactive, fitView, onNodeClick, onEdgeClick, }: FlowRendererProps): React.JSX.Element | null;
|
|
174
|
+
declare function FlowRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, edgeTypeDefs, background, interactive, fitView, onNodeClick, onEdgeClick, }: FlowRendererProps): React.JSX.Element | null;
|
|
159
175
|
|
|
160
|
-
export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES, type CanvasData, type DynamicNodeData, type DynamicNodeSlotProps, type EdgeTypeDef, type FlowEdge, type FlowNode, type FlowNodeData, type FlowNodePosition, FlowRenderer, type FlowRendererProps, type FlowViewport, type FrameNodeData, type NodeTypeDef, type NodeTypeFieldDef, type UseFlowOptions, type UseFlowResult, isDynamicNode, isFrameNode, useFlow };
|
|
176
|
+
export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES, type CanvasData, type DynamicNodeData, type DynamicNodeSlotProps, type EdgeTypeDef, type FlowEdge, type FlowNode, type FlowNodeData, type FlowNodePosition, FlowRenderer, type FlowRendererProps, type FlowViewport, type FrameNodeData, type NodeTypeDef, type NodeTypeFieldDef, type SDKClient, type UseFlowOptions, type UseFlowResult, isDynamicNode, isFrameNode, useFlow };
|
|
@@ -24,6 +24,7 @@ interface FlowNode {
|
|
|
24
24
|
height?: number;
|
|
25
25
|
};
|
|
26
26
|
draggable?: boolean;
|
|
27
|
+
selectable?: boolean;
|
|
27
28
|
[key: string]: unknown;
|
|
28
29
|
}
|
|
29
30
|
interface FlowEdge {
|
|
@@ -34,6 +35,9 @@ interface FlowEdge {
|
|
|
34
35
|
targetHandle?: string | null;
|
|
35
36
|
type?: string;
|
|
36
37
|
style?: React.CSSProperties;
|
|
38
|
+
animated?: boolean;
|
|
39
|
+
markerStart?: unknown;
|
|
40
|
+
markerEnd?: unknown;
|
|
37
41
|
edgeTypeSlug?: string;
|
|
38
42
|
fields?: Record<string, unknown>;
|
|
39
43
|
[key: string]: unknown;
|
|
@@ -77,6 +81,8 @@ interface EdgeTypeDef {
|
|
|
77
81
|
strokeWidth: number;
|
|
78
82
|
animated: boolean;
|
|
79
83
|
lineStyle: string;
|
|
84
|
+
markerStart: string;
|
|
85
|
+
markerEnd: string;
|
|
80
86
|
fields: NodeTypeFieldDef[];
|
|
81
87
|
}
|
|
82
88
|
declare function isDynamicNode(node: FlowNode): node is FlowNode & {
|
|
@@ -96,23 +102,31 @@ interface FrameNodeData {
|
|
|
96
102
|
label: string;
|
|
97
103
|
color?: string;
|
|
98
104
|
padding?: number;
|
|
105
|
+
borderStyle?: 'dashed' | 'solid' | 'none';
|
|
106
|
+
opacity?: number;
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
declare const BUILT_IN_NODE_TYPES: NodeTypeDef[];
|
|
102
110
|
|
|
103
111
|
declare const BUILT_IN_EDGE_TYPES: EdgeTypeDef[];
|
|
104
112
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
findById
|
|
113
|
+
type FlowCollection = 'flows' | 'flow-node-types' | 'flow-edge-types';
|
|
114
|
+
type AnyFn = (...args: any[]) => any;
|
|
115
|
+
interface SDKClient {
|
|
116
|
+
from(collection: FlowCollection): {
|
|
117
|
+
find: AnyFn;
|
|
118
|
+
findById: AnyFn;
|
|
111
119
|
};
|
|
112
120
|
queryClient: QueryClient;
|
|
113
121
|
}
|
|
114
122
|
interface UseFlowOptions {
|
|
115
|
-
client
|
|
123
|
+
/** SDK client instance (BrowserClient or ServerClient) */
|
|
124
|
+
client: SDKClient;
|
|
125
|
+
/** Flow slug (URL-friendly identifier) */
|
|
126
|
+
slug?: string;
|
|
127
|
+
/** Flow document ID (UUID) */
|
|
128
|
+
id?: string;
|
|
129
|
+
/** Enable/disable data fetching (default: true) */
|
|
116
130
|
enabled?: boolean;
|
|
117
131
|
}
|
|
118
132
|
interface UseFlowResult {
|
|
@@ -123,7 +137,7 @@ interface UseFlowResult {
|
|
|
123
137
|
isLoading: boolean;
|
|
124
138
|
error: Error | null;
|
|
125
139
|
}
|
|
126
|
-
declare function useFlow(
|
|
140
|
+
declare function useFlow(options: UseFlowOptions): UseFlowResult;
|
|
127
141
|
|
|
128
142
|
/**
|
|
129
143
|
* Renders a Flow canvas in read-only mode.
|
|
@@ -142,8 +156,10 @@ interface FlowRendererProps {
|
|
|
142
156
|
style?: React.CSSProperties;
|
|
143
157
|
/** Custom renderers by node type slug (e.g., `{ 'product-card': MyProductCard }`) */
|
|
144
158
|
nodeRenderers?: Record<string, React.ComponentType<DynamicNodeSlotProps>>;
|
|
145
|
-
/** Node type definitions for enhanced rendering (
|
|
159
|
+
/** Node type definitions for enhanced rendering (field-type-aware display) */
|
|
146
160
|
nodeTypeDefs?: NodeTypeDef[];
|
|
161
|
+
/** Edge type definitions for styled edges (color, stroke, markers, animation) */
|
|
162
|
+
edgeTypeDefs?: EdgeTypeDef[];
|
|
147
163
|
/** Show background pattern (default: true) */
|
|
148
164
|
background?: boolean;
|
|
149
165
|
/** Allow user interaction - pan, zoom (default: false for read-only display) */
|
|
@@ -155,6 +171,6 @@ interface FlowRendererProps {
|
|
|
155
171
|
/** Called when an edge is clicked */
|
|
156
172
|
onEdgeClick?: (event: React.MouseEvent, edge: FlowEdge) => void;
|
|
157
173
|
}
|
|
158
|
-
declare function FlowRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, background, interactive, fitView, onNodeClick, onEdgeClick, }: FlowRendererProps): React.JSX.Element | null;
|
|
174
|
+
declare function FlowRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, edgeTypeDefs, background, interactive, fitView, onNodeClick, onEdgeClick, }: FlowRendererProps): React.JSX.Element | null;
|
|
159
175
|
|
|
160
|
-
export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES, type CanvasData, type DynamicNodeData, type DynamicNodeSlotProps, type EdgeTypeDef, type FlowEdge, type FlowNode, type FlowNodeData, type FlowNodePosition, FlowRenderer, type FlowRendererProps, type FlowViewport, type FrameNodeData, type NodeTypeDef, type NodeTypeFieldDef, type UseFlowOptions, type UseFlowResult, isDynamicNode, isFrameNode, useFlow };
|
|
176
|
+
export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES, type CanvasData, type DynamicNodeData, type DynamicNodeSlotProps, type EdgeTypeDef, type FlowEdge, type FlowNode, type FlowNodeData, type FlowNodePosition, FlowRenderer, type FlowRendererProps, type FlowViewport, type FrameNodeData, type NodeTypeDef, type NodeTypeFieldDef, type SDKClient, type UseFlowOptions, type UseFlowResult, isDynamicNode, isFrameNode, useFlow };
|