@uipath/apollo-react 4.16.0 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/components/CanvasTooltip.cjs +2 -0
- package/dist/canvas/components/CanvasTooltip.d.ts +2 -2
- package/dist/canvas/components/CanvasTooltip.d.ts.map +1 -1
- package/dist/canvas/components/CanvasTooltip.js +2 -0
- package/dist/canvas/components/Toolbox/ListView.cjs +66 -19
- package/dist/canvas/components/Toolbox/ListView.d.ts +12 -1
- package/dist/canvas/components/Toolbox/ListView.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/ListView.js +66 -19
- package/dist/canvas/components/Toolbox/Toolbox.cjs +6 -5
- package/dist/canvas/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/Toolbox.js +6 -5
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/package.json +3 -3
|
@@ -102,6 +102,8 @@ function CanvasTooltip({ content, placement = 'top', smartTooltip = false, delay
|
|
|
102
102
|
]);
|
|
103
103
|
const effectiveOpen = isTooltipHidden ? false : isOpen ?? hoverOpen;
|
|
104
104
|
const hasProvider = (0, external_react_namespaceObject.useContext)(HasTooltipProviderContext);
|
|
105
|
+
const isEmptyContent = null == content || false === content || 'string' == typeof content && '' === content.trim();
|
|
106
|
+
if (isEmptyContent) return children;
|
|
105
107
|
const tooltip = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(tooltip_namespaceObject.Tooltip, {
|
|
106
108
|
open: effectiveOpen,
|
|
107
109
|
onOpenChange: handleOpenChange,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PropsWithChildren, type ReactNode } from 'react';
|
|
1
|
+
import React, { type PropsWithChildren, type ReactNode } from 'react';
|
|
2
2
|
export declare function CanvasTooltipProviderMarker({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
type TooltipPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
4
4
|
interface CanvasTooltipProps extends PropsWithChildren {
|
|
@@ -9,6 +9,6 @@ interface CanvasTooltipProps extends PropsWithChildren {
|
|
|
9
9
|
isOpen?: boolean;
|
|
10
10
|
hide?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export declare function CanvasTooltip({ content, placement, smartTooltip, delay, isOpen, hide, children, }: Readonly<CanvasTooltipProps>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function CanvasTooltip({ content, placement, smartTooltip, delay, isOpen, hide, children, }: Readonly<CanvasTooltipProps>): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
|
|
13
13
|
export type { CanvasTooltipProps };
|
|
14
14
|
//# sourceMappingURL=CanvasTooltip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasTooltip.d.ts","sourceRoot":"","sources":["../../../src/canvas/components/CanvasTooltip.tsx"],"names":[],"mappings":"AAOA,
|
|
1
|
+
{"version":3,"file":"CanvasTooltip.d.ts","sourceRoot":"","sources":["../../../src/canvas/components/CanvasTooltip.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,EAEZ,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AASf,wBAAgB,2BAA2B,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,2CAI1E;AAED,KAAK,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5D,UAAU,kBAAmB,SAAQ,iBAAiB;IAEpD,OAAO,EAAE,SAAS,CAAC;IAEnB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAE7B,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AASD,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,SAAiB,EACjB,YAAoB,EACpB,KAAa,EACb,MAAM,EACN,IAAI,EACJ,QAAQ,GACT,EAAE,QAAQ,CAAC,kBAAkB,CAAC,yTAkG9B;AAED,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -63,6 +63,8 @@ function CanvasTooltip({ content, placement = 'top', smartTooltip = false, delay
|
|
|
63
63
|
]);
|
|
64
64
|
const effectiveOpen = isTooltipHidden ? false : isOpen ?? hoverOpen;
|
|
65
65
|
const hasProvider = useContext(HasTooltipProviderContext);
|
|
66
|
+
const isEmptyContent = null == content || false === content || 'string' == typeof content && '' === content.trim();
|
|
67
|
+
if (isEmptyContent) return children;
|
|
66
68
|
const tooltip = /*#__PURE__*/ jsxs(Tooltip, {
|
|
67
69
|
open: effectiveOpen,
|
|
68
70
|
onOpenChange: handleOpenChange,
|
|
@@ -35,14 +35,22 @@ const external_react_namespaceObject = require("react");
|
|
|
35
35
|
const CanvasThemeContext_cjs_namespaceObject = require("../BaseCanvas/CanvasThemeContext.cjs");
|
|
36
36
|
const external_CanvasTooltip_cjs_namespaceObject = require("../CanvasTooltip.cjs");
|
|
37
37
|
const external_ListView_styles_cjs_namespaceObject = require("./ListView.styles.cjs");
|
|
38
|
-
|
|
38
|
+
const DEFAULT_SKELETON_COUNT = 3;
|
|
39
|
+
function buildRenderedItems(items, enableSections, loadingSkeleton) {
|
|
39
40
|
const result = [];
|
|
40
|
-
|
|
41
|
+
const skeletonConfig = 'object' == typeof loadingSkeleton ? loadingSkeleton : loadingSkeleton ? {} : void 0;
|
|
42
|
+
const baseSkeletonCount = skeletonConfig?.count ?? DEFAULT_SKELETON_COUNT;
|
|
43
|
+
const pushSkeletons = (count)=>{
|
|
44
|
+
for(let i = 0; i < count; i++)result.push({
|
|
45
|
+
type: 'skeleton'
|
|
46
|
+
});
|
|
47
|
+
};
|
|
41
48
|
if (!enableSections) {
|
|
42
49
|
for (const item of items)result.push({
|
|
43
50
|
type: 'item',
|
|
44
51
|
item
|
|
45
52
|
});
|
|
53
|
+
if (skeletonConfig && !skeletonConfig.sections) pushSkeletons(baseSkeletonCount);
|
|
46
54
|
return result;
|
|
47
55
|
}
|
|
48
56
|
const [itemsWithSection, itemsWithoutSection] = (0, external_utils_index_cjs_namespaceObject.partition)(items, (item)=>!!item.section);
|
|
@@ -50,18 +58,36 @@ function buildRenderedItems(items, enableSections) {
|
|
|
50
58
|
type: 'item',
|
|
51
59
|
item
|
|
52
60
|
});
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
61
|
+
const itemsBySection = new Map();
|
|
62
|
+
for (const item of itemsWithSection){
|
|
63
|
+
const name = item.section;
|
|
64
|
+
const bucket = itemsBySection.get(name);
|
|
65
|
+
if (bucket) bucket.push(item);
|
|
66
|
+
else itemsBySection.set(name, [
|
|
67
|
+
item
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
const skeletonBySection = new Map(skeletonConfig?.sections?.map((s)=>[
|
|
71
|
+
s.name,
|
|
72
|
+
s
|
|
73
|
+
]) ?? []);
|
|
74
|
+
const sectionNames = [
|
|
75
|
+
...itemsBySection.keys()
|
|
76
|
+
];
|
|
77
|
+
for (const s of skeletonConfig?.sections ?? [])if (!itemsBySection.has(s.name)) sectionNames.push(s.name);
|
|
78
|
+
for (const sectionName of sectionNames){
|
|
56
79
|
result.push({
|
|
57
80
|
type: 'section',
|
|
58
|
-
sectionName
|
|
81
|
+
sectionName
|
|
59
82
|
});
|
|
60
|
-
for (const item of
|
|
83
|
+
for (const item of itemsBySection.get(sectionName) ?? [])result.push({
|
|
61
84
|
type: 'item',
|
|
62
85
|
item
|
|
63
86
|
});
|
|
87
|
+
const skeletonForSection = skeletonBySection.get(sectionName);
|
|
88
|
+
if (skeletonForSection) pushSkeletons(skeletonForSection.count ?? baseSkeletonCount);
|
|
64
89
|
}
|
|
90
|
+
if (skeletonConfig && !skeletonConfig.sections) pushSkeletons(baseSkeletonCount);
|
|
65
91
|
return result;
|
|
66
92
|
}
|
|
67
93
|
const IconContainerMemoized = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(external_ListView_styles_cjs_namespaceObject.IconContainer);
|
|
@@ -100,6 +126,10 @@ const ListViewRow = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ in
|
|
|
100
126
|
children: renderItem.sectionName
|
|
101
127
|
})
|
|
102
128
|
});
|
|
129
|
+
if ('skeleton' === renderItem.type) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
130
|
+
style: style,
|
|
131
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ListItemSkeleton, {})
|
|
132
|
+
});
|
|
103
133
|
const item = renderItem.item;
|
|
104
134
|
const bgColor = isDarkMode ? item.colorDark ?? item.color : item.color;
|
|
105
135
|
const isActive = index === activeIndex;
|
|
@@ -167,11 +197,35 @@ const ListViewRow = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ in
|
|
|
167
197
|
]
|
|
168
198
|
});
|
|
169
199
|
});
|
|
170
|
-
const
|
|
200
|
+
const ListItemSkeleton = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
201
|
+
className: "flex items-center gap-2.5 h-8",
|
|
202
|
+
role: "presentation",
|
|
203
|
+
"aria-hidden": "true",
|
|
204
|
+
"data-testid": "list-item-skeleton",
|
|
205
|
+
children: [
|
|
206
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.Skeleton, {
|
|
207
|
+
className: "h-8 w-8 shrink-0 rounded-lg"
|
|
208
|
+
}),
|
|
209
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
210
|
+
className: "flex-1 space-y-1.5 min-w-0",
|
|
211
|
+
children: [
|
|
212
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.Skeleton, {
|
|
213
|
+
className: "h-3.5 w-1/3"
|
|
214
|
+
}),
|
|
215
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.Skeleton, {
|
|
216
|
+
className: "h-3 w-2/3"
|
|
217
|
+
})
|
|
218
|
+
]
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
});
|
|
222
|
+
const ListViewInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)(function({ items, activeIndex = -1, listRef, onItemClick, onItemHover, onScroll, emptyStateMessage = 'No items found', emptyStateIcon = 'search-x', isLoading = false, enableSections = true, loadingSkeleton }, ref) {
|
|
171
223
|
const { isDarkMode } = (0, CanvasThemeContext_cjs_namespaceObject.useCanvasTheme)();
|
|
172
|
-
const
|
|
224
|
+
const activeSkeleton = loadingSkeleton ?? (isLoading && 0 === items.length ? true : void 0);
|
|
225
|
+
const renderedItems = (0, external_react_namespaceObject.useMemo)(()=>buildRenderedItems(items, enableSections, activeSkeleton), [
|
|
173
226
|
items,
|
|
174
|
-
enableSections
|
|
227
|
+
enableSections,
|
|
228
|
+
activeSkeleton
|
|
175
229
|
]);
|
|
176
230
|
(0, external_react_namespaceObject.useImperativeHandle)(ref, ()=>({
|
|
177
231
|
renderedItems
|
|
@@ -193,15 +247,7 @@ const ListViewInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRe
|
|
|
193
247
|
onItemClick,
|
|
194
248
|
onItemHover
|
|
195
249
|
]);
|
|
196
|
-
if (
|
|
197
|
-
gap: 8,
|
|
198
|
-
children: [
|
|
199
|
-
...Array(3)
|
|
200
|
-
].map((_, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.Skeleton, {
|
|
201
|
-
className: "h-8 w-full"
|
|
202
|
-
}, index))
|
|
203
|
-
});
|
|
204
|
-
if (0 === items.length) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(index_cjs_namespaceObject.Column, {
|
|
250
|
+
if (0 === renderedItems.length) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(index_cjs_namespaceObject.Column, {
|
|
205
251
|
align: "center",
|
|
206
252
|
justify: "center",
|
|
207
253
|
flex: 1,
|
|
@@ -224,6 +270,7 @@ const ListViewInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRe
|
|
|
224
270
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ListView_styles_cjs_namespaceObject.StyledList, {
|
|
225
271
|
id: "toolbox-listbox",
|
|
226
272
|
role: "listbox",
|
|
273
|
+
"aria-busy": activeSkeleton ? true : void 0,
|
|
227
274
|
listRef: listRef,
|
|
228
275
|
rowProps: rowProps,
|
|
229
276
|
rowComponent: ListViewRow,
|
|
@@ -4,6 +4,13 @@ export interface ListItemIcon {
|
|
|
4
4
|
url?: string;
|
|
5
5
|
Component?: React.ComponentType;
|
|
6
6
|
}
|
|
7
|
+
export type ChildrenLoadingSpec = {
|
|
8
|
+
count?: number;
|
|
9
|
+
sections?: {
|
|
10
|
+
name: string;
|
|
11
|
+
count?: number;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
7
14
|
export type ListItem<T = any> = {
|
|
8
15
|
id: string;
|
|
9
16
|
name: string;
|
|
@@ -14,6 +21,7 @@ export type ListItem<T = any> = {
|
|
|
14
21
|
color?: string;
|
|
15
22
|
colorDark?: string;
|
|
16
23
|
children?: ListItem<T>[] | ((id: string, name: string) => Promise<ListItem<T>[]>);
|
|
24
|
+
childrenLoading?: boolean | ChildrenLoadingSpec;
|
|
17
25
|
};
|
|
18
26
|
export type RenderItem<T extends ListItem> = {
|
|
19
27
|
type: 'section';
|
|
@@ -21,8 +29,10 @@ export type RenderItem<T extends ListItem> = {
|
|
|
21
29
|
} | {
|
|
22
30
|
type: 'item';
|
|
23
31
|
item: T;
|
|
32
|
+
} | {
|
|
33
|
+
type: 'skeleton';
|
|
24
34
|
};
|
|
25
|
-
export declare function buildRenderedItems<T extends ListItem>(items: T[], enableSections: boolean): RenderItem<T>[];
|
|
35
|
+
export declare function buildRenderedItems<T extends ListItem>(items: T[], enableSections: boolean, loadingSkeleton?: boolean | ChildrenLoadingSpec): RenderItem<T>[];
|
|
26
36
|
export interface ListViewRowProps<T extends ListItem> {
|
|
27
37
|
renderedItems: RenderItem<T>[];
|
|
28
38
|
activeIndex: number;
|
|
@@ -45,6 +55,7 @@ interface ListViewProps<T extends ListItem> {
|
|
|
45
55
|
emptyStateIcon?: string;
|
|
46
56
|
isLoading?: boolean;
|
|
47
57
|
enableSections?: boolean;
|
|
58
|
+
loadingSkeleton?: boolean | ChildrenLoadingSpec;
|
|
48
59
|
}
|
|
49
60
|
export declare const ListView: <T extends ListItem>(props: ListViewProps<T> & {
|
|
50
61
|
ref?: React.Ref<ListViewHandle<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/ListView.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,cAAc,CAAC;AAKzE,MAAM,WAAW,YAAY;IAI3B,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,GAAG,CAAC,EAAE,MAAM,CAAC;IAIb,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACjC;
|
|
1
|
+
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/ListView.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,cAAc,CAAC;AAKzE,MAAM,WAAW,YAAY;IAI3B,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,GAAG,CAAC,EAAE,MAAM,CAAC;IAIb,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACjC;AAUD,MAAM,MAAM,mBAAmB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C,CAAA;CAAE,KAC7D,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC"}
|
|
@@ -6,14 +6,22 @@ import { forwardRef, memo, useCallback, useImperativeHandle, useMemo } from "rea
|
|
|
6
6
|
import { useCanvasTheme } from "../BaseCanvas/CanvasThemeContext.js";
|
|
7
7
|
import { CanvasTooltip } from "../CanvasTooltip.js";
|
|
8
8
|
import { IconContainer, ListItemButton, SectionHeader, StyledList } from "./ListView.styles.js";
|
|
9
|
-
|
|
9
|
+
const DEFAULT_SKELETON_COUNT = 3;
|
|
10
|
+
function buildRenderedItems(items, enableSections, loadingSkeleton) {
|
|
10
11
|
const result = [];
|
|
11
|
-
|
|
12
|
+
const skeletonConfig = 'object' == typeof loadingSkeleton ? loadingSkeleton : loadingSkeleton ? {} : void 0;
|
|
13
|
+
const baseSkeletonCount = skeletonConfig?.count ?? DEFAULT_SKELETON_COUNT;
|
|
14
|
+
const pushSkeletons = (count)=>{
|
|
15
|
+
for(let i = 0; i < count; i++)result.push({
|
|
16
|
+
type: 'skeleton'
|
|
17
|
+
});
|
|
18
|
+
};
|
|
12
19
|
if (!enableSections) {
|
|
13
20
|
for (const item of items)result.push({
|
|
14
21
|
type: 'item',
|
|
15
22
|
item
|
|
16
23
|
});
|
|
24
|
+
if (skeletonConfig && !skeletonConfig.sections) pushSkeletons(baseSkeletonCount);
|
|
17
25
|
return result;
|
|
18
26
|
}
|
|
19
27
|
const [itemsWithSection, itemsWithoutSection] = partition(items, (item)=>!!item.section);
|
|
@@ -21,18 +29,36 @@ function buildRenderedItems(items, enableSections) {
|
|
|
21
29
|
type: 'item',
|
|
22
30
|
item
|
|
23
31
|
});
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
32
|
+
const itemsBySection = new Map();
|
|
33
|
+
for (const item of itemsWithSection){
|
|
34
|
+
const name = item.section;
|
|
35
|
+
const bucket = itemsBySection.get(name);
|
|
36
|
+
if (bucket) bucket.push(item);
|
|
37
|
+
else itemsBySection.set(name, [
|
|
38
|
+
item
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
const skeletonBySection = new Map(skeletonConfig?.sections?.map((s)=>[
|
|
42
|
+
s.name,
|
|
43
|
+
s
|
|
44
|
+
]) ?? []);
|
|
45
|
+
const sectionNames = [
|
|
46
|
+
...itemsBySection.keys()
|
|
47
|
+
];
|
|
48
|
+
for (const s of skeletonConfig?.sections ?? [])if (!itemsBySection.has(s.name)) sectionNames.push(s.name);
|
|
49
|
+
for (const sectionName of sectionNames){
|
|
27
50
|
result.push({
|
|
28
51
|
type: 'section',
|
|
29
|
-
sectionName
|
|
52
|
+
sectionName
|
|
30
53
|
});
|
|
31
|
-
for (const item of
|
|
54
|
+
for (const item of itemsBySection.get(sectionName) ?? [])result.push({
|
|
32
55
|
type: 'item',
|
|
33
56
|
item
|
|
34
57
|
});
|
|
58
|
+
const skeletonForSection = skeletonBySection.get(sectionName);
|
|
59
|
+
if (skeletonForSection) pushSkeletons(skeletonForSection.count ?? baseSkeletonCount);
|
|
35
60
|
}
|
|
61
|
+
if (skeletonConfig && !skeletonConfig.sections) pushSkeletons(baseSkeletonCount);
|
|
36
62
|
return result;
|
|
37
63
|
}
|
|
38
64
|
const IconContainerMemoized = /*#__PURE__*/ memo(IconContainer);
|
|
@@ -71,6 +97,10 @@ const ListViewRow = /*#__PURE__*/ memo(({ index, style, ariaAttributes, rendered
|
|
|
71
97
|
children: renderItem.sectionName
|
|
72
98
|
})
|
|
73
99
|
});
|
|
100
|
+
if ('skeleton' === renderItem.type) return /*#__PURE__*/ jsx("div", {
|
|
101
|
+
style: style,
|
|
102
|
+
children: /*#__PURE__*/ jsx(ListItemSkeleton, {})
|
|
103
|
+
});
|
|
74
104
|
const item = renderItem.item;
|
|
75
105
|
const bgColor = isDarkMode ? item.colorDark ?? item.color : item.color;
|
|
76
106
|
const isActive = index === activeIndex;
|
|
@@ -138,11 +168,35 @@ const ListViewRow = /*#__PURE__*/ memo(({ index, style, ariaAttributes, rendered
|
|
|
138
168
|
]
|
|
139
169
|
});
|
|
140
170
|
});
|
|
141
|
-
const
|
|
171
|
+
const ListItemSkeleton = ()=>/*#__PURE__*/ jsxs("div", {
|
|
172
|
+
className: "flex items-center gap-2.5 h-8",
|
|
173
|
+
role: "presentation",
|
|
174
|
+
"aria-hidden": "true",
|
|
175
|
+
"data-testid": "list-item-skeleton",
|
|
176
|
+
children: [
|
|
177
|
+
/*#__PURE__*/ jsx(Skeleton, {
|
|
178
|
+
className: "h-8 w-8 shrink-0 rounded-lg"
|
|
179
|
+
}),
|
|
180
|
+
/*#__PURE__*/ jsxs("div", {
|
|
181
|
+
className: "flex-1 space-y-1.5 min-w-0",
|
|
182
|
+
children: [
|
|
183
|
+
/*#__PURE__*/ jsx(Skeleton, {
|
|
184
|
+
className: "h-3.5 w-1/3"
|
|
185
|
+
}),
|
|
186
|
+
/*#__PURE__*/ jsx(Skeleton, {
|
|
187
|
+
className: "h-3 w-2/3"
|
|
188
|
+
})
|
|
189
|
+
]
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
});
|
|
193
|
+
const ListViewInner = /*#__PURE__*/ forwardRef(function({ items, activeIndex = -1, listRef, onItemClick, onItemHover, onScroll, emptyStateMessage = 'No items found', emptyStateIcon = 'search-x', isLoading = false, enableSections = true, loadingSkeleton }, ref) {
|
|
142
194
|
const { isDarkMode } = useCanvasTheme();
|
|
143
|
-
const
|
|
195
|
+
const activeSkeleton = loadingSkeleton ?? (isLoading && 0 === items.length ? true : void 0);
|
|
196
|
+
const renderedItems = useMemo(()=>buildRenderedItems(items, enableSections, activeSkeleton), [
|
|
144
197
|
items,
|
|
145
|
-
enableSections
|
|
198
|
+
enableSections,
|
|
199
|
+
activeSkeleton
|
|
146
200
|
]);
|
|
147
201
|
useImperativeHandle(ref, ()=>({
|
|
148
202
|
renderedItems
|
|
@@ -164,15 +218,7 @@ const ListViewInner = /*#__PURE__*/ forwardRef(function({ items, activeIndex = -
|
|
|
164
218
|
onItemClick,
|
|
165
219
|
onItemHover
|
|
166
220
|
]);
|
|
167
|
-
if (
|
|
168
|
-
gap: 8,
|
|
169
|
-
children: [
|
|
170
|
-
...Array(3)
|
|
171
|
-
].map((_, index)=>/*#__PURE__*/ jsx(Skeleton, {
|
|
172
|
-
className: "h-8 w-full"
|
|
173
|
-
}, index))
|
|
174
|
-
});
|
|
175
|
-
if (0 === items.length) return /*#__PURE__*/ jsxs(Column, {
|
|
221
|
+
if (0 === renderedItems.length) return /*#__PURE__*/ jsxs(Column, {
|
|
176
222
|
align: "center",
|
|
177
223
|
justify: "center",
|
|
178
224
|
flex: 1,
|
|
@@ -195,6 +241,7 @@ const ListViewInner = /*#__PURE__*/ forwardRef(function({ items, activeIndex = -
|
|
|
195
241
|
return /*#__PURE__*/ jsx(StyledList, {
|
|
196
242
|
id: "toolbox-listbox",
|
|
197
243
|
role: "listbox",
|
|
244
|
+
"aria-busy": activeSkeleton ? true : void 0,
|
|
198
245
|
listRef: listRef,
|
|
199
246
|
rowProps: rowProps,
|
|
200
247
|
rowComponent: ListViewRow,
|
|
@@ -84,7 +84,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
84
84
|
const [items, setItems] = (0, external_react_namespaceObject.useState)(initialItems);
|
|
85
85
|
const [search, setSearch] = (0, external_react_namespaceObject.useState)('');
|
|
86
86
|
const [searchLoading, setSearchLoading] = (0, external_react_namespaceObject.useState)(false);
|
|
87
|
-
const [
|
|
87
|
+
const [awaitingChildren, setAwaitingChildren] = (0, external_react_namespaceObject.useState)(false);
|
|
88
88
|
const [isSearchingInitialItems, setIsSearchingInitialItems] = (0, external_react_namespaceObject.useState)(true);
|
|
89
89
|
const [searchedItems, setSearchedItems] = (0, external_react_namespaceObject.useState)([]);
|
|
90
90
|
const [currentParentItem, setCurrentParentItem] = (0, external_react_namespaceObject.useState)(null);
|
|
@@ -206,7 +206,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
206
206
|
]);
|
|
207
207
|
const handleItemSelect = (0, external_react_namespaceObject.useCallback)(async (item, index)=>{
|
|
208
208
|
if (!item.children) return void onItemSelect(item);
|
|
209
|
-
|
|
209
|
+
setAwaitingChildren(true);
|
|
210
210
|
const nestedItems = 'function' == typeof item.children ? await item.children(item.id, item.name) : item.children;
|
|
211
211
|
const savedIndex = isSearching ? SEARCH_BAR_INDEX : index ?? activeIndex;
|
|
212
212
|
const savedScrollTop = isSearching ? 0 : lastScrollTopRef.current;
|
|
@@ -229,7 +229,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
229
229
|
lastScrollTopRef.current = 0;
|
|
230
230
|
});
|
|
231
231
|
startTransition('forward');
|
|
232
|
-
|
|
232
|
+
setAwaitingChildren(false);
|
|
233
233
|
}, [
|
|
234
234
|
navigationStack,
|
|
235
235
|
currentParentItem,
|
|
@@ -446,7 +446,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
446
446
|
direction: animationDirection,
|
|
447
447
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ListView_cjs_namespaceObject.ListView, {
|
|
448
448
|
ref: listViewRef,
|
|
449
|
-
isLoading:
|
|
449
|
+
isLoading: awaitingChildren || searchLoading || loading,
|
|
450
450
|
items: displayedItems,
|
|
451
451
|
activeIndex: activeIndex,
|
|
452
452
|
listRef: listRef,
|
|
@@ -454,7 +454,8 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
454
454
|
onItemClick: handleItemSelect,
|
|
455
455
|
onItemHover: onItemHover,
|
|
456
456
|
onScroll: handleListScroll,
|
|
457
|
-
enableSections: !isSearching
|
|
457
|
+
enableSections: !isSearching,
|
|
458
|
+
loadingSkeleton: isSearching ? void 0 : currentParentItem?.childrenLoading
|
|
458
459
|
})
|
|
459
460
|
})
|
|
460
461
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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fjB"}
|
|
@@ -56,7 +56,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
56
56
|
const [items, setItems] = useState(initialItems);
|
|
57
57
|
const [search, setSearch] = useState('');
|
|
58
58
|
const [searchLoading, setSearchLoading] = useState(false);
|
|
59
|
-
const [
|
|
59
|
+
const [awaitingChildren, setAwaitingChildren] = useState(false);
|
|
60
60
|
const [isSearchingInitialItems, setIsSearchingInitialItems] = useState(true);
|
|
61
61
|
const [searchedItems, setSearchedItems] = useState([]);
|
|
62
62
|
const [currentParentItem, setCurrentParentItem] = useState(null);
|
|
@@ -178,7 +178,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
178
178
|
]);
|
|
179
179
|
const handleItemSelect = useCallback(async (item, index)=>{
|
|
180
180
|
if (!item.children) return void onItemSelect(item);
|
|
181
|
-
|
|
181
|
+
setAwaitingChildren(true);
|
|
182
182
|
const nestedItems = 'function' == typeof item.children ? await item.children(item.id, item.name) : item.children;
|
|
183
183
|
const savedIndex = isSearching ? SEARCH_BAR_INDEX : index ?? activeIndex;
|
|
184
184
|
const savedScrollTop = isSearching ? 0 : lastScrollTopRef.current;
|
|
@@ -201,7 +201,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
201
201
|
lastScrollTopRef.current = 0;
|
|
202
202
|
});
|
|
203
203
|
startTransition('forward');
|
|
204
|
-
|
|
204
|
+
setAwaitingChildren(false);
|
|
205
205
|
}, [
|
|
206
206
|
navigationStack,
|
|
207
207
|
currentParentItem,
|
|
@@ -418,7 +418,7 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
418
418
|
direction: animationDirection,
|
|
419
419
|
children: /*#__PURE__*/ jsx(ListView, {
|
|
420
420
|
ref: listViewRef,
|
|
421
|
-
isLoading:
|
|
421
|
+
isLoading: awaitingChildren || searchLoading || loading,
|
|
422
422
|
items: displayedItems,
|
|
423
423
|
activeIndex: activeIndex,
|
|
424
424
|
listRef: listRef,
|
|
@@ -426,7 +426,8 @@ function Toolbox({ onClose, onBack, onItemSelect, onSearch, onItemHover, title,
|
|
|
426
426
|
onItemClick: handleItemSelect,
|
|
427
427
|
onItemHover: onItemHover,
|
|
428
428
|
onScroll: handleListScroll,
|
|
429
|
-
enableSections: !isSearching
|
|
429
|
+
enableSections: !isSearching,
|
|
430
|
+
loadingSkeleton: isSearching ? void 0 : currentParentItem?.childrenLoading
|
|
430
431
|
})
|
|
431
432
|
})
|
|
432
433
|
})
|