@industry-theme/principal-view-panels 0.1.13 → 0.1.14

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.
@@ -47788,19 +47788,11 @@ function requireEdgeInfoPanel() {
47788
47788
  EdgeInfoPanel.EdgeInfoPanel = void 0;
47789
47789
  const jsx_runtime_1 = require$$0;
47790
47790
  const industry_theme_1 = requireCjs();
47791
- const EdgeInfoPanel$1 = ({ edge, typeDefinition, sourceNodeId, targetNodeId, onClose, onDelete }) => {
47791
+ const SIDE_OPTIONS = ["top", "right", "bottom", "left"];
47792
+ const EdgeInfoPanel$1 = ({ edge, typeDefinition, sourceNodeId, targetNodeId, onClose, onDelete, onUpdateSides }) => {
47793
+ var _a, _b;
47792
47794
  const { theme } = (0, industry_theme_1.useTheme)();
47793
47795
  const edgeColor = typeDefinition.color || theme.colors.primary;
47794
- const displayFields = typeDefinition.dataSchema ? Object.entries(typeDefinition.dataSchema).filter(([, schema2]) => schema2.displayInInfo).map(([field, schema2]) => {
47795
- var _a;
47796
- return {
47797
- field,
47798
- label: schema2.label || field,
47799
- value: (_a = edge.data) == null ? void 0 : _a[field]
47800
- };
47801
- }) : [];
47802
- const hasSchemaFields = displayFields.length > 0;
47803
- const edgeDataEntries = edge.data ? Object.entries(edge.data) : [];
47804
47796
  return (0, jsx_runtime_1.jsxs)("div", { style: {
47805
47797
  position: "absolute",
47806
47798
  top: "60px",
@@ -47850,17 +47842,37 @@ function requireEdgeInfoPanel() {
47850
47842
  backgroundColor: theme.colors.muted,
47851
47843
  padding: "2px 6px",
47852
47844
  borderRadius: "3px"
47853
- }, children: targetNodeId })] })] }), hasSchemaFields && (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "12px" }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
47854
- fontSize: "10px",
47855
- color: theme.colors.textSecondary,
47856
- marginBottom: "8px",
47857
- fontWeight: "bold"
47858
- }, children: "Properties" }), displayFields.map(({ field, label, value }) => (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "8px" }, children: [(0, jsx_runtime_1.jsx)("div", { style: { fontSize: "10px", color: theme.colors.textSecondary, marginBottom: "2px" }, children: label }), (0, jsx_runtime_1.jsx)("div", { style: { fontSize: "12px" }, children: value !== void 0 && value !== null ? typeof value === "object" ? JSON.stringify(value, null, 2) : String(value) : "-" })] }, field))] }), !hasSchemaFields && edgeDataEntries.length > 0 && (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "12px" }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
47859
- fontSize: "10px",
47860
- color: theme.colors.textSecondary,
47861
- marginBottom: "8px",
47862
- fontWeight: "bold"
47863
- }, children: "Data" }), edgeDataEntries.map(([key, value]) => (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "8px" }, children: [(0, jsx_runtime_1.jsx)("div", { style: { fontSize: "10px", color: theme.colors.textSecondary, marginBottom: "2px" }, children: key }), (0, jsx_runtime_1.jsx)("div", { style: { fontSize: "12px", wordBreak: "break-word" }, children: value !== void 0 && value !== null ? typeof value === "object" ? JSON.stringify(value, null, 2) : String(value) : "-" })] }, key))] }), (0, jsx_runtime_1.jsxs)("div", { style: {
47845
+ }, children: targetNodeId })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: "12px" }, children: [(0, jsx_runtime_1.jsx)("div", { style: { fontSize: "10px", color: theme.colors.textSecondary, marginBottom: "8px" }, children: "Connection Sides" }), (0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", gap: "12px" }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)("div", { style: { fontSize: "10px", color: theme.colors.textMuted, marginBottom: "4px" }, children: "From Side" }), (0, jsx_runtime_1.jsx)("select", { value: ((_a = edge.data) == null ? void 0 : _a.fromSide) || "right", onChange: (e) => {
47846
+ var _a2;
47847
+ if (onUpdateSides) {
47848
+ onUpdateSides(edge.id, e.target.value, ((_a2 = edge.data) == null ? void 0 : _a2.toSide) || "left");
47849
+ }
47850
+ }, disabled: !onUpdateSides, style: {
47851
+ width: "100%",
47852
+ padding: "6px 8px",
47853
+ fontSize: "12px",
47854
+ borderRadius: "4px",
47855
+ border: `1px solid ${theme.colors.border}`,
47856
+ backgroundColor: theme.colors.background,
47857
+ color: theme.colors.text,
47858
+ cursor: onUpdateSides ? "pointer" : "not-allowed",
47859
+ opacity: onUpdateSides ? 1 : 0.6
47860
+ }, children: SIDE_OPTIONS.map((side) => (0, jsx_runtime_1.jsx)("option", { value: side, children: side }, side)) })] }), (0, jsx_runtime_1.jsxs)("div", { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)("div", { style: { fontSize: "10px", color: theme.colors.textMuted, marginBottom: "4px" }, children: "To Side" }), (0, jsx_runtime_1.jsx)("select", { value: ((_b = edge.data) == null ? void 0 : _b.toSide) || "left", onChange: (e) => {
47861
+ var _a2;
47862
+ if (onUpdateSides) {
47863
+ onUpdateSides(edge.id, ((_a2 = edge.data) == null ? void 0 : _a2.fromSide) || "right", e.target.value);
47864
+ }
47865
+ }, disabled: !onUpdateSides, style: {
47866
+ width: "100%",
47867
+ padding: "6px 8px",
47868
+ fontSize: "12px",
47869
+ borderRadius: "4px",
47870
+ border: `1px solid ${theme.colors.border}`,
47871
+ backgroundColor: theme.colors.background,
47872
+ color: theme.colors.text,
47873
+ cursor: onUpdateSides ? "pointer" : "not-allowed",
47874
+ opacity: onUpdateSides ? 1 : 0.6
47875
+ }, children: SIDE_OPTIONS.map((side) => (0, jsx_runtime_1.jsx)("option", { value: side, children: side }, side)) })] })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
47864
47876
  fontSize: "10px",
47865
47877
  color: theme.colors.textMuted,
47866
47878
  marginTop: "12px",
@@ -48237,6 +48249,16 @@ function requireGraphRenderer() {
48237
48249
  const onCloseEdgeInfoPanel = (0, react_1.useCallback)(() => {
48238
48250
  setSelectedEdgeId(null);
48239
48251
  }, []);
48252
+ const handleUpdateEdgeSides = (0, react_1.useCallback)((edgeId, fromSide, toSide) => {
48253
+ setLocalEdges((currentEdges) => currentEdges.map((edge) => edge.id === edgeId ? {
48254
+ ...edge,
48255
+ data: {
48256
+ ...edge.data,
48257
+ fromSide,
48258
+ toSide
48259
+ }
48260
+ } : edge));
48261
+ }, []);
48240
48262
  const onCloseNodeInfoPanel = (0, react_1.useCallback)(() => {
48241
48263
  setSelectedNodeId(null);
48242
48264
  }, []);
@@ -48675,11 +48697,11 @@ function requireGraphRenderer() {
48675
48697
  }, 100);
48676
48698
  return () => clearTimeout(timeoutId);
48677
48699
  }, [baseNodesKey, fitView]);
48678
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_2.ReactFlow, { nodes: xyflowNodes, edges: xyflowEdges, nodeTypes, edgeTypes, minZoom: 0.1, maxZoom: 4, defaultEdgeOptions: { type: "custom" }, onEdgeClick, onNodeClick, proOptions: { hideAttribution: true }, nodesDraggable: editable, elementsSelectable: editable, nodesConnectable: editable, edgesReconnectable: editable, onNodesChange: handleNodesChange, onConnect: handleConnect, onReconnectStart: handleReconnectStart, onReconnect: handleReconnect, onReconnectEnd: handleReconnectEnd, panOnDrag: true, selectionOnDrag: false, children: [showBackground && (0, jsx_runtime_1.jsx)(react_2.Background, { color: theme.colors.border, gap: 16, size: 1 }), showControls && (0, jsx_runtime_1.jsx)(react_2.Controls, { showZoom: true, showFitView: true, showInteractive: true }), showMinimap && (0, jsx_runtime_1.jsx)(react_2.MiniMap, { nodeColor: (node) => {
48700
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_2.ReactFlow, { nodes: xyflowNodes, edges: xyflowEdges, nodeTypes, edgeTypes, minZoom: 0.1, maxZoom: 4, defaultEdgeOptions: { type: "custom" }, onEdgeClick, onNodeClick, proOptions: { hideAttribution: true }, nodesDraggable: editable, elementsSelectable: true, nodesConnectable: editable, edgesReconnectable: editable, reconnectRadius: 100, elevateEdgesOnSelect: true, onNodesChange: handleNodesChange, onConnect: handleConnect, onReconnectStart: handleReconnectStart, onReconnect: handleReconnect, onReconnectEnd: handleReconnectEnd, panOnDrag: true, selectionOnDrag: false, children: [showBackground && (0, jsx_runtime_1.jsx)(react_2.Background, { color: theme.colors.border, gap: 16, size: 1 }), showControls && (0, jsx_runtime_1.jsx)(react_2.Controls, { showZoom: true, showFitView: true, showInteractive: true }), showMinimap && (0, jsx_runtime_1.jsx)(react_2.MiniMap, { nodeColor: (node) => {
48679
48701
  var _a;
48680
48702
  const nodeData = node.data;
48681
48703
  return ((_a = nodeData == null ? void 0 : nodeData.typeDefinition) == null ? void 0 : _a.color) || theme.colors.secondary;
48682
- }, nodeBorderRadius: 2, pannable: true, zoomable: true })] }, baseNodesKey), selectedEdge && selectedEdgeTypeDefinition && (0, jsx_runtime_1.jsx)(EdgeInfoPanel_1.EdgeInfoPanel, { edge: selectedEdge, typeDefinition: selectedEdgeTypeDefinition, sourceNodeId: selectedEdge.from, targetNodeId: selectedEdge.to, onClose: onCloseEdgeInfoPanel, onDelete: editable ? handleEdgeDelete : void 0 }), selectedNode && selectedNodeTypeDefinition && (0, jsx_runtime_1.jsx)(NodeInfoPanel_1.NodeInfoPanel, { node: selectedNode, typeDefinition: selectedNodeTypeDefinition, availableNodeTypes: configuration.nodeTypes, onClose: onCloseNodeInfoPanel, onDelete: editable ? handleNodeDelete : void 0, onUpdate: editable ? handleNodeUpdate : void 0 }), pendingConnection && (0, jsx_runtime_1.jsxs)("div", { style: {
48704
+ }, nodeBorderRadius: 2, pannable: true, zoomable: true })] }, baseNodesKey), selectedEdge && selectedEdgeTypeDefinition && (0, jsx_runtime_1.jsx)(EdgeInfoPanel_1.EdgeInfoPanel, { edge: selectedEdge, typeDefinition: selectedEdgeTypeDefinition, sourceNodeId: selectedEdge.from, targetNodeId: selectedEdge.to, onClose: onCloseEdgeInfoPanel, onDelete: editable ? handleEdgeDelete : void 0, onUpdateSides: editable ? handleUpdateEdgeSides : void 0 }), selectedNode && selectedNodeTypeDefinition && (0, jsx_runtime_1.jsx)(NodeInfoPanel_1.NodeInfoPanel, { node: selectedNode, typeDefinition: selectedNodeTypeDefinition, availableNodeTypes: configuration.nodeTypes, onClose: onCloseNodeInfoPanel, onDelete: editable ? handleNodeDelete : void 0, onUpdate: editable ? handleNodeUpdate : void 0 }), pendingConnection && (0, jsx_runtime_1.jsxs)("div", { style: {
48683
48705
  position: "absolute",
48684
48706
  top: "50%",
48685
48707
  left: "50%",