@uipath/apollo-react 4.39.0 → 4.39.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.
@@ -41,6 +41,7 @@ const external_index_cjs_namespaceObject = require("../../index.cjs");
41
41
  const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
42
42
  const external_motion_react_namespaceObject = require("motion/react");
43
43
  const external_react_namespaceObject = require("react");
44
+ const external_react_dom_namespaceObject = require("react-dom");
44
45
  const external_react_markdown_namespaceObject = require("react-markdown");
45
46
  var external_react_markdown_default = /*#__PURE__*/ __webpack_require__.n(external_react_markdown_namespaceObject);
46
47
  const external_remark_breaks_namespaceObject = require("remark-breaks");
@@ -68,6 +69,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
68
69
  const [isColorPickerOpen, setIsColorPickerOpen] = (0, external_react_namespaceObject.useState)(false);
69
70
  const [localContent, setLocalContent] = (0, external_react_namespaceObject.useState)(data.content || '');
70
71
  const textAreaRef = (0, external_react_namespaceObject.useRef)(null);
72
+ const skipBlurRef = (0, external_react_namespaceObject.useRef)(null);
71
73
  const { ref: markdownRef, scrollCaptureProps } = (0, external_useScrollCapture_cjs_namespaceObject.useScrollCapture)();
72
74
  const colorButtonRef = (0, external_react_namespaceObject.useRef)(null);
73
75
  const [activeFormats, setActiveFormats] = (0, external_react_namespaceObject.useState)({
@@ -131,10 +133,15 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
131
133
  const handleBlur = (0, external_react_namespaceObject.useCallback)(()=>{
132
134
  setIsEditing(false);
133
135
  if (readOnly) return;
134
- if (localContent !== data.content) {
135
- onContentChange?.(localContent);
136
+ const content = textAreaRef.current?.value ?? localContent;
137
+ if (skipBlurRef.current === content) {
138
+ skipBlurRef.current = null;
139
+ return;
140
+ }
141
+ if (content !== data.content) {
142
+ onContentChange?.(content);
136
143
  updateNodeData(id, {
137
- content: localContent
144
+ content
138
145
  });
139
146
  }
140
147
  }, [
@@ -146,6 +153,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
146
153
  readOnly
147
154
  ]);
148
155
  const handleChange = (0, external_react_namespaceObject.useCallback)((e)=>{
156
+ skipBlurRef.current = null;
149
157
  setLocalContent(e.target.value);
150
158
  }, []);
151
159
  const handleFormat = (0, external_react_namespaceObject.useCallback)((result)=>{
@@ -170,6 +178,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
170
178
  const shortcutKeyDown = (0, external_useMarkdownShortcuts_cjs_namespaceObject.useMarkdownShortcuts)(textAreaRef, handleFormat);
171
179
  const handleKeyDown = (0, external_react_namespaceObject.useCallback)((e)=>{
172
180
  if ('Escape' === e.key) {
181
+ skipBlurRef.current = textAreaRef.current?.value ?? localContent;
173
182
  setIsEditing(false);
174
183
  setLocalContent(data.content || '');
175
184
  textAreaRef.current?.blur();
@@ -193,16 +202,35 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
193
202
  shortcutKeyDown(e);
194
203
  }, [
195
204
  data.content,
205
+ localContent,
196
206
  shortcutKeyDown,
197
207
  handleFormat
198
208
  ]);
199
209
  const handleResizeStart = (0, external_react_namespaceObject.useCallback)(()=>{
200
- if (isEditing) textAreaRef.current?.blur();
210
+ if (isEditing) {
211
+ const content = textAreaRef.current?.value ?? localContent;
212
+ if (!readOnly && content !== data.content) {
213
+ skipBlurRef.current = content;
214
+ (0, external_react_dom_namespaceObject.flushSync)(()=>{
215
+ onContentChange?.(content);
216
+ updateNodeData(id, {
217
+ content
218
+ });
219
+ });
220
+ }
221
+ textAreaRef.current?.blur();
222
+ }
201
223
  setIsResizing(true);
202
224
  onResizeStart?.();
203
225
  }, [
226
+ data.content,
227
+ id,
204
228
  isEditing,
205
- onResizeStart
229
+ localContent,
230
+ onContentChange,
231
+ onResizeStart,
232
+ readOnly,
233
+ updateNodeData
206
234
  ]);
207
235
  const handleResizeEnd = (0, external_react_namespaceObject.useCallback)((_event, params)=>{
208
236
  setIsResizing(false);
@@ -1 +1 @@
1
- {"version":3,"file":"StickyNoteNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAiC1E,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAiB,MAAM,wBAAwB,CAAC;AAM7F,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AA2aD,eAAO,MAAM,cAAc,kMAzZxB,mBAAmB,6CAyZqC,CAAC"}
1
+ {"version":3,"file":"StickyNoteNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAkC1E,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAiB,MAAM,wBAAwB,CAAC;AAM7F,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAwcD,eAAO,MAAM,cAAc,kMAtbxB,mBAAmB,6CAsbqC,CAAC"}
@@ -4,6 +4,7 @@ import { CanvasIcon } from "../../index.js";
4
4
  import { NodeResizeControl, useReactFlow } from "../../xyflow/react.js";
5
5
  import { AnimatePresence } from "motion/react";
6
6
  import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
7
+ import { flushSync } from "react-dom";
7
8
  import react_markdown from "react-markdown";
8
9
  import remark_breaks from "remark-breaks";
9
10
  import remark_gfm from "remark-gfm";
@@ -28,6 +29,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
28
29
  const [isColorPickerOpen, setIsColorPickerOpen] = useState(false);
29
30
  const [localContent, setLocalContent] = useState(data.content || '');
30
31
  const textAreaRef = useRef(null);
32
+ const skipBlurRef = useRef(null);
31
33
  const { ref: markdownRef, scrollCaptureProps } = useScrollCapture();
32
34
  const colorButtonRef = useRef(null);
33
35
  const [activeFormats, setActiveFormats] = useState({
@@ -91,10 +93,15 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
91
93
  const handleBlur = useCallback(()=>{
92
94
  setIsEditing(false);
93
95
  if (readOnly) return;
94
- if (localContent !== data.content) {
95
- onContentChange?.(localContent);
96
+ const content = textAreaRef.current?.value ?? localContent;
97
+ if (skipBlurRef.current === content) {
98
+ skipBlurRef.current = null;
99
+ return;
100
+ }
101
+ if (content !== data.content) {
102
+ onContentChange?.(content);
96
103
  updateNodeData(id, {
97
- content: localContent
104
+ content
98
105
  });
99
106
  }
100
107
  }, [
@@ -106,6 +113,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
106
113
  readOnly
107
114
  ]);
108
115
  const handleChange = useCallback((e)=>{
116
+ skipBlurRef.current = null;
109
117
  setLocalContent(e.target.value);
110
118
  }, []);
111
119
  const handleFormat = useCallback((result)=>{
@@ -130,6 +138,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
130
138
  const shortcutKeyDown = useMarkdownShortcuts(textAreaRef, handleFormat);
131
139
  const handleKeyDown = useCallback((e)=>{
132
140
  if ('Escape' === e.key) {
141
+ skipBlurRef.current = textAreaRef.current?.value ?? localContent;
133
142
  setIsEditing(false);
134
143
  setLocalContent(data.content || '');
135
144
  textAreaRef.current?.blur();
@@ -153,16 +162,35 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
153
162
  shortcutKeyDown(e);
154
163
  }, [
155
164
  data.content,
165
+ localContent,
156
166
  shortcutKeyDown,
157
167
  handleFormat
158
168
  ]);
159
169
  const handleResizeStart = useCallback(()=>{
160
- if (isEditing) textAreaRef.current?.blur();
170
+ if (isEditing) {
171
+ const content = textAreaRef.current?.value ?? localContent;
172
+ if (!readOnly && content !== data.content) {
173
+ skipBlurRef.current = content;
174
+ flushSync(()=>{
175
+ onContentChange?.(content);
176
+ updateNodeData(id, {
177
+ content
178
+ });
179
+ });
180
+ }
181
+ textAreaRef.current?.blur();
182
+ }
161
183
  setIsResizing(true);
162
184
  onResizeStart?.();
163
185
  }, [
186
+ data.content,
187
+ id,
164
188
  isEditing,
165
- onResizeStart
189
+ localContent,
190
+ onContentChange,
191
+ onResizeStart,
192
+ readOnly,
193
+ updateNodeData
166
194
  ]);
167
195
  const handleResizeEnd = useCallback((_event, params)=>{
168
196
  setIsResizing(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/apollo-react",
3
- "version": "4.39.0",
3
+ "version": "4.39.1",
4
4
  "description": "Apollo Design System - React component library with Material UI theming",
5
5
  "repository": {
6
6
  "type": "git",