@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/README.md
CHANGED
|
@@ -68,6 +68,8 @@ pnpm add @uipath/apollo-react
|
|
|
68
68
|
yarn add @uipath/apollo-react
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
**Note:** This package is published to both npm and GitHub Package Registry. External users will automatically pull from npm. Internal UiPath users with `.npmrc` configured will automatically pull from GitHub Package Registry.
|
|
72
|
+
|
|
71
73
|
## Quick Start
|
|
72
74
|
|
|
73
75
|
### Apollo Themes with Standard Material UI
|
|
@@ -33,7 +33,7 @@ const CaseManagementProject = ({ w = 22, h = 22 })=>/*#__PURE__*/ (0, jsx_runtim
|
|
|
33
33
|
width: w,
|
|
34
34
|
height: h,
|
|
35
35
|
fill: "none",
|
|
36
|
-
viewBox: "0 0
|
|
36
|
+
viewBox: "0 0 16 16",
|
|
37
37
|
children: [
|
|
38
38
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("path", {
|
|
39
39
|
fill: "currentColor",
|
|
@@ -44,16 +44,13 @@ const index_cjs_namespaceObject = require("./tiptap/index.cjs");
|
|
|
44
44
|
const chat_input_editor_EditorWithPicker = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)(function(props, ref) {
|
|
45
45
|
const { value, placeholder, minRows, maxRows, lineHeight, onChange, onKeyDown, editorRef } = props;
|
|
46
46
|
const dropdownRef = (0, external_react_namespaceObject.useRef)(null);
|
|
47
|
-
const {
|
|
47
|
+
const { isOpen, drillDown, open, close, setQuery } = (0, resource_picker_provider_cjs_namespaceObject.useAutopilotChatResourcePicker)();
|
|
48
|
+
const isOpenRef = (0, external_react_namespaceObject.useRef)(isOpen);
|
|
48
49
|
const drillDownRef = (0, external_react_namespaceObject.useRef)(drillDown);
|
|
49
50
|
const valueRef = (0, external_react_namespaceObject.useRef)(value);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, [
|
|
54
|
-
drillDown,
|
|
55
|
-
value
|
|
56
|
-
]);
|
|
51
|
+
isOpenRef.current = isOpen;
|
|
52
|
+
drillDownRef.current = drillDown;
|
|
53
|
+
valueRef.current = value;
|
|
57
54
|
const handleChange = (0, external_react_namespaceObject.useCallback)((newValue)=>{
|
|
58
55
|
if (isOpenRef.current && drillDownRef.current && !newValue.includes('@')) close();
|
|
59
56
|
onChange(newValue);
|
|
@@ -93,7 +90,7 @@ const chat_input_editor_EditorWithPicker = /*#__PURE__*/ (0, external_react_name
|
|
|
93
90
|
onChange: handleChange,
|
|
94
91
|
onKeyDown: handleKeyDown,
|
|
95
92
|
onMentionStart: open,
|
|
96
|
-
onMentionEnd:
|
|
93
|
+
onMentionEnd: close,
|
|
97
94
|
onMentionQueryChange: setQuery
|
|
98
95
|
}),
|
|
99
96
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_chat_input_resource_picker_cjs_namespaceObject.ResourcePickerDropdown, {
|
|
@@ -111,13 +108,9 @@ const chat_input_editor_ChatInputEditor = /*#__PURE__*/ external_react_default()
|
|
|
111
108
|
const handleDrillDown = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
112
109
|
editorRef.current?.clearMentionQuery();
|
|
113
110
|
}, []);
|
|
114
|
-
const handleClose = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
115
|
-
editorRef.current?.exitMention();
|
|
116
|
-
}, []);
|
|
117
111
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(resource_picker_provider_cjs_namespaceObject.AutopilotChatResourcePickerProvider, {
|
|
118
112
|
onResourceSelect: handleResourceSelect,
|
|
119
113
|
onDrillDown: handleDrillDown,
|
|
120
|
-
onClose: handleClose,
|
|
121
114
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(chat_input_editor_EditorWithPicker, {
|
|
122
115
|
...props,
|
|
123
116
|
ref: ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-input-editor.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/input/chat-input-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"chat-input-editor.d.ts","sourceRoot":"","sources":["../../../../../../src/material/components/ap-chat/components/input/chat-input-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+D,MAAM,OAAO,CAAC;AAYpF,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,oBAAoB,EAAE,MAAM,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;CAC/C;AAiFD,eAAO,MAAM,eAAe,+FAyB3B,CAAC"}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import react, { forwardRef, useCallback, useImperativeHandle,
|
|
2
|
+
import react, { forwardRef, useCallback, useImperativeHandle, useRef } from "react";
|
|
3
3
|
import { AutopilotChatResourcePickerProvider, useAutopilotChatResourcePicker } from "../../providers/resource-picker-provider.js";
|
|
4
4
|
import { ResourcePickerDropdown } from "./chat-input-resource-picker.js";
|
|
5
5
|
import { TipTapEditor } from "./tiptap/index.js";
|
|
6
6
|
const chat_input_editor_EditorWithPicker = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
7
7
|
const { value, placeholder, minRows, maxRows, lineHeight, onChange, onKeyDown, editorRef } = props;
|
|
8
8
|
const dropdownRef = useRef(null);
|
|
9
|
-
const {
|
|
9
|
+
const { isOpen, drillDown, open, close, setQuery } = useAutopilotChatResourcePicker();
|
|
10
|
+
const isOpenRef = useRef(isOpen);
|
|
10
11
|
const drillDownRef = useRef(drillDown);
|
|
11
12
|
const valueRef = useRef(value);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, [
|
|
16
|
-
drillDown,
|
|
17
|
-
value
|
|
18
|
-
]);
|
|
13
|
+
isOpenRef.current = isOpen;
|
|
14
|
+
drillDownRef.current = drillDown;
|
|
15
|
+
valueRef.current = value;
|
|
19
16
|
const handleChange = useCallback((newValue)=>{
|
|
20
17
|
if (isOpenRef.current && drillDownRef.current && !newValue.includes('@')) close();
|
|
21
18
|
onChange(newValue);
|
|
@@ -55,7 +52,7 @@ const chat_input_editor_EditorWithPicker = /*#__PURE__*/ forwardRef(function(pro
|
|
|
55
52
|
onChange: handleChange,
|
|
56
53
|
onKeyDown: handleKeyDown,
|
|
57
54
|
onMentionStart: open,
|
|
58
|
-
onMentionEnd:
|
|
55
|
+
onMentionEnd: close,
|
|
59
56
|
onMentionQueryChange: setQuery
|
|
60
57
|
}),
|
|
61
58
|
/*#__PURE__*/ jsx(ResourcePickerDropdown, {
|
|
@@ -73,13 +70,9 @@ const chat_input_editor_ChatInputEditor = /*#__PURE__*/ react.memo(/*#__PURE__*/
|
|
|
73
70
|
const handleDrillDown = useCallback(()=>{
|
|
74
71
|
editorRef.current?.clearMentionQuery();
|
|
75
72
|
}, []);
|
|
76
|
-
const handleClose = useCallback(()=>{
|
|
77
|
-
editorRef.current?.exitMention();
|
|
78
|
-
}, []);
|
|
79
73
|
return /*#__PURE__*/ jsx(AutopilotChatResourcePickerProvider, {
|
|
80
74
|
onResourceSelect: handleResourceSelect,
|
|
81
75
|
onDrillDown: handleDrillDown,
|
|
82
|
-
onClose: handleClose,
|
|
83
76
|
children: /*#__PURE__*/ jsx(chat_input_editor_EditorWithPicker, {
|
|
84
77
|
...props,
|
|
85
78
|
ref: ref,
|
|
@@ -49,7 +49,6 @@ var apollo_core_default = /*#__PURE__*/ __webpack_require__.n(apollo_core_namesp
|
|
|
49
49
|
const external_index_cjs_namespaceObject = require("../../../../index.cjs");
|
|
50
50
|
const external_react_namespaceObject = require("react");
|
|
51
51
|
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
52
|
-
const external_react_window_namespaceObject = require("react-window");
|
|
53
52
|
const index_cjs_namespaceObject = require("../../../ap-skeleton/index.cjs");
|
|
54
53
|
const chat_state_provider_cjs_namespaceObject = require("../../providers/chat-state-provider.cjs");
|
|
55
54
|
const resource_picker_provider_cjs_namespaceObject = require("../../providers/resource-picker-provider.cjs");
|
|
@@ -89,6 +88,12 @@ const EmptyContainer = (0, styles_namespaceObject.styled)('div')(({ theme })=>({
|
|
|
89
88
|
padding: `${apollo_core_default().Padding.PadXxl} ${apollo_core_default().Padding.PadXxxl}`,
|
|
90
89
|
color: theme.palette.semantic.colorForegroundDeEmp
|
|
91
90
|
}));
|
|
91
|
+
const LoadMoreContainer = (0, styles_namespaceObject.styled)('div')({
|
|
92
|
+
display: 'flex',
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
justifyContent: 'center',
|
|
95
|
+
padding: apollo_core_default().Padding.PadXxl
|
|
96
|
+
});
|
|
92
97
|
const DrillDownHeader = (0, styles_namespaceObject.styled)('div')(({ theme })=>({
|
|
93
98
|
display: 'flex',
|
|
94
99
|
alignItems: 'center',
|
|
@@ -99,57 +104,17 @@ const DrillDownHeader = (0, styles_namespaceObject.styled)('div')(({ theme })=>(
|
|
|
99
104
|
const SkeletonItem = (0, styles_namespaceObject.styled)(StyledMenuItem)({
|
|
100
105
|
pointerEvents: 'none'
|
|
101
106
|
});
|
|
102
|
-
const
|
|
103
|
-
'&::-webkit-scrollbar': {
|
|
104
|
-
width: '6px'
|
|
105
|
-
},
|
|
106
|
-
'&::-webkit-scrollbar-track': {
|
|
107
|
-
background: 'transparent'
|
|
108
|
-
},
|
|
109
|
-
'&::-webkit-scrollbar-thumb': {
|
|
110
|
-
background: 'var(--color-border-de-emp)',
|
|
111
|
-
borderRadius: '3px'
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
const loaderRowStyle = {
|
|
115
|
-
display: 'flex',
|
|
116
|
-
alignItems: 'center',
|
|
117
|
-
justifyContent: 'center'
|
|
118
|
-
};
|
|
119
|
-
const preventDefaultMouseDown = (e)=>e.preventDefault();
|
|
120
|
-
const MENU_SLOT_PROPS = {
|
|
121
|
-
paper: {
|
|
122
|
-
sx: {
|
|
123
|
-
width: external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_MENU_WIDTH,
|
|
124
|
-
maxHeight: external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_MENU_MAX_HEIGHT,
|
|
125
|
-
overflowY: 'hidden',
|
|
126
|
-
display: 'flex',
|
|
127
|
-
flexDirection: 'column'
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
const VirtualizedResourceRow = ({ index, style, ariaAttributes, items, selectedIndex, navigationMode, handleItemClick, onMouseEnterItem, tooltipPlacement, fontToken })=>{
|
|
132
|
-
if (index >= items.length) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
133
|
-
style: {
|
|
134
|
-
...style,
|
|
135
|
-
...loaderRowStyle
|
|
136
|
-
},
|
|
137
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CircularProgress_default(), {
|
|
138
|
-
size: 20
|
|
139
|
-
})
|
|
140
|
-
});
|
|
141
|
-
const item = items[index];
|
|
142
|
-
const isSelected = index === selectedIndex;
|
|
107
|
+
const chat_input_resource_picker_ResourceMenuItem = /*#__PURE__*/ external_react_default().memo(function({ item, isSelected, onItemClick, tooltipPlacement, fontToken }) {
|
|
143
108
|
const isCategory = (0, resource_picker_provider_cjs_namespaceObject.isResourceSelector)(item);
|
|
144
109
|
const tooltipContent = item.tooltip;
|
|
145
|
-
const
|
|
110
|
+
const handleClick = (0, external_react_namespaceObject.useCallback)(()=>onItemClick(item), [
|
|
111
|
+
onItemClick,
|
|
112
|
+
item
|
|
113
|
+
]);
|
|
146
114
|
const menuItem = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(StyledMenuItem, {
|
|
147
115
|
id: `resource-item-${item.id}`,
|
|
148
116
|
selected: isSelected,
|
|
149
|
-
onClick:
|
|
150
|
-
onMouseEnter: ()=>onMouseEnterItem(index),
|
|
151
|
-
style: style,
|
|
152
|
-
...ariaAttributes,
|
|
117
|
+
onClick: handleClick,
|
|
153
118
|
children: [
|
|
154
119
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(ResourceItemContent, {
|
|
155
120
|
children: [
|
|
@@ -180,167 +145,49 @@ const VirtualizedResourceRow = ({ index, style, ariaAttributes, items, selectedI
|
|
|
180
145
|
children: tooltipContent
|
|
181
146
|
}),
|
|
182
147
|
placement: tooltipPlacement,
|
|
183
|
-
open:
|
|
184
|
-
enterDelay:
|
|
185
|
-
enterNextDelay:
|
|
148
|
+
open: isSelected ? true : void 0,
|
|
149
|
+
enterDelay: isSelected ? 0 : external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_TOOLTIP_ENTER_DELAY,
|
|
150
|
+
enterNextDelay: isSelected ? 0 : external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_TOOLTIP_ENTER_DELAY,
|
|
186
151
|
children: menuItem
|
|
187
152
|
});
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const {
|
|
153
|
+
});
|
|
154
|
+
function ResourcePickerDropdownInner(_props, ref) {
|
|
155
|
+
const { isOpen, anchorPosition, displayedItems, drillDown, query, loading, loadingMore, searchInProgress, hasMore, error, previousDisplayCount, handleItemClick, close, goBackOrClose, retryLoad, loadMore } = (0, resource_picker_provider_cjs_namespaceObject.useAutopilotChatResourcePicker)();
|
|
191
156
|
const { theming, spacing } = (0, chat_state_provider_cjs_namespaceObject.useChatState)();
|
|
157
|
+
const listRef = (0, external_react_namespaceObject.useRef)(null);
|
|
158
|
+
const isOpenRef = (0, external_react_namespaceObject.useRef)(isOpen);
|
|
159
|
+
isOpenRef.current = isOpen;
|
|
192
160
|
const { _ } = (0, react_namespaceObject.useLingui)();
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
196
|
-
if (!drillDown) return void setDrillDownHeaderHeight(0);
|
|
197
|
-
setDrillDownHeaderHeight(drillDownHeaderRef.current?.offsetHeight ?? 0);
|
|
198
|
-
}, [
|
|
199
|
-
drillDown
|
|
200
|
-
]);
|
|
201
|
-
const handleRowsRendered = (0, external_react_namespaceObject.useCallback)((visibleRows, _allRows)=>{
|
|
202
|
-
if (!hasMore || loadingMore) return;
|
|
203
|
-
if (visibleRows.stopIndex >= items.length - external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_LOAD_MORE_THRESHOLD) loadMore();
|
|
204
|
-
}, [
|
|
205
|
-
items.length,
|
|
161
|
+
const [selectedIndex, setSelectedIndex] = (0, external_react_namespaceObject.useState)(0);
|
|
162
|
+
const scrollStateRef = (0, external_react_namespaceObject.useRef)({
|
|
206
163
|
hasMore,
|
|
207
164
|
loadingMore,
|
|
208
|
-
loadMore
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const isLoadingState = loading || searchInProgress;
|
|
212
|
-
const skeletonElements = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
213
|
-
const skeletonCount = Math.min(Math.max(previousDisplayCount, external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_MIN_SKELETON_COUNT), external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_MAX_SKELETON_COUNT);
|
|
214
|
-
return Array.from({
|
|
215
|
-
length: skeletonCount
|
|
216
|
-
}).map((_, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SkeletonItem, {
|
|
217
|
-
disabled: true,
|
|
218
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApSkeleton, {})
|
|
219
|
-
}, `skeleton-${index}`));
|
|
220
|
-
}, [
|
|
221
|
-
previousDisplayCount
|
|
222
|
-
]);
|
|
223
|
-
const rowCount = items.length + (loadingMore ? 1 : 0);
|
|
224
|
-
const listHeight = Math.min(external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_MENU_MAX_HEIGHT - drillDownHeaderHeight, rowCount * external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_ITEM_HEIGHT);
|
|
225
|
-
const rowProps = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
226
|
-
items,
|
|
227
|
-
selectedIndex,
|
|
228
|
-
navigationMode,
|
|
229
|
-
handleItemClick: onItemClick,
|
|
230
|
-
onMouseEnterItem,
|
|
231
|
-
tooltipPlacement,
|
|
232
|
-
fontToken: spacing.primaryFontToken
|
|
233
|
-
}), [
|
|
234
|
-
items,
|
|
235
|
-
selectedIndex,
|
|
236
|
-
navigationMode,
|
|
237
|
-
onItemClick,
|
|
238
|
-
onMouseEnterItem,
|
|
239
|
-
tooltipPlacement,
|
|
240
|
-
spacing.primaryFontToken
|
|
241
|
-
]);
|
|
242
|
-
const drillDownHeader = drillDown ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(DrillDownHeader, {
|
|
243
|
-
ref: drillDownHeaderRef,
|
|
244
|
-
children: [
|
|
245
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_button_cjs_namespaceObject.AutopilotChatIconButton, {
|
|
246
|
-
size: "small",
|
|
247
|
-
onClick: goBackOrClose,
|
|
248
|
-
"aria-label": _({
|
|
249
|
-
id: 'autopilot-chat.resource-picker.back'
|
|
250
|
-
}),
|
|
251
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ApIcon, {
|
|
252
|
-
variant: "outlined",
|
|
253
|
-
name: "arrow_back",
|
|
254
|
-
size: apollo_core_default().Icon.IconXs
|
|
255
|
-
})
|
|
256
|
-
}),
|
|
257
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ApTypography, {
|
|
258
|
-
variant: spacing.primaryBoldFontToken,
|
|
259
|
-
style: ellipsisStyle,
|
|
260
|
-
children: drillDown.category.displayName
|
|
261
|
-
})
|
|
262
|
-
]
|
|
263
|
-
}) : null;
|
|
264
|
-
if (isLoadingState) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
265
|
-
children: [
|
|
266
|
-
drillDownHeader,
|
|
267
|
-
skeletonElements
|
|
268
|
-
]
|
|
269
|
-
});
|
|
270
|
-
if (error) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
271
|
-
children: [
|
|
272
|
-
drillDownHeader,
|
|
273
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(ErrorContainer, {
|
|
274
|
-
children: [
|
|
275
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ApTypography, {
|
|
276
|
-
variant: apollo_core_namespaceObject.FontVariantToken.fontSizeS,
|
|
277
|
-
children: error
|
|
278
|
-
}),
|
|
279
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ApButton, {
|
|
280
|
-
variant: "text",
|
|
281
|
-
size: "small",
|
|
282
|
-
onClick: retryLoad,
|
|
283
|
-
label: _({
|
|
284
|
-
id: 'autopilot-chat.resource-picker.retry'
|
|
285
|
-
})
|
|
286
|
-
})
|
|
287
|
-
]
|
|
288
|
-
})
|
|
289
|
-
]
|
|
290
|
-
});
|
|
291
|
-
if (0 === items.length) {
|
|
292
|
-
const emptyMessage = query.trim() ? _({
|
|
293
|
-
id: 'autopilot-chat.resource-picker.no-results'
|
|
294
|
-
}) : _({
|
|
295
|
-
id: 'autopilot-chat.resource-picker.empty'
|
|
296
|
-
});
|
|
297
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
298
|
-
children: [
|
|
299
|
-
drillDownHeader,
|
|
300
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EmptyContainer, {
|
|
301
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ApTypography, {
|
|
302
|
-
variant: apollo_core_namespaceObject.FontVariantToken.fontSizeS,
|
|
303
|
-
children: emptyMessage
|
|
304
|
-
})
|
|
305
|
-
})
|
|
306
|
-
]
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
310
|
-
children: [
|
|
311
|
-
drillDownHeader,
|
|
312
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(StyledResourceList, {
|
|
313
|
-
listRef: virtualListRef,
|
|
314
|
-
rowProps: rowProps,
|
|
315
|
-
rowComponent: VirtualizedResourceRow,
|
|
316
|
-
rowCount: rowCount,
|
|
317
|
-
rowHeight: external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_ITEM_HEIGHT,
|
|
318
|
-
overscanCount: 5,
|
|
319
|
-
onRowsRendered: handleRowsRendered,
|
|
320
|
-
style: {
|
|
321
|
-
height: listHeight
|
|
322
|
-
}
|
|
323
|
-
})
|
|
324
|
-
]
|
|
165
|
+
loadMore,
|
|
166
|
+
scrollTop: 0,
|
|
167
|
+
container: null
|
|
325
168
|
});
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
const virtualListRef = (0, external_react_window_namespaceObject.useListRef)(null);
|
|
330
|
-
const { _ } = (0, react_namespaceObject.useLingui)();
|
|
331
|
-
const [selectedIndex, setSelectedIndex] = (0, external_react_namespaceObject.useState)(0);
|
|
332
|
-
const [navigationMode, setNavigationMode] = (0, external_react_namespaceObject.useState)('none');
|
|
169
|
+
scrollStateRef.current.hasMore = hasMore;
|
|
170
|
+
scrollStateRef.current.loadingMore = loadingMore;
|
|
171
|
+
scrollStateRef.current.loadMore = loadMore;
|
|
333
172
|
const prevStateRef = (0, external_react_namespaceObject.useRef)({
|
|
334
173
|
query,
|
|
335
|
-
drillDownId: drillDown?.category?.id
|
|
174
|
+
drillDownId: drillDown?.category?.id,
|
|
175
|
+
selectedIndex,
|
|
176
|
+
loadingMore
|
|
336
177
|
});
|
|
178
|
+
const handleScroll = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
179
|
+
const target = event.currentTarget;
|
|
180
|
+
const state = scrollStateRef.current;
|
|
181
|
+
state.scrollTop = target.scrollTop;
|
|
182
|
+
state.container = target;
|
|
183
|
+
if (!state.hasMore || state.loadingMore) return;
|
|
184
|
+
const nearBottom = target.scrollHeight - target.scrollTop - target.clientHeight < external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_SCROLL_THRESHOLD;
|
|
185
|
+
if (nearBottom) state.loadMore();
|
|
186
|
+
}, []);
|
|
337
187
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
338
188
|
const prev = prevStateRef.current;
|
|
339
189
|
const currentDrillDownId = drillDown?.category?.id;
|
|
340
|
-
if (prev.query !== query || prev.drillDownId !== currentDrillDownId)
|
|
341
|
-
setSelectedIndex(0);
|
|
342
|
-
setNavigationMode('none');
|
|
343
|
-
}
|
|
190
|
+
if (prev.query !== query || prev.drillDownId !== currentDrillDownId) setSelectedIndex(0);
|
|
344
191
|
prev.query = query;
|
|
345
192
|
prev.drillDownId = currentDrillDownId;
|
|
346
193
|
}, [
|
|
@@ -348,42 +195,44 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
348
195
|
drillDown
|
|
349
196
|
]);
|
|
350
197
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
198
|
+
const prev = prevStateRef.current;
|
|
199
|
+
if (prev.selectedIndex === selectedIndex) return;
|
|
200
|
+
prev.selectedIndex = selectedIndex;
|
|
201
|
+
const selectedItem = displayedItems[selectedIndex];
|
|
202
|
+
if (listRef.current && selectedItem) {
|
|
203
|
+
const selectedElement = listRef.current.querySelector(`#resource-item-${selectedItem.id}`);
|
|
204
|
+
selectedElement?.scrollIntoView({
|
|
205
|
+
block: 'nearest'
|
|
206
|
+
});
|
|
354
207
|
}
|
|
355
208
|
}, [
|
|
356
|
-
|
|
209
|
+
selectedIndex,
|
|
210
|
+
displayedItems
|
|
357
211
|
]);
|
|
358
|
-
(0, external_react_namespaceObject.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
212
|
+
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
213
|
+
const prev = prevStateRef.current;
|
|
214
|
+
const wasLoadingMore = prev.loadingMore;
|
|
215
|
+
prev.loadingMore = loadingMore;
|
|
216
|
+
if (wasLoadingMore && !loadingMore) {
|
|
217
|
+
const { scrollTop, container } = scrollStateRef.current;
|
|
218
|
+
if (container && scrollTop > 0) container.scrollTop = scrollTop;
|
|
219
|
+
}
|
|
363
220
|
}, [
|
|
364
|
-
|
|
365
|
-
navigationMode,
|
|
366
|
-
virtualListRef
|
|
221
|
+
loadingMore
|
|
367
222
|
]);
|
|
368
223
|
const navigateUp = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
369
224
|
setSelectedIndex((prev)=>Math.max(prev - 1, 0));
|
|
370
|
-
setNavigationMode('keyboard');
|
|
371
225
|
}, []);
|
|
372
226
|
const navigateDown = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
373
|
-
setSelectedIndex((prev)=>Math.min(prev + 1,
|
|
374
|
-
setNavigationMode('keyboard');
|
|
227
|
+
setSelectedIndex((prev)=>Math.min(prev + 1, displayedItems.length - 1));
|
|
375
228
|
}, [
|
|
376
|
-
|
|
229
|
+
displayedItems.length
|
|
377
230
|
]);
|
|
378
|
-
const handleMouseEnterItem = (0, external_react_namespaceObject.useCallback)((index)=>{
|
|
379
|
-
setSelectedIndex(index);
|
|
380
|
-
setNavigationMode('pointer');
|
|
381
|
-
}, []);
|
|
382
231
|
const selectItem = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
383
|
-
const selectedItem =
|
|
232
|
+
const selectedItem = displayedItems[selectedIndex];
|
|
384
233
|
if (selectedItem) handleItemClick(selectedItem);
|
|
385
234
|
}, [
|
|
386
|
-
|
|
235
|
+
displayedItems,
|
|
387
236
|
selectedIndex,
|
|
388
237
|
handleItemClick
|
|
389
238
|
]);
|
|
@@ -406,7 +255,7 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
406
255
|
return true;
|
|
407
256
|
case 'Escape':
|
|
408
257
|
event.preventDefault();
|
|
409
|
-
|
|
258
|
+
goBackOrClose();
|
|
410
259
|
return true;
|
|
411
260
|
default:
|
|
412
261
|
return false;
|
|
@@ -416,23 +265,138 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
416
265
|
navigateDown,
|
|
417
266
|
navigateUp,
|
|
418
267
|
selectItem,
|
|
419
|
-
goBackOrClose
|
|
420
|
-
drillDown,
|
|
421
|
-
close
|
|
268
|
+
goBackOrClose
|
|
422
269
|
]);
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
|
|
270
|
+
const tooltipPlacement = theming?.chatMenu?.groupItemTooltipPlacement ?? 'left';
|
|
271
|
+
const skeletonElements = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
272
|
+
const skeletonCount = Math.min(Math.max(previousDisplayCount, external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_MIN_SKELETON_COUNT), external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_MAX_SKELETON_COUNT);
|
|
273
|
+
return Array.from({
|
|
274
|
+
length: skeletonCount
|
|
275
|
+
}).map((_, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SkeletonItem, {
|
|
276
|
+
disabled: true,
|
|
277
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.ApSkeleton, {})
|
|
278
|
+
}, `skeleton-${index}`));
|
|
279
|
+
}, [
|
|
280
|
+
previousDisplayCount
|
|
281
|
+
]);
|
|
282
|
+
const menuSlotProps = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
283
|
+
paper: {
|
|
284
|
+
sx: {
|
|
285
|
+
width: external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_MENU_WIDTH,
|
|
286
|
+
maxHeight: external_service_index_cjs_namespaceObject.CHAT_RESOURCE_PICKER_MENU_MAX_HEIGHT,
|
|
287
|
+
overflowY: 'auto'
|
|
288
|
+
},
|
|
289
|
+
onScroll: handleScroll
|
|
290
|
+
}
|
|
291
|
+
}), [
|
|
292
|
+
handleScroll
|
|
293
|
+
]);
|
|
294
|
+
const isLoadingState = loading || searchInProgress;
|
|
295
|
+
const drillDownHeader = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
296
|
+
if (!drillDown) return null;
|
|
297
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(DrillDownHeader, {
|
|
298
|
+
children: [
|
|
299
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_button_cjs_namespaceObject.AutopilotChatIconButton, {
|
|
300
|
+
size: "small",
|
|
301
|
+
onClick: goBackOrClose,
|
|
302
|
+
"aria-label": _({
|
|
303
|
+
id: 'autopilot-chat.resource-picker.back'
|
|
304
|
+
}),
|
|
305
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ApIcon, {
|
|
306
|
+
variant: "outlined",
|
|
307
|
+
name: "arrow_back",
|
|
308
|
+
size: apollo_core_default().Icon.IconXs
|
|
309
|
+
})
|
|
310
|
+
}),
|
|
311
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ApTypography, {
|
|
312
|
+
variant: spacing.primaryBoldFontToken,
|
|
313
|
+
style: ellipsisStyle,
|
|
314
|
+
children: drillDown.category.displayName
|
|
315
|
+
})
|
|
316
|
+
]
|
|
317
|
+
}, "drilldown-header");
|
|
426
318
|
}, [
|
|
427
319
|
drillDown,
|
|
428
320
|
goBackOrClose,
|
|
429
|
-
|
|
321
|
+
spacing.primaryBoldFontToken,
|
|
322
|
+
_
|
|
323
|
+
]);
|
|
324
|
+
const menuContent = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
325
|
+
if (isLoadingState) return [
|
|
326
|
+
drillDownHeader,
|
|
327
|
+
...skeletonElements
|
|
328
|
+
];
|
|
329
|
+
if (error) return [
|
|
330
|
+
drillDownHeader,
|
|
331
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(ErrorContainer, {
|
|
332
|
+
children: [
|
|
333
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ApTypography, {
|
|
334
|
+
variant: apollo_core_namespaceObject.FontVariantToken.fontSizeS,
|
|
335
|
+
children: error
|
|
336
|
+
}),
|
|
337
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ApButton, {
|
|
338
|
+
variant: "text",
|
|
339
|
+
size: "small",
|
|
340
|
+
onClick: retryLoad,
|
|
341
|
+
label: "retry",
|
|
342
|
+
children: _({
|
|
343
|
+
id: 'autopilot-chat.resource-picker.retry'
|
|
344
|
+
})
|
|
345
|
+
})
|
|
346
|
+
]
|
|
347
|
+
}, "error")
|
|
348
|
+
];
|
|
349
|
+
if (0 === displayedItems.length) {
|
|
350
|
+
const emptyMessage = query.trim() ? _({
|
|
351
|
+
id: 'autopilot-chat.resource-picker.no-results'
|
|
352
|
+
}) : _({
|
|
353
|
+
id: 'autopilot-chat.resource-picker.empty'
|
|
354
|
+
});
|
|
355
|
+
return [
|
|
356
|
+
drillDownHeader,
|
|
357
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EmptyContainer, {
|
|
358
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ApTypography, {
|
|
359
|
+
variant: apollo_core_namespaceObject.FontVariantToken.fontSizeS,
|
|
360
|
+
children: emptyMessage
|
|
361
|
+
})
|
|
362
|
+
}, "empty")
|
|
363
|
+
];
|
|
364
|
+
}
|
|
365
|
+
return [
|
|
366
|
+
drillDownHeader,
|
|
367
|
+
...displayedItems.map((item, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(chat_input_resource_picker_ResourceMenuItem, {
|
|
368
|
+
item: item,
|
|
369
|
+
isSelected: index === selectedIndex,
|
|
370
|
+
onItemClick: handleItemClick,
|
|
371
|
+
tooltipPlacement: tooltipPlacement,
|
|
372
|
+
fontToken: spacing.primaryFontToken
|
|
373
|
+
}, item.id)),
|
|
374
|
+
loadingMore && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LoadMoreContainer, {
|
|
375
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CircularProgress_default(), {
|
|
376
|
+
size: 20
|
|
377
|
+
})
|
|
378
|
+
}, "loading-more")
|
|
379
|
+
];
|
|
380
|
+
}, [
|
|
381
|
+
isLoadingState,
|
|
382
|
+
drillDownHeader,
|
|
383
|
+
skeletonElements,
|
|
384
|
+
error,
|
|
385
|
+
retryLoad,
|
|
386
|
+
_,
|
|
387
|
+
displayedItems,
|
|
388
|
+
query,
|
|
389
|
+
selectedIndex,
|
|
390
|
+
handleItemClick,
|
|
391
|
+
tooltipPlacement,
|
|
392
|
+
spacing.primaryFontToken,
|
|
393
|
+
loadingMore
|
|
430
394
|
]);
|
|
431
395
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Menu_default(), {
|
|
432
396
|
open: isOpen,
|
|
433
397
|
anchorReference: "anchorPosition",
|
|
434
398
|
anchorPosition: anchorPosition ?? void 0,
|
|
435
|
-
onClose:
|
|
399
|
+
onClose: close,
|
|
436
400
|
anchorOrigin: {
|
|
437
401
|
vertical: 'top',
|
|
438
402
|
horizontal: 'left'
|
|
@@ -448,17 +412,10 @@ function ResourcePickerDropdownInner(_props, ref) {
|
|
|
448
412
|
id: 'autopilot-chat.resource-picker.label'
|
|
449
413
|
}),
|
|
450
414
|
dense: true,
|
|
451
|
-
|
|
452
|
-
onMouseDown: preventDefaultMouseDown
|
|
415
|
+
ref: listRef
|
|
453
416
|
},
|
|
454
|
-
slotProps:
|
|
455
|
-
children:
|
|
456
|
-
virtualListRef: virtualListRef,
|
|
457
|
-
selectedIndex: selectedIndex,
|
|
458
|
-
navigationMode: navigationMode,
|
|
459
|
-
onMouseEnterItem: handleMouseEnterItem,
|
|
460
|
-
onItemClick: handleItemClick
|
|
461
|
-
})
|
|
417
|
+
slotProps: menuSlotProps,
|
|
418
|
+
children: menuContent
|
|
462
419
|
});
|
|
463
420
|
}
|
|
464
421
|
const ResourcePickerDropdown = /*#__PURE__*/ external_react_default().memo(/*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)(ResourcePickerDropdownInner));
|