@uipath/apollo-react 4.16.1 → 4.17.0-pr605.8e85d9c
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/AddNodeManager.cjs +35 -21
- package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.cjs +150 -0
- package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts +20 -0
- package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts.map +1 -0
- package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.js +110 -0
- package/dist/canvas/components/AddNodePanel/AddNodeManager.js +35 -21
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +15 -4
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts +5 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +15 -4
- package/dist/canvas/components/AddNodePanel/index.d.ts +1 -1
- package/dist/canvas/components/AddNodePanel/index.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +23 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +23 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.cjs +0 -14
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.js +2 -16
- package/dist/canvas/components/LoopNode/LoopNode.cjs +25 -19
- package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNode.helpers.cjs +33 -42
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +9 -10
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNode.helpers.js +25 -31
- package/dist/canvas/components/LoopNode/LoopNode.js +17 -11
- package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +17 -4
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNodePreview.js +17 -4
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +25 -14
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +25 -14
- 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/constants.cjs +0 -8
- package/dist/canvas/constants.d.ts +0 -2
- package/dist/canvas/constants.d.ts.map +1 -1
- package/dist/canvas/constants.js +1 -3
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +4 -2
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.d.ts.map +1 -1
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +4 -2
- package/dist/canvas/storybook-utils/hooks/useCanvasStory.d.ts.map +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/canvas/utils/NodeUtils.cjs +26 -10
- package/dist/canvas/utils/NodeUtils.d.ts +7 -0
- package/dist/canvas/utils/NodeUtils.d.ts.map +1 -1
- package/dist/canvas/utils/NodeUtils.js +13 -6
- package/dist/canvas/utils/collapse.cjs +3 -3
- package/dist/canvas/utils/collapse.d.ts.map +1 -1
- package/dist/canvas/utils/collapse.js +1 -1
- package/dist/canvas/utils/container.cjs +642 -0
- package/dist/canvas/utils/container.d.ts +97 -0
- package/dist/canvas/utils/container.d.ts.map +1 -0
- package/dist/canvas/utils/container.js +566 -0
- package/dist/canvas/utils/createPreviewGraph.cjs +13 -17
- package/dist/canvas/utils/createPreviewGraph.d.ts +10 -8
- package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewGraph.js +13 -17
- package/dist/canvas/utils/createPreviewNode.cjs +16 -10
- package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewNode.js +16 -10
- package/dist/canvas/utils/index.cjs +29 -22
- package/dist/canvas/utils/index.d.ts +1 -0
- package/dist/canvas/utils/index.d.ts.map +1 -1
- package/dist/canvas/utils/index.js +1 -0
- package/package.json +3 -3
- package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +0 -56
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +0 -7
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.constants.js +0 -7
|
@@ -2,10 +2,10 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { NodeResizeControl, useStore, useUpdateNodeInternals } from "../../xyflow/react.js";
|
|
3
3
|
import { cn } from "@uipath/apollo-wind";
|
|
4
4
|
import { memo, useCallback, useEffect, useMemo, useState } from "react";
|
|
5
|
-
import { DEFAULT_CONTAINER_HEIGHT, DEFAULT_CONTAINER_WIDTH } from "../../constants.js";
|
|
6
5
|
import { useOptionalNodeTypeRegistry } from "../../core/index.js";
|
|
7
6
|
import { useElementValidationStatus, useNodeExecutionState } from "../../hooks/index.js";
|
|
8
7
|
import { resolveAdornments } from "../../utils/adornment-resolver.js";
|
|
8
|
+
import { DEFAULT_CONTAINER_HEIGHT, DEFAULT_CONTAINER_MIN_HEIGHT, DEFAULT_CONTAINER_MIN_WIDTH, DEFAULT_CONTAINER_WIDTH } from "../../utils/container.js";
|
|
9
9
|
import { CanvasIcon } from "../../utils/icon-registry.js";
|
|
10
10
|
import { resolveDisplay, resolveHandles } from "../../utils/manifest-resolver.js";
|
|
11
11
|
import { selectIsConnecting, snapToGrid } from "../../utils/NodeUtils.js";
|
|
@@ -18,8 +18,9 @@ import { getStatusBorder } from "../BaseNode/BaseNodeContainer.js";
|
|
|
18
18
|
import { MissingManifestNode } from "../BaseNode/BaseNodeMissingManifest.js";
|
|
19
19
|
import { ButtonHandles } from "../ButtonHandle/index.js";
|
|
20
20
|
import { NodeToolbar } from "../Toolbar/index.js";
|
|
21
|
-
import { DEFAULT_CONTAINER_MIN_HEIGHT, DEFAULT_CONTAINER_MIN_WIDTH, DEFAULT_LOOP_ICON, DEFAULT_LOOP_TITLE } from "./LoopNode.constants.js";
|
|
22
21
|
import { resolveContainerHandleGroups } from "./LoopNode.helpers.js";
|
|
22
|
+
const DEFAULT_LOOP_ICON = 'repeat';
|
|
23
|
+
const DEFAULT_LOOP_TITLE = 'Loop';
|
|
23
24
|
const EMPTY_DATA = {};
|
|
24
25
|
const RESIZE_CONTROLS = [
|
|
25
26
|
{
|
|
@@ -186,7 +187,7 @@ function LoopNodeComponent(props) {
|
|
|
186
187
|
]);
|
|
187
188
|
const handleMouseEnter = useCallback(()=>setIsHovered(true), []);
|
|
188
189
|
const handleMouseLeave = useCallback(()=>setIsHovered(false), []);
|
|
189
|
-
const
|
|
190
|
+
const handleHandleAction = useCallback((_event)=>{
|
|
190
191
|
setIsHovered(false);
|
|
191
192
|
}, []);
|
|
192
193
|
const shouldShowHandles = (isConnecting || selected || isHovered) && !dragging;
|
|
@@ -264,7 +265,7 @@ function LoopNodeComponent(props) {
|
|
|
264
265
|
nodeWidth: containerWidth,
|
|
265
266
|
nodeHeight: containerHeight,
|
|
266
267
|
connectedHandleIds: connectedHandleIds,
|
|
267
|
-
|
|
268
|
+
onHandleAction: handleHandleAction
|
|
268
269
|
})
|
|
269
270
|
]
|
|
270
271
|
});
|
|
@@ -376,24 +377,29 @@ function HandleGroups({ groups, ...handleGroupProps }) {
|
|
|
376
377
|
}, `${group.boundary}:${group.position}:${groupIndex}`))
|
|
377
378
|
});
|
|
378
379
|
}
|
|
379
|
-
function HandleGroup({ nodeId, group, selected, hovered, shouldShowHandles, showAddButton, showNotches, nodeWidth, nodeHeight, connectedHandleIds,
|
|
380
|
+
function HandleGroup({ nodeId, group, selected, hovered, shouldShowHandles, showAddButton, showNotches, nodeWidth, nodeHeight, connectedHandleIds, onHandleAction }) {
|
|
380
381
|
const groupVisible = shouldShowHandles && (group.visible ?? true);
|
|
381
382
|
const position = group.position;
|
|
382
383
|
const enhancedHandles = useMemo(()=>group.handles.map((handle)=>{
|
|
383
|
-
const
|
|
384
|
-
|
|
384
|
+
const showHandle = connectedHandleIds.has(handle.id) || groupVisible;
|
|
385
|
+
if ('inner' === group.boundary) return {
|
|
386
|
+
...handle,
|
|
387
|
+
showHandle,
|
|
388
|
+
showButton: false,
|
|
389
|
+
onAction: void 0
|
|
390
|
+
};
|
|
385
391
|
return {
|
|
386
392
|
...handle,
|
|
387
|
-
showHandle
|
|
388
|
-
showButton:
|
|
389
|
-
onAction: handle.onAction ??
|
|
393
|
+
showHandle,
|
|
394
|
+
showButton: handle.showButton,
|
|
395
|
+
onAction: handle.onAction ?? onHandleAction
|
|
390
396
|
};
|
|
391
397
|
}), [
|
|
392
398
|
group.boundary,
|
|
393
399
|
group.handles,
|
|
394
400
|
connectedHandleIds,
|
|
395
401
|
groupVisible,
|
|
396
|
-
|
|
402
|
+
onHandleAction
|
|
397
403
|
]);
|
|
398
404
|
return /*#__PURE__*/ jsx(ButtonHandles, {
|
|
399
405
|
nodeId: nodeId,
|
|
@@ -39,15 +39,28 @@ function showCenteredContainerPreview({ containerId, reactFlowInstance, previewH
|
|
|
39
39
|
x: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(containerAbsolutePosition.x + relativeCenter.x),
|
|
40
40
|
y: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(containerAbsolutePosition.y + relativeCenter.y)
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
const placement = {
|
|
43
|
+
containerId,
|
|
43
44
|
sourceNodeId: containerId,
|
|
44
|
-
|
|
45
|
+
targetNodeId: containerId,
|
|
46
|
+
mode: 'first-child'
|
|
47
|
+
};
|
|
48
|
+
(0, createPreviewGraph_cjs_namespaceObject.showPreviewGraph)({
|
|
49
|
+
source: {
|
|
50
|
+
nodeId: containerId,
|
|
51
|
+
handleId: previewHandles.sourceHandleId
|
|
52
|
+
},
|
|
45
53
|
reactFlowInstance,
|
|
46
54
|
position: previewCenter,
|
|
47
55
|
positionMode: 'center',
|
|
48
56
|
handlePosition: previewHandles.sourceHandlePosition,
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
target: {
|
|
58
|
+
nodeId: containerId,
|
|
59
|
+
handleId: previewHandles.targetHandleId
|
|
60
|
+
},
|
|
61
|
+
data: {
|
|
62
|
+
placement
|
|
63
|
+
},
|
|
51
64
|
containerId,
|
|
52
65
|
trailingEdgeId
|
|
53
66
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoopNodePreview.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNodePreview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"LoopNodePreview.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNodePreview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAIlF,OAAO,EACL,KAAK,iCAAiC,EAEvC,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,4BAA4B,CAAC,EAC3C,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,cAAc,EAAE,iCAAiC,CAAC;IAClD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,QAmCA"}
|
|
@@ -11,15 +11,28 @@ function showCenteredContainerPreview({ containerId, reactFlowInstance, previewH
|
|
|
11
11
|
x: snapToGrid(containerAbsolutePosition.x + relativeCenter.x),
|
|
12
12
|
y: snapToGrid(containerAbsolutePosition.y + relativeCenter.y)
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
const placement = {
|
|
15
|
+
containerId,
|
|
15
16
|
sourceNodeId: containerId,
|
|
16
|
-
|
|
17
|
+
targetNodeId: containerId,
|
|
18
|
+
mode: 'first-child'
|
|
19
|
+
};
|
|
20
|
+
showPreviewGraph({
|
|
21
|
+
source: {
|
|
22
|
+
nodeId: containerId,
|
|
23
|
+
handleId: previewHandles.sourceHandleId
|
|
24
|
+
},
|
|
17
25
|
reactFlowInstance,
|
|
18
26
|
position: previewCenter,
|
|
19
27
|
positionMode: 'center',
|
|
20
28
|
handlePosition: previewHandles.sourceHandlePosition,
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
target: {
|
|
30
|
+
nodeId: containerId,
|
|
31
|
+
handleId: previewHandles.targetHandleId
|
|
32
|
+
},
|
|
33
|
+
data: {
|
|
34
|
+
placement
|
|
35
|
+
},
|
|
23
36
|
containerId,
|
|
24
37
|
trailingEdgeId
|
|
25
38
|
});
|
|
@@ -29,14 +29,20 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
const react_cjs_namespaceObject = require("../../../xyflow/react.cjs");
|
|
30
30
|
const external_react_namespaceObject = require("react");
|
|
31
31
|
const external_constants_cjs_namespaceObject = require("../../../constants.cjs");
|
|
32
|
+
const index_cjs_namespaceObject = require("../../../core/index.cjs");
|
|
32
33
|
const createPreviewGraph_cjs_namespaceObject = require("../../../utils/createPreviewGraph.cjs");
|
|
33
34
|
const createPreviewNode_cjs_namespaceObject = require("../../../utils/createPreviewNode.cjs");
|
|
34
35
|
const BaseCanvasModeProvider_cjs_namespaceObject = require("../../BaseCanvas/BaseCanvasModeProvider.cjs");
|
|
36
|
+
const LoopNode_helpers_cjs_namespaceObject = require("../../LoopNode/LoopNode.helpers.cjs");
|
|
35
37
|
const external_useEdgeToolbarPositioning_cjs_namespaceObject = require("./useEdgeToolbarPositioning.cjs");
|
|
36
38
|
function useEdgeToolbarState({ edgeId, pathElementRef, isHovered, source, target, sourceHandleId, targetHandleId, sourcePosition, targetPosition, ignoredNodeTypes }) {
|
|
37
39
|
const reactFlow = (0, react_cjs_namespaceObject.useReactFlow)();
|
|
40
|
+
const registry = (0, index_cjs_namespaceObject.useOptionalNodeTypeRegistry)();
|
|
38
41
|
const { mode } = (0, BaseCanvasModeProvider_cjs_namespaceObject.useBaseCanvasMode)();
|
|
39
42
|
const isDesignMode = 'design' === mode;
|
|
43
|
+
const getManifestForNode = (0, external_react_namespaceObject.useCallback)((node)=>node.type ? registry?.getManifest(node.type) : void 0, [
|
|
44
|
+
registry
|
|
45
|
+
]);
|
|
40
46
|
const previewEdge = (0, createPreviewNode_cjs_namespaceObject.isPreviewEdge)({
|
|
41
47
|
id: edgeId,
|
|
42
48
|
source,
|
|
@@ -48,36 +54,41 @@ function useEdgeToolbarState({ edgeId, pathElementRef, isHovered, source, target
|
|
|
48
54
|
targetPosition
|
|
49
55
|
});
|
|
50
56
|
const handleAddNodeOnEdge = (0, external_react_namespaceObject.useCallback)((position)=>{
|
|
51
|
-
const originalEdge =
|
|
52
|
-
|
|
53
|
-
source,
|
|
54
|
-
|
|
55
|
-
target,
|
|
56
|
-
targetHandle: targetHandleId,
|
|
57
|
-
type: 'default'
|
|
57
|
+
const originalEdge = reactFlow.getEdges().find((edge)=>edge.id === edgeId);
|
|
58
|
+
const sourceEndpoint = {
|
|
59
|
+
nodeId: source,
|
|
60
|
+
handleId: sourceHandleId ?? external_constants_cjs_namespaceObject.DEFAULT_SOURCE_HANDLE_ID
|
|
58
61
|
};
|
|
62
|
+
const containerOverrides = registry ? (0, LoopNode_helpers_cjs_namespaceObject.resolveContainerAddNodePreview)({
|
|
63
|
+
source: sourceEndpoint,
|
|
64
|
+
sourceHandleType: 'source',
|
|
65
|
+
reactFlowInstance: reactFlow,
|
|
66
|
+
getManifestForNode
|
|
67
|
+
}) : null;
|
|
59
68
|
(0, createPreviewGraph_cjs_namespaceObject.showPreviewGraph)({
|
|
60
|
-
|
|
61
|
-
sourceHandleId: sourceHandleId ?? external_constants_cjs_namespaceObject.DEFAULT_SOURCE_HANDLE_ID,
|
|
69
|
+
source: sourceEndpoint,
|
|
62
70
|
reactFlowInstance: reactFlow,
|
|
63
71
|
position,
|
|
72
|
+
positionMode: 'drop',
|
|
64
73
|
data: {
|
|
65
74
|
originalEdge
|
|
66
75
|
},
|
|
67
76
|
sourceHandleType: 'source',
|
|
68
77
|
handlePosition: sourcePosition,
|
|
69
78
|
ignoredNodeTypes: ignoredNodeTypes ?? [],
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
target: {
|
|
80
|
+
nodeId: target,
|
|
81
|
+
handleId: targetHandleId
|
|
82
|
+
},
|
|
83
|
+
...containerOverrides ?? {}
|
|
75
84
|
});
|
|
76
85
|
}, [
|
|
77
86
|
sourcePosition,
|
|
78
87
|
source,
|
|
79
88
|
sourceHandleId,
|
|
80
89
|
reactFlow,
|
|
90
|
+
registry,
|
|
91
|
+
getManifestForNode,
|
|
81
92
|
target,
|
|
82
93
|
targetHandleId,
|
|
83
94
|
edgeId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEdgeToolbarState.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,QAAQ,EAAgB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"useEdgeToolbarState.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,QAAQ,EAAgB,MAAM,0CAA0C,CAAC;AAQlG,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAGtF,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,KAAK,CAAC,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC9D,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACnD,MAAM,EAAE,iBAAiB,CAAC;IAC1B,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CAC3D;AAED,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,cAAc,EACd,SAAS,EACT,MAAM,EACN,MAAM,EACN,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,GACjB,EAAE,wBAAwB,GAAG,gBAAgB,CA6F7C"}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { useReactFlow } from "../../../xyflow/react.js";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
3
|
import { DEFAULT_SOURCE_HANDLE_ID } from "../../../constants.js";
|
|
4
|
+
import { useOptionalNodeTypeRegistry } from "../../../core/index.js";
|
|
4
5
|
import { showPreviewGraph } from "../../../utils/createPreviewGraph.js";
|
|
5
6
|
import { isPreviewEdge } from "../../../utils/createPreviewNode.js";
|
|
6
7
|
import { useBaseCanvasMode } from "../../BaseCanvas/BaseCanvasModeProvider.js";
|
|
8
|
+
import { resolveContainerAddNodePreview } from "../../LoopNode/LoopNode.helpers.js";
|
|
7
9
|
import { useEdgeToolbarPositioning } from "./useEdgeToolbarPositioning.js";
|
|
8
10
|
function useEdgeToolbarState({ edgeId, pathElementRef, isHovered, source, target, sourceHandleId, targetHandleId, sourcePosition, targetPosition, ignoredNodeTypes }) {
|
|
9
11
|
const reactFlow = useReactFlow();
|
|
12
|
+
const registry = useOptionalNodeTypeRegistry();
|
|
10
13
|
const { mode } = useBaseCanvasMode();
|
|
11
14
|
const isDesignMode = 'design' === mode;
|
|
15
|
+
const getManifestForNode = useCallback((node)=>node.type ? registry?.getManifest(node.type) : void 0, [
|
|
16
|
+
registry
|
|
17
|
+
]);
|
|
12
18
|
const previewEdge = isPreviewEdge({
|
|
13
19
|
id: edgeId,
|
|
14
20
|
source,
|
|
@@ -20,36 +26,41 @@ function useEdgeToolbarState({ edgeId, pathElementRef, isHovered, source, target
|
|
|
20
26
|
targetPosition
|
|
21
27
|
});
|
|
22
28
|
const handleAddNodeOnEdge = useCallback((position)=>{
|
|
23
|
-
const originalEdge =
|
|
24
|
-
|
|
25
|
-
source,
|
|
26
|
-
|
|
27
|
-
target,
|
|
28
|
-
targetHandle: targetHandleId,
|
|
29
|
-
type: 'default'
|
|
29
|
+
const originalEdge = reactFlow.getEdges().find((edge)=>edge.id === edgeId);
|
|
30
|
+
const sourceEndpoint = {
|
|
31
|
+
nodeId: source,
|
|
32
|
+
handleId: sourceHandleId ?? DEFAULT_SOURCE_HANDLE_ID
|
|
30
33
|
};
|
|
34
|
+
const containerOverrides = registry ? resolveContainerAddNodePreview({
|
|
35
|
+
source: sourceEndpoint,
|
|
36
|
+
sourceHandleType: 'source',
|
|
37
|
+
reactFlowInstance: reactFlow,
|
|
38
|
+
getManifestForNode
|
|
39
|
+
}) : null;
|
|
31
40
|
showPreviewGraph({
|
|
32
|
-
|
|
33
|
-
sourceHandleId: sourceHandleId ?? DEFAULT_SOURCE_HANDLE_ID,
|
|
41
|
+
source: sourceEndpoint,
|
|
34
42
|
reactFlowInstance: reactFlow,
|
|
35
43
|
position,
|
|
44
|
+
positionMode: 'drop',
|
|
36
45
|
data: {
|
|
37
46
|
originalEdge
|
|
38
47
|
},
|
|
39
48
|
sourceHandleType: 'source',
|
|
40
49
|
handlePosition: sourcePosition,
|
|
41
50
|
ignoredNodeTypes: ignoredNodeTypes ?? [],
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
target: {
|
|
52
|
+
nodeId: target,
|
|
53
|
+
handleId: targetHandleId
|
|
54
|
+
},
|
|
55
|
+
...containerOverrides ?? {}
|
|
47
56
|
});
|
|
48
57
|
}, [
|
|
49
58
|
sourcePosition,
|
|
50
59
|
source,
|
|
51
60
|
sourceHandleId,
|
|
52
61
|
reactFlow,
|
|
62
|
+
registry,
|
|
63
|
+
getManifestForNode,
|
|
53
64
|
target,
|
|
54
65
|
targetHandleId,
|
|
55
66
|
edgeId,
|
|
@@ -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":"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"}
|
|
@@ -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,
|