@uipath/apollo-react 7.16.4 → 7.17.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/StageNode/StageHeaderChips.cjs +160 -0
- package/dist/canvas/components/StageNode/StageHeaderChips.d.ts +8 -0
- package/dist/canvas/components/StageNode/StageHeaderChips.d.ts.map +1 -0
- package/dist/canvas/components/StageNode/StageHeaderChips.js +126 -0
- package/dist/canvas/components/StageNode/StageNode.types.cjs +1 -0
- package/dist/canvas/components/StageNode/StageNode.types.d.ts +1 -0
- package/dist/canvas/components/StageNode/StageNode.types.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNode.types.js +1 -0
- package/dist/canvas/components/StageNode/StageNodeHeader.cjs +5 -108
- package/dist/canvas/components/StageNode/StageNodeHeader.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNodeHeader.js +7 -110
- package/dist/canvas/components/StageNode/index.cjs +4 -0
- package/dist/canvas/components/StageNode/index.d.ts +2 -0
- package/dist/canvas/components/StageNode/index.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/index.js +2 -1
- package/dist/canvas/components/Toolbox/Header.cjs +3 -1
- package/dist/canvas/components/Toolbox/Header.d.ts +2 -0
- package/dist/canvas/components/Toolbox/Header.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/Header.js +3 -1
- package/dist/canvas/components/Toolbox/ListView.cjs +38 -24
- package/dist/canvas/components/Toolbox/ListView.d.ts +3 -0
- package/dist/canvas/components/Toolbox/ListView.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/ListView.js +37 -26
- package/dist/canvas/components/Toolbox/SearchBox.cjs +5 -13
- package/dist/canvas/components/Toolbox/SearchBox.d.ts +2 -2
- package/dist/canvas/components/Toolbox/SearchBox.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/SearchBox.js +5 -13
- package/dist/canvas/components/Toolbox/Toolbox.cjs +41 -20
- package/dist/canvas/components/Toolbox/Toolbox.d.ts +4 -1
- package/dist/canvas/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/Toolbox.js +42 -21
- package/dist/canvas/locales/de.cjs +1 -1
- package/dist/canvas/locales/de.d.ts.map +1 -1
- package/dist/canvas/locales/de.js +1 -1
- package/dist/canvas/locales/en.cjs +1 -1
- package/dist/canvas/locales/en.d.ts.map +1 -1
- package/dist/canvas/locales/en.js +1 -1
- package/dist/canvas/locales/es-MX.cjs +1 -1
- package/dist/canvas/locales/es-MX.d.ts.map +1 -1
- package/dist/canvas/locales/es-MX.js +1 -1
- package/dist/canvas/locales/es.cjs +1 -1
- package/dist/canvas/locales/es.d.ts.map +1 -1
- package/dist/canvas/locales/es.js +1 -1
- package/dist/canvas/locales/fr.cjs +1 -1
- package/dist/canvas/locales/fr.d.ts.map +1 -1
- package/dist/canvas/locales/fr.js +1 -1
- package/dist/canvas/locales/ja.cjs +1 -1
- package/dist/canvas/locales/ja.d.ts.map +1 -1
- package/dist/canvas/locales/ja.js +1 -1
- package/dist/canvas/locales/ko.cjs +1 -1
- package/dist/canvas/locales/ko.d.ts.map +1 -1
- package/dist/canvas/locales/ko.js +1 -1
- package/dist/canvas/locales/pt-BR.cjs +1 -1
- package/dist/canvas/locales/pt-BR.d.ts.map +1 -1
- package/dist/canvas/locales/pt-BR.js +1 -1
- package/dist/canvas/locales/pt.cjs +1 -1
- package/dist/canvas/locales/pt.d.ts.map +1 -1
- package/dist/canvas/locales/pt.js +1 -1
- package/dist/canvas/locales/ro.cjs +1 -1
- package/dist/canvas/locales/ro.d.ts.map +1 -1
- package/dist/canvas/locales/ro.js +1 -1
- package/dist/canvas/locales/ru.cjs +1 -1
- package/dist/canvas/locales/ru.d.ts.map +1 -1
- package/dist/canvas/locales/ru.js +1 -1
- package/dist/canvas/locales/tr.cjs +1 -1
- package/dist/canvas/locales/tr.d.ts.map +1 -1
- package/dist/canvas/locales/tr.js +1 -1
- package/dist/canvas/locales/zh-CN.cjs +1 -1
- package/dist/canvas/locales/zh-CN.d.ts.map +1 -1
- package/dist/canvas/locales/zh-CN.js +1 -1
- package/dist/canvas/locales/zh-TW.cjs +1 -1
- package/dist/canvas/locales/zh-TW.d.ts.map +1 -1
- package/dist/canvas/locales/zh-TW.js +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/chat/locales/de.cjs +1 -1
- package/dist/chat/locales/de.d.ts.map +1 -1
- package/dist/chat/locales/de.js +1 -1
- package/dist/chat/locales/es-MX.cjs +1 -1
- package/dist/chat/locales/es-MX.d.ts.map +1 -1
- package/dist/chat/locales/es-MX.js +1 -1
- package/dist/chat/locales/es.cjs +1 -1
- package/dist/chat/locales/es.d.ts.map +1 -1
- package/dist/chat/locales/es.js +1 -1
- package/dist/chat/locales/fr.cjs +1 -1
- package/dist/chat/locales/fr.d.ts.map +1 -1
- package/dist/chat/locales/fr.js +1 -1
- package/dist/chat/locales/ja.cjs +1 -1
- package/dist/chat/locales/ja.d.ts.map +1 -1
- package/dist/chat/locales/ja.js +1 -1
- package/dist/chat/locales/ko.cjs +1 -1
- package/dist/chat/locales/ko.d.ts.map +1 -1
- package/dist/chat/locales/ko.js +1 -1
- package/dist/chat/locales/pt-BR.cjs +1 -1
- package/dist/chat/locales/pt-BR.d.ts.map +1 -1
- package/dist/chat/locales/pt-BR.js +1 -1
- package/dist/chat/locales/pt.cjs +1 -1
- package/dist/chat/locales/pt.d.ts.map +1 -1
- package/dist/chat/locales/pt.js +1 -1
- package/dist/chat/locales/ro.cjs +1 -1
- package/dist/chat/locales/ro.d.ts.map +1 -1
- package/dist/chat/locales/ro.js +1 -1
- package/dist/chat/locales/tr.cjs +1 -1
- package/dist/chat/locales/tr.d.ts.map +1 -1
- package/dist/chat/locales/tr.js +1 -1
- package/dist/chat/locales/zh-CN.cjs +1 -1
- package/dist/chat/locales/zh-CN.d.ts.map +1 -1
- package/dist/chat/locales/zh-CN.js +1 -1
- package/dist/chat/locales/zh-TW.cjs +1 -1
- package/dist/chat/locales/zh-TW.d.ts.map +1 -1
- package/dist/chat/locales/zh-TW.js +1 -1
- package/dist/chat/styles/tailwind.chat.css +1 -1
- package/dist/decision-table/styles/tailwind.decision-table.css +1 -1
- package/package.json +3 -3
|
@@ -44,6 +44,7 @@ const ENTER_ANIMATION_CLASS = {
|
|
|
44
44
|
};
|
|
45
45
|
const TRANSITION_DURATION = 150;
|
|
46
46
|
const SEARCH_BAR_INDEX = -1;
|
|
47
|
+
const SEARCH_ANNOUNCEMENT_DELAY = 500;
|
|
47
48
|
function findItemById(items, id) {
|
|
48
49
|
const queue = [
|
|
49
50
|
...items
|
|
@@ -86,7 +87,7 @@ function searchLeafItems(items, query) {
|
|
|
86
87
|
}
|
|
87
88
|
return results;
|
|
88
89
|
}
|
|
89
|
-
function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title, initialItems, loading, fullWidth = false, fullHeight = false, quickActions, renderEmptyState, searchPlaceholder: searchPlaceholderProp, initialCategoryId }) {
|
|
90
|
+
function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title, titleHeadingLevel, initialItems, loading, fullWidth = false, fullHeight = false, maxHeight, quickActions, renderEmptyState, searchPlaceholder: searchPlaceholderProp, initialCategoryId }) {
|
|
90
91
|
const { _ } = (0, external_i18n_index_cjs_namespaceObject.useSafeLingui)();
|
|
91
92
|
const searchPlaceholder = searchPlaceholderProp ?? _({
|
|
92
93
|
id: 'toolbox.search',
|
|
@@ -100,6 +101,10 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
100
101
|
id: 'toolbox.search.pending',
|
|
101
102
|
message: 'Searching'
|
|
102
103
|
});
|
|
104
|
+
const noMatchesLabel = _({
|
|
105
|
+
id: 'toolbox.search.noResults',
|
|
106
|
+
message: 'No matching nodes found'
|
|
107
|
+
});
|
|
103
108
|
const [items, setItems] = (0, external_react_namespaceObject.useState)(initialItems);
|
|
104
109
|
const [search, setSearch] = (0, external_react_namespaceObject.useState)('');
|
|
105
110
|
const [searchLoading, setSearchLoading] = (0, external_react_namespaceObject.useState)(false);
|
|
@@ -109,6 +114,8 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
109
114
|
const [currentParentItem, setCurrentParentItem] = (0, external_react_namespaceObject.useState)(null);
|
|
110
115
|
const [isTransitioning, setIsTransitioning] = (0, external_react_namespaceObject.useState)(false);
|
|
111
116
|
const [animationDirection, setAnimationDirection] = (0, external_react_namespaceObject.useState)('forward');
|
|
117
|
+
const [searchAnnouncement, setSearchAnnouncement] = (0, external_react_namespaceObject.useState)('');
|
|
118
|
+
const [isListboxPresent, setIsListboxPresent] = (0, external_react_namespaceObject.useState)(true);
|
|
112
119
|
const navigationStack = (0, index_cjs_namespaceObject.useNavigationStack)();
|
|
113
120
|
const [activeIndex, setActiveIndex] = (0, external_react_namespaceObject.useState)(SEARCH_BAR_INDEX);
|
|
114
121
|
const [keyboardNav, setKeyboardNav] = (0, external_react_namespaceObject.useState)(false);
|
|
@@ -119,7 +126,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
119
126
|
const listRef = (0, external_react_window_namespaceObject.useListRef)(null);
|
|
120
127
|
const listViewRef = (0, external_react_namespaceObject.useRef)(null);
|
|
121
128
|
const searchInputRef = (0, external_react_namespaceObject.useRef)(null);
|
|
122
|
-
const clearButtonRef = (0, external_react_namespaceObject.useRef)(null);
|
|
123
129
|
const lastScrollTopRef = (0, external_react_namespaceObject.useRef)(0);
|
|
124
130
|
const initialCategoryAppliedRef = (0, external_react_namespaceObject.useRef)(false);
|
|
125
131
|
const handleListScroll = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
@@ -149,6 +155,22 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
149
155
|
count: displayedItems.length
|
|
150
156
|
}
|
|
151
157
|
});
|
|
158
|
+
const searchResultsText = !isSearching || searchLoading || loading || isSearchingInitialItems ? '' : 0 === searchedItems.length ? noMatchesLabel : _({
|
|
159
|
+
id: 'toolbox.search.results',
|
|
160
|
+
message: 'Results: {count}',
|
|
161
|
+
values: {
|
|
162
|
+
count: searchedItems.length
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
166
|
+
setSearchAnnouncement('');
|
|
167
|
+
if (!searchResultsText) return;
|
|
168
|
+
const timeout = setTimeout(()=>setSearchAnnouncement(searchResultsText), SEARCH_ANNOUNCEMENT_DELAY);
|
|
169
|
+
return ()=>clearTimeout(timeout);
|
|
170
|
+
}, [
|
|
171
|
+
search,
|
|
172
|
+
searchResultsText
|
|
173
|
+
]);
|
|
152
174
|
const startTransition = (0, external_react_namespaceObject.useCallback)((direction)=>{
|
|
153
175
|
if (transitionTimeoutRef.current) clearTimeout(transitionTimeoutRef.current);
|
|
154
176
|
setIsTransitioning(true);
|
|
@@ -408,16 +430,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
408
430
|
e.preventDefault();
|
|
409
431
|
handleBackTransition();
|
|
410
432
|
break;
|
|
411
|
-
case 'Tab':
|
|
412
|
-
if (activeIndex === SEARCH_BAR_INDEX && search.length > 0 && !e.shiftKey) break;
|
|
413
|
-
e.preventDefault();
|
|
414
|
-
if (activeIndex === SEARCH_BAR_INDEX && e.shiftKey) break;
|
|
415
|
-
if (e.shiftKey) {
|
|
416
|
-
navigateUp();
|
|
417
|
-
const nextUp = getNextSelectableIndex(renderedItems, activeIndex, 'up');
|
|
418
|
-
if (nextUp === SEARCH_BAR_INDEX && search.length > 0) clearButtonRef.current?.focus();
|
|
419
|
-
} else navigateDown();
|
|
420
|
-
break;
|
|
421
433
|
case 'Home':
|
|
422
434
|
if (activeIndex === SEARCH_BAR_INDEX) break;
|
|
423
435
|
e.preventDefault();
|
|
@@ -449,6 +461,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
449
461
|
navigationStack,
|
|
450
462
|
onClose
|
|
451
463
|
]);
|
|
464
|
+
const [opener] = (0, external_react_namespaceObject.useState)(()=>"u" < typeof document ? null : document.activeElement);
|
|
452
465
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
453
466
|
const handleKeyDown = (e)=>{
|
|
454
467
|
if ('Escape' === e.key) if (isSearching) {
|
|
@@ -456,7 +469,11 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
456
469
|
startTransition('back');
|
|
457
470
|
clearSearch();
|
|
458
471
|
} else if (navigationStack.canGoBack) handleBackTransition();
|
|
459
|
-
else
|
|
472
|
+
else {
|
|
473
|
+
const focusWasInside = containerRef.current?.contains(document.activeElement) ?? false;
|
|
474
|
+
handleClose();
|
|
475
|
+
if (focusWasInside && opener?.isConnected && opener !== document.body) opener.focus();
|
|
476
|
+
}
|
|
460
477
|
};
|
|
461
478
|
const handleClickOutside = (e)=>{
|
|
462
479
|
if (containerRef.current && !containerRef.current.contains(e.target)) handleClose();
|
|
@@ -473,7 +490,8 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
473
490
|
handleClose,
|
|
474
491
|
clearSearch,
|
|
475
492
|
startTransition,
|
|
476
|
-
handleBackTransition
|
|
493
|
+
handleBackTransition,
|
|
494
|
+
opener
|
|
477
495
|
]);
|
|
478
496
|
const responsiveStyle = (0, external_react_namespaceObject.useMemo)(()=>fullHeight ? {
|
|
479
497
|
boxSizing: 'border-box',
|
|
@@ -481,9 +499,10 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
481
499
|
} : {
|
|
482
500
|
boxSizing: 'border-box',
|
|
483
501
|
overflow: 'hidden',
|
|
484
|
-
maxHeight: `min(${external_constants_cjs_namespaceObject.TOOLBOX_HEIGHT}px, var(--floating-available-height, ${external_constants_cjs_namespaceObject.TOOLBOX_HEIGHT}px))`
|
|
502
|
+
maxHeight: `min(${Math.min(external_constants_cjs_namespaceObject.TOOLBOX_HEIGHT, maxHeight ?? external_constants_cjs_namespaceObject.TOOLBOX_HEIGHT)}px, var(--floating-available-height, ${external_constants_cjs_namespaceObject.TOOLBOX_HEIGHT}px))`
|
|
485
503
|
}, [
|
|
486
|
-
fullHeight
|
|
504
|
+
fullHeight,
|
|
505
|
+
maxHeight
|
|
487
506
|
]);
|
|
488
507
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
489
508
|
ref: containerRef,
|
|
@@ -506,13 +525,14 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
506
525
|
}),
|
|
507
526
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_Header_cjs_namespaceObject.Header, {
|
|
508
527
|
title: currentParentItem?.name || title,
|
|
528
|
+
headingLevel: titleHeadingLevel,
|
|
509
529
|
onBack: handleBackTransition,
|
|
510
530
|
showBackButton: navigationStack.canGoBack
|
|
511
531
|
}),
|
|
512
532
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("output", {
|
|
513
533
|
"aria-live": "polite",
|
|
514
534
|
className: "sr-only",
|
|
515
|
-
children: categoryAnnouncement
|
|
535
|
+
children: searchAnnouncement || categoryAnnouncement
|
|
516
536
|
}),
|
|
517
537
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_SearchBox_cjs_namespaceObject.SearchBox, {
|
|
518
538
|
value: search,
|
|
@@ -521,10 +541,10 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
521
541
|
placeholder: searchPlaceholder,
|
|
522
542
|
clearButtonAriaLabel: clearSearchLabel,
|
|
523
543
|
inputRef: searchInputRef,
|
|
524
|
-
clearButtonRef: clearButtonRef,
|
|
525
544
|
onNavigationKeyDown: handleNavigationKeyDown,
|
|
526
|
-
|
|
545
|
+
onBlur: ()=>setKeyboardNav(false),
|
|
527
546
|
activeDescendantId: activeDescendantId,
|
|
547
|
+
listboxId: isListboxPresent ? external_ListView_cjs_namespaceObject.TOOLBOX_LISTBOX_ID : void 0,
|
|
528
548
|
pending: searchLoading,
|
|
529
549
|
pendingLabel: searchPendingLabel
|
|
530
550
|
}),
|
|
@@ -540,11 +560,12 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
540
560
|
items: displayedItems,
|
|
541
561
|
activeIndex: activeIndex,
|
|
542
562
|
listRef: listRef,
|
|
543
|
-
emptyStateMessage: isSearching ?
|
|
563
|
+
emptyStateMessage: isSearching ? noMatchesLabel : 'No nodes found',
|
|
544
564
|
renderEmptyState: wrappedRenderEmptyState,
|
|
545
565
|
onItemClick: handleItemSelect,
|
|
546
566
|
onItemHover: onItemHover,
|
|
547
567
|
onScroll: handleListScroll,
|
|
568
|
+
onListboxPresenceChange: setIsListboxPresent,
|
|
548
569
|
enableSections: !isSearching,
|
|
549
570
|
loadingSkeleton: isSearching ? void 0 : currentParentItem?.childrenLoading
|
|
550
571
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type HeadingLevel } from './Header';
|
|
1
2
|
import { type ListItem } from './ListView';
|
|
2
3
|
import { type ToolboxQuickAction } from './QuickActionsRow';
|
|
3
4
|
export type ToolboxEmptyStateRenderer<T = any> = (ctx: {
|
|
@@ -9,10 +10,12 @@ export type ToolboxSearchHandler<T = any> = (query: string, isTopLevelSearch: bo
|
|
|
9
10
|
}) => Promise<ListItem<T>[]>;
|
|
10
11
|
export interface ToolboxProps<T> {
|
|
11
12
|
title: string;
|
|
13
|
+
titleHeadingLevel?: HeadingLevel;
|
|
12
14
|
initialItems: ListItem<T>[];
|
|
13
15
|
loading?: boolean;
|
|
14
16
|
fullWidth?: boolean;
|
|
15
17
|
fullHeight?: boolean;
|
|
18
|
+
maxHeight?: number;
|
|
16
19
|
onClose: () => void;
|
|
17
20
|
onItemSelect: (item: ListItem<T>) => Promise<void> | void;
|
|
18
21
|
onItemHover?: (item: ListItem<T>) => void;
|
|
@@ -23,5 +26,5 @@ export interface ToolboxProps<T> {
|
|
|
23
26
|
renderEmptyState?: ToolboxEmptyStateRenderer<T>;
|
|
24
27
|
initialCategoryId?: string;
|
|
25
28
|
}
|
|
26
|
-
export declare function Toolbox<T>({ onClose, onBack, onItemSelect, onSearch, onItemHover, title, initialItems, loading, fullWidth, fullHeight, quickActions, renderEmptyState, searchPlaceholder: searchPlaceholderProp, initialCategoryId, }: ToolboxProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare function Toolbox<T>({ onClose, onBack, onItemSelect, onSearch, onItemHover, title, titleHeadingLevel, initialItems, loading, fullWidth, fullHeight, maxHeight, quickActions, renderEmptyState, searchPlaceholder: searchPlaceholderProp, initialCategoryId, }: ToolboxProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
27
30
|
//# sourceMappingURL=Toolbox.d.ts.map
|
|
@@ -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":"AAaA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EACL,KAAK,QAAQ,EAKd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAiE7E,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IACrD,eAAe,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CAC/B,KAAK,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;AAEhC,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;IAKd,iBAAiB,CAAC,EAAE,YAAY,CAAC;IAQjC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IAMrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,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;IAKnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAO3B,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAOpC,gBAAgB,CAAC,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAOhD,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAgDD,wBAAgB,OAAO,CAAC,CAAC,EAAE,EACzB,OAAO,EACP,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,SAAiB,EACjB,UAAkB,EAClB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EAAE,qBAAqB,EACxC,iBAAiB,GAClB,EAAE,YAAY,CAAC,CAAC,CAAC,2CAymBjB"}
|
|
@@ -7,7 +7,7 @@ import { useListRef } from "react-window";
|
|
|
7
7
|
import { useSafeLingui } from "../../../i18n/index.js";
|
|
8
8
|
import { TOOLBOX_GAP, TOOLBOX_HEIGHT, TOOLBOX_PADDING_X, TOOLBOX_PADDING_Y, TOOLBOX_WIDTH } from "../../constants.js";
|
|
9
9
|
import { Header } from "./Header.js";
|
|
10
|
-
import { ListView } from "./ListView.js";
|
|
10
|
+
import { ListView, TOOLBOX_LISTBOX_ID } from "./ListView.js";
|
|
11
11
|
import { QuickActionsRow } from "./QuickActionsRow.js";
|
|
12
12
|
import { SearchBox } from "./SearchBox.js";
|
|
13
13
|
const ENTER_ANIMATION_CLASS = {
|
|
@@ -16,6 +16,7 @@ const ENTER_ANIMATION_CLASS = {
|
|
|
16
16
|
};
|
|
17
17
|
const TRANSITION_DURATION = 150;
|
|
18
18
|
const SEARCH_BAR_INDEX = -1;
|
|
19
|
+
const SEARCH_ANNOUNCEMENT_DELAY = 500;
|
|
19
20
|
function findItemById(items, id) {
|
|
20
21
|
const queue = [
|
|
21
22
|
...items
|
|
@@ -58,7 +59,7 @@ function searchLeafItems(items, query) {
|
|
|
58
59
|
}
|
|
59
60
|
return results;
|
|
60
61
|
}
|
|
61
|
-
function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title, initialItems, loading, fullWidth = false, fullHeight = false, quickActions, renderEmptyState, searchPlaceholder: searchPlaceholderProp, initialCategoryId }) {
|
|
62
|
+
function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title, titleHeadingLevel, initialItems, loading, fullWidth = false, fullHeight = false, maxHeight, quickActions, renderEmptyState, searchPlaceholder: searchPlaceholderProp, initialCategoryId }) {
|
|
62
63
|
const { _ } = useSafeLingui();
|
|
63
64
|
const searchPlaceholder = searchPlaceholderProp ?? _({
|
|
64
65
|
id: 'toolbox.search',
|
|
@@ -72,6 +73,10 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
72
73
|
id: 'toolbox.search.pending',
|
|
73
74
|
message: 'Searching'
|
|
74
75
|
});
|
|
76
|
+
const noMatchesLabel = _({
|
|
77
|
+
id: 'toolbox.search.noResults',
|
|
78
|
+
message: 'No matching nodes found'
|
|
79
|
+
});
|
|
75
80
|
const [items, setItems] = useState(initialItems);
|
|
76
81
|
const [search, setSearch] = useState('');
|
|
77
82
|
const [searchLoading, setSearchLoading] = useState(false);
|
|
@@ -81,6 +86,8 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
81
86
|
const [currentParentItem, setCurrentParentItem] = useState(null);
|
|
82
87
|
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
83
88
|
const [animationDirection, setAnimationDirection] = useState('forward');
|
|
89
|
+
const [searchAnnouncement, setSearchAnnouncement] = useState('');
|
|
90
|
+
const [isListboxPresent, setIsListboxPresent] = useState(true);
|
|
84
91
|
const navigationStack = useNavigationStack();
|
|
85
92
|
const [activeIndex, setActiveIndex] = useState(SEARCH_BAR_INDEX);
|
|
86
93
|
const [keyboardNav, setKeyboardNav] = useState(false);
|
|
@@ -91,7 +98,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
91
98
|
const listRef = useListRef(null);
|
|
92
99
|
const listViewRef = useRef(null);
|
|
93
100
|
const searchInputRef = useRef(null);
|
|
94
|
-
const clearButtonRef = useRef(null);
|
|
95
101
|
const lastScrollTopRef = useRef(0);
|
|
96
102
|
const initialCategoryAppliedRef = useRef(false);
|
|
97
103
|
const handleListScroll = useCallback((e)=>{
|
|
@@ -121,6 +127,22 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
121
127
|
count: displayedItems.length
|
|
122
128
|
}
|
|
123
129
|
});
|
|
130
|
+
const searchResultsText = !isSearching || searchLoading || loading || isSearchingInitialItems ? '' : 0 === searchedItems.length ? noMatchesLabel : _({
|
|
131
|
+
id: 'toolbox.search.results',
|
|
132
|
+
message: 'Results: {count}',
|
|
133
|
+
values: {
|
|
134
|
+
count: searchedItems.length
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
useEffect(()=>{
|
|
138
|
+
setSearchAnnouncement('');
|
|
139
|
+
if (!searchResultsText) return;
|
|
140
|
+
const timeout = setTimeout(()=>setSearchAnnouncement(searchResultsText), SEARCH_ANNOUNCEMENT_DELAY);
|
|
141
|
+
return ()=>clearTimeout(timeout);
|
|
142
|
+
}, [
|
|
143
|
+
search,
|
|
144
|
+
searchResultsText
|
|
145
|
+
]);
|
|
124
146
|
const startTransition = useCallback((direction)=>{
|
|
125
147
|
if (transitionTimeoutRef.current) clearTimeout(transitionTimeoutRef.current);
|
|
126
148
|
setIsTransitioning(true);
|
|
@@ -380,16 +402,6 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
380
402
|
e.preventDefault();
|
|
381
403
|
handleBackTransition();
|
|
382
404
|
break;
|
|
383
|
-
case 'Tab':
|
|
384
|
-
if (activeIndex === SEARCH_BAR_INDEX && search.length > 0 && !e.shiftKey) break;
|
|
385
|
-
e.preventDefault();
|
|
386
|
-
if (activeIndex === SEARCH_BAR_INDEX && e.shiftKey) break;
|
|
387
|
-
if (e.shiftKey) {
|
|
388
|
-
navigateUp();
|
|
389
|
-
const nextUp = getNextSelectableIndex(renderedItems, activeIndex, 'up');
|
|
390
|
-
if (nextUp === SEARCH_BAR_INDEX && search.length > 0) clearButtonRef.current?.focus();
|
|
391
|
-
} else navigateDown();
|
|
392
|
-
break;
|
|
393
405
|
case 'Home':
|
|
394
406
|
if (activeIndex === SEARCH_BAR_INDEX) break;
|
|
395
407
|
e.preventDefault();
|
|
@@ -421,6 +433,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
421
433
|
navigationStack,
|
|
422
434
|
onClose
|
|
423
435
|
]);
|
|
436
|
+
const [opener] = useState(()=>"u" < typeof document ? null : document.activeElement);
|
|
424
437
|
useEffect(()=>{
|
|
425
438
|
const handleKeyDown = (e)=>{
|
|
426
439
|
if ('Escape' === e.key) if (isSearching) {
|
|
@@ -428,7 +441,11 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
428
441
|
startTransition('back');
|
|
429
442
|
clearSearch();
|
|
430
443
|
} else if (navigationStack.canGoBack) handleBackTransition();
|
|
431
|
-
else
|
|
444
|
+
else {
|
|
445
|
+
const focusWasInside = containerRef.current?.contains(document.activeElement) ?? false;
|
|
446
|
+
handleClose();
|
|
447
|
+
if (focusWasInside && opener?.isConnected && opener !== document.body) opener.focus();
|
|
448
|
+
}
|
|
432
449
|
};
|
|
433
450
|
const handleClickOutside = (e)=>{
|
|
434
451
|
if (containerRef.current && !containerRef.current.contains(e.target)) handleClose();
|
|
@@ -445,7 +462,8 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
445
462
|
handleClose,
|
|
446
463
|
clearSearch,
|
|
447
464
|
startTransition,
|
|
448
|
-
handleBackTransition
|
|
465
|
+
handleBackTransition,
|
|
466
|
+
opener
|
|
449
467
|
]);
|
|
450
468
|
const responsiveStyle = useMemo(()=>fullHeight ? {
|
|
451
469
|
boxSizing: 'border-box',
|
|
@@ -453,9 +471,10 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
453
471
|
} : {
|
|
454
472
|
boxSizing: 'border-box',
|
|
455
473
|
overflow: 'hidden',
|
|
456
|
-
maxHeight: `min(${TOOLBOX_HEIGHT}px, var(--floating-available-height, ${TOOLBOX_HEIGHT}px))`
|
|
474
|
+
maxHeight: `min(${Math.min(TOOLBOX_HEIGHT, maxHeight ?? TOOLBOX_HEIGHT)}px, var(--floating-available-height, ${TOOLBOX_HEIGHT}px))`
|
|
457
475
|
}, [
|
|
458
|
-
fullHeight
|
|
476
|
+
fullHeight,
|
|
477
|
+
maxHeight
|
|
459
478
|
]);
|
|
460
479
|
return /*#__PURE__*/ jsx("div", {
|
|
461
480
|
ref: containerRef,
|
|
@@ -478,13 +497,14 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
478
497
|
}),
|
|
479
498
|
/*#__PURE__*/ jsx(Header, {
|
|
480
499
|
title: currentParentItem?.name || title,
|
|
500
|
+
headingLevel: titleHeadingLevel,
|
|
481
501
|
onBack: handleBackTransition,
|
|
482
502
|
showBackButton: navigationStack.canGoBack
|
|
483
503
|
}),
|
|
484
504
|
/*#__PURE__*/ jsx("output", {
|
|
485
505
|
"aria-live": "polite",
|
|
486
506
|
className: "sr-only",
|
|
487
|
-
children: categoryAnnouncement
|
|
507
|
+
children: searchAnnouncement || categoryAnnouncement
|
|
488
508
|
}),
|
|
489
509
|
/*#__PURE__*/ jsx(SearchBox, {
|
|
490
510
|
value: search,
|
|
@@ -493,10 +513,10 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
493
513
|
placeholder: searchPlaceholder,
|
|
494
514
|
clearButtonAriaLabel: clearSearchLabel,
|
|
495
515
|
inputRef: searchInputRef,
|
|
496
|
-
clearButtonRef: clearButtonRef,
|
|
497
516
|
onNavigationKeyDown: handleNavigationKeyDown,
|
|
498
|
-
|
|
517
|
+
onBlur: ()=>setKeyboardNav(false),
|
|
499
518
|
activeDescendantId: activeDescendantId,
|
|
519
|
+
listboxId: isListboxPresent ? TOOLBOX_LISTBOX_ID : void 0,
|
|
500
520
|
pending: searchLoading,
|
|
501
521
|
pendingLabel: searchPendingLabel
|
|
502
522
|
}),
|
|
@@ -512,11 +532,12 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
512
532
|
items: displayedItems,
|
|
513
533
|
activeIndex: activeIndex,
|
|
514
534
|
listRef: listRef,
|
|
515
|
-
emptyStateMessage: isSearching ?
|
|
535
|
+
emptyStateMessage: isSearching ? noMatchesLabel : 'No nodes found',
|
|
516
536
|
renderEmptyState: wrappedRenderEmptyState,
|
|
517
537
|
onItemClick: handleItemSelect,
|
|
518
538
|
onItemHover: onItemHover,
|
|
519
539
|
onScroll: handleListScroll,
|
|
540
|
+
onListboxPresenceChange: setIsListboxPresent,
|
|
520
541
|
enableSections: !isSearching,
|
|
521
542
|
loadingSkeleton: isSearching ? void 0 : currentParentItem?.childrenLoading
|
|
522
543
|
})
|