From 977987722c5161d2c15cb54de12f7db597770349 Mon Sep 17 00:00:00 2001 From: iana Date: Thu, 8 Feb 2024 15:39:41 +0100 Subject: [PATCH] feat(app-menu-item): render `a-keyboard-shortcut` if 'shortcut' prop is provided --- src/components/AppMenuItem.vue | 17 ++++++++-- src/stories/AppMenu/AppMenuItem.stories.ts | 39 +++++++++++++++++++++- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/components/AppMenuItem.vue b/src/components/AppMenuItem.vue index 8aa61fd..0a99318 100644 --- a/src/components/AppMenuItem.vue +++ b/src/components/AppMenuItem.vue @@ -4,10 +4,11 @@ import { useElementBounding } from '@vueuse/core' import AIcon from './Icon.vue' import ArrowKeyFocusable from './ArrowKeyFocusable.vue' +import { type Shortcut, default as KeyboardShortcut } from './KeyboardShortcut.vue' export default defineComponent({ name: 'AAppMenuItem', - components: { AIcon, ArrowKeyFocusable }, + components: { AIcon, ArrowKeyFocusable, KeyboardShortcut }, props: { disabled: { type: Boolean, @@ -29,8 +30,12 @@ export default defineComponent({ type: String as PropType<'radio' | 'checkbox' | ''>, default: '' }, + /** + * type `string` for shortcut prop is deprecated, + * use type `Shortcut` or `Shortcut[]` instead to + */ shortcut: { - type: String, + type: [String, Object, Array] as PropType, default: '' }, /** @@ -225,7 +230,13 @@ export default defineComponent({
- {{ shortcut }} +
Cut - + + Copy + + Status + + ` + }), + play: openMenu +} +export const MultipleShortcuts: Story = { + render: () => ({ + components: { AAppMenu, AAppMenuItem, AAppMenuButton }, + template: ` + + + Cut + + Copy + + Status + + ` + }), + play: openMenu +} + +export const DisabledWithShortcuts: Story = { + render: () => ({ + components: { AAppMenu, AAppMenuItem, AAppMenuButton }, + template: ` + + + Cut + Copy Status