@redis-ui/components 51.30.0 → 51.31.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.
@@ -18,13 +18,26 @@ let _redislabsdev_redis_ui_styles = require("@redis-ui/styles");
18
18
  let react_jsx_runtime = require("react/jsx-runtime");
19
19
  let react = require("react");
20
20
  //#region src/SideBar/SideBar.tsx
21
- var SideBar = Object.assign(({ isExpanded, expandedWidth, showActiveIndicator = true, ...rest }) => {
21
+ var SideBar = Object.assign(({ isExpanded, expandedWidth, showActiveIndicator = true, overlay = false, ...rest }) => {
22
22
  const [transitionEnd, setTransitionEnd] = (0, react.useState)(true);
23
23
  const prefersReducedMotion = (0, _redislabsdev_redis_ui_styles.usePrefersReducedMotion)();
24
24
  const sidebarId = require_index.useId();
25
25
  const handleTransitionChange = (end) => {
26
26
  setTransitionEnd(prefersReducedMotion ? true : end);
27
27
  };
28
+ const nav = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SideBar_style.SideBarContainer, {
29
+ component: "nav",
30
+ direction: "column",
31
+ gap: "0",
32
+ id: sidebarId,
33
+ onTransitionEnd: () => handleTransitionChange(true),
34
+ "data-state": isExpanded ? "expanded" : "collapsed",
35
+ "data-transition": transitionEnd ? "inactive" : "active",
36
+ "data-role": "nav-bar",
37
+ $expandedWidth: expandedWidth,
38
+ $overlay: overlay,
39
+ ...rest
40
+ });
28
41
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SideBar_context.SideBarContextProvider, {
29
42
  value: {
30
43
  transitionEnd,
@@ -33,17 +46,9 @@ var SideBar = Object.assign(({ isExpanded, expandedWidth, showActiveIndicator =
33
46
  showActiveIndicator,
34
47
  sidebarId
35
48
  },
36
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Provider.default, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SideBar_style.SideBarContainer, {
37
- component: "nav",
38
- direction: "column",
39
- gap: "0",
40
- id: sidebarId,
41
- onTransitionEnd: () => handleTransitionChange(true),
42
- "data-state": isExpanded ? "expanded" : "collapsed",
43
- "data-transition": transitionEnd ? "inactive" : "active",
44
- "data-role": "nav-bar",
45
- $expandedWidth: expandedWidth,
46
- ...rest
49
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Provider.default, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SideBar_style.OverlaySlot, {
50
+ $overlay: overlay,
51
+ children: nav
47
52
  }) })
48
53
  });
49
54
  }, {
@@ -1,5 +1,5 @@
1
1
  import { SideBarProps } from './SideBar.types';
2
- declare const SideBar: (({ isExpanded, expandedWidth, showActiveIndicator, ...rest }: SideBarProps) => import("react/jsx-runtime").JSX.Element) & {
2
+ declare const SideBar: (({ isExpanded, expandedWidth, showActiveIndicator, overlay, ...rest }: SideBarProps) => import("react/jsx-runtime").JSX.Element) & {
3
3
  SideBarLogo: ({ logoIcon: LogoIcon, ...restProps }: import("./components/SideBarLogo/SideBarLogo.types").SideBarLogoProps) => import("react/jsx-runtime").JSX.Element;
4
4
  ItemsContainer: (props: import("./components/ItemsContainer/ItemsContainer.types").SideBarItemsContainerProps) => import("react/jsx-runtime").JSX.Element;
5
5
  ScrollContainer: (props: import("./components/ScrollContainer/ScrollContainer.types").SideBarScrollContainerProps) => import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ import { FlexSplit } from "../Layouts/FlexSplit/FlexSplit.js";
4
4
  import { SideBarContextProvider } from "./SideBar.context.js";
5
5
  import SideBarLogo from "./components/SideBarLogo/SideBarLogo.js";
6
6
  import SideBarItemsContainer from "./components/ItemsContainer/ItemsContainer.js";
7
- import { SideBarContainer } from "./SideBar.style.js";
7
+ import { OverlaySlot, SideBarContainer } from "./SideBar.style.js";
8
8
  import Divider from "./components/Divider/Divider.js";
9
9
  import Item from "./components/Item/Item.js";
10
10
  import Button from "./components/Button/Button.js";
@@ -18,13 +18,26 @@ import { usePrefersReducedMotion } from "@redis-ui/styles";
18
18
  import { jsx } from "react/jsx-runtime";
19
19
  import { useState } from "react";
20
20
  //#region src/SideBar/SideBar.tsx
21
- var SideBar = Object.assign(({ isExpanded, expandedWidth, showActiveIndicator = true, ...rest }) => {
21
+ var SideBar = Object.assign(({ isExpanded, expandedWidth, showActiveIndicator = true, overlay = false, ...rest }) => {
22
22
  const [transitionEnd, setTransitionEnd] = useState(true);
23
23
  const prefersReducedMotion = usePrefersReducedMotion();
24
24
  const sidebarId = useId();
25
25
  const handleTransitionChange = (end) => {
26
26
  setTransitionEnd(prefersReducedMotion ? true : end);
27
27
  };
28
+ const nav = /* @__PURE__ */ jsx(SideBarContainer, {
29
+ component: "nav",
30
+ direction: "column",
31
+ gap: "0",
32
+ id: sidebarId,
33
+ onTransitionEnd: () => handleTransitionChange(true),
34
+ "data-state": isExpanded ? "expanded" : "collapsed",
35
+ "data-transition": transitionEnd ? "inactive" : "active",
36
+ "data-role": "nav-bar",
37
+ $expandedWidth: expandedWidth,
38
+ $overlay: overlay,
39
+ ...rest
40
+ });
28
41
  return /* @__PURE__ */ jsx(SideBarContextProvider, {
29
42
  value: {
30
43
  transitionEnd,
@@ -33,17 +46,9 @@ var SideBar = Object.assign(({ isExpanded, expandedWidth, showActiveIndicator =
33
46
  showActiveIndicator,
34
47
  sidebarId
35
48
  },
36
- children: /* @__PURE__ */ jsx(Provider, { children: /* @__PURE__ */ jsx(SideBarContainer, {
37
- component: "nav",
38
- direction: "column",
39
- gap: "0",
40
- id: sidebarId,
41
- onTransitionEnd: () => handleTransitionChange(true),
42
- "data-state": isExpanded ? "expanded" : "collapsed",
43
- "data-transition": transitionEnd ? "inactive" : "active",
44
- "data-role": "nav-bar",
45
- $expandedWidth: expandedWidth,
46
- ...rest
49
+ children: /* @__PURE__ */ jsx(Provider, { children: /* @__PURE__ */ jsx(OverlaySlot, {
50
+ $overlay: overlay,
51
+ children: nav
47
52
  }) })
48
53
  });
49
54
  }, {
@@ -22,11 +22,40 @@ var useRootStateStyle = (getStyle) => {
22
22
  var SideBarContainer = (0, styled_components.default)(require_FlexGroup.FlexGroup).withConfig({
23
23
  displayName: "SideBarstyle__SideBarContainer",
24
24
  componentId: "RedisUI__sc-suwica-0"
25
- })(["position:relative;height:100%;transition:width 0.6s;@media (prefers-reduced-motion:reduce){transition:none;}", ""], ({ $expandedWidth }) => useRootStateStyle((theme, state) => styled_components.css`
25
+ })([
26
+ "position:relative;height:100%;transition:width 0.6s;@media (prefers-reduced-motion:reduce){transition:none;}",
27
+ " ",
28
+ ""
29
+ ], ({ $expandedWidth }) => useRootStateStyle((theme, state) => styled_components.css`
26
30
  box-shadow: ${require_SideBar_constants.SIDEBAR_CONSTANTS.shadow};
27
31
  background-color: ${theme.bgColor};
28
32
  width: ${(state === "expanded" ? $expandedWidth : void 0) ?? require_SideBar_constants.SIDEBAR_CONSTANTS.width[state]};
29
33
  border-right: ${theme.borderRight};
30
- `));
34
+ `), ({ $overlay }) => {
35
+ const { zIndex, shadow } = (0, _redislabsdev_redis_ui_styles.useTheme)().core;
36
+ return $overlay && styled_components.css`
37
+ position: absolute;
38
+ top: 0;
39
+ left: 0;
40
+ z-index: ${zIndex.zIndex5};
41
+
42
+ &[data-state='expanded'] {
43
+ box-shadow: ${shadow.shadow1};
44
+ }
45
+ `;
46
+ });
47
+ var OverlaySlot = styled_components.default.div.withConfig({
48
+ displayName: "SideBarstyle__OverlaySlot",
49
+ componentId: "RedisUI__sc-suwica-1"
50
+ })(["", ""], ({ $overlay }) => $overlay ? styled_components.css`
51
+ position: relative;
52
+ flex-shrink: 0;
53
+ width: ${require_SideBar_constants.SIDEBAR_CONSTANTS.width.collapsed};
54
+ /* A height would stop a flex parent from stretching the slot, which has no in-flow content */
55
+ min-height: 100%;
56
+ ` : styled_components.css`
57
+ display: contents;
58
+ `);
31
59
  //#endregion
60
+ exports.OverlaySlot = OverlaySlot;
32
61
  exports.SideBarContainer = SideBarContainer;
@@ -1,3 +1,7 @@
1
1
  export declare const SideBarContainer: import("styled-components").StyledComponent<({ gap, direction, align, justify, wrap, ...restProps }: import("..").FlexGroupProps) => import("react/jsx-runtime").JSX.Element, any, {
2
2
  $expandedWidth?: string;
3
+ $overlay?: boolean;
4
+ }, never>;
5
+ export declare const OverlaySlot: import("styled-components").StyledComponent<"div", any, {
6
+ $overlay: boolean;
3
7
  }, never>;
@@ -20,11 +20,39 @@ var useRootStateStyle = (getStyle) => {
20
20
  var SideBarContainer = _styled(FlexGroup).withConfig({
21
21
  displayName: "SideBarstyle__SideBarContainer",
22
22
  componentId: "RedisUI__sc-suwica-0"
23
- })(["position:relative;height:100%;transition:width 0.6s;@media (prefers-reduced-motion:reduce){transition:none;}", ""], ({ $expandedWidth }) => useRootStateStyle((theme, state) => css`
23
+ })([
24
+ "position:relative;height:100%;transition:width 0.6s;@media (prefers-reduced-motion:reduce){transition:none;}",
25
+ " ",
26
+ ""
27
+ ], ({ $expandedWidth }) => useRootStateStyle((theme, state) => css`
24
28
  box-shadow: ${SIDEBAR_CONSTANTS.shadow};
25
29
  background-color: ${theme.bgColor};
26
30
  width: ${(state === "expanded" ? $expandedWidth : void 0) ?? SIDEBAR_CONSTANTS.width[state]};
27
31
  border-right: ${theme.borderRight};
28
- `));
32
+ `), ({ $overlay }) => {
33
+ const { zIndex, shadow } = useTheme().core;
34
+ return $overlay && css`
35
+ position: absolute;
36
+ top: 0;
37
+ left: 0;
38
+ z-index: ${zIndex.zIndex5};
39
+
40
+ &[data-state='expanded'] {
41
+ box-shadow: ${shadow.shadow1};
42
+ }
43
+ `;
44
+ });
45
+ var OverlaySlot = _styled.div.withConfig({
46
+ displayName: "SideBarstyle__OverlaySlot",
47
+ componentId: "RedisUI__sc-suwica-1"
48
+ })(["", ""], ({ $overlay }) => $overlay ? css`
49
+ position: relative;
50
+ flex-shrink: 0;
51
+ width: ${SIDEBAR_CONSTANTS.width.collapsed};
52
+ /* A height would stop a flex parent from stretching the slot, which has no in-flow content */
53
+ min-height: 100%;
54
+ ` : css`
55
+ display: contents;
56
+ `);
29
57
  //#endregion
30
- export { SideBarContainer };
58
+ export { OverlaySlot, SideBarContainer };
@@ -5,6 +5,8 @@ export interface SideBarProps extends Omit<FlexGroupProps, 'direction'> {
5
5
  expandedWidth?: string;
6
6
  /** Shows the line next to the active item. The active item keeps its background either way. */
7
7
  showActiveIndicator?: boolean;
8
+ /** Expands over the content next to it, like a drawer, instead of pushing it. The sidebar keeps its collapsed width in the layout. */
9
+ overlay?: boolean;
8
10
  }
9
11
  export interface SideBarContextProps {
10
12
  isExpanded: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redis-ui/components",
3
3
  "license": "UNLICENSED",
4
- "version": "51.30.0",
4
+ "version": "51.31.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "repository": "git@github.com:redislabsdev/redis-ui.git",
@@ -15,6 +15,7 @@ import { SideBar } from '@redis-ui/components';
15
15
  | isExpanded | `boolean` | *required* | Controls whether the sidebar is expanded or collapsed |
16
16
  | expandedWidth | `string` | design-system default | Overrides the sidebar width when expanded |
17
17
  | showActiveIndicator | `boolean` | `true` | Shows the line next to the active item. The active item keeps its background either way |
18
+ | overlay | `boolean` | `false` | Expands over the content next to it, like a drawer, instead of pushing it. The sidebar keeps its collapsed width in the layout |
18
19
 
19
20
  The component also accepts all `FlexGroupProps` except `direction`, which is fixed to a vertical sidebar layout.
20
21
 
@@ -310,6 +311,38 @@ const [activeLink, setActiveLink] = useState(items.top[0].content);
310
311
  </SideBar>
311
312
  ```
312
313
 
314
+ ### Overlay
315
+
316
+ > With `overlay`, the expanded sidebar opens over the content next to it, like a drawer, instead of pushing it aside. The sidebar keeps its collapsed width in the layout and stretches to the height of the row. Use it on narrow screens.
317
+
318
+ ```tsx
319
+ import { SideBar, Typography } from '@redis-ui/components';
320
+ import { useState } from 'react';
321
+ import { RedisLogoDarkMinIcon } from '@redis-ui/icons/multicolor';
322
+ import { items } from './SideBar.data';
323
+
324
+ const [expanded, setExpanded] = useState(true);
325
+
326
+ <div style={{ display: 'flex' }}>
327
+ <SideBar isExpanded={expanded} overlay>
328
+ <SideBar.Header onToggle={() => setExpanded(!expanded)}>
329
+ <SideBar.SideBarLogo logoIcon={RedisLogoDarkMinIcon} />
330
+ </SideBar.Header>
331
+ <SideBar.ItemsContainer>
332
+ {items.top.map((item) => (
333
+ <SideBar.Item key={item.content} tooltipProps={{ text: item.content, placement: 'right' }}>
334
+ <SideBar.Item.Icon icon={item.icon} />
335
+ <SideBar.Item.Text>{item.content}</SideBar.Item.Text>
336
+ </SideBar.Item>
337
+ ))}
338
+ </SideBar.ItemsContainer>
339
+ </SideBar>
340
+ <div style={{ flex: 1, minHeight: '40rem', padding: '2rem', background: '#8881' }}>
341
+ <Typography.Body>The page content stays in place while the sidebar is open.</Typography.Body>
342
+ </div>
343
+ </div>
344
+ ```
345
+
313
346
  ### Groups
314
347
 
315
348
  > Sidebar items can be split into groups, each with an optional title label. Items inside a group may also render an optional `SideBar.Item.Badge` (e.g. `NEW`, `BETA`) to the right of the text.
@@ -780,6 +813,7 @@ const [activeLink, setActiveLink] = useState('Agent Memory');
780
813
 
781
814
  - `SideBar` is a collapsible navigation shell with a fixed header/footer layout and grouped content in the middle.
782
815
  - Hosts can override the expanded width by passing the `expandedWidth` prop.
816
+ - `overlay` makes the expanded sidebar float over the content next to it, like a drawer, with a shadow, instead of pushing the content aside. It keeps its collapsed width in the layout and fills the height of its parent, whether that comes from a set height or, in a flex row, from the content next to it. Hosts usually turn it on for narrow screens.
783
817
  - `SideBar.Header` needs an `onToggle` handler and should usually render `SideBar.SideBarLogo` inside it.
784
818
  - `SideBar.Footer` is typically used with `Footer.MetaData`; that metadata area is hidden when the sidebar is collapsed.
785
819
  - `SideBar.ScrollContainer` is intended for the middle content when vertical space is constrained, and the docs recommend using only one per sidebar.
@@ -795,4 +829,4 @@ const [activeLink, setActiveLink] = useState('Agent Memory');
795
829
  - `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.
796
830
  - **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.
797
831
  - **Optional sizing theme keys**: a theme can set `button.height`, `item.fontSize`, `item.gap`, `item.iconSize`, `item.height`, `item.margin`, `groupTitle.fontSize` and `groupTitle.letterSpacing` 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`), `groupTitle.fontSize` replaces the `S` group title size, and `groupTitle.letterSpacing` sets the group title letter spacing. `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.
798
- - **Optional label color**: a theme can set `labelColor` on `item.states.normal`, `item.states.hover` and `item.states.active` to color `Item.Text` apart from the row. The row color (`textColor`) still applies to `Item.Icon`, the `ExpandableItem` chevron and anything else in the item, and `labelColor` only applies to an `Item.Text` without a `color` prop. Themes that leave it unset keep the text on the row color; the Next themes set it so the text matches the breadcrumbs while the icons keep the row color.
832
+ - **Optional label color**: a theme can set `labelColor` on `item.states.normal`, `item.states.hover` and `item.states.active` to color `Item.Text` apart from the row. The row color (`textColor`) still applies to `Item.Icon`, the `ExpandableItem` chevron and anything else in the item, and `labelColor` only applies to an `Item.Text` without a `color` prop. Themes that leave it unset keep the text on the row color; the Next themes set it so the text matches the breadcrumbs while the icons keep the row color. On hover, the Next themes turn both the text and the icon to the brand red.