@mezzanine-ui/react 1.0.0-beta.0 → 1.0.0-beta.1

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.
Files changed (45) hide show
  1. package/Dropdown/Dropdown.d.ts +116 -15
  2. package/Dropdown/Dropdown.js +235 -32
  3. package/Dropdown/DropdownAction.d.ts +50 -0
  4. package/Dropdown/DropdownAction.js +26 -0
  5. package/Dropdown/DropdownItem.d.ts +60 -0
  6. package/Dropdown/DropdownItem.js +318 -0
  7. package/Dropdown/DropdownItemCard.d.ts +96 -0
  8. package/Dropdown/DropdownItemCard.js +115 -0
  9. package/Dropdown/DropdownStatus.d.ts +22 -0
  10. package/Dropdown/dropdownKeydownHandler.d.ts +15 -0
  11. package/Dropdown/highlightText.d.ts +9 -0
  12. package/Dropdown/highlightText.js +32 -0
  13. package/Dropdown/index.d.ts +1 -1
  14. package/Navigation/Navigation.d.ts +11 -17
  15. package/Navigation/Navigation.js +58 -41
  16. package/Navigation/NavigationFooter.d.ts +10 -0
  17. package/Navigation/NavigationFooter.js +26 -0
  18. package/Navigation/NavigationHeader.d.ts +8 -0
  19. package/Navigation/NavigationHeader.js +13 -0
  20. package/Navigation/NavigationIconButton.d.ts +15 -0
  21. package/Navigation/NavigationIconButton.js +12 -0
  22. package/Navigation/NavigationOption.d.ts +35 -0
  23. package/Navigation/NavigationOption.js +60 -0
  24. package/Navigation/NavigationOptionCategory.d.ts +6 -0
  25. package/Navigation/NavigationOptionCategory.js +12 -0
  26. package/Navigation/NavigationUserMenu.d.ts +8 -0
  27. package/Navigation/NavigationUserMenu.js +18 -0
  28. package/Navigation/context.d.ts +13 -0
  29. package/Navigation/context.js +7 -0
  30. package/Navigation/index.d.ts +12 -6
  31. package/Navigation/index.js +6 -3
  32. package/Navigation/useCurrentPathname.d.ts +1 -0
  33. package/Navigation/useCurrentPathname.js +14 -0
  34. package/Slider/useSlider.js +1 -1
  35. package/hooks/useElementHeight.d.ts +8 -0
  36. package/hooks/useElementHeight.js +41 -0
  37. package/index.d.ts +2 -2
  38. package/index.js +0 -2
  39. package/package.json +5 -4
  40. package/Navigation/NavigationContext.d.ts +0 -5
  41. package/Navigation/NavigationContext.js +0 -8
  42. package/Navigation/NavigationItem.d.ts +0 -31
  43. package/Navigation/NavigationItem.js +0 -23
  44. package/Navigation/NavigationSubMenu.d.ts +0 -22
  45. package/Navigation/NavigationSubMenu.js +0 -50
@@ -1,22 +0,0 @@
1
- import { ReactElement } from 'react';
2
- import { NavigationItemProps } from './NavigationItem';
3
- export type NavigationSubMenuChild = ReactElement<NavigationItemProps>;
4
- export type NavigationSubMenuChildren = NavigationSubMenuChild | NavigationSubMenuChild[];
5
- export interface NavigationSubMenuProps extends Omit<NavigationItemProps, 'onClick' | 'eventKey' | 'key'> {
6
- /**
7
- * Strict children with `NavigationItem`.
8
- * @default []
9
- */
10
- children?: NavigationSubMenuChildren;
11
- /**
12
- * Set display title for sub-menu item.
13
- */
14
- title?: string;
15
- /**
16
- * Open menu as default
17
- * @default false
18
- */
19
- defaultOpen?: boolean;
20
- }
21
- declare const NavigationSubMenu: import("react").ForwardRefExoticComponent<NavigationSubMenuProps & import("react").RefAttributes<HTMLLIElement>>;
22
- export default NavigationSubMenu;
@@ -1,50 +0,0 @@
1
- 'use client';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { forwardRef, useState, useRef, useContext } from 'react';
4
- import { navigationSubMenuClasses } from '@mezzanine-ui/core/navigation';
5
- import { ChevronUpIcon, ChevronDownIcon } from '@mezzanine-ui/icons';
6
- import { offset, size } from '@floating-ui/react-dom';
7
- import { useClickAway } from '../hooks/useClickAway.js';
8
- import { useComposeRefs } from '../hooks/useComposeRefs.js';
9
- import NavigationItem from './NavigationItem.js';
10
- import { NavigationContext } from './NavigationContext.js';
11
- import Icon from '../Icon/Icon.js';
12
- import Popper from '../Popper/Popper.js';
13
- import Collapse from '../Transition/Collapse.js';
14
- import cx from 'clsx';
15
-
16
- // Middleware to make the submenu have the same width as the reference element
17
- const sameWidthMiddleware = size({
18
- apply({ rects, elements }) {
19
- Object.assign(elements.floating.style, {
20
- width: `${rects.reference.width}px`,
21
- });
22
- },
23
- });
24
- const NavigationSubMenu = forwardRef((props, ref) => {
25
- const { active, className, children = [], defaultOpen = false, icon, title, ...rest } = props;
26
- const [open, setOpen] = useState(defaultOpen);
27
- const nodeRef = useRef(null);
28
- const composedNodeRef = useComposeRefs([ref, nodeRef]);
29
- const { orientation } = useContext(NavigationContext);
30
- const GroupToggleIcon = open ? ChevronUpIcon : ChevronDownIcon;
31
- useClickAway(() => {
32
- if (!open || orientation === 'vertical') {
33
- return;
34
- }
35
- return () => {
36
- setOpen(!open);
37
- };
38
- }, nodeRef, [open, orientation]);
39
- const WrapChildren = jsx("ul", { className: navigationSubMenuClasses.group, children: children });
40
- return (jsxs(NavigationItem, { ...rest, ref: composedNodeRef, className: cx(navigationSubMenuClasses.host, active && navigationSubMenuClasses.active, open && navigationSubMenuClasses.open, icon && orientation === 'vertical' && navigationSubMenuClasses.indent, className), onClick: () => setOpen(!open), children: [jsxs("div", { className: navigationSubMenuClasses.title, children: [icon && jsx(Icon, { className: navigationSubMenuClasses.icon, icon: icon }), title, jsx(Icon, { className: navigationSubMenuClasses.toggleIcon, icon: GroupToggleIcon })] }), orientation === 'horizontal' && (jsx(Popper, { anchor: nodeRef, disablePortal: true, open: !!open, options: {
41
- middleware: [
42
- offset({ mainAxis: 0, crossAxis: 0 }),
43
- sameWidthMiddleware,
44
- ],
45
- }, children: WrapChildren })), orientation === 'vertical' && (jsx(Collapse, { style: {
46
- width: '100%',
47
- }, in: !!open, children: WrapChildren }))] }));
48
- });
49
-
50
- export { NavigationSubMenu as default };