@uipath/apollo-react 3.26.1-pr170.dbcf8c9 → 3.26.2-pr202.089892a
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/README.md +2 -0
- package/dist/canvas/icons/CaseManagementProject.cjs +1 -1
- package/dist/canvas/icons/CaseManagementProject.js +1 -1
- package/dist/material/components/ap-chat/components/input/chat-input-editor.cjs +6 -13
- package/dist/material/components/ap-chat/components/input/chat-input-editor.d.ts +1 -0
- 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 +7 -14
- package/dist/material/components/ap-chat/components/input/chat-input-resource-picker.cjs +193 -236
- 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 +195 -238
- package/dist/material/components/ap-chat/components/input/chat-input.cjs +2 -1
- 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 +2 -1
- package/dist/material/components/ap-chat/components/input/tiptap/resource-chip-node-view.cjs +3 -12
- 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 +4 -13
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.cjs +3 -25
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.d.ts +0 -1
- 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 +4 -26
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-editor.styles.cjs +1 -2
- 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 +1 -2
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.cjs +14 -19
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap-resource-suggestion.d.ts +2 -5
- 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 +14 -16
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap.utils.cjs +0 -21
- package/dist/material/components/ap-chat/components/input/tiptap/tiptap.utils.d.ts +0 -5
- 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 +1 -19
- package/dist/material/components/ap-chat/components/message/chat-message.cjs +0 -2
- 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 +0 -2
- package/dist/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.cjs +2 -11
- package/dist/material/components/ap-chat/components/message/markdown/parsers/resource-token-parser.d.ts +0 -1
- 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 +1 -7
- package/dist/material/components/ap-chat/hooks/use-resource-picker-state.cjs +4 -13
- 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 +4 -13
- package/dist/material/components/ap-chat/providers/resource-picker-provider.cjs +19 -54
- package/dist/material/components/ap-chat/providers/resource-picker-provider.d.ts +1 -4
- 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 +20 -55
- package/dist/material/components/ap-chat/service/ChatConstants.cjs +4 -16
- package/dist/material/components/ap-chat/service/ChatConstants.d.ts +1 -4
- package/dist/material/components/ap-chat/service/ChatConstants.d.ts.map +1 -1
- package/dist/material/components/ap-chat/service/ChatConstants.js +2 -5
- package/package.json +1 -2
package/dist/material/components/ap-chat/components/input/chat-input-resource-picker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-input-resource-picker.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/input/chat-input-resource-picker.tsx"],"names":[],"mappings":"AAQA,OAAO,KASN,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-input-resource-picker.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/input/chat-input-resource-picker.tsx"],"names":[],"mappings":"AAQA,OAAO,KASN,MAAM,OAAO,CAAC;AAoIf,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;CAClD;AA0SD,eAAO,MAAM,sBAAsB,wFAAsD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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,11 +7,10 @@ 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";
|
|
11
10
|
import { ApSkeleton } from "../../../ap-skeleton/index.js";
|
|
12
11
|
import { useChatState } from "../../providers/chat-state-provider.js";
|
|
13
12
|
import { isResourceSelector, useAutopilotChatResourcePicker } from "../../providers/resource-picker-provider.js";
|
|
14
|
-
import {
|
|
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, CHAT_RESOURCE_PICKER_SCROLL_THRESHOLD, CHAT_RESOURCE_PICKER_TOOLTIP_ENTER_DELAY } from "../../service/index.js";
|
|
15
14
|
import { AutopilotChatIconButton } from "../common/icon-button.js";
|
|
16
15
|
import { AutopilotChatTooltip } from "../common/tooltip.js";
|
|
17
16
|
const ellipsisStyle = {
|
|
@@ -47,6 +46,12 @@ const EmptyContainer = styled('div')(({ theme })=>({
|
|
|
47
46
|
padding: `${apollo_core.Padding.PadXxl} ${apollo_core.Padding.PadXxxl}`,
|
|
48
47
|
color: theme.palette.semantic.colorForegroundDeEmp
|
|
49
48
|
}));
|
|
49
|
+
const LoadMoreContainer = styled('div')({
|
|
50
|
+
display: 'flex',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
padding: apollo_core.Padding.PadXxl
|
|
54
|
+
});
|
|
50
55
|
const DrillDownHeader = styled('div')(({ theme })=>({
|
|
51
56
|
display: 'flex',
|
|
52
57
|
alignItems: 'center',
|
|
@@ -57,57 +62,17 @@ const DrillDownHeader = styled('div')(({ theme })=>({
|
|
|
57
62
|
const SkeletonItem = styled(StyledMenuItem)({
|
|
58
63
|
pointerEvents: 'none'
|
|
59
64
|
});
|
|
60
|
-
const
|
|
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;
|
|
65
|
+
const chat_input_resource_picker_ResourceMenuItem = /*#__PURE__*/ react.memo(function({ item, isSelected, onItemClick, tooltipPlacement, fontToken }) {
|
|
101
66
|
const isCategory = isResourceSelector(item);
|
|
102
67
|
const tooltipContent = item.tooltip;
|
|
103
|
-
const
|
|
68
|
+
const handleClick = useCallback(()=>onItemClick(item), [
|
|
69
|
+
onItemClick,
|
|
70
|
+
item
|
|
71
|
+
]);
|
|
104
72
|
const menuItem = /*#__PURE__*/ jsxs(StyledMenuItem, {
|
|
105
73
|
id: `resource-item-${item.id}`,
|
|
106
74
|
selected: isSelected,
|
|
107
|
-
onClick:
|
|
108
|
-
onMouseEnter: ()=>onMouseEnterItem(index),
|
|
109
|
-
style: style,
|
|
110
|
-
...ariaAttributes,
|
|
75
|
+
onClick: handleClick,
|
|
111
76
|
children: [
|
|
112
77
|
/*#__PURE__*/ jsxs(ResourceItemContent, {
|
|
113
78
|
children: [
|
|
@@ -138,167 +103,49 @@ const VirtualizedResourceRow = ({ index, style, ariaAttributes, items, selectedI
|
|
|
138
103
|
children: tooltipContent
|
|
139
104
|
}),
|
|
140
105
|
placement: tooltipPlacement,
|
|
141
|
-
open:
|
|
142
|
-
enterDelay:
|
|
143
|
-
enterNextDelay:
|
|
106
|
+
open: isSelected ? true : void 0,
|
|
107
|
+
enterDelay: isSelected ? 0 : CHAT_RESOURCE_PICKER_TOOLTIP_ENTER_DELAY,
|
|
108
|
+
enterNextDelay: isSelected ? 0 : CHAT_RESOURCE_PICKER_TOOLTIP_ENTER_DELAY,
|
|
144
109
|
children: menuItem
|
|
145
110
|
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const {
|
|
111
|
+
});
|
|
112
|
+
function ResourcePickerDropdownInner(_props, ref) {
|
|
113
|
+
const { isOpen, anchorPosition, displayedItems, drillDown, query, loading, loadingMore, searchInProgress, hasMore, error, previousDisplayCount, handleItemClick, close, goBackOrClose, retryLoad, loadMore } = useAutopilotChatResourcePicker();
|
|
149
114
|
const { theming, spacing } = useChatState();
|
|
115
|
+
const listRef = useRef(null);
|
|
116
|
+
const isOpenRef = useRef(isOpen);
|
|
117
|
+
isOpenRef.current = isOpen;
|
|
150
118
|
const { _ } = useLingui();
|
|
151
|
-
const
|
|
152
|
-
const
|
|
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,
|
|
119
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
120
|
+
const scrollStateRef = useRef({
|
|
164
121
|
hasMore,
|
|
165
122
|
loadingMore,
|
|
166
|
-
loadMore
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
]
|
|
123
|
+
loadMore,
|
|
124
|
+
scrollTop: 0,
|
|
125
|
+
container: null
|
|
227
126
|
});
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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');
|
|
127
|
+
scrollStateRef.current.hasMore = hasMore;
|
|
128
|
+
scrollStateRef.current.loadingMore = loadingMore;
|
|
129
|
+
scrollStateRef.current.loadMore = loadMore;
|
|
291
130
|
const prevStateRef = useRef({
|
|
292
131
|
query,
|
|
293
|
-
drillDownId: drillDown?.category?.id
|
|
132
|
+
drillDownId: drillDown?.category?.id,
|
|
133
|
+
selectedIndex,
|
|
134
|
+
loadingMore
|
|
294
135
|
});
|
|
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
|
+
}, []);
|
|
295
145
|
useEffect(()=>{
|
|
296
146
|
const prev = prevStateRef.current;
|
|
297
147
|
const currentDrillDownId = drillDown?.category?.id;
|
|
298
|
-
if (prev.query !== query || prev.drillDownId !== currentDrillDownId)
|
|
299
|
-
setSelectedIndex(0);
|
|
300
|
-
setNavigationMode('none');
|
|
301
|
-
}
|
|
148
|
+
if (prev.query !== query || prev.drillDownId !== currentDrillDownId) setSelectedIndex(0);
|
|
302
149
|
prev.query = query;
|
|
303
150
|
prev.drillDownId = currentDrillDownId;
|
|
304
151
|
}, [
|
|
@@ -306,42 +153,44 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
306
153
|
drillDown
|
|
307
154
|
]);
|
|
308
155
|
useEffect(()=>{
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
156
|
+
const prev = prevStateRef.current;
|
|
157
|
+
if (prev.selectedIndex === selectedIndex) return;
|
|
158
|
+
prev.selectedIndex = selectedIndex;
|
|
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
|
+
});
|
|
312
165
|
}
|
|
313
166
|
}, [
|
|
314
|
-
|
|
167
|
+
selectedIndex,
|
|
168
|
+
displayedItems
|
|
315
169
|
]);
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
170
|
+
useLayoutEffect(()=>{
|
|
171
|
+
const prev = prevStateRef.current;
|
|
172
|
+
const wasLoadingMore = prev.loadingMore;
|
|
173
|
+
prev.loadingMore = loadingMore;
|
|
174
|
+
if (wasLoadingMore && !loadingMore) {
|
|
175
|
+
const { scrollTop, container } = scrollStateRef.current;
|
|
176
|
+
if (container && scrollTop > 0) container.scrollTop = scrollTop;
|
|
177
|
+
}
|
|
321
178
|
}, [
|
|
322
|
-
|
|
323
|
-
navigationMode,
|
|
324
|
-
virtualListRef
|
|
179
|
+
loadingMore
|
|
325
180
|
]);
|
|
326
181
|
const navigateUp = useCallback(()=>{
|
|
327
182
|
setSelectedIndex((prev)=>Math.max(prev - 1, 0));
|
|
328
|
-
setNavigationMode('keyboard');
|
|
329
183
|
}, []);
|
|
330
184
|
const navigateDown = useCallback(()=>{
|
|
331
|
-
setSelectedIndex((prev)=>Math.min(prev + 1,
|
|
332
|
-
setNavigationMode('keyboard');
|
|
185
|
+
setSelectedIndex((prev)=>Math.min(prev + 1, displayedItems.length - 1));
|
|
333
186
|
}, [
|
|
334
|
-
|
|
187
|
+
displayedItems.length
|
|
335
188
|
]);
|
|
336
|
-
const handleMouseEnterItem = useCallback((index)=>{
|
|
337
|
-
setSelectedIndex(index);
|
|
338
|
-
setNavigationMode('pointer');
|
|
339
|
-
}, []);
|
|
340
189
|
const selectItem = useCallback(()=>{
|
|
341
|
-
const selectedItem =
|
|
190
|
+
const selectedItem = displayedItems[selectedIndex];
|
|
342
191
|
if (selectedItem) handleItemClick(selectedItem);
|
|
343
192
|
}, [
|
|
344
|
-
|
|
193
|
+
displayedItems,
|
|
345
194
|
selectedIndex,
|
|
346
195
|
handleItemClick
|
|
347
196
|
]);
|
|
@@ -364,7 +213,7 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
364
213
|
return true;
|
|
365
214
|
case 'Escape':
|
|
366
215
|
event.preventDefault();
|
|
367
|
-
|
|
216
|
+
goBackOrClose();
|
|
368
217
|
return true;
|
|
369
218
|
default:
|
|
370
219
|
return false;
|
|
@@ -374,23 +223,138 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
374
223
|
navigateDown,
|
|
375
224
|
navigateUp,
|
|
376
225
|
selectItem,
|
|
377
|
-
goBackOrClose
|
|
378
|
-
drillDown,
|
|
379
|
-
close
|
|
226
|
+
goBackOrClose
|
|
380
227
|
]);
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
228
|
+
const tooltipPlacement = theming?.chatMenu?.groupItemTooltipPlacement ?? 'left';
|
|
229
|
+
const skeletonElements = useMemo(()=>{
|
|
230
|
+
const skeletonCount = Math.min(Math.max(previousDisplayCount, CHAT_RESOURCE_PICKER_MIN_SKELETON_COUNT), CHAT_RESOURCE_PICKER_MAX_SKELETON_COUNT);
|
|
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");
|
|
384
276
|
}, [
|
|
385
277
|
drillDown,
|
|
386
278
|
goBackOrClose,
|
|
387
|
-
|
|
279
|
+
spacing.primaryBoldFontToken,
|
|
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
|
|
388
352
|
]);
|
|
389
353
|
return /*#__PURE__*/ jsx(Menu, {
|
|
390
354
|
open: isOpen,
|
|
391
355
|
anchorReference: "anchorPosition",
|
|
392
356
|
anchorPosition: anchorPosition ?? void 0,
|
|
393
|
-
onClose:
|
|
357
|
+
onClose: close,
|
|
394
358
|
anchorOrigin: {
|
|
395
359
|
vertical: 'top',
|
|
396
360
|
horizontal: 'left'
|
|
@@ -406,17 +370,10 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
406
370
|
id: 'autopilot-chat.resource-picker.label'
|
|
407
371
|
}),
|
|
408
372
|
dense: true,
|
|
409
|
-
|
|
410
|
-
onMouseDown: preventDefaultMouseDown
|
|
373
|
+
ref: listRef
|
|
411
374
|
},
|
|
412
|
-
slotProps:
|
|
413
|
-
children:
|
|
414
|
-
virtualListRef: virtualListRef,
|
|
415
|
-
selectedIndex: selectedIndex,
|
|
416
|
-
navigationMode: navigationMode,
|
|
417
|
-
onMouseEnterItem: handleMouseEnterItem,
|
|
418
|
-
onItemClick: handleItemClick
|
|
419
|
-
})
|
|
375
|
+
slotProps: menuSlotProps,
|
|
376
|
+
children: menuContent
|
|
420
377
|
});
|
|
421
378
|
}
|
|
422
379
|
const ResourcePickerDropdown = /*#__PURE__*/ react.memo(/*#__PURE__*/ forwardRef(ResourcePickerDropdownInner));
|
|
@@ -245,7 +245,8 @@ function AutopilotChatInputComponent() {
|
|
|
245
245
|
onKeyDown: handleKeyDown,
|
|
246
246
|
minRows: spacing.promptBox.minRows,
|
|
247
247
|
maxRows: spacing.promptBox.maxRows,
|
|
248
|
-
lineHeight: editorLineHeight
|
|
248
|
+
lineHeight: editorLineHeight,
|
|
249
|
+
anchorEl: inputContainerRef.current
|
|
249
250
|
})
|
|
250
251
|
}),
|
|
251
252
|
/*#__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,4CAuNnC;AAED,eAAO,MAAM,kBAAkB,+DAA0C,CAAC"}
|
|
@@ -206,7 +206,8 @@ function AutopilotChatInputComponent() {
|
|
|
206
206
|
onKeyDown: handleKeyDown,
|
|
207
207
|
minRows: spacing.promptBox.minRows,
|
|
208
208
|
maxRows: spacing.promptBox.maxRows,
|
|
209
|
-
lineHeight: editorLineHeight
|
|
209
|
+
lineHeight: editorLineHeight,
|
|
210
|
+
anchorEl: inputContainerRef.current
|
|
210
211
|
})
|
|
211
212
|
}),
|
|
212
213
|
/*#__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");
|
|
50
49
|
const action_button_cjs_namespaceObject = require("../../common/action-button.cjs");
|
|
51
50
|
const tooltip_cjs_namespaceObject = require("../../common/tooltip.cjs");
|
|
52
51
|
const ChipContent = (0, styles_namespaceObject.styled)('span')(({ theme, readonly })=>({
|
|
53
52
|
display: 'inline-flex',
|
|
54
53
|
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,8 +73,7 @@ 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'
|
|
77
|
-
padding: `0 ${apollo_core_default().Padding.PadS}`
|
|
76
|
+
whiteSpace: 'nowrap'
|
|
78
77
|
}));
|
|
79
78
|
const ChipDeleteContainer = (0, styles_namespaceObject.styled)('span')(({ visible, compactMode, theme })=>({
|
|
80
79
|
opacity: visible ? 1 : 0,
|
|
@@ -87,7 +86,7 @@ const ChipDeleteContainer = (0, styles_namespaceObject.styled)('span')(({ visibl
|
|
|
87
86
|
backgroundColor: theme.palette.semantic.colorPrimaryLighter,
|
|
88
87
|
borderRadius: `calc(${apollo_core_default().Border.BorderRadiusL} * 2)`,
|
|
89
88
|
transition: 'opacity 0.15s ease-in-out',
|
|
90
|
-
'& .MuiButtonBase-root
|
|
89
|
+
'& .MuiButtonBase-root': {
|
|
91
90
|
height: compactMode ? apollo_core_default().Spacing.SpacingS : apollo_core_default().Spacing.SpacingM,
|
|
92
91
|
width: compactMode ? apollo_core_default().Spacing.SpacingS : apollo_core_default().Spacing.SpacingM,
|
|
93
92
|
padding: 0,
|
|
@@ -158,16 +157,8 @@ const ResourceChipBase = /*#__PURE__*/ external_react_default().memo(ResourceChi
|
|
|
158
157
|
ResourceChipBase.displayName = 'ResourceChipBase';
|
|
159
158
|
const ResourceChipNodeView = /*#__PURE__*/ external_react_default().memo(({ node, deleteNode })=>{
|
|
160
159
|
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;
|
|
163
160
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tiptap_react_namespaceObject.NodeViewWrapper, {
|
|
164
161
|
as: "span",
|
|
165
|
-
style: {
|
|
166
|
-
display: 'inline-flex',
|
|
167
|
-
alignItems: 'center',
|
|
168
|
-
height: lineHeight,
|
|
169
|
-
verticalAlign: 'top'
|
|
170
|
-
},
|
|
171
162
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ResourceChipBase, {
|
|
172
163
|
label: label,
|
|
173
164
|
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;AA2D1B,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,CAQvD,CAAC"}
|