The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Compose SearchInput with input primitives (#26986)
Raphaël Bosi1c4d79047a75
diff --git a/packages/twenty-docs/snippets/ui/generated/components/search-input.mdx b/packages/twenty-docs/snippets/ui/generated/components/search-input.mdxindex 6b07e8f15a2..f50b86af003 100644--- a/packages/twenty-docs/snippets/ui/generated/components/search-input.mdx+++ b/packages/twenty-docs/snippets/ui/generated/components/search-input.mdx@@ -23,8 +23,12 @@Focuses the input when mounted.</ParamField>-<ParamField body="className" type="string">- Class applied to the wrapper.+<ParamField body="className" type="string | ((state: InputState) => string | undefined)">+ Class applied to the input.+</ParamField>++<ParamField body="defaultValue" type="string | number | readonly string[]">+ The default value of the input. Use when uncontrolled.</ParamField><ParamField body="disabled" type="boolean">@@ -43,14 +47,38 @@Input ID, generated when omitted.</ParamField>-<ParamField body="onChange" type="(value: string) => void" required>- Called with the new text, not a DOM change event. The application owns filtering.+<ParamField body="onChange" type="((event: BaseUIEvent<ChangeEvent<HTMLInputElement, HTMLInputElement>>) => void)">+ Native input change event handler.+</ParamField>++<ParamField body="onValueChange" type="((value: string, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)">+ Called with the new text. The application owns filtering.</ParamField><ParamField body="placeholder" type="string">Hint shown when the input is empty. Also used as the accessible name if no explicit label is supplied.</ParamField>-<ParamField body="value" type="string" required>+<ParamField body="ref" type="Ref<HTMLInputElement>">+ Ref to the native input element.+</ParamField>++<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, InputState>">+ Allows you to replace the component's HTML element+ with a different tag, or compose it with another component.++ Accepts a `ReactElement` or a function that returns the element to render.+</ParamField>++<ParamField body="size" type=""md" | "sm"" default="md">+ Visual size of the input group and optional filter button.+</ParamField>++<ParamField body="style" type="CSSProperties | ((state: InputState) => CSSProperties | undefined)">+ Style applied to the element, or a function that+ returns a style object based on the component's state.+</ParamField>++<ParamField body="value" type="string | number | readonly string[]">Current search text.</ParamField>diff --git a/packages/twenty-docs/ui/components/search-input.mdx b/packages/twenty-docs/ui/components/search-input.mdxindex b0563727e1c..3fa2c4184e7 100644--- a/packages/twenty-docs/ui/components/search-input.mdx+++ b/packages/twenty-docs/ui/components/search-input.mdx@@ -6,7 +6,7 @@ description: Controlled search text with an optional filter popup.import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';import SearchInputReference from '/snippets/ui/generated/components/search-input.mdx';-`SearchInput` supplies a search icon and text input. `onChange` receives the new string. Filtering, fetching, and debouncing belong to your application.+`SearchInput` supplies a search icon and text input. `onValueChange` receives the new string; `onChange` receives the native React change event. Filtering, fetching, and debouncing belong to your application.```tsximport { useState } from 'react';@@ -20,7 +20,7 @@ export const PeopleSearch = () => {aria-label="Search people"placeholder="Name or email"value={search}- onChange={setSearch}+ onValueChange={setSearch}/>);};@@ -34,6 +34,8 @@ Use `aria-label` or `aria-labelledby` for an accessible name. `filterDropdown` rheight={280}/>+Native input props, `className`, `style`, and `ref` apply to the input itself. The shared `InputGroup` owns the search adornment and focus treatment. Use `size="sm"` for a compact search field.+## Props<SearchInputReference />diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsxindex ad9b048eb9f..178990aa6ff 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx@@ -137,7 +137,7 @@ const INPUT_ENTRIES: GalleryEntry[] = [},{name: 'SearchInput',- node: <SearchInput value="" onChange={() => {}} placeholder="Search" />,+ node: <SearchInput defaultValue="" placeholder="Search" />,},{name: 'SegmentedControl',diff --git a/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsx b/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsxindex d3a48023ce2..0b3ef45babc 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsx+++ b/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsx@@ -210,7 +210,7 @@ export const SettingsAdminApps = () => {<SearchInputplaceholder={t`Search registrations...`}value={searchQuery}- onChange={setSearchQuery}+ onValueChange={setSearchQuery}filterDropdown={(filterButton) => (<DropdownRootdropdownId="settings-admin-apps-filter-dropdown"diff --git a/packages/twenty-front/src/modules/settings/admin-panel/config-variables/components/ConfigVariableSearchInput.tsx b/packages/twenty-front/src/modules/settings/admin-panel/config-variables/components/ConfigVariableSearchInput.tsxindex 50345f4da1d..f1bfb161d21 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/config-variables/components/ConfigVariableSearchInput.tsx+++ b/packages/twenty-front/src/modules/settings/admin-panel/config-variables/components/ConfigVariableSearchInput.tsx@@ -14,7 +14,7 @@ export const ConfigVariableSearchInput = ({<SearchInputplaceholder={t`Search config variables`}value={value}- onChange={onChange}+ onValueChange={onChange}/>);};diff --git a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsTable.tsx b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsTable.tsxindex b70148ac88a..1818adb38be 100644--- a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsTable.tsx+++ b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsTable.tsx@@ -208,7 +208,7 @@ export const SettingsBillingLimitsTable = ({<SearchInputplaceholder={t`Search a limit`}value={searchText}- onChange={setSearchText}+ onValueChange={setSearchText}filterButtonAriaLabel={t`Filter limits`}filterDropdown={(filterButton) => (<SettingsBillingLimitsFilterDropdowndiff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectIndexesSection.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectIndexesSection.tsxindex 1162f033cdc..b4a9e65b03e 100644--- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectIndexesSection.tsx+++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectIndexesSection.tsx@@ -167,7 +167,7 @@ export const SettingsObjectIndexesSection = ({<SearchInputplaceholder={t`Search an index...`}value={searchTerm}- onChange={setSearchTerm}+ onValueChange={setSearchTerm}filterDropdown={(filterButton) => (<DropdownRootdropdownId={HIDE_SYSTEM_INDEXES_DROPDOWN_ID}diff --git a/packages/twenty-front/src/modules/settings/unsubscribers/components/SettingsUnsubscribersList.tsx b/packages/twenty-front/src/modules/settings/unsubscribers/components/SettingsUnsubscribersList.tsxindex 6dac057bed3..26d469c237b 100644--- a/packages/twenty-front/src/modules/settings/unsubscribers/components/SettingsUnsubscribersList.tsx+++ b/packages/twenty-front/src/modules/settings/unsubscribers/components/SettingsUnsubscribersList.tsx@@ -139,7 +139,7 @@ export const SettingsUnsubscribersList = () => {<SearchInputplaceholder={t`Search by email address`}value={searchText}- onChange={handleSearchChange}+ onValueChange={handleSearchChange}/></StyledSearch><SettingsUnsubscribersFilterDropdowndiff --git a/packages/twenty-front/src/modules/settings/usage/components/UsageByUserTableSection.tsx b/packages/twenty-front/src/modules/settings/usage/components/UsageByUserTableSection.tsxindex 19c23df47e0..37682a34cb4 100644--- a/packages/twenty-front/src/modules/settings/usage/components/UsageByUserTableSection.tsx+++ b/packages/twenty-front/src/modules/settings/usage/components/UsageByUserTableSection.tsx@@ -94,7 +94,7 @@ export const UsageByUserTableSection = ({<SearchInputplaceholder={t`Search for a user...`}value={searchTerm}- onChange={setSearchTerm}+ onValueChange={setSearchTerm}/></StyledSearchInputContainer><Table>diff --git a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminAiProviderDetail.tsx b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminAiProviderDetail.tsxindex 0dcc60cf9e6..3aa9551f2d7 100644--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminAiProviderDetail.tsx+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminAiProviderDetail.tsx@@ -350,7 +350,7 @@ export const SettingsAdminAiProviderDetail = () => {<SearchInputplaceholder={t`Search a model...`}value={searchQuery}- onChange={setSearchQuery}+ onValueChange={setSearchQuery}/>)}diff --git a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminChats.tsx b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminChats.tsxindex b122105861c..f6f488f7c2d 100644--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminChats.tsx+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminChats.tsx@@ -61,7 +61,7 @@ export const SettingsAdminChats = () => {<SearchInputplaceholder={t`Search by workspace, user email or thread id...`}value={searchQuery}- onChange={setSearchQuery}+ onValueChange={setSearchQuery}filterDropdown={(filterButton) => (<SettingsAdminChatsFilterDropdownfilterButton={filterButton}diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsxindex 10a3cd08191..ccbc92a4a5e 100644--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsx+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsx@@ -130,7 +130,7 @@ export const SettingsAgentSkillsTab = () => {<SearchInputplaceholder={t`Search a skill...`}value={searchTerm}- onChange={setSearchTerm}+ onValueChange={setSearchTerm}filterDropdown={(filterButton) => (<DropdownRootdropdownId="settings-skills-filter-dropdown"diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsxindex 71dfaf1d0b6..724f8abc34c 100644--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsx+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsx@@ -85,7 +85,7 @@ export const SettingsAgentToolsTab = () => {<SearchInputplaceholder={t`Search a tool...`}value={searchTerm}- onChange={setSearchTerm}+ onValueChange={setSearchTerm}filterDropdown={(filterButton) => (<DropdownRootdropdownId="settings-tools-filter-dropdown"diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationsTable.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationsTable.tsxindex 1a9f5bce2b4..47278dba187 100644--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationsTable.tsx+++ b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationsTable.tsx@@ -68,7 +68,7 @@ export const SettingsApplicationsTable = ({<SearchInputplaceholder={t`Search an application`}value={searchTerm}- onChange={setSearchTerm}+ onValueChange={setSearchTerm}/></StyledSearchInputContainer><Table>diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailContentTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailContentTab.tsxindex be3e2572058..eb9efd62829 100644--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailContentTab.tsx+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailContentTab.tsx@@ -225,7 +225,7 @@ export const SettingsApplicationDetailContentTab = ({<SearchInputplaceholder={t`Search...`}value={searchTerm}- onChange={setSearchTerm}+ onValueChange={setSearchTerm}/></Section.Root>diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsxindex 1560c1119ce..066c2c00804 100644--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx@@ -98,7 +98,7 @@ export const SettingsApplicationsAvailableTab = () => {<SearchInputplaceholder={t`Search an application`}value={searchTerm}- onChange={setSearchTerm}+ onValueChange={setSearchTerm}filterDropdown={(filterButton) => (<DropdownRoot dropdownId="marketplace-filter-dropdown" type="panel"><Dropdown.Trigger render={filterButton} />diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsDeveloperTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsDeveloperTab.tsxindex f7a257f9d2e..e1b58b6e27d 100644--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsDeveloperTab.tsx+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsDeveloperTab.tsx@@ -128,7 +128,7 @@ export const SettingsApplicationsDeveloperTab = () => {<SearchInputplaceholder={t`Search an application`}value={myAppsSearchTerm}- onChange={setMyAppsSearchTerm}+ onValueChange={setMyAppsSearchTerm}/></StyledSearchInputContainer><Table>diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldTable.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldTable.tsxindex 08954b43e9a..4e72addd656 100644--- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldTable.tsx+++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldTable.tsx@@ -171,7 +171,7 @@ export const SettingsObjectFieldTable = ({<SearchInputplaceholder={t`Search a field...`}value={searchTerm}- onChange={setSearchTerm}+ onValueChange={setSearchTerm}filterDropdown={(filterButton) => (<DropdownRootdropdownId="settings-fields-filter-dropdown"diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsxindex 534c9625044..6d56c49506e 100644--- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsx+++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsx@@ -160,7 +160,7 @@ export const SettingsObjectTable = ({<SearchInputplaceholder={t`Search for an object...`}value={searchTerm}- onChange={setSearchTerm}+ onValueChange={setSearchTerm}filterDropdown={(filterButton) => (<DropdownRootdropdownId="settings-objects-filter-dropdown"diff --git a/packages/twenty-front/src/pages/settings/members/tabs/SettingsWorkspaceMembersTeamTab.tsx b/packages/twenty-front/src/pages/settings/members/tabs/SettingsWorkspaceMembersTeamTab.tsxindex e76fcc0cca7..d87f23185bb 100644--- a/packages/twenty-front/src/pages/settings/members/tabs/SettingsWorkspaceMembersTeamTab.tsx+++ b/packages/twenty-front/src/pages/settings/members/tabs/SettingsWorkspaceMembersTeamTab.tsx@@ -167,7 +167,7 @@ export const SettingsWorkspaceMembersTeamTab = () => {<StyledSearchContainer><SearchInputvalue={searchFilter}- onChange={handleSearchChange}+ onValueChange={handleSearchChange}placeholder={t`Search a team member...`}/><DropdownRoot type="menu" dropdownId="workspace-members-open-dropdown">diff --git a/packages/twenty-ui/docs/searchInputPropDescriptions.ts b/packages/twenty-ui/docs/searchInputPropDescriptions.tsindex 1afc606ae89..fb940145d9f 100644--- a/packages/twenty-ui/docs/searchInputPropDescriptions.ts+++ b/packages/twenty-ui/docs/searchInputPropDescriptions.ts@@ -4,15 +4,17 @@ import { type SearchInput } from '../src/components/input/SearchInput/SearchInpuexport const SEARCH_INPUT_PROP_DESCRIPTIONS = {value: 'Current search text.',- onChange:- 'Called with the new text, not a DOM change event. The application owns filtering.',+ onValueChange: 'Called with the new text. The application owns filtering.',+ onChange: 'Native input change event handler.',+ ref: 'Ref to the native input element.',+ size: 'Visual size of the input group and optional filter button.',placeholder:'Hint shown when the input is empty. Also used as the accessible name if no explicit label is supplied.',filterDropdown: 'Renders a filter popup around the supplied filter button.',autoFocus: 'Focuses the input when mounted.',disabled:'Disables the text input. Configure filter popup controls separately.',- className: 'Class applied to the wrapper.',+ className: 'Class applied to the input.',id: 'Input ID, generated when omitted.',filterButtonAriaLabel: 'Accessible label for the optional filter button.','aria-label': 'Accessible name when aria-labelledby is absent.',diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex 522d490e108..5eb56cb052c 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -8472,10 +8472,17 @@},{"name": "className",- "type": "string",+ "type": "string | ((state: InputState) => string | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "Class applied to the input."+ },+ {+ "name": "defaultValue",+ "type": "string | number | readonly string[]","required": false,"defaultValue": null,- "description": "Class applied to the wrapper."+ "description": "The default value of the input. Use when uncontrolled."},{"name": "disabled",@@ -8507,10 +8514,17 @@},{"name": "onChange",- "type": "(value: string) => void",- "required": true,+ "type": "((event: BaseUIEvent<ChangeEvent<HTMLInputElement, HTMLInputElement>>) => void)",+ "required": false,+ "defaultValue": null,+ "description": "Native input change event handler."+ },+ {+ "name": "onValueChange",+ "type": "((value: string, eventDetails: { reason: \"none\"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)",+ "required": false,"defaultValue": null,- "description": "Called with the new text, not a DOM change event. The application owns filtering."+ "description": "Called with the new text. The application owns filtering."},{"name": "placeholder",@@ -8519,10 +8533,38 @@"defaultValue": null,"description": "Hint shown when the input is empty. Also used as the accessible name if no explicit label is supplied."},+ {+ "name": "ref",+ "type": "Ref<HTMLInputElement>",+ "required": false,+ "defaultValue": null,+ "description": "Ref to the native input element."+ },+ {+ "name": "render",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, InputState>",+ "required": false,+ "defaultValue": null,+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."+ },+ {+ "name": "size",+ "type": "\"md\" | \"sm\"",+ "required": false,+ "defaultValue": "md",+ "description": "Visual size of the input group and optional filter button."+ },+ {+ "name": "style",+ "type": "CSSProperties | ((state: InputState) => CSSProperties | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."+ },{"name": "value",- "type": "string",- "required": true,+ "type": "string | number | readonly string[]",+ "required": false,"defaultValue": null,"description": "Current search text."}diff --git a/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx b/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsxindex 82fa370055d..8c2b16e1aa4 100644--- a/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx+++ b/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx@@ -79,7 +79,7 @@ export const NativeNames: Story = {<Text id="search-label">Find contacts</Text><SearchInputvalue=""- onChange={fn()}+ onValueChange={fn()}placeholder="Search everything"aria-label="Fallback search"aria-labelledby="search-label"diff --git a/packages/twenty-ui/src/components/input/SearchInput/SearchInput.module.scss b/packages/twenty-ui/src/components/input/SearchInput/SearchInput.module.scssindex 6a91b88f2a2..caf291f279a 100644--- a/packages/twenty-ui/src/components/input/SearchInput/SearchInput.module.scss+++ b/packages/twenty-ui/src/components/input/SearchInput/SearchInput.module.scss@@ -9,55 +9,16 @@@include square-button;}-.filterIcon {- display: flex;-}--.inputContainer {- align-items: center;- background-color: var(--t-background-transparent-lighter);- border: 1px solid var(--t-border-color-medium);- border-radius: var(--t-border-radius-md);+.inputGroup {box-sizing: border-box;- display: flex;flex: 1;- gap: var(--t-spacing-1);- height: 32px;- padding: 0 var(--t-spacing-2);+ min-width: 0;}-.inputContainer:focus-within {- border-color: var(--t-color-blue);-}--.iconContainer {- align-items: center;+.searchIcon {color: var(--t-font-color-light);- display: flex;- justify-content: center;}-.iconContainer[data-focused] {+.inputGroup:focus-within .searchIcon {color: var(--t-font-color-secondary);}--.input {- background: transparent;- border: none;- color: var(--t-font-color-primary);- flex: 1;- font-family: var(--t-font-family);- font-size: var(--t-font-size-md);- font-weight: var(--t-font-weight-regular);- outline: none;- width: 100%;-}--.input::placeholder {- color: var(--t-font-color-light);- font-weight: var(--t-font-weight-medium);-}--.input:disabled {- color: var(--t-font-color-tertiary);-}diff --git a/packages/twenty-ui/src/components/input/SearchInput/SearchInput.module.scss.d.ts b/packages/twenty-ui/src/components/input/SearchInput/SearchInput.module.scss.d.tsindex 2504bcbe57a..7dabe4c96e1 100644--- a/packages/twenty-ui/src/components/input/SearchInput/SearchInput.module.scss.d.ts+++ b/packages/twenty-ui/src/components/input/SearchInput/SearchInput.module.scss.d.ts@@ -1,9 +1,7 @@declare const classNames: {readonly wrapper: 'wrapper';readonly filterButton: 'filterButton';- readonly filterIcon: 'filterIcon';- readonly inputContainer: 'inputContainer';- readonly iconContainer: 'iconContainer';- readonly input: 'input';+ readonly inputGroup: 'inputGroup';+ readonly searchIcon: 'searchIcon';};export default classNames;diff --git a/packages/twenty-ui/src/components/input/SearchInput/SearchInput.tsx b/packages/twenty-ui/src/components/input/SearchInput/SearchInput.tsxindex c0c5f70f7d5..66a4f5be96b 100644--- a/packages/twenty-ui/src/components/input/SearchInput/SearchInput.tsx+++ b/packages/twenty-ui/src/components/input/SearchInput/SearchInput.tsx@@ -1,70 +1,65 @@-import { Input } from '@base-ui/react/input';-import { clsx } from 'clsx';-import { useId, useState } from 'react';+import { isNonEmptyString } from '@sniptt/guards';+import { useId } from 'react';import { type SearchInputProps } from './types/SearchInputProps';import { IconFilter, IconSearch } from '@ui/icon';import { Button } from '@ui/primitives/input/Button/Button';+import { Input } from '@ui/primitives/input/Input/Input';+import { InputGroup } from '@ui/primitives/input/InputGroup/InputGroup';import { useTheme } from '@ui/theme';import styles from './SearchInput.module.scss';export const SearchInput = ({- value,- onChange,placeholder,filterDropdown,- autoFocus,- disabled,- className,+ size = 'md',id,filterButtonAriaLabel = 'Filter','aria-label': ariaLabel,'aria-labelledby': ariaLabelledby,+ ...props}: SearchInputProps) => {const theme = useTheme();- const [isFocused, setIsFocused] = useState(false);const generatedId = useId();const inputId = id ?? generatedId;const filterButton = (<Buttonvariant="outline"+ size={size}aria-label={filterButtonAriaLabel}- startIcon={- <span className={styles.filterIcon}>- <IconFilter size={theme.icon.size.md} />- </span>- }+ startIcon={<IconFilter size={theme.icon.size.md} />}className={styles.filterButton}/>);return (- <div className={clsx(styles.wrapper, className)}>- <div className={styles.inputContainer}>- <div- className={styles.iconContainer}- data-focused={isFocused || undefined}- aria-hidden- >- <IconSearch size={theme.icon.size.md} />- </div>+ <div className={styles.wrapper}>+ <InputGroup+ className={styles.inputGroup}+ size={size}+ startElement={+ <IconSearch+ className={styles.searchIcon}+ size={theme.icon.size.md}+ aria-hidden+ />+ }+ ><Input+ {...props}id={inputId}- className={styles.input}- value={value}- onValueChange={(newValue) => onChange(newValue)}- onFocus={() => setIsFocused(true)}- onBlur={() => setIsFocused(false)}placeholder={placeholder}- autoFocus={autoFocus}- disabled={disabled}- aria-label={ariaLabelledby ? undefined : (ariaLabel ?? placeholder)}+ aria-label={+ isNonEmptyString(ariaLabelledby)+ ? undefined+ : (ariaLabel ?? placeholder)+ }aria-labelledby={ariaLabelledby}/>- </div>- {filterDropdown && filterDropdown(filterButton)}+ </InputGroup>+ {filterDropdown?.(filterButton)}</div>);};diff --git a/packages/twenty-ui/src/components/input/SearchInput/__stories__/SearchInput.interactions.stories.tsx b/packages/twenty-ui/src/components/input/SearchInput/__stories__/SearchInput.interactions.stories.tsxnew file mode 100644index 00000000000..6a2213492d3--- /dev/null+++ b/packages/twenty-ui/src/components/input/SearchInput/__stories__/SearchInput.interactions.stories.tsx@@ -0,0 +1,223 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { useRef, useState } from 'react';+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';++import { Dropdown } from '@ui/components/navigation/Dropdown/Dropdown';+import { Button } from '@ui/primitives/input/Button/Button';+import { Field } from '@ui/primitives/input/Field/Field';+import { Input } from '@ui/primitives/input/Input/Input';+import { Text } from '@ui/primitives/typography/Text/Text';+import { ComponentDecorator } from '@ui/testing';++import { SearchInput } from '../SearchInput';+import { SearchInputExample } from './SearchInputExample';++const onChange = fn();+const onFocus = fn();+const onBlur = fn();+const onParentKeyDown = fn();+const onParentClick = fn();+const onTriggerClick = fn();+const onSubmit = fn();++const NativeInputExample = () => {+ const inputRef = useRef<HTMLInputElement>(null);++ return (+ <form+ onKeyDown={onParentKeyDown}+ onSubmit={(event) => {+ event.preventDefault();+ onSubmit(new FormData(event.currentTarget).get('search'));+ }}+ >+ <Text id="people-search-label">Find people</Text>+ <SearchInputExample+ ref={inputRef}+ id="people-search"+ name="search"+ aria-labelledby="people-search-label"+ aria-label="Fallback search"+ placeholder="Name or email"+ autoComplete="off"+ onChange={onChange}+ onFocus={onFocus}+ onBlur={onBlur}+ onKeyDown={(event) => event.stopPropagation()}+ />+ <Button onClick={() => inputRef.current?.focus()}>Focus search</Button>+ <Button type="submit">Search people</Button>+ </form>+ );+};++type FilterPanelExampleProps = {+ filterDisabled?: boolean;+ searchDisabled?: boolean;+};++const FilterPanelExample = ({+ filterDisabled = false,+ searchDisabled = false,+}: FilterPanelExampleProps) => {+ const [open, setOpen] = useState(false);+ const [search, setSearch] = useState('');+ const triggerRef = useRef<HTMLButtonElement>(null);++ return (+ <form+ onClick={onParentClick}+ onKeyDown={onParentKeyDown}+ onSubmit={(event) => {+ event.preventDefault();+ onSubmit();+ }}+ >+ <SearchInput+ placeholder="Search people"+ value={search}+ onValueChange={setSearch}+ disabled={searchDisabled}+ filterButtonAriaLabel="Filter people"+ filterDropdown={(filterButton) => (+ <Dropdown.Root type="panel" open={open} onOpenChange={setOpen}>+ <Dropdown.Trigger+ render={filterButton}+ ref={triggerRef}+ onClick={onTriggerClick}+ disabled={filterDisabled}+ />+ <Dropdown.Content>+ <Dropdown.Section>+ <Field.Root>+ <Field.Label style={{ color: 'var(--t-font-color-primary)' }}>+ Company+ </Field.Label>+ <Input />+ </Field.Root>+ </Dropdown.Section>+ </Dropdown.Content>+ </Dropdown.Root>+ )}+ />+ <Button onClick={() => triggerRef.current?.focus()}>Focus filters</Button>+ </form>+ );+};++const meta: Meta = {+ title: 'UI/Input/SearchInput/Interactions',+ tags: ['!autodocs'],+ decorators: [ComponentDecorator],+ beforeEach: () => {+ onChange.mockClear();+ onFocus.mockClear();+ onBlur.mockClear();+ onParentKeyDown.mockClear();+ onParentClick.mockClear();+ onTriggerClick.mockClear();+ onSubmit.mockClear();+ },+};++export default meta;+type Story = StoryObj;++export const NativeInput: Story = {+ render: () => <NativeInputExample />,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const input = canvas.getByRole('textbox', { name: 'Find people' });++ await userEvent.click(canvas.getByRole('button', { name: 'Focus search' }));+ expect(input).toHaveFocus();+ expect(onFocus).toHaveBeenCalledOnce();+ expect(input).toHaveAttribute('id', 'people-search');+ expect(input).toHaveAttribute('autocomplete', 'off');++ await userEvent.type(input, 'Ada');+ expect(input).toHaveValue('Ada');+ expect(onChange).toHaveBeenLastCalledWith(+ expect.objectContaining({ target: input, type: 'change' }),+ );+ expect(onParentKeyDown).not.toHaveBeenCalled();++ await userEvent.click(+ canvas.getByRole('button', { name: 'Search people' }),+ );+ expect(onSubmit).toHaveBeenCalledWith('Ada');+ expect(onBlur).toHaveBeenCalledOnce();+ },+};++export const FilterPanel: Story = {+ render: () => <FilterPanelExample />,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const body = within(canvasElement.ownerDocument.body);+ const input = canvas.getByRole('textbox', { name: 'Search people' });+ const trigger = canvas.getByRole('button', { name: 'Filter people' });++ await userEvent.type(input, 'Ada');+ expect(input).toHaveValue('Ada');+ await userEvent.click(+ canvas.getByRole('button', { name: 'Focus filters' }),+ );+ expect(trigger).toHaveFocus();+ onParentClick.mockClear();++ await userEvent.keyboard('{Enter}');+ expect(onTriggerClick).toHaveBeenCalledOnce();+ expect(onParentClick).not.toHaveBeenCalled();+ expect(onSubmit).not.toHaveBeenCalled();+ await waitFor(() =>+ expect(body.getByRole('dialog', { name: 'Filter people' })).toBeVisible(),+ );+ const companyInput = body.getByRole('textbox', { name: 'Company' });+ await waitFor(() => expect(companyInput).toHaveFocus());+ await userEvent.type(companyInput, 'Acme');+ expect(companyInput).toHaveValue('Acme');++ await userEvent.keyboard('{Escape}');+ await waitFor(() =>+ expect(body.queryByRole('dialog')).not.toBeInTheDocument(),+ );+ await waitFor(() => expect(trigger).toHaveFocus());+ expect(input).toHaveValue('Ada');+ await userEvent.type(input, ' Lovelace');+ expect(input).toHaveValue('Ada Lovelace');+ },+};++export const DisabledSearch: Story = {+ render: () => <FilterPanelExample searchDisabled />,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const body = within(canvasElement.ownerDocument.body);++ expect(+ canvas.getByRole('textbox', { name: 'Search people' }),+ ).toBeDisabled();+ await userEvent.click(+ canvas.getByRole('button', { name: 'Filter people' }),+ );+ await waitFor(() =>+ expect(body.getByRole('dialog', { name: 'Filter people' })).toBeVisible(),+ );+ },+};++export const DisabledFilter: Story = {+ render: () => <FilterPanelExample filterDisabled />,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const body = within(canvasElement.ownerDocument.body);+ const trigger = canvas.getByRole('button', { name: 'Filter people' });++ expect(trigger).toBeDisabled();+ await userEvent.click(trigger);+ expect(body.queryByRole('dialog')).not.toBeInTheDocument();+ expect(onTriggerClick).not.toHaveBeenCalled();+ expect(onSubmit).not.toHaveBeenCalled();+ },+};diff --git a/packages/twenty-ui/src/components/input/SearchInput/__stories__/SearchInput.stories.tsx b/packages/twenty-ui/src/components/input/SearchInput/__stories__/SearchInput.stories.tsxindex 74a17b93705..de9316d7699 100644--- a/packages/twenty-ui/src/components/input/SearchInput/__stories__/SearchInput.stories.tsx+++ b/packages/twenty-ui/src/components/input/SearchInput/__stories__/SearchInput.stories.tsx@@ -1,44 +1,18 @@import { type Meta, type StoryObj } from '@storybook/react-vite';import { ComponentDecorator } from '@ui/testing';-import { useState } from 'react';+import { Dropdown } from '@ui/components/navigation/Dropdown/Dropdown';+import { SettingsRow } from '@ui/components/input/SettingsRow/SettingsRow';-import { SearchInput } from '@ui/components/input/SearchInput/SearchInput';+import { SearchInputExample } from './SearchInputExample';-type InteractiveSearchInputProps = {- placeholder?: string;- disabled?: boolean;- autoFocus?: boolean;- className?: string;-};--const InteractiveSearchInput = ({- placeholder,- disabled,- autoFocus,- className,-}: InteractiveSearchInputProps) => {- const [value, setValue] = useState('');-- return (- <SearchInput- value={value}- onChange={setValue}- placeholder={placeholder}- disabled={disabled}- autoFocus={autoFocus}- className={className}- />- );-};--const meta: Meta<typeof InteractiveSearchInput> = {+const meta: Meta<typeof SearchInputExample> = {title: 'UI/Input/SearchInput',- component: InteractiveSearchInput,+ component: SearchInputExample,decorators: [ComponentDecorator],};export default meta;-type Story = StoryObj<typeof InteractiveSearchInput>;+type Story = StoryObj<typeof SearchInputExample>;export const Default: Story = {args: {@@ -52,3 +26,27 @@ export const Disabled: Story = {disabled: true,},};++export const Compact: Story = {+ args: {+ placeholder: 'Search...',+ size: 'sm',+ },+};++export const WithFilter: Story = {+ args: {+ placeholder: 'Search people...',+ filterButtonAriaLabel: 'Filter people',+ filterDropdown: (filterButton) => (+ <Dropdown.Root type="panel">+ <Dropdown.Trigger render={filterButton} />+ <Dropdown.Content align="end">+ <Dropdown.Section>+ <SettingsRow defaultChecked>Include inactive people</SettingsRow>+ </Dropdown.Section>+ </Dropdown.Content>+ </Dropdown.Root>+ ),+ },+};diff --git a/packages/twenty-ui/src/components/input/SearchInput/__stories__/SearchInputExample.tsx b/packages/twenty-ui/src/components/input/SearchInput/__stories__/SearchInputExample.tsxnew file mode 100644index 00000000000..2c0574fc9a1--- /dev/null+++ b/packages/twenty-ui/src/components/input/SearchInput/__stories__/SearchInputExample.tsx@@ -0,0 +1,10 @@+import { useState } from 'react';++import { SearchInput } from '../SearchInput';+import { type SearchInputProps } from '../types/SearchInputProps';++export const SearchInputExample = (props: SearchInputProps) => {+ const [value, setValue] = useState('');++ return <SearchInput value={value} onValueChange={setValue} {...props} />;+};diff --git a/packages/twenty-ui/src/components/input/SearchInput/__tests__/SearchInput.test.tsx b/packages/twenty-ui/src/components/input/SearchInput/__tests__/SearchInput.test.tsxnew file mode 100644index 00000000000..e9256ad400c--- /dev/null+++ b/packages/twenty-ui/src/components/input/SearchInput/__tests__/SearchInput.test.tsx@@ -0,0 +1,10 @@+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';++import { SearchInput } from '../SearchInput';++runComponentConformance({+ name: 'SearchInput',+ element: <SearchInput aria-label="Search people" />,+ refInstanceOf: HTMLInputElement,+ renderPropTagName: 'input',+});diff --git a/packages/twenty-ui/src/components/input/SearchInput/types/SearchInputProps.ts b/packages/twenty-ui/src/components/input/SearchInput/types/SearchInputProps.tsindex 0e3601df897..7efe3d8a99e 100644--- a/packages/twenty-ui/src/components/input/SearchInput/types/SearchInputProps.ts+++ b/packages/twenty-ui/src/components/input/SearchInput/types/SearchInputProps.ts@@ -1,15 +1,8 @@import { type ReactElement, type ReactNode } from 'react';-export type SearchInputProps = {- value: string;- onChange: (value: string) => void;- placeholder?: string;+import { type InputProps } from '@ui/primitives/input/Input/types/InputProps';++export type SearchInputProps = InputProps & {filterDropdown?: (filterButton: ReactElement) => ReactNode;- autoFocus?: boolean;- disabled?: boolean;- className?: string;- id?: string;filterButtonAriaLabel?: string;- 'aria-label'?: string;- 'aria-labelledby'?: string;};