@uipath/apollo-react 3.54.0-pr354.fe74f94 → 3.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/components/AddNodePanel/AddNodePanel.cjs +8 -21
- package/dist/canvas/components/AddNodePanel/AddNodePanel.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/AddNodePanel.js +8 -11
- package/dist/canvas/components/Toolbox/ListView.cjs +34 -45
- package/dist/canvas/components/Toolbox/ListView.d.ts +2 -7
- package/dist/canvas/components/Toolbox/ListView.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/ListView.js +33 -41
- package/dist/canvas/components/Toolbox/ListView.styles.cjs +1 -7
- package/dist/canvas/components/Toolbox/ListView.styles.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/ListView.styles.js +1 -7
- package/dist/canvas/components/Toolbox/SearchBox.cjs +4 -8
- package/dist/canvas/components/Toolbox/SearchBox.d.ts +0 -2
- package/dist/canvas/components/Toolbox/SearchBox.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/SearchBox.js +4 -8
- package/dist/canvas/components/Toolbox/Toolbox.cjs +2 -135
- package/dist/canvas/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/Toolbox.js +3 -136
- package/package.json +6 -6
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
3
|
(()=>{
|
|
13
4
|
__webpack_require__.d = (exports1, definition)=>{
|
|
14
5
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -37,8 +28,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
37
28
|
});
|
|
38
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
39
30
|
const external_react_namespaceObject = require("react");
|
|
40
|
-
const external_react_focus_lock_namespaceObject = require("react-focus-lock");
|
|
41
|
-
var external_react_focus_lock_default = /*#__PURE__*/ __webpack_require__.n(external_react_focus_lock_namespaceObject);
|
|
42
31
|
const index_cjs_namespaceObject = require("../../core/index.cjs");
|
|
43
32
|
const external_hooks_index_cjs_namespaceObject = require("../../hooks/index.cjs");
|
|
44
33
|
const external_Toolbox_index_cjs_namespaceObject = require("../Toolbox/index.cjs");
|
|
@@ -79,16 +68,14 @@ const AddNodePanel_AddNodePanel = /*#__PURE__*/ (0, external_react_namespaceObje
|
|
|
79
68
|
}, [
|
|
80
69
|
onNodeSelect
|
|
81
70
|
]);
|
|
82
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
onItemHover: onNodeHover
|
|
91
|
-
})
|
|
71
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Toolbox_index_cjs_namespaceObject.Toolbox, {
|
|
72
|
+
title: title ?? 'Add Node',
|
|
73
|
+
initialItems: nodeListOptions,
|
|
74
|
+
loading: loading,
|
|
75
|
+
onItemSelect: handleNodeListItemSelect,
|
|
76
|
+
onSearch: handleSearch,
|
|
77
|
+
onClose: onClose,
|
|
78
|
+
onItemHover: onNodeHover
|
|
92
79
|
});
|
|
93
80
|
});
|
|
94
81
|
exports.AddNodePanel = __webpack_exports__.AddNodePanel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNodePanel.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/AddNodePanel/AddNodePanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AddNodePanel.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/AddNodePanel/AddNodePanel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAU9D,eAAO,MAAM,YAAY,yDA2EvB,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useCallback, useMemo } from "react";
|
|
3
|
-
import react_focus_lock from "react-focus-lock";
|
|
4
3
|
import { useOptionalNodeTypeRegistry } from "../../core/index.js";
|
|
5
4
|
import { usePreviewNode } from "../../hooks/index.js";
|
|
6
5
|
import { Toolbox } from "../Toolbox/index.js";
|
|
@@ -41,16 +40,14 @@ const AddNodePanel_AddNodePanel = /*#__PURE__*/ memo(function({ onNodeSelect, on
|
|
|
41
40
|
}, [
|
|
42
41
|
onNodeSelect
|
|
43
42
|
]);
|
|
44
|
-
return /*#__PURE__*/ jsx(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
onItemHover: onNodeHover
|
|
53
|
-
})
|
|
43
|
+
return /*#__PURE__*/ jsx(Toolbox, {
|
|
44
|
+
title: title ?? 'Add Node',
|
|
45
|
+
initialItems: nodeListOptions,
|
|
46
|
+
loading: loading,
|
|
47
|
+
onItemSelect: handleNodeListItemSelect,
|
|
48
|
+
onSearch: handleSearch,
|
|
49
|
+
onClose: onClose,
|
|
50
|
+
onItemHover: onNodeHover
|
|
54
51
|
});
|
|
55
52
|
});
|
|
56
53
|
export { AddNodePanel_AddNodePanel as AddNodePanel };
|
|
@@ -24,8 +24,7 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
ListView: ()=>ListView_ListView
|
|
28
|
-
buildRenderedItems: ()=>buildRenderedItems
|
|
27
|
+
ListView: ()=>ListView_ListView
|
|
29
28
|
});
|
|
30
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
30
|
const apollo_core_namespaceObject = require("@uipath/apollo-core");
|
|
@@ -36,37 +35,8 @@ const components_index_cjs_namespaceObject = require("../../../material/componen
|
|
|
36
35
|
const external_react_namespaceObject = require("react");
|
|
37
36
|
const CanvasThemeContext_cjs_namespaceObject = require("../BaseCanvas/CanvasThemeContext.cjs");
|
|
38
37
|
const external_ListView_styles_cjs_namespaceObject = require("./ListView.styles.cjs");
|
|
39
|
-
function buildRenderedItems(items, enableSections) {
|
|
40
|
-
const result = [];
|
|
41
|
-
if (0 === items.length) return result;
|
|
42
|
-
if (!enableSections) {
|
|
43
|
-
for (const item of items)result.push({
|
|
44
|
-
type: 'item',
|
|
45
|
-
item
|
|
46
|
-
});
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
const [itemsWithSection, itemsWithoutSection] = (0, external_utils_index_cjs_namespaceObject.partition)(items, (item)=>!!item.section);
|
|
50
|
-
for (const item of itemsWithoutSection)result.push({
|
|
51
|
-
type: 'item',
|
|
52
|
-
item
|
|
53
|
-
});
|
|
54
|
-
if (0 === itemsWithSection.length) return result;
|
|
55
|
-
const sections = Array.from(new Set(itemsWithSection.map((item)=>item.section)));
|
|
56
|
-
for (const section of sections){
|
|
57
|
-
result.push({
|
|
58
|
-
type: 'section',
|
|
59
|
-
sectionName: section
|
|
60
|
-
});
|
|
61
|
-
for (const item of itemsWithSection.filter((item)=>item.section === section))result.push({
|
|
62
|
-
type: 'item',
|
|
63
|
-
item
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
38
|
const IconContainerMemoized = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(external_ListView_styles_cjs_namespaceObject.IconContainer);
|
|
69
|
-
const ListViewRow = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ index, style, ariaAttributes, renderedItems,
|
|
39
|
+
const ListViewRow = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ index, style, ariaAttributes, renderedItems, isLoading, isDarkMode, onItemClick, onItemHover })=>{
|
|
70
40
|
const renderItem = renderedItems[index];
|
|
71
41
|
const buttonStyle = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
72
42
|
...style,
|
|
@@ -104,16 +74,12 @@ const ListViewRow = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ in
|
|
|
104
74
|
});
|
|
105
75
|
const item = renderItem.item;
|
|
106
76
|
const bgColor = isDarkMode ? item.colorDark ?? item.color : item.color;
|
|
107
|
-
const isActive = index === activeIndex;
|
|
108
77
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_ListView_styles_cjs_namespaceObject.ListItemButton, {
|
|
109
78
|
...ariaAttributes,
|
|
110
|
-
id: `toolbox-item-${item.id}`,
|
|
111
|
-
role: "option",
|
|
112
|
-
"aria-selected": isActive,
|
|
113
79
|
style: buttonStyle,
|
|
114
80
|
onClick: handleButtonClick,
|
|
115
81
|
onHoverStart: handleButtonHover,
|
|
116
|
-
className:
|
|
82
|
+
className: isLoading ? 'loading' : '',
|
|
117
83
|
disabled: isLoading,
|
|
118
84
|
children: [
|
|
119
85
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(IconContainerMemoized, {
|
|
@@ -168,22 +134,48 @@ const ListViewRow = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ in
|
|
|
168
134
|
]
|
|
169
135
|
});
|
|
170
136
|
});
|
|
171
|
-
const ListView_ListView = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(function({ items,
|
|
137
|
+
const ListView_ListView = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(function({ items, onItemClick, onItemHover, emptyStateMessage = 'No items found', emptyStateIcon = 'search_off', isLoading = false, enableSections = true }) {
|
|
172
138
|
const { isDarkMode } = (0, CanvasThemeContext_cjs_namespaceObject.useCanvasTheme)();
|
|
173
|
-
const renderedItems = (0, external_react_namespaceObject.useMemo)(()=>
|
|
139
|
+
const renderedItems = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
140
|
+
const result = [];
|
|
141
|
+
if (0 === items.length) return result;
|
|
142
|
+
if (!enableSections) {
|
|
143
|
+
for (const item of items)result.push({
|
|
144
|
+
type: 'item',
|
|
145
|
+
item
|
|
146
|
+
});
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
const [itemsWithSection, itemsWithoutSection] = (0, external_utils_index_cjs_namespaceObject.partition)(items, (item)=>!!item.section);
|
|
150
|
+
for (const item of itemsWithoutSection)result.push({
|
|
151
|
+
type: 'item',
|
|
152
|
+
item
|
|
153
|
+
});
|
|
154
|
+
if (0 === itemsWithSection.length) return result;
|
|
155
|
+
const sections = Array.from(new Set(itemsWithSection.map((item)=>item.section)));
|
|
156
|
+
for (const section of sections){
|
|
157
|
+
result.push({
|
|
158
|
+
type: 'section',
|
|
159
|
+
sectionName: section
|
|
160
|
+
});
|
|
161
|
+
for (const item of itemsWithSection.filter((item)=>item.section === section))result.push({
|
|
162
|
+
type: 'item',
|
|
163
|
+
item
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return result;
|
|
167
|
+
}, [
|
|
174
168
|
items,
|
|
175
169
|
enableSections
|
|
176
170
|
]);
|
|
177
171
|
const rowProps = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
178
172
|
renderedItems,
|
|
179
|
-
activeIndex,
|
|
180
173
|
isLoading,
|
|
181
174
|
isDarkMode,
|
|
182
175
|
onItemClick,
|
|
183
176
|
onItemHover
|
|
184
177
|
}), [
|
|
185
178
|
renderedItems,
|
|
186
|
-
activeIndex,
|
|
187
179
|
isLoading,
|
|
188
180
|
isDarkMode,
|
|
189
181
|
onItemClick,
|
|
@@ -223,7 +215,6 @@ const ListView_ListView = /*#__PURE__*/ (0, external_react_namespaceObject.memo)
|
|
|
223
215
|
]
|
|
224
216
|
});
|
|
225
217
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ListView_styles_cjs_namespaceObject.StyledList, {
|
|
226
|
-
listRef: listRef,
|
|
227
218
|
rowProps: rowProps,
|
|
228
219
|
rowComponent: ListViewRow,
|
|
229
220
|
rowCount: renderedItems.length,
|
|
@@ -232,10 +223,8 @@ const ListView_ListView = /*#__PURE__*/ (0, external_react_namespaceObject.memo)
|
|
|
232
223
|
});
|
|
233
224
|
});
|
|
234
225
|
exports.ListView = __webpack_exports__.ListView;
|
|
235
|
-
exports.buildRenderedItems = __webpack_exports__.buildRenderedItems;
|
|
236
226
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
237
|
-
"ListView"
|
|
238
|
-
"buildRenderedItems"
|
|
227
|
+
"ListView"
|
|
239
228
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
240
229
|
Object.defineProperty(exports, '__esModule', {
|
|
241
230
|
value: true
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ListImperativeAPI } from 'react-window';
|
|
2
1
|
export interface ListItemIcon {
|
|
3
2
|
name?: string;
|
|
4
3
|
url?: string;
|
|
@@ -15,17 +14,15 @@ export type ListItem<T = any> = {
|
|
|
15
14
|
colorDark?: string;
|
|
16
15
|
children?: ListItem<T>[] | ((id: string, name: string) => Promise<ListItem<T>[]>);
|
|
17
16
|
};
|
|
18
|
-
|
|
17
|
+
type RenderItem<T extends ListItem> = {
|
|
19
18
|
type: 'section';
|
|
20
19
|
sectionName: string;
|
|
21
20
|
} | {
|
|
22
21
|
type: 'item';
|
|
23
22
|
item: T;
|
|
24
23
|
};
|
|
25
|
-
export declare function buildRenderedItems<T extends ListItem>(items: T[], enableSections: boolean): RenderItem<T>[];
|
|
26
24
|
export interface ListViewRowProps<T extends ListItem> {
|
|
27
25
|
renderedItems: RenderItem<T>[];
|
|
28
|
-
activeIndex: number;
|
|
29
26
|
isLoading?: boolean;
|
|
30
27
|
isDarkMode?: boolean;
|
|
31
28
|
onItemClick: (item: T) => void;
|
|
@@ -33,8 +30,6 @@ export interface ListViewRowProps<T extends ListItem> {
|
|
|
33
30
|
}
|
|
34
31
|
interface ListViewProps<T extends ListItem> {
|
|
35
32
|
items: T[];
|
|
36
|
-
activeIndex?: number;
|
|
37
|
-
listRef?: React.RefObject<ListImperativeAPI | null>;
|
|
38
33
|
onItemClick: (item: T) => void;
|
|
39
34
|
onItemHover?: (item: T) => void;
|
|
40
35
|
emptyStateMessage?: string;
|
|
@@ -42,6 +37,6 @@ interface ListViewProps<T extends ListItem> {
|
|
|
42
37
|
isLoading?: boolean;
|
|
43
38
|
enableSections?: boolean;
|
|
44
39
|
}
|
|
45
|
-
export declare const ListView: import("react").MemoExoticComponent<(<T extends ListItem>({ items,
|
|
40
|
+
export declare const ListView: import("react").MemoExoticComponent<(<T extends ListItem>({ items, onItemClick, onItemHover, emptyStateMessage, emptyStateIcon, isLoading, enableSections, }: ListViewProps<T>) => import("react/jsx-runtime").JSX.Element)>;
|
|
46
41
|
export {};
|
|
47
42
|
//# sourceMappingURL=ListView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/ListView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/ListView.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,YAAY;IAI3B,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,GAAG,CAAC,EAAE,MAAM,CAAC;IAIb,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACjC;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,GAAG,IAAI;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACnF,CAAC;AAEF,KAAK,UAAU,CAAC,CAAC,SAAS,QAAQ,IAC9B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC;AAE9B,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,QAAQ;IAClD,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;CACjC;AAyGD,UAAU,aAAa,CAAC,CAAC,SAAS,QAAQ;IACxC,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,QAAQ,wCAA0B,CAAC,SAAS,QAAQ,sGAQ9D,aAAa,CAAC,CAAC,CAAC,8CAkFjB,CAAC"}
|
|
@@ -7,37 +7,8 @@ import { ApIcon, ApTooltip } from "../../../material/components/index.js";
|
|
|
7
7
|
import { memo, useCallback, useMemo } from "react";
|
|
8
8
|
import { useCanvasTheme } from "../BaseCanvas/CanvasThemeContext.js";
|
|
9
9
|
import { IconContainer, ListItemButton, SectionHeader, StyledList } from "./ListView.styles.js";
|
|
10
|
-
function buildRenderedItems(items, enableSections) {
|
|
11
|
-
const result = [];
|
|
12
|
-
if (0 === items.length) return result;
|
|
13
|
-
if (!enableSections) {
|
|
14
|
-
for (const item of items)result.push({
|
|
15
|
-
type: 'item',
|
|
16
|
-
item
|
|
17
|
-
});
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
const [itemsWithSection, itemsWithoutSection] = partition(items, (item)=>!!item.section);
|
|
21
|
-
for (const item of itemsWithoutSection)result.push({
|
|
22
|
-
type: 'item',
|
|
23
|
-
item
|
|
24
|
-
});
|
|
25
|
-
if (0 === itemsWithSection.length) return result;
|
|
26
|
-
const sections = Array.from(new Set(itemsWithSection.map((item)=>item.section)));
|
|
27
|
-
for (const section of sections){
|
|
28
|
-
result.push({
|
|
29
|
-
type: 'section',
|
|
30
|
-
sectionName: section
|
|
31
|
-
});
|
|
32
|
-
for (const item of itemsWithSection.filter((item)=>item.section === section))result.push({
|
|
33
|
-
type: 'item',
|
|
34
|
-
item
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
10
|
const IconContainerMemoized = /*#__PURE__*/ memo(IconContainer);
|
|
40
|
-
const ListViewRow = /*#__PURE__*/ memo(({ index, style, ariaAttributes, renderedItems,
|
|
11
|
+
const ListViewRow = /*#__PURE__*/ memo(({ index, style, ariaAttributes, renderedItems, isLoading, isDarkMode, onItemClick, onItemHover })=>{
|
|
41
12
|
const renderItem = renderedItems[index];
|
|
42
13
|
const buttonStyle = useMemo(()=>({
|
|
43
14
|
...style,
|
|
@@ -75,16 +46,12 @@ const ListViewRow = /*#__PURE__*/ memo(({ index, style, ariaAttributes, rendered
|
|
|
75
46
|
});
|
|
76
47
|
const item = renderItem.item;
|
|
77
48
|
const bgColor = isDarkMode ? item.colorDark ?? item.color : item.color;
|
|
78
|
-
const isActive = index === activeIndex;
|
|
79
49
|
return /*#__PURE__*/ jsxs(ListItemButton, {
|
|
80
50
|
...ariaAttributes,
|
|
81
|
-
id: `toolbox-item-${item.id}`,
|
|
82
|
-
role: "option",
|
|
83
|
-
"aria-selected": isActive,
|
|
84
51
|
style: buttonStyle,
|
|
85
52
|
onClick: handleButtonClick,
|
|
86
53
|
onHoverStart: handleButtonHover,
|
|
87
|
-
className:
|
|
54
|
+
className: isLoading ? 'loading' : '',
|
|
88
55
|
disabled: isLoading,
|
|
89
56
|
children: [
|
|
90
57
|
/*#__PURE__*/ jsxs(IconContainerMemoized, {
|
|
@@ -139,22 +106,48 @@ const ListViewRow = /*#__PURE__*/ memo(({ index, style, ariaAttributes, rendered
|
|
|
139
106
|
]
|
|
140
107
|
});
|
|
141
108
|
});
|
|
142
|
-
const ListView_ListView = /*#__PURE__*/ memo(function({ items,
|
|
109
|
+
const ListView_ListView = /*#__PURE__*/ memo(function({ items, onItemClick, onItemHover, emptyStateMessage = 'No items found', emptyStateIcon = 'search_off', isLoading = false, enableSections = true }) {
|
|
143
110
|
const { isDarkMode } = useCanvasTheme();
|
|
144
|
-
const renderedItems = useMemo(()=>
|
|
111
|
+
const renderedItems = useMemo(()=>{
|
|
112
|
+
const result = [];
|
|
113
|
+
if (0 === items.length) return result;
|
|
114
|
+
if (!enableSections) {
|
|
115
|
+
for (const item of items)result.push({
|
|
116
|
+
type: 'item',
|
|
117
|
+
item
|
|
118
|
+
});
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
const [itemsWithSection, itemsWithoutSection] = partition(items, (item)=>!!item.section);
|
|
122
|
+
for (const item of itemsWithoutSection)result.push({
|
|
123
|
+
type: 'item',
|
|
124
|
+
item
|
|
125
|
+
});
|
|
126
|
+
if (0 === itemsWithSection.length) return result;
|
|
127
|
+
const sections = Array.from(new Set(itemsWithSection.map((item)=>item.section)));
|
|
128
|
+
for (const section of sections){
|
|
129
|
+
result.push({
|
|
130
|
+
type: 'section',
|
|
131
|
+
sectionName: section
|
|
132
|
+
});
|
|
133
|
+
for (const item of itemsWithSection.filter((item)=>item.section === section))result.push({
|
|
134
|
+
type: 'item',
|
|
135
|
+
item
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}, [
|
|
145
140
|
items,
|
|
146
141
|
enableSections
|
|
147
142
|
]);
|
|
148
143
|
const rowProps = useMemo(()=>({
|
|
149
144
|
renderedItems,
|
|
150
|
-
activeIndex,
|
|
151
145
|
isLoading,
|
|
152
146
|
isDarkMode,
|
|
153
147
|
onItemClick,
|
|
154
148
|
onItemHover
|
|
155
149
|
}), [
|
|
156
150
|
renderedItems,
|
|
157
|
-
activeIndex,
|
|
158
151
|
isLoading,
|
|
159
152
|
isDarkMode,
|
|
160
153
|
onItemClick,
|
|
@@ -194,7 +187,6 @@ const ListView_ListView = /*#__PURE__*/ memo(function({ items, activeIndex = -1,
|
|
|
194
187
|
]
|
|
195
188
|
});
|
|
196
189
|
return /*#__PURE__*/ jsx(StyledList, {
|
|
197
|
-
listRef: listRef,
|
|
198
190
|
rowProps: rowProps,
|
|
199
191
|
rowComponent: ListViewRow,
|
|
200
192
|
rowCount: renderedItems.length,
|
|
@@ -202,4 +194,4 @@ const ListView_ListView = /*#__PURE__*/ memo(function({ items, activeIndex = -1,
|
|
|
202
194
|
overscanCount: 20
|
|
203
195
|
});
|
|
204
196
|
});
|
|
205
|
-
export { ListView_ListView as ListView
|
|
197
|
+
export { ListView_ListView as ListView };
|
|
@@ -68,15 +68,9 @@ const ListItemButton = styled_default()(react_namespaceObject.motion.button)`
|
|
|
68
68
|
width: 100%;
|
|
69
69
|
transition: all 0.15s ease;
|
|
70
70
|
|
|
71
|
-
&:hover
|
|
72
|
-
&.active {
|
|
71
|
+
&:hover {
|
|
73
72
|
background: var(--uix-canvas-background-hover);
|
|
74
73
|
}
|
|
75
|
-
|
|
76
|
-
&.active {
|
|
77
|
-
outline: 1px solid var(--uix-canvas-border);
|
|
78
|
-
outline-offset: -1px;
|
|
79
|
-
}
|
|
80
74
|
`;
|
|
81
75
|
const IconContainer = styled_default().div`
|
|
82
76
|
width: 32px;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.styles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/ListView.styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,eAAO,MAAM,aAAa;;;yGAazB,CAAC;AAEF,eAAO,MAAM,cAAc;;
|
|
1
|
+
{"version":3,"file":"ListView.styles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/ListView.styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,eAAO,MAAM,aAAa;;;yGAazB,CAAC;AAEF,eAAO,MAAM,cAAc;;UAe1B,CAAC;AAEF,eAAO,MAAM,aAAa;;;;cAA0B,MAAM;yGAazD,CAAC;AAEF,eAAO,MAAM,UAAU,EAkClB,OAAO,IAAI,CAAC"}
|
|
@@ -27,15 +27,9 @@ const ListItemButton = styled(motion.button)`
|
|
|
27
27
|
width: 100%;
|
|
28
28
|
transition: all 0.15s ease;
|
|
29
29
|
|
|
30
|
-
&:hover
|
|
31
|
-
&.active {
|
|
30
|
+
&:hover {
|
|
32
31
|
background: var(--uix-canvas-background-hover);
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
&.active {
|
|
36
|
-
outline: 1px solid var(--uix-canvas-border);
|
|
37
|
-
outline-offset: -1px;
|
|
38
|
-
}
|
|
39
33
|
`;
|
|
40
34
|
const IconContainer = styled.div`
|
|
41
35
|
width: 32px;
|
|
@@ -31,14 +31,11 @@ const index_cjs_namespaceObject = require("../../utils/index.cjs");
|
|
|
31
31
|
const components_index_cjs_namespaceObject = require("../../../material/components/index.cjs");
|
|
32
32
|
const external_react_namespaceObject = require("react");
|
|
33
33
|
const external_SearchBox_styles_cjs_namespaceObject = require("./SearchBox.styles.cjs");
|
|
34
|
-
const SearchBox_SearchBox = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(function({ value, onChange, clear, placeholder = 'Search...'
|
|
35
|
-
const
|
|
36
|
-
const inputRef = externalInputRef ?? internalRef;
|
|
34
|
+
const SearchBox_SearchBox = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(function({ value, onChange, clear, placeholder = 'Search...' }) {
|
|
35
|
+
const inputRef = (0, external_react_namespaceObject.useRef)(null);
|
|
37
36
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
38
37
|
inputRef.current?.focus();
|
|
39
|
-
}, [
|
|
40
|
-
inputRef
|
|
41
|
-
]);
|
|
38
|
+
}, []);
|
|
42
39
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_SearchBox_styles_cjs_namespaceObject.StyledSearchForm, {
|
|
43
40
|
autoComplete: "off",
|
|
44
41
|
className: "searchbox-form",
|
|
@@ -62,8 +59,7 @@ const SearchBox_SearchBox = /*#__PURE__*/ (0, external_react_namespaceObject.mem
|
|
|
62
59
|
className: "searchbox-input",
|
|
63
60
|
placeholder: placeholder,
|
|
64
61
|
value: value,
|
|
65
|
-
onChange: (e)=>onChange(e.target.value)
|
|
66
|
-
onKeyDown: onNavigationKeyDown
|
|
62
|
+
onChange: (e)=>onChange(e.target.value)
|
|
67
63
|
}),
|
|
68
64
|
value && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
69
65
|
type: "button",
|
|
@@ -3,8 +3,6 @@ interface SearchBoxProps {
|
|
|
3
3
|
onChange: (value: string) => void;
|
|
4
4
|
clear: () => void;
|
|
5
5
|
placeholder?: string;
|
|
6
|
-
inputRef?: React.RefObject<HTMLInputElement | null>;
|
|
7
|
-
onNavigationKeyDown?: (e: React.KeyboardEvent) => void;
|
|
8
6
|
}
|
|
9
7
|
export declare const SearchBox: import("react").NamedExoticComponent<SearchBoxProps>;
|
|
10
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchBox.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/SearchBox.tsx"],"names":[],"mappings":"AAKA,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchBox.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/SearchBox.tsx"],"names":[],"mappings":"AAKA,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,SAAS,sDAuCpB,CAAC"}
|
|
@@ -3,14 +3,11 @@ import { cx } from "../../utils/index.js";
|
|
|
3
3
|
import { ApIcon } from "../../../material/components/index.js";
|
|
4
4
|
import { memo, useEffect, useRef } from "react";
|
|
5
5
|
import { StyledSearchForm } from "./SearchBox.styles.js";
|
|
6
|
-
const SearchBox_SearchBox = /*#__PURE__*/ memo(function({ value, onChange, clear, placeholder = 'Search...'
|
|
7
|
-
const
|
|
8
|
-
const inputRef = externalInputRef ?? internalRef;
|
|
6
|
+
const SearchBox_SearchBox = /*#__PURE__*/ memo(function({ value, onChange, clear, placeholder = 'Search...' }) {
|
|
7
|
+
const inputRef = useRef(null);
|
|
9
8
|
useEffect(()=>{
|
|
10
9
|
inputRef.current?.focus();
|
|
11
|
-
}, [
|
|
12
|
-
inputRef
|
|
13
|
-
]);
|
|
10
|
+
}, []);
|
|
14
11
|
return /*#__PURE__*/ jsx(StyledSearchForm, {
|
|
15
12
|
autoComplete: "off",
|
|
16
13
|
className: "searchbox-form",
|
|
@@ -34,8 +31,7 @@ const SearchBox_SearchBox = /*#__PURE__*/ memo(function({ value, onChange, clear
|
|
|
34
31
|
className: "searchbox-input",
|
|
35
32
|
placeholder: placeholder,
|
|
36
33
|
value: value,
|
|
37
|
-
onChange: (e)=>onChange(e.target.value)
|
|
38
|
-
onKeyDown: onNavigationKeyDown
|
|
34
|
+
onChange: (e)=>onChange(e.target.value)
|
|
39
35
|
}),
|
|
40
36
|
value && /*#__PURE__*/ jsx("button", {
|
|
41
37
|
type: "button",
|
|
@@ -30,7 +30,6 @@ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
|
30
30
|
const index_cjs_namespaceObject = require("../../hooks/index.cjs");
|
|
31
31
|
const external_layouts_index_cjs_namespaceObject = require("../../layouts/index.cjs");
|
|
32
32
|
const external_react_namespaceObject = require("react");
|
|
33
|
-
const external_react_window_namespaceObject = require("react-window");
|
|
34
33
|
const external_Header_cjs_namespaceObject = require("./Header.cjs");
|
|
35
34
|
const external_ListView_cjs_namespaceObject = require("./ListView.cjs");
|
|
36
35
|
const external_SearchBox_cjs_namespaceObject = require("./SearchBox.cjs");
|
|
@@ -72,48 +71,13 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
72
71
|
const [isTransitioning, setIsTransitioning] = (0, external_react_namespaceObject.useState)(false);
|
|
73
72
|
const [animationDirection, setAnimationDirection] = (0, external_react_namespaceObject.useState)('forward');
|
|
74
73
|
const navigationStack = (0, index_cjs_namespaceObject.useNavigationStack)();
|
|
75
|
-
const [activeIndex, setActiveIndex] = (0, external_react_namespaceObject.useState)(-1);
|
|
76
74
|
const containerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
77
75
|
const transitionTimeoutRef = (0, external_react_namespaceObject.useRef)(void 0);
|
|
78
76
|
const searchIdRef = (0, external_react_namespaceObject.useRef)(0);
|
|
79
77
|
const initialItemsRef = (0, external_react_namespaceObject.useRef)(initialItems);
|
|
80
|
-
const listRef = (0, external_react_window_namespaceObject.useListRef)(null);
|
|
81
|
-
const searchInputRef = (0, external_react_namespaceObject.useRef)(null);
|
|
82
78
|
const isSearching = (0, external_react_namespaceObject.useMemo)(()=>search.length > 0, [
|
|
83
79
|
search
|
|
84
80
|
]);
|
|
85
|
-
const displayedItems = (0, external_react_namespaceObject.useMemo)(()=>isSearching && !isSearchingInitialItems ? searchedItems : items, [
|
|
86
|
-
isSearching,
|
|
87
|
-
isSearchingInitialItems,
|
|
88
|
-
searchedItems,
|
|
89
|
-
items
|
|
90
|
-
]);
|
|
91
|
-
const renderedItems = (0, external_react_namespaceObject.useMemo)(()=>(0, external_ListView_cjs_namespaceObject.buildRenderedItems)(displayedItems, !isSearching), [
|
|
92
|
-
displayedItems,
|
|
93
|
-
isSearching
|
|
94
|
-
]);
|
|
95
|
-
const getNextSelectableIndex = (0, external_react_namespaceObject.useCallback)((currentIndex, direction)=>{
|
|
96
|
-
let next = currentIndex + direction;
|
|
97
|
-
while(next >= 0 && next < renderedItems.length){
|
|
98
|
-
if (renderedItems[next]?.type === 'item') return next;
|
|
99
|
-
next += direction;
|
|
100
|
-
}
|
|
101
|
-
return -1;
|
|
102
|
-
}, [
|
|
103
|
-
renderedItems
|
|
104
|
-
]);
|
|
105
|
-
const getFirstSelectableIndex = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
106
|
-
for(let i = 0; i < renderedItems.length; i++)if (renderedItems[i]?.type === 'item') return i;
|
|
107
|
-
return -1;
|
|
108
|
-
}, [
|
|
109
|
-
renderedItems
|
|
110
|
-
]);
|
|
111
|
-
const getLastSelectableIndex = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
112
|
-
for(let i = renderedItems.length - 1; i >= 0; i--)if (renderedItems[i]?.type === 'item') return i;
|
|
113
|
-
return -1;
|
|
114
|
-
}, [
|
|
115
|
-
renderedItems
|
|
116
|
-
]);
|
|
117
81
|
const startTransition = (0, external_react_namespaceObject.useCallback)((direction)=>{
|
|
118
82
|
if (transitionTimeoutRef.current) clearTimeout(transitionTimeoutRef.current);
|
|
119
83
|
setIsTransitioning(true);
|
|
@@ -122,21 +86,11 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
122
86
|
setIsTransitioning(false);
|
|
123
87
|
}, TRANSITION_DURATION);
|
|
124
88
|
}, []);
|
|
125
|
-
const navigateToIndex = (0, external_react_namespaceObject.useCallback)((index)=>{
|
|
126
|
-
setActiveIndex(index);
|
|
127
|
-
if (index >= 0) listRef.current?.scrollToRow({
|
|
128
|
-
index,
|
|
129
|
-
align: 'auto'
|
|
130
|
-
});
|
|
131
|
-
}, [
|
|
132
|
-
listRef
|
|
133
|
-
]);
|
|
134
89
|
const clearSearch = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
135
90
|
setSearch('');
|
|
136
91
|
setSearchedItems([]);
|
|
137
92
|
setSearchLoading(false);
|
|
138
93
|
setIsSearchingInitialItems(true);
|
|
139
|
-
setActiveIndex(-1);
|
|
140
94
|
}, []);
|
|
141
95
|
const handleSearch = (0, external_react_namespaceObject.useCallback)(async (query)=>{
|
|
142
96
|
if (!query.trim()) {
|
|
@@ -147,7 +101,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
147
101
|
return;
|
|
148
102
|
}
|
|
149
103
|
setSearch(query);
|
|
150
|
-
setActiveIndex(-1);
|
|
151
104
|
searchIdRef.current += 1;
|
|
152
105
|
const currentRequestId = searchIdRef.current;
|
|
153
106
|
setSearchLoading(true);
|
|
@@ -168,7 +121,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
168
121
|
]);
|
|
169
122
|
const handleBackTransition = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
170
123
|
startTransition('back');
|
|
171
|
-
setActiveIndex(-1);
|
|
172
124
|
const previousState = navigationStack.pop();
|
|
173
125
|
if (previousState) {
|
|
174
126
|
setItems(previousState.data.items);
|
|
@@ -197,7 +149,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
197
149
|
setItems(nestedItems);
|
|
198
150
|
setCurrentParentItem(item);
|
|
199
151
|
clearSearch();
|
|
200
|
-
setActiveIndex(-1);
|
|
201
152
|
startTransition('forward');
|
|
202
153
|
setChildrenLoading(false);
|
|
203
154
|
}, [
|
|
@@ -255,82 +206,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
255
206
|
}, [
|
|
256
207
|
items
|
|
257
208
|
]);
|
|
258
|
-
const activeDescendantId = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
259
|
-
if (activeIndex < 0) return;
|
|
260
|
-
const renderItem = renderedItems[activeIndex];
|
|
261
|
-
if (renderItem?.type === 'item') return `toolbox-item-${renderItem.item.id}`;
|
|
262
|
-
}, [
|
|
263
|
-
activeIndex,
|
|
264
|
-
renderedItems
|
|
265
|
-
]);
|
|
266
|
-
const handleNavigationKeyDown = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
267
|
-
if (isTransitioning) return;
|
|
268
|
-
switch(e.key){
|
|
269
|
-
case 'ArrowDown':
|
|
270
|
-
e.preventDefault();
|
|
271
|
-
if (-1 === activeIndex) {
|
|
272
|
-
const firstIndex = getFirstSelectableIndex();
|
|
273
|
-
if (-1 !== firstIndex) navigateToIndex(firstIndex);
|
|
274
|
-
} else {
|
|
275
|
-
const nextIndex = getNextSelectableIndex(activeIndex, 1);
|
|
276
|
-
if (-1 !== nextIndex) navigateToIndex(nextIndex);
|
|
277
|
-
}
|
|
278
|
-
break;
|
|
279
|
-
case 'ArrowUp':
|
|
280
|
-
e.preventDefault();
|
|
281
|
-
activeIndex <= 0 || -1 === getNextSelectableIndex(activeIndex, -1) ? navigateToIndex(-1) : navigateToIndex(getNextSelectableIndex(activeIndex, -1));
|
|
282
|
-
break;
|
|
283
|
-
case 'Enter':
|
|
284
|
-
if (activeIndex >= 0) {
|
|
285
|
-
const renderItem = renderedItems[activeIndex];
|
|
286
|
-
if (renderItem?.type === 'item') {
|
|
287
|
-
e.preventDefault();
|
|
288
|
-
handleItemSelect(renderItem.item);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
break;
|
|
292
|
-
case 'ArrowRight':
|
|
293
|
-
if (activeIndex >= 0) {
|
|
294
|
-
const renderItem = renderedItems[activeIndex];
|
|
295
|
-
if (renderItem?.type === 'item' && renderItem.item.children) {
|
|
296
|
-
e.preventDefault();
|
|
297
|
-
handleItemSelect(renderItem.item);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
break;
|
|
301
|
-
case 'ArrowLeft':
|
|
302
|
-
if (activeIndex >= 0 && navigationStack.canGoBack) {
|
|
303
|
-
e.preventDefault();
|
|
304
|
-
handleBackTransition();
|
|
305
|
-
}
|
|
306
|
-
break;
|
|
307
|
-
case 'Home':
|
|
308
|
-
{
|
|
309
|
-
e.preventDefault();
|
|
310
|
-
const firstIndex = getFirstSelectableIndex();
|
|
311
|
-
if (-1 !== firstIndex) navigateToIndex(firstIndex);
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
case 'End':
|
|
315
|
-
{
|
|
316
|
-
e.preventDefault();
|
|
317
|
-
const lastIndex = getLastSelectableIndex();
|
|
318
|
-
if (-1 !== lastIndex) navigateToIndex(lastIndex);
|
|
319
|
-
break;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}, [
|
|
323
|
-
isTransitioning,
|
|
324
|
-
activeIndex,
|
|
325
|
-
renderedItems,
|
|
326
|
-
navigationStack.canGoBack,
|
|
327
|
-
navigateToIndex,
|
|
328
|
-
handleItemSelect,
|
|
329
|
-
handleBackTransition,
|
|
330
|
-
getNextSelectableIndex,
|
|
331
|
-
getFirstSelectableIndex,
|
|
332
|
-
getLastSelectableIndex
|
|
333
|
-
]);
|
|
334
209
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
335
210
|
const handleKeyDown = (e)=>{
|
|
336
211
|
if ('Escape' === e.key) if (isSearching) {
|
|
@@ -360,10 +235,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
360
235
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
361
236
|
ref: containerRef,
|
|
362
237
|
"data-testid": "toolbox-container",
|
|
363
|
-
tabIndex: 0,
|
|
364
|
-
role: "application",
|
|
365
|
-
"aria-activedescendant": activeDescendantId,
|
|
366
|
-
"aria-label": currentParentItem?.name || title,
|
|
367
238
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_layouts_index_cjs_namespaceObject.Column, {
|
|
368
239
|
px: 20,
|
|
369
240
|
py: 12,
|
|
@@ -380,9 +251,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
380
251
|
value: search,
|
|
381
252
|
onChange: handleSearch,
|
|
382
253
|
clear: clearSearch,
|
|
383
|
-
placeholder: "Search"
|
|
384
|
-
inputRef: searchInputRef,
|
|
385
|
-
onNavigationKeyDown: handleNavigationKeyDown
|
|
254
|
+
placeholder: "Search"
|
|
386
255
|
}),
|
|
387
256
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Toolbox_styles_cjs_namespaceObject.AnimatedContainer, {
|
|
388
257
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Toolbox_styles_cjs_namespaceObject.AnimatedContent, {
|
|
@@ -390,9 +259,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
390
259
|
direction: animationDirection,
|
|
391
260
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ListView_cjs_namespaceObject.ListView, {
|
|
392
261
|
isLoading: childrenLoading || searchLoading || loading,
|
|
393
|
-
items:
|
|
394
|
-
activeIndex: activeIndex,
|
|
395
|
-
listRef: listRef,
|
|
262
|
+
items: isSearching && !isSearchingInitialItems ? searchedItems : items,
|
|
396
263
|
emptyStateMessage: isSearching ? 'No matching nodes found' : 'No nodes found',
|
|
397
264
|
enableSections: !isSearching,
|
|
398
265
|
onItemClick: handleItemSelect,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbox.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/Toolbox.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Toolbox.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/Toolbox.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,YAAY,CAAC;AAuCrD,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,GAAG,IAAI,CAC1C,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,OAAO,EACzB,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE;IAAE,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAC5E,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE5B,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1D,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;CACpC;AAoBD,wBAAgB,OAAO,CAAC,CAAC,EAAE,EACzB,OAAO,EACP,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,YAAY,EACZ,OAAO,GACR,EAAE,YAAY,CAAC,CAAC,CAAC,2CAoQjB"}
|
|
@@ -2,9 +2,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useNavigationStack } from "../../hooks/index.js";
|
|
3
3
|
import { Column } from "../../layouts/index.js";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
-
import { useListRef } from "react-window";
|
|
6
5
|
import { Header } from "./Header.js";
|
|
7
|
-
import { ListView
|
|
6
|
+
import { ListView } from "./ListView.js";
|
|
8
7
|
import { SearchBox } from "./SearchBox.js";
|
|
9
8
|
import { AnimatedContainer, AnimatedContent } from "./Toolbox.styles.js";
|
|
10
9
|
const TRANSITION_DURATION = 150;
|
|
@@ -44,48 +43,13 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
44
43
|
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
45
44
|
const [animationDirection, setAnimationDirection] = useState('forward');
|
|
46
45
|
const navigationStack = useNavigationStack();
|
|
47
|
-
const [activeIndex, setActiveIndex] = useState(-1);
|
|
48
46
|
const containerRef = useRef(null);
|
|
49
47
|
const transitionTimeoutRef = useRef(void 0);
|
|
50
48
|
const searchIdRef = useRef(0);
|
|
51
49
|
const initialItemsRef = useRef(initialItems);
|
|
52
|
-
const listRef = useListRef(null);
|
|
53
|
-
const searchInputRef = useRef(null);
|
|
54
50
|
const isSearching = useMemo(()=>search.length > 0, [
|
|
55
51
|
search
|
|
56
52
|
]);
|
|
57
|
-
const displayedItems = useMemo(()=>isSearching && !isSearchingInitialItems ? searchedItems : items, [
|
|
58
|
-
isSearching,
|
|
59
|
-
isSearchingInitialItems,
|
|
60
|
-
searchedItems,
|
|
61
|
-
items
|
|
62
|
-
]);
|
|
63
|
-
const renderedItems = useMemo(()=>buildRenderedItems(displayedItems, !isSearching), [
|
|
64
|
-
displayedItems,
|
|
65
|
-
isSearching
|
|
66
|
-
]);
|
|
67
|
-
const getNextSelectableIndex = useCallback((currentIndex, direction)=>{
|
|
68
|
-
let next = currentIndex + direction;
|
|
69
|
-
while(next >= 0 && next < renderedItems.length){
|
|
70
|
-
if (renderedItems[next]?.type === 'item') return next;
|
|
71
|
-
next += direction;
|
|
72
|
-
}
|
|
73
|
-
return -1;
|
|
74
|
-
}, [
|
|
75
|
-
renderedItems
|
|
76
|
-
]);
|
|
77
|
-
const getFirstSelectableIndex = useCallback(()=>{
|
|
78
|
-
for(let i = 0; i < renderedItems.length; i++)if (renderedItems[i]?.type === 'item') return i;
|
|
79
|
-
return -1;
|
|
80
|
-
}, [
|
|
81
|
-
renderedItems
|
|
82
|
-
]);
|
|
83
|
-
const getLastSelectableIndex = useCallback(()=>{
|
|
84
|
-
for(let i = renderedItems.length - 1; i >= 0; i--)if (renderedItems[i]?.type === 'item') return i;
|
|
85
|
-
return -1;
|
|
86
|
-
}, [
|
|
87
|
-
renderedItems
|
|
88
|
-
]);
|
|
89
53
|
const startTransition = useCallback((direction)=>{
|
|
90
54
|
if (transitionTimeoutRef.current) clearTimeout(transitionTimeoutRef.current);
|
|
91
55
|
setIsTransitioning(true);
|
|
@@ -94,21 +58,11 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
94
58
|
setIsTransitioning(false);
|
|
95
59
|
}, TRANSITION_DURATION);
|
|
96
60
|
}, []);
|
|
97
|
-
const navigateToIndex = useCallback((index)=>{
|
|
98
|
-
setActiveIndex(index);
|
|
99
|
-
if (index >= 0) listRef.current?.scrollToRow({
|
|
100
|
-
index,
|
|
101
|
-
align: 'auto'
|
|
102
|
-
});
|
|
103
|
-
}, [
|
|
104
|
-
listRef
|
|
105
|
-
]);
|
|
106
61
|
const clearSearch = useCallback(()=>{
|
|
107
62
|
setSearch('');
|
|
108
63
|
setSearchedItems([]);
|
|
109
64
|
setSearchLoading(false);
|
|
110
65
|
setIsSearchingInitialItems(true);
|
|
111
|
-
setActiveIndex(-1);
|
|
112
66
|
}, []);
|
|
113
67
|
const handleSearch = useCallback(async (query)=>{
|
|
114
68
|
if (!query.trim()) {
|
|
@@ -119,7 +73,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
119
73
|
return;
|
|
120
74
|
}
|
|
121
75
|
setSearch(query);
|
|
122
|
-
setActiveIndex(-1);
|
|
123
76
|
searchIdRef.current += 1;
|
|
124
77
|
const currentRequestId = searchIdRef.current;
|
|
125
78
|
setSearchLoading(true);
|
|
@@ -140,7 +93,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
140
93
|
]);
|
|
141
94
|
const handleBackTransition = useCallback(()=>{
|
|
142
95
|
startTransition('back');
|
|
143
|
-
setActiveIndex(-1);
|
|
144
96
|
const previousState = navigationStack.pop();
|
|
145
97
|
if (previousState) {
|
|
146
98
|
setItems(previousState.data.items);
|
|
@@ -169,7 +121,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
169
121
|
setItems(nestedItems);
|
|
170
122
|
setCurrentParentItem(item);
|
|
171
123
|
clearSearch();
|
|
172
|
-
setActiveIndex(-1);
|
|
173
124
|
startTransition('forward');
|
|
174
125
|
setChildrenLoading(false);
|
|
175
126
|
}, [
|
|
@@ -227,82 +178,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
227
178
|
}, [
|
|
228
179
|
items
|
|
229
180
|
]);
|
|
230
|
-
const activeDescendantId = useMemo(()=>{
|
|
231
|
-
if (activeIndex < 0) return;
|
|
232
|
-
const renderItem = renderedItems[activeIndex];
|
|
233
|
-
if (renderItem?.type === 'item') return `toolbox-item-${renderItem.item.id}`;
|
|
234
|
-
}, [
|
|
235
|
-
activeIndex,
|
|
236
|
-
renderedItems
|
|
237
|
-
]);
|
|
238
|
-
const handleNavigationKeyDown = useCallback((e)=>{
|
|
239
|
-
if (isTransitioning) return;
|
|
240
|
-
switch(e.key){
|
|
241
|
-
case 'ArrowDown':
|
|
242
|
-
e.preventDefault();
|
|
243
|
-
if (-1 === activeIndex) {
|
|
244
|
-
const firstIndex = getFirstSelectableIndex();
|
|
245
|
-
if (-1 !== firstIndex) navigateToIndex(firstIndex);
|
|
246
|
-
} else {
|
|
247
|
-
const nextIndex = getNextSelectableIndex(activeIndex, 1);
|
|
248
|
-
if (-1 !== nextIndex) navigateToIndex(nextIndex);
|
|
249
|
-
}
|
|
250
|
-
break;
|
|
251
|
-
case 'ArrowUp':
|
|
252
|
-
e.preventDefault();
|
|
253
|
-
activeIndex <= 0 || -1 === getNextSelectableIndex(activeIndex, -1) ? navigateToIndex(-1) : navigateToIndex(getNextSelectableIndex(activeIndex, -1));
|
|
254
|
-
break;
|
|
255
|
-
case 'Enter':
|
|
256
|
-
if (activeIndex >= 0) {
|
|
257
|
-
const renderItem = renderedItems[activeIndex];
|
|
258
|
-
if (renderItem?.type === 'item') {
|
|
259
|
-
e.preventDefault();
|
|
260
|
-
handleItemSelect(renderItem.item);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
break;
|
|
264
|
-
case 'ArrowRight':
|
|
265
|
-
if (activeIndex >= 0) {
|
|
266
|
-
const renderItem = renderedItems[activeIndex];
|
|
267
|
-
if (renderItem?.type === 'item' && renderItem.item.children) {
|
|
268
|
-
e.preventDefault();
|
|
269
|
-
handleItemSelect(renderItem.item);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
break;
|
|
273
|
-
case 'ArrowLeft':
|
|
274
|
-
if (activeIndex >= 0 && navigationStack.canGoBack) {
|
|
275
|
-
e.preventDefault();
|
|
276
|
-
handleBackTransition();
|
|
277
|
-
}
|
|
278
|
-
break;
|
|
279
|
-
case 'Home':
|
|
280
|
-
{
|
|
281
|
-
e.preventDefault();
|
|
282
|
-
const firstIndex = getFirstSelectableIndex();
|
|
283
|
-
if (-1 !== firstIndex) navigateToIndex(firstIndex);
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
case 'End':
|
|
287
|
-
{
|
|
288
|
-
e.preventDefault();
|
|
289
|
-
const lastIndex = getLastSelectableIndex();
|
|
290
|
-
if (-1 !== lastIndex) navigateToIndex(lastIndex);
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}, [
|
|
295
|
-
isTransitioning,
|
|
296
|
-
activeIndex,
|
|
297
|
-
renderedItems,
|
|
298
|
-
navigationStack.canGoBack,
|
|
299
|
-
navigateToIndex,
|
|
300
|
-
handleItemSelect,
|
|
301
|
-
handleBackTransition,
|
|
302
|
-
getNextSelectableIndex,
|
|
303
|
-
getFirstSelectableIndex,
|
|
304
|
-
getLastSelectableIndex
|
|
305
|
-
]);
|
|
306
181
|
useEffect(()=>{
|
|
307
182
|
const handleKeyDown = (e)=>{
|
|
308
183
|
if ('Escape' === e.key) if (isSearching) {
|
|
@@ -332,10 +207,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
332
207
|
return /*#__PURE__*/ jsx("div", {
|
|
333
208
|
ref: containerRef,
|
|
334
209
|
"data-testid": "toolbox-container",
|
|
335
|
-
tabIndex: 0,
|
|
336
|
-
role: "application",
|
|
337
|
-
"aria-activedescendant": activeDescendantId,
|
|
338
|
-
"aria-label": currentParentItem?.name || title,
|
|
339
210
|
children: /*#__PURE__*/ jsxs(Column, {
|
|
340
211
|
px: 20,
|
|
341
212
|
py: 12,
|
|
@@ -352,9 +223,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
352
223
|
value: search,
|
|
353
224
|
onChange: handleSearch,
|
|
354
225
|
clear: clearSearch,
|
|
355
|
-
placeholder: "Search"
|
|
356
|
-
inputRef: searchInputRef,
|
|
357
|
-
onNavigationKeyDown: handleNavigationKeyDown
|
|
226
|
+
placeholder: "Search"
|
|
358
227
|
}),
|
|
359
228
|
/*#__PURE__*/ jsx(AnimatedContainer, {
|
|
360
229
|
children: /*#__PURE__*/ jsx(AnimatedContent, {
|
|
@@ -362,9 +231,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
362
231
|
direction: animationDirection,
|
|
363
232
|
children: /*#__PURE__*/ jsx(ListView, {
|
|
364
233
|
isLoading: childrenLoading || searchLoading || loading,
|
|
365
|
-
items:
|
|
366
|
-
activeIndex: activeIndex,
|
|
367
|
-
listRef: listRef,
|
|
234
|
+
items: isSearching && !isSearchingInitialItems ? searchedItems : items,
|
|
368
235
|
emptyStateMessage: isSearching ? 'No matching nodes found' : 'No nodes found',
|
|
369
236
|
enableSections: !isSearching,
|
|
370
237
|
onItemClick: handleItemSelect,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/apollo-react",
|
|
3
|
-
"version": "3.54.
|
|
3
|
+
"version": "3.54.1",
|
|
4
4
|
"description": "Apollo Design System - React component library with Material UI theming",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -200,8 +200,8 @@
|
|
|
200
200
|
"use-sync-external-store": "^1.2.0",
|
|
201
201
|
"zod": "^4.3.5",
|
|
202
202
|
"zustand": "^5.0.9",
|
|
203
|
-
"@uipath/apollo-core": "5.7.
|
|
204
|
-
"@uipath/apollo-wind": "0.15.
|
|
203
|
+
"@uipath/apollo-core": "5.7.2",
|
|
204
|
+
"@uipath/apollo-wind": "0.15.2"
|
|
205
205
|
},
|
|
206
206
|
"devDependencies": {
|
|
207
207
|
"@lingui/cli": "^5.6.1",
|
|
@@ -235,8 +235,8 @@
|
|
|
235
235
|
"@types/sanitize-html": "^2.16.0",
|
|
236
236
|
"@types/webpack-bundle-analyzer": "^4.7.0",
|
|
237
237
|
"@vitejs/plugin-react": "^4.7.0",
|
|
238
|
-
"@vitest/coverage-v8": "^4.0
|
|
239
|
-
"@vitest/ui": "^4.0
|
|
238
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
239
|
+
"@vitest/ui": "^4.1.0",
|
|
240
240
|
"esbuild": "^0.27.0",
|
|
241
241
|
"glob": "^13.0.0",
|
|
242
242
|
"happy-dom": "^20.0.0",
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
"typescript": "^5.9.3",
|
|
246
246
|
"use-sync-external-store": "^1.2.0",
|
|
247
247
|
"vite-tsconfig-paths": "^5.1.4",
|
|
248
|
-
"vitest": "^4.0
|
|
248
|
+
"vitest": "^4.1.0",
|
|
249
249
|
"webpack-bundle-analyzer": "^5.0.1"
|
|
250
250
|
},
|
|
251
251
|
"scripts": {
|