@edifice.io/react 2.6.0-develop-integration.20260716154944 → 2.6.0-develop-integration.20260717095527

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.
@@ -5,6 +5,7 @@ import useUser from "../../../../hooks/useUser/useUser.js";
5
5
  import Nextcloud$1 from "../../Nextcloud/Nextcloud.js";
6
6
  const Nextcloud = () => {
7
7
  const {
8
+ type,
8
9
  setResultCounter,
9
10
  setResult,
10
11
  setPreSuccess,
@@ -12,10 +13,22 @@ const Nextcloud = () => {
12
13
  } = useMediaLibraryContext(), {
13
14
  user
14
15
  } = useUser();
16
+ function getDocumentRoleFilter() {
17
+ switch (type) {
18
+ case "image":
19
+ return "img";
20
+ case "audio":
21
+ return "audio";
22
+ case "video":
23
+ return "video";
24
+ default:
25
+ return null;
26
+ }
27
+ }
15
28
  function handleSelect(result) {
16
29
  setResultCounter(result.length), result.length ? (setResult(result), setPreSuccess(() => () => user != null && user.userId ? odeServices.nextcloud().copyDocumentToWorkspace(user.userId, result.map((doc) => doc.path)) : Promise.resolve([]))) : (setResult(), setPreSuccess(void 0));
17
30
  }
18
- return /* @__PURE__ */ jsx(Nextcloud$1, { onSelect: handleSelect, multiple, className: "border rounded overflow-y-auto" });
31
+ return /* @__PURE__ */ jsx(Nextcloud$1, { roles: getDocumentRoleFilter(), onSelect: handleSelect, multiple, className: "border rounded overflow-y-auto" });
19
32
  };
20
33
  export {
21
34
  Nextcloud
@@ -1,4 +1,4 @@
1
- import { NextcloudDocument } from '@edifice.io/client';
1
+ import { NextcloudDocument, Role } from '@edifice.io/client';
2
2
  /**
3
3
  * Nextcloud component properties
4
4
  */
@@ -11,10 +11,14 @@ export interface NextcloudProps {
11
11
  * Boolean to know if we can select 1 or many files.
12
12
  */
13
13
  multiple?: boolean | undefined;
14
+ /**
15
+ * Document roles to filter files by; null (default) shows all roles.
16
+ */
17
+ roles?: Role | Role[] | null;
14
18
  /**
15
19
  * Optional class for styling purpose
16
20
  */
17
21
  className?: string;
18
22
  }
19
- declare const Nextcloud: ({ onSelect, multiple, className, }: NextcloudProps) => import("react/jsx-runtime").JSX.Element;
23
+ declare const Nextcloud: ({ onSelect, multiple, roles, className, }: NextcloudProps) => import("react/jsx-runtime").JSX.Element;
20
24
  export default Nextcloud;
@@ -1,5 +1,6 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useState, useCallback, useEffect, useMemo } from "react";
3
+ import { DocumentHelper } from "@edifice.io/client";
3
4
  import clsx from "clsx";
4
5
  import { useTranslation } from "react-i18next";
5
6
  import { findNodeById } from "../../../components/Tree/utilities/tree.js";
@@ -23,6 +24,7 @@ function compare(a, b) {
23
24
  const Nextcloud = ({
24
25
  onSelect,
25
26
  multiple = !0,
27
+ roles,
26
28
  className
27
29
  }) => {
28
30
  const {
@@ -32,7 +34,7 @@ const Nextcloud = ({
32
34
  } = useUser(), {
33
35
  root,
34
36
  loadContent
35
- } = useNextcloudSearch(ROOT_ID, t("nextcloud.tree.root"), user == null ? void 0 : user.userId), [currentNodeId, setCurrentNodeId] = useState(ROOT_ID), treeRoot = root, currentNode = findNodeById(treeRoot, currentNodeId) ?? root, [searchTerm, setSearchTerm] = useState(null), [sortOrder, setSortOrder] = useState(["modified", "desc"]), [selectedDocuments, setSelectedDocuments] = useState([]), handleTreeItemChange = useCallback((nodeId) => {
37
+ } = useNextcloudSearch(ROOT_ID, t("nextcloud"), user == null ? void 0 : user.userId), [currentNodeId, setCurrentNodeId] = useState(ROOT_ID), treeRoot = root, currentNode = findNodeById(treeRoot, currentNodeId) ?? root, [searchTerm, setSearchTerm] = useState(null), [sortOrder, setSortOrder] = useState(["modified", "desc"]), [selectedDocuments, setSelectedDocuments] = useState([]), handleTreeItemChange = useCallback((nodeId) => {
36
38
  setCurrentNodeId(nodeId), loadContent(nodeId);
37
39
  }, [loadContent]);
38
40
  useEffect(() => {
@@ -41,10 +43,13 @@ const Nextcloud = ({
41
43
  const documents = useMemo(() => {
42
44
  if (!currentNode.files) return;
43
45
  let list = [].concat(currentNode.files);
44
- searchTerm && (list = list.filter((f) => f.name.indexOf(searchTerm) >= 0));
46
+ searchTerm && (list = list.filter((f) => f.name.indexOf(searchTerm) >= 0)), roles && (list = list.filter((f) => {
47
+ const role = DocumentHelper.role(f.contentType, !1);
48
+ return typeof roles == "string" ? roles === role : Array.isArray(roles) ? roles.includes(role) : !1;
49
+ }));
45
50
  const sortFunction = sortOrder[0] === "name" ? sortOrder[1] === "asc" ? (a, b) => compare(a.name, b.name) : (a, b) => compare(b.name, a.name) : (a, b) => compare(b.lastModified, a.lastModified);
46
51
  return list.sort(sortFunction);
47
- }, [root, currentNode, searchTerm, sortOrder]), selectedPaths = useMemo(() => new Set(selectedDocuments.map((d) => d.path)), [selectedDocuments]), handleSearchChange = useCallback((e) => {
52
+ }, [root, currentNode, searchTerm, sortOrder, roles]), selectedPaths = useMemo(() => new Set(selectedDocuments.map((d) => d.path)), [selectedDocuments]), handleSearchChange = useCallback((e) => {
48
53
  setSearchTerm(e.target.value);
49
54
  }, [setSearchTerm]);
50
55
  function getSortOrderLabel() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.6.0-develop-integration.20260716154944",
3
+ "version": "2.6.0-develop-integration.20260717095527",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -140,9 +140,9 @@
140
140
  "swiper": "10.1.0",
141
141
  "ua-parser-js": "1.0.36",
142
142
  "zustand": "4.5.7",
143
- "@edifice.io/bootstrap": "2.6.0-develop-integration.20260716154944",
144
- "@edifice.io/tiptap-extensions": "2.6.0-develop-integration.20260716154944",
145
- "@edifice.io/utilities": "2.6.0-develop-integration.20260716154944"
143
+ "@edifice.io/tiptap-extensions": "2.6.0-develop-integration.20260717095527",
144
+ "@edifice.io/bootstrap": "2.6.0-develop-integration.20260717095527",
145
+ "@edifice.io/utilities": "2.6.0-develop-integration.20260717095527"
146
146
  },
147
147
  "devDependencies": {
148
148
  "@babel/plugin-transform-react-pure-annotations": "7.27.1",
@@ -173,8 +173,8 @@
173
173
  "vite": "5.4.14",
174
174
  "vite-plugin-dts": "4.5.4",
175
175
  "vite-tsconfig-paths": "5.1.4",
176
- "@edifice.io/client": "2.6.0-develop-integration.20260716154944",
177
- "@edifice.io/config": "2.6.0-develop-integration.20260716154944"
176
+ "@edifice.io/client": "2.6.0-develop-integration.20260717095527",
177
+ "@edifice.io/config": "2.6.0-develop-integration.20260717095527"
178
178
  },
179
179
  "peerDependencies": {
180
180
  "@react-spring/web": "9.7.5",