@edifice.io/react 2.6.11-develop-b2school.20261029162931 → 2.6.11-develop-b2school.20261029171425
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/SearchBar/SearchBar.js +17 -26
- package/dist/homepage.js +2 -0
- package/dist/modules/homepage/components/TabsKids/components/TabsKids.d.ts +43 -0
- package/dist/modules/homepage/components/TabsKids/components/TabsKids.js +23 -0
- package/dist/modules/homepage/components/TabsKids/components/TabsKidsItem.d.ts +34 -0
- package/dist/modules/homepage/components/TabsKids/components/TabsKidsItem.js +26 -0
- package/dist/modules/homepage/components/TabsKids/components/TabsKidsList.d.ts +14 -0
- package/dist/modules/homepage/components/TabsKids/components/TabsKidsList.js +64 -0
- package/dist/modules/homepage/components/TabsKids/hooks/useTabsKidsOverflow.d.ts +20 -0
- package/dist/modules/homepage/components/TabsKids/hooks/useTabsKidsOverflow.js +43 -0
- package/dist/modules/homepage/components/TabsKids/index.d.ts +3 -0
- package/dist/modules/homepage/components/TabsKids/utils/visibleTabs.d.ts +15 -0
- package/dist/modules/homepage/components/TabsKids/utils/visibleTabs.js +21 -0
- package/dist/modules/homepage/components/index.d.ts +1 -0
- package/dist/modules/multimedia/Workspace/Workspace.js +1 -1
- package/package.json +6 -6
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import clsx from "clsx";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
3
4
|
import { useTranslation } from "react-i18next";
|
|
4
|
-
import SvgIconClose from "../../modules/icons/components/IconClose.js";
|
|
5
5
|
import SvgIconSearch from "../../modules/icons/components/IconSearch.js";
|
|
6
6
|
import FormControl from "../Form/FormControl.js";
|
|
7
|
-
import
|
|
7
|
+
import ButtonBeta from "../ButtonBeta/ButtonBeta.js";
|
|
8
8
|
const SearchBar = ({
|
|
9
9
|
isVariant = !1,
|
|
10
10
|
size = "md",
|
|
@@ -15,38 +15,29 @@ const SearchBar = ({
|
|
|
15
15
|
onChange,
|
|
16
16
|
onClick,
|
|
17
17
|
value,
|
|
18
|
-
clearable = !
|
|
18
|
+
clearable = !0,
|
|
19
19
|
...restProps
|
|
20
20
|
}) => {
|
|
21
|
+
var _a;
|
|
21
22
|
const {
|
|
22
23
|
t
|
|
23
|
-
} = useTranslation(),
|
|
24
|
-
"input-group": !isVariant,
|
|
25
|
-
"position-relative": isVariant
|
|
26
|
-
}), input = clsx({
|
|
27
|
-
"border-end-0": !isVariant,
|
|
28
|
-
"ps-48": isVariant,
|
|
29
|
-
"searchbar-hide-native-clear": isVariant && clearable
|
|
30
|
-
}), handleClick = () => {
|
|
24
|
+
} = useTranslation(), input = "searchbar__input", handleClick = () => {
|
|
31
25
|
onClick == null || onClick();
|
|
32
26
|
}, handleKeyDown = (e) => {
|
|
33
27
|
e.key === "Enter" && (e.preventDefault(), handleClick());
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
}, inputRef = useRef(null), isControlled = value !== void 0, [hasUncontrolledText, setHasUncontrolledText] = useState(!!((_a = restProps.defaultValue) != null && _a.toString())), hasText = isControlled ? !!value : hasUncontrolledText, [isFocused, setIsFocused] = useState(!1), handleBlur = (e) => {
|
|
29
|
+
e.currentTarget.contains(e.relatedTarget) || setIsFocused(!1);
|
|
30
|
+
}, handleMouseDown = (e) => {
|
|
31
|
+
e.target.closest("button") && e.preventDefault();
|
|
32
|
+
}, isActive = isFocused || hasText, searchbar = clsx("searchbar", `searchbar--${size}`, {
|
|
33
|
+
"searchbar--active": isActive
|
|
34
|
+
}, className), handleChange = (e) => {
|
|
35
|
+
isControlled || setHasUncontrolledText(!!e.target.value), onChange == null || onChange(e);
|
|
41
36
|
};
|
|
42
|
-
return /* @__PURE__ */ jsxs(FormControl, { id: "search-bar", className: searchbar, children: [
|
|
43
|
-
isVariant && /* @__PURE__ */ jsx("div", { className: "
|
|
44
|
-
/* @__PURE__ */ jsx(FormControl.Input, { type: "search", placeholder: t(placeholder), size,
|
|
45
|
-
isVariant &&
|
|
46
|
-
width: 12,
|
|
47
|
-
height: 12
|
|
48
|
-
} }) }),
|
|
49
|
-
!isVariant && /* @__PURE__ */ jsx(SearchButton, { type: "submit", "aria-label": t("search"), icon: /* @__PURE__ */ jsx(SvgIconSearch, {}), className: "border-start-0", onClick: handleClick, disabled: buttonDisabled })
|
|
37
|
+
return /* @__PURE__ */ jsxs(FormControl, { id: "search-bar", className: searchbar, onFocus: () => setIsFocused(!0), onBlur: handleBlur, onMouseDown: handleMouseDown, children: [
|
|
38
|
+
isVariant && /* @__PURE__ */ jsx("div", { className: "searchbar__icon", children: /* @__PURE__ */ jsx(SvgIconSearch, { width: 20, height: 20 }) }),
|
|
39
|
+
/* @__PURE__ */ jsx(FormControl.Input, { ref: inputRef, type: "search", placeholder: t(placeholder), size, className: input, onChange: handleChange, value, disabled, onKeyDown: handleKeyDown, clearable: clearable && !disabled, ...restProps }),
|
|
40
|
+
!isVariant && /* @__PURE__ */ jsx(ButtonBeta, { type: "submit", className: "btn-search", "aria-label": t("search"), leftIcon: /* @__PURE__ */ jsx(SvgIconSearch, {}), onClick: handleClick, disabled: buttonDisabled || disabled })
|
|
50
41
|
] });
|
|
51
42
|
};
|
|
52
43
|
export {
|
package/dist/homepage.js
CHANGED
|
@@ -17,6 +17,7 @@ import { default as default17 } from "./modules/homepage/components/Notification
|
|
|
17
17
|
import { NotificationListContainer } from "./modules/homepage/components/Notifications/NotificationListContainer.js";
|
|
18
18
|
import { default as default18 } from "./modules/homepage/components/Qwant/Qwant.js";
|
|
19
19
|
import { default as default19 } from "./modules/homepage/components/SchoolSpace/SchoolSpace.js";
|
|
20
|
+
import { TabsKids } from "./modules/homepage/components/TabsKids/components/TabsKids.js";
|
|
20
21
|
import { default as default20 } from "./modules/homepage/components/Universalis/Universalis.js";
|
|
21
22
|
import { default as default21 } from "./modules/homepage/components/UserSpace/UserSpace.js";
|
|
22
23
|
import { Agenda } from "./modules/homepage/components/Agenda/Agenda.js";
|
|
@@ -99,6 +100,7 @@ export {
|
|
|
99
100
|
RssFeedsModal,
|
|
100
101
|
default19 as SchoolSpace,
|
|
101
102
|
SchoolSpaceContainer,
|
|
103
|
+
TabsKids,
|
|
102
104
|
default20 as Universalis,
|
|
103
105
|
UniversalisContainer,
|
|
104
106
|
UsefulLinks,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TabsKidsItemProps } from './TabsKidsItem';
|
|
3
|
+
export interface TabsKidsProps {
|
|
4
|
+
/**
|
|
5
|
+
* Items to be displayed
|
|
6
|
+
*/
|
|
7
|
+
items: TabsKidsItemProps[];
|
|
8
|
+
/**
|
|
9
|
+
* Identifier of the selected item (controlled)
|
|
10
|
+
*/
|
|
11
|
+
activeId: string;
|
|
12
|
+
/**
|
|
13
|
+
* Get notified when an item is selected
|
|
14
|
+
*/
|
|
15
|
+
onChange: (id: string) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Content of the selected tab, rendered in a panel below the tab bar
|
|
18
|
+
*/
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Display the tab bar, even with a single item. When hidden, only the panel
|
|
22
|
+
* of the active item is rendered (e.g. for a student viewing their own data)
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
showTabBar?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Accessible name of the tab list
|
|
28
|
+
*/
|
|
29
|
+
ariaLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Accessible name of the overflow dropdown trigger
|
|
32
|
+
*/
|
|
33
|
+
overflowLabel?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Additional class name
|
|
36
|
+
*/
|
|
37
|
+
className?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare const TabsKids: {
|
|
40
|
+
({ items, activeId, onChange, children, showTabBar, ariaLabel, overflowLabel, className, }: TabsKidsProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
displayName: string;
|
|
42
|
+
};
|
|
43
|
+
export default TabsKids;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import TabsKidsList from "./TabsKidsList.js";
|
|
4
|
+
const COMPACT_THRESHOLD = 3, TabsKids = ({
|
|
5
|
+
items,
|
|
6
|
+
activeId,
|
|
7
|
+
onChange,
|
|
8
|
+
children,
|
|
9
|
+
showTabBar = !0,
|
|
10
|
+
ariaLabel,
|
|
11
|
+
overflowLabel,
|
|
12
|
+
className
|
|
13
|
+
}) => {
|
|
14
|
+
const hasTabs = showTabBar && items.length > 0, activeItem = items.find((item) => item.id === activeId);
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", { className: clsx("tabs-kids", className), children: [
|
|
16
|
+
hasTabs && /* @__PURE__ */ jsx(TabsKidsList, { items, activeId, onSelect: onChange, isCompact: items.length >= COMPACT_THRESHOLD, ariaLabel, overflowLabel }),
|
|
17
|
+
activeItem && /* @__PURE__ */ jsx("div", { id: hasTabs ? `tabs-kids-panel-${activeId}` : void 0, role: hasTabs ? "tabpanel" : "region", "aria-labelledby": hasTabs ? `tabs-kids-${activeId}` : void 0, "aria-label": hasTabs ? void 0 : activeItem.label, className: "tabs-kids-panel", children })
|
|
18
|
+
] });
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
TabsKids,
|
|
22
|
+
TabsKids as default
|
|
23
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { KeyboardEvent, Ref } from 'react';
|
|
2
|
+
export interface TabsKidsItemProps {
|
|
3
|
+
/**
|
|
4
|
+
* Item identifier
|
|
5
|
+
*/
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* Item label
|
|
9
|
+
*/
|
|
10
|
+
label: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional avatar URL displayed before the label
|
|
13
|
+
*/
|
|
14
|
+
avatar?: string;
|
|
15
|
+
}
|
|
16
|
+
interface TabsKidsItemInternalProps extends TabsKidsItemProps {
|
|
17
|
+
isActive: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Display only the initial of the label when the tab is inactive
|
|
20
|
+
*/
|
|
21
|
+
isCompact: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Hidden copy only used to measure the tab width: no id nor tab semantics
|
|
24
|
+
*/
|
|
25
|
+
isMeasure?: boolean;
|
|
26
|
+
onSelect?: (id: string) => void;
|
|
27
|
+
onKeyDown?: (event: KeyboardEvent<HTMLButtonElement>) => void;
|
|
28
|
+
buttonRef?: Ref<HTMLButtonElement>;
|
|
29
|
+
}
|
|
30
|
+
declare const TabsKidsItem: {
|
|
31
|
+
({ id, label, avatar, isActive, isCompact, isMeasure, onSelect, onKeyDown, buttonRef, }: TabsKidsItemInternalProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
displayName: string;
|
|
33
|
+
};
|
|
34
|
+
export default TabsKidsItem;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import Avatar from "../../../../../components/Avatar/Avatar.js";
|
|
4
|
+
const TabsKidsItem = ({
|
|
5
|
+
id,
|
|
6
|
+
label,
|
|
7
|
+
avatar,
|
|
8
|
+
isActive,
|
|
9
|
+
isCompact,
|
|
10
|
+
isMeasure = !1,
|
|
11
|
+
onSelect,
|
|
12
|
+
onKeyDown,
|
|
13
|
+
buttonRef
|
|
14
|
+
}) => {
|
|
15
|
+
const isAbbreviated = isCompact && !isActive, displayedLabel = isAbbreviated ? `${label.trim().charAt(0).toUpperCase()}.` : label;
|
|
16
|
+
return /* @__PURE__ */ jsxs("button", { ref: buttonRef, type: "button", role: isMeasure ? void 0 : "tab", id: isMeasure ? void 0 : `tabs-kids-${id}`, "aria-selected": isMeasure ? void 0 : isActive, "aria-controls": isActive && !isMeasure ? `tabs-kids-panel-${id}` : void 0, tabIndex: isActive && !isMeasure ? 0 : -1, title: isMeasure ? void 0 : label, "aria-label": isAbbreviated && !isMeasure ? label : void 0, className: clsx("tabs-kids-item", {
|
|
17
|
+
active: isActive,
|
|
18
|
+
compact: isAbbreviated
|
|
19
|
+
}), onClick: () => onSelect == null ? void 0 : onSelect(id), onKeyDown, children: [
|
|
20
|
+
avatar && /* @__PURE__ */ jsx("span", { className: "tabs-kids-item-avatar", children: /* @__PURE__ */ jsx(Avatar, { alt: "", size: "xs", variant: "circle", src: avatar }) }),
|
|
21
|
+
/* @__PURE__ */ jsx("span", { className: "tabs-kids-item-label", children: displayedLabel })
|
|
22
|
+
] });
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
TabsKidsItem as default
|
|
26
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TabsKidsItemProps } from './TabsKidsItem';
|
|
2
|
+
interface TabsKidsListProps {
|
|
3
|
+
items: TabsKidsItemProps[];
|
|
4
|
+
activeId: string;
|
|
5
|
+
onSelect: (id: string) => void;
|
|
6
|
+
isCompact: boolean;
|
|
7
|
+
ariaLabel?: string;
|
|
8
|
+
overflowLabel?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const TabsKidsList: {
|
|
11
|
+
({ items, activeId, onSelect, isCompact, ariaLabel, overflowLabel, }: TabsKidsListProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
export default TabsKidsList;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import SvgIconUsers from "../../../../icons/components/IconUsers.js";
|
|
4
|
+
import { useTabsKidsOverflow } from "../hooks/useTabsKidsOverflow.js";
|
|
5
|
+
import TabsKidsItem from "./TabsKidsItem.js";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
import Dropdown from "../../../../../components/Dropdown/Dropdown.js";
|
|
8
|
+
import ButtonBeta from "../../../../../components/ButtonBeta/ButtonBeta.js";
|
|
9
|
+
const TabsKidsList = ({
|
|
10
|
+
items,
|
|
11
|
+
activeId,
|
|
12
|
+
onSelect,
|
|
13
|
+
isCompact,
|
|
14
|
+
ariaLabel,
|
|
15
|
+
overflowLabel
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
t
|
|
19
|
+
} = useTranslation(), tabsRef = useRef([]), {
|
|
20
|
+
tabBarRef,
|
|
21
|
+
measureRef,
|
|
22
|
+
visibleItems,
|
|
23
|
+
overflowItems
|
|
24
|
+
} = useTabsKidsOverflow({
|
|
25
|
+
items,
|
|
26
|
+
activeId,
|
|
27
|
+
isCompact
|
|
28
|
+
}), handleKeyDown = (event, order) => {
|
|
29
|
+
var _a;
|
|
30
|
+
const last = visibleItems.length - 1;
|
|
31
|
+
let next;
|
|
32
|
+
switch (event.key) {
|
|
33
|
+
case "ArrowRight":
|
|
34
|
+
next = order === last ? 0 : order + 1;
|
|
35
|
+
break;
|
|
36
|
+
case "ArrowLeft":
|
|
37
|
+
next = order === 0 ? last : order - 1;
|
|
38
|
+
break;
|
|
39
|
+
case "Home":
|
|
40
|
+
next = 0;
|
|
41
|
+
break;
|
|
42
|
+
case "End":
|
|
43
|
+
next = last;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
next !== void 0 && (event.preventDefault(), (_a = tabsRef.current[next]) == null || _a.focus(), onSelect(visibleItems[next].id));
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ jsxs("div", { className: "tabs-kids-bar", ref: tabBarRef, children: [
|
|
49
|
+
/* @__PURE__ */ jsx("div", { className: "tabs-kids-list", role: "tablist", "aria-label": ariaLabel, children: visibleItems.map((item, order) => /* @__PURE__ */ jsx(TabsKidsItem, { ...item, isActive: item.id === activeId, isCompact, onSelect, onKeyDown: (event) => handleKeyDown(event, order), buttonRef: (el) => {
|
|
50
|
+
tabsRef.current[order] = el;
|
|
51
|
+
} }, item.id)) }),
|
|
52
|
+
overflowItems.length > 0 && /* @__PURE__ */ jsx("div", { className: "tabs-kids-overflow", children: /* @__PURE__ */ jsx(Dropdown, { placement: "bottom-end", children: (triggerProps) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53
|
+
/* @__PURE__ */ jsx(ButtonBeta, { ...triggerProps, type: "button", "aria-label": overflowLabel ?? t("homepage.tabsKids.see.more", "Voir plus"), color: "default", variant: "ghost", leftIcon: /* @__PURE__ */ jsx(SvgIconUsers, {}) }),
|
|
54
|
+
/* @__PURE__ */ jsx(Dropdown.Menu, { children: overflowItems.map((item) => /* @__PURE__ */ jsx(Dropdown.RadioItem, { value: item.id, model: activeId, onChange: onSelect, children: item.label }, item.id)) })
|
|
55
|
+
] }) }) }),
|
|
56
|
+
/* @__PURE__ */ jsx("div", { className: "tabs-kids-measure", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("div", { className: "tabs-kids-measure-content", ref: measureRef, children: [
|
|
57
|
+
items.map((item) => /* @__PURE__ */ jsx(TabsKidsItem, { ...item, isActive: item.id === activeId, isCompact, isMeasure: !0 }, item.id)),
|
|
58
|
+
/* @__PURE__ */ jsx("div", { className: "tabs-kids-overflow tabs-kids-measure-trigger", children: /* @__PURE__ */ jsx(ButtonBeta, { tabIndex: -1, "aria-label": "", color: "default", variant: "ghost", leftIcon: /* @__PURE__ */ jsx(SvgIconUsers, {}) }) })
|
|
59
|
+
] }) })
|
|
60
|
+
] });
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
TabsKidsList as default
|
|
64
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TabsKidsItemProps } from '../components/TabsKidsItem';
|
|
2
|
+
interface UseTabsKidsOverflowProps {
|
|
3
|
+
items: TabsKidsItemProps[];
|
|
4
|
+
activeId: string;
|
|
5
|
+
isCompact: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Splits the items between the visible tabs and the overflow dropdown,
|
|
9
|
+
* according to the space available in the tab bar.
|
|
10
|
+
*
|
|
11
|
+
* Tied to the markup of `TabsKidsList`: `measureRef` must contain a hidden
|
|
12
|
+
* copy of every `.tabs-kids-item` and the `.tabs-kids-measure-trigger`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useTabsKidsOverflow: ({ items, activeId, isCompact, }: UseTabsKidsOverflowProps) => {
|
|
15
|
+
tabBarRef: import('react').RefObject<HTMLDivElement>;
|
|
16
|
+
measureRef: import('react').RefObject<HTMLDivElement>;
|
|
17
|
+
visibleItems: TabsKidsItemProps[];
|
|
18
|
+
overflowItems: TabsKidsItemProps[];
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useRef, useState, useCallback, useLayoutEffect, useMemo } from "react";
|
|
2
|
+
import { getVisibleCount, getVisibleIndexes } from "../utils/visibleTabs.js";
|
|
3
|
+
const useTabsKidsOverflow = ({
|
|
4
|
+
items,
|
|
5
|
+
activeId,
|
|
6
|
+
isCompact
|
|
7
|
+
}) => {
|
|
8
|
+
const tabBarRef = useRef(null), measureRef = useRef(null), [visibleCount, setVisibleCount] = useState(items.length), activeIndex = items.findIndex((item) => item.id === activeId), activeIndexRef = useRef(activeIndex);
|
|
9
|
+
activeIndexRef.current = activeIndex;
|
|
10
|
+
const updateVisibleCount = useCallback(() => {
|
|
11
|
+
const bar = tabBarRef.current, measure = measureRef.current;
|
|
12
|
+
if (!bar || !measure) return;
|
|
13
|
+
const barStyle = getComputedStyle(bar), available = bar.clientWidth - parseFloat(barStyle.paddingInlineStart) - parseFloat(barStyle.paddingInlineEnd), tabs = Array.from(measure.querySelectorAll(".tabs-kids-item")), trigger = measure.querySelector(".tabs-kids-measure-trigger"), gap = parseFloat(barStyle.columnGap) || 0, corner = tabs[0] && parseFloat(getComputedStyle(tabs[0], "::after").width) || 0;
|
|
14
|
+
setVisibleCount(getVisibleCount(tabs.map((tab) => tab.offsetWidth), activeIndexRef.current, available, gap, (trigger == null ? void 0 : trigger.offsetWidth) ?? 0, corner));
|
|
15
|
+
}, []);
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
updateVisibleCount();
|
|
18
|
+
}, [updateVisibleCount, items, isCompact]), useLayoutEffect(() => {
|
|
19
|
+
const bar = tabBarRef.current;
|
|
20
|
+
if (!bar || typeof ResizeObserver > "u") return;
|
|
21
|
+
const observer = new ResizeObserver(() => updateVisibleCount());
|
|
22
|
+
return observer.observe(bar), () => observer.disconnect();
|
|
23
|
+
}, [updateVisibleCount]);
|
|
24
|
+
const {
|
|
25
|
+
visibleItems,
|
|
26
|
+
overflowItems
|
|
27
|
+
} = useMemo(() => {
|
|
28
|
+
const indexes = getVisibleIndexes(items.length, visibleCount, activeIndex);
|
|
29
|
+
return {
|
|
30
|
+
visibleItems: indexes.map((i) => items[i]),
|
|
31
|
+
overflowItems: items.filter((_, i) => !indexes.includes(i))
|
|
32
|
+
};
|
|
33
|
+
}, [items, visibleCount, activeIndex]);
|
|
34
|
+
return {
|
|
35
|
+
tabBarRef,
|
|
36
|
+
measureRef,
|
|
37
|
+
visibleItems,
|
|
38
|
+
overflowItems
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
useTabsKidsOverflow
|
|
43
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns how many tabs fit in the available space. The active tab is always
|
|
3
|
+
* counted, then the other tabs are added from the start until one does not
|
|
4
|
+
* fit. Never returns less than one.
|
|
5
|
+
*
|
|
6
|
+
* Tabs are laid out without gap between them. `gap` is the space between the
|
|
7
|
+
* tab list and the overflow dropdown trigger, `trigger` the width of that
|
|
8
|
+
* trigger, `corner` the room needed after the last tab for its inverted corner.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getVisibleCount: (widths: number[], activeIndex: number, available: number, gap: number, trigger: number, corner: number) => number;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the indexes of the visible tabs: the first `count` items, the last
|
|
13
|
+
* one being replaced by the active item when it is not among them.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getVisibleIndexes: (length: number, count: number, activeIndex: number) => number[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const getVisibleCount = (widths, activeIndex, available, gap, trigger, corner) => {
|
|
2
|
+
if (widths.reduce((sum, w) => sum + w, 0) + corner <= available) return widths.length;
|
|
3
|
+
const pinned = activeIndex < 0 ? 0 : activeIndex, budget = available - corner - gap - trigger;
|
|
4
|
+
let used = widths[pinned], count = 1;
|
|
5
|
+
for (let i = 0; i < widths.length; i++)
|
|
6
|
+
if (i !== pinned) {
|
|
7
|
+
if (used + widths[i] > budget) break;
|
|
8
|
+
used += widths[i], count++;
|
|
9
|
+
}
|
|
10
|
+
return count;
|
|
11
|
+
}, getVisibleIndexes = (length, count, activeIndex) => {
|
|
12
|
+
if (length === 0) return [];
|
|
13
|
+
const visibleCount = Math.max(1, Math.min(count, length)), indexes = Array.from({
|
|
14
|
+
length: visibleCount
|
|
15
|
+
}, (_, i) => i);
|
|
16
|
+
return activeIndex >= visibleCount && (indexes[visibleCount - 1] = activeIndex), indexes;
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
getVisibleCount,
|
|
20
|
+
getVisibleIndexes
|
|
21
|
+
};
|
|
@@ -150,7 +150,7 @@ const WORKSPACE_VIEW_WORKFLOW = "org.entcore.workspace.controllers.WorkspaceCont
|
|
|
150
150
|
] }) }),
|
|
151
151
|
/* @__PURE__ */ jsx(Grid.Col, { sm: "12", md: "5", xl: "8", children: /* @__PURE__ */ jsxs(Grid, { className: "flex-grow-1 gap-0", children: [
|
|
152
152
|
/* @__PURE__ */ jsxs(Grid.Col, { sm: "4", md: "8", xl: "12", children: [
|
|
153
|
-
/* @__PURE__ */ jsx("div", { className: "workspace-search px-16 py-8 ", children: /* @__PURE__ */ jsx(SearchBar, { isVariant: !0,
|
|
153
|
+
/* @__PURE__ */ jsx("div", { className: "workspace-search px-16 py-8 ", children: /* @__PURE__ */ jsx(SearchBar, { isVariant: !0, onChange: handleSearchChange }) }),
|
|
154
154
|
/* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center justify-content-end px-8 py-4", children: [
|
|
155
155
|
/* @__PURE__ */ jsx("small", { className: "text-muted", children: t("workspace.search.order") }),
|
|
156
156
|
/* @__PURE__ */ jsxs(Dropdown, { children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.6.11-develop-b2school.
|
|
3
|
+
"version": "2.6.11-develop-b2school.20261029171425",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -140,9 +140,9 @@
|
|
|
140
140
|
"swiper": "10.1.0",
|
|
141
141
|
"ua-parser-js": "1.0.36",
|
|
142
142
|
"zustand": "4.5.7",
|
|
143
|
-
"@edifice.io/
|
|
144
|
-
"@edifice.io/
|
|
145
|
-
"@edifice.io/bootstrap": "2.6.11-develop-b2school.
|
|
143
|
+
"@edifice.io/tiptap-extensions": "2.6.11-develop-b2school.20261029171425",
|
|
144
|
+
"@edifice.io/utilities": "2.6.11-develop-b2school.20261029171425",
|
|
145
|
+
"@edifice.io/bootstrap": "2.6.11-develop-b2school.20261029171425"
|
|
146
146
|
},
|
|
147
147
|
"devDependencies": {
|
|
148
148
|
"@babel/plugin-transform-react-pure-annotations": "7.27.1",
|
|
@@ -174,8 +174,8 @@
|
|
|
174
174
|
"vite": "5.4.14",
|
|
175
175
|
"vite-plugin-dts": "4.5.4",
|
|
176
176
|
"vite-tsconfig-paths": "5.1.4",
|
|
177
|
-
"@edifice.io/client": "2.6.11-develop-b2school.
|
|
178
|
-
"@edifice.io/config": "2.6.11-develop-b2school.
|
|
177
|
+
"@edifice.io/client": "2.6.11-develop-b2school.20261029171425",
|
|
178
|
+
"@edifice.io/config": "2.6.11-develop-b2school.20261029171425"
|
|
179
179
|
},
|
|
180
180
|
"peerDependencies": {
|
|
181
181
|
"@react-spring/web": "9.7.5",
|