+ Try pressing the keyboard shortcuts to trigger the buttons: +
++ When a custom suffix is provided, hotkeys are still functional but the + shortcut hint is not shown: +
+{ * @param props - Props to pass to the menu component * @param triggerProps - Additional props for MenuTrigger (merged with defaultTriggerProps) */ - open(props: P, triggerProps?: T): void; + open(props?: P, triggerProps?: T): void; /** * Updates the props of the currently open menu. @@ -53,6 +53,7 @@ export interface UseAnchoredMenuReturn
{ * * @param Component - A React component that represents the menu content (Menu or CommandMenu). * @param defaultTriggerProps - Default props to pass to the MenuTrigger. + * @param defaultMenuProps - Default props to pass to the Menu component. * @returns An object with `anchorRef` to position the menu, `open` function to open the menu with provided props, `close` function to close the menu, and `rendered` JSX element to include in your component tree. */ export function useAnchoredMenu
>( @@ -61,6 +62,7 @@ export function useAnchoredMenu
>(
ComponentProps {
const [isOpen, setIsOpen] = useState(false);
const [componentProps, setComponentProps] = useState (null);
@@ -112,10 +114,15 @@ export function useAnchoredMenu >(
}
// 'open' accepts props required by the Component and opens the menu
- const open = useEvent((props: P, triggerProps?: T) => {
+ const open = useEvent((props: P = {} as P, triggerProps?: T) => {
setupCheck();
- setComponentProps(props);
+ // Merge defaultMenuProps with provided props
+ const finalProps = defaultMenuProps
+ ? { ...defaultMenuProps, ...props }
+ : props;
+
+ setComponentProps(finalProps);
setTriggerProps(triggerProps ?? null);
setIsOpen(true);
});
@@ -123,7 +130,12 @@ export function useAnchoredMenu >(
const update = useEvent((props: P, triggerProps?: T) => {
setupCheck();
- setComponentProps(props);
+ // Merge defaultMenuProps with provided props
+ const finalProps = defaultMenuProps
+ ? { ...defaultMenuProps, ...props }
+ : props;
+
+ setComponentProps(finalProps);
setTriggerProps(triggerProps ?? null);
});
diff --git a/src/components/actions/use-context-menu.docs.mdx b/src/components/actions/use-context-menu.docs.mdx
index 9c19c4373..9a0dd0f48 100644
--- a/src/components/actions/use-context-menu.docs.mdx
+++ b/src/components/actions/use-context-menu.docs.mdx
@@ -1,4 +1,4 @@
-import { Meta } from '@storybook/blocks';
+import { Meta } from '@storybook/addon-docs/blocks';
diff --git a/src/components/actions/use-context-menu.tsx b/src/components/actions/use-context-menu.tsx
index 49bbfaf17..b41d8bdb6 100644
--- a/src/components/actions/use-context-menu.tsx
+++ b/src/components/actions/use-context-menu.tsx
@@ -199,7 +199,7 @@ export function useContextMenu<
// 'open' accepts props, trigger props, and optional event for positioning, then opens the menu
const open = useEvent(
(
- props?: P,
+ props: P = {} as P,
triggerProps?: T,
event?: NativeMouseEvent | NativePointerEvent | MouseEvent | PointerEvent,
) => {
@@ -234,7 +234,7 @@ export function useContextMenu<
? { ...defaultMenuProps, ...props }
: props;
- setComponentProps(finalProps as P);
+ setComponentProps(finalProps);
setTriggerProps(triggerProps ?? null);
setIsOpen(true);
},
diff --git a/src/components/content/Alert/Alert.stories.tsx b/src/components/content/Alert/Alert.stories.tsx
index 6b658a37c..438642f18 100644
--- a/src/components/content/Alert/Alert.stories.tsx
+++ b/src/components/content/Alert/Alert.stories.tsx
@@ -1,4 +1,4 @@
-import { Meta, StoryFn } from '@storybook/react';
+import { Meta, StoryFn } from '@storybook/react-vite';
import { baseProps } from '../../../stories/lists/baseProps';
diff --git a/src/components/content/Avatar/Avatar.stories.tsx b/src/components/content/Avatar/Avatar.stories.tsx
index 460fcfc8c..e8183ed09 100644
--- a/src/components/content/Avatar/Avatar.stories.tsx
+++ b/src/components/content/Avatar/Avatar.stories.tsx
@@ -1,4 +1,4 @@
-import { StoryFn } from '@storybook/react';
+import { StoryFn } from '@storybook/react-vite';
import { IconCoin } from '@tabler/icons-react';
import { baseProps } from '../../../stories/lists/baseProps';
diff --git a/src/components/content/CopyPasteBlock/CopyPasteBlock.stories.tsx b/src/components/content/CopyPasteBlock/CopyPasteBlock.stories.tsx
index 60fd8e1d2..f0b936026 100644
--- a/src/components/content/CopyPasteBlock/CopyPasteBlock.stories.tsx
+++ b/src/components/content/CopyPasteBlock/CopyPasteBlock.stories.tsx
@@ -1,4 +1,4 @@
-import { Meta, StoryFn } from '@storybook/react';
+import { Meta, StoryFn } from '@storybook/react-vite';
import { useState } from 'react';
import { baseProps } from '../../../stories/lists/baseProps';
diff --git a/src/components/content/CopySnippet/CopySnippet.stories.tsx b/src/components/content/CopySnippet/CopySnippet.stories.tsx
index 8d521e2fe..f6ce49180 100644
--- a/src/components/content/CopySnippet/CopySnippet.stories.tsx
+++ b/src/components/content/CopySnippet/CopySnippet.stories.tsx
@@ -1,4 +1,4 @@
-import { Meta, StoryFn } from '@storybook/react';
+import { Meta, StoryFn } from '@storybook/react-vite';
import { IconSettings } from '@tabler/icons-react';
import { baseProps } from '../../../stories/lists/baseProps';
diff --git a/src/components/content/HotKeys/HotKeys.docs.mdx b/src/components/content/HotKeys/HotKeys.docs.mdx
index f5c575f51..5980f46b1 100644
--- a/src/components/content/HotKeys/HotKeys.docs.mdx
+++ b/src/components/content/HotKeys/HotKeys.docs.mdx
@@ -1,4 +1,4 @@
-import { Meta, Canvas, Story, Controls } from '@storybook/blocks';
+import { Meta, Canvas, Story, Controls } from '@storybook/addon-docs/blocks';
import { HotKeys } from './HotKeys';
import * as HotKeysStories from './HotKeys.stories';
diff --git a/src/components/content/HotKeys/HotKeys.stories.tsx b/src/components/content/HotKeys/HotKeys.stories.tsx
index 3e539d2d8..59cb23d13 100644
--- a/src/components/content/HotKeys/HotKeys.stories.tsx
+++ b/src/components/content/HotKeys/HotKeys.stories.tsx
@@ -1,4 +1,4 @@
-import { StoryFn } from '@storybook/react';
+import { StoryFn } from '@storybook/react-vite';
import { CubeHotKeysProps, HotKeys } from './HotKeys';
diff --git a/src/components/content/HotKeys/HotKeys.tsx b/src/components/content/HotKeys/HotKeys.tsx
index f96e7efe4..e315e6c8d 100644
--- a/src/components/content/HotKeys/HotKeys.tsx
+++ b/src/components/content/HotKeys/HotKeys.tsx
@@ -10,7 +10,6 @@ import {
} from '../../../tasty';
import { useKeySymbols } from '../../../utils/react/useKeySymbols';
import { Space } from '../../layout/Space';
-import { Tag } from '../Tag/Tag';
import { Text } from '../Text';
const StyledHotKeys = tasty(Space, {
@@ -21,6 +20,37 @@ const StyledHotKeys = tasty(Space, {
display: 'inline-flex',
flow: 'row',
gap: '1x',
+ placeSelf: 'center',
+ },
+});
+
+const KeyElement = tasty({
+ as: 'kbd',
+ role: 'text',
+ styles: {
+ display: 'inline-flex',
+ placeContent: 'center',
+ placeItems: 'center start',
+ radius: '1r',
+ preset: 'tag',
+ boxSizing: 'border-box',
+ width: '2.5x max-content max-content',
+ height: 'min-content',
+ textAlign: 'left',
+ whiteSpace: 'nowrap',
+ padding: '0 (.5x - 1bw)',
+ color: {
+ '': '#dark.65',
+ '[data-type="primary"]': '#white',
+ },
+ fill: {
+ '': '#dark.04',
+ '[data-type="primary"]': '#clear',
+ },
+ border: {
+ '': true,
+ '[data-type="primary"]': '#white',
+ },
},
});
@@ -28,10 +58,11 @@ export interface CubeHotKeysProps
extends BasePropsWithoutChildren,
ContainerStyleProps {
children: string;
+ type?: 'default' | 'primary';
}
function HotKeys(props: CubeHotKeysProps, ref) {
- const { children: keys, ...otherProps } = props;
+ const { children: keys, type, ...otherProps } = props;
const parsedKeys = useKeySymbols(keys);
const styles = extractStyles(otherProps, CONTAINER_STYLES);
@@ -56,14 +87,15 @@ function HotKeys(props: CubeHotKeysProps, ref) {
aria-label={`Key combination ${groupIndex + 1}`}
>
{keyGroup.map((key, keyIndex) => (
-