@sproutsocial/seeds-react-menu 1.3.1 → 1.4.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/index.d.mts CHANGED
@@ -293,7 +293,9 @@ interface TypeMenuHeaderProps extends Omit<React$1.ComponentPropsWithoutRef<"div
293
293
  */
294
294
  declare const MenuHeader: ({ children, title, leftAction, rightAction, ...rest }: TypeMenuHeaderProps) => react_jsx_runtime.JSX.Element;
295
295
 
296
- type TypeMenuContentProps<I extends TypeMenuItemProps = TypeMenuItemProps> = Omit<React.ComponentPropsWithoutRef<"ul">, "children"> & {
296
+ interface TypeMenuContentContainerProps extends Omit<React.ComponentPropsWithoutRef<"ul">, "children" | "color">, TypeStyledComponentsCommonProps, TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypeSpaceSystemProps, TypePositionSystemProps {
297
+ }
298
+ type TypeMenuContentProps<I extends TypeMenuItemProps = TypeMenuItemProps> = TypeMenuContentContainerProps & {
297
299
  innerRef?: React.Ref<HTMLUListElement>;
298
300
  emptyStateElement?: React.ReactNode;
299
301
  } & TypeChildrenOrItems<I>;
@@ -544,7 +546,7 @@ interface TypeNestedMenuProps<I extends TypeMenuItemProps = TypeNestedMenuItemPr
544
546
  };
545
547
  }
546
548
 
547
- declare const NestedMenu: <I extends TypeMenuItemProps = TypeNestedMenuItemProps>({ initialMenuId, menus, onBackButtonClick, backArrowLabel, menuToggleElement, popoutProps, width, stateReducer: rootExternalStateReducer, id: externalNestedMenuId, ...useSelectProps }: TypeNestedMenuProps<I>) => react_jsx_runtime.JSX.Element;
549
+ declare const NestedMenu: <I extends TypeMenuItemProps = TypeNestedMenuItemProps>({ initialMenuId, menus, onBackButtonClick, backArrowLabel, menuToggleElement, popoutProps: { scheduleUpdateRef: externalPopoutUpdateRef, ...restPopoutProps }, width, stateReducer: rootExternalStateReducer, id: externalNestedMenuId, ...useSelectProps }: TypeNestedMenuProps<I>) => react_jsx_runtime.JSX.Element;
548
550
 
549
551
  declare const NestedMenuItem: {
550
552
  ({ children, childMenuId, onClick: onClickProp, ...rest }: TypeNestedMenuItemProps): react_jsx_runtime.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -293,7 +293,9 @@ interface TypeMenuHeaderProps extends Omit<React$1.ComponentPropsWithoutRef<"div
293
293
  */
294
294
  declare const MenuHeader: ({ children, title, leftAction, rightAction, ...rest }: TypeMenuHeaderProps) => react_jsx_runtime.JSX.Element;
295
295
 
296
- type TypeMenuContentProps<I extends TypeMenuItemProps = TypeMenuItemProps> = Omit<React.ComponentPropsWithoutRef<"ul">, "children"> & {
296
+ interface TypeMenuContentContainerProps extends Omit<React.ComponentPropsWithoutRef<"ul">, "children" | "color">, TypeStyledComponentsCommonProps, TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypeSpaceSystemProps, TypePositionSystemProps {
297
+ }
298
+ type TypeMenuContentProps<I extends TypeMenuItemProps = TypeMenuItemProps> = TypeMenuContentContainerProps & {
297
299
  innerRef?: React.Ref<HTMLUListElement>;
298
300
  emptyStateElement?: React.ReactNode;
299
301
  } & TypeChildrenOrItems<I>;
@@ -544,7 +546,7 @@ interface TypeNestedMenuProps<I extends TypeMenuItemProps = TypeNestedMenuItemPr
544
546
  };
545
547
  }
546
548
 
547
- declare const NestedMenu: <I extends TypeMenuItemProps = TypeNestedMenuItemProps>({ initialMenuId, menus, onBackButtonClick, backArrowLabel, menuToggleElement, popoutProps, width, stateReducer: rootExternalStateReducer, id: externalNestedMenuId, ...useSelectProps }: TypeNestedMenuProps<I>) => react_jsx_runtime.JSX.Element;
549
+ declare const NestedMenu: <I extends TypeMenuItemProps = TypeNestedMenuItemProps>({ initialMenuId, menus, onBackButtonClick, backArrowLabel, menuToggleElement, popoutProps: { scheduleUpdateRef: externalPopoutUpdateRef, ...restPopoutProps }, width, stateReducer: rootExternalStateReducer, id: externalNestedMenuId, ...useSelectProps }: TypeNestedMenuProps<I>) => react_jsx_runtime.JSX.Element;
548
550
 
549
551
  declare const NestedMenuItem: {
550
552
  ({ children, childMenuId, onClick: onClickProp, ...rest }: TypeNestedMenuItemProps): react_jsx_runtime.JSX.Element;
package/dist/index.js CHANGED
@@ -307,58 +307,46 @@ var import_styled_components2 = __toESM(require("styled-components"));
307
307
 
308
308
  // ../../node_modules/@babel/runtime/helpers/esm/extends.js
309
309
  function _extends() {
310
- _extends = Object.assign ? Object.assign.bind() : function(target) {
311
- for (var i = 1; i < arguments.length; i++) {
312
- var source = arguments[i];
313
- for (var key in source) {
314
- if (Object.prototype.hasOwnProperty.call(source, key)) {
315
- target[key] = source[key];
316
- }
317
- }
310
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
311
+ for (var e = 1; e < arguments.length; e++) {
312
+ var t = arguments[e];
313
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
318
314
  }
319
- return target;
320
- };
321
- return _extends.apply(this, arguments);
315
+ return n;
316
+ }, _extends.apply(null, arguments);
322
317
  }
323
318
 
324
319
  // ../../node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
325
- function _assertThisInitialized(self) {
326
- if (self === void 0) {
327
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
328
- }
329
- return self;
320
+ function _assertThisInitialized(e) {
321
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
322
+ return e;
330
323
  }
331
324
 
332
325
  // ../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
333
- function _setPrototypeOf(o, p) {
334
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p2) {
335
- o2.__proto__ = p2;
336
- return o2;
337
- };
338
- return _setPrototypeOf(o, p);
326
+ function _setPrototypeOf(t, e) {
327
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t2, e2) {
328
+ return t2.__proto__ = e2, t2;
329
+ }, _setPrototypeOf(t, e);
339
330
  }
340
331
 
341
332
  // ../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js
342
- function _inheritsLoose(subClass, superClass) {
343
- subClass.prototype = Object.create(superClass.prototype);
344
- subClass.prototype.constructor = subClass;
345
- _setPrototypeOf(subClass, superClass);
333
+ function _inheritsLoose(t, o) {
334
+ t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
346
335
  }
347
336
 
348
337
  // ../../node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
349
- function _getPrototypeOf(o) {
350
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
351
- return o2.__proto__ || Object.getPrototypeOf(o2);
352
- };
353
- return _getPrototypeOf(o);
338
+ function _getPrototypeOf(t) {
339
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t2) {
340
+ return t2.__proto__ || Object.getPrototypeOf(t2);
341
+ }, _getPrototypeOf(t);
354
342
  }
355
343
 
356
344
  // ../../node_modules/@babel/runtime/helpers/esm/isNativeFunction.js
357
- function _isNativeFunction(fn) {
345
+ function _isNativeFunction(t) {
358
346
  try {
359
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
360
- } catch (e) {
361
- return typeof fn === "function";
347
+ return -1 !== Function.toString.call(t).indexOf("[native code]");
348
+ } catch (n) {
349
+ return "function" == typeof t;
362
350
  }
363
351
  }
364
352
 
@@ -384,31 +372,27 @@ function _construct(t, e, r) {
384
372
  }
385
373
 
386
374
  // ../../node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js
387
- function _wrapNativeSuper(Class) {
388
- var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
389
- _wrapNativeSuper = function _wrapNativeSuper2(Class2) {
390
- if (Class2 === null || !_isNativeFunction(Class2)) return Class2;
391
- if (typeof Class2 !== "function") {
392
- throw new TypeError("Super expression must either be null or a function");
393
- }
394
- if (typeof _cache !== "undefined") {
395
- if (_cache.has(Class2)) return _cache.get(Class2);
396
- _cache.set(Class2, Wrapper);
375
+ function _wrapNativeSuper(t) {
376
+ var r = "function" == typeof Map ? /* @__PURE__ */ new Map() : void 0;
377
+ return _wrapNativeSuper = function _wrapNativeSuper2(t2) {
378
+ if (null === t2 || !_isNativeFunction(t2)) return t2;
379
+ if ("function" != typeof t2) throw new TypeError("Super expression must either be null or a function");
380
+ if (void 0 !== r) {
381
+ if (r.has(t2)) return r.get(t2);
382
+ r.set(t2, Wrapper);
397
383
  }
398
384
  function Wrapper() {
399
- return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
385
+ return _construct(t2, arguments, _getPrototypeOf(this).constructor);
400
386
  }
401
- Wrapper.prototype = Object.create(Class2.prototype, {
387
+ return Wrapper.prototype = Object.create(t2.prototype, {
402
388
  constructor: {
403
389
  value: Wrapper,
404
390
  enumerable: false,
405
391
  writable: true,
406
392
  configurable: true
407
393
  }
408
- });
409
- return _setPrototypeOf(Wrapper, Class2);
410
- };
411
- return _wrapNativeSuper(Class);
394
+ }), _setPrototypeOf(Wrapper, t2);
395
+ }, _wrapNativeSuper(t);
412
396
  }
413
397
 
414
398
  // ../../node_modules/polished/dist/polished.esm.js
@@ -2192,11 +2176,20 @@ var import_styled_components5 = __toESM(require("styled-components"));
2192
2176
  var StyledMenuContent = import_styled_components5.default.ul`
2193
2177
  margin: 0;
2194
2178
  padding: 0;
2179
+ overflow: auto;
2195
2180
 
2196
2181
  &:focus {
2197
2182
  outline: none;
2198
2183
  box-shadow: none;
2199
2184
  }
2185
+
2186
+ ${border}
2187
+ ${color}
2188
+ ${flexbox}
2189
+ ${grid}
2190
+ ${layout}
2191
+ ${space}
2192
+ ${position}
2200
2193
  `;
2201
2194
 
2202
2195
  // src/hooks/useMenuChildren.tsx
@@ -2653,8 +2646,10 @@ var CustomPopoutContent = (0, import_styled_components11.default)(import_seeds_r
2653
2646
  padding: 0;
2654
2647
  margin-left: 0;
2655
2648
  margin-right: 0;
2649
+ overflow: hidden;
2656
2650
  `;
2657
2651
  var menuAnimationConfig = {
2652
+ layout: true,
2658
2653
  initial: {
2659
2654
  scale: 0,
2660
2655
  opacity: 0,
@@ -2809,20 +2804,29 @@ var import_seeds_react_button = require("@sproutsocial/seeds-react-button");
2809
2804
  var import_jsx_runtime13 = require("react/jsx-runtime");
2810
2805
  var MenuToggleButton = (props) => {
2811
2806
  const { getToggleButtonProps, isListbox, getDropdownProps, ref, ariaProps } = useMenuToggleContext();
2812
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2813
- import_seeds_react_button.Button,
2814
- {
2815
- appearance: "secondary",
2816
- ...getToggleButtonProps?.({
2817
- // Decide if we want the preventKeyAction stuff. Maybe create a prop to allow for this to be overriden.
2818
- ...getDropdownProps?.({ ref, preventKeyAction: true }) || { ref },
2819
- refKey: "innerRef",
2820
- ...ariaProps,
2821
- ...isListbox ? {} : { role: "button", "aria-haspopup": "menu" }
2822
- }),
2823
- ...props
2824
- }
2825
- );
2807
+ const {
2808
+ onClick: userOnClick,
2809
+ onKeyDown: userOnKeyDown,
2810
+ onBlur: userOnBlur,
2811
+ ...restProps
2812
+ } = props;
2813
+ const defaultDropdownProps = {
2814
+ ref,
2815
+ onClick: userOnClick,
2816
+ onKeyDown: userOnKeyDown,
2817
+ onBlur: userOnBlur
2818
+ };
2819
+ const dropdownProps = getDropdownProps?.({
2820
+ ...defaultDropdownProps,
2821
+ preventKeyAction: true
2822
+ }) ?? defaultDropdownProps;
2823
+ const toggleButtonProps = getToggleButtonProps?.({
2824
+ ...dropdownProps,
2825
+ refKey: "innerRef",
2826
+ ...ariaProps,
2827
+ ...isListbox ? {} : { role: "button", "aria-haspopup": "menu" }
2828
+ });
2829
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_seeds_react_button.Button, { appearance: "secondary", ...toggleButtonProps, ...restProps });
2826
2830
  };
2827
2831
 
2828
2832
  // src/MenuSearchInput/MenuSearchInput.tsx
@@ -4233,19 +4237,23 @@ var NestedMenuPopout = ({
4233
4237
  content,
4234
4238
  menuToggleElement,
4235
4239
  width: width2,
4240
+ onClose,
4236
4241
  ...popoutProps
4237
4242
  }) => {
4238
4243
  const { activeMenuContext, rootMenuContextProps, resetSelectedMenuPath } = useNestedMenuContext();
4239
4244
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4240
4245
  MenuPopout,
4241
4246
  {
4242
- ...popoutProps,
4243
- onClose: () => setTimeout(() => resetSelectedMenuPath?.(), 100),
4247
+ onClose: () => {
4248
+ onClose?.();
4249
+ setTimeout(() => resetSelectedMenuPath?.(), 100);
4250
+ },
4244
4251
  isOpen: !!rootMenuContextProps.isOpen,
4245
4252
  openMenu: rootMenuContextProps.openMenu,
4246
4253
  closeMenu: rootMenuContextProps.closeMenu,
4247
4254
  width: width2,
4248
4255
  content: (props) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(StyledDiv, { layout: "position", children: typeof content === "function" ? content(props) : content }),
4256
+ ...popoutProps,
4249
4257
  children: (toggleProps) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4250
4258
  MenuToggleProvider,
4251
4259
  {
@@ -4269,7 +4277,10 @@ var NestedMenu = ({
4269
4277
  onBackButtonClick,
4270
4278
  backArrowLabel,
4271
4279
  menuToggleElement,
4272
- popoutProps = {},
4280
+ popoutProps: {
4281
+ scheduleUpdateRef: externalPopoutUpdateRef,
4282
+ ...restPopoutProps
4283
+ } = {},
4273
4284
  width: width2 = "300px",
4274
4285
  stateReducer: rootExternalStateReducer,
4275
4286
  id: externalNestedMenuId,
@@ -4318,6 +4329,7 @@ var NestedMenu = ({
4318
4329
  const [activeMenuContext, setActiveMenuContext] = (0, import_react32.useState)(defaultMenuContext);
4319
4330
  const [currentMenuId, setCurrentMenuId] = (0, import_react32.useState)(initialMenuId);
4320
4331
  const [isAdding, setIsAdding] = (0, import_react32.useState)(false);
4332
+ const [popoutUpdateRef, setPopoutUpdateRef] = (0, import_react32.useState)();
4321
4333
  const setSelectedMenuId = (id) => {
4322
4334
  setIsAdding(true);
4323
4335
  setSelectedMenuPath((currentPath) => [...currentPath, id]);
@@ -4326,6 +4338,7 @@ var NestedMenu = ({
4326
4338
  if (selectedMenuPath.length > 0) {
4327
4339
  const newMenuId = selectedMenuPath[selectedMenuPath.length - 1];
4328
4340
  setCurrentMenuId(newMenuId);
4341
+ popoutUpdateRef?.();
4329
4342
  }
4330
4343
  }, [selectedMenuPath.join("-")]);
4331
4344
  const resetSelectedMenuPath = () => {
@@ -4479,7 +4492,11 @@ var NestedMenu = ({
4479
4492
  ) }),
4480
4493
  menuToggleElement,
4481
4494
  width: width2,
4482
- ...popoutProps
4495
+ scheduleUpdateRef: (callback) => {
4496
+ setPopoutUpdateRef(callback);
4497
+ externalPopoutUpdateRef?.(callback);
4498
+ },
4499
+ ...restPopoutProps
4483
4500
  }
4484
4501
  )
4485
4502
  }