@edifice.io/react 2.6.11 → 2.6.12-develop-integration-crna.20261101211105
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/Dropdown/Dropdown.js +20 -14
- package/dist/components/Dropdown/DropdownContext.d.ts +5 -0
- package/dist/components/Dropdown/DropdownMenuGroup.js +23 -6
- package/dist/components/Dropdown/DropdownSearchInput.js +16 -8
- package/dist/components/Dropdown/DropdownTrigger.js +24 -8
- package/dist/components/Dropdown/useDropdownItemFilter.js +2 -2
- package/dist/components/Dropdown/useMatchRegistry.d.ts +13 -0
- package/dist/components/Dropdown/useMatchRegistry.js +20 -0
- package/dist/components/Layout/components/Header.js +4 -4
- package/dist/components/Layout/components/NavLink.d.ts +3 -3
- package/dist/components/Layout/components/NavLink.js +5 -3
- package/dist/components/Select/Select.d.ts +14 -1
- package/dist/components/Select/Select.js +11 -5
- package/dist/hooks/useDropdown/useDropdown.d.ts +5 -0
- package/dist/hooks/useDropdown/useDropdown.js +16 -6
- package/dist/hooks/useNextcloudSearch/useNextcloudSearch.d.ts +1 -1
- package/dist/hooks/useNextcloudSearch/useNextcloudSearch.js +2 -2
- package/dist/icons.js +234 -232
- package/dist/index.js +158 -156
- package/dist/modules/homepage/components/Communities/Communities.js +4 -4
- package/dist/modules/homepage/components/Favorites/Favorites.js +1 -4
- package/dist/modules/homepage/components/Header/AccountActionListPopover.d.ts +13 -0
- package/dist/modules/homepage/components/Header/AccountActionListPopover.js +26 -0
- package/dist/modules/homepage/components/Header/ActionItem.d.ts +38 -0
- package/dist/modules/homepage/components/Header/ActionItem.js +34 -0
- package/dist/modules/homepage/components/Header/Header.js +28 -22
- package/dist/modules/homepage/components/Header/MyAppsPopover.d.ts +5 -0
- package/dist/modules/homepage/components/Header/MyAppsPopover.js +28 -0
- package/dist/modules/homepage/components/Header/useSafeHoverPopover.js +32 -0
- package/dist/modules/homepage/components/MessageFlashList/MessageFlash.js +1 -1
- package/dist/modules/homepage/components/Notifications/components/NotificationFilterMenu.js +1 -5
- package/dist/modules/homepage/components/Notifications/components/NotificationOptionsMenu.js +3 -9
- package/dist/modules/icons/components/IconLogout.d.ts +7 -0
- package/dist/modules/icons/components/IconLogout.js +13 -0
- package/dist/modules/icons/components/index.d.ts +1 -0
- package/dist/modules/multimedia/Nextcloud/Nextcloud.js +7 -19
- package/dist/modules/multimedia/Nextcloud/NextcloudLogin.d.ts +12 -0
- package/dist/modules/multimedia/Nextcloud/NextcloudLogin.js +33 -0
- package/dist/modules/multimedia/NextcloudFolders/NextcloudFolders.d.ts +12 -0
- package/dist/modules/multimedia/NextcloudFolders/NextcloudFolders.js +51 -0
- package/dist/modules/multimedia/NextcloudFolders/components/NewFolderForm.d.ts +16 -0
- package/dist/modules/multimedia/NextcloudFolders/components/NewFolderForm.js +51 -0
- package/dist/modules/multimedia/NextcloudFolders/index.d.ts +1 -0
- package/dist/modules/multimedia/index.d.ts +1 -0
- package/dist/multimedia.js +14 -12
- package/package.json +7 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useState,
|
|
2
|
+
import { forwardRef, useState, useImperativeHandle, useCallback, useMemo, useEffect } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import useDropdown from "../../hooks/useDropdown/useDropdown.js";
|
|
5
5
|
import DropdownCheckboxItem from "./DropdownCheckboxItem.js";
|
|
@@ -11,6 +11,7 @@ import DropdownRadioItem from "./DropdownRadioItem.js";
|
|
|
11
11
|
import DropdownSearchInput from "./DropdownSearchInput.js";
|
|
12
12
|
import DropdownSeparator from "./DropdownSeparator.js";
|
|
13
13
|
import DropdownTrigger from "./DropdownTrigger.js";
|
|
14
|
+
import { useMatchRegistry } from "./useMatchRegistry.js";
|
|
14
15
|
import useClickOutside from "../../hooks/useClickOutside/useClickOutside.js";
|
|
15
16
|
const Root = /* @__PURE__ */ forwardRef(({
|
|
16
17
|
children,
|
|
@@ -25,15 +26,11 @@ const Root = /* @__PURE__ */ forwardRef(({
|
|
|
25
26
|
openOnSpace = !0,
|
|
26
27
|
focusOnMouseEnter = !0
|
|
27
28
|
}, refDropdown) => {
|
|
28
|
-
const [searchQuery, setSearchQuery] = useState(""), [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
matchMapRef.current.delete(id);
|
|
34
|
-
const next = matchMapRef.current.size === 0 || [...matchMapRef.current.values()].some(Boolean);
|
|
35
|
-
setHasMatches((prev) => prev !== next ? next : prev);
|
|
36
|
-
}, []), {
|
|
29
|
+
const [searchQuery, setSearchQuery] = useState(""), [hasSearchInput, setHasSearchInput] = useState(!1), {
|
|
30
|
+
hasMatches,
|
|
31
|
+
reportMatch,
|
|
32
|
+
unregisterMatch
|
|
33
|
+
} = useMatchRegistry(), {
|
|
37
34
|
visible,
|
|
38
35
|
isFocused,
|
|
39
36
|
triggerProps,
|
|
@@ -43,6 +40,7 @@ const Root = /* @__PURE__ */ forwardRef(({
|
|
|
43
40
|
setVisible,
|
|
44
41
|
menuRef,
|
|
45
42
|
triggerRef,
|
|
43
|
+
searchInputRef,
|
|
46
44
|
closeDropdown,
|
|
47
45
|
openDropdown
|
|
48
46
|
} = useDropdown(placement, extraTriggerKeyDownHandler, isTriggerHovered, focusOnVisible, openOnSpace, focusOnMouseEnter);
|
|
@@ -57,30 +55,38 @@ const Root = /* @__PURE__ */ forwardRef(({
|
|
|
57
55
|
}));
|
|
58
56
|
const ref = useClickOutside(() => {
|
|
59
57
|
setVisible(!1);
|
|
60
|
-
}),
|
|
58
|
+
}), [rootElement, setRootElement] = useState(null), rootRef = useCallback((node) => {
|
|
59
|
+
ref.current = node, setRootElement(node);
|
|
60
|
+
}, [ref]), value = useMemo(() => ({
|
|
61
61
|
visible,
|
|
62
62
|
isFocused,
|
|
63
63
|
triggerProps,
|
|
64
64
|
menuProps,
|
|
65
65
|
itemProps,
|
|
66
66
|
itemRefs,
|
|
67
|
+
searchInputRef,
|
|
67
68
|
block,
|
|
68
69
|
setVisible,
|
|
69
70
|
openDropdown,
|
|
70
71
|
closeDropdown,
|
|
71
72
|
searchQuery,
|
|
72
73
|
setSearchQuery,
|
|
74
|
+
hasSearchInput,
|
|
75
|
+
setHasSearchInput,
|
|
76
|
+
rootElement,
|
|
73
77
|
hasMatches,
|
|
74
78
|
reportMatch,
|
|
75
79
|
unregisterMatch
|
|
76
|
-
}), [visible, isFocused, triggerProps, menuProps, itemProps, itemRefs, block, setVisible, openDropdown, closeDropdown, searchQuery, hasMatches, reportMatch, unregisterMatch]), dropdown = clsx("dropdown", {
|
|
80
|
+
}), [visible, isFocused, triggerProps, menuProps, itemProps, itemRefs, searchInputRef, block, setVisible, openDropdown, closeDropdown, searchQuery, hasSearchInput, rootElement, hasMatches, reportMatch, unregisterMatch]), dropdown = clsx("dropdown", {
|
|
77
81
|
"w-100": block,
|
|
78
82
|
"dropdown-nowrap": noWrap,
|
|
79
|
-
overflow
|
|
83
|
+
overflow,
|
|
84
|
+
// The search input is positioned over the trigger, within the root box.
|
|
85
|
+
"dropdown-searching": hasSearchInput
|
|
80
86
|
});
|
|
81
87
|
return useEffect(() => {
|
|
82
88
|
onToggle == null || onToggle(visible), visible || setSearchQuery("");
|
|
83
|
-
}, [visible]), /* @__PURE__ */ jsx(DropdownContext.Provider, { value, children: /* @__PURE__ */ jsx("div", { ref, className: dropdown, children: typeof children == "function" ? children(triggerProps, itemRefs, setVisible) : children }) });
|
|
89
|
+
}, [visible]), /* @__PURE__ */ jsx(DropdownContext.Provider, { value, children: /* @__PURE__ */ jsx("div", { ref: rootRef, className: dropdown, children: typeof children == "function" ? children(triggerProps, itemRefs, setVisible) : children }) });
|
|
84
90
|
}), Dropdown = Object.assign(Root, {
|
|
85
91
|
Trigger: DropdownTrigger,
|
|
86
92
|
Menu: DropdownMenu,
|
|
@@ -4,6 +4,11 @@ export interface DropdownContextProps extends OmittedProps {
|
|
|
4
4
|
block?: boolean;
|
|
5
5
|
searchQuery: string;
|
|
6
6
|
setSearchQuery: (query: string) => void;
|
|
7
|
+
/** True while a `Dropdown.SearchInput` is displayed in place of the trigger. */
|
|
8
|
+
hasSearchInput: boolean;
|
|
9
|
+
setHasSearchInput: (hasSearchInput: boolean) => void;
|
|
10
|
+
/** Dropdown root element, where the search input is displayed over the trigger. */
|
|
11
|
+
rootElement: HTMLDivElement | null;
|
|
7
12
|
hasMatches: boolean;
|
|
8
13
|
reportMatch: (id: string, isMatch: boolean) => void;
|
|
9
14
|
unregisterMatch: (id: string) => void;
|
|
@@ -1,12 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef } from "react";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useContext, useCallback, useMemo } from "react";
|
|
3
|
+
import { DropdownContext } from "./DropdownContext.js";
|
|
4
|
+
import { useMatchRegistry } from "./useMatchRegistry.js";
|
|
3
5
|
const DropdownMenuGroup = /* @__PURE__ */ forwardRef(({
|
|
4
6
|
label,
|
|
5
7
|
children
|
|
6
|
-
}, forwardRef2) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
}, forwardRef2) => {
|
|
9
|
+
const context = useContext(DropdownContext), {
|
|
10
|
+
hasMatches,
|
|
11
|
+
reportMatch,
|
|
12
|
+
unregisterMatch
|
|
13
|
+
} = useMatchRegistry(), parentReportMatch = context == null ? void 0 : context.reportMatch, parentUnregisterMatch = context == null ? void 0 : context.unregisterMatch, groupReportMatch = useCallback((id, isMatch) => {
|
|
14
|
+
reportMatch(id, isMatch), parentReportMatch == null || parentReportMatch(id, isMatch);
|
|
15
|
+
}, [reportMatch, parentReportMatch]), groupUnregisterMatch = useCallback((id) => {
|
|
16
|
+
unregisterMatch(id), parentUnregisterMatch == null || parentUnregisterMatch(id);
|
|
17
|
+
}, [unregisterMatch, parentUnregisterMatch]), groupContext = useMemo(() => context && {
|
|
18
|
+
...context,
|
|
19
|
+
reportMatch: groupReportMatch,
|
|
20
|
+
unregisterMatch: groupUnregisterMatch
|
|
21
|
+
}, [context, groupReportMatch, groupUnregisterMatch]);
|
|
22
|
+
return /* @__PURE__ */ jsx(DropdownContext.Provider, { value: groupContext, children: /* @__PURE__ */ jsxs("div", { ref: forwardRef2, role: "group", hidden: !hasMatches, children: [
|
|
23
|
+
/* @__PURE__ */ jsx("span", { className: "small px-4", children: /* @__PURE__ */ jsx("strong", { children: label }) }),
|
|
24
|
+
children
|
|
25
|
+
] }) });
|
|
26
|
+
});
|
|
10
27
|
export {
|
|
11
28
|
DropdownMenuGroup as default
|
|
12
29
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
2
4
|
import { useDropdownContext } from "./DropdownContext.js";
|
|
3
5
|
import SearchBar from "../SearchBar/SearchBar.js";
|
|
4
6
|
const DropdownSearchInput = ({
|
|
@@ -9,15 +11,21 @@ const DropdownSearchInput = ({
|
|
|
9
11
|
const {
|
|
10
12
|
searchQuery,
|
|
11
13
|
setSearchQuery,
|
|
12
|
-
hasMatches
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
hasMatches,
|
|
15
|
+
searchInputRef,
|
|
16
|
+
setHasSearchInput,
|
|
17
|
+
rootElement,
|
|
18
|
+
itemProps
|
|
19
|
+
} = useDropdownContext(), registerSearchInput = useCallback((node) => {
|
|
20
|
+
searchInputRef.current = (node == null ? void 0 : node.querySelector("input")) ?? null, setHasSearchInput(!!node);
|
|
21
|
+
}, [searchInputRef, setHasSearchInput]);
|
|
22
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23
|
+
rootElement && /* @__PURE__ */ createPortal(/* @__PURE__ */ jsx("div", { ref: registerSearchInput, className: "dropdown-search position-absolute top-0 start-0 w-100 h-100 z-1", children: /* @__PURE__ */ jsx(SearchBar, { isVariant: !0, clearable: !0, size: "md", className: "h-100", placeholder, value: searchQuery, onChange: (e) => {
|
|
16
24
|
setSearchQuery(e.target.value), onSearch == null || onSearch(e.target.value);
|
|
17
25
|
}, onKeyDown: (e) => {
|
|
18
|
-
["ArrowUp", "ArrowDown", "Enter", " "].includes(e.key) && e.stopPropagation();
|
|
19
|
-
} }),
|
|
20
|
-
searchQuery && !hasMatches && /* @__PURE__ */ jsx("p", { className: "body-2 text-gray-700 text-center
|
|
26
|
+
(e.key === "ArrowDown" || e.key === "Escape" || e.key === "Tab" && e.shiftKey) && itemProps.onMenuItemKeyDown(e), ["ArrowUp", "ArrowDown", "Enter", " "].includes(e.key) && e.stopPropagation();
|
|
27
|
+
} }) }), rootElement),
|
|
28
|
+
searchQuery && !hasMatches && /* @__PURE__ */ jsx("p", { className: "body-2 text-gray-700 text-center my-8", children: noResultsLabel })
|
|
21
29
|
] });
|
|
22
30
|
};
|
|
23
31
|
export {
|
|
@@ -23,14 +23,30 @@ const DropdownTrigger = /* @__PURE__ */ forwardRef(({
|
|
|
23
23
|
}, forwardRef2) => {
|
|
24
24
|
const {
|
|
25
25
|
triggerProps,
|
|
26
|
-
block
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
block,
|
|
27
|
+
visible,
|
|
28
|
+
hasSearchInput
|
|
29
|
+
} = useDropdownContext(), className = clsx(
|
|
30
|
+
"dropdown-toggle ",
|
|
31
|
+
size,
|
|
32
|
+
variant,
|
|
33
|
+
{
|
|
34
|
+
"w-100": block
|
|
35
|
+
},
|
|
36
|
+
// The open menu covers the trigger with its search input: hide the trigger
|
|
37
|
+
// without removing it, so it keeps its place and can take the focus back.
|
|
38
|
+
{
|
|
39
|
+
"opacity-0": visible && hasSearchInput
|
|
40
|
+
},
|
|
41
|
+
triggerProps.className,
|
|
42
|
+
restProps.className,
|
|
43
|
+
{
|
|
44
|
+
"rounded-pill": pill
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"base-shade": baseShade
|
|
48
|
+
}
|
|
49
|
+
), style = {
|
|
34
50
|
...outerBorderColor && {
|
|
35
51
|
outline: `${outerBorderWidth}px solid var(--edifice-${outerBorderColor})`,
|
|
36
52
|
outlineOffset: outerBorderOffset
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useId, useLayoutEffect } from "react";
|
|
2
2
|
import { useDropdownContext } from "./DropdownContext.js";
|
|
3
|
-
const useDropdownItemFilter = (searchValue) => {
|
|
3
|
+
const normalize = (value) => value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), useDropdownItemFilter = (searchValue) => {
|
|
4
4
|
const {
|
|
5
5
|
searchQuery,
|
|
6
6
|
reportMatch,
|
|
7
7
|
unregisterMatch
|
|
8
|
-
} = useDropdownContext(), id = useId(), isFiltered = searchValue !== void 0 && searchQuery !== "" && !searchValue
|
|
8
|
+
} = useDropdownContext(), id = useId(), isFiltered = searchValue !== void 0 && searchQuery !== "" && !normalize(searchValue).includes(normalize(searchQuery));
|
|
9
9
|
return useLayoutEffect(() => {
|
|
10
10
|
if (searchValue !== void 0)
|
|
11
11
|
return reportMatch(id, !isFiltered), () => unregisterMatch(id);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks which searchable items match the current search query.
|
|
3
|
+
* Used by the Dropdown root (empty state) and by menu groups (hide empty groups).
|
|
4
|
+
*
|
|
5
|
+
* @returns `hasMatches` – true when at least one item matches, or when no item is searchable
|
|
6
|
+
* @returns `reportMatch` – registers or updates the match state of an item
|
|
7
|
+
* @returns `unregisterMatch` – removes an item from the registry
|
|
8
|
+
*/
|
|
9
|
+
export declare const useMatchRegistry: () => {
|
|
10
|
+
hasMatches: boolean;
|
|
11
|
+
reportMatch: (id: string, isMatch: boolean) => void;
|
|
12
|
+
unregisterMatch: (id: string) => void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useState, useRef, useCallback } from "react";
|
|
2
|
+
const useMatchRegistry = () => {
|
|
3
|
+
const [hasMatches, setHasMatches] = useState(!0), matchMapRef = useRef(/* @__PURE__ */ new Map()), reportMatch = useCallback((id, isMatch) => {
|
|
4
|
+
matchMapRef.current.set(id, isMatch);
|
|
5
|
+
const next = [...matchMapRef.current.values()].some(Boolean);
|
|
6
|
+
setHasMatches((prev) => prev !== next ? next : prev);
|
|
7
|
+
}, []), unregisterMatch = useCallback((id) => {
|
|
8
|
+
matchMapRef.current.delete(id);
|
|
9
|
+
const next = matchMapRef.current.size === 0 || [...matchMapRef.current.values()].some(Boolean);
|
|
10
|
+
setHasMatches((prev) => prev !== next ? next : prev);
|
|
11
|
+
}, []);
|
|
12
|
+
return {
|
|
13
|
+
hasMatches,
|
|
14
|
+
reportMatch,
|
|
15
|
+
unregisterMatch
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
useMatchRegistry
|
|
20
|
+
};
|
|
@@ -138,7 +138,7 @@ const Header = ({
|
|
|
138
138
|
/* @__PURE__ */ jsxs("ul", { className: "navbar-nav", children: [
|
|
139
139
|
/* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsx(NavLink, { link: "/timeline/timeline", translate: t("navbar.home"), children: /* @__PURE__ */ jsx(SvgIconHome, { color: "#fff" }) }) }),
|
|
140
140
|
/* @__PURE__ */ jsxs(NavItem, { className: "position-relative", ref: appsRef, id: popoverAppsId, "aria-haspopup": "true", "aria-expanded": isAppsHovered, children: [
|
|
141
|
-
/* @__PURE__ */ jsx(NavLink, { link: "/welcome", translate: t("navbar.applications"), children: /* @__PURE__ */ jsx(SvgIconMyApps, { color: "#fff" }) }),
|
|
141
|
+
/* @__PURE__ */ jsx(NavLink, { link: "/welcome", translate: t("navbar.applications"), "data-testid": "header-my-apps-button", children: /* @__PURE__ */ jsx(SvgIconMyApps, { color: "#fff" }) }),
|
|
142
142
|
/* @__PURE__ */ jsxs(Popover, { className: "top-100 widget", id: popoverAppsId, isVisible: isAppsHovered, children: [
|
|
143
143
|
/* @__PURE__ */ jsx(PopoverBody, { children: /* @__PURE__ */ jsx(WidgetAppsBody, { bookmarkedApps }) }),
|
|
144
144
|
/* @__PURE__ */ jsx(PopoverFooter, { className: "widget-footer border-top border-ghost", children: /* @__PURE__ */ jsx(WidgetAppsFooter, {}) })
|
|
@@ -174,17 +174,17 @@ const Header = ({
|
|
|
174
174
|
/* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsxs("div", { className: "dropdown", children: [
|
|
175
175
|
/* @__PURE__ */ jsx("button", { className: "nav-link btn btn-naked d-md-none", type: "button", "aria-controls": "dropdown-navbar", "aria-expanded": !isCollapsed, "aria-label": t("navbar.open.menu"), onClick: toggleCollapsedNav, children: /* @__PURE__ */ jsx(SvgIconRafterDown, { className: "icon rafter-down", width: "20", height: "20", color: "#fff" }) }),
|
|
176
176
|
/* @__PURE__ */ jsxs("ul", { className: `dropdown-menu dropdown-menu-end ${isCollapsed ? "" : "show"}`, id: "dropdown-navbar", children: [
|
|
177
|
-
communitiesWorkflow && /* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsxs("a", { href: "/communities", className: "nav-link dropdown-item", children: [
|
|
177
|
+
communitiesWorkflow && /* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsxs("a", { href: "/communities", className: "nav-link dropdown-item", "data-testid": "header-community-button", children: [
|
|
178
178
|
/* @__PURE__ */ jsx(SvgIconCommunities, { className: "icon communities" }),
|
|
179
179
|
/* @__PURE__ */ jsx("span", { className: "nav-text", children: t("navbar.community") })
|
|
180
180
|
] }) }),
|
|
181
181
|
searchWorkflow ? /* @__PURE__ */ jsx(SearchEngine, {}) : null,
|
|
182
|
-
/* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsxs("a", { href: "/userbook/mon-compte", className: "nav-link dropdown-item", children: [
|
|
182
|
+
/* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsxs("a", { href: "/userbook/mon-compte", className: "nav-link dropdown-item", "data-testid": "header-user-profile-button", children: [
|
|
183
183
|
/* @__PURE__ */ jsx(Avatar, { alt: userName, size: "sm", src: userAvatar, variant: "circle", className: "bg-white", width: "32", height: "32" }),
|
|
184
184
|
/* @__PURE__ */ jsx("span", { className: "nav-text", children: t("navbar.myaccount") })
|
|
185
185
|
] }) }),
|
|
186
186
|
/* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsx("hr", { className: "dropdown-divider" }) }),
|
|
187
|
-
/* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsxs("a", { href: "/auth/logout?callback=" + ((theme == null ? void 0 : theme.logoutCallback) ?? ""), className: "nav-link dropdown-item", children: [
|
|
187
|
+
/* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsxs("a", { href: "/auth/logout?callback=" + ((theme == null ? void 0 : theme.logoutCallback) ?? ""), className: "nav-link dropdown-item", "data-testid": "header-logout-button", children: [
|
|
188
188
|
/* @__PURE__ */ jsx(SvgIconDisconnect, { className: "icon logout" }),
|
|
189
189
|
/* @__PURE__ */ jsx("span", { id: "logout-label", className: "nav-text", children: t("navbar.disconnect") })
|
|
190
190
|
] }) })
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export interface NavLinkProps<T> {
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
export interface NavLinkProps<T> extends Omit<ComponentPropsWithoutRef<'a'>, 'className' | 'translate'> {
|
|
3
3
|
/**
|
|
4
4
|
* href link
|
|
5
5
|
*/
|
|
@@ -21,4 +21,4 @@ export interface NavLinkProps<T> {
|
|
|
21
21
|
*/
|
|
22
22
|
button?: boolean;
|
|
23
23
|
}
|
|
24
|
-
export declare
|
|
24
|
+
export declare const NavLink: import('react').ForwardRefExoticComponent<NavLinkProps<string> & import('react').RefAttributes<HTMLAnchorElement>>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
2
3
|
import clsx from "clsx";
|
|
3
4
|
import VisuallyHidden from "../../VisuallyHidden/VisuallyHidden.js";
|
|
4
|
-
function
|
|
5
|
+
function NavLinkRender({
|
|
5
6
|
link,
|
|
6
7
|
className,
|
|
7
8
|
children,
|
|
@@ -9,13 +10,14 @@ function NavLink({
|
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
11
|
button,
|
|
11
12
|
...restProps
|
|
12
|
-
}) {
|
|
13
|
+
}, ref) {
|
|
13
14
|
const classes = clsx("nav-link", className);
|
|
14
|
-
return /* @__PURE__ */ jsxs("a", { href: link, className: classes, ...restProps, children: [
|
|
15
|
+
return /* @__PURE__ */ jsxs("a", { ref, href: link, className: classes, ...restProps, children: [
|
|
15
16
|
children,
|
|
16
17
|
translate && /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("span", { className: "nav-text", children: translate }) })
|
|
17
18
|
] });
|
|
18
19
|
}
|
|
20
|
+
const NavLink = /* @__PURE__ */ forwardRef(NavLinkRender);
|
|
19
21
|
export {
|
|
20
22
|
NavLink
|
|
21
23
|
};
|
|
@@ -35,13 +35,26 @@ export interface SelectProps extends Omit<DropdownProps, 'children'>, Omit<Dropd
|
|
|
35
35
|
* Default value
|
|
36
36
|
*/
|
|
37
37
|
defaultValue?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Filter the options with a search input:
|
|
40
|
+
* when the menu opens, the trigger turns into a search field.
|
|
41
|
+
*/
|
|
42
|
+
searchable?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Placeholder of the search input (with `searchable`)
|
|
45
|
+
*/
|
|
46
|
+
searchPlaceholder?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Label shown when no option matches the search (with `searchable`)
|
|
49
|
+
*/
|
|
50
|
+
noResultsLabel?: string;
|
|
38
51
|
}
|
|
39
52
|
/**
|
|
40
53
|
*
|
|
41
54
|
* Select component is based on Dropdown Component. It extends `Dropdown` and `Dropdown.Trigger` props `block`, `overflow`, `icon`, `variant`, `size`, `disabled`
|
|
42
55
|
*/
|
|
43
56
|
declare const Select: {
|
|
44
|
-
({ selectedValue, icon, options, overflow, block, variant, size, disabled, placeholderOption, onValueChange, defaultValue, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
({ selectedValue, icon, options, overflow, block, variant, size, disabled, placeholderOption, onValueChange, defaultValue, searchable, searchPlaceholder, noResultsLabel, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
45
58
|
displayName: string;
|
|
46
59
|
};
|
|
47
60
|
export default Select;
|
|
@@ -14,7 +14,10 @@ const Select = ({
|
|
|
14
14
|
disabled,
|
|
15
15
|
placeholderOption,
|
|
16
16
|
onValueChange,
|
|
17
|
-
defaultValue
|
|
17
|
+
defaultValue,
|
|
18
|
+
searchable,
|
|
19
|
+
searchPlaceholder,
|
|
20
|
+
noResultsLabel
|
|
18
21
|
}) => {
|
|
19
22
|
const [localValue, setLocalValue] = useState(), {
|
|
20
23
|
t
|
|
@@ -35,10 +38,13 @@ const Select = ({
|
|
|
35
38
|
const label = typeof localValue == "object" ? localValue.label : localValue, iconChange = typeof localValue == "object" ? localValue.icon : void 0;
|
|
36
39
|
return /* @__PURE__ */ jsxs(Dropdown, { overflow, block, children: [
|
|
37
40
|
/* @__PURE__ */ jsx(SelectTrigger, { icon: iconChange || icon, label: /* @__PURE__ */ jsx("span", { className: "text-truncate", children: t(label || placeholderOption) }), variant, size, disabled }),
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
/* @__PURE__ */ jsxs(Dropdown.Menu, { role: "listbox", children: [
|
|
42
|
+
searchable && /* @__PURE__ */ jsx(Dropdown.SearchInput, { placeholder: searchPlaceholder, noResultsLabel }),
|
|
43
|
+
options == null ? void 0 : options.map((option) => {
|
|
44
|
+
const value = typeof option == "object" ? option.value : option, label2 = typeof option == "object" ? option.label : option, icon2 = typeof option == "object" ? option.icon : void 0;
|
|
45
|
+
return /* @__PURE__ */ jsx(Dropdown.Item, { type: "action", onClick: () => setLocalValue(option), icon: icon2, searchValue: searchable ? label2 : void 0, children: label2 }, value);
|
|
46
|
+
})
|
|
47
|
+
] })
|
|
42
48
|
] });
|
|
43
49
|
};
|
|
44
50
|
export {
|
|
@@ -23,6 +23,11 @@ export interface UseDropdownProps {
|
|
|
23
23
|
}>;
|
|
24
24
|
triggerRef: MutableRefObject<HTMLButtonElement | null>;
|
|
25
25
|
menuRef: MutableRefObject<HTMLUListElement | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Search input displayed in place of the trigger while the menu is open, if any.
|
|
28
|
+
* When set, it gets the focus on open and is reachable from the items with the keyboard.
|
|
29
|
+
*/
|
|
30
|
+
searchInputRef: MutableRefObject<HTMLInputElement | null>;
|
|
26
31
|
triggerProps: Record<string, any>;
|
|
27
32
|
menuProps: Record<string, any>;
|
|
28
33
|
itemProps: Record<string, any>;
|
|
@@ -2,7 +2,7 @@ import { useId, useState, useRef, useEffect, useCallback } from "react";
|
|
|
2
2
|
import { useFloating, autoUpdate, offset, size, flip, useHover, safePolygon } from "@floating-ui/react";
|
|
3
3
|
import { mergeRefs } from "../../utilities/refs/ref.js";
|
|
4
4
|
const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !1, focusOnVisible = !0, openOnSpace = !0, focusOnMouseEnter = !0) => {
|
|
5
|
-
const id = useId(), [visible, setVisible] = useState(!1), [activeIndex, setActiveIndex] = useState(-1), [isFocused, setIsFocused] = useState(null), {
|
|
5
|
+
const id = useId(), [visible, setVisible] = useState(!1), [activeIndex, setActiveIndex] = useState(-1), [isFocused, setIsFocused] = useState(null), searchInputRef = useRef(null), {
|
|
6
6
|
refs,
|
|
7
7
|
floatingStyles,
|
|
8
8
|
context
|
|
@@ -30,9 +30,14 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
30
30
|
},
|
|
31
31
|
handleClose: safePolygon()
|
|
32
32
|
});
|
|
33
|
-
const menuRef = useRef(null), triggerRef = useRef(null), itemRefs = useRef({})
|
|
33
|
+
const menuRef = useRef(null), triggerRef = useRef(null), itemRefs = useRef({}), focusSearchInput = () => {
|
|
34
|
+
var _a;
|
|
35
|
+
setActiveIndex(-1), setIsFocused(null), (_a = searchInputRef.current) == null || _a.focus({
|
|
36
|
+
preventScroll: !0
|
|
37
|
+
});
|
|
38
|
+
};
|
|
34
39
|
useEffect(() => {
|
|
35
|
-
visible && menuRef.current && focusOnVisible ? (menuRef.current.focus(), setActiveIndex(0)) : (setActiveIndex(-1), itemRefs.current = {});
|
|
40
|
+
visible && searchInputRef.current && focusOnVisible ? focusSearchInput() : visible && menuRef.current && focusOnVisible ? (menuRef.current.focus(), setActiveIndex(0)) : (setActiveIndex(-1), itemRefs.current = {});
|
|
36
41
|
}, [visible]), useEffect(() => {
|
|
37
42
|
if (activeIndex !== -1) {
|
|
38
43
|
const filteredItems = Object.values(itemRefs.current).filter((item) => !!item);
|
|
@@ -49,10 +54,14 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
49
54
|
}, [activeIndex]);
|
|
50
55
|
const visibleItemCount = () => Object.values(itemRefs.current).filter(Boolean).length, nextItem = () => {
|
|
51
56
|
const count = visibleItemCount();
|
|
52
|
-
setActiveIndex((prevIndex) => (prevIndex + 1) % count);
|
|
57
|
+
count !== 0 && setActiveIndex((prevIndex) => (prevIndex + 1) % count);
|
|
53
58
|
}, previousItem = () => {
|
|
59
|
+
if (activeIndex === 0 && searchInputRef.current) {
|
|
60
|
+
focusSearchInput();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
54
63
|
const count = visibleItemCount();
|
|
55
|
-
setActiveIndex((prevIndex) => (prevIndex - 1 + count) % count);
|
|
64
|
+
count !== 0 && setActiveIndex((prevIndex) => (prevIndex - 1 + count) % count);
|
|
56
65
|
}, firstItem = () => {
|
|
57
66
|
setActiveIndex(0);
|
|
58
67
|
}, lastItem = () => {
|
|
@@ -105,7 +114,7 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
105
114
|
break;
|
|
106
115
|
case " ":
|
|
107
116
|
case "Enter":
|
|
108
|
-
activeIndex !== -1 && (Object.values(itemRefs.current)[activeIndex].getAttribute("role") === "menuitem" && triggerRef.current && (triggerRef.current.focus(), setVisible(!1)), onSuccess == null || onSuccess()), flag = !0;
|
|
117
|
+
activeIndex !== -1 && (Object.values(itemRefs.current).filter(Boolean)[activeIndex].getAttribute("role") === "menuitem" && triggerRef.current && (triggerRef.current.focus(), setVisible(!1)), onSuccess == null || onSuccess()), flag = !0;
|
|
109
118
|
break;
|
|
110
119
|
case "ArrowDown":
|
|
111
120
|
case "Down":
|
|
@@ -133,6 +142,7 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
133
142
|
itemRefs,
|
|
134
143
|
triggerRef,
|
|
135
144
|
menuRef,
|
|
145
|
+
searchInputRef,
|
|
136
146
|
/* TriggerProps to spread to any Trigger component */
|
|
137
147
|
triggerProps: {
|
|
138
148
|
ref: mergeRefs(triggerRef, refs.setReference),
|
|
@@ -9,6 +9,6 @@ export default function useNextcloudSearch(rootId: string, rootName: string, use
|
|
|
9
9
|
isCheckingAuth: boolean;
|
|
10
10
|
isAuthError: boolean;
|
|
11
11
|
refetchAuthStatus: () => void;
|
|
12
|
-
loadContent: (folderId?: ID) => void;
|
|
12
|
+
loadContent: (folderId?: ID, force?: boolean) => void;
|
|
13
13
|
loadError: unknown;
|
|
14
14
|
};
|
|
@@ -33,14 +33,14 @@ function useNextcloudSearch(rootId, rootName, userId) {
|
|
|
33
33
|
queryKey: ["nextcloud", "oauth2-status", userId],
|
|
34
34
|
queryFn: () => odeServices.nextcloud().getOauth2Status(userId),
|
|
35
35
|
enabled: !!userId
|
|
36
|
-
}), needsAuth = !((_a = oauth2StatusQuery.data) != null && _a.connected), [loadError, setLoadError] = useState(null), loadContent = useCallback(async (folderId) => {
|
|
36
|
+
}), needsAuth = !((_a = oauth2StatusQuery.data) != null && _a.connected), [loadError, setLoadError] = useState(null), loadContent = useCallback(async (folderId, force = !1) => {
|
|
37
37
|
if (!userId) return;
|
|
38
38
|
const path = folderId === rootId ? void 0 : folderId;
|
|
39
39
|
try {
|
|
40
40
|
const payload = await queryClient.fetchQuery({
|
|
41
41
|
queryKey: ["nextcloud", "documents", userId, path ?? "/"],
|
|
42
42
|
queryFn: () => odeServices.nextcloud().listDocuments(userId, path),
|
|
43
|
-
staleTime: 6e4
|
|
43
|
+
staleTime: force ? 0 : 6e4
|
|
44
44
|
}), subfolders = [], files = [], currentPath = path ?? "/";
|
|
45
45
|
payload.filter((doc) => doc.path !== currentPath).forEach((doc) => {
|
|
46
46
|
doc.isFolder ? subfolders.push(doc) : files.push(doc);
|