@edifice.io/react 2.2.2-develop-b2school.20250407165159 → 2.2.2-develop-b2school.20250408143232
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.
|
@@ -17,6 +17,7 @@ const ComboboxTrigger = ({
|
|
|
17
17
|
const {
|
|
18
18
|
triggerProps,
|
|
19
19
|
itemProps,
|
|
20
|
+
menuProps,
|
|
20
21
|
setVisible
|
|
21
22
|
} = useDropdownContext(), containerProps = {
|
|
22
23
|
...triggerProps,
|
|
@@ -37,7 +38,7 @@ const ComboboxTrigger = ({
|
|
|
37
38
|
return useEffect(() => {
|
|
38
39
|
setVisible(value.length >= searchMinLength);
|
|
39
40
|
}, [value, searchMinLength]), /* @__PURE__ */ jsxs(FormControl, { id: "search", ...containerProps, children: [
|
|
40
|
-
!!renderInputGroup && /* @__PURE__ */ jsx("
|
|
41
|
+
!!renderInputGroup && /* @__PURE__ */ jsx("label", { className: "input-group-text pe-0" + classNameVariant, htmlFor: triggerProps.id, children: renderInputGroup }),
|
|
41
42
|
/* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center flex-wrap flex-fill", children: [
|
|
42
43
|
renderSelectedItems,
|
|
43
44
|
/* @__PURE__ */ jsx(Input, { ...inputProps, className: classNameInput, noValidationIcon: !0, placeholder, size: "md", type: "search", onKeyDown: itemProps.onMenuItemKeyDown })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { odeServices } from "@edifice.io/client";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { useMemo } from "react";
|
|
3
|
+
import { useState, useMemo } from "react";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
5
|
function useWorkspaceFolders() {
|
|
6
6
|
const {
|
|
@@ -10,16 +10,22 @@ function useWorkspaceFolders() {
|
|
|
10
10
|
} = useQuery({
|
|
11
11
|
queryKey: ["workspace-folders"],
|
|
12
12
|
queryFn: () => odeServices.workspace().listFolder("owner", !0)
|
|
13
|
-
})
|
|
13
|
+
}), [searchQuery, setSearchQuery] = useState(""), filterTree = (nodes, search) => nodes.map((node) => {
|
|
14
|
+
const filteredChildren = node.children ? filterTree(node.children, search) : [];
|
|
15
|
+
return node.name.toLowerCase().includes(search.toLowerCase()) || filteredChildren.length > 0 ? {
|
|
16
|
+
...node,
|
|
17
|
+
children: filteredChildren
|
|
18
|
+
} : null;
|
|
19
|
+
}).filter((node) => node !== null);
|
|
14
20
|
return {
|
|
15
21
|
folderTree: useMemo(() => {
|
|
16
22
|
const buildWorkspaceTree = (data) => [{
|
|
17
|
-
id: "
|
|
23
|
+
id: "",
|
|
18
24
|
name: t("workspace.myDocuments"),
|
|
19
25
|
children: data
|
|
20
26
|
}];
|
|
21
27
|
if (!folderData) return buildWorkspaceTree([]);
|
|
22
|
-
const nodes = /* @__PURE__ */ new Map(),
|
|
28
|
+
const nodes = /* @__PURE__ */ new Map(), fullTree = [];
|
|
23
29
|
return folderData.forEach((item) => {
|
|
24
30
|
nodes.set(item._id, {
|
|
25
31
|
id: item._id,
|
|
@@ -27,9 +33,10 @@ function useWorkspaceFolders() {
|
|
|
27
33
|
children: []
|
|
28
34
|
});
|
|
29
35
|
}), folderData.forEach((item) => {
|
|
30
|
-
item.eParent && nodes.has(item.eParent) ? nodes.get(item.eParent).children.push(nodes.get(item._id)) :
|
|
31
|
-
}), buildWorkspaceTree(
|
|
32
|
-
}, [folderData])
|
|
36
|
+
item.eParent && nodes.has(item.eParent) ? nodes.get(item.eParent).children.push(nodes.get(item._id)) : fullTree.push(nodes.get(item._id));
|
|
37
|
+
}), buildWorkspaceTree(searchQuery ? filterTree(fullTree, searchQuery) : fullTree);
|
|
38
|
+
}, [folderData, searchQuery]),
|
|
39
|
+
setSearchQuery
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
42
|
export {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { useState } from "react";
|
|
3
4
|
import useWorkspaceFolders from "../../../hooks/useWorkspaceFolders/useWorkspaceFolders.js";
|
|
5
|
+
import SearchBar from "../../../components/SearchBar/SearchBar.js";
|
|
4
6
|
import Tree from "../../../components/Tree/components/Tree.js";
|
|
5
7
|
function WorkspaceFolders({
|
|
6
8
|
onFolderSelected
|
|
@@ -8,11 +10,17 @@ function WorkspaceFolders({
|
|
|
8
10
|
const {
|
|
9
11
|
t
|
|
10
12
|
} = useTranslation(), {
|
|
11
|
-
folderTree
|
|
12
|
-
|
|
13
|
+
folderTree,
|
|
14
|
+
setSearchQuery
|
|
15
|
+
} = useWorkspaceFolders(), [shouldExpandAllNodes, setShouldExpandAllNodes] = useState(!1), [searchValue, setSearchValue] = useState(""), handleSearchChange = (e) => {
|
|
16
|
+
setSearchValue(e.target.value);
|
|
17
|
+
}, handleSearchSubmit = () => {
|
|
18
|
+
setSearchQuery(searchValue), setShouldExpandAllNodes(searchValue !== "");
|
|
19
|
+
};
|
|
13
20
|
return /* @__PURE__ */ jsxs("div", { className: "d-flex flex-column gap-12", children: [
|
|
14
21
|
/* @__PURE__ */ jsx("p", { children: t("attachments.add.to.folder.modal.description") }),
|
|
15
|
-
/* @__PURE__ */ jsx(
|
|
22
|
+
/* @__PURE__ */ jsx(SearchBar, { onChange: handleSearchChange, isVariant: !1, placeholder: t("search"), onClick: handleSearchSubmit }),
|
|
23
|
+
/* @__PURE__ */ jsx("div", { className: "border border-gray-400 rounded", children: /* @__PURE__ */ jsx("div", { className: "p-12", children: /* @__PURE__ */ jsx(Tree, { nodes: folderTree, onTreeItemClick: onFolderSelected, shouldExpandAllNodes }) }) })
|
|
16
24
|
] });
|
|
17
25
|
}
|
|
18
26
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.2.2-develop-b2school.
|
|
3
|
+
"version": "2.2.2-develop-b2school.20250408143232",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -118,9 +118,9 @@
|
|
|
118
118
|
"react-slugify": "^3.0.3",
|
|
119
119
|
"swiper": "^10.1.0",
|
|
120
120
|
"ua-parser-js": "^1.0.36",
|
|
121
|
-
"@edifice.io/bootstrap": "2.2.2-develop-b2school.
|
|
122
|
-
"@edifice.io/tiptap-extensions": "2.2.2-develop-b2school.
|
|
123
|
-
"@edifice.io/utilities": "2.2.2-develop-b2school.
|
|
121
|
+
"@edifice.io/bootstrap": "2.2.2-develop-b2school.20250408143232",
|
|
122
|
+
"@edifice.io/tiptap-extensions": "2.2.2-develop-b2school.20250408143232",
|
|
123
|
+
"@edifice.io/utilities": "2.2.2-develop-b2school.20250408143232"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@babel/plugin-transform-react-pure-annotations": "^7.23.3",
|
|
@@ -151,8 +151,8 @@
|
|
|
151
151
|
"vite": "^5.4.11",
|
|
152
152
|
"vite-plugin-dts": "^4.1.0",
|
|
153
153
|
"vite-tsconfig-paths": "^5.0.1",
|
|
154
|
-
"@edifice.io/client": "2.2.2-develop-b2school.
|
|
155
|
-
"@edifice.io/config": "2.2.2-develop-b2school.
|
|
154
|
+
"@edifice.io/client": "2.2.2-develop-b2school.20250408143232",
|
|
155
|
+
"@edifice.io/config": "2.2.2-develop-b2school.20250408143232"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"@react-spring/web": "^9.7.5",
|