The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Add AlertDialog compound to twenty-ui (#25665)
Raphaël Bosi7a95c177372b
diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/AlertDialog.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/AlertDialog.tsxnew file mode 100644index 00000000000..ff88a3144e2--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/AlertDialog.tsx@@ -0,0 +1,23 @@+import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';++import { AlertDialogBody } from './internal/AlertDialogBody';+import { AlertDialogDescription } from './internal/AlertDialogDescription';+import { AlertDialogFooter } from './internal/AlertDialogFooter';+import { AlertDialogHeader } from './internal/AlertDialogHeader';+import { AlertDialogPopup } from './internal/AlertDialogPopup';+import { AlertDialogTitle } from './internal/AlertDialogTitle';++const createAlertDialog = () => ({+ Root: AlertDialogPrimitive.Root,+ Trigger: AlertDialogPrimitive.Trigger,+ Popup: AlertDialogPopup,+ Title: AlertDialogTitle,+ Description: AlertDialogDescription,+ Close: AlertDialogPrimitive.Close,+ Header: AlertDialogHeader,+ Body: AlertDialogBody,+ Footer: AlertDialogFooter,+});++// Base UI namespace reads would otherwise retain AlertDialog in unrelated imports.+export const AlertDialog = /* @__PURE__ */ createAlertDialog();diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.interactions.stories.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.interactions.stories.tsxnew file mode 100644index 00000000000..ece6a529dfb--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.interactions.stories.tsx@@ -0,0 +1,321 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { useRef, useState } from 'react';+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';++import { Input } from '@ui/input/Input/Input';+import { ComponentDecorator } from '@ui/testing';++import { AlertDialog } from '../AlertDialog';+import { AlertDialogExample } from './AlertDialogExample';+import styles from './AlertDialog.stories.module.scss';+import { waitForAlertDialog } from './waitForAlertDialog';++const meta: Meta<typeof AlertDialogExample> = {+ title: 'UI/Surfaces/AlertDialog',+ component: AlertDialogExample,+};++export default meta;+type Story = StoryObj<typeof AlertDialogExample>;++export const KeyboardAndDismissal: Story = {+ decorators: [ComponentDecorator],+ args: { onOpenChange: fn() },+ play: async ({ args, canvasElement, step }) => {+ const canvas = within(canvasElement);+ const body = within(canvasElement.ownerDocument.body);+ const trigger = canvas.getByRole('button', { name: 'Delete record' });+ const initialOverflow = canvasElement.ownerDocument.body.style.overflow;++ await step('Open from the keyboard and focus the safe action', async () => {+ trigger.focus();+ await userEvent.keyboard('{Enter}');+ const dialog = await waitForAlertDialog(canvasElement);+ expect(canvasElement.ownerDocument.body.style.overflow).toBe('hidden');+ expect(trigger).toHaveAttribute('aria-expanded', 'true');+ expect(trigger).toHaveAttribute('aria-controls', dialog.id);+ await waitFor(() =>+ expect(body.getByRole('button', { name: 'Cancel' })).toHaveFocus(),+ );+ expect(args.onOpenChange).toHaveBeenLastCalledWith(+ true,+ expect.objectContaining({ reason: 'trigger-press' }),+ );+ });++ await step('Keep forward and backward tab navigation inside', async () => {+ await userEvent.tab();+ await waitFor(() =>+ expect(body.getByRole('button', { name: 'Delete' })).toHaveFocus(),+ );+ await userEvent.tab();+ await waitFor(() =>+ expect(body.getByRole('button', { name: 'Cancel' })).toHaveFocus(),+ );+ await userEvent.tab({ shift: true });+ await waitFor(() =>+ expect(body.getByRole('button', { name: 'Delete' })).toHaveFocus(),+ );+ });++ await step(+ 'Require a response instead of dismissing on outside click',+ async () => {+ const dialog = body.getByRole('alertdialog');+ const viewport = dialog.parentElement;+ const outsideTarget = canvasElement.ownerDocument.elementFromPoint(+ 1,+ 1,+ );++ expect(outsideTarget).not.toBeNull();+ expect(outsideTarget).toBe(viewport);+ await userEvent.pointer({+ keys: '[MouseLeft]',+ target: outsideTarget!,+ coords: { clientX: 1, clientY: 1 },+ });+ expect(dialog).toBeVisible();+ expect(args.onOpenChange).toHaveBeenCalledTimes(1);+ },+ );++ await step(+ 'Escape dismisses and returns focus to the trigger',+ async () => {+ await userEvent.keyboard('{Escape}');+ await waitFor(() =>+ expect(body.queryByRole('alertdialog')).not.toBeInTheDocument(),+ );+ await waitFor(() => expect(trigger).toHaveFocus());+ expect(canvasElement.ownerDocument.body.style.overflow).toBe(+ initialOverflow,+ );+ expect(args.onOpenChange).toHaveBeenLastCalledWith(+ false,+ expect.objectContaining({ reason: 'escape-key' }),+ );+ },+ );++ await step('Cancel and confirmation both close the dialog', async () => {+ for (const name of ['Cancel', 'Delete']) {+ await userEvent.click(trigger);+ await waitForAlertDialog(canvasElement);+ await userEvent.click(body.getByRole('button', { name }));+ await waitFor(() =>+ expect(body.queryByRole('alertdialog')).not.toBeInTheDocument(),+ );+ expect(args.onOpenChange).toHaveBeenLastCalledWith(+ false,+ expect.objectContaining({ reason: 'close-press' }),+ );+ }+ });+ },+};++const ControlledAlertDialog = () => {+ const [open, setOpen] = useState(false);+ const [deleted, setDeleted] = useState(false);++ return (+ <>+ <p>{deleted ? 'Record deleted' : 'Record available'}</p>+ <AlertDialog.Root open={open} onOpenChange={setOpen}>+ <AlertDialog.Trigger className={styles.button}>+ Delete record+ </AlertDialog.Trigger>+ <AlertDialog.Popup>+ <AlertDialog.Header>+ <AlertDialog.Title>Delete this record?</AlertDialog.Title>+ <AlertDialog.Description>+ This action cannot be undone.+ </AlertDialog.Description>+ </AlertDialog.Header>+ <AlertDialog.Footer>+ <AlertDialog.Close className={styles.button}>+ Cancel+ </AlertDialog.Close>+ <button+ type="button"+ className={styles.button}+ onClick={() => {+ setDeleted(true);+ setOpen(false);+ }}+ >+ Confirm deletion+ </button>+ </AlertDialog.Footer>+ </AlertDialog.Popup>+ </AlertDialog.Root>+ </>+ );+};++export const Controlled: Story = {+ decorators: [ComponentDecorator],+ render: () => <ControlledAlertDialog />,+ play: async ({ canvasElement }) => {+ await userEvent.click(+ within(canvasElement).getByRole('button', { name: 'Delete record' }),+ );+ const dialog = await waitForAlertDialog(canvasElement);+ await userEvent.click(+ within(dialog).getByRole('button', { name: 'Confirm deletion' }),+ );+ await waitFor(() => expect(dialog).not.toBeInTheDocument());+ expect(within(canvasElement).getByText('Record deleted')).toBeVisible();+ },+};++export const DisabledTrigger: Story = {+ decorators: [ComponentDecorator],+ args: { disabled: true, onOpenChange: fn() },+ play: async ({ args, canvasElement }) => {+ const trigger = within(canvasElement).getByRole('button', {+ name: 'Delete record',+ });+ expect(trigger).toBeDisabled();+ await userEvent.click(trigger);+ expect(args.onOpenChange).not.toHaveBeenCalled();+ expect(+ within(canvasElement.ownerDocument.body).queryByRole('alertdialog'),+ ).not.toBeInTheDocument();+ },+};++export const KeepMounted: Story = {+ decorators: [ComponentDecorator],+ args: {+ popupProps: { keepMounted: true },+ content: <Input aria-label="Reason" />,+ },+ play: async ({ canvasElement }) => {+ const body = within(canvasElement.ownerDocument.body);+ const trigger = within(canvasElement).getByRole('button', {+ name: 'Delete record',+ });+ expect(body.getByRole('alertdialog', { hidden: true })).not.toBeVisible();+ await userEvent.click(trigger);+ const dialog = await waitForAlertDialog(canvasElement);+ await userEvent.type(+ within(dialog).getByRole('textbox', { name: 'Reason' }),+ 'Duplicate',+ );+ await userEvent.click(+ within(dialog).getByRole('button', { name: 'Cancel' }),+ );+ await waitFor(() => expect(dialog).not.toBeVisible());+ expect(dialog).toBeInTheDocument();+ await userEvent.click(trigger);+ await waitForAlertDialog(canvasElement);+ expect(within(dialog).getByRole('textbox', { name: 'Reason' })).toHaveValue(+ 'Duplicate',+ );+ },+};++const CustomFocusAlertDialog = () => {+ const initialFocus = useRef<HTMLInputElement>(null);+ const finalFocus = useRef<HTMLButtonElement>(null);++ return (+ <>+ <AlertDialogExample+ popupProps={{ initialFocus, finalFocus }}+ content={<Input ref={initialFocus} aria-label="Confirmation" />}+ />+ <button type="button" ref={finalFocus}>+ Next record+ </button>+ </>+ );+};++export const CustomFocus: Story = {+ decorators: [ComponentDecorator],+ render: () => <CustomFocusAlertDialog />,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await userEvent.click(+ canvas.getByRole('button', { name: 'Delete record' }),+ );+ const dialog = await waitForAlertDialog(canvasElement);+ await waitFor(() =>+ expect(+ within(dialog).getByRole('textbox', { name: 'Confirmation' }),+ ).toHaveFocus(),+ );+ await userEvent.keyboard('{Escape}');+ await waitFor(() => expect(dialog).not.toBeInTheDocument());+ await waitFor(() =>+ expect(canvas.getByRole('button', { name: 'Next record' })).toHaveFocus(),+ );+ },+};++export const CanceledClose: Story = {+ decorators: [ComponentDecorator],+ args: {+ defaultOpen: true,+ onOpenChange: (open, eventDetails) => {+ if (!open && eventDetails.reason === 'escape-key') {+ eventDetails.cancel();+ }+ },+ },+ play: async ({ canvasElement }) => {+ const dialog = await waitForAlertDialog(canvasElement);+ await userEvent.keyboard('{Escape}');+ expect(dialog).toBeVisible();+ await userEvent.click(+ within(dialog).getByRole('button', { name: 'Cancel' }),+ );+ await waitFor(() => expect(dialog).not.toBeInTheDocument());+ },+};++export const Nested: Story = {+ decorators: [ComponentDecorator],+ args: { defaultOpen: true, content: <AlertDialogExample /> },+ play: async ({ canvasElement }) => {+ const parentDialog = await waitForAlertDialog(canvasElement);+ const nestedTrigger = within(parentDialog).getByRole('button', {+ name: 'Delete record',+ });+ await userEvent.click(nestedTrigger);+ const nestedDialog = await waitForAlertDialog(canvasElement);+ expect(nestedDialog).not.toBe(parentDialog);+ expect(nestedDialog).toHaveAttribute('data-nested');+ expect(parentDialog).toHaveAttribute('data-nested-dialog-open');+ await userEvent.keyboard('{Escape}');+ await waitFor(() => expect(nestedDialog).not.toBeInTheDocument());+ expect(parentDialog).toBeVisible();+ await waitFor(() => expect(nestedTrigger).toHaveFocus());+ },+};++export const Scrollable: Story = {+ decorators: [ComponentDecorator],+ args: {+ defaultOpen: true,+ content: Array.from({ length: 50 }, (_, index) => (+ <p key={index}>Record {index + 1} will be removed.</p>+ )),+ },+ play: async ({ canvasElement }) => {+ const dialog = await waitForAlertDialog(canvasElement);+ expect(dialog.scrollHeight).toBeGreaterThan(dialog.clientHeight);+ const bounds = dialog.getBoundingClientRect();+ expect(bounds.top).toBeGreaterThanOrEqual(0);+ expect(bounds.bottom).toBeLessThanOrEqual(+ canvasElement.ownerDocument.documentElement.clientHeight,+ );+ await userEvent.click(+ within(dialog).getByRole('button', { name: 'Cancel' }),+ );+ await waitFor(() => expect(dialog).not.toBeInTheDocument());+ },+};diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.portals.stories.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.portals.stories.tsxnew file mode 100644index 00000000000..9703a6a96a3--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.portals.stories.tsx@@ -0,0 +1,160 @@+import { DirectionProvider } from '@base-ui/react/direction-provider';+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { useRef, useState } from 'react';+import { expect, userEvent, waitFor, within } from 'storybook/test';++import { ComponentDecorator } from '@ui/testing';+import { ThemeProvider } from '@ui/theme-constants/ThemeProvider';++import { AlertDialogExample } from './AlertDialogExample';+import { waitForAlertDialog } from './waitForAlertDialog';++const meta: Meta<typeof AlertDialogExample> = {+ title: 'UI/Surfaces/AlertDialog',+ component: AlertDialogExample,+};++export default meta;+type Story = StoryObj<typeof AlertDialogExample>;++export const ScopedThemeAndDirection: Story = {+ decorators: [ComponentDecorator],+ render: () => (+ <DirectionProvider direction="rtl">+ <ThemeProvider colorScheme="dark" applyToRoot={false}>+ <div data-testid="theme-scope">+ <div+ data-testid="theme-color"+ style={{ backgroundColor: 'var(--t-background-primary)' }}+ />+ <AlertDialogExample defaultOpen />+ </div>+ </ThemeProvider>+ </DirectionProvider>+ ),+ play: async ({ canvasElement }) => {+ const dialog = await waitForAlertDialog(canvasElement);+ const colorSample = within(canvasElement).getByTestId('theme-color');+ expect(canvasElement).toContainElement(dialog);+ expect(dialog.closest('.dark')).not.toBeNull();+ expect(getComputedStyle(dialog).direction).toBe('rtl');+ expect(getComputedStyle(dialog).backgroundColor).toBe(+ getComputedStyle(colorSample).backgroundColor,+ );+ const cancel = within(dialog).getByRole('button', { name: 'Cancel' });+ const confirm = within(dialog).getByRole('button', {+ name: 'Delete',+ });+ expect(cancel.getBoundingClientRect().left).toBeGreaterThan(+ confirm.getBoundingClientRect().left,+ );+ },+};++const ExplicitContainerAlertDialog = () => {+ const [container, setContainer] = useState<HTMLDivElement | null>(null);++ return (+ <>+ <div ref={setContainer} data-testid="portal-container" />+ <ThemeProvider colorScheme="dark" applyToRoot={false}>+ <AlertDialogExample defaultOpen popupProps={{ container }} />+ </ThemeProvider>+ </>+ );+};++export const ExplicitContainer: Story = {+ decorators: [ComponentDecorator],+ render: () => <ExplicitContainerAlertDialog />,+ play: async ({ canvasElement }) => {+ const dialog = await waitForAlertDialog(canvasElement);+ expect(+ within(canvasElement).getByTestId('portal-container'),+ ).toContainElement(dialog);+ expect(dialog.closest('.dark')).toBeNull();+ },+};++const DeferredContainerAlertDialog = () => {+ const containerRef = useRef<HTMLDivElement>(null);+ const [container, setContainer] = useState<HTMLDivElement | null>(null);++ return (+ <ThemeProvider colorScheme="light" applyToRoot={false}>+ <div ref={containerRef} data-testid="deferred-container" />+ <button type="button" onClick={() => setContainer(containerRef.current)}>+ Attach container+ </button>+ <AlertDialogExample defaultOpen popupProps={{ container }} />+ </ThemeProvider>+ );+};++export const DeferredContainer: Story = {+ decorators: [ComponentDecorator],+ render: () => <DeferredContainerAlertDialog />,+ play: async ({ canvasElement }) => {+ const body = within(canvasElement.ownerDocument.body);+ expect(body.queryByRole('alertdialog')).not.toBeInTheDocument();+ const canvas = within(canvasElement);+ await userEvent.click(+ canvas.getByRole('button', { name: 'Attach container' }),+ );+ const dialog = await waitForAlertDialog(canvasElement);+ expect(canvas.getByTestId('deferred-container')).toContainElement(dialog);+ },+};++const RefContainerAlertDialog = () => {+ const container = useRef<HTMLDivElement>(null);++ return (+ <>+ <div ref={container} data-testid="ref-container" />+ <AlertDialogExample defaultOpen popupProps={{ container }} />+ </>+ );+};++export const RefContainer: Story = {+ decorators: [ComponentDecorator],+ render: () => <RefContainerAlertDialog />,+ play: async ({ canvasElement }) => {+ const dialog = await waitForAlertDialog(canvasElement);+ expect(within(canvasElement).getByTestId('ref-container')).toContainElement(+ dialog,+ );+ },+};++export const RenderComposition: Story = {+ decorators: [ComponentDecorator],+ args: {+ popupProps: {+ render: (props, state) => (+ <section {...props} data-render-open={state.open} />+ ),+ className: (state) => (state.open ? 'consumer-open' : 'consumer-closed'),+ style: (state) => ({+ borderTopWidth: state.open ? 3 : 1,+ borderTopStyle: 'solid',+ }),+ },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await userEvent.click(+ canvas.getByRole('button', { name: 'Delete record' }),+ );+ const dialog = await waitForAlertDialog(canvasElement);+ expect(dialog.tagName).toBe('SECTION');+ expect(dialog).toHaveAttribute('data-render-open', 'true');+ expect(dialog).toHaveClass('consumer-open');+ expect(dialog).toHaveStyle({ borderTopWidth: '3px' });+ await userEvent.click(+ within(dialog).getByRole('button', { name: 'Cancel' }),+ );+ await waitFor(() => expect(dialog).not.toBeInTheDocument());+ },+};diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.stories.module.scss b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.stories.module.scssnew file mode 100644index 00000000000..1d30c88e003--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.stories.module.scss@@ -0,0 +1,37 @@+.button {+ align-items: center;+ background: var(--t-background-primary);+ border: 1px solid var(--t-border-color-strong);+ border-radius: var(--t-border-radius-sm);+ color: var(--t-font-color-primary);+ cursor: pointer;+ display: inline-flex;+ font-family: var(--t-font-family);+ font-size: var(--t-font-size-md);+ font-weight: var(--t-font-weight-medium);+ justify-content: center;+ min-block-size: var(--t-spacing-8);+ padding: var(--t-spacing-1) var(--t-spacing-3);++ @include focus-ring;++ &:hover {+ background: var(--t-background-tertiary);+ }++ &[data-danger] {+ color: var(--t-color-red11);+ }++ &:disabled {+ color: var(--t-font-color-tertiary);+ cursor: not-allowed;+ }+}++.record {+ background: var(--t-background-secondary);+ border: 1px solid var(--t-border-color-medium);+ border-radius: var(--t-border-radius-sm);+ padding: var(--t-spacing-3);+}diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.stories.module.scss.d.ts b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.stories.module.scss.d.tsnew file mode 100644index 00000000000..cf7b19e25bf--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.stories.module.scss.d.ts@@ -0,0 +1,5 @@+declare const classNames: {+ readonly button: 'button';+ readonly record: 'record';+};+export default classNames;diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.stories.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.stories.tsxnew file mode 100644index 00000000000..fe5c86b51e6--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialog.stories.tsx@@ -0,0 +1,79 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, within } from 'storybook/test';++import { ComponentDecorator } from '@ui/testing';++import { AlertDialogExample } from './AlertDialogExample';+import styles from './AlertDialog.stories.module.scss';+import { waitForAlertDialog } from './waitForAlertDialog';++const meta: Meta<typeof AlertDialogExample> = {+ title: 'UI/Surfaces/AlertDialog',+ component: AlertDialogExample,+ argTypes: {+ size: {+ control: 'select',+ options: ['sm', 'md', 'lg', 'xl', 'fullscreen'],+ },+ },+};++export default meta;+type Story = StoryObj<typeof AlertDialogExample>;++export const Default: Story = {+ decorators: [ComponentDecorator],+ args: { defaultOpen: true },+ play: async ({ canvasElement }) => {+ const dialog = await waitForAlertDialog(canvasElement);+ const body = within(canvasElement.ownerDocument.body);++ expect(dialog).toHaveAccessibleName('Delete this record?');+ expect(dialog).toHaveAccessibleDescription(+ 'This record will be permanently deleted. This action cannot be undone.',+ );+ expect(dialog).toHaveAttribute(+ 'aria-labelledby',+ body.getByRole('heading', { name: 'Delete this record?' }).id,+ );+ expect(canvasElement).not.toContainElement(dialog);+ const bounds = dialog.getBoundingClientRect();+ const viewport = canvasElement.ownerDocument.documentElement;++ expect(bounds.left).toBeGreaterThanOrEqual(0);+ expect(bounds.top).toBeGreaterThanOrEqual(0);+ expect(bounds.right).toBeLessThanOrEqual(viewport.clientWidth);+ expect(bounds.bottom).toBeLessThanOrEqual(viewport.clientHeight);+ },+};++export const Small: Story = {+ ...Default,+ args: { defaultOpen: true, size: 'sm' },+};+export const Large: Story = {+ ...Default,+ args: { defaultOpen: true, size: 'lg' },+};+export const ExtraLarge: Story = {+ ...Default,+ args: { defaultOpen: true, size: 'xl' },+};+export const Fullscreen: Story = {+ ...Default,+ args: { defaultOpen: true, size: 'fullscreen' },+};++export const Catalog: Story = {+ ...Default,+ args: {+ defaultOpen: true,+ content: <div className={styles.record}>Acme · Company record</div>,+ },+};++export const CatalogDark: Story = {+ ...Catalog,+ tags: ['!autodocs'],+ globals: { colorScheme: 'dark' },+};diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialogExample.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialogExample.tsxnew file mode 100644index 00000000000..8548dc0a3bb--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/AlertDialogExample.tsx@@ -0,0 +1,43 @@+import { type ReactNode } from 'react';++import { AlertDialog } from '../AlertDialog';+import { type AlertDialogPopupProps } from '../types/AlertDialogPopupProps';+import { type AlertDialogRootProps } from '../types/AlertDialogRootProps';++import styles from './AlertDialog.stories.module.scss';++export type AlertDialogExampleProps = AlertDialogRootProps & {+ size?: AlertDialogPopupProps['size'];+ popupProps?: AlertDialogPopupProps;+ disabled?: boolean;+ content?: ReactNode;+};++export const AlertDialogExample = ({+ size,+ popupProps,+ disabled,+ content,+ ...props+}: AlertDialogExampleProps) => (+ <AlertDialog.Root {...props}>+ <AlertDialog.Trigger className={styles.button} disabled={disabled}>+ Delete record+ </AlertDialog.Trigger>+ <AlertDialog.Popup size={size} {...popupProps}>+ <AlertDialog.Header>+ <AlertDialog.Title>Delete this record?</AlertDialog.Title>+ <AlertDialog.Description>+ This record will be permanently deleted. This action cannot be undone.+ </AlertDialog.Description>+ </AlertDialog.Header>+ {content && <AlertDialog.Body>{content}</AlertDialog.Body>}+ <AlertDialog.Footer>+ <AlertDialog.Close className={styles.button}>Cancel</AlertDialog.Close>+ <AlertDialog.Close className={styles.button} data-danger>+ Delete+ </AlertDialog.Close>+ </AlertDialog.Footer>+ </AlertDialog.Popup>+ </AlertDialog.Root>+);diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/waitForAlertDialog.ts b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/waitForAlertDialog.tsnew file mode 100644index 00000000000..661905482c2--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/__stories__/waitForAlertDialog.ts@@ -0,0 +1,14 @@+import { expect, waitFor, within } from 'storybook/test';++export const waitForAlertDialog = async (canvasElement: HTMLElement) => {+ const dialog = await within(canvasElement.ownerDocument.body).findByRole(+ 'alertdialog',+ );++ await waitFor(() => {+ expect(dialog).toBeVisible();+ expect(getComputedStyle(dialog).opacity).toBe('1');+ });++ return dialog;+};diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/__tests__/AlertDialog.test.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/__tests__/AlertDialog.test.tsxnew file mode 100644index 00000000000..8b979ff5773--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/__tests__/AlertDialog.test.tsx@@ -0,0 +1,72 @@+import { type ReactNode } from 'react';++import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';++import styles from '../../internal/Dialog.module.scss';+import { AlertDialog } from '../AlertDialog';++const AlertDialogRootWrapper = ({ children }: { children: ReactNode }) => (+ <AlertDialog.Root>{children}</AlertDialog.Root>+);+const OpenAlertDialogWrapper = ({ children }: { children: ReactNode }) => (+ <AlertDialog.Root open>{children}</AlertDialog.Root>+);+const AlertDialogPopupWrapper = ({ children }: { children: ReactNode }) => (+ <AlertDialog.Root open>+ <AlertDialog.Popup initialFocus={false}>{children}</AlertDialog.Popup>+ </AlertDialog.Root>+);++runComponentConformance({+ name: 'AlertDialog.Trigger',+ element: <AlertDialog.Trigger>Open</AlertDialog.Trigger>,+ refInstanceOf: HTMLButtonElement,+ wrapper: AlertDialogRootWrapper,+ renderPropTagName: 'button',+});+runComponentConformance({+ name: 'AlertDialog.Popup',+ element: <AlertDialog.Popup initialFocus={false} />,+ refInstanceOf: HTMLDivElement,+ wrapper: OpenAlertDialogWrapper,+ ownClassName: styles.popup,+});+runComponentConformance({+ name: 'AlertDialog.Title',+ element: <AlertDialog.Title>Title</AlertDialog.Title>,+ refInstanceOf: HTMLHeadingElement,+ wrapper: AlertDialogPopupWrapper,+ ownClassName: styles.title,+});+runComponentConformance({+ name: 'AlertDialog.Description',+ element: <AlertDialog.Description>Description</AlertDialog.Description>,+ refInstanceOf: HTMLParagraphElement,+ wrapper: AlertDialogPopupWrapper,+ ownClassName: styles.description,+});+runComponentConformance({+ name: 'AlertDialog.Close',+ element: <AlertDialog.Close>Cancel</AlertDialog.Close>,+ refInstanceOf: HTMLButtonElement,+ wrapper: AlertDialogPopupWrapper,+ renderPropTagName: 'button',+});+runComponentConformance({+ name: 'AlertDialog.Header',+ element: <AlertDialog.Header>Header</AlertDialog.Header>,+ refInstanceOf: HTMLDivElement,+ ownClassName: styles.header,+});+runComponentConformance({+ name: 'AlertDialog.Body',+ element: <AlertDialog.Body>Body</AlertDialog.Body>,+ refInstanceOf: HTMLDivElement,+ ownClassName: styles.body,+});+runComponentConformance({+ name: 'AlertDialog.Footer',+ element: <AlertDialog.Footer>Footer</AlertDialog.Footer>,+ refInstanceOf: HTMLDivElement,+ ownClassName: styles.footer,+});diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogBody.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogBody.tsxnew file mode 100644index 00000000000..e75143eaad2--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogBody.tsx@@ -0,0 +1,17 @@+import { useRender } from '@base-ui/react/use-render';+import { clsx } from 'clsx';++import styles from '../../internal/Dialog.module.scss';+import { type AlertDialogBodyProps } from '../types/AlertDialogBodyProps';++export const AlertDialogBody = ({+ render,+ ref,+ className,+ ...props+}: AlertDialogBodyProps) =>+ useRender({+ render,+ ref,+ props: { ...props, className: clsx(styles.body, className) },+ });diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogDescription.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogDescription.tsxnew file mode 100644index 00000000000..d6bc78290e1--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogDescription.tsx@@ -0,0 +1,16 @@+import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';++import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';++import styles from '../../internal/Dialog.module.scss';+import { type AlertDialogDescriptionProps } from '../types/AlertDialogDescriptionProps';++export const AlertDialogDescription = ({+ className,+ ...props+}: AlertDialogDescriptionProps) => (+ <AlertDialogPrimitive.Description+ {...props}+ className={mergeClassNames(styles.description, className)}+ />+);diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogFooter.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogFooter.tsxnew file mode 100644index 00000000000..087385c3ff5--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogFooter.tsx@@ -0,0 +1,17 @@+import { useRender } from '@base-ui/react/use-render';+import { clsx } from 'clsx';++import styles from '../../internal/Dialog.module.scss';+import { type AlertDialogFooterProps } from '../types/AlertDialogFooterProps';++export const AlertDialogFooter = ({+ render,+ ref,+ className,+ ...props+}: AlertDialogFooterProps) =>+ useRender({+ render,+ ref,+ props: { ...props, className: clsx(styles.footer, className) },+ });diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogHeader.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogHeader.tsxnew file mode 100644index 00000000000..3ba8d0ee6e7--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogHeader.tsx@@ -0,0 +1,17 @@+import { useRender } from '@base-ui/react/use-render';+import { clsx } from 'clsx';++import styles from '../../internal/Dialog.module.scss';+import { type AlertDialogHeaderProps } from '../types/AlertDialogHeaderProps';++export const AlertDialogHeader = ({+ render,+ ref,+ className,+ ...props+}: AlertDialogHeaderProps) =>+ useRender({+ render,+ ref,+ props: { ...props, className: clsx(styles.header, className) },+ });diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogPopup.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogPopup.tsxnew file mode 100644index 00000000000..79d7a1e39b4--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogPopup.tsx@@ -0,0 +1,40 @@+import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';+import { useDirection } from '@base-ui/react/direction-provider';++import { useThemeContainer } from '@ui/theme-constants';+import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';++import styles from '../../internal/Dialog.module.scss';+import { type AlertDialogPopupProps } from '../types/AlertDialogPopupProps';++export const AlertDialogPopup = ({+ size = 'md',+ container,+ keepMounted,+ className,+ ...props+}: AlertDialogPopupProps) => {+ const themeContainer = useThemeContainer();+ const direction = useDirection();++ return (+ <AlertDialogPrimitive.Portal+ container={+ container === undefined ? (themeContainer ?? undefined) : container+ }+ keepMounted={keepMounted}+ >+ <AlertDialogPrimitive.Backdrop className={styles.backdrop} />+ <AlertDialogPrimitive.Viewport+ dir={direction}+ className={styles.viewport}+ >+ <AlertDialogPrimitive.Popup+ {...props}+ data-size={size}+ className={mergeClassNames(styles.popup, className)}+ />+ </AlertDialogPrimitive.Viewport>+ </AlertDialogPrimitive.Portal>+ );+};diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogTitle.tsx b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogTitle.tsxnew file mode 100644index 00000000000..840156c4664--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/internal/AlertDialogTitle.tsx@@ -0,0 +1,16 @@+import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';++import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';++import styles from '../../internal/Dialog.module.scss';+import { type AlertDialogTitleProps } from '../types/AlertDialogTitleProps';++export const AlertDialogTitle = ({+ className,+ ...props+}: AlertDialogTitleProps) => (+ <AlertDialogPrimitive.Title+ {...props}+ className={mergeClassNames(styles.title, className)}+ />+);diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogBodyProps.ts b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogBodyProps.tsnew file mode 100644index 00000000000..501cfcf5fb8--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogBodyProps.ts@@ -0,0 +1,3 @@+import { type useRender } from '@base-ui/react/use-render';++export type AlertDialogBodyProps = useRender.ComponentProps<'div'>;diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogCloseProps.ts b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogCloseProps.tsnew file mode 100644index 00000000000..368afb768e8--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogCloseProps.ts@@ -0,0 +1,3 @@+import { type AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';++export type AlertDialogCloseProps = AlertDialogPrimitive.Close.Props;diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogDescriptionProps.ts b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogDescriptionProps.tsnew file mode 100644index 00000000000..5abb542f849--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogDescriptionProps.ts@@ -0,0 +1,4 @@+import { type AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';++export type AlertDialogDescriptionProps =+ AlertDialogPrimitive.Description.Props;diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogFooterProps.ts b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogFooterProps.tsnew file mode 100644index 00000000000..968db467396--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogFooterProps.ts@@ -0,0 +1,3 @@+import { type useRender } from '@base-ui/react/use-render';++export type AlertDialogFooterProps = useRender.ComponentProps<'div'>;diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogHeaderProps.ts b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogHeaderProps.tsnew file mode 100644index 00000000000..994b92a8465--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogHeaderProps.ts@@ -0,0 +1,3 @@+import { type useRender } from '@base-ui/react/use-render';++export type AlertDialogHeaderProps = useRender.ComponentProps<'div'>;diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogPopupProps.ts b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogPopupProps.tsnew file mode 100644index 00000000000..59f412d8a13--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogPopupProps.ts@@ -0,0 +1,9 @@+import { type AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';++import { type AlertDialogSize } from './AlertDialogSize';++export type AlertDialogPopupProps = AlertDialogPrimitive.Popup.Props & {+ size?: AlertDialogSize;+ container?: AlertDialogPrimitive.Portal.Props['container'];+ keepMounted?: boolean;+};diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogRootProps.ts b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogRootProps.tsnew file mode 100644index 00000000000..b7841014ab0--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogRootProps.ts@@ -0,0 +1,4 @@+import { type AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';++export type AlertDialogRootProps<TPayload = unknown> =+ AlertDialogPrimitive.Root.Props<TPayload>;diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogSize.ts b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogSize.tsnew file mode 100644index 00000000000..0ce38c1471c--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogSize.ts@@ -0,0 +1 @@+export type AlertDialogSize = 'sm' | 'md' | 'lg' | 'xl' | 'fullscreen';diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogTitleProps.ts b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogTitleProps.tsnew file mode 100644index 00000000000..8fce2f7bf47--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogTitleProps.ts@@ -0,0 +1,3 @@+import { type AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';++export type AlertDialogTitleProps = AlertDialogPrimitive.Title.Props;diff --git a/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogTriggerProps.ts b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogTriggerProps.tsnew file mode 100644index 00000000000..40788a4c967--- /dev/null+++ b/packages/twenty-ui/src/surfaces/AlertDialog/types/AlertDialogTriggerProps.ts@@ -0,0 +1,4 @@+import { type AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';++export type AlertDialogTriggerProps<TPayload = unknown> =+ AlertDialogPrimitive.Trigger.Props<TPayload>;diff --git a/packages/twenty-ui/src/surfaces/index.ts b/packages/twenty-ui/src/surfaces/index.tsindex 9eee0aa84db..c9dce700aed 100644--- a/packages/twenty-ui/src/surfaces/index.ts+++ b/packages/twenty-ui/src/surfaces/index.ts@@ -7,6 +7,17 @@* |___/*/+export { AlertDialog } from './AlertDialog/AlertDialog';+export type { AlertDialogBodyProps } from './AlertDialog/types/AlertDialogBodyProps';+export type { AlertDialogCloseProps } from './AlertDialog/types/AlertDialogCloseProps';+export type { AlertDialogDescriptionProps } from './AlertDialog/types/AlertDialogDescriptionProps';+export type { AlertDialogFooterProps } from './AlertDialog/types/AlertDialogFooterProps';+export type { AlertDialogHeaderProps } from './AlertDialog/types/AlertDialogHeaderProps';+export type { AlertDialogPopupProps } from './AlertDialog/types/AlertDialogPopupProps';+export type { AlertDialogRootProps } from './AlertDialog/types/AlertDialogRootProps';+export type { AlertDialogSize } from './AlertDialog/types/AlertDialogSize';+export type { AlertDialogTitleProps } from './AlertDialog/types/AlertDialogTitleProps';+export type { AlertDialogTriggerProps } from './AlertDialog/types/AlertDialogTriggerProps';export type { AppTooltipProps } from './AppTooltip/AppTooltip';export {TooltipPosition,diff --git a/packages/twenty-ui/src/surfaces/internal/Dialog.module.scss b/packages/twenty-ui/src/surfaces/internal/Dialog.module.scssnew file mode 100644index 00000000000..86536a987c1--- /dev/null+++ b/packages/twenty-ui/src/surfaces/internal/Dialog.module.scss@@ -0,0 +1,122 @@+.backdrop {+ background: var(--t-background-overlay-primary);+ inset: 0;+ position: fixed;+ transition: opacity duration(normal) ease-out;+ z-index: 39;++ &[data-starting-style],+ &[data-ending-style] {+ opacity: 0;+ }+}++.viewport {+ align-items: center;+ box-sizing: border-box;+ display: flex;+ inset: 0;+ justify-content: center;+ overflow: auto;+ overscroll-behavior: contain;+ padding: var(--t-spacing-4);+ position: fixed;+ z-index: 40;++ &[hidden] {+ display: none;+ }++ &:has(> [data-size='fullscreen']) {+ padding: 0;+ }+}++.popup {+ background: var(--t-background-primary);+ border-radius: var(--t-border-radius-md);+ box-shadow: var(--t-box-shadow-super-heavy);+ box-sizing: border-box;+ color: var(--t-font-color-primary);+ display: flex;+ flex-direction: column;+ flex-shrink: 0;+ font-family: var(--t-font-family);+ font-size: var(--t-font-size-md);+ inline-size: var(--t-modal-size-md-width);+ max-block-size: calc(100dvh / var(--t-zoom, 1) - var(--t-spacing-8));+ max-inline-size: 100%;+ outline: none;+ overflow: auto;+ overscroll-behavior: contain;+ transition: opacity duration(normal) ease-out;++ &[hidden] {+ display: none;+ }++ &[data-starting-style],+ &[data-ending-style] {+ opacity: 0;+ }++ &[data-size='sm'] {+ inline-size: var(--t-modal-size-sm-width);+ }++ &[data-size='lg'] {+ inline-size: max(+ var(--t-modal-size-md-width),+ var(--t-modal-size-lg-width)+ );+ }++ &[data-size='xl'] {+ inline-size: var(--t-modal-size-xl-width);+ }++ &[data-size='fullscreen'] {+ block-size: var(--t-modal-size-fullscreen-height);+ border-radius: 0;+ box-shadow: none;+ inline-size: 100%;+ max-block-size: none;+ }+}++.header {+ display: flex;+ flex-direction: column;+ flex-shrink: 0;+ gap: var(--t-spacing-2);+ padding: var(--t-spacing-6);+}++.body {+ padding: 0 var(--t-spacing-6) var(--t-spacing-6);+}++.footer {+ align-items: center;+ display: flex;+ flex-shrink: 0;+ flex-wrap: wrap;+ gap: var(--t-spacing-2);+ justify-content: flex-end;+ margin-block-start: auto;+ padding: 0 var(--t-spacing-6) var(--t-spacing-6);+}++.title {+ color: var(--t-font-color-primary);+ font-size: var(--t-font-size-lg);+ font-weight: var(--t-font-weight-semi-bold);+ margin: 0;+}++.description {+ color: var(--t-font-color-secondary);+ font-size: var(--t-font-size-md);+ line-height: 1.5;+ margin: 0;+}diff --git a/packages/twenty-ui/src/surfaces/internal/Dialog.module.scss.d.ts b/packages/twenty-ui/src/surfaces/internal/Dialog.module.scss.d.tsnew file mode 100644index 00000000000..14098e8d71b--- /dev/null+++ b/packages/twenty-ui/src/surfaces/internal/Dialog.module.scss.d.ts@@ -0,0 +1,11 @@+declare const classNames: {+ readonly backdrop: 'backdrop';+ readonly viewport: 'viewport';+ readonly popup: 'popup';+ readonly header: 'header';+ readonly body: 'body';+ readonly footer: 'footer';+ readonly title: 'title';+ readonly description: 'description';+};+export default classNames;