@wonderflow/react-components 3.0.0-beta.19 → 3.0.0-beta.22

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.
@@ -41,6 +41,19 @@ export declare type MenuItemProps = {
41
41
  * Read more: https://design.wonderflow.ai/design/recipes/menu/#items-with-icons
42
42
  */
43
43
  padding?: boolean;
44
+ /**
45
+ * Set item to gain focus automatically when the menu is opened.
46
+ * This property is commonly used on the first item in the menu.
47
+ */
48
+ autoFocus?: boolean;
49
+ /**
50
+ * Add an element to decorate the menu item. This is useful for adding extra elements
51
+ * and informations to the menu item.
52
+ *
53
+ * @note Don't use interactive elements (link, buttons, etc..) as decoration
54
+ * if `Menu.Item` is rendered as ´<button>´ (default).
55
+ */
56
+ decoration?: ReactNode;
44
57
  };
45
58
  declare type PolymorphicMenuItem = Polymorphic.ForwardRefComponent<'button', MenuItemProps>;
46
59
  export declare const MenuItem: PolymorphicMenuItem;
@@ -4,7 +4,7 @@ import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
4
4
  import { MenuItem as MenuItemClass, Icon as IconClass, ItemContent } from './menu-item.module.css';
5
5
  import { Tooltip, Stack, Icon } from '../..';
6
6
  import clsx from 'clsx';
7
- export const MenuItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, padding = true, disabled = false, ...otherProps }, forwardedRef) => {
7
+ export const MenuItem = forwardRef(({ className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description, padding = true, disabled = false, autoFocus, decoration, ...otherProps }, forwardedRef) => {
8
8
  const itemRef = useRef(forwardedRef);
9
9
  const [tabIndex, focused, handleKeyDown, handleClick] = useRovingTabIndex(itemRef, disabled);
10
10
  const isIconRight = iconPosition === 'right';
@@ -15,8 +15,8 @@ export const MenuItem = forwardRef(({ className, children, onClick, icon, dimens
15
15
  onClick();
16
16
  }
17
17
  }, [handleClick, onClick]);
18
- const InnerContent = useMemo(() => (_jsxs(Stack, { direction: "row", as: "span", fill: false, className: ItemContent, horizontalAlign: isIconRight ? 'space-between' : 'start', verticalAlign: "start", columnGap: 8, horizontalPadding: 16, verticalPadding: 8, "data-menu-item-icon-right": isIconRight, "data-menu-item-has-icon": Boolean(icon), "data-menu-item-padding": padding, style: { inlineSize: '100%' }, children: [icon && (_jsx(Icon, { className: IconClass, name: icon, dimension: dimension === 'small' ? 14 : 16 }, void 0)), children] }, void 0)), [children, dimension, icon, isIconRight, padding]);
19
- return (_jsx(Wrapper, { ref: itemRef, role: "menuitem", className: clsx(MenuItemClass, className), onClick: disabled ? undefined : triggerClick, onKeyDown: disabled ? undefined : handleKeyDown, tabIndex: tabIndex, "aria-disabled": disabled, type: Wrapper === 'button' ? 'button' : undefined, "data-menu-item-dimension": dimension, ...otherProps, children: description
18
+ const InnerContent = useMemo(() => (_jsxs(Stack, { direction: isIconRight ? 'row-reverse' : 'row', as: "span", className: ItemContent, horizontalAlign: isIconRight ? 'space-between' : 'start', verticalAlign: "center", columnGap: 8, horizontalPadding: 16, verticalPadding: 8, "data-menu-item-icon-right": isIconRight, "data-menu-item-has-icon": Boolean(icon), "data-menu-item-padding": padding, style: { inlineSize: '100%' }, children: [icon && (_jsx(Icon, { className: IconClass, name: icon, dimension: dimension === 'small' ? 14 : 16 }, void 0)), _jsxs(Stack, { columnGap: 16, direction: "row", horizontalAlign: "space-between", children: [children, decoration] }, void 0)] }, void 0)), [children, dimension, icon, isIconRight, decoration, padding]);
19
+ return (_jsx(Wrapper, { autoFocus: autoFocus, ref: itemRef, role: "menuitem", className: clsx(MenuItemClass, className), onClick: disabled ? undefined : triggerClick, onKeyDown: disabled ? undefined : handleKeyDown, tabIndex: tabIndex, "aria-disabled": disabled, type: Wrapper === 'button' ? 'button' : undefined, "data-menu-item-dimension": dimension, ...otherProps, children: description
20
20
  ? (_jsx(Tooltip, { fill: true, open: focused, placement: "right-start", interactive: true, trigger: InnerContent, children: description }, void 0))
21
21
  : InnerContent }, void 0));
22
22
  });
@@ -1 +1 @@
1
- .MenuItem{background:none;border:0;box-sizing:border-box;color:var(--dimmed-6);cursor:pointer;font:inherit;font-size:.89rem;font-weight:600;inline-size:100%;line-height:1.2;padding:0;position:relative;text-align:start}.MenuItem[aria-checked=true]{color:var(--global-interactive-text)}.MenuItem:before{border-radius:.22rem;bottom:0;content:"";left:.44rem;opacity:60%;position:absolute;right:.44rem;top:0;z-index:0}.MenuItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.MenuItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.MenuItem[data-menu-item-dimension=small]{font-size:.78rem}.MenuItem>*{position:relative}.MenuItem[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=false]{padding-left:2.22rem}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=true]{padding-right:2.22rem}.ItemContent{position:relative}.Icon{flex-shrink:0;margin-top:1px}[data-menu-item-icon-right=true] .Icon{order:2}
1
+ .MenuItem{background:none;border:0;box-sizing:border-box;color:var(--dimmed-6);cursor:pointer;font:inherit;font-size:.89rem;font-weight:600;inline-size:100%;padding:0;position:relative;text-align:start}.MenuItem:hover{color:var(--global-foreground)}.MenuItem[aria-checked=true]{color:var(--global-interactive-text)}.MenuItem:before{border-radius:.22rem;bottom:0;content:"";left:.44rem;opacity:60%;position:absolute;right:.44rem;top:0;z-index:0}.MenuItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]){outline:none}.MenuItem:is(:hover,.focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.MenuItem:is(:hover,:focus-visible,[aria-pressed=true]):not([aria-disabled=true]):before{background-color:var(--dimmed-1)}.MenuItem[data-menu-item-dimension=small]{font-size:.78rem}.MenuItem>*{position:relative}.MenuItem[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=false]{padding-left:2.22rem}.MenuItem [data-menu-item-padding=true][data-menu-item-has-icon=false][data-menu-item-icon-right=true]{padding-right:2.22rem}.ItemContent{position:relative}.Icon{align-self:flex-start;flex-grow:0;flex-shrink:0;margin-top:4px}
package/menu/menu.js CHANGED
@@ -1,16 +1,14 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Children, cloneElement, forwardRef } from 'react';
2
+ import { Children, forwardRef } from 'react';
3
3
  import { RovingTabIndexProvider } from 'react-roving-tabindex';
4
4
  import { MenuItem } from './menu-item/menu-item';
5
5
  import { MenuItemCheckbox } from './menu-item/menu-item-checkbox';
6
- import { Stack, Elevator } from '..';
6
+ import { Stack, Elevator, Card } from '..';
7
7
  import { Menu as MenuClass } from './menu.module.css';
8
8
  import clsx from 'clsx';
9
9
  export const Menu = forwardRef(({ className, children, ...otherProps }, forwardedRef) => {
10
10
  const renderedChildren = Children.toArray(children).filter(Boolean);
11
- return (_jsx(Elevator, { resting: 2, children: _jsx(Stack, { as: "ul", ref: forwardedRef, className: clsx(MenuClass, className), role: "menu", ...otherProps, children: _jsx(RovingTabIndexProvider, { options: { direction: 'vertical', loopAround: true }, children: Children.map(renderedChildren, (child, index) => (_jsx(Stack, { as: "li", role: "none", verticalPadding: child.type?.displayName === 'Separator' ? 8 : undefined, children: cloneElement(child, {
12
- autoFocus: index === 0 && true
13
- }) }, void 0))) }, void 0) }, void 0) }, void 0));
11
+ return (_jsx(Elevator, { resting: 2, children: _jsx(Card, { bordered: true, radius: 8, padding: false, as: "ul", ref: forwardedRef, className: clsx(MenuClass, className), role: "menu", ...otherProps, children: _jsx(RovingTabIndexProvider, { options: { direction: 'vertical', loopAround: true }, children: Children.map(renderedChildren, (child) => (_jsx(Stack, { as: "li", role: "none", verticalPadding: child.type?.displayName === 'Separator' ? 8 : undefined, children: child }, void 0))) }, void 0) }, void 0) }, void 0));
14
12
  });
15
13
  Menu.displayName = 'Menu';
16
14
  Menu.Item = MenuItem;
@@ -1 +1 @@
1
- .Menu{background-color:var(--global-background);border:1px solid var(--dimmed-1);border-radius:.44rem;list-style-type:none;overflow:hidden;padding:.44rem 0;position:relative}.Menu hr{margin:0 .44rem}
1
+ .Menu{list-style-type:none;overflow:hidden;padding:.44rem 0;position:relative}.Menu hr{margin:0 .44rem}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
3
  "description": "UI components from Wonderflow's Wanda design system",
4
- "version": "3.0.0-beta.19",
4
+ "version": "3.0.0-beta.22",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
package/stack/stack.d.ts CHANGED
@@ -41,9 +41,10 @@ export declare type StackProps = {
41
41
  */
42
42
  verticalPadding?: TokensTypes['space'];
43
43
  /**
44
- * Renderes children as rows or columns
44
+ * Renderes children as rows or columns. The value can be one of the flex directions.
45
+ * More info: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction
45
46
  */
46
- direction?: 'row' | 'column';
47
+ direction?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
47
48
  };
48
49
  declare type PolymorphicStack = Polymorphic.ForwardRefComponent<'div', StackProps>;
49
50
  export declare const Stack: PolymorphicStack;
@@ -1 +1 @@
1
- :where(.Stack){grid-gap:var(--rGap,0) var(--cGap,0);align-items:var(--hAlign);display:flex;flex-direction:column;justify-content:var(--vAlign);padding:var(--vPadding,0) var(--hPadding,0)}[data-stack-fill=true]:where(.Stack)>*{flex-grow:1}[data-stack-direction=row]:where(.Stack){align-items:var(--vAlign);flex-direction:row;justify-content:var(--hAlign)}[data-stack-inline=true]:where(.Stack){display:inline-flex;flex-grow:0}[data-stack-wrap=true]:where(.Stack){flex-wrap:wrap}
1
+ :where(.Stack){grid-gap:var(--rGap,0) var(--cGap,0);align-items:var(--hAlign);display:flex;flex-direction:column;justify-content:var(--vAlign);padding:var(--vPadding,0) var(--hPadding,0)}:where(.Stack):where([data-stack-fill=true])>*{flex-grow:1}[data-stack-direction=column-reverse]:where(.Stack){flex-direction:column-reverse}[data-stack-direction^=row]:where(.Stack){align-items:var(--vAlign);justify-content:var(--hAlign)}[data-stack-direction=row]:where(.Stack){flex-direction:row}[data-stack-direction=row-reverse]:where(.Stack){flex-direction:row-reverse}[data-stack-inline=true]:where(.Stack){display:inline-flex;flex-grow:0}[data-stack-wrap=true]:where(.Stack){flex-wrap:wrap}
package/themes/dark.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 31 Dec 2021 13:33:54 GMT
3
+ * Generated on Mon, 03 Jan 2022 10:10:21 GMT
4
4
  */
5
5
 
6
6
  :root {
package/themes/light.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 31 Dec 2021 13:33:54 GMT
3
+ * Generated on Mon, 03 Jan 2022 10:10:21 GMT
4
4
  */
5
5
 
6
6
  :root {