@edifice.io/react 2.2.8-develop.20250605102441 → 2.2.9-develop-b2school.20250611105531
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/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.js +1 -1
- package/dist/components/Button/IconButton.js +1 -1
- package/dist/components/Combobox/Combobox.d.ts +26 -7
- package/dist/components/Combobox/Combobox.js +37 -16
- package/dist/components/Combobox/ComboboxTrigger.d.ts +35 -3
- package/dist/components/Combobox/ComboboxTrigger.js +35 -8
- package/dist/components/Dropdown/Dropdown.d.ts +14 -2
- package/dist/components/Dropdown/Dropdown.js +6 -3
- package/dist/components/Dropdown/DropdownItem.d.ts +5 -1
- package/dist/components/Dropdown/DropdownItem.js +4 -1
- package/dist/components/Dropdown/DropdownTrigger.js +5 -1
- package/dist/components/Input/Input.d.ts +4 -0
- package/dist/components/Input/Input.js +21 -5
- package/dist/components/Layout/components/Header.js +1 -1
- package/dist/components/List/List.d.ts +16 -1
- package/dist/components/List/List.js +30 -26
- package/dist/components/Modal/ModalHeader.js +2 -2
- package/dist/components/SearchBar/SearchBar.d.ts +1 -1
- package/dist/components/SearchBar/SearchBar.js +3 -1
- package/dist/components/Toolbar/Toolbar.d.ts +4 -0
- package/dist/components/Toolbar/Toolbar.js +8 -3
- package/dist/components/Tree/components/Tree.js +1 -2
- package/dist/components/Tree/hooks/useTree.d.ts +0 -1
- package/dist/components/Tree/hooks/useTree.js +2 -25
- package/dist/components/Tree/types/index.d.ts +0 -4
- package/dist/editor.js +28 -24
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCheckable/useCheckable.js +10 -3
- package/dist/hooks/useConversation/useConversation.d.ts +1 -1
- package/dist/hooks/useConversation/useConversation.js +15 -17
- package/dist/hooks/useDate/useDate.d.ts +1 -0
- package/dist/hooks/useDate/useDate.js +33 -27
- package/dist/hooks/useDropdown/useDropdown.d.ts +2 -1
- package/dist/hooks/useDropdown/useDropdown.js +9 -5
- package/dist/hooks/useHttpErrorToast/useHttpErrorToast.js +12 -3
- package/dist/hooks/useWorkspaceFolders/index.d.ts +3 -0
- package/dist/hooks/useWorkspaceFolders/useWorkspaceFolders.js +54 -0
- package/dist/hooks/useWorkspaceFolders/useWorkspaceFoldersTree.d.ts +13 -0
- package/dist/hooks/useWorkspaceFolders/useWorkspaceFoldersTree.js +51 -0
- package/dist/icons.js +236 -216
- package/dist/index.d.ts +1 -0
- package/dist/index.js +50 -20
- package/dist/modals.js +16 -14
- package/dist/modules/editor/components/Editor/Editor.d.ts +8 -1
- package/dist/modules/editor/components/Editor/Editor.js +7 -3
- package/dist/modules/editor/components/NodeView/ConversationHistoryNodeView.d.ts +2 -0
- package/dist/modules/editor/components/NodeView/ConversationHistoryNodeView.js +10 -0
- package/dist/modules/editor/components/NodeView/index.d.ts +2 -1
- package/dist/modules/editor/components/Renderer/ConversationHistoryRenderer.d.ts +8 -0
- package/dist/modules/editor/components/Renderer/ConversationHistoryRenderer.js +28 -0
- package/dist/modules/editor/components/Renderer/index.d.ts +2 -1
- package/dist/modules/editor/hooks/useTipTapEditor.d.ts +6 -2
- package/dist/modules/editor/hooks/useTipTapEditor.js +2 -2
- package/dist/modules/icons/components/IconFolderAdd.d.ts +7 -0
- package/dist/modules/icons/components/IconFolderAdd.js +13 -0
- package/dist/modules/icons/components/IconFolderDelete.d.ts +7 -0
- package/dist/modules/icons/components/IconFolderDelete.js +12 -0
- package/dist/modules/icons/components/IconGlobe2.d.ts +7 -0
- package/dist/modules/icons/components/IconGlobe2.js +16 -0
- package/dist/modules/icons/components/IconGroupAvatar.d.ts +7 -0
- package/dist/modules/icons/components/IconGroupAvatar.js +12 -0
- package/dist/modules/icons/components/IconMailRecall.d.ts +7 -0
- package/dist/modules/icons/components/IconMailRecall.js +13 -0
- package/dist/modules/icons/components/IconQuestionMark.d.ts +7 -0
- package/dist/modules/icons/components/IconQuestionMark.js +13 -0
- package/dist/modules/icons/components/IconReadMail.d.ts +7 -0
- package/dist/modules/icons/components/IconReadMail.js +16 -0
- package/dist/modules/icons/components/IconSignature.d.ts +7 -0
- package/dist/modules/icons/components/IconSignature.js +13 -0
- package/dist/modules/icons/components/IconUndoAll.d.ts +7 -0
- package/dist/modules/icons/components/IconUndoAll.js +14 -0
- package/dist/modules/icons/components/IconUnreadMail.d.ts +7 -0
- package/dist/modules/icons/components/IconUnreadMail.js +16 -0
- package/dist/modules/icons/components/index.d.ts +10 -0
- package/dist/modules/modals/ConfirmModal/ConfirmModal.d.ts +47 -0
- package/dist/modules/modals/ConfirmModal/ConfirmModal.js +37 -0
- package/dist/modules/modals/ConfirmModal/index.d.ts +1 -0
- package/dist/modules/modals/OnboardingModal/OnboardingModal.d.ts +9 -5
- package/dist/modules/modals/OnboardingModal/OnboardingModal.js +5 -4
- package/dist/modules/modals/index.d.ts +1 -0
- package/dist/modules/multimedia/WorkspaceFolders/WorkspaceFolders.d.ts +8 -0
- package/dist/modules/multimedia/WorkspaceFolders/WorkspaceFolders.js +55 -0
- package/dist/modules/multimedia/WorkspaceFolders/components/NewFolderForm.d.ts +16 -0
- package/dist/modules/multimedia/WorkspaceFolders/components/NewFolderForm.js +39 -0
- package/dist/modules/multimedia/WorkspaceFolders/index.d.ts +1 -0
- package/dist/modules/multimedia/index.d.ts +1 -0
- package/dist/multimedia.js +3 -1
- package/package.json +6 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useState, useRef, useEffect, createElement } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
+
import useBreakpoint from "../../hooks/useBreakpoint/useBreakpoint.js";
|
|
4
5
|
import { mergeRefs } from "../../utilities/refs/ref.js";
|
|
5
6
|
import Tooltip from "../Tooltip/Tooltip.js";
|
|
6
7
|
import Button from "../Button/Button.js";
|
|
@@ -12,9 +13,12 @@ const Toolbar = /* @__PURE__ */ forwardRef(({
|
|
|
12
13
|
align = "space",
|
|
13
14
|
isBlock = !1,
|
|
14
15
|
ariaControls,
|
|
15
|
-
className
|
|
16
|
+
className,
|
|
17
|
+
shouldHideLabelsOnMobile = !1
|
|
16
18
|
}, ref) => {
|
|
17
|
-
const [firstFocusableItemIndex, setFirstFocusableItemIndex] = useState(0), [a11yNavigationItems, setA11yNavigationItems] = useState([]), [firstA11yNavigationItem, setFirstA11yNavigationItem] = useState(), [lastA11yNavigationItem, setA11yNavigationLastItem] = useState(), divToolbarRef = useRef(),
|
|
19
|
+
const [firstFocusableItemIndex, setFirstFocusableItemIndex] = useState(0), [a11yNavigationItems, setA11yNavigationItems] = useState([]), [firstA11yNavigationItem, setFirstA11yNavigationItem] = useState(), [lastA11yNavigationItem, setA11yNavigationLastItem] = useState(), divToolbarRef = useRef(), {
|
|
20
|
+
lg
|
|
21
|
+
} = useBreakpoint(), classes = clsx("toolbar z-1000 bg-white", className, {
|
|
18
22
|
default: variant === "default",
|
|
19
23
|
"no-shadow": variant === "no-shadow",
|
|
20
24
|
"d-flex": isBlock,
|
|
@@ -57,11 +61,12 @@ const Toolbar = /* @__PURE__ */ forwardRef(({
|
|
|
57
61
|
};
|
|
58
62
|
return /* @__PURE__ */ jsx("div", { ref: mergeRefs(ref, divToolbarRef), className: classes, role: "toolbar", "aria-label": "Text Formatting", "aria-controls": ariaControls, onFocus: handleFocus, onBlur: handleBlur, children: items.map((item, index) => {
|
|
59
63
|
if (item.visibility === "hide") return null;
|
|
64
|
+
const hideLabel = shouldHideLabelsOnMobile && !lg;
|
|
60
65
|
switch (item.type) {
|
|
61
66
|
case "divider":
|
|
62
67
|
return /* @__PURE__ */ jsx("div", { className: "toolbar-divider" }, item.name ?? index);
|
|
63
68
|
case "button":
|
|
64
|
-
return /* @__PURE__ */ jsx(Tooltip, { message: renderTooltipMessage(item), placement: renderTooltipPosition(item), children: /* @__PURE__ */ createElement(Button, { ...item.props, key: item.name ?? index, color: item.props.color
|
|
69
|
+
return /* @__PURE__ */ jsx(Tooltip, { message: hideLabel ? renderTooltipMessage(item) : void 0, placement: renderTooltipPosition(item), children: /* @__PURE__ */ createElement(Button, { ...item.props, children: !hideLabel && item.props.children, "aria-label": item.name, key: item.name ?? index, color: item.props.color || "tertiary", variant: "ghost", tabIndex: index === firstFocusableItemIndex ? 0 : -1, onKeyDown: handleKeyDown }) }, item.name ?? index);
|
|
65
70
|
case "icon":
|
|
66
71
|
return /* @__PURE__ */ jsx(Tooltip, { message: renderTooltipMessage(item), placement: renderTooltipPosition(item), children: /* @__PURE__ */ createElement(IconButton, { ...item.props, key: item.name ?? index, color: item.props.color ? item.props.color : "tertiary", variant: item.props.variant ? item.props.variant : "ghost", tabIndex: index === firstFocusableItemIndex ? 0 : -1, onKeyDown: handleKeyDown }) }, item.name ?? index);
|
|
67
72
|
case "dropdown":
|
|
@@ -19,7 +19,6 @@ const Tree = ({
|
|
|
19
19
|
const {
|
|
20
20
|
selectedNodeId,
|
|
21
21
|
expandedNodes,
|
|
22
|
-
siblingsNodes,
|
|
23
22
|
handleItemClick,
|
|
24
23
|
handleFoldUnfold
|
|
25
24
|
} = useTree({
|
|
@@ -31,7 +30,7 @@ const Tree = ({
|
|
|
31
30
|
onTreeItemFold,
|
|
32
31
|
onTreeItemUnfold
|
|
33
32
|
});
|
|
34
|
-
return /* @__PURE__ */ jsx("div", { className: "treeview", children: /* @__PURE__ */ jsx("ul", { role: "tree", className: "m-0 p-0", children: Array.isArray(nodes) ? nodes.map((node) => /* @__PURE__ */ jsx(TreeNode, { node, showIcon, selectedNodeId, expandedNodes,
|
|
33
|
+
return /* @__PURE__ */ jsx("div", { className: "treeview", children: /* @__PURE__ */ jsx("ul", { role: "tree", className: "m-0 p-0", children: Array.isArray(nodes) ? nodes.map((node) => /* @__PURE__ */ jsx(TreeNode, { node, showIcon, selectedNodeId, expandedNodes, onTreeItemClick: handleItemClick, onToggleNode: handleFoldUnfold, renderNode }, node.id)) : /* @__PURE__ */ jsx(TreeNode, { node: nodes, selectedNodeId, expandedNodes, showIcon, onTreeItemClick: handleItemClick, onToggleNode: handleFoldUnfold }) }) });
|
|
35
34
|
}, TreeNode = /* @__PURE__ */ forwardRef(({
|
|
36
35
|
node,
|
|
37
36
|
selectedNodeId,
|
|
@@ -23,7 +23,6 @@ export declare const useTree: ({ data, externalSelectedNodeId, draggedNode, shou
|
|
|
23
23
|
}) => {
|
|
24
24
|
selectedNodeId: string | null | undefined;
|
|
25
25
|
expandedNodes: Set<string>;
|
|
26
|
-
siblingsNodes: import('react').MutableRefObject<Set<string>>;
|
|
27
26
|
draggedNodeId: string | undefined;
|
|
28
27
|
handleItemClick: (nodeId: string) => void;
|
|
29
28
|
handleFoldUnfold: (nodeId: string) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState,
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
2
|
import { findNodeById, findPathById } from "../utilities/tree.js";
|
|
3
3
|
const useTree = ({
|
|
4
4
|
data,
|
|
@@ -9,33 +9,11 @@ const useTree = ({
|
|
|
9
9
|
onTreeItemFold,
|
|
10
10
|
onTreeItemClick
|
|
11
11
|
}) => {
|
|
12
|
-
const [internalSelectedNodeId, setInternalSelectedNodeId] = useState(void 0), [expandedNodes, setExpandedNodes] = useState(/* @__PURE__ */ new Set()),
|
|
13
|
-
function addNodesWithSiblingHavingChildren(data2) {
|
|
14
|
-
var _a;
|
|
15
|
-
Array.isArray(data2) ? data2.forEach((node) => {
|
|
16
|
-
const resultSet = new Set(siblingsNodes.current);
|
|
17
|
-
data2.filter(({
|
|
18
|
-
id
|
|
19
|
-
}) => id !== node.id).some((sibling) => sibling.children && sibling.children.length > 0) && resultSet.add(node.id), node.children && node.children.length > 0 && node.children.forEach((child) => {
|
|
20
|
-
var _a2;
|
|
21
|
-
const childSiblings = (_a2 = node.children) == null ? void 0 : _a2.filter(({
|
|
22
|
-
id
|
|
23
|
-
}) => id !== child.id);
|
|
24
|
-
(childSiblings == null ? void 0 : childSiblings.some((sibling) => sibling.children && sibling.children.length > 0)) && resultSet.add(child.id), addNodesWithSiblingHavingChildren(child);
|
|
25
|
-
});
|
|
26
|
-
}) : (_a = data2.children) == null || _a.forEach((child) => {
|
|
27
|
-
var _a2;
|
|
28
|
-
const resultSet = new Set(siblingsNodes.current), siblings = (_a2 = data2.children) == null ? void 0 : _a2.filter((c) => c.id !== child.id);
|
|
29
|
-
(siblings == null ? void 0 : siblings.some((sibling) => sibling.children && sibling.children.length > 0)) && (resultSet.add(child.id), siblingsNodes.current = resultSet), addNodesWithSiblingHavingChildren(child);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
const expandAllNodes = (shouldExpandAllNodes2) => {
|
|
12
|
+
const [internalSelectedNodeId, setInternalSelectedNodeId] = useState(void 0), [expandedNodes, setExpandedNodes] = useState(/* @__PURE__ */ new Set()), [draggedNodeId, setDraggedNodeId] = useState(void 0), selectedNodeId = internalSelectedNodeId ?? externalSelectedNodeId, expandAllNodes = (shouldExpandAllNodes2) => {
|
|
33
13
|
const initExpandedNodes = new Set("");
|
|
34
14
|
data && Array.isArray(data) && shouldExpandAllNodes2 && (data.forEach((node) => initExpandedNodes.add(node.id)), setExpandedNodes(initExpandedNodes));
|
|
35
15
|
};
|
|
36
16
|
useEffect(() => {
|
|
37
|
-
data && addNodesWithSiblingHavingChildren(data);
|
|
38
|
-
}, [data]), useEffect(() => {
|
|
39
17
|
draggedNode != null && draggedNode.isOver && draggedNode.isTreeview ? (draggedNode.overId && handleItemDrag(draggedNode.overId), setDraggedNodeId(draggedNode.overId)) : setDraggedNodeId(void 0);
|
|
40
18
|
}, [draggedNode]), useEffect(() => {
|
|
41
19
|
shouldExpandAllNodes && expandAllNodes(shouldExpandAllNodes);
|
|
@@ -73,7 +51,6 @@ const useTree = ({
|
|
|
73
51
|
return {
|
|
74
52
|
selectedNodeId,
|
|
75
53
|
expandedNodes,
|
|
76
|
-
siblingsNodes,
|
|
77
54
|
draggedNodeId,
|
|
78
55
|
handleItemClick,
|
|
79
56
|
handleFoldUnfold,
|
|
@@ -115,10 +115,6 @@ export interface TreeNodeProps extends ComponentPropsWithRef<'li'>, SharedTreePr
|
|
|
115
115
|
* Nodes expanded (opened)
|
|
116
116
|
*/
|
|
117
117
|
expandedNodes: Set<string>;
|
|
118
|
-
/**
|
|
119
|
-
* Siblings nodes
|
|
120
|
-
*/
|
|
121
|
-
siblingsNodes?: React.MutableRefObject<Set<string>>;
|
|
122
118
|
/**
|
|
123
119
|
* Node is a child
|
|
124
120
|
*/
|
package/dist/editor.js
CHANGED
|
@@ -2,19 +2,21 @@ import { EditorContent, Editor, useEditor } from "@tiptap/react";
|
|
|
2
2
|
import { default as default2 } from "@tiptap/starter-kit";
|
|
3
3
|
import { default as default3 } from "./modules/editor/components/Editor/Editor.js";
|
|
4
4
|
import { default as default4 } from "./modules/editor/components/BubbleMenuEditImage/BubbleMenuEditImage.js";
|
|
5
|
-
import { default as default5 } from "./modules/editor/components/NodeView/
|
|
6
|
-
import { default as default6 } from "./modules/editor/components/NodeView/
|
|
7
|
-
import { default as default7 } from "./modules/editor/components/NodeView/
|
|
8
|
-
import { default as default8 } from "./modules/editor/components/NodeView/
|
|
9
|
-
import { default as default9 } from "./modules/editor/components/NodeView/
|
|
10
|
-
import { default as default10 } from "./modules/editor/components/NodeView/
|
|
11
|
-
import { default as default11 } from "./modules/editor/components/
|
|
5
|
+
import { default as default5 } from "./modules/editor/components/NodeView/AttachmentNodeView.js";
|
|
6
|
+
import { default as default6 } from "./modules/editor/components/NodeView/AudioNodeView.js";
|
|
7
|
+
import { default as default7 } from "./modules/editor/components/NodeView/ConversationHistoryNodeView.js";
|
|
8
|
+
import { default as default8 } from "./modules/editor/components/NodeView/ImageNodeView.js";
|
|
9
|
+
import { default as default9 } from "./modules/editor/components/NodeView/LinkerNodeView.js";
|
|
10
|
+
import { default as default10 } from "./modules/editor/components/NodeView/VideoNodeView.js";
|
|
11
|
+
import { default as default11 } from "./modules/editor/components/NodeView/InformationPaneNodeView.js";
|
|
12
12
|
import { default as default12 } from "./modules/editor/components/Renderer/AttachmentRenderer.js";
|
|
13
|
-
import { default as default13 } from "./modules/editor/components/Renderer/
|
|
14
|
-
import { default as default14 } from "./modules/editor/components/Renderer/
|
|
15
|
-
import { default as default15 } from "./modules/editor/components/Renderer/
|
|
16
|
-
import { default as default16 } from "./modules/editor/components/
|
|
17
|
-
import { default as default17 } from "./modules/editor/components/
|
|
13
|
+
import { default as default13 } from "./modules/editor/components/Renderer/AudioRenderer.js";
|
|
14
|
+
import { default as default14 } from "./modules/editor/components/Renderer/ConversationHistoryRenderer.js";
|
|
15
|
+
import { default as default15 } from "./modules/editor/components/Renderer/LinkerRenderer.js";
|
|
16
|
+
import { default as default16 } from "./modules/editor/components/Renderer/MediaRenderer.js";
|
|
17
|
+
import { default as default17 } from "./modules/editor/components/Renderer/InformationPaneRenderer.js";
|
|
18
|
+
import { default as default18 } from "./modules/editor/components/Toolbar/TableToolbar.js";
|
|
19
|
+
import { default as default19 } from "./modules/editor/components/Toolbar/LinkToolbar.js";
|
|
18
20
|
import { EditorToolbar } from "./modules/editor/components/EditorToolbar/EditorToolbar.js";
|
|
19
21
|
import { useActionOptions } from "./modules/editor/hooks/useActionOptions.js";
|
|
20
22
|
import { useCommentEditor } from "./modules/editor/hooks/useCommentEditor.js";
|
|
@@ -30,26 +32,28 @@ import { useSpeechSynthetisis } from "./modules/editor/hooks/useSpeechSynthetisi
|
|
|
30
32
|
import { useTipTapEditor } from "./modules/editor/hooks/useTipTapEditor.js";
|
|
31
33
|
import { useCantooEditor } from "./modules/editor/hooks/useCantooEditor.js";
|
|
32
34
|
export {
|
|
33
|
-
|
|
35
|
+
default5 as AttachmentNodeView,
|
|
34
36
|
default12 as AttachmentRenderer,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
default6 as AudioNodeView,
|
|
38
|
+
default13 as AudioRenderer,
|
|
37
39
|
default4 as BubbleMenuEditImage,
|
|
40
|
+
default7 as ConversationHistoryNodeView,
|
|
41
|
+
default14 as ConversationHistoryRenderer,
|
|
38
42
|
default3 as Editor,
|
|
39
43
|
EditorContent,
|
|
40
44
|
EditorContext,
|
|
41
45
|
Editor as EditorInstance,
|
|
42
46
|
EditorToolbar,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
default8 as ImageNodeView,
|
|
48
|
+
default11 as InformationPaneNodeView,
|
|
49
|
+
default17 as InformationPaneRenderer,
|
|
50
|
+
default19 as LinkToolbar,
|
|
51
|
+
default9 as LinkerNodeView,
|
|
52
|
+
default15 as LinkerRenderer,
|
|
53
|
+
default16 as MediaRenderer,
|
|
50
54
|
default2 as StarterKit,
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
default18 as TableToolbar,
|
|
56
|
+
default10 as VideoNodeView,
|
|
53
57
|
useActionOptions,
|
|
54
58
|
useCantooEditor,
|
|
55
59
|
useCommentEditor,
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from './useUpload';
|
|
|
29
29
|
export * from './useUploadFiles';
|
|
30
30
|
export * from './useUser';
|
|
31
31
|
export * from './useWorkspaceFile';
|
|
32
|
+
export * from './useWorkspaceFolders';
|
|
32
33
|
export * from './useWorkspaceSearch';
|
|
33
34
|
export * from './useXitiTrackPageLoad';
|
|
34
35
|
export * from './useZendeskGuide';
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
2
|
const useCheckable = (data) => {
|
|
3
|
-
const [selectedItems, setSelectedItems] = useState([])
|
|
3
|
+
const [selectedItems, setSelectedItems] = useState([]);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (data) {
|
|
6
|
+
const validSelectedItems = selectedItems.filter((id) => data.some((item) => item._id === id));
|
|
7
|
+
validSelectedItems.length !== selectedItems.length && setSelectedItems(validSelectedItems);
|
|
8
|
+
}
|
|
9
|
+
}, [data]);
|
|
10
|
+
const handleOnSelectItem = (itemId) => {
|
|
4
11
|
setSelectedItems((currentSelection) => {
|
|
5
12
|
const newSelection = [...currentSelection];
|
|
6
13
|
return newSelection.includes(itemId) ? newSelection.splice(newSelection.indexOf(itemId), 1) : newSelection.push(itemId), newSelection;
|
|
7
14
|
});
|
|
8
15
|
}, handleOnSelectAllItems = (deselect) => {
|
|
9
16
|
setSelectedItems(() => deselect ? [] : (data == null ? void 0 : data.map((item) => item._id)) ?? []);
|
|
10
|
-
}, allItemsSelected = (selectedItems == null ? void 0 : selectedItems.length) === (data == null ? void 0 : data.length), isIndeterminate = data ? (selectedItems == null ? void 0 : selectedItems.length) > 0 && (selectedItems == null ? void 0 : selectedItems.length) < (data == null ? void 0 : data.length) : !1;
|
|
17
|
+
}, allItemsSelected = (selectedItems == null ? void 0 : selectedItems.length) === (data == null ? void 0 : data.length) && (data == null ? void 0 : data.length) > 0, isIndeterminate = data ? (selectedItems == null ? void 0 : selectedItems.length) > 0 && (selectedItems == null ? void 0 : selectedItems.length) < (data == null ? void 0 : data.length) : !1;
|
|
11
18
|
return {
|
|
12
19
|
selectedItems,
|
|
13
20
|
allItemsSelected,
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { useState, useEffect } from "react";
|
|
2
2
|
import { odeServices } from "@edifice.io/client";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
4
|
import useHasWorkflow from "../useHasWorkflow/useHasWorkflow.js";
|
|
4
5
|
const useConversation = () => {
|
|
5
|
-
const zimbraWorkflow = useHasWorkflow("fr.openent.zimbra.controllers.ZimbraController|view"), zimbraPreauth = useHasWorkflow("fr.openent.zimbra.controllers.ZimbraController|preauth"), [
|
|
6
|
+
const zimbraWorkflow = useHasWorkflow("fr.openent.zimbra.controllers.ZimbraController|view"), zimbraPreauth = useHasWorkflow("fr.openent.zimbra.controllers.ZimbraController|preauth"), [msgLink, setMsgLink] = useState(""), queryParams = {
|
|
6
7
|
unread: !0,
|
|
7
8
|
_: (/* @__PURE__ */ new Date()).getTime()
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, goToMessagerie = async () => {
|
|
9
|
+
}, {
|
|
10
|
+
data: messages
|
|
11
|
+
} = useQuery({
|
|
12
|
+
queryKey: ["folder", "count", "inbox", {
|
|
13
|
+
unread: !0
|
|
14
|
+
}],
|
|
15
|
+
queryFn: async () => await odeServices.http().get(zimbraWorkflow ? "/zimbra/count/INBOX" : "/conversation/count/inbox", {
|
|
16
|
+
queryParams
|
|
17
|
+
}),
|
|
18
|
+
staleTime: 5 * 60 * 1e3
|
|
19
|
+
// 5 minutes
|
|
20
|
+
}), goToMessagerie = async () => {
|
|
21
21
|
const defaultLink = "/zimbra/zimbra";
|
|
22
22
|
try {
|
|
23
23
|
const {
|
|
@@ -29,11 +29,9 @@ const useConversation = () => {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
return useEffect(() => {
|
|
32
|
-
refreshMails();
|
|
33
|
-
}, []), useEffect(() => {
|
|
34
32
|
goToMessagerie();
|
|
35
33
|
}, []), {
|
|
36
|
-
messages,
|
|
34
|
+
messages: messages ? messages.count : 0,
|
|
37
35
|
msgLink,
|
|
38
36
|
zimbraWorkflow
|
|
39
37
|
};
|
|
@@ -11,4 +11,5 @@ export type CoreDate = IsoDate | MongoDate | NumberDate;
|
|
|
11
11
|
export default function useDate(): {
|
|
12
12
|
fromNow: (date: CoreDate | NumberDate) => string;
|
|
13
13
|
formatDate: (date: CoreDate, format?: string) => string;
|
|
14
|
+
formatTimeAgo: (date: CoreDate | NumberDate) => string;
|
|
14
15
|
};
|
|
@@ -9,13 +9,16 @@ import "dayjs/locale/fr.js";
|
|
|
9
9
|
import "dayjs/locale/it.js";
|
|
10
10
|
import "dayjs/locale/pt.js";
|
|
11
11
|
import { useEdificeClient } from "../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
|
|
12
|
+
import { useTranslation } from "react-i18next";
|
|
12
13
|
dayjs.extend(relativeTime);
|
|
13
14
|
dayjs.extend(customParseFormat);
|
|
14
15
|
dayjs.extend(localizedFormat);
|
|
15
16
|
function useDate() {
|
|
16
17
|
const {
|
|
17
18
|
currentLanguage
|
|
18
|
-
} = useEdificeClient(),
|
|
19
|
+
} = useEdificeClient(), {
|
|
20
|
+
t
|
|
21
|
+
} = useTranslation(), parseDate = useCallback((date, lang) => {
|
|
19
22
|
if (date.length < 11) return dayjs(date, ["YYYY-MM-DD"], lang);
|
|
20
23
|
if (date.split("").findIndex((char) => "0" > char || char > "9") < 0)
|
|
21
24
|
return dayjs(Number.parseInt(date)).locale(currentLanguage);
|
|
@@ -23,41 +26,44 @@ function useDate() {
|
|
|
23
26
|
let day = dayjs(date).locale(currentLanguage);
|
|
24
27
|
return day.isValid() || (day = dayjs(date, ["YYYY-MM-DD HH:mm:ss.SSS"]).locale(currentLanguage)), day;
|
|
25
28
|
}
|
|
26
|
-
}, [currentLanguage]),
|
|
29
|
+
}, [currentLanguage]), toComputedDate = useCallback((date) => {
|
|
27
30
|
let computedDate = dayjs();
|
|
28
31
|
try {
|
|
29
|
-
return typeof date > "u" ?
|
|
32
|
+
return typeof date > "u" ? void 0 : (typeof date == "string" ? computedDate = parseDate(date) : typeof date == "number" ? computedDate = dayjs(date).locale(currentLanguage) : typeof date.$date == "number" ? computedDate = dayjs(new Date(date.$date)).locale(currentLanguage) : typeof date.$date == "string" && (computedDate = parseDate(date.$date)), computedDate);
|
|
30
33
|
} catch (error) {
|
|
31
|
-
|
|
34
|
+
console.error(error);
|
|
32
35
|
}
|
|
36
|
+
return computedDate;
|
|
37
|
+
}, [currentLanguage, parseDate]), formatTimeAgo = useCallback((date) => {
|
|
38
|
+
const computedDate = toComputedDate(date);
|
|
39
|
+
if (!(computedDate != null && computedDate.isValid())) return "";
|
|
40
|
+
const now = dayjs();
|
|
41
|
+
return computedDate.isSame(now, "date") ? computedDate.fromNow() : computedDate.isSame(now.subtract(1, "day"), "date") ? t("date.format.yesterday") : now.diff(computedDate, "days") <= 7 ? computedDate.format(t("date.format.currentWeek")) : computedDate.isSame(now, "year") ? computedDate.format(t("date.format.currentYear")) : computedDate.format(t("date.format.previousYear"));
|
|
42
|
+
}, [currentLanguage, parseDate]), fromNow = useCallback((date) => {
|
|
43
|
+
const computedDate = toComputedDate(date);
|
|
44
|
+
return computedDate != null && computedDate.isValid() ? computedDate.fromNow() : "";
|
|
33
45
|
}, [currentLanguage, parseDate]), formatDate = useCallback((date, format = "short") => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
dayjsFormat = "ll";
|
|
49
|
-
break;
|
|
50
|
-
default:
|
|
51
|
-
dayjsFormat = format;
|
|
52
|
-
}
|
|
53
|
-
return computedDate.isValid() ? computedDate.locale(currentLanguage).format(dayjsFormat) : "";
|
|
54
|
-
} catch (error) {
|
|
55
|
-
return console.error(error), "";
|
|
46
|
+
const computedDate = toComputedDate(date);
|
|
47
|
+
let dayjsFormat = "";
|
|
48
|
+
switch (format) {
|
|
49
|
+
case "short":
|
|
50
|
+
dayjsFormat = "L";
|
|
51
|
+
break;
|
|
52
|
+
case "long":
|
|
53
|
+
dayjsFormat = "LL";
|
|
54
|
+
break;
|
|
55
|
+
case "abbr":
|
|
56
|
+
dayjsFormat = "ll";
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
dayjsFormat = format;
|
|
56
60
|
}
|
|
61
|
+
return computedDate != null && computedDate.isValid() ? computedDate.locale(currentLanguage).format(dayjsFormat) : "";
|
|
57
62
|
}, [currentLanguage, parseDate]);
|
|
58
63
|
return {
|
|
59
64
|
fromNow,
|
|
60
|
-
formatDate
|
|
65
|
+
formatDate,
|
|
66
|
+
formatTimeAgo
|
|
61
67
|
};
|
|
62
68
|
}
|
|
63
69
|
export {
|
|
@@ -27,6 +27,7 @@ export interface UseDropdownProps {
|
|
|
27
27
|
menuProps: Record<string, any>;
|
|
28
28
|
itemProps: Record<string, any>;
|
|
29
29
|
setVisible: Dispatch<SetStateAction<boolean>>;
|
|
30
|
+
openOnSpace?: boolean;
|
|
30
31
|
}
|
|
31
|
-
declare const useDropdown: (placement: Placement | undefined, extraTriggerKeyDownHandler?: (event: React.KeyboardEvent<HTMLButtonElement>) => void, isTriggerHovered?: boolean) => UseDropdownProps;
|
|
32
|
+
declare const useDropdown: (placement: Placement | undefined, extraTriggerKeyDownHandler?: (event: React.KeyboardEvent<HTMLButtonElement>) => void, isTriggerHovered?: boolean, focusOnVisible?: boolean, openOnSpace?: boolean, focusOnMouseEnter?: boolean) => UseDropdownProps;
|
|
32
33
|
export default useDropdown;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useId, useState, useRef, useEffect, useCallback } from "react";
|
|
2
2
|
import { useFloating, offset, size, flip, autoUpdate, useHover, safePolygon } from "@floating-ui/react";
|
|
3
3
|
import { mergeRefs } from "../../utilities/refs/ref.js";
|
|
4
|
-
const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !1) => {
|
|
4
|
+
const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !1, focusOnVisible = !0, openOnSpace = !0, focusOnMouseEnter = !0) => {
|
|
5
5
|
const id = useId(), [visible, setVisible] = useState(!1), [activeIndex, setActiveIndex] = useState(-1), [isFocused, setIsFocused] = useState(null), {
|
|
6
6
|
refs,
|
|
7
7
|
floatingStyles,
|
|
@@ -11,7 +11,7 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
11
11
|
open: visible,
|
|
12
12
|
onOpenChange: setVisible,
|
|
13
13
|
whileElementsMounted: autoUpdate,
|
|
14
|
-
middleware: [offset(
|
|
14
|
+
middleware: [offset(0), size({
|
|
15
15
|
apply({
|
|
16
16
|
rects,
|
|
17
17
|
elements
|
|
@@ -32,7 +32,7 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
32
32
|
});
|
|
33
33
|
const menuRef = useRef(null), triggerRef = useRef(null), itemRefs = useRef({});
|
|
34
34
|
useEffect(() => {
|
|
35
|
-
visible
|
|
35
|
+
visible && menuRef.current && focusOnVisible ? (menuRef.current.focus(), setActiveIndex(0)) : (setActiveIndex(-1), itemRefs.current = {});
|
|
36
36
|
}, [visible]), useEffect(() => {
|
|
37
37
|
if (activeIndex !== -1) {
|
|
38
38
|
const currentItem = Object.values(itemRefs.current)[activeIndex];
|
|
@@ -66,6 +66,8 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
66
66
|
switch (event.code) {
|
|
67
67
|
case " ":
|
|
68
68
|
case "Space":
|
|
69
|
+
if (!openOnSpace)
|
|
70
|
+
break;
|
|
69
71
|
case "Enter":
|
|
70
72
|
case "ArrowDown":
|
|
71
73
|
case "Down":
|
|
@@ -82,8 +84,10 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
82
84
|
}
|
|
83
85
|
extraTriggerKeyDownHandler == null || extraTriggerKeyDownHandler(event), stopEvents(flag, event);
|
|
84
86
|
}, [closeDropdown, openDropdown]), onMenuItemMouseEnter = (event) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
if (focusOnMouseEnter) {
|
|
88
|
+
const index = Object.values(itemRefs.current).findIndex((item) => item.id === event.currentTarget.getAttribute("id"));
|
|
89
|
+
setActiveIndex(index);
|
|
90
|
+
}
|
|
87
91
|
}, onMenuItemKeyDown = useCallback((event, onSuccess) => {
|
|
88
92
|
let flag = !1;
|
|
89
93
|
if (event.shiftKey)
|
|
@@ -8,10 +8,19 @@ const useHttpErrorToast = (options) => {
|
|
|
8
8
|
} = useTranslation();
|
|
9
9
|
return useEffect(() => {
|
|
10
10
|
const subscription = odeServices.notify().events().subscribe(LAYER_NAME.TRANSPORT, (event) => {
|
|
11
|
-
var _a
|
|
12
|
-
|
|
11
|
+
var _a;
|
|
12
|
+
if (!(event != null && event.data)) return;
|
|
13
|
+
const {
|
|
14
|
+
response
|
|
15
|
+
} = event.data, i18nKey = (
|
|
16
|
+
// The payload may include the i18n key of the error message to show,
|
|
17
|
+
((_a = event.data.payload) == null ? void 0 : _a.error) || // otherwise, try showing the translation of some known HTTP error code.
|
|
18
|
+
([400, 401, 403, 404, 408, 413, 500, 504].includes(response == null ? void 0 : response.status) ? `e${event.data.response.status}` : void 0) || // otherwise try showing the statusText (may be technical, in english),
|
|
19
|
+
(response == null ? void 0 : response.statusText)
|
|
20
|
+
);
|
|
21
|
+
typeof i18nKey == "string" && (message.current = t(i18nKey), toast.error(/* @__PURE__ */ React.createElement("div", {
|
|
13
22
|
children: [message.current]
|
|
14
|
-
}), options);
|
|
23
|
+
}), options));
|
|
15
24
|
});
|
|
16
25
|
return () => subscription.revoke();
|
|
17
26
|
}, [t, toast]), message.current;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { odeServices } from "@edifice.io/client";
|
|
2
|
+
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { useMemo, useCallback } from "react";
|
|
4
|
+
import { useEdificeClient } from "../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import useToast from "../useToast/useToast.js";
|
|
7
|
+
function useWorkspaceFolders() {
|
|
8
|
+
const queryClient = useQueryClient(), {
|
|
9
|
+
user
|
|
10
|
+
} = useEdificeClient(), toast = useToast(), {
|
|
11
|
+
t
|
|
12
|
+
} = useTranslation(), {
|
|
13
|
+
data: ownerWorkspaceData = [],
|
|
14
|
+
isLoading: isLoadingOwner
|
|
15
|
+
} = useQuery({
|
|
16
|
+
queryKey: ["workspace", "folders", "owner"],
|
|
17
|
+
queryFn: () => odeServices.workspace().listOwnerFolders(!0)
|
|
18
|
+
}), {
|
|
19
|
+
data: sharedWorkspaceData = [],
|
|
20
|
+
isLoading: isLoadingShared
|
|
21
|
+
} = useQuery({
|
|
22
|
+
queryKey: ["workspace", "folders", "shared"],
|
|
23
|
+
queryFn: () => odeServices.workspace().listSharedFolders(!0)
|
|
24
|
+
}), createFolderMutation = useMutation({
|
|
25
|
+
mutationFn: ({
|
|
26
|
+
folderName,
|
|
27
|
+
folderParentId
|
|
28
|
+
}) => odeServices.workspace().createFolder(folderName, folderParentId),
|
|
29
|
+
onSuccess: (newFolder) => {
|
|
30
|
+
const queryKey = ["workspace", "folders", newFolder.isShared ? "shared" : "owner"];
|
|
31
|
+
queryClient.setQueryData(queryKey, (oldFolders) => [...oldFolders, newFolder]);
|
|
32
|
+
},
|
|
33
|
+
onError: () => {
|
|
34
|
+
toast.error(t("e400"));
|
|
35
|
+
}
|
|
36
|
+
}), folders = useMemo(() => [...ownerWorkspaceData, ...sharedWorkspaceData], [ownerWorkspaceData, sharedWorkspaceData]), canCopyFileIntoFolder = useCallback((folderId) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const folder = folders.find((folder2) => folder2._id === folderId);
|
|
39
|
+
if (!folder || !user) return !1;
|
|
40
|
+
const userId = user.userId;
|
|
41
|
+
if (folder.owner === userId) return !0;
|
|
42
|
+
const userRights = (_a = folder.inheritedShares) == null ? void 0 : _a.filter((right) => right.userId === userId || user.groupsIds.includes(right.groupId)), contrib = "org-entcore-workspace-controllers-WorkspaceController|updateDocument";
|
|
43
|
+
return !!(userRights != null && userRights.find((right) => right[contrib]));
|
|
44
|
+
}, [folders, user]);
|
|
45
|
+
return {
|
|
46
|
+
folders,
|
|
47
|
+
createFolderMutation,
|
|
48
|
+
canCopyFileIntoFolder,
|
|
49
|
+
isLoading: isLoadingOwner || isLoadingShared
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
useWorkspaceFolders as default
|
|
54
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WorkspaceElement } from '@edifice.io/client';
|
|
2
|
+
interface FolderTreeNode {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
children?: FolderTreeNode[];
|
|
6
|
+
}
|
|
7
|
+
export declare const WORKSPACE_USER_FOLDER_ID = "workspace-user-folder-id";
|
|
8
|
+
export declare const WORKSPACE_SHARED_FOLDER_ID = "workspace-shared-folder-id";
|
|
9
|
+
declare function useWorkspaceFoldersTree(folders?: WorkspaceElement[]): {
|
|
10
|
+
foldersTree: FolderTreeNode[];
|
|
11
|
+
filterTree: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
12
|
+
};
|
|
13
|
+
export default useWorkspaceFoldersTree;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useState, useMemo } from "react";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { useEdificeClient } from "../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
|
|
4
|
+
const WORKSPACE_USER_FOLDER_ID = "workspace-user-folder-id", WORKSPACE_SHARED_FOLDER_ID = "workspace-shared-folder-id";
|
|
5
|
+
function useWorkspaceFoldersTree(folders) {
|
|
6
|
+
const {
|
|
7
|
+
t
|
|
8
|
+
} = useTranslation(), {
|
|
9
|
+
user
|
|
10
|
+
} = useEdificeClient(), [searchQuery, setSearchQuery] = useState("");
|
|
11
|
+
return {
|
|
12
|
+
foldersTree: useMemo(() => {
|
|
13
|
+
const userTreeLabel = t("workspace.myDocuments"), sharedTreeLabel = t("workspace.sharedDocuments"), foldersTree = buildTree(folders || [], userTreeLabel, sharedTreeLabel);
|
|
14
|
+
return searchQuery ? filterTree(foldersTree, searchQuery) : foldersTree;
|
|
15
|
+
}, [folders, searchQuery, user]),
|
|
16
|
+
filterTree: setSearchQuery
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const buildTree = (workspaceData, userTreeLabel, sharedTreeLabel) => {
|
|
20
|
+
const nodes = /* @__PURE__ */ new Map(), userTree = [], sharedTree = [];
|
|
21
|
+
return workspaceData.forEach((item) => {
|
|
22
|
+
nodes.set(item._id, {
|
|
23
|
+
id: item._id,
|
|
24
|
+
name: item.name,
|
|
25
|
+
children: []
|
|
26
|
+
});
|
|
27
|
+
}), workspaceData.forEach((item) => {
|
|
28
|
+
var _a;
|
|
29
|
+
const nodeItem = nodes.get(item._id);
|
|
30
|
+
item.eParent && nodes.has(item.eParent) ? (_a = nodes.get(item.eParent)) == null || _a.children.push(nodeItem) : item.isShared ? sharedTree.push(nodeItem) : userTree.push(nodeItem);
|
|
31
|
+
}), [{
|
|
32
|
+
id: WORKSPACE_USER_FOLDER_ID,
|
|
33
|
+
name: userTreeLabel,
|
|
34
|
+
children: userTree
|
|
35
|
+
}, {
|
|
36
|
+
id: WORKSPACE_SHARED_FOLDER_ID,
|
|
37
|
+
name: sharedTreeLabel,
|
|
38
|
+
children: sharedTree
|
|
39
|
+
}];
|
|
40
|
+
}, filterTree = (nodes, search) => nodes.map((node) => {
|
|
41
|
+
const filteredChildren = node.children ? filterTree(node.children, search) : [];
|
|
42
|
+
return node.name.toLowerCase().includes(search.toLowerCase()) || filteredChildren.length > 0 ? {
|
|
43
|
+
...node,
|
|
44
|
+
children: filteredChildren
|
|
45
|
+
} : null;
|
|
46
|
+
}).filter((node) => node !== null);
|
|
47
|
+
export {
|
|
48
|
+
WORKSPACE_SHARED_FOLDER_ID,
|
|
49
|
+
WORKSPACE_USER_FOLDER_ID,
|
|
50
|
+
useWorkspaceFoldersTree as default
|
|
51
|
+
};
|