@uipath/apollo-react 3.53.0 → 3.54.0-pr354.9b2638b
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 +21 -8
- package/dist/canvas/components/AddNodePanel/AddNodePanel.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/AddNodePanel.js +11 -8
- package/dist/canvas/components/BaseNode/BaseNode.styles.cjs +4 -52
- package/dist/canvas/components/BaseNode/BaseNode.styles.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.styles.js +2 -50
- package/dist/canvas/components/GroupNode/GroupNode.cjs +147 -75
- package/dist/canvas/components/GroupNode/GroupNode.d.ts.map +1 -1
- package/dist/canvas/components/GroupNode/GroupNode.js +147 -75
- package/dist/canvas/components/GroupNode/GroupNode.stories.cjs +610 -13
- package/dist/canvas/components/GroupNode/GroupNode.stories.d.ts +5 -0
- package/dist/canvas/components/GroupNode/GroupNode.stories.d.ts.map +1 -1
- package/dist/canvas/components/GroupNode/GroupNode.stories.js +589 -7
- package/dist/canvas/components/GroupNode/GroupNode.styles.cjs +6 -2
- package/dist/canvas/components/GroupNode/GroupNode.styles.d.ts +1 -0
- package/dist/canvas/components/GroupNode/GroupNode.styles.d.ts.map +1 -1
- package/dist/canvas/components/GroupNode/GroupNode.styles.js +6 -2
- package/dist/canvas/components/GroupNode/GroupNode.types.d.ts +1 -0
- package/dist/canvas/components/GroupNode/GroupNode.types.d.ts.map +1 -1
- package/dist/canvas/components/GroupNode/GroupNodeConfigContext.cjs +45 -0
- package/dist/canvas/components/GroupNode/GroupNodeConfigContext.d.ts +11 -0
- package/dist/canvas/components/GroupNode/GroupNodeConfigContext.d.ts.map +1 -0
- package/dist/canvas/components/GroupNode/GroupNodeConfigContext.js +8 -0
- package/dist/canvas/components/GroupNode/index.cjs +9 -2
- package/dist/canvas/components/GroupNode/index.d.ts +2 -0
- package/dist/canvas/components/GroupNode/index.d.ts.map +1 -1
- package/dist/canvas/components/GroupNode/index.js +2 -1
- package/dist/canvas/components/Toolbox/ListView.cjs +43 -34
- package/dist/canvas/components/Toolbox/ListView.d.ts +7 -2
- package/dist/canvas/components/Toolbox/ListView.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/ListView.js +39 -33
- package/dist/canvas/components/Toolbox/ListView.styles.cjs +7 -1
- package/dist/canvas/components/Toolbox/ListView.styles.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/ListView.styles.js +7 -1
- package/dist/canvas/components/Toolbox/SearchBox.cjs +16 -4
- package/dist/canvas/components/Toolbox/SearchBox.d.ts +2 -0
- package/dist/canvas/components/Toolbox/SearchBox.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/SearchBox.js +17 -5
- package/dist/canvas/components/Toolbox/Toolbox.cjs +127 -9
- package/dist/canvas/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/Toolbox.js +128 -10
- package/dist/canvas/styles/execution-status.cjs +88 -0
- package/dist/canvas/styles/execution-status.d.ts +8 -0
- package/dist/canvas/styles/execution-status.d.ts.map +1 -0
- package/dist/canvas/styles/execution-status.js +51 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupNode.styles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/GroupNode/GroupNode.styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GroupNode.styles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/GroupNode/GroupNode.styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc;;;;sBACP,MAAM;kBACV,MAAM;eACT,OAAO;gBACN,OAAO;sBACD,MAAM;yGA0BzB,CAAC;AAEF,eAAO,MAAM,WAAW;;;yGAgBvB,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;yGAe5B,CAAC;AAEF,eAAO,MAAM,UAAU;;;yGAUtB,CAAC;AAEF,eAAO,MAAM,aAAa;;;yGAIzB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;gBAA+B,OAAO;qHA0BnE,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;yGAMhC,CAAC;AAEF,eAAO,MAAM,YAAY;;;;gBAA4B,OAAO;yGAK3D,CAAC;AAEF,eAAO,MAAM,YAAY;;;;eAA2B,OAAO;aAAW,MAAM;yGAW3E,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;eAA2B,OAAO;yGAgCjE,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;eAA2B,OAAO;yGAgCpE,CAAC"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import styled from "@emotion/styled";
|
|
2
|
+
import { getExecutionStatusBorder } from "../../styles/execution-status.js";
|
|
2
3
|
const GroupContainer = styled.div`
|
|
3
4
|
position: relative;
|
|
4
5
|
width: 100%;
|
|
5
6
|
height: 100%;
|
|
6
7
|
background-color: ${({ backgroundColor })=>backgroundColor || 'var(--uix-canvas-background-raised)'} !important;
|
|
7
8
|
border: 2px solid
|
|
8
|
-
${({ borderColor, selected })=>selected ? 'var(--uix-canvas-primary)' : borderColor || 'var(--uix-canvas-border)'}
|
|
9
|
+
${({ borderColor, selected })=>selected ? 'var(--uix-canvas-primary)' : borderColor || 'var(--uix-canvas-border)'};
|
|
9
10
|
border-radius: 16px !important;
|
|
10
11
|
transition: border-color 0.2s ease;
|
|
11
12
|
overflow: visible;
|
|
12
13
|
box-shadow: ${({ selected })=>selected ? '0 0 0 1px var(--uix-canvas-primary)' : 'none'};
|
|
13
14
|
padding: 0 !important;
|
|
14
15
|
|
|
16
|
+
${({ executionStatus })=>getExecutionStatusBorder(executionStatus)}
|
|
17
|
+
|
|
15
18
|
&:hover {
|
|
16
|
-
|
|
19
|
+
${({ selected, executionStatus })=>executionStatus ? '' : `border-color: ${selected ? 'var(--uix-canvas-primary)' : 'var(--uix-canvas-border-hover)'};`}
|
|
17
20
|
}
|
|
18
21
|
`;
|
|
19
22
|
const GroupHeader = styled.div`
|
|
@@ -95,6 +98,7 @@ const GroupHeaderButton = styled.button`
|
|
|
95
98
|
const GroupHeaderSeparator = styled.div`
|
|
96
99
|
width: 1px;
|
|
97
100
|
height: 20px;
|
|
101
|
+
margin: 0 4px;
|
|
98
102
|
background: var(--uix-canvas-border-grid);
|
|
99
103
|
align-self: center;
|
|
100
104
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupNode.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/GroupNode/GroupNode.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,aAAc,SAAQ,YAAY;IAEjD,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,SAAS,CAAC,EAAE,OAAO,CAAC;IAGpB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
1
|
+
{"version":3,"file":"GroupNode.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/GroupNode/GroupNode.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,aAAc,SAAQ,YAAY;IAEjD,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,SAAS,CAAC,EAAE,OAAO,CAAC;IAGpB,cAAc,CAAC,EAAE,MAAM,CAAC;IAGxB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
GroupNodeConfigProvider: ()=>GroupNodeConfigProvider,
|
|
28
|
+
useGroupNodeConfig: ()=>useGroupNodeConfig
|
|
29
|
+
});
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
const EMPTY_CONFIG = {};
|
|
32
|
+
const GroupNodeConfigContext = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)(EMPTY_CONFIG);
|
|
33
|
+
const GroupNodeConfigProvider = GroupNodeConfigContext.Provider;
|
|
34
|
+
function useGroupNodeConfig() {
|
|
35
|
+
return (0, external_react_namespaceObject.useContext)(GroupNodeConfigContext);
|
|
36
|
+
}
|
|
37
|
+
exports.GroupNodeConfigProvider = __webpack_exports__.GroupNodeConfigProvider;
|
|
38
|
+
exports.useGroupNodeConfig = __webpack_exports__.useGroupNodeConfig;
|
|
39
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
40
|
+
"GroupNodeConfigProvider",
|
|
41
|
+
"useGroupNodeConfig"
|
|
42
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
43
|
+
Object.defineProperty(exports, '__esModule', {
|
|
44
|
+
value: true
|
|
45
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface GroupNodeConfig {
|
|
2
|
+
headerActions?: React.ReactNode;
|
|
3
|
+
executionStatus?: string;
|
|
4
|
+
executionMessage?: string;
|
|
5
|
+
onMoreOptions?: () => void;
|
|
6
|
+
hideMoreOptions?: boolean;
|
|
7
|
+
hideCollapseButton?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const GroupNodeConfigProvider: import("react").Provider<GroupNodeConfig>;
|
|
10
|
+
export declare function useGroupNodeConfig(): GroupNodeConfig;
|
|
11
|
+
//# sourceMappingURL=GroupNodeConfigContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GroupNodeConfigContext.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/GroupNode/GroupNodeConfigContext.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAE9B,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEhC,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAE3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAMD,eAAO,MAAM,uBAAuB,2CAAkC,CAAC;AAEvE,wBAAgB,kBAAkB,IAAI,eAAe,CAEpD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const EMPTY_CONFIG = {};
|
|
3
|
+
const GroupNodeConfigContext = /*#__PURE__*/ createContext(EMPTY_CONFIG);
|
|
4
|
+
const GroupNodeConfigProvider = GroupNodeConfigContext.Provider;
|
|
5
|
+
function useGroupNodeConfig() {
|
|
6
|
+
return useContext(GroupNodeConfigContext);
|
|
7
|
+
}
|
|
8
|
+
export { GroupNodeConfigProvider, useGroupNodeConfig };
|
|
@@ -24,12 +24,19 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
GroupNode: ()=>external_GroupNode_cjs_namespaceObject.GroupNode
|
|
27
|
+
GroupNode: ()=>external_GroupNode_cjs_namespaceObject.GroupNode,
|
|
28
|
+
GroupNodeConfigProvider: ()=>external_GroupNodeConfigContext_cjs_namespaceObject.GroupNodeConfigProvider,
|
|
29
|
+
useGroupNodeConfig: ()=>external_GroupNodeConfigContext_cjs_namespaceObject.useGroupNodeConfig
|
|
28
30
|
});
|
|
29
31
|
const external_GroupNode_cjs_namespaceObject = require("./GroupNode.cjs");
|
|
32
|
+
const external_GroupNodeConfigContext_cjs_namespaceObject = require("./GroupNodeConfigContext.cjs");
|
|
30
33
|
exports.GroupNode = __webpack_exports__.GroupNode;
|
|
34
|
+
exports.GroupNodeConfigProvider = __webpack_exports__.GroupNodeConfigProvider;
|
|
35
|
+
exports.useGroupNodeConfig = __webpack_exports__.useGroupNodeConfig;
|
|
31
36
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
32
|
-
"GroupNode"
|
|
37
|
+
"GroupNode",
|
|
38
|
+
"GroupNodeConfigProvider",
|
|
39
|
+
"useGroupNodeConfig"
|
|
33
40
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
34
41
|
Object.defineProperty(exports, '__esModule', {
|
|
35
42
|
value: true
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type { GroupNodeProps } from './GroupNode';
|
|
2
2
|
export { GroupNode } from './GroupNode';
|
|
3
3
|
export type { GroupNodeData } from './GroupNode.types';
|
|
4
|
+
export type { GroupNodeConfig } from './GroupNodeConfigContext';
|
|
5
|
+
export { GroupNodeConfigProvider, useGroupNodeConfig } from './GroupNodeConfigContext';
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/GroupNode/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/GroupNode/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -24,7 +24,8 @@ 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
|
|
27
|
+
ListView: ()=>ListView_ListView,
|
|
28
|
+
buildRenderedItems: ()=>buildRenderedItems
|
|
28
29
|
});
|
|
29
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
31
|
const apollo_core_namespaceObject = require("@uipath/apollo-core");
|
|
@@ -35,8 +36,37 @@ const components_index_cjs_namespaceObject = require("../../../material/componen
|
|
|
35
36
|
const external_react_namespaceObject = require("react");
|
|
36
37
|
const CanvasThemeContext_cjs_namespaceObject = require("../BaseCanvas/CanvasThemeContext.cjs");
|
|
37
38
|
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
|
+
}
|
|
38
68
|
const IconContainerMemoized = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(external_ListView_styles_cjs_namespaceObject.IconContainer);
|
|
39
|
-
const ListViewRow = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ index, style, ariaAttributes, renderedItems, isLoading, isDarkMode, onItemClick, onItemHover })=>{
|
|
69
|
+
const ListViewRow = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ index, style, ariaAttributes, renderedItems, activeIndex, isLoading, isDarkMode, onItemClick, onItemHover })=>{
|
|
40
70
|
const renderItem = renderedItems[index];
|
|
41
71
|
const buttonStyle = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
42
72
|
...style,
|
|
@@ -74,12 +104,14 @@ const ListViewRow = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ in
|
|
|
74
104
|
});
|
|
75
105
|
const item = renderItem.item;
|
|
76
106
|
const bgColor = isDarkMode ? item.colorDark ?? item.color : item.color;
|
|
107
|
+
const isActive = index === activeIndex;
|
|
77
108
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_ListView_styles_cjs_namespaceObject.ListItemButton, {
|
|
78
109
|
...ariaAttributes,
|
|
79
110
|
style: buttonStyle,
|
|
80
111
|
onClick: handleButtonClick,
|
|
81
112
|
onHoverStart: handleButtonHover,
|
|
82
|
-
className: isLoading ? 'loading' : ''
|
|
113
|
+
className: `${isLoading ? 'loading' : ''} ${isActive ? 'active' : ''}`,
|
|
114
|
+
"data-active": isActive || void 0,
|
|
83
115
|
disabled: isLoading,
|
|
84
116
|
children: [
|
|
85
117
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(IconContainerMemoized, {
|
|
@@ -134,48 +166,22 @@ const ListViewRow = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ in
|
|
|
134
166
|
]
|
|
135
167
|
});
|
|
136
168
|
});
|
|
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 }) {
|
|
169
|
+
const ListView_ListView = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(function({ items, activeIndex = -1, listRef, onItemClick, onItemHover, emptyStateMessage = 'No items found', emptyStateIcon = 'search_off', isLoading = false, enableSections = true }) {
|
|
138
170
|
const { isDarkMode } = (0, CanvasThemeContext_cjs_namespaceObject.useCanvasTheme)();
|
|
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
|
-
}, [
|
|
171
|
+
const renderedItems = (0, external_react_namespaceObject.useMemo)(()=>buildRenderedItems(items, enableSections), [
|
|
168
172
|
items,
|
|
169
173
|
enableSections
|
|
170
174
|
]);
|
|
171
175
|
const rowProps = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
172
176
|
renderedItems,
|
|
177
|
+
activeIndex,
|
|
173
178
|
isLoading,
|
|
174
179
|
isDarkMode,
|
|
175
180
|
onItemClick,
|
|
176
181
|
onItemHover
|
|
177
182
|
}), [
|
|
178
183
|
renderedItems,
|
|
184
|
+
activeIndex,
|
|
179
185
|
isLoading,
|
|
180
186
|
isDarkMode,
|
|
181
187
|
onItemClick,
|
|
@@ -215,6 +221,7 @@ const ListView_ListView = /*#__PURE__*/ (0, external_react_namespaceObject.memo)
|
|
|
215
221
|
]
|
|
216
222
|
});
|
|
217
223
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ListView_styles_cjs_namespaceObject.StyledList, {
|
|
224
|
+
listRef: listRef,
|
|
218
225
|
rowProps: rowProps,
|
|
219
226
|
rowComponent: ListViewRow,
|
|
220
227
|
rowCount: renderedItems.length,
|
|
@@ -223,8 +230,10 @@ const ListView_ListView = /*#__PURE__*/ (0, external_react_namespaceObject.memo)
|
|
|
223
230
|
});
|
|
224
231
|
});
|
|
225
232
|
exports.ListView = __webpack_exports__.ListView;
|
|
233
|
+
exports.buildRenderedItems = __webpack_exports__.buildRenderedItems;
|
|
226
234
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
227
|
-
"ListView"
|
|
235
|
+
"ListView",
|
|
236
|
+
"buildRenderedItems"
|
|
228
237
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
229
238
|
Object.defineProperty(exports, '__esModule', {
|
|
230
239
|
value: true
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListImperativeAPI } from 'react-window';
|
|
1
2
|
export interface ListItemIcon {
|
|
2
3
|
name?: string;
|
|
3
4
|
url?: string;
|
|
@@ -14,15 +15,17 @@ export type ListItem<T = any> = {
|
|
|
14
15
|
colorDark?: string;
|
|
15
16
|
children?: ListItem<T>[] | ((id: string, name: string) => Promise<ListItem<T>[]>);
|
|
16
17
|
};
|
|
17
|
-
type RenderItem<T extends ListItem> = {
|
|
18
|
+
export type RenderItem<T extends ListItem> = {
|
|
18
19
|
type: 'section';
|
|
19
20
|
sectionName: string;
|
|
20
21
|
} | {
|
|
21
22
|
type: 'item';
|
|
22
23
|
item: T;
|
|
23
24
|
};
|
|
25
|
+
export declare function buildRenderedItems<T extends ListItem>(items: T[], enableSections: boolean): RenderItem<T>[];
|
|
24
26
|
export interface ListViewRowProps<T extends ListItem> {
|
|
25
27
|
renderedItems: RenderItem<T>[];
|
|
28
|
+
activeIndex: number;
|
|
26
29
|
isLoading?: boolean;
|
|
27
30
|
isDarkMode?: boolean;
|
|
28
31
|
onItemClick: (item: T) => void;
|
|
@@ -30,6 +33,8 @@ export interface ListViewRowProps<T extends ListItem> {
|
|
|
30
33
|
}
|
|
31
34
|
interface ListViewProps<T extends ListItem> {
|
|
32
35
|
items: T[];
|
|
36
|
+
activeIndex?: number;
|
|
37
|
+
listRef?: React.RefObject<ListImperativeAPI | null>;
|
|
33
38
|
onItemClick: (item: T) => void;
|
|
34
39
|
onItemHover?: (item: T) => void;
|
|
35
40
|
emptyStateMessage?: string;
|
|
@@ -37,6 +42,6 @@ interface ListViewProps<T extends ListItem> {
|
|
|
37
42
|
isLoading?: boolean;
|
|
38
43
|
enableSections?: boolean;
|
|
39
44
|
}
|
|
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)>;
|
|
45
|
+
export declare const ListView: import("react").MemoExoticComponent<(<T extends ListItem>({ items, activeIndex, listRef, onItemClick, onItemHover, emptyStateMessage, emptyStateIcon, isLoading, enableSections, }: ListViewProps<T>) => import("react/jsx-runtime").JSX.Element)>;
|
|
41
46
|
export {};
|
|
42
47
|
//# 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":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,cAAc,CAAC;AAIzE,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,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,QAAQ,IACrC;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,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,QAAQ,EACnD,KAAK,EAAE,CAAC,EAAE,EACV,cAAc,EAAE,OAAO,GACtB,UAAU,CAAC,CAAC,CAAC,EAAE,CAiCjB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,QAAQ;IAClD,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,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;AA6GD,UAAU,aAAa,CAAC,CAAC,SAAS,QAAQ;IACxC,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACpD,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,4HAU9D,aAAa,CAAC,CAAC,CAAC,8CAiDjB,CAAC"}
|
|
@@ -7,8 +7,37 @@ 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
|
+
}
|
|
10
39
|
const IconContainerMemoized = /*#__PURE__*/ memo(IconContainer);
|
|
11
|
-
const ListViewRow = /*#__PURE__*/ memo(({ index, style, ariaAttributes, renderedItems, isLoading, isDarkMode, onItemClick, onItemHover })=>{
|
|
40
|
+
const ListViewRow = /*#__PURE__*/ memo(({ index, style, ariaAttributes, renderedItems, activeIndex, isLoading, isDarkMode, onItemClick, onItemHover })=>{
|
|
12
41
|
const renderItem = renderedItems[index];
|
|
13
42
|
const buttonStyle = useMemo(()=>({
|
|
14
43
|
...style,
|
|
@@ -46,12 +75,14 @@ const ListViewRow = /*#__PURE__*/ memo(({ index, style, ariaAttributes, rendered
|
|
|
46
75
|
});
|
|
47
76
|
const item = renderItem.item;
|
|
48
77
|
const bgColor = isDarkMode ? item.colorDark ?? item.color : item.color;
|
|
78
|
+
const isActive = index === activeIndex;
|
|
49
79
|
return /*#__PURE__*/ jsxs(ListItemButton, {
|
|
50
80
|
...ariaAttributes,
|
|
51
81
|
style: buttonStyle,
|
|
52
82
|
onClick: handleButtonClick,
|
|
53
83
|
onHoverStart: handleButtonHover,
|
|
54
|
-
className: isLoading ? 'loading' : ''
|
|
84
|
+
className: `${isLoading ? 'loading' : ''} ${isActive ? 'active' : ''}`,
|
|
85
|
+
"data-active": isActive || void 0,
|
|
55
86
|
disabled: isLoading,
|
|
56
87
|
children: [
|
|
57
88
|
/*#__PURE__*/ jsxs(IconContainerMemoized, {
|
|
@@ -106,48 +137,22 @@ const ListViewRow = /*#__PURE__*/ memo(({ index, style, ariaAttributes, rendered
|
|
|
106
137
|
]
|
|
107
138
|
});
|
|
108
139
|
});
|
|
109
|
-
const ListView_ListView = /*#__PURE__*/ memo(function({ items, onItemClick, onItemHover, emptyStateMessage = 'No items found', emptyStateIcon = 'search_off', isLoading = false, enableSections = true }) {
|
|
140
|
+
const ListView_ListView = /*#__PURE__*/ memo(function({ items, activeIndex = -1, listRef, onItemClick, onItemHover, emptyStateMessage = 'No items found', emptyStateIcon = 'search_off', isLoading = false, enableSections = true }) {
|
|
110
141
|
const { isDarkMode } = useCanvasTheme();
|
|
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
|
-
}, [
|
|
142
|
+
const renderedItems = useMemo(()=>buildRenderedItems(items, enableSections), [
|
|
140
143
|
items,
|
|
141
144
|
enableSections
|
|
142
145
|
]);
|
|
143
146
|
const rowProps = useMemo(()=>({
|
|
144
147
|
renderedItems,
|
|
148
|
+
activeIndex,
|
|
145
149
|
isLoading,
|
|
146
150
|
isDarkMode,
|
|
147
151
|
onItemClick,
|
|
148
152
|
onItemHover
|
|
149
153
|
}), [
|
|
150
154
|
renderedItems,
|
|
155
|
+
activeIndex,
|
|
151
156
|
isLoading,
|
|
152
157
|
isDarkMode,
|
|
153
158
|
onItemClick,
|
|
@@ -187,6 +192,7 @@ const ListView_ListView = /*#__PURE__*/ memo(function({ items, onItemClick, onIt
|
|
|
187
192
|
]
|
|
188
193
|
});
|
|
189
194
|
return /*#__PURE__*/ jsx(StyledList, {
|
|
195
|
+
listRef: listRef,
|
|
190
196
|
rowProps: rowProps,
|
|
191
197
|
rowComponent: ListViewRow,
|
|
192
198
|
rowCount: renderedItems.length,
|
|
@@ -194,4 +200,4 @@ const ListView_ListView = /*#__PURE__*/ memo(function({ items, onItemClick, onIt
|
|
|
194
200
|
overscanCount: 20
|
|
195
201
|
});
|
|
196
202
|
});
|
|
197
|
-
export { ListView_ListView as ListView };
|
|
203
|
+
export { ListView_ListView as ListView, buildRenderedItems };
|
|
@@ -68,9 +68,15 @@ const ListItemButton = styled_default()(react_namespaceObject.motion.button)`
|
|
|
68
68
|
width: 100%;
|
|
69
69
|
transition: all 0.15s ease;
|
|
70
70
|
|
|
71
|
-
&:hover
|
|
71
|
+
&:hover,
|
|
72
|
+
&.active {
|
|
72
73
|
background: var(--uix-canvas-background-hover);
|
|
73
74
|
}
|
|
75
|
+
|
|
76
|
+
&.active {
|
|
77
|
+
outline: 1px solid var(--uix-canvas-border);
|
|
78
|
+
outline-offset: -1px;
|
|
79
|
+
}
|
|
74
80
|
`;
|
|
75
81
|
const IconContainer = styled_default().div`
|
|
76
82
|
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;;UAqB1B,CAAC;AAEF,eAAO,MAAM,aAAa;;;;cAA0B,MAAM;yGAazD,CAAC;AAEF,eAAO,MAAM,UAAU,EAkClB,OAAO,IAAI,CAAC"}
|
|
@@ -27,9 +27,15 @@ const ListItemButton = styled(motion.button)`
|
|
|
27
27
|
width: 100%;
|
|
28
28
|
transition: all 0.15s ease;
|
|
29
29
|
|
|
30
|
-
&:hover
|
|
30
|
+
&:hover,
|
|
31
|
+
&.active {
|
|
31
32
|
background: var(--uix-canvas-background-hover);
|
|
32
33
|
}
|
|
34
|
+
|
|
35
|
+
&.active {
|
|
36
|
+
outline: 1px solid var(--uix-canvas-border);
|
|
37
|
+
outline-offset: -1px;
|
|
38
|
+
}
|
|
33
39
|
`;
|
|
34
40
|
const IconContainer = styled.div`
|
|
35
41
|
width: 32px;
|
|
@@ -31,11 +31,22 @@ 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
|
|
34
|
+
const SearchBox_SearchBox = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(function({ value, onChange, clear, placeholder = 'Search...', inputRef: externalInputRef, onArrowDown }) {
|
|
35
|
+
const internalRef = (0, external_react_namespaceObject.useRef)(null);
|
|
36
|
+
const inputRef = externalInputRef ?? internalRef;
|
|
36
37
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
37
38
|
inputRef.current?.focus();
|
|
38
|
-
}, [
|
|
39
|
+
}, [
|
|
40
|
+
inputRef
|
|
41
|
+
]);
|
|
42
|
+
const handleKeyDown = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
43
|
+
if ('ArrowDown' === e.key) {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
onArrowDown?.();
|
|
46
|
+
}
|
|
47
|
+
}, [
|
|
48
|
+
onArrowDown
|
|
49
|
+
]);
|
|
39
50
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_SearchBox_styles_cjs_namespaceObject.StyledSearchForm, {
|
|
40
51
|
autoComplete: "off",
|
|
41
52
|
className: "searchbox-form",
|
|
@@ -59,7 +70,8 @@ const SearchBox_SearchBox = /*#__PURE__*/ (0, external_react_namespaceObject.mem
|
|
|
59
70
|
className: "searchbox-input",
|
|
60
71
|
placeholder: placeholder,
|
|
61
72
|
value: value,
|
|
62
|
-
onChange: (e)=>onChange(e.target.value)
|
|
73
|
+
onChange: (e)=>onChange(e.target.value),
|
|
74
|
+
onKeyDown: handleKeyDown
|
|
63
75
|
}),
|
|
64
76
|
value && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
65
77
|
type: "button",
|
|
@@ -3,6 +3,8 @@ interface SearchBoxProps {
|
|
|
3
3
|
onChange: (value: string) => void;
|
|
4
4
|
clear: () => void;
|
|
5
5
|
placeholder?: string;
|
|
6
|
+
inputRef?: React.RefObject<HTMLInputElement | null>;
|
|
7
|
+
onArrowDown?: () => void;
|
|
6
8
|
}
|
|
7
9
|
export declare const SearchBox: import("react").NamedExoticComponent<SearchBoxProps>;
|
|
8
10
|
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;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACpD,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,eAAO,MAAM,SAAS,sDAqDpB,CAAC"}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from "../../utils/index.js";
|
|
3
3
|
import { ApIcon } from "../../../material/components/index.js";
|
|
4
|
-
import { memo, useEffect, useRef } from "react";
|
|
4
|
+
import { memo, useCallback, 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
|
|
6
|
+
const SearchBox_SearchBox = /*#__PURE__*/ memo(function({ value, onChange, clear, placeholder = 'Search...', inputRef: externalInputRef, onArrowDown }) {
|
|
7
|
+
const internalRef = useRef(null);
|
|
8
|
+
const inputRef = externalInputRef ?? internalRef;
|
|
8
9
|
useEffect(()=>{
|
|
9
10
|
inputRef.current?.focus();
|
|
10
|
-
}, [
|
|
11
|
+
}, [
|
|
12
|
+
inputRef
|
|
13
|
+
]);
|
|
14
|
+
const handleKeyDown = useCallback((e)=>{
|
|
15
|
+
if ('ArrowDown' === e.key) {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
onArrowDown?.();
|
|
18
|
+
}
|
|
19
|
+
}, [
|
|
20
|
+
onArrowDown
|
|
21
|
+
]);
|
|
11
22
|
return /*#__PURE__*/ jsx(StyledSearchForm, {
|
|
12
23
|
autoComplete: "off",
|
|
13
24
|
className: "searchbox-form",
|
|
@@ -31,7 +42,8 @@ const SearchBox_SearchBox = /*#__PURE__*/ memo(function({ value, onChange, clear
|
|
|
31
42
|
className: "searchbox-input",
|
|
32
43
|
placeholder: placeholder,
|
|
33
44
|
value: value,
|
|
34
|
-
onChange: (e)=>onChange(e.target.value)
|
|
45
|
+
onChange: (e)=>onChange(e.target.value),
|
|
46
|
+
onKeyDown: handleKeyDown
|
|
35
47
|
}),
|
|
36
48
|
value && /*#__PURE__*/ jsx("button", {
|
|
37
49
|
type: "button",
|