The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Complete radio and segmented selection (#27707)
Raphaël Bosi05b2b484c901
diff --git a/packages/twenty-companion/src/renderer/components/Settings.tsx b/packages/twenty-companion/src/renderer/components/Settings.tsxindex 38c0dba5188..7cd7cd1bf84 100644--- a/packages/twenty-companion/src/renderer/components/Settings.tsx+++ b/packages/twenty-companion/src/renderer/components/Settings.tsx@@ -6,7 +6,7 @@ import { Card } from '@ui/primitives/surfaces/Card/Card';import { type ReactNode } from 'react';import { Switch } from '@ui/primitives/input/Switch/Switch';import { Status } from '@ui/primitives/data-display/Status/Status';-import { SegmentedControl } from '@ui/primitives/input/SegmentedControl/SegmentedControl';+import { SegmentedControl } from '@ui/components/input/SegmentedControl/SegmentedControl';import {IconCalendarEvent,IconCircleDot,diff --git a/packages/twenty-docs/docs.json b/packages/twenty-docs/docs.jsonindex 4c0747ec3eb..423a32da2c8 100644--- a/packages/twenty-docs/docs.json+++ b/packages/twenty-docs/docs.json@@ -577,8 +577,7 @@"ui/primitives/input/radio-group","ui/primitives/input/select","ui/primitives/input/slider",- "ui/primitives/input/switch",- "ui/primitives/input/segmented-control"+ "ui/primitives/input/switch"]},{@@ -653,7 +652,8 @@"ui/components/input/phone-country-picker","ui/components/input/image-input","ui/components/input/search-input",- "ui/components/input/number-stepper"+ "ui/components/input/number-stepper",+ "ui/components/input/segmented-control"]},{diff --git a/packages/twenty-docs/navigation/base-structure.json b/packages/twenty-docs/navigation/base-structure.jsonindex aa1c0d9f5e5..e3e18183254 100644--- a/packages/twenty-docs/navigation/base-structure.json+++ b/packages/twenty-docs/navigation/base-structure.json@@ -590,8 +590,7 @@"ui/primitives/input/radio-group","ui/primitives/input/select","ui/primitives/input/slider",- "ui/primitives/input/switch",- "ui/primitives/input/segmented-control"+ "ui/primitives/input/switch"]},{@@ -674,7 +673,8 @@"ui/components/input/phone-country-picker","ui/components/input/image-input","ui/components/input/search-input",- "ui/components/input/number-stepper"+ "ui/components/input/number-stepper",+ "ui/components/input/segmented-control"]},{diff --git a/packages/twenty-docs/snippets/ui/generated/input/segmented-control.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/segmented-control.mdxsimilarity index 100%rename from packages/twenty-docs/snippets/ui/generated/input/segmented-control.mdxrename to packages/twenty-docs/snippets/ui/generated/components/input/segmented-control.mdxdiff --git a/packages/twenty-docs/snippets/ui/generated/input/radio.mdx b/packages/twenty-docs/snippets/ui/generated/input/radio.mdxindex 964320e99c4..982985c0149 100644--- a/packages/twenty-docs/snippets/ui/generated/input/radio.mdx+++ b/packages/twenty-docs/snippets/ui/generated/input/radio.mdx@@ -63,5 +63,73 @@</ParamField><ParamField body="variant" type=""card" | "default"" default="default">- Presentation of the option: a standard radio or a full-width card. Defaults to default.+ Appearance of the styled assembly: a standard radio or a full-width card. Standard radios use a span and card radios use a div unless render replaces the root.+</ParamField>++### Radio.Root++<ParamField body="Root.className" type="string | ((state: RadioRootState) => string | undefined)">+ CSS class applied to the element, or a function that+ returns a class based on the component's state.+</ParamField>++<ParamField body="Root.disabled" type="boolean">+ Whether the component should ignore user interaction.+</ParamField>++<ParamField body="Root.inputRef" type="Ref<HTMLInputElement>">+ A ref to access the hidden input element.+</ParamField>++<ParamField body="Root.nativeButton" type="boolean" default="false">+ Whether the component renders a native `<button>` element when replacing it+ via the `render` prop.+ Set to `true` if the rendered element is a native button.+</ParamField>++<ParamField body="Root.readOnly" type="boolean">+ Whether the user should be unable to select the radio button.+</ParamField>++<ParamField body="Root.render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, RadioRootState>">+ Allows you to replace the component's HTML element+ with a different tag, or compose it with another component.++ Accepts a `ReactElement` or a function that returns the element to render.+</ParamField>++<ParamField body="Root.required" type="boolean">+ Whether the user must choose a value before submitting a form.+</ParamField>++<ParamField body="Root.style" type="CSSProperties | ((state: RadioRootState) => CSSProperties | undefined)">+ Style applied to the element, or a function that+ returns a style object based on the component's state.+</ParamField>++<ParamField body="Root.value" type="Value" required>+ The unique identifying value of the radio in a group.+</ParamField>++### Radio.Indicator++<ParamField body="Indicator.className" type="string | ((state: RadioIndicatorState) => string | undefined)">+ CSS class applied to the element, or a function that+ returns a class based on the component's state.+</ParamField>++<ParamField body="Indicator.keepMounted" type="boolean" default="false">+ Whether to keep the HTML element in the DOM when the radio button is inactive.+</ParamField>++<ParamField body="Indicator.render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, RadioIndicatorState>">+ Allows you to replace the component's HTML element+ with a different tag, or compose it with another component.++ Accepts a `ReactElement` or a function that returns the element to render.+</ParamField>++<ParamField body="Indicator.style" type="CSSProperties | ((state: RadioIndicatorState) => CSSProperties | undefined)">+ Style applied to the element, or a function that+ returns a style object based on the component's state.</ParamField>diff --git a/packages/twenty-docs/ui/primitives/input/segmented-control.mdx b/packages/twenty-docs/ui/components/input/segmented-control.mdxsimilarity index 60%rename from packages/twenty-docs/ui/primitives/input/segmented-control.mdxrename to packages/twenty-docs/ui/components/input/segmented-control.mdxindex 3956920b55a..3a59239f5f5 100644--- a/packages/twenty-docs/ui/primitives/input/segmented-control.mdx+++ b/packages/twenty-docs/ui/components/input/segmented-control.mdx@@ -5,12 +5,12 @@ description: Choose one value from a compact group of labeled or icon options.import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';-import SegmentedControlReference from '/snippets/ui/generated/input/segmented-control.mdx';+import SegmentedControlReference from '/snippets/ui/generated/components/input/segmented-control.mdx';-`SegmentedControl` is a radio group with joined options. Use it for a short, mutually exclusive choice. For navigation between content panels, use [Tabs](/ui/primitives/navigation/tabs).+`SegmentedControl` is a preset assembled from [Radio](/ui/primitives/input/radio) and [RadioGroup](/ui/primitives/input/radio-group), with joined options. Use it for a short, mutually exclusive choice. For navigation between content panels, use [Tabs](/ui/primitives/navigation/tabs).<StoryEmbed- storyId="ui-input-segmentedcontrol--documentation"+ storyId="components-input-segmentedcontrol--documentation"title="SegmentedControl example"/>@@ -21,7 +21,7 @@ Supply an accessible group name with `aria-label` or `aria-labelledby`. Each opt## Uncontrolled state```tsx-import { SegmentedControl } from 'twenty-ui/primitives/input';+import { SegmentedControl } from 'twenty-ui/components/input';export const BillingPeriod = () => (<SegmentedControl@@ -42,7 +42,7 @@ export const BillingPeriod = () => (```tsximport { useState } from 'react';-import { SegmentedControl } from 'twenty-ui/primitives/input';+import { SegmentedControl } from 'twenty-ui/components/input';export const BillingPeriod = () => {const [period, setPeriod] = useState('annual');@@ -67,7 +67,7 @@ Keep `value` in application state and update it in `onValueChange`. Do not combi## Icon options```tsx-import { SegmentedControl } from 'twenty-ui/primitives/input';+import { SegmentedControl } from 'twenty-ui/components/input';import { IconList, IconLayoutKanban } from 'twenty-ui/icon';export const RecordLayout = () => (@@ -91,10 +91,14 @@ An icon-only option requires an `aria-label`. `startIcon` is decorative and hidd## Keyboard, forms, and direction-Tab enters the group; arrow keys move between enabled options and update selection. `itemWidth="equal"` is the default; use `content` when labels should determine widths. Set `name` to include the selected value in native form submission.+Tab enters the group; arrow keys move between enabled options and update selection. This follows radio behavior. Dropdown selection groups move focus with arrow keys and select on activation. `itemWidth="equal"` is the default; use `content` when labels should determine widths. Set `name` to include the selected value in native form submission. The preset preserves RadioGroup's `required`, `readOnly`, disabled state, and native form integration. `onValueChange` receives the selected value and Base UI event details, including `reason` and `cancel()`.For right-to-left content, pair [DirectionProvider](/ui/primitives/layout/direction-provider) with a matching `dir` attribute. The provider controls directional interaction; `dir` controls the document layout.+## Composition and native props++Native props, `className`, `style`, `render`, and `ref` target the group's `div`. Use `render` to compose that group with another element; preserve its accessible name and radio-group semantics. Options render `span` elements with `role="radio"` and hidden native radio inputs. The preset does not assign tab or tab-panel roles. For custom radio content, per-option native props, or a different radio render target, compose `Radio.Root` and `RadioGroup` directly.+## Props<SegmentedControlReference />diff --git a/packages/twenty-docs/ui/components/overview.mdx b/packages/twenty-docs/ui/components/overview.mdxindex 3c9778f19b0..db25fc813ef 100644--- a/packages/twenty-docs/ui/components/overview.mdx+++ b/packages/twenty-docs/ui/components/overview.mdx@@ -23,6 +23,7 @@ Import from `twenty-ui/components/input`.| [CountrySelect](/ui/components/input/country-select) | Searchable country choices, flags, and an explicit empty selection. || [CurrencyPicker](/ui/components/input/currency-picker) | Searchable currency choices with explicit formatting. || [ImageInput](/ui/components/input/image-input) | Image selection and preview with caller-owned uploads. |+| [SegmentedControl](/ui/components/input/segmented-control) | Compact radio choice with joined text or icon options. |## Navigationdiff --git a/packages/twenty-docs/ui/getting-started.mdx b/packages/twenty-docs/ui/getting-started.mdxindex 18bc678a4a6..000d6c189a0 100644--- a/packages/twenty-docs/ui/getting-started.mdx+++ b/packages/twenty-docs/ui/getting-started.mdx@@ -75,7 +75,7 @@ Each primitive and shared component family has a matching public entry point, su| `twenty-ui/components` | All shared component families except the optional editor || `twenty-ui/components/data-display` | Avatar groups, JSON trees, metrics, counters, and icon tiles || `twenty-ui/components/feedback` | Callouts, inline banners, and notifications |-| `twenty-ui/components/input` | Button presets, search and image inputs, and country/currency pickers |+| `twenty-ui/components/input` | Button and radio presets, search and image inputs, and country/currency pickers || `twenty-ui/components/layout` | Sections, overflowing lists, and icon transitions || `twenty-ui/components/navigation` | Dropdowns, menu compositions, and tab actions || `twenty-ui/components/settings` | Settings rows and settings-specific compositions |diff --git a/packages/twenty-docs/ui/primitives/input/radio-group.mdx b/packages/twenty-docs/ui/primitives/input/radio-group.mdxindex 388decc53c6..ffe24fae7e9 100644--- a/packages/twenty-docs/ui/primitives/input/radio-group.mdx+++ b/packages/twenty-docs/ui/primitives/input/radio-group.mdx@@ -17,7 +17,7 @@ import RadioGroupReference from '/snippets/ui/generated/input/radio-group.mdx';## Anatomy-Put each `Radio` inside the group and associate it with a label. `RadioGroup` and `Radio` are separate exports.+Put each `Radio` or `Radio.Root` inside the group and associate it with a label. Use `Radio.Indicator` to compose a custom indicator. `RadioGroup` and `Radio` are separate exports.```textfieldset@@ -108,7 +108,19 @@ export const BillingFrequency = () => {};```-`onValueChange` receives the next value and event details. The generic value type is inferred from the props. Use `disabled` on the group to disable every option, or on an individual radio to disable one choice. Arrow keys navigate the enabled options; Tab moves out of the group.+`onValueChange` receives the next value and event details. The generic value type is inferred from the props. Use `disabled` on the group to disable every option, or on an individual radio to disable one choice. Arrow keys navigate and select enabled options; Tab moves out of the group. The installed Base UI version supports both horizontal and vertical arrow keys and does not expose an orientation prop. Use [DirectionProvider](/ui/primitives/layout/direction-provider) for right-to-left horizontal navigation. Visual row or column layout does not replace the upstream keyboard behavior.++## Native integration and event details++`RadioGroup` renders a div by default. Native props and `ref` target that element; `render` composes another element and changes the actual ref target. `inputRef` targets the representative hidden input of a child radio, using the selected enabled option or an enabled fallback. The public types include generic `RadioGroupProps`, `RadioGroupState`, `RadioGroupChangeEventReason` and `RadioGroupChangeEventDetails`.++The callback receives the original event details, including the native `event`, `reason`, `cancel()` and `allowPropagation()`. Cancel a proposed change before updating controlled state when the choice should be rejected.++Keep `name`, `form`, `required`, `disabled` and `readOnly` on the group for the existing Base UI form contract. The selected value is submitted under `name`; disabled groups are excluded and read-only groups keep their selection. `form` supports a group outside its owning form. The installed version does not restore group state automatically on native form reset. Reset controlled state from the form's `onReset` handler when your workflow requires it.++In sandboxed front components, put the group inside its owning form. The renderer forwards `required` validation and blocks explicit `form` references, which otherwise resolve across the host document.++[SegmentedControl](/ui/components/input/segmented-control) is a convenience preset assembled from these primitives for a short exclusive choice. It uses radio semantics and requires an accessible group name. Tabs and tab-panel navigation are separate controls.## Propsdiff --git a/packages/twenty-docs/ui/primitives/input/radio.mdx b/packages/twenty-docs/ui/primitives/input/radio.mdxindex 28b3460e237..80de1e39273 100644--- a/packages/twenty-docs/ui/primitives/input/radio.mdx+++ b/packages/twenty-docs/ui/primitives/input/radio.mdx@@ -44,9 +44,31 @@ export const ContactMethod = () => (The `size` prop accepts `sm` or `md` and defaults to `sm`. Use the same size for options in a group.+## Complete parts++`Radio.Root` and `Radio.Indicator` expose the installed Base UI parts without the styled assembly. Compose them when you need custom content or indicator placement. The callable `Radio` supplies Twenty's radio appearance and indicator for common options.++```tsx+import { Radio, RadioGroup } from 'twenty-ui/primitives/input';++export const StorageChoice = () => (+ <RadioGroup aria-label="Storage" defaultValue="ssd">+ <Radio.Root value="ssd">+ <Radio.Indicator keepMounted render={<span />}>+ ✓+ </Radio.Indicator>+ SSD+ </Radio.Root>+ <Radio.Root value="hdd">HDD</Radio.Root>+ </RadioGroup>+);+```++Standard radios and `Radio.Root` render a span with radio semantics and an adjacent hidden native input. Card radios render a div. `ref` targets the rendered root; `inputRef` targets the input. `Radio.Indicator` renders a span and its ref targets that element. `render`, state-based `className` and `style`, native attributes and event handlers retain their upstream contracts. The public types include `RadioProps`, `RadioRootProps`, `RadioRootState`, `RadioIndicatorProps` and `RadioIndicatorState`.+## Card options-Use `variant="card"` for full-width options with an inset radio indicator. Card options render a div with radio semantics and accept the same size, disabled, and native props as standard radios. Keep interactive controls outside the card content.+Use `variant="card"` for full-width options with an inset radio indicator. Card radios keep their div root by default. Use `render` to choose another element explicitly. When that element is a native button, also set `nativeButton`. Keep interactive controls outside the card content.<StoryEmbedstoryId="ui-input-radio--cards-documentation"@@ -73,11 +95,42 @@ export const ViewChoice = () => ();```+## Explicit native composition++```tsx+import { Radio, RadioGroup } from 'twenty-ui/primitives/input';++export const BillingChoice = () => (+ <RadioGroup aria-label="Billing interval" defaultValue="monthly">+ <Radio+ variant="card"+ value="monthly"+ nativeButton+ render={<button type="button" />}+ >+ Monthly+ </Radio>+ <Radio+ variant="card"+ value="yearly"+ nativeButton+ render={<button type="button" />}+ >+ Yearly+ </Radio>+ </RadioGroup>+);+```++The ref targets the composed button. For custom non-button roots, leave `nativeButton` false and forward the supplied render props and ref to the actual element.+## Keyboard and selection-Tab enters or leaves the group. Arrow keys move between enabled options and select the focused option. Space selects the focused radio. Selection and change handlers belong on `RadioGroup`; see its [uncontrolled example](/ui/primitives/input/radio-group#uncontrolled-state) and [controlled example](/ui/primitives/input/radio-group#controlled-state).+Tab enters or leaves the group. Arrow keys move between enabled options and select the focused option. Space selects the focused radio. The installed Base UI radio suppresses Enter selection for both default roots and composed native buttons. Selection and change handlers belong on `RadioGroup`; see its [uncontrolled example](/ui/primitives/input/radio-group#uncontrolled-state) and [controlled example](/ui/primitives/input/radio-group#controlled-state).++Radio arrows change selection as they move focus. This differs from the focus-only arrow navigation planned for `Dropdown.SelectionGroup`, where Enter or Space commits a choice.-`Radio` is generic over the value type. Keep that type consistent with its group. Native attributes such as `aria-describedby` can associate an option with additional help text.+`Radio` and `Radio.Root` are generic over the value type. Keep that type consistent with its group. Native attributes such as `aria-describedby` can associate an option with additional help text.## Propsdiff --git a/packages/twenty-docs/ui/primitives/layout/direction-provider.mdx b/packages/twenty-docs/ui/primitives/layout/direction-provider.mdxindex b261cd1beb7..1b91a974387 100644--- a/packages/twenty-docs/ui/primitives/layout/direction-provider.mdx+++ b/packages/twenty-docs/ui/primitives/layout/direction-provider.mdx@@ -10,14 +10,14 @@ import DirectionProviderReference from '/snippets/ui/generated/layout/direction-`DirectionProvider` supplies `ltr` or `rtl` direction to Twenty UI controls. It does not render a DOM element or set an HTML `dir` attribute. Set both the provider direction and the matching document direction.<StoryEmbed- storyId="ui-input-segmentedcontrol--right-to-left-documentation"+ storyId="components-input-segmentedcontrol--right-to-left-documentation"title="DirectionProvider example"/>## Usage```tsx-import { SegmentedControl } from 'twenty-ui/primitives/input';+import { SegmentedControl } from 'twenty-ui/components/input';import { DirectionProvider } from 'twenty-ui/primitives/layout';type DirectionalChoicesProps = { direction: 'ltr' | 'rtl' };@@ -38,7 +38,7 @@ export const DirectionalChoices = ({ direction }: DirectionalChoicesProps) => ();```-The host application supplies translated labels and chooses the direction. Direction context affects directional interactions; the HTML attribute handles text and layout. For example, [SegmentedControl](/ui/primitives/input/segmented-control) reverses horizontal arrow navigation, and [ResizeHandle](/ui/primitives/layout/resize-handle) reverses horizontal resizing.+The host application supplies translated labels and chooses the direction. Direction context affects directional interactions; the HTML attribute handles text and layout. For example, [SegmentedControl](/ui/components/input/segmented-control) reverses horizontal arrow navigation, and [ResizeHandle](/ui/primitives/layout/resize-handle) reverses horizontal resizing.## Scope and statediff --git a/packages/twenty-docs/ui/primitives/overview.mdx b/packages/twenty-docs/ui/primitives/overview.mdxindex bfe785ebd0e..1b79b579d83 100644--- a/packages/twenty-docs/ui/primitives/overview.mdx+++ b/packages/twenty-docs/ui/primitives/overview.mdx@@ -97,7 +97,7 @@ Each page includes usage examples, interaction guidance, and a generated API ref| Accessibility | [VisuallyHidden](/ui/primitives/accessibility/visually-hidden) || Data display | [Avatar](/ui/primitives/data-display/avatar), [Chip](/ui/primitives/data-display/chip), [ColorSample](/ui/primitives/data-display/color-sample), [Badge](/ui/primitives/data-display/badge), [Status](/ui/primitives/data-display/status), [Tag](/ui/primitives/data-display/tag) || Feedback | [Banner](/ui/primitives/feedback/banner), [Loader](/ui/primitives/feedback/loader), [ProgressBar](/ui/primitives/feedback/progress-bar), [ProgressRing](/ui/primitives/feedback/progress-ring) |-| Forms | [Button](/ui/primitives/input/button), [ButtonGroup](/ui/primitives/input/button-group), [Checkbox](/ui/primitives/input/checkbox), [Field](/ui/primitives/input/field), [Input](/ui/primitives/input/input), [InputGroup](/ui/primitives/input/input-group), [Radio](/ui/primitives/input/radio), [RadioGroup](/ui/primitives/input/radio-group), [SegmentedControl](/ui/primitives/input/segmented-control), [Select](/ui/primitives/input/select), [Slider](/ui/primitives/input/slider), [Switch](/ui/primitives/input/switch), [Textarea](/ui/primitives/input/textarea) |+| Forms | [Button](/ui/primitives/input/button), [ButtonGroup](/ui/primitives/input/button-group), [Checkbox](/ui/primitives/input/checkbox), [Field](/ui/primitives/input/field), [Input](/ui/primitives/input/input), [InputGroup](/ui/primitives/input/input-group), [Radio](/ui/primitives/input/radio), [RadioGroup](/ui/primitives/input/radio-group), [Select](/ui/primitives/input/select), [Slider](/ui/primitives/input/slider), [Switch](/ui/primitives/input/switch), [Textarea](/ui/primitives/input/textarea) || Layout | [Collapsible](/ui/primitives/layout/collapsible), [Separator](/ui/primitives/layout/separator), [ResizeHandle](/ui/primitives/layout/resize-handle), [DirectionProvider](/ui/primitives/layout/direction-provider) || Navigation | [ListItem](/ui/primitives/navigation/list-item), [Tabs](/ui/primitives/navigation/tabs) || Surfaces | [AlertDialog](/ui/primitives/surfaces/alert-dialog), [Card](/ui/primitives/surfaces/card), [Dialog](/ui/primitives/surfaces/dialog), [Popover](/ui/primitives/surfaces/popover), [Tooltip](/ui/primitives/surfaces/tooltip) |diff --git a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsxindex 3d3702e70e4..5de57c10ddc 100644--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx@@ -59,6 +59,7 @@ import { radioCardTest } from '@/__stories__/twenty-ui-gallery/utils/radioCardTeimport { checkboxTest } from '@/__stories__/twenty-ui-gallery/utils/checkboxTest';import { fieldControlsTest } from '@/__stories__/twenty-ui-gallery/utils/fieldControlsTest';import { radioGroupTest } from '@/__stories__/twenty-ui-gallery/utils/radioGroupTest';+import { segmentedControlTest } from '@/__stories__/twenty-ui-gallery/utils/segmentedControlTest';import { sliderRangeTest } from '@/__stories__/twenty-ui-gallery/utils/sliderRangeTest';import { sliderTest } from '@/__stories__/twenty-ui-gallery/utils/sliderTest';import { toastTest } from '@/__stories__/twenty-ui-gallery/utils/toastTest';@@ -549,6 +550,17 @@ export const RadioCardPreact: Story = createGalleryStory({play: radioCardTest,});+export const SegmentedControlReact: Story = createGalleryStory({+ frontComponentBundleName: 'twenty-ui-radio-group',+ runtime: 'react',+ play: segmentedControlTest,+});+export const SegmentedControlPreact: Story = createGalleryStory({+ frontComponentBundleName: 'twenty-ui-radio-group',+ runtime: 'preact',+ play: segmentedControlTest,+});+export const StatusControlsReact: Story = createGalleryStory({frontComponentBundleName: 'twenty-ui-status-controls',runtime: 'react',diff --git a/packages/twenty-front-component-renderer/src/__stories__/html-tag/form/input/host-form-association-target-id.ts b/packages/twenty-front-component-renderer/src/__stories__/html-tag/form/input/host-form-association-target-id.tsnew file mode 100644index 00000000000..57f35f88eec--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/html-tag/form/input/host-form-association-target-id.ts@@ -0,0 +1 @@+export const HOST_FORM_ASSOCIATION_TARGET_ID = 'host-preferences';diff --git a/packages/twenty-front-component-renderer/src/__stories__/html-tag/form/input/input-form-association.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/html-tag/form/input/input-form-association.front-component.tsxnew file mode 100644index 00000000000..66874739e2b--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/html-tag/form/input/input-form-association.front-component.tsx@@ -0,0 +1,63 @@+import { useRef, useState } from 'react';+import { defineFrontComponent } from 'twenty-sdk/define';+import { isDefined } from 'twenty-shared/utils';++import { FrontComponentCard } from '@/__stories__/shared/front-components/front-component-card';+import { HOST_FORM_ASSOCIATION_TARGET_ID } from './host-form-association-target-id';++type FormAssociationInput = HTMLInputElement & {+ updateRemoteProperty: (name: string, value: unknown) => void;+};++const InputFormAssociationFrontComponent = () => {+ const inputRef = useRef<FormAssociationInput>(null);+ const [attempt, setAttempt] = useState('idle');++ const requestFormOwner = (attributeName: string) => {+ const input = inputRef.current;++ if (!isDefined(input)) {+ return;+ }++ input.updateRemoteProperty(attributeName, HOST_FORM_ASSOCIATION_TARGET_ID);+ setAttempt(`${attributeName} requested`);+ };++ return (+ <FrontComponentCard title="input:form association">+ <input+ ref={inputRef}+ aria-label="External choice"+ type="checkbox"+ name="guest-choice"+ value="guest-value"+ form={HOST_FORM_ASSOCIATION_TARGET_ID}+ required+ />+ <button type="button" onClick={() => requestFormOwner('FORM')}>+ Send uppercase form owner+ </button>+ <button type="button" onClick={() => requestFormOwner('form')}>+ Send lowercase form owner+ </button>+ <span>Attempt: {attempt}</span>+ <form aria-label="Guest preferences">+ <input+ aria-label="Descendant choice"+ type="checkbox"+ name="descendant-choice"+ value="descendant-value"+ required+ />+ </form>+ </FrontComponentCard>+ );+};++export default defineFrontComponent({+ universalIdentifier: '680d73f3-8d96-4ee5-931d-c315e7f1e1c6',+ name: 'input-form-association-front-component',+ description: 'External form ownership filtering and descendant validation',+ component: InputFormAssociationFrontComponent,+});diff --git a/packages/twenty-front-component-renderer/src/__stories__/html-tag/form/input/input-form-association.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/html-tag/form/input/input-form-association.stories.tsxnew file mode 100644index 00000000000..2cfefe2d93d--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/html-tag/form/input/input-form-association.stories.tsx@@ -0,0 +1,104 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, userEvent, waitFor, within } from 'storybook/test';++import { FrontComponentRenderer } from '@/host/components/FrontComponentRenderer';+import {+ FRONT_COMPONENT_STORY_DEFAULT_ARGS,+ resetFrontComponentStoryMocks,+} from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';+import { runFrontComponentStory } from '@/__stories__/shared/test-utils/runFrontComponentStory';+import { HOST_FORM_ASSOCIATION_TARGET_ID } from './host-form-association-target-id';++const meta: Meta<typeof FrontComponentRenderer> = {+ title: 'FrontComponent/HtmlTag/Form/Input/Form association',+ component: FrontComponentRenderer,+ parameters: { layout: 'centered' },+ args: FRONT_COMPONENT_STORY_DEFAULT_ARGS,+ beforeEach: resetFrontComponentStoryMocks,+ decorators: [+ (Story) => (+ <>+ <form+ id={HOST_FORM_ASSOCIATION_TARGET_ID}+ aria-label="Host preferences"+ >+ <input type="hidden" name="host-choice" value="host-value" />+ </form>+ <Story />+ </>+ ),+ ],+};++export default meta;++type Story = StoryObj<typeof FrontComponentRenderer>;++const play: NonNullable<Story['play']> = async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await expectFrontComponentMounted(canvas);++ const hostForm = canvas.getByRole<HTMLFormElement>('form', {+ name: 'Host preferences',+ });+ const externalChoice = canvas.getByRole<HTMLInputElement>('checkbox', {+ name: 'External choice',+ });++ expect(externalChoice).not.toHaveAttribute('form');+ expect(externalChoice.form).toBeNull();+ expect(hostForm.checkValidity()).toBe(true);+ expect(new FormData(hostForm).get('host-choice')).toBe('host-value');++ await userEvent.click(externalChoice);+ await waitFor(() => expect(externalChoice).toBeChecked());+ expect(new FormData(hostForm).has('guest-choice')).toBe(false);++ await userEvent.click(+ canvas.getByRole('button', { name: 'Send uppercase form owner' }),+ );+ await waitFor(() =>+ expect(canvas.getByText('Attempt: FORM requested')).toBeVisible(),+ );+ expect(externalChoice).not.toHaveAttribute('form');+ expect(externalChoice.form).toBeNull();+ expect(new FormData(hostForm).has('guest-choice')).toBe(false);++ await userEvent.click(+ canvas.getByRole('button', { name: 'Send lowercase form owner' }),+ );+ await waitFor(() =>+ expect(canvas.getByText('Attempt: form requested')).toBeVisible(),+ );+ expect(externalChoice).not.toHaveAttribute('form');+ expect(externalChoice.form).toBeNull();+ expect(new FormData(hostForm).has('guest-choice')).toBe(false);++ const guestForm = canvas.getByRole<HTMLFormElement>('form', {+ name: 'Guest preferences',+ });+ const descendantChoice = canvas.getByRole<HTMLInputElement>('checkbox', {+ name: 'Descendant choice',+ });+ expect(descendantChoice.form).toBe(guestForm);+ expect(guestForm.checkValidity()).toBe(false);+ await userEvent.click(descendantChoice);+ await waitFor(() => expect(descendantChoice).toBeChecked());+ expect(guestForm.checkValidity()).toBe(true);+ expect(new FormData(guestForm).get('descendant-choice')).toBe(+ 'descendant-value',+ );+ expect(new FormData(hostForm).has('descendant-choice')).toBe(false);+};++export const React: Story = runFrontComponentStory({+ frontComponentBundleName: 'input-form-association',+ play,+});++export const Preact: Story = runFrontComponentStory({+ frontComponentBundleName: 'input-form-association',+ runtime: 'preact',+ play,+});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.mdindex efccc7cf2e0..0abfbba7d37 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@@ -23,6 +23,10 @@ Tag and Status retain their presentational span when a native click handler is sCard composition checks native part props and DOM refs, customized anatomy, ordinary display semantics, independent nested controls, button keyboard activation and disabled state, and explicit link ownership in both runtimes.+RadioGroup checks controlled and uncontrolled selection, disabled skipping and looping, arrow selection in vertical and horizontal layouts, RTL direction, and Space activation. Enter does not select a radio. `Radio.Root` and `Radio.Indicator` preserve render state, native props and registered remote HTML refs, whose tag names use the `HTML-` prefix. Host queries separately verify the composed fieldset, default div card and explicit native button card. Descendant native forms retain named radio values and required validation before and after a choice. External form association is filtered at the host boundary until renderer-scoped ownership is supported.++SegmentedControl is imported from `twenty-ui/components/input` and presents an accessible exclusive-choice radio group without tab panels. Its disabled options are skipped during arrow selection. Radio arrows select the focused choice; Dropdown.SelectionGroup arrows only move focus.+AvatarGroup checks derived counts, partially loaded totals, custom overflow and surviving keyed child state. Its native button and link (`target="_blank"`) verify refs, focus and pointer/keyboard activation in React and Preact.Badge checks ordinary node content, compact sizes, colors and circle shape. Its React and Preact fixtures keep count clamping and zero visibility in the caller, and verify native span attributes, refs and pointer handlers plus explicit button and link render composition with keyboard activation.@@ -71,7 +75,7 @@ effect within the interaction timeout.| `twenty-ui-toast` | Toast || `twenty-ui-switch` | Switch (interaction coverage in addition to the original input gallery) || `twenty-ui-checkbox` | Checkbox |-| `twenty-ui-radio-group` | RadioGroup, Radio (standard and card) |+| `twenty-ui-radio-group` | RadioGroup, Radio Root/Indicator and styled cards, SegmentedControl || `twenty-ui-tooltip` | Tooltip (convenience and compound APIs) || `twenty-ui-responsive-hooks` | useIsMobile, useIsTouchDevice, Button hotkeys || `twenty-ui-reading-directions` | Callout, ButtonGroup, Button, AvatarGroup, ListItem, JsonTree in LTR and RTL side by side (`TwentyUiReadingDirections.stories.tsx`) |diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsxindex 16062b75150..465879ec107 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx@@ -5,6 +5,7 @@ import {LightIconButton,MainButton,SearchInput,+ SegmentedControl,} from 'twenty-ui/components/input';import { TabButton } from 'twenty-ui/components/navigation';import { CodeEditorHeader } from 'twenty-ui/components/code-editor';@@ -15,7 +16,6 @@ import {Checkbox,Radio,RadioGroup,- SegmentedControl,Slider,Switch,} from 'twenty-ui/primitives/input';diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-radio-group.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-radio-group.front-component.tsxindex f0533fc5faf..33d9c82f329 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-radio-group.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-radio-group.front-component.tsx@@ -1,40 +1,145 @@-import { useState } from 'react';+import { createElement, useRef, useState } from 'react';import { defineFrontComponent } from 'twenty-sdk/define';+import { SegmentedControl } from 'twenty-ui/components/input';import { Radio, RadioGroup } from 'twenty-ui/primitives/input';+import { DirectionProvider } from 'twenty-ui/primitives/layout';+import { Text } from 'twenty-ui/primitives/typography';import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';const RadioGroupExample = () => {const [frequency, setFrequency] = useState('weekly');const [plan, setPlan] = useState('basic');+ const [frequencyChanges, setFrequencyChanges] = useState(0);+ const [frequencyCallback, setFrequencyCallback] = useState('pending');+ const [frequencyTargets, setFrequencyTargets] = useState('pending');+ const [planTargets, setPlanTargets] = useState('pending');+ const [view, setView] = useState('list');+ const [viewChanges, setViewChanges] = useState(0);+ const groupRef = useRef<HTMLDivElement>(null);+ const radioRef = useRef<HTMLSpanElement>(null);+ const inputRef = useRef<HTMLInputElement>(null);+ const indicatorRef = useRef<HTMLSpanElement>(null);+ const cardRef = useRef<HTMLSpanElement>(null);+ const cardInputRef = useRef<HTMLInputElement>(null);return (<TwentyUiGalleryCard title="Radio group">- <RadioGroup- aria-label="Digest frequency"- value={frequency}- onValueChange={setFrequency}- >- <Radio value="daily">Daily</Radio>- <Radio value="weekly">Weekly</Radio>- <Radio value="monthly" disabled>- Monthly- </Radio>- </RadioGroup>- <p>Frequency: {frequency}</p>- <RadioGroup- aria-label="Plan"- defaultValue="basic"- onValueChange={setPlan}- >- <Radio variant="card" value="basic">- Basic plan- </Radio>- <Radio variant="card" value="pro">- Pro plan- </Radio>- </RadioGroup>- <p>Plan: {plan}</p>+ <form id="digest-preferences" aria-label="Digest preferences">+ <RadioGroup+ name="digest"+ ref={groupRef}+ aria-label="Digest frequency"+ data-native-owner="digest"+ render={<fieldset />}+ value={frequency}+ onValueChange={(nextFrequency, details) => {+ setFrequency(nextFrequency);+ setFrequencyChanges((count) => count + 1);+ setFrequencyCallback(`${details.reason}/${details.event.type}`);+ setFrequencyTargets(+ `${groupRef.current?.tagName}/${radioRef.current?.tagName}/${inputRef.current?.tagName}/${indicatorRef.current?.tagName}`,+ );+ }}+ >+ <Radio.Root+ ref={radioRef}+ inputRef={inputRef}+ value="daily"+ render={(props, state) =>+ createElement('span', {+ ...props,+ 'data-selected': String(state.checked),+ })+ }+ >+ <Radio.Indicator+ ref={indicatorRef}+ keepMounted+ data-testid="daily-indicator"+ render={(props, state) =>+ createElement('span', {+ ...props,+ 'data-selected': String(state.checked),+ })+ }+ />+ Daily+ </Radio.Root>+ <Radio value="weekly">Weekly</Radio>+ <Radio value="monthly" disabled>+ Monthly+ </Radio>+ <Radio value="quarterly">Quarterly</Radio>+ </RadioGroup>+ </form>+ <Text>Frequency: {frequency}</Text>+ <Text>+ Frequency changes: {frequencyChanges}; Callback: {frequencyCallback};+ Targets: {frequencyTargets}+ </Text>+ <form aria-label="Plan preferences">+ <RadioGroup+ aria-label="Plan"+ name="plan"+ defaultValue="basic"+ onValueChange={(nextPlan) => {+ setPlan(nextPlan);+ setPlanTargets(+ `${cardRef.current?.tagName}/${cardInputRef.current?.tagName}`,+ );+ }}+ >+ <Radio variant="card" value="basic">+ Basic plan+ </Radio>+ <Radio+ ref={cardRef}+ inputRef={cardInputRef}+ variant="card"+ value="pro"+ nativeButton+ render={<button type="button" data-native-owner="plan" />}+ >+ Pro plan+ </Radio>+ </RadioGroup>+ </form>+ <Text>+ Plan: {plan}; Targets: {planTargets}+ </Text>+ <DirectionProvider direction="rtl">+ <RadioGroup+ aria-label="Reading mode"+ defaultValue="summary"+ style={{ flexDirection: 'row' }}+ >+ <Radio value="summary">Summary</Radio>+ <Radio value="full">Full detail</Radio>+ <Radio value="audit">Detailed audit</Radio>+ </RadioGroup>+ </DirectionProvider>+ <form aria-label="Required preferences">+ <RadioGroup aria-label="Required preference" name="summaries" required>+ <Radio value="enabled">Enable summaries</Radio>+ </RadioGroup>+ </form>+ <SegmentedControl+ aria-label="Record view"+ value={view}+ onValueChange={(nextView) => {+ setView(nextView);+ setViewChanges((count) => count + 1);+ }}+ options={[+ { value: 'list', label: 'List view' },+ { value: 'board', label: 'Board view', disabled: true },+ { value: 'grid', label: 'Grid view' },+ ]}+ />+ <Text>+ View: {view}; Changes: {viewChanges}+ </Text></TwentyUiGalleryCard>);};@@ -43,6 +148,6 @@ export default defineFrontComponent({universalIdentifier: '4d23e9af-7cb3-4e4a-bbca-8e960f840014',name: 'twenty-ui-radio-group',description:- 'RadioGroup selection with standard and card Radio options in the sandbox',+ 'Radio primitives, card composition and segmented choices in the sandbox',component: RadioGroupExample,});diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/createRadioGroupTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/createRadioGroupTest.tsdeleted file mode 100644index d59cf2c1318..00000000000--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/createRadioGroupTest.ts+++ /dev/null@@ -1,41 +0,0 @@-import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';-import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';-import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';-import { expect, userEvent, waitFor, within } from 'storybook/test';--type CreateRadioGroupTestOptions = {- optionName: string;- initiallyCheckedOptionName: string;- activatedStatus: string;-};--export const createRadioGroupTest =- ({- optionName,- initiallyCheckedOptionName,- activatedStatus,- }: CreateRadioGroupTestOptions): TwentyUiGalleryPlayFunction =>- async ({ canvasElement }) => {- const canvas = within(canvasElement);- await expectFrontComponentMounted(canvas);- expect(canvas.getByRole('radio', { name: 'Weekly' })).toBeChecked();- const disabled = canvas.getByRole('radio', { name: 'Monthly' });- expect(disabled).toHaveAttribute('aria-disabled', 'true');- await userEvent.click(disabled);- expect(disabled).not.toBeChecked();- expect(canvas.getByRole('radio', { name: 'Basic plan' })).toBeChecked();-- const option = canvas.getByRole('radio', { name: optionName });- const initiallyCheckedOption = canvas.getByRole('radio', {- name: initiallyCheckedOptionName,- });-- await userEvent.click(option);-- await waitFor(() =>- expect(canvas.getByText(activatedStatus)).toBeVisible(),- );- expect(option).toBeChecked();- expect(initiallyCheckedOption).not.toBeChecked();- expect(errorHandler).not.toHaveBeenCalled();- };diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/radioCardTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/radioCardTest.tsindex 55e20e7a285..166459ade10 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/radioCardTest.ts+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/radioCardTest.ts@@ -1,7 +1,47 @@-import { createRadioGroupTest } from '@/__stories__/twenty-ui-gallery/utils/createRadioGroupTest';+import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';+import { expect, userEvent, waitFor, within } from 'storybook/test';-export const radioCardTest = createRadioGroupTest({- optionName: 'Pro plan',- initiallyCheckedOptionName: 'Basic plan',- activatedStatus: 'Plan: pro',-});+export const radioCardTest: TwentyUiGalleryPlayFunction = async ({+ canvasElement,+}) => {+ const canvas = within(canvasElement);+ await expectFrontComponentMounted(canvas);+ const plan = within(canvas.getByRole('radiogroup', { name: 'Plan' }));+ const basic = plan.getByRole('radio', { name: 'Basic plan' });+ const pro = plan.getByRole('radio', { name: 'Pro plan' });++ expect(basic.tagName).toBe('DIV');+ expect(basic).toBeChecked();+ expect(pro.tagName).toBe('BUTTON');+ expect(pro).toHaveAttribute('type', 'button');+ expect(pro).toHaveAttribute('data-native-owner', 'plan');+ pro.focus();+ await userEvent.keyboard('{Enter}');+ expect(basic).toBeChecked();+ expect(pro).not.toBeChecked();+ await userEvent.keyboard(' ');+ await waitFor(() =>+ expect(+ canvas.getByText('Plan: pro; Targets: HTML-BUTTON/HTML-INPUT'),+ ).toBeVisible(),+ );+ expect(pro).toBeChecked();+ expect(basic).not.toBeChecked();+ expect(+ new FormData(+ canvas.getByRole<HTMLFormElement>('form', {+ name: 'Plan preferences',+ }),+ ).get('plan'),+ ).toBe('pro');++ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => {+ expect(basic).toHaveFocus();+ expect(basic).toBeChecked();+ });+ expect(pro).not.toBeChecked();+ expect(errorHandler).not.toHaveBeenCalled();+};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/radioGroupTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/radioGroupTest.tsindex edd7ce86b60..d1dd5ef6996 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/radioGroupTest.ts+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/radioGroupTest.ts@@ -1,7 +1,104 @@-import { createRadioGroupTest } from '@/__stories__/twenty-ui-gallery/utils/createRadioGroupTest';+import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';+import { expect, userEvent, waitFor, within } from 'storybook/test';-export const radioGroupTest = createRadioGroupTest({- optionName: 'Daily',- initiallyCheckedOptionName: 'Weekly',- activatedStatus: 'Frequency: daily',-});+export const radioGroupTest: TwentyUiGalleryPlayFunction = async ({+ canvasElement,+}) => {+ const canvas = within(canvasElement);+ await expectFrontComponentMounted(canvas);+ const group = canvas.getByRole('radiogroup', { name: 'Digest frequency' });+ const daily = within(group).getByRole('radio', { name: 'Daily' });+ const weekly = within(group).getByRole('radio', { name: 'Weekly' });+ const monthly = within(group).getByRole('radio', { name: 'Monthly' });+ const quarterly = within(group).getByRole('radio', { name: 'Quarterly' });++ expect(group.tagName).toBe('FIELDSET');+ expect(group).toHaveAttribute('data-native-owner', 'digest');+ expect(weekly).toBeChecked();+ expect(monthly).toHaveAttribute('aria-disabled', 'true');+ expect(daily).toHaveAttribute('data-selected', 'false');+ expect(canvas.getByTestId('daily-indicator')).toHaveAttribute(+ 'data-selected',+ 'false',+ );+ await userEvent.click(monthly);+ expect(monthly).not.toBeChecked();++ await userEvent.click(daily);+ await waitFor(() =>+ expect(canvas.getByText('Frequency: daily')).toBeVisible(),+ );+ expect(weekly).not.toBeChecked();+ expect(daily).toBeChecked();+ expect(+ new FormData(+ canvas.getByRole<HTMLFormElement>('form', {+ name: 'Digest preferences',+ }),+ ).get('digest'),+ ).toBe('daily');+ expect(daily).toHaveAttribute('data-selected', 'true');+ expect(canvas.getByTestId('daily-indicator')).toHaveAttribute(+ 'data-selected',+ 'true',+ );+ expect(+ canvas.getByText(+ /Frequency changes: 1; Callback: none\/(click|change); Targets: HTML-FIELDSET\/HTML-SPAN\/HTML-INPUT\/HTML-SPAN/,+ ),+ ).toBeVisible();++ await userEvent.keyboard('{ArrowDown}');+ await waitFor(() => {+ expect(weekly).toHaveFocus();+ expect(weekly).toBeChecked();+ });+ await userEvent.keyboard('{ArrowDown}');+ await waitFor(() => {+ expect(quarterly).toHaveFocus();+ expect(quarterly).toBeChecked();+ });+ expect(+ new FormData(+ canvas.getByRole<HTMLFormElement>('form', {+ name: 'Digest preferences',+ }),+ ).get('digest'),+ ).toBe('quarterly');+ expect(monthly).not.toBeChecked();+ expect(canvas.getByText('Frequency: quarterly')).toBeVisible();+ await userEvent.keyboard('{ArrowDown}');+ await waitFor(() => {+ expect(daily).toHaveFocus();+ expect(daily).toBeChecked();+ });++ const summary = canvas.getByRole('radio', { name: 'Summary' });+ const fullDetail = canvas.getByRole('radio', { name: 'Full detail' });+ await userEvent.click(summary);+ await userEvent.keyboard('{ArrowLeft}');+ await waitFor(() => {+ expect(fullDetail).toHaveFocus();+ expect(fullDetail).toBeChecked();+ });+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => expect(summary).toBeChecked());++ const enableSummaries = canvas.getByRole('radio', {+ name: 'Enable summaries',+ });+ const requiredForm = canvas.getByRole<HTMLFormElement>('form', {+ name: 'Required preferences',+ });+ expect(requiredForm.checkValidity()).toBe(false);+ enableSummaries.focus();+ await userEvent.keyboard('{Enter}');+ expect(enableSummaries).not.toBeChecked();+ await userEvent.keyboard(' ');+ await waitFor(() => expect(enableSummaries).toBeChecked());+ expect(requiredForm.checkValidity()).toBe(true);+ expect(new FormData(requiredForm).get('summaries')).toBe('enabled');+ expect(errorHandler).not.toHaveBeenCalled();+};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/segmentedControlTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/segmentedControlTest.tsnew file mode 100644index 00000000000..a8561070228--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/segmentedControlTest.ts@@ -0,0 +1,43 @@+import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';+import { expect, userEvent, waitFor, within } from 'storybook/test';++export const segmentedControlTest: TwentyUiGalleryPlayFunction = async ({+ canvasElement,+}) => {+ const canvas = within(canvasElement);+ await expectFrontComponentMounted(canvas);+ const group = canvas.getByRole('radiogroup', { name: 'Record view' });+ const list = within(group).getByRole('radio', { name: 'List view' });+ const board = within(group).getByRole('radio', { name: 'Board view' });+ const grid = within(group).getByRole('radio', { name: 'Grid view' });++ expect(list).toBeChecked();+ expect(board).toHaveAttribute('aria-disabled', 'true');+ expect(canvas.queryByRole('tablist')).not.toBeInTheDocument();+ expect(canvas.queryByRole('tabpanel')).not.toBeInTheDocument();+ expect(list).not.toHaveAttribute('aria-controls');+ await userEvent.click(board);+ expect(board).not.toBeChecked();+ expect(canvas.getByText('View: list; Changes: 0')).toBeVisible();++ await userEvent.click(list);+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() =>+ expect(canvas.getByText('View: grid; Changes: 1')).toBeVisible(),+ );+ expect(grid).toHaveFocus();+ expect(grid).toBeChecked();+ expect(list).not.toBeChecked();+ expect(board).not.toBeChecked();++ await userEvent.keyboard('{ArrowLeft}');+ await waitFor(() =>+ expect(canvas.getByText('View: list; Changes: 2')).toBeVisible(),+ );+ expect(list).toHaveFocus();+ expect(list).toBeChecked();+ expect(grid).not.toBeChecked();+ expect(errorHandler).not.toHaveBeenCalled();+};diff --git a/packages/twenty-front-component-renderer/src/constants/AllowedHtmlElements.ts b/packages/twenty-front-component-renderer/src/constants/AllowedHtmlElements.tsindex 8b5ab4f45ec..058cf384338 100644--- a/packages/twenty-front-component-renderer/src/constants/AllowedHtmlElements.ts+++ b/packages/twenty-front-component-renderer/src/constants/AllowedHtmlElements.ts@@ -87,6 +87,7 @@ export const ALLOWED_HTML_ELEMENTS: AllowedHtmlElement[] = [disabled: { type: 'boolean', optional: true },checked: { type: 'boolean', optional: true },readOnly: { type: 'boolean', optional: true },+ required: { type: 'boolean', optional: true },accept: { type: 'string', optional: true },multiple: { type: 'boolean', optional: true },capture: { type: 'string', optional: true },diff --git a/packages/twenty-front-component-renderer/src/host/elements/utils/__tests__/buildHostReactPropsFromRemoteProps.test.ts b/packages/twenty-front-component-renderer/src/host/elements/utils/__tests__/buildHostReactPropsFromRemoteProps.test.tsindex b1f2017fee6..1ec9e407074 100644--- a/packages/twenty-front-component-renderer/src/host/elements/utils/__tests__/buildHostReactPropsFromRemoteProps.test.ts+++ b/packages/twenty-front-component-renderer/src/host/elements/utils/__tests__/buildHostReactPropsFromRemoteProps.test.ts@@ -198,6 +198,32 @@ describe('buildHostReactPropsFromRemoteProps', () => {expect(result.href).toBe('https://twenty.com');});+ it.each(['form', 'Form', 'FORM'])(+ 'should block %s attributes from assigning host form ownership',+ (formAttributeName) => {+ for (const htmlTag of [+ 'input',+ 'button',+ 'select',+ 'textarea',+ 'fieldset',+ 'output',+ 'div',+ ]) {+ const result = buildHostReactPropsFromRemoteProps({+ remoteProps: {+ [formAttributeName]: 'host-preferences',+ name: 'guest-choice',+ required: true,+ },+ htmlTag,+ });++ expect(result).toEqual({ name: 'guest-choice', required: true });+ }+ },+ );+it('should forward arbitrary aria-* and data-* attributes', () => {const result = buildHostReactPropsFromRemoteProps({remoteProps: {diff --git a/packages/twenty-front-component-renderer/src/host/elements/utils/buildHostReactPropsFromRemoteProps.ts b/packages/twenty-front-component-renderer/src/host/elements/utils/buildHostReactPropsFromRemoteProps.tsindex d6301ab3292..6feab344780 100644--- a/packages/twenty-front-component-renderer/src/host/elements/utils/buildHostReactPropsFromRemoteProps.ts+++ b/packages/twenty-front-component-renderer/src/host/elements/utils/buildHostReactPropsFromRemoteProps.ts@@ -9,6 +9,7 @@ import { isEventHandlerKey } from '@/host/events/utils/isEventHandlerKey';import { type FindRemoteElementIdContainingNode } from '@/host/geometry/types/FindRemoteElementIdContainingNode';const INTERNAL_PROPS = new Set(['element', 'receiver', 'components', 'ref']);+const FORM_OWNER_ATTRIBUTE = 'form';export const buildHostReactPropsFromRemoteProps = ({remoteProps,@@ -26,6 +27,10 @@ export const buildHostReactPropsFromRemoteProps = ({continue;}+ if (remotePropName.toLowerCase() === FORM_OWNER_ATTRIBUTE) {+ continue;+ }+if (remotePropName === 'style') {hostReactProps.style = parseCssString(remotePropValue as string | undefined,diff --git a/packages/twenty-front-component-renderer/src/remote/generated/remote-elements.ts b/packages/twenty-front-component-renderer/src/remote/generated/remote-elements.tsindex f074964a7d5..03811372420 100644--- a/packages/twenty-front-component-renderer/src/remote/generated/remote-elements.ts+++ b/packages/twenty-front-component-renderer/src/remote/generated/remote-elements.ts@@ -534,6 +534,7 @@ export type HtmlInputProperties = HtmlCommonProperties & {disabled?: boolean;checked?: boolean;readOnly?: boolean;+ required?: boolean;accept?: string;multiple?: boolean;capture?: string;@@ -562,6 +563,7 @@ export const HtmlInputElement = createRemoteElement<disabled: { type: Boolean },checked: { type: Boolean },readOnly: { type: Boolean },+ required: { type: Boolean },accept: { type: String },multiple: { type: Boolean },capture: { type: String },diff --git a/packages/twenty-front/src/modules/settings/billing/components/internal/SettingsBillingPlanComparisonTable.tsx b/packages/twenty-front/src/modules/settings/billing/components/internal/SettingsBillingPlanComparisonTable.tsxindex a055ad16f18..f9ced3f2901 100644--- a/packages/twenty-front/src/modules/settings/billing/components/internal/SettingsBillingPlanComparisonTable.tsx+++ b/packages/twenty-front/src/modules/settings/billing/components/internal/SettingsBillingPlanComparisonTable.tsx@@ -12,10 +12,10 @@ import { useNumberFormat } from '@/localization/hooks/useNumberFormat';import { useLingui } from '@lingui/react/macro';import { styled } from '@linaria/react';import {- Button,SegmentedControl,type SegmentedControlOption,-} from 'twenty-ui/primitives/input';+} from 'twenty-ui/components/input';+import { Button } from 'twenty-ui/primitives/input';import { themeCssVariables } from 'twenty-ui/theme';import {BillingPlanKey,diff --git a/packages/twenty-front/src/modules/settings/enterprise/components/EnterprisePlanModal.tsx b/packages/twenty-front/src/modules/settings/enterprise/components/EnterprisePlanModal.tsxindex 1a87f174f1f..6138791a6d1 100644--- a/packages/twenty-front/src/modules/settings/enterprise/components/EnterprisePlanModal.tsx+++ b/packages/twenty-front/src/modules/settings/enterprise/components/EnterprisePlanModal.tsx@@ -79,18 +79,18 @@ const StyledIntervalContainer = styled.div`width: 100%;`;-const StyledIntervalCardContent = styled.div`+const StyledIntervalCardContent = styled.span`display: flex;flex-direction: column;`;-const StyledIntervalTitle = styled.div`+const StyledIntervalTitle = styled.span`color: ${themeCssVariables.font.color.secondary};font-size: ${themeCssVariables.font.size.md};margin-bottom: ${themeCssVariables.spacing[2]};`;-const StyledIntervalSubtitle = styled.div`+const StyledIntervalSubtitle = styled.span`color: ${themeCssVariables.font.color.tertiary};font-size: ${themeCssVariables.font.size.md};`;diff --git a/packages/twenty-shared/src/constants/DocumentationPaths.ts b/packages/twenty-shared/src/constants/DocumentationPaths.tsindex 3fdbddc00f8..efd015b1566 100644--- a/packages/twenty-shared/src/constants/DocumentationPaths.ts+++ b/packages/twenty-shared/src/constants/DocumentationPaths.ts@@ -156,6 +156,8 @@ export const DOCUMENTATION_PATHS = {UI_COMPONENTS_INPUT_PHONE_COUNTRY_PICKER:'/ui/components/input/phone-country-picker',UI_COMPONENTS_INPUT_SEARCH_INPUT: '/ui/components/input/search-input',+ UI_COMPONENTS_INPUT_SEGMENTED_CONTROL:+ '/ui/components/input/segmented-control',UI_COMPONENTS_LAYOUT_ANIMATED_ICON_CROSSFADE:'/ui/components/layout/animated-icon-crossfade',UI_COMPONENTS_LAYOUT_OVERFLOWING_LIST:@@ -195,8 +197,6 @@ export const DOCUMENTATION_PATHS = {UI_PRIMITIVES_INPUT_NUMBER_FIELD: '/ui/primitives/input/number-field',UI_PRIMITIVES_INPUT_RADIO: '/ui/primitives/input/radio',UI_PRIMITIVES_INPUT_RADIO_GROUP: '/ui/primitives/input/radio-group',- UI_PRIMITIVES_INPUT_SEGMENTED_CONTROL:- '/ui/primitives/input/segmented-control',UI_PRIMITIVES_INPUT_SELECT: '/ui/primitives/input/select',UI_PRIMITIVES_INPUT_SLIDER: '/ui/primitives/input/slider',UI_PRIMITIVES_INPUT_SWITCH: '/ui/primitives/input/switch',diff --git a/packages/twenty-ui/.size-limit.json b/packages/twenty-ui/.size-limit.jsonindex baad3bbd7e9..3c490a4b980 100644--- a/packages/twenty-ui/.size-limit.json+++ b/packages/twenty-ui/.size-limit.json@@ -13,7 +13,7 @@{"name": "components","path": "dist/components.mjs",- "limit": "145 kB"+ "limit": "150 kB"},{"name": "components/code-editor",diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.tsindex cce8b646c21..3b5f1380b29 100644--- a/packages/twenty-ui/docs/components.ts+++ b/packages/twenty-ui/docs/components.ts@@ -193,9 +193,9 @@ export const DOCUMENTED_COMPONENTS = [},{name: 'SegmentedControl',- source: 'primitives/input/SegmentedControl/SegmentedControl.tsx',- entryPoint: 'twenty-ui/primitives/input',- slug: 'input/segmented-control',+ source: 'components/input/SegmentedControl/SegmentedControl.tsx',+ entryPoint: 'twenty-ui/components/input',+ slug: 'components/input/segmented-control',propDescriptions: SEGMENTED_CONTROL_PROP_DESCRIPTIONS,},{@@ -402,7 +402,9 @@ export const DOCUMENTED_COMPONENTS = [source: 'primitives/input/Radio/Radio.tsx',entryPoint: 'twenty-ui/primitives/input',slug: 'input/radio',+ parts: ['Root', 'Indicator'],propDescriptions: RADIO_PROP_DESCRIPTIONS,+ propDefaults: { size: 'sm', variant: 'default' },},{name: 'RadioGroup',diff --git a/packages/twenty-ui/docs/module-ownership.json b/packages/twenty-ui/docs/module-ownership.jsonindex a0e19d07a48..b75d74f8fde 100644--- a/packages/twenty-ui/docs/module-ownership.json+++ b/packages/twenty-ui/docs/module-ownership.json@@ -29,7 +29,6 @@"Radio","RadioGroup","ResizeHandle",- "SegmentedControl","Select","Separator","Shortcut",@@ -73,6 +72,7 @@"PhoneCountryPicker","SearchInput","Section",+ "SegmentedControl","SettingsRow","TabButton","TintedIconTile",diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.jsonindex 2fac6a35e04..08c8b522dc9 100644--- a/packages/twenty-ui/docs/public-exports.json+++ b/packages/twenty-ui/docs/public-exports.json@@ -94,7 +94,8 @@"MainButton": "components/input/MainButton/MainButton","NumberStepper": "components/input/NumberStepper/NumberStepper","PhoneCountryPicker": "components/input/PhoneCountryPicker/PhoneCountryPicker",- "SearchInput": "components/input/SearchInput/SearchInput"+ "SearchInput": "components/input/SearchInput/SearchInput",+ "SegmentedControl": "components/input/SegmentedControl/SegmentedControl"},"types": {"CountryChoice": "components/input/CountrySelect/types/CountryChoice",@@ -111,7 +112,9 @@"PhoneCountryOption": "components/input/PhoneCountryPicker/types/PhoneCountryOption","PhoneCountryPickerOptionsProps": "components/input/PhoneCountryPicker/types/PhoneCountryPickerOptionsProps","PhoneCountryPickerTriggerProps": "components/input/PhoneCountryPicker/types/PhoneCountryPickerTriggerProps",- "SearchInputProps": "components/input/SearchInput/types/SearchInputProps"+ "SearchInputProps": "components/input/SearchInput/types/SearchInputProps",+ "SegmentedControlOption": "components/input/SegmentedControl/types/SegmentedControlOption",+ "SegmentedControlProps": "components/input/SegmentedControl/types/SegmentedControlProps"}},"components/layout": {@@ -793,7 +796,6 @@"NumberField": "primitives/input/NumberField/NumberField","Radio": "primitives/input/Radio/Radio","RadioGroup": "primitives/input/RadioGroup/RadioGroup",- "SegmentedControl": "primitives/input/SegmentedControl/SegmentedControl","Select": "primitives/input/Select/Select","Slider": "primitives/input/Slider/Slider","Switch": "primitives/input/Switch/Switch",@@ -890,10 +892,15 @@"NumberFieldScrubAreaCursorState": "primitives/input/NumberField/types/NumberFieldScrubAreaCursorState","NumberFieldScrubAreaProps": "primitives/input/NumberField/types/NumberFieldScrubAreaProps","NumberFieldScrubAreaState": "primitives/input/NumberField/types/NumberFieldScrubAreaState",+ "RadioGroupChangeEventDetails": "primitives/input/RadioGroup/types/RadioGroupChangeEventDetails",+ "RadioGroupChangeEventReason": "primitives/input/RadioGroup/types/RadioGroupChangeEventReason","RadioGroupProps": "primitives/input/RadioGroup/types/RadioGroupProps",+ "RadioGroupState": "primitives/input/RadioGroup/types/RadioGroupState",+ "RadioIndicatorProps": "primitives/input/Radio/types/RadioIndicatorProps",+ "RadioIndicatorState": "primitives/input/Radio/types/RadioIndicatorState","RadioProps": "primitives/input/Radio/types/RadioProps",- "SegmentedControlOption": "primitives/input/SegmentedControl/types/SegmentedControlOption",- "SegmentedControlProps": "primitives/input/SegmentedControl/types/SegmentedControlProps",+ "RadioRootProps": "primitives/input/Radio/types/RadioRootProps",+ "RadioRootState": "primitives/input/Radio/types/RadioRootState","SelectArrowProps": "primitives/input/Select/types/SelectArrowProps","SelectArrowState": "primitives/input/Select/types/SelectArrowState","SelectBackdropProps": "primitives/input/Select/types/SelectBackdropProps",diff --git a/packages/twenty-ui/docs/radioPropDescriptions.ts b/packages/twenty-ui/docs/radioPropDescriptions.tsindex f31e5b49182..06e1292577b 100644--- a/packages/twenty-ui/docs/radioPropDescriptions.ts+++ b/packages/twenty-ui/docs/radioPropDescriptions.ts@@ -6,5 +6,5 @@ export const RADIO_PROP_DESCRIPTIONS = {children:'Option content. Card options wrap it in a padded full-width content area.',variant:- 'Presentation of the option: a standard radio or a full-width card. Defaults to default.',+ 'Appearance of the styled assembly: a standard radio or a full-width card. Standard radios use a span and card radios use a div unless render replaces the root.',} satisfies Partial<Record<keyof ComponentProps<typeof Radio>, string>>;diff --git a/packages/twenty-ui/docs/segmentedControlPropDescriptions.ts b/packages/twenty-ui/docs/segmentedControlPropDescriptions.tsindex c39a89a7d64..54c1d595297 100644--- a/packages/twenty-ui/docs/segmentedControlPropDescriptions.ts+++ b/packages/twenty-ui/docs/segmentedControlPropDescriptions.ts@@ -1,7 +1,7 @@import { type ComponentProps } from 'react';import { type KeysOfUnion } from 'type-fest';-import { type SegmentedControl } from '../src/primitives/input/SegmentedControl/SegmentedControl';+import { type SegmentedControl } from '../src/components/input/SegmentedControl/SegmentedControl';export const SEGMENTED_CONTROL_PROP_DESCRIPTIONS = {itemWidth: 'Use equal-width options or size each option to its content.',diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex 700c4682bf8..9e1c047e619 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -1006,8 +1006,8 @@},{"name": "SegmentedControl",- "entryPoint": "twenty-ui/primitives/input",- "slug": "input/segmented-control",+ "entryPoint": "twenty-ui/components/input",+ "slug": "components/input/segmented-control","props": [{"name": "aria-label",@@ -3837,7 +3837,110 @@"type": "\"card\" | \"default\"","required": false,"defaultValue": "default",- "description": "Presentation of the option: a standard radio or a full-width card. Defaults to default."+ "description": "Appearance of the styled assembly: a standard radio or a full-width card. Standard radios use a span and card radios use a div unless render replaces the root."+ }+ ],+ "parts": [+ {+ "name": "Root",+ "props": [+ {+ "name": "className",+ "type": "string | ((state: RadioRootState) => 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."+ },+ {+ "name": "disabled",+ "type": "boolean",+ "required": false,+ "defaultValue": null,+ "description": "Whether the component should ignore user interaction."+ },+ {+ "name": "inputRef",+ "type": "Ref<HTMLInputElement>",+ "required": false,+ "defaultValue": null,+ "description": "A ref to access the hidden input element."+ },+ {+ "name": "nativeButton",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the component renders a native `<button>` element when replacing it\nvia the `render` prop.\nSet to `true` if the rendered element is a native button."+ },+ {+ "name": "readOnly",+ "type": "boolean",+ "required": false,+ "defaultValue": null,+ "description": "Whether the user should be unable to select the radio button."+ },+ {+ "name": "render",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, RadioRootState>",+ "required": false,+ "defaultValue": null,+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."+ },+ {+ "name": "required",+ "type": "boolean",+ "required": false,+ "defaultValue": null,+ "description": "Whether the user must choose a value before submitting a form."+ },+ {+ "name": "style",+ "type": "CSSProperties | ((state: RadioRootState) => 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": "Value",+ "required": true,+ "defaultValue": null,+ "description": "The unique identifying value of the radio in a group."+ }+ ]+ },+ {+ "name": "Indicator",+ "props": [+ {+ "name": "className",+ "type": "string | ((state: RadioIndicatorState) => 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."+ },+ {+ "name": "keepMounted",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether to keep the HTML element in the DOM when the radio button is inactive."+ },+ {+ "name": "render",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, RadioIndicatorState>",+ "required": false,+ "defaultValue": null,+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."+ },+ {+ "name": "style",+ "type": "CSSProperties | ((state: RadioIndicatorState) => 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."+ }+ ]}]},diff --git a/packages/twenty-ui/src/components/__stories__/reading-direction/DirectionalLayoutExample.tsx b/packages/twenty-ui/src/components/__stories__/reading-direction/DirectionalLayoutExample.tsxindex 15a395bd2c3..88a608da6a6 100644--- a/packages/twenty-ui/src/components/__stories__/reading-direction/DirectionalLayoutExample.tsx+++ b/packages/twenty-ui/src/components/__stories__/reading-direction/DirectionalLayoutExample.tsx@@ -1,12 +1,7 @@import { AvatarGroup, Callout, JsonTree } from '@ui/components';+import { SegmentedControl } from '@ui/components/input/SegmentedControl/SegmentedControl';import { Avatar, Badge } from '@ui/primitives/data-display';-import {- Button,- ButtonGroup,- Radio,- RadioGroup,- SegmentedControl,-} from '@ui/primitives/input';+import { Button, ButtonGroup, Radio, RadioGroup } from '@ui/primitives/input';import { ListItem } from '@ui/primitives/navigation';import { Text } from '@ui/primitives/typography';diff --git a/packages/twenty-ui/src/primitives/input/SegmentedControl/SegmentedControl.module.scss b/packages/twenty-ui/src/components/input/SegmentedControl/SegmentedControl.module.scsssimilarity index 100%rename from packages/twenty-ui/src/primitives/input/SegmentedControl/SegmentedControl.module.scssrename to packages/twenty-ui/src/components/input/SegmentedControl/SegmentedControl.module.scssdiff --git a/packages/twenty-ui/src/primitives/input/SegmentedControl/SegmentedControl.module.scss.d.ts b/packages/twenty-ui/src/components/input/SegmentedControl/SegmentedControl.module.scss.d.tssimilarity index 100%rename from packages/twenty-ui/src/primitives/input/SegmentedControl/SegmentedControl.module.scss.d.tsrename to packages/twenty-ui/src/components/input/SegmentedControl/SegmentedControl.module.scss.d.tsdiff --git a/packages/twenty-ui/src/primitives/input/SegmentedControl/SegmentedControl.tsx b/packages/twenty-ui/src/components/input/SegmentedControl/SegmentedControl.tsxsimilarity index 91%rename from packages/twenty-ui/src/primitives/input/SegmentedControl/SegmentedControl.tsxrename to packages/twenty-ui/src/components/input/SegmentedControl/SegmentedControl.tsxindex 0fa3290e431..574e61a2bfc 100644--- a/packages/twenty-ui/src/primitives/input/SegmentedControl/SegmentedControl.tsx+++ b/packages/twenty-ui/src/components/input/SegmentedControl/SegmentedControl.tsx@@ -1,7 +1,8 @@-import { Radio as RadioPrimitive } from '@base-ui/react/radio';import { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group';import { clsx } from 'clsx';+import { Radio } from '@ui/primitives/input/Radio/Radio';+import { isRenderableSlot } from '@ui/utilities/internal/isRenderableSlot';import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';@@ -21,7 +22,7 @@ export const SegmentedControl = <TValue extends string>({>{options.map(({ 'aria-label': ariaLabel, disabled, label, startIcon, value }) => (- <RadioPrimitive.Root+ <Radio.Rootkey={value}value={value}disabled={disabled}@@ -39,7 +40,7 @@ export const SegmentedControl = <TValue extends string>({{isRenderableSlot(label) && (<span className={styles.label}>{label}</span>)}- </RadioPrimitive.Root>+ </Radio.Root>),)}</RadioGroupPrimitive>diff --git a/packages/twenty-ui/src/primitives/input/SegmentedControl/__stories__/SegmentedControl.stories.tsx b/packages/twenty-ui/src/components/input/SegmentedControl/__stories__/SegmentedControl.stories.tsxsimilarity index 77%rename from packages/twenty-ui/src/primitives/input/SegmentedControl/__stories__/SegmentedControl.stories.tsxrename to packages/twenty-ui/src/components/input/SegmentedControl/__stories__/SegmentedControl.stories.tsxindex 3b4258ebdf9..496f8d5dc43 100644--- a/packages/twenty-ui/src/primitives/input/SegmentedControl/__stories__/SegmentedControl.stories.tsx+++ b/packages/twenty-ui/src/components/input/SegmentedControl/__stories__/SegmentedControl.stories.tsx@@ -8,7 +8,7 @@ import { ComponentDecorator } from '@ui/testing';import { SegmentedControl } from '../SegmentedControl';const meta: Meta<typeof SegmentedControl> = {- title: 'UI/Input/SegmentedControl',+ title: 'Components/Input/SegmentedControl',component: SegmentedControl,decorators: [ComponentDecorator],args: {@@ -27,14 +27,13 @@ type Story = StoryObj<typeof SegmentedControl>;export const Default: Story = {play: async ({ canvasElement }) => {const canvas = within(canvasElement);+ const annual = canvas.getByRole('radio', { name: 'Annual' });+ const monthly = canvas.getByRole('radio', { name: 'Monthly' });const monthlyLabel = canvas.getByText('Monthly');- await expect(- canvas.getByRole('radio', { name: 'Annual' }).getBoundingClientRect()- .width,- ).toBe(- canvas.getByRole('radio', { name: 'Monthly' }).getBoundingClientRect()- .width,+ await expect(annual).toBeChecked();+ await expect(annual.getBoundingClientRect().width).toBe(+ monthly.getBoundingClientRect().width,);await expect(monthlyLabel.scrollWidth).toBeLessThanOrEqual(monthlyLabel.clientWidth,@@ -46,6 +45,7 @@ export const Documentation: Story = {};export const Dark: Story = {globals: { colorScheme: 'dark' },+ play: Default.play,};export const WithDisabledOption: Story = {@@ -56,6 +56,15 @@ export const WithDisabledOption: Story = {{ disabled: true, label: 'Weekly', value: 'weekly' },],},+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const weekly = canvas.getByRole('radio', { name: 'Weekly' });++ await expect(weekly).toHaveAttribute('aria-disabled', 'true');+ await userEvent.click(weekly);+ await expect(weekly).not.toBeChecked();+ await expect(canvas.getByRole('radio', { name: 'Annual' })).toBeChecked();+ },};export const IconOnly: Story = {@@ -64,16 +73,12 @@ export const IconOnly: Story = {defaultValue: 'home',options: [{- startIcon: <IconHome data-testid="direct-icon" />,+ startIcon: <IconHome />,'aria-label': 'Home',value: 'home',},{- startIcon: (- <span>- <IconComment data-testid="wrapped-icon" />- </span>- ),+ startIcon: <IconComment />,'aria-label': 'Chat',value: 'chat',},@@ -83,19 +88,7 @@ export const IconOnly: Story = {const canvas = within(canvasElement);const home = canvas.getByRole('radio', { name: 'Home' });const chat = canvas.getByRole('radio', { name: 'Chat' });- const directIcon = canvas.getByTestId('direct-icon');- const directIconBounds = directIcon.getBoundingClientRect();- const wrappedIconBounds = canvas- .getByTestId('wrapped-icon')- .getBoundingClientRect();-- await expect(directIcon.parentElement).toHaveAttribute(- 'aria-hidden',- 'true',- );- await expect(directIconBounds.width).toBeGreaterThan(0);- await expect(wrappedIconBounds.width).toBe(directIconBounds.width);- await expect(wrappedIconBounds.height).toBe(directIconBounds.height);+await expect(home).toBeChecked();await expect(chat).not.toBeChecked();await userEvent.click(chat);@@ -106,10 +99,22 @@ export const IconOnly: Story = {export const ContentWidth: Story = {args: { itemWidth: 'content' },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await expect(+ canvas.getByRole('radio', { name: 'Annual' }).getBoundingClientRect()+ .width,+ ).toBeLessThan(+ canvas.getByRole('radio', { name: 'Monthly' }).getBoundingClientRect()+ .width,+ );+ },};export const EqualWidth: Story = {args: { style: { width: 280 } },+ play: Default.play,};export const RightToLeft: Story = {diff --git a/packages/twenty-ui/src/components/input/SegmentedControl/__stories__/SegmentedControlInteractions.stories.tsx b/packages/twenty-ui/src/components/input/SegmentedControl/__stories__/SegmentedControlInteractions.stories.tsxnew file mode 100644index 00000000000..f051f5d1b14--- /dev/null+++ b/packages/twenty-ui/src/components/input/SegmentedControl/__stories__/SegmentedControlInteractions.stories.tsx@@ -0,0 +1,443 @@+import { isFunction } from '@sniptt/guards';+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { useState } from 'react';+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';++import { IconComment, IconHome } from '@ui/icon';+import { DirectionProvider } from '@ui/primitives/layout/DirectionProvider/DirectionProvider';+import { Button } from '@ui/primitives/input/Button/Button';+import { ComponentDecorator } from '@ui/testing';++import { SegmentedControl } from '../SegmentedControl';+import { type SegmentedControlProps } from '../types/SegmentedControlProps';++const ControlledExample = (props: SegmentedControlProps<string>) => {+ const [appearance, setAppearance] = useState('system');++ return (+ <>+ <SegmentedControl+ {...props}+ defaultValue={undefined}+ value={appearance}+ onValueChange={(value, eventDetails) => {+ props.onValueChange?.(value, eventDetails);+ setAppearance(value);+ }}+ />+ <output aria-label="Selected appearance">{appearance}</output>+ </>+ );+};++const CallerAppliedExample = (props: SegmentedControlProps<string>) => {+ const [appearance, setAppearance] = useState('system');++ return (+ <>+ <SegmentedControl+ {...props}+ defaultValue={undefined}+ value={appearance}+ />+ <Button onClick={() => setAppearance('dark')}>Apply Dark</Button>+ </>+ );+};++const PendingExample = (props: SegmentedControlProps<string>) => {+ const [isPending, setIsPending] = useState(false);++ return (+ <>+ <SegmentedControl+ {...props}+ disabled={isPending}+ onValueChange={(value, eventDetails) => {+ props.onValueChange?.(value, eventDetails);+ setIsPending(true);+ }}+ />+ <Button onClick={() => setIsPending(false)}>Finish saving</Button>+ </>+ );+};++const FormExample = (props: SegmentedControlProps<string>) => {+ const [savedAppearance, setSavedAppearance] = useState('Not saved');++ return (+ <form+ onSubmit={(event) => {+ event.preventDefault();+ setSavedAppearance(+ String(new FormData(event.currentTarget).get('appearance')),+ );+ }}+ >+ <SegmentedControl {...props} name="appearance" />+ <Button type="submit">Save appearance</Button>+ <output aria-label="Saved appearance">{savedAppearance}</output>+ </form>+ );+};++const meta: Meta<typeof SegmentedControl> = {+ title: 'Components/Input/SegmentedControl/Interactions',+ component: SegmentedControl,+ decorators: [ComponentDecorator],+ args: {+ 'aria-label': 'Appearance',+ defaultValue: 'system',+ onValueChange: fn(),+ options: [+ { value: 'system', label: 'System' },+ { value: 'light', label: 'Light', disabled: true },+ { value: 'dark', label: 'Dark' },+ { value: 'contrast', label: 'High contrast' },+ ],+ },+};++export default meta;+type Story = StoryObj<typeof SegmentedControl>;++const onUncontrolledValueChange =+ fn<NonNullable<SegmentedControlProps<string>['onValueChange']>>();++export const Uncontrolled: Story = {+ args: { onValueChange: onUncontrolledValueChange },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const dark = canvas.getByRole('radio', { name: 'Dark' });++ await expect(+ canvas.getByRole('radiogroup', { name: 'Appearance' }),+ ).toBeVisible();+ await expect(canvas.getByRole('radio', { name: 'System' })).toBeChecked();+ await userEvent.click(dark);+ await userEvent.click(dark);++ await expect(dark).toBeChecked();+ await expect(+ canvas.getByRole('radio', { name: 'System' }),+ ).not.toBeChecked();+ await expect(args.onValueChange).toHaveBeenCalledTimes(1);+ await expect(canvas.queryByRole('tab')).toBeNull();+ await expect(args.onValueChange).toHaveBeenCalledWith(+ 'dark',+ expect.objectContaining({+ reason: 'none',+ event: expect.objectContaining({ type: 'click' }),+ }),+ );+ await expect(+ isFunction(onUncontrolledValueChange.mock.calls[0]?.[1].cancel),+ ).toBe(true);+ },+};++export const DisabledOption: Story = {+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const light = canvas.getByRole('radio', { name: 'Light' });++ await expect(light).toHaveAttribute('aria-disabled', 'true');+ await userEvent.click(light);+ await expect(canvas.getByRole('radio', { name: 'System' })).toBeChecked();+ await expect(args.onValueChange).not.toHaveBeenCalled();+ },+};++export const DisabledCheckedOption: Story = {+ args: { defaultValue: 'light' },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const dark = canvas.getByRole('radio', { name: 'Dark' });++ await userEvent.tab();+ await expect(canvas.getByRole('radio', { name: 'Light' })).toHaveFocus();+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => expect(dark).toHaveFocus());+ await expect(dark).toBeChecked();+ },+};++export const Pending: Story = {+ render: (args) => <PendingExample {...args} />,+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const dark = canvas.getByRole('radio', { name: 'Dark' });+ const contrast = canvas.getByRole('radio', { name: 'High contrast' });++ await userEvent.tab();+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => expect(dark).toBeChecked());+ for (const choice of canvas.getAllByRole('radio')) {+ await expect(choice).toHaveAttribute('aria-disabled', 'true');+ }+ await expect(dark).toHaveFocus();+ await userEvent.keyboard('{ArrowRight}');+ await expect(dark).toHaveFocus();+ await userEvent.click(contrast);+ await expect(contrast).not.toBeChecked();+ await expect(args.onValueChange).toHaveBeenCalledTimes(1);++ await userEvent.click(+ canvas.getByRole('button', { name: 'Finish saving' }),+ );+ await expect(contrast).not.toHaveAttribute('aria-disabled');+ await userEvent.click(contrast);+ await expect(contrast).toBeChecked();+ await expect(args.onValueChange).toHaveBeenCalledTimes(2);+ await expect(args.onValueChange).toHaveBeenLastCalledWith(+ 'contrast',+ expect.anything(),+ );+ },+};++export const FormSubmission: Story = {+ render: (args) => <FormExample {...args} />,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const savedAppearance = canvas.getByLabelText('Saved appearance');++ await userEvent.click(canvas.getByRole('radio', { name: 'Dark' }));+ await expect(savedAppearance).toHaveTextContent('Not saved');++ await userEvent.click(+ canvas.getByRole('button', { name: 'Save appearance' }),+ );+ await expect(savedAppearance).toHaveTextContent('dark');+ },+};++export const Keyboard: Story = {+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const system = canvas.getByRole('radio', { name: 'System' });+ const dark = canvas.getByRole('radio', { name: 'Dark' });+ const contrast = canvas.getByRole('radio', { name: 'High contrast' });++ await userEvent.tab();+ await expect(system).toHaveFocus();+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => expect(dark).toHaveFocus());+ await expect(dark).toBeChecked();+ await expect(args.onValueChange).toHaveBeenLastCalledWith(+ 'dark',+ expect.anything(),+ );+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => expect(contrast).toBeChecked());+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => expect(system).toHaveFocus());+ await expect(system).toBeChecked();+ await userEvent.keyboard('{ArrowLeft}');+ await waitFor(() => expect(contrast).toBeChecked());+ await userEvent.tab({ shift: true });+ await expect(contrast).not.toHaveFocus();+ await userEvent.tab();+ await expect(contrast).toHaveFocus();+ },+};++export const Controlled: Story = {+ render: (args) => <ControlledExample {...args} />,+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const dark = canvas.getByRole('radio', { name: 'Dark' });++ await userEvent.click(dark);++ await expect(dark).toBeChecked();+ await expect(+ canvas.getByLabelText('Selected appearance'),+ ).toHaveTextContent('dark');+ await expect(args.onValueChange).toHaveBeenCalledTimes(1);+ await expect(args.onValueChange).toHaveBeenCalledWith(+ 'dark',+ expect.objectContaining({ reason: 'none' }),+ );+ },+};++export const ControlledSelection: Story = {+ render: (args) => <CallerAppliedExample {...args} />,+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const system = canvas.getByRole('radio', { name: 'System' });+ const dark = canvas.getByRole('radio', { name: 'Dark' });++ await userEvent.click(dark);++ await expect(system).toBeChecked();+ await expect(dark).not.toBeChecked();+ await expect(args.onValueChange).toHaveBeenCalledTimes(1);+ await expect(args.onValueChange).toHaveBeenCalledWith(+ 'dark',+ expect.objectContaining({+ reason: 'none',+ event: expect.objectContaining({ type: 'click' }),+ }),+ );++ await userEvent.click(canvas.getByRole('button', { name: 'Apply Dark' }));++ await expect(dark).toBeChecked();+ await expect(system).not.toBeChecked();+ await expect(args.onValueChange).toHaveBeenCalledTimes(1);+ },+};++export const CanceledChange: Story = {+ args: {+ onValueChange: fn<+ NonNullable<SegmentedControlProps<string>['onValueChange']>+ >((_value, eventDetails) => eventDetails.cancel()),+ },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const dark = canvas.getByRole('radio', { name: 'Dark' });++ await userEvent.click(dark);++ await expect(canvas.getByRole('radio', { name: 'System' })).toBeChecked();+ await expect(dark).not.toBeChecked();+ await expect(args.onValueChange).toHaveBeenCalledTimes(1);+ await expect(args.onValueChange).toHaveBeenCalledWith(+ 'dark',+ expect.objectContaining({ reason: 'none', isCanceled: true }),+ );+ },+};++export const EqualWidths: Story = {+ args: {+ 'aria-label': 'Billing period',+ defaultValue: 'annual',+ style: { width: 280 },+ options: [+ { label: 'Annual', value: 'annual' },+ { label: 'Monthly', value: 'monthly' },+ ],+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const monthlyLabel = canvas.getByText('Monthly');++ await expect(+ canvas.getByRole('radio', { name: 'Annual' }).getBoundingClientRect()+ .width,+ ).toBe(+ canvas.getByRole('radio', { name: 'Monthly' }).getBoundingClientRect()+ .width,+ );+ await expect(monthlyLabel.scrollWidth).toBeLessThanOrEqual(+ monthlyLabel.clientWidth,+ );+ await expect(+ canvas.getByRole('radiogroup', { name: 'Billing period' }),+ ).toHaveStyle({ gridAutoFlow: 'column', gap: '2px' });+ },+};++export const ConsumerClassName: Story = {+ render: (args) => (+ <>+ <SegmentedControl+ {...args}+ className="segmented-control-consumer-overrides"+ />+ <style>{`+ .segmented-control-consumer-overrides {+ display: grid;+ gap: 8px;+ padding: 6px;+ }+ `}</style>+ </>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const group = canvas.getByRole('radiogroup', { name: 'Appearance' });++ await expect(group).toHaveStyle({+ display: 'grid',+ gap: '8px',+ padding: '6px',+ });++ await userEvent.click(canvas.getByRole('radio', { name: 'Dark' }));++ await expect(canvas.getByRole('radio', { name: 'Dark' })).toBeChecked();+ },+};++export const IconOnly: Story = {+ args: {+ 'aria-label': 'Start page',+ defaultValue: 'home',+ options: [+ {+ startIcon: <IconHome data-testid="direct-icon" />,+ 'aria-label': 'Home',+ value: 'home',+ },+ {+ startIcon: (+ <span>+ <IconComment data-testid="wrapped-icon" />+ </span>+ ),+ 'aria-label': 'Chat',+ value: 'chat',+ },+ ],+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const home = canvas.getByRole('radio', { name: 'Home' });+ const chat = canvas.getByRole('radio', { name: 'Chat' });+ const directIcon = canvas.getByTestId('direct-icon');+ const directIconBounds = directIcon.getBoundingClientRect();+ const wrappedIconBounds = canvas+ .getByTestId('wrapped-icon')+ .getBoundingClientRect();++ await expect(directIcon.parentElement).toHaveAttribute(+ 'aria-hidden',+ 'true',+ );+ await expect(directIconBounds.width).toBeGreaterThan(0);+ await expect(wrappedIconBounds.width).toBe(directIconBounds.width);+ await expect(wrappedIconBounds.height).toBe(directIconBounds.height);+ await expect(home).toBeChecked();+ await expect(chat).not.toBeChecked();+ await userEvent.click(chat);+ await expect(chat).toBeChecked();+ await expect(home).not.toBeChecked();+ },+};++export const RightToLeft: Story = {+ render: (args) => (+ <DirectionProvider direction="rtl">+ <SegmentedControl {...args} dir="rtl" />+ </DirectionProvider>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const system = canvas.getByRole('radio', { name: 'System' });+ const dark = canvas.getByRole('radio', { name: 'Dark' });++ await userEvent.tab();+ await expect(system).toHaveFocus();+ await userEvent.keyboard('{ArrowLeft}');+ await waitFor(() => expect(dark).toHaveFocus());+ await expect(dark).toBeChecked();+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => expect(system).toBeChecked());+ },+};diff --git a/packages/twenty-ui/src/primitives/input/SegmentedControl/__tests__/SegmentedControl.test.tsx b/packages/twenty-ui/src/components/input/SegmentedControl/__tests__/SegmentedControl.test.tsxsimilarity index 100%rename from packages/twenty-ui/src/primitives/input/SegmentedControl/__tests__/SegmentedControl.test.tsxrename to packages/twenty-ui/src/components/input/SegmentedControl/__tests__/SegmentedControl.test.tsxdiff --git a/packages/twenty-ui/src/primitives/input/SegmentedControl/types/SegmentedControlOption.ts b/packages/twenty-ui/src/components/input/SegmentedControl/types/SegmentedControlOption.tssimilarity index 100%rename from packages/twenty-ui/src/primitives/input/SegmentedControl/types/SegmentedControlOption.tsrename to packages/twenty-ui/src/components/input/SegmentedControl/types/SegmentedControlOption.tsdiff --git a/packages/twenty-ui/src/primitives/input/SegmentedControl/types/SegmentedControlProps.ts b/packages/twenty-ui/src/components/input/SegmentedControl/types/SegmentedControlProps.tssimilarity index 100%rename from packages/twenty-ui/src/primitives/input/SegmentedControl/types/SegmentedControlProps.tsrename to packages/twenty-ui/src/components/input/SegmentedControl/types/SegmentedControlProps.tsdiff --git a/packages/twenty-ui/src/components/input/index.ts b/packages/twenty-ui/src/components/input/index.tsindex 71e61d07c74..7b27ba2f5b7 100644--- a/packages/twenty-ui/src/components/input/index.ts+++ b/packages/twenty-ui/src/components/input/index.ts@@ -32,3 +32,6 @@ export type { PhoneCountryPickerOptionsProps } from './PhoneCountryPicker/types/export type { PhoneCountryPickerTriggerProps } from './PhoneCountryPicker/types/PhoneCountryPickerTriggerProps';export { SearchInput } from './SearchInput/SearchInput';export type { SearchInputProps } from './SearchInput/types/SearchInputProps';+export { SegmentedControl } from './SegmentedControl/SegmentedControl';+export type { SegmentedControlOption } from './SegmentedControl/types/SegmentedControlOption';+export type { SegmentedControlProps } from './SegmentedControl/types/SegmentedControlProps';diff --git a/packages/twenty-ui/src/primitives/input/Radio/Radio.tsx b/packages/twenty-ui/src/primitives/input/Radio/Radio.tsxindex cf6aa3e0376..b24cacdc0fc 100644--- a/packages/twenty-ui/src/primitives/input/Radio/Radio.tsx+++ b/packages/twenty-ui/src/primitives/input/Radio/Radio.tsx@@ -1,33 +1,8 @@-import { Radio as RadioPrimitive } from '@base-ui/react/radio';-import { clsx } from 'clsx';+import { RadioComponent } from './internal/RadioComponent';+import { RadioIndicator } from './internal/RadioIndicator';+import { RadioRoot } from './internal/RadioRoot';-import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';--import styles from './Radio.module.scss';-import { type RadioProps } from './types/RadioProps';--export const Radio = <TValue,>({- children,- className,- size = 'sm',- variant = 'default',- ...props-}: RadioProps<TValue>) => (- <RadioPrimitive.Root- render={variant === 'card' ? <div /> : undefined}- {...props}- className={mergeClassNames(- clsx(styles.root, styles[size], variant === 'card' && styles.card),- className,- )}- >- <span className={styles.control} aria-hidden>- <RadioPrimitive.Indicator className={styles.indicator} />- </span>- {variant === 'card' ? (- <div className={styles.cardContent}>{children}</div>- ) : (- children- )}- </RadioPrimitive.Root>-);+export const Radio = Object.assign(RadioComponent, {+ Root: RadioRoot,+ Indicator: RadioIndicator,+});diff --git a/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.form-association.stories.tsx b/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.form-association.stories.tsxnew file mode 100644index 00000000000..82a1dd46d69--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.form-association.stories.tsx@@ -0,0 +1,75 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, fn, userEvent, within } from 'storybook/test';++import { RadioGroup } from '@ui/primitives/input/RadioGroup/RadioGroup';+import { ComponentDecorator } from '@ui/testing';++import { Radio } from '../Radio';++const meta: Meta<typeof RadioGroup> = {+ title: 'UI/Input/Radio/Interactions/Form association',+ component: RadioGroup,+ decorators: [ComponentDecorator],+ tags: ['!autodocs'],+ args: { onValueChange: fn() },+};++export default meta;+type Story = StoryObj<typeof RadioGroup>;++export const ExternalForm: Story = {+ render: (args) => (+ <>+ <form id="preferences" aria-label="Preferences" />+ <RadioGroup form="preferences" name="fruit" aria-label="Fruit" required>+ <Radio.Root value="apple">Apple</Radio.Root>+ <Radio.Root value="cherry">Cherry</Radio.Root>+ </RadioGroup>+ <RadioGroup+ form="preferences"+ name="locked"+ aria-label="Read only preference"+ defaultValue="original"+ readOnly+ onValueChange={args.onValueChange}+ >+ <Radio.Root value="original">Original</Radio.Root>+ <Radio.Root value="replacement">Replacement</Radio.Root>+ </RadioGroup>+ <RadioGroup+ form="preferences"+ name="excluded"+ aria-label="Disabled preference"+ defaultValue="disabled"+ disabled+ >+ <Radio.Root value="disabled">Disabled</Radio.Root>+ </RadioGroup>+ </>+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const form = canvas.getByRole<HTMLFormElement>('form', {+ name: 'Preferences',+ });+ const appleInput = canvasElement.querySelector<HTMLInputElement>(+ 'input[value="apple"]',+ );+ await expect(appleInput?.form).toBe(form);+ await expect(form.checkValidity()).toBe(false);+ await expect(Object.fromEntries(new FormData(form))).toEqual({+ locked: 'original',+ });++ await userEvent.click(canvas.getByRole('radio', { name: 'Apple' }));+ await userEvent.click(canvas.getByRole('radio', { name: 'Replacement' }));++ await expect(form.checkValidity()).toBe(true);+ await expect(canvas.getByRole('radio', { name: 'Original' })).toBeChecked();+ await expect(args.onValueChange).not.toHaveBeenCalled();+ await expect(Object.fromEntries(new FormData(form))).toEqual({+ fruit: 'apple',+ locked: 'original',+ });+ },+};diff --git a/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.interactions.stories.tsx b/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.interactions.stories.tsxindex fbd48cd8dbb..94ed5ad7687 100644--- a/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.interactions.stories.tsx+++ b/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.interactions.stories.tsx@@ -1,10 +1,11 @@-import { DirectionProvider } from '@base-ui/react/direction-provider';-import { Field as FieldPrimitive } from '@base-ui/react/field';+import { isFunction } from '@sniptt/guards';import { type Meta, type StoryObj } from '@storybook/react-vite';import { useRef, useState } from 'react';import { expect, fn, userEvent, waitFor, within } from 'storybook/test';+import { Button } from '@ui/primitives/input/Button/Button';import { Field } from '@ui/primitives/input/Field/Field';+import { DirectionProvider } from '@ui/primitives/layout/DirectionProvider/DirectionProvider';import { RadioGroup } from '@ui/primitives/input/RadioGroup/RadioGroup';import { type RadioGroupProps } from '@ui/primitives/input/RadioGroup/types/RadioGroupProps';import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';@@ -42,6 +43,10 @@ const meta: Meta<typeof RadioExample> = {export default meta;type Story = StoryObj<typeof RadioExample>;+const numericValueChange =+ fn<NonNullable<RadioGroupProps<number>['onValueChange']>>();+const nativeButtonClick = fn();+export const Keyboard: Story = {decorators: [ComponentDecorator],args: { defaultValue: 'apple' },@@ -57,7 +62,10 @@ export const Keyboard: Story = {await expect(apple).not.toBeChecked();await expect(args.onValueChange).toHaveBeenLastCalledWith('cherry',- expect.anything(),+ expect.objectContaining({+ reason: 'none',+ isCanceled: false,+ }),);await userEvent.keyboard('{ArrowDown}');await waitFor(() => expect(apple).toHaveFocus());@@ -150,39 +158,60 @@ export const CanceledChange: Story = {const canvas = within(canvasElement);await userEvent.click(canvas.getByRole('radio', { name: 'Cherry' }));await expect(args.onValueChange).toHaveBeenCalledTimes(1);+ await expect(args.onValueChange).toHaveBeenCalledWith(+ 'cherry',+ expect.objectContaining({ isCanceled: true }),+ );await expect(canvas.getByRole('radio', { name: 'Apple' })).toBeChecked();- await expect(- canvas.getByRole('radio', { name: 'Cherry' }),- ).not.toBeChecked();+ const cherry = canvas.getByRole('radio', { name: 'Cherry' });+ await expect(cherry).not.toBeChecked();+ await expect(cherry.nextElementSibling).not.toBeChecked();},};-const ControlledExample = ({ onValueChange }: RadioGroupProps) => {- const [value, setValue] = useState('apple');+const ControlledExample = ({ onValueChange }: RadioGroupProps<number>) => {+ const [value, setValue] = useState(0);return (<>- <RadioExample value={value} onValueChange={onValueChange} />- <button type="button" onClick={() => setValue('cherry')}>- Apply Cherry- </button>+ <RadioGroup+ aria-label="Number"+ value={value}+ onValueChange={onValueChange}+ >+ <Radio.Root value={0}>Zero</Radio.Root>+ <Radio.Root value={1}>One</Radio.Root>+ </RadioGroup>+ <Button onClick={() => setValue(1)}>Apply One</Button></>);};export const Controlled: Story = {decorators: [ComponentDecorator],- render: (args) => <ControlledExample {...args} />,- play: async ({ canvasElement, args }) => {+ beforeEach: () => {+ numericValueChange.mockClear();+ },+ render: () => <ControlledExample onValueChange={numericValueChange} />,+ play: async ({ canvasElement }) => {const canvas = within(canvasElement);- await userEvent.click(canvas.getByRole('radio', { name: 'Cherry' }));- await expect(args.onValueChange).toHaveBeenCalledWith(- 'cherry',- expect.anything(),+ const one = canvas.getByRole('radio', { name: 'One' });+ await userEvent.click(one);+ await expect(numericValueChange).toHaveBeenCalledTimes(1);+ await expect(numericValueChange).toHaveBeenCalledWith(+ 1,+ expect.objectContaining({+ reason: 'none',+ event: expect.objectContaining({ type: 'click' }),+ }),);- await expect(canvas.getByRole('radio', { name: 'Apple' })).toBeChecked();- await userEvent.click(canvas.getByRole('button', { name: 'Apply Cherry' }));- await expect(canvas.getByRole('radio', { name: 'Cherry' })).toBeChecked();+ await expect(canvas.getByRole('radio', { name: 'Zero' })).toBeChecked();+ await expect(one).not.toBeChecked();+ await expect(one.nextElementSibling).not.toBeChecked();+ await userEvent.click(canvas.getByRole('button', { name: 'Apply One' }));+ await expect(one).toBeChecked();+ await expect(one.nextElementSibling).toBeChecked();+ await expect(numericValueChange).toHaveBeenCalledTimes(1);},};@@ -192,6 +221,7 @@ const FormExample = ({ variant }: Pick<RadioProps, 'variant'>) => {return (<form+ aria-label="Preferences"onSubmit={(event) => {event.preventDefault();setSubmitted(@@ -203,21 +233,21 @@ const FormExample = ({ variant }: Pick<RadioProps, 'variant'>) => {<Field.Root name="fruit"><Field.Label>Fruit</Field.Label><RadioGroup value={value} onValueChange={setValue} required>- <FieldPrimitive.Item>+ <Field.Item><Radio variant={variant} value="apple">Apple</Radio>- </FieldPrimitive.Item>- <FieldPrimitive.Item>+ </Field.Item>+ <Field.Item><Radio variant={variant} value="cherry">Cherry</Radio>- </FieldPrimitive.Item>+ </Field.Item></RadioGroup><Field.Description>Choose one fruit</Field.Description></Field.Root>- <button type="submit">Submit</button>- <button type="reset">Reset</button>+ <Button type="submit">Submit</Button>+ <Button type="reset">Reset</Button><output aria-label="Submitted fruit">{submitted}</output></form>);@@ -229,47 +259,79 @@ export const Form: Story = {render: () => <FormExample />,play: async ({ canvasElement }) => {const canvas = within(canvasElement);- await expect(- canvas.getByRole('radiogroup', { name: 'Fruit' }),- ).toHaveAttribute('aria-required', 'true');+ const form = canvas.getByRole<HTMLFormElement>('form', {+ name: 'Preferences',+ });+ const group = canvas.getByRole('radiogroup', { name: 'Fruit' });+ await expect(group).toHaveAttribute('aria-required', 'true');+ await expect(group).toHaveAccessibleDescription('Choose one fruit');await userEvent.click(canvas.getByRole('radio', { name: 'Cherry' }));+ await expect(new FormData(form).get('fruit')).toBe('cherry');await userEvent.click(canvas.getByRole('button', { name: 'Submit' }));await expect(canvas.getByRole('status', { name: 'Submitted fruit' }),).toHaveTextContent(/^cherry$/);await userEvent.click(canvas.getByRole('button', { name: 'Reset' }));await expect(canvas.getByRole('radio', { name: 'Apple' })).toBeChecked();+ await expect(+ canvas.getByRole('radio', { name: 'Cherry' }),+ ).not.toBeChecked();+ await expect(new FormData(form).get('fruit')).toBe('apple');},};-const InputRefExample = () => {+const InputRefExample = ({ onValueChange }: RadioGroupProps<number>) => {const inputRef = useRef<HTMLInputElement>(null);return (<>- <RadioGroup defaultValue={0} aria-label="Number">+ <RadioGroup+ defaultValue={0}+ aria-label="Number"+ onValueChange={onValueChange}+ ><Radio value={0}>Zero</Radio><Radio value={1} inputRef={inputRef}>One</Radio></RadioGroup>- <button type="button" onClick={() => inputRef.current?.focus()}>- Focus One- </button>+ <Button onClick={() => inputRef.current?.focus()}>Focus One</Button></>);};export const NumericValuesAndInputRef: Story = {decorators: [ComponentDecorator],- render: () => <InputRefExample />,+ beforeEach: () => {+ numericValueChange.mockClear();+ },+ render: () => <InputRefExample onValueChange={numericValueChange} />,play: async ({ canvasElement }) => {const canvas = within(canvasElement);+ const one = canvas.getByRole('radio', { name: 'One' });await expect(canvas.getByRole('radio', { name: 'Zero' })).toBeChecked();await userEvent.click(canvas.getByRole('button', { name: 'Focus One' }));- await expect(canvas.getByRole('radio', { name: 'One' })).toHaveFocus();+ await expect(one).toHaveFocus();+ await userEvent.click(one);+ await userEvent.click(one);await userEvent.keyboard(' ');- await expect(canvas.getByRole('radio', { name: 'One' })).toBeChecked();+ await expect(one).toBeChecked();+ await expect(one.nextElementSibling).toBeChecked();+ await expect(canvas.getByRole('radio', { name: 'Zero' })).not.toBeChecked();+ await expect(numericValueChange).toHaveBeenCalledTimes(1);+ await expect(numericValueChange).toHaveBeenCalledWith(+ 1,+ expect.objectContaining({+ reason: 'none',+ event: expect.objectContaining({ type: 'click' }),+ isCanceled: false,+ isPropagationAllowed: false,+ trigger: undefined,+ }),+ );+ const eventDetails = numericValueChange.mock.calls[0]?.[1];+ await expect(isFunction(eventDetails?.cancel)).toBe(true);+ await expect(isFunction(eventDetails?.allowPropagation)).toBe(true);},};@@ -358,3 +420,151 @@ export const CardsRightToLeft: Story = {...RightToLeft,args: { ...RightToLeft.args, variant: 'card' },};++export const CompleteParts: Story = {+ decorators: [ComponentDecorator],+ args: { defaultValue: 'apple' },+ render: (args) => (+ <RadioGroup {...args} aria-label="Fruit" render={<fieldset />}>+ <Radio.Root value="apple">+ <Radio.Indicator+ keepMounted+ aria-hidden+ className={({ checked }) => (checked ? 'selected' : 'unselected')}+ style={({ checked }) => ({ opacity: checked ? 1 : 0.75 })}+ render={(props, state) => (+ <strong {...props} data-active={state.checked}>+ {state.checked ? 'Selected' : 'Unselected'}+ </strong>+ )}+ />+ Apple+ </Radio.Root>+ <Radio.Root value="cherry">+ <Radio.Indicator+ keepMounted+ aria-hidden+ className={({ checked }) => (checked ? 'selected' : 'unselected')}+ style={({ checked }) => ({ opacity: checked ? 1 : 0.75 })}+ render={(props, state) => (+ <strong {...props} data-active={state.checked}>+ {state.checked ? 'Selected' : 'Unselected'}+ </strong>+ )}+ />+ Cherry+ </Radio.Root>+ </RadioGroup>+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const apple = canvas.getByRole('radio', { name: 'Apple' });+ const cherry = canvas.getByRole('radio', { name: 'Cherry' });+ await expect(canvas.getByRole('radiogroup').tagName).toBe('FIELDSET');+ await expect(apple.tagName).toBe('SPAN');+ await expect(apple.querySelector('strong')).toHaveAttribute('data-checked');+ await expect(cherry.querySelector('strong')).toHaveAttribute(+ 'data-unchecked',+ );+ await expect(cherry.querySelector('strong')).toHaveClass('unselected');+ await expect(cherry.querySelector('strong')).toHaveStyle({+ opacity: '0.75',+ });+ await userEvent.tab();+ await userEvent.keyboard('{Enter}');+ await expect(args.onValueChange).not.toHaveBeenCalled();+ await userEvent.keyboard('{ArrowRight}');+ await expect(cherry).toHaveFocus();+ await expect(cherry).toBeChecked();+ await expect(cherry.nextElementSibling).toBeChecked();+ await expect(cherry.querySelector('strong')).toHaveTextContent('Selected');+ await expect(cherry.querySelector('strong')).toHaveClass('selected');+ await expect(cherry.querySelector('strong')).toHaveStyle({ opacity: '1' });+ await expect(cherry.querySelector('strong')).toHaveAttribute(+ 'data-active',+ 'true',+ );+ await expect(cherry.querySelector('strong')).toHaveAttribute(+ 'data-checked',+ );+ await expect(apple.querySelector('strong')).toHaveAttribute(+ 'data-unchecked',+ );+ await expect(args.onValueChange).toHaveBeenCalledTimes(1);+ },+};++export const NativeButtonCards: Story = {+ decorators: [ComponentDecorator],+ beforeEach: () => {+ nativeButtonClick.mockClear();+ },+ args: { defaultValue: 'apple' },+ render: (args) => (+ <RadioGroup {...args} aria-label="Fruit">+ <Radio+ variant="card"+ value="apple"+ nativeButton+ render={<button type="button" />}+ >+ Apple+ </Radio>+ <Radio+ variant="card"+ value="cherry"+ onClick={nativeButtonClick}+ nativeButton+ render={<button type="button" />}+ >+ Cherry+ </Radio>+ </RadioGroup>+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const apple = canvas.getByRole('radio', { name: 'Apple' });+ const cherry = canvas.getByRole('radio', { name: 'Cherry' });+ await expect(apple.tagName).toBe('BUTTON');+ await userEvent.click(cherry);+ await expect(cherry).toBeChecked();+ await expect(cherry.nextElementSibling).toBeChecked();+ await expect(nativeButtonClick).toHaveBeenCalledTimes(1);+ await expect(args.onValueChange).toHaveBeenCalledTimes(1);+ await userEvent.keyboard('{ArrowLeft}');+ await expect(apple).toBeChecked();+ await userEvent.keyboard('{ArrowRight}');+ await expect(cherry).toHaveFocus();+ await expect(cherry).toBeChecked();+ await expect(args.onValueChange).toHaveBeenCalledTimes(3);+ },+};++export const IndicatorMounting: Story = {+ decorators: [ComponentDecorator],+ args: { defaultValue: 'apple' },+ render: (args) => (+ <RadioGroup {...args} aria-label="Fruit">+ <Radio.Root value="apple" aria-label="Apple">+ <Radio.Indicator aria-hidden>Apple indicator</Radio.Indicator>+ Apple+ </Radio.Root>+ <Radio.Root value="cherry" aria-label="Cherry">+ <Radio.Indicator aria-hidden>Cherry indicator</Radio.Indicator>+ Cherry+ </Radio.Root>+ </RadioGroup>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await expect(canvas.getByText('Apple indicator')).toBeVisible();+ await expect(+ canvas.queryByText('Cherry indicator'),+ ).not.toBeInTheDocument();+ await userEvent.click(canvas.getByRole('radio', { name: 'Cherry' }));+ await expect(canvas.getByText('Cherry indicator')).toBeVisible();+ await waitFor(() =>+ expect(canvas.queryByText('Apple indicator')).not.toBeInTheDocument(),+ );+ },+};diff --git a/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.stories.tsx b/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.stories.tsxindex b84d7074a7b..7fe775a2de5 100644--- a/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.stories.tsx+++ b/packages/twenty-ui/src/primitives/input/Radio/__stories__/Radio.stories.tsx@@ -16,7 +16,7 @@ const RadioExample = ({selected = false,...props}: RadioProps & { selected?: boolean }) => (- <RadioGroup defaultValue={selected ? props.value : ''}>+ <RadioGroup aria-label="Choice" defaultValue={selected ? props.value : ''}><Radio {...props} /></RadioGroup>);@@ -116,3 +116,19 @@ export const CardsCatalogDark: typeof Catalog = {tags: ['!autodocs'],globals: { colorScheme: 'dark' },};++export const PartsDocumentation: Story = {+ decorators: [ComponentDecorator],+ render: () => (+ <RadioGroup aria-label="Storage" defaultValue="ssd">+ <Radio.Root value="ssd">+ <Radio.Indicator keepMounted>✓</Radio.Indicator>+ SSD+ </Radio.Root>+ <Radio.Root value="hdd">+ <Radio.Indicator keepMounted>✓</Radio.Indicator>+ HDD+ </Radio.Root>+ </RadioGroup>+ ),+};diff --git a/packages/twenty-ui/src/primitives/input/Radio/__tests__/Radio.parts.test.tsx b/packages/twenty-ui/src/primitives/input/Radio/__tests__/Radio.parts.test.tsxnew file mode 100644index 00000000000..55693689869--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Radio/__tests__/Radio.parts.test.tsx@@ -0,0 +1,99 @@+import { render, screen } from '@testing-library/react';+import { createRef } from 'react';+import { describe, expect, it } from 'vitest';++import { RadioGroup } from '@ui/primitives/input/RadioGroup/RadioGroup';++import { Radio } from '../Radio';++describe('Radio parts', () => {+ it('preserves distinct root, hidden input and custom indicator refs', () => {+ const rootRef = createRef<HTMLSpanElement>();+ const inputRef = createRef<HTMLInputElement>();+ const indicatorRef = createRef<HTMLSpanElement>();++ render(+ <RadioGroup aria-label="Number" name="number">+ <Radio.Root+ ref={rootRef}+ inputRef={inputRef}+ value={0}+ aria-label="Zero"+ >+ <Radio.Indicator+ ref={indicatorRef}+ keepMounted+ className={({ checked }) => (checked ? 'selected' : 'unselected')}+ style={({ checked }) => ({ opacity: checked ? 1 : 0.5 })}+ render={(props, state) => (+ <span {...props} data-active={state.checked}>+ {state.checked ? 'Selected' : 'Unselected'}+ </span>+ )}+ />+ </Radio.Root>+ </RadioGroup>,+ );++ const radio = screen.getByRole('radio', { name: 'Zero' });+ expect(rootRef.current).toBe(radio);+ expect(rootRef.current).toBeInstanceOf(HTMLSpanElement);+ expect(inputRef.current).toBeInstanceOf(HTMLInputElement);+ expect(inputRef.current?.type).toBe('radio');+ expect(inputRef.current?.value).toBe('0');+ expect(inputRef.current?.previousElementSibling).toBe(radio);+ expect(indicatorRef.current).toBe(screen.getByText('Unselected'));+ expect(indicatorRef.current).toHaveClass('unselected');+ expect(indicatorRef.current).toHaveStyle({ opacity: '0.5' });+ });++ it('mounts the indicator for the selected option', () => {+ render(+ <RadioGroup aria-label="Fruit" defaultValue="apple">+ <Radio.Root value="apple" aria-label="Apple">+ <Radio.Indicator>Apple indicator</Radio.Indicator>+ </Radio.Root>+ <Radio.Root value="cherry" aria-label="Cherry">+ <Radio.Indicator>Cherry indicator</Radio.Indicator>+ </Radio.Root>+ </RadioGroup>,+ );++ expect(screen.getByText('Apple indicator')).toBeVisible();+ expect(screen.queryByText('Cherry indicator')).toBeNull();+ });++ it('keeps explicit native button composition independent of card appearance', () => {+ const rootRef = createRef<HTMLButtonElement>();+ const groupRef = createRef<HTMLDivElement>();+ const inputRef = createRef<HTMLInputElement>();++ render(+ <RadioGroup+ ref={groupRef}+ aria-label="Plan"+ render={<fieldset title="Available plans" />}+ >+ <Radio+ ref={rootRef}+ inputRef={inputRef}+ variant="card"+ value="pro"+ nativeButton+ render={<button type="button" title="Pro choice" />}+ >+ Pro+ </Radio>+ </RadioGroup>,+ );++ const radio = screen.getByRole('radio', { name: 'Pro' });+ expect(groupRef.current).toBeInstanceOf(HTMLFieldSetElement);+ expect(groupRef.current).toHaveAttribute('title', 'Available plans');+ expect(rootRef.current).toBe(radio);+ expect(rootRef.current).toBeInstanceOf(HTMLButtonElement);+ expect(radio).toHaveAttribute('type', 'button');+ expect(radio).toHaveAttribute('title', 'Pro choice');+ expect(inputRef.current).toBeInstanceOf(HTMLInputElement);+ });+});diff --git a/packages/twenty-ui/src/primitives/input/Radio/__tests__/Radio.test.tsx b/packages/twenty-ui/src/primitives/input/Radio/__tests__/Radio.test.tsxindex daa92628d65..bb8085e8779 100644--- a/packages/twenty-ui/src/primitives/input/Radio/__tests__/Radio.test.tsx+++ b/packages/twenty-ui/src/primitives/input/Radio/__tests__/Radio.test.tsx@@ -36,5 +36,4 @@ runComponentConformance({wrapper: RadioGroupWrapper,refInstanceOf: HTMLDivElement,ownClassName: styles.card,- renderPropTagName: 'div',});diff --git a/packages/twenty-ui/src/primitives/input/Radio/internal/RadioComponent.tsx b/packages/twenty-ui/src/primitives/input/Radio/internal/RadioComponent.tsxnew file mode 100644index 00000000000..70e95b34c47--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Radio/internal/RadioComponent.tsx@@ -0,0 +1,36 @@+import { clsx } from 'clsx';++import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';++import styles from '../Radio.module.scss';+import { type RadioProps } from '../types/RadioProps';++import { RadioIndicator } from './RadioIndicator';+import { RadioRoot } from './RadioRoot';++export const RadioComponent = <TValue,>({+ children,+ className,+ size = 'sm',+ variant = 'default',+ render = variant === 'card' ? <div /> : undefined,+ ...props+}: RadioProps<TValue>) => (+ <RadioRoot+ {...props}+ render={render}+ className={mergeClassNames(+ clsx(styles.root, styles[size], variant === 'card' && styles.card),+ className,+ )}+ >+ <span className={styles.control} aria-hidden>+ <RadioIndicator className={styles.indicator} />+ </span>+ {variant === 'card' ? (+ <span className={styles.cardContent}>{children}</span>+ ) : (+ children+ )}+ </RadioRoot>+);diff --git a/packages/twenty-ui/src/primitives/input/Radio/internal/RadioIndicator.tsx b/packages/twenty-ui/src/primitives/input/Radio/internal/RadioIndicator.tsxnew file mode 100644index 00000000000..8b430de3511--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Radio/internal/RadioIndicator.tsx@@ -0,0 +1,3 @@+import { Radio as RadioPrimitive } from '@base-ui/react/radio';++export const RadioIndicator = RadioPrimitive.Indicator;diff --git a/packages/twenty-ui/src/primitives/input/Radio/internal/RadioRoot.tsx b/packages/twenty-ui/src/primitives/input/Radio/internal/RadioRoot.tsxnew file mode 100644index 00000000000..b34f48995ce--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Radio/internal/RadioRoot.tsx@@ -0,0 +1,3 @@+import { Radio as RadioPrimitive } from '@base-ui/react/radio';++export const RadioRoot = RadioPrimitive.Root;diff --git a/packages/twenty-ui/src/primitives/input/Radio/types/RadioIndicatorProps.ts b/packages/twenty-ui/src/primitives/input/Radio/types/RadioIndicatorProps.tsnew file mode 100644index 00000000000..52a9bdc359d--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Radio/types/RadioIndicatorProps.ts@@ -0,0 +1,3 @@+import { type Radio as RadioPrimitive } from '@base-ui/react/radio';++export type RadioIndicatorProps = RadioPrimitive.Indicator.Props;diff --git a/packages/twenty-ui/src/primitives/input/Radio/types/RadioIndicatorState.ts b/packages/twenty-ui/src/primitives/input/Radio/types/RadioIndicatorState.tsnew file mode 100644index 00000000000..d8d9bf5bd35--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Radio/types/RadioIndicatorState.ts@@ -0,0 +1,3 @@+import { type Radio as RadioPrimitive } from '@base-ui/react/radio';++export type RadioIndicatorState = RadioPrimitive.Indicator.State;diff --git a/packages/twenty-ui/src/primitives/input/Radio/types/RadioRootProps.ts b/packages/twenty-ui/src/primitives/input/Radio/types/RadioRootProps.tsnew file mode 100644index 00000000000..dea6f397965--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Radio/types/RadioRootProps.ts@@ -0,0 +1,4 @@+import { type Radio as RadioPrimitive } from '@base-ui/react/radio';++export type RadioRootProps<TValue = unknown> =+ RadioPrimitive.Root.Props<TValue>;diff --git a/packages/twenty-ui/src/primitives/input/Radio/types/RadioRootState.ts b/packages/twenty-ui/src/primitives/input/Radio/types/RadioRootState.tsnew file mode 100644index 00000000000..20d41d49af6--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Radio/types/RadioRootState.ts@@ -0,0 +1,3 @@+import { type Radio as RadioPrimitive } from '@base-ui/react/radio';++export type RadioRootState = RadioPrimitive.Root.State;diff --git a/packages/twenty-ui/src/primitives/input/RadioGroup/types/RadioGroupChangeEventDetails.ts b/packages/twenty-ui/src/primitives/input/RadioGroup/types/RadioGroupChangeEventDetails.tsnew file mode 100644index 00000000000..f82179517ce--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/RadioGroup/types/RadioGroupChangeEventDetails.ts@@ -0,0 +1,4 @@+import { type RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group';++export type RadioGroupChangeEventDetails =+ RadioGroupPrimitive.ChangeEventDetails;diff --git a/packages/twenty-ui/src/primitives/input/RadioGroup/types/RadioGroupChangeEventReason.ts b/packages/twenty-ui/src/primitives/input/RadioGroup/types/RadioGroupChangeEventReason.tsnew file mode 100644index 00000000000..e7cc78c05e7--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/RadioGroup/types/RadioGroupChangeEventReason.ts@@ -0,0 +1,3 @@+import { type RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group';++export type RadioGroupChangeEventReason = RadioGroupPrimitive.ChangeEventReason;diff --git a/packages/twenty-ui/src/primitives/input/RadioGroup/types/RadioGroupState.ts b/packages/twenty-ui/src/primitives/input/RadioGroup/types/RadioGroupState.tsnew file mode 100644index 00000000000..4957320e8b3--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/RadioGroup/types/RadioGroupState.ts@@ -0,0 +1,3 @@+import { type RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group';++export type RadioGroupState = RadioGroupPrimitive.State;diff --git a/packages/twenty-ui/src/primitives/input/SegmentedControl/__stories__/SegmentedControlInteractions.stories.tsx b/packages/twenty-ui/src/primitives/input/SegmentedControl/__stories__/SegmentedControlInteractions.stories.tsxdeleted file mode 100644index 87099168d35..00000000000--- a/packages/twenty-ui/src/primitives/input/SegmentedControl/__stories__/SegmentedControlInteractions.stories.tsx+++ /dev/null@@ -1,196 +0,0 @@-import { type Meta, type StoryObj } from '@storybook/react-vite';-import { useState } from 'react';-import { expect, fn, userEvent, waitFor, within } from 'storybook/test';--import { Button } from '@ui/primitives/input/Button/Button';-import { ComponentDecorator } from '@ui/testing';--import { SegmentedControl } from '../SegmentedControl';-import { type SegmentedControlProps } from '../types/SegmentedControlProps';--const PendingExample = (props: SegmentedControlProps<string>) => {- const [isPending, setIsPending] = useState(false);-- return (- <>- <SegmentedControl- {...props}- disabled={isPending}- onValueChange={(value, eventDetails) => {- props.onValueChange?.(value, eventDetails);- setIsPending(true);- }}- />- <Button onClick={() => setIsPending(false)}>Finish saving</Button>- </>- );-};--const FormExample = (props: SegmentedControlProps<string>) => {- const [savedAppearance, setSavedAppearance] = useState('Not saved');-- return (- <form- onSubmit={(event) => {- event.preventDefault();- setSavedAppearance(- String(new FormData(event.currentTarget).get('appearance')),- );- }}- >- <SegmentedControl {...props} name="appearance" />- <Button type="submit">Save appearance</Button>- <output aria-label="Saved appearance">{savedAppearance}</output>- </form>- );-};--const meta: Meta<typeof SegmentedControl> = {- title: 'UI/Input/SegmentedControl/Interactions',- component: SegmentedControl,- decorators: [ComponentDecorator],- args: {- 'aria-label': 'Appearance',- defaultValue: 'system',- onValueChange: fn(),- options: [- { value: 'system', label: 'System' },- { value: 'light', label: 'Light', disabled: true },- { value: 'dark', label: 'Dark' },- { value: 'contrast', label: 'High contrast' },- ],- },-};--export default meta;-type Story = StoryObj<typeof SegmentedControl>;--export const Uncontrolled: Story = {- play: async ({ canvasElement, args }) => {- const canvas = within(canvasElement);- const dark = canvas.getByRole('radio', { name: 'Dark' });-- await expect(- canvas.getByRole('radiogroup', { name: 'Appearance' }),- ).toBeVisible();- await expect(canvas.getByRole('radio', { name: 'System' })).toBeChecked();- await userEvent.click(dark);- await userEvent.click(dark);-- await expect(dark).toBeChecked();- await expect(- canvas.getByRole('radio', { name: 'System' }),- ).not.toBeChecked();- await expect(args.onValueChange).toHaveBeenCalledTimes(1);- await expect(args.onValueChange).toHaveBeenCalledWith(- 'dark',- expect.anything(),- );- },-};--export const DisabledOption: Story = {- play: async ({ canvasElement, args }) => {- const canvas = within(canvasElement);- const light = canvas.getByRole('radio', { name: 'Light' });-- await expect(light).toHaveAttribute('aria-disabled', 'true');- await userEvent.click(light);- await expect(canvas.getByRole('radio', { name: 'System' })).toBeChecked();- await expect(args.onValueChange).not.toHaveBeenCalled();- },-};--export const DisabledCheckedOption: Story = {- args: { defaultValue: 'light' },- play: async ({ canvasElement }) => {- const canvas = within(canvasElement);- const dark = canvas.getByRole('radio', { name: 'Dark' });-- await userEvent.tab();- await expect(canvas.getByRole('radio', { name: 'Light' })).toHaveFocus();- await userEvent.keyboard('{ArrowRight}');- await waitFor(() => expect(dark).toHaveFocus());- await expect(dark).toBeChecked();- },-};--export const Pending: Story = {- render: (args) => <PendingExample {...args} />,- play: async ({ canvasElement, args }) => {- const canvas = within(canvasElement);- const dark = canvas.getByRole('radio', { name: 'Dark' });- const contrast = canvas.getByRole('radio', { name: 'High contrast' });-- await userEvent.tab();- await userEvent.keyboard('{ArrowRight}');- await waitFor(() => expect(dark).toBeChecked());- for (const choice of canvas.getAllByRole('radio')) {- await expect(choice).toHaveAttribute('aria-disabled', 'true');- }- await expect(dark).toHaveFocus();- await userEvent.keyboard('{ArrowRight}');- await expect(dark).toHaveFocus();- await userEvent.click(contrast);- await expect(contrast).not.toBeChecked();- await expect(args.onValueChange).toHaveBeenCalledTimes(1);-- await userEvent.click(- canvas.getByRole('button', { name: 'Finish saving' }),- );- await expect(contrast).not.toHaveAttribute('aria-disabled');- await userEvent.click(contrast);- await expect(contrast).toBeChecked();- await expect(args.onValueChange).toHaveBeenCalledTimes(2);- await expect(args.onValueChange).toHaveBeenLastCalledWith(- 'contrast',- expect.anything(),- );- },-};--export const FormSubmission: Story = {- render: (args) => <FormExample {...args} />,- play: async ({ canvasElement }) => {- const canvas = within(canvasElement);- const savedAppearance = canvas.getByLabelText('Saved appearance');-- await userEvent.click(canvas.getByRole('radio', { name: 'Dark' }));- await expect(savedAppearance).toHaveTextContent('Not saved');-- await userEvent.click(- canvas.getByRole('button', { name: 'Save appearance' }),- );- await expect(savedAppearance).toHaveTextContent('dark');- },-};--export const Keyboard: Story = {- play: async ({ canvasElement, args }) => {- const canvas = within(canvasElement);- const system = canvas.getByRole('radio', { name: 'System' });- const dark = canvas.getByRole('radio', { name: 'Dark' });- const contrast = canvas.getByRole('radio', { name: 'High contrast' });-- await userEvent.tab();- await expect(system).toHaveFocus();- await userEvent.keyboard('{ArrowRight}');- await waitFor(() => expect(dark).toHaveFocus());- await expect(dark).toBeChecked();- await expect(args.onValueChange).toHaveBeenLastCalledWith(- 'dark',- expect.anything(),- );- await userEvent.keyboard('{ArrowRight}');- await waitFor(() => expect(contrast).toBeChecked());- await userEvent.keyboard('{ArrowRight}');- await waitFor(() => expect(system).toHaveFocus());- await expect(system).toBeChecked();- await userEvent.keyboard('{ArrowLeft}');- await waitFor(() => expect(contrast).toBeChecked());- await userEvent.tab({ shift: true });- await expect(contrast).not.toHaveFocus();- await userEvent.tab();- await expect(contrast).toHaveFocus();- },-};diff --git a/packages/twenty-ui/src/primitives/input/index.ts b/packages/twenty-ui/src/primitives/input/index.tsindex 734e81cd7bc..2a5b1e701c0 100644--- a/packages/twenty-ui/src/primitives/input/index.ts+++ b/packages/twenty-ui/src/primitives/input/index.ts@@ -105,12 +105,16 @@ export type { NumberFieldScrubAreaCursorState } from './NumberField/types/Numberexport type { NumberFieldScrubAreaProps } from './NumberField/types/NumberFieldScrubAreaProps';export type { NumberFieldScrubAreaState } from './NumberField/types/NumberFieldScrubAreaState';export { Radio } from './Radio/Radio';+export type { RadioIndicatorProps } from './Radio/types/RadioIndicatorProps';+export type { RadioIndicatorState } from './Radio/types/RadioIndicatorState';export type { RadioProps } from './Radio/types/RadioProps';+export type { RadioRootProps } from './Radio/types/RadioRootProps';+export type { RadioRootState } from './Radio/types/RadioRootState';export { RadioGroup } from './RadioGroup/RadioGroup';+export type { RadioGroupChangeEventDetails } from './RadioGroup/types/RadioGroupChangeEventDetails';+export type { RadioGroupChangeEventReason } from './RadioGroup/types/RadioGroupChangeEventReason';export type { RadioGroupProps } from './RadioGroup/types/RadioGroupProps';-export { SegmentedControl } from './SegmentedControl/SegmentedControl';-export type { SegmentedControlOption } from './SegmentedControl/types/SegmentedControlOption';-export type { SegmentedControlProps } from './SegmentedControl/types/SegmentedControlProps';+export type { RadioGroupState } from './RadioGroup/types/RadioGroupState';export { Select } from './Select/Select';export type { SelectArrowProps } from './Select/types/SelectArrowProps';export type { SelectArrowState } from './Select/types/SelectArrowState';