@uipath/apollo-react 6.28.0 → 6.30.0
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/AgentCanvas/agent-flow.manifest.d.ts +2 -0
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts.map +1 -1
- package/dist/canvas/components/CaseFlow/case-flow.manifest.d.ts +2 -0
- package/dist/canvas/components/CaseFlow/case-flow.manifest.d.ts.map +1 -1
- package/dist/canvas/locales/de.cjs +1 -1
- package/dist/canvas/locales/de.d.ts.map +1 -1
- package/dist/canvas/locales/de.js +1 -1
- package/dist/canvas/locales/es-MX.cjs +1 -1
- package/dist/canvas/locales/es-MX.d.ts.map +1 -1
- package/dist/canvas/locales/es-MX.js +1 -1
- package/dist/canvas/locales/es.cjs +1 -1
- package/dist/canvas/locales/es.d.ts.map +1 -1
- package/dist/canvas/locales/es.js +1 -1
- package/dist/canvas/locales/fr.cjs +1 -1
- package/dist/canvas/locales/fr.d.ts.map +1 -1
- package/dist/canvas/locales/fr.js +1 -1
- package/dist/canvas/locales/ja.cjs +1 -1
- package/dist/canvas/locales/ja.d.ts.map +1 -1
- package/dist/canvas/locales/ja.js +1 -1
- package/dist/canvas/locales/ko.cjs +1 -1
- package/dist/canvas/locales/ko.d.ts.map +1 -1
- package/dist/canvas/locales/ko.js +1 -1
- package/dist/canvas/locales/pt-BR.cjs +1 -1
- package/dist/canvas/locales/pt-BR.d.ts.map +1 -1
- package/dist/canvas/locales/pt-BR.js +1 -1
- package/dist/canvas/locales/pt.cjs +1 -1
- package/dist/canvas/locales/pt.d.ts.map +1 -1
- package/dist/canvas/locales/pt.js +1 -1
- package/dist/canvas/locales/ro.cjs +1 -1
- package/dist/canvas/locales/ro.d.ts.map +1 -1
- package/dist/canvas/locales/ro.js +1 -1
- package/dist/canvas/locales/tr.cjs +1 -1
- package/dist/canvas/locales/tr.d.ts.map +1 -1
- package/dist/canvas/locales/tr.js +1 -1
- package/dist/canvas/locales/zh-CN.cjs +1 -1
- package/dist/canvas/locales/zh-CN.d.ts.map +1 -1
- package/dist/canvas/locales/zh-CN.js +1 -1
- package/dist/canvas/locales/zh-TW.cjs +1 -1
- package/dist/canvas/locales/zh-TW.d.ts.map +1 -1
- package/dist/canvas/locales/zh-TW.js +1 -1
- package/dist/canvas/schema/node-definition/index.cjs +2 -1
- package/dist/canvas/schema/node-definition/index.d.ts +4 -2
- package/dist/canvas/schema/node-definition/index.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/index.js +2 -1
- package/dist/canvas/schema/node-definition/node-manifest.cjs +4 -12
- package/dist/canvas/schema/node-definition/node-manifest.d.ts +12 -7
- package/dist/canvas/schema/node-definition/node-manifest.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/node-manifest.js +2 -7
- package/dist/canvas/schema/node-definition/shape.cjs +42 -0
- package/dist/canvas/schema/node-definition/shape.d.ts +9 -0
- package/dist/canvas/schema/node-definition/shape.d.ts.map +1 -0
- package/dist/canvas/schema/node-definition/shape.js +8 -0
- package/dist/canvas/schema/node-instance/base.cjs +2 -2
- package/dist/canvas/schema/node-instance/base.js +1 -1
- package/dist/canvas/schema/toolbar.cjs +2 -0
- package/dist/canvas/schema/toolbar.d.ts +30 -0
- package/dist/canvas/schema/toolbar.d.ts.map +1 -1
- package/dist/canvas/schema/toolbar.js +2 -0
- package/dist/canvas/storybook-utils/manifests/index.d.ts +2 -0
- package/dist/canvas/storybook-utils/manifests/index.d.ts.map +1 -1
- package/dist/canvas/utils/manifest-resolver.cjs +2 -1
- package/dist/canvas/utils/manifest-resolver.d.ts.map +1 -1
- package/dist/canvas/utils/manifest-resolver.js +2 -1
- package/dist/canvas/utils/toolbar-resolver.cjs +31 -4
- package/dist/canvas/utils/toolbar-resolver.d.ts.map +1 -1
- package/dist/canvas/utils/toolbar-resolver.js +31 -4
- package/dist/material/components/ap-chat/components/history/chat-history-item.cjs +174 -46
- package/dist/material/components/ap-chat/components/history/chat-history-item.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/history/chat-history-item.js +174 -46
- package/dist/material/components/ap-chat/locales/en.cjs +1 -1
- package/dist/material/components/ap-chat/locales/en.d.ts.map +1 -1
- package/dist/material/components/ap-chat/locales/en.js +1 -1
- package/dist/material/components/ap-chat/service/ChatModel.cjs +2 -0
- package/dist/material/components/ap-chat/service/ChatModel.d.ts +8 -1
- package/dist/material/components/ap-chat/service/ChatModel.d.ts.map +1 -1
- package/dist/material/components/ap-chat/service/ChatModel.js +2 -0
- package/dist/material/components/ap-chat/service/ChatService.cjs +9 -1
- package/dist/material/components/ap-chat/service/ChatService.d.ts +1 -0
- package/dist/material/components/ap-chat/service/ChatService.d.ts.map +1 -1
- package/dist/material/components/ap-chat/service/ChatService.js +9 -1
- package/dist/material/components/ap-chat/service/LocalHistory.cjs +22 -0
- package/dist/material/components/ap-chat/service/LocalHistory.d.ts +1 -0
- package/dist/material/components/ap-chat/service/LocalHistory.d.ts.map +1 -1
- package/dist/material/components/ap-chat/service/LocalHistory.js +22 -0
- package/dist/material/stories/chat-story-support.cjs +20 -3
- package/dist/material/stories/chat-story-support.d.ts.map +1 -1
- package/dist/material/stories/chat-story-support.js +20 -3
- package/package.json +3 -3
|
@@ -14,6 +14,16 @@ const DEFAULT_ACTIONS_FOR_ALL_MODES = [
|
|
|
14
14
|
}
|
|
15
15
|
]
|
|
16
16
|
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'collapse',
|
|
20
|
+
icon: 'chevrons-down-up',
|
|
21
|
+
label: 'Toggle collapse',
|
|
22
|
+
condition: {
|
|
23
|
+
shapes: [
|
|
24
|
+
'container'
|
|
25
|
+
]
|
|
26
|
+
}
|
|
17
27
|
}
|
|
18
28
|
];
|
|
19
29
|
const DEFAULT_MODE_TOOLBARS = {
|
|
@@ -67,6 +77,10 @@ function evaluateCondition(manifest, action, nodeType, context) {
|
|
|
67
77
|
}
|
|
68
78
|
if (condition.hideOnExecution && context.executionState) return false;
|
|
69
79
|
if (condition.nodeTypes && !condition.nodeTypes.includes(nodeType)) return false;
|
|
80
|
+
if (condition.shapes?.length) {
|
|
81
|
+
const shape = manifest.display?.shape;
|
|
82
|
+
if (!shape || !condition.shapes.includes(shape)) return false;
|
|
83
|
+
}
|
|
70
84
|
if (condition.handles?.length) {
|
|
71
85
|
const manifestHandles = manifest.handleConfiguration.flatMap((group)=>group.handles);
|
|
72
86
|
const hasMatchingHandle = condition.handles.some((requiredHandle)=>manifestHandles.some((manifestHandle)=>manifestHandle.handleType === requiredHandle.handleType && (void 0 === requiredHandle.type || manifestHandle.type === requiredHandle.type)));
|
|
@@ -94,19 +108,31 @@ function convertToNodeAction(action, mode, nodeData) {
|
|
|
94
108
|
}
|
|
95
109
|
};
|
|
96
110
|
}
|
|
111
|
+
function dedupeById(actions) {
|
|
112
|
+
const byId = new Map();
|
|
113
|
+
for (const action of actions)byId.set(action.id, action);
|
|
114
|
+
return [
|
|
115
|
+
...byId.values()
|
|
116
|
+
];
|
|
117
|
+
}
|
|
97
118
|
function mergeToolbarConfigs(base, extension) {
|
|
98
119
|
if (!base && !extension) return {
|
|
99
120
|
actions: []
|
|
100
121
|
};
|
|
101
122
|
if (!base) return extension;
|
|
102
123
|
if (!extension) return base;
|
|
124
|
+
const extensionIds = new Set([
|
|
125
|
+
...extension.actions,
|
|
126
|
+
...extension.overflowActions ?? []
|
|
127
|
+
].map((action)=>action.id));
|
|
128
|
+
const notOverridden = (action)=>!extensionIds.has(action.id);
|
|
103
129
|
return {
|
|
104
130
|
actions: [
|
|
105
|
-
...base.actions,
|
|
131
|
+
...base.actions.filter(notOverridden),
|
|
106
132
|
...extension.actions
|
|
107
133
|
],
|
|
108
134
|
overflowActions: [
|
|
109
|
-
...base.overflowActions ?? [],
|
|
135
|
+
...(base.overflowActions ?? []).filter(notOverridden),
|
|
110
136
|
...extension.overflowActions ?? []
|
|
111
137
|
]
|
|
112
138
|
};
|
|
@@ -122,8 +148,9 @@ function resolveToolbar(manifest, context, nodeData) {
|
|
|
122
148
|
} : rawDefaults;
|
|
123
149
|
const nodeExtensions = manifestToolbarExtensions?.[mode];
|
|
124
150
|
const merged = mergeToolbarConfigs(modeDefaults, nodeExtensions);
|
|
125
|
-
const
|
|
126
|
-
const
|
|
151
|
+
const resolveActions = (actions)=>dedupeById(actions.filter((action)=>evaluateCondition(manifest, action, nodeType, context))).map((action)=>convertToNodeAction(action, mode, nodeData));
|
|
152
|
+
const filteredActions = resolveActions(merged.actions);
|
|
153
|
+
const filteredOverflow = resolveActions(merged.overflowActions ?? []);
|
|
127
154
|
if (0 === filteredActions.length && 0 === filteredOverflow.length) return;
|
|
128
155
|
return {
|
|
129
156
|
actions: filteredActions,
|
|
@@ -48,7 +48,7 @@ const chat_state_provider_cjs_namespaceObject = require("../../providers/chat-st
|
|
|
48
48
|
const loading_provider_cjs_namespaceObject = require("../../providers/loading-provider.cjs");
|
|
49
49
|
const external_service_index_cjs_namespaceObject = require("../../service/index.cjs");
|
|
50
50
|
const action_button_cjs_namespaceObject = require("../common/action-button.cjs");
|
|
51
|
-
const GroupItem = (0, material_namespaceObject.styled)('div')(({ isActive,
|
|
51
|
+
const GroupItem = (0, material_namespaceObject.styled)('div')(({ isActive, showActionButtons })=>({
|
|
52
52
|
width: `calc(100% - 2 * ${apollo_core_default().Spacing.SpacingBase})`,
|
|
53
53
|
padding: `0 calc(${apollo_core_default().Padding.PadL} + ${apollo_core_default().Spacing.SpacingBase})`,
|
|
54
54
|
display: 'flex',
|
|
@@ -66,11 +66,14 @@ const GroupItem = (0, material_namespaceObject.styled)('div')(({ isActive, showR
|
|
|
66
66
|
backgroundColor: 'var(--color-background-selected)',
|
|
67
67
|
borderLeft: "4px solid var(--color-selection-indicator)"
|
|
68
68
|
},
|
|
69
|
-
'& .
|
|
70
|
-
opacity:
|
|
69
|
+
'& .action-buttons-wrapper': {
|
|
70
|
+
opacity: showActionButtons ? 1 : 0,
|
|
71
71
|
position: 'relative',
|
|
72
72
|
left: apollo_core_default().Spacing.SpacingXs,
|
|
73
|
-
marginRight: apollo_core_default().Spacing.SpacingBase
|
|
73
|
+
marginRight: apollo_core_default().Spacing.SpacingBase,
|
|
74
|
+
display: 'flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
gap: apollo_core_default().Spacing.SpacingXs
|
|
74
77
|
}
|
|
75
78
|
}));
|
|
76
79
|
const GroupTitle = (0, material_namespaceObject.styled)('div')(()=>({
|
|
@@ -82,20 +85,47 @@ const GroupTitle = (0, material_namespaceObject.styled)('div')(()=>({
|
|
|
82
85
|
whiteSpace: 'nowrap'
|
|
83
86
|
}
|
|
84
87
|
}));
|
|
88
|
+
const RenameInput = (0, material_namespaceObject.styled)('input')(()=>({
|
|
89
|
+
width: '100%',
|
|
90
|
+
padding: 0,
|
|
91
|
+
margin: 0,
|
|
92
|
+
border: 'none',
|
|
93
|
+
background: 'transparent',
|
|
94
|
+
color: 'var(--color-foreground)',
|
|
95
|
+
fontFamily: 'inherit',
|
|
96
|
+
fontSize: 'inherit',
|
|
97
|
+
lineHeight: 'inherit',
|
|
98
|
+
outline: 'none',
|
|
99
|
+
'&:focus-visible': {
|
|
100
|
+
outline: "1px solid var(--color-focus-indicator)",
|
|
101
|
+
outlineOffset: '2px',
|
|
102
|
+
borderRadius: apollo_core_default().Border.BorderRadiusS
|
|
103
|
+
}
|
|
104
|
+
}));
|
|
85
105
|
const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
|
|
86
106
|
const { _ } = (0, react_namespaceObject.useLingui)();
|
|
87
107
|
const chatService = (0, chat_service_provider_cjs_namespaceObject.useChatService)();
|
|
88
|
-
const { spacing } = (0, chat_state_provider_cjs_namespaceObject.useChatState)();
|
|
108
|
+
const { spacing, disabledFeatures } = (0, chat_state_provider_cjs_namespaceObject.useChatState)();
|
|
109
|
+
const renameEnabled = !disabledFeatures.renameChat;
|
|
89
110
|
const [isActive, setIsActive] = external_react_default().useState(chatService.activeConversationId === item.id);
|
|
90
111
|
const { setWaitingResponse } = (0, loading_provider_cjs_namespaceObject.useLoading)();
|
|
91
|
-
const [
|
|
112
|
+
const [isActionButtonsVisible, setIsActionButtonsVisible] = external_react_default().useState(false);
|
|
92
113
|
const [isFocused, setIsFocused] = external_react_default().useState(false);
|
|
114
|
+
const [isEditing, setIsEditing] = external_react_default().useState(false);
|
|
115
|
+
const [draftName, setDraftName] = external_react_default().useState(item.name);
|
|
93
116
|
const itemRef = external_react_default().useRef(null);
|
|
117
|
+
const inputRef = external_react_default().useRef(null);
|
|
94
118
|
const lastMousePosition = external_react_default().useRef({
|
|
95
119
|
x: 0,
|
|
96
120
|
y: 0
|
|
97
121
|
});
|
|
98
|
-
const
|
|
122
|
+
const isCommittingRef = external_react_default().useRef(false);
|
|
123
|
+
external_react_default().useEffect(()=>{
|
|
124
|
+
if (!isEditing) setDraftName(item.name);
|
|
125
|
+
}, [
|
|
126
|
+
item.name,
|
|
127
|
+
isEditing
|
|
128
|
+
]);
|
|
99
129
|
external_react_default().useEffect(()=>{
|
|
100
130
|
const handleMouseMove = (e)=>{
|
|
101
131
|
if (isFocused) return;
|
|
@@ -106,7 +136,7 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
|
|
|
106
136
|
if (itemRef.current) {
|
|
107
137
|
const rect = itemRef.current.getBoundingClientRect();
|
|
108
138
|
const isInside = e.clientX >= rect.left && e.clientX <= rect.right && e.clientY >= rect.top && e.clientY <= rect.bottom;
|
|
109
|
-
|
|
139
|
+
setIsActionButtonsVisible(isInside);
|
|
110
140
|
}
|
|
111
141
|
};
|
|
112
142
|
document.addEventListener('mousemove', handleMouseMove);
|
|
@@ -138,6 +168,54 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
|
|
|
138
168
|
isActive,
|
|
139
169
|
setWaitingResponse
|
|
140
170
|
]);
|
|
171
|
+
external_react_default().useEffect(()=>{
|
|
172
|
+
if (isEditing) {
|
|
173
|
+
inputRef.current?.focus();
|
|
174
|
+
inputRef.current?.select();
|
|
175
|
+
}
|
|
176
|
+
}, [
|
|
177
|
+
isEditing
|
|
178
|
+
]);
|
|
179
|
+
const enterEditMode = external_react_default().useCallback(()=>{
|
|
180
|
+
if (!isHistoryOpen) return;
|
|
181
|
+
isCommittingRef.current = false;
|
|
182
|
+
setDraftName(item.name);
|
|
183
|
+
setIsEditing(true);
|
|
184
|
+
}, [
|
|
185
|
+
isHistoryOpen,
|
|
186
|
+
item.name
|
|
187
|
+
]);
|
|
188
|
+
const cancelRename = external_react_default().useCallback(()=>{
|
|
189
|
+
isCommittingRef.current = false;
|
|
190
|
+
setDraftName(item.name);
|
|
191
|
+
setIsEditing(false);
|
|
192
|
+
}, [
|
|
193
|
+
item.name
|
|
194
|
+
]);
|
|
195
|
+
const commitRename = external_react_default().useCallback(()=>{
|
|
196
|
+
if (isCommittingRef.current) return;
|
|
197
|
+
const trimmed = draftName.trim();
|
|
198
|
+
if ('' === trimmed || trimmed === item.name) return void cancelRename();
|
|
199
|
+
if (!chatService) return void setIsEditing(false);
|
|
200
|
+
isCommittingRef.current = true;
|
|
201
|
+
chatService.getPreHook(external_service_index_cjs_namespaceObject.AutopilotChatPreHookAction.RenameConversation)({
|
|
202
|
+
conversationId: item.id,
|
|
203
|
+
name: trimmed
|
|
204
|
+
}).then((proceed)=>{
|
|
205
|
+
if (!proceed) return void cancelRename();
|
|
206
|
+
chatService.renameConversation(item.id, trimmed);
|
|
207
|
+
setIsEditing(false);
|
|
208
|
+
isCommittingRef.current = false;
|
|
209
|
+
}).catch(()=>{
|
|
210
|
+
cancelRename();
|
|
211
|
+
});
|
|
212
|
+
}, [
|
|
213
|
+
draftName,
|
|
214
|
+
item.id,
|
|
215
|
+
item.name,
|
|
216
|
+
chatService,
|
|
217
|
+
cancelRename
|
|
218
|
+
]);
|
|
141
219
|
const handleDelete = external_react_default().useCallback((ev, itemId)=>{
|
|
142
220
|
ev.stopPropagation();
|
|
143
221
|
setIsFocused(false);
|
|
@@ -151,65 +229,115 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
|
|
|
151
229
|
}, [
|
|
152
230
|
chatService
|
|
153
231
|
]);
|
|
232
|
+
const handleRename = external_react_default().useCallback((ev)=>{
|
|
233
|
+
ev.stopPropagation();
|
|
234
|
+
setIsFocused(false);
|
|
235
|
+
enterEditMode();
|
|
236
|
+
}, [
|
|
237
|
+
enterEditMode
|
|
238
|
+
]);
|
|
154
239
|
const handleItemClick = external_react_default().useCallback((itemId)=>{
|
|
155
|
-
if (isActive) return;
|
|
240
|
+
if (isEditing || isActive) return;
|
|
156
241
|
chatService.openConversation(itemId);
|
|
157
242
|
chatService.toggleHistory(false);
|
|
158
243
|
}, [
|
|
159
244
|
chatService,
|
|
160
|
-
isActive
|
|
161
|
-
|
|
162
|
-
external_react_default().useEffect(()=>{
|
|
163
|
-
if (isFocused) focusButtonRef.current?.focus();
|
|
164
|
-
}, [
|
|
165
|
-
isFocused
|
|
245
|
+
isActive,
|
|
246
|
+
isEditing
|
|
166
247
|
]);
|
|
248
|
+
const renameLabel = _({
|
|
249
|
+
id: 'autopilot-chat.history.rename'
|
|
250
|
+
});
|
|
251
|
+
const renameInputLabel = _({
|
|
252
|
+
id: 'autopilot-chat.history.rename-input'
|
|
253
|
+
});
|
|
254
|
+
const deleteLabel = _({
|
|
255
|
+
id: 'autopilot-chat.history.delete'
|
|
256
|
+
});
|
|
257
|
+
const showActionButtons = !isEditing && (isFocused || isActionButtonsVisible);
|
|
258
|
+
const tooltipVisible = showActionButtons && isHistoryOpen;
|
|
167
259
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(GroupItem, {
|
|
168
|
-
|
|
260
|
+
showActionButtons: showActionButtons,
|
|
169
261
|
ref: itemRef,
|
|
170
|
-
tabIndex: isHistoryOpen ? 0 : -1,
|
|
262
|
+
tabIndex: isHistoryOpen && !isEditing ? 0 : -1,
|
|
171
263
|
isActive: isActive,
|
|
172
264
|
onClick: ()=>handleItemClick(item.id),
|
|
173
265
|
onKeyDown: (ev)=>{
|
|
266
|
+
if (isEditing) return;
|
|
174
267
|
if ('Enter' === ev.key || ' ' === ev.key) handleItemClick(item.id);
|
|
175
268
|
},
|
|
176
|
-
"aria-label": item.name,
|
|
177
|
-
role:
|
|
178
|
-
"aria-pressed": isActive,
|
|
269
|
+
"aria-label": isEditing ? void 0 : item.name,
|
|
270
|
+
role: isEditing ? void 0 : 'button',
|
|
271
|
+
"aria-pressed": isEditing ? void 0 : isActive,
|
|
179
272
|
children: [
|
|
180
273
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(GroupTitle, {
|
|
181
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
274
|
+
children: isEditing ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RenameInput, {
|
|
275
|
+
ref: inputRef,
|
|
276
|
+
value: draftName,
|
|
277
|
+
"aria-label": renameInputLabel,
|
|
278
|
+
"data-testid": "autopilot-chat-history-rename-input",
|
|
279
|
+
onChange: (ev)=>setDraftName(ev.target.value),
|
|
280
|
+
onClick: (ev)=>ev.stopPropagation(),
|
|
281
|
+
onBlur: commitRename,
|
|
282
|
+
onKeyDown: (ev)=>{
|
|
283
|
+
if ('Enter' === ev.key) {
|
|
284
|
+
ev.preventDefault();
|
|
285
|
+
ev.stopPropagation();
|
|
286
|
+
commitRename();
|
|
287
|
+
} else if ('Escape' === ev.key) {
|
|
288
|
+
ev.preventDefault();
|
|
289
|
+
ev.stopPropagation();
|
|
290
|
+
cancelRename();
|
|
291
|
+
} else ev.stopPropagation();
|
|
292
|
+
}
|
|
293
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApTypography, {
|
|
182
294
|
variant: spacing.primaryFontToken,
|
|
183
295
|
color: 'var(--color-foreground)',
|
|
184
296
|
children: item.name
|
|
185
297
|
})
|
|
186
298
|
}),
|
|
187
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
188
|
-
className: "
|
|
189
|
-
children:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
299
|
+
!isEditing && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
300
|
+
className: "action-buttons-wrapper",
|
|
301
|
+
children: [
|
|
302
|
+
renameEnabled && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(action_button_cjs_namespaceObject.AutopilotChatActionButton, {
|
|
303
|
+
disabled: !isHistoryOpen,
|
|
304
|
+
onClick: (ev)=>handleRename(ev),
|
|
305
|
+
onFocus: ()=>{
|
|
306
|
+
setIsFocused(true);
|
|
307
|
+
},
|
|
308
|
+
onBlur: ()=>{
|
|
309
|
+
setIsFocused(false);
|
|
310
|
+
},
|
|
311
|
+
onKeyDown: (ev)=>{
|
|
312
|
+
if ('Escape' !== ev.key) ev.stopPropagation();
|
|
313
|
+
if ('Enter' === ev.key || ' ' === ev.key) handleRename(ev);
|
|
314
|
+
},
|
|
315
|
+
iconName: "edit",
|
|
316
|
+
iconSize: "16px",
|
|
317
|
+
tooltip: tooltipVisible ? renameLabel : '',
|
|
318
|
+
"data-testid": "autopilot-chat-history-rename",
|
|
319
|
+
ariaLabel: renameLabel
|
|
320
|
+
}),
|
|
321
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(action_button_cjs_namespaceObject.AutopilotChatActionButton, {
|
|
322
|
+
disabled: !isHistoryOpen,
|
|
323
|
+
onClick: (ev)=>handleDelete(ev, item.id),
|
|
324
|
+
onFocus: ()=>{
|
|
325
|
+
setIsFocused(true);
|
|
326
|
+
},
|
|
327
|
+
onBlur: ()=>{
|
|
328
|
+
setIsFocused(false);
|
|
329
|
+
},
|
|
330
|
+
onKeyDown: (ev)=>{
|
|
331
|
+
if ('Escape' !== ev.key) ev.stopPropagation();
|
|
332
|
+
if ('Enter' === ev.key || ' ' === ev.key) handleDelete(ev, item.id);
|
|
333
|
+
},
|
|
334
|
+
iconName: "delete",
|
|
335
|
+
iconSize: "16px",
|
|
336
|
+
tooltip: tooltipVisible ? deleteLabel : '',
|
|
337
|
+
"data-testid": "autopilot-chat-history-delete",
|
|
338
|
+
ariaLabel: deleteLabel
|
|
211
339
|
})
|
|
212
|
-
|
|
340
|
+
]
|
|
213
341
|
})
|
|
214
342
|
]
|
|
215
343
|
}, item.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-history-item.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/history/chat-history-item.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-history-item.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/history/chat-history-item.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,eAAe,CAAC;AA+DvB,UAAU,6BAA6B;IACrC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;CACxB;AA0UD,eAAO,MAAM,wBAAwB,2DAAgD,CAAC"}
|
|
@@ -9,7 +9,7 @@ import { useChatState } from "../../providers/chat-state-provider.js";
|
|
|
9
9
|
import { useLoading } from "../../providers/loading-provider.js";
|
|
10
10
|
import { AutopilotChatEvent, AutopilotChatPreHookAction } from "../../service/index.js";
|
|
11
11
|
import { AutopilotChatActionButton } from "../common/action-button.js";
|
|
12
|
-
const GroupItem = styled('div')(({ isActive,
|
|
12
|
+
const GroupItem = styled('div')(({ isActive, showActionButtons })=>({
|
|
13
13
|
width: `calc(100% - 2 * ${apollo_core.Spacing.SpacingBase})`,
|
|
14
14
|
padding: `0 calc(${apollo_core.Padding.PadL} + ${apollo_core.Spacing.SpacingBase})`,
|
|
15
15
|
display: 'flex',
|
|
@@ -27,11 +27,14 @@ const GroupItem = styled('div')(({ isActive, showRemoveIcon })=>({
|
|
|
27
27
|
backgroundColor: 'var(--color-background-selected)',
|
|
28
28
|
borderLeft: "4px solid var(--color-selection-indicator)"
|
|
29
29
|
},
|
|
30
|
-
'& .
|
|
31
|
-
opacity:
|
|
30
|
+
'& .action-buttons-wrapper': {
|
|
31
|
+
opacity: showActionButtons ? 1 : 0,
|
|
32
32
|
position: 'relative',
|
|
33
33
|
left: apollo_core.Spacing.SpacingXs,
|
|
34
|
-
marginRight: apollo_core.Spacing.SpacingBase
|
|
34
|
+
marginRight: apollo_core.Spacing.SpacingBase,
|
|
35
|
+
display: 'flex',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
gap: apollo_core.Spacing.SpacingXs
|
|
35
38
|
}
|
|
36
39
|
}));
|
|
37
40
|
const GroupTitle = styled('div')(()=>({
|
|
@@ -43,20 +46,47 @@ const GroupTitle = styled('div')(()=>({
|
|
|
43
46
|
whiteSpace: 'nowrap'
|
|
44
47
|
}
|
|
45
48
|
}));
|
|
49
|
+
const RenameInput = styled('input')(()=>({
|
|
50
|
+
width: '100%',
|
|
51
|
+
padding: 0,
|
|
52
|
+
margin: 0,
|
|
53
|
+
border: 'none',
|
|
54
|
+
background: 'transparent',
|
|
55
|
+
color: 'var(--color-foreground)',
|
|
56
|
+
fontFamily: 'inherit',
|
|
57
|
+
fontSize: 'inherit',
|
|
58
|
+
lineHeight: 'inherit',
|
|
59
|
+
outline: 'none',
|
|
60
|
+
'&:focus-visible': {
|
|
61
|
+
outline: "1px solid var(--color-focus-indicator)",
|
|
62
|
+
outlineOffset: '2px',
|
|
63
|
+
borderRadius: apollo_core.Border.BorderRadiusS
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
46
66
|
const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
|
|
47
67
|
const { _ } = useLingui();
|
|
48
68
|
const chatService = useChatService();
|
|
49
|
-
const { spacing } = useChatState();
|
|
69
|
+
const { spacing, disabledFeatures } = useChatState();
|
|
70
|
+
const renameEnabled = !disabledFeatures.renameChat;
|
|
50
71
|
const [isActive, setIsActive] = react.useState(chatService.activeConversationId === item.id);
|
|
51
72
|
const { setWaitingResponse } = useLoading();
|
|
52
|
-
const [
|
|
73
|
+
const [isActionButtonsVisible, setIsActionButtonsVisible] = react.useState(false);
|
|
53
74
|
const [isFocused, setIsFocused] = react.useState(false);
|
|
75
|
+
const [isEditing, setIsEditing] = react.useState(false);
|
|
76
|
+
const [draftName, setDraftName] = react.useState(item.name);
|
|
54
77
|
const itemRef = react.useRef(null);
|
|
78
|
+
const inputRef = react.useRef(null);
|
|
55
79
|
const lastMousePosition = react.useRef({
|
|
56
80
|
x: 0,
|
|
57
81
|
y: 0
|
|
58
82
|
});
|
|
59
|
-
const
|
|
83
|
+
const isCommittingRef = react.useRef(false);
|
|
84
|
+
react.useEffect(()=>{
|
|
85
|
+
if (!isEditing) setDraftName(item.name);
|
|
86
|
+
}, [
|
|
87
|
+
item.name,
|
|
88
|
+
isEditing
|
|
89
|
+
]);
|
|
60
90
|
react.useEffect(()=>{
|
|
61
91
|
const handleMouseMove = (e)=>{
|
|
62
92
|
if (isFocused) return;
|
|
@@ -67,7 +97,7 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
|
|
|
67
97
|
if (itemRef.current) {
|
|
68
98
|
const rect = itemRef.current.getBoundingClientRect();
|
|
69
99
|
const isInside = e.clientX >= rect.left && e.clientX <= rect.right && e.clientY >= rect.top && e.clientY <= rect.bottom;
|
|
70
|
-
|
|
100
|
+
setIsActionButtonsVisible(isInside);
|
|
71
101
|
}
|
|
72
102
|
};
|
|
73
103
|
document.addEventListener('mousemove', handleMouseMove);
|
|
@@ -99,6 +129,54 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
|
|
|
99
129
|
isActive,
|
|
100
130
|
setWaitingResponse
|
|
101
131
|
]);
|
|
132
|
+
react.useEffect(()=>{
|
|
133
|
+
if (isEditing) {
|
|
134
|
+
inputRef.current?.focus();
|
|
135
|
+
inputRef.current?.select();
|
|
136
|
+
}
|
|
137
|
+
}, [
|
|
138
|
+
isEditing
|
|
139
|
+
]);
|
|
140
|
+
const enterEditMode = react.useCallback(()=>{
|
|
141
|
+
if (!isHistoryOpen) return;
|
|
142
|
+
isCommittingRef.current = false;
|
|
143
|
+
setDraftName(item.name);
|
|
144
|
+
setIsEditing(true);
|
|
145
|
+
}, [
|
|
146
|
+
isHistoryOpen,
|
|
147
|
+
item.name
|
|
148
|
+
]);
|
|
149
|
+
const cancelRename = react.useCallback(()=>{
|
|
150
|
+
isCommittingRef.current = false;
|
|
151
|
+
setDraftName(item.name);
|
|
152
|
+
setIsEditing(false);
|
|
153
|
+
}, [
|
|
154
|
+
item.name
|
|
155
|
+
]);
|
|
156
|
+
const commitRename = react.useCallback(()=>{
|
|
157
|
+
if (isCommittingRef.current) return;
|
|
158
|
+
const trimmed = draftName.trim();
|
|
159
|
+
if ('' === trimmed || trimmed === item.name) return void cancelRename();
|
|
160
|
+
if (!chatService) return void setIsEditing(false);
|
|
161
|
+
isCommittingRef.current = true;
|
|
162
|
+
chatService.getPreHook(AutopilotChatPreHookAction.RenameConversation)({
|
|
163
|
+
conversationId: item.id,
|
|
164
|
+
name: trimmed
|
|
165
|
+
}).then((proceed)=>{
|
|
166
|
+
if (!proceed) return void cancelRename();
|
|
167
|
+
chatService.renameConversation(item.id, trimmed);
|
|
168
|
+
setIsEditing(false);
|
|
169
|
+
isCommittingRef.current = false;
|
|
170
|
+
}).catch(()=>{
|
|
171
|
+
cancelRename();
|
|
172
|
+
});
|
|
173
|
+
}, [
|
|
174
|
+
draftName,
|
|
175
|
+
item.id,
|
|
176
|
+
item.name,
|
|
177
|
+
chatService,
|
|
178
|
+
cancelRename
|
|
179
|
+
]);
|
|
102
180
|
const handleDelete = react.useCallback((ev, itemId)=>{
|
|
103
181
|
ev.stopPropagation();
|
|
104
182
|
setIsFocused(false);
|
|
@@ -112,65 +190,115 @@ const AutopilotChatHistoryItemComponent = ({ item, isHistoryOpen })=>{
|
|
|
112
190
|
}, [
|
|
113
191
|
chatService
|
|
114
192
|
]);
|
|
193
|
+
const handleRename = react.useCallback((ev)=>{
|
|
194
|
+
ev.stopPropagation();
|
|
195
|
+
setIsFocused(false);
|
|
196
|
+
enterEditMode();
|
|
197
|
+
}, [
|
|
198
|
+
enterEditMode
|
|
199
|
+
]);
|
|
115
200
|
const handleItemClick = react.useCallback((itemId)=>{
|
|
116
|
-
if (isActive) return;
|
|
201
|
+
if (isEditing || isActive) return;
|
|
117
202
|
chatService.openConversation(itemId);
|
|
118
203
|
chatService.toggleHistory(false);
|
|
119
204
|
}, [
|
|
120
205
|
chatService,
|
|
121
|
-
isActive
|
|
122
|
-
|
|
123
|
-
react.useEffect(()=>{
|
|
124
|
-
if (isFocused) focusButtonRef.current?.focus();
|
|
125
|
-
}, [
|
|
126
|
-
isFocused
|
|
206
|
+
isActive,
|
|
207
|
+
isEditing
|
|
127
208
|
]);
|
|
209
|
+
const renameLabel = _({
|
|
210
|
+
id: 'autopilot-chat.history.rename'
|
|
211
|
+
});
|
|
212
|
+
const renameInputLabel = _({
|
|
213
|
+
id: 'autopilot-chat.history.rename-input'
|
|
214
|
+
});
|
|
215
|
+
const deleteLabel = _({
|
|
216
|
+
id: 'autopilot-chat.history.delete'
|
|
217
|
+
});
|
|
218
|
+
const showActionButtons = !isEditing && (isFocused || isActionButtonsVisible);
|
|
219
|
+
const tooltipVisible = showActionButtons && isHistoryOpen;
|
|
128
220
|
return /*#__PURE__*/ jsxs(GroupItem, {
|
|
129
|
-
|
|
221
|
+
showActionButtons: showActionButtons,
|
|
130
222
|
ref: itemRef,
|
|
131
|
-
tabIndex: isHistoryOpen ? 0 : -1,
|
|
223
|
+
tabIndex: isHistoryOpen && !isEditing ? 0 : -1,
|
|
132
224
|
isActive: isActive,
|
|
133
225
|
onClick: ()=>handleItemClick(item.id),
|
|
134
226
|
onKeyDown: (ev)=>{
|
|
227
|
+
if (isEditing) return;
|
|
135
228
|
if ('Enter' === ev.key || ' ' === ev.key) handleItemClick(item.id);
|
|
136
229
|
},
|
|
137
|
-
"aria-label": item.name,
|
|
138
|
-
role:
|
|
139
|
-
"aria-pressed": isActive,
|
|
230
|
+
"aria-label": isEditing ? void 0 : item.name,
|
|
231
|
+
role: isEditing ? void 0 : 'button',
|
|
232
|
+
"aria-pressed": isEditing ? void 0 : isActive,
|
|
140
233
|
children: [
|
|
141
234
|
/*#__PURE__*/ jsx(GroupTitle, {
|
|
142
|
-
children: /*#__PURE__*/ jsx(
|
|
235
|
+
children: isEditing ? /*#__PURE__*/ jsx(RenameInput, {
|
|
236
|
+
ref: inputRef,
|
|
237
|
+
value: draftName,
|
|
238
|
+
"aria-label": renameInputLabel,
|
|
239
|
+
"data-testid": "autopilot-chat-history-rename-input",
|
|
240
|
+
onChange: (ev)=>setDraftName(ev.target.value),
|
|
241
|
+
onClick: (ev)=>ev.stopPropagation(),
|
|
242
|
+
onBlur: commitRename,
|
|
243
|
+
onKeyDown: (ev)=>{
|
|
244
|
+
if ('Enter' === ev.key) {
|
|
245
|
+
ev.preventDefault();
|
|
246
|
+
ev.stopPropagation();
|
|
247
|
+
commitRename();
|
|
248
|
+
} else if ('Escape' === ev.key) {
|
|
249
|
+
ev.preventDefault();
|
|
250
|
+
ev.stopPropagation();
|
|
251
|
+
cancelRename();
|
|
252
|
+
} else ev.stopPropagation();
|
|
253
|
+
}
|
|
254
|
+
}) : /*#__PURE__*/ jsx(ApTypography, {
|
|
143
255
|
variant: spacing.primaryFontToken,
|
|
144
256
|
color: 'var(--color-foreground)',
|
|
145
257
|
children: item.name
|
|
146
258
|
})
|
|
147
259
|
}),
|
|
148
|
-
/*#__PURE__*/
|
|
149
|
-
className: "
|
|
150
|
-
children:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
260
|
+
!isEditing && /*#__PURE__*/ jsxs("div", {
|
|
261
|
+
className: "action-buttons-wrapper",
|
|
262
|
+
children: [
|
|
263
|
+
renameEnabled && /*#__PURE__*/ jsx(AutopilotChatActionButton, {
|
|
264
|
+
disabled: !isHistoryOpen,
|
|
265
|
+
onClick: (ev)=>handleRename(ev),
|
|
266
|
+
onFocus: ()=>{
|
|
267
|
+
setIsFocused(true);
|
|
268
|
+
},
|
|
269
|
+
onBlur: ()=>{
|
|
270
|
+
setIsFocused(false);
|
|
271
|
+
},
|
|
272
|
+
onKeyDown: (ev)=>{
|
|
273
|
+
if ('Escape' !== ev.key) ev.stopPropagation();
|
|
274
|
+
if ('Enter' === ev.key || ' ' === ev.key) handleRename(ev);
|
|
275
|
+
},
|
|
276
|
+
iconName: "edit",
|
|
277
|
+
iconSize: "16px",
|
|
278
|
+
tooltip: tooltipVisible ? renameLabel : '',
|
|
279
|
+
"data-testid": "autopilot-chat-history-rename",
|
|
280
|
+
ariaLabel: renameLabel
|
|
281
|
+
}),
|
|
282
|
+
/*#__PURE__*/ jsx(AutopilotChatActionButton, {
|
|
283
|
+
disabled: !isHistoryOpen,
|
|
284
|
+
onClick: (ev)=>handleDelete(ev, item.id),
|
|
285
|
+
onFocus: ()=>{
|
|
286
|
+
setIsFocused(true);
|
|
287
|
+
},
|
|
288
|
+
onBlur: ()=>{
|
|
289
|
+
setIsFocused(false);
|
|
290
|
+
},
|
|
291
|
+
onKeyDown: (ev)=>{
|
|
292
|
+
if ('Escape' !== ev.key) ev.stopPropagation();
|
|
293
|
+
if ('Enter' === ev.key || ' ' === ev.key) handleDelete(ev, item.id);
|
|
294
|
+
},
|
|
295
|
+
iconName: "delete",
|
|
296
|
+
iconSize: "16px",
|
|
297
|
+
tooltip: tooltipVisible ? deleteLabel : '',
|
|
298
|
+
"data-testid": "autopilot-chat-history-delete",
|
|
299
|
+
ariaLabel: deleteLabel
|
|
172
300
|
})
|
|
173
|
-
|
|
301
|
+
]
|
|
174
302
|
})
|
|
175
303
|
]
|
|
176
304
|
}, item.id);
|