@sproutsocial/seeds-react-menu 1.5.1 → 1.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/seeds-react-menu",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "Seeds React Menu",
5
5
  "author": "Sprout Social, Inc.",
6
6
  "license": "MIT",
@@ -1,17 +1,21 @@
1
1
  import styled from "styled-components";
2
+ import { Box, type TypeBoxProps } from "@sproutsocial/seeds-react-box";
2
3
 
3
- const StyledEmptyState = styled.div`
4
+ export interface TypeDefaultMenuEmptyStateProps extends TypeBoxProps {
5
+ children?: React.ReactNode;
6
+ }
7
+
8
+ const StyledEmptyState = styled(Box)`
4
9
  padding: ${({ theme }) => theme.space[350]};
5
10
  text-align: center;
6
11
  font-size: ${({ theme }) => theme.typography[200].fontSize};
7
12
  `;
8
13
 
9
14
  const DefaultMenuEmptyState = ({
10
- children,
11
- }: {
12
- children?: React.ReactNode;
13
- }) => {
14
- return <StyledEmptyState>{children || "No results found."}</StyledEmptyState>;
15
+ children = "No items found",
16
+ ...props
17
+ }: TypeDefaultMenuEmptyStateProps) => {
18
+ return <StyledEmptyState {...props}>{children}</StyledEmptyState>;
15
19
  };
16
20
 
17
21
  export { DefaultMenuEmptyState };
@@ -1,2 +1,3 @@
1
- export { MenuContent } from "./MenuContent";
2
- export type { TypeMenuContentProps } from "./MenuContentTypes";
1
+ export * from "./MenuContent";
2
+ export * from "./DefaultMenuEmptyState";
3
+ export * from "./MenuContentTypes";
@@ -1,4 +1,4 @@
1
- import { useId, useEffect, useState } from "react";
1
+ import { useId, useEffect, useState, useRef } from "react";
2
2
  import { AnimatePresence, motion } from "motion/react";
3
3
  import { useSelect } from "downshift";
4
4
 
@@ -99,8 +99,7 @@ export const NestedMenu = <
99
99
  useState<TypeMenuContext>(defaultMenuContext);
100
100
  const [currentMenuId, setCurrentMenuId] = useState(initialMenuId);
101
101
  const [isAdding, setIsAdding] = useState(false);
102
- const [popoutUpdateRef, setPopoutUpdateRef] =
103
- useState<() => void | undefined>();
102
+ const popoutUpdateRef = useRef<() => void | undefined>();
104
103
 
105
104
  const setSelectedMenuId = (id: string) => {
106
105
  setIsAdding(true);
@@ -113,7 +112,6 @@ export const NestedMenu = <
113
112
  if (selectedMenuPath.length > 0) {
114
113
  const newMenuId = selectedMenuPath[selectedMenuPath.length - 1];
115
114
  setCurrentMenuId(newMenuId);
116
- popoutUpdateRef?.();
117
115
  }
118
116
  }, [selectedMenuPath.join("-")]);
119
117
 
@@ -244,6 +242,11 @@ export const NestedMenu = <
244
242
  ...restMenuProps,
245
243
  };
246
244
 
245
+ // Update the popout position when the nestedMenuProps.children change.
246
+ useEffect(() => {
247
+ popoutUpdateRef.current?.();
248
+ }, [nestedMenuProps.children]);
249
+
247
250
  return (
248
251
  <NestedMenuProvider
249
252
  {...{
@@ -279,7 +282,7 @@ export const NestedMenu = <
279
282
  menuToggleElement={menuToggleElement}
280
283
  width={width}
281
284
  scheduleUpdateRef={(callback) => {
282
- setPopoutUpdateRef(callback);
285
+ popoutUpdateRef.current = callback;
283
286
  externalPopoutUpdateRef?.(callback);
284
287
  }}
285
288
  {...restPopoutProps}