From 4807e092bb8b2e3ca8a6a190f35539bce288d2a5 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Mon, 29 Sep 2025 11:04:22 -0600 Subject: [PATCH] update mention input for --- .../BusterInput/BusterInput.stories.tsx | 3 +- .../ui/inputs/BusterInput/BusterInput.tsx | 2 + .../inputs/BusterInput/BusterInput.types.ts | 3 +- .../BusterInput/BusterMentionsInput.tsx | 3 + .../ui/inputs/MentionInput/MentionInput.tsx | 75 ++++--------------- .../inputs/MentionInput/MentionInput.types.ts | 1 + .../MentionInput/SubmitEnterExtension.ts | 29 +++++++ .../MentionInput/update-transformers.ts | 48 ++++++++++++ 8 files changed, 102 insertions(+), 62 deletions(-) create mode 100644 apps/web/src/components/ui/inputs/MentionInput/SubmitEnterExtension.ts create mode 100644 apps/web/src/components/ui/inputs/MentionInput/update-transformers.ts diff --git a/apps/web/src/components/ui/inputs/BusterInput/BusterInput.stories.tsx b/apps/web/src/components/ui/inputs/BusterInput/BusterInput.stories.tsx index b5bc17f93..bd11e4143 100644 --- a/apps/web/src/components/ui/inputs/BusterInput/BusterInput.stories.tsx +++ b/apps/web/src/components/ui/inputs/BusterInput/BusterInput.stories.tsx @@ -1,11 +1,11 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; +import { fn } from 'storybook/test'; import { BusterInput } from './BusterInput'; import type { BusterInputProps } from './BusterInput.types'; const meta: Meta = { title: 'UI/Inputs/BusterInput', component: BusterInput, - tags: ['autodocs'], decorators: [ (Story) => (
@@ -78,5 +78,6 @@ export const Default: Story = { value: 'Sample text value', suggestionItems: items, mentions, + onSubmit: fn(), }, }; diff --git a/apps/web/src/components/ui/inputs/BusterInput/BusterInput.tsx b/apps/web/src/components/ui/inputs/BusterInput/BusterInput.tsx index ee7367214..b057d8f72 100644 --- a/apps/web/src/components/ui/inputs/BusterInput/BusterInput.tsx +++ b/apps/web/src/components/ui/inputs/BusterInput/BusterInput.tsx @@ -15,6 +15,7 @@ export const BusterInput = ({ emptyComponent, submitting, onSubmit, + onPressEnter, disabled: disabledGlobal = false, onStop, sendIcon, @@ -105,6 +106,7 @@ export const BusterInput = ({ shouldFilter={shouldFilter} filter={filter} onMentionItemClick={onMentionItemClick} + onPressEnter={onPressEnter || onSubmit} /> diff --git a/apps/web/src/components/ui/inputs/BusterInput/BusterInput.types.ts b/apps/web/src/components/ui/inputs/BusterInput/BusterInput.types.ts index 4cbcb54cb..83671cb06 100644 --- a/apps/web/src/components/ui/inputs/BusterInput/BusterInput.types.ts +++ b/apps/web/src/components/ui/inputs/BusterInput/BusterInput.types.ts @@ -1,7 +1,7 @@ import type { Command } from 'cmdk'; import type React from 'react'; import type { MentionSuggestionExtension } from '../MentionInput'; -import type { MentionTriggerItem } from '../MentionInput/MentionInput.types'; +import type { MentionInputProps, MentionTriggerItem } from '../MentionInput/MentionInput.types'; /** * @description Override the addValueToInput and closeOnSelect props for the item based on the group props @@ -59,6 +59,7 @@ export type BusterInputProps = { disabled?: boolean; readOnly?: boolean; onSubmit: (value: string) => void; + onPressEnter: MentionInputProps['onPressEnter']; onStop: () => void; variant?: 'default'; autoFocus?: boolean; diff --git a/apps/web/src/components/ui/inputs/BusterInput/BusterMentionsInput.tsx b/apps/web/src/components/ui/inputs/BusterInput/BusterMentionsInput.tsx index 7a60485e1..6ac21ed5e 100644 --- a/apps/web/src/components/ui/inputs/BusterInput/BusterMentionsInput.tsx +++ b/apps/web/src/components/ui/inputs/BusterInput/BusterMentionsInput.tsx @@ -15,6 +15,7 @@ export type BusterMentionsInputProps = Pick< | 'onMentionItemClick' > & { onChange: MentionInputProps['onChange']; + onPressEnter: MentionInputProps['onPressEnter']; className?: string; style?: React.CSSProperties; autoFocus?: boolean; @@ -35,7 +36,9 @@ export const BusterMentionsInput = ({