@uipath/apollo-react 3.27.0 → 3.28.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/material/components/ap-chat/components/input/chat-input-editor.cjs +13 -6
- package/dist/material/components/ap-chat/components/input/chat-input-editor.d.ts +0 -1
- package/dist/material/components/ap-chat/components/input/chat-input-editor.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/input/chat-input-editor.js +14 -7
- package/dist/material/components/ap-chat/components/input/chat-input-resource-picker.cjs +236 -193
- package/dist/material/components/ap-chat/components/input/chat-input-resource-picker.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/input/chat-input-resource-picker.js +238 -195
- package/dist/material/components/ap-chat/components/input/chat-input.cjs +1 -2
- package/dist/material/components/ap-chat/components/input/chat-input.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/input/chat-input.js +1 -2
- package/dist/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.cjs +12 -3
- package/dist/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.js +13 -4
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.cjs +25 -3
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.d.ts +1 -0
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.js +26 -4
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.styles.cjs +2 -1
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.styles.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.styles.js +2 -1
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.cjs +24 -14
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.d.ts +5 -2
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.js +21 -14
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap.utils.cjs +25 -0
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap.utils.d.ts +5 -0
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap.utils.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap.utils.js +23 -1
- package/dist/material/components/ap-chat/components/message/chat-message.cjs +2 -0
- package/dist/material/components/ap-chat/components/message/chat-message.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/message/chat-message.js +2 -0
- package/dist/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.cjs +11 -2
- package/dist/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.d.ts +1 -0
- package/dist/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.d.ts.map +1 -1
- package/dist/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.js +7 -1
- package/dist/material/components/ap-chat/hooks/use-resource-picker-state.cjs +13 -4
- package/dist/material/components/ap-chat/hooks/use-resource-picker-state.d.ts.map +1 -1
- package/dist/material/components/ap-chat/hooks/use-resource-picker-state.js +13 -4
- package/dist/material/components/ap-chat/providers/resource-picker-provider.cjs +54 -19
- package/dist/material/components/ap-chat/providers/resource-picker-provider.d.ts +4 -1
- package/dist/material/components/ap-chat/providers/resource-picker-provider.d.ts.map +1 -1
- package/dist/material/components/ap-chat/providers/resource-picker-provider.js +55 -20
- package/dist/material/components/ap-chat/service/ChatConstants.cjs +16 -4
- package/dist/material/components/ap-chat/service/ChatConstants.d.ts +4 -1
- package/dist/material/components/ap-chat/service/ChatConstants.d.ts.map +1 -1
- package/dist/material/components/ap-chat/service/ChatConstants.js +5 -2
- package/package.json +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useLingui } from "@lingui/react";
|
|
3
3
|
import CircularProgress from "@mui/material/CircularProgress";
|
|
4
4
|
import Menu from "@mui/material/Menu";
|
|
@@ -7,10 +7,11 @@ import { styled } from "@mui/material/styles";
|
|
|
7
7
|
import apollo_core, { FontVariantToken } from "@uipath/apollo-core";
|
|
8
8
|
import { ApButton, ApIcon, ApTypography } from "../../../../index.js";
|
|
9
9
|
import react, { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { List, useListRef } from "react-window";
|
|
10
11
|
import { ApSkeleton } from "../../../ap-skeleton/index.js";
|
|
11
12
|
import { useChatState } from "../../providers/chat-state-provider.js";
|
|
12
13
|
import { isResourceSelector, useAutopilotChatResourcePicker } from "../../providers/resource-picker-provider.js";
|
|
13
|
-
import { CHAT_RESOURCE_PICKER_MAX_SKELETON_COUNT, CHAT_RESOURCE_PICKER_MENU_MAX_HEIGHT, CHAT_RESOURCE_PICKER_MENU_WIDTH, CHAT_RESOURCE_PICKER_MIN_SKELETON_COUNT,
|
|
14
|
+
import { CHAT_RESOURCE_PICKER_ITEM_HEIGHT, CHAT_RESOURCE_PICKER_LOAD_MORE_THRESHOLD, CHAT_RESOURCE_PICKER_MAX_SKELETON_COUNT, CHAT_RESOURCE_PICKER_MENU_MAX_HEIGHT, CHAT_RESOURCE_PICKER_MENU_WIDTH, CHAT_RESOURCE_PICKER_MIN_SKELETON_COUNT, CHAT_RESOURCE_PICKER_TOOLTIP_ENTER_DELAY } from "../../service/index.js";
|
|
14
15
|
import { AutopilotChatIconButton } from "../common/icon-button.js";
|
|
15
16
|
import { AutopilotChatTooltip } from "../common/tooltip.js";
|
|
16
17
|
const ellipsisStyle = {
|
|
@@ -46,12 +47,6 @@ const EmptyContainer = styled('div')(({ theme })=>({
|
|
|
46
47
|
padding: `${apollo_core.Padding.PadXxl} ${apollo_core.Padding.PadXxxl}`,
|
|
47
48
|
color: theme.palette.semantic.colorForegroundDeEmp
|
|
48
49
|
}));
|
|
49
|
-
const LoadMoreContainer = styled('div')({
|
|
50
|
-
display: 'flex',
|
|
51
|
-
alignItems: 'center',
|
|
52
|
-
justifyContent: 'center',
|
|
53
|
-
padding: apollo_core.Padding.PadXxl
|
|
54
|
-
});
|
|
55
50
|
const DrillDownHeader = styled('div')(({ theme })=>({
|
|
56
51
|
display: 'flex',
|
|
57
52
|
alignItems: 'center',
|
|
@@ -62,17 +57,57 @@ const DrillDownHeader = styled('div')(({ theme })=>({
|
|
|
62
57
|
const SkeletonItem = styled(StyledMenuItem)({
|
|
63
58
|
pointerEvents: 'none'
|
|
64
59
|
});
|
|
65
|
-
const
|
|
60
|
+
const StyledResourceList = styled(List)({
|
|
61
|
+
'&::-webkit-scrollbar': {
|
|
62
|
+
width: '6px'
|
|
63
|
+
},
|
|
64
|
+
'&::-webkit-scrollbar-track': {
|
|
65
|
+
background: 'transparent'
|
|
66
|
+
},
|
|
67
|
+
'&::-webkit-scrollbar-thumb': {
|
|
68
|
+
background: 'var(--color-border-de-emp)',
|
|
69
|
+
borderRadius: '3px'
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const loaderRowStyle = {
|
|
73
|
+
display: 'flex',
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
justifyContent: 'center'
|
|
76
|
+
};
|
|
77
|
+
const preventDefaultMouseDown = (e)=>e.preventDefault();
|
|
78
|
+
const MENU_SLOT_PROPS = {
|
|
79
|
+
paper: {
|
|
80
|
+
sx: {
|
|
81
|
+
width: CHAT_RESOURCE_PICKER_MENU_WIDTH,
|
|
82
|
+
maxHeight: CHAT_RESOURCE_PICKER_MENU_MAX_HEIGHT,
|
|
83
|
+
overflowY: 'hidden',
|
|
84
|
+
display: 'flex',
|
|
85
|
+
flexDirection: 'column'
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const VirtualizedResourceRow = ({ index, style, ariaAttributes, items, selectedIndex, navigationMode, handleItemClick, onMouseEnterItem, tooltipPlacement, fontToken })=>{
|
|
90
|
+
if (index >= items.length) return /*#__PURE__*/ jsx("div", {
|
|
91
|
+
style: {
|
|
92
|
+
...style,
|
|
93
|
+
...loaderRowStyle
|
|
94
|
+
},
|
|
95
|
+
children: /*#__PURE__*/ jsx(CircularProgress, {
|
|
96
|
+
size: 20
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
const item = items[index];
|
|
100
|
+
const isSelected = index === selectedIndex;
|
|
66
101
|
const isCategory = isResourceSelector(item);
|
|
67
102
|
const tooltipContent = item.tooltip;
|
|
68
|
-
const
|
|
69
|
-
onItemClick,
|
|
70
|
-
item
|
|
71
|
-
]);
|
|
103
|
+
const isKeyboardSelected = isSelected && 'keyboard' === navigationMode;
|
|
72
104
|
const menuItem = /*#__PURE__*/ jsxs(StyledMenuItem, {
|
|
73
105
|
id: `resource-item-${item.id}`,
|
|
74
106
|
selected: isSelected,
|
|
75
|
-
onClick:
|
|
107
|
+
onClick: ()=>handleItemClick(item),
|
|
108
|
+
onMouseEnter: ()=>onMouseEnterItem(index),
|
|
109
|
+
style: style,
|
|
110
|
+
...ariaAttributes,
|
|
76
111
|
children: [
|
|
77
112
|
/*#__PURE__*/ jsxs(ResourceItemContent, {
|
|
78
113
|
children: [
|
|
@@ -103,49 +138,167 @@ const chat_input_resource_picker_ResourceMenuItem = /*#__PURE__*/ react.memo(fun
|
|
|
103
138
|
children: tooltipContent
|
|
104
139
|
}),
|
|
105
140
|
placement: tooltipPlacement,
|
|
106
|
-
open:
|
|
107
|
-
enterDelay:
|
|
108
|
-
enterNextDelay:
|
|
141
|
+
open: isKeyboardSelected ? true : void 0,
|
|
142
|
+
enterDelay: isKeyboardSelected ? 0 : CHAT_RESOURCE_PICKER_TOOLTIP_ENTER_DELAY,
|
|
143
|
+
enterNextDelay: isKeyboardSelected ? 0 : CHAT_RESOURCE_PICKER_TOOLTIP_ENTER_DELAY,
|
|
109
144
|
children: menuItem
|
|
110
145
|
});
|
|
111
|
-
}
|
|
112
|
-
function
|
|
113
|
-
const {
|
|
146
|
+
};
|
|
147
|
+
const chat_input_resource_picker_MenuContent = /*#__PURE__*/ react.memo(function({ virtualListRef, selectedIndex, navigationMode, onMouseEnterItem, onItemClick }) {
|
|
148
|
+
const { displayedItems: items, drillDown, query, loading, loadingMore, searchInProgress, hasMore, error, previousDisplayCount, goBackOrClose, retryLoad, loadMore } = useAutopilotChatResourcePicker();
|
|
114
149
|
const { theming, spacing } = useChatState();
|
|
115
|
-
const listRef = useRef(null);
|
|
116
|
-
const isOpenRef = useRef(isOpen);
|
|
117
|
-
isOpenRef.current = isOpen;
|
|
118
150
|
const { _ } = useLingui();
|
|
119
|
-
const
|
|
120
|
-
const
|
|
151
|
+
const drillDownHeaderRef = useRef(null);
|
|
152
|
+
const [drillDownHeaderHeight, setDrillDownHeaderHeight] = useState(0);
|
|
153
|
+
useLayoutEffect(()=>{
|
|
154
|
+
if (!drillDown) return void setDrillDownHeaderHeight(0);
|
|
155
|
+
setDrillDownHeaderHeight(drillDownHeaderRef.current?.offsetHeight ?? 0);
|
|
156
|
+
}, [
|
|
157
|
+
drillDown
|
|
158
|
+
]);
|
|
159
|
+
const handleRowsRendered = useCallback((visibleRows, _allRows)=>{
|
|
160
|
+
if (!hasMore || loadingMore) return;
|
|
161
|
+
if (visibleRows.stopIndex >= items.length - CHAT_RESOURCE_PICKER_LOAD_MORE_THRESHOLD) loadMore();
|
|
162
|
+
}, [
|
|
163
|
+
items.length,
|
|
121
164
|
hasMore,
|
|
122
165
|
loadingMore,
|
|
123
|
-
loadMore
|
|
124
|
-
|
|
125
|
-
|
|
166
|
+
loadMore
|
|
167
|
+
]);
|
|
168
|
+
const tooltipPlacement = theming?.chatMenu?.groupItemTooltipPlacement ?? 'left';
|
|
169
|
+
const isLoadingState = loading || searchInProgress;
|
|
170
|
+
const skeletonElements = useMemo(()=>{
|
|
171
|
+
const skeletonCount = Math.min(Math.max(previousDisplayCount, CHAT_RESOURCE_PICKER_MIN_SKELETON_COUNT), CHAT_RESOURCE_PICKER_MAX_SKELETON_COUNT);
|
|
172
|
+
return Array.from({
|
|
173
|
+
length: skeletonCount
|
|
174
|
+
}).map((_, index)=>/*#__PURE__*/ jsx(SkeletonItem, {
|
|
175
|
+
disabled: true,
|
|
176
|
+
children: /*#__PURE__*/ jsx(ApSkeleton, {})
|
|
177
|
+
}, `skeleton-${index}`));
|
|
178
|
+
}, [
|
|
179
|
+
previousDisplayCount
|
|
180
|
+
]);
|
|
181
|
+
const rowCount = items.length + (loadingMore ? 1 : 0);
|
|
182
|
+
const listHeight = Math.min(CHAT_RESOURCE_PICKER_MENU_MAX_HEIGHT - drillDownHeaderHeight, rowCount * CHAT_RESOURCE_PICKER_ITEM_HEIGHT);
|
|
183
|
+
const rowProps = useMemo(()=>({
|
|
184
|
+
items,
|
|
185
|
+
selectedIndex,
|
|
186
|
+
navigationMode,
|
|
187
|
+
handleItemClick: onItemClick,
|
|
188
|
+
onMouseEnterItem,
|
|
189
|
+
tooltipPlacement,
|
|
190
|
+
fontToken: spacing.primaryFontToken
|
|
191
|
+
}), [
|
|
192
|
+
items,
|
|
193
|
+
selectedIndex,
|
|
194
|
+
navigationMode,
|
|
195
|
+
onItemClick,
|
|
196
|
+
onMouseEnterItem,
|
|
197
|
+
tooltipPlacement,
|
|
198
|
+
spacing.primaryFontToken
|
|
199
|
+
]);
|
|
200
|
+
const drillDownHeader = drillDown ? /*#__PURE__*/ jsxs(DrillDownHeader, {
|
|
201
|
+
ref: drillDownHeaderRef,
|
|
202
|
+
children: [
|
|
203
|
+
/*#__PURE__*/ jsx(AutopilotChatIconButton, {
|
|
204
|
+
size: "small",
|
|
205
|
+
onClick: goBackOrClose,
|
|
206
|
+
"aria-label": _({
|
|
207
|
+
id: 'autopilot-chat.resource-picker.back'
|
|
208
|
+
}),
|
|
209
|
+
children: /*#__PURE__*/ jsx(ApIcon, {
|
|
210
|
+
variant: "outlined",
|
|
211
|
+
name: "arrow_back",
|
|
212
|
+
size: apollo_core.Icon.IconXs
|
|
213
|
+
})
|
|
214
|
+
}),
|
|
215
|
+
/*#__PURE__*/ jsx(ApTypography, {
|
|
216
|
+
variant: spacing.primaryBoldFontToken,
|
|
217
|
+
style: ellipsisStyle,
|
|
218
|
+
children: drillDown.category.displayName
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
}) : null;
|
|
222
|
+
if (isLoadingState) return /*#__PURE__*/ jsxs(Fragment, {
|
|
223
|
+
children: [
|
|
224
|
+
drillDownHeader,
|
|
225
|
+
skeletonElements
|
|
226
|
+
]
|
|
126
227
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
228
|
+
if (error) return /*#__PURE__*/ jsxs(Fragment, {
|
|
229
|
+
children: [
|
|
230
|
+
drillDownHeader,
|
|
231
|
+
/*#__PURE__*/ jsxs(ErrorContainer, {
|
|
232
|
+
children: [
|
|
233
|
+
/*#__PURE__*/ jsx(ApTypography, {
|
|
234
|
+
variant: FontVariantToken.fontSizeS,
|
|
235
|
+
children: error
|
|
236
|
+
}),
|
|
237
|
+
/*#__PURE__*/ jsx(ApButton, {
|
|
238
|
+
variant: "text",
|
|
239
|
+
size: "small",
|
|
240
|
+
onClick: retryLoad,
|
|
241
|
+
label: _({
|
|
242
|
+
id: 'autopilot-chat.resource-picker.retry'
|
|
243
|
+
})
|
|
244
|
+
})
|
|
245
|
+
]
|
|
246
|
+
})
|
|
247
|
+
]
|
|
248
|
+
});
|
|
249
|
+
if (0 === items.length) {
|
|
250
|
+
const emptyMessage = query.trim() ? _({
|
|
251
|
+
id: 'autopilot-chat.resource-picker.no-results'
|
|
252
|
+
}) : _({
|
|
253
|
+
id: 'autopilot-chat.resource-picker.empty'
|
|
254
|
+
});
|
|
255
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
256
|
+
children: [
|
|
257
|
+
drillDownHeader,
|
|
258
|
+
/*#__PURE__*/ jsx(EmptyContainer, {
|
|
259
|
+
children: /*#__PURE__*/ jsx(ApTypography, {
|
|
260
|
+
variant: FontVariantToken.fontSizeS,
|
|
261
|
+
children: emptyMessage
|
|
262
|
+
})
|
|
263
|
+
})
|
|
264
|
+
]
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
268
|
+
children: [
|
|
269
|
+
drillDownHeader,
|
|
270
|
+
/*#__PURE__*/ jsx(StyledResourceList, {
|
|
271
|
+
listRef: virtualListRef,
|
|
272
|
+
rowProps: rowProps,
|
|
273
|
+
rowComponent: VirtualizedResourceRow,
|
|
274
|
+
rowCount: rowCount,
|
|
275
|
+
rowHeight: CHAT_RESOURCE_PICKER_ITEM_HEIGHT,
|
|
276
|
+
overscanCount: 5,
|
|
277
|
+
onRowsRendered: handleRowsRendered,
|
|
278
|
+
style: {
|
|
279
|
+
height: listHeight
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
]
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
function ResourcePickerDropdownInner(_props, ref) {
|
|
286
|
+
const { isOpen, isOpenRef, anchorPosition, displayedItems: items, drillDown, query, handleItemClick, close, goBackOrClose } = useAutopilotChatResourcePicker();
|
|
287
|
+
const virtualListRef = useListRef(null);
|
|
288
|
+
const { _ } = useLingui();
|
|
289
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
290
|
+
const [navigationMode, setNavigationMode] = useState('none');
|
|
130
291
|
const prevStateRef = useRef({
|
|
131
292
|
query,
|
|
132
|
-
drillDownId: drillDown?.category?.id
|
|
133
|
-
selectedIndex,
|
|
134
|
-
loadingMore
|
|
293
|
+
drillDownId: drillDown?.category?.id
|
|
135
294
|
});
|
|
136
|
-
const handleScroll = useCallback((event)=>{
|
|
137
|
-
const target = event.currentTarget;
|
|
138
|
-
const state = scrollStateRef.current;
|
|
139
|
-
state.scrollTop = target.scrollTop;
|
|
140
|
-
state.container = target;
|
|
141
|
-
if (!state.hasMore || state.loadingMore) return;
|
|
142
|
-
const nearBottom = target.scrollHeight - target.scrollTop - target.clientHeight < CHAT_RESOURCE_PICKER_SCROLL_THRESHOLD;
|
|
143
|
-
if (nearBottom) state.loadMore();
|
|
144
|
-
}, []);
|
|
145
295
|
useEffect(()=>{
|
|
146
296
|
const prev = prevStateRef.current;
|
|
147
297
|
const currentDrillDownId = drillDown?.category?.id;
|
|
148
|
-
if (prev.query !== query || prev.drillDownId !== currentDrillDownId)
|
|
298
|
+
if (prev.query !== query || prev.drillDownId !== currentDrillDownId) {
|
|
299
|
+
setSelectedIndex(0);
|
|
300
|
+
setNavigationMode('none');
|
|
301
|
+
}
|
|
149
302
|
prev.query = query;
|
|
150
303
|
prev.drillDownId = currentDrillDownId;
|
|
151
304
|
}, [
|
|
@@ -153,44 +306,42 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
153
306
|
drillDown
|
|
154
307
|
]);
|
|
155
308
|
useEffect(()=>{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const selectedItem = displayedItems[selectedIndex];
|
|
160
|
-
if (listRef.current && selectedItem) {
|
|
161
|
-
const selectedElement = listRef.current.querySelector(`#resource-item-${selectedItem.id}`);
|
|
162
|
-
selectedElement?.scrollIntoView({
|
|
163
|
-
block: 'nearest'
|
|
164
|
-
});
|
|
309
|
+
if (isOpen) {
|
|
310
|
+
setSelectedIndex(0);
|
|
311
|
+
setNavigationMode('none');
|
|
165
312
|
}
|
|
166
313
|
}, [
|
|
167
|
-
|
|
168
|
-
displayedItems
|
|
314
|
+
isOpen
|
|
169
315
|
]);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const { scrollTop, container } = scrollStateRef.current;
|
|
176
|
-
if (container && scrollTop > 0) container.scrollTop = scrollTop;
|
|
177
|
-
}
|
|
316
|
+
useEffect(()=>{
|
|
317
|
+
if ('keyboard' === navigationMode) virtualListRef.current?.scrollToRow({
|
|
318
|
+
index: selectedIndex,
|
|
319
|
+
align: 'auto'
|
|
320
|
+
});
|
|
178
321
|
}, [
|
|
179
|
-
|
|
322
|
+
selectedIndex,
|
|
323
|
+
navigationMode,
|
|
324
|
+
virtualListRef
|
|
180
325
|
]);
|
|
181
326
|
const navigateUp = useCallback(()=>{
|
|
182
327
|
setSelectedIndex((prev)=>Math.max(prev - 1, 0));
|
|
328
|
+
setNavigationMode('keyboard');
|
|
183
329
|
}, []);
|
|
184
330
|
const navigateDown = useCallback(()=>{
|
|
185
|
-
setSelectedIndex((prev)=>Math.min(prev + 1,
|
|
331
|
+
setSelectedIndex((prev)=>Math.min(prev + 1, items.length - 1));
|
|
332
|
+
setNavigationMode('keyboard');
|
|
186
333
|
}, [
|
|
187
|
-
|
|
334
|
+
items.length
|
|
188
335
|
]);
|
|
336
|
+
const handleMouseEnterItem = useCallback((index)=>{
|
|
337
|
+
setSelectedIndex(index);
|
|
338
|
+
setNavigationMode('pointer');
|
|
339
|
+
}, []);
|
|
189
340
|
const selectItem = useCallback(()=>{
|
|
190
|
-
const selectedItem =
|
|
341
|
+
const selectedItem = items[selectedIndex];
|
|
191
342
|
if (selectedItem) handleItemClick(selectedItem);
|
|
192
343
|
}, [
|
|
193
|
-
|
|
344
|
+
items,
|
|
194
345
|
selectedIndex,
|
|
195
346
|
handleItemClick
|
|
196
347
|
]);
|
|
@@ -213,7 +364,7 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
213
364
|
return true;
|
|
214
365
|
case 'Escape':
|
|
215
366
|
event.preventDefault();
|
|
216
|
-
goBackOrClose();
|
|
367
|
+
drillDown ? goBackOrClose() : close();
|
|
217
368
|
return true;
|
|
218
369
|
default:
|
|
219
370
|
return false;
|
|
@@ -223,138 +374,23 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
223
374
|
navigateDown,
|
|
224
375
|
navigateUp,
|
|
225
376
|
selectItem,
|
|
226
|
-
goBackOrClose
|
|
377
|
+
goBackOrClose,
|
|
378
|
+
drillDown,
|
|
379
|
+
close
|
|
227
380
|
]);
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return Array.from({
|
|
232
|
-
length: skeletonCount
|
|
233
|
-
}).map((_, index)=>/*#__PURE__*/ jsx(SkeletonItem, {
|
|
234
|
-
disabled: true,
|
|
235
|
-
children: /*#__PURE__*/ jsx(ApSkeleton, {})
|
|
236
|
-
}, `skeleton-${index}`));
|
|
237
|
-
}, [
|
|
238
|
-
previousDisplayCount
|
|
239
|
-
]);
|
|
240
|
-
const menuSlotProps = useMemo(()=>({
|
|
241
|
-
paper: {
|
|
242
|
-
sx: {
|
|
243
|
-
width: CHAT_RESOURCE_PICKER_MENU_WIDTH,
|
|
244
|
-
maxHeight: CHAT_RESOURCE_PICKER_MENU_MAX_HEIGHT,
|
|
245
|
-
overflowY: 'auto'
|
|
246
|
-
},
|
|
247
|
-
onScroll: handleScroll
|
|
248
|
-
}
|
|
249
|
-
}), [
|
|
250
|
-
handleScroll
|
|
251
|
-
]);
|
|
252
|
-
const isLoadingState = loading || searchInProgress;
|
|
253
|
-
const drillDownHeader = useMemo(()=>{
|
|
254
|
-
if (!drillDown) return null;
|
|
255
|
-
return /*#__PURE__*/ jsxs(DrillDownHeader, {
|
|
256
|
-
children: [
|
|
257
|
-
/*#__PURE__*/ jsx(AutopilotChatIconButton, {
|
|
258
|
-
size: "small",
|
|
259
|
-
onClick: goBackOrClose,
|
|
260
|
-
"aria-label": _({
|
|
261
|
-
id: 'autopilot-chat.resource-picker.back'
|
|
262
|
-
}),
|
|
263
|
-
children: /*#__PURE__*/ jsx(ApIcon, {
|
|
264
|
-
variant: "outlined",
|
|
265
|
-
name: "arrow_back",
|
|
266
|
-
size: apollo_core.Icon.IconXs
|
|
267
|
-
})
|
|
268
|
-
}),
|
|
269
|
-
/*#__PURE__*/ jsx(ApTypography, {
|
|
270
|
-
variant: spacing.primaryBoldFontToken,
|
|
271
|
-
style: ellipsisStyle,
|
|
272
|
-
children: drillDown.category.displayName
|
|
273
|
-
})
|
|
274
|
-
]
|
|
275
|
-
}, "drilldown-header");
|
|
381
|
+
const handleMenuClose = useCallback((_event, reason)=>{
|
|
382
|
+
if ('escapeKeyDown' === reason && drillDown) return void goBackOrClose();
|
|
383
|
+
close();
|
|
276
384
|
}, [
|
|
277
385
|
drillDown,
|
|
278
386
|
goBackOrClose,
|
|
279
|
-
|
|
280
|
-
_
|
|
281
|
-
]);
|
|
282
|
-
const menuContent = useMemo(()=>{
|
|
283
|
-
if (isLoadingState) return [
|
|
284
|
-
drillDownHeader,
|
|
285
|
-
...skeletonElements
|
|
286
|
-
];
|
|
287
|
-
if (error) return [
|
|
288
|
-
drillDownHeader,
|
|
289
|
-
/*#__PURE__*/ jsxs(ErrorContainer, {
|
|
290
|
-
children: [
|
|
291
|
-
/*#__PURE__*/ jsx(ApTypography, {
|
|
292
|
-
variant: FontVariantToken.fontSizeS,
|
|
293
|
-
children: error
|
|
294
|
-
}),
|
|
295
|
-
/*#__PURE__*/ jsx(ApButton, {
|
|
296
|
-
variant: "text",
|
|
297
|
-
size: "small",
|
|
298
|
-
onClick: retryLoad,
|
|
299
|
-
label: "retry",
|
|
300
|
-
children: _({
|
|
301
|
-
id: 'autopilot-chat.resource-picker.retry'
|
|
302
|
-
})
|
|
303
|
-
})
|
|
304
|
-
]
|
|
305
|
-
}, "error")
|
|
306
|
-
];
|
|
307
|
-
if (0 === displayedItems.length) {
|
|
308
|
-
const emptyMessage = query.trim() ? _({
|
|
309
|
-
id: 'autopilot-chat.resource-picker.no-results'
|
|
310
|
-
}) : _({
|
|
311
|
-
id: 'autopilot-chat.resource-picker.empty'
|
|
312
|
-
});
|
|
313
|
-
return [
|
|
314
|
-
drillDownHeader,
|
|
315
|
-
/*#__PURE__*/ jsx(EmptyContainer, {
|
|
316
|
-
children: /*#__PURE__*/ jsx(ApTypography, {
|
|
317
|
-
variant: FontVariantToken.fontSizeS,
|
|
318
|
-
children: emptyMessage
|
|
319
|
-
})
|
|
320
|
-
}, "empty")
|
|
321
|
-
];
|
|
322
|
-
}
|
|
323
|
-
return [
|
|
324
|
-
drillDownHeader,
|
|
325
|
-
...displayedItems.map((item, index)=>/*#__PURE__*/ jsx(chat_input_resource_picker_ResourceMenuItem, {
|
|
326
|
-
item: item,
|
|
327
|
-
isSelected: index === selectedIndex,
|
|
328
|
-
onItemClick: handleItemClick,
|
|
329
|
-
tooltipPlacement: tooltipPlacement,
|
|
330
|
-
fontToken: spacing.primaryFontToken
|
|
331
|
-
}, item.id)),
|
|
332
|
-
loadingMore && /*#__PURE__*/ jsx(LoadMoreContainer, {
|
|
333
|
-
children: /*#__PURE__*/ jsx(CircularProgress, {
|
|
334
|
-
size: 20
|
|
335
|
-
})
|
|
336
|
-
}, "loading-more")
|
|
337
|
-
];
|
|
338
|
-
}, [
|
|
339
|
-
isLoadingState,
|
|
340
|
-
drillDownHeader,
|
|
341
|
-
skeletonElements,
|
|
342
|
-
error,
|
|
343
|
-
retryLoad,
|
|
344
|
-
_,
|
|
345
|
-
displayedItems,
|
|
346
|
-
query,
|
|
347
|
-
selectedIndex,
|
|
348
|
-
handleItemClick,
|
|
349
|
-
tooltipPlacement,
|
|
350
|
-
spacing.primaryFontToken,
|
|
351
|
-
loadingMore
|
|
387
|
+
close
|
|
352
388
|
]);
|
|
353
389
|
return /*#__PURE__*/ jsx(Menu, {
|
|
354
390
|
open: isOpen,
|
|
355
391
|
anchorReference: "anchorPosition",
|
|
356
392
|
anchorPosition: anchorPosition ?? void 0,
|
|
357
|
-
onClose:
|
|
393
|
+
onClose: handleMenuClose,
|
|
358
394
|
anchorOrigin: {
|
|
359
395
|
vertical: 'top',
|
|
360
396
|
horizontal: 'left'
|
|
@@ -370,10 +406,17 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
370
406
|
id: 'autopilot-chat.resource-picker.label'
|
|
371
407
|
}),
|
|
372
408
|
dense: true,
|
|
373
|
-
|
|
409
|
+
disableListWrap: true,
|
|
410
|
+
onMouseDown: preventDefaultMouseDown
|
|
374
411
|
},
|
|
375
|
-
slotProps:
|
|
376
|
-
children:
|
|
412
|
+
slotProps: MENU_SLOT_PROPS,
|
|
413
|
+
children: /*#__PURE__*/ jsx(chat_input_resource_picker_MenuContent, {
|
|
414
|
+
virtualListRef: virtualListRef,
|
|
415
|
+
selectedIndex: selectedIndex,
|
|
416
|
+
navigationMode: navigationMode,
|
|
417
|
+
onMouseEnterItem: handleMouseEnterItem,
|
|
418
|
+
onItemClick: handleItemClick
|
|
419
|
+
})
|
|
377
420
|
});
|
|
378
421
|
}
|
|
379
422
|
const ResourcePickerDropdown = /*#__PURE__*/ react.memo(/*#__PURE__*/ forwardRef(ResourcePickerDropdownInner));
|
|
@@ -245,8 +245,7 @@ function AutopilotChatInputComponent() {
|
|
|
245
245
|
onKeyDown: handleKeyDown,
|
|
246
246
|
minRows: spacing.promptBox.minRows,
|
|
247
247
|
maxRows: spacing.promptBox.maxRows,
|
|
248
|
-
lineHeight: editorLineHeight
|
|
249
|
-
anchorEl: inputContainerRef.current
|
|
248
|
+
lineHeight: editorLineHeight
|
|
250
249
|
})
|
|
251
250
|
}),
|
|
252
251
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(GradientContainer, {})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-input.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/input/chat-input.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgF1B,iBAAS,2BAA2B,
|
|
1
|
+
{"version":3,"file":"chat-input.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/input/chat-input.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgF1B,iBAAS,2BAA2B,4CAsNnC;AAED,eAAO,MAAM,kBAAkB,+DAA0C,CAAC"}
|
|
@@ -206,8 +206,7 @@ function AutopilotChatInputComponent() {
|
|
|
206
206
|
onKeyDown: handleKeyDown,
|
|
207
207
|
minRows: spacing.promptBox.minRows,
|
|
208
208
|
maxRows: spacing.promptBox.maxRows,
|
|
209
|
-
lineHeight: editorLineHeight
|
|
210
|
-
anchorEl: inputContainerRef.current
|
|
209
|
+
lineHeight: editorLineHeight
|
|
211
210
|
})
|
|
212
211
|
}),
|
|
213
212
|
/*#__PURE__*/ jsx(GradientContainer, {})
|
package/dist/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.cjs
CHANGED
|
@@ -46,12 +46,12 @@ const external_react_namespaceObject = require("react");
|
|
|
46
46
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
47
47
|
const chat_state_provider_cjs_namespaceObject = require("../../../providers/chat-state-provider.cjs");
|
|
48
48
|
const index_cjs_namespaceObject = require("../../../service/index.cjs");
|
|
49
|
+
const font_by_variant_cjs_namespaceObject = require("../../../utils/font-by-variant.cjs");
|
|
49
50
|
const action_button_cjs_namespaceObject = require("../../common/action-button.cjs");
|
|
50
51
|
const tooltip_cjs_namespaceObject = require("../../common/tooltip.cjs");
|
|
51
52
|
const ChipContent = (0, styles_namespaceObject.styled)('span')(({ theme, readonly })=>({
|
|
52
53
|
display: 'inline-flex',
|
|
53
54
|
alignItems: 'center',
|
|
54
|
-
gap: apollo_core_default().Spacing.SpacingMicro,
|
|
55
55
|
padding: `0 ${apollo_core_default().Padding.PadS}`,
|
|
56
56
|
backgroundColor: theme.palette.semantic.colorPrimaryLighter,
|
|
57
57
|
color: theme.palette.semantic.colorForeground,
|
|
@@ -73,7 +73,8 @@ const ChipLabel = (0, styles_namespaceObject.styled)('span')(()=>({
|
|
|
73
73
|
fontWeight: apollo_core_default().FontFamily.FontWeightSemibold,
|
|
74
74
|
overflow: 'hidden',
|
|
75
75
|
textOverflow: 'ellipsis',
|
|
76
|
-
whiteSpace: 'nowrap'
|
|
76
|
+
whiteSpace: 'nowrap',
|
|
77
|
+
padding: `0 ${apollo_core_default().Padding.PadS}`
|
|
77
78
|
}));
|
|
78
79
|
const ChipDeleteContainer = (0, styles_namespaceObject.styled)('span')(({ visible, compactMode, theme })=>({
|
|
79
80
|
opacity: visible ? 1 : 0,
|
|
@@ -86,7 +87,7 @@ const ChipDeleteContainer = (0, styles_namespaceObject.styled)('span')(({ visibl
|
|
|
86
87
|
backgroundColor: theme.palette.semantic.colorPrimaryLighter,
|
|
87
88
|
borderRadius: `calc(${apollo_core_default().Border.BorderRadiusL} * 2)`,
|
|
88
89
|
transition: 'opacity 0.15s ease-in-out',
|
|
89
|
-
'& .MuiButtonBase-root': {
|
|
90
|
+
'& .MuiButtonBase-root.MuiButtonBase-root': {
|
|
90
91
|
height: compactMode ? apollo_core_default().Spacing.SpacingS : apollo_core_default().Spacing.SpacingM,
|
|
91
92
|
width: compactMode ? apollo_core_default().Spacing.SpacingS : apollo_core_default().Spacing.SpacingM,
|
|
92
93
|
padding: 0,
|
|
@@ -157,8 +158,16 @@ const ResourceChipBase = /*#__PURE__*/ external_react_default().memo(ResourceChi
|
|
|
157
158
|
ResourceChipBase.displayName = 'ResourceChipBase';
|
|
158
159
|
const ResourceChipNodeView = /*#__PURE__*/ external_react_default().memo(({ node, deleteNode })=>{
|
|
159
160
|
const { label, icon } = node.attrs;
|
|
161
|
+
const { spacing } = (0, chat_state_provider_cjs_namespaceObject.useChatState)();
|
|
162
|
+
const lineHeight = (0, font_by_variant_cjs_namespaceObject.fontByVariant)(spacing.primaryFontToken)?.lineHeight ?? apollo_core_namespaceObject.Typography.fontSizeM.lineHeight;
|
|
160
163
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tiptap_react_namespaceObject.NodeViewWrapper, {
|
|
161
164
|
as: "span",
|
|
165
|
+
style: {
|
|
166
|
+
display: 'inline-flex',
|
|
167
|
+
alignItems: 'center',
|
|
168
|
+
height: lineHeight,
|
|
169
|
+
verticalAlign: 'top'
|
|
170
|
+
},
|
|
162
171
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ResourceChipBase, {
|
|
163
172
|
label: label,
|
|
164
173
|
icon: icon,
|
package/dist/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-chip-node-view.d.ts","sourceRoot":"","sources":["../../../../../../../src/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,eAAe,CAAC;AAEpE,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-chip-node-view.d.ts","sourceRoot":"","sources":["../../../../../../../src/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,eAAe,CAAC;AAEpE,OAAO,KAAK,MAAM,OAAO,CAAC;AA4D1B,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAmED,eAAO,MAAM,gBAAgB,mDAAoC,CAAC;AAGlE,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAmBvD,CAAC"}
|
|
@@ -2,16 +2,16 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useLingui } from "@lingui/react";
|
|
3
3
|
import { styled } from "@mui/material/styles";
|
|
4
4
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
5
|
-
import apollo_core from "@uipath/apollo-core";
|
|
5
|
+
import apollo_core, { Typography } from "@uipath/apollo-core";
|
|
6
6
|
import react from "react";
|
|
7
7
|
import { useChatState } from "../../../providers/chat-state-provider.js";
|
|
8
8
|
import { CHAT_RESOURCE_CHIP_MAX_WIDTH } from "../../../service/index.js";
|
|
9
|
+
import { fontByVariant } from "../../../utils/font-by-variant.js";
|
|
9
10
|
import { AutopilotChatActionButton } from "../../common/action-button.js";
|
|
10
11
|
import { AutopilotChatTooltip } from "../../common/tooltip.js";
|
|
11
12
|
const ChipContent = styled('span')(({ theme, readonly })=>({
|
|
12
13
|
display: 'inline-flex',
|
|
13
14
|
alignItems: 'center',
|
|
14
|
-
gap: apollo_core.Spacing.SpacingMicro,
|
|
15
15
|
padding: `0 ${apollo_core.Padding.PadS}`,
|
|
16
16
|
backgroundColor: theme.palette.semantic.colorPrimaryLighter,
|
|
17
17
|
color: theme.palette.semantic.colorForeground,
|
|
@@ -33,7 +33,8 @@ const ChipLabel = styled('span')(()=>({
|
|
|
33
33
|
fontWeight: apollo_core.FontFamily.FontWeightSemibold,
|
|
34
34
|
overflow: 'hidden',
|
|
35
35
|
textOverflow: 'ellipsis',
|
|
36
|
-
whiteSpace: 'nowrap'
|
|
36
|
+
whiteSpace: 'nowrap',
|
|
37
|
+
padding: `0 ${apollo_core.Padding.PadS}`
|
|
37
38
|
}));
|
|
38
39
|
const ChipDeleteContainer = styled('span')(({ visible, compactMode, theme })=>({
|
|
39
40
|
opacity: visible ? 1 : 0,
|
|
@@ -46,7 +47,7 @@ const ChipDeleteContainer = styled('span')(({ visible, compactMode, theme })=>({
|
|
|
46
47
|
backgroundColor: theme.palette.semantic.colorPrimaryLighter,
|
|
47
48
|
borderRadius: `calc(${apollo_core.Border.BorderRadiusL} * 2)`,
|
|
48
49
|
transition: 'opacity 0.15s ease-in-out',
|
|
49
|
-
'& .MuiButtonBase-root': {
|
|
50
|
+
'& .MuiButtonBase-root.MuiButtonBase-root': {
|
|
50
51
|
height: compactMode ? apollo_core.Spacing.SpacingS : apollo_core.Spacing.SpacingM,
|
|
51
52
|
width: compactMode ? apollo_core.Spacing.SpacingS : apollo_core.Spacing.SpacingM,
|
|
52
53
|
padding: 0,
|
|
@@ -117,8 +118,16 @@ const ResourceChipBase = /*#__PURE__*/ react.memo(ResourceChipBaseInner);
|
|
|
117
118
|
ResourceChipBase.displayName = 'ResourceChipBase';
|
|
118
119
|
const ResourceChipNodeView = /*#__PURE__*/ react.memo(({ node, deleteNode })=>{
|
|
119
120
|
const { label, icon } = node.attrs;
|
|
121
|
+
const { spacing } = useChatState();
|
|
122
|
+
const lineHeight = fontByVariant(spacing.primaryFontToken)?.lineHeight ?? Typography.fontSizeM.lineHeight;
|
|
120
123
|
return /*#__PURE__*/ jsx(NodeViewWrapper, {
|
|
121
124
|
as: "span",
|
|
125
|
+
style: {
|
|
126
|
+
display: 'inline-flex',
|
|
127
|
+
alignItems: 'center',
|
|
128
|
+
height: lineHeight,
|
|
129
|
+
verticalAlign: 'top'
|
|
130
|
+
},
|
|
122
131
|
children: /*#__PURE__*/ jsx(ResourceChipBase, {
|
|
123
132
|
label: label,
|
|
124
133
|
icon: icon,
|