@edifice.io/react 2.6.12 → 2.6.13-develop-integration-demo.20261108115137
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 +19 -14
- package/dist/components/Dropdown/DropdownContext.d.ts +8 -0
- package/dist/components/Dropdown/DropdownItem.js +17 -1
- package/dist/components/Dropdown/DropdownMenuGroup.js +24 -6
- package/dist/components/Dropdown/DropdownSearchInput.js +16 -8
- package/dist/components/Dropdown/DropdownTrigger.js +24 -8
- package/dist/components/Dropdown/useDropdownItemFilter.js +5 -7
- package/dist/components/Dropdown/useMatchRegistry.d.ts +5 -0
- package/dist/components/Dropdown/useMatchRegistry.js +20 -0
- package/dist/components/Select/Select.d.ts +14 -1
- package/dist/components/Select/Select.js +11 -5
- package/dist/components/Tree/components/Tree.d.ts +2 -5
- package/dist/components/Tree/components/Tree.js +10 -7
- package/dist/components/Tree/hooks/useTree.d.ts +1 -0
- package/dist/components/Tree/hooks/useTree.js +6 -2
- package/dist/components/Tree/types/index.d.ts +7 -0
- package/dist/homepage.js +28 -24
- package/dist/hooks/useDropdown/useDropdown.d.ts +1 -0
- package/dist/hooks/useDropdown/useDropdown.js +27 -9
- package/dist/hooks/useNextcloudSearch/useNextcloudSearch.d.ts +1 -1
- package/dist/hooks/useNextcloudSearch/useNextcloudSearch.js +2 -2
- package/dist/icons-apps.js +256 -254
- package/dist/index.js +158 -156
- package/dist/modules/editor/components/Editor/Editor.d.ts +5 -0
- package/dist/modules/editor/components/Editor/Editor.js +3 -0
- package/dist/modules/homepage/components/AlloRegion/AlloRegion.d.ts +11 -0
- package/dist/modules/homepage/components/AlloRegion/AlloRegion.js +32 -0
- package/dist/modules/homepage/components/AlloRegion/AlloRegionContainer.d.ts +4 -0
- package/dist/modules/homepage/components/AlloRegion/AlloRegionContainer.js +10 -0
- package/dist/modules/homepage/components/AlloRegion/index.d.ts +3 -0
- package/dist/modules/homepage/components/Favorites/Favorites.js +1 -4
- package/dist/modules/homepage/components/index.d.ts +1 -0
- package/dist/modules/icons/components/apps/IconAlloregion.d.ts +7 -0
- package/dist/modules/icons/components/apps/IconAlloregion.js +17 -0
- package/dist/modules/icons/components/apps/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 +52 -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 +6 -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,37 @@ 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
|
+
"dropdown-searching": hasSearchInput
|
|
80
85
|
});
|
|
81
86
|
return useEffect(() => {
|
|
82
87
|
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 }) });
|
|
88
|
+
}, [visible]), /* @__PURE__ */ jsx(DropdownContext.Provider, { value, children: /* @__PURE__ */ jsx("div", { ref: rootRef, className: dropdown, children: typeof children == "function" ? children(triggerProps, itemRefs, setVisible) : children }) });
|
|
84
89
|
}), Dropdown = Object.assign(Root, {
|
|
85
90
|
Trigger: DropdownTrigger,
|
|
86
91
|
Menu: DropdownMenu,
|
|
@@ -4,9 +4,17 @@ export interface DropdownContextProps extends OmittedProps {
|
|
|
4
4
|
block?: boolean;
|
|
5
5
|
searchQuery: string;
|
|
6
6
|
setSearchQuery: (query: string) => void;
|
|
7
|
+
hasSearchInput: boolean;
|
|
8
|
+
setHasSearchInput: (hasSearchInput: boolean) => void;
|
|
9
|
+
rootElement: HTMLDivElement | null;
|
|
7
10
|
hasMatches: boolean;
|
|
8
11
|
reportMatch: (id: string, isMatch: boolean) => void;
|
|
9
12
|
unregisterMatch: (id: string) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Provided by MenuGroup: an item without searchValue keeps its group visible,
|
|
15
|
+
* without counting as a search result. Returns the unregister function.
|
|
16
|
+
*/
|
|
17
|
+
registerUnfilteredItem?: (id: string) => () => void;
|
|
10
18
|
}
|
|
11
19
|
export declare const DropdownContext: import('react').Context<DropdownContextProps | null>;
|
|
12
20
|
export declare const useDropdownContext: () => DropdownContextProps;
|
|
@@ -39,7 +39,23 @@ const DropdownItem = ({
|
|
|
39
39
|
icon,
|
|
40
40
|
children
|
|
41
41
|
] });
|
|
42
|
-
return isFiltered ? /* @__PURE__ */ jsx(DropdownItemHidden, { children: content }) : /* @__PURE__ */ jsx(
|
|
42
|
+
return isFiltered ? /* @__PURE__ */ jsx(DropdownItemHidden, { children: content }) : /* @__PURE__ */ jsx(
|
|
43
|
+
"div",
|
|
44
|
+
{
|
|
45
|
+
id,
|
|
46
|
+
role: "menuitem",
|
|
47
|
+
style,
|
|
48
|
+
ref: (el) => itemRefs.current[id] = el,
|
|
49
|
+
tabIndex: isFocused === id ? 0 : -1,
|
|
50
|
+
className: dropdownItem,
|
|
51
|
+
"aria-current": isFocused === id,
|
|
52
|
+
onClick: handleOnClick,
|
|
53
|
+
onMouseEnter: onMenuItemMouseEnter,
|
|
54
|
+
onKeyDown: (event) => onMenuItemKeyDown(event, onClick, type === "action"),
|
|
55
|
+
...restProps,
|
|
56
|
+
children: content
|
|
57
|
+
}
|
|
58
|
+
);
|
|
43
59
|
};
|
|
44
60
|
export {
|
|
45
61
|
DropdownItem as default
|
|
@@ -1,12 +1,30 @@
|
|
|
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]), registerUnfilteredItem = useCallback((id) => (reportMatch(id, !0), () => unregisterMatch(id)), [reportMatch, unregisterMatch]), groupContext = useMemo(() => context && {
|
|
18
|
+
...context,
|
|
19
|
+
reportMatch: groupReportMatch,
|
|
20
|
+
unregisterMatch: groupUnregisterMatch,
|
|
21
|
+
registerUnfilteredItem
|
|
22
|
+
}, [context, groupReportMatch, groupUnregisterMatch, registerUnfilteredItem]);
|
|
23
|
+
return /* @__PURE__ */ jsx(DropdownContext.Provider, { value: groupContext, children: /* @__PURE__ */ jsxs("div", { ref: forwardRef2, role: "group", hidden: !hasMatches, children: [
|
|
24
|
+
/* @__PURE__ */ jsx("span", { className: "small px-4", children: /* @__PURE__ */ jsx("strong", { children: label }) }),
|
|
25
|
+
children
|
|
26
|
+
] }) });
|
|
27
|
+
});
|
|
10
28
|
export {
|
|
11
29
|
DropdownMenuGroup as default
|
|
12
30
|
};
|
|
@@ -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,15 +1,13 @@
|
|
|
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
|
-
unregisterMatch
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return reportMatch(id, !isFiltered), () => unregisterMatch(id);
|
|
12
|
-
}, [id, isFiltered, searchValue, reportMatch, unregisterMatch]), {
|
|
7
|
+
unregisterMatch,
|
|
8
|
+
registerUnfilteredItem
|
|
9
|
+
} = useDropdownContext(), id = useId(), isFiltered = searchValue !== void 0 && searchQuery !== "" && !normalize(searchValue).includes(normalize(searchQuery));
|
|
10
|
+
return useLayoutEffect(() => searchValue === void 0 ? registerUnfilteredItem == null ? void 0 : registerUnfilteredItem(id) : (reportMatch(id, !isFiltered), () => unregisterMatch(id)), [id, isFiltered, searchValue, reportMatch, unregisterMatch, registerUnfilteredItem]), {
|
|
13
11
|
id,
|
|
14
12
|
isFiltered
|
|
15
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
|
+
};
|
|
@@ -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 {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { TreeNodeProps, TreeProps } from '../types';
|
|
2
|
-
declare const Tree:
|
|
3
|
-
({ nodes, selectedNodeId: externalSelectedNodeId, showIcon, shouldExpandAllNodes, draggedNode, renderNode, onTreeItemFold, onTreeItemUnfold, onTreeItemClick, }: TreeProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
displayName: string;
|
|
5
|
-
};
|
|
1
|
+
import { TreeHandlers, TreeNodeProps, TreeProps } from '../types';
|
|
2
|
+
declare const Tree: import('react').ForwardRefExoticComponent<TreeProps & import('react').RefAttributes<TreeHandlers>>;
|
|
6
3
|
export declare const TreeNode: import('react').ForwardRefExoticComponent<Omit<TreeNodeProps, "ref"> & import('react').RefAttributes<HTMLLIElement>>;
|
|
7
4
|
export default Tree;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, createElement } from "react";
|
|
2
|
+
import { forwardRef, useRef, useImperativeHandle, createElement } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
5
|
import SvgIconFolder from "../../../modules/icons/components/IconFolder.js";
|
|
6
6
|
import SvgIconRafterRight from "../../../modules/icons/components/IconRafterRight.js";
|
|
7
7
|
import { useTree } from "../hooks/useTree.js";
|
|
8
8
|
import { getRotateTransitionStyle } from "../../../utilities/rotate-transition-style/get-rotate-transition-style.js";
|
|
9
|
-
const Tree = ({
|
|
9
|
+
const Tree = /* @__PURE__ */ forwardRef(({
|
|
10
10
|
nodes,
|
|
11
11
|
selectedNodeId: externalSelectedNodeId,
|
|
12
12
|
showIcon = !1,
|
|
@@ -16,12 +16,13 @@ const Tree = ({
|
|
|
16
16
|
onTreeItemFold,
|
|
17
17
|
onTreeItemUnfold,
|
|
18
18
|
onTreeItemClick
|
|
19
|
-
}) => {
|
|
19
|
+
}, ref) => {
|
|
20
20
|
const {
|
|
21
21
|
selectedNodeId,
|
|
22
22
|
expandedNodes,
|
|
23
23
|
handleItemClick,
|
|
24
|
-
handleFoldUnfold
|
|
24
|
+
handleFoldUnfold,
|
|
25
|
+
expandNode
|
|
25
26
|
} = useTree({
|
|
26
27
|
data: nodes,
|
|
27
28
|
externalSelectedNodeId,
|
|
@@ -30,9 +31,11 @@ const Tree = ({
|
|
|
30
31
|
onTreeItemClick,
|
|
31
32
|
onTreeItemFold,
|
|
32
33
|
onTreeItemUnfold
|
|
33
|
-
});
|
|
34
|
-
return
|
|
35
|
-
|
|
34
|
+
}), latestExpandNode = useRef(expandNode);
|
|
35
|
+
return latestExpandNode.current = expandNode, useImperativeHandle(ref, () => ({
|
|
36
|
+
expandNode: (nodeId) => latestExpandNode.current(nodeId)
|
|
37
|
+
}), []), /* @__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 }) }) });
|
|
38
|
+
}), TreeNode = /* @__PURE__ */ forwardRef(({
|
|
36
39
|
node,
|
|
37
40
|
selectedNodeId,
|
|
38
41
|
showIcon = !1,
|
|
@@ -27,4 +27,5 @@ export declare const useTree: ({ data, externalSelectedNodeId, draggedNode, shou
|
|
|
27
27
|
handleItemClick: (nodeId: string) => void;
|
|
28
28
|
handleFoldUnfold: (nodeId: string) => void;
|
|
29
29
|
handleCollapseNode: (nodeId: string) => void;
|
|
30
|
+
expandNode: (nodeId: string) => void;
|
|
30
31
|
};
|
|
@@ -45,7 +45,10 @@ const useTree = ({
|
|
|
45
45
|
selectedNodeId !== nodeId && setInternalSelectedNodeId(nodeId);
|
|
46
46
|
}, handleItemClick = (nodeId) => {
|
|
47
47
|
handleSelectedItem(nodeId), handleExpandNode(nodeId), onTreeItemClick == null || onTreeItemClick(nodeId);
|
|
48
|
-
}, handleFoldUnfold = (nodeId) => handleToggleNode(nodeId),
|
|
48
|
+
}, handleFoldUnfold = (nodeId) => handleToggleNode(nodeId), expandNode = (nodeId) => {
|
|
49
|
+
const path = findPathById(data, nodeId);
|
|
50
|
+
path.length === 0 || path.every((id) => expandedNodes.has(id)) || handleExpandNode(nodeId);
|
|
51
|
+
}, handleItemDrag = (nodeId) => {
|
|
49
52
|
findNodeById(data, externalSelectedNodeId) && handleCollapseNode(nodeId);
|
|
50
53
|
};
|
|
51
54
|
return {
|
|
@@ -54,7 +57,8 @@ const useTree = ({
|
|
|
54
57
|
draggedNodeId,
|
|
55
58
|
handleItemClick,
|
|
56
59
|
handleFoldUnfold,
|
|
57
|
-
handleCollapseNode
|
|
60
|
+
handleCollapseNode,
|
|
61
|
+
expandNode
|
|
58
62
|
};
|
|
59
63
|
};
|
|
60
64
|
export {
|
|
@@ -14,6 +14,13 @@ export type Projected = {
|
|
|
14
14
|
parentId: string | null;
|
|
15
15
|
activeId: UniqueIdentifier;
|
|
16
16
|
} | null;
|
|
17
|
+
export interface TreeHandlers {
|
|
18
|
+
/**
|
|
19
|
+
* Expands a node and its ancestors, without selecting it.
|
|
20
|
+
* Does nothing if the node is unknown or already expanded with all its ancestors.
|
|
21
|
+
*/
|
|
22
|
+
expandNode: (nodeId: string) => void;
|
|
23
|
+
}
|
|
17
24
|
export interface TreeProps extends SharedTreeProps {
|
|
18
25
|
/**
|
|
19
26
|
* Tree data
|
package/dist/homepage.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { default as default2 } from "./modules/homepage/components/
|
|
2
|
-
import { default as default3 } from "./modules/homepage/components/Communities/
|
|
3
|
-
import { default as default4 } from "./modules/homepage/components/Communities/
|
|
4
|
-
import { default as default5 } from "./modules/homepage/components/
|
|
5
|
-
import { default as default6 } from "./modules/homepage/components/
|
|
6
|
-
import { default as default7 } from "./modules/homepage/components/
|
|
7
|
-
import { default as default8 } from "./modules/homepage/components/
|
|
8
|
-
import { default as default9 } from "./modules/homepage/components/MessageFlashList/
|
|
9
|
-
import { default as default10 } from "./modules/homepage/components/
|
|
10
|
-
import { default as default11 } from "./modules/homepage/components/Notifications/
|
|
1
|
+
import { default as default2 } from "./modules/homepage/components/AlloRegion/AlloRegion.js";
|
|
2
|
+
import { default as default3 } from "./modules/homepage/components/Communities/Communities.js";
|
|
3
|
+
import { default as default4 } from "./modules/homepage/components/Communities/CommunityItem.js";
|
|
4
|
+
import { default as default5 } from "./modules/homepage/components/Communities/CommunitiesSkeleton.js";
|
|
5
|
+
import { default as default6 } from "./modules/homepage/components/Header/Header.js";
|
|
6
|
+
import { default as default7 } from "./modules/homepage/components/HomeCard/HomeCard.js";
|
|
7
|
+
import { default as default8 } from "./modules/homepage/components/LastInfos/LastInfos.js";
|
|
8
|
+
import { default as default9 } from "./modules/homepage/components/MessageFlashList/MessageFlash.js";
|
|
9
|
+
import { default as default10 } from "./modules/homepage/components/MessageFlashList/MessageFlashList.js";
|
|
10
|
+
import { default as default11 } from "./modules/homepage/components/Notifications/NotificationItem.js";
|
|
11
|
+
import { default as default12 } from "./modules/homepage/components/Notifications/NotificationList.js";
|
|
11
12
|
import { NotificationListContainer } from "./modules/homepage/components/Notifications/NotificationListContainer.js";
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
13
|
+
import { default as default13 } from "./modules/homepage/components/SchoolSpace/SchoolSpace.js";
|
|
14
|
+
import { default as default14 } from "./modules/homepage/components/UserSpace/UserSpace.js";
|
|
15
|
+
import { AlloRegionContainer } from "./modules/homepage/components/AlloRegion/AlloRegionContainer.js";
|
|
14
16
|
import { COMMUNITIES_PREVIEW_SIZE, useCommunities } from "./modules/homepage/components/Communities/useCommunities.js";
|
|
15
17
|
import { CommunitiesContainer } from "./modules/homepage/components/Communities/CommunitiesContainer.js";
|
|
16
18
|
import { Favorites } from "./modules/homepage/components/Favorites/Favorites.js";
|
|
@@ -26,32 +28,34 @@ import { UsefulLinksContainer } from "./modules/homepage/components/UsefulLinks/
|
|
|
26
28
|
import { UsefulLinksModal } from "./modules/homepage/components/UsefulLinks/UsefulLinksModal.js";
|
|
27
29
|
import { UserSpaceContainer } from "./modules/homepage/components/UserSpace/UserSpaceContainer.js";
|
|
28
30
|
export {
|
|
31
|
+
default2 as AlloRegion,
|
|
32
|
+
AlloRegionContainer,
|
|
29
33
|
COMMUNITIES_PREVIEW_SIZE,
|
|
30
|
-
|
|
34
|
+
default3 as Communities,
|
|
31
35
|
CommunitiesContainer,
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
default4 as CommunitiesItem,
|
|
37
|
+
default5 as CommunitiesSkeleton,
|
|
34
38
|
Favorites,
|
|
35
39
|
FavoritesContainer,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
default6 as Header,
|
|
41
|
+
default7 as HomeCard,
|
|
42
|
+
default8 as LastInfos,
|
|
39
43
|
LastInfosContainer,
|
|
40
44
|
LastInfosList,
|
|
41
45
|
LinkForm,
|
|
42
46
|
MAX_USEFUL_LINKS,
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
default9 as MessageFlash,
|
|
48
|
+
default10 as MessageFlashList,
|
|
45
49
|
MessageFlashListContainer,
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
default11 as NotificationItem,
|
|
51
|
+
default12 as NotificationList,
|
|
48
52
|
NotificationListContainer,
|
|
49
|
-
|
|
53
|
+
default13 as SchoolSpace,
|
|
50
54
|
SchoolSpaceContainer,
|
|
51
55
|
UsefulLinks,
|
|
52
56
|
UsefulLinksContainer,
|
|
53
57
|
UsefulLinksModal,
|
|
54
|
-
|
|
58
|
+
default14 as UserSpace,
|
|
55
59
|
UserSpaceContainer,
|
|
56
60
|
useCommunities,
|
|
57
61
|
useUsefulLinksContainer
|
|
@@ -23,6 +23,7 @@ export interface UseDropdownProps {
|
|
|
23
23
|
}>;
|
|
24
24
|
triggerRef: MutableRefObject<HTMLButtonElement | null>;
|
|
25
25
|
menuRef: MutableRefObject<HTMLUListElement | null>;
|
|
26
|
+
searchInputRef: MutableRefObject<HTMLInputElement | null>;
|
|
26
27
|
triggerProps: Record<string, any>;
|
|
27
28
|
menuProps: Record<string, any>;
|
|
28
29
|
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);
|
|
@@ -47,12 +52,23 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
}, [activeIndex]);
|
|
50
|
-
const visibleItemCount = () => Object.values(itemRefs.current).filter(Boolean).length,
|
|
55
|
+
const visibleItemCount = () => Object.values(itemRefs.current).filter(Boolean).length, focusFirstItem = () => {
|
|
56
|
+
const firstVisibleItem = Object.values(itemRefs.current).find(Boolean);
|
|
57
|
+
firstVisibleItem && (setActiveIndex(0), setIsFocused(firstVisibleItem.getAttribute("id")), firstVisibleItem.focus());
|
|
58
|
+
}, nextItem = () => {
|
|
59
|
+
if (searchInputRef.current && document.activeElement === searchInputRef.current) {
|
|
60
|
+
focusFirstItem();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
51
63
|
const count = visibleItemCount();
|
|
52
|
-
setActiveIndex((prevIndex) => (prevIndex + 1) % count);
|
|
64
|
+
count !== 0 && setActiveIndex((prevIndex) => (prevIndex + 1) % count);
|
|
53
65
|
}, previousItem = () => {
|
|
66
|
+
if (activeIndex === 0 && searchInputRef.current) {
|
|
67
|
+
focusSearchInput();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
54
70
|
const count = visibleItemCount();
|
|
55
|
-
setActiveIndex((prevIndex) => (prevIndex - 1 + count) % count);
|
|
71
|
+
count !== 0 && setActiveIndex((prevIndex) => (prevIndex - 1 + count) % count);
|
|
56
72
|
}, firstItem = () => {
|
|
57
73
|
setActiveIndex(0);
|
|
58
74
|
}, lastItem = () => {
|
|
@@ -90,11 +106,12 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
90
106
|
}
|
|
91
107
|
extraTriggerKeyDownHandler == null || extraTriggerKeyDownHandler(event), stopEvents(flag, event);
|
|
92
108
|
}, [closeDropdown, openDropdown]), onMenuItemMouseEnter = (event) => {
|
|
93
|
-
|
|
109
|
+
const isTypingInSearchInput = !!searchInputRef.current && document.activeElement === searchInputRef.current;
|
|
110
|
+
if (focusOnMouseEnter && !isTypingInSearchInput) {
|
|
94
111
|
const index = Object.values(itemRefs.current).filter((item) => !!item).findIndex((item) => item.id === event.currentTarget.getAttribute("id"));
|
|
95
112
|
setActiveIndex(index);
|
|
96
113
|
}
|
|
97
|
-
}, onMenuItemKeyDown = useCallback((event, onSuccess) => {
|
|
114
|
+
}, onMenuItemKeyDown = useCallback((event, onSuccess, closeOnSuccess = !0) => {
|
|
98
115
|
let flag = !1;
|
|
99
116
|
if (event.shiftKey)
|
|
100
117
|
event.key === "Tab" && (closeDropdown(), flag = !0);
|
|
@@ -105,7 +122,7 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
105
122
|
break;
|
|
106
123
|
case " ":
|
|
107
124
|
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;
|
|
125
|
+
activeIndex !== -1 && (Object.values(itemRefs.current).filter(Boolean)[activeIndex].getAttribute("role") === "menuitem" && closeOnSuccess && triggerRef.current && (triggerRef.current.focus(), setVisible(!1)), onSuccess == null || onSuccess()), flag = !0;
|
|
109
126
|
break;
|
|
110
127
|
case "ArrowDown":
|
|
111
128
|
case "Down":
|
|
@@ -133,6 +150,7 @@ const useDropdown = (placement, extraTriggerKeyDownHandler, isTriggerHovered = !
|
|
|
133
150
|
itemRefs,
|
|
134
151
|
triggerRef,
|
|
135
152
|
menuRef,
|
|
153
|
+
searchInputRef,
|
|
136
154
|
/* TriggerProps to spread to any Trigger component */
|
|
137
155
|
triggerProps: {
|
|
138
156
|
ref: mergeRefs(triggerRef, refs.setReference),
|