@inspirer-dev/crm-dashboard 1.0.44 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
1
  import React, { useCallback, useEffect, useRef, useState, useMemo } from 'react';
2
2
  import ReactFlow, {
3
3
  Background,
4
- MiniMap,
5
4
  useNodesState,
6
5
  useEdgesState,
7
6
  useReactFlow,
@@ -74,12 +73,12 @@ const FlowCanvas: React.FC<FlowCanvasProps> = ({
74
73
  onValidationChange?.(validation);
75
74
  }, [validation, onValidationChange]);
76
75
 
77
- const fitViewWithTopPadding = useCallback(
78
- (topOffset = 40) => {
79
- fitView({ padding: 0.2, duration: 200 });
76
+ const fitViewWithOffset = useCallback(
77
+ ({ topOffset = 40, rightOffset = 150, targetZoom = 0.8 } = {}) => {
78
+ fitView({ padding: 0.3, duration: 200, maxZoom: targetZoom, minZoom: targetZoom });
80
79
  setTimeout(() => {
81
- const { x, y, zoom } = getViewport();
82
- setViewport({ x, y: y - topOffset, zoom }, { duration: 200 });
80
+ const { x, y } = getViewport();
81
+ setViewport({ x: x + rightOffset, y: y - topOffset, zoom: targetZoom }, { duration: 200 });
83
82
  }, 210);
84
83
  },
85
84
  [fitView, getViewport, setViewport]
@@ -292,11 +291,11 @@ const FlowCanvas: React.FC<FlowCanvasProps> = ({
292
291
  setEdges(e);
293
292
 
294
293
  setTimeout(() => {
295
- fitViewWithTopPadding();
294
+ fitViewWithOffset();
296
295
  }, 50);
297
296
  }
298
297
  isInitialMount.current = false;
299
- }, [steps, setNodes, setEdges, fitViewWithTopPadding]);
298
+ }, [steps, setNodes, setEdges, fitViewWithOffset]);
300
299
 
301
300
  const syncToParent = useCallback(() => {
302
301
  if (isInitialMount.current) return;
@@ -403,9 +402,9 @@ const FlowCanvas: React.FC<FlowCanvasProps> = ({
403
402
  const layoutedNodes = applyAutoLayout(nodes, edges);
404
403
  setNodes(layoutedNodes);
405
404
  setTimeout(() => {
406
- fitViewWithTopPadding();
405
+ fitViewWithOffset();
407
406
  }, 50);
408
- }, [nodes, edges, setNodes, fitViewWithTopPadding]);
407
+ }, [nodes, edges, setNodes, fitViewWithOffset]);
409
408
 
410
409
  const handleNodeUpdate = useCallback(
411
410
  (nodeId: string, data: Partial<FlowNodeData>) => {
@@ -528,26 +527,6 @@ const FlowCanvas: React.FC<FlowCanvasProps> = ({
528
527
  }}
529
528
  >
530
529
  <Background color="#f0f0f0" gap={20} />
531
- <MiniMap
532
- nodeColor={(node) => {
533
- switch (node.data?.stepType) {
534
- case 'entry':
535
- return '#5cb176';
536
- case 'message':
537
- return '#0077cc';
538
- case 'wait':
539
- return '#e9b200';
540
- case 'branch':
541
- return '#7b61ff';
542
- case 'exit':
543
- return '#dc2626';
544
- default:
545
- return '#999';
546
- }
547
- }}
548
- maskColor="rgba(0, 0, 0, 0.1)"
549
- style={{ background: '#f7f7f7' }}
550
- />
551
530
  <FlowToolbar
552
531
  onAddNode={handleAddNode}
553
532
  onAutoLayout={handleAutoLayout}
@@ -38,8 +38,9 @@ const BranchConfig: React.FC<BranchConfigProps> = ({ data, onUpdate, disabled })
38
38
  });
39
39
  const results = response.data?.results || [];
40
40
  setSegments(
41
- results.map((s: { id: number; name: string }) => ({
41
+ results.map((s: { id: number; documentId: string; name: string }) => ({
42
42
  id: s.id,
43
+ documentId: s.documentId,
43
44
  name: s.name,
44
45
  }))
45
46
  );
@@ -58,7 +59,9 @@ const BranchConfig: React.FC<BranchConfigProps> = ({ data, onUpdate, disabled })
58
59
  onUpdate({
59
60
  config: {
60
61
  ...data.config,
61
- branchSegment: segment ? { id: segment.id, name: segment.name } : null,
62
+ branchSegment: segment
63
+ ? { id: segment.id, documentId: segment.documentId, name: segment.name }
64
+ : null,
62
65
  },
63
66
  });
64
67
  };
@@ -49,8 +49,9 @@ const MessageConfig: React.FC<MessageConfigProps> = ({ data, onUpdate, disabled
49
49
  );
50
50
  const results = response.data?.results || [];
51
51
  setTemplates(
52
- results.map((t: { id: number; name: string; channel?: string }) => ({
52
+ results.map((t: { id: number; documentId: string; name: string; channel?: string }) => ({
53
53
  id: t.id,
54
+ documentId: t.documentId,
54
55
  name: t.name,
55
56
  channel: t.channel,
56
57
  }))
@@ -116,7 +117,12 @@ const MessageConfig: React.FC<MessageConfigProps> = ({ data, onUpdate, disabled
116
117
  const template = templates.find((t) => t.id.toString() === templateId);
117
118
  const updated = variants.map((v, i) =>
118
119
  i === index
119
- ? { ...v, template: template ? { id: template.id, name: template.name } : null }
120
+ ? {
121
+ ...v,
122
+ template: template
123
+ ? { id: template.id, documentId: template.documentId, name: template.name }
124
+ : null,
125
+ }
120
126
  : v
121
127
  );
122
128
  setVariants(updated);
@@ -8,7 +8,7 @@ export type DurationUnit = 'minutes' | 'hours' | 'days';
8
8
  export interface CampaignVariant {
9
9
  id?: number;
10
10
  name: string;
11
- template?: { id: number; name?: string } | null;
11
+ template?: { id: number; documentId: string; name?: string } | null;
12
12
  weight: number;
13
13
  }
14
14
 
@@ -21,7 +21,7 @@ export interface FlowStep {
21
21
  variants?: CampaignVariant[];
22
22
  duration?: number;
23
23
  durationUnit?: DurationUnit;
24
- branchSegment?: { id: number; name?: string } | null;
24
+ branchSegment?: { id: number; documentId: string; name?: string } | null;
25
25
  branchSegmentId?: number;
26
26
  nextStep?: string;
27
27
  yesNextStep?: string;
@@ -36,7 +36,7 @@ export interface FlowNodeData {
36
36
  variants?: CampaignVariant[];
37
37
  duration?: number;
38
38
  durationUnit?: DurationUnit;
39
- branchSegment?: { id: number; name?: string } | null;
39
+ branchSegment?: { id: number; documentId: string; name?: string } | null;
40
40
  };
41
41
  }
42
42
 
@@ -70,11 +70,13 @@ export interface FlowToolbarProps {
70
70
 
71
71
  export interface SegmentOption {
72
72
  id: number;
73
+ documentId: string;
73
74
  name: string;
74
75
  }
75
76
 
76
77
  export interface TemplateOption {
77
78
  id: number;
79
+ documentId: string;
78
80
  name: string;
79
81
  channel?: ChannelType;
80
82
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { createContext, useContext, memo, useState, useEffect, useCallback, useRef, useMemo } from "react";
3
- import ReactFlow, { Handle, Position, getSimpleBezierPath, BaseEdge, EdgeLabelRenderer, useNodesState, useEdgesState, useReactFlow, useStoreApi, addEdge, Background, MiniMap } from "reactflow";
3
+ import ReactFlow, { Handle, Position, getSimpleBezierPath, BaseEdge, EdgeLabelRenderer, useNodesState, useEdgesState, useReactFlow, useStoreApi, addEdge, Background } from "reactflow";
4
4
  import "reactflow/dist/style.css";
5
5
  import { Flex, Box, Typography, SingleSelect, SingleSelectOption, TextInput, NumberInput, Loader, Tooltip } from "@strapi/design-system";
6
6
  import { Plus, Trash, Cross, Layout } from "@strapi/icons";
@@ -1222,6 +1222,7 @@ const MessageConfig = ({ data, onUpdate, disabled }) => {
1222
1222
  setTemplates(
1223
1223
  results.map((t) => ({
1224
1224
  id: t.id,
1225
+ documentId: t.documentId,
1225
1226
  name: t.name,
1226
1227
  channel: t.channel
1227
1228
  }))
@@ -1281,7 +1282,10 @@ const MessageConfig = ({ data, onUpdate, disabled }) => {
1281
1282
  const handleTemplateChange = (index, templateId) => {
1282
1283
  const template = templates.find((t) => t.id.toString() === templateId);
1283
1284
  const updated = variants.map(
1284
- (v, i) => i === index ? { ...v, template: template ? { id: template.id, name: template.name } : null } : v
1285
+ (v, i) => i === index ? {
1286
+ ...v,
1287
+ template: template ? { id: template.id, documentId: template.documentId, name: template.name } : null
1288
+ } : v
1285
1289
  );
1286
1290
  setVariants(updated);
1287
1291
  onUpdate({
@@ -1678,6 +1682,7 @@ const BranchConfig = ({ data, onUpdate, disabled }) => {
1678
1682
  setSegments(
1679
1683
  results.map((s) => ({
1680
1684
  id: s.id,
1685
+ documentId: s.documentId,
1681
1686
  name: s.name
1682
1687
  }))
1683
1688
  );
@@ -1695,7 +1700,7 @@ const BranchConfig = ({ data, onUpdate, disabled }) => {
1695
1700
  onUpdate({
1696
1701
  config: {
1697
1702
  ...data.config,
1698
- branchSegment: segment ? { id: segment.id, name: segment.name } : null
1703
+ branchSegment: segment ? { id: segment.id, documentId: segment.documentId, name: segment.name } : null
1699
1704
  }
1700
1705
  });
1701
1706
  };
@@ -3215,12 +3220,12 @@ const FlowCanvas = ({
3215
3220
  useEffect(() => {
3216
3221
  onValidationChange?.(validation);
3217
3222
  }, [validation, onValidationChange]);
3218
- const fitViewWithTopPadding = useCallback(
3219
- (topOffset = 40) => {
3220
- fitView({ padding: 0.2, duration: 200 });
3223
+ const fitViewWithOffset = useCallback(
3224
+ ({ topOffset = 40, rightOffset = 150, targetZoom = 0.8 } = {}) => {
3225
+ fitView({ padding: 0.3, duration: 200, maxZoom: targetZoom, minZoom: targetZoom });
3221
3226
  setTimeout(() => {
3222
- const { x, y, zoom } = getViewport();
3223
- setViewport({ x, y: y - topOffset, zoom }, { duration: 200 });
3227
+ const { x, y } = getViewport();
3228
+ setViewport({ x: x + rightOffset, y: y - topOffset, zoom: targetZoom }, { duration: 200 });
3224
3229
  }, 210);
3225
3230
  },
3226
3231
  [fitView, getViewport, setViewport]
@@ -3395,11 +3400,11 @@ const FlowCanvas = ({
3395
3400
  setNodes(layoutedNodes);
3396
3401
  setEdges(e);
3397
3402
  setTimeout(() => {
3398
- fitViewWithTopPadding();
3403
+ fitViewWithOffset();
3399
3404
  }, 50);
3400
3405
  }
3401
3406
  isInitialMount.current = false;
3402
- }, [steps, setNodes, setEdges, fitViewWithTopPadding]);
3407
+ }, [steps, setNodes, setEdges, fitViewWithOffset]);
3403
3408
  const syncToParent = useCallback(() => {
3404
3409
  if (isInitialMount.current) return;
3405
3410
  if (syncTimeoutRef.current) {
@@ -3486,9 +3491,9 @@ const FlowCanvas = ({
3486
3491
  const layoutedNodes = applyAutoLayout(nodes, edges);
3487
3492
  setNodes(layoutedNodes);
3488
3493
  setTimeout(() => {
3489
- fitViewWithTopPadding();
3494
+ fitViewWithOffset();
3490
3495
  }, 50);
3491
- }, [nodes, edges, setNodes, fitViewWithTopPadding]);
3496
+ }, [nodes, edges, setNodes, fitViewWithOffset]);
3492
3497
  const handleNodeUpdate = useCallback(
3493
3498
  (nodeId, data) => {
3494
3499
  setNodes(
@@ -3604,29 +3609,6 @@ const FlowCanvas = ({
3604
3609
  },
3605
3610
  children: [
3606
3611
  /* @__PURE__ */ jsx(Background, { color: "#f0f0f0", gap: 20 }),
3607
- /* @__PURE__ */ jsx(
3608
- MiniMap,
3609
- {
3610
- nodeColor: (node) => {
3611
- switch (node.data?.stepType) {
3612
- case "entry":
3613
- return "#5cb176";
3614
- case "message":
3615
- return "#0077cc";
3616
- case "wait":
3617
- return "#e9b200";
3618
- case "branch":
3619
- return "#7b61ff";
3620
- case "exit":
3621
- return "#dc2626";
3622
- default:
3623
- return "#999";
3624
- }
3625
- },
3626
- maskColor: "rgba(0, 0, 0, 0.1)",
3627
- style: { background: "#f7f7f7" }
3628
- }
3629
- ),
3630
3612
  /* @__PURE__ */ jsx(
3631
3613
  FlowToolbar,
3632
3614
  {
@@ -1226,6 +1226,7 @@ const MessageConfig = ({ data, onUpdate, disabled }) => {
1226
1226
  setTemplates(
1227
1227
  results.map((t) => ({
1228
1228
  id: t.id,
1229
+ documentId: t.documentId,
1229
1230
  name: t.name,
1230
1231
  channel: t.channel
1231
1232
  }))
@@ -1285,7 +1286,10 @@ const MessageConfig = ({ data, onUpdate, disabled }) => {
1285
1286
  const handleTemplateChange = (index, templateId) => {
1286
1287
  const template = templates.find((t) => t.id.toString() === templateId);
1287
1288
  const updated = variants.map(
1288
- (v, i) => i === index ? { ...v, template: template ? { id: template.id, name: template.name } : null } : v
1289
+ (v, i) => i === index ? {
1290
+ ...v,
1291
+ template: template ? { id: template.id, documentId: template.documentId, name: template.name } : null
1292
+ } : v
1289
1293
  );
1290
1294
  setVariants(updated);
1291
1295
  onUpdate({
@@ -1682,6 +1686,7 @@ const BranchConfig = ({ data, onUpdate, disabled }) => {
1682
1686
  setSegments(
1683
1687
  results.map((s) => ({
1684
1688
  id: s.id,
1689
+ documentId: s.documentId,
1685
1690
  name: s.name
1686
1691
  }))
1687
1692
  );
@@ -1699,7 +1704,7 @@ const BranchConfig = ({ data, onUpdate, disabled }) => {
1699
1704
  onUpdate({
1700
1705
  config: {
1701
1706
  ...data.config,
1702
- branchSegment: segment ? { id: segment.id, name: segment.name } : null
1707
+ branchSegment: segment ? { id: segment.id, documentId: segment.documentId, name: segment.name } : null
1703
1708
  }
1704
1709
  });
1705
1710
  };
@@ -3219,12 +3224,12 @@ const FlowCanvas = ({
3219
3224
  React.useEffect(() => {
3220
3225
  onValidationChange?.(validation);
3221
3226
  }, [validation, onValidationChange]);
3222
- const fitViewWithTopPadding = React.useCallback(
3223
- (topOffset = 40) => {
3224
- fitView({ padding: 0.2, duration: 200 });
3227
+ const fitViewWithOffset = React.useCallback(
3228
+ ({ topOffset = 40, rightOffset = 150, targetZoom = 0.8 } = {}) => {
3229
+ fitView({ padding: 0.3, duration: 200, maxZoom: targetZoom, minZoom: targetZoom });
3225
3230
  setTimeout(() => {
3226
- const { x, y, zoom } = getViewport();
3227
- setViewport({ x, y: y - topOffset, zoom }, { duration: 200 });
3231
+ const { x, y } = getViewport();
3232
+ setViewport({ x: x + rightOffset, y: y - topOffset, zoom: targetZoom }, { duration: 200 });
3228
3233
  }, 210);
3229
3234
  },
3230
3235
  [fitView, getViewport, setViewport]
@@ -3399,11 +3404,11 @@ const FlowCanvas = ({
3399
3404
  setNodes(layoutedNodes);
3400
3405
  setEdges(e);
3401
3406
  setTimeout(() => {
3402
- fitViewWithTopPadding();
3407
+ fitViewWithOffset();
3403
3408
  }, 50);
3404
3409
  }
3405
3410
  isInitialMount.current = false;
3406
- }, [steps, setNodes, setEdges, fitViewWithTopPadding]);
3411
+ }, [steps, setNodes, setEdges, fitViewWithOffset]);
3407
3412
  const syncToParent = React.useCallback(() => {
3408
3413
  if (isInitialMount.current) return;
3409
3414
  if (syncTimeoutRef.current) {
@@ -3490,9 +3495,9 @@ const FlowCanvas = ({
3490
3495
  const layoutedNodes = applyAutoLayout(nodes, edges);
3491
3496
  setNodes(layoutedNodes);
3492
3497
  setTimeout(() => {
3493
- fitViewWithTopPadding();
3498
+ fitViewWithOffset();
3494
3499
  }, 50);
3495
- }, [nodes, edges, setNodes, fitViewWithTopPadding]);
3500
+ }, [nodes, edges, setNodes, fitViewWithOffset]);
3496
3501
  const handleNodeUpdate = React.useCallback(
3497
3502
  (nodeId, data) => {
3498
3503
  setNodes(
@@ -3608,29 +3613,6 @@ const FlowCanvas = ({
3608
3613
  },
3609
3614
  children: [
3610
3615
  /* @__PURE__ */ jsxRuntime.jsx(ReactFlow.Background, { color: "#f0f0f0", gap: 20 }),
3611
- /* @__PURE__ */ jsxRuntime.jsx(
3612
- ReactFlow.MiniMap,
3613
- {
3614
- nodeColor: (node) => {
3615
- switch (node.data?.stepType) {
3616
- case "entry":
3617
- return "#5cb176";
3618
- case "message":
3619
- return "#0077cc";
3620
- case "wait":
3621
- return "#e9b200";
3622
- case "branch":
3623
- return "#7b61ff";
3624
- case "exit":
3625
- return "#dc2626";
3626
- default:
3627
- return "#999";
3628
- }
3629
- },
3630
- maskColor: "rgba(0, 0, 0, 0.1)",
3631
- style: { background: "#f7f7f7" }
3632
- }
3633
- ),
3634
3616
  /* @__PURE__ */ jsxRuntime.jsx(
3635
3617
  FlowToolbar,
3636
3618
  {
@@ -4,7 +4,7 @@ import { ReactFlowProvider } from "reactflow";
4
4
  import "reactflow/dist/style.css";
5
5
  import { Field, Flex, Badge, Box } from "@strapi/design-system";
6
6
  import { useForm, useFetchClient, unstable_useContentManagerContext } from "@strapi/strapi/admin";
7
- import { p as parseValue, F as FlowCanvas } from "./FlowCanvas-C7Ea3Xdf.mjs";
7
+ import { p as parseValue, F as FlowCanvas } from "./FlowCanvas-DYo3sZ0Q.mjs";
8
8
  const StepFlowBuilderInner = forwardRef(
9
9
  ({ name, value, onChange, intlLabel, disabled, error: externalError, required, hint }, ref) => {
10
10
  const [steps, setSteps] = useState([]);
@@ -6,7 +6,7 @@ const ReactFlow = require("reactflow");
6
6
  require("reactflow/dist/style.css");
7
7
  const designSystem = require("@strapi/design-system");
8
8
  const admin = require("@strapi/strapi/admin");
9
- const FlowCanvas = require("./FlowCanvas-xt_QOMvb.js");
9
+ const FlowCanvas = require("./FlowCanvas-GXRzXKtK.js");
10
10
  const StepFlowBuilderInner = React.forwardRef(
11
11
  ({ name, value, onChange, intlLabel, disabled, error: externalError, required, hint }, ref) => {
12
12
  const [steps, setSteps] = React.useState([]);