Skip to content

The open alternative to Salesforce, designed for AI.

Unify CurrencyPicker shorthand and parts (#28156)

Raphaël Bosia1e048f44426
diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/currency-picker.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/currency-picker.mdx
index 4b9b2929f8f..a5d219dbc07 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/input/currency-picker.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/input/currency-picker.mdx
@@ -11,15 +11,168 @@
* npx nx generate:ui twenty-docs
*/}
+<ParamField body="children" type="ReactNode">
+ Caller-owned trigger content that overrides the selected value display.
+</ParamField>
+
+<ParamField body="className" type="string | ((state: PopoverTriggerState) =&gt; string | undefined)">
+ Class applied to the trigger button.
+</ParamField>
+
+<ParamField body="closeOnSelect" type="boolean">
+ Whether committing an enabled option closes the dropdown. Defaults to true. A canceled selection never closes automatically.
+</ParamField>
+
+<ParamField body="contentProps" type="Omit&lt;DropdownContentProps, &quot;children&quot;&gt;">
+ Dropdown popup props, including placement, width, and accessible attributes.
+</ParamField>
+
+<ParamField body="currencies" type="readonly CurrencyPickerOption[]" required>
+ Available currencies in display order. Each code is a unique stable identifier; name and optional symbol are caller-owned data. A currency can be disabled.
+</ParamField>
+
+<ParamField body="defaultOpen" type="boolean">
+ Whether the popup is initially open when uncontrolled.
+</ParamField>
+
+<ParamField body="defaultValue" type="string | null" default="null">
+ Initial uncontrolled currency code, or null for an empty selection. Defaults to null.
+</ParamField>
+
+<ParamField body="disabled" type="boolean" default="false">
+ Disables opening, search, and every currency option.
+</ParamField>
+
+<ParamField body="getOptionLabel" type="((currency: CurrencyPickerOption) =&gt; ReactNode)" default="Name (CODE)">
+ Returns caller-owned content for a currency option. Defaults to Name (CODE). Display content does not change the search text.
+</ParamField>
+
+<ParamField body="getSearchText" type="((currency: CurrencyPickerOption) =&gt; string)" default="Name (CODE) and symbol">
+ Returns searchable text for a currency. Defaults to Name (CODE) and its optional symbol. Search trims the query and matches without case sensitivity.
+</ParamField>
+
+<ParamField body="id" type="string">
+ ID forwarded to the trigger button.
+</ParamField>
+
+<ParamField body="nativeButton" type="boolean" default="true">
+ Whether render composes a native button. Set false for a custom non-button element so Base UI supplies button interaction.
+</ParamField>
+
+<ParamField body="onEscapeKeyDown" type="((event: DropdownDismissEvent) =&gt; void)">
+ Called before Escape closes the popup. Call event.preventDefault() to keep it open.
+</ParamField>
+
+<ParamField body="onInteractOutside" type="((event: DropdownDismissEvent) =&gt; void)">
+ Called before an outside press or Tab out closes the popup. Call event.preventDefault() to keep it open.
+</ParamField>
+
+<ParamField body="onOpenChange" type="((open: boolean) =&gt; void)">
+ Called with the next open state when the popup opens or closes.
+</ParamField>
+
+<ParamField body="onValueChange" type="((value: string | null, eventDetails: DropdownSelectionGroupChangeEventDetails) =&gt; void)">
+ Called with the next code or null and cancellable Dropdown selection details: event, reason, trigger, cancel and isCanceled. Calling cancel() preserves selection and prevents automatic close. Repeated single selection does not emit a change.
+</ParamField>
+
+<ParamField body="open" type="boolean">
+ Whether the popup is open. Use with onOpenChange to control it.
+</ParamField>
+
+<ParamField body="optionsProps" type="CurrencyPickerOptionsProps">
+ Props for the options wrapper div, listLabel, and search behavior. Native input customization belongs in optionsProps.searchProps.
+</ParamField>
+
+<ParamField body="placeholder" type="ReactNode">
+ Trigger content displayed when the selected value is null.
+</ParamField>
+
+<ParamField body="ref" type="Ref&lt;HTMLButtonElement&gt;">
+ Ref to the trigger button, or the element composed through render.
+</ParamField>
+
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, PopoverTriggerState&gt;">
+ Replaces the native trigger button. Forward the supplied props and ref when rendering a custom component.
+</ParamField>
+
+<ParamField body="renderValue" type="((state: CurrencyPickerState) =&gt; ReactNode)">
+ Returns selected trigger content from &#123; value, selectedCurrency, disabled &#125;. The default display is the raw code, or the trigger placeholder when null. Trigger children override it.
+</ParamField>
+
+<ParamField body="selectedFirst" type="boolean" default="false">
+ Moves the matching selected currency before other results. Defaults to false, preserving catalogue order.
+</ParamField>
+
+<ParamField body="style" type="CSSProperties | ((state: PopoverTriggerState) =&gt; CSSProperties | undefined)">
+ Inline styles applied to the trigger button.
+</ParamField>
+
+<ParamField body="triggerProps" type="CurrencyPickerTriggerProps">
+ Props for the trigger button, including native attributes, ref, render, placeholder, and caller-owned children. These override shorthand trigger props.
+</ParamField>
+
+<ParamField body="value" type="string | null">
+ Controlled currency code or null for an empty selection. Undefined leaves selection uncontrolled. Empty and unknown strings remain identifiers.
+</ParamField>
+
+### CurrencyPicker.Root
+
+<ParamField body="Root.children" type="ReactNode | ((state: CurrencyPickerState) =&gt; ReactNode)" required>
+ Picker parts and supporting content, or a render function receiving &#123; value, selectedCurrency, disabled &#125;. Root owns selection and prepared data without adding a DOM element.
+</ParamField>
+
+<ParamField body="Root.closeOnSelect" type="boolean">
+ Whether committing an enabled option closes the dropdown. Defaults to true. A canceled selection never closes automatically.
+</ParamField>
+
+<ParamField body="Root.currencies" type="readonly CurrencyPickerOption[]" required>
+ Available currencies in display order. Each code is a unique stable identifier; name and optional symbol are caller-owned data. A currency can be disabled.
+</ParamField>
+
+<ParamField body="Root.defaultValue" type="string | null" default="null">
+ Initial uncontrolled currency code, or null for an empty selection. Defaults to null.
+</ParamField>
+
+<ParamField body="Root.disabled" type="boolean" default="false">
+ Disables the trigger, search input, and every currency option.
+</ParamField>
+
+<ParamField body="Root.getOptionLabel" type="((currency: CurrencyPickerOption) =&gt; ReactNode)" default="Name (CODE)">
+ Returns caller-owned content for a currency option. Defaults to Name (CODE). Display content does not change the search text.
+</ParamField>
+
+<ParamField body="Root.getSearchText" type="((currency: CurrencyPickerOption) =&gt; string)" default="Name (CODE) and symbol">
+ Returns searchable text for a currency. Defaults to Name (CODE) and its optional symbol. Search trims the query and matches without case sensitivity.
+</ParamField>
+
+<ParamField body="Root.onValueChange" type="((value: string | null, eventDetails: DropdownSelectionGroupChangeEventDetails) =&gt; void)">
+ Called with the next code or null and cancellable Dropdown selection details: event, reason, trigger, cancel and isCanceled. Calling cancel() preserves selection and prevents automatic close. Repeated single selection does not emit a change.
+</ParamField>
+
+<ParamField body="Root.renderValue" type="((state: CurrencyPickerState) =&gt; ReactNode)">
+ Returns selected trigger content from &#123; value, selectedCurrency, disabled &#125;. The default display is the raw code, or the trigger placeholder when null. Trigger children override it.
+</ParamField>
+
+<ParamField body="Root.selectedFirst" type="boolean" default="false">
+ Moves the matching selected currency before other results. Defaults to false, preserving catalogue order.
+</ParamField>
+
+<ParamField body="Root.value" type="string | null">
+ Controlled currency code or null for an empty selection. Undefined leaves selection uncontrolled. Empty and unknown strings remain identifiers.
+</ParamField>
+
### CurrencyPicker.Trigger
+<ParamField body="Trigger.children" type="ReactNode">
+ Caller-owned trigger content that overrides the selected value display.
+</ParamField>
+
<ParamField body="Trigger.className" type="string | ((state: PopoverTriggerState) =&gt; string | undefined)">
- CSS class applied to the element, or a function that
- returns a class based on the component's state.
+ Class applied to the trigger button.
</ParamField>
-<ParamField body="Trigger.disabled" type="boolean">
- Disables opening the picker.
+<ParamField body="Trigger.disabled" type="boolean" default="false">
+ Additionally disables the native trigger button. Root disabled state always takes precedence.
</ParamField>
<ParamField body="Trigger.id" type="string">
@@ -27,9 +180,15 @@
</ParamField>
<ParamField body="Trigger.nativeButton" type="boolean" default="true">
- Whether the component renders a native `<button>` element when replacing it
- via the `render` prop.
- Set to `false` if the rendered element is not a button (e.g. `<div>`).
+ Whether render composes a native button. Set false for a custom non-button element so Base UI supplies button interaction.
+</ParamField>
+
+<ParamField body="Trigger.placeholder" type="ReactNode">
+ Trigger content displayed when the selected value is null.
+</ParamField>
+
+<ParamField body="Trigger.ref" type="Ref&lt;HTMLButtonElement&gt;">
+ Ref to the trigger button, or the element composed through render.
</ParamField>
<ParamField body="Trigger.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, PopoverTriggerState&gt;">
@@ -37,40 +196,47 @@
</ParamField>
<ParamField body="Trigger.style" type="CSSProperties | ((state: PopoverTriggerState) =&gt; CSSProperties | undefined)">
- Style applied to the element, or a function that
- returns a style object based on the component's state.
-</ParamField>
-
-<ParamField body="Trigger.value" type="string" required>
- Required currency code displayed beside the chevron. The application chooses its initial value and any fallback.
+ Inline styles applied to the trigger button.
</ParamField>
### CurrencyPicker.Options
-<ParamField body="Options.currencies" type="readonly CurrencyPickerOption[]" required>
- Available currency codes and names, in catalogue order. Each code must be unique. An option can be disabled.
+<ParamField body="Options.className" type="string">
+ Class applied to the options wrapper div.
</ParamField>
<ParamField body="Options.disabled" type="boolean" default="false">
- Disables search and every currency option.
+ Additionally disables search and every currency option. Root disabled state always takes precedence.
</ParamField>
-<ParamField body="Options.emptyLabel" type="string" default="No results">
- Text announced when no currencies match. Defaults to No results.
+<ParamField body="Options.emptyLabel" type="ReactNode" default="No results">
+ Content announced when no currencies match. Defaults to No results.
</ParamField>
-<ParamField body="Options.onValueChange" type="(code: string) =&gt; void" required>
- Called with the code chosen by pointer or keyboard. The application updates the selected value.
+<ParamField body="Options.listLabel" type="string">
+ Accessible name for the selection listbox. Defaults to the registered Dropdown title or trigger name. Native accessible attributes on Options target only its wrapper.
+</ParamField>
+
+<ParamField body="Options.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the options wrapper div, or the element composed through render.
</ParamField>
<ParamField body="Options.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
- Replaces the non-interactive root div. Forward the supplied props and ref when rendering a custom component.
+ Replaces the non-interactive wrapper div. Forward the supplied props and ref when rendering a custom component. Use searchProps.render to customize the input.
+</ParamField>
+
+<ParamField body="Options.searchable" type="boolean" default="true">
+ Renders a search input above the options. Defaults to true.
</ParamField>
<ParamField body="Options.searchLabel" type="string" default="Search">
Search placeholder and accessible name. Defaults to Search.
</ParamField>
-<ParamField body="Options.value" type="string">
- Selected currency code. Its matching row appears first and is marked pressed.
+<ParamField body="Options.searchProps" type="DropdownSearchProps">
+ Native input attributes, ref, render, and controlled or uncontrolled query props forwarded to Dropdown.Search. Use value with onValueChange or defaultValue.
+</ParamField>
+
+<ParamField body="Options.style" type="CSSProperties">
+ Inline styles applied to the options wrapper div.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx
index 399c862755d..519d19316fa 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx
@@ -15,7 +15,7 @@
Default, danger, or placeholder row styling.
</ParamField>
-<ParamField body="avatar" type="Pick&lt;AvatarProps, &quot;name&quot; | &quot;size&quot; | &quot;shape&quot; | &quot;src&quot; | &quot;colorSeed&quot;&gt; | null">
+<ParamField body="avatar" type="Pick&lt;AvatarProps, &quot;name&quot; | &quot;size&quot; | &quot;src&quot; | &quot;shape&quot; | &quot;colorSeed&quot;&gt; | null">
Avatar name, source, color seed, size, and shape. Omit to hide the avatar.
</ParamField>
diff --git a/packages/twenty-docs/ui/components/input/currency-picker.mdx b/packages/twenty-docs/ui/components/input/currency-picker.mdx
index 1e0d2459fe3..0294dab6b08 100644
--- a/packages/twenty-docs/ui/components/input/currency-picker.mdx
+++ b/packages/twenty-docs/ui/components/input/currency-picker.mdx
@@ -1,12 +1,12 @@
---
title: CurrencyPicker
-description: A compact currency trigger and searchable currency options for picker dropdowns.
+description: Choose a currency with a complete picker or compose its parts in a dropdown.
---
import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import CurrencyPickerReference from '/snippets/ui/generated/components/input/currency-picker.mdx';
-`CurrencyPicker` provides a compact selected currency code and searchable currency options. Import it from `twenty-ui/components` and compose it inside a [Dropdown](/ui/components/navigation/dropdown) with `type="picker"`.
+`CurrencyPicker` combines a compact currency trigger, searchable options, and a [Dropdown](/ui/components/navigation/dropdown). Supply a currency catalogue and use one component for ordinary selection. Compose `Root`, `Trigger`, and `Options` with Dropdown when the popup needs other content or pages.
<StoryEmbed
storyId="ui-input-currencypicker--display"
@@ -16,62 +16,135 @@ import CurrencyPickerReference from '/snippets/ui/generated/components/input/cur
## Usage
-Supply the available currencies and the selected code. `Options` calls `onValueChange` with the chosen code. The trigger requires a currency code through `value`; your application chooses its initial value and any fallback.
+Each currency has a unique `code`, a `name`, and optional `symbol` and `disabled` properties. The code is the stable selection identifier. The picker does not ship a currency catalogue or choose an application default.
+
+```tsx
+import { CurrencyPicker } from 'twenty-ui/components/input';
+
+const CURRENCIES = [
+ { code: 'EUR', name: 'Euro', symbol: '€' },
+ { code: 'USD', name: 'US Dollar', symbol: '$' },
+];
+
+export const InvoiceCurrency = () => (
+ <CurrencyPicker
+ currencies={CURRENCIES}
+ defaultValue="USD"
+ aria-label="Invoice currency"
+ optionsProps={{
+ searchLabel: 'Search currencies',
+ emptyLabel: 'No currencies found',
+ }}
+ contentProps={{ width: 280 }}
+ />
+);
+```
+
+Use `defaultValue` for uncontrolled selection. For controlled selection, pass `value` and update it from `onValueChange`. The callback receives the next code or `null` and Dropdown selection details containing `event`, `reason`, `trigger`, `cancel`, and `isCanceled`. Call `details.cancel()` to preserve the current selection and keep the popup open. Selecting the current code does not emit another change.
+
+`null` clears the selection. An empty string remains a valid code and does not clear it. An unknown value stays unchanged and appears as its raw code in the trigger; it does not add an option to the catalogue. A later controlled update or catalogue change updates the trigger and selected row.
```tsx
import { useState } from 'react';
import { CurrencyPicker } from 'twenty-ui/components/input';
-import { Dropdown } from 'twenty-ui/components/navigation';
+import { Button } from 'twenty-ui/primitives/input';
const CURRENCIES = [
{ code: 'EUR', name: 'Euro' },
{ code: 'USD', name: 'US Dollar' },
];
-export const InvoiceCurrency = () => {
- const [currencyCode, setCurrencyCode] = useState('USD');
+export const ClearableCurrency = () => {
+ const [value, setValue] = useState<string | null>('USD');
return (
- <Dropdown.Root type="picker">
- <CurrencyPicker.Trigger
- value={currencyCode}
- aria-label={`Invoice currency: ${currencyCode}`}
+ <>
+ <CurrencyPicker
+ currencies={CURRENCIES}
+ value={value}
+ onValueChange={setValue}
+ aria-label="Invoice currency"
+ triggerProps={{ placeholder: 'Choose a currency' }}
/>
- <Dropdown.Content aria-label="Invoice currency" width={280}>
- <CurrencyPicker.Options
- currencies={CURRENCIES}
- value={currencyCode}
- onValueChange={setCurrencyCode}
- searchLabel="Search currencies"
- emptyLabel="No currencies found"
- />
- </Dropdown.Content>
- </Dropdown.Root>
+ <Button onClick={() => setValue(null)}>Clear currency</Button>
+ </>
);
};
```
-`Trigger` and `Options` can be used separately. Use `Options` with a `Dropdown.Trigger` rendering a Twenty UI `Button` when the host needs a full button instead of the compact code control.
+## Advanced composition
+
+`CurrencyPicker.Root` prepares the catalogue and owns selection for both parts. It adds no DOM element and must be inside `Dropdown.Root`. Keep `Trigger` and `Options` under the same picker root, including when the options live in another dropdown page. The root's render-function children expose `value`, `selectedCurrency`, and `disabled` for caller-owned labels and supporting content.
+
+```tsx
+import { CurrencyPicker } from 'twenty-ui/components/input';
+import { Dropdown } from 'twenty-ui/components/navigation';
+
+const CURRENCIES = [
+ { code: 'EUR', name: 'Euro' },
+ { code: 'USD', name: 'US Dollar' },
+];
+
+export const ComposedCurrency = () => (
+ <Dropdown.Root type="picker">
+ <CurrencyPicker.Root
+ currencies={CURRENCIES}
+ defaultValue="USD"
+ closeOnSelect={false}
+ >
+ {({ value }) => (
+ <>
+ <CurrencyPicker.Trigger
+ aria-label={`Invoice currency: ${value ?? 'none'}`}
+ placeholder="Choose a currency"
+ />
+ <Dropdown.Content aria-label="Invoice currency" width={280}>
+ <Dropdown.Title>Invoice currency</Dropdown.Title>
+ <CurrencyPicker.Options
+ searchLabel="Search currencies"
+ emptyLabel="No currencies found"
+ />
+ </Dropdown.Content>
+ </>
+ )}
+ </CurrencyPicker.Root>
+ </Dropdown.Root>
+);
+```
+
+Dropdown owns opening, popup placement, pages, search navigation, and focus. The picker uses a Dropdown selection group for persistent selected values and the close policy. `Root.closeOnSelect` defaults to `true`; use `false` to keep the popup open after choosing a currency. Arrow keys, Home, and End move focus without changing the value. Enter, Space, or pointer activation selects an enabled option. Disabled currencies stay visible and cannot be selected.
+
+## Search and ordering
+
+Options are searchable by default. Search ignores surrounding whitespace and matches codes, names, symbols, and the default `Name (CODE)` label without case sensitivity, using the same rules in every browser locale. `getSearchText` on the root replaces the searchable text for each currency. Display customization and search text are independent.
+
+Results retain catalogue order. Set `selectedFirst` on the shorthand or root to move the selected currency before the other matches. A query that excludes it also removes its row. An unknown value does not create a selected result. Empty results show `emptyLabel` in a status region.
-## Search and selection
+Set `Options.searchable={false}` to omit the search field. `Options.searchProps` targets the native search input, including its `ref`, `render`, accessible attributes, and controlled `value` or uncontrolled `defaultValue`. `searchProps.onValueChange` receives the query. In shorthand use, pass these options through `optionsProps`.
-Search ignores surrounding whitespace and matches currency codes, names, and the displayed `Name (CODE)` label without case sensitivity, using the same matching rules in every browser locale. Results keep the supplied order, with the selected currency first when it matches the search. Each row shows `Name (CODE)` and exposes its selected state through `aria-pressed`.
+The search field receives focus when a searchable picker opens. Enter with a nonempty query activates the first enabled result. With an empty query, move focus to an option before selecting it. Search activation during IME composition and fresh search on reopen remain subject to the shared Dropdown search and page-session contracts.
-Search receives focus when the picker opens. With a nonempty search, Enter selects the first enabled match. With an empty search, Enter does nothing until ArrowDown moves focus to an option. Empty results keep the picker open and show the empty label in a status region that stays in place while the picker is open, so screen readers announce it. Selection closes a single-selection dropdown; Escape and outside interaction use the dropdown's existing dismissal and focus behavior.
+## Presentation and native targets
-Set `disabled` on a currency to keep its row visible while preventing selection. `Trigger.disabled` prevents opening; `Options.disabled` disables search and all options in an already open host.
+The trigger shows the selected code by default. `renderValue` receives `{ value, selectedCurrency, disabled }` to customize that display without looking up the currency again. `Trigger.children` overrides the value display, and `Trigger.placeholder` supplies the empty display. `getOptionLabel` customizes each option's content, with the default `Name (CODE)` label. Currency names, symbols, labels, and option content belong to the caller.
-## Ownership and labels
+The shorthand's native button attributes, event handlers, `className`, `style`, `ref`, and `render` target its trigger. `triggerProps` customizes that same button. Use `optionsProps` for the options wrapper div and its nested `searchProps` for the input. `contentProps` customizes Dropdown's popup. `open`, `defaultOpen`, and `onOpenChange` coordinate the shorthand's open state.
-The picker owns searching, selected-first ordering, and currency selection. The application owns the currency catalogue, amount editing, formatting, default currency, persistence, and dropdown lifecycle. Currency names are data supplied by the caller.
+In compound use, native attributes, `ref`, and `render` on `Trigger` target its button, while those on `Options` target its wrapper div. `Options.listLabel` names only the inner selection listbox. Forward the supplied props and ref from a custom `render` component. Wrapper styling does not change the input's native target.
-`searchLabel` defaults to `Search` and provides both the search placeholder and accessible name. `emptyLabel` defaults to `No results`. Supply translated labels and accessible names from your application. Give the trigger an accessible name that includes its visible currency code, such as `Invoice currency: USD`, and give the dropdown content a name that describes the currency being selected.
+Set `disabled` on the shorthand or root to disable opening, search, and selection. A part's `disabled` prop can additionally disable that part. Selection is a picker value; native form submission, reset, required validation, and Field integration remain outside this API.
-Native attributes, `className`, `style`, `ref`, and `render` apply to each part's root element. The trigger forwards the shared dropdown trigger interface, except `children`, hover opening (`openOnHover`, `delay`, `closeDelay`), and the popover `handle` and `payload` props; the options root is a div by default.
+## Labels and application integration
+
+`searchLabel` defaults to `Search` and supplies the search placeholder and accessible name. `emptyLabel` defaults to `No results` and accepts content. Supply localized source labels, an accessible trigger name, and any placeholder from your application. Dropdown content takes the trigger name unless a `Dropdown.Title` or explicit content label names it. The selection listbox takes the registered Dropdown title or trigger name by default. Set `Options.listLabel` to give only that listbox its own accessible name, or pass `optionsProps.listLabel` in shorthand use. Native `aria-label` and `aria-labelledby` on `Options` label only its wrapper. The trigger keeps its own accessible name.
+
+The application owns amount editing, currency storage, formatting, catalogue loading, and its initial value. An adapter should map stored currency codes and clearing behavior to `value` and `onValueChange`, preserving the application's formatting and fallback rules. Keep translated currency names and labels in the application.
## Front-component renderer
-React and Preact sandbox fixtures verify code presentation and the disabled trigger. In both runtimes the trigger opens the popup, but the popup renders into the sandbox document instead of the page, so its content is not visible. Search, currency selection, popup focus, and closing from the popup are not supported in that sandbox until these limitations are resolved. Ordinary React hosts exercise the complete interaction.
+The React and Preact sandbox fixtures cover shorthand and compound search and selection, disabled controls and options, trigger refs, null clearing, external controlled updates, reopening, and Escape focus restoration. They also verify that clearing an earlier query and typing `$` preserves the symbol query.
+
+Popup visibility, geometry, scrolling, and dismissal depend on the shared renderer's Dropdown and portal support. The picker uses that shared implementation.
## Props
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
index 635733ac931..35ef8b745dc 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
@@ -258,12 +258,17 @@ must change the corresponding story to assert successful behavior; do not keep
or broaden an obsolete expectation. No stories are skipped or marked as
expected-to-fail by the runner.
-| Component | Current limitation |
-| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Popover, Select, CurrencyPicker, PhoneCountryPicker, CountrySelect (React and Preact) | Body portal content reaches the host inside the component portal area. These fixtures cover opening and visible content; search, selection, dismissal and focus restoration are not covered yet. |
-| Slider (React) | Edge-aligned thumbs stay hidden until the value changes. Base UI 1.8 and 1.9 set up the thumb's `ResizeObserver` before React attaches the `Slider.Control` ref, so the thumb never re-measures once the first host geometry arrives ([mui/base-ui#5995](https://github.com/mui/base-ui/issues/5995), fix pending in [mui/base-ui#6000](https://github.com/mui/base-ui/pull/6000)). Preact attaches the ref first, so its thumbs appear. `thumbAlignment="center"` avoids the issue. |
-| OverflowingList | Item widths come from the last host layout, because a worker cannot lay out the measuring state synchronously. The truncated last item is measured at its truncated width, so the visible count can differ from a native render when that item's full width decides whether it fits. |
-| Responsive hooks | The sandbox `window.matchMedia` answers for the widget's own box, so `useIsMobile` follows the widget width rather than the browser viewport: a widget 768px wide or narrower gets the mobile layout, and Button drops its hotkey hint, on any screen. `useIsTouchDevice` follows the primary input of the host device, so it is `false` under the desktop Chromium that runs these stories. The fixture asserts both at a 1024px and a 400px widget width. |
+| Component | Current limitation |
+| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| Popover, Select, PhoneCountryPicker, CountrySelect (React and Preact) | Body portal content reaches the host inside the component portal area. These fixtures cover opening and visible content; search, selection, dismissal and focus restoration are not covered yet. |
+| Slider (React) | Edge-aligned thumbs stay hidden until the value changes. Base UI 1.8 and 1.9 set up the thumb's `ResizeObserver` before React attaches the `Slider.Control` ref, so the thumb never re-measures once the first host geometry arrives ([mui/base-ui#5995](https://github.com/mui/base-ui/issues/5995), fix pending in [mui/base-ui#6000](https://github.com/mui/base-ui/pull/6000)). Preact attaches the ref first, so its thumbs appear. `thumbAlignment="center"` avoids the issue. |
+| OverflowingList | Item widths come from the last host layout, because a worker cannot lay out the measuring state synchronously. The truncated last item is measured at its truncated width, so the visible count can differ from a native render when that item's full width decides whether it fits. |
+| Responsive hooks | The sandbox `window.matchMedia` answers for the widget's own box, so `useIsMobile` follows the widget width rather than the browser viewport: a widget 768px wide or narrower gets the mobile layout, and Button drops its hotkey hint, on any screen. `useIsTouchDevice` follows the primary input of the host device, so it is `false` under the desktop Chromium that runs these stories. The fixture asserts both at a 1024px and a 400px widget width. |
+
+The CurrencyPicker fixtures cover shorthand and composed selection in React and
+Preact, disabled controls and options, exact no-results/name/symbol search,
+callback details and trigger refs, null clearing, external updates, dismissal
+and focus restoration. These cases do not establish integrated V1 acceptance.
The worker DOM now provides `Node.contains`, `compareDocumentPosition`,
`getRootNode`, `Element.matches`, `closest`, `querySelector` backed by
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-currency-picker.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-currency-picker.front-component.tsx
index efbf2aa5b84..ce9aae70b8d 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-currency-picker.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-currency-picker.front-component.tsx
@@ -1,70 +1,91 @@
-import { useState } from 'react';
+import { useRef, useState } from 'react';
import { defineFrontComponent } from 'twenty-sdk/define';
import { CurrencyPicker } from 'twenty-ui/components/input';
import { Dropdown } from 'twenty-ui/components/navigation';
+import { Button } from 'twenty-ui/primitives/input';
import { Text } from 'twenty-ui/primitives/typography';
import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';
const CURRENCIES = [
- { code: 'CAD', name: 'Canadian Dollar' },
- { code: 'EUR', name: 'Euro' },
- { code: 'JPY', name: 'Japanese Yen', disabled: true },
- { code: 'USD', name: 'US Dollar' },
+ { code: 'CAD', name: 'Canadian Dollar', symbol: '$' },
+ { code: 'EUR', name: 'Euro', symbol: '€' },
+ { code: 'JPY', name: 'Japanese Yen', symbol: '¥', disabled: true },
+ { code: 'USD', name: 'US Dollar', symbol: '$' },
];
const CurrencyPickerExample = () => {
- const [primaryCurrency, setPrimaryCurrency] = useState('EUR');
- const [secondaryCurrency, setSecondaryCurrency] = useState('USD');
+ const [primaryCurrency, setPrimaryCurrency] = useState<string | null>('EUR');
+ const [secondaryCurrency, setSecondaryCurrency] = useState<string | null>(
+ 'USD',
+ );
+
+ const [primaryChanges, setPrimaryChanges] = useState(0);
+ const [primaryReason, setPrimaryReason] = useState('none');
+ const [primaryTriggerTarget, setPrimaryTriggerTarget] = useState('unread');
+ const primaryTriggerRef = useRef<HTMLButtonElement>(null);
return (
<TwentyUiGalleryCard title="Currency picker">
+ <CurrencyPicker
+ currencies={CURRENCIES}
+ data-currency-trigger="primary"
+ value={primaryCurrency}
+ onValueChange={(currencyCode, details) => {
+ setPrimaryCurrency(currencyCode);
+ setPrimaryChanges((count) => count + 1);
+ setPrimaryReason(details.reason);
+ setPrimaryTriggerTarget(
+ primaryTriggerRef.current?.getAttribute('data-currency-trigger') ??
+ 'missing',
+ );
+ }}
+ renderValue={({ selectedCurrency }) => selectedCurrency?.code ?? 'None'}
+ triggerProps={{
+ 'aria-label': 'Primary currency',
+ ref: primaryTriggerRef,
+ }}
+ contentProps={{ 'aria-label': 'Primary currencies' }}
+ optionsProps={{
+ searchLabel: 'Search primary currencies',
+ emptyLabel: 'No matching currencies',
+ }}
+ />
<Dropdown.Root type="picker">
- <CurrencyPicker.Trigger
- aria-label="Primary currency"
- value={primaryCurrency}
- />
- <Dropdown.Content aria-label="Primary currencies">
- <CurrencyPicker.Options
- currencies={CURRENCIES}
- value={primaryCurrency}
- searchLabel="Search primary currencies"
- emptyLabel="No matching currencies"
- onValueChange={setPrimaryCurrency}
- />
- </Dropdown.Content>
- </Dropdown.Root>
- <Dropdown.Root type="picker">
- <CurrencyPicker.Trigger
- aria-label="Secondary currency"
+ <CurrencyPicker.Root
+ currencies={CURRENCIES}
value={secondaryCurrency}
- />
- <Dropdown.Content aria-label="Secondary currencies">
- <CurrencyPicker.Options
- currencies={CURRENCIES}
- value={secondaryCurrency}
- searchLabel="Search secondary currencies"
- onValueChange={setSecondaryCurrency}
- />
- </Dropdown.Content>
+ onValueChange={setSecondaryCurrency}
+ >
+ <CurrencyPicker.Trigger aria-label="Secondary currency" />
+ <Dropdown.Content aria-label="Secondary currencies">
+ <CurrencyPicker.Options
+ searchLabel="Search secondary currencies"
+ emptyLabel="No matching currencies"
+ />
+ </Dropdown.Content>
+ </CurrencyPicker.Root>
</Dropdown.Root>
- <Dropdown.Root type="picker">
- <CurrencyPicker.Trigger
- aria-label="Disabled currency"
- value="EUR"
- disabled
- />
- <Dropdown.Content aria-label="Disabled currencies">
- <CurrencyPicker.Options
- currencies={CURRENCIES}
- value="EUR"
- disabled
- onValueChange={() => undefined}
- />
- </Dropdown.Content>
- </Dropdown.Root>
- <Text role="status">
- Primary: {primaryCurrency}; Secondary: {secondaryCurrency}
+ <CurrencyPicker
+ currencies={CURRENCIES}
+ defaultValue="EUR"
+ disabled
+ triggerProps={{ 'aria-label': 'Disabled currency' }}
+ contentProps={{ 'aria-label': 'Disabled currencies' }}
+ />
+ <Button onClick={() => setPrimaryCurrency(null)}>
+ Clear primary currency
+ </Button>
+ <Button onClick={() => setPrimaryCurrency('USD')}>
+ Use USD for primary
+ </Button>
+ <Text role="status" aria-label="Saved currencies">
+ Primary: {primaryCurrency ?? 'None'}; Secondary:{' '}
+ {secondaryCurrency ?? 'None'}
+ </Text>
+ <Text role="status" aria-label="Primary currency changes">
+ Changes: {primaryChanges}; Reason: {primaryReason}; Trigger:{' '}
+ {primaryTriggerTarget}
</Text>
</TwentyUiGalleryCard>
);
@@ -73,6 +94,6 @@ const CurrencyPickerExample = () => {
export default defineFrontComponent({
universalIdentifier: 'b613ee94-d9d9-477a-b76a-606637c81c11',
name: 'twenty-ui-currency-picker',
- description: 'Currency search and independent selections in the sandbox',
+ description: 'Shorthand and composed currency search in the sandbox',
component: CurrencyPickerExample,
});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/currencyPickerTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/currencyPickerTest.ts
index b9d6cf8be12..b802b39b8e3 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/currencyPickerTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/currencyPickerTest.ts
@@ -1,25 +1,19 @@
-import { expect, userEvent, within } from 'storybook/test';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
+import { waitForSandboxRoundTrip } from '@/__stories__/shared/test-utils/waitForSandboxRoundTrip';
import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
-import { createDropdownOpenTest } from '@/__stories__/twenty-ui-gallery/utils/createDropdownOpenTest';
-const PRIMARY_CURRENCY_TRIGGER_NAME = 'Primary currency';
-
-const primaryCurrencyPickerOpenTest = createDropdownOpenTest({
- triggerName: PRIMARY_CURRENCY_TRIGGER_NAME,
- popupText: 'Canadian Dollar',
-});
-
-export const currencyPickerTest: TwentyUiGalleryPlayFunction = async (
- context,
-) => {
- const canvas = within(context.canvasElement);
- const page = within(context.canvasElement.ownerDocument.body);
+export const currencyPickerTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
await expectFrontComponentMounted(canvas);
const primaryTrigger = canvas.getByRole('button', {
- name: PRIMARY_CURRENCY_TRIGGER_NAME,
+ name: 'Primary currency',
});
const secondaryTrigger = canvas.getByRole('button', {
name: 'Secondary currency',
@@ -27,16 +21,105 @@ export const currencyPickerTest: TwentyUiGalleryPlayFunction = async (
const disabledTrigger = canvas.getByRole('button', {
name: 'Disabled currency',
});
+ const savedCurrencies = canvas.getByRole('status', {
+ name: 'Saved currencies',
+ });
+ const currencyChanges = canvas.getByRole('status', {
+ name: 'Primary currency changes',
+ });
+ expect(primaryTrigger.tagName).toBe('BUTTON');
+ expect(primaryTrigger).toHaveAttribute('data-currency-trigger', 'primary');
expect(primaryTrigger).toHaveTextContent('EUR');
expect(secondaryTrigger).toHaveTextContent('USD');
expect(disabledTrigger).toBeDisabled();
await userEvent.click(disabledTrigger);
-
- await primaryCurrencyPickerOpenTest(context);
-
expect(disabledTrigger).toHaveAttribute('aria-expanded', 'false');
expect(
page.queryByRole('dialog', { name: 'Disabled currencies' }),
).toBeNull();
+
+ await userEvent.click(primaryTrigger);
+ const primarySearch = await page.findByRole('searchbox', {
+ name: 'Search primary currencies',
+ });
+ const yen = await page.findByRole('option', { name: 'Japanese Yen (JPY)' });
+ expect(yen.tagName).toBe('BUTTON');
+ expect(yen).toBeDisabled();
+ await userEvent.click(yen);
+ await waitForSandboxRoundTrip();
+ expect(savedCurrencies).toHaveTextContent('Primary: EUR; Secondary: USD');
+ expect(currencyChanges).toHaveTextContent('Changes: 0; Reason: none');
+
+ await userEvent.type(primarySearch, 'zzzz');
+ await waitForSandboxRoundTrip();
+ expect(primarySearch).toHaveValue('zzzz');
+ await waitFor(() =>
+ expect(page.getByText('No matching currencies')).toBeVisible(),
+ );
+ await userEvent.clear(primarySearch);
+ await userEvent.type(primarySearch, '$');
+ await waitForSandboxRoundTrip();
+ expect(primarySearch).toHaveValue('$');
+ const canadianDollar = await page.findByRole('option', {
+ name: 'Canadian Dollar (CAD)',
+ });
+ await waitFor(() =>
+ expect(page.queryByRole('option', { name: 'Euro (EUR)' })).toBeNull(),
+ );
+ await userEvent.click(canadianDollar);
+ await waitFor(() => {
+ expect(savedCurrencies).toHaveTextContent('Primary: CAD; Secondary: USD');
+ expect(currencyChanges).toHaveTextContent(
+ 'Changes: 1; Reason: item-press; Trigger: primary',
+ );
+ expect(primaryTrigger).toHaveAttribute('aria-expanded', 'false');
+ });
+ expect(primaryTrigger).toHaveTextContent('CAD');
+
+ await userEvent.click(secondaryTrigger);
+ const secondarySearch = await page.findByRole('searchbox', {
+ name: 'Search secondary currencies',
+ });
+ await userEvent.type(secondarySearch, 'euro');
+ await waitForSandboxRoundTrip();
+ expect(secondarySearch).toHaveValue('euro');
+ await userEvent.click(
+ await page.findByRole('option', { name: 'Euro (EUR)' }),
+ );
+ await waitFor(() => {
+ expect(savedCurrencies).toHaveTextContent('Primary: CAD; Secondary: EUR');
+ expect(secondaryTrigger).toHaveAttribute('aria-expanded', 'false');
+ });
+ expect(secondaryTrigger).toHaveTextContent('EUR');
+ expect(primaryTrigger).toHaveTextContent('CAD');
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Clear primary currency' }),
+ );
+ await waitFor(() => expect(primaryTrigger).toHaveTextContent('None'));
+ await userEvent.click(primaryTrigger);
+ const reopenedSearch = await page.findByRole('searchbox', {
+ name: 'Search primary currencies',
+ });
+ expect(reopenedSearch).toHaveValue('');
+ expect(page.queryByRole('option', { selected: true })).toBeNull();
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(primaryTrigger).toHaveAttribute('aria-expanded', 'false'),
+ );
+ await waitFor(() => expect(primaryTrigger).toHaveFocus());
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Use USD for primary' }),
+ );
+ await waitFor(() => expect(primaryTrigger).toHaveTextContent('USD'));
+ await userEvent.click(primaryTrigger);
+ expect(
+ await page.findByRole('option', { name: 'US Dollar (USD)' }),
+ ).toHaveAttribute('aria-selected', 'true');
+ expect(currencyChanges).toHaveTextContent('Changes: 1; Reason: item-press');
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(primaryTrigger).toHaveFocus());
+ expect(errorHandler).not.toHaveBeenCalled();
};
diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownButton.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownButton.tsx
index 8d32068f1ae..3d37af7aa6c 100644
--- a/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownButton.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownButton.tsx
@@ -1,6 +1,7 @@
import { t } from '@lingui/core/macro';
import { type KeyboardEvent, useId } from 'react';
import { CurrencyCode } from 'twenty-shared/constants';
+import { isDefined } from 'twenty-shared/utils';
import { CurrencyPicker } from 'twenty-ui/components/input';
import { useCurrencyPickerCurrencies } from '@/ui/input/components/internal/currency/hooks/useCurrencyPickerCurrencies';
@@ -30,34 +31,52 @@ export const CurrencyPickerDropdownButton = ({
}: CurrencyPickerDropdownButtonProps) => {
const dropdownId = useId();
const currencyPickerCurrencies = useCurrencyPickerCurrencies();
- const selectedCurrency = currencyPickerCurrencies.find(
- ({ code }) => code === selectedCurrencyCode,
- );
- const currencyCode = selectedCurrency?.code ?? CurrencyCode.USD;
+
+ const handleValueChange = (currencyCode: string | null) => {
+ if (!isDefined(currencyCode)) {
+ return;
+ }
+
+ onChange(currencyCode);
+ };
return (
<DropdownRoot dropdownId={dropdownId} type="picker">
- <CurrencyPicker.Trigger
- value={currencyCode}
+ <CurrencyPicker.Root
+ currencies={currencyPickerCurrencies}
+ value={selectedCurrencyCode}
+ onValueChange={handleValueChange}
disabled={disabled}
- aria-label={t`Currency: ${currencyCode}`}
- onKeyDown={keepEnterAwayFromFieldHotkeys}
- />
- <DropdownContent
- side="bottom"
- align="start"
- sideOffset={4}
- alignOffset={0}
- aria-label={t`Currency`}
+ selectedFirst
>
- <CurrencyPicker.Options
- currencies={currencyPickerCurrencies}
- value={selectedCurrency?.code}
- onValueChange={onChange}
- searchLabel={t`Search`}
- emptyLabel={t`No results`}
- />
- </DropdownContent>
+ {({ selectedCurrency }) => {
+ const currencyCode = selectedCurrency?.code ?? CurrencyCode.USD;
+
+ return (
+ <>
+ <CurrencyPicker.Trigger
+ aria-label={t`Currency: ${currencyCode}`}
+ onKeyDown={keepEnterAwayFromFieldHotkeys}
+ >
+ {currencyCode}
+ </CurrencyPicker.Trigger>
+ <DropdownContent
+ side="bottom"
+ align="start"
+ sideOffset={4}
+ alignOffset={0}
+ aria-label={t`Currency`}
+ >
+ <CurrencyPicker.Options
+ listLabel={t`Currency`}
+ searchLabel={t`Search`}
+ emptyLabel={t`No results`}
+ />
+ </DropdownContent>
+ </>
+ );
+ }}
+ </CurrencyPicker.Root>
</DropdownRoot>
);
};
diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/__stories__/CurrencyPickerDropdownButton.stories.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/__stories__/CurrencyPickerDropdownButton.stories.tsx
index a487ca39bb8..3094f02aa30 100644
--- a/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/__stories__/CurrencyPickerDropdownButton.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/__stories__/CurrencyPickerDropdownButton.stories.tsx
@@ -43,9 +43,9 @@ export const SearchPreservesCurrencyCallback: Story = {
expect(await body.findByText('No results')).toBeVisible();
await userEvent.clear(search);
await userEvent.type(search, 'euro');
- const euro = await body.findByRole('button', { name: 'Euro (EUR)' });
+ const euro = await body.findByRole('option', { name: 'Euro (EUR)' });
expect(
- body.queryByRole('button', { pressed: true }),
+ body.queryByRole('option', { selected: true }),
).not.toBeInTheDocument();
await waitFor(() => expect(euro).toHaveAttribute('data-highlighted'));
await userEvent.keyboard('{Enter}');
@@ -64,8 +64,8 @@ export const SearchPreservesCurrencyCallback: Story = {
'',
);
expect(
- await body.findByRole('button', { name: 'Euro (EUR)' }),
- ).toHaveAttribute('aria-pressed', 'true');
+ await body.findByRole('option', { name: 'Euro (EUR)' }),
+ ).toHaveAttribute('aria-selected', 'true');
await userEvent.keyboard('{Escape}');
await waitFor(() => expect(trigger).toHaveFocus());
},
@@ -118,14 +118,14 @@ export const IndependentInstances: Story = {
'',
);
expect(
- await body.findByRole('button', { name: 'Euro (EUR)' }),
- ).toHaveAttribute('aria-pressed', 'true');
+ await body.findByRole('option', { name: 'Euro (EUR)' }),
+ ).toHaveAttribute('aria-selected', 'true');
await userEvent.type(
body.getByRole('searchbox', { name: 'Search' }),
'gbp',
);
await userEvent.click(
- await body.findByRole('button', { name: /\(GBP\)$/ }),
+ await body.findByRole('option', { name: /\(GBP\)$/ }),
);
await waitFor(() =>
expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
@@ -148,7 +148,7 @@ export const UnknownCurrencyUsesDisplayFallback: Story = {
const dialog = await body.findByRole('dialog', { name: 'Currency' });
await waitFor(() => expect(dialog).toBeVisible());
expect(
- body.queryByRole('button', { pressed: true }),
+ body.queryByRole('option', { selected: true }),
).not.toBeInTheDocument();
const search = await body.findByRole('searchbox', { name: 'Search' });
@@ -160,7 +160,7 @@ export const UnknownCurrencyUsesDisplayFallback: Story = {
await userEvent.type(search, 'usd');
await userEvent.click(
- await body.findByRole('button', { name: /\(USD\)$/ }),
+ await body.findByRole('option', { name: /\(USD\)$/ }),
);
await waitFor(() =>
expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
@@ -169,9 +169,52 @@ export const UnknownCurrencyUsesDisplayFallback: Story = {
expect(onCurrencyChange).toHaveBeenCalledWith('USD');
await userEvent.click(trigger);
expect(
- await body.findByRole('button', { name: /\(USD\)$/ }),
- ).toHaveAttribute('aria-pressed', 'true');
+ await body.findByRole('option', { name: /\(USD\)$/ }),
+ ).toHaveAttribute('aria-selected', 'true');
await userEvent.keyboard('{Escape}');
await waitFor(() => expect(trigger).toHaveFocus());
},
};
+
+export const ExternalValueUpdates: Story = {
+ render: ({ onChange }) => (
+ <CurrencyPickerDropdownButtonExample
+ selectedCurrencyCode="USD"
+ onChange={onChange}
+ showExternalUpdates
+ />
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const trigger = canvas.getByRole('button', { name: 'Currency: USD' });
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Use EUR' }));
+ expect(trigger).toHaveAccessibleName('Currency: EUR');
+ await userEvent.click(trigger);
+ expect(
+ await body.findByRole('option', { name: 'Euro (EUR)' }),
+ ).toHaveAttribute('aria-selected', 'true');
+ await userEvent.keyboard('{Escape}');
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Clear currency' }),
+ );
+ expect(trigger).toHaveAccessibleName('Currency: USD');
+ expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Stored currency: empty',
+ );
+ await userEvent.click(trigger);
+ expect(body.queryByRole('option', { selected: true })).toBeNull();
+ await userEvent.keyboard('{Escape}');
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Use unknown currency' }),
+ );
+ expect(trigger).toHaveAccessibleName('Currency: USD');
+ expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Stored currency: UNKNOWN',
+ );
+ expect(onCurrencyChange).not.toHaveBeenCalled();
+ },
+};
diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/__stories__/CurrencyPickerDropdownButtonExample.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/__stories__/CurrencyPickerDropdownButtonExample.tsx
index bbf5ac7411a..6b380bbdbda 100644
--- a/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/__stories__/CurrencyPickerDropdownButtonExample.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/__stories__/CurrencyPickerDropdownButtonExample.tsx
@@ -1,24 +1,43 @@
+import { isNonEmptyString } from '@sniptt/guards';
import { useState, type ComponentProps } from 'react';
+import { Button } from 'twenty-ui/primitives/input';
+import { Text } from 'twenty-ui/primitives/typography';
import { CurrencyPickerDropdownButton } from '@/ui/input/components/internal/currency/components/CurrencyPickerDropdownButton';
type CurrencyPickerDropdownButtonExampleProps = ComponentProps<
typeof CurrencyPickerDropdownButton
->;
+> & { showExternalUpdates?: boolean };
export const CurrencyPickerDropdownButtonExample = ({
selectedCurrencyCode,
onChange,
+ showExternalUpdates = false,
}: CurrencyPickerDropdownButtonExampleProps) => {
const [currencyCode, setCurrencyCode] = useState(selectedCurrencyCode);
return (
- <CurrencyPickerDropdownButton
- selectedCurrencyCode={currencyCode}
- onChange={(newCurrencyCode) => {
- setCurrencyCode(newCurrencyCode);
- onChange(newCurrencyCode);
- }}
- />
+ <>
+ <CurrencyPickerDropdownButton
+ selectedCurrencyCode={currencyCode}
+ onChange={(newCurrencyCode) => {
+ setCurrencyCode(newCurrencyCode);
+ onChange(newCurrencyCode);
+ }}
+ />
+ {showExternalUpdates && (
+ <>
+ <Button onClick={() => setCurrencyCode('EUR')}>Use EUR</Button>
+ <Button onClick={() => setCurrencyCode('')}>Clear currency</Button>
+ <Button onClick={() => setCurrencyCode('UNKNOWN')}>
+ Use unknown currency
+ </Button>
+ <Text role="status">
+ Stored currency:{' '}
+ {isNonEmptyString(currencyCode) ? currencyCode : 'empty'}
+ </Text>
+ </>
+ )}
+ </>
);
};
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 66adbc68663..d6ee8372dd0 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -6,6 +6,7 @@ import { INPUT_GROUP_PROP_DESCRIPTIONS } from './inputGroupPropDescriptions';
import { INPUT_PROP_DESCRIPTIONS } from './inputPropDescriptions';
import { COUNTRY_SELECT_PROP_DESCRIPTIONS } from './countrySelectPropDescriptions';
import { CURRENCY_PICKER_PART_PROP_DESCRIPTIONS } from './currencyPickerPartPropDescriptions';
+import { CURRENCY_PICKER_PROP_DESCRIPTIONS } from './currencyPickerPropDescriptions';
import { OVERFLOWING_LIST_PROP_DESCRIPTIONS } from './overflowingListPropDescriptions';
import { METRIC_ROW_PROP_DESCRIPTIONS } from './metricRowPropDescriptions';
import { PROGRESS_PART_PROP_DESCRIPTIONS } from './progressPartPropDescriptions';
@@ -107,8 +108,22 @@ export const DOCUMENTED_COMPONENTS = [
source: 'components/input/CurrencyPicker/CurrencyPicker.tsx',
entryPoint: 'twenty-ui/components/input',
slug: 'components/input/currency-picker',
- parts: ['Trigger', 'Options'],
+ propDescriptions: CURRENCY_PICKER_PROP_DESCRIPTIONS,
+ propDefaults: {
+ defaultValue: 'null',
+ disabled: 'false',
+ selectedFirst: 'false',
+ getOptionLabel: 'Name (CODE)',
+ getSearchText: 'Name (CODE) and symbol',
+ },
+ parts: ['Root', 'Trigger', 'Options'],
partPropDescriptions: CURRENCY_PICKER_PART_PROP_DESCRIPTIONS,
+ partPropDefaults: {
+ Root: {
+ getOptionLabel: 'Name (CODE)',
+ getSearchText: 'Name (CODE) and symbol',
+ },
+ },
},
{
name: 'ProgressRing',
diff --git a/packages/twenty-ui/docs/currencyPickerPartPropDescriptions.ts b/packages/twenty-ui/docs/currencyPickerPartPropDescriptions.ts
index 0f437f9c20d..7878b7a8abb 100644
--- a/packages/twenty-ui/docs/currencyPickerPartPropDescriptions.ts
+++ b/packages/twenty-ui/docs/currencyPickerPartPropDescriptions.ts
@@ -1,27 +1,25 @@
import { type CurrencyPickerOptionsProps } from '../src/components/input/CurrencyPicker/types/CurrencyPickerOptionsProps';
-import { type CurrencyPickerTriggerProps } from '../src/components/input/CurrencyPicker/types/CurrencyPickerTriggerProps';
+import { CURRENCY_PICKER_ROOT_PROP_DESCRIPTIONS } from './currencyPickerRootPropDescriptions';
+import { CURRENCY_PICKER_TRIGGER_PROP_DESCRIPTIONS } from './currencyPickerTriggerPropDescriptions';
export const CURRENCY_PICKER_PART_PROP_DESCRIPTIONS = {
- Trigger: {
- value:
- 'Required currency code displayed beside the chevron. The application chooses its initial value and any fallback.',
- disabled: 'Disables opening the picker.',
- id: 'ID forwarded to the trigger button.',
- render:
- 'Replaces the native trigger button. Forward the supplied props and ref when rendering a custom component.',
- } satisfies Partial<Record<keyof CurrencyPickerTriggerProps, string>>,
+ Root: CURRENCY_PICKER_ROOT_PROP_DESCRIPTIONS,
+ Trigger: CURRENCY_PICKER_TRIGGER_PROP_DESCRIPTIONS,
Options: {
- currencies:
- 'Available currency codes and names, in catalogue order. Each code must be unique. An option can be disabled.',
- value:
- 'Selected currency code. Its matching row appears first and is marked pressed.',
- onValueChange:
- 'Called with the code chosen by pointer or keyboard. The application updates the selected value.',
+ searchable: 'Renders a search input above the options. Defaults to true.',
+ searchProps:
+ 'Native input attributes, ref, render, and controlled or uncontrolled query props forwarded to Dropdown.Search. Use value with onValueChange or defaultValue.',
searchLabel: 'Search placeholder and accessible name. Defaults to Search.',
+ listLabel:
+ 'Accessible name for the selection listbox. Defaults to the registered Dropdown title or trigger name. Native accessible attributes on Options target only its wrapper.',
emptyLabel:
- 'Text announced when no currencies match. Defaults to No results.',
- disabled: 'Disables search and every currency option.',
+ 'Content announced when no currencies match. Defaults to No results.',
+ disabled:
+ 'Additionally disables search and every currency option. Root disabled state always takes precedence.',
+ className: 'Class applied to the options wrapper div.',
+ style: 'Inline styles applied to the options wrapper div.',
+ ref: 'Ref to the options wrapper div, or the element composed through render.',
render:
- 'Replaces the non-interactive root div. Forward the supplied props and ref when rendering a custom component.',
+ 'Replaces the non-interactive wrapper div. Forward the supplied props and ref when rendering a custom component. Use searchProps.render to customize the input.',
} satisfies Partial<Record<keyof CurrencyPickerOptionsProps, string>>,
};
diff --git a/packages/twenty-ui/docs/currencyPickerPropDescriptions.ts b/packages/twenty-ui/docs/currencyPickerPropDescriptions.ts
new file mode 100644
index 00000000000..9dd2fe56647
--- /dev/null
+++ b/packages/twenty-ui/docs/currencyPickerPropDescriptions.ts
@@ -0,0 +1,23 @@
+import { type CurrencyPickerProps } from '../src/components/input/CurrencyPicker/types/CurrencyPickerProps';
+import { CURRENCY_PICKER_ROOT_PROP_DESCRIPTIONS } from './currencyPickerRootPropDescriptions';
+import { CURRENCY_PICKER_TRIGGER_PROP_DESCRIPTIONS } from './currencyPickerTriggerPropDescriptions';
+
+export const CURRENCY_PICKER_PROP_DESCRIPTIONS = {
+ ...CURRENCY_PICKER_ROOT_PROP_DESCRIPTIONS,
+ ...CURRENCY_PICKER_TRIGGER_PROP_DESCRIPTIONS,
+ disabled: 'Disables opening, search, and every currency option.',
+ triggerProps:
+ 'Props for the trigger button, including native attributes, ref, render, placeholder, and caller-owned children. These override shorthand trigger props.',
+ optionsProps:
+ 'Props for the options wrapper div, listLabel, and search behavior. Native input customization belongs in optionsProps.searchProps.',
+ contentProps:
+ 'Dropdown popup props, including placement, width, and accessible attributes.',
+ open: 'Whether the popup is open. Use with onOpenChange to control it.',
+ defaultOpen: 'Whether the popup is initially open when uncontrolled.',
+ onOpenChange:
+ 'Called with the next open state when the popup opens or closes.',
+ onEscapeKeyDown:
+ 'Called before Escape closes the popup. Call event.preventDefault() to keep it open.',
+ onInteractOutside:
+ 'Called before an outside press or Tab out closes the popup. Call event.preventDefault() to keep it open.',
+} satisfies Partial<Record<keyof CurrencyPickerProps, string>>;
diff --git a/packages/twenty-ui/docs/currencyPickerRootPropDescriptions.ts b/packages/twenty-ui/docs/currencyPickerRootPropDescriptions.ts
new file mode 100644
index 00000000000..7b5fc86a7d3
--- /dev/null
+++ b/packages/twenty-ui/docs/currencyPickerRootPropDescriptions.ts
@@ -0,0 +1,25 @@
+import { type CurrencyPickerRootProps } from '../src/components/input/CurrencyPicker/types/CurrencyPickerRootProps';
+
+export const CURRENCY_PICKER_ROOT_PROP_DESCRIPTIONS = {
+ currencies:
+ 'Available currencies in display order. Each code is a unique stable identifier; name and optional symbol are caller-owned data. A currency can be disabled.',
+ value:
+ 'Controlled currency code or null for an empty selection. Undefined leaves selection uncontrolled. Empty and unknown strings remain identifiers.',
+ defaultValue:
+ 'Initial uncontrolled currency code, or null for an empty selection. Defaults to null.',
+ onValueChange:
+ 'Called with the next code or null and cancellable Dropdown selection details: event, reason, trigger, cancel and isCanceled. Calling cancel() preserves selection and prevents automatic close. Repeated single selection does not emit a change.',
+ closeOnSelect:
+ 'Whether committing an enabled option closes the dropdown. Defaults to true. A canceled selection never closes automatically.',
+ disabled: 'Disables the trigger, search input, and every currency option.',
+ selectedFirst:
+ 'Moves the matching selected currency before other results. Defaults to false, preserving catalogue order.',
+ getOptionLabel:
+ 'Returns caller-owned content for a currency option. Defaults to Name (CODE). Display content does not change the search text.',
+ getSearchText:
+ 'Returns searchable text for a currency. Defaults to Name (CODE) and its optional symbol. Search trims the query and matches without case sensitivity.',
+ renderValue:
+ 'Returns selected trigger content from { value, selectedCurrency, disabled }. The default display is the raw code, or the trigger placeholder when null. Trigger children override it.',
+ children:
+ 'Picker parts and supporting content, or a render function receiving { value, selectedCurrency, disabled }. Root owns selection and prepared data without adding a DOM element.',
+} satisfies Partial<Record<keyof CurrencyPickerRootProps, string>>;
diff --git a/packages/twenty-ui/docs/currencyPickerTriggerPropDescriptions.ts b/packages/twenty-ui/docs/currencyPickerTriggerPropDescriptions.ts
new file mode 100644
index 00000000000..49388a93195
--- /dev/null
+++ b/packages/twenty-ui/docs/currencyPickerTriggerPropDescriptions.ts
@@ -0,0 +1,17 @@
+import { type CurrencyPickerTriggerProps } from '../src/components/input/CurrencyPicker/types/CurrencyPickerTriggerProps';
+
+export const CURRENCY_PICKER_TRIGGER_PROP_DESCRIPTIONS = {
+ children:
+ 'Caller-owned trigger content that overrides the selected value display.',
+ placeholder: 'Trigger content displayed when the selected value is null.',
+ disabled:
+ 'Additionally disables the native trigger button. Root disabled state always takes precedence.',
+ id: 'ID forwarded to the trigger button.',
+ className: 'Class applied to the trigger button.',
+ style: 'Inline styles applied to the trigger button.',
+ ref: 'Ref to the trigger button, or the element composed through render.',
+ render:
+ 'Replaces the native trigger button. Forward the supplied props and ref when rendering a custom component.',
+ nativeButton:
+ 'Whether render composes a native button. Set false for a custom non-button element so Base UI supplies button interaction.',
+} satisfies Partial<Record<keyof CurrencyPickerTriggerProps, string>>;
diff --git a/packages/twenty-ui/docs/label-ownership.md b/packages/twenty-ui/docs/label-ownership.md
index 64ff3fcf0b9..e175ed040e8 100644
--- a/packages/twenty-ui/docs/label-ownership.md
+++ b/packages/twenty-ui/docs/label-ownership.md
@@ -2,27 +2,27 @@
This covers production exports under components, primitives, and icons, including the Dropdown compound API.
-| Surface | Text ownership |
-| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Callout | `title`, `description`, `icon`, and `action` nodes, plus `closeLabel` (default `Close`). The optional `onDismiss` requests caller-owned visibility changes. |
-| ListItem | Children, description, action slots, native accessible attributes, and `shortcutJoinLabel` (default `then`). |
-| ListItemButton | Children, description, native accessible attributes, and `shortcutJoinLabel` (default `then`). Independent actions remain sibling controls. |
-| Dropdown | Children name actions, options, titles, sections, empty states, and loading states. `Back` children default to `Back`. Search accepts native placeholder and accessible attributes. Close requires a caller-supplied accessible label and accepts native `aria-labelledby`. Item parts pass `shortcutJoinLabel` to ListItem. |
-| CurrencyPicker | `searchLabel` defaults to `Search` and supplies the search placeholder and accessible name. `emptyLabel` defaults to `No results`. Currency names and codes are caller data; trigger and dropdown accessible names belong to the host. |
-| Legacy menu compositions | MenuItem exposes `text`, contextual slots, and `shortcutJoinLabel` (default `then`). Avatar, draggable, suggestion, and picker presets receive their text from callers; they add no English fallback. Keep this additive option until their separate migration removes the exports. |
-| Button, MainButton, LightButton | Children and native accessible attributes. Applications compose upcoming-feature labels with Badge. Loading preserves the supplied name and marks the button busy; its spinner is decorative. Button hints use the shared Shortcut presentation and remain decorative. `shortcutJoinLabel` supplies the sequence join label. |
-| IconButton and LightIconButton | Caller-supplied accessible label and optional tooltip. Native `aria-labelledby` remains available and takes precedence. |
-| SearchInput | Caller-owned placeholder, native accessible name and action labels. Referenced labels take precedence over explicit labels and placeholder fallback. |
-| CountrySelect | `searchLabel`, `noCountryLabel`, and `noResultsLabel` default to `Search`, `No country`, and `No results`. The search label names the search input and is its placeholder. Applications supply `label` or native accessible names and the country labels, including translated strings. |
-| PhoneCountryPicker | Callers supply country labels and the trigger accessible name. The popup takes the trigger name unless a `Dropdown.Title` or an explicit `Dropdown.Content` label names it, and the selected country label describes the trigger. `searchLabel` defaults to `Search`; `emptyLabel` defaults to `No results`. Calling codes are supplied as data without a leading plus sign. |
-| ImageInput | `uploadLabel`, `removeLabel`, and `abortLabel` default to `Upload`, `Remove`, and `Abort`. The upload label names the visible upload button, preview button, and hidden file input. Native accessible attributes can supply names and descriptions for the file input. Applications supply `helperText` and `errorMessage`, including validation instructions and translated strings. |
-| Toast and Toaster | Caller-owned children, description, icon, action, and `cancelLabel` nodes (default `Cancel`), plus `iconLabel` and `closeLabel` (default `Close`). Live updates replace only supplied fields. Toaster accepts native accessible attributes over its `Notifications` region default. Multiple Toasters mirror one provider-owned notification lifecycle; each region owns its accessible name. |
-| Chip and Avatar | Chip content, translated fallbacks and interactive accessible names belong to the caller. Missing children add no label. Avatar's image and default fallback are decorative. `name` supplies the visual initial and colors. Explicit `imageProps.alt` labels the image and default fallback; caller fallback semantics take precedence. Composed buttons and links own their labels and interaction handlers. |
-| JsonTree | Callers supply empty string, array, and object labels and expanded/collapsed arrow names. JSON booleans, null, property names, and values are data. |
-| ResizeHandle and CodeEditor | ResizeHandle accepts native labels over `Resize`. Hosts supply a contextual label, `aria-controls`, and the focus destination when collapsing a panel removes its handle. CodeEditor exposes `resizeLabel` (default `Resize editor`) and Monaco `options`, including its editor accessible label. The loading indicator adds no text. Monaco owns its internal editor messages. |
-| Input, Textarea, Select, Field, Slider, Radio, RadioGroup, Checkbox, Switch, SegmentedControl | Native attributes, compound label/description/error parts, options, and children belong to the caller. Browser validation messages remain browser-owned; Field.Error children or render content can replace them. |
-| Dialog, AlertDialog, Popover, Tooltip, Tabs | Text belongs to title, description, close, trigger, tab, and popup parts. No built-in English action or status strings. |
-| Banner, InlineBanner, SettingsRow, Section, CommandBlock | Content and labels belong to supplied props or children. |
-| Tag, Status, Badge, AvatarGroup, ColorSample, TintedIconTile, typography, layout and icon exports | Caller content, data values, native accessible attributes where supported, or decorative output. Applications own badge count formatting, clamping, zero visibility, and translated labels. Loader and progress graphics add no built-in English loading message. |
+| Surface | Text ownership |
+| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| Callout | `title`, `description`, `icon`, and `action` nodes, plus `closeLabel` (default `Close`). The optional `onDismiss` requests caller-owned visibility changes. |
+| ListItem | Children, description, action slots, native accessible attributes, and `shortcutJoinLabel` (default `then`). |
+| ListItemButton | Children, description, native accessible attributes, and `shortcutJoinLabel` (default `then`). Independent actions remain sibling controls. |
+| Dropdown | Children name actions, options, titles, sections, empty states, and loading states. `Back` children default to `Back`. Search accepts native placeholder and accessible attributes. Close requires a caller-supplied accessible label and accepts native `aria-labelledby`. Item parts pass `shortcutJoinLabel` to ListItem. |
+| CurrencyPicker | Caller-owned catalogue, option content, selected content, placeholders, and trigger and popup names. `searchLabel` defaults to `Search`; native `searchProps` can override its attributes. `emptyLabel` defaults to `No results`. The listbox inherits the registered Dropdown title or trigger name; `listLabel` names only that selection listbox. Native Options accessible labels stay on its own wrapper div. |
+| Legacy menu compositions | MenuItem exposes `text`, contextual slots, and `shortcutJoinLabel` (default `then`). Avatar, draggable, suggestion, and picker presets receive their text from callers; they add no English fallback. Keep this additive option until their separate migration removes the exports. |
+| Button, MainButton, LightButton | Children and native accessible attributes. Applications compose upcoming-feature labels with Badge. Loading preserves the supplied name and marks the button busy; its spinner is decorative. Button hints use the shared Shortcut presentation and remain decorative. `shortcutJoinLabel` supplies the sequence join label. |
+| IconButton and LightIconButton | Caller-supplied accessible label and optional tooltip. Native `aria-labelledby` remains available and takes precedence. |
+| SearchInput | Caller-owned placeholder, native accessible name and action labels. Referenced labels take precedence over explicit labels and placeholder fallback. |
+| CountrySelect | `searchLabel`, `noCountryLabel`, and `noResultsLabel` default to `Search`, `No country`, and `No results`. The search label names the search input and is its placeholder. Applications supply `label` or native accessible names and the country labels, including translated strings. |
+| PhoneCountryPicker | Callers supply country labels and the trigger accessible name. The popup takes the trigger name unless a `Dropdown.Title` or an explicit `Dropdown.Content` label names it, and the selected country label describes the trigger. `searchLabel` defaults to `Search`; `emptyLabel` defaults to `No results`. Calling codes are supplied as data without a leading plus sign. |
+| ImageInput | `uploadLabel`, `removeLabel`, and `abortLabel` default to `Upload`, `Remove`, and `Abort`. The upload label names the visible upload button, preview button, and hidden file input. Native accessible attributes can supply names and descriptions for the file input. Applications supply `helperText` and `errorMessage`, including validation instructions and translated strings. |
+| Toast and Toaster | Caller-owned children, description, icon, action, and `cancelLabel` nodes (default `Cancel`), plus `iconLabel` and `closeLabel` (default `Close`). Live updates replace only supplied fields. Toaster accepts native accessible attributes over its `Notifications` region default. Multiple Toasters mirror one provider-owned notification lifecycle; each region owns its accessible name. |
+| Chip and Avatar | Chip content, translated fallbacks and interactive accessible names belong to the caller. Missing children add no label. Avatar's image and default fallback are decorative. `name` supplies the visual initial and colors. Explicit `imageProps.alt` labels the image and default fallback; caller fallback semantics take precedence. Composed buttons and links own their labels and interaction handlers. |
+| JsonTree | Callers supply empty string, array, and object labels and expanded/collapsed arrow names. JSON booleans, null, property names, and values are data. |
+| ResizeHandle and CodeEditor | ResizeHandle accepts native labels over `Resize`. Hosts supply a contextual label, `aria-controls`, and the focus destination when collapsing a panel removes its handle. CodeEditor exposes `resizeLabel` (default `Resize editor`) and Monaco `options`, including its editor accessible label. The loading indicator adds no text. Monaco owns its internal editor messages. |
+| Input, Textarea, Select, Field, Slider, Radio, RadioGroup, Checkbox, Switch, SegmentedControl | Native attributes, compound label/description/error parts, options, and children belong to the caller. Browser validation messages remain browser-owned; Field.Error children or render content can replace them. |
+| Dialog, AlertDialog, Popover, Tooltip, Tabs | Text belongs to title, description, close, trigger, tab, and popup parts. No built-in English action or status strings. |
+| Banner, InlineBanner, SettingsRow, Section, CommandBlock | Content and labels belong to supplied props or children. |
+| Tag, Status, Badge, AvatarGroup, ColorSample, TintedIconTile, typography, layout and icon exports | Caller content, data values, native accessible attributes where supported, or decorative output. Applications own badge count formatting, clamping, zero visibility, and translated labels. Loader and progress graphics add no built-in English loading message. |
Shortcut owns symbol and separator formatting for visual hints and strings. Flat key arrays represent simultaneous combinations; nested key arrays represent ordered sequences of combinations. Hosts supply `sequenceJoinLabel` (default `then`), optional `combinationSeparator`, and native accessible labels. The `shortcutJoinLabel` props on host controls forward the sequence label.
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index 9626ef90a30..9c1b41bedf2 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -103,8 +103,12 @@
"types": {
"CountryChoice": "components/input/CountrySelect/types/CountryChoice",
"CountrySelectProps": "components/input/CountrySelect/types/CountrySelectProps",
+ "CurrencyPickerChangeEventDetails": "components/input/CurrencyPicker/types/CurrencyPickerChangeEventDetails",
"CurrencyPickerOption": "components/input/CurrencyPicker/types/CurrencyPickerOption",
"CurrencyPickerOptionsProps": "components/input/CurrencyPicker/types/CurrencyPickerOptionsProps",
+ "CurrencyPickerProps": "components/input/CurrencyPicker/types/CurrencyPickerProps",
+ "CurrencyPickerRootProps": "components/input/CurrencyPicker/types/CurrencyPickerRootProps",
+ "CurrencyPickerState": "components/input/CurrencyPicker/types/CurrencyPickerState",
"CurrencyPickerTriggerProps": "components/input/CurrencyPicker/types/CurrencyPickerTriggerProps",
"IconButtonProps": "components/input/IconButton/types/IconButtonProps",
"IconButtonSize": "components/input/IconButton/types/IconButtonSize",
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 9f5db651447..7b4be243bf8 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -129,24 +129,296 @@
"name": "CurrencyPicker",
"entryPoint": "twenty-ui/components/input",
"slug": "components/input/currency-picker",
- "props": [],
+ "props": [
+ {
+ "name": "children",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Caller-owned trigger content that overrides the selected value display."
+ },
+ {
+ "name": "className",
+ "type": "string | ((state: PopoverTriggerState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Class applied to the trigger button."
+ },
+ {
+ "name": "closeOnSelect",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Whether committing an enabled option closes the dropdown. Defaults to true. A canceled selection never closes automatically."
+ },
+ {
+ "name": "contentProps",
+ "type": "Omit<DropdownContentProps, \"children\">",
+ "required": false,
+ "defaultValue": null,
+ "description": "Dropdown popup props, including placement, width, and accessible attributes."
+ },
+ {
+ "name": "currencies",
+ "type": "readonly CurrencyPickerOption[]",
+ "required": true,
+ "defaultValue": null,
+ "description": "Available currencies in display order. Each code is a unique stable identifier; name and optional symbol are caller-owned data. A currency can be disabled."
+ },
+ {
+ "name": "defaultOpen",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Whether the popup is initially open when uncontrolled."
+ },
+ {
+ "name": "defaultValue",
+ "type": "string | null",
+ "required": false,
+ "defaultValue": "null",
+ "description": "Initial uncontrolled currency code, or null for an empty selection. Defaults to null."
+ },
+ {
+ "name": "disabled",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Disables opening, search, and every currency option."
+ },
+ {
+ "name": "getOptionLabel",
+ "type": "((currency: CurrencyPickerOption) => ReactNode)",
+ "required": false,
+ "defaultValue": "Name (CODE)",
+ "description": "Returns caller-owned content for a currency option. Defaults to Name (CODE). Display content does not change the search text."
+ },
+ {
+ "name": "getSearchText",
+ "type": "((currency: CurrencyPickerOption) => string)",
+ "required": false,
+ "defaultValue": "Name (CODE) and symbol",
+ "description": "Returns searchable text for a currency. Defaults to Name (CODE) and its optional symbol. Search trims the query and matches without case sensitivity."
+ },
+ {
+ "name": "id",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "ID forwarded to the trigger button."
+ },
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Whether render composes a native button. Set false for a custom non-button element so Base UI supplies button interaction."
+ },
+ {
+ "name": "onEscapeKeyDown",
+ "type": "((event: DropdownDismissEvent) => void)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Called before Escape closes the popup. Call event.preventDefault() to keep it open."
+ },
+ {
+ "name": "onInteractOutside",
+ "type": "((event: DropdownDismissEvent) => void)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Called before an outside press or Tab out closes the popup. Call event.preventDefault() to keep it open."
+ },
+ {
+ "name": "onOpenChange",
+ "type": "((open: boolean) => void)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Called with the next open state when the popup opens or closes."
+ },
+ {
+ "name": "onValueChange",
+ "type": "((value: string | null, eventDetails: DropdownSelectionGroupChangeEventDetails) => void)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Called with the next code or null and cancellable Dropdown selection details: event, reason, trigger, cancel and isCanceled. Calling cancel() preserves selection and prevents automatic close. Repeated single selection does not emit a change."
+ },
+ {
+ "name": "open",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Whether the popup is open. Use with onOpenChange to control it."
+ },
+ {
+ "name": "optionsProps",
+ "type": "CurrencyPickerOptionsProps",
+ "required": false,
+ "defaultValue": null,
+ "description": "Props for the options wrapper div, listLabel, and search behavior. Native input customization belongs in optionsProps.searchProps."
+ },
+ {
+ "name": "placeholder",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Trigger content displayed when the selected value is null."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLButtonElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the trigger button, or the element composed through render."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverTriggerState>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Replaces the native trigger button. Forward the supplied props and ref when rendering a custom component."
+ },
+ {
+ "name": "renderValue",
+ "type": "((state: CurrencyPickerState) => ReactNode)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Returns selected trigger content from { value, selectedCurrency, disabled }. The default display is the raw code, or the trigger placeholder when null. Trigger children override it."
+ },
+ {
+ "name": "selectedFirst",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Moves the matching selected currency before other results. Defaults to false, preserving catalogue order."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties | ((state: PopoverTriggerState) => CSSProperties | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Inline styles applied to the trigger button."
+ },
+ {
+ "name": "triggerProps",
+ "type": "CurrencyPickerTriggerProps",
+ "required": false,
+ "defaultValue": null,
+ "description": "Props for the trigger button, including native attributes, ref, render, placeholder, and caller-owned children. These override shorthand trigger props."
+ },
+ {
+ "name": "value",
+ "type": "string | null",
+ "required": false,
+ "defaultValue": null,
+ "description": "Controlled currency code or null for an empty selection. Undefined leaves selection uncontrolled. Empty and unknown strings remain identifiers."
+ }
+ ],
"parts": [
+ {
+ "name": "Root",
+ "props": [
+ {
+ "name": "children",
+ "type": "ReactNode | ((state: CurrencyPickerState) => ReactNode)",
+ "required": true,
+ "defaultValue": null,
+ "description": "Picker parts and supporting content, or a render function receiving { value, selectedCurrency, disabled }. Root owns selection and prepared data without adding a DOM element."
+ },
+ {
+ "name": "closeOnSelect",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Whether committing an enabled option closes the dropdown. Defaults to true. A canceled selection never closes automatically."
+ },
+ {
+ "name": "currencies",
+ "type": "readonly CurrencyPickerOption[]",
+ "required": true,
+ "defaultValue": null,
+ "description": "Available currencies in display order. Each code is a unique stable identifier; name and optional symbol are caller-owned data. A currency can be disabled."
+ },
+ {
+ "name": "defaultValue",
+ "type": "string | null",
+ "required": false,
+ "defaultValue": "null",
+ "description": "Initial uncontrolled currency code, or null for an empty selection. Defaults to null."
+ },
+ {
+ "name": "disabled",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Disables the trigger, search input, and every currency option."
+ },
+ {
+ "name": "getOptionLabel",
+ "type": "((currency: CurrencyPickerOption) => ReactNode)",
+ "required": false,
+ "defaultValue": "Name (CODE)",
+ "description": "Returns caller-owned content for a currency option. Defaults to Name (CODE). Display content does not change the search text."
+ },
+ {
+ "name": "getSearchText",
+ "type": "((currency: CurrencyPickerOption) => string)",
+ "required": false,
+ "defaultValue": "Name (CODE) and symbol",
+ "description": "Returns searchable text for a currency. Defaults to Name (CODE) and its optional symbol. Search trims the query and matches without case sensitivity."
+ },
+ {
+ "name": "onValueChange",
+ "type": "((value: string | null, eventDetails: DropdownSelectionGroupChangeEventDetails) => void)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Called with the next code or null and cancellable Dropdown selection details: event, reason, trigger, cancel and isCanceled. Calling cancel() preserves selection and prevents automatic close. Repeated single selection does not emit a change."
+ },
+ {
+ "name": "renderValue",
+ "type": "((state: CurrencyPickerState) => ReactNode)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Returns selected trigger content from { value, selectedCurrency, disabled }. The default display is the raw code, or the trigger placeholder when null. Trigger children override it."
+ },
+ {
+ "name": "selectedFirst",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Moves the matching selected currency before other results. Defaults to false, preserving catalogue order."
+ },
+ {
+ "name": "value",
+ "type": "string | null",
+ "required": false,
+ "defaultValue": null,
+ "description": "Controlled currency code or null for an empty selection. Undefined leaves selection uncontrolled. Empty and unknown strings remain identifiers."
+ }
+ ]
+ },
{
"name": "Trigger",
"props": [
+ {
+ "name": "children",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Caller-owned trigger content that overrides the selected value display."
+ },
{
"name": "className",
"type": "string | ((state: PopoverTriggerState) => string | undefined)",
"required": false,
"defaultValue": null,
- "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
+ "description": "Class applied to the trigger button."
},
{
"name": "disabled",
"type": "boolean",
"required": false,
- "defaultValue": null,
- "description": "Disables opening the picker."
+ "defaultValue": "false",
+ "description": "Additionally disables the native trigger button. Root disabled state always takes precedence."
},
{
"name": "id",
@@ -160,7 +432,21 @@
"type": "boolean",
"required": false,
"defaultValue": "true",
- "description": "Whether the component renders a native `<button>` element when replacing it\nvia the `render` prop.\nSet to `false` if the rendered element is not a button (e.g. `<div>`)."
+ "description": "Whether render composes a native button. Set false for a custom non-button element so Base UI supplies button interaction."
+ },
+ {
+ "name": "placeholder",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Trigger content displayed when the selected value is null."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLButtonElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the trigger button, or the element composed through render."
},
{
"name": "render",
@@ -174,14 +460,7 @@
"type": "CSSProperties | ((state: PopoverTriggerState) => 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,
- "defaultValue": null,
- "description": "Required currency code displayed beside the chevron. The application chooses its initial value and any fallback."
+ "description": "Inline styles applied to the trigger button."
}
]
},
@@ -189,39 +468,53 @@
"name": "Options",
"props": [
{
- "name": "currencies",
- "type": "readonly CurrencyPickerOption[]",
- "required": true,
+ "name": "className",
+ "type": "string",
+ "required": false,
"defaultValue": null,
- "description": "Available currency codes and names, in catalogue order. Each code must be unique. An option can be disabled."
+ "description": "Class applied to the options wrapper div."
},
{
"name": "disabled",
"type": "boolean",
"required": false,
"defaultValue": "false",
- "description": "Disables search and every currency option."
+ "description": "Additionally disables search and every currency option. Root disabled state always takes precedence."
},
{
"name": "emptyLabel",
- "type": "string",
+ "type": "ReactNode",
"required": false,
"defaultValue": "No results",
- "description": "Text announced when no currencies match. Defaults to No results."
+ "description": "Content announced when no currencies match. Defaults to No results."
},
{
- "name": "onValueChange",
- "type": "(code: string) => void",
- "required": true,
+ "name": "listLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Accessible name for the selection listbox. Defaults to the registered Dropdown title or trigger name. Native accessible attributes on Options target only its wrapper."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
"defaultValue": null,
- "description": "Called with the code chosen by pointer or keyboard. The application updates the selected value."
+ "description": "Ref to the options wrapper div, or the element composed through render."
},
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",
"required": false,
"defaultValue": null,
- "description": "Replaces the non-interactive root div. Forward the supplied props and ref when rendering a custom component."
+ "description": "Replaces the non-interactive wrapper div. Forward the supplied props and ref when rendering a custom component. Use searchProps.render to customize the input."
+ },
+ {
+ "name": "searchable",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Renders a search input above the options. Defaults to true."
},
{
"name": "searchLabel",
@@ -231,11 +524,18 @@
"description": "Search placeholder and accessible name. Defaults to Search."
},
{
- "name": "value",
- "type": "string",
+ "name": "searchProps",
+ "type": "DropdownSearchProps",
+ "required": false,
+ "defaultValue": null,
+ "description": "Native input attributes, ref, render, and controlled or uncontrolled query props forwarded to Dropdown.Search. Use value with onValueChange or defaultValue."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties",
"required": false,
"defaultValue": null,
- "description": "Selected currency code. Its matching row appears first and is marked pressed."
+ "description": "Inline styles applied to the options wrapper div."
}
]
}
@@ -13976,7 +14276,7 @@
},
{
"name": "avatar",
- "type": "Pick<AvatarProps, \"name\" | \"size\" | \"shape\" | \"src\" | \"colorSeed\"> | null",
+ "type": "Pick<AvatarProps, \"name\" | \"size\" | \"src\" | \"shape\" | \"colorSeed\"> | null",
"required": false,
"defaultValue": null,
"description": "Avatar name, source, color seed, size, and shape. Omit to hide the avatar."
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/CurrencyPicker.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/CurrencyPicker.tsx
index c43d1b1a36c..01d4f5e6b54 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/CurrencyPicker.tsx
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/CurrencyPicker.tsx
@@ -1,7 +1,10 @@
import { CurrencyPickerOptions } from './internal/CurrencyPickerOptions';
+import { CurrencyPickerRoot } from './internal/CurrencyPickerRoot';
+import { CurrencyPickerShorthand } from './internal/CurrencyPickerShorthand';
import { CurrencyPickerTrigger } from './internal/CurrencyPickerTrigger';
-export const CurrencyPicker = {
+export const CurrencyPicker = Object.assign(CurrencyPickerShorthand, {
+ Root: CurrencyPickerRoot,
Trigger: CurrencyPickerTrigger,
Options: CurrencyPickerOptions,
-};
+});
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.api.stories.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.api.stories.tsx
new file mode 100644
index 00000000000..c44ef4d033b
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.api.stories.tsx
@@ -0,0 +1,590 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { createRef } from 'react';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
+
+import { CurrencyPicker } from '../CurrencyPicker';
+import { type CurrencyPickerChangeEventDetails } from '../types/CurrencyPickerChangeEventDetails';
+import { CurrencyPickerChangingDefaultExample } from './CurrencyPickerChangingDefaultExample';
+import { CurrencyPickerControlledExample } from './CurrencyPickerControlledExample';
+import { CurrencyPickerControlledSearchExample } from './CurrencyPickerControlledSearchExample';
+import { CurrencyPickerExample } from './CurrencyPickerExample';
+import { CurrencyPickerListLabelExample } from './CurrencyPickerListLabelExample';
+import { CurrencyPickerRootStateExample } from './CurrencyPickerRootStateExample';
+import { CURRENCY_PICKER_STORY_OPTIONS } from './currencyPickerStoryOptions';
+import { openCurrencyPicker } from './openCurrencyPicker';
+
+const meta: Meta<typeof CurrencyPickerExample> = {
+ id: 'ui-input-currencypicker-api',
+ title: 'UI/Components/Input/CurrencyPicker/API',
+ component: CurrencyPickerExample,
+ render: (args) => (
+ <CurrencyPickerExample
+ key={args.defaultValue}
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ />
+ ),
+ decorators: [ComponentDecorator],
+ args: { onValueChange: fn() },
+ parameters: {
+ container: { width: 360, height: 420 },
+ a11y: A11Y_DEFER_COLOR_CONTRAST,
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof CurrencyPickerExample>;
+
+const nativeSearchRef = createRef<HTMLInputElement>();
+
+export const ControlledExternalUpdates: Story = {
+ render: (args) => (
+ <CurrencyPickerControlledExample
+ composition={args.composition}
+ onValueChange={args.onValueChange}
+ />
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const trigger = canvas.getByRole('button', { name: 'Currency' });
+
+ await expect(trigger.textContent).toBe('USD');
+ await userEvent.click(canvas.getByRole('button', { name: 'Set Euro' }));
+ await expect(trigger).toHaveTextContent('EUR');
+ const selectedPicker = await openCurrencyPicker({ canvasElement });
+
+ await expect(
+ within(selectedPicker.dialog).getByRole('listbox', { name: 'Currency' }),
+ ).toHaveAttribute('aria-labelledby', trigger.id);
+
+ await expect(
+ within(selectedPicker.dialog).getByRole('option', { name: 'Euro (EUR)' }),
+ ).toHaveAttribute('aria-selected', 'true');
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(selectedPicker.dialog).not.toBeInTheDocument());
+
+ for (const { buttonLabel, expectedLabel } of [
+ { buttonLabel: 'Clear currency', expectedLabel: '' },
+ { buttonLabel: 'Set unknown currency', expectedLabel: 'ZZZ' },
+ { buttonLabel: 'Set empty identifier', expectedLabel: '' },
+ ]) {
+ await userEvent.click(canvas.getByRole('button', { name: buttonLabel }));
+ await expect(trigger.textContent).toBe(expectedLabel);
+ const picker = await openCurrencyPicker({ canvasElement });
+
+ await expect(
+ within(picker.dialog).queryAllByRole('option', { selected: true }),
+ ).toHaveLength(0);
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(picker.dialog).not.toBeInTheDocument());
+ }
+
+ await expect(args.onValueChange).not.toHaveBeenCalled();
+ const picker = await openCurrencyPicker({ canvasElement });
+ await userEvent.click(
+ within(picker.dialog).getByRole('option', {
+ name: 'Australian Dollar (AUD)',
+ }),
+ );
+ await waitFor(() => expect(picker.dialog).not.toBeInTheDocument());
+ await expect(trigger).toHaveTextContent('AUD');
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'AUD',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
+ },
+};
+
+export const CompoundControlledExternalUpdates: Story = {
+ ...ControlledExternalUpdates,
+ args: { composition: 'compound' },
+};
+
+export const CanceledSelection: Story = {
+ args: {
+ onValueChange: fn(
+ (_value: string | null, eventDetails: CurrencyPickerChangeEventDetails) =>
+ eventDetails.cancel(),
+ ),
+ },
+ play: async ({ canvasElement, args }) => {
+ const { trigger, dialog, search } = await openCurrencyPicker({
+ canvasElement,
+ });
+ const euro = within(dialog).getByRole('option', { name: 'Euro (EUR)' });
+
+ await userEvent.click(euro);
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'EUR',
+ expect.objectContaining({
+ reason: 'item-press',
+ event: expect.objectContaining({ type: 'click', target: euro }),
+ trigger: euro,
+ isCanceled: true,
+ }),
+ );
+ await expect(trigger).toHaveTextContent('USD');
+ await expect(dialog).toBeVisible();
+ await expect(euro).toHaveAttribute('aria-selected', 'false');
+ await userEvent.type(search, 'euro');
+ await userEvent.keyboard('{Shift>}{Enter}{/Shift}');
+ await expect(args.onValueChange).toHaveBeenLastCalledWith(
+ 'EUR',
+ expect.objectContaining({
+ reason: 'item-press',
+ event: expect.objectContaining({
+ key: 'Enter',
+ shiftKey: true,
+ target: search,
+ }),
+ trigger: euro,
+ isCanceled: true,
+ }),
+ );
+ await expect(args.onValueChange).toHaveBeenCalledTimes(2);
+ await expect(trigger).toHaveTextContent('USD');
+ await expect(dialog).toBeVisible();
+ },
+};
+
+export const CompoundCanceledSelection: Story = {
+ ...CanceledSelection,
+ args: {
+ composition: 'compound',
+ onValueChange: fn(
+ (_value: string | null, eventDetails: CurrencyPickerChangeEventDetails) =>
+ eventDetails.cancel(),
+ ),
+ },
+};
+
+export const SelectedFirstIsExplicit: Story = {
+ args: { selectedFirst: true },
+ play: async ({ canvasElement }) => {
+ const { dialog } = await openCurrencyPicker({ canvasElement });
+
+ await expect(within(dialog).getAllByRole('option')[0]).toHaveTextContent(
+ 'US Dollar (USD)',
+ );
+ },
+};
+
+export const CallerPresentationAndSearch: Story = {
+ args: {
+ defaultValue: 'EUR',
+ currencies: [
+ { code: 'USD', name: 'Dollar', symbol: '$' },
+ { code: 'EUR', name: 'Euro', symbol: '€' },
+ ],
+ getOptionLabel: (currency) => (
+ <Text>
+ {currency.symbol} {currency.name}
+ </Text>
+ ),
+ getSearchText: (currency) =>
+ `${currency.code} ${currency.name} ${currency.symbol}`,
+ renderValue: ({ selectedCurrency, value }) =>
+ selectedCurrency?.symbol ?? value,
+ },
+ play: async ({ canvasElement, args }) => {
+ const { trigger, dialog, search } = await openCurrencyPicker({
+ canvasElement,
+ });
+
+ await expect(trigger).toHaveTextContent('€');
+ await userEvent.type(search, '$');
+ await expect(within(dialog).getAllByRole('option')).toHaveLength(1);
+ await userEvent.click(
+ within(dialog).getByRole('option', { name: '$ Dollar' }),
+ );
+ await waitFor(() => expect(dialog).not.toBeInTheDocument());
+ await expect(trigger).toHaveTextContent('$');
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'USD',
+ expect.objectContaining({ reason: 'item-press' }),
+ );
+ },
+};
+
+export const CompoundCallerPresentationAndSearch: Story = {
+ ...CallerPresentationAndSearch,
+ args: { ...CallerPresentationAndSearch.args, composition: 'compound' },
+};
+
+export const EmptyCurrencies: Story = {
+ args: {
+ currencies: [],
+ defaultValue: null,
+ emptyLabel: 'No currencies available',
+ },
+ play: async ({ canvasElement, args }) => {
+ const { dialog, search } = await openCurrencyPicker({ canvasElement });
+
+ await expect(within(dialog).queryAllByRole('option')).toHaveLength(0);
+ await expect(within(dialog).getByRole('status')).toHaveTextContent(
+ 'No currencies available',
+ );
+ await userEvent.type(search, 'EUR');
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onValueChange).not.toHaveBeenCalled();
+ await expect(dialog).toBeVisible();
+ },
+};
+
+export const SearchDisabledUsesSelectedOpeningFocus: Story = {
+ args: { searchable: false, defaultValue: 'EUR' },
+ play: async ({ canvasElement, args }) => {
+ await userEvent.click(
+ within(canvasElement).getByRole('button', { name: 'Currency' }),
+ );
+ const dialog = await within(canvasElement.ownerDocument.body).findByRole(
+ 'dialog',
+ { name: 'Currency' },
+ );
+ const euro = within(dialog).getByRole('option', { name: 'Euro (EUR)' });
+
+ await expect(
+ within(dialog).queryByRole('searchbox'),
+ ).not.toBeInTheDocument();
+ await waitFor(() => expect(euro).toHaveFocus());
+ await userEvent.keyboard('{ArrowDown}');
+ const japaneseYen = within(dialog).getByRole('option', {
+ name: 'Japanese Yen (JPY)',
+ });
+ await expect(japaneseYen).toHaveFocus();
+ await expect(args.onValueChange).not.toHaveBeenCalled();
+ await userEvent.keyboard(' ');
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'JPY',
+ expect.objectContaining({ reason: 'item-press' }),
+ );
+ await waitFor(() => expect(dialog).not.toBeInTheDocument());
+ },
+};
+
+export const EmptyIdentifierIsSelectable: Story = {
+ args: {
+ defaultValue: 'USD',
+ currencies: [
+ { code: '', name: 'No currency' },
+ { code: 'USD', name: 'US Dollar' },
+ ],
+ getOptionLabel: (currency) => currency.name,
+ },
+ play: async ({ canvasElement, args }) => {
+ const { trigger, dialog } = await openCurrencyPicker({ canvasElement });
+
+ await userEvent.click(
+ within(dialog).getByRole('option', { name: 'No currency' }),
+ );
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ '',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
+ await waitFor(() => expect(dialog).not.toBeInTheDocument());
+ await expect(trigger.textContent).toBe('');
+ const reopenedPicker = await openCurrencyPicker({ canvasElement });
+
+ await expect(
+ within(reopenedPicker.dialog).getByRole('option', {
+ name: 'No currency',
+ }),
+ ).toHaveAttribute('aria-selected', 'true');
+ },
+};
+
+export const UnknownDefaultValue: Story = {
+ args: { defaultValue: 'ZZZ' },
+ play: async ({ canvasElement, args }) => {
+ const { trigger, dialog, search } = await openCurrencyPicker({
+ canvasElement,
+ });
+
+ await expect(trigger).toHaveTextContent('ZZZ');
+ await expect(
+ within(dialog).queryAllByRole('option', { selected: true }),
+ ).toHaveLength(0);
+ await userEvent.type(search, 'eur');
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'EUR',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
+ await waitFor(() => expect(dialog).not.toBeInTheDocument());
+ await expect(trigger).toHaveTextContent('EUR');
+ },
+};
+
+export const DefaultSearchAndPersistentSelection: Story = {
+ args: {
+ closeOnSelect: false,
+ searchProps: { defaultValue: 'yen' },
+ },
+ play: async ({ canvasElement, args }) => {
+ const { trigger, dialog, search } = await openCurrencyPicker({
+ canvasElement,
+ });
+ const japaneseYen = within(dialog).getByRole('option', {
+ name: 'Japanese Yen (JPY)',
+ });
+
+ await expect(search).toHaveValue('yen');
+ await expect(within(dialog).getAllByRole('option')).toHaveLength(1);
+ await expect(args.onValueChange).not.toHaveBeenCalled();
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'JPY',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
+ await expect(trigger).toHaveTextContent('JPY');
+ await expect(dialog).toBeVisible();
+ await expect(japaneseYen).toHaveAttribute('aria-selected', 'true');
+ await userEvent.click(japaneseYen);
+ await expect(args.onValueChange).toHaveBeenCalledOnce();
+ await expect(dialog).toBeVisible();
+ await userEvent.clear(search);
+ await expect(within(dialog).getAllByRole('option')).toHaveLength(5);
+ await expect(japaneseYen).toHaveAttribute('aria-selected', 'true');
+ },
+};
+
+export const CompoundDefaultSearchAndPersistentSelection: Story = {
+ ...DefaultSearchAndPersistentSelection,
+ args: {
+ ...DefaultSearchAndPersistentSelection.args,
+ composition: 'compound',
+ },
+};
+
+export const ControlledSearchQuery: Story = {
+ render: (args) => (
+ <CurrencyPickerControlledSearchExample
+ composition={args.composition}
+ onValueChange={args.onValueChange}
+ />
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Find Euro' }));
+ const picker = await openCurrencyPicker({ canvasElement });
+
+ await expect(picker.search).toHaveValue('EUR');
+ await expect(within(picker.dialog).getAllByRole('option')).toHaveLength(1);
+ await expect(
+ within(picker.dialog).getByRole('option'),
+ ).toHaveAccessibleName('Euro (EUR)');
+ await userEvent.clear(picker.search);
+ await expect(picker.search).toHaveValue('');
+ await expect(within(picker.dialog).getAllByRole('option')).toHaveLength(5);
+ await userEvent.type(picker.search, 'jpy');
+ await expect(picker.search).toHaveValue('jpy');
+ await expect(within(picker.dialog).getAllByRole('option')).toHaveLength(1);
+ await userEvent.keyboard('{Enter}');
+ await expect(picker.trigger).toHaveTextContent('JPY');
+ await expect(picker.dialog).toBeVisible();
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'JPY',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(picker.dialog).not.toBeInTheDocument());
+ await userEvent.click(canvas.getByRole('button', { name: 'Find Euro' }));
+ const reopenedPicker = await openCurrencyPicker({ canvasElement });
+ const euro = within(reopenedPicker.dialog).getByRole('option', {
+ name: 'Euro (EUR)',
+ });
+
+ await expect(reopenedPicker.search).toHaveValue('EUR');
+ await expect(reopenedPicker.trigger).toHaveTextContent('JPY');
+ await expect(euro).toHaveAttribute('aria-selected', 'false');
+ await userEvent.click(euro);
+ await expect(args.onValueChange).toHaveBeenLastCalledWith(
+ 'EUR',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
+ await expect(args.onValueChange).toHaveBeenCalledTimes(2);
+ await expect(reopenedPicker.trigger).toHaveTextContent('EUR');
+ await expect(reopenedPicker.dialog).toBeVisible();
+ },
+};
+
+export const CompoundControlledSearchQuery: Story = {
+ ...ControlledSearchQuery,
+ args: { composition: 'compound' },
+};
+
+export const DefaultChangesBeforeOpening: Story = {
+ render: (args) => (
+ <CurrencyPickerChangingDefaultExample
+ composition={args.composition}
+ onValueChange={args.onValueChange}
+ />
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const trigger = canvas.getByRole('button', { name: 'Currency' });
+
+ await expect(trigger).toHaveTextContent('USD');
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Change default to Euro' }),
+ );
+ await expect(trigger).toHaveTextContent('USD');
+ const picker = await openCurrencyPicker({ canvasElement });
+
+ await expect(
+ within(picker.dialog).getByRole('option', { name: 'US Dollar (USD)' }),
+ ).toHaveAttribute('aria-selected', 'true');
+ await expect(args.onValueChange).not.toHaveBeenCalled();
+ await userEvent.click(
+ within(picker.dialog).getByRole('option', {
+ name: 'Australian Dollar (AUD)',
+ }),
+ );
+ await waitFor(() => expect(picker.dialog).not.toBeInTheDocument());
+ await expect(trigger).toHaveTextContent('AUD');
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Change default to Yen' }),
+ );
+ await expect(trigger).toHaveTextContent('AUD');
+ const reopenedPicker = await openCurrencyPicker({ canvasElement });
+
+ await expect(
+ within(reopenedPicker.dialog).getByRole('option', {
+ name: 'Australian Dollar (AUD)',
+ }),
+ ).toHaveAttribute('aria-selected', 'true');
+ await expect(args.onValueChange).toHaveBeenCalledOnce();
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'AUD',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
+ },
+};
+
+export const CompoundDefaultChangesBeforeOpening: Story = {
+ ...DefaultChangesBeforeOpening,
+ args: { composition: 'compound' },
+};
+
+export const PreparedRootState: Story = {
+ render: () => <CurrencyPickerRootStateExample />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const host = canvas.getByTestId('root-host');
+ const rootState = canvas.getByTestId('root-state');
+
+ await expect(rootState).toHaveTextContent('USD:US Dollar:true');
+ await expect(host.children).toHaveLength(1);
+ await expect(host.firstElementChild).toBe(rootState);
+ await userEvent.click(canvas.getByRole('button', { name: 'Use Euro' }));
+ await expect(rootState).toHaveTextContent('EUR:Euro:false');
+ await expect(host.firstElementChild).toBe(rootState);
+ },
+};
+
+export const NativeTargets: Story = {
+ render: () => (
+ <CurrencyPicker
+ currencies={CURRENCY_PICKER_STORY_OPTIONS}
+ defaultValue={null}
+ placeholder="Choose currency"
+ title="Top level trigger title"
+ triggerProps={{ title: 'Trigger title', 'aria-label': 'Currency' }}
+ optionsProps={{
+ title: 'Options title',
+ 'aria-label': 'Options wrapper',
+ listLabel: 'Supported currencies',
+ render: <section data-options-render="native" />,
+ searchProps: {
+ ref: nativeSearchRef,
+ title: 'Search title',
+ 'aria-label': 'Find a currency',
+ render: <input data-search-render="native" />,
+ },
+ }}
+ contentProps={{
+ 'aria-label': 'Available currencies',
+ title: 'Popup title',
+ }}
+ />
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const trigger = canvas.getByRole('button', { name: 'Currency' });
+
+ await expect(trigger.textContent).toBe('Choose currency');
+ await expect(trigger).toHaveAttribute('title', 'Trigger title');
+ await userEvent.click(trigger);
+ const dialog = await within(canvasElement.ownerDocument.body).findByRole(
+ 'dialog',
+ { name: 'Available currencies' },
+ );
+ const options = within(dialog).getByTitle('Options title');
+ const search = within(dialog).getByRole('searchbox', {
+ name: 'Find a currency',
+ });
+
+ await expect(dialog).toHaveAttribute('title', 'Popup title');
+ await expect(options.tagName).toBe('SECTION');
+ await expect(options).toHaveAttribute('aria-label', 'Options wrapper');
+ const listbox = within(dialog).getByRole('listbox', {
+ name: 'Supported currencies',
+ });
+
+ await expect(listbox).toHaveAttribute('aria-label', 'Supported currencies');
+ await expect(listbox).not.toHaveAttribute('aria-labelledby');
+ await expect(options).toHaveAttribute('data-options-render', 'native');
+ await expect(search).toHaveAttribute('title', 'Search title');
+ await expect(search).toHaveAttribute('data-search-render', 'native');
+ await expect(nativeSearchRef.current).toBe(search);
+ await waitFor(() => expect(search).toHaveFocus());
+ await userEvent.type(search, 'EUR');
+ await userEvent.keyboard('{Enter}');
+ await waitFor(() => expect(dialog).not.toBeInTheDocument());
+ await expect(trigger).toHaveTextContent('EUR');
+ await expect(nativeSearchRef.current).toBeNull();
+ },
+};
+
+export const ListLabelUsesTitleThenTrigger: Story = {
+ render: () => <CurrencyPickerListLabelExample />,
+ play: async ({ canvasElement }) => {
+ const trigger = within(canvasElement).getByRole('button', {
+ name: 'Billing currency',
+ });
+
+ await userEvent.click(trigger);
+ const dialog = await within(canvasElement.ownerDocument.body).findByRole(
+ 'dialog',
+ { name: 'Currency options' },
+ );
+ const listbox = within(dialog).getByRole('listbox', {
+ name: 'Billing currencies',
+ });
+ const title = within(dialog).getByText('Billing currencies');
+ const options = within(dialog).getByLabelText('Currency options wrapper');
+
+ await expect(listbox).toHaveAttribute('aria-labelledby', title.id);
+ await expect(listbox).not.toHaveAttribute('aria-label');
+ await userEvent.click(
+ within(dialog).getByRole('button', { name: 'Hide title' }),
+ );
+ await waitFor(() =>
+ expect(listbox).toHaveAccessibleName('Billing currency'),
+ );
+ await expect(listbox).toHaveAttribute('aria-labelledby', trigger.id);
+ await expect(options).toHaveAttribute(
+ 'aria-label',
+ 'Currency options wrapper',
+ );
+ await userEvent.click(
+ within(listbox).getByRole('option', { name: 'Euro (EUR)' }),
+ );
+ await waitFor(() => expect(dialog).not.toBeInTheDocument());
+ await expect(trigger).toHaveTextContent('EUR');
+ },
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.interactions.stories.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.interactions.stories.tsx
index 2b74e081ebf..b8453152bd4 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.interactions.stories.tsx
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.interactions.stories.tsx
@@ -11,7 +11,13 @@ const meta: Meta<typeof CurrencyPickerExample> = {
id: 'ui-input-currencypicker-interactions',
title: 'UI/Components/Input/CurrencyPicker/Interactions',
component: CurrencyPickerExample,
- render: (args) => <CurrencyPickerExample key={args.defaultValue} {...args} />,
+ render: (args) => (
+ <CurrencyPickerExample
+ key={args.defaultValue}
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ />
+ ),
decorators: [ComponentDecorator],
args: { onValueChange: fn() },
parameters: {
@@ -30,35 +36,38 @@ export const SearchAndPointerSelection: Story = {
});
const options = within(dialog);
- await expect(options.getAllByRole('button')[0]).toHaveTextContent(
- 'US Dollar (USD)',
+ await expect(options.getAllByRole('option')[0]).toHaveTextContent(
+ 'Australian Dollar (AUD)',
);
await expect(
- options.getByRole('button', { name: 'US Dollar (USD)' }),
- ).toHaveAttribute('aria-pressed', 'true');
+ options.getByRole('option', { name: 'US Dollar (USD)' }),
+ ).toHaveAttribute('aria-selected', 'true');
await userEvent.type(search, 'dOlLaR');
- await expect(options.getAllByRole('button')).toHaveLength(2);
- await expect(options.getAllByRole('button')[0]).toHaveTextContent(
- 'US Dollar (USD)',
+ await expect(options.getAllByRole('option')).toHaveLength(2);
+ await expect(options.getAllByRole('option')[0]).toHaveTextContent(
+ 'Australian Dollar (AUD)',
);
await userEvent.clear(search);
await userEvent.type(search, 'eUr');
- await expect(options.getAllByRole('button')).toHaveLength(1);
+ await expect(options.getAllByRole('option')).toHaveLength(1);
await expect(
- options.queryByRole('button', { name: 'US Dollar (USD)' }),
+ options.queryByRole('option', { name: 'US Dollar (USD)' }),
).not.toBeInTheDocument();
await userEvent.clear(search);
await userEvent.type(search, ' eUr ');
- await expect(options.getAllByRole('button')).toHaveLength(1);
- await expect(options.getByRole('button')).toHaveAccessibleName(
+ await expect(options.getAllByRole('option')).toHaveLength(1);
+ await expect(options.getByRole('option')).toHaveAccessibleName(
'Euro (EUR)',
);
await userEvent.clear(search);
await userEvent.type(search, 'Euro (EUR)');
- await expect(options.getAllByRole('button')).toHaveLength(1);
- await userEvent.click(options.getByRole('button', { name: 'Euro (EUR)' }));
+ await expect(options.getAllByRole('option')).toHaveLength(1);
+ await userEvent.click(options.getByRole('option', { name: 'Euro (EUR)' }));
await expect(args.onValueChange).toHaveBeenCalledOnce();
- await expect(args.onValueChange).toHaveBeenCalledWith('EUR');
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'EUR',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
await waitFor(() => expect(dialog).not.toBeInTheDocument());
await expect(trigger).toHaveTextContent('EUR');
await waitFor(() => expect(trigger).toHaveFocus());
@@ -88,15 +97,31 @@ export const KeyboardNavigation: Story = {
await expect(trigger).toHaveAttribute('aria-expanded', 'true');
await userEvent.keyboard('{ArrowDown}');
await expect(
- within(dialog).getByRole('button', { name: 'US Dollar (USD)' }),
+ within(dialog).getByRole('option', { name: 'Australian Dollar (AUD)' }),
).toHaveFocus();
await userEvent.keyboard('{ArrowDown}');
await expect(
- within(dialog).getByRole('button', { name: 'Australian Dollar (AUD)' }),
+ within(dialog).getByRole('option', { name: 'Euro (EUR)' }),
).toHaveFocus();
- await userEvent.keyboard('{Enter}');
+ await userEvent.keyboard('{ArrowDown}');
+ await expect(
+ within(dialog).getByRole('option', { name: 'Japanese Yen (JPY)' }),
+ ).toHaveFocus();
+ await userEvent.keyboard('{Home}');
+ await expect(
+ within(dialog).getByRole('option', { name: 'Australian Dollar (AUD)' }),
+ ).toHaveFocus();
+ await userEvent.keyboard('{End}');
+ await expect(
+ within(dialog).getByRole('option', { name: 'US Dollar (USD)' }),
+ ).toHaveFocus();
+ await expect(args.onValueChange).not.toHaveBeenCalled();
+ await userEvent.keyboard('{ArrowUp}{Enter}');
await expect(args.onValueChange).toHaveBeenCalledOnce();
- await expect(args.onValueChange).toHaveBeenCalledWith('AUD');
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'JPY',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
await waitFor(() => expect(dialog).not.toBeInTheDocument());
await waitFor(() => expect(trigger).toHaveFocus());
},
@@ -109,7 +134,7 @@ export const MatchingSearchEnter: Story = {
});
await userEvent.type(search, 'jApAn');
- const japaneseYen = within(dialog).getByRole('button', {
+ const japaneseYen = within(dialog).getByRole('option', {
name: 'Japanese Yen (JPY)',
});
@@ -122,7 +147,10 @@ export const MatchingSearchEnter: Story = {
);
await userEvent.keyboard('{Enter}');
await expect(args.onValueChange).toHaveBeenCalledOnce();
- await expect(args.onValueChange).toHaveBeenCalledWith('JPY');
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'JPY',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
await waitFor(() => expect(dialog).not.toBeInTheDocument());
await expect(trigger).toHaveTextContent('JPY');
},
@@ -144,7 +172,7 @@ export const EmptyResultsAndLabelOverrides: Story = {
await expect(emptyStatus).toBeEmptyDOMElement();
await userEvent.type(search, 'unknown');
- await expect(within(dialog).queryAllByRole('button')).toHaveLength(0);
+ await expect(within(dialog).queryAllByRole('option')).toHaveLength(0);
await expect(emptyStatus).toHaveTextContent('No matching currencies');
await userEvent.keyboard('{Enter}');
await expect(args.onValueChange).not.toHaveBeenCalled();
@@ -161,7 +189,7 @@ export const DisabledCurrency: Story = {
const { trigger, dialog, search } = await openCurrencyPicker({
canvasElement,
});
- const disabledCurrency = within(dialog).getByRole('button', {
+ const disabledCurrency = within(dialog).getByRole('option', {
name: 'British Pound (GBP)',
});
@@ -177,7 +205,10 @@ export const DisabledCurrency: Story = {
await userEvent.type(search, 'jpy');
await userEvent.keyboard('{Enter}');
await expect(args.onValueChange).toHaveBeenCalledOnce();
- await expect(args.onValueChange).toHaveBeenCalledWith('JPY');
+ await expect(args.onValueChange).toHaveBeenCalledWith(
+ 'JPY',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
await waitFor(() => expect(dialog).not.toBeInTheDocument());
await waitFor(() => expect(trigger).toHaveFocus());
},
@@ -216,11 +247,11 @@ export const DisabledOptions: Story = {
await waitFor(() => expect(dialog).toBeVisible());
await expect(within(dialog).getByRole('searchbox')).toBeDisabled();
- for (const option of within(dialog).getAllByRole('button')) {
+ for (const option of within(dialog).getAllByRole('option')) {
await expect(option).toBeDisabled();
}
await userEvent.click(
- within(dialog).getByRole('button', { name: 'Euro (EUR)' }),
+ within(dialog).getByRole('option', { name: 'Euro (EUR)' }),
);
await userEvent.keyboard('{Enter}');
await expect(args.onValueChange).not.toHaveBeenCalled();
@@ -259,8 +290,8 @@ export const IndependentInstances: Story = {
await expect(budget.search).toHaveValue('');
await expect(budget.trigger).toHaveTextContent('EUR');
await expect(
- within(budget.dialog).getAllByRole('button')[0],
- ).toHaveTextContent('Euro (EUR)');
+ within(budget.dialog).getByRole('option', { name: 'Euro (EUR)' }),
+ ).toHaveAttribute('aria-selected', 'true');
await userEvent.keyboard('{Escape}');
await waitFor(() => expect(budget.dialog).not.toBeInTheDocument());
@@ -272,15 +303,21 @@ export const IndependentInstances: Story = {
await expect(reopenedInvoice.search).toHaveValue('');
await expect(reopenedInvoice.trigger).toHaveTextContent('JPY');
await expect(
- within(reopenedInvoice.dialog).getAllByRole('button')[0],
- ).toHaveTextContent('Japanese Yen (JPY)');
+ within(reopenedInvoice.dialog).getByRole('option', {
+ name: 'Japanese Yen (JPY)',
+ }),
+ ).toHaveAttribute('aria-selected', 'true');
},
};
export const OutsideDismissal: Story = {
render: (args) => (
<>
- <CurrencyPickerExample key={args.defaultValue} {...args} />
+ <CurrencyPickerExample
+ key={args.defaultValue}
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ />
<Button>Continue</Button>
</>
),
@@ -294,3 +331,13 @@ export const OutsideDismissal: Story = {
await expect(args.onValueChange).not.toHaveBeenCalled();
},
};
+
+export const CompoundSearchAndPointerSelection: Story = {
+ ...SearchAndPointerSelection,
+ args: { composition: 'compound' },
+};
+
+export const CompoundKeyboardNavigation: Story = {
+ ...KeyboardNavigation,
+ args: { composition: 'compound' },
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.locale.stories.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.locale.stories.tsx
index 2bba756109b..eee8f015117 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.locale.stories.tsx
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.locale.stories.tsx
@@ -10,7 +10,13 @@ const meta: Meta<typeof CurrencyPickerExample> = {
id: 'ui-input-currencypicker-locale',
title: 'UI/Components/Input/CurrencyPicker/Locale',
component: CurrencyPickerExample,
- render: (args) => <CurrencyPickerExample key={args.defaultValue} {...args} />,
+ render: (args) => (
+ <CurrencyPickerExample
+ key={args.defaultValue}
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ />
+ ),
decorators: [ComponentDecorator],
args: { onValueChange: fn() },
parameters: {
@@ -49,32 +55,38 @@ export const TurkishLocaleSearch: Story = {
await userEvent.type(firstPicker.search, 'indian');
await expect(
- within(firstPicker.dialog).getByRole('button', {
+ within(firstPicker.dialog).getByRole('option', {
name: 'Indian Rupee (INR)',
}),
).toBeVisible();
await userEvent.keyboard('{Enter}');
await waitFor(() => expect(firstPicker.dialog).not.toBeInTheDocument());
- await expect(args.onValueChange).toHaveBeenLastCalledWith('INR');
+ await expect(args.onValueChange).toHaveBeenLastCalledWith(
+ 'INR',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
const secondPicker = await openCurrencyPicker({ canvasElement });
await userEvent.type(secondPicker.search, 'idr');
await expect(
- within(secondPicker.dialog).getByRole('button', {
+ within(secondPicker.dialog).getByRole('option', {
name: 'Indonesian Rupiah (IDR)',
}),
).toBeVisible();
await userEvent.clear(secondPicker.search);
await userEvent.type(secondPicker.search, 'IDR');
await expect(
- within(secondPicker.dialog).getByRole('button', {
+ within(secondPicker.dialog).getByRole('option', {
name: 'Indonesian Rupiah (IDR)',
}),
).toBeVisible();
await userEvent.keyboard('{Enter}');
await waitFor(() => expect(secondPicker.dialog).not.toBeInTheDocument());
- await expect(args.onValueChange).toHaveBeenLastCalledWith('IDR');
+ await expect(args.onValueChange).toHaveBeenLastCalledWith(
+ 'IDR',
+ expect.objectContaining({ reason: 'item-press', isCanceled: false }),
+ );
await expect(args.onValueChange).toHaveBeenCalledTimes(2);
},
};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.stories.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.stories.tsx
index cc7c451e733..c6562fc51ae 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.stories.tsx
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.stories.tsx
@@ -11,7 +11,13 @@ const meta: Meta<typeof CurrencyPickerExample> = {
id: 'ui-input-currencypicker',
title: 'UI/Components/Input/CurrencyPicker',
component: CurrencyPickerExample,
- render: (args) => <CurrencyPickerExample key={args.defaultValue} {...args} />,
+ render: (args) => (
+ <CurrencyPickerExample
+ key={args.defaultValue}
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...args}
+ />
+ ),
decorators: [ComponentDecorator],
parameters: {
container: { width: 320, height: 340 },
@@ -39,8 +45,8 @@ export const Default: Story = {
const { dialog } = await openCurrencyPicker({ canvasElement });
await expect(
- within(dialog).getByRole('button', { name: 'US Dollar (USD)' }),
- ).toHaveAttribute('aria-pressed', 'true');
+ within(dialog).getByRole('option', { name: 'US Dollar (USD)' }),
+ ).toHaveAttribute('aria-selected', 'true');
},
};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerChangingDefaultExample.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerChangingDefaultExample.tsx
new file mode 100644
index 00000000000..74954527c77
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerChangingDefaultExample.tsx
@@ -0,0 +1,33 @@
+import { type ComponentProps, useState } from 'react';
+
+import { Button } from '@ui/primitives/input/Button/Button';
+
+import { CurrencyPickerExample } from './CurrencyPickerExample';
+
+type CurrencyPickerChangingDefaultExampleProps = Pick<
+ ComponentProps<typeof CurrencyPickerExample>,
+ 'onValueChange' | 'composition'
+>;
+
+export const CurrencyPickerChangingDefaultExample = ({
+ onValueChange,
+ composition,
+}: CurrencyPickerChangingDefaultExampleProps) => {
+ const [defaultValue, setDefaultValue] = useState('USD');
+
+ return (
+ <>
+ <CurrencyPickerExample
+ composition={composition}
+ defaultValue={defaultValue}
+ onValueChange={onValueChange}
+ />
+ <Button onClick={() => setDefaultValue('EUR')}>
+ Change default to Euro
+ </Button>
+ <Button onClick={() => setDefaultValue('JPY')}>
+ Change default to Yen
+ </Button>
+ </>
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerControlledExample.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerControlledExample.tsx
new file mode 100644
index 00000000000..1db2a9a3308
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerControlledExample.tsx
@@ -0,0 +1,37 @@
+import { type ComponentProps, useState } from 'react';
+
+import { Button } from '@ui/primitives/input/Button/Button';
+
+import { CurrencyPickerExample } from './CurrencyPickerExample';
+
+type CurrencyPickerControlledExampleProps = Pick<
+ ComponentProps<typeof CurrencyPickerExample>,
+ 'onValueChange' | 'composition'
+>;
+
+export const CurrencyPickerControlledExample = ({
+ onValueChange,
+ composition,
+}: CurrencyPickerControlledExampleProps) => {
+ const [value, setValue] = useState<string | null>('USD');
+
+ return (
+ <>
+ <CurrencyPickerExample
+ composition={composition}
+ value={value}
+ onValueChange={(nextValue, eventDetails) => {
+ onValueChange?.(nextValue, eventDetails);
+
+ if (!eventDetails.isCanceled) {
+ setValue(nextValue);
+ }
+ }}
+ />
+ <Button onClick={() => setValue('EUR')}>Set Euro</Button>
+ <Button onClick={() => setValue(null)}>Clear currency</Button>
+ <Button onClick={() => setValue('ZZZ')}>Set unknown currency</Button>
+ <Button onClick={() => setValue('')}>Set empty identifier</Button>
+ </>
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerControlledSearchExample.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerControlledSearchExample.tsx
new file mode 100644
index 00000000000..5a7e6dd5357
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerControlledSearchExample.tsx
@@ -0,0 +1,29 @@
+import { type ComponentProps, useState } from 'react';
+
+import { Button } from '@ui/primitives/input/Button/Button';
+
+import { CurrencyPickerExample } from './CurrencyPickerExample';
+
+type CurrencyPickerControlledSearchExampleProps = Pick<
+ ComponentProps<typeof CurrencyPickerExample>,
+ 'onValueChange' | 'composition'
+>;
+
+export const CurrencyPickerControlledSearchExample = ({
+ onValueChange,
+ composition,
+}: CurrencyPickerControlledSearchExampleProps) => {
+ const [search, setSearch] = useState('USD');
+
+ return (
+ <>
+ <CurrencyPickerExample
+ composition={composition}
+ onValueChange={onValueChange}
+ closeOnSelect={false}
+ searchProps={{ value: search, onValueChange: setSearch }}
+ />
+ <Button onClick={() => setSearch('EUR')}>Find Euro</Button>
+ </>
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerExample.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerExample.tsx
index 44988ab78df..53bc9bdae11 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerExample.tsx
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerExample.tsx
@@ -1,4 +1,4 @@
-import { type ComponentProps, useState } from 'react';
+import { type ComponentProps } from 'react';
import { Dropdown } from '@ui/components/navigation/Dropdown/Dropdown';
@@ -6,52 +6,103 @@ import { CurrencyPicker } from '../CurrencyPicker';
import { CURRENCY_PICKER_STORY_OPTIONS } from './currencyPickerStoryOptions';
type CurrencyPickerExampleProps = Pick<
- ComponentProps<typeof CurrencyPicker.Options>,
- 'currencies' | 'searchLabel' | 'emptyLabel' | 'onValueChange' | 'dir'
-> & {
- defaultValue?: string;
- disabled?: boolean;
- optionsDisabled?: boolean;
- defaultOpen?: boolean;
- triggerLabel?: string;
-};
+ ComponentProps<typeof CurrencyPicker>,
+ | 'currencies'
+ | 'value'
+ | 'defaultValue'
+ | 'onValueChange'
+ | 'disabled'
+ | 'closeOnSelect'
+ | 'selectedFirst'
+ | 'getOptionLabel'
+ | 'getSearchText'
+ | 'renderValue'
+> &
+ Pick<
+ ComponentProps<typeof CurrencyPicker.Options>,
+ 'searchLabel' | 'emptyLabel' | 'searchable' | 'searchProps' | 'dir'
+ > & {
+ composition?: 'shorthand' | 'compound';
+ optionsDisabled?: boolean;
+ defaultOpen?: boolean;
+ triggerLabel?: string;
+ };
export const CurrencyPickerExample = ({
currencies = CURRENCY_PICKER_STORY_OPTIONS,
+ value,
defaultValue = 'USD',
disabled = false,
optionsDisabled = false,
defaultOpen = false,
triggerLabel = 'Currency',
+ composition = 'shorthand',
+ selectedFirst,
+ closeOnSelect,
+ getOptionLabel,
+ getSearchText,
+ renderValue,
searchLabel,
+ searchProps,
emptyLabel,
+ searchable,
onValueChange,
dir,
}: Partial<CurrencyPickerExampleProps>) => {
- const [value, setValue] = useState(defaultValue);
-
- return (
- <Dropdown.Root type="picker" defaultOpen={defaultOpen}>
- <CurrencyPicker.Trigger
- aria-label={triggerLabel}
- value={value}
- disabled={disabled}
- dir={dir}
- />
- <Dropdown.Content aria-label={triggerLabel} width={280} dir={dir}>
- <CurrencyPicker.Options
+ if (composition === 'compound') {
+ return (
+ <Dropdown.Root type="picker" defaultOpen={defaultOpen}>
+ <CurrencyPicker.Root
currencies={currencies}
value={value}
- onValueChange={(currencyCode) => {
- setValue(currencyCode);
- onValueChange?.(currencyCode);
- }}
- searchLabel={searchLabel}
- emptyLabel={emptyLabel}
- disabled={optionsDisabled}
- dir={dir}
- />
- </Dropdown.Content>
- </Dropdown.Root>
+ defaultValue={defaultValue}
+ onValueChange={onValueChange}
+ disabled={disabled}
+ closeOnSelect={closeOnSelect}
+ selectedFirst={selectedFirst}
+ getOptionLabel={getOptionLabel}
+ getSearchText={getSearchText}
+ renderValue={renderValue}
+ >
+ <CurrencyPicker.Trigger aria-label={triggerLabel} dir={dir} />
+ <Dropdown.Content aria-label={triggerLabel} width={280} dir={dir}>
+ <CurrencyPicker.Options
+ searchLabel={searchLabel}
+ searchProps={searchProps}
+ emptyLabel={emptyLabel}
+ searchable={searchable}
+ disabled={optionsDisabled}
+ dir={dir}
+ />
+ </Dropdown.Content>
+ </CurrencyPicker.Root>
+ </Dropdown.Root>
+ );
+ }
+
+ return (
+ <CurrencyPicker
+ currencies={currencies}
+ value={value}
+ defaultValue={defaultValue}
+ onValueChange={onValueChange}
+ disabled={disabled}
+ closeOnSelect={closeOnSelect}
+ selectedFirst={selectedFirst}
+ getOptionLabel={getOptionLabel}
+ getSearchText={getSearchText}
+ renderValue={renderValue}
+ defaultOpen={defaultOpen}
+ triggerProps={{ 'aria-label': triggerLabel, dir }}
+ optionsProps={{
+ searchLabel,
+ searchProps,
+ emptyLabel,
+ searchable,
+ disabled: optionsDisabled,
+ dir,
+ }}
+ contentProps={{ 'aria-label': triggerLabel, width: 280, dir }}
+ />
);
};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerListLabelExample.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerListLabelExample.tsx
new file mode 100644
index 00000000000..fe44494688b
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerListLabelExample.tsx
@@ -0,0 +1,29 @@
+import { useState } from 'react';
+
+import { Dropdown } from '@ui/components/navigation/Dropdown/Dropdown';
+import { Button } from '@ui/primitives/input/Button/Button';
+
+import { CurrencyPicker } from '../CurrencyPicker';
+import { CURRENCY_PICKER_STORY_OPTIONS } from './currencyPickerStoryOptions';
+
+export const CurrencyPickerListLabelExample = () => {
+ const [showTitle, setShowTitle] = useState(true);
+
+ return (
+ <Dropdown.Root type="picker">
+ <CurrencyPicker.Root
+ currencies={CURRENCY_PICKER_STORY_OPTIONS}
+ defaultValue="USD"
+ >
+ <CurrencyPicker.Trigger aria-label="Billing currency" />
+ <Dropdown.Content aria-label="Currency options">
+ <Dropdown.Header>
+ {showTitle && <Dropdown.Title>Billing currencies</Dropdown.Title>}
+ <Button onClick={() => setShowTitle(false)}>Hide title</Button>
+ </Dropdown.Header>
+ <CurrencyPicker.Options aria-label="Currency options wrapper" />
+ </Dropdown.Content>
+ </CurrencyPicker.Root>
+ </Dropdown.Root>
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerRootStateExample.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerRootStateExample.tsx
new file mode 100644
index 00000000000..6f17e1bfcdb
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPickerRootStateExample.tsx
@@ -0,0 +1,35 @@
+import { useState } from 'react';
+
+import { Dropdown } from '@ui/components/navigation/Dropdown/Dropdown';
+import { Button } from '@ui/primitives/input/Button/Button';
+import { Text } from '@ui/primitives/typography/Text/Text';
+
+import { CurrencyPicker } from '../CurrencyPicker';
+import { CURRENCY_PICKER_STORY_OPTIONS } from './currencyPickerStoryOptions';
+
+export const CurrencyPickerRootStateExample = () => {
+ const [selection, setSelection] = useState({ value: 'USD', disabled: true });
+
+ return (
+ <>
+ <Text data-testid="root-host">
+ <Dropdown.Root type="picker">
+ <CurrencyPicker.Root
+ currencies={CURRENCY_PICKER_STORY_OPTIONS}
+ value={selection.value}
+ disabled={selection.disabled}
+ >
+ {({ value, selectedCurrency, disabled }) => (
+ <Text data-testid="root-state">
+ {value}:{selectedCurrency?.name}:{String(disabled)}
+ </Text>
+ )}
+ </CurrencyPicker.Root>
+ </Dropdown.Root>
+ </Text>
+ <Button onClick={() => setSelection({ value: 'EUR', disabled: false })}>
+ Use Euro
+ </Button>
+ </>
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__tests__/CurrencyPicker.test.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__tests__/CurrencyPicker.test.tsx
index 7b50f1edb68..a6fbe7b8830 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/__tests__/CurrencyPicker.test.tsx
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__tests__/CurrencyPicker.test.tsx
@@ -7,11 +7,19 @@ import { Dropdown } from '@ui/components/navigation/Dropdown/Dropdown';
import { CurrencyPicker } from '../CurrencyPicker';
import styles from '../CurrencyPicker.module.scss';
+const CURRENCIES = [{ code: 'USD', name: 'US Dollar' }];
+
const CurrencyPickerTriggerWrapper = ({
children,
}: {
children: ReactNode;
-}) => <Dropdown.Root type="picker">{children}</Dropdown.Root>;
+}) => (
+ <Dropdown.Root type="picker">
+ <CurrencyPicker.Root currencies={CURRENCIES} defaultValue="USD">
+ {children}
+ </CurrencyPicker.Root>
+ </Dropdown.Root>
+);
const CurrencyPickerOptionsWrapper = ({
children,
@@ -19,13 +27,29 @@ const CurrencyPickerOptionsWrapper = ({
children: ReactNode;
}) => (
<Dropdown.Root type="picker" open>
- <Dropdown.Content aria-label="Currency">{children}</Dropdown.Content>
+ <CurrencyPicker.Root currencies={CURRENCIES} defaultValue="USD">
+ <Dropdown.Content aria-label="Currency">{children}</Dropdown.Content>
+ </CurrencyPicker.Root>
</Dropdown.Root>
);
+runComponentConformance({
+ name: 'CurrencyPicker',
+ element: (
+ <CurrencyPicker
+ currencies={CURRENCIES}
+ defaultValue="USD"
+ aria-label="Currency"
+ />
+ ),
+ refInstanceOf: HTMLButtonElement,
+ ownClassName: styles.trigger,
+ renderPropTagName: 'button',
+});
+
runComponentConformance({
name: 'CurrencyPicker.Trigger',
- element: <CurrencyPicker.Trigger value="USD" aria-label="Currency" />,
+ element: <CurrencyPicker.Trigger aria-label="Currency" />,
refInstanceOf: HTMLButtonElement,
wrapper: CurrencyPickerTriggerWrapper,
ownClassName: styles.trigger,
@@ -34,13 +58,7 @@ runComponentConformance({
runComponentConformance({
name: 'CurrencyPicker.Options',
- element: (
- <CurrencyPicker.Options
- currencies={[{ code: 'USD', name: 'US Dollar' }]}
- value="USD"
- onValueChange={() => undefined}
- />
- ),
+ element: <CurrencyPicker.Options />,
refInstanceOf: HTMLDivElement,
wrapper: CurrencyPickerOptionsWrapper,
ownClassName: styles.options,
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerContext.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerContext.ts
new file mode 100644
index 00000000000..595865219b6
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerContext.ts
@@ -0,0 +1,19 @@
+import { createContext, type ReactNode } from 'react';
+
+import { type CurrencyPickerRootProps } from '../types/CurrencyPickerRootProps';
+import { type CurrencyPickerState } from '../types/CurrencyPickerState';
+import { type PreparedCurrencyPickerOption } from './PreparedCurrencyPickerOption';
+
+export const CurrencyPickerContext = createContext<
+ | {
+ state: CurrencyPickerState;
+ groupId: string;
+ options: PreparedCurrencyPickerOption[];
+ selectionProps: Pick<
+ CurrencyPickerRootProps,
+ 'value' | 'defaultValue' | 'onValueChange' | 'closeOnSelect'
+ >;
+ renderValue?: (state: CurrencyPickerState) => ReactNode;
+ }
+ | undefined
+>(undefined);
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerOptions.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerOptions.tsx
index a0a56c5fd55..93b8162d520 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerOptions.tsx
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerOptions.tsx
@@ -1,44 +1,53 @@
import { useRender } from '@base-ui/react/use-render';
-import { isNonEmptyArray } from '@sniptt/guards';
+import { isNonEmptyArray, isString, isUndefined } from '@sniptt/guards';
import { clsx } from 'clsx';
import { useState } from 'react';
import { Dropdown } from '@ui/components/navigation/Dropdown/Dropdown';
+import { useDropdownContext } from '@ui/components/navigation/Dropdown/internal/useDropdownContext';
import { OverflowingTextWithTooltip } from '@ui/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip';
import { isDefined } from '@ui/utilities/utils/isDefined';
+import { doNotTranslate } from '@ui/utilities/internal/doNotTranslate';
+
import styles from '../CurrencyPicker.module.scss';
-import { getCurrencyPickerLabel } from './getCurrencyPickerLabel';
import { type CurrencyPickerOptionsProps } from '../types/CurrencyPickerOptionsProps';
-import { doNotTranslate } from '@ui/utilities/internal/doNotTranslate';
+import { useCurrencyPickerContextOrThrow } from './useCurrencyPickerContextOrThrow';
export const CurrencyPickerOptions = ({
- currencies,
- value,
- onValueChange,
disabled = false,
+ searchable = true,
searchLabel = doNotTranslate('Search'),
+ listLabel,
emptyLabel = doNotTranslate('No results'),
+ searchProps,
className,
render,
ref,
...props
}: CurrencyPickerOptionsProps) => {
- const [search, setSearch] = useState('');
- const normalizedSearch = search.trim().toLowerCase();
- const matchingCurrencies = currencies.filter((currency) =>
- getCurrencyPickerLabel(currency).toLowerCase().includes(normalizedSearch),
+ const { state, groupId, options, selectionProps } =
+ useCurrencyPickerContextOrThrow();
+ const { titleId, triggerId } = useDropdownContext();
+ const {
+ value: controlledSearch,
+ defaultValue: defaultSearch = '',
+ onValueChange: onSearchChange,
+ ...searchElementProps
+ } = searchProps ?? {};
+ const [uncontrolledSearch, setUncontrolledSearch] = useState(defaultSearch);
+ const search = controlledSearch ?? uncontrolledSearch;
+ const normalizedSearch = searchable
+ ? String(search).trim().toLowerCase()
+ : '';
+ const matchingCurrencies = options.filter(({ searchText }) =>
+ searchText.includes(normalizedSearch),
);
const hasMatchingCurrencies = isNonEmptyArray(matchingCurrencies);
- const selectedCurrency = matchingCurrencies.find(
- ({ code }) => code === value,
- );
- const orderedCurrencies = isDefined(selectedCurrency)
- ? [
- selectedCurrency,
- ...matchingCurrencies.filter(({ code }) => code !== value),
- ]
- : matchingCurrencies;
+ const isDisabled = state.disabled || disabled;
+ const defaultAriaLabelledBy = isDefined(listLabel)
+ ? undefined
+ : (titleId ?? triggerId);
return useRender({
render,
@@ -48,30 +57,51 @@ export const CurrencyPickerOptions = ({
className: clsx(styles.options, className),
children: (
<>
- <Dropdown.Search
- value={search}
- placeholder={searchLabel}
- aria-label={searchLabel}
- onValueChange={setSearch}
- disabled={disabled}
- />
- <Dropdown.Separator />
- {hasMatchingCurrencies && (
- <Dropdown.Section scrollable>
- {orderedCurrencies.map((currency) => (
- <Dropdown.OptionItem
- key={currency.code}
- selected={currency.code === value}
- disabled={disabled || currency.disabled}
- onSelect={() => onValueChange(currency.code)}
- >
- <OverflowingTextWithTooltip
- text={getCurrencyPickerLabel(currency)}
- />
- </Dropdown.OptionItem>
- ))}
- </Dropdown.Section>
+ {searchable && (
+ <>
+ <Dropdown.Search
+ placeholder={searchLabel}
+ aria-label={searchLabel}
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...searchElementProps}
+ value={search}
+ onValueChange={(nextSearch) => {
+ onSearchChange?.(nextSearch);
+
+ if (isUndefined(controlledSearch)) {
+ setUncontrolledSearch(nextSearch);
+ }
+ }}
+ disabled={isDisabled || searchProps?.disabled}
+ />
+ <Dropdown.Separator />
+ </>
)}
+ <Dropdown.SelectionGroup
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...selectionProps}
+ id={groupId}
+ aria-label={listLabel}
+ aria-labelledby={defaultAriaLabelledBy}
+ >
+ {hasMatchingCurrencies && (
+ <Dropdown.Section scrollable>
+ {matchingCurrencies.map(({ currency, label }) => (
+ <Dropdown.OptionItem
+ key={currency.code}
+ value={currency.code}
+ disabled={isDisabled || currency.disabled}
+ >
+ {isString(label) ? (
+ <OverflowingTextWithTooltip text={label} />
+ ) : (
+ label
+ )}
+ </Dropdown.OptionItem>
+ ))}
+ </Dropdown.Section>
+ )}
+ </Dropdown.SelectionGroup>
<Dropdown.Empty className={styles.emptyStatus}>
{hasMatchingCurrencies ? null : emptyLabel}
</Dropdown.Empty>
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerRoot.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerRoot.tsx
new file mode 100644
index 00000000000..c7c5d9e3449
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerRoot.tsx
@@ -0,0 +1,71 @@
+import { isFunction, isUndefined } from '@sniptt/guards';
+import { useId } from 'react';
+
+import { DropdownSelectionGroupEffect } from '@ui/components/navigation/Dropdown/internal/DropdownSelectionGroupEffect';
+import { getDropdownSelectionGroupState } from '@ui/components/navigation/Dropdown/internal/getDropdownSelectionGroupState';
+import { useDropdownContext } from '@ui/components/navigation/Dropdown/internal/useDropdownContext';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import { type CurrencyPickerRootProps } from '../types/CurrencyPickerRootProps';
+import { CurrencyPickerContext } from './CurrencyPickerContext';
+import { getCurrencyPickerLabel } from './getCurrencyPickerLabel';
+import { getCurrencyPickerSearchText } from './getCurrencyPickerSearchText';
+
+export const CurrencyPickerRoot = ({
+ currencies,
+ value: controlledValue,
+ defaultValue = null,
+ onValueChange,
+ closeOnSelect,
+ disabled = false,
+ selectedFirst = false,
+ getOptionLabel = getCurrencyPickerLabel,
+ getSearchText = getCurrencyPickerSearchText,
+ renderValue,
+ children,
+}: CurrencyPickerRootProps) => {
+ const groupId = useId();
+ const { selections, initializeSelection } = useDropdownContext();
+ const selectionProps = {
+ value: controlledValue,
+ defaultValue,
+ onValueChange,
+ closeOnSelect,
+ };
+ const selection = getDropdownSelectionGroupState({
+ props: { ...selectionProps, id: groupId },
+ storedState: selections.get(groupId),
+ });
+ const value = selection.multiple ? null : selection.value;
+ const preparedOptions = currencies.map((currency) => ({
+ currency,
+ label: getOptionLabel(currency),
+ searchText: getSearchText(currency).toLowerCase(),
+ }));
+ const selectedOption = preparedOptions.find(
+ ({ currency }) => currency.code === value,
+ );
+ const options =
+ selectedFirst && isDefined(selectedOption)
+ ? [
+ selectedOption,
+ ...preparedOptions.filter((option) => option !== selectedOption),
+ ]
+ : preparedOptions;
+ const state = { value, selectedCurrency: selectedOption?.currency, disabled };
+
+ return (
+ <CurrencyPickerContext.Provider
+ value={{ state, groupId, options, selectionProps, renderValue }}
+ >
+ {isUndefined(controlledValue) && (
+ <DropdownSelectionGroupEffect
+ id={groupId}
+ initialState={selection}
+ initializeSelection={initializeSelection}
+ />
+ )}
+ {isFunction(children) ? children(state) : children}
+ </CurrencyPickerContext.Provider>
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerShorthand.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerShorthand.tsx
new file mode 100644
index 00000000000..6bff80b7d44
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerShorthand.tsx
@@ -0,0 +1,66 @@
+import { Dropdown } from '@ui/components/navigation/Dropdown/Dropdown';
+
+import { type CurrencyPickerProps } from '../types/CurrencyPickerProps';
+import { CurrencyPickerOptions } from './CurrencyPickerOptions';
+import { CurrencyPickerRoot } from './CurrencyPickerRoot';
+import { CurrencyPickerTrigger } from './CurrencyPickerTrigger';
+
+export const CurrencyPickerShorthand = ({
+ currencies,
+ value,
+ defaultValue,
+ onValueChange,
+ closeOnSelect,
+ disabled,
+ selectedFirst,
+ getOptionLabel,
+ getSearchText,
+ renderValue,
+ open,
+ defaultOpen,
+ onOpenChange,
+ onEscapeKeyDown,
+ onInteractOutside,
+ triggerProps,
+ contentProps,
+ optionsProps,
+ ...props
+}: CurrencyPickerProps) => (
+ <Dropdown.Root
+ type="picker"
+ open={open}
+ defaultOpen={defaultOpen}
+ onOpenChange={onOpenChange}
+ onEscapeKeyDown={onEscapeKeyDown}
+ onInteractOutside={onInteractOutside}
+ >
+ <CurrencyPickerRoot
+ currencies={currencies}
+ value={value}
+ defaultValue={defaultValue}
+ onValueChange={onValueChange}
+ closeOnSelect={closeOnSelect}
+ disabled={disabled}
+ selectedFirst={selectedFirst}
+ getOptionLabel={getOptionLabel}
+ getSearchText={getSearchText}
+ renderValue={renderValue}
+ >
+ <CurrencyPickerTrigger
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...props}
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...triggerProps}
+ />
+ <Dropdown.Content
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...contentProps}
+ >
+ <CurrencyPickerOptions
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...optionsProps}
+ />
+ </Dropdown.Content>
+ </CurrencyPickerRoot>
+ </Dropdown.Root>
+);
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerTrigger.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerTrigger.tsx
index 59f2da6c9e3..5d8cbda8193 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerTrigger.tsx
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/CurrencyPickerTrigger.tsx
@@ -1,20 +1,31 @@
import { Dropdown } from '@ui/components/navigation/Dropdown/Dropdown';
import { IconChevronDown } from '@ui/icon';
import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
+import { isDefined } from '@ui/utilities/utils/isDefined';
import styles from '../CurrencyPicker.module.scss';
import { type CurrencyPickerTriggerProps } from '../types/CurrencyPickerTriggerProps';
+import { useCurrencyPickerContextOrThrow } from './useCurrencyPickerContextOrThrow';
export const CurrencyPickerTrigger = ({
- value,
+ children,
+ placeholder,
+ disabled = false,
className,
...props
-}: CurrencyPickerTriggerProps) => (
- <Dropdown.Trigger
- {...props}
- className={mergeClassNames(styles.trigger, className)}
- >
- {value}
- <IconChevronDown aria-hidden="true" className={styles.chevron} />
- </Dropdown.Trigger>
-);
+}: CurrencyPickerTriggerProps) => {
+ const { state, renderValue } = useCurrencyPickerContextOrThrow();
+ const valueLabel = isDefined(state.value) ? state.value : placeholder;
+
+ return (
+ <Dropdown.Trigger
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...props}
+ disabled={state.disabled || disabled}
+ className={mergeClassNames(styles.trigger, className)}
+ >
+ {children ?? (isDefined(renderValue) ? renderValue(state) : valueLabel)}
+ <IconChevronDown aria-hidden="true" className={styles.chevron} />
+ </Dropdown.Trigger>
+ );
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/internal/PreparedCurrencyPickerOption.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/PreparedCurrencyPickerOption.ts
new file mode 100644
index 00000000000..3b67feba598
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/PreparedCurrencyPickerOption.ts
@@ -0,0 +1,9 @@
+import { type ReactNode } from 'react';
+
+import { type CurrencyPickerOption } from '../types/CurrencyPickerOption';
+
+export type PreparedCurrencyPickerOption = {
+ currency: CurrencyPickerOption;
+ label: ReactNode;
+ searchText: string;
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/internal/getCurrencyPickerSearchText.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/getCurrencyPickerSearchText.ts
new file mode 100644
index 00000000000..bd7c298e107
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/getCurrencyPickerSearchText.ts
@@ -0,0 +1,5 @@
+import { type CurrencyPickerOption } from '../types/CurrencyPickerOption';
+import { getCurrencyPickerLabel } from './getCurrencyPickerLabel';
+
+export const getCurrencyPickerSearchText = (currency: CurrencyPickerOption) =>
+ `${getCurrencyPickerLabel(currency)} ${currency.symbol ?? ''}`;
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/internal/useCurrencyPickerContextOrThrow.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/useCurrencyPickerContextOrThrow.ts
new file mode 100644
index 00000000000..ff70e44a1b2
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/internal/useCurrencyPickerContextOrThrow.ts
@@ -0,0 +1,18 @@
+import { useContext } from 'react';
+
+import { doNotTranslate } from '@ui/utilities/internal/doNotTranslate';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import { CurrencyPickerContext } from './CurrencyPickerContext';
+
+export const useCurrencyPickerContextOrThrow = () => {
+ const context = useContext(CurrencyPickerContext);
+
+ if (!isDefined(context)) {
+ throw new Error(
+ doNotTranslate('CurrencyPicker parts must be inside CurrencyPicker.Root'),
+ );
+ }
+
+ return context;
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerChangeEventDetails.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerChangeEventDetails.ts
new file mode 100644
index 00000000000..b6a039ac0ad
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerChangeEventDetails.ts
@@ -0,0 +1,4 @@
+import { type DropdownSelectionGroupChangeEventDetails } from '@ui/components/navigation/Dropdown/types/DropdownSelectionGroupChangeEventDetails';
+
+export type CurrencyPickerChangeEventDetails =
+ DropdownSelectionGroupChangeEventDetails;
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerOption.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerOption.ts
index a4f8b0571d0..d99425eb8e1 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerOption.ts
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerOption.ts
@@ -1,5 +1,6 @@
export type CurrencyPickerOption = {
code: string;
name: string;
+ symbol?: string;
disabled?: boolean;
};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerOptionsProps.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerOptionsProps.ts
index 1e473e8f477..1c298985f50 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerOptionsProps.ts
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerOptionsProps.ts
@@ -1,15 +1,16 @@
import { type useRender } from '@base-ui/react/use-render';
+import { type ReactNode } from 'react';
-import { type CurrencyPickerOption } from './CurrencyPickerOption';
+import { type DropdownSearchProps } from '@ui/components/navigation/Dropdown/types/DropdownSearchProps';
export type CurrencyPickerOptionsProps = Omit<
useRender.ComponentProps<'div'>,
'children'
> & {
- currencies: readonly CurrencyPickerOption[];
- value?: string;
- onValueChange: (code: string) => void;
disabled?: boolean;
+ searchable?: boolean;
searchLabel?: string;
- emptyLabel?: string;
+ listLabel?: string;
+ emptyLabel?: ReactNode;
+ searchProps?: DropdownSearchProps;
};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerProps.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerProps.ts
new file mode 100644
index 00000000000..267676cec11
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerProps.ts
@@ -0,0 +1,21 @@
+import { type DropdownContentProps } from '@ui/components/navigation/Dropdown/types/DropdownContentProps';
+import { type DropdownRootProps } from '@ui/components/navigation/Dropdown/types/DropdownRootProps';
+
+import { type CurrencyPickerOptionsProps } from './CurrencyPickerOptionsProps';
+import { type CurrencyPickerRootProps } from './CurrencyPickerRootProps';
+import { type CurrencyPickerTriggerProps } from './CurrencyPickerTriggerProps';
+
+export type CurrencyPickerProps = Omit<CurrencyPickerRootProps, 'children'> &
+ CurrencyPickerTriggerProps &
+ Pick<
+ DropdownRootProps,
+ | 'open'
+ | 'defaultOpen'
+ | 'onOpenChange'
+ | 'onEscapeKeyDown'
+ | 'onInteractOutside'
+ > & {
+ triggerProps?: CurrencyPickerTriggerProps;
+ contentProps?: Omit<DropdownContentProps, 'children'>;
+ optionsProps?: CurrencyPickerOptionsProps;
+ };
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerRootProps.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerRootProps.ts
new file mode 100644
index 00000000000..9766d8ac24b
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerRootProps.ts
@@ -0,0 +1,22 @@
+import { type ReactNode } from 'react';
+
+import { type CurrencyPickerChangeEventDetails } from './CurrencyPickerChangeEventDetails';
+import { type CurrencyPickerOption } from './CurrencyPickerOption';
+import { type CurrencyPickerState } from './CurrencyPickerState';
+
+export type CurrencyPickerRootProps = {
+ currencies: readonly CurrencyPickerOption[];
+ value?: string | null;
+ defaultValue?: string | null;
+ onValueChange?: (
+ value: string | null,
+ eventDetails: CurrencyPickerChangeEventDetails,
+ ) => void;
+ closeOnSelect?: boolean;
+ disabled?: boolean;
+ selectedFirst?: boolean;
+ getOptionLabel?: (currency: CurrencyPickerOption) => ReactNode;
+ getSearchText?: (currency: CurrencyPickerOption) => string;
+ renderValue?: (state: CurrencyPickerState) => ReactNode;
+ children: ReactNode | ((state: CurrencyPickerState) => ReactNode);
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerState.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerState.ts
new file mode 100644
index 00000000000..3aaf901fc2a
--- /dev/null
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerState.ts
@@ -0,0 +1,7 @@
+import { type CurrencyPickerOption } from './CurrencyPickerOption';
+
+export type CurrencyPickerState = {
+ value: string | null;
+ selectedCurrency: CurrencyPickerOption | undefined;
+ disabled: boolean;
+};
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerTriggerProps.ts b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerTriggerProps.ts
index 12078f01978..eb43dffc9fb 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerTriggerProps.ts
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/types/CurrencyPickerTriggerProps.ts
@@ -1,14 +1,10 @@
+import { type ReactNode } from 'react';
+
import { type DropdownTriggerProps } from '@ui/components/navigation/Dropdown/types/DropdownTriggerProps';
export type CurrencyPickerTriggerProps = Omit<
DropdownTriggerProps,
- | 'children'
- | 'value'
- | 'openOnHover'
- | 'delay'
- | 'closeDelay'
- | 'handle'
- | 'payload'
+ 'value' | 'openOnHover' | 'delay' | 'closeDelay'
> & {
- value: string;
+ placeholder?: ReactNode;
};
diff --git a/packages/twenty-ui/src/components/input/index.ts b/packages/twenty-ui/src/components/input/index.ts
index 2523b385599..035be1b4309 100644
--- a/packages/twenty-ui/src/components/input/index.ts
+++ b/packages/twenty-ui/src/components/input/index.ts
@@ -11,8 +11,12 @@ export { CountrySelect } from './CountrySelect/CountrySelect';
export type { CountryChoice } from './CountrySelect/types/CountryChoice';
export type { CountrySelectProps } from './CountrySelect/types/CountrySelectProps';
export { CurrencyPicker } from './CurrencyPicker/CurrencyPicker';
+export type { CurrencyPickerChangeEventDetails } from './CurrencyPicker/types/CurrencyPickerChangeEventDetails';
export type { CurrencyPickerOption } from './CurrencyPicker/types/CurrencyPickerOption';
export type { CurrencyPickerOptionsProps } from './CurrencyPicker/types/CurrencyPickerOptionsProps';
+export type { CurrencyPickerProps } from './CurrencyPicker/types/CurrencyPickerProps';
+export type { CurrencyPickerRootProps } from './CurrencyPicker/types/CurrencyPickerRootProps';
+export type { CurrencyPickerState } from './CurrencyPicker/types/CurrencyPickerState';
export type { CurrencyPickerTriggerProps } from './CurrencyPicker/types/CurrencyPickerTriggerProps';
export { IconButton } from './IconButton/IconButton';
export type { IconButtonProps } from './IconButton/types/IconButtonProps';