The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Clarify SettingsRow control integration (#27686)
Raphaël Bosif58262639d49
diff --git a/packages/twenty-docs/snippets/ui/generated/components/settings/settings-row.mdx b/packages/twenty-docs/snippets/ui/generated/components/settings/settings-row.mdxindex 70be07e03a1..e2badf69c9a 100644--- a/packages/twenty-docs/snippets/ui/generated/components/settings/settings-row.mdx+++ b/packages/twenty-docs/snippets/ui/generated/components/settings/settings-row.mdx@@ -12,53 +12,110 @@*/}<ParamField body="checked" type="boolean">- Controlled checked state of the switch.+ Whether the switch is currently active.++ To render an uncontrolled switch, use the `defaultChecked` prop instead.</ParamField><ParamField body="children" type="ReactNode" required>- Visible label and accessible name of the switch. Use non-interactive content.+ Visible label and default accessible name of the switch. Use non-interactive node content.+</ParamField>++<ParamField body="className" type="string | ((state: SwitchRootState) => string | undefined)">+ Customizes the visible Switch root and accepts a Switch state callback.</ParamField><ParamField body="defaultChecked" type="boolean" default="false">- Initial checked state when uncontrolled.+ Whether the switch is initially active.++ To render a controlled switch, use the `checked` prop instead.</ParamField><ParamField body="description" type="ReactNode">- Non-interactive supporting content, associated with the switch as its accessible description.+ Non-interactive supporting node content, used as the default accessible description of the switch.</ParamField><ParamField body="disabled" type="boolean" default="false">- Disables both the row and its switch.+ Whether the component should ignore user interaction.</ParamField><ParamField body="focused" type="boolean" default="false">Applies the highlighted row style without moving keyboard focus.</ParamField>+<ParamField body="form" type="string">+ Identifies the form that owns the hidden input.+ Useful when the switch is rendered outside the form.+</ParamField>++<ParamField body="id" type="string">+ Identifies the associated checkbox, or the visible root with nativeButton. The label association follows this ID.+</ParamField>++<ParamField body="inputRef" type="Ref<HTMLInputElement>">+ Targets the underlying native checkbox.+</ParamField>++<ParamField body="labelRef" type="Ref<HTMLLabelElement>">+ Targets the outer native label.+</ParamField>++<ParamField body="labelRender" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>">+ Customizes the outer native label with its complete composed row children. Preserve a label element and forward its props to retain control association.+</ParamField>+<ParamField body="name" type="string">- Name of the hidden checkbox used in form submission.+ Identifies the field when a form is submitted.+</ParamField>++<ParamField body="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="onCheckedChange" type="((checked: boolean, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)">- Called when the switch value changes, with the next checked state and Base UI event details.+ Receives the next checked value and Base UI event details. Controlled callers own accepted state updates; cancellation prevents a change.+</ParamField>++<ParamField body="onClick" type="((event: BaseUIEvent<MouseEvent<HTMLSpanElement, MouseEvent>>) => void)">+ Native click handler for the visible Switch root.</ParamField><ParamField body="readOnly" type="boolean" default="false">- Keeps the switch focusable while preventing changes.+ Whether the user should be unable to activate or deactivate the switch.+</ParamField>++<ParamField body="ref" type="Ref<HTMLSpanElement>">+ Targets the visible Switch root, which defaults to a span.+</ParamField>++<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SwitchRootState>">+ Customizes the visible Switch root with control props and Switch state. Use nativeButton when composing a button.</ParamField><ParamField body="required" type="boolean" default="false">- Requires the switch to be checked for form submission.+ Whether the user must activate the switch before submitting a form.</ParamField><ParamField body="size" type=""md" | "sm"" default="sm">- Visual size of the switch. The row height stays the same.+ Visual size of the switch. Defaults to sm.+</ParamField>++<ParamField body="startElement" type="ReactNode">+ Non-interactive node content before the label.+</ParamField>++<ParamField body="style" type="CSSProperties | ((state: SwitchRootState) => CSSProperties | undefined)">+ Customizes the visible Switch root and accepts a Switch state callback.</ParamField>-<ParamField body="startIcon" type="ReactNode">- Decorative content before the label.+<ParamField body="uncheckedValue" type="string">+ The value submitted with the form when the switch is off.+ By default, unchecked switches do not submit any value, matching native checkbox behavior.</ParamField><ParamField body="value" type="string">- Value submitted when the switch is checked.+ The value submitted with the form when the switch is on.+ By default, switch submits the "on" value, matching native checkbox behavior.</ParamField>diff --git a/packages/twenty-docs/ui/components/settings/settings-row.mdx b/packages/twenty-docs/ui/components/settings/settings-row.mdxindex 3a5e9cac89b..1029c6b43e2 100644--- a/packages/twenty-docs/ui/components/settings/settings-row.mdx+++ b/packages/twenty-docs/ui/components/settings/settings-row.mdx@@ -1,12 +1,12 @@---title: SettingsRow-description: A labeled switch row for settings and filters.+description: A labeled switch row with flat control props and native label composition.---import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';import SettingsRowReference from '/snippets/ui/generated/components/settings/settings-row.mdx';-`SettingsRow` combines [ListItem](/ui/primitives/navigation/list-item) and [Switch](/ui/primitives/input/switch). It associates the visible label with the switch, makes the whole row clickable, and keeps disabled behavior consistent.+`SettingsRow` combines the appearance of [ListItem](/ui/primitives/navigation/list-item) with [Switch](/ui/primitives/input/switch). It renders a native label associated with its switch. Your application supplies the row content and owns any preference updates.<StoryEmbedstoryId="ui-components-settingsrow--default"@@ -14,9 +14,11 @@ import SettingsRowReference from '/snippets/ui/generated/components/settings/setheight={160}/>-## Controlled setting+## Configure the switch-Pass `checked` and `onCheckedChange` when your application owns the value. The handler receives the next checked state and Base UI event details. Clicking either the label or switch invokes it once; keyboard users can focus the switch and press Space.+Pass [Switch props](/ui/primitives/input/switch) directly to `SettingsRow`. Checked state, event details, disabled and read-only behavior, size, native form configuration, handlers, refs, and render composition configure the switch. `children` supplies the visible row label.++Use `checked` and `onCheckedChange` when your application owns the value. The handler receives the next checked state and Base UI event details. Clicking the label or switch invokes it once. Call `eventDetails.cancel()` to reject a change, and keep your controlled value unchanged when the change is canceled.```tsximport { useState } from 'react';@@ -28,7 +30,7 @@ export const NotificationSetting = () => {return (<SettingsRow- startIcon={<IconBell aria-hidden />}+ startElement={<IconBell aria-hidden />}checked={enabled}onCheckedChange={setEnabled}>@@ -38,9 +40,24 @@ export const NotificationSetting = () => {};```-## Description and initial value+Use `defaultChecked` for an uncontrolled setting. Keyboard users focus the switch and press Space. `disabled` disables the control and applies the row's disabled appearance. `readOnly` prevents changes while keeping the switch focusable.++```tsx+import { SettingsRow } from 'twenty-ui/components/settings';++export const WorkspaceSettings = () => (+ <>+ <SettingsRow disabled>Notifications</SettingsRow>+ <SettingsRow readOnly defaultChecked>+ Activity history+ </SettingsRow>+ </>+);+```++## Row content and accessible text-Use `defaultChecked` for an uncontrolled setting. `description` supplies supporting text and the switch's accessible description, while the children provide its accessible name.+`children`, `startElement`, and `description` accept caller-owned nodes. The children supply the switch's accessible name, and the description supplies its accessible description. Keep content inside the label non-interactive. For navigation or action rows, use [ListItem](/ui/primitives/navigation/list-item) with a button or link.<StoryEmbedstoryId="ui-components-settingsrow--with-description"@@ -58,32 +75,97 @@ export const WeeklyDigestSetting = () => ();```-`name`, `value`, and `required` configure the switch's underlying checkbox for form submission. An unchecked switch does not submit a value.+Set `aria-label`, `aria-labelledby`, or `aria-describedby` to supply your own accessible text for the switch. An explicit `aria-label` replaces the generated name association; explicit `aria-labelledby` and `aria-describedby` values replace the corresponding generated associations.++## Native targets and composition++The ordinary native props configure the control. Label customization has two explicit names:-## Disabled and read-only settings+| Props | Target |+| --------------------------------------------------------------------------------------- | --------------------------------------- |+| Native attributes, handlers, `className`, `style`, `ref`, and `render` | The visible Switch root |+| `inputRef`, `name`, `value`, `uncheckedValue`, `required`, and `form` | The Switch's underlying native checkbox |+| `labelRef` and attributes, handlers, classes, and styles supplied through `labelRender` | The outer native label |-Pass `disabled` once to disable both the row and switch. Use `readOnly` to prevent changes while keeping the switch focusable.+The label's `htmlFor` is managed internally and follows `id`, or a generated control ID when no ID is supplied. With the default Switch composition, this ID identifies the underlying checkbox. With `nativeButton`, it identifies the visible button. `ref` targets the visible root in both cases.++Use `labelRender` to customize the row's native label. Preserve a label element and forward the render callback props to your element. Its `props.children` contains the complete row, including the switch. Element composition merges its classes and styles with the row's defaults.```tsx+import { useRef } from 'react';import { SettingsRow } from 'twenty-ui/components/settings';-export const WorkspaceSettings = () => (- <>- <SettingsRow disabled>Notifications</SettingsRow>- <SettingsRow readOnly defaultChecked>- Activity history+export const ComposedNotificationSetting = () => {+ const labelRef = useRef<HTMLLabelElement>(null);+ const controlRef = useRef<HTMLElement>(null);+ const inputRef = useRef<HTMLInputElement>(null);++ return (+ <SettingsRow+ id="notification-control"+ ref={controlRef}+ inputRef={inputRef}+ nativeButton+ render={<button />}+ labelRef={labelRef}+ labelRender={<label id="notification-row" data-setting="notifications" />}+ >+ Notifications</SettingsRow>- </>+ );+};+```++`onClick` receives control clicks. Native handlers supplied through `labelRender` receive label events and bubbled control events. Calling `preventDefault()` on a label click prevents its native control activation. Use `onCheckedChange` for preference updates, rather than inferring state from a label click.++The switch defaults to `size="sm"`; use `"md"` for a larger switch. The row height stays the same. `focused` applies the row's highlighted appearance without moving keyboard focus. `className`, `style`, and `render` accept Switch state callbacks and customize the control. Supply label classes and styles through `labelRender` to customize the row.++## Front component renderer++Inside a front component, use the native button composition for a switch nested in the row's label:++```tsx+import { SettingsRow } from 'twenty-ui/components/settings';++export const FrontComponentNotificationSetting = () => (+ <SettingsRow nativeButton render={<button />}>+ Notifications+ </SettingsRow>);```-## Appearance and composition+This composition activates once when clicking the label or control. The renderer's asynchronous event bridge cannot cancel the host label's default activation in time for a span-based control, which can produce duplicate change callbacks on a direct control click. Native form validation attributes such as `required` are also filtered by the current renderer. Standalone `SettingsRow` retains the full Switch form contract.++## Forms and reset-The switch defaults to `size="sm"`; use `size="md"` for a larger switch. The row height stays the same. `focused` applies the row's highlighted style without moving keyboard focus.+`name`, `value`, and `required` configure the underlying checkbox for form submission and validation. A checked switch submits its value. An unchecked switch omits the value unless `uncheckedValue` is supplied. Use `form` to associate the input with a form outside the row's parent tree.++For controlled form reset, restore the application-owned checked value in the form's `onReset` handler. Base UI 1.8 does not restore uncontrolled switch state on native form reset. `SettingsRow` preserves this upstream behavior.++```tsx+import { useState } from 'react';+import { SettingsRow } from 'twenty-ui/components/settings';+import { Button } from 'twenty-ui/primitives/input';-Native label attributes, `className`, `style`, and `ref` target the outer label. The label and switch association is managed internally. Keep the children, description, and icon non-interactive. Use `onCheckedChange` for value updates.+export const NotificationPreferences = () => {+ const [enabled, setEnabled] = useState(true);-For navigation or action rows, use [ListItem](/ui/primitives/navigation/list-item) with a button or link.+ return (+ <form onReset={() => setEnabled(true)}>+ <SettingsRow+ checked={enabled}+ onCheckedChange={setEnabled}+ name="notifications"+ value="enabled"+ uncheckedValue="disabled"+ >+ Notifications+ </SettingsRow>+ <Button type="reset">Reset</Button>+ </form>+ );+};+```## Propsdiff --git a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx b/packages/twenty-docs/ui/primitives/navigation/list-item.mdxindex 39188897303..4c1f850d5d4 100644--- a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx+++ b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx@@ -62,7 +62,7 @@ The default element is a `div`. Use `render` to give an interactive row appropri## Settings row-Use [SettingsRow](/ui/components/settings/settings-row) for a labeled switch row. It composes `ListItem` and `Switch`, manages their accessible association, and applies disabled behavior to both.+Use [SettingsRow](/ui/components/settings/settings-row) for a labeled switch row. It composes `ListItem` and `Switch`, manages their accessible association, and uses the switch’s disabled state for the row’s appearance.## Selection indicatordiff --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 83d3a0dcf6c..9ff06e7a5e5 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@@ -130,6 +130,17 @@ Direct app-owned `Dialog`/`AlertDialog` modality and native browser dialog/popovAn invisible popup is not a compatibility pass.+SettingsRow's flat Switch props target the control. Its controlled composition+uses `nativeButton` and an actual button through `render`, preserving one change+callback for label and control activation. `labelRender` supplies native label+attributes and handlers, and `labelRef` targets that label. Default span-based+rows still cover label activation, uncontrolled state, read-only and disabled+behavior. Directly+clicking a span control inside its label can produce duplicate change callbacks+because worker cancellation cannot stop the host label's default activation in+time. Native validation attributes such as `required` are currently filtered by+the renderer; standalone UI stories verify that form contract.+These are compatibility regression stories, not assertions that the componentswork fully in the sandbox. Scenarios pin the current behavior exactly: ascenario that reaches a gap asserts what the component reports, and one thatdiff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-settings-row.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-settings-row.front-component.tsxindex b12f01068c9..ed9eec38647 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-settings-row.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-settings-row.front-component.tsx@@ -1,4 +1,4 @@-import { useState } from 'react';+import { createElement, type MouseEvent, useState } from 'react';import { defineFrontComponent } from 'twenty-sdk/define';import { SettingsRow } from 'twenty-ui/components/settings';import { IconBell } from 'twenty-ui/icon';@@ -8,17 +8,77 @@ import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twentconst SettingsRowExample = () => {const [notifications, setNotifications] = useState(false);const [changes, setChanges] = useState(0);+ const [changeEvent, setChangeEvent] = useState('none');+ const [labelEvent, setLabelEvent] = useState('none');+ const [controlEvent, setControlEvent] = useState('none');+ const [cancelledChanges, setCancelledChanges] = useState(0);+ const [cancelledEvent, setCancelledEvent] = useState('none');return (<TwentyUiGalleryCard title="SettingsRow"><SettingsRow- startIcon={<IconBell aria-hidden />}- description="Updates by email"+ id="notifications-control"+ title="Switch control"+ name="notifications"+ value="enabled"+ uncheckedValue="disabled"checked={notifications}- onCheckedChange={(checked) => {+ nativeButton+ ref={(element) => {+ element?.setAttribute('data-ref-target', 'control');+ }}+ inputRef={(element) => {+ element?.setAttribute('data-ref-target', 'input');+ }}+ render={(props, state) =>+ createElement('button', {+ ...props,+ 'data-active': String(state.checked),+ })+ }+ onClick={(event) => {+ setControlEvent(`${event.currentTarget.tagName}/${event.type}`);+ }}+ onCheckedChange={(checked, details) => {setNotifications(checked);setChanges((count) => count + 1);+ setChangeEvent(`${details.event.type}/${typeof details.cancel}`);+ }}+ labelRef={(element) => {+ element?.setAttribute('data-ref-target', 'label');}}+ labelRender={(props) =>+ createElement(+ 'label',+ {+ ...props,+ id: 'notifications-row',+ title: 'Native label',+ 'data-testid': 'notifications-row',+ 'data-label-render': 'true',+ onClick: (event: MouseEvent<HTMLLabelElement>) => {+ props.onClick?.(event);+ setLabelEvent(`${event.currentTarget.tagName}/${event.type}`);+ },+ },+ createElement(+ 'span',+ { style: { display: 'contents' } },+ props.children,+ ),+ )+ }+ startElement={+ <span data-testid="notifications-start">+ <IconBell aria-hidden />+ </span>+ }+ description={+ <span>+ Updates <strong>by email</strong>+ </span>+ }>Notifications</SettingsRow>@@ -28,9 +88,31 @@ const SettingsRowExample = () => {>Disabled notifications</SettingsRow>+ <SettingsRow defaultChecked>Uncontrolled notifications</SettingsRow>+ <SettingsRow+ defaultChecked+ readOnly+ onCheckedChange={() => setChanges((count) => count + 1)}+ >+ Read-only notifications+ </SettingsRow>+ <SettingsRow+ onCheckedChange={(_checked, details) => {+ details.cancel();+ setCancelledChanges((count) => count + 1);+ setCancelledEvent(details.event.type);+ }}+ >+ Cancelled notifications+ </SettingsRow><p role="status">Notifications: {notifications ? 'enabled' : 'disabled'}; Changes:{' '}- {changes}+ {changes}; Event: {changeEvent}+ </p>+ <p aria-label="Native label event">{labelEvent}</p>+ <p aria-label="Switch control event">{controlEvent}</p>+ <p aria-label="Cancelled changes">+ {cancelledChanges}/{cancelledEvent}</p></TwentyUiGalleryCard>);@@ -39,6 +121,6 @@ const SettingsRowExample = () => {export default defineFrontComponent({universalIdentifier: '68a0e63b-fd20-4515-a733-96f457ceba71',name: 'twenty-ui-settings-row',- description: 'SettingsRow labels and disabled behavior in the sandbox',+ description: 'SettingsRow label and Switch control contracts in the sandbox',component: SettingsRowExample,});diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/settingsRowTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/settingsRowTest.tsindex c8920dea6c8..625faac6453 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/settingsRowTest.ts+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/settingsRowTest.ts@@ -11,22 +11,96 @@ export const settingsRowTest: TwentyUiGalleryPlayFunction = async ({await expectFrontComponentMounted(canvas);const notifications = canvas.getByRole('switch', { name: 'Notifications' });+ const label = canvas.getByTestId('notifications-row');+ const input = label.querySelector('input[type="checkbox"]');+ const disabled = canvas.getByRole('switch', {+ name: 'Disabled notifications',+ });+ const uncontrolled = canvas.getByRole('switch', {+ name: 'Uncontrolled notifications',+ });+ const readOnly = canvas.getByRole('switch', {+ name: 'Read-only notifications',+ });+ const cancelled = canvas.getByRole('switch', {+ name: 'Cancelled notifications',+ });+await expect(notifications).toHaveAccessibleDescription('Updates by email');+ expect(canvas.getByTestId('notifications-start')).toHaveTextContent('Email');+ expect(label.tagName).toBe('LABEL');+ expect(label).toHaveAttribute('for', 'notifications-control');+ expect(label).toHaveAttribute('title', 'Native label');+ expect(label).toHaveAttribute('data-ref-target', 'label');+ expect(label).toHaveAttribute('data-label-render', 'true');+ expect(notifications).toHaveAttribute('title', 'Switch control');+ expect(notifications).toHaveAttribute('data-ref-target', 'control');+ expect(notifications).toHaveAttribute('data-active', 'false');+ expect(notifications).toHaveAttribute('id', 'notifications-control');+ expect(input).toHaveAttribute('data-ref-target', 'input');+ expect(input).toHaveAttribute('name', 'notifications');+ expect(input).toHaveAttribute('value', 'enabled');+ expect(uncontrolled).toBeChecked();+ expect(readOnly).toBeChecked();+ expect(disabled).toHaveAttribute('aria-disabled', 'true');+await userEvent.click(canvas.getByText('Disabled notifications'));- await userEvent.click(- canvas.getByRole('switch', { name: 'Disabled notifications' }),- );- await expect(canvas.getByRole('status')).toHaveTextContent(+ await userEvent.click(disabled);+ await userEvent.click(canvas.getByText('Read-only notifications'));+ await userEvent.click(readOnly);+ expect(disabled).not.toBeChecked();+ expect(readOnly).toBeChecked();+ expect(canvas.getByRole('status')).toHaveTextContent('Notifications: disabled; Changes: 0',);await userEvent.click(canvas.getByText('Notifications'));-await waitFor(() =>expect(canvas.getByRole('status')).toHaveTextContent('Notifications: enabled; Changes: 1',),);expect(notifications).toBeChecked();+ expect(notifications).toHaveAttribute('data-active', 'true');+ expect(canvas.getByRole('status')).toHaveTextContent(+ /Event: (click|change)\/function/,+ );+ expect(canvas.getByLabelText('Native label event')).toHaveTextContent(+ 'LABEL/click',+ );+ expect(canvas.getByLabelText('Switch control event')).toHaveTextContent(+ 'BUTTON/click',+ );++ await userEvent.click(notifications);+ await waitFor(() =>+ expect(canvas.getByRole('status')).toHaveTextContent(+ 'Notifications: disabled; Changes: 2',+ ),+ );+ expect(canvas.getByLabelText('Switch control event')).toHaveTextContent(+ 'BUTTON/click',+ );+ notifications.focus();+ await userEvent.keyboard(' ');+ await waitFor(() =>+ expect(canvas.getByRole('status')).toHaveTextContent(+ 'Notifications: enabled; Changes: 3',+ ),+ );+ expect(notifications).toBeChecked();++ await userEvent.click(canvas.getByText('Uncontrolled notifications'));+ await waitFor(() => expect(uncontrolled).not.toBeChecked());+ await userEvent.click(canvas.getByText('Cancelled notifications'));+ await waitFor(() =>+ expect(canvas.getByLabelText('Cancelled changes')).toHaveTextContent(+ /^1\/(click|change)$/,+ ),+ );+ expect(cancelled).not.toBeChecked();+ expect(canvas.getByRole('status')).toHaveTextContent(+ 'Notifications: enabled; Changes: 3',+ );expect(errorHandler).not.toHaveBeenCalled();};diff --git a/packages/twenty-front/src/modules/command-menu-item/edit/components/CommandMenuItemOptionsDropdown.tsx b/packages/twenty-front/src/modules/command-menu-item/edit/components/CommandMenuItemOptionsDropdown.tsxindex bcdab171584..b51e26ccf4f 100644--- a/packages/twenty-front/src/modules/command-menu-item/edit/components/CommandMenuItemOptionsDropdown.tsx+++ b/packages/twenty-front/src/modules/command-menu-item/edit/components/CommandMenuItemOptionsDropdown.tsx@@ -52,7 +52,7 @@ export const CommandMenuItemOptionsDropdown = ({<DropdownContent align="end"><Dropdown.Section><SettingsRow- startIcon={<IconTag />}+ startElement={<IconTag />}disabled={hasNoShortLabel}checked={isLabelHidden || hasNoShortLabel}onCheckedChange={handleHiddenLabelChange}diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemSwitch.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemSwitch.tsxindex 0df83072517..1fb27c75907 100644--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemSwitch.tsx+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemSwitch.tsx@@ -2,11 +2,9 @@ import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-lisimport { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';import { styled } from '@linaria/react';import { isDefined } from 'twenty-shared/utils';-import {- SettingsRow,- type SettingsRowProps,-} from 'twenty-ui/components/settings';+import { SettingsRow } from 'twenty-ui/components/settings';import { type IconComponent } from 'twenty-ui/icon';+import { type SwitchProps } from 'twenty-ui/primitives/input';import { themeCssVariables } from 'twenty-ui/theme';type CommandMenuItemSwitchProps = {@@ -14,8 +12,8 @@ type CommandMenuItemSwitchProps = {LeftIcon?: IconComponent;text: string;checked: boolean;- onCheckedChange?: SettingsRowProps['onCheckedChange'];- size?: SettingsRowProps['size'];+ onCheckedChange?: SwitchProps['onCheckedChange'];+ size?: SwitchProps['size'];disabled?: boolean;className?: string;};@@ -51,16 +49,16 @@ export const CommandMenuItemSwitch = ({return (<SettingsRow- className={className}+ labelRender={<label className={className} />}focused={isSelectedItemId}- disabled={disabled}- startIcon={+ startElement={isDefined(LeftIcon) && (<StyledIconContainer><LeftIcon /></StyledIconContainer>)}+ disabled={disabled}checked={checked}onCheckedChange={onCheckedChange}size={size}diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownLayoutContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownLayoutContent.tsxindex 40f3c543b5c..df4c0c64c5d 100644--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownLayoutContent.tsx+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownLayoutContent.tsx@@ -330,7 +330,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {><SettingsRowfocused={selectedItemId === 'Compact view'}- startIcon={<IconBaselineDensitySmall />}+ startElement={<IconBaselineDensitySmall />}onCheckedChange={() =>setAndPersistIsCompactModeActive(!isCompactModeActive,diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupsContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupsContent.tsxindex 2e1289bcf0f..43285a94108 100644--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupsContent.tsx+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupsContent.tsx@@ -204,8 +204,8 @@ export const ObjectOptionsDropdownRecordGroupsContent = () => {><SettingsRowfocused={selectedItemId === 'HideEmptyGroups'}+ startElement={<IconCircleOff />}disabled={!canPersistChanges}- startIcon={<IconCircleOff />}onCheckedChange={handleHideEmptyRecordGroupChange}checked={shouldHideEmptyGroups}>{t`Hide empty groups`}</SettingsRow>diff --git a/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsx b/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsxindex 8396718e582..e854698abe5 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsx+++ b/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsx@@ -218,7 +218,7 @@ export const SettingsAdminApps = () => {<DropdownContent align="end" sideOffset={8}><Dropdown.Section><SettingsRow- startIcon={<IconPinned />}+ startElement={<IconPinned />}onCheckedChange={() =>setShowPreInstalledOnly(!showPreInstalledOnly)}diff --git a/packages/twenty-front/src/modules/settings/admin-panel/chats/components/SettingsAdminChatsFilterDropdown.tsx b/packages/twenty-front/src/modules/settings/admin-panel/chats/components/SettingsAdminChatsFilterDropdown.tsxindex 7ef80c4318c..b8aa155fb4e 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/chats/components/SettingsAdminChatsFilterDropdown.tsx+++ b/packages/twenty-front/src/modules/settings/admin-panel/chats/components/SettingsAdminChatsFilterDropdown.tsx@@ -29,7 +29,7 @@ export const SettingsAdminChatsFilterDropdown = ({<DropdownContent side="bottom" align="end" sideOffset={8} alignOffset={0}><Dropdown.Section><SettingsRow- startIcon={<IconSparkles />}+ startElement={<IconSparkles />}onCheckedChange={() =>onFiltersChange({...filters,@@ -39,7 +39,7 @@ export const SettingsAdminChatsFilterDropdown = ({checked={filters.onboardingOnly}>{t`Onboarding only`}</SettingsRow><SettingsRow- startIcon={<IconAlertTriangle />}+ startElement={<IconAlertTriangle />}onCheckedChange={() =>onFiltersChange({...filters,@@ -49,7 +49,7 @@ export const SettingsAdminChatsFilterDropdown = ({checked={filters.hasErrorOnly}>{t`Has error`}</SettingsRow><SettingsRow- startIcon={<IconMessage />}+ startElement={<IconMessage />}onCheckedChange={() =>onFiltersChange({...filters,diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldTable.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldTable.tsxindex a80cd23c0ca..b01c58d736b 100644--- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldTable.tsx+++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldTable.tsx@@ -188,14 +188,14 @@ export const SettingsObjectFieldTable = ({><Dropdown.Section><SettingsRow- startIcon={<IconArchive />}+ startElement={<IconArchive />}onCheckedChange={() => setShowInactive(!showInactive)}checked={showInactive}>{t`Inactive`}</SettingsRow>{(mostlyEmptyFieldMetadataIds.size > 0 ||showOnlyMostlyEmpty) && (<SettingsRow- startIcon={<IconCircleDashed />}+ startElement={<IconCircleDashed />}onCheckedChange={() =>setShowOnlyMostlyEmpty(!showOnlyMostlyEmpty)}@@ -204,7 +204,7 @@ export const SettingsObjectFieldTable = ({)}{isAdvancedModeEnabled && (<SettingsRow- startIcon={<IconSettings />}+ startElement={<IconSettings />}onCheckedChange={() =>setShowSystemFields(!showSystemFields)}diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectRelationsTable.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectRelationsTable.tsxindex eea7cc6515a..929e5ef4219 100644--- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectRelationsTable.tsx+++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectRelationsTable.tsx@@ -223,7 +223,7 @@ export const SettingsObjectRelationsTable = ({><Dropdown.Section><SettingsRow- startIcon={<IconArchive />}+ startElement={<IconArchive />}onCheckedChange={() => setShowInactive(!showInactive)}checked={showInactive}>{t`Inactive`}</SettingsRow>diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectIndexesSection.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectIndexesSection.tsxindex 2e2ca8574f1..53d32b4971e 100644--- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectIndexesSection.tsx+++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectIndexesSection.tsx@@ -175,7 +175,7 @@ export const SettingsObjectIndexesSection = ({<DropdownContent align="end" sideOffset={8}><Dropdown.Section><SettingsRow- startIcon={<IconEyeOff />}+ startElement={<IconEyeOff />}onCheckedChange={() =>setHideSystemIndexes(!hideSystemIndexes)}diff --git a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsxindex 6489281a9a0..705d7142448 100644--- a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx+++ b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx@@ -107,12 +107,12 @@ export const SettingsRolesList = () => {<DropdownContent align="end" sideOffset={8}><Dropdown.Section><SettingsRow- startIcon={<IconLego />}+ startElement={<IconLego />}onCheckedChange={() => setShowAgentRoles(!showAgentRoles)}checked={showAgentRoles}>{t`Agent roles`}</SettingsRow><SettingsRow- startIcon={<IconKey />}+ startElement={<IconKey />}onCheckedChange={() => setShowApiKeyRoles(!showApiKeyRoles)}checked={showApiKeyRoles}>{t`API key roles`}</SettingsRow>diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsxindex a6c00393cfd..935a334306a 100644--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx@@ -100,7 +100,7 @@ export const SidePanelObjectFilterDropdownContent = ({<Dropdown.Separator /><Dropdown.Section><SettingsRow- startIcon={<IconCube />}+ startElement={<IconCube />}onCheckedChange={() =>setSidePanelShowHiddenObjects(!sidePanelShowHiddenObjects)}diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsxindex 46f253bc430..5ed11b4933c 100644--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsx+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsx@@ -142,13 +142,13 @@ export const SettingsAgentSkillsTab = () => {><Dropdown.Section><SettingsRow- startIcon={<IconArchive />}+ startElement={<IconArchive />}onCheckedChange={setShowDeactivated}checked={showDeactivated}>{t`Deactivated`}</SettingsRow>{isAdvancedModeEnabled && (<SettingsRow- startIcon={<IconSettings />}+ startElement={<IconSettings />}onCheckedChange={setShowSystemSkills}checked={showSystemSkills}>{t`System skills`}</SettingsRow>diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsxindex b495ff4b2ed..a124a2d72b6 100644--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsx+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsx@@ -98,17 +98,17 @@ export const SettingsAgentToolsTab = () => {><Dropdown.Section><SettingsRow- startIcon={<IconTool />}+ startElement={<IconTool />}onCheckedChange={setShowCustomTools}checked={showCustomTools}>{t`Custom`}</SettingsRow><SettingsRow- startIcon={<IconLock />}+ startElement={<IconLock />}onCheckedChange={setShowManagedTools}checked={showManagedTools}>{t`Managed`}</SettingsRow><SettingsRow- startIcon={<IconPuzzle />}+ startElement={<IconPuzzle />}onCheckedChange={setShowStandardTools}checked={showStandardTools}>{t`Standard`}</SettingsRow>diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsxindex 81019c5ef07..fd598e0ea09 100644--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx@@ -108,7 +108,7 @@ export const SettingsApplicationsAvailableTab = () => {><Dropdown.Section><SettingsRow- startIcon={<IconSparkles />}+ startElement={<IconSparkles />}onCheckedChange={() => setShowVettedOnly(!showVettedOnly)}checked={showVettedOnly}>{t`Vetted only`}</SettingsRow>diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsxindex 9e073c0e5b7..c4a5088bcfb 100644--- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsx+++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsx@@ -177,7 +177,7 @@ export const SettingsObjectTable = ({><Dropdown.Section><SettingsRow- startIcon={<IconArchive />}+ startElement={<IconArchive />}onCheckedChange={() =>setShowDeactivated(!showDeactivated)}@@ -185,7 +185,7 @@ export const SettingsObjectTable = ({>{t`Deactivated`}</SettingsRow>{isAdvancedModeEnabled && (<SettingsRow- startIcon={<IconSettings />}+ startElement={<IconSettings />}onCheckedChange={() =>setShowSystemObjects(!showSystemObjects)}diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.tsindex 1785f638988..b1ffa280531 100644--- a/packages/twenty-ui/docs/components.ts+++ b/packages/twenty-ui/docs/components.ts@@ -655,6 +655,7 @@ export const DOCUMENTED_COMPONENTS = [entryPoint: 'twenty-ui/components/settings',slug: 'components/settings/settings-row',propDescriptions: SETTINGS_ROW_PROP_DESCRIPTIONS,+ propDefaults: { size: 'sm' },},{name: 'PhoneCountryPicker',diff --git a/packages/twenty-ui/docs/settingsRowPropDescriptions.ts b/packages/twenty-ui/docs/settingsRowPropDescriptions.tsindex 2e48e28f3f0..376bda32ca2 100644--- a/packages/twenty-ui/docs/settingsRowPropDescriptions.ts+++ b/packages/twenty-ui/docs/settingsRowPropDescriptions.ts@@ -2,19 +2,25 @@ import { type SettingsRowProps } from '../src/components/settings/SettingsRow/tyexport const SETTINGS_ROW_PROP_DESCRIPTIONS = {children:- 'Visible label and accessible name of the switch. Use non-interactive content.',- startIcon: 'Decorative content before the label.',+ 'Visible label and default accessible name of the switch. Use non-interactive node content.',+ startElement: 'Non-interactive node content before the label.',description:- 'Non-interactive supporting content, associated with the switch as its accessible description.',+ 'Non-interactive supporting node content, used as the default accessible description of the switch.',focused: 'Applies the highlighted row style without moving keyboard focus.',- checked: 'Controlled checked state of the switch.',- defaultChecked: 'Initial checked state when uncontrolled.',+ labelRender:+ 'Customizes the outer native label with its complete composed row children. Preserve a label element and forward its props to retain control association.',+ labelRef: 'Targets the outer native label.',+ id: 'Identifies the associated checkbox, or the visible root with nativeButton. The label association follows this ID.',+ size: 'Visual size of the switch. Defaults to sm.',+ onClick: 'Native click handler for the visible Switch root.',onCheckedChange:- 'Called when the switch value changes, with the next checked state and Base UI event details.',- disabled: 'Disables both the row and its switch.',- readOnly: 'Keeps the switch focusable while preventing changes.',- size: 'Visual size of the switch. The row height stays the same.',- name: 'Name of the hidden checkbox used in form submission.',- value: 'Value submitted when the switch is checked.',- required: 'Requires the switch to be checked for form submission.',+ 'Receives the next checked value and Base UI event details. Controlled callers own accepted state updates; cancellation prevents a change.',+ className:+ 'Customizes the visible Switch root and accepts a Switch state callback.',+ style:+ 'Customizes the visible Switch root and accepts a Switch state callback.',+ render:+ 'Customizes the visible Switch root with control props and Switch state. Use nativeButton when composing a button.',+ ref: 'Targets the visible Switch root, which defaults to a span.',+ inputRef: 'Targets the underlying native checkbox.',} satisfies Partial<Record<keyof SettingsRowProps, string>>;diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex e5fd0ace1fc..c29347c44db 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -9754,35 +9754,42 @@"type": "boolean","required": false,"defaultValue": null,- "description": "Controlled checked state of the switch."+ "description": "Whether the switch is currently active.\n\nTo render an uncontrolled switch, use the `defaultChecked` prop instead."},{"name": "children","type": "ReactNode","required": true,"defaultValue": null,- "description": "Visible label and accessible name of the switch. Use non-interactive content."+ "description": "Visible label and default accessible name of the switch. Use non-interactive node content."+ },+ {+ "name": "className",+ "type": "string | ((state: SwitchRootState) => string | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "Customizes the visible Switch root and accepts a Switch state callback."},{"name": "defaultChecked","type": "boolean","required": false,"defaultValue": "false",- "description": "Initial checked state when uncontrolled."+ "description": "Whether the switch is initially active.\n\nTo render a controlled switch, use the `checked` prop instead."},{"name": "description","type": "ReactNode","required": false,"defaultValue": null,- "description": "Non-interactive supporting content, associated with the switch as its accessible description."+ "description": "Non-interactive supporting node content, used as the default accessible description of the switch."},{"name": "disabled","type": "boolean","required": false,"defaultValue": "false",- "description": "Disables both the row and its switch."+ "description": "Whether the component should ignore user interaction."},{"name": "focused",@@ -9791,54 +9798,131 @@"defaultValue": "false","description": "Applies the highlighted row style without moving keyboard focus."},+ {+ "name": "form",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Identifies the form that owns the hidden input.\nUseful when the switch is rendered outside the form."+ },+ {+ "name": "id",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Identifies the associated checkbox, or the visible root with nativeButton. The label association follows this ID."+ },+ {+ "name": "inputRef",+ "type": "Ref<HTMLInputElement>",+ "required": false,+ "defaultValue": null,+ "description": "Targets the underlying native checkbox."+ },+ {+ "name": "labelRef",+ "type": "Ref<HTMLLabelElement>",+ "required": false,+ "defaultValue": null,+ "description": "Targets the outer native label."+ },+ {+ "name": "labelRender",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",+ "required": false,+ "defaultValue": null,+ "description": "Customizes the outer native label with its complete composed row children. Preserve a label element and forward its props to retain control association."+ },{"name": "name","type": "string","required": false,"defaultValue": null,- "description": "Name of the hidden checkbox used in form submission."+ "description": "Identifies the field when a form is submitted."+ },+ {+ "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": "onCheckedChange","type": "((checked: boolean, eventDetails: { reason: \"none\"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)","required": false,"defaultValue": null,- "description": "Called when the switch value changes, with the next checked state and Base UI event details."+ "description": "Receives the next checked value and Base UI event details. Controlled callers own accepted state updates; cancellation prevents a change."+ },+ {+ "name": "onClick",+ "type": "((event: BaseUIEvent<MouseEvent<HTMLSpanElement, MouseEvent>>) => void)",+ "required": false,+ "defaultValue": null,+ "description": "Native click handler for the visible Switch root."},{"name": "readOnly","type": "boolean","required": false,"defaultValue": "false",- "description": "Keeps the switch focusable while preventing changes."+ "description": "Whether the user should be unable to activate or deactivate the switch."+ },+ {+ "name": "ref",+ "type": "Ref<HTMLSpanElement>",+ "required": false,+ "defaultValue": null,+ "description": "Targets the visible Switch root, which defaults to a span."+ },+ {+ "name": "render",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SwitchRootState>",+ "required": false,+ "defaultValue": null,+ "description": "Customizes the visible Switch root with control props and Switch state. Use nativeButton when composing a button."},{"name": "required","type": "boolean","required": false,"defaultValue": "false",- "description": "Requires the switch to be checked for form submission."+ "description": "Whether the user must activate the switch before submitting a form."},{"name": "size","type": "\"md\" | \"sm\"","required": false,"defaultValue": "sm",- "description": "Visual size of the switch. The row height stays the same."+ "description": "Visual size of the switch. Defaults to sm."},{- "name": "startIcon",+ "name": "startElement","type": "ReactNode","required": false,"defaultValue": null,- "description": "Decorative content before the label."+ "description": "Non-interactive node content before the label."+ },+ {+ "name": "style",+ "type": "CSSProperties | ((state: SwitchRootState) => CSSProperties | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "Customizes the visible Switch root and accepts a Switch state callback."+ },+ {+ "name": "uncheckedValue",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "The value submitted with the form when the switch is off.\nBy default, unchecked switches do not submit any value, matching native checkbox behavior."},{"name": "value","type": "string","required": false,"defaultValue": null,- "description": "Value submitted when the switch is checked."+ "description": "The value submitted with the form when the switch is on.\nBy default, switch submits the \"on\" value, matching native checkbox behavior."}]},diff --git a/packages/twenty-ui/src/components/settings/SettingsRow/SettingsRow.tsx b/packages/twenty-ui/src/components/settings/SettingsRow/SettingsRow.tsxindex 00d4889d7ad..9577ab9ace0 100644--- a/packages/twenty-ui/src/components/settings/SettingsRow/SettingsRow.tsx+++ b/packages/twenty-ui/src/components/settings/SettingsRow/SettingsRow.tsx@@ -3,60 +3,55 @@ import { useId } from 'react';import { Switch } from '@ui/primitives/input/Switch/Switch';import { ListItem } from '@ui/primitives/navigation/ListItem/ListItem';import { isRenderableSlot } from '@ui/utilities/internal/isRenderableSlot';+import { isDefined } from '@ui/utilities/utils/isDefined';+import { SettingsRowLabel } from './internal/SettingsRowLabel';import { type SettingsRowProps } from './types/SettingsRowProps';export const SettingsRow = ({children,- startIcon,+ startElement,description,focused = false,- checked,- defaultChecked,- onCheckedChange,- disabled = false,- readOnly = false,- size = 'sm',- name,- value,- required,- className,- style,- ref,- ...labelProps+ labelRender,+ labelRef,+ ...controlProps}: SettingsRowProps) => {- const switchId = useId();- const labelId = `${switchId}-label`;- const descriptionId = `${switchId}-description`;+ const generatedSwitchId = useId();+ const { id: switchId = generatedSwitchId, size = 'sm' } = controlProps;+ const labelId = `${generatedSwitchId}-label`;+ const descriptionId = `${generatedSwitchId}-description`;const hasDescription = isRenderableSlot(description);+ const hasControlLabel = isDefined(controlProps['aria-label']);return (<ListItem- className={className}- style={style}- startIcon={startIcon}+ startIcon={startElement}focused={focused}- disabled={disabled}+ data-disabled={controlProps.disabled || undefined}description={hasDescription && <span id={descriptionId}>{description}</span>}render={(renderProps) => (- <label {...labelProps} {...renderProps} htmlFor={switchId} ref={ref} />+ <SettingsRowLabel+ {...renderProps}+ htmlFor={switchId}+ render={labelRender}+ ref={labelRef}+ />)}endIcon={<Switch+ {...controlProps}+ aria-labelledby={+ controlProps['aria-labelledby'] ?? (hasControlLabel ? '' : labelId)+ }+ aria-describedby={+ controlProps['aria-describedby'] ??+ (hasDescription ? descriptionId : undefined)+ }id={switchId}- aria-labelledby={labelId}- aria-describedby={hasDescription ? descriptionId : undefined}- checked={checked}- defaultChecked={defaultChecked}- onCheckedChange={onCheckedChange}- disabled={disabled}- readOnly={readOnly}size={size}- name={name}- value={value}- required={required}/>}>diff --git a/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/ControlledSettingsRowExample.tsx b/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/ControlledSettingsRowExample.tsxindex bd8657705f8..7c185b1cf39 100644--- a/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/ControlledSettingsRowExample.tsx+++ b/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/ControlledSettingsRowExample.tsx@@ -15,8 +15,13 @@ export const ControlledSettingsRowExample = ({{...props}checked={checked}onCheckedChange={(nextChecked, eventDetails) => {- setChecked(nextChecked);onCheckedChange?.(nextChecked, eventDetails);++ if (eventDetails.isCanceled) {+ return;+ }++ setChecked(nextChecked);}}/>);diff --git a/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/ControlledSettingsRowFormExample.tsx b/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/ControlledSettingsRowFormExample.tsxnew file mode 100644index 00000000000..f54f2184d47--- /dev/null+++ b/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/ControlledSettingsRowFormExample.tsx@@ -0,0 +1,36 @@+import { useState } from 'react';++import { Button } from '@ui/primitives/input/Button/Button';++import { SettingsRow } from '../SettingsRow';+import { type SettingsRowProps } from '../types/SettingsRowProps';++export const ControlledSettingsRowFormExample = ({+ defaultChecked = false,+ onCheckedChange,+ ...props+}: SettingsRowProps) => {+ const [checked, setChecked] = useState(defaultChecked);++ return (+ <form+ aria-label="Notification preferences"+ onReset={() => setChecked(defaultChecked)}+ >+ <SettingsRow+ {...props}+ checked={checked}+ onCheckedChange={(nextChecked, eventDetails) => {+ onCheckedChange?.(nextChecked, eventDetails);++ if (eventDetails.isCanceled) {+ return;+ }++ setChecked(nextChecked);+ }}+ />+ <Button type="reset">Reset</Button>+ </form>+ );+};diff --git a/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/SettingsRow.stories.tsx b/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/SettingsRow.stories.tsxindex 66d12273807..9424daeef5a 100644--- a/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/SettingsRow.stories.tsx+++ b/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/SettingsRow.stories.tsx@@ -16,7 +16,7 @@ const meta: Meta<typeof SettingsRow> = {id: 'ui-components-settingsrow',title: 'UI/Components/Settings/SettingsRow',component: SettingsRow,- args: { children: 'Notifications', startIcon: <IconBell aria-hidden /> },+ args: { children: 'Notifications', startElement: <IconBell aria-hidden /> },parameters: { container: { width: 320 } },};diff --git a/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/SettingsRowInteractions.stories.tsx b/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/SettingsRowInteractions.stories.tsxindex 74c856dd7df..c4fc282f332 100644--- a/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/SettingsRowInteractions.stories.tsx+++ b/packages/twenty-ui/src/components/settings/SettingsRow/__stories__/SettingsRowInteractions.stories.tsx@@ -1,11 +1,15 @@+import { mergeProps } from '@base-ui/react/merge-props';import { type Meta, type StoryObj } from '@storybook/react-vite';-import { expect, fn, userEvent, within } from 'storybook/test';+import { type MouseEvent } from 'react';+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';import { Button } from '@ui/primitives/input/Button/Button';+import { Text } from '@ui/primitives/typography/Text/Text';import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';import { SettingsRow } from '../SettingsRow';import { ControlledSettingsRowExample } from './ControlledSettingsRowExample';+import { ControlledSettingsRowFormExample } from './ControlledSettingsRowFormExample';const meta: Meta<typeof SettingsRow> = {id: 'ui-components-settingsrow-interactions',@@ -14,7 +18,10 @@ const meta: Meta<typeof SettingsRow> = {tags: ['!autodocs'],decorators: [ComponentDecorator],parameters: { container: { width: 320 } },- args: { children: 'Notifications', onCheckedChange: fn() },+ args: {+ children: 'Notifications',+ onCheckedChange: fn(),+ },};export default meta;@@ -33,6 +40,12 @@ export const Controlled: Story = {await userEvent.click(canvas.getByText('Notifications'));await expect(control).not.toBeChecked();await expect(args.onCheckedChange).toHaveBeenCalledTimes(2);+ await expect(args.onCheckedChange).toHaveBeenLastCalledWith(+ false,+ expect.objectContaining({+ event: expect.objectContaining({ type: 'click' }),+ }),+ );control.focus();await userEvent.keyboard(' ');@@ -42,17 +55,32 @@ export const Controlled: Story = {};export const IndependentRows: Story = {+ args: {+ id: 'notification-input',+ ref: fn(),+ inputRef: fn(),+ labelRef: fn(),+ },render: (args) => (<><SettingsRow {...args} /><SettingsRow defaultChecked>Weekly digest</SettingsRow></>),- play: async ({ canvasElement }) => {+ play: async ({ canvasElement, args }) => {const canvas = within(canvasElement);const notifications = canvas.getByRole('switch', { name: 'Notifications' });const digest = canvas.getByRole('switch', { name: 'Weekly digest' });+ const label = canvas.getByText('Notifications').closest('label');+ const input = canvasElement.querySelector('input#notification-input');+ await expect(notifications.tagName).toBe('SPAN');+ await expect(notifications).not.toHaveAttribute('id', 'notification-input');+ await expect(input).toHaveAttribute('id', 'notification-input');+ await expect(label).toHaveAttribute('for', 'notification-input');+ await expect(args.ref).toHaveBeenCalledWith(notifications);+ await expect(args.inputRef).toHaveBeenCalledWith(input);+ await expect(args.labelRef).toHaveBeenCalledWith(label);await expect(notifications).not.toBeChecked();await expect(digest).toBeChecked();await userEvent.click(canvas.getByText('Weekly digest'));@@ -64,22 +92,31 @@ export const IndependentRows: Story = {};export const Disabled: Story = {- args: { disabled: true },+ args: { disabled: true, onCheckedChange: fn() },play: async ({ canvasElement, args }) => {const canvas = within(canvasElement);const control = canvas.getByRole('switch', { name: 'Notifications' });await userEvent.click(canvas.getByText('Notifications'));await userEvent.click(control);+ await userEvent.tab();+ await expect(control).not.toHaveFocus();await expect(control).not.toBeChecked();await expect(control).toHaveAttribute('aria-disabled', 'true');+ await expect(+ canvas.getByText('Notifications').closest('label'),+ ).toHaveAttribute('data-disabled');await expect(args.onCheckedChange).not.toHaveBeenCalled();},};export const ReadOnly: Story = {- args: { readOnly: true, defaultChecked: true },+ args: {+ readOnly: true,+ defaultChecked: true,+ onCheckedChange: fn(),+ },play: async ({ canvasElement, args }) => {const canvas = within(canvasElement);const control = canvas.getByRole('switch', { name: 'Notifications' });@@ -96,7 +133,10 @@ export const ReadOnly: Story = {};export const AccessibleDescription: Story = {- args: { description: 'Updates by email' },+ args: {+ children: <Text>Notifications</Text>,+ description: <Text>Updates by email</Text>,+ },parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },play: async ({ canvasElement }) => {const canvas = within(canvasElement);@@ -108,10 +148,37 @@ export const AccessibleDescription: Story = {},};+export const AccessibleOverrides: Story = {+ args: {+ description: 'Updates by email',+ 'aria-label': 'Email preferences',+ 'aria-labelledby': undefined,+ 'aria-describedby': 'notification-description',+ },+ parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },+ render: (args) => (+ <>+ <Text id="notification-description">Receive workspace updates</Text>+ <SettingsRow {...args} />+ </>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const control = canvas.getByRole('switch', { name: 'Email preferences' });++ await expect(control).toHaveAccessibleDescription(+ 'Receive workspace updates',+ );+ await userEvent.click(canvas.getByText('Notifications'));+ await expect(control).toBeChecked();+ },+};+export const CanceledChange: Story = {args: {onCheckedChange: fn((_checked, eventDetails) => eventDetails.cancel()),},+ render: (args) => <ControlledSettingsRowExample {...args} />,play: async ({ canvasElement, args }) => {const canvas = within(canvasElement);@@ -122,6 +189,106 @@ export const CanceledChange: Story = {},};+export const CanceledLabelActivation: Story = {+ args: {+ labelRender: (props) => (+ <label {...props} onClick={(event) => event.preventDefault()}>+ {props.children}+ </label>+ ),+ },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);++ await userEvent.click(canvas.getByText('Notifications'));++ await expect(args.onCheckedChange).not.toHaveBeenCalled();+ await expect(canvas.getByRole('switch')).not.toBeChecked();+ },+};++const nativeLabelClick = fn(+ (event: MouseEvent<HTMLLabelElement>) => event.currentTarget,+);++export const NativeTargets: Story = {+ args: {+ id: 'notification-control',+ title: 'Notification control',+ name: 'notifications',+ ref: fn(),+ inputRef: fn(),+ onClick: fn((event: MouseEvent<HTMLElement>) => event.currentTarget),+ onCheckedChange: fn(),+ nativeButton: true,+ render: (props, state) => (+ <button {...props} data-composed-checked={state.checked} />+ ),+ className: (state) =>+ state.checked ? 'consumer-checked' : 'consumer-unchecked',+ style: (state) => ({ marginInlineStart: state.checked ? 8 : 0 }),+ labelRef: fn(),+ labelRender: (props) => (+ <label+ {...mergeProps(props, {+ id: 'notification-row',+ title: 'Notification row',+ 'data-composed-label': 'true',+ className: 'consumer-label',+ style: { paddingInline: 8 },+ onClick: nativeLabelClick,+ })}+ >+ <span data-composed-content="true" style={{ display: 'contents' }}>+ {props.children}+ </span>+ </label>+ ),+ },+ play: async ({ canvasElement, args }) => {+ nativeLabelClick.mockClear();++ const canvas = within(canvasElement);+ const control = canvas.getByRole('switch', { name: 'Notifications' });+ const label = canvas.getByText('Notifications').closest('label');+ const input = canvasElement.querySelector('input[name="notifications"]');++ await expect(label).toHaveAttribute('id', 'notification-row');+ await expect(label).toHaveAttribute('for', 'notification-control');+ await expect(label).toHaveAttribute('title', 'Notification row');+ await expect(label).toHaveAttribute('data-composed-label', 'true');+ await expect(label).toHaveClass('consumer-label');+ await expect(label).toHaveStyle({ display: 'flex', paddingInline: '8px' });+ await expect(control.closest('[data-composed-content]')).toHaveAttribute(+ 'data-composed-content',+ 'true',+ );+ await expect(args.labelRef).toHaveBeenCalledWith(label);+ await expect(control).toHaveAttribute('id', 'notification-control');+ await expect(control).toHaveAttribute('title', 'Notification control');+ await expect(args.ref).toHaveBeenCalledWith(control);+ await expect(args.inputRef).toHaveBeenCalledWith(input);+ await expect(control).toHaveClass('consumer-unchecked');+ await expect(label).not.toHaveClass('consumer-unchecked');+ await expect(label).not.toHaveAttribute('data-composed-checked');++ await userEvent.click(control);++ await expect(nativeLabelClick).toHaveBeenCalledTimes(1);+ await expect(nativeLabelClick).toHaveReturnedWith(label);+ await expect(args.onClick).toHaveBeenCalledTimes(1);+ await expect(args.onClick).toHaveReturnedWith(control);+ await expect(args.onCheckedChange).toHaveBeenCalledTimes(1);+ await expect(control).toHaveClass('consumer-checked');+ await expect(control).toHaveAttribute('data-composed-checked', 'true');+ await expect(control).toHaveStyle({ marginInlineStart: '8px' });+ await expect(control).toBeChecked();+ await userEvent.click(canvas.getByText('Notifications'));+ await expect(control).not.toBeChecked();+ await expect(args.onCheckedChange).toHaveBeenCalledTimes(2);+ },+};+export const FormSubmission: Story = {render: (args) => (<form@@ -155,3 +322,52 @@ export const FormSubmission: Story = {}},};++export const ControlledFormReset: Story = {+ args: {+ defaultChecked: true,+ name: 'notifications',+ value: 'enabled',+ uncheckedValue: 'disabled',+ onCheckedChange: fn(),+ },+ render: (args) => <ControlledSettingsRowFormExample {...args} />,+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const control = canvas.getByRole('switch', { name: 'Notifications' });+ const form = canvas.getByRole<HTMLFormElement>('form', {+ name: 'Notification preferences',+ });++ await expect(control).toBeChecked();+ await expect(new FormData(form).get('notifications')).toBe('enabled');+ await userEvent.click(canvas.getByText('Notifications'));+ await expect(control).not.toBeChecked();+ await expect(new FormData(form).get('notifications')).toBe('disabled');+ await userEvent.click(canvas.getByRole('button', { name: 'Reset' }));+ await waitFor(() => expect(control).toBeChecked());+ await expect(new FormData(form).get('notifications')).toBe('enabled');+ await expect(args.onCheckedChange).toHaveBeenCalledTimes(1);+ },+};++export const UncontrolledFormReset: Story = {+ args: { defaultChecked: true, onCheckedChange: fn() },+ render: (args) => (+ <form>+ <SettingsRow {...args} />+ <Button type="reset">Reset</Button>+ </form>+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const control = canvas.getByRole('switch', { name: 'Notifications' });++ await expect(control).toBeChecked();+ await userEvent.click(canvas.getByText('Notifications'));+ await expect(control).not.toBeChecked();+ await userEvent.click(canvas.getByRole('button', { name: 'Reset' }));+ await expect(control).not.toBeChecked();+ await expect(args.onCheckedChange).toHaveBeenCalledTimes(1);+ },+};diff --git a/packages/twenty-ui/src/components/settings/SettingsRow/__tests__/SettingsRow.test.tsx b/packages/twenty-ui/src/components/settings/SettingsRow/__tests__/SettingsRow.test.tsxindex 78c67263b9e..e32c91dbbaf 100644--- a/packages/twenty-ui/src/components/settings/SettingsRow/__tests__/SettingsRow.test.tsx+++ b/packages/twenty-ui/src/components/settings/SettingsRow/__tests__/SettingsRow.test.tsx@@ -5,6 +5,5 @@ import { SettingsRow } from '../SettingsRow';runComponentConformance({name: 'SettingsRow',element: <SettingsRow>Notifications</SettingsRow>,- refInstanceOf: HTMLLabelElement,- skip: ['renderProp'],+ refInstanceOf: HTMLSpanElement,});diff --git a/packages/twenty-ui/src/components/settings/SettingsRow/internal/SettingsRowLabel.tsx b/packages/twenty-ui/src/components/settings/SettingsRow/internal/SettingsRowLabel.tsxnew file mode 100644index 00000000000..14943118f5e--- /dev/null+++ b/packages/twenty-ui/src/components/settings/SettingsRow/internal/SettingsRowLabel.tsx@@ -0,0 +1,8 @@+import { useRender } from '@base-ui/react/use-render';++export const SettingsRowLabel = ({+ render,+ ref,+ ...props+}: useRender.ComponentProps<'label'>) =>+ useRender({ defaultTagName: 'label', render, ref, props });diff --git a/packages/twenty-ui/src/components/settings/SettingsRow/types/SettingsRowProps.ts b/packages/twenty-ui/src/components/settings/SettingsRow/types/SettingsRowProps.tsindex cf6361c1ed8..fbcd5493c77 100644--- a/packages/twenty-ui/src/components/settings/SettingsRow/types/SettingsRowProps.ts+++ b/packages/twenty-ui/src/components/settings/SettingsRow/types/SettingsRowProps.ts@@ -1,24 +1,13 @@-import { type ComponentPropsWithRef, type ReactNode } from 'react';+import { type useRender } from '@base-ui/react/use-render';+import { type ReactNode } from 'react';import { type SwitchProps } from '@ui/primitives/input/Switch/types/SwitchProps';-import { type ListItemProps } from '@ui/primitives/navigation/ListItem/types/ListItemProps';-export type SettingsRowProps = Omit<- ComponentPropsWithRef<'label'>,- 'children' | 'htmlFor' | 'onChange' | 'onClick'-> &- Pick<ListItemProps, 'startIcon' | 'description' | 'focused'> &- Pick<- SwitchProps,- | 'checked'- | 'defaultChecked'- | 'onCheckedChange'- | 'disabled'- | 'readOnly'- | 'size'- | 'name'- | 'value'- | 'required'- > & {- children: ReactNode;- };+export type SettingsRowProps = Omit<SwitchProps, 'children'> & {+ children: ReactNode;+ startElement?: ReactNode;+ description?: ReactNode;+ focused?: boolean;+ labelRef?: useRender.ComponentProps<'label'>['ref'];+ labelRender?: useRender.ComponentProps<'label'>['render'];+};