@sproutsocial/seeds-react-menu 1.3.0 → 1.3.2

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/index.d.mts CHANGED
@@ -122,6 +122,7 @@ interface TypeMenuContext extends TypeMenuContextProps {
122
122
  };
123
123
  isItemSelected: (id: string) => boolean;
124
124
  getInputComponentProps: (props: Pick<TypeTokenInputProps, "inputProps"> & Parameters<Required<TypeMenuContextProps>["getInputProps"]>[0]) => Omit<TypeDownshiftMergedInputProps<TypeTokenInputProps>, "onClick">;
125
+ isInitialized?: boolean;
125
126
  }
126
127
  interface TypeMenuProviderProps {
127
128
  children: TypeNotEmptyChildren;
package/dist/index.d.ts CHANGED
@@ -122,6 +122,7 @@ interface TypeMenuContext extends TypeMenuContextProps {
122
122
  };
123
123
  isItemSelected: (id: string) => boolean;
124
124
  getInputComponentProps: (props: Pick<TypeTokenInputProps, "inputProps"> & Parameters<Required<TypeMenuContextProps>["getInputProps"]>[0]) => Omit<TypeDownshiftMergedInputProps<TypeTokenInputProps>, "onClick">;
125
+ isInitialized?: boolean;
125
126
  }
126
127
  interface TypeMenuProviderProps {
127
128
  children: TypeNotEmptyChildren;
package/dist/index.js CHANGED
@@ -170,7 +170,8 @@ var defaultMenuContext = {
170
170
  itemsMap: {},
171
171
  isItemSelected: () => false,
172
172
  getInputComponentProps: () => ({}),
173
- hasVisibleItems: false
173
+ hasVisibleItems: false,
174
+ isInitialized: false
174
175
  };
175
176
  var getSelectedItemIds = (selectedItems) => selectedItems?.reduce(
176
177
  (selected, item) => ({ ...selected, [item.id]: true }),
@@ -264,6 +265,7 @@ var useMenu = ({
264
265
  contentRef,
265
266
  hasVisibleItems,
266
267
  autoCloseOnEmpty,
268
+ isInitialized: true,
267
269
  ...menuProps
268
270
  };
269
271
  };
@@ -2402,11 +2404,12 @@ var MenuContent = ({
2402
2404
  getMenuProps,
2403
2405
  isListbox,
2404
2406
  hasVisibleItems,
2405
- autoCloseOnEmpty
2407
+ autoCloseOnEmpty,
2408
+ isInitialized
2406
2409
  } = useMenuContentContext();
2407
2410
  const toggleButtonProps = getToggleButtonProps?.();
2408
2411
  const children = childrenProp || !menuItems || !menuItems.length ? childrenProp : mapMenuItems({ menuItems, MenuItemComponent });
2409
- if (!hasVisibleItems && !autoCloseOnEmpty) {
2412
+ if (isInitialized && !hasVisibleItems && !autoCloseOnEmpty) {
2410
2413
  return emptyStateElement ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DefaultMenuEmptyState, {});
2411
2414
  }
2412
2415
  if (!children) {
@@ -2806,20 +2809,29 @@ var import_seeds_react_button = require("@sproutsocial/seeds-react-button");
2806
2809
  var import_jsx_runtime13 = require("react/jsx-runtime");
2807
2810
  var MenuToggleButton = (props) => {
2808
2811
  const { getToggleButtonProps, isListbox, getDropdownProps, ref, ariaProps } = useMenuToggleContext();
2809
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2810
- import_seeds_react_button.Button,
2811
- {
2812
- appearance: "secondary",
2813
- ...getToggleButtonProps?.({
2814
- // Decide if we want the preventKeyAction stuff. Maybe create a prop to allow for this to be overriden.
2815
- ...getDropdownProps?.({ ref, preventKeyAction: true }) || { ref },
2816
- refKey: "innerRef",
2817
- ...ariaProps,
2818
- ...isListbox ? {} : { role: "button", "aria-haspopup": "menu" }
2819
- }),
2820
- ...props
2821
- }
2822
- );
2812
+ const {
2813
+ onClick: userOnClick,
2814
+ onKeyDown: userOnKeyDown,
2815
+ onBlur: userOnBlur,
2816
+ ...restProps
2817
+ } = props;
2818
+ const defaultDropdownProps = {
2819
+ ref,
2820
+ onClick: userOnClick,
2821
+ onKeyDown: userOnKeyDown,
2822
+ onBlur: userOnBlur
2823
+ };
2824
+ const dropdownProps = getDropdownProps?.({
2825
+ ...defaultDropdownProps,
2826
+ preventKeyAction: true
2827
+ }) ?? defaultDropdownProps;
2828
+ const toggleButtonProps = getToggleButtonProps?.({
2829
+ ...dropdownProps,
2830
+ refKey: "innerRef",
2831
+ ...ariaProps,
2832
+ ...isListbox ? {} : { role: "button", "aria-haspopup": "menu" }
2833
+ });
2834
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_seeds_react_button.Button, { appearance: "secondary", ...toggleButtonProps, ...restProps });
2823
2835
  };
2824
2836
 
2825
2837
  // src/MenuSearchInput/MenuSearchInput.tsx