From 1e160a5f03c2eb8cb20ff2b23c492bf9e5c615d8 Mon Sep 17 00:00:00 2001 From: Arthurk12 Date: Thu, 9 Jul 2026 19:24:59 -0300 Subject: [PATCH 1/2] feat(BBBInput): add labeled text field with inline action button Adds a new BBBInput component unifying the recurring "text field + submit button" pattern found ad hoc in chat, guest messages and breakouts (issue #34): an auto-growing textarea with a labeled action button, submit-on-Enter, controlled/uncontrolled value handling matching BBBSearch, an opt-in "sent" feedback affordance, and beforeButton/afterButton slots for extra actions (e.g. an emoji picker) next to the submit button. Registers the component across the package's export surface (components index, webpack entries, package.json exports/typesVersions, root README) following the existing per-component conventions. --- README.md | 1 + package.json | 10 + src/components/Input/README.md | 118 +++++++++++ src/components/Input/component.stories.tsx | 229 +++++++++++++++++++++ src/components/Input/component.tsx | 192 +++++++++++++++++ src/components/Input/index.ts | 1 + src/components/Input/styles.ts | 107 ++++++++++ src/components/Input/types.ts | 108 ++++++++++ src/components/index.ts | 1 + webpack.config.babel.js | 1 + 10 files changed, 768 insertions(+) create mode 100644 src/components/Input/README.md create mode 100644 src/components/Input/component.stories.tsx create mode 100644 src/components/Input/component.tsx create mode 100644 src/components/Input/index.ts create mode 100644 src/components/Input/styles.ts create mode 100644 src/components/Input/types.ts diff --git a/README.md b/README.md index 8f6d7b0..6fbee16 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Below is a list of the components available in this library. Each component has - [BBBCheckbox](./src/components/Checkbox/README.md) - [BBBDivider](./src/components/Divider/README.md) - [BBBHint](./src/components/Hint/README.md) +- [BBBInput](./src/components/Input/README.md) - [BBBModal](./src/components/Modal//README.md) - [BBBNavigation](./src/components/Navigation/README.md) - [BBBSearch](./src/components/Search/README.md) diff --git a/package.json b/package.json index 9f3e200..c867055 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,13 @@ "require": "./dist/components/Hint.js", "default": "./dist/components/Hint.js" }, + "./Input": { + "types": "./dist/types/components/Input/index.d.ts", + "node": "./dist/components/Input.js", + "import": "./dist/esm/components/Input/index.js", + "require": "./dist/components/Input.js", + "default": "./dist/components/Input.js" + }, "./Modal": { "types": "./dist/types/components/Modal/index.d.ts", "node": "./dist/components/Modal.js", @@ -172,6 +179,9 @@ "Hint": [ "dist/types/components/Hint/index.d.ts" ], + "Input": [ + "dist/types/components/Input/index.d.ts" + ], "Modal": [ "dist/types/components/Modal/index.d.ts" ], diff --git a/src/components/Input/README.md b/src/components/Input/README.md new file mode 100644 index 0000000..873e6e9 --- /dev/null +++ b/src/components/Input/README.md @@ -0,0 +1,118 @@ +# BBBInput + +The `BBBInput` component provides a labeled, auto-growing text field with an inline action button. It unifies the recurring "text field + submit button" pattern used across chat, guest messages, breakouts and similar areas, modeled after the core chat text input. + +`BBBTextInput` and `BBBTextAreaInput` remain the right choice for standalone fields with no inline action button. + +## Usage Example + +### Basic usage — text field with a submit icon button +```jsx +import { BBBInput } from 'bbb-ui-components-react'; +import { MdSend } from 'react-icons/md'; + +} + buttonAriaLabel="Send message" + onSubmit={(value) => handleSend(value)} +/> +``` + +### With a text button label instead of an icon +```jsx + sendGuestMessage(value)} +/> +``` + +### Controlled +```jsx +const [value, setValue] = useState(''); + +} + buttonAriaLabel="Send message" + onSubmit={(submittedValue) => { + submitMessage(submittedValue); + setValue(''); + }} +/> +``` + +### With sent feedback +```jsx +} + buttonAriaLabel="Send message" + showSentFeedback + onSubmit={(value) => handleSend(value)} +/> +``` + +### With extra actions around the submit button +```jsx +import { MdEmojiEmotions } from 'react-icons/md'; + +} + buttonAriaLabel="Send message" + beforeButton={( + + )} + onSubmit={(value) => handleSend(value)} +/> +``` + +## Props + +| Property | Type | Default | Description | +| ----------------------- | --------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------ | +| `label` | `string` | | Label displayed above the field. | +| `placeholder` | `string` | | Placeholder text displayed when the field is empty. | +| `value` | `string` | | Controlled value. Enables controlled mode when provided together with `onChange`. | +| `onChange` | `(value: string) => void` | | Called on every keystroke. Required in controlled mode. | +| `onSubmit` | `(value: string) => void` | | Called with the trimmed, non-empty value when the field is submitted. **Required.** | +| `buttonIcon` | `React.ReactNode` | | Icon rendered inside the action button. | +| `buttonLabel` | `string` | | Text label rendered by the action button, instead of (or alongside) `buttonIcon`. | +| `buttonAriaLabel` | `string` | | Accessible name for the action button. **Required** when only `buttonIcon` is set (no `buttonLabel`). | +| `buttonVariant` | `'primary' \| 'secondary' \| 'tertiary' \| 'subtle'` | `'primary'` | Visual variant of the action button (same variants as the shared `Button`). | +| `dataTest` | `string` | | `data-test` attribute on the underlying `