@uipath/apollo-react 6.69.0 → 6.70.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/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +2 -2
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts +1 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +1 -1
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts +11 -0
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/edges/StaticEdge.d.ts +1 -1
- package/dist/canvas/components/AgentCanvas/edges/StaticEdge.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/NodeLabel.cjs +4 -85
- package/dist/canvas/components/BaseNode/NodeLabel.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/NodeLabel.js +5 -86
- package/dist/canvas/components/BaseNode/useInlineLabelEditing.cjs +141 -0
- package/dist/canvas/components/BaseNode/useInlineLabelEditing.d.ts +28 -0
- package/dist/canvas/components/BaseNode/useInlineLabelEditing.d.ts.map +1 -0
- package/dist/canvas/components/BaseNode/useInlineLabelEditing.js +107 -0
- package/dist/canvas/components/CaseFlow/case-flow.manifest.d.ts +11 -0
- package/dist/canvas/components/CaseFlow/case-flow.manifest.d.ts.map +1 -1
- package/dist/canvas/components/ContainerNode/ContainerBadge.cjs +45 -0
- package/dist/canvas/components/ContainerNode/ContainerBadge.d.ts +6 -0
- package/dist/canvas/components/ContainerNode/ContainerBadge.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/ContainerBadge.js +11 -0
- package/dist/canvas/components/ContainerNode/ContainerCanvasNode.cjs +83 -0
- package/dist/canvas/components/ContainerNode/ContainerCanvasNode.d.ts +6 -0
- package/dist/canvas/components/ContainerNode/ContainerCanvasNode.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/ContainerCanvasNode.js +49 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.cjs +375 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.config.cjs +65 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.config.d.ts +20 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.config.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.config.js +28 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.constants.cjs +173 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.constants.d.ts +50 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.constants.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.constants.js +100 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.d.ts +5 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.helpers.cjs +183 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.helpers.d.ts +34 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.helpers.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.helpers.js +137 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.hooks.cjs +100 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.hooks.d.ts +9 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.hooks.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.hooks.js +54 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.js +341 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.types.cjs +18 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.types.d.ts +69 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.types.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/ContainerNode.types.js +0 -0
- package/dist/canvas/components/ContainerNode/ContainerNodeHeader.cjs +144 -0
- package/dist/canvas/components/ContainerNode/ContainerNodeHeader.d.ts +32 -0
- package/dist/canvas/components/ContainerNode/ContainerNodeHeader.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/ContainerNodeHeader.js +110 -0
- package/dist/canvas/components/ContainerNode/ContainerNodeParts.cjs +167 -0
- package/dist/canvas/components/ContainerNode/ContainerNodeParts.d.ts +51 -0
- package/dist/canvas/components/ContainerNode/ContainerNodeParts.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/ContainerNodeParts.js +118 -0
- package/dist/canvas/components/{LoopNode/LoopNodePreview.cjs → ContainerNode/ContainerNodePreview.cjs} +4 -4
- package/dist/canvas/components/{LoopNode/LoopNodePreview.d.ts → ContainerNode/ContainerNodePreview.d.ts} +2 -2
- package/dist/canvas/components/ContainerNode/ContainerNodePreview.d.ts.map +1 -0
- package/dist/canvas/components/{LoopNode/LoopNodePreview.js → ContainerNode/ContainerNodePreview.js} +3 -3
- package/dist/canvas/components/ContainerNode/index.cjs +86 -0
- package/dist/canvas/components/ContainerNode/index.d.ts +6 -0
- package/dist/canvas/components/ContainerNode/index.d.ts.map +1 -0
- package/dist/canvas/components/ContainerNode/index.js +5 -0
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +2 -2
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +2 -2
- package/dist/canvas/components/LoopNode/LoopCanvasNode.cjs +2 -41
- package/dist/canvas/components/LoopNode/LoopCanvasNode.d.ts +1 -5
- package/dist/canvas/components/LoopNode/LoopCanvasNode.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopCanvasNode.js +2 -41
- package/dist/canvas/components/LoopNode/LoopNode.cjs +49 -525
- package/dist/canvas/components/LoopNode/LoopNode.d.ts +5 -1
- package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNode.helpers.cjs +32 -155
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +1 -33
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNode.helpers.js +1 -135
- package/dist/canvas/components/LoopNode/LoopNode.js +50 -529
- package/dist/canvas/components/LoopNode/LoopNode.types.d.ts +3 -12
- package/dist/canvas/components/LoopNode/LoopNode.types.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +2 -2
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +1 -1
- package/dist/canvas/components/index.cjs +51 -44
- package/dist/canvas/components/index.d.ts +1 -0
- package/dist/canvas/components/index.d.ts.map +1 -1
- package/dist/canvas/components/index.js +1 -0
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +2 -2
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +1 -1
- package/dist/canvas/locales/en.cjs +1 -1
- package/dist/canvas/locales/en.d.ts.map +1 -1
- package/dist/canvas/locales/en.js +1 -1
- package/dist/canvas/schema/node-definition/index.cjs +3 -0
- package/dist/canvas/schema/node-definition/index.d.ts +2 -2
- package/dist/canvas/schema/node-definition/index.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/index.js +2 -2
- package/dist/canvas/schema/node-definition/node-manifest.cjs +37 -2
- package/dist/canvas/schema/node-definition/node-manifest.d.ts +85 -0
- package/dist/canvas/schema/node-definition/node-manifest.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/node-manifest.js +34 -2
- package/dist/canvas/storybook-utils/hooks/useCanvasStory.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/manifests/index.d.ts +11 -0
- package/dist/canvas/storybook-utils/manifests/index.d.ts.map +1 -1
- package/dist/canvas/styles/reactflow-reset.css +2 -2
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/canvas/xyflow/base.css +11 -3
- package/dist/canvas/xyflow/style.css +11 -3
- package/package.json +3 -3
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +0 -1
|
@@ -29,7 +29,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
30
30
|
const createPreviewGraph_cjs_namespaceObject = require("../../utils/createPreviewGraph.cjs");
|
|
31
31
|
const manifest_resolver_cjs_namespaceObject = require("../../utils/manifest-resolver.cjs");
|
|
32
|
-
const
|
|
32
|
+
const ContainerNode_helpers_cjs_namespaceObject = require("../ContainerNode/ContainerNode.helpers.cjs");
|
|
33
33
|
function buildSourceBoundaryResolver(sourceNodeId, reactFlowInstance, getManifestForNode) {
|
|
34
34
|
const sourceNode = reactFlowInstance.getNode(sourceNodeId);
|
|
35
35
|
if (!sourceNode) return;
|
|
@@ -51,7 +51,7 @@ function createAddNodePreview(sourceNodeId, sourceHandleId, reactFlowInstance, h
|
|
|
51
51
|
nodeId: sourceNodeId,
|
|
52
52
|
handleId: sourceHandleId
|
|
53
53
|
};
|
|
54
|
-
const overrides = options.getManifestForNode ? (0,
|
|
54
|
+
const overrides = options.getManifestForNode ? (0, ContainerNode_helpers_cjs_namespaceObject.resolveContainerAddNodePreview)({
|
|
55
55
|
source,
|
|
56
56
|
sourceHandleType,
|
|
57
57
|
reactFlowInstance,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Position, type ReactFlowInstance } from '../../xyflow/react.ts';
|
|
2
|
-
import { type ContainerPreviewManifestResolver } from '../
|
|
2
|
+
import { type ContainerPreviewManifestResolver } from '../ContainerNode/ContainerNode.helpers';
|
|
3
3
|
export interface AddNodePreviewOptions {
|
|
4
4
|
getManifestForNode?: ContainerPreviewManifestResolver;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAddNodePreview.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/AddNodePanel/createAddNodePreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAI5F,OAAO,EACL,KAAK,gCAAgC,EAEtC,MAAM,
|
|
1
|
+
{"version":3,"file":"createAddNodePreview.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/AddNodePanel/createAddNodePreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAI5F,OAAO,EACL,KAAK,gCAAgC,EAEtC,MAAM,wCAAwC,CAAC;AAEhD,MAAM,WAAW,qBAAqB;IACpC,kBAAkB,CAAC,EAAE,gCAAgC,CAAC;CACvD;AAoDD,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,GAAE,QAAyB,EACzC,gBAAgB,GAAE,QAAQ,GAAG,QAAmB,EAChD,gBAAgB,GAAE,MAAM,EAAO,EAC/B,OAAO,GAAE,qBAA0B,GAClC,IAAI,CA0BN"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Position } from "../../xyflow/react.js";
|
|
2
2
|
import { showPreviewGraph } from "../../utils/createPreviewGraph.js";
|
|
3
3
|
import { resolveHandles } from "../../utils/manifest-resolver.js";
|
|
4
|
-
import { resolveContainerAddNodePreview } from "../
|
|
4
|
+
import { resolveContainerAddNodePreview } from "../ContainerNode/ContainerNode.helpers.js";
|
|
5
5
|
function buildSourceBoundaryResolver(sourceNodeId, reactFlowInstance, getManifestForNode) {
|
|
6
6
|
const sourceNode = reactFlowInstance.getNode(sourceNodeId);
|
|
7
7
|
if (!sourceNode) return;
|
|
@@ -38,6 +38,17 @@ export declare const agentFlowManifest: {
|
|
|
38
38
|
iconBackgroundDark?: string | undefined;
|
|
39
39
|
iconColor?: string | undefined;
|
|
40
40
|
shadow?: boolean | undefined;
|
|
41
|
+
container?: {
|
|
42
|
+
kind?: string | undefined;
|
|
43
|
+
badge?: string | false | undefined;
|
|
44
|
+
subtitle?: string | undefined;
|
|
45
|
+
emptyStateLabel?: string | undefined;
|
|
46
|
+
borderStyle?: "dashed" | "solid" | undefined;
|
|
47
|
+
accent?: "default" | "info" | "warning" | "error" | "success" | undefined;
|
|
48
|
+
radius?: "default" | "lg" | "xl" | undefined;
|
|
49
|
+
bodyFrame?: "none" | "dashed" | "solid" | undefined;
|
|
50
|
+
labelEditable?: boolean | undefined;
|
|
51
|
+
} | undefined;
|
|
41
52
|
};
|
|
42
53
|
handleConfiguration: {
|
|
43
54
|
position: "top" | "right" | "bottom" | "left";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-flow.manifest.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/AgentCanvas/agent-flow.manifest.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAMnF,eAAO,MAAM,mBAAmB,EAAE,gBAAgB,EAmBjD,CAAC;AAMF,eAAO,MAAM,2BAA2B,EAAE,YAsDzC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,YAqDrC,CAAC;AAMF,eAAO,MAAM,uBAAuB,EAAE,YAwBrC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,YAwBlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,YAwBjC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,YAwBxC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,YAwBpC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,YAwBjC,CAAC;AAMF,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"agent-flow.manifest.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/AgentCanvas/agent-flow.manifest.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAMnF,eAAO,MAAM,mBAAmB,EAAE,gBAAgB,EAmBjD,CAAC;AAMF,eAAO,MAAM,2BAA2B,EAAE,YAsDzC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,YAqDrC,CAAC;AAMF,eAAO,MAAM,uBAAuB,EAAE,YAwBrC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,YAwBlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,YAwBjC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,YAwBxC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,YAwBpC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,YAwBjC,CAAC;AAMF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAa7B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EdgeProps, type Position } from '../../../xyflow/react.ts';
|
|
2
2
|
import type { AgentFlowDefaultEdge, SuggestionType } from '../../../types';
|
|
3
|
-
type StaticEdgeProps = EdgeProps & AgentFlowDefaultEdge & {
|
|
3
|
+
type StaticEdgeProps = EdgeProps & Omit<AgentFlowDefaultEdge, 'type'> & {
|
|
4
4
|
sourceX: number;
|
|
5
5
|
sourceY: number;
|
|
6
6
|
targetX: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticEdge.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/AgentCanvas/edges/StaticEdge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,QAAQ,EACd,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG3E,KAAK,eAAe,GAAG,SAAS,GAC9B,oBAAoB,GAAG;
|
|
1
|
+
{"version":3,"file":"StaticEdge.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/AgentCanvas/edges/StaticEdge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,QAAQ,EACd,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG3E,KAAK,eAAe,GAAG,SAAS,GAC9B,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEJ,eAAO,MAAM,UAAU,GAAI,kLAgBxB,eAAe,4CA2DjB,CAAC"}
|
|
@@ -33,6 +33,7 @@ const external_constants_cjs_namespaceObject = require("../../constants.cjs");
|
|
|
33
33
|
const index_cjs_namespaceObject = require("../../schema/index.cjs");
|
|
34
34
|
const CssUtil_cjs_namespaceObject = require("../../utils/CssUtil.cjs");
|
|
35
35
|
const external_CanvasTooltip_cjs_namespaceObject = require("../CanvasTooltip.cjs");
|
|
36
|
+
const external_useInlineLabelEditing_cjs_namespaceObject = require("./useInlineLabelEditing.cjs");
|
|
36
37
|
const BaseTextContainer = ({ hasBottomHandles, shape, children })=>{
|
|
37
38
|
if ((0, index_cjs_namespaceObject.isWideNodeShape)(shape)) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
38
39
|
"data-node-part": "label",
|
|
@@ -107,97 +108,15 @@ const EmptyLabelPlaceholder = ({ disabled, onDoubleClick })=>/*#__PURE__*/ (0, j
|
|
|
107
108
|
"data-testid": "empty-label-placeholder"
|
|
108
109
|
});
|
|
109
110
|
const NodeLabelInternal = ({ label = '', subLabel = '', labelPlaceholder = 'Name', subLabelPlaceholder = "Description", labelTooltip, labelBackgroundColor, shape, hasBottomHandles, selected, dragging, centerAdornment, readonly, discardDraftOnReadonly, onChange })=>{
|
|
110
|
-
const
|
|
111
|
-
const [localLabel, setLocalLabel] = (0, external_react_namespaceObject.useState)('');
|
|
112
|
-
const [localSubLabel, setLocalSubLabel] = (0, external_react_namespaceObject.useState)('');
|
|
113
|
-
const [focusTarget, setFocusTarget] = (0, external_react_namespaceObject.useState)(null);
|
|
114
|
-
const labelInputRef = (0, external_react_namespaceObject.useRef)(null);
|
|
115
|
-
const subLabelInputRef = (0, external_react_namespaceObject.useRef)(null);
|
|
116
|
-
const handleSave = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
117
|
-
setIsEditing(false);
|
|
118
|
-
setFocusTarget(null);
|
|
119
|
-
const [nextLabel, nextSubLabel] = [
|
|
120
|
-
localLabel.trim(),
|
|
121
|
-
localSubLabel.trim()
|
|
122
|
-
];
|
|
123
|
-
if (nextLabel !== label || nextSubLabel !== subLabel) onChange?.({
|
|
124
|
-
label: nextLabel,
|
|
125
|
-
subLabel: nextSubLabel
|
|
126
|
-
});
|
|
127
|
-
}, [
|
|
128
|
-
localLabel,
|
|
129
|
-
localSubLabel,
|
|
111
|
+
const { isEditing, localLabel, setLocalLabel, localSubLabel, setLocalSubLabel, labelInputRef, subLabelInputRef, handleDoubleClick, handleKeyDown, handleBlur } = (0, external_useInlineLabelEditing_cjs_namespaceObject.useInlineLabelEditing)({
|
|
130
112
|
label,
|
|
131
113
|
subLabel,
|
|
132
|
-
onChange
|
|
133
|
-
]);
|
|
134
|
-
const startEditing = (0, external_react_namespaceObject.useCallback)((targetRef)=>{
|
|
135
|
-
setIsEditing(true);
|
|
136
|
-
setLocalLabel(label);
|
|
137
|
-
setLocalSubLabel(subLabel);
|
|
138
|
-
setFocusTarget(targetRef);
|
|
139
|
-
}, [
|
|
140
|
-
label,
|
|
141
|
-
subLabel
|
|
142
|
-
]);
|
|
143
|
-
const handleDoubleClick = (0, external_react_namespaceObject.useCallback)((targetRef)=>(e)=>{
|
|
144
|
-
e.stopPropagation();
|
|
145
|
-
startEditing(targetRef);
|
|
146
|
-
}, [
|
|
147
|
-
startEditing
|
|
148
|
-
]);
|
|
149
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
150
|
-
if (isEditing && focusTarget?.current) {
|
|
151
|
-
focusTarget.current.focus();
|
|
152
|
-
focusTarget.current.select();
|
|
153
|
-
}
|
|
154
|
-
}, [
|
|
155
|
-
isEditing,
|
|
156
|
-
focusTarget
|
|
157
|
-
]);
|
|
158
|
-
const handleCancel = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
159
|
-
setIsEditing(false);
|
|
160
|
-
setFocusTarget(null);
|
|
161
|
-
setLocalLabel(label);
|
|
162
|
-
setLocalSubLabel(subLabel);
|
|
163
|
-
}, [
|
|
164
|
-
label,
|
|
165
|
-
subLabel
|
|
166
|
-
]);
|
|
167
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
168
|
-
if (!isEditing) return;
|
|
169
|
-
if (readonly && discardDraftOnReadonly) handleCancel();
|
|
170
|
-
else if (!selected || dragging || readonly) handleSave();
|
|
171
|
-
}, [
|
|
172
114
|
selected,
|
|
173
115
|
dragging,
|
|
174
|
-
isEditing,
|
|
175
116
|
readonly,
|
|
176
117
|
discardDraftOnReadonly,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
]);
|
|
180
|
-
const handleKeyDown = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
181
|
-
if ('Enter' === e.key) {
|
|
182
|
-
e.preventDefault();
|
|
183
|
-
e.stopPropagation();
|
|
184
|
-
handleSave();
|
|
185
|
-
} else if ('Escape' === e.key) {
|
|
186
|
-
e.preventDefault();
|
|
187
|
-
e.stopPropagation();
|
|
188
|
-
handleCancel();
|
|
189
|
-
}
|
|
190
|
-
}, [
|
|
191
|
-
handleSave,
|
|
192
|
-
handleCancel
|
|
193
|
-
]);
|
|
194
|
-
const handleBlur = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
195
|
-
const relatedTarget = e.relatedTarget;
|
|
196
|
-
if (relatedTarget === labelInputRef.current || relatedTarget === subLabelInputRef.current) return;
|
|
197
|
-
handleSave();
|
|
198
|
-
}, [
|
|
199
|
-
handleSave
|
|
200
|
-
]);
|
|
118
|
+
onChange
|
|
119
|
+
});
|
|
201
120
|
if (!label && !subLabel && !isEditing) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(BaseTextContainer, {
|
|
202
121
|
hasBottomHandles: hasBottomHandles,
|
|
203
122
|
shape: shape,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeLabel.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/NodeLabel.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeLabel.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/NodeLabel.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAK/D,UAAU,sBAAsB;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,iBAAiB,GAAI,wCAI/B,sBAAsB,4CAwBxB,CAAC;AAyKF,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAClE;AAuHD,eAAO,MAAM,SAAS,kPAtGnB,cAAc,6CAsG+B,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, memo
|
|
2
|
+
import { forwardRef, memo } from "react";
|
|
3
3
|
import { NODE_TEXT_BOTTOM_OFFSET, NODE_TEXT_BOTTOM_OFFSET_WITH_HANDLES } from "../../constants.js";
|
|
4
4
|
import { isWideNodeShape } from "../../schema/index.js";
|
|
5
5
|
import { cx } from "../../utils/CssUtil.js";
|
|
6
6
|
import { CanvasTooltip } from "../CanvasTooltip.js";
|
|
7
|
+
import { useInlineLabelEditing } from "./useInlineLabelEditing.js";
|
|
7
8
|
const BaseTextContainer = ({ hasBottomHandles, shape, children })=>{
|
|
8
9
|
if (isWideNodeShape(shape)) return /*#__PURE__*/ jsx("div", {
|
|
9
10
|
"data-node-part": "label",
|
|
@@ -78,97 +79,15 @@ const EmptyLabelPlaceholder = ({ disabled, onDoubleClick })=>/*#__PURE__*/ jsx("
|
|
|
78
79
|
"data-testid": "empty-label-placeholder"
|
|
79
80
|
});
|
|
80
81
|
const NodeLabelInternal = ({ label = '', subLabel = '', labelPlaceholder = 'Name', subLabelPlaceholder = "Description", labelTooltip, labelBackgroundColor, shape, hasBottomHandles, selected, dragging, centerAdornment, readonly, discardDraftOnReadonly, onChange })=>{
|
|
81
|
-
const
|
|
82
|
-
const [localLabel, setLocalLabel] = useState('');
|
|
83
|
-
const [localSubLabel, setLocalSubLabel] = useState('');
|
|
84
|
-
const [focusTarget, setFocusTarget] = useState(null);
|
|
85
|
-
const labelInputRef = useRef(null);
|
|
86
|
-
const subLabelInputRef = useRef(null);
|
|
87
|
-
const handleSave = useCallback(()=>{
|
|
88
|
-
setIsEditing(false);
|
|
89
|
-
setFocusTarget(null);
|
|
90
|
-
const [nextLabel, nextSubLabel] = [
|
|
91
|
-
localLabel.trim(),
|
|
92
|
-
localSubLabel.trim()
|
|
93
|
-
];
|
|
94
|
-
if (nextLabel !== label || nextSubLabel !== subLabel) onChange?.({
|
|
95
|
-
label: nextLabel,
|
|
96
|
-
subLabel: nextSubLabel
|
|
97
|
-
});
|
|
98
|
-
}, [
|
|
99
|
-
localLabel,
|
|
100
|
-
localSubLabel,
|
|
82
|
+
const { isEditing, localLabel, setLocalLabel, localSubLabel, setLocalSubLabel, labelInputRef, subLabelInputRef, handleDoubleClick, handleKeyDown, handleBlur } = useInlineLabelEditing({
|
|
101
83
|
label,
|
|
102
84
|
subLabel,
|
|
103
|
-
onChange
|
|
104
|
-
]);
|
|
105
|
-
const startEditing = useCallback((targetRef)=>{
|
|
106
|
-
setIsEditing(true);
|
|
107
|
-
setLocalLabel(label);
|
|
108
|
-
setLocalSubLabel(subLabel);
|
|
109
|
-
setFocusTarget(targetRef);
|
|
110
|
-
}, [
|
|
111
|
-
label,
|
|
112
|
-
subLabel
|
|
113
|
-
]);
|
|
114
|
-
const handleDoubleClick = useCallback((targetRef)=>(e)=>{
|
|
115
|
-
e.stopPropagation();
|
|
116
|
-
startEditing(targetRef);
|
|
117
|
-
}, [
|
|
118
|
-
startEditing
|
|
119
|
-
]);
|
|
120
|
-
useEffect(()=>{
|
|
121
|
-
if (isEditing && focusTarget?.current) {
|
|
122
|
-
focusTarget.current.focus();
|
|
123
|
-
focusTarget.current.select();
|
|
124
|
-
}
|
|
125
|
-
}, [
|
|
126
|
-
isEditing,
|
|
127
|
-
focusTarget
|
|
128
|
-
]);
|
|
129
|
-
const handleCancel = useCallback(()=>{
|
|
130
|
-
setIsEditing(false);
|
|
131
|
-
setFocusTarget(null);
|
|
132
|
-
setLocalLabel(label);
|
|
133
|
-
setLocalSubLabel(subLabel);
|
|
134
|
-
}, [
|
|
135
|
-
label,
|
|
136
|
-
subLabel
|
|
137
|
-
]);
|
|
138
|
-
useEffect(()=>{
|
|
139
|
-
if (!isEditing) return;
|
|
140
|
-
if (readonly && discardDraftOnReadonly) handleCancel();
|
|
141
|
-
else if (!selected || dragging || readonly) handleSave();
|
|
142
|
-
}, [
|
|
143
85
|
selected,
|
|
144
86
|
dragging,
|
|
145
|
-
isEditing,
|
|
146
87
|
readonly,
|
|
147
88
|
discardDraftOnReadonly,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
]);
|
|
151
|
-
const handleKeyDown = useCallback((e)=>{
|
|
152
|
-
if ('Enter' === e.key) {
|
|
153
|
-
e.preventDefault();
|
|
154
|
-
e.stopPropagation();
|
|
155
|
-
handleSave();
|
|
156
|
-
} else if ('Escape' === e.key) {
|
|
157
|
-
e.preventDefault();
|
|
158
|
-
e.stopPropagation();
|
|
159
|
-
handleCancel();
|
|
160
|
-
}
|
|
161
|
-
}, [
|
|
162
|
-
handleSave,
|
|
163
|
-
handleCancel
|
|
164
|
-
]);
|
|
165
|
-
const handleBlur = useCallback((e)=>{
|
|
166
|
-
const relatedTarget = e.relatedTarget;
|
|
167
|
-
if (relatedTarget === labelInputRef.current || relatedTarget === subLabelInputRef.current) return;
|
|
168
|
-
handleSave();
|
|
169
|
-
}, [
|
|
170
|
-
handleSave
|
|
171
|
-
]);
|
|
89
|
+
onChange
|
|
90
|
+
});
|
|
172
91
|
if (!label && !subLabel && !isEditing) return /*#__PURE__*/ jsxs(BaseTextContainer, {
|
|
173
92
|
hasBottomHandles: hasBottomHandles,
|
|
174
93
|
shape: shape,
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
useInlineLabelEditing: ()=>useInlineLabelEditing
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
function useInlineLabelEditing({ label, subLabel, selected, dragging, readonly, discardDraftOnReadonly, onChange }) {
|
|
31
|
+
const [isEditing, setIsEditing] = (0, external_react_namespaceObject.useState)(false);
|
|
32
|
+
const [localLabel, setLocalLabel] = (0, external_react_namespaceObject.useState)('');
|
|
33
|
+
const [localSubLabel, setLocalSubLabel] = (0, external_react_namespaceObject.useState)('');
|
|
34
|
+
const [focusTarget, setFocusTarget] = (0, external_react_namespaceObject.useState)(null);
|
|
35
|
+
const labelInputRef = (0, external_react_namespaceObject.useRef)(null);
|
|
36
|
+
const subLabelInputRef = (0, external_react_namespaceObject.useRef)(null);
|
|
37
|
+
const handleSave = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
38
|
+
setIsEditing(false);
|
|
39
|
+
setFocusTarget(null);
|
|
40
|
+
const [nextLabel, nextSubLabel] = [
|
|
41
|
+
localLabel.trim(),
|
|
42
|
+
localSubLabel.trim()
|
|
43
|
+
];
|
|
44
|
+
if (nextLabel !== label || nextSubLabel !== subLabel) onChange?.({
|
|
45
|
+
label: nextLabel,
|
|
46
|
+
subLabel: nextSubLabel
|
|
47
|
+
});
|
|
48
|
+
}, [
|
|
49
|
+
localLabel,
|
|
50
|
+
localSubLabel,
|
|
51
|
+
label,
|
|
52
|
+
subLabel,
|
|
53
|
+
onChange
|
|
54
|
+
]);
|
|
55
|
+
const startEditing = (0, external_react_namespaceObject.useCallback)((targetRef)=>{
|
|
56
|
+
setIsEditing(true);
|
|
57
|
+
setLocalLabel(label);
|
|
58
|
+
setLocalSubLabel(subLabel);
|
|
59
|
+
setFocusTarget(targetRef);
|
|
60
|
+
}, [
|
|
61
|
+
label,
|
|
62
|
+
subLabel
|
|
63
|
+
]);
|
|
64
|
+
const handleDoubleClick = (0, external_react_namespaceObject.useCallback)((targetRef)=>(e)=>{
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
startEditing(targetRef);
|
|
67
|
+
}, [
|
|
68
|
+
startEditing
|
|
69
|
+
]);
|
|
70
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
71
|
+
if (isEditing && focusTarget?.current) {
|
|
72
|
+
focusTarget.current.focus();
|
|
73
|
+
focusTarget.current.select();
|
|
74
|
+
}
|
|
75
|
+
}, [
|
|
76
|
+
isEditing,
|
|
77
|
+
focusTarget
|
|
78
|
+
]);
|
|
79
|
+
const handleCancel = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
80
|
+
setIsEditing(false);
|
|
81
|
+
setFocusTarget(null);
|
|
82
|
+
setLocalLabel(label);
|
|
83
|
+
setLocalSubLabel(subLabel);
|
|
84
|
+
}, [
|
|
85
|
+
label,
|
|
86
|
+
subLabel
|
|
87
|
+
]);
|
|
88
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
89
|
+
if (!isEditing) return;
|
|
90
|
+
if (readonly && discardDraftOnReadonly) handleCancel();
|
|
91
|
+
else if (!selected || dragging || readonly) handleSave();
|
|
92
|
+
}, [
|
|
93
|
+
selected,
|
|
94
|
+
dragging,
|
|
95
|
+
isEditing,
|
|
96
|
+
readonly,
|
|
97
|
+
discardDraftOnReadonly,
|
|
98
|
+
handleSave,
|
|
99
|
+
handleCancel
|
|
100
|
+
]);
|
|
101
|
+
const handleKeyDown = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
102
|
+
if ('Enter' === e.key) {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
e.stopPropagation();
|
|
105
|
+
handleSave();
|
|
106
|
+
} else if ('Escape' === e.key) {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
handleCancel();
|
|
110
|
+
}
|
|
111
|
+
}, [
|
|
112
|
+
handleSave,
|
|
113
|
+
handleCancel
|
|
114
|
+
]);
|
|
115
|
+
const handleBlur = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
116
|
+
const relatedTarget = e.relatedTarget;
|
|
117
|
+
if (relatedTarget === labelInputRef.current || relatedTarget === subLabelInputRef.current) return;
|
|
118
|
+
handleSave();
|
|
119
|
+
}, [
|
|
120
|
+
handleSave
|
|
121
|
+
]);
|
|
122
|
+
return {
|
|
123
|
+
isEditing,
|
|
124
|
+
localLabel,
|
|
125
|
+
setLocalLabel,
|
|
126
|
+
localSubLabel,
|
|
127
|
+
setLocalSubLabel,
|
|
128
|
+
labelInputRef,
|
|
129
|
+
subLabelInputRef,
|
|
130
|
+
handleDoubleClick,
|
|
131
|
+
handleKeyDown,
|
|
132
|
+
handleBlur
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
exports.useInlineLabelEditing = __webpack_exports__.useInlineLabelEditing;
|
|
136
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
137
|
+
"useInlineLabelEditing"
|
|
138
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
139
|
+
Object.defineProperty(exports, '__esModule', {
|
|
140
|
+
value: true
|
|
141
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface InlineLabelValues {
|
|
2
|
+
label: string;
|
|
3
|
+
subLabel: string;
|
|
4
|
+
}
|
|
5
|
+
export interface UseInlineLabelEditingOptions {
|
|
6
|
+
label: string;
|
|
7
|
+
subLabel: string;
|
|
8
|
+
selected?: boolean;
|
|
9
|
+
dragging?: boolean;
|
|
10
|
+
readonly?: boolean;
|
|
11
|
+
discardDraftOnReadonly?: boolean;
|
|
12
|
+
onChange?: (values: InlineLabelValues) => void;
|
|
13
|
+
}
|
|
14
|
+
type InputRef = React.RefObject<HTMLTextAreaElement | null>;
|
|
15
|
+
export declare function useInlineLabelEditing({ label, subLabel, selected, dragging, readonly, discardDraftOnReadonly, onChange, }: UseInlineLabelEditingOptions): {
|
|
16
|
+
isEditing: boolean;
|
|
17
|
+
localLabel: string;
|
|
18
|
+
setLocalLabel: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
19
|
+
localSubLabel: string;
|
|
20
|
+
setLocalSubLabel: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
21
|
+
labelInputRef: import("react").RefObject<HTMLTextAreaElement | null>;
|
|
22
|
+
subLabelInputRef: import("react").RefObject<HTMLTextAreaElement | null>;
|
|
23
|
+
handleDoubleClick: (targetRef: InputRef) => (e: React.MouseEvent) => void;
|
|
24
|
+
handleKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
25
|
+
handleBlur: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=useInlineLabelEditing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInlineLabelEditing.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/BaseNode/useInlineLabelEditing.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAChD;AAED,KAAK,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;AAQ5D,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,sBAAsB,EACtB,QAAQ,GACT,EAAE,4BAA4B;;;;;;;;mCAiCf,QAAQ,SAAS,KAAK,CAAC,UAAU;uBAmCzC,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC;oBAexC,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC;EA2B5C"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
function useInlineLabelEditing({ label, subLabel, selected, dragging, readonly, discardDraftOnReadonly, onChange }) {
|
|
3
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
4
|
+
const [localLabel, setLocalLabel] = useState('');
|
|
5
|
+
const [localSubLabel, setLocalSubLabel] = useState('');
|
|
6
|
+
const [focusTarget, setFocusTarget] = useState(null);
|
|
7
|
+
const labelInputRef = useRef(null);
|
|
8
|
+
const subLabelInputRef = useRef(null);
|
|
9
|
+
const handleSave = useCallback(()=>{
|
|
10
|
+
setIsEditing(false);
|
|
11
|
+
setFocusTarget(null);
|
|
12
|
+
const [nextLabel, nextSubLabel] = [
|
|
13
|
+
localLabel.trim(),
|
|
14
|
+
localSubLabel.trim()
|
|
15
|
+
];
|
|
16
|
+
if (nextLabel !== label || nextSubLabel !== subLabel) onChange?.({
|
|
17
|
+
label: nextLabel,
|
|
18
|
+
subLabel: nextSubLabel
|
|
19
|
+
});
|
|
20
|
+
}, [
|
|
21
|
+
localLabel,
|
|
22
|
+
localSubLabel,
|
|
23
|
+
label,
|
|
24
|
+
subLabel,
|
|
25
|
+
onChange
|
|
26
|
+
]);
|
|
27
|
+
const startEditing = useCallback((targetRef)=>{
|
|
28
|
+
setIsEditing(true);
|
|
29
|
+
setLocalLabel(label);
|
|
30
|
+
setLocalSubLabel(subLabel);
|
|
31
|
+
setFocusTarget(targetRef);
|
|
32
|
+
}, [
|
|
33
|
+
label,
|
|
34
|
+
subLabel
|
|
35
|
+
]);
|
|
36
|
+
const handleDoubleClick = useCallback((targetRef)=>(e)=>{
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
startEditing(targetRef);
|
|
39
|
+
}, [
|
|
40
|
+
startEditing
|
|
41
|
+
]);
|
|
42
|
+
useEffect(()=>{
|
|
43
|
+
if (isEditing && focusTarget?.current) {
|
|
44
|
+
focusTarget.current.focus();
|
|
45
|
+
focusTarget.current.select();
|
|
46
|
+
}
|
|
47
|
+
}, [
|
|
48
|
+
isEditing,
|
|
49
|
+
focusTarget
|
|
50
|
+
]);
|
|
51
|
+
const handleCancel = useCallback(()=>{
|
|
52
|
+
setIsEditing(false);
|
|
53
|
+
setFocusTarget(null);
|
|
54
|
+
setLocalLabel(label);
|
|
55
|
+
setLocalSubLabel(subLabel);
|
|
56
|
+
}, [
|
|
57
|
+
label,
|
|
58
|
+
subLabel
|
|
59
|
+
]);
|
|
60
|
+
useEffect(()=>{
|
|
61
|
+
if (!isEditing) return;
|
|
62
|
+
if (readonly && discardDraftOnReadonly) handleCancel();
|
|
63
|
+
else if (!selected || dragging || readonly) handleSave();
|
|
64
|
+
}, [
|
|
65
|
+
selected,
|
|
66
|
+
dragging,
|
|
67
|
+
isEditing,
|
|
68
|
+
readonly,
|
|
69
|
+
discardDraftOnReadonly,
|
|
70
|
+
handleSave,
|
|
71
|
+
handleCancel
|
|
72
|
+
]);
|
|
73
|
+
const handleKeyDown = useCallback((e)=>{
|
|
74
|
+
if ('Enter' === e.key) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
handleSave();
|
|
78
|
+
} else if ('Escape' === e.key) {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
handleCancel();
|
|
82
|
+
}
|
|
83
|
+
}, [
|
|
84
|
+
handleSave,
|
|
85
|
+
handleCancel
|
|
86
|
+
]);
|
|
87
|
+
const handleBlur = useCallback((e)=>{
|
|
88
|
+
const relatedTarget = e.relatedTarget;
|
|
89
|
+
if (relatedTarget === labelInputRef.current || relatedTarget === subLabelInputRef.current) return;
|
|
90
|
+
handleSave();
|
|
91
|
+
}, [
|
|
92
|
+
handleSave
|
|
93
|
+
]);
|
|
94
|
+
return {
|
|
95
|
+
isEditing,
|
|
96
|
+
localLabel,
|
|
97
|
+
setLocalLabel,
|
|
98
|
+
localSubLabel,
|
|
99
|
+
setLocalSubLabel,
|
|
100
|
+
labelInputRef,
|
|
101
|
+
subLabelInputRef,
|
|
102
|
+
handleDoubleClick,
|
|
103
|
+
handleKeyDown,
|
|
104
|
+
handleBlur
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export { useInlineLabelEditing };
|
|
@@ -31,6 +31,17 @@ export declare const caseFlowManifest: {
|
|
|
31
31
|
iconBackgroundDark?: string | undefined;
|
|
32
32
|
iconColor?: string | undefined;
|
|
33
33
|
shadow?: boolean | undefined;
|
|
34
|
+
container?: {
|
|
35
|
+
kind?: string | undefined;
|
|
36
|
+
badge?: string | false | undefined;
|
|
37
|
+
subtitle?: string | undefined;
|
|
38
|
+
emptyStateLabel?: string | undefined;
|
|
39
|
+
borderStyle?: "dashed" | "solid" | undefined;
|
|
40
|
+
accent?: "default" | "info" | "warning" | "error" | "success" | undefined;
|
|
41
|
+
radius?: "default" | "lg" | "xl" | undefined;
|
|
42
|
+
bodyFrame?: "none" | "dashed" | "solid" | undefined;
|
|
43
|
+
labelEditable?: boolean | undefined;
|
|
44
|
+
} | undefined;
|
|
34
45
|
};
|
|
35
46
|
handleConfiguration: {
|
|
36
47
|
position: "top" | "right" | "bottom" | "left";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"case-flow.manifest.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/CaseFlow/case-flow.manifest.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAMnF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,EAUhD,CAAC;AAMF,eAAO,MAAM,6BAA6B,EAAE,YA2D3C,CAAC;AAMF,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"case-flow.manifest.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/CaseFlow/case-flow.manifest.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAMnF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,EAUhD,CAAC;AAMF,eAAO,MAAM,6BAA6B,EAAE,YA2D3C,CAAC;AAMF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAI5B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
ContainerBadge: ()=>ContainerBadge
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
function ContainerBadge({ icon, children }) {
|
|
31
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
32
|
+
className: "flex h-6 shrink-0 items-center gap-1 rounded-full border border-border bg-surface px-2.5 text-[11px] font-semibold leading-4 text-foreground shadow-sm",
|
|
33
|
+
children: [
|
|
34
|
+
icon,
|
|
35
|
+
children
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.ContainerBadge = __webpack_exports__.ContainerBadge;
|
|
40
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
41
|
+
"ContainerBadge"
|
|
42
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
43
|
+
Object.defineProperty(exports, '__esModule', {
|
|
44
|
+
value: true
|
|
45
|
+
});
|