@redis-ui/components 51.14.1 → 51.15.0
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/SideBar/SideBar.cjs +2 -0
- package/dist/SideBar/SideBar.constants.cjs +2 -0
- package/dist/SideBar/SideBar.constants.d.ts +2 -0
- package/dist/SideBar/SideBar.constants.js +2 -0
- package/dist/SideBar/SideBar.d.ts +4 -0
- package/dist/SideBar/SideBar.js +2 -0
- package/dist/SideBar/components/CollapseButton/CollapseButton.style.d.ts +1 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.cjs +78 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.context.cjs +11 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.context.d.ts +4 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.context.js +8 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.d.ts +6 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.js +78 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.style.cjs +36 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.style.d.ts +7 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.style.js +30 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.types.d.ts +21 -0
- package/dist/SideBar/components/ExpandableItem/ExpandableItem.types.js +1 -0
- package/dist/SideBar/components/Item/Item.cjs +4 -1
- package/dist/SideBar/components/Item/Item.js +4 -1
- package/dist/SideBar/components/Item/Item.style.cjs +7 -4
- package/dist/SideBar/components/Item/Item.style.d.ts +1 -0
- package/dist/SideBar/components/Item/Item.style.js +7 -4
- package/dist/SideBar/components/Item/components/Text/Text.cjs +3 -0
- package/dist/SideBar/components/Item/components/Text/Text.js +3 -0
- package/dist/SideBar/components/Item/components/Text/Text.style.cjs +3 -2
- package/dist/SideBar/components/Item/components/Text/Text.style.d.ts +1 -0
- package/dist/SideBar/components/Item/components/Text/Text.style.js +3 -2
- package/dist/SideBar/index.d.ts +1 -0
- package/package.json +2 -2
- package/skills/redis-ui-components/references/SideBar.md +115 -1
package/dist/SideBar/SideBar.cjs
CHANGED
|
@@ -13,6 +13,7 @@ const require_ScrollContainer = require("./components/ScrollContainer/ScrollCont
|
|
|
13
13
|
const require_Footer = require("./components/Footer/Footer.cjs");
|
|
14
14
|
const require_Group = require("./components/Group/Group.cjs");
|
|
15
15
|
const require_CollapseButton = require("./components/CollapseButton/CollapseButton.cjs");
|
|
16
|
+
const require_ExpandableItem = require("./components/ExpandableItem/ExpandableItem.cjs");
|
|
16
17
|
let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
|
|
17
18
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
18
19
|
let react = require("react");
|
|
@@ -52,6 +53,7 @@ var SideBar = Object.assign(({ isExpanded, expandedWidth, showActiveIndicator =
|
|
|
52
53
|
Split: require_FlexSplit.FlexSplit,
|
|
53
54
|
Divider: require_Divider.default,
|
|
54
55
|
Item: require_Item.default,
|
|
56
|
+
ExpandableItem: require_ExpandableItem.default,
|
|
55
57
|
Button: require_Button.default,
|
|
56
58
|
Header: require_Header.default,
|
|
57
59
|
Footer: require_Footer.default,
|
|
@@ -35,7 +35,9 @@ export declare const SIDEBAR_CONSTANTS: {
|
|
|
35
35
|
readonly item: {
|
|
36
36
|
readonly margin: "0.2rem 0.5rem 0.2rem 1rem";
|
|
37
37
|
readonly height: "3.2rem";
|
|
38
|
+
readonly childHeight: "2.8rem";
|
|
38
39
|
readonly padding: "0 0.8rem";
|
|
40
|
+
readonly paddingInline: "0.8rem";
|
|
39
41
|
readonly gap: "0.8rem";
|
|
40
42
|
readonly borderRadius: "0.4rem";
|
|
41
43
|
readonly itemWithButtonOffset: "1.8rem";
|
|
@@ -11,6 +11,10 @@ declare const SideBar: (({ isExpanded, expandedWidth, showActiveIndicator, ...re
|
|
|
11
11
|
Button: import("react").ForwardRefExoticComponent<import("..").ActionIconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
12
12
|
Badge: import("react").ForwardRefExoticComponent<import("..").BadgeProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
13
|
};
|
|
14
|
+
ExpandableItem: (({ isOpen: controlledOpen, defaultOpen, onOpenChange, hasActiveChild, children }: import(".").SideBarExpandableItemProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
15
|
+
Trigger: ({ isActive, onClick, expandText, collapseText, children, ...rest }: import(".").SideBarExpandableItemTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
Items: ({ children, ...rest }: import(".").SideBarExpandableItemItemsProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
};
|
|
14
18
|
Button: ({ tooltipProps: { text: tooltipText, placement, ...tooltipProps }, buttonExpandedContent, buttonCollapsedIcon: ButtonCollapsedIcon, ...rest }: import("./components/Button/Button.types").SideBarButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
19
|
Header: ({ children, onToggle, ...rest }: import("./components/Header/Header.types").SideBarHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
20
|
Footer: ((props: import("./components/Footer/Footer.types").SideBarFooterProps) => import("react/jsx-runtime").JSX.Element) & {
|
package/dist/SideBar/SideBar.js
CHANGED
|
@@ -13,6 +13,7 @@ import ScrollContainer from "./components/ScrollContainer/ScrollContainer.js";
|
|
|
13
13
|
import Footer from "./components/Footer/Footer.js";
|
|
14
14
|
import Group from "./components/Group/Group.js";
|
|
15
15
|
import CollapseButton from "./components/CollapseButton/CollapseButton.js";
|
|
16
|
+
import ExpandableItem from "./components/ExpandableItem/ExpandableItem.js";
|
|
16
17
|
import { usePrefersReducedMotion } from "@redis-ui/styles";
|
|
17
18
|
import { jsx } from "react/jsx-runtime";
|
|
18
19
|
import { useState } from "react";
|
|
@@ -52,6 +53,7 @@ var SideBar = Object.assign(({ isExpanded, expandedWidth, showActiveIndicator =
|
|
|
52
53
|
Split: FlexSplit,
|
|
53
54
|
Divider,
|
|
54
55
|
Item,
|
|
56
|
+
ExpandableItem,
|
|
55
57
|
Button,
|
|
56
58
|
Header,
|
|
57
59
|
Footer,
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const require_index = require("../../../node_modules/@radix-ui/react-id/dist/index.cjs");
|
|
2
|
+
const require_index$1 = require("../../../node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs");
|
|
3
|
+
const require_SideBar_context = require("../../SideBar.context.cjs");
|
|
4
|
+
const require_ExpandableItem_context = require("./ExpandableItem.context.cjs");
|
|
5
|
+
const require_Item = require("../Item/Item.cjs");
|
|
6
|
+
const require_ExpandableItem_style = require("./ExpandableItem.style.cjs");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let _redislabsdev_redis_ui_icons = require("@redis-ui/icons");
|
|
9
|
+
//#region src/SideBar/components/ExpandableItem/ExpandableItem.tsx
|
|
10
|
+
var Trigger = ({ isActive = false, onClick, expandText = "Expand", collapseText = "Collapse", children, ...rest }) => {
|
|
11
|
+
const { isOpen, setOpen, hasActiveChild, itemsId } = require_ExpandableItem_context.useExpandableItemContext();
|
|
12
|
+
const { isExpanded } = require_SideBar_context.useSideBarContext();
|
|
13
|
+
const highlightsHiddenChild = !isActive && hasActiveChild && !isOpen;
|
|
14
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Item.default, {
|
|
15
|
+
...rest,
|
|
16
|
+
...highlightsHiddenChild ? { "data-state": "active" } : {},
|
|
17
|
+
isActive,
|
|
18
|
+
onClick: isExpanded || onClick ? (e) => {
|
|
19
|
+
if (isExpanded) setOpen(!isOpen);
|
|
20
|
+
onClick?.(e);
|
|
21
|
+
} : void 0,
|
|
22
|
+
children: [children, isExpanded && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ExpandableItem_style.ToggleWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ExpandableItem_style.Toggle, {
|
|
23
|
+
type: "button",
|
|
24
|
+
"aria-expanded": isOpen,
|
|
25
|
+
"aria-controls": itemsId,
|
|
26
|
+
"aria-label": isOpen ? collapseText : expandText,
|
|
27
|
+
onClick: (e) => {
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
setOpen(!isOpen);
|
|
30
|
+
},
|
|
31
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ExpandableItem_style.ToggleIcon, {
|
|
32
|
+
$isOpen: isOpen,
|
|
33
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_redislabsdev_redis_ui_icons.ChevronDownIcon, {
|
|
34
|
+
size: "S",
|
|
35
|
+
"aria-hidden": true
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
}) })]
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
var Items = ({ children, ...rest }) => {
|
|
42
|
+
const { isOpen, itemsId } = require_ExpandableItem_context.useExpandableItemContext();
|
|
43
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ExpandableItem_style.ItemsWrapper, {
|
|
44
|
+
role: "none",
|
|
45
|
+
"data-state": isOpen ? "open" : "closed",
|
|
46
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ExpandableItem_style.ItemsList, {
|
|
47
|
+
...rest,
|
|
48
|
+
id: itemsId,
|
|
49
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ExpandableItem_context.NestedItemContext.Provider, {
|
|
50
|
+
value: true,
|
|
51
|
+
children
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var ExpandableItem = Object.assign(({ isOpen: controlledOpen, defaultOpen = true, onOpenChange, hasActiveChild = false, children }) => {
|
|
57
|
+
const [open = false, setOpen] = require_index$1.useControllableState({
|
|
58
|
+
prop: controlledOpen,
|
|
59
|
+
defaultProp: defaultOpen,
|
|
60
|
+
onChange: onOpenChange
|
|
61
|
+
});
|
|
62
|
+
const { isExpanded } = require_SideBar_context.useSideBarContext();
|
|
63
|
+
const itemsId = require_index.useId();
|
|
64
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ExpandableItem_context.ExpandableItemContextProvider, {
|
|
65
|
+
value: {
|
|
66
|
+
isOpen: open && isExpanded,
|
|
67
|
+
setOpen,
|
|
68
|
+
hasActiveChild,
|
|
69
|
+
itemsId
|
|
70
|
+
},
|
|
71
|
+
children
|
|
72
|
+
});
|
|
73
|
+
}, {
|
|
74
|
+
Trigger,
|
|
75
|
+
Items
|
|
76
|
+
});
|
|
77
|
+
//#endregion
|
|
78
|
+
exports.default = ExpandableItem;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const require_NullableContext = require("../../../Helpers/contexts/NullableContext.cjs");
|
|
2
|
+
let react = require("react");
|
|
3
|
+
//#region src/SideBar/components/ExpandableItem/ExpandableItem.context.ts
|
|
4
|
+
var [useExpandableItemContext, ExpandableItemContextProvider] = require_NullableContext.createNullableContext({ forComponentName: "SideBar.ExpandableItem" });
|
|
5
|
+
var NestedItemContext = (0, react.createContext)(false);
|
|
6
|
+
var useIsNestedItem = () => (0, react.useContext)(NestedItemContext);
|
|
7
|
+
//#endregion
|
|
8
|
+
exports.ExpandableItemContextProvider = ExpandableItemContextProvider;
|
|
9
|
+
exports.NestedItemContext = NestedItemContext;
|
|
10
|
+
exports.useExpandableItemContext = useExpandableItemContext;
|
|
11
|
+
exports.useIsNestedItem = useIsNestedItem;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SideBarExpandableItemContextProps } from './ExpandableItem.types';
|
|
2
|
+
export declare const useExpandableItemContext: () => SideBarExpandableItemContextProps, ExpandableItemContextProvider: import("react").Provider<SideBarExpandableItemContextProps>;
|
|
3
|
+
export declare const NestedItemContext: import("react").Context<boolean>;
|
|
4
|
+
export declare const useIsNestedItem: () => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createNullableContext } from "../../../Helpers/contexts/NullableContext.js";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
//#region src/SideBar/components/ExpandableItem/ExpandableItem.context.ts
|
|
4
|
+
var [useExpandableItemContext, ExpandableItemContextProvider] = createNullableContext({ forComponentName: "SideBar.ExpandableItem" });
|
|
5
|
+
var NestedItemContext = createContext(false);
|
|
6
|
+
var useIsNestedItem = () => useContext(NestedItemContext);
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ExpandableItemContextProvider, NestedItemContext, useExpandableItemContext, useIsNestedItem };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SideBarExpandableItemItemsProps, SideBarExpandableItemProps, SideBarExpandableItemTriggerProps } from './ExpandableItem.types';
|
|
2
|
+
declare const ExpandableItem: (({ isOpen: controlledOpen, defaultOpen, onOpenChange, hasActiveChild, children }: SideBarExpandableItemProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
3
|
+
Trigger: ({ isActive, onClick, expandText, collapseText, children, ...rest }: SideBarExpandableItemTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
Items: ({ children, ...rest }: SideBarExpandableItemItemsProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
};
|
|
6
|
+
export default ExpandableItem;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useId } from "../../../node_modules/@radix-ui/react-id/dist/index.js";
|
|
2
|
+
import { useControllableState } from "../../../node_modules/@radix-ui/react-use-controllable-state/dist/index.js";
|
|
3
|
+
import { useSideBarContext } from "../../SideBar.context.js";
|
|
4
|
+
import { ExpandableItemContextProvider, NestedItemContext, useExpandableItemContext } from "./ExpandableItem.context.js";
|
|
5
|
+
import Item from "../Item/Item.js";
|
|
6
|
+
import { ItemsList, ItemsWrapper, Toggle, ToggleIcon, ToggleWrapper } from "./ExpandableItem.style.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { ChevronDownIcon } from "@redis-ui/icons";
|
|
9
|
+
//#region src/SideBar/components/ExpandableItem/ExpandableItem.tsx
|
|
10
|
+
var Trigger = ({ isActive = false, onClick, expandText = "Expand", collapseText = "Collapse", children, ...rest }) => {
|
|
11
|
+
const { isOpen, setOpen, hasActiveChild, itemsId } = useExpandableItemContext();
|
|
12
|
+
const { isExpanded } = useSideBarContext();
|
|
13
|
+
const highlightsHiddenChild = !isActive && hasActiveChild && !isOpen;
|
|
14
|
+
return /* @__PURE__ */ jsxs(Item, {
|
|
15
|
+
...rest,
|
|
16
|
+
...highlightsHiddenChild ? { "data-state": "active" } : {},
|
|
17
|
+
isActive,
|
|
18
|
+
onClick: isExpanded || onClick ? (e) => {
|
|
19
|
+
if (isExpanded) setOpen(!isOpen);
|
|
20
|
+
onClick?.(e);
|
|
21
|
+
} : void 0,
|
|
22
|
+
children: [children, isExpanded && /* @__PURE__ */ jsx(ToggleWrapper, { children: /* @__PURE__ */ jsx(Toggle, {
|
|
23
|
+
type: "button",
|
|
24
|
+
"aria-expanded": isOpen,
|
|
25
|
+
"aria-controls": itemsId,
|
|
26
|
+
"aria-label": isOpen ? collapseText : expandText,
|
|
27
|
+
onClick: (e) => {
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
setOpen(!isOpen);
|
|
30
|
+
},
|
|
31
|
+
children: /* @__PURE__ */ jsx(ToggleIcon, {
|
|
32
|
+
$isOpen: isOpen,
|
|
33
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
34
|
+
size: "S",
|
|
35
|
+
"aria-hidden": true
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
}) })]
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
var Items = ({ children, ...rest }) => {
|
|
42
|
+
const { isOpen, itemsId } = useExpandableItemContext();
|
|
43
|
+
return /* @__PURE__ */ jsx(ItemsWrapper, {
|
|
44
|
+
role: "none",
|
|
45
|
+
"data-state": isOpen ? "open" : "closed",
|
|
46
|
+
children: /* @__PURE__ */ jsx(ItemsList, {
|
|
47
|
+
...rest,
|
|
48
|
+
id: itemsId,
|
|
49
|
+
children: /* @__PURE__ */ jsx(NestedItemContext.Provider, {
|
|
50
|
+
value: true,
|
|
51
|
+
children
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var ExpandableItem = Object.assign(({ isOpen: controlledOpen, defaultOpen = true, onOpenChange, hasActiveChild = false, children }) => {
|
|
57
|
+
const [open = false, setOpen] = useControllableState({
|
|
58
|
+
prop: controlledOpen,
|
|
59
|
+
defaultProp: defaultOpen,
|
|
60
|
+
onChange: onOpenChange
|
|
61
|
+
});
|
|
62
|
+
const { isExpanded } = useSideBarContext();
|
|
63
|
+
const itemsId = useId();
|
|
64
|
+
return /* @__PURE__ */ jsx(ExpandableItemContextProvider, {
|
|
65
|
+
value: {
|
|
66
|
+
isOpen: open && isExpanded,
|
|
67
|
+
setOpen,
|
|
68
|
+
hasActiveChild,
|
|
69
|
+
itemsId
|
|
70
|
+
},
|
|
71
|
+
children
|
|
72
|
+
});
|
|
73
|
+
}, {
|
|
74
|
+
Trigger,
|
|
75
|
+
Items
|
|
76
|
+
});
|
|
77
|
+
//#endregion
|
|
78
|
+
export { ExpandableItem as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_Badge_style = require("../Item/components/Badge/Badge.style.cjs");
|
|
3
|
+
let styled_components = require("styled-components");
|
|
4
|
+
styled_components = require_runtime.__toESM(styled_components, 1);
|
|
5
|
+
let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
|
|
6
|
+
//#region src/SideBar/components/ExpandableItem/ExpandableItem.style.ts
|
|
7
|
+
var ToggleWrapper = styled_components.default.span.withConfig({
|
|
8
|
+
displayName: "ExpandableItemstyle__ToggleWrapper",
|
|
9
|
+
componentId: "RedisUI__sc-11si4vt-0"
|
|
10
|
+
})(["display:flex;margin-inline-start:auto;", " ~ &{margin-inline-start:0;}"], require_Badge_style.Badge);
|
|
11
|
+
var Toggle = styled_components.default.button.withConfig({
|
|
12
|
+
displayName: "ExpandableItemstyle__Toggle",
|
|
13
|
+
componentId: "RedisUI__sc-11si4vt-1"
|
|
14
|
+
})([
|
|
15
|
+
"display:flex;align-items:center;justify-content:center;padding:0;border:0;border-radius:0.4rem;background:transparent;color:inherit;cursor:pointer;&:focus-visible{outline:",
|
|
16
|
+
" solid ",
|
|
17
|
+
";}"
|
|
18
|
+
], () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.size, () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.color);
|
|
19
|
+
var ToggleIcon = styled_components.default.span.withConfig({
|
|
20
|
+
displayName: "ExpandableItemstyle__ToggleIcon",
|
|
21
|
+
componentId: "RedisUI__sc-11si4vt-2"
|
|
22
|
+
})(["display:flex;transition:transform 160ms ease-out;transform:rotate(", ");@media (prefers-reduced-motion:reduce){transition:none;}"], ({ $isOpen }) => $isOpen ? "180deg" : "0deg");
|
|
23
|
+
var ItemsWrapper = styled_components.default.li.withConfig({
|
|
24
|
+
displayName: "ExpandableItemstyle__ItemsWrapper",
|
|
25
|
+
componentId: "RedisUI__sc-11si4vt-3"
|
|
26
|
+
})(["display:grid;grid-template-rows:0fr;opacity:0;transform:translateY(-0.4rem);visibility:hidden;list-style:none;transition:grid-template-rows 240ms ease-in-out,opacity 180ms ease-out,transform 240ms ease-in-out,visibility 0s 240ms;&[data-state='open']{grid-template-rows:1fr;opacity:1;transform:none;visibility:visible;transition-delay:0s;}@media (prefers-reduced-motion:reduce){transition:none;}"]);
|
|
27
|
+
var ItemsList = styled_components.default.ul.withConfig({
|
|
28
|
+
displayName: "ExpandableItemstyle__ItemsList",
|
|
29
|
+
componentId: "RedisUI__sc-11si4vt-4"
|
|
30
|
+
})(["display:flex;flex-direction:column;min-height:0;margin:0;padding:0;overflow:hidden;list-style:none;"]);
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.ItemsList = ItemsList;
|
|
33
|
+
exports.ItemsWrapper = ItemsWrapper;
|
|
34
|
+
exports.Toggle = Toggle;
|
|
35
|
+
exports.ToggleIcon = ToggleIcon;
|
|
36
|
+
exports.ToggleWrapper = ToggleWrapper;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ToggleWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
2
|
+
export declare const Toggle: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
3
|
+
export declare const ToggleIcon: import("styled-components").StyledComponent<"span", any, {
|
|
4
|
+
$isOpen: boolean;
|
|
5
|
+
}, never>;
|
|
6
|
+
export declare const ItemsWrapper: import("styled-components").StyledComponent<"li", any, {}, never>;
|
|
7
|
+
export declare const ItemsList: import("styled-components").StyledComponent<"ul", any, {}, never>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Badge } from "../Item/components/Badge/Badge.style.js";
|
|
2
|
+
import _styled from "styled-components";
|
|
3
|
+
import { useTheme } from "@redis-ui/styles";
|
|
4
|
+
//#region src/SideBar/components/ExpandableItem/ExpandableItem.style.ts
|
|
5
|
+
var ToggleWrapper = _styled.span.withConfig({
|
|
6
|
+
displayName: "ExpandableItemstyle__ToggleWrapper",
|
|
7
|
+
componentId: "RedisUI__sc-11si4vt-0"
|
|
8
|
+
})(["display:flex;margin-inline-start:auto;", " ~ &{margin-inline-start:0;}"], Badge);
|
|
9
|
+
var Toggle = _styled.button.withConfig({
|
|
10
|
+
displayName: "ExpandableItemstyle__Toggle",
|
|
11
|
+
componentId: "RedisUI__sc-11si4vt-1"
|
|
12
|
+
})([
|
|
13
|
+
"display:flex;align-items:center;justify-content:center;padding:0;border:0;border-radius:0.4rem;background:transparent;color:inherit;cursor:pointer;&:focus-visible{outline:",
|
|
14
|
+
" solid ",
|
|
15
|
+
";}"
|
|
16
|
+
], () => useTheme().core.focus.size, () => useTheme().core.focus.color);
|
|
17
|
+
var ToggleIcon = _styled.span.withConfig({
|
|
18
|
+
displayName: "ExpandableItemstyle__ToggleIcon",
|
|
19
|
+
componentId: "RedisUI__sc-11si4vt-2"
|
|
20
|
+
})(["display:flex;transition:transform 160ms ease-out;transform:rotate(", ");@media (prefers-reduced-motion:reduce){transition:none;}"], ({ $isOpen }) => $isOpen ? "180deg" : "0deg");
|
|
21
|
+
var ItemsWrapper = _styled.li.withConfig({
|
|
22
|
+
displayName: "ExpandableItemstyle__ItemsWrapper",
|
|
23
|
+
componentId: "RedisUI__sc-11si4vt-3"
|
|
24
|
+
})(["display:grid;grid-template-rows:0fr;opacity:0;transform:translateY(-0.4rem);visibility:hidden;list-style:none;transition:grid-template-rows 240ms ease-in-out,opacity 180ms ease-out,transform 240ms ease-in-out,visibility 0s 240ms;&[data-state='open']{grid-template-rows:1fr;opacity:1;transform:none;visibility:visible;transition-delay:0s;}@media (prefers-reduced-motion:reduce){transition:none;}"]);
|
|
25
|
+
var ItemsList = _styled.ul.withConfig({
|
|
26
|
+
displayName: "ExpandableItemstyle__ItemsList",
|
|
27
|
+
componentId: "RedisUI__sc-11si4vt-4"
|
|
28
|
+
})(["display:flex;flex-direction:column;min-height:0;margin:0;padding:0;overflow:hidden;list-style:none;"]);
|
|
29
|
+
//#endregion
|
|
30
|
+
export { ItemsList, ItemsWrapper, Toggle, ToggleIcon, ToggleWrapper };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SideBarItemProps } from '../Item/Item.types';
|
|
3
|
+
export interface SideBarExpandableItemProps {
|
|
4
|
+
isOpen?: boolean;
|
|
5
|
+
defaultOpen?: boolean;
|
|
6
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
7
|
+
/** Highlights the trigger while the section is closed, so the active row stays visible. */
|
|
8
|
+
hasActiveChild?: boolean;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export interface SideBarExpandableItemTriggerProps extends SideBarItemProps {
|
|
12
|
+
expandText?: string;
|
|
13
|
+
collapseText?: string;
|
|
14
|
+
}
|
|
15
|
+
export type SideBarExpandableItemItemsProps = React.HTMLAttributes<HTMLUListElement>;
|
|
16
|
+
export interface SideBarExpandableItemContextProps {
|
|
17
|
+
isOpen: boolean;
|
|
18
|
+
setOpen: (isOpen: boolean) => void;
|
|
19
|
+
hasActiveChild: boolean;
|
|
20
|
+
itemsId: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_Tooltip = require("../../../Tooltip/Tooltip.cjs");
|
|
2
2
|
const require_SideBar_context = require("../../SideBar.context.cjs");
|
|
3
3
|
const require_Icon = require("./components/Icon/Icon.cjs");
|
|
4
|
+
const require_ExpandableItem_context = require("../ExpandableItem/ExpandableItem.context.cjs");
|
|
4
5
|
const require_Text = require("./components/Text/Text.cjs");
|
|
5
6
|
const require_Button = require("./components/Button/Button.cjs");
|
|
6
7
|
const require_Badge = require("./components/Badge/Badge.cjs");
|
|
@@ -11,6 +12,7 @@ let react = require("react");
|
|
|
11
12
|
var Item = Object.assign(({ tooltipProps, isActive = false, onKeyDown, ...restProps }) => {
|
|
12
13
|
const itemRef = (0, react.useRef)(null);
|
|
13
14
|
const { isExpanded, showActiveIndicator } = require_SideBar_context.useSideBarContext();
|
|
15
|
+
const isNested = require_ExpandableItem_context.useIsNestedItem();
|
|
14
16
|
const activeLinkAttributes = isActive ? {
|
|
15
17
|
"data-state": "active",
|
|
16
18
|
"aria-current": "page"
|
|
@@ -30,7 +32,8 @@ var Item = Object.assign(({ tooltipProps, isActive = false, onKeyDown, ...restPr
|
|
|
30
32
|
tabIndex,
|
|
31
33
|
onKeyDown: handleKeyDown,
|
|
32
34
|
ref: itemRef,
|
|
33
|
-
$hasActiveIndicator: showActiveIndicator
|
|
35
|
+
$hasActiveIndicator: showActiveIndicator,
|
|
36
|
+
$isNested: isNested
|
|
34
37
|
});
|
|
35
38
|
return isExpanded ? item : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Tooltip.default, {
|
|
36
39
|
...tooltipProps,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Tooltip from "../../../Tooltip/Tooltip.js";
|
|
2
2
|
import { useSideBarContext } from "../../SideBar.context.js";
|
|
3
3
|
import Icon from "./components/Icon/Icon.js";
|
|
4
|
+
import { useIsNestedItem } from "../ExpandableItem/ExpandableItem.context.js";
|
|
4
5
|
import Text from "./components/Text/Text.js";
|
|
5
6
|
import Button from "./components/Button/Button.js";
|
|
6
7
|
import Badge from "./components/Badge/Badge.js";
|
|
@@ -11,6 +12,7 @@ import { useRef } from "react";
|
|
|
11
12
|
var Item = Object.assign(({ tooltipProps, isActive = false, onKeyDown, ...restProps }) => {
|
|
12
13
|
const itemRef = useRef(null);
|
|
13
14
|
const { isExpanded, showActiveIndicator } = useSideBarContext();
|
|
15
|
+
const isNested = useIsNestedItem();
|
|
14
16
|
const activeLinkAttributes = isActive ? {
|
|
15
17
|
"data-state": "active",
|
|
16
18
|
"aria-current": "page"
|
|
@@ -30,7 +32,8 @@ var Item = Object.assign(({ tooltipProps, isActive = false, onKeyDown, ...restPr
|
|
|
30
32
|
tabIndex,
|
|
31
33
|
onKeyDown: handleKeyDown,
|
|
32
34
|
ref: itemRef,
|
|
33
|
-
$hasActiveIndicator: showActiveIndicator
|
|
35
|
+
$hasActiveIndicator: showActiveIndicator,
|
|
36
|
+
$isNested: isNested
|
|
34
37
|
});
|
|
35
38
|
return isExpanded ? item : /* @__PURE__ */ jsx(Tooltip, {
|
|
36
39
|
...tooltipProps,
|
|
@@ -17,9 +17,12 @@ var SideBarItem = styled_components.default.li.withConfig({
|
|
|
17
17
|
";outline-offset:-",
|
|
18
18
|
";}",
|
|
19
19
|
";& > svg{transition:inherit;}"
|
|
20
|
-
], () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.size, () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.color, () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.size, ({ $hasActiveIndicator = true }) => {
|
|
20
|
+
], () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.size, () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.color, () => (0, _redislabsdev_redis_ui_styles.useTheme)().core.focus.size, ({ $hasActiveIndicator = true, $isNested = false }) => {
|
|
21
|
+
const { core } = (0, _redislabsdev_redis_ui_styles.useTheme)();
|
|
21
22
|
return require_SideBar_utils.useStateStyle(({ item: theme }, state) => {
|
|
22
23
|
const { states } = theme;
|
|
24
|
+
const gap = theme.gap ?? require_SideBar_constants.SIDEBAR_CONSTANTS.item.gap;
|
|
25
|
+
const nestedPaddingStart = `calc(${require_SideBar_constants.SIDEBAR_CONSTANTS.item.paddingInline} + ${theme.iconSize ?? core.icon.size.L} + ${gap})`;
|
|
23
26
|
return styled_components.css`
|
|
24
27
|
margin: ${theme.margin ?? require_SideBar_constants.SIDEBAR_CONSTANTS.item.margin};
|
|
25
28
|
${state === "expanded" && styled_components.css`
|
|
@@ -27,10 +30,10 @@ var SideBarItem = styled_components.default.li.withConfig({
|
|
|
27
30
|
margin-inline-end: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.itemWithButtonOffset};
|
|
28
31
|
}
|
|
29
32
|
`}
|
|
30
|
-
height: ${theme.height ?? require_SideBar_constants.SIDEBAR_CONSTANTS.item.height};
|
|
31
|
-
padding: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.padding};
|
|
33
|
+
height: ${$isNested ? theme.child?.height ?? require_SideBar_constants.SIDEBAR_CONSTANTS.item.childHeight : theme.height ?? require_SideBar_constants.SIDEBAR_CONSTANTS.item.height};
|
|
34
|
+
padding: ${$isNested ? `0 ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.paddingInline} 0 ${nestedPaddingStart}` : require_SideBar_constants.SIDEBAR_CONSTANTS.item.padding};
|
|
32
35
|
border-radius: ${require_SideBar_constants.SIDEBAR_CONSTANTS.item.borderRadius};
|
|
33
|
-
gap: ${
|
|
36
|
+
gap: ${gap};
|
|
34
37
|
|
|
35
38
|
& {
|
|
36
39
|
${require_css_utils.styleFromTokens({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const SideBarItem: import("styled-components").StyledComponent<"li", any, {
|
|
2
2
|
$hasActiveIndicator?: boolean;
|
|
3
|
+
$isNested?: boolean;
|
|
3
4
|
}, never>;
|
|
4
5
|
export declare const TooltipContent: import("styled-components").StyledComponent<(props: import("../../..").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
|
|
@@ -15,9 +15,12 @@ var SideBarItem = _styled.li.withConfig({
|
|
|
15
15
|
";outline-offset:-",
|
|
16
16
|
";}",
|
|
17
17
|
";& > svg{transition:inherit;}"
|
|
18
|
-
], () => useTheme().core.focus.size, () => useTheme().core.focus.color, () => useTheme().core.focus.size, ({ $hasActiveIndicator = true }) => {
|
|
18
|
+
], () => useTheme().core.focus.size, () => useTheme().core.focus.color, () => useTheme().core.focus.size, ({ $hasActiveIndicator = true, $isNested = false }) => {
|
|
19
|
+
const { core } = useTheme();
|
|
19
20
|
return useStateStyle(({ item: theme }, state) => {
|
|
20
21
|
const { states } = theme;
|
|
22
|
+
const gap = theme.gap ?? SIDEBAR_CONSTANTS.item.gap;
|
|
23
|
+
const nestedPaddingStart = `calc(${SIDEBAR_CONSTANTS.item.paddingInline} + ${theme.iconSize ?? core.icon.size.L} + ${gap})`;
|
|
21
24
|
return css`
|
|
22
25
|
margin: ${theme.margin ?? SIDEBAR_CONSTANTS.item.margin};
|
|
23
26
|
${state === "expanded" && css`
|
|
@@ -25,10 +28,10 @@ var SideBarItem = _styled.li.withConfig({
|
|
|
25
28
|
margin-inline-end: ${SIDEBAR_CONSTANTS.item.itemWithButtonOffset};
|
|
26
29
|
}
|
|
27
30
|
`}
|
|
28
|
-
height: ${theme.height ?? SIDEBAR_CONSTANTS.item.height};
|
|
29
|
-
padding: ${SIDEBAR_CONSTANTS.item.padding};
|
|
31
|
+
height: ${$isNested ? theme.child?.height ?? SIDEBAR_CONSTANTS.item.childHeight : theme.height ?? SIDEBAR_CONSTANTS.item.height};
|
|
32
|
+
padding: ${$isNested ? `0 ${SIDEBAR_CONSTANTS.item.paddingInline} 0 ${nestedPaddingStart}` : SIDEBAR_CONSTANTS.item.padding};
|
|
30
33
|
border-radius: ${SIDEBAR_CONSTANTS.item.borderRadius};
|
|
31
|
-
gap: ${
|
|
34
|
+
gap: ${gap};
|
|
32
35
|
|
|
33
36
|
& {
|
|
34
37
|
${styleFromTokens({
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const require_SideBar_context = require("../../../../SideBar.context.cjs");
|
|
2
|
+
const require_ExpandableItem_context = require("../../../ExpandableItem/ExpandableItem.context.cjs");
|
|
2
3
|
const require_Text_style = require("./Text.style.cjs");
|
|
3
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
5
|
//#region src/SideBar/components/Item/components/Text/Text.tsx
|
|
5
6
|
var Text = (props) => {
|
|
6
7
|
const { isExpanded, transitionEnd } = require_SideBar_context.useSideBarContext();
|
|
8
|
+
const isNested = require_ExpandableItem_context.useIsNestedItem();
|
|
7
9
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Text_style.SideBarItemText, {
|
|
8
10
|
ellipsis: true,
|
|
9
11
|
tooltipOnEllipsis: true,
|
|
@@ -11,6 +13,7 @@ var Text = (props) => {
|
|
|
11
13
|
$isExpanded: isExpanded,
|
|
12
14
|
$transitionEnd: transitionEnd,
|
|
13
15
|
$useThemeFontSize: props.size === void 0,
|
|
16
|
+
$isNested: isNested,
|
|
14
17
|
...props
|
|
15
18
|
});
|
|
16
19
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { useSideBarContext } from "../../../../SideBar.context.js";
|
|
2
|
+
import { useIsNestedItem } from "../../../ExpandableItem/ExpandableItem.context.js";
|
|
2
3
|
import { SideBarItemText } from "./Text.style.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
//#region src/SideBar/components/Item/components/Text/Text.tsx
|
|
5
6
|
var Text = (props) => {
|
|
6
7
|
const { isExpanded, transitionEnd } = useSideBarContext();
|
|
8
|
+
const isNested = useIsNestedItem();
|
|
7
9
|
return /* @__PURE__ */ jsx(SideBarItemText, {
|
|
8
10
|
ellipsis: true,
|
|
9
11
|
tooltipOnEllipsis: true,
|
|
@@ -11,6 +13,7 @@ var Text = (props) => {
|
|
|
11
13
|
$isExpanded: isExpanded,
|
|
12
14
|
$transitionEnd: transitionEnd,
|
|
13
15
|
$useThemeFontSize: props.size === void 0,
|
|
16
|
+
$isNested: isNested,
|
|
14
17
|
...props
|
|
15
18
|
});
|
|
16
19
|
};
|
|
@@ -11,8 +11,9 @@ var SideBarItemText = (0, styled_components.default)(require_Typography.default.
|
|
|
11
11
|
"transition:opacity 0.4s;@media (prefers-reduced-motion:reduce){transition:none;}opacity:",
|
|
12
12
|
";",
|
|
13
13
|
""
|
|
14
|
-
], ({ $isExpanded, $transitionEnd }) => $isExpanded && $transitionEnd ? "1" : "0", ({ $useThemeFontSize }) => {
|
|
15
|
-
const { fontSize } = (0, _redislabsdev_redis_ui_styles.useTheme)().components.sideBar.item;
|
|
14
|
+
], ({ $isExpanded, $transitionEnd }) => $isExpanded && $transitionEnd ? "1" : "0", ({ $useThemeFontSize, $isNested }) => {
|
|
15
|
+
const { fontSize: itemFontSize, child } = (0, _redislabsdev_redis_ui_styles.useTheme)().components.sideBar.item;
|
|
16
|
+
const fontSize = $isNested ? child?.fontSize ?? itemFontSize : itemFontSize;
|
|
16
17
|
return $useThemeFontSize && fontSize && styled_components.css`
|
|
17
18
|
font-size: ${fontSize};
|
|
18
19
|
`;
|
|
@@ -9,8 +9,9 @@ var SideBarItemText = _styled(Typography.Body).withConfig({
|
|
|
9
9
|
"transition:opacity 0.4s;@media (prefers-reduced-motion:reduce){transition:none;}opacity:",
|
|
10
10
|
";",
|
|
11
11
|
""
|
|
12
|
-
], ({ $isExpanded, $transitionEnd }) => $isExpanded && $transitionEnd ? "1" : "0", ({ $useThemeFontSize }) => {
|
|
13
|
-
const { fontSize } = useTheme().components.sideBar.item;
|
|
12
|
+
], ({ $isExpanded, $transitionEnd }) => $isExpanded && $transitionEnd ? "1" : "0", ({ $useThemeFontSize, $isNested }) => {
|
|
13
|
+
const { fontSize: itemFontSize, child } = useTheme().components.sideBar.item;
|
|
14
|
+
const fontSize = $isNested ? child?.fontSize ?? itemFontSize : itemFontSize;
|
|
14
15
|
return $useThemeFontSize && fontSize && css`
|
|
15
16
|
font-size: ${fontSize};
|
|
16
17
|
`;
|
package/dist/SideBar/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redis-ui/components",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "51.
|
|
4
|
+
"version": "51.15.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"repository": "git@github.com:redislabsdev/redis-ui.git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@redis-ui/icons": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
33
|
-
"@redis-ui/styles": "^21.
|
|
33
|
+
"@redis-ui/styles": "^21.22.0",
|
|
34
34
|
"react": "^18.0.0 || ^19.0.0",
|
|
35
35
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
36
36
|
"styled-components": "^5.0.0"
|
|
@@ -32,6 +32,9 @@ The component also accepts all `FlexGroupProps` except `direction`, which is fix
|
|
|
32
32
|
- `SideBar.Item.Text` - Text slot for a sidebar item.
|
|
33
33
|
- `SideBar.Item.Button` - Compact action button rendered inside a sidebar item.
|
|
34
34
|
- `SideBar.Item.Badge` - Badge slot rendered to the right of `Item.Text` (e.g. `NEW`, `BETA`).
|
|
35
|
+
- `SideBar.ExpandableItem` - Section root that opens and closes a list of nested items. Holds the open state.
|
|
36
|
+
- `SideBar.ExpandableItem.Trigger` - Parent row of a section, with a chevron that toggles it.
|
|
37
|
+
- `SideBar.ExpandableItem.Items` - List of nested `SideBar.Item`s, shown while the section is open.
|
|
35
38
|
- `SideBar.Group` - Wrapper around a section's `Group.Title` and items. Use one `SideBar.Group` per logical section.
|
|
36
39
|
- `SideBar.Group.Title` - Section label rendered above a group of items.
|
|
37
40
|
- `SideBar.Footer` - Footer wrapper for metadata, links, and text.
|
|
@@ -102,6 +105,31 @@ This slot inherits all `ActionIconButtonProps` and defaults `size` to `M`. It is
|
|
|
102
105
|
|
|
103
106
|
This slot inherits all `BadgeProps` from the base `Badge` component. It is shown next to item text when the sidebar is expanded and hidden while collapsed.
|
|
104
107
|
|
|
108
|
+
### SideBar.ExpandableItem Props
|
|
109
|
+
|
|
110
|
+
| Prop | Type | Default | Description |
|
|
111
|
+
|------|------|---------|-------------|
|
|
112
|
+
| children | `React.ReactNode` | *required* | A `Trigger` followed by `Items` |
|
|
113
|
+
| isOpen | `boolean` | - | Controlled open state |
|
|
114
|
+
| defaultOpen | `boolean` | `true` | Initial open state when uncontrolled |
|
|
115
|
+
| onOpenChange | `(isOpen: boolean) => void` | - | Called when the section opens or closes |
|
|
116
|
+
| hasActiveChild | `boolean` | `false` | Highlights the trigger while the section is closed, so the active row stays visible |
|
|
117
|
+
|
|
118
|
+
The section is always shown closed while the sidebar is collapsed, so only the triggers stay in the rail.
|
|
119
|
+
|
|
120
|
+
### SideBar.ExpandableItem.Trigger Props
|
|
121
|
+
|
|
122
|
+
| Prop | Type | Default | Description |
|
|
123
|
+
|------|------|---------|-------------|
|
|
124
|
+
| expandText | `string` | `'Expand'` | Accessible name of the chevron while the section is closed |
|
|
125
|
+
| collapseText | `string` | `'Collapse'` | Accessible name of the chevron while the section is open |
|
|
126
|
+
|
|
127
|
+
The trigger also accepts all `SideBar.Item` props. Clicking the row toggles the section (while the sidebar is expanded) and then calls `onClick`. The chevron only toggles the section. Compose it with `Item.Icon`, `Item.Text` and `Item.Badge` like a regular item. `Item.Button` is not supported on a trigger, since the chevron sits at the end of the row.
|
|
128
|
+
|
|
129
|
+
### SideBar.ExpandableItem.Items Props
|
|
130
|
+
|
|
131
|
+
This list accepts standard `HTMLAttributes<HTMLUListElement>`. Its `SideBar.Item` children render as nested rows: shorter than top-level items, with their label lined up with the trigger's label. Nested items don't need an `Item.Icon`.
|
|
132
|
+
|
|
105
133
|
### SideBar.Group Props
|
|
106
134
|
|
|
107
135
|
This wrapper accepts standard `HTMLAttributes<HTMLDivElement>`. Place a `SideBar.Group.Title` and the section's items inside.
|
|
@@ -664,6 +692,90 @@ const [expanded, setExpanded] = useState(true);
|
|
|
664
692
|
</SideBar>
|
|
665
693
|
```
|
|
666
694
|
|
|
695
|
+
### ExpandableItem Playground
|
|
696
|
+
|
|
697
|
+
> A section with children. Click the row or the chevron to open and close it.
|
|
698
|
+
|
|
699
|
+
```tsx
|
|
700
|
+
import { SideBar } from '@redis-ui/components';
|
|
701
|
+
import { DatabaseIcon, IconType, SettingsIcon, StarsIcon } from '@redis-ui/icons';
|
|
702
|
+
import { useState } from 'react';
|
|
703
|
+
|
|
704
|
+
const sections: { label: string; icon: IconType; children: string[] }[] = [
|
|
705
|
+
{ label: 'Databases', icon: DatabaseIcon, children: ['Redis', 'Redis Flex'] },
|
|
706
|
+
{
|
|
707
|
+
label: 'Iris',
|
|
708
|
+
icon: StarsIcon,
|
|
709
|
+
children: ['Agent Playbooks', 'Agent Memory', 'Context Gateway', 'Lens']
|
|
710
|
+
}
|
|
711
|
+
];
|
|
712
|
+
|
|
713
|
+
const Section = ({ label, icon, children, activeLink, onNavigate, defaultOpen }) => (
|
|
714
|
+
<SideBar.ExpandableItem defaultOpen={defaultOpen} hasActiveChild={children.includes(activeLink)}>
|
|
715
|
+
<SideBar.ExpandableItem.Trigger
|
|
716
|
+
isActive={activeLink === label}
|
|
717
|
+
onClick={() => onNavigate(label)}
|
|
718
|
+
tooltipProps={{ text: label, placement: 'right' }}
|
|
719
|
+
expandText={`Expand ${label}`}
|
|
720
|
+
collapseText={`Collapse ${label}`}
|
|
721
|
+
>
|
|
722
|
+
<SideBar.Item.Icon icon={icon} />
|
|
723
|
+
<SideBar.Item.Text>{label}</SideBar.Item.Text>
|
|
724
|
+
</SideBar.ExpandableItem.Trigger>
|
|
725
|
+
<SideBar.ExpandableItem.Items>
|
|
726
|
+
{children.map((child) => (
|
|
727
|
+
<SideBar.Item
|
|
728
|
+
key={child}
|
|
729
|
+
isActive={activeLink === child}
|
|
730
|
+
onClick={() => onNavigate(child)}
|
|
731
|
+
tooltipProps={{ text: child, placement: 'right' }}
|
|
732
|
+
>
|
|
733
|
+
<SideBar.Item.Text>{child}</SideBar.Item.Text>
|
|
734
|
+
</SideBar.Item>
|
|
735
|
+
))}
|
|
736
|
+
</SideBar.ExpandableItem.Items>
|
|
737
|
+
</SideBar.ExpandableItem>
|
|
738
|
+
);
|
|
739
|
+
|
|
740
|
+
const [activeLink, setActiveLink] = useState('Agent Memory');
|
|
741
|
+
|
|
742
|
+
<SideBar isExpanded expandedWidth="24rem" showActiveIndicator={false}>
|
|
743
|
+
<SideBar.ScrollContainer>
|
|
744
|
+
<SideBar.ItemsContainer>
|
|
745
|
+
{sections.map((section) => (
|
|
746
|
+
<Section
|
|
747
|
+
key={section.label}
|
|
748
|
+
{...section}
|
|
749
|
+
activeLink={activeLink}
|
|
750
|
+
onNavigate={setActiveLink}
|
|
751
|
+
/>
|
|
752
|
+
))}
|
|
753
|
+
<SideBar.Item
|
|
754
|
+
isActive={activeLink === 'Settings'}
|
|
755
|
+
onClick={() => setActiveLink('Settings')}
|
|
756
|
+
tooltipProps={{ text: 'Settings', placement: 'right' }}
|
|
757
|
+
>
|
|
758
|
+
<SideBar.Item.Icon icon={SettingsIcon} />
|
|
759
|
+
<SideBar.Item.Text>Settings</SideBar.Item.Text>
|
|
760
|
+
</SideBar.Item>
|
|
761
|
+
</SideBar.ItemsContainer>
|
|
762
|
+
</SideBar.ScrollContainer>
|
|
763
|
+
</SideBar>
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
### ExpandableItem States
|
|
767
|
+
|
|
768
|
+
> While a section is closed, its trigger takes the highlight of the active child.
|
|
769
|
+
> In the collapsed rail only triggers show, and their tooltips carry the labels.
|
|
770
|
+
|
|
771
|
+
```tsx
|
|
772
|
+
// Closed section with an active child: the Iris trigger is highlighted
|
|
773
|
+
<Section {...irisSection} activeLink="Agent Memory" onNavigate={setActiveLink} defaultOpen={false} />
|
|
774
|
+
|
|
775
|
+
// Collapsed rail: nested items are hidden, triggers show with tooltips
|
|
776
|
+
<SideBar isExpanded={false}>...</SideBar>
|
|
777
|
+
```
|
|
778
|
+
|
|
667
779
|
## Notes
|
|
668
780
|
|
|
669
781
|
- `SideBar` is a collapsible navigation shell with a fixed header/footer layout and grouped content in the middle.
|
|
@@ -677,7 +789,9 @@ const [expanded, setExpanded] = useState(true);
|
|
|
677
789
|
- `SideBar.Item` supports the `isActive` prop for marking the current route or selected item.
|
|
678
790
|
- `SideBar.Item.Button` defaults its size to `M`.
|
|
679
791
|
- `SideBar.Button` is the root collapsible action button, and it defaults to `PlusIcon` when no collapsed icon is provided.
|
|
792
|
+
- `SideBar.ExpandableItem` adds one level of nesting. Put `Trigger` and `Items` inside it, and place it in a `SideBar.ItemsContainer` next to regular items.
|
|
793
|
+
- Pass `hasActiveChild` when a nested item is active, so the trigger stays highlighted while the section is closed. Only one row is highlighted at a time.
|
|
680
794
|
- `SideBar.Group` wraps a section's `Group.Title` (optional) and items so the title and the items stay together as one logical unit.
|
|
681
795
|
- `SideBar.Group.Title` labels a group of items. Pair `SideBar.Item.Badge` with `Item.Text` if you need to mark individual items as `NEW`, `BETA`, etc.
|
|
682
796
|
- **Theme Architecture (v17.0.0+)**: The SideBar theme uses a flattened structure where state-dependent theme properties (`collapseButton.border`, `collapseButton.right`, `footer.meta.visibility`, `footer.meta.whiteSpace`) are defined as `{ collapsed: string; expanded: string }` objects directly on the theme. Structural layout values (widths, heights, margins, paddings, gaps, radii, shadows) that don't vary across light/dark themes are defined in `SIDEBAR_CONSTANTS` rather than duplicated in each theme file. This eliminates the need for runtime theme merging and provides full type safety.
|
|
683
|
-
- **Optional sizing theme keys**: a theme can set `button.height`, `item.fontSize`, `item.gap`, `item.iconSize`, `item.height`, `item.margin` and `groupTitle.fontSize` to resize the sidebar. `button.height` replaces `SIDEBAR_CONSTANTS.button.height` and also sets the collapsed `SideBar.Button` width, so it stays square. `item.gap`, `item.height` and `item.margin` replace the matching `SIDEBAR_CONSTANTS.item` values (for items and `CollapseButton`), `item.iconSize` replaces the `L` icon size, `item.fontSize` applies to `Item.Text` without a `size` (including `CollapseButton`), and `groupTitle.fontSize` replaces the `S` group title size. Themes that leave them unset keep the defaults; the Next themes set them for Ultra.
|
|
797
|
+
- **Optional sizing theme keys**: a theme can set `button.height`, `item.fontSize`, `item.gap`, `item.iconSize`, `item.height`, `item.margin` and `groupTitle.fontSize` to resize the sidebar. `button.height` replaces `SIDEBAR_CONSTANTS.button.height` and also sets the collapsed `SideBar.Button` width, so it stays square. `item.gap`, `item.height` and `item.margin` replace the matching `SIDEBAR_CONSTANTS.item` values (for items and `CollapseButton`), `item.iconSize` replaces the `L` icon size, `item.fontSize` applies to `Item.Text` without a `size` (including `CollapseButton`), and `groupTitle.fontSize` replaces the `S` group title size. `item.child.height` and `item.child.fontSize` size the items inside `SideBar.ExpandableItem.Items` (defaulting to `2.8rem` and `item.fontSize`). Themes that leave them unset keep the defaults; the Next themes set them for Ultra.
|