The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Expose Checkbox and Switch parts (#27587)
Raphaël Bosidee8de22f7c7
diff --git a/packages/twenty-docs/snippets/ui/generated/input/checkbox.mdx b/packages/twenty-docs/snippets/ui/generated/input/checkbox.mdxindex 24db919e789..e6ab69b9158 100644--- a/packages/twenty-docs/snippets/ui/generated/input/checkbox.mdx+++ b/packages/twenty-docs/snippets/ui/generated/input/checkbox.mdx@@ -42,8 +42,7 @@</ParamField><ParamField body="hoverable" type="boolean" default="true">- Adds padding around the box and a hover background. Disable it for a- compact checkbox inside another interactive element.+ Adds padding and a hover background around the box.</ParamField><ParamField body="id" type="string">@@ -119,3 +118,136 @@<ParamField body="variant" type=""outline" | "soft" | "solid"" default="solid">Visual style of the box: filled, outlined, or tinted.</ParamField>++### Checkbox.Root++<ParamField body="Root.checked" type="boolean">+ Whether the checkbox is currently ticked.++ To render an uncontrolled checkbox, use the `defaultChecked` prop instead.+</ParamField>++<ParamField body="Root.className" type="string | ((state: CheckboxRootState) => string | undefined)">+ CSS class applied to the element, or a function that+ returns a class based on the component's state.+</ParamField>++<ParamField body="Root.color" type=""accent" | "success" | "warning"" default="accent">+ Color used while the checkbox is checked or indeterminate.+</ParamField>++<ParamField body="Root.defaultChecked" type="boolean" default="false">+ Whether the checkbox is initially ticked.++ To render a controlled checkbox, use the `checked` prop instead.+</ParamField>++<ParamField body="Root.disabled" type="boolean" default="false">+ Whether the component should ignore user interaction.+</ParamField>++<ParamField body="Root.form" type="string">+ Identifies the form that owns the hidden input.+ Useful when the checkbox is rendered outside the form.+</ParamField>++<ParamField body="Root.hoverable" type="boolean" default="true">+ Adds padding and a hover background around the box.+</ParamField>++<ParamField body="Root.id" type="string">+ The id of the input element.+</ParamField>++<ParamField body="Root.indeterminate" type="boolean" default="false">+ Whether the checkbox is in a mixed state: neither ticked, nor unticked.+</ParamField>++<ParamField body="Root.inputRef" type="Ref<HTMLInputElement>">+ A ref to access the hidden `<input>` element.+</ParamField>++<ParamField body="Root.name" type="string">+ Identifies the field when a form is submitted.+</ParamField>++<ParamField body="Root.nativeButton" type="boolean" default="false">+ Whether the component renders a native `<button>` element when replacing it+ via the `render` prop.+ Set to `true` if the rendered element is a native button.+</ParamField>++<ParamField body="Root.onCheckedChange" type="((checked: boolean, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)">+ Event handler called when the checkbox is ticked or unticked.+</ParamField>++<ParamField body="Root.parent" type="boolean" default="false">+ Whether the checkbox controls a group of child checkboxes.++ Must be used in a [Checkbox Group](https://base-ui.com/react/components/checkbox-group).+</ParamField>++<ParamField body="Root.readOnly" type="boolean" default="false">+ Whether the user should be unable to tick or untick the checkbox.+</ParamField>++<ParamField body="Root.render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, CheckboxRootState>">+ Allows you to replace the component's HTML element+ with a different tag, or compose it with another component.++ Accepts a `ReactElement` or a function that returns the element to render.+</ParamField>++<ParamField body="Root.required" type="boolean" default="false">+ Whether the user must tick the checkbox before submitting a form.+</ParamField>++<ParamField body="Root.shape" type=""round" | "square"" default="square">+ Corner shape of the box.+</ParamField>++<ParamField body="Root.size" type=""md" | "sm"" default="sm">+ Visual size of the checkbox.+</ParamField>++<ParamField body="Root.style" type="CSSProperties | ((state: CheckboxRootState) => CSSProperties | undefined)">+ Style applied to the element, or a function that+ returns a style object based on the component's state.+</ParamField>++<ParamField body="Root.uncheckedValue" type="string">+ The value submitted with the form when the checkbox is unchecked.+ By default, unchecked checkboxes do not submit any value, matching native checkbox behavior.+</ParamField>++<ParamField body="Root.value" type="string">+ The checkbox's value. Identifies it within a [Checkbox Group](https://base-ui.com/react/components/checkbox-group), falling back to `name` when omitted.+ When submitting a form, a checked box submits `value`; with no `value`, it submits the native "on".+</ParamField>++<ParamField body="Root.variant" type=""outline" | "soft" | "solid"" default="solid">+ Visual style of the box: filled, outlined, or tinted.+</ParamField>++### Checkbox.Indicator++<ParamField body="Indicator.className" type="string | ((state: CheckboxIndicatorState) => string | undefined)">+ CSS class applied to the element, or a function that+ returns a class based on the component's state.+</ParamField>++<ParamField body="Indicator.keepMounted" type="boolean" default="false">+ Whether to keep the element in the DOM when the checkbox is not checked.+</ParamField>++<ParamField body="Indicator.render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, CheckboxIndicatorState>">+ Allows you to replace the component's HTML element+ with a different tag, or compose it with another component.++ Accepts a `ReactElement` or a function that returns the element to render.+</ParamField>++<ParamField body="Indicator.style" type="CSSProperties | ((state: CheckboxIndicatorState) => CSSProperties | undefined)">+ Style applied to the element, or a function that+ returns a style object based on the component's state.+</ParamField>diff --git a/packages/twenty-docs/snippets/ui/generated/input/switch.mdx b/packages/twenty-docs/snippets/ui/generated/input/switch.mdxindex 89f75fcf12d..f781ae8bef0 100644--- a/packages/twenty-docs/snippets/ui/generated/input/switch.mdx+++ b/packages/twenty-docs/snippets/ui/generated/input/switch.mdx@@ -94,3 +94,108 @@The value submitted with the form when the switch is on.By default, switch submits the "on" value, matching native checkbox behavior.</ParamField>++### Switch.Root++<ParamField body="Root.checked" type="boolean">+ Whether the switch is currently active.++ To render an uncontrolled switch, use the `defaultChecked` prop instead.+</ParamField>++<ParamField body="Root.className" type="string | ((state: SwitchRootState) => string | undefined)">+ CSS class applied to the element, or a function that+ returns a class based on the component's state.+</ParamField>++<ParamField body="Root.defaultChecked" type="boolean" default="false">+ Whether the switch is initially active.++ To render a controlled switch, use the `checked` prop instead.+</ParamField>++<ParamField body="Root.disabled" type="boolean" default="false">+ Whether the component should ignore user interaction.+</ParamField>++<ParamField body="Root.form" type="string">+ Identifies the form that owns the hidden input.+ Useful when the switch is rendered outside the form.+</ParamField>++<ParamField body="Root.id" type="string">+ The id of the hidden input element.++ When `nativeButton` is `true`, the id is applied to the root element.+</ParamField>++<ParamField body="Root.inputRef" type="Ref<HTMLInputElement>">+ A ref to access the hidden `<input>` element.+</ParamField>++<ParamField body="Root.name" type="string">+ Identifies the field when a form is submitted.+</ParamField>++<ParamField body="Root.nativeButton" type="boolean" default="false">+ Whether the component renders a native `<button>` element when replacing it+ via the `render` prop.+ Set to `true` if the rendered element is a native button.+</ParamField>++<ParamField body="Root.onCheckedChange" type="((checked: boolean, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)">+ Event handler called when the switch is activated or deactivated.+</ParamField>++<ParamField body="Root.readOnly" type="boolean" default="false">+ Whether the user should be unable to activate or deactivate the switch.+</ParamField>++<ParamField body="Root.render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SwitchRootState>">+ Allows you to replace the component's HTML element+ with a different tag, or compose it with another component.++ Accepts a `ReactElement` or a function that returns the element to render.+</ParamField>++<ParamField body="Root.required" type="boolean" default="false">+ Whether the user must activate the switch before submitting a form.+</ParamField>++<ParamField body="Root.size" type=""md" | "sm"" default="md">+ Visual size of the switch.+</ParamField>++<ParamField body="Root.style" type="CSSProperties | ((state: SwitchRootState) => CSSProperties | undefined)">+ Style applied to the element, or a function that+ returns a style object based on the component's state.+</ParamField>++<ParamField body="Root.uncheckedValue" type="string">+ The value submitted with the form when the switch is off.+ By default, unchecked switches do not submit any value, matching native checkbox behavior.+</ParamField>++<ParamField body="Root.value" type="string">+ The value submitted with the form when the switch is on.+ By default, switch submits the "on" value, matching native checkbox behavior.+</ParamField>++### Switch.Thumb++<ParamField body="Thumb.className" type="string | ((state: SwitchThumbState) => string | undefined)">+ CSS class applied to the element, or a function that+ returns a class based on the component's state.+</ParamField>++<ParamField body="Thumb.render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SwitchThumbState>">+ Allows you to replace the component's HTML element+ with a different tag, or compose it with another component.++ Accepts a `ReactElement` or a function that returns the element to render.+</ParamField>++<ParamField body="Thumb.style" type="CSSProperties | ((state: SwitchThumbState) => CSSProperties | undefined)">+ Style applied to the element, or a function that+ returns a style object based on the component's state.+</ParamField>diff --git a/packages/twenty-docs/ui/primitives/input/checkbox.mdx b/packages/twenty-docs/ui/primitives/input/checkbox.mdxindex 8cfb65e1b51..7205325216d 100644--- a/packages/twenty-docs/ui/primitives/input/checkbox.mdx+++ b/packages/twenty-docs/ui/primitives/input/checkbox.mdx@@ -107,6 +107,37 @@ export const ColumnSelection = () => {Tab focuses the checkbox and Space toggles it. Clicking its label also toggles it. Use `disabled` to prevent interaction, or `readOnly` when the value should remain unchanged while the control stays focusable. Keep meaning in the label rather than communicating it through color alone.+## Parts and custom content++`Checkbox` assembles the styled root and its default check and indeterminate icons. Use `Checkbox.Root` with `Checkbox.Indicator` to own the indicator content. Root owns state and box appearance; Indicator renders the content you supply.++```tsx+import { IconCheck } from 'twenty-ui/icon';+import { Checkbox } from 'twenty-ui/primitives/input';++export const CustomPreference = () => (+ <Checkbox.Root aria-label="Updates" defaultChecked>+ <Checkbox.Indicator>+ <IconCheck aria-hidden />+ </Checkbox.Indicator>+ </Checkbox.Root>+);+```++`CheckboxRootProps` and `CheckboxIndicatorProps` are public types exported from `twenty-ui/primitives/input`. Both parts accept native attributes, handlers, refs, `render`, and state-based `className` and `style` callbacks. Root's `ref` targets the visible control; `inputRef` targets the native input. The part ref targets its rendered element. Pass `nativeButton` with `render={<button />}` when replacing Root with a button. Appearance props belong on Root; explicit classes and styles are merged with the defaults.++Indicator receives checked and indeterminate state, including transition state. Set `keepMounted` to retain an unchecked indicator in the DOM; the default styling hides it with opacity. Override its `style` or `className` for custom transitions.++<StoryEmbed+ storyId="ui-input-checkbox-parts--composition"+ title="Checkbox part composition"+ height={240}+/>++The callable assembly and its `CheckboxProps` type remain supported. Replace the assembly with Root and its part when supplying custom icons instead of appending another part to the assembly's children.++For controlled form reset, handle the form's `onReset` and restore `checked` to your initial value. Base UI 1.8 does not restore uncontrolled component state on native form reset. `required`, `form`, `value`, and `uncheckedValue` keep the upstream native input behavior.+## PropsThe reference is generated from the public component types. Native attributes, including accessible names and event handlers, are also accepted on parts that render elements.diff --git a/packages/twenty-docs/ui/primitives/input/switch.mdx b/packages/twenty-docs/ui/primitives/input/switch.mdxindex d1d0ca61d15..957e2242d6a 100644--- a/packages/twenty-docs/ui/primitives/input/switch.mdx+++ b/packages/twenty-docs/ui/primitives/input/switch.mdx@@ -64,6 +64,34 @@ Tab moves focus to the switch; Space toggles it. Clicking its associated label aA named switch submits its value when checked. Use `value` to customize that value, and `uncheckedValue` if the form should also submit a value when it is off.+## Parts and custom content++`Switch` assembles the styled root and its default thumb. Use `Switch.Root` with `Switch.Thumb` to own the thumb content. Root owns state and track appearance; Thumb renders the content you supply.++```tsx+import { Switch } from 'twenty-ui/primitives/input';++export const CustomPreference = () => (+ <Switch.Root aria-label="Updates" defaultChecked>+ <Switch.Thumb></Switch.Thumb>+ </Switch.Root>+);+```++`SwitchRootProps` and `SwitchThumbProps` are public types exported from `twenty-ui/primitives/input`. Both parts accept native attributes, handlers, refs, `render`, and state-based `className` and `style` callbacks. Root's `ref` targets the visible control; `inputRef` targets the native input. The part ref targets its rendered element. Pass `nativeButton` with `render={<button />}` when replacing Root with a button. Appearance props belong on Root; explicit classes and styles are merged with the defaults.++Thumb receives the current checked, disabled, readOnly, required, and Field state. Its position follows the reading direction.++<StoryEmbed+ storyId="ui-input-switch-parts--composition"+ title="Switch part composition"+ height={240}+/>++The callable assembly and its `SwitchProps` type remain supported. Replace the assembly with Root and its part when supplying custom thumb content instead of appending another part to the assembly's children.++For controlled form reset, handle the form's `onReset` and restore `checked` to your initial value. Base UI 1.8 does not restore uncontrolled component state on native form reset. `required`, `form`, `value`, and `uncheckedValue` keep the upstream native input behavior.+## PropsThe reference includes component-specific and inherited Base UI props. Native attributes such as `aria-label` and `data-*` are also accepted.diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-checkbox.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-checkbox.front-component.tsxindex cb50a216956..441e896bb8c 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-checkbox.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-checkbox.front-component.tsx@@ -1,29 +1,69 @@-import { useState } from 'react';+import { createElement, useRef, useState } from 'react';import { defineFrontComponent } from 'twenty-sdk/define';import { Checkbox } from 'twenty-ui/primitives/input';+import { isDefined } from 'twenty-ui/utilities';+import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';const CheckboxExample = () => {const [checked, setChecked] = useState(false);const [changeCount, setChangeCount] = useState(0);+ const rootRef = useRef<HTMLSpanElement>(null);+ const inputRef = useRef<HTMLInputElement>(null);+ const partRef = useRef<HTMLSpanElement>(null);+ const [composition, setComposition] = useState('pending');+return (<TwentyUiGalleryCard title="Checkbox">- <Checkbox+ <Checkbox.Root+ ref={rootRef}+ inputRef={inputRef}+ render={(props, state) =>+ createElement('span', {+ ...props,+ 'data-active': String(state.checked),+ })+ }aria-label="Select account"checked={checked}- onCheckedChange={(nextChecked) => {+ onCheckedChange={(nextChecked, details) => {setChecked(nextChecked);+ setComposition(+ `${details.event.type}/${isDefined(rootRef.current) && isDefined(inputRef.current) && isDefined(partRef.current)}`,+ );setChangeCount((count) => count + 1);}}- />+ >+ <Checkbox.Indicator+ ref={partRef}+ keepMounted+ render={(props, state) =>+ createElement('span', {+ ...props,+ 'data-active': String(state.checked),+ })+ }+ />+ </Checkbox.Root><Checkbox aria-label="Uncontrolled selection" defaultChecked />- <Checkbox aria-label="Partial selection" indeterminate />+ <Checkbox.Root aria-label="Partial selection" indeterminate>+ <Checkbox.Indicator+ render={(props, state) =>+ createElement(+ 'span',+ props,+ state.indeterminate ? 'Mixed selection' : 'Selected',+ )+ }+ />+ </Checkbox.Root><Checkbox aria-label="Disabled selection" disabled /><Checkbox aria-label="Read-only selection" defaultChecked readOnly /><p role="status">Selection: {checked ? 'selected' : 'unselected'}; Changes: {changeCount}+ ; Composition: {composition}</p></TwentyUiGalleryCard>);diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-switch.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-switch.front-component.tsxindex 4b714dc2ba8..23223deaab2 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-switch.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-switch.front-component.tsx@@ -1,22 +1,56 @@-import { useState } from 'react';+import { createElement, useRef, useState } from 'react';import { defineFrontComponent } from 'twenty-sdk/define';import { Switch } from 'twenty-ui/primitives/input';+import { isDefined } from 'twenty-ui/utilities';+import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';const SwitchExample = () => {const [checked, setChecked] = useState(false);+ const rootRef = useRef<HTMLSpanElement>(null);+ const inputRef = useRef<HTMLInputElement>(null);+ const partRef = useRef<HTMLSpanElement>(null);+ const [composition, setComposition] = useState('pending');+return (<TwentyUiGalleryCard title="Switch">- <Switch+ <Switch.Root+ ref={rootRef}+ inputRef={inputRef}+ render={(props, state) =>+ createElement('span', {+ ...props,+ 'data-active': String(state.checked),+ })+ }aria-label="Email notifications"checked={checked}- onCheckedChange={setChecked}- />+ onCheckedChange={(nextChecked, details) => {+ setChecked(nextChecked);+ setComposition(+ `${details.event.type}/${isDefined(rootRef.current) && isDefined(inputRef.current) && isDefined(partRef.current)}`,+ );+ }}+ >+ <Switch.Thumb+ ref={partRef}+ render={(props, state) =>+ createElement('span', {+ ...props,+ 'data-active': String(state.checked),+ })+ }+ />+ </Switch.Root><Switch aria-label="Uncontrolled notifications" defaultChecked /><Switch aria-label="Disabled notifications" disabled />- <p role="status">Notifications: {checked ? 'enabled' : 'disabled'}</p>+ <Switch aria-label="Read-only notifications" defaultChecked readOnly />+ <p role="status">+ Notifications: {checked ? 'enabled' : 'disabled'}; Composition:{' '}+ {composition}+ </p></TwentyUiGalleryCard>);};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/checkboxTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/checkboxTest.tsindex 25b97967a30..f0a7395a82c 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/checkboxTest.ts+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/checkboxTest.ts@@ -42,5 +42,12 @@ export const checkboxTest: TwentyUiGalleryPlayFunction = async ({await userEvent.click(uncontrolled);await waitFor(() => expect(uncontrolled).not.toBeChecked());+ expect(canvas.getByRole('status')).toHaveTextContent(+ /Composition: (click|change)\/true/,+ );+ expect(checkbox).toHaveAttribute('data-active', 'true');+ const customPart = checkbox.querySelector('[data-active]');+ expect(customPart).toHaveAttribute('data-active', 'true');+ expect(canvas.getByText('Mixed selection')).toBeVisible();expect(errorHandler).not.toHaveBeenCalled();};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/switchTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/switchTest.tsindex b0603c4f38e..605b74f26b5 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/switchTest.ts+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/switchTest.ts@@ -39,5 +39,16 @@ export const switchTest: TwentyUiGalleryPlayFunction = async ({await userEvent.click(uncontrolledSwitch);await waitFor(() => expect(uncontrolledSwitch).not.toBeChecked());+ expect(canvas.getByRole('status')).toHaveTextContent(+ /Composition: (click|change)\/true/,+ );+ expect(emailNotificationsSwitch).toHaveAttribute('data-active', 'true');+ const customPart = emailNotificationsSwitch.querySelector('[data-active]');+ expect(customPart).toHaveAttribute('data-active', 'true');+ const readOnly = canvas.getByRole('switch', {+ name: 'Read-only notifications',+ });+ await userEvent.click(readOnly);+ expect(readOnly).toBeChecked();expect(errorHandler).not.toHaveBeenCalled();};diff --git a/packages/twenty-ui/docs/checkboxPropDescriptions.ts b/packages/twenty-ui/docs/checkboxPropDescriptions.tsnew file mode 100644index 00000000000..c4998256eff--- /dev/null+++ b/packages/twenty-ui/docs/checkboxPropDescriptions.ts@@ -0,0 +1,7 @@+export const CHECKBOX_PROP_DESCRIPTIONS = {+ size: 'Visual size of the checkbox.',+ variant: 'Visual style of the box: filled, outlined, or tinted.',+ shape: 'Corner shape of the box.',+ color: 'Color used while the checkbox is checked or indeterminate.',+ hoverable: 'Adds padding and a hover background around the box.',+};diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.tsindex 52c7e171556..1272a4b81b0 100644--- a/packages/twenty-ui/docs/components.ts+++ b/packages/twenty-ui/docs/components.ts@@ -1,3 +1,5 @@+import { CHECKBOX_PROP_DESCRIPTIONS } from './checkboxPropDescriptions';+import { SWITCH_PROP_DESCRIPTIONS } from './switchPropDescriptions';import { TEXTAREA_PROP_DESCRIPTIONS } from './textareaPropDescriptions';import { INPUT_GROUP_PROP_DESCRIPTIONS } from './inputGroupPropDescriptions';import { INPUT_PROP_DESCRIPTIONS } from './inputPropDescriptions';@@ -75,6 +77,16 @@ import { TOOLTIP_PART_PROP_DESCRIPTIONS } from './tooltipPartPropDescriptions';import { TOOLTIP_PROP_DESCRIPTIONS } from './tooltipPropDescriptions';import { VISUALLY_HIDDEN_PROP_DESCRIPTIONS } from './visuallyHiddenPropDescriptions';+const CHECKBOX_PROP_DEFAULTS = {+ size: 'sm',+ variant: 'solid',+ shape: 'square',+ color: 'accent',+ hoverable: 'true',+};++const SWITCH_PROP_DEFAULTS = { size: 'md' };+export const DOCUMENTED_COMPONENTS = [{name: 'CountrySelect',@@ -335,6 +347,11 @@ export const DOCUMENTED_COMPONENTS = [source: 'primitives/input/Checkbox/Checkbox.tsx',entryPoint: 'twenty-ui/primitives/input',slug: 'input/checkbox',+ parts: ['Root', 'Indicator'],+ propDescriptions: CHECKBOX_PROP_DESCRIPTIONS,+ partPropDescriptions: { Root: CHECKBOX_PROP_DESCRIPTIONS },+ propDefaults: CHECKBOX_PROP_DEFAULTS,+ partPropDefaults: { Root: CHECKBOX_PROP_DEFAULTS },},{name: 'Radio',@@ -387,6 +404,11 @@ export const DOCUMENTED_COMPONENTS = [source: 'primitives/input/Switch/Switch.tsx',entryPoint: 'twenty-ui/primitives/input',slug: 'input/switch',+ parts: ['Root', 'Thumb'],+ propDescriptions: SWITCH_PROP_DESCRIPTIONS,+ partPropDescriptions: { Root: SWITCH_PROP_DESCRIPTIONS },+ propDefaults: SWITCH_PROP_DEFAULTS,+ partPropDefaults: { Root: SWITCH_PROP_DEFAULTS },},{name: 'Breadcrumb',diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.jsonindex 2613be92c71..fb1eca909d5 100644--- a/packages/twenty-ui/docs/public-exports.json+++ b/packages/twenty-ui/docs/public-exports.json@@ -798,7 +798,9 @@"ButtonSize": "primitives/input/Button/types/ButtonSize","ButtonVariant": "primitives/input/Button/types/ButtonVariant","CheckboxColor": "primitives/input/Checkbox/types/CheckboxColor",+ "CheckboxIndicatorProps": "primitives/input/Checkbox/types/CheckboxIndicatorProps","CheckboxProps": "primitives/input/Checkbox/types/CheckboxProps",+ "CheckboxRootProps": "primitives/input/Checkbox/types/CheckboxRootProps","CheckboxShape": "primitives/input/Checkbox/types/CheckboxShape","CheckboxSize": "primitives/input/Checkbox/types/CheckboxSize","CheckboxVariant": "primitives/input/Checkbox/types/CheckboxVariant",@@ -834,7 +836,9 @@"SliderTrackProps": "primitives/input/Slider/types/SliderTrackProps","SliderValueProps": "primitives/input/Slider/types/SliderValueProps","SwitchProps": "primitives/input/Switch/types/SwitchProps",+ "SwitchRootProps": "primitives/input/Switch/types/SwitchRootProps","SwitchSize": "primitives/input/Switch/types/SwitchSize",+ "SwitchThumbProps": "primitives/input/Switch/types/SwitchThumbProps","TextareaProps": "primitives/input/Textarea/types/TextareaProps"}},diff --git a/packages/twenty-ui/docs/switchPropDescriptions.ts b/packages/twenty-ui/docs/switchPropDescriptions.tsnew file mode 100644index 00000000000..6c8403eec7f--- /dev/null+++ b/packages/twenty-ui/docs/switchPropDescriptions.ts@@ -0,0 +1,3 @@+export const SWITCH_PROP_DESCRIPTIONS = {+ size: 'Visual size of the switch.',+};diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex 2af3f089815..86696d1d5e9 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -2949,7 +2949,7 @@"type": "boolean","required": false,"defaultValue": "true",- "description": "Adds padding around the box and a hover background. Disable it for a\ncompact checkbox inside another interactive element."+ "description": "Adds padding and a hover background around the box."},{"name": "id",@@ -3063,6 +3063,207 @@"defaultValue": "solid","description": "Visual style of the box: filled, outlined, or tinted."}+ ],+ "parts": [+ {+ "name": "Root",+ "props": [+ {+ "name": "checked",+ "type": "boolean",+ "required": false,+ "defaultValue": null,+ "description": "Whether the checkbox is currently ticked.\n\nTo render an uncontrolled checkbox, use the `defaultChecked` prop instead."+ },+ {+ "name": "className",+ "type": "string | ((state: CheckboxRootState) => string | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."+ },+ {+ "name": "color",+ "type": "\"accent\" | \"success\" | \"warning\"",+ "required": false,+ "defaultValue": "accent",+ "description": "Color used while the checkbox is checked or indeterminate."+ },+ {+ "name": "defaultChecked",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the checkbox is initially ticked.\n\nTo render a controlled checkbox, use the `checked` prop instead."+ },+ {+ "name": "disabled",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the component should ignore user interaction."+ },+ {+ "name": "form",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Identifies the form that owns the hidden input.\nUseful when the checkbox is rendered outside the form."+ },+ {+ "name": "hoverable",+ "type": "boolean",+ "required": false,+ "defaultValue": "true",+ "description": "Adds padding and a hover background around the box."+ },+ {+ "name": "id",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "The id of the input element."+ },+ {+ "name": "indeterminate",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the checkbox is in a mixed state: neither ticked, nor unticked."+ },+ {+ "name": "inputRef",+ "type": "Ref<HTMLInputElement>",+ "required": false,+ "defaultValue": null,+ "description": "A ref to access the hidden `<input>` element."+ },+ {+ "name": "name",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Identifies the field when a form is submitted."+ },+ {+ "name": "nativeButton",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the component renders a native `<button>` element when replacing it\nvia the `render` prop.\nSet to `true` if the rendered element is a native button."+ },+ {+ "name": "onCheckedChange",+ "type": "((checked: boolean, eventDetails: { reason: \"none\"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)",+ "required": false,+ "defaultValue": null,+ "description": "Event handler called when the checkbox is ticked or unticked."+ },+ {+ "name": "parent",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the checkbox controls a group of child checkboxes.\n\nMust be used in a [Checkbox Group](https://base-ui.com/react/components/checkbox-group)."+ },+ {+ "name": "readOnly",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the user should be unable to tick or untick the checkbox."+ },+ {+ "name": "render",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, CheckboxRootState>",+ "required": false,+ "defaultValue": null,+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."+ },+ {+ "name": "required",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the user must tick the checkbox before submitting a form."+ },+ {+ "name": "shape",+ "type": "\"round\" | \"square\"",+ "required": false,+ "defaultValue": "square",+ "description": "Corner shape of the box."+ },+ {+ "name": "size",+ "type": "\"md\" | \"sm\"",+ "required": false,+ "defaultValue": "sm",+ "description": "Visual size of the checkbox."+ },+ {+ "name": "style",+ "type": "CSSProperties | ((state: CheckboxRootState) => CSSProperties | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."+ },+ {+ "name": "uncheckedValue",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "The value submitted with the form when the checkbox is unchecked.\nBy default, unchecked checkboxes do not submit any value, matching native checkbox behavior."+ },+ {+ "name": "value",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "The checkbox's value. Identifies it within a [Checkbox Group](https://base-ui.com/react/components/checkbox-group), falling back to `name` when omitted.\nWhen submitting a form, a checked box submits `value`; with no `value`, it submits the native \"on\"."+ },+ {+ "name": "variant",+ "type": "\"outline\" | \"soft\" | \"solid\"",+ "required": false,+ "defaultValue": "solid",+ "description": "Visual style of the box: filled, outlined, or tinted."+ }+ ]+ },+ {+ "name": "Indicator",+ "props": [+ {+ "name": "className",+ "type": "string | ((state: CheckboxIndicatorState) => string | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."+ },+ {+ "name": "keepMounted",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether to keep the element in the DOM when the checkbox is not checked."+ },+ {+ "name": "render",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, CheckboxIndicatorState>",+ "required": false,+ "defaultValue": null,+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."+ },+ {+ "name": "style",+ "type": "CSSProperties | ((state: CheckboxIndicatorState) => CSSProperties | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."+ }+ ]+ }]},{@@ -4814,6 +5015,158 @@"defaultValue": null,"description": "The value submitted with the form when the switch is on.\nBy default, switch submits the \"on\" value, matching native checkbox behavior."}+ ],+ "parts": [+ {+ "name": "Root",+ "props": [+ {+ "name": "checked",+ "type": "boolean",+ "required": false,+ "defaultValue": null,+ "description": "Whether the switch is currently active.\n\nTo render an uncontrolled switch, use the `defaultChecked` prop instead."+ },+ {+ "name": "className",+ "type": "string | ((state: SwitchRootState) => string | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."+ },+ {+ "name": "defaultChecked",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the switch is initially active.\n\nTo render a controlled switch, use the `checked` prop instead."+ },+ {+ "name": "disabled",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the component should ignore user interaction."+ },+ {+ "name": "form",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Identifies the form that owns the hidden input.\nUseful when the switch is rendered outside the form."+ },+ {+ "name": "id",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "The id of the hidden input element.\n\nWhen `nativeButton` is `true`, the id is applied to the root element."+ },+ {+ "name": "inputRef",+ "type": "Ref<HTMLInputElement>",+ "required": false,+ "defaultValue": null,+ "description": "A ref to access the hidden `<input>` element."+ },+ {+ "name": "name",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Identifies the field when a form is submitted."+ },+ {+ "name": "nativeButton",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the component renders a native `<button>` element when replacing it\nvia the `render` prop.\nSet to `true` if the rendered element is a native button."+ },+ {+ "name": "onCheckedChange",+ "type": "((checked: boolean, eventDetails: { reason: \"none\"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)",+ "required": false,+ "defaultValue": null,+ "description": "Event handler called when the switch is activated or deactivated."+ },+ {+ "name": "readOnly",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the user should be unable to activate or deactivate the switch."+ },+ {+ "name": "render",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SwitchRootState>",+ "required": false,+ "defaultValue": null,+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."+ },+ {+ "name": "required",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether the user must activate the switch before submitting a form."+ },+ {+ "name": "size",+ "type": "\"md\" | \"sm\"",+ "required": false,+ "defaultValue": "md",+ "description": "Visual size of the switch."+ },+ {+ "name": "style",+ "type": "CSSProperties | ((state: SwitchRootState) => CSSProperties | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."+ },+ {+ "name": "uncheckedValue",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "The value submitted with the form when the switch is off.\nBy default, unchecked switches do not submit any value, matching native checkbox behavior."+ },+ {+ "name": "value",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "The value submitted with the form when the switch is on.\nBy default, switch submits the \"on\" value, matching native checkbox behavior."+ }+ ]+ },+ {+ "name": "Thumb",+ "props": [+ {+ "name": "className",+ "type": "string | ((state: SwitchThumbState) => string | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."+ },+ {+ "name": "render",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SwitchThumbState>",+ "required": false,+ "defaultValue": null,+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."+ },+ {+ "name": "style",+ "type": "CSSProperties | ((state: SwitchThumbState) => CSSProperties | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."+ }+ ]+ }]},{diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.module.scss b/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.module.scssindex c47fd2eebcb..7674ebb0d75 100644--- a/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.module.scss+++ b/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.module.scss@@ -5,6 +5,7 @@--tw-checkbox-icon-size: 14px;--tw-checkbox-border-width: 1px;--tw-checkbox-bg: transparent;+ --tw-checkbox-padding: 0px;--tw-checkbox-border-color: var(--t-border-color-secondary-inverted);--tw-checkbox-box-radius: var(--t-border-radius-sm-round);@@ -14,7 +15,7 @@cursor: pointer;display: inline-flex;flex-shrink: 0;- padding: 0;+ padding: var(--tw-checkbox-padding);position: relative;}@@ -75,11 +76,11 @@}.hoverable {- padding: 5px;+ --tw-checkbox-padding: 5px;}.hoverable.md {- padding: 6px;+ --tw-checkbox-padding: 6px;}@include hover-capable {@@ -117,14 +118,7 @@background-color: transparent;}-.box {- block-size: calc(var(--tw-checkbox-box-size) + 2px);- padding: 0;- position: relative;- inline-size: calc(var(--tw-checkbox-box-size) + 2px);-}--.box::before {+.root::before {background: var(--tw-checkbox-bg);border-color: var(--tw-checkbox-border-color);border-radius: var(--tw-checkbox-box-radius);@@ -142,12 +136,17 @@.indicator {display: block;block-size: var(--tw-checkbox-icon-size);- inset-inline-start: 0;+ inset-block: 0;+ inset-inline-start: var(--tw-checkbox-padding);+ margin-block: auto;position: absolute;- inset-block-start: 0;inline-size: var(--tw-checkbox-icon-size);}+.indicator[data-unchecked] {+ opacity: 0;+}+.indicator svg {display: block;block-size: 100%;diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.module.scss.d.ts b/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.module.scss.d.tsindex 98c3a0cfa92..d7fbbb18cd6 100644--- a/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.module.scss.d.ts+++ b/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.module.scss.d.ts@@ -11,7 +11,6 @@ declare const classNames: {readonly success: 'success';readonly warning: 'warning';readonly hoverable: 'hoverable';- readonly box: 'box';readonly indicator: 'indicator';readonly check: 'check';readonly minus: 'minus';diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.tsx b/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.tsxindex c43b583223f..2c85d19c633 100644--- a/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.tsx+++ b/packages/twenty-ui/src/primitives/input/Checkbox/Checkbox.tsx@@ -1,42 +1,8 @@-import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';-import { clsx } from 'clsx';+import { CheckboxComponent } from './internal/CheckboxComponent';+import { CheckboxIndicator } from './internal/CheckboxIndicator';+import { CheckboxRoot } from './internal/CheckboxRoot';-import { IconCheck, IconMinus } from '@ui/icon';-import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';--import styles from './Checkbox.module.scss';-import { type CheckboxProps } from './types/CheckboxProps';--export const Checkbox = ({- size = 'sm',- variant = 'solid',- shape = 'square',- color = 'accent',- hoverable = true,- className,- children,- ...props-}: CheckboxProps) => (- <CheckboxPrimitive.Root- {...props}- className={mergeClassNames(- clsx(- styles.root,- styles[size],- styles[variant],- styles[shape],- styles[color],- hoverable && styles.hoverable,- ),- className,- )}- >- <span className={styles.box}>- <CheckboxPrimitive.Indicator className={styles.indicator}>- <IconCheck className={styles.check} aria-hidden />- <IconMinus className={styles.minus} aria-hidden />- </CheckboxPrimitive.Indicator>- </span>- {children}- </CheckboxPrimitive.Root>-);+export const Checkbox = Object.assign(CheckboxComponent, {+ Root: CheckboxRoot,+ Indicator: CheckboxIndicator,+});diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/__stories__/Checkbox.parts.stories.tsx b/packages/twenty-ui/src/primitives/input/Checkbox/__stories__/Checkbox.parts.stories.tsxnew file mode 100644index 00000000000..cee47f8f4d8--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Checkbox/__stories__/Checkbox.parts.stories.tsx@@ -0,0 +1,190 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { useRef, useState } from 'react';+import { expect, userEvent, within } from 'storybook/test';++import { IconCheck } from '@ui/icon';+import { Button } from '@ui/primitives/input/Button/Button';+import { Field } from '@ui/primitives/input/Field/Field';+import { Text } from '@ui/primitives/typography/Text/Text';+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';++import { Checkbox } from '../Checkbox';++const meta: Meta<typeof Checkbox> = {+ title: 'UI/Input/Checkbox/Parts',+ component: Checkbox,+ decorators: [ComponentDecorator],+};++export default meta;+type Story = StoryObj<typeof Checkbox>;++export const Composition: Story = {+ render: () => (+ <Checkbox.Root aria-label="Updates" defaultChecked>+ <Checkbox.Indicator>+ <IconCheck aria-hidden />+ </Checkbox.Indicator>+ </Checkbox.Root>+ ),+};++const FormExample = () => {+ const [checked, setChecked] = useState(false);+ const [submitted, setSubmitted] = useState('Not submitted');+ const rootRef = useRef<HTMLButtonElement>(null);+ const inputRef = useRef<HTMLInputElement>(null);+ const partRef = useRef<HTMLSpanElement>(null);++ return (+ <form+ onReset={() => setChecked(false)}+ onSubmit={(event) => {+ event.preventDefault();+ setSubmitted(String(new FormData(event.currentTarget).get('updates')));+ }}+ >+ <Field.Root name="updates">+ <Field.Label>Updates</Field.Label>+ <Checkbox.Root+ checked={checked}+ onCheckedChange={setChecked}+ required+ value="enabled"+ uncheckedValue="disabled"+ ref={rootRef}+ inputRef={inputRef}+ nativeButton+ render={<button />}+ >+ <Checkbox.Indicator+ ref={partRef}+ render={(props, state) => (+ <span {...props} data-active={state.checked} />+ )}+ />+ </Checkbox.Root>+ <Field.Description>Receive workspace updates.</Field.Description>+ </Field.Root>+ <Button type="submit">Save</Button>+ <Button type="reset">Reset</Button>+ <Button+ onClick={() => {+ rootRef.current?.focus();+ setSubmitted(`${inputRef.current?.name}/${partRef.current?.tagName}`);+ }}+ >+ Inspect refs+ </Button>+ <output>{submitted}</output>+ </form>+ );+};++export const FormAndRefs: Story = {+ parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },+ render: () => <FormExample />,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const control = canvas.getByRole('checkbox', { name: 'Updates' });+ await expect(control).toHaveAccessibleDescription(+ 'Receive workspace updates.',+ );+ await userEvent.click(canvas.getByRole('button', { name: 'Save' }));+ await expect(canvas.getByRole('status')).toHaveTextContent('Not submitted');+ await userEvent.click(canvas.getByText('Updates'));+ await expect(control).toBeChecked();+ await userEvent.click(canvas.getByRole('button', { name: 'Save' }));+ await expect(canvas.getByRole('status')).toHaveTextContent('enabled');+ await userEvent.click(canvas.getByRole('button', { name: 'Inspect refs' }));+ await expect(control).toHaveFocus();+ await expect(canvas.getByRole('status')).toHaveTextContent('updates/SPAN');+ await userEvent.click(canvas.getByRole('button', { name: 'Reset' }));+ await expect(control).not.toBeChecked();+ },+};++const IndicatorExample = () => {+ const [checked, setChecked] = useState(false);+ const [indeterminate, setIndeterminate] = useState(true);++ return (+ <Checkbox.Root+ checked={checked}+ indeterminate={indeterminate}+ aria-label="Partial selection"+ onCheckedChange={(nextChecked) => {+ setChecked(nextChecked);+ setIndeterminate(false);+ }}+ >+ <Checkbox.Indicator+ keepMounted+ render={(props, state) => (+ <span {...props} data-mixed={state.indeterminate} />+ )}+ />+ </Checkbox.Root>+ );+};++export const IndicatorState: Story = {+ render: () => <IndicatorExample />,+ play: async ({ canvasElement }) => {+ const control = within(canvasElement).getByRole('checkbox');+ const indicator = control.querySelector('[data-mixed]');+ await expect(control).toBePartiallyChecked();+ await expect(indicator).toHaveAttribute('data-mixed', 'true');+ await userEvent.click(control);+ await expect(control).toBeChecked();+ await expect(indicator).toHaveAttribute('data-mixed', 'false');+ await userEvent.keyboard(' ');+ await expect(control).not.toBeChecked();+ await expect(indicator).toHaveAttribute('data-unchecked');+ await expect(indicator).toHaveStyle({ opacity: '0' });+ await expect(indicator).toBeInTheDocument();+ },+};++export const TallChildren: Story = {+ render: () => (+ <>+ {(['sm', 'md'] as const).map((size) =>+ [false, true].flatMap((hoverable) =>+ [false, true].map((isScaled) => (+ <Checkbox.Root+ key={`${size}-${hoverable}-${isScaled}`}+ size={size}+ hoverable={hoverable}+ defaultChecked+ aria-label={`${size} ${hoverable ? 'with hover' : 'without hover'} ${isScaled ? 'scaled indicator' : 'default indicator'}`}+ >+ <Checkbox.Indicator+ data-testid="selection-indicator"+ style={isScaled ? { transform: 'scale(0.75)' } : undefined}+ >+ <IconCheck aria-hidden />+ </Checkbox.Indicator>+ <Text render={<span />} style={{ lineHeight: '48px' }}>+ Tall content+ </Text>+ </Checkbox.Root>+ )),+ ),+ )}+ </>+ ),+ play: async ({ canvasElement }) => {+ for (const checkbox of within(canvasElement).getAllByRole('checkbox')) {+ const indicator = within(checkbox).getByTestId('selection-indicator');+ const checkboxBounds = checkbox.getBoundingClientRect();+ const indicatorBounds = indicator.getBoundingClientRect();+ const checkboxCenter = checkboxBounds.top + checkboxBounds.height / 2;+ const indicatorCenter = indicatorBounds.top + indicatorBounds.height / 2;++ await expect(Math.abs(checkboxCenter - indicatorCenter)).toBeLessThan(+ 0.5,+ );+ }+ },+};diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/__tests__/Checkbox.parts.test.tsx b/packages/twenty-ui/src/primitives/input/Checkbox/__tests__/Checkbox.parts.test.tsxnew file mode 100644index 00000000000..b0a05bf9d2f--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Checkbox/__tests__/Checkbox.parts.test.tsx@@ -0,0 +1,215 @@+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { createRef } from 'react';+import { describe, expect, it, vi } from 'vitest';++import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';+import { Field } from '@ui/primitives/input/Field/Field';+import { Switch } from '@ui/primitives/input/Switch/Switch';++import { Checkbox } from '../Checkbox';+import styles from '../Checkbox.module.scss';++runComponentConformance({+ name: 'Checkbox.Root',+ element: <Checkbox.Root aria-label="Selection" />,+ refInstanceOf: HTMLSpanElement,+ ownClassName: styles.root,+});++runComponentConformance({+ name: 'Checkbox.Indicator',+ element: <Checkbox.Indicator />,+ wrapper: ({ children }) => (+ <Checkbox.Root defaultChecked>{children}</Checkbox.Root>+ ),+ refInstanceOf: HTMLSpanElement,+ ownClassName: styles.indicator,+});++describe.each([+ { name: 'Checkbox.Root', Control: Checkbox.Root, role: 'checkbox' },+ { name: 'Switch.Root', Control: Switch.Root, role: 'switch' },+])('$name native behavior', ({ Control, role }) => {+ it('preserves uncontrolled state and click event details', async () => {+ const onCheckedChange = vi.fn();+ render(+ <Control+ aria-label="Preference"+ defaultChecked+ onCheckedChange={onCheckedChange}+ />,+ );+ const control = screen.getByRole(role, { name: 'Preference' });+ await userEvent.click(control);+ expect(control).not.toBeChecked();+ expect(onCheckedChange).toHaveBeenCalledWith(+ false,+ expect.objectContaining({+ event: expect.objectContaining({ type: 'click' }),+ cancel: expect.any(Function),+ }),+ );+ await userEvent.keyboard(' ');+ expect(control).toBeChecked();+ });++ it('leaves controlled updates to the caller', async () => {+ const onCheckedChange = vi.fn();+ const { rerender } = render(+ <Control+ aria-label="Preference"+ checked={false}+ onCheckedChange={onCheckedChange}+ />,+ );+ const control = screen.getByRole(role, { name: 'Preference' });+ await userEvent.click(control);+ expect(onCheckedChange).toHaveBeenCalledTimes(1);+ expect(control).not.toBeChecked();+ rerender(+ <Control+ aria-label="Preference"+ checked+ onCheckedChange={onCheckedChange}+ />,+ );+ expect(control).toBeChecked();+ expect(onCheckedChange).toHaveBeenCalledTimes(1);+ });++ it('allows the caller to cancel a state change', async () => {+ render(+ <Control+ aria-label="Preference"+ onCheckedChange={(_checked, details) => details.cancel()}+ />,+ );+ const control = screen.getByRole(role, { name: 'Preference' });+ await userEvent.click(control);+ expect(control).not.toBeChecked();+ });++ it.each(['disabled', 'readOnly'] as const)(+ 'preserves %s interaction',+ async (mode) => {+ const onCheckedChange = vi.fn();+ render(+ <Control+ aria-label="Preference"+ defaultChecked+ {...{ [mode]: true }}+ onCheckedChange={onCheckedChange}+ />,+ );+ const control = screen.getByRole(role, { name: 'Preference' });+ await userEvent.click(control);+ await userEvent.keyboard(' ');+ expect(control).toBeChecked();+ expect(onCheckedChange).not.toHaveBeenCalled();+ },+ );++ it('associates the Field label, description and name', async () => {+ render(+ <form aria-label="Preferences">+ <Field.Root name="preference">+ <Field.Label>+ <Control value="yes" />+ Preference+ </Field.Label>+ <Field.Description>Workspace updates</Field.Description>+ </Field.Root>+ </form>,+ );+ const control = screen.getByRole(role, { name: 'Preference' });+ expect(control).toHaveAccessibleDescription('Workspace updates');+ await userEvent.click(screen.getByText('Preference'));+ expect(control).toBeChecked();+ expect(+ new FormData(+ screen.getByRole<HTMLFormElement>('form', { name: 'Preferences' }),+ ).get('preference'),+ ).toBe('yes');+ });++ it('preserves native values, required validation, external form ownership', async () => {+ const inputRef = createRef<HTMLInputElement>();+ render(+ <>+ <form id="preferences" aria-label="Preferences" />+ <Control+ form="preferences"+ name="updates"+ value="yes"+ uncheckedValue="no"+ required+ inputRef={inputRef}+ aria-label="Updates"+ />+ <Control+ form="preferences"+ name="disabled"+ defaultChecked+ disabled+ aria-label="Disabled"+ />+ <Control form="preferences" defaultChecked aria-label="Unnamed" />+ </>,+ );+ const form = screen.getByRole<HTMLFormElement>('form', {+ name: 'Preferences',+ });+ expect(inputRef.current?.form).toBe(form);+ expect(form.checkValidity()).toBe(false);+ expect([...new FormData(form).entries()]).toEqual([['updates', 'no']]);+ await userEvent.click(screen.getByRole(role, { name: 'Updates' }));+ expect(form.checkValidity()).toBe(true);+ expect([...new FormData(form).entries()]).toEqual([['updates', 'yes']]);+ await userEvent.click(screen.getByRole(role, { name: 'Updates' }));+ expect(form.checkValidity()).toBe(false);+ });+});++it('customizes the indicator with live indeterminate state and both DOM refs', async () => {+ const rootRef = createRef<HTMLSpanElement>();+ const indicatorRef = createRef<HTMLSpanElement>();+ const inputRef = createRef<HTMLInputElement>();+ const { rerender } = render(+ <Checkbox.Root+ ref={rootRef}+ inputRef={inputRef}+ indeterminate+ aria-label="Partial"+ >+ <Checkbox.Indicator+ ref={indicatorRef}+ keepMounted+ render={(props, state) => (+ <span {...props}>+ {state.indeterminate ? 'Partial indicator' : 'Selected indicator'}+ </span>+ )}+ />+ </Checkbox.Root>,+ );+ expect(rootRef.current).toBe(+ screen.getByRole('checkbox', { name: 'Partial' }),+ );+ expect(rootRef.current).toBePartiallyChecked();+ expect(inputRef.current).toBeInstanceOf(HTMLInputElement);+ expect(inputRef.current?.indeterminate).toBe(true);+ expect(indicatorRef.current).toHaveTextContent('Partial indicator');+ rerender(+ <Checkbox.Root aria-label="Partial">+ <Checkbox.Indicator keepMounted>Retained indicator</Checkbox.Indicator>+ </Checkbox.Root>,+ );+ expect(screen.getByText('Retained indicator')).toHaveAttribute(+ 'data-unchecked',+ );+ await userEvent.click(screen.getByRole('checkbox', { name: 'Partial' }));+ expect(screen.getByText('Retained indicator')).not.toHaveAttribute(+ 'data-unchecked',+ );+});diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/__tests__/CheckboxSwitch.types.test.tsx b/packages/twenty-ui/src/primitives/input/Checkbox/__tests__/CheckboxSwitch.types.test.tsxnew file mode 100644index 00000000000..20075f5bb29--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Checkbox/__tests__/CheckboxSwitch.types.test.tsx@@ -0,0 +1,28 @@+import { type Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';+import { type Switch as SwitchPrimitive } from '@base-ui/react/switch';+import { expectTypeOf, it } from 'vitest';++import {+ type CheckboxIndicatorProps,+ type CheckboxRootProps,+ type SwitchRootProps,+ type SwitchThumbProps,+} from '@ui/primitives/input';++it('preserves upstream part props including render state and refs', () => {+ expectTypeOf<CheckboxIndicatorProps>().toEqualTypeOf<CheckboxPrimitive.Indicator.Props>();+ expectTypeOf<SwitchThumbProps>().toEqualTypeOf<SwitchPrimitive.Thumb.Props>();+ expectTypeOf<Omit<CheckboxRootProps, 'color'>>().toExtend<+ Omit<CheckboxPrimitive.Root.Props, 'color'>+ >();+ expectTypeOf<SwitchRootProps>().toExtend<SwitchPrimitive.Root.Props>();+});++it('preserves upstream change event details', () => {+ expectTypeOf<CheckboxRootProps['onCheckedChange']>().toEqualTypeOf<+ CheckboxPrimitive.Root.Props['onCheckedChange']+ >();+ expectTypeOf<SwitchRootProps['onCheckedChange']>().toEqualTypeOf<+ SwitchPrimitive.Root.Props['onCheckedChange']+ >();+});diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/internal/CheckboxComponent.tsx b/packages/twenty-ui/src/primitives/input/Checkbox/internal/CheckboxComponent.tsxnew file mode 100644index 00000000000..208f4027f03--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Checkbox/internal/CheckboxComponent.tsx@@ -0,0 +1,16 @@+import { IconCheck, IconMinus } from '@ui/icon';++import styles from '../Checkbox.module.scss';+import { type CheckboxProps } from '../types/CheckboxProps';+import { CheckboxIndicator } from './CheckboxIndicator';+import { CheckboxRoot } from './CheckboxRoot';++export const CheckboxComponent = ({ children, ...props }: CheckboxProps) => (+ <CheckboxRoot {...props}>+ <CheckboxIndicator>+ <IconCheck className={styles.check} aria-hidden />+ <IconMinus className={styles.minus} aria-hidden />+ </CheckboxIndicator>+ {children}+ </CheckboxRoot>+);diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/internal/CheckboxIndicator.tsx b/packages/twenty-ui/src/primitives/input/Checkbox/internal/CheckboxIndicator.tsxnew file mode 100644index 00000000000..c32f6713b75--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Checkbox/internal/CheckboxIndicator.tsx@@ -0,0 +1,16 @@+import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';++import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';++import styles from '../Checkbox.module.scss';+import { type CheckboxIndicatorProps } from '../types/CheckboxIndicatorProps';++export const CheckboxIndicator = ({+ className,+ ...props+}: CheckboxIndicatorProps) => (+ <CheckboxPrimitive.Indicator+ {...props}+ className={mergeClassNames(styles.indicator, className)}+ />+);diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/internal/CheckboxRoot.tsx b/packages/twenty-ui/src/primitives/input/Checkbox/internal/CheckboxRoot.tsxnew file mode 100644index 00000000000..c13ee325360--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Checkbox/internal/CheckboxRoot.tsx@@ -0,0 +1,32 @@+import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';+import { clsx } from 'clsx';++import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';++import styles from '../Checkbox.module.scss';+import { type CheckboxRootProps } from '../types/CheckboxRootProps';++export const CheckboxRoot = ({+ size = 'sm',+ variant = 'solid',+ shape = 'square',+ color = 'accent',+ hoverable = true,+ className,+ ...props+}: CheckboxRootProps) => (+ <CheckboxPrimitive.Root+ {...props}+ className={mergeClassNames(+ clsx(+ styles.root,+ styles[size],+ styles[variant],+ styles[shape],+ styles[color],+ hoverable && styles.hoverable,+ ),+ className,+ )}+ />+);diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/types/CheckboxIndicatorProps.ts b/packages/twenty-ui/src/primitives/input/Checkbox/types/CheckboxIndicatorProps.tsnew file mode 100644index 00000000000..8d66b664b2c--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Checkbox/types/CheckboxIndicatorProps.ts@@ -0,0 +1,3 @@+import { type Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';++export type CheckboxIndicatorProps = CheckboxPrimitive.Indicator.Props;diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/types/CheckboxProps.ts b/packages/twenty-ui/src/primitives/input/Checkbox/types/CheckboxProps.tsindex d449818b189..579c2fda823 100644--- a/packages/twenty-ui/src/primitives/input/Checkbox/types/CheckboxProps.ts+++ b/packages/twenty-ui/src/primitives/input/Checkbox/types/CheckboxProps.ts@@ -1,22 +1,3 @@-import { type Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';+import { type CheckboxRootProps } from './CheckboxRootProps';-import { type CheckboxColor } from './CheckboxColor';-import { type CheckboxShape } from './CheckboxShape';-import { type CheckboxSize } from './CheckboxSize';-import { type CheckboxVariant } from './CheckboxVariant';--export type CheckboxProps = Omit<CheckboxPrimitive.Root.Props, 'color'> & {- /** Visual size of the checkbox. */- size?: CheckboxSize;- /** Visual style of the box: filled, outlined, or tinted. */- variant?: CheckboxVariant;- /** Corner shape of the box. */- shape?: CheckboxShape;- /** Color used while the checkbox is checked or indeterminate. */- color?: CheckboxColor;- /**- * Adds padding around the box and a hover background. Disable it for a- * compact checkbox inside another interactive element.- */- hoverable?: boolean;-};+export type CheckboxProps = CheckboxRootProps;diff --git a/packages/twenty-ui/src/primitives/input/Checkbox/types/CheckboxRootProps.ts b/packages/twenty-ui/src/primitives/input/Checkbox/types/CheckboxRootProps.tsnew file mode 100644index 00000000000..c14430105f3--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Checkbox/types/CheckboxRootProps.ts@@ -0,0 +1,14 @@+import { type Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';++import { type CheckboxColor } from './CheckboxColor';+import { type CheckboxShape } from './CheckboxShape';+import { type CheckboxSize } from './CheckboxSize';+import { type CheckboxVariant } from './CheckboxVariant';++export type CheckboxRootProps = Omit<CheckboxPrimitive.Root.Props, 'color'> & {+ size?: CheckboxSize;+ variant?: CheckboxVariant;+ shape?: CheckboxShape;+ color?: CheckboxColor;+ hoverable?: boolean;+};diff --git a/packages/twenty-ui/src/primitives/input/Switch/Switch.tsx b/packages/twenty-ui/src/primitives/input/Switch/Switch.tsxindex 96029e1243d..c2f8c88bdde 100644--- a/packages/twenty-ui/src/primitives/input/Switch/Switch.tsx+++ b/packages/twenty-ui/src/primitives/input/Switch/Switch.tsx@@ -1,22 +1,8 @@-import { Switch as SwitchPrimitive } from '@base-ui/react/switch';-import { clsx } from 'clsx';+import { SwitchComponent } from './internal/SwitchComponent';+import { SwitchRoot } from './internal/SwitchRoot';+import { SwitchThumb } from './internal/SwitchThumb';-import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';--import styles from './Switch.module.scss';-import { type SwitchProps } from './types/SwitchProps';--export const Switch = ({- size = 'md',- className,- children,- ...props-}: SwitchProps) => (- <SwitchPrimitive.Root- {...props}- className={mergeClassNames(clsx(styles.root, styles[size]), className)}- >- <SwitchPrimitive.Thumb className={styles.thumb} />- {children}- </SwitchPrimitive.Root>-);+export const Switch = Object.assign(SwitchComponent, {+ Root: SwitchRoot,+ Thumb: SwitchThumb,+});diff --git a/packages/twenty-ui/src/primitives/input/Switch/__stories__/Switch.parts.stories.tsx b/packages/twenty-ui/src/primitives/input/Switch/__stories__/Switch.parts.stories.tsxnew file mode 100644index 00000000000..68eca0ab38a--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Switch/__stories__/Switch.parts.stories.tsx@@ -0,0 +1,101 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { useRef, useState } from 'react';+import { expect, userEvent, within } from 'storybook/test';++import { Button } from '@ui/primitives/input/Button/Button';+import { Field } from '@ui/primitives/input/Field/Field';+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';++import { Switch } from '../Switch';++const meta: Meta<typeof Switch> = {+ title: 'UI/Input/Switch/Parts',+ component: Switch,+ decorators: [ComponentDecorator],+};++export default meta;+type Story = StoryObj<typeof Switch>;++export const Composition: Story = {+ render: () => (+ <Switch.Root aria-label="Updates" defaultChecked>+ <Switch.Thumb></Switch.Thumb>+ </Switch.Root>+ ),+};++const FormExample = () => {+ const [checked, setChecked] = useState(false);+ const [submitted, setSubmitted] = useState('Not submitted');+ const rootRef = useRef<HTMLButtonElement>(null);+ const inputRef = useRef<HTMLInputElement>(null);+ const partRef = useRef<HTMLSpanElement>(null);++ return (+ <form+ onReset={() => setChecked(false)}+ onSubmit={(event) => {+ event.preventDefault();+ setSubmitted(String(new FormData(event.currentTarget).get('updates')));+ }}+ >+ <Field.Root name="updates">+ <Field.Label>Updates</Field.Label>+ <Switch.Root+ checked={checked}+ onCheckedChange={setChecked}+ required+ value="enabled"+ uncheckedValue="disabled"+ ref={rootRef}+ inputRef={inputRef}+ nativeButton+ render={<button />}+ >+ <Switch.Thumb+ ref={partRef}+ render={(props, state) => (+ <span {...props} data-active={state.checked} />+ )}+ />+ </Switch.Root>+ <Field.Description>Receive workspace updates.</Field.Description>+ </Field.Root>+ <Button type="submit">Save</Button>+ <Button type="reset">Reset</Button>+ <Button+ onClick={() => {+ rootRef.current?.focus();+ setSubmitted(`${inputRef.current?.name}/${partRef.current?.tagName}`);+ }}+ >+ Inspect refs+ </Button>+ <output>{submitted}</output>+ </form>+ );+};++export const FormAndRefs: Story = {+ parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },+ render: () => <FormExample />,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const control = canvas.getByRole('switch', { name: 'Updates' });+ await expect(control).toHaveAccessibleDescription(+ 'Receive workspace updates.',+ );+ await userEvent.click(canvas.getByRole('button', { name: 'Save' }));+ await expect(canvas.getByRole('status')).toHaveTextContent('Not submitted');+ await userEvent.click(canvas.getByText('Updates'));+ await expect(control).toBeChecked();+ await userEvent.click(canvas.getByRole('button', { name: 'Save' }));+ await expect(canvas.getByRole('status')).toHaveTextContent('enabled');+ await userEvent.click(canvas.getByRole('button', { name: 'Inspect refs' }));+ await expect(control).toHaveFocus();+ await expect(canvas.getByRole('status')).toHaveTextContent('updates/SPAN');+ await userEvent.click(canvas.getByRole('button', { name: 'Reset' }));+ await expect(control).not.toBeChecked();+ },+};diff --git a/packages/twenty-ui/src/primitives/input/Switch/__tests__/Switch.parts.test.tsx b/packages/twenty-ui/src/primitives/input/Switch/__tests__/Switch.parts.test.tsxnew file mode 100644index 00000000000..cd6fa8d22a9--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Switch/__tests__/Switch.parts.test.tsx@@ -0,0 +1,56 @@+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { createRef } from 'react';+import { expect, it } from 'vitest';++import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';++import { Switch } from '../Switch';+import styles from '../Switch.module.scss';++runComponentConformance({+ name: 'Switch.Root',+ element: <Switch.Root aria-label="Notifications" />,+ refInstanceOf: HTMLSpanElement,+ ownClassName: styles.root,+});++runComponentConformance({+ name: 'Switch.Thumb',+ element: <Switch.Thumb />,+ wrapper: ({ children }) => <Switch.Root>{children}</Switch.Root>,+ refInstanceOf: HTMLSpanElement,+ ownClassName: styles.thumb,+});++it('composes a native button and a thumb with state callbacks and refs', async () => {+ const rootRef = createRef<HTMLButtonElement>();+ const thumbRef = createRef<HTMLSpanElement>();+ render(+ <Switch.Root+ ref={rootRef}+ nativeButton+ render={<button />}+ aria-label="Notifications"+ >+ <Switch.Thumb+ ref={thumbRef}+ className={(state) => (state.checked ? 'enabled' : 'disabled')}+ style={(state) => ({ opacity: state.checked ? 1 : 0.5 })}+ render={(props, state) => (+ <span {...props} data-active={state.checked}>+ {state.checked ? 'On' : 'Off'}+ </span>+ )}+ />+ </Switch.Root>,+ );+ expect(rootRef.current).toBe(screen.getByRole('switch'));+ expect(rootRef.current).toBeInstanceOf(HTMLButtonElement);+ expect(thumbRef.current).toBe(screen.getByText('Off'));+ await userEvent.click(screen.getByRole('switch'));+ expect(thumbRef.current).toHaveTextContent('On');+ expect(thumbRef.current).toHaveClass('enabled');+ expect(thumbRef.current).toHaveStyle({ opacity: '1' });+ expect(thumbRef.current).toHaveAttribute('data-active', 'true');+});diff --git a/packages/twenty-ui/src/primitives/input/Switch/internal/SwitchComponent.tsx b/packages/twenty-ui/src/primitives/input/Switch/internal/SwitchComponent.tsxnew file mode 100644index 00000000000..22039b191fe--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Switch/internal/SwitchComponent.tsx@@ -0,0 +1,10 @@+import { type SwitchProps } from '../types/SwitchProps';+import { SwitchRoot } from './SwitchRoot';+import { SwitchThumb } from './SwitchThumb';++export const SwitchComponent = ({ children, ...props }: SwitchProps) => (+ <SwitchRoot {...props}>+ <SwitchThumb />+ {children}+ </SwitchRoot>+);diff --git a/packages/twenty-ui/src/primitives/input/Switch/internal/SwitchRoot.tsx b/packages/twenty-ui/src/primitives/input/Switch/internal/SwitchRoot.tsxnew file mode 100644index 00000000000..ba2d7aad8bd--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Switch/internal/SwitchRoot.tsx@@ -0,0 +1,18 @@+import { Switch as SwitchPrimitive } from '@base-ui/react/switch';+import { clsx } from 'clsx';++import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';++import styles from '../Switch.module.scss';+import { type SwitchRootProps } from '../types/SwitchRootProps';++export const SwitchRoot = ({+ size = 'md',+ className,+ ...props+}: SwitchRootProps) => (+ <SwitchPrimitive.Root+ {...props}+ className={mergeClassNames(clsx(styles.root, styles[size]), className)}+ />+);diff --git a/packages/twenty-ui/src/primitives/input/Switch/internal/SwitchThumb.tsx b/packages/twenty-ui/src/primitives/input/Switch/internal/SwitchThumb.tsxnew file mode 100644index 00000000000..aabf5bf0bae--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Switch/internal/SwitchThumb.tsx@@ -0,0 +1,13 @@+import { Switch as SwitchPrimitive } from '@base-ui/react/switch';++import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';++import styles from '../Switch.module.scss';+import { type SwitchThumbProps } from '../types/SwitchThumbProps';++export const SwitchThumb = ({ className, ...props }: SwitchThumbProps) => (+ <SwitchPrimitive.Thumb+ {...props}+ className={mergeClassNames(styles.thumb, className)}+ />+);diff --git a/packages/twenty-ui/src/primitives/input/Switch/types/SwitchProps.ts b/packages/twenty-ui/src/primitives/input/Switch/types/SwitchProps.tsindex 3c58276b9b3..f97dd5cf801 100644--- a/packages/twenty-ui/src/primitives/input/Switch/types/SwitchProps.ts+++ b/packages/twenty-ui/src/primitives/input/Switch/types/SwitchProps.ts@@ -1,8 +1,3 @@-import { type Switch as SwitchPrimitive } from '@base-ui/react/switch';+import { type SwitchRootProps } from './SwitchRootProps';-import { type SwitchSize } from './SwitchSize';--export type SwitchProps = SwitchPrimitive.Root.Props & {- /** Visual size of the switch. */- size?: SwitchSize;-};+export type SwitchProps = SwitchRootProps;diff --git a/packages/twenty-ui/src/primitives/input/Switch/types/SwitchRootProps.ts b/packages/twenty-ui/src/primitives/input/Switch/types/SwitchRootProps.tsnew file mode 100644index 00000000000..40f37f97dbb--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Switch/types/SwitchRootProps.ts@@ -0,0 +1,7 @@+import { type Switch as SwitchPrimitive } from '@base-ui/react/switch';++import { type SwitchSize } from './SwitchSize';++export type SwitchRootProps = SwitchPrimitive.Root.Props & {+ size?: SwitchSize;+};diff --git a/packages/twenty-ui/src/primitives/input/Switch/types/SwitchThumbProps.ts b/packages/twenty-ui/src/primitives/input/Switch/types/SwitchThumbProps.tsnew file mode 100644index 00000000000..c87098ea898--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Switch/types/SwitchThumbProps.ts@@ -0,0 +1,3 @@+import { type Switch as SwitchPrimitive } from '@base-ui/react/switch';++export type SwitchThumbProps = SwitchPrimitive.Thumb.Props;diff --git a/packages/twenty-ui/src/primitives/input/index.ts b/packages/twenty-ui/src/primitives/input/index.tsindex d4d614f1ae0..0cb627875fb 100644--- a/packages/twenty-ui/src/primitives/input/index.ts+++ b/packages/twenty-ui/src/primitives/input/index.ts@@ -25,7 +25,9 @@ export { ButtonGroup } from './ButtonGroup/ButtonGroup';export type { ButtonGroupProps } from './ButtonGroup/types/ButtonGroupProps';export { Checkbox } from './Checkbox/Checkbox';export type { CheckboxColor } from './Checkbox/types/CheckboxColor';+export type { CheckboxIndicatorProps } from './Checkbox/types/CheckboxIndicatorProps';export type { CheckboxProps } from './Checkbox/types/CheckboxProps';+export type { CheckboxRootProps } from './Checkbox/types/CheckboxRootProps';export type { CheckboxShape } from './Checkbox/types/CheckboxShape';export type { CheckboxSize } from './Checkbox/types/CheckboxSize';export type { CheckboxVariant } from './Checkbox/types/CheckboxVariant';@@ -69,7 +71,9 @@ export type { SliderTrackProps } from './Slider/types/SliderTrackProps';export type { SliderValueProps } from './Slider/types/SliderValueProps';export { Switch } from './Switch/Switch';export type { SwitchProps } from './Switch/types/SwitchProps';+export type { SwitchRootProps } from './Switch/types/SwitchRootProps';export type { SwitchSize } from './Switch/types/SwitchSize';+export type { SwitchThumbProps } from './Switch/types/SwitchThumbProps';export { Textarea } from './Textarea/Textarea';export type { TextareaProps } from './Textarea/types/TextareaProps';export type { InputSize } from './types/InputSize';diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/internal/ListItemCheckboxIndicator.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/internal/ListItemCheckboxIndicator.tsxindex 705826b209c..1bf1f2894b1 100644--- a/packages/twenty-ui/src/primitives/navigation/ListItem/internal/ListItemCheckboxIndicator.tsx+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/internal/ListItemCheckboxIndicator.tsx@@ -24,12 +24,10 @@ export const ListItemCheckboxIndicator = ({data-checked={checked || undefined}data-disabled={disabled || undefined}>- <span className={checkboxStyles.box}>- {checked && (- <span className={checkboxStyles.indicator}>- <IconCheck aria-hidden />- </span>- )}- </span>+ {checked && (+ <span className={checkboxStyles.indicator}>+ <IconCheck aria-hidden />+ </span>+ )}</span>);