@wonderflow/react-components 3.0.0-beta.20 → 3.0.0-beta.21
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.
|
@@ -46,6 +46,15 @@ export declare type MenuItemProps = {
|
|
|
46
46
|
* This property is commonly used on the first item in the menu.
|
|
47
47
|
*/
|
|
48
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. The decoration element will be placed on the
|
|
52
|
+
* opposite side of the icon, based on `iconPosition`.
|
|
53
|
+
*
|
|
54
|
+
* @note Don't use interactive elements (link, buttons, etc..) as decoration
|
|
55
|
+
* if `Menu.Item` is rendered as ´<button>´ (default).
|
|
56
|
+
*/
|
|
57
|
+
decoration?: ReactNode;
|
|
49
58
|
};
|
|
50
59
|
declare type PolymorphicMenuItem = Polymorphic.ForwardRefComponent<'button', MenuItemProps>;
|
|
51
60
|
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, autoFocus, ...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,7 +15,7 @@ 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:
|
|
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, { direction: "row", horizontalAlign: "space-between", children: [children, decoration] }, void 0)] }, void 0)), [children, dimension, icon, isIconRight, decoration, padding]);
|
|
19
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));
|
|
@@ -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%;
|
|
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/package.json
CHANGED
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;
|
package/stack/stack.module.css
CHANGED
|
@@ -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)
|
|
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