Skip to content

The open alternative to Salesforce, designed for AI.

Add SettingsRow and migrate legacy rows (#26200)

Raphaël Bosi7953e5d683b2
diff --git a/packages/twenty-docs/docs.json b/packages/twenty-docs/docs.json
index afe9b6385ff..e3f6b123fec 100644
--- a/packages/twenty-docs/docs.json
+++ b/packages/twenty-docs/docs.json
@@ -580,6 +580,7 @@
"ui/components/input/icon-button",
"ui/components/input/light-icon-button",
"ui/components/section",
+ "ui/components/settings-row",
"ui/components/tab-button",
"ui/components/code-editor"
]
diff --git a/packages/twenty-docs/navigation/base-structure.json b/packages/twenty-docs/navigation/base-structure.json
index 59d8b7f0f86..4dc2c604a67 100644
--- a/packages/twenty-docs/navigation/base-structure.json
+++ b/packages/twenty-docs/navigation/base-structure.json
@@ -594,6 +594,7 @@
"ui/components/input/icon-button",
"ui/components/input/light-icon-button",
"ui/components/section",
+ "ui/components/settings-row",
"ui/components/tab-button",
"ui/components/code-editor"
]
diff --git a/packages/twenty-docs/snippets/ui/generated/components/settings-row.mdx b/packages/twenty-docs/snippets/ui/generated/components/settings-row.mdx
new file mode 100644
index 00000000000..70be07e03a1
--- /dev/null
+++ b/packages/twenty-docs/snippets/ui/generated/components/settings-row.mdx
@@ -0,0 +1,64 @@
+{/*
+ * _____ _
+ *|_ _|_ _____ _ __ | |_ _ _
+ * | | \ \ /\ / / _ \ '_ \| __| | | | Auto-generated file
+ * | | \ V V / __/ | | | |_| |_| | DO NOT EDIT - changes will be overwritten
+ * |_| \_/\_/ \___|_| |_|\__|\__, | Generated by: npx nx generate:ui twenty-docs
+ * |___/
+ *
+ * This file is generated from the documentation data in packages/twenty-ui/generated.
+ * To update it, edit the component prop types or design tokens in twenty-ui and run:
+ * npx nx generate:ui twenty-docs
+ */}
+
+<ParamField body="checked" type="boolean">
+ Controlled checked state of the switch.
+</ParamField>
+
+<ParamField body="children" type="ReactNode" required>
+ Visible label and accessible name of the switch. Use non-interactive content.
+</ParamField>
+
+<ParamField body="defaultChecked" type="boolean" default="false">
+ Initial checked state when uncontrolled.
+</ParamField>
+
+<ParamField body="description" type="ReactNode">
+ Non-interactive supporting content, associated with the switch as its accessible description.
+</ParamField>
+
+<ParamField body="disabled" type="boolean" default="false">
+ Disables both the row and its switch.
+</ParamField>
+
+<ParamField body="focused" type="boolean" default="false">
+ Applies the highlighted row style without moving keyboard focus.
+</ParamField>
+
+<ParamField body="name" type="string">
+ Name of the hidden checkbox used in form submission.
+</ParamField>
+
+<ParamField body="onCheckedChange" type="((checked: boolean, eventDetails: { reason: &quot;none&quot;; event: Event; cancel: () =&gt; void; allowPropagation: () =&gt; void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) =&gt; void)">
+ Called when the switch value changes, with the next checked state and Base UI event details.
+</ParamField>
+
+<ParamField body="readOnly" type="boolean" default="false">
+ Keeps the switch focusable while preventing changes.
+</ParamField>
+
+<ParamField body="required" type="boolean" default="false">
+ Requires the switch to be checked for form submission.
+</ParamField>
+
+<ParamField body="size" type="&quot;md&quot; | &quot;sm&quot;" default="sm">
+ Visual size of the switch. The row height stays the same.
+</ParamField>
+
+<ParamField body="startIcon" type="ReactNode">
+ Decorative content before the label.
+</ParamField>
+
+<ParamField body="value" type="string">
+ Value submitted when the switch is checked.
+</ParamField>
diff --git a/packages/twenty-docs/ui/components/overview.mdx b/packages/twenty-docs/ui/components/overview.mdx
index 31f690f37ba..ce3d0331f21 100644
--- a/packages/twenty-docs/ui/components/overview.mdx
+++ b/packages/twenty-docs/ui/components/overview.mdx
@@ -17,5 +17,6 @@ Import shared components from `twenty-ui/components`. The code editor has its ow
| [IconButton](/ui/components/input/icon-button) | Square or round icon actions built on Button. |
| [LightIconButton](/ui/components/input/light-icon-button) | Lightweight icon actions with standard or subtle emphasis. |
| [Section](/ui/components/section) | Related content with a heading, description, and optional action. |
+| [SettingsRow](/ui/components/settings-row) | Labeled switches for settings and filters. |
| [TabButton](/ui/components/tab-button) | Route links and adjacent actions with the same appearance as tabs. |
| [CodeEditor](/ui/components/code-editor) | Code editing with Monaco, an optional header, and the Twenty theme. |
diff --git a/packages/twenty-docs/ui/components/settings-row.mdx b/packages/twenty-docs/ui/components/settings-row.mdx
new file mode 100644
index 00000000000..59910de6d7c
--- /dev/null
+++ b/packages/twenty-docs/ui/components/settings-row.mdx
@@ -0,0 +1,90 @@
+---
+title: SettingsRow
+description: A labeled switch row for settings and filters.
+---
+
+import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
+import SettingsRowReference from '/snippets/ui/generated/components/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.
+
+<StoryEmbed
+ storyId="ui-components-settingsrow--default"
+ title="Settings row example"
+ height={160}
+/>
+
+## Controlled setting
+
+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.
+
+```tsx
+import { useState } from 'react';
+import { SettingsRow } from 'twenty-ui/components';
+import { IconBell } from 'twenty-ui/icon';
+
+export const NotificationSetting = () => {
+ const [enabled, setEnabled] = useState(false);
+
+ return (
+ <SettingsRow
+ startIcon={<IconBell aria-hidden />}
+ checked={enabled}
+ onCheckedChange={setEnabled}
+ >
+ Notifications
+ </SettingsRow>
+ );
+};
+```
+
+## Description and initial value
+
+Use `defaultChecked` for an uncontrolled setting. `description` supplies supporting text and the switch's accessible description, while the children provide its accessible name.
+
+<StoryEmbed
+ storyId="ui-components-settingsrow--with-description"
+ title="Settings row with a description"
+ height={160}
+/>
+
+```tsx
+import { SettingsRow } from 'twenty-ui/components';
+
+export const WeeklyDigestSetting = () => (
+ <SettingsRow defaultChecked description="Sent every Monday" name="digest">
+ Weekly digest
+ </SettingsRow>
+);
+```
+
+`name`, `value`, and `required` configure the switch's underlying checkbox for form submission. An unchecked switch does not submit a value.
+
+## Disabled and read-only settings
+
+Pass `disabled` once to disable both the row and switch. Use `readOnly` to prevent changes while keeping the switch focusable.
+
+```tsx
+import { SettingsRow } from 'twenty-ui/components';
+
+export const WorkspaceSettings = () => (
+ <>
+ <SettingsRow disabled>Notifications</SettingsRow>
+ <SettingsRow readOnly defaultChecked>
+ Activity history
+ </SettingsRow>
+ </>
+);
+```
+
+## Appearance and composition
+
+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.
+
+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.
+
+For navigation or action rows, use [ListItem](/ui/primitives/navigation/list-item) with a button or link.
+
+## Props
+
+<SettingsRowReference />
diff --git a/packages/twenty-docs/ui/primitives/input/switch.mdx b/packages/twenty-docs/ui/primitives/input/switch.mdx
index f664ae3e513..e2df6571ccd 100644
--- a/packages/twenty-docs/ui/primitives/input/switch.mdx
+++ b/packages/twenty-docs/ui/primitives/input/switch.mdx
@@ -56,6 +56,8 @@ export const NotificationsPreference = () => {
`onCheckedChange` receives the next boolean and event details. The `size` prop accepts `sm` or `md` and defaults to `md`.
+For a consistent full-width row with an icon, description, and switch, use [SettingsRow](/ui/components/settings-row).
+
## Keyboard and forms
Tab moves focus to the switch; Space toggles it. Clicking its associated label also toggles it. Use `disabled` to prevent interaction or `readOnly` to retain a focusable control whose value cannot be changed.
diff --git a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
index 0839538fef4..91404c46f71 100644
--- a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
+++ b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
@@ -60,6 +60,10 @@ export const DuplicateAction = ({ onDuplicate }: DuplicateActionProps) => (
The default element is a `div`. Use `render` to give an interactive row appropriate semantics, such as a button or link. `hotkeys` displays shortcut hints; your application must register the shortcuts.
+## Settings row
+
+Use [SettingsRow](/ui/components/settings-row) for a labeled switch row. It composes `ListItem` and `Switch`, manages their accessible association, and applies disabled behavior to both.
+
## Selection indicator
```tsx
diff --git a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
index d7d2e18ef14..e99c556a067 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -1,3 +1,5 @@
+import { settingsRowTest } from '@/__stories__/twenty-ui-gallery/utils/settingsRowTest';
+import { listItemTest } from '@/__stories__/twenty-ui-gallery/utils/listItemTest';
import { buttonControlsTest } from '@/__stories__/twenty-ui-gallery/utils/buttonControlsTest';
import { dialogTest } from '@/__stories__/twenty-ui-gallery/utils/dialogTest';
import { type Meta } from '@storybook/react-vite';
@@ -11,7 +13,6 @@ import {
createCheckboxTest,
createFieldControlsTest,
createRadioGroupPreactTest,
- listItemTest,
sliderTest,
toastTest,
} from '@/__stories__/twenty-ui-gallery/utils/componentInteractionTests';
@@ -232,6 +233,18 @@ export const ListItemPreact: Story = createGalleryStory({
play: listItemTest,
});
+export const SettingsRowReact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-settings-row',
+ runtime: 'react',
+ play: settingsRowTest,
+});
+
+export const SettingsRowPreact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-settings-row',
+ runtime: 'preact',
+ play: settingsRowTest,
+});
+
export const TabsReact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-tabs',
runtime: 'react',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS.ts
index 981b9f7632a..5be4295ebfd 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS.ts
@@ -5,6 +5,8 @@ export const SANDBOX_ERROR_PATTERNS = {
"Uncaught TypeError: Cannot use 'in' operator to search for 'composedPath' in undefined",
VIEWPORT_WIDTH:
"Uncaught TypeError: Cannot read properties of undefined (reading 'width')",
+ NATIVE_EVENT_DEFAULT_PREVENTED:
+ "Uncaught TypeError: Cannot read properties of undefined (reading 'defaultPrevented')",
POINTER_TYPE:
"Uncaught TypeError: Cannot read properties of undefined (reading 'pointerType')",
ELEMENT_MATCHES: /^(?:Uncaught TypeError: )?\w+\.matches is not a function$/,
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-list-item.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-list-item.front-component.tsx
index c90b546cb6e..09cdf533660 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-list-item.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-list-item.front-component.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react';
+import { createElement, useState } from 'react';
import { defineFrontComponent } from 'twenty-sdk/define';
import { ListItem } from 'twenty-ui/primitives/navigation';
@@ -6,6 +6,7 @@ import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twent
const ListItemExample = () => {
const [selected, setSelected] = useState(false);
+ const [opened, setOpened] = useState(false);
return (
<TwentyUiGalleryCard title="ListItem">
@@ -20,6 +21,16 @@ const ListItemExample = () => {
<ListItem disabled role="button" onClick={() => setSelected(true)}>
Disabled preference
</ListItem>
+ <ListItem
+ render={(renderProps) =>
+ createElement('button', { ...renderProps, type: 'button' })
+ }
+ hasSubmenu
+ onClick={() => setOpened(true)}
+ >
+ Hidden fields
+ </ListItem>
+ <p>Fields: {opened ? 'open' : 'closed'}</p>
<p role="status">Digest: {selected ? 'enabled' : 'disabled'}</p>
</TwentyUiGalleryCard>
);
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx
index 0abf0530863..4d984cf9a69 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx
@@ -13,13 +13,11 @@ import {
MenuItemMultiSelect,
MenuItemMultiSelectAvatar,
MenuItemMultiSelectTag,
- MenuItemNavigate,
MenuItemSelect,
MenuItemSelectAvatar,
MenuItemSelectColor,
MenuItemSelectTag,
MenuItemSuggestion,
- MenuItemSwitch,
MenuPicker,
NavigationBar,
NavigationBarItem,
@@ -32,6 +30,7 @@ import {
StyledMenuItemLeftContent,
StyledMenuItemSelect,
UndecoratedLink,
+ ListItem,
} from 'twenty-ui/primitives/navigation';
import { ThemeProvider } from 'twenty-ui/theme-constants';
@@ -134,13 +133,16 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
),
},
{
- name: 'MenuItemNavigate',
+ name: 'ListItem navigation',
node: (
- <MenuItemNavigate
- text="Navigate"
- LeftIcon={IconUser}
+ <ListItem
+ startIcon={<IconUser />}
onClick={() => {}}
- />
+ render={<button type="button" />}
+ hasSubmenu
+ >
+ Navigate
+ </ListItem>
),
},
{
@@ -182,12 +184,6 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
name: 'MenuItemSuggestion',
node: <MenuItemSuggestion text="Suggestion" onClick={() => {}} />,
},
- {
- name: 'MenuItemSwitch',
- node: (
- <MenuItemSwitch text="Switch" checked={true} onCheckedChange={() => {}} />
- ),
- },
{
name: 'MenuPicker',
node: <MenuPicker id="picker-1" icon={IconHome} label="Picker" />,
diff --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.tsx
new file mode 100644
index 00000000000..027dddb91e6
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-settings-row.front-component.tsx
@@ -0,0 +1,44 @@
+import { useState } from 'react';
+import { defineFrontComponent } from 'twenty-sdk/define';
+import { SettingsRow } from 'twenty-ui/components';
+import { IconBell } from 'twenty-ui/icon';
+
+import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';
+
+const SettingsRowExample = () => {
+ const [notifications, setNotifications] = useState(false);
+ const [changes, setChanges] = useState(0);
+
+ return (
+ <TwentyUiGalleryCard title="SettingsRow">
+ <SettingsRow
+ startIcon={<IconBell aria-hidden />}
+ description="Updates by email"
+ checked={notifications}
+ onCheckedChange={(checked) => {
+ setNotifications(checked);
+ setChanges((count) => count + 1);
+ }}
+ >
+ Notifications
+ </SettingsRow>
+ <SettingsRow
+ disabled
+ onCheckedChange={() => setChanges((count) => count + 1)}
+ >
+ Disabled notifications
+ </SettingsRow>
+ <p role="status">
+ Notifications: {notifications ? 'enabled' : 'disabled'}; Changes:{' '}
+ {changes}
+ </p>
+ </TwentyUiGalleryCard>
+ );
+};
+
+export default defineFrontComponent({
+ universalIdentifier: '68a0e63b-fd20-4515-a733-96f457ceba71',
+ name: 'twenty-ui-settings-row',
+ description: 'SettingsRow labels and disabled behavior in the sandbox',
+ component: SettingsRowExample,
+});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/componentInteractionTests.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/componentInteractionTests.ts
index 1aeb8a5873a..911c64e1d36 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/componentInteractionTests.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/componentInteractionTests.ts
@@ -102,27 +102,6 @@ export const createFieldControlsTest =
});
};
-export const listItemTest: TwentyUiGalleryPlayFunction = async ({
- canvasElement,
-}) => {
- const canvas = within(canvasElement);
- await expectFrontComponentMounted(canvas);
-
- const digest = canvas.getByText('Weekly digest');
-
- await userEvent.click(digest);
- await waitFor(() =>
- expect(canvas.getByRole('status')).toHaveTextContent('Digest: enabled'),
- );
- await userEvent.click(digest);
- await waitFor(() =>
- expect(canvas.getByRole('status')).toHaveTextContent('Digest: disabled'),
- );
- await userEvent.click(canvas.getByText('Disabled preference'));
- expect(canvas.getByRole('status')).toHaveTextContent('Digest: disabled');
- expect(errorHandler).not.toHaveBeenCalled();
-};
-
export const toastTest: TwentyUiGalleryPlayFunction = async ({
canvasElement,
}) => {
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemTest.ts
new file mode 100644
index 00000000000..b1672553314
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemTest.ts
@@ -0,0 +1,29 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const listItemTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ await expectFrontComponentMounted(canvas);
+
+ const digest = canvas.getByText('Weekly digest');
+
+ await userEvent.click(digest);
+ await waitFor(() =>
+ expect(canvas.getByRole('status')).toHaveTextContent('Digest: enabled'),
+ );
+ await userEvent.click(digest);
+ await waitFor(() =>
+ expect(canvas.getByRole('status')).toHaveTextContent('Digest: disabled'),
+ );
+ await userEvent.click(canvas.getByText('Disabled preference'));
+ expect(canvas.getByRole('status')).toHaveTextContent('Digest: disabled');
+ const hiddenFields = canvas.getByRole('button', { name: 'Hidden fields' });
+ await userEvent.click(hiddenFields);
+ await waitFor(() => expect(canvas.getByText('Fields: open')).toBeVisible());
+ expect(errorHandler).not.toHaveBeenCalled();
+};
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.ts
new file mode 100644
index 00000000000..3b69e3942a1
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/settingsRowTest.ts
@@ -0,0 +1,30 @@
+import { expect, userEvent, within } from 'storybook/test';
+
+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
+import { SANDBOX_ERROR_PATTERNS } from '@/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS';
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+import { expectSandboxErrors } from '@/__stories__/twenty-ui-gallery/utils/expectSandboxErrors';
+
+export const settingsRowTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ await expectFrontComponentMounted(canvas);
+
+ await expect(
+ canvas.getByRole('switch', { name: 'Notifications' }),
+ ).toHaveAccessibleDescription('Updates by email');
+ await userEvent.click(canvas.getByText('Disabled notifications'));
+ await userEvent.click(
+ canvas.getByRole('switch', { name: 'Disabled notifications' }),
+ );
+ await expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Notifications: disabled; Changes: 0',
+ );
+
+ await userEvent.click(canvas.getByText('Notifications'));
+
+ await expectSandboxErrors({
+ requiredErrors: [SANDBOX_ERROR_PATTERNS.NATIVE_EVENT_DEFAULT_PREVENTED],
+ });
+};
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.tsx
index 945a6ee0e11..4a257e8e771 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
@@ -8,8 +8,9 @@ import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown';
import { useLingui } from '@lingui/react/macro';
import { type ReactElement } from 'react';
import { isDefined } from 'twenty-shared/utils';
+import { SettingsRow } from 'twenty-ui/components';
import { IconRefresh, IconTag } from 'twenty-ui/icon';
-import { MenuItem, MenuItemSwitch } from 'twenty-ui/primitives/navigation';
+import { MenuItem } from 'twenty-ui/primitives/navigation';
import { type CommandMenuItemFieldsFragment } from '~/generated-metadata/graphql';
type CommandMenuItemOptionsDropdownProps = Pick<
@@ -62,14 +63,12 @@ export const CommandMenuItemOptionsDropdown = ({
dropdownComponents={
<DropdownContent widthInPixels={GenericDropdownContentWidth.Medium}>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconTag}
- text={t`Hide label`}
+ <SettingsRow
+ startIcon={<IconTag />}
+ disabled={hasNoShortLabel}
checked={isLabelHidden || hasNoShortLabel}
onCheckedChange={handleHiddenLabelChange}
- size="sm"
- disabled={hasNoShortLabel}
- />
+ >{t`Hide label`}</SettingsRow>
<MenuItem
LeftIcon={IconRefresh}
onClick={handleResetToDefault}
diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemSwitch.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemSwitch.tsx
index 0d9b10dd9ed..06bf6d52ebe 100644
--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemSwitch.tsx
+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemSwitch.tsx
@@ -1,26 +1,68 @@
import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';
import { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';
-import {
- MenuItemSwitch,
- type MenuItemSwitchProps,
-} from 'twenty-ui/primitives/navigation';
+import { styled } from '@linaria/react';
+import { SettingsRow, type SettingsRowProps } from 'twenty-ui/components';
+import { themeCssVariables } from 'twenty-ui/theme-constants';
+import { isDefined } from 'twenty-shared/utils';
+import { type IconComponent } from 'twenty-ui/icon';
-export type CommandMenuItemSwitchProps = MenuItemSwitchProps & {
+type CommandMenuItemSwitchProps = {
id: string;
+ LeftIcon?: IconComponent;
+ text: string;
+ checked: boolean;
+ onCheckedChange?: SettingsRowProps['onCheckedChange'];
+ size?: SettingsRowProps['size'];
+ disabled?: boolean;
+ className?: string;
};
-export const CommandMenuItemSwitch = (props: CommandMenuItemSwitchProps) => {
+const StyledIconContainer = styled.span`
+ align-items: center;
+ background: ${themeCssVariables.background.transparent.light};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ display: flex;
+ padding: ${themeCssVariables.spacing[1]};
+
+ svg {
+ height: ${themeCssVariables.icon.size.md}px;
+ stroke-width: ${themeCssVariables.icon.stroke.sm};
+ width: ${themeCssVariables.icon.size.md}px;
+ }
+`;
+
+export const CommandMenuItemSwitch = ({
+ id,
+ LeftIcon,
+ text,
+ checked,
+ onCheckedChange,
+ size = 'md',
+ disabled = false,
+ className,
+}: CommandMenuItemSwitchProps) => {
const isSelectedItemId = useAtomComponentFamilyStateValue(
isSelectedItemIdComponentFamilyState,
- props.id,
+ id,
);
return (
- <MenuItemSwitch
- // oxlint-disable-next-line react/jsx-props-no-spreading
- {...props}
+ <SettingsRow
+ className={className}
focused={isSelectedItemId}
- withIconContainer
- />
+ disabled={disabled}
+ startIcon={
+ isDefined(LeftIcon) && (
+ <StyledIconContainer>
+ <LeftIcon />
+ </StyledIconContainer>
+ )
+ }
+ checked={checked}
+ onCheckedChange={onCheckedChange}
+ size={size}
+ >
+ {text}
+ </SettingsRow>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownFieldsContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownFieldsContent.tsx
index 7de583ae3bb..34d2efba362 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownFieldsContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownFieldsContent.tsx
@@ -11,7 +11,7 @@ import { useLingui } from '@lingui/react/macro';
import { isNonEmptyString } from '@sniptt/guards';
import { useState } from 'react';
import { IconChevronLeft, IconEyeOff } from 'twenty-ui/icon';
-import { MenuItemNavigate } from 'twenty-ui/primitives/navigation';
+import { ListItem } from 'twenty-ui/primitives/navigation';
export const ObjectOptionsDropdownFieldsContent = () => {
const { t } = useLingui();
@@ -45,11 +45,12 @@ export const ObjectOptionsDropdownFieldsContent = () => {
<ViewFieldsVisibleDropdownSection />
<DropdownMenuSeparator />
<DropdownMenuItemsContainer scrollable={false}>
- <MenuItemNavigate
+ <ListItem
onClick={() => onContentChange('hiddenFields')}
- LeftIcon={IconEyeOff}
- text={t`Hidden Fields`}
- />
+ startIcon={<IconEyeOff />}
+ render={<button type="button" />}
+ hasSubmenu
+ >{t`Hidden Fields`}</ListItem>
</DropdownMenuItemsContainer>
</>
)}
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.tsx
index 01f5ff3e342..e333b41e779 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
@@ -25,6 +25,7 @@ import { useGetAvailableFieldsToGroupRecordsBy } from '@/views/view-picker/hooks
import { useLingui } from '@lingui/react/macro';
import { useCallback } from 'react';
import { isDefined } from 'twenty-shared/utils';
+import { SettingsRow } from 'twenty-ui/components';
import {
IconBaselineDensitySmall,
IconCalendar,
@@ -34,11 +35,7 @@ import {
IconTable,
} from 'twenty-ui/icon';
import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/surfaces';
-import {
- MenuItem,
- MenuItemSelect,
- MenuItemSwitch,
-} from 'twenty-ui/primitives/navigation';
+import { MenuItem, MenuItemSelect } from 'twenty-ui/primitives/navigation';
import { ViewCalendarLayout } from '~/generated-metadata/graphql';
export const ObjectOptionsDropdownLayoutContent = () => {
@@ -307,9 +304,9 @@ export const ObjectOptionsDropdownLayoutContent = () => {
);
}}
>
- <MenuItemSwitch
+ <SettingsRow
focused={selectedItemId === 'Compact view'}
- LeftIcon={IconBaselineDensitySmall}
+ startIcon={<IconBaselineDensitySmall />}
onCheckedChange={() =>
setAndPersistIsCompactModeActive(
!isCompactModeActive,
@@ -317,9 +314,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
)
}
checked={isCompactModeActive}
- text={t`Compact view`}
- size="sm"
- />
+ >{t`Compact view`}</SettingsRow>
</SelectableListItem>
)}
</DropdownMenuItemsContainer>
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.tsx
index c1b19b39c75..202ff23ba46 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
@@ -1,5 +1,4 @@
import { useEffect } from 'react';
-
import { isManyToOneRelationField } from '@/object-metadata/utils/isManyToOneRelationField';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
import { RecordGroupsVisibilityDropdownSection } from '@/object-record/record-group/components/RecordGroupsVisibilityDropdownSection';
@@ -25,6 +24,7 @@ import { useGetCurrentViewOnly } from '@/views/hooks/useGetCurrentViewOnly';
import { useGetAvailableFieldsToGroupRecordsBy } from '@/views/view-picker/hooks/useGetAvailableFieldsToGroupRecordsBy';
import { useLingui } from '@lingui/react/macro';
import { isDefined } from 'twenty-shared/utils';
+import { SettingsRow } from 'twenty-ui/components';
import {
IconArrowsSort,
IconChevronLeft,
@@ -33,11 +33,7 @@ import {
IconLayoutList,
IconPlus,
} from 'twenty-ui/icon';
-import {
- MenuItem,
- MenuItemNavigate,
- MenuItemSwitch,
-} from 'twenty-ui/primitives/navigation';
+import { MenuItem, ListItem } from 'twenty-ui/primitives/navigation';
export const ObjectOptionsDropdownRecordGroupsContent = () => {
const { t } = useLingui();
@@ -173,14 +169,12 @@ export const ObjectOptionsDropdownRecordGroupsContent = () => {
itemId="HideEmptyGroups"
onEnter={() => handleHideEmptyRecordGroupChange()}
>
- <MenuItemSwitch
+ <SettingsRow
focused={selectedItemId === 'HideEmptyGroups'}
- LeftIcon={IconCircleOff}
+ startIcon={<IconCircleOff />}
onCheckedChange={handleHideEmptyRecordGroupChange}
checked={shouldHideEmptyGroups}
- text={t`Hide empty groups`}
- size="sm"
- />
+ >{t`Hide empty groups`}</SettingsRow>
</SelectableListItem>
</SelectableList>
</DropdownMenuItemsContainer>
@@ -222,11 +216,12 @@ export const ObjectOptionsDropdownRecordGroupsContent = () => {
itemId="HiddenGroups"
onEnter={() => onContentChange('hiddenRecordGroups')}
>
- <MenuItemNavigate
+ <ListItem
onClick={() => onContentChange('hiddenRecordGroups')}
- LeftIcon={IconEyeOff}
- text={`${t`Hidden`} ${recordIndexGroupFieldMetadataItem?.label ?? ''}`}
- />
+ startIcon={<IconEyeOff />}
+ render={<button type="button" />}
+ hasSubmenu
+ >{`${t`Hidden`} ${recordIndexGroupFieldMetadataItem?.label ?? ''}`}</ListItem>
</SelectableListItem>
</SelectableList>
</DropdownMenuItemsContainer>
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.tsx
index cffea1e2c58..6ddd9f2957c 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
@@ -21,7 +21,7 @@ import {
getSettingsPath,
isDefined,
} from 'twenty-shared/utils';
-import { Section } from 'twenty-ui/components';
+import { SettingsRow, Section } from 'twenty-ui/components';
import {
IconChevronRight,
IconDotsVertical,
@@ -31,7 +31,6 @@ import {
import { Tag } from 'twenty-ui/primitives/data-display';
import { useToast } from 'twenty-ui/primitives/feedback';
import { Button, SearchInput } from 'twenty-ui/primitives/input';
-import { MenuItemSwitch } from 'twenty-ui/primitives/navigation';
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
import { useDebounce } from 'use-debounce';
import {
@@ -218,69 +217,59 @@ export const SettingsAdminApps = () => {
dropdownComponents={
<DropdownContent>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconPinned}
+ <SettingsRow
+ startIcon={<IconPinned />}
onCheckedChange={() =>
setShowPreInstalledOnly(!showPreInstalledOnly)
}
checked={showPreInstalledOnly}
- text={t`Pre-installed only`}
- size="sm"
- />
+ >{t`Pre-installed only`}</SettingsRow>
<DropdownMenuSectionLabel label={t`Source`} />
{SOURCE_TYPE_FILTER_OPTIONS.map(({ sourceType, label }) => (
- <MenuItemSwitch
+ <SettingsRow
key={sourceType}
onCheckedChange={() =>
toggleSourceTypeFilter(sourceType)
}
checked={sourceTypeFilters.includes(sourceType)}
- text={label}
- size="sm"
- />
+ >
+ {label}
+ </SettingsRow>
))}
<DropdownMenuSectionLabel label={t`Listed`} />
- <MenuItemSwitch
+ <SettingsRow
onCheckedChange={() =>
setIsListedFilter(
isListedFilter === true ? undefined : true,
)
}
checked={isListedFilter === true}
- text={t`Listed`}
- size="sm"
- />
- <MenuItemSwitch
+ >{t`Listed`}</SettingsRow>
+ <SettingsRow
onCheckedChange={() =>
setIsListedFilter(
isListedFilter === false ? undefined : false,
)
}
checked={isListedFilter === false}
- text={t`Not listed`}
- size="sm"
- />
+ >{t`Not listed`}</SettingsRow>
<DropdownMenuSectionLabel label={t`Configured`} />
- <MenuItemSwitch
+ <SettingsRow
onCheckedChange={() =>
setIsConfiguredFilter(
isConfiguredFilter === true ? undefined : true,
)
}
checked={isConfiguredFilter === true}
- text={t`Configured`}
- size="sm"
- />
- <MenuItemSwitch
+ >{t`Configured`}</SettingsRow>
+ <SettingsRow
onCheckedChange={() =>
setIsConfiguredFilter(
isConfiguredFilter === false ? undefined : false,
)
}
checked={isConfiguredFilter === false}
- text={t`Not configured`}
- size="sm"
- />
+ >{t`Not configured`}</SettingsRow>
</DropdownMenuItemsContainer>
</DropdownContent>
}
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.tsx
index 15b41a7406e..44f53e82fa5 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
@@ -1,9 +1,7 @@
import { t } from '@lingui/core/macro';
import { type ReactNode } from 'react';
-
+import { SettingsRow } from 'twenty-ui/components';
import { IconAlertTriangle, IconMessage, IconSparkles } from 'twenty-ui/icon';
-import { MenuItemSwitch } from 'twenty-ui/primitives/navigation';
-
import { type AdminChatsFilterState } from '@/settings/admin-panel/chats/types/AdminChatsFilterState';
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';
@@ -29,8 +27,8 @@ export const SettingsAdminChatsFilterDropdown = ({
dropdownComponents={
<DropdownContent>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconSparkles}
+ <SettingsRow
+ startIcon={<IconSparkles />}
onCheckedChange={() =>
onFiltersChange({
...filters,
@@ -38,11 +36,9 @@ export const SettingsAdminChatsFilterDropdown = ({
})
}
checked={filters.onboardingOnly}
- text={t`Onboarding only`}
- size="sm"
- />
- <MenuItemSwitch
- LeftIcon={IconAlertTriangle}
+ >{t`Onboarding only`}</SettingsRow>
+ <SettingsRow
+ startIcon={<IconAlertTriangle />}
onCheckedChange={() =>
onFiltersChange({
...filters,
@@ -50,11 +46,9 @@ export const SettingsAdminChatsFilterDropdown = ({
})
}
checked={filters.hasErrorOnly}
- text={t`Has error`}
- size="sm"
- />
- <MenuItemSwitch
- LeftIcon={IconMessage}
+ >{t`Has error`}</SettingsRow>
+ <SettingsRow
+ startIcon={<IconMessage />}
onCheckedChange={() =>
onFiltersChange({
...filters,
@@ -62,9 +56,7 @@ export const SettingsAdminChatsFilterDropdown = ({
})
}
checked={filters.userNeverEngagedOnly}
- text={t`No user reply`}
- size="sm"
- />
+ >{t`No user reply`}</SettingsRow>
</DropdownMenuItemsContainer>
</DropdownContent>
}
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.tsx
index 6d71752a338..ecab1ce1a07 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
@@ -21,9 +21,9 @@ import { msg } from '@lingui/core/macro';
import { useLingui } from '@lingui/react/macro';
import { useMemo, useState } from 'react';
import { FieldMetadataType } from 'twenty-shared/types';
+import { SettingsRow } from 'twenty-ui/components';
import { IconArchive, IconFilter, IconSearch } from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
-import { MenuItemSwitch } from 'twenty-ui/primitives/navigation';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import { isDefined } from 'twenty-shared/utils';
import { normalizeSearchText } from '~/utils/normalizeSearchText';
@@ -216,13 +216,11 @@ export const SettingsObjectRelationsTable = ({
dropdownComponents={
<DropdownContent>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconArchive}
+ <SettingsRow
+ startIcon={<IconArchive />}
onCheckedChange={() => setShowInactive(!showInactive)}
checked={showInactive}
- text={t`Inactive`}
- size="sm"
- />
+ >{t`Inactive`}</SettingsRow>
</DropdownMenuItemsContainer>
</DropdownContent>
}
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.tsx
index a5fc42c8762..aa582c83e15 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
@@ -1,5 +1,4 @@
import { NavigationButton } from '@/ui/input/components/NavigationButton';
-
import { useDeleteOneIndexMetadataItem } from '@/object-metadata/hooks/useDeleteOneIndexMetadataItem';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
@@ -18,10 +17,10 @@ import { type ReactNode, useMemo, useState } from 'react';
import { MAX_CUSTOM_INDEXES_PER_OBJECT } from 'twenty-shared/constants';
import { SettingsPath } from 'twenty-shared/types';
import { getSettingsPath, isDefined } from 'twenty-shared/utils';
+import { SettingsRow } from 'twenty-ui/components';
import { useToast } from 'twenty-ui/primitives/feedback';
import { IconEyeOff, IconPlus } from 'twenty-ui/icon';
import { Button, SearchInput } from 'twenty-ui/primitives/input';
-import { MenuItemSwitch } from 'twenty-ui/primitives/navigation';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import { SettingsObjectIndexTable } from '~/pages/settings/data-model/SettingsObjectIndexTable';
import { type SettingsObjectIndexesTableItem } from '~/pages/settings/data-model/types/SettingsObjectIndexesTableItem';
@@ -175,15 +174,13 @@ export const SettingsObjectIndexesSection = ({
dropdownComponents={
<DropdownContent>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconEyeOff}
+ <SettingsRow
+ startIcon={<IconEyeOff />}
onCheckedChange={() =>
setHideSystemIndexes(!hideSystemIndexes)
}
checked={hideSystemIndexes}
- text={t`Hide system indexes`}
- size="sm"
- />
+ >{t`Hide system indexes`}</SettingsRow>
</DropdownMenuItemsContainer>
</DropdownContent>
}
diff --git a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx
index 20b472eec63..65d20dd5990 100644
--- a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx
+++ b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx
@@ -4,7 +4,6 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop
import { Table } from '@/ui/layout/table/components/Table';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
-
import { SettingsRolesTableHeader } from '@/settings/roles/components/SettingsRolesTableHeader';
import { SettingsRolesTableRow } from '@/settings/roles/components/SettingsRolesTableRow';
import { useSettingsAllRoles } from '@/settings/roles/hooks/useSettingsAllRoles';
@@ -12,7 +11,7 @@ import { SettingsTextInput } from '@/ui/input/components/SettingsTextInput';
import { TableCell } from '@/ui/layout/table/components/TableCell';
import { useState } from 'react';
import { SettingsPath } from 'twenty-shared/types';
-import { Section } from 'twenty-ui/components';
+import { SettingsRow, Section } from 'twenty-ui/components';
import {
IconFilter,
IconKey,
@@ -21,7 +20,6 @@ import {
IconSearch,
} from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
-import { MenuItemSwitch } from 'twenty-ui/primitives/navigation';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
import { sortByAscString } from '~/utils/array/sortByAscString';
@@ -109,20 +107,16 @@ export const SettingsRolesList = () => {
dropdownComponents={
<DropdownContent>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconLego}
+ <SettingsRow
+ startIcon={<IconLego />}
onCheckedChange={() => setShowAgentRoles(!showAgentRoles)}
checked={showAgentRoles}
- text={t`Agent roles`}
- size="sm"
- />
- <MenuItemSwitch
- LeftIcon={IconKey}
+ >{t`Agent roles`}</SettingsRow>
+ <SettingsRow
+ startIcon={<IconKey />}
onCheckedChange={() => setShowApiKeyRoles(!showApiKeyRoles)}
checked={showApiKeyRoles}
- text={t`API key roles`}
- size="sm"
- />
+ >{t`API key roles`}</SettingsRow>
</DropdownMenuItemsContainer>
</DropdownContent>
}
diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx
index 1dde6976e15..bcb3a4f79a8 100644
--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx
@@ -1,13 +1,10 @@
import { useLingui } from '@lingui/react/macro';
import { useState } from 'react';
import { OBJECTS_WITH_CHANNEL_VISIBILITY_CONSTRAINTS } from 'twenty-shared/constants';
+import { SettingsRow } from 'twenty-ui/components';
import { TintedIconTile } from 'twenty-ui/primitives/data-display';
import { IconCube } from 'twenty-ui/icon';
-import {
- MenuItemSelectAvatar,
- MenuItemSwitch,
-} from 'twenty-ui/primitives/navigation';
-
+import { MenuItemSelectAvatar } from 'twenty-ui/primitives/navigation';
import { ObjectMetadataIcon } from '@/object-metadata/components/ObjectMetadataIcon';
import { useReadableObjectMetadataItems } from '@/object-metadata/hooks/useReadableObjectMetadataItems';
import { OBJECT_FILTER_DROPDOWN_ID } from '@/side-panel/components/SidePanelObjectFilterDropdown';
@@ -130,15 +127,13 @@ export const SidePanelObjectFilterDropdownContent = ({
</SelectableList>
<DropdownMenuSeparator />
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconCube}
+ <SettingsRow
+ startIcon={<IconCube />}
onCheckedChange={() =>
setSidePanelShowHiddenObjects(!sidePanelShowHiddenObjects)
}
checked={sidePanelShowHiddenObjects}
- text={t`Show hidden objects`}
- size="sm"
- />
+ >{t`Show hidden objects`}</SettingsRow>
</DropdownMenuItemsContainer>
</DropdownContent>
);
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx
index 423dcca25f5..f93aba2c48a 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx
@@ -15,10 +15,7 @@ import { type DraggableListDropResult } from '@/ui/layout/draggable-list/types/D
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
import { IconEyeOff, useIcons } from 'twenty-ui/icon';
-import {
- MenuItemDraggable,
- MenuItemNavigate,
-} from 'twenty-ui/primitives/navigation';
+import { MenuItemDraggable, ListItem } from 'twenty-ui/primitives/navigation';
import { sortByProperty } from '~/utils/array/sortByProperty';
type RecordTableFieldsDropdownVisibleFieldsContentProps = {
@@ -158,11 +155,12 @@ export const RecordTableFieldsDropdownVisibleFieldsContent = ({
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />
<DropdownMenuItemsContainer scrollable={false}>
- <MenuItemNavigate
+ <ListItem
onClick={onShowHiddenFields}
- LeftIcon={IconEyeOff}
- text={t`Hidden Fields`}
- />
+ startIcon={<IconEyeOff />}
+ render={<button type="button" />}
+ hasSubmenu
+ >{t`Hidden Fields`}</ListItem>
</DropdownMenuItemsContainer>
</DropdownContent>
);
diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsx
index 4cba6aa103d..4c01311d5fb 100644
--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsx
+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTab.tsx
@@ -1,4 +1,4 @@
-import { Section } from 'twenty-ui/components';
+import { SettingsRow, Section } from 'twenty-ui/components';
import { useToast } from 'twenty-ui/primitives/feedback';
import { getApplicationDisplayName } from '@/applications/utils/getApplicationDisplayName';
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
@@ -13,9 +13,7 @@ import { useLingui } from '@lingui/react/macro';
import { useMemo, useState } from 'react';
import { IconArchive, IconSettings } from 'twenty-ui/icon';
import { SearchInput } from 'twenty-ui/primitives/input';
-import { MenuItemSwitch } from 'twenty-ui/primitives/navigation';
import { themeCssVariables } from 'twenty-ui/theme-constants';
-
import { useMutation, useQuery } from '@apollo/client/react';
import { isDefined } from 'twenty-shared/utils';
import {
@@ -139,21 +137,17 @@ export const SettingsAgentSkillsTab = () => {
dropdownComponents={
<DropdownContent>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconArchive}
+ <SettingsRow
+ startIcon={<IconArchive />}
onCheckedChange={setShowDeactivated}
checked={showDeactivated}
- text={t`Deactivated`}
- size="sm"
- />
+ >{t`Deactivated`}</SettingsRow>
{isAdvancedModeEnabled && (
- <MenuItemSwitch
- LeftIcon={IconSettings}
+ <SettingsRow
+ startIcon={<IconSettings />}
onCheckedChange={setShowSystemSkills}
checked={showSystemSkills}
- text={t`System skills`}
- size="sm"
- />
+ >{t`System skills`}</SettingsRow>
)}
</DropdownMenuItemsContainer>
</DropdownContent>
diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsx
index 84738ba8f02..f8ca6e63cd6 100644
--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsx
+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentToolsTab.tsx
@@ -1,15 +1,13 @@
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { type ReactNode, useState } from 'react';
-
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { isDefined } from 'twenty-shared/utils';
-import { Section } from 'twenty-ui/components';
+import { SettingsRow, Section } from 'twenty-ui/components';
import { IconLock, IconPuzzle, IconTool } from 'twenty-ui/icon';
import { SearchInput } from 'twenty-ui/primitives/input';
-import { MenuItemSwitch } from 'twenty-ui/primitives/navigation';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import { SettingsAgentToolsTable } from '~/pages/settings/ai/components/SettingsAgentToolsTable';
import { useSettingsAgentToolsTable } from '~/pages/settings/ai/hooks/useSettingsAgentToolsTable';
@@ -94,27 +92,21 @@ export const SettingsAgentToolsTab = () => {
dropdownComponents={
<DropdownContent>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconTool}
+ <SettingsRow
+ startIcon={<IconTool />}
onCheckedChange={setShowCustomTools}
checked={showCustomTools}
- text={t`Custom`}
- size="sm"
- />
- <MenuItemSwitch
- LeftIcon={IconLock}
+ >{t`Custom`}</SettingsRow>
+ <SettingsRow
+ startIcon={<IconLock />}
onCheckedChange={setShowManagedTools}
checked={showManagedTools}
- text={t`Managed`}
- size="sm"
- />
- <MenuItemSwitch
- LeftIcon={IconPuzzle}
+ >{t`Managed`}</SettingsRow>
+ <SettingsRow
+ startIcon={<IconPuzzle />}
onCheckedChange={setShowStandardTools}
checked={showStandardTools}
- text={t`Standard`}
- size="sm"
- />
+ >{t`Standard`}</SettingsRow>
</DropdownMenuItemsContainer>
</DropdownContent>
}
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx
index dca86d4079f..aecf4f9da4f 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx
@@ -5,11 +5,10 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { type ReactNode, useState } from 'react';
-import { Section } from 'twenty-ui/components';
+import { SettingsRow, Section } from 'twenty-ui/components';
import { InlineBanner } from 'twenty-ui/primitives/feedback';
import { IconSparkles } from 'twenty-ui/icon';
import { SearchInput } from 'twenty-ui/primitives/input';
-import { MenuItemSwitch } from 'twenty-ui/primitives/navigation';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import { useMarketplaceApps } from '~/modules/marketplace/hooks/useMarketplaceApps';
import { SettingsAvailableApplicationCard } from '~/pages/settings/applications/components/SettingsAvailableApplicationCard';
@@ -106,13 +105,11 @@ export const SettingsApplicationsAvailableTab = () => {
dropdownComponents={
<DropdownContent>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconSparkles}
+ <SettingsRow
+ startIcon={<IconSparkles />}
onCheckedChange={() => setShowVettedOnly(!showVettedOnly)}
checked={showVettedOnly}
- text={t`Vetted only`}
- size="sm"
- />
+ >{t`Vetted only`}</SettingsRow>
</DropdownMenuItemsContainer>
</DropdownContent>
}
diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldTable.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldTable.tsx
index b45dc0e4f4e..62a13158e4a 100644
--- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldTable.tsx
+++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldTable.tsx
@@ -25,9 +25,9 @@ import { useAtomFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAto
import { useSetAtomFamilyState } from '@/ui/utilities/state/jotai/hooks/useSetAtomFamilyState';
import { useEffect, useMemo, useState } from 'react';
import { FieldMetadataType } from 'twenty-shared/types';
+import { SettingsRow } from 'twenty-ui/components';
import { IconArchive, IconCircleDashed, IconSettings } from 'twenty-ui/icon';
import { SearchInput } from 'twenty-ui/primitives/input';
-import { MenuItemSwitch } from 'twenty-ui/primitives/navigation';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import { useMostlyEmptyFieldMetadataIds } from '@/settings/data-model/object-details/hooks/useMostlyEmptyFieldMetadataIds';
import { useMapFieldMetadataItemToSettingsObjectDetailTableItem } from '~/pages/settings/data-model/hooks/useMapFieldMetadataItemToSettingsObjectDetailTableItem';
@@ -183,35 +183,29 @@ export const SettingsObjectFieldTable = ({
dropdownComponents={
<DropdownContent>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconArchive}
+ <SettingsRow
+ startIcon={<IconArchive />}
onCheckedChange={() => setShowInactive(!showInactive)}
checked={showInactive}
- text={t`Inactive`}
- size="sm"
- />
+ >{t`Inactive`}</SettingsRow>
{(mostlyEmptyFieldMetadataIds.size > 0 ||
showOnlyMostlyEmpty) && (
- <MenuItemSwitch
- LeftIcon={IconCircleDashed}
+ <SettingsRow
+ startIcon={<IconCircleDashed />}
onCheckedChange={() =>
setShowOnlyMostlyEmpty(!showOnlyMostlyEmpty)
}
checked={showOnlyMostlyEmpty}
- text={t`Mostly empty`}
- size="sm"
- />
+ >{t`Mostly empty`}</SettingsRow>
)}
{isAdvancedModeEnabled && (
- <MenuItemSwitch
- LeftIcon={IconSettings}
+ <SettingsRow
+ startIcon={<IconSettings />}
onCheckedChange={() =>
setShowSystemFields(!showSystemFields)
}
checked={showSystemFields}
- text={t`System fields`}
- size="sm"
- />
+ >{t`System fields`}</SettingsRow>
)}
</DropdownMenuItemsContainer>
</DropdownContent>
diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsx
index 81390f29e38..3de0a83a3c7 100644
--- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsx
+++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectTable.tsx
@@ -30,9 +30,9 @@ import { useLingui } from '@lingui/react/macro';
import { type ReactNode, useContext, useMemo, useState } from 'react';
import { SettingsPath } from 'twenty-shared/types';
import { getSettingsPath } from 'twenty-shared/utils';
+import { SettingsRow } from 'twenty-ui/components';
import { IconArchive, IconChevronRight, IconSettings } from 'twenty-ui/icon';
import { SearchInput } from 'twenty-ui/primitives/input';
-import { MenuItemSwitch } from 'twenty-ui/primitives/navigation';
import {
MOBILE_VIEWPORT,
ThemeContext,
@@ -176,25 +176,21 @@ export const SettingsObjectTable = ({
dropdownComponents={
<DropdownContent>
<DropdownMenuItemsContainer>
- <MenuItemSwitch
- LeftIcon={IconArchive}
+ <SettingsRow
+ startIcon={<IconArchive />}
onCheckedChange={() =>
setShowDeactivated(!showDeactivated)
}
checked={showDeactivated}
- text={t`Deactivated`}
- size="sm"
- />
+ >{t`Deactivated`}</SettingsRow>
{isAdvancedModeEnabled && (
- <MenuItemSwitch
- LeftIcon={IconSettings}
+ <SettingsRow
+ startIcon={<IconSettings />}
onCheckedChange={() =>
setShowSystemObjects(!showSystemObjects)
}
checked={showSystemObjects}
- text={t`System objects`}
- size="sm"
- />
+ >{t`System objects`}</SettingsRow>
)}
</DropdownMenuItemsContainer>
</DropdownContent>
diff --git a/packages/twenty-shared/src/constants/DocumentationPaths.ts b/packages/twenty-shared/src/constants/DocumentationPaths.ts
index e836ca8cfc2..00c18cc6a0a 100644
--- a/packages/twenty-shared/src/constants/DocumentationPaths.ts
+++ b/packages/twenty-shared/src/constants/DocumentationPaths.ts
@@ -136,6 +136,7 @@ export const DOCUMENTATION_PATHS = {
UI_COMPONENTS_INPUT_MAIN_BUTTON: '/ui/components/input/main-button',
UI_COMPONENTS_OVERVIEW: '/ui/components/overview',
UI_COMPONENTS_SECTION: '/ui/components/section',
+ UI_COMPONENTS_SETTINGS_ROW: '/ui/components/settings-row',
UI_COMPONENTS_TAB_BUTTON: '/ui/components/tab-button',
UI_DARK_MODE: '/ui/dark-mode',
UI_GETTING_STARTED: '/ui/getting-started',
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 4ef94598545..10ec5b016ae 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -12,6 +12,7 @@ import { HEADING_PROP_DESCRIPTIONS } from './headingPropDescriptions';
import { LIGHT_BUTTON_PROP_DESCRIPTIONS } from './lightButtonPropDescriptions';
import { SECTION_HEADER_PROP_DESCRIPTIONS } from './sectionHeaderPropDescriptions';
import { SECTION_ROOT_PROP_DESCRIPTIONS } from './sectionRootPropDescriptions';
+import { SETTINGS_ROW_PROP_DESCRIPTIONS } from './settingsRowPropDescriptions';
import { STATUS_PROP_DESCRIPTIONS } from './statusPropDescriptions';
import { TAG_PROP_DESCRIPTIONS } from './tagPropDescriptions';
import { TOOLTIP_PART_PROP_DESCRIPTIONS } from './tooltipPartPropDescriptions';
@@ -221,6 +222,13 @@ export const DOCUMENTED_COMPONENTS = [
slug: 'typography/heading',
propDescriptions: HEADING_PROP_DESCRIPTIONS,
},
+ {
+ name: 'SettingsRow',
+ source: 'components/SettingsRow/SettingsRow.tsx',
+ entryPoint: 'twenty-ui/components',
+ slug: 'components/settings-row',
+ propDescriptions: SETTINGS_ROW_PROP_DESCRIPTIONS,
+ },
{
name: 'Section',
source: 'components/Section/Section.tsx',
diff --git a/packages/twenty-ui/docs/settingsRowPropDescriptions.ts b/packages/twenty-ui/docs/settingsRowPropDescriptions.ts
new file mode 100644
index 00000000000..e76c8304766
--- /dev/null
+++ b/packages/twenty-ui/docs/settingsRowPropDescriptions.ts
@@ -0,0 +1,20 @@
+import { type SettingsRowProps } from '../src/components/SettingsRow/types/SettingsRowProps';
+
+export const SETTINGS_ROW_PROP_DESCRIPTIONS = {
+ children:
+ 'Visible label and accessible name of the switch. Use non-interactive content.',
+ startIcon: 'Decorative content before the label.',
+ description:
+ 'Non-interactive supporting content, associated with the switch as its accessible description.',
+ focused: 'Applies the highlighted row style without moving keyboard focus.',
+ checked: 'Controlled checked state of the switch.',
+ defaultChecked: 'Initial checked state when uncontrolled.',
+ 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.',
+} satisfies Partial<Record<keyof SettingsRowProps, string>>;
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 3548c234e7d..5ce569ef65c 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -5799,6 +5799,104 @@
}
]
},
+ {
+ "name": "SettingsRow",
+ "entryPoint": "twenty-ui/components",
+ "slug": "components/settings-row",
+ "props": [
+ {
+ "name": "checked",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Controlled checked state of the switch."
+ },
+ {
+ "name": "children",
+ "type": "ReactNode",
+ "required": true,
+ "defaultValue": null,
+ "description": "Visible label and accessible name of the switch. Use non-interactive content."
+ },
+ {
+ "name": "defaultChecked",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Initial checked state when uncontrolled."
+ },
+ {
+ "name": "description",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Non-interactive supporting content, associated with the switch as its accessible description."
+ },
+ {
+ "name": "disabled",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Disables both the row and its switch."
+ },
+ {
+ "name": "focused",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Applies the highlighted row style without moving keyboard focus."
+ },
+ {
+ "name": "name",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Name of the hidden checkbox used in form submission."
+ },
+ {
+ "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."
+ },
+ {
+ "name": "readOnly",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Keeps the switch focusable while preventing changes."
+ },
+ {
+ "name": "required",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Requires the switch to be checked for form submission."
+ },
+ {
+ "name": "size",
+ "type": "\"md\" | \"sm\"",
+ "required": false,
+ "defaultValue": "sm",
+ "description": "Visual size of the switch. The row height stays the same."
+ },
+ {
+ "name": "startIcon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Decorative content before the label."
+ },
+ {
+ "name": "value",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Value submitted when the switch is checked."
+ }
+ ]
+ },
{
"name": "Section",
"entryPoint": "twenty-ui/components",
diff --git a/packages/twenty-ui/src/components/SettingsRow/SettingsRow.tsx b/packages/twenty-ui/src/components/SettingsRow/SettingsRow.tsx
new file mode 100644
index 00000000000..4123c26f9f6
--- /dev/null
+++ b/packages/twenty-ui/src/components/SettingsRow/SettingsRow.tsx
@@ -0,0 +1,66 @@
+import { useId } from 'react';
+
+import { Switch } from '@ui/primitives/input/Switch/Switch';
+import { isRenderableSlot } from '@ui/primitives/navigation/ListItem/internal/isRenderableSlot';
+import { ListItem } from '@ui/primitives/navigation/ListItem/ListItem';
+
+import { type SettingsRowProps } from './types/SettingsRowProps';
+
+export const SettingsRow = ({
+ children,
+ startIcon,
+ description,
+ focused = false,
+ checked,
+ defaultChecked,
+ onCheckedChange,
+ disabled = false,
+ readOnly = false,
+ size = 'sm',
+ name,
+ value,
+ required,
+ className,
+ style,
+ ref,
+ ...labelProps
+}: SettingsRowProps) => {
+ const switchId = useId();
+ const labelId = `${switchId}-label`;
+ const descriptionId = `${switchId}-description`;
+ const hasDescription = isRenderableSlot(description);
+
+ return (
+ <ListItem
+ className={className}
+ style={style}
+ startIcon={startIcon}
+ focused={focused}
+ disabled={disabled}
+ description={
+ hasDescription && <span id={descriptionId}>{description}</span>
+ }
+ render={(renderProps) => (
+ <label {...labelProps} {...renderProps} htmlFor={switchId} ref={ref} />
+ )}
+ endIcon={
+ <Switch
+ 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}
+ />
+ }
+ >
+ <span id={labelId}>{children}</span>
+ </ListItem>
+ );
+};
diff --git a/packages/twenty-ui/src/components/SettingsRow/__stories__/ControlledSettingsRowExample.tsx b/packages/twenty-ui/src/components/SettingsRow/__stories__/ControlledSettingsRowExample.tsx
new file mode 100644
index 00000000000..bd8657705f8
--- /dev/null
+++ b/packages/twenty-ui/src/components/SettingsRow/__stories__/ControlledSettingsRowExample.tsx
@@ -0,0 +1,23 @@
+import { useState } from 'react';
+
+import { SettingsRow } from '../SettingsRow';
+import { type SettingsRowProps } from '../types/SettingsRowProps';
+
+export const ControlledSettingsRowExample = ({
+ defaultChecked = false,
+ onCheckedChange,
+ ...props
+}: SettingsRowProps) => {
+ const [checked, setChecked] = useState(defaultChecked);
+
+ return (
+ <SettingsRow
+ {...props}
+ checked={checked}
+ onCheckedChange={(nextChecked, eventDetails) => {
+ setChecked(nextChecked);
+ onCheckedChange?.(nextChecked, eventDetails);
+ }}
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/components/SettingsRow/__stories__/SettingsRow.stories.tsx b/packages/twenty-ui/src/components/SettingsRow/__stories__/SettingsRow.stories.tsx
new file mode 100644
index 00000000000..173281f8aa7
--- /dev/null
+++ b/packages/twenty-ui/src/components/SettingsRow/__stories__/SettingsRow.stories.tsx
@@ -0,0 +1,76 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+
+import { IconBell } from '@ui/icon';
+import { type SwitchSize } from '@ui/primitives/input/Switch/types/SwitchSize';
+import {
+ A11Y_DEFER_COLOR_CONTRAST,
+ CatalogDecorator,
+ type CatalogStory,
+ ComponentDecorator,
+} from '@ui/testing';
+
+import { SettingsRow } from '../SettingsRow';
+import { type SettingsRowProps } from '../types/SettingsRowProps';
+
+const meta: Meta<typeof SettingsRow> = {
+ title: 'UI/Components/SettingsRow',
+ component: SettingsRow,
+ args: { children: 'Notifications', startIcon: <IconBell aria-hidden /> },
+ parameters: { container: { width: 320 } },
+};
+
+export default meta;
+type Story = StoryObj<typeof SettingsRow>;
+
+export const Default: Story = { decorators: [ComponentDecorator] };
+export const Checked: Story = { ...Default, args: { defaultChecked: true } };
+export const Disabled: Story = {
+ ...Default,
+ args: { disabled: true, defaultChecked: true },
+};
+export const ReadOnly: Story = {
+ ...Default,
+ args: { readOnly: true, defaultChecked: true },
+};
+export const WithDescription: Story = {
+ ...Default,
+ parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
+ args: { description: 'Updates by email' },
+};
+
+const STATE_PROPS = {
+ off: {},
+ on: { defaultChecked: true },
+ highlighted: { focused: true },
+ disabled: { disabled: true },
+ 'disabled on': { disabled: true, defaultChecked: true },
+ 'read only': { readOnly: true, defaultChecked: true },
+} satisfies Record<string, Partial<SettingsRowProps>>;
+
+export const Catalog: CatalogStory<Story, typeof SettingsRow> = {
+ decorators: [CatalogDecorator],
+ parameters: {
+ a11y: A11Y_DEFER_COLOR_CONTRAST,
+ catalog: {
+ dimensions: [
+ {
+ name: 'size',
+ values: ['sm', 'md'] satisfies SwitchSize[],
+ props: (size: SwitchSize) => ({ size }),
+ },
+ {
+ name: 'state',
+ values: Object.keys(STATE_PROPS),
+ props: (state: keyof typeof STATE_PROPS) => STATE_PROPS[state],
+ },
+ ],
+ options: { elementContainer: { style: { width: 240 } } },
+ },
+ },
+};
+
+export const CatalogDark: typeof Catalog = {
+ ...Catalog,
+ tags: ['!autodocs'],
+ globals: { colorScheme: 'dark' },
+};
diff --git a/packages/twenty-ui/src/components/SettingsRow/__stories__/SettingsRowInteractions.stories.tsx b/packages/twenty-ui/src/components/SettingsRow/__stories__/SettingsRowInteractions.stories.tsx
new file mode 100644
index 00000000000..bee2193d872
--- /dev/null
+++ b/packages/twenty-ui/src/components/SettingsRow/__stories__/SettingsRowInteractions.stories.tsx
@@ -0,0 +1,156 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, within } from 'storybook/test';
+
+import { Button } from '@ui/primitives/input/Button/Button';
+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
+
+import { SettingsRow } from '../SettingsRow';
+import { ControlledSettingsRowExample } from './ControlledSettingsRowExample';
+
+const meta: Meta<typeof SettingsRow> = {
+ title: 'UI/Components/SettingsRow/Interactions',
+ component: SettingsRow,
+ tags: ['!autodocs'],
+ decorators: [ComponentDecorator],
+ parameters: { container: { width: 320 } },
+ args: { children: 'Notifications', onCheckedChange: fn() },
+};
+
+export default meta;
+type Story = StoryObj<typeof SettingsRow>;
+
+export const Controlled: Story = {
+ render: (args) => <ControlledSettingsRowExample {...args} />,
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const control = canvas.getByRole('switch', { name: 'Notifications' });
+
+ await userEvent.click(control);
+ await expect(control).toBeChecked();
+ await expect(args.onCheckedChange).toHaveBeenCalledTimes(1);
+
+ await userEvent.click(canvas.getByText('Notifications'));
+ await expect(control).not.toBeChecked();
+ await expect(args.onCheckedChange).toHaveBeenCalledTimes(2);
+
+ control.focus();
+ await userEvent.keyboard(' ');
+ await expect(control).toBeChecked();
+ await expect(args.onCheckedChange).toHaveBeenCalledTimes(3);
+ },
+};
+
+export const IndependentRows: Story = {
+ render: (args) => (
+ <>
+ <SettingsRow {...args} />
+ <SettingsRow defaultChecked>Weekly digest</SettingsRow>
+ </>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const notifications = canvas.getByRole('switch', { name: 'Notifications' });
+ const digest = canvas.getByRole('switch', { name: 'Weekly digest' });
+
+ await expect(notifications).not.toBeChecked();
+ await expect(digest).toBeChecked();
+ await userEvent.click(canvas.getByText('Weekly digest'));
+ await expect(digest).not.toBeChecked();
+ await userEvent.click(canvas.getByText('Notifications'));
+ await expect(notifications).toBeChecked();
+ await expect(digest).not.toBeChecked();
+ },
+};
+
+export const Disabled: Story = {
+ args: { disabled: true },
+ 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 expect(control).not.toBeChecked();
+ await expect(control).toHaveAttribute('aria-disabled', 'true');
+ await expect(args.onCheckedChange).not.toHaveBeenCalled();
+ },
+};
+
+export const ReadOnly: Story = {
+ args: { readOnly: true, defaultChecked: true },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const control = canvas.getByRole('switch', { name: 'Notifications' });
+
+ await userEvent.click(canvas.getByText('Notifications'));
+ control.focus();
+ await userEvent.keyboard(' ');
+
+ await expect(control).toHaveFocus();
+ await expect(control).toBeChecked();
+ await expect(control).toHaveAttribute('aria-readonly', 'true');
+ await expect(args.onCheckedChange).not.toHaveBeenCalled();
+ },
+};
+
+export const AccessibleDescription: Story = {
+ args: { description: 'Updates by email' },
+ parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const control = canvas.getByRole('switch', { name: 'Notifications' });
+
+ await expect(control).toHaveAccessibleDescription('Updates by email');
+ await userEvent.click(canvas.getByText('Updates by email'));
+ await expect(control).toBeChecked();
+ },
+};
+
+export const CanceledChange: Story = {
+ args: {
+ onCheckedChange: fn((_checked, eventDetails) => eventDetails.cancel()),
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+
+ await userEvent.click(canvas.getByText('Notifications'));
+
+ await expect(args.onCheckedChange).toHaveBeenCalledTimes(1);
+ await expect(canvas.getByRole('switch')).not.toBeChecked();
+ },
+};
+
+export const FormSubmission: Story = {
+ render: (args) => (
+ <form
+ aria-label="Notification preferences"
+ onSubmit={(event) => event.preventDefault()}
+ >
+ <SettingsRow {...args} name="notifications" value="enabled" required />
+ <Button type="submit">Save</Button>
+ </form>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const form = canvas.getByRole<HTMLFormElement>('form', {
+ name: 'Notification preferences',
+ });
+ const onSubmit = fn();
+ form.addEventListener('submit', onSubmit);
+
+ try {
+ await userEvent.click(canvas.getByRole('button', { name: 'Save' }));
+ await expect(onSubmit).not.toHaveBeenCalled();
+ await expect(new FormData(form).has('notifications')).toBe(false);
+
+ await userEvent.click(canvas.getByText('Notifications'));
+ await userEvent.click(canvas.getByRole('button', { name: 'Save' }));
+
+ await expect(onSubmit).toHaveBeenCalledTimes(1);
+ await expect(new FormData(form).get('notifications')).toBe('enabled');
+ } finally {
+ form.removeEventListener('submit', onSubmit);
+ }
+ },
+};
diff --git a/packages/twenty-ui/src/components/SettingsRow/__tests__/SettingsRow.test.tsx b/packages/twenty-ui/src/components/SettingsRow/__tests__/SettingsRow.test.tsx
new file mode 100644
index 00000000000..78c67263b9e
--- /dev/null
+++ b/packages/twenty-ui/src/components/SettingsRow/__tests__/SettingsRow.test.tsx
@@ -0,0 +1,10 @@
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+
+import { SettingsRow } from '../SettingsRow';
+
+runComponentConformance({
+ name: 'SettingsRow',
+ element: <SettingsRow>Notifications</SettingsRow>,
+ refInstanceOf: HTMLLabelElement,
+ skip: ['renderProp'],
+});
diff --git a/packages/twenty-ui/src/components/SettingsRow/types/SettingsRowProps.ts b/packages/twenty-ui/src/components/SettingsRow/types/SettingsRowProps.ts
new file mode 100644
index 00000000000..cf6361c1ed8
--- /dev/null
+++ b/packages/twenty-ui/src/components/SettingsRow/types/SettingsRowProps.ts
@@ -0,0 +1,24 @@
+import { type ComponentPropsWithRef, 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;
+ };
diff --git a/packages/twenty-ui/src/components/index.ts b/packages/twenty-ui/src/components/index.ts
index e307ed115c8..aec47cc1cc4 100644
--- a/packages/twenty-ui/src/components/index.ts
+++ b/packages/twenty-ui/src/components/index.ts
@@ -18,5 +18,7 @@ export { MainButton } from './MainButton/MainButton';
export { Section } from './Section/Section';
export type { SectionHeaderProps } from './Section/types/SectionHeaderProps';
export type { SectionRootProps } from './Section/types/SectionRootProps';
+export { SettingsRow } from './SettingsRow/SettingsRow';
+export type { SettingsRowProps } from './SettingsRow/types/SettingsRowProps';
export { TabButton } from './TabButton/TabButton';
export type { TabButtonProps } from './TabButton/types/TabButtonProps';
diff --git a/packages/twenty-ui/src/primitives/input/Switch/__stories__/Switch.integrations.stories.tsx b/packages/twenty-ui/src/primitives/input/Switch/__stories__/Switch.integrations.stories.tsx
deleted file mode 100644
index 4a5edb58fc6..00000000000
--- a/packages/twenty-ui/src/primitives/input/Switch/__stories__/Switch.integrations.stories.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { useState } from 'react';
-import { expect, fn, userEvent, within } from 'storybook/test';
-
-import { MenuItemSwitch } from '@ui/primitives/navigation/MenuItemSwitch/MenuItemSwitch';
-import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
-
-const meta: Meta<typeof MenuItemSwitch> = {
- title: 'UI/Input/Switch/Integrations',
- component: MenuItemSwitch,
- parameters: { container: { width: 300 }, a11y: A11Y_DEFER_COLOR_CONTRAST },
-};
-
-export default meta;
-type Story = StoryObj<typeof MenuItemSwitch>;
-
-type MenuSwitchProps = { onCheckedChange?: (checked: boolean) => void };
-
-const MenuSwitch = ({ onCheckedChange }: MenuSwitchProps) => {
- const [checked, setChecked] = useState(false);
- return (
- <MenuItemSwitch
- text="Notifications"
- checked={checked}
- onCheckedChange={(nextChecked) => {
- setChecked(nextChecked);
- onCheckedChange?.(nextChecked);
- }}
- />
- );
-};
-
-export const MenuItem: Story = {
- decorators: [ComponentDecorator],
- args: { onCheckedChange: fn() },
- render: (args) => <MenuSwitch {...args} />,
- play: async ({ canvasElement, args }) => {
- const canvas = within(canvasElement);
- const control = canvas.getByRole('switch', { name: 'Notifications' });
- await userEvent.click(control);
- await expect(control).toBeChecked();
- await expect(args.onCheckedChange).toHaveBeenCalledTimes(1);
- await userEvent.click(canvas.getByText('Notifications'));
- await expect(control).not.toBeChecked();
- await expect(args.onCheckedChange).toHaveBeenCalledTimes(2);
- },
-};
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss
index 847a819c5d1..daf02751c9d 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss
@@ -4,8 +4,11 @@
--tw-list-item-hover-background: var(--t-background-transparent-light);
align-items: center;
+ appearance: none;
background: var(--tw-list-item-background);
+ border: 0;
border-radius: calc(var(--t-border-radius-md) - var(--t-spacing-1));
+ box-sizing: border-box;
color: var(--tw-list-item-color);
cursor: pointer;
display: flex;
@@ -18,6 +21,7 @@
padding-block: 0;
padding-inline: var(--t-spacing-1);
position: relative;
+ text-align: start;
transition: background duration(instant) ease;
user-select: none;
@@ -72,6 +76,7 @@
}
.text {
+ display: block;
flex-shrink: 0;
max-inline-size: 100%;
overflow: hidden;
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
index 199b5a4bae8..aa8c367af55 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
@@ -57,33 +57,33 @@ export const ListItem = ({
<ListItemCheckboxIndicator checked={selected} disabled={disabled} />
)}
{isRenderableSlot(startIcon) && (
- <div className={styles.startIcon}>{startIcon}</div>
+ <span className={styles.startIcon}>{startIcon}</span>
)}
- <div className={styles.label}>
- <div className={styles.text}>{children}</div>
+ <span className={styles.label}>
+ <span className={styles.text}>{children}</span>
{hasDescription && descriptionPlacement === 'inline' && (
- <div
+ <span
className={clsx(styles.description, styles.inlineDescription)}
>
{description}
- </div>
+ </span>
)}
- </div>
+ </span>
{hasDescription && descriptionPlacement === 'end' && (
- <div className={clsx(styles.description, styles.endDescription)}>
+ <span className={clsx(styles.description, styles.endDescription)}>
{description}
- </div>
+ </span>
)}
{isRenderableSlot(actions) && (
- <div className={styles.actions}>{actions}</div>
+ <span className={styles.actions}>{actions}</span>
)}
{isNonEmptyArray(hotkeys) && (
- <div className={styles.hotkeys}>
+ <span className={styles.hotkeys}>
<MenuItemHotKeys hotKeys={hotkeys} />
- </div>
+ </span>
)}
{isRenderableSlot(endIcon) && (
- <div className={styles.endIcon}>{endIcon}</div>
+ <span className={styles.endIcon}>{endIcon}</span>
)}
{indicator === 'check' && selected && (
<IconCheck className={styles.checkIndicator} aria-hidden />
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemInteractions.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemInteractions.stories.tsx
index 59f741221b7..2b9cf8c9a4c 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemInteractions.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemInteractions.stories.tsx
@@ -185,3 +185,23 @@ export const DecorativeCheckbox: Story = {
await expect(item.querySelector('[data-checked]')).not.toBeNull();
},
};
+
+export const NavigationRow: Story = {
+ args: { role: 'button', hasSubmenu: true },
+ render: (args) => (
+ <div role="listitem">
+ <ListItem {...args} render={<button type="button" />} />
+ </div>
+ ),
+ play: async ({ canvasElement, args }) => {
+ const row = within(canvasElement).getByRole('button', { name: 'Item' });
+
+ row.focus();
+ await userEvent.keyboard('{Enter}');
+ await userEvent.keyboard(' ');
+
+ await expect(args.onClick).toHaveBeenCalledTimes(2);
+ await expect(row).toHaveFocus();
+ await expect(row.getBoundingClientRect().height).toBe(32);
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/navigation/MenuItemNavigate/MenuItemNavigate.tsx b/packages/twenty-ui/src/primitives/navigation/MenuItemNavigate/MenuItemNavigate.tsx
deleted file mode 100644
index 9d5cc8bb4fa..00000000000
--- a/packages/twenty-ui/src/primitives/navigation/MenuItemNavigate/MenuItemNavigate.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { IconChevronRight, type IconComponent } from '@ui/icon';
-import { useTheme } from '@ui/theme-constants';
-import { MenuItemLeftContent } from '@ui/primitives/navigation/MenuItem/parts/MenuItemLeftContent';
-import {
- StyledMenuItemBase,
- StyledMenuItemLeftContent,
-} from '@ui/primitives/navigation/MenuItem/parts/StyledMenuItemBase';
-
-export type MenuItemNavigateProps = {
- LeftIcon?: IconComponent;
- withIconContainer?: boolean;
- text: string;
- onClick?: () => void;
- className?: string;
-};
-
-export const MenuItemNavigate = ({
- LeftIcon,
- withIconContainer = false,
- text,
- className,
- onClick,
-}: MenuItemNavigateProps) => {
- const theme = useTheme();
-
- return (
- <StyledMenuItemBase onClick={onClick} className={className}>
- <StyledMenuItemLeftContent>
- <MenuItemLeftContent
- LeftIcon={LeftIcon}
- text={text}
- withIconContainer={withIconContainer}
- />
- </StyledMenuItemLeftContent>
- <IconChevronRight
- size={theme.icon.size.sm}
- color={theme.font.color.tertiary}
- />
- </StyledMenuItemBase>
- );
-};
diff --git a/packages/twenty-ui/src/primitives/navigation/MenuItemNavigate/__stories__/MenuItemNavigate.stories.tsx b/packages/twenty-ui/src/primitives/navigation/MenuItemNavigate/__stories__/MenuItemNavigate.stories.tsx
deleted file mode 100644
index d453d66a776..00000000000
--- a/packages/twenty-ui/src/primitives/navigation/MenuItemNavigate/__stories__/MenuItemNavigate.stories.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-
-import { IconBell } from '@ui/icon';
-import { MenuItemNavigate } from '@ui/primitives/navigation/MenuItemNavigate/MenuItemNavigate';
-
-import {
- A11Y_DEFER_COLOR_CONTRAST,
- CatalogDecorator,
- type CatalogDimension,
- type CatalogOptions,
- type CatalogStory,
- ComponentDecorator,
-} from '@ui/testing';
-
-const meta: Meta<typeof MenuItemNavigate> = {
- title: 'UI/Navigation/Menu/MenuItem/MenuItemNavigate',
- component: MenuItemNavigate,
-};
-
-export default meta;
-
-type Story = StoryObj<typeof MenuItemNavigate>;
-
-export const Default: Story = {
- args: {
- text: 'First option',
- },
- decorators: [ComponentDecorator],
-};
-
-export const Catalog: CatalogStory<Story, typeof MenuItemNavigate> = {
- args: { LeftIcon: IconBell, text: 'Menu item' },
- argTypes: {
- className: { control: false },
- },
- parameters: {
- a11y: A11Y_DEFER_COLOR_CONTRAST,
- pseudo: { hover: ['.hover'], active: ['.pressed'], focus: ['.focus'] },
- catalog: {
- dimensions: [
- {
- name: 'withIcon',
- values: [true, false],
- props: (withIcon: boolean) => ({
- LeftIcon: withIcon ? IconBell : undefined,
- }),
- labels: (withIcon: boolean) =>
- withIcon ? 'With left icon' : 'Without left icon',
- },
- {
- name: 'withIconContainer',
- values: [true, false],
- props: (withIconContainer: boolean) => ({ withIconContainer }),
- labels: (withIconContainer: boolean) =>
- withIconContainer
- ? 'With icon container'
- : 'Without icon container',
- },
- {
- name: 'states',
- values: ['default', 'hover'],
- props: (state: string) => {
- switch (state) {
- case 'default':
- return {};
- case 'hover':
- return { className: state };
- default:
- return {};
- }
- },
- },
- ] as CatalogDimension[],
- options: {
- elementContainer: {
- width: 200,
- },
- } as CatalogOptions,
- },
- },
- decorators: [CatalogDecorator],
-};
diff --git a/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/MenuItemSwitch.module.scss b/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/MenuItemSwitch.module.scss
deleted file mode 100644
index feff91d7b73..00000000000
--- a/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/MenuItemSwitch.module.scss
+++ /dev/null
@@ -1,7 +0,0 @@
-.switchContainer {
- align-items: center;
- cursor: pointer;
- display: flex;
- justify-content: space-between;
- width: 100%;
-}
diff --git a/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/MenuItemSwitch.module.scss.d.ts b/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/MenuItemSwitch.module.scss.d.ts
deleted file mode 100644
index 7874db198b2..00000000000
--- a/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/MenuItemSwitch.module.scss.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-declare const classNames: {
- readonly switchContainer: 'switchContainer';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/MenuItemSwitch.tsx b/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/MenuItemSwitch.tsx
deleted file mode 100644
index c4668991044..00000000000
--- a/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/MenuItemSwitch.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import { type IconComponent } from '@ui/icon';
-import { Switch } from '@ui/primitives/input/Switch/Switch';
-import { type SwitchSize } from '@ui/primitives/input/Switch/types/SwitchSize';
-import { MenuItemLeftContent } from '@ui/primitives/navigation/MenuItem/parts/MenuItemLeftContent';
-import {
- StyledMenuItemBase,
- StyledMenuItemRightContent,
-} from '@ui/primitives/navigation/MenuItem/parts/StyledMenuItemBase';
-
-import styles from './MenuItemSwitch.module.scss';
-
-export type MenuItemSwitchProps = {
- focused?: boolean;
- LeftIcon?: IconComponent;
- withIconContainer?: boolean;
- checked: boolean;
- text: string;
- className?: string;
- onCheckedChange?: (checked: boolean) => void;
- size?: SwitchSize;
- disabled?: boolean;
-};
-
-export const MenuItemSwitch = ({
- focused,
- LeftIcon,
- withIconContainer = false,
- text,
- checked,
- className,
- onCheckedChange,
- size = 'md',
- disabled = false,
-}: MenuItemSwitchProps) => {
- const handleClick = () => {
- if (!disabled) {
- onCheckedChange?.(!checked);
- }
- };
-
- return (
- <StyledMenuItemBase
- className={className}
- focused={focused}
- disabled={disabled}
- onClick={handleClick}
- >
- <div className={styles.switchContainer}>
- <MenuItemLeftContent
- LeftIcon={LeftIcon}
- text={text}
- withIconContainer={withIconContainer}
- disabled={disabled}
- />
- <StyledMenuItemRightContent onClick={(e) => e.stopPropagation()}>
- <Switch
- checked={checked}
- onCheckedChange={disabled ? undefined : onCheckedChange}
- size={size}
- disabled={disabled}
- aria-label={text}
- />
- </StyledMenuItemRightContent>
- </div>
- </StyledMenuItemBase>
- );
-};
diff --git a/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/__stories__/MenuItemSwitch.stories.tsx b/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/__stories__/MenuItemSwitch.stories.tsx
deleted file mode 100644
index c3eb1b04c72..00000000000
--- a/packages/twenty-ui/src/primitives/navigation/MenuItemSwitch/__stories__/MenuItemSwitch.stories.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-
-import { IconBell } from '@ui/icon';
-import {
- A11Y_DEFER_COLOR_CONTRAST,
- CatalogDecorator,
- type CatalogDimension,
- type CatalogOptions,
- type CatalogStory,
- ComponentDecorator,
-} from '@ui/testing';
-import { MenuItemSwitch } from '@ui/primitives/navigation/MenuItemSwitch/MenuItemSwitch';
-
-const meta: Meta<typeof MenuItemSwitch> = {
- title: 'UI/Navigation/Menu/MenuItem/MenuItemSwitch',
- component: MenuItemSwitch,
-};
-
-export default meta;
-
-type Story = StoryObj<typeof MenuItemSwitch>;
-
-export const Default: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- args: {
- text: 'First option',
- },
- decorators: [ComponentDecorator],
-};
-
-export const Catalog: CatalogStory<Story, typeof MenuItemSwitch> = {
- args: { LeftIcon: IconBell, text: 'Menu item' },
- argTypes: {
- className: { control: false },
- },
- parameters: {
- a11y: A11Y_DEFER_COLOR_CONTRAST,
- pseudo: { hover: ['.hover'], active: ['.pressed'], focus: ['.focus'] },
- catalog: {
- dimensions: [
- {
- name: 'withIcon',
- values: [true, false],
- props: (withIcon: boolean) => ({
- LeftIcon: withIcon ? IconBell : undefined,
- }),
- labels: (withIcon: boolean) =>
- withIcon ? 'With left icon' : 'Without left icon',
- },
- {
- name: 'withIconContainer',
- values: [true, false],
- props: (withIconContainer: boolean) => ({ withIconContainer }),
- labels: (withIconContainer: boolean) =>
- withIconContainer
- ? 'With icon container'
- : 'Without icon container',
- },
- {
- name: 'checked',
- values: [true, false],
- props: (checked: boolean) => ({ checked }),
- labels: (checked: boolean) => (checked ? 'Checked' : 'Unchecked'),
- },
- {
- name: 'states',
- values: ['default', 'hover'],
- props: (state: string) => {
- switch (state) {
- case 'default':
- return {};
- case 'hover':
- return { className: state };
- default:
- return {};
- }
- },
- },
- ] satisfies CatalogDimension[],
- options: {
- elementContainer: {
- width: 200,
- },
- } satisfies CatalogOptions,
- },
- },
- decorators: [CatalogDecorator],
-};
diff --git a/packages/twenty-ui/src/primitives/navigation/index.ts b/packages/twenty-ui/src/primitives/navigation/index.ts
index e4402425f9c..8e7b74ffd01 100644
--- a/packages/twenty-ui/src/primitives/navigation/index.ts
+++ b/packages/twenty-ui/src/primitives/navigation/index.ts
@@ -41,8 +41,6 @@ export { MenuItemHotKeys } from './MenuItemHotKeys/MenuItemHotKeys';
export { MenuItemMultiSelect } from './MenuItemMultiSelect/MenuItemMultiSelect';
export { MenuItemMultiSelectAvatar } from './MenuItemMultiSelectAvatar/MenuItemMultiSelectAvatar';
export { MenuItemMultiSelectTag } from './MenuItemMultiSelectTag/MenuItemMultiSelectTag';
-export type { MenuItemNavigateProps } from './MenuItemNavigate/MenuItemNavigate';
-export { MenuItemNavigate } from './MenuItemNavigate/MenuItemNavigate';
export {
StyledMenuItemSelect,
MenuItemSelect,
@@ -52,8 +50,6 @@ export { MenuItemSelectColor } from './MenuItemSelectColor/MenuItemSelectColor';
export { MenuItemSelectTag } from './MenuItemSelectTag/MenuItemSelectTag';
export type { MenuItemSuggestionProps } from './MenuItemSuggestion/MenuItemSuggestion';
export { MenuItemSuggestion } from './MenuItemSuggestion/MenuItemSuggestion';
-export type { MenuItemSwitchProps } from './MenuItemSwitch/MenuItemSwitch';
-export { MenuItemSwitch } from './MenuItemSwitch/MenuItemSwitch';
export { MenuPicker } from './MenuPicker/MenuPicker';
export type { MenuPickerProps } from './MenuPicker/types/MenuPickerProps';
export { NavigationBar } from './NavigationBar/NavigationBar';