The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Use twenty-ui date picker in the frontend (#28649)
Raphaël Bosi788380986f83
diff --git a/packages/twenty-front/package.json b/packages/twenty-front/package.jsonindex 8395a362f31..042432a5b90 100644--- a/packages/twenty-front/package.json+++ b/packages/twenty-front/package.json@@ -121,7 +121,6 @@"qs": "^6.15.2","react": "^19.2.0","react-data-grid": "7.0.0-beta.59",- "react-datepicker": "^9.1.0","react-dom": "^19.2.0","react-dropzone": "^14.2.3","react-error-boundary": "^4.0.11",diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/__stories__/DateTimeFieldInput.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/__stories__/DateTimeFieldInput.stories.tsxindex 9ca4dda0df6..32b9f3caa06 100644--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/__stories__/DateTimeFieldInput.stories.tsx+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/__stories__/DateTimeFieldInput.stories.tsx@@ -1,4 +1,5 @@import { type Meta, type StoryObj } from '@storybook/react-vite';+import { isNonEmptyString } from '@sniptt/guards';import { useEffect } from 'react';import { expect, userEvent, waitFor, within } from 'storybook/test';import { Button } from 'twenty-ui/primitives/input';@@ -23,6 +24,7 @@ const {} = getFieldInputEventContextProviderWithJestMocks();const formattedDate = new Date('2022-01-01T02:00:00.000Z');+const MONTH_ROW_LABEL_PATTERN = /^Month /;const DateFieldValueSetterEffect = ({ value }: { value: Date }) => {const { setFieldValue } = useDateTimeField();@@ -31,13 +33,13 @@ const DateFieldValueSetterEffect = ({ value }: { value: Date }) => {setFieldValue(value.toISOString());}, [setFieldValue, value]);- return <></>;+ return null;};const DateFieldValueGater = () => {const { fieldValue } = useDateTimeField();- return fieldValue ? <DateTimeFieldInput /> : null;+ return isNonEmptyString(fieldValue) ? <DateTimeFieldInput /> : null;};type DateFieldInputWithContextProps = {@@ -45,33 +47,39 @@ type DateFieldInputWithContextProps = {recordId: string;};-const DateFieldInputWithContext = ({- value,- recordId,-}: DateFieldInputWithContextProps) => {+const DateFieldInputFocusEffect = ({ instanceId }: { instanceId: string }) => {const { pushFocusItemToFocusStack } = usePushFocusItemToFocusStack();- const instanceId = getRecordFieldInputInstanceId({- recordId,- fieldName: 'Date',- prefix: RECORD_TABLE_CELL_INPUT_ID_PREFIX,- });useEffect(() => {pushFocusItemToFocusStack({focusId: instanceId,component: {type: FocusComponentType.OPENED_FIELD_INPUT,- instanceId: instanceId,+ instanceId,},});}, [pushFocusItemToFocusStack, instanceId]);+ return null;+};++const DateFieldInputWithContext = ({+ value,+ recordId,+}: DateFieldInputWithContextProps) => {+ const instanceId = getRecordFieldInputInstanceId({+ recordId,+ fieldName: 'Date',+ prefix: RECORD_TABLE_CELL_INPUT_ID_PREFIX,+ });+return (<RecordFieldComponentInstanceContext.Providervalue={{instanceId: instanceId,}}>+ <DateFieldInputFocusEffect instanceId={instanceId} /><FieldContext.Providervalue={{fieldDefinition: {@@ -131,17 +139,14 @@ export const Default: Story = {const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);- const calendarButton = await canvas.findByRole(- 'button',- { name: 'Select month and year' },- { timeout: 10000 },+ await userEvent.click(+ await canvas.findByRole('button', { name: 'Select month and year' }),);- await userEvent.click(calendarButton);-- // Increased timeout to account for lazy-loaded react-datepicker on slower CI runners- const div = await body.findByText('January', {}, { timeout: 10000 });-- await expect(div.innerText).toContain('January');+ const panel = await body.findByRole('dialog', {+ name: 'Select month and year',+ });+ await expect(within(panel).getByText('January')).toBeVisible();+ await expect(canvas.getAllByRole('gridcell').length).toBeGreaterThan(0);},};@@ -150,27 +155,21 @@ export const ClickOutside: Story = {const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);- await expect(handleClickoutsideMocked).toHaveBeenCalledTimes(0);-- const calendarButton = await canvas.findByRole(- 'button',- { name: 'Select month and year' },- { timeout: 10000 },+ await expect(handleClickoutsideMocked).not.toHaveBeenCalled();+ await userEvent.click(+ await canvas.findByRole('button', { name: 'Select month and year' }),);- await userEvent.click(calendarButton);-- // Increased timeout to account for lazy-loaded react-datepicker on slower CI runners- await body.findByText('January', {}, { timeout: 10000 });+ await body.findByRole('dialog', { name: 'Select month and year' });const outsideButton = canvas.getByRole('button', {name: 'Outside date field',});await userEvent.click(outsideButton);- await waitFor(() => {+ await waitFor(() =>expect(body.queryByRole('dialog', { name: 'Select month and year' }),- ).not.toBeInTheDocument();- });+ ).not.toBeInTheDocument(),+ );await expect(handleClickoutsideMocked).not.toHaveBeenCalled();await userEvent.click(outsideButton);@@ -180,28 +179,22 @@ export const ClickOutside: Story = {export const Escape: Story = {play: async ({ canvasElement }) => {- await expect(handleEscapeMocked).toHaveBeenCalledTimes(0);const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);- const calendarButton = await canvas.findByRole(- 'button',- { name: 'Select month and year' },- { timeout: 10000 },+ await expect(handleEscapeMocked).not.toHaveBeenCalled();+ await userEvent.click(+ await canvas.findByRole('button', { name: 'Select month and year' }),);- await userEvent.click(calendarButton);-- // Increased timeout to account for lazy-loaded react-datepicker on slower CI runners- await body.findByText('January', {}, { timeout: 10000 });-- await userEvent.keyboard('{escape}');- await waitFor(() => {+ await body.findByRole('dialog', { name: 'Select month and year' });+ await userEvent.keyboard('{Escape}');+ await waitFor(() =>expect(body.queryByRole('dialog', { name: 'Select month and year' }),- ).not.toBeInTheDocument();- });+ ).not.toBeInTheDocument(),+ );await expect(handleEscapeMocked).not.toHaveBeenCalled();- await userEvent.keyboard('{escape}');+ await userEvent.keyboard('{Escape}');await expect(handleEscapeMocked).toHaveBeenCalledTimes(1);},@@ -209,30 +202,67 @@ export const Escape: Story = {export const Enter: Story = {play: async ({ canvasElement }) => {- await expect(handleEnterMocked).toHaveBeenCalledTimes(0);const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);- const calendarButton = await canvas.findByRole(- 'button',- { name: 'Select month and year' },- { timeout: 10000 },- );- await userEvent.click(calendarButton);-- // Increased timeout to account for lazy-loaded react-datepicker on slower CI runners- await body.findByText('January', {}, { timeout: 10000 });-- await userEvent.keyboard('{enter}');- await waitFor(() => {+ await expect(handleEnterMocked).not.toHaveBeenCalled();+ const monthYearTrigger = await canvas.findByRole('button', {+ name: 'Select month and year',+ });+ monthYearTrigger.focus();+ await userEvent.keyboard('{Enter}');+ const panel = await body.findByRole('dialog', {+ name: 'Select month and year',+ });+ await expect(panel).toBeVisible();+ await expect(monthYearTrigger).toHaveAttribute('aria-expanded', 'true');+ await expect(handleEnterMocked).not.toHaveBeenCalled();+ await userEvent.keyboard('{Enter}');+ await waitFor(() =>expect(body.queryByRole('dialog', { name: 'Select month and year' }),- ).not.toBeInTheDocument();- });+ ).not.toBeInTheDocument(),+ );await expect(handleEnterMocked).not.toHaveBeenCalled();- await userEvent.click(await canvas.findByPlaceholderText(/HH:mm/));- await userEvent.keyboard('{enter}');+ await userEvent.click(canvas.getByRole('textbox', { name: 'Time' }));+ await userEvent.keyboard('{Enter}');await expect(handleEnterMocked).toHaveBeenCalledTimes(1);+ await expect(handleEnterMocked).toHaveBeenLastCalledWith({+ newValue: '2022-01-01T02:00:00Z',+ });+ },+};++export const CalendarNavigationDoesNotSubmit: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const nextMonth = await canvas.findByRole('button', { name: 'Next' });+ const dateInput = canvas.getByRole<HTMLInputElement>('textbox', {+ name: 'Date and time',+ });+ const initialValue = dateInput.value;+ const initialMonth = canvas+ .getByRole('rowgroup', { name: MONTH_ROW_LABEL_PATTERN })+ .getAttribute('aria-label');++ await expect(initialMonth).toMatch(MONTH_ROW_LABEL_PATTERN);++ nextMonth.focus();+ await userEvent.keyboard('{Enter}');+ await expect(handleEnterMocked).not.toHaveBeenCalled();+ await expect(dateInput).toHaveValue(initialValue);+ await expect(+ canvas.getByRole('rowgroup', { name: MONTH_ROW_LABEL_PATTERN }),+ ).not.toHaveAttribute('aria-label', initialMonth);+ canvas.getByRole('button', { name: 'Previous' }).focus();+ await userEvent.keyboard('{Enter}');+ await waitFor(() =>+ expect(+ canvas.getByRole('rowgroup', { name: MONTH_ROW_LABEL_PATTERN }),+ ).toHaveAttribute('aria-label', initialMonth),+ );+ await expect(dateInput).toHaveValue(initialValue);+ await expect(handleEnterMocked).not.toHaveBeenCalled();},};diff --git a/packages/twenty-front/src/modules/settings/components/__stories__/SettingsDatePickerInput.stories.tsx b/packages/twenty-front/src/modules/settings/components/__stories__/SettingsDatePickerInput.stories.tsxindex f50769a4862..3eadd23abf5 100644--- a/packages/twenty-front/src/modules/settings/components/__stories__/SettingsDatePickerInput.stories.tsx+++ b/packages/twenty-front/src/modules/settings/components/__stories__/SettingsDatePickerInput.stories.tsx@@ -30,53 +30,47 @@ export const Default: Story = {const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);- await userEvent.click(- await canvas.findByText(/2023/, {}, { timeout: 10000 }),- );+ await userEvent.click(await canvas.findByText(/2023/));- await body.findByRole(- 'button',- { name: 'Select month and year' },- { timeout: 10000 },- );+ expect(+ await body.findByRole('button', { name: 'Select month and year' }),+ ).toBeVisible();+ expect(+ await body.findByRole('gridcell', {+ name: /^Choose Sunday, January 15/,+ }),+ ).toBeVisible();},};-// Regression test for the month/year panel closing the whole picker on click.-// Opening the month select used to trigger the parent click-outside listener and-// close the date picker, so the month/year controls could never be used.export const ChangingMonthKeepsPickerOpen: Story = {play: async ({ canvasElement }) => {const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);+ const displayedDate = await canvas.findByText(/2023/);+ const initialDateText = displayedDate.textContent;- await userEvent.click(- await canvas.findByText(/2023/, {}, { timeout: 10000 }),- );-- const monthYearButton = await body.findByRole(- 'button',- { name: 'Select month and year' },- { timeout: 10000 },- );- await userEvent.click(monthYearButton);+ expect(initialDateText).toContain('2023');- await userEvent.click(- await body.findByText('January', {}, { timeout: 10000 }),+ await userEvent.click(displayedDate);+ const calendarButton = await body.findByRole('button', {+ name: 'Select month and year',+ });+ await userEvent.click(calendarButton);+ const panel = within(+ await body.findByRole('dialog', { name: 'Select month and year' }),);+ await userEvent.click(panel.getByText('January'));- // The picker must stay open after interacting with the month select- expect(- body.getByRole('button', { name: 'Select month and year' }),- ).toBeInTheDocument();-- await userEvent.click(- await body.findByText('February', {}, { timeout: 10000 }),- );+ const options = within(await body.findByRole('listbox'));+ await userEvent.click(options.getByRole('option', { name: 'February' }));- expect(await body.findByText('February')).toBeInTheDocument();+ expect(calendarButton).toBeVisible();expect(- body.getByRole('button', { name: 'Select month and year' }),- ).toBeInTheDocument();+ await body.findByRole('gridcell', {+ name: /^Choose Wednesday, February 15/,+ }),+ ).toBeVisible();+ expect(displayedDate.textContent).toBe(initialDateText);},};diff --git a/packages/twenty-front/src/modules/ui/field/input/components/__stories__/DateInput.stories.tsx b/packages/twenty-front/src/modules/ui/field/input/components/__stories__/DateInput.stories.tsxnew file mode 100644index 00000000000..be649864c0c--- /dev/null+++ b/packages/twenty-front/src/modules/ui/field/input/components/__stories__/DateInput.stories.tsx@@ -0,0 +1,96 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';+import { ComponentDecorator } from 'twenty-ui/testing';++import { DateInput } from '@/ui/field/input/components/DateInput';+import { DateInputFocusEffect } from '@/ui/field/input/components/__stories__/DateInputFocusEffect';++const INITIAL_DATE = '2026-01-15';+const MONTH_ROW_LABEL_PATTERN = /^Month /;++const meta: Meta<typeof DateInput> = {+ title: 'UI/Field/Input/DateInput',+ component: DateInput,+ decorators: [ComponentDecorator],+ args: {+ instanceId: 'story-date-input',+ value: INITIAL_DATE,+ onEnter: fn(),+ onEscape: fn(),+ onClickOutside: fn(),+ onChange: fn(),+ },+ render: ({+ instanceId,+ value,+ onEnter,+ onEscape,+ onClickOutside,+ onChange,+ }) => (+ <>+ <DateInputFocusEffect instanceId={instanceId} />+ <DateInput+ instanceId={instanceId}+ value={value}+ onEnter={onEnter}+ onEscape={onEscape}+ onClickOutside={onClickOutside}+ onChange={onChange}+ />+ </>+ ),+};++export default meta;++type Story = StoryObj<typeof DateInput>;++export const CalendarNavigationDoesNotSubmit: Story = {+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const nextMonth = await canvas.findByRole('button', { name: 'Next' });+ const dateInput = canvas.getByRole<HTMLInputElement>('textbox', {+ name: 'Date',+ });+ const initialValue = dateInput.value;+ const initialMonth = canvas+ .getByRole('rowgroup', { name: MONTH_ROW_LABEL_PATTERN })+ .getAttribute('aria-label');++ await expect(initialMonth).toMatch(MONTH_ROW_LABEL_PATTERN);++ nextMonth.focus();+ await userEvent.keyboard('{Enter}');+ await waitFor(() =>+ expect(+ canvas.getByRole('rowgroup', { name: MONTH_ROW_LABEL_PATTERN }),+ ).not.toHaveAttribute('aria-label', initialMonth),+ );+ await expect(dateInput).toHaveValue(initialValue);++ canvas.getByRole('button', { name: 'Previous' }).focus();+ await userEvent.keyboard('{Enter}');+ await waitFor(() =>+ expect(+ canvas.getByRole('rowgroup', { name: MONTH_ROW_LABEL_PATTERN }),+ ).toHaveAttribute('aria-label', initialMonth),+ );+ await expect(dateInput).toHaveValue(initialValue);+ await expect(args.onChange).not.toHaveBeenCalled();+ await expect(args.onEnter).not.toHaveBeenCalled();+ },+};++export const EnterSubmitsDate: Story = {+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const dateInput = await canvas.findByRole('textbox', { name: 'Date' });++ dateInput.focus();+ await userEvent.keyboard('{Enter}');++ await expect(args.onEnter).toHaveBeenCalledOnce();+ await expect(args.onEnter).toHaveBeenCalledWith(INITIAL_DATE);+ },+};diff --git a/packages/twenty-front/src/modules/ui/field/input/components/__stories__/DateInputFocusEffect.tsx b/packages/twenty-front/src/modules/ui/field/input/components/__stories__/DateInputFocusEffect.tsxnew file mode 100644index 00000000000..64f049558ee--- /dev/null+++ b/packages/twenty-front/src/modules/ui/field/input/components/__stories__/DateInputFocusEffect.tsx@@ -0,0 +1,26 @@+import { useEffect } from 'react';++import { usePushFocusItemToFocusStack } from '@/ui/utilities/focus/hooks/usePushFocusItemToFocusStack';+import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';++type DateInputFocusEffectProps = {+ instanceId: string;+};++export const DateInputFocusEffect = ({+ instanceId,+}: DateInputFocusEffectProps) => {+ const { pushFocusItemToFocusStack } = usePushFocusItemToFocusStack();++ useEffect(() => {+ pushFocusItemToFocusStack({+ focusId: instanceId,+ component: {+ type: FocusComponentType.OPENED_FIELD_INPUT,+ instanceId,+ },+ });+ }, [instanceId, pushFocusItemToFocusStack]);++ return null;+};diff --git a/packages/twenty-front/src/modules/ui/field/input/components/__tests__/DateInput.test.tsx b/packages/twenty-front/src/modules/ui/field/input/components/__tests__/DateInput.test.tsxdeleted file mode 100644index ada462a9dfc..00000000000--- a/packages/twenty-front/src/modules/ui/field/input/components/__tests__/DateInput.test.tsx+++ /dev/null@@ -1,86 +0,0 @@-import { act, render, screen, within } from '@testing-library/react';-import userEvent from '@testing-library/user-event';-import { i18n } from '@lingui/core';-import { I18nProvider } from '@lingui/react';-import { type ReactNode } from 'react';--import { DateInput } from '@/ui/field/input/components/DateInput';-import { focusStackState } from '@/ui/utilities/focus/states/focusStackState';-import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';-import { DEFAULT_GLOBAL_HOTKEYS_CONFIG } from '@/ui/utilities/hotkey/constants/DefaultGlobalHotkeysConfig';-import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';--const DATE_INPUT_INSTANCE_ID = 'date-input';--const renderDateInput = () => {- const onEnter = jest.fn();- const onChange = jest.fn();- const BaseWrapper = getJestMetadataAndApolloMocksWrapper({- onInitializeJotaiStore: (store) => {- store.set(focusStackState.atom, [- {- focusId: DATE_INPUT_INSTANCE_ID,- componentInstance: {- componentType: FocusComponentType.OPENED_FIELD_INPUT,- componentInstanceId: DATE_INPUT_INSTANCE_ID,- },- globalHotkeysConfig: DEFAULT_GLOBAL_HOTKEYS_CONFIG,- },- ]);- },- });-- const Wrapper = ({ children }: { children: ReactNode }) => (- <I18nProvider i18n={i18n}>- <BaseWrapper>{children}</BaseWrapper>- </I18nProvider>- );-- render(- <DateInput- instanceId={DATE_INPUT_INSTANCE_ID}- value="2026-01-15"- onEnter={onEnter}- onEscape={jest.fn()}- onClickOutside={jest.fn()}- onChange={onChange}- />,- { wrapper: Wrapper },- );-- return { onEnter, onChange };-};--describe('DateInput keyboard submission', () => {- it.each([- ['Next', '2026-02-15'],- ['Previous', '2025-12-15'],- ])(- 'pages the calendar with Enter on the %s button without submitting',- async (buttonName, expectedDate) => {- const user = userEvent.setup();- const { onEnter, onChange } = renderDateInput();- const pageButton = await screen.findByRole('button', {- name: buttonName,- });-- act(() => pageButton.focus());- await user.keyboard('{Enter}');-- expect(onChange).toHaveBeenCalledWith(expectedDate);- expect(onEnter).not.toHaveBeenCalled();- },- );-- it('submits the date with Enter from the date text input', async () => {- const user = userEvent.setup();- const { onEnter } = renderDateInput();- const calendar = await screen.findByRole('dialog', { name: 'Choose Date' });- const dateTextInput = within(calendar).getByRole('textbox');-- act(() => dateTextInput.focus());- await user.keyboard('{Enter}');-- expect(onEnter).toHaveBeenCalledWith('2026-01-15');- });-});diff --git a/packages/twenty-front/src/modules/ui/field/input/components/__tests__/DateTimeInput.test.tsx b/packages/twenty-front/src/modules/ui/field/input/components/__tests__/DateTimeInput.test.tsxdeleted file mode 100644index b31871339b6..00000000000--- a/packages/twenty-front/src/modules/ui/field/input/components/__tests__/DateTimeInput.test.tsx+++ /dev/null@@ -1,101 +0,0 @@-import { act, render, screen } from '@testing-library/react';-import userEvent from '@testing-library/user-event';-import { i18n } from '@lingui/core';-import { I18nProvider } from '@lingui/react';-import { type ReactNode } from 'react';-import { Temporal } from 'temporal-polyfill';--import { DateTimeInput } from '@/ui/field/input/components/DateTimeInput';-import { focusStackState } from '@/ui/utilities/focus/states/focusStackState';-import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';-import { DEFAULT_GLOBAL_HOTKEYS_CONFIG } from '@/ui/utilities/hotkey/constants/DefaultGlobalHotkeysConfig';-import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';--const DATE_TIME_INPUT_INSTANCE_ID = 'date-time-input';--const renderDateTimeInput = () => {- const onEnter = jest.fn();- const onChange = jest.fn();- const BaseWrapper = getJestMetadataAndApolloMocksWrapper({- onInitializeJotaiStore: (store) => {- store.set(focusStackState.atom, [- {- focusId: DATE_TIME_INPUT_INSTANCE_ID,- componentInstance: {- componentType: FocusComponentType.OPENED_FIELD_INPUT,- componentInstanceId: DATE_TIME_INPUT_INSTANCE_ID,- },- globalHotkeysConfig: DEFAULT_GLOBAL_HOTKEYS_CONFIG,- },- ]);- },- });-- const Wrapper = ({ children }: { children: ReactNode }) => (- <I18nProvider i18n={i18n}>- <BaseWrapper>{children}</BaseWrapper>- </I18nProvider>- );-- render(- <DateTimeInput- instanceId={DATE_TIME_INPUT_INSTANCE_ID}- value={Temporal.Instant.from('2026-01-15T10:00:00Z')}- onEnter={onEnter}- onEscape={jest.fn()}- onClickOutside={jest.fn()}- onChange={onChange}- />,- { wrapper: Wrapper },- );-- return { onEnter, onChange };-};--describe('DateTimeInput keyboard submission', () => {- it.each([- ['Next', '2026-02-15T10:00:00Z'],- ['Previous', '2025-12-15T10:00:00Z'],- ])(- 'pages the calendar with Enter on the %s button without submitting',- async (buttonName, expectedInstant) => {- const user = userEvent.setup();- const { onEnter, onChange } = renderDateTimeInput();- const pageButton = await screen.findByRole('button', {- name: buttonName,- });-- act(() => pageButton.focus());- await user.keyboard('{Enter}');-- expect(onChange.mock.lastCall?.[0]?.toString()).toBe(expectedInstant);- expect(onEnter).not.toHaveBeenCalled();- },- );-- it('opens the month and year panel with Enter without submitting', async () => {- const user = userEvent.setup();- const { onEnter } = renderDateTimeInput();- const monthYearTrigger = await screen.findByRole('button', {- name: 'Select month and year',- });-- act(() => monthYearTrigger.focus());- await user.keyboard('{Enter}');-- expect(monthYearTrigger).toHaveAttribute('aria-expanded', 'true');- expect(await screen.findByText('January')).toBeVisible();- expect(onEnter).not.toHaveBeenCalled();- });-- it('submits the date with Enter from the time input', async () => {- const user = userEvent.setup();- const { onEnter } = renderDateTimeInput();- const timeInput = await screen.findByPlaceholderText(/HH:mm/);-- act(() => timeInput.focus());- await user.keyboard('{Enter}');-- expect(onEnter.mock.lastCall?.[0]?.toString()).toBe('2026-01-15T10:00:00Z');- });-});diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePicker.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePicker.tsxindex 6f773b24430..390592cc463 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePicker.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePicker.tsx@@ -1,75 +1,17 @@-import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';-import { styled } from '@linaria/react';-import { Suspense, lazy, type ComponentType } from 'react';-import type { DatePickerProps as ReactDatePickerLibProps } from 'react-datepicker';-import { SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';--import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';-import { CalendarStartDay } from 'twenty-shared/constants';--import { detectCalendarStartDay } from '@/localization/utils/detection/detectCalendarStartDay';+import { DatePickerCalendar } from '@/ui/input/components/internal/date/components/DatePickerCalendar';+import { DatePickerLoadingFallback } from '@/ui/input/components/internal/date/components/DatePickerLoadingFallback';+import { DatePickerClearButton } from '@/ui/input/components/internal/date/components/DatePickerClearButton';import { DatePickerHeader } from '@/ui/input/components/internal/date/components/DatePickerHeader';import { RelativeDatePickerHeader } from '@/ui/input/components/internal/date/components/RelativeDatePickerHeader';-import {- DATE_PICKER_CONTAINER_WIDTH,- StyledDatePickerContainer,-} from '@/ui/input/components/internal/date/components/StyledDatePickerContainer';-import { getRelativeDatePickerCalendarRange } from '@/ui/input/components/internal/date/utils/getRelativeDatePickerCalendarRange';-import { t } from '@lingui/core/macro';-import 'react-datepicker/dist/react-datepicker.css';--import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';+import { StyledDatePickerContainer } from '@/ui/input/components/internal/date/components/StyledDatePickerContainer';import { Temporal } from 'temporal-polyfill';import { type Nullable } from 'twenty-shared/types';+import { doNotTranslate } from 'twenty-shared/i18n';import {isDefined,- turnJSDateToPlainDate,turnPlainDateToShiftedDateInSystemTimeZone,type RelativeDateFilter,} from 'twenty-shared/utils';-import { doNotTranslate } from 'twenty-shared/i18n';-import { IconCalendarX } from 'twenty-ui/icon';-import { Text } from 'twenty-ui/primitives/typography';-import { useTheme, themeCssVariables } from 'twenty-ui/theme';--const StyledButtonContainer = styled.div`- align-items: center;- border-radius: calc(- ${themeCssVariables.border.radius.md} - ${themeCssVariables.spacing[1]}- );- box-sizing: border-box;- cursor: pointer;- display: flex;- height: 32px;- margin: ${themeCssVariables.spacing[1]};- padding: ${themeCssVariables.spacing[1]};- width: auto;-- &:hover {- background: ${themeCssVariables.background.transparent.light};- }-`;--const StyledButtonContent = styled.div`- align-items: center;- display: flex;- gap: ${themeCssVariables.spacing[2]};- justify-content: start;-`;--const StyledDatePickerFallback = styled.div`- align-items: center;- background: ${themeCssVariables.background.secondary};- border-radius: ${themeCssVariables.border.radius.md};- color: ${themeCssVariables.font.color.tertiary};- display: flex;- flex-direction: column;- gap: ${themeCssVariables.spacing[2]};- height: 300px;- justify-content: center;- padding: ${themeCssVariables.spacing[4]};- width: 280px;-`;type DatePickerProps = {instanceId: string;@@ -93,28 +35,6 @@ type DatePickerProps = {hideCalendar?: boolean;};-// react-datepicker v9 types its props as a discriminated union keyed on-// selectsRange/selectsMultiple. We drive selectsRange dynamically (relative-// filters highlight a contiguous range), which TS cannot narrow to a single-// union branch, so collapse the discriminants to plain optionals.-type DatePickerPropsType = Omit<- ReactDatePickerLibProps,- 'selectsRange' | 'selectsMultiple' | 'onChange' | 'formatMultipleDates'-> & {- selectsRange?: boolean;- onChange?: (date: Date | null) => void;-};--const ReactDatePicker = lazy<ComponentType<DatePickerPropsType>>(() =>- import('react-datepicker').then((mod) => ({- // react-datepicker ships CJS; under vite 8 this dynamic import's `default`- // can be the module namespace ({ default: Component }) rather than the- // component itself, so unwrap a nested default when present.- default: ((mod.default as any)?.default ??- mod.default) as unknown as ComponentType<DatePickerPropsType>,- })),-);-export const DatePicker = ({instanceId,plainDateString,@@ -127,172 +47,66 @@ export const DatePicker = ({onRelativeDateChange,hideHeaderInput,}: DatePickerProps) => {- const theme = useTheme();const plainDate = isDefined(plainDateString)? Temporal.PlainDate.from(plainDateString): Temporal.Now.plainDateISO();-- const relativeRangeStart = isRelative ? relativeDate?.start : undefined;- const relativeRangeEnd = isRelative ? relativeDate?.end : undefined;-- const relativeRangeStartPlainDate = isDefined(relativeRangeStart)- ? Temporal.PlainDate.from(relativeRangeStart)- : null;-- const relativeRangeEndPlainDate = isDefined(relativeRangeEnd)- ? Temporal.PlainDate.from(relativeRangeEnd).subtract({ days: 1 })- : null;-- const {- startDate: relativeRangeStartDate,- endDate: relativeRangeEndDate,- rangeKey: relativeDateRangeKey,- } = getRelativeDatePickerCalendarRange(- relativeRangeStartPlainDate,- relativeRangeEndPlainDate,- );-- const currentWorkspaceMember = useAtomStateValue(currentWorkspaceMemberState);-- const handleChangeMonth = (month: number) => {- const newDate = plainDate?.with({ month: month });-- onChange?.(newDate?.toString() ?? null);- };-- const handleAddMonth = () => {- const newDate = plainDate?.add({ months: 1 });-- onChange?.(newDate?.toString() ?? null);- };-- const handleSubtractMonth = () => {- const newDate = plainDate?.subtract({ months: 1 });-- onChange?.(newDate?.toString() ?? null);- };-- const handleChangeYear = (year: number) => {- const newDate = plainDate?.with({ year: year });-- onChange?.(newDate?.toString() ?? null);- };-- const handleDateChange = (datePicked: Date | null) => {- if (!isDefined(datePicked)) {- return;- }- const plainDatePicked = turnJSDateToPlainDate(datePicked);-- onChange?.(plainDatePicked.toString());- };-- const handleDateSelect = (datePicked: Date | null) => {- if (!isDefined(datePicked)) {- return;- }- const plainDatePicked = turnJSDateToPlainDate(datePicked);-- onClose?.(plainDatePicked.toString());- };-- const calendarStartDay =- currentWorkspaceMember?.calendarStartDay === CalendarStartDay.SYSTEM- ? CalendarStartDay[detectCalendarStartDay()]- : (currentWorkspaceMember?.calendarStartDay ?? undefined);-- const dateForDatePicker =- turnPlainDateToShiftedDateInSystemTimeZone(plainDate);+ const highlightedRange =+ isRelative && isDefined(relativeDate)+ ? {+ start: relativeDate.start,+ end: Temporal.PlainDate.from(relativeDate.end)+ .subtract({ days: 1 })+ .toString(),+ }+ : undefined;return (- <StyledDatePickerContainer calendarDisabled={isRelative}>- <div className={clearable ? 'clearable ' : ''}>- <Suspense- fallback={- <StyledDatePickerFallback>- <SkeletonLine- width={DATE_PICKER_CONTAINER_WIDTH - 16}- height={SKELETON_HEIGHT_SIZES.l}- borderRadius={2}- />- <SkeletonLine- width={DATE_PICKER_CONTAINER_WIDTH - 16}- height={SKELETON_HEIGHT_SIZES.l}- borderRadius={2}- />- <SkeletonLine- width={DATE_PICKER_CONTAINER_WIDTH - 16}- height={SKELETON_HEIGHT_SIZES.l}- borderRadius={2}+ <StyledDatePickerContainer>+ <DatePickerCalendar+ loadingFallback={<DatePickerLoadingFallback />}+ value={isRelative ? null : plainDate.toString()}+ onChange={onChange}+ onSelect={onClose}+ highlightedRange={highlightedRange}+ readOnly={isRelative}+ renderHeader={(header) => {+ if (isRelative) {+ return (+ <RelativeDatePickerHeader+ instanceId={instanceId}+ direction={relativeDate?.direction ?? 'PAST'}+ amount={relativeDate?.amount}+ unit={relativeDate?.unit ?? doNotTranslate('DAY')}+ onChange={onRelativeDateChange}+ calendarMonthDate={turnPlainDateToShiftedDateInSystemTimeZone(+ Temporal.PlainDate.from(`${header.viewedMonth}-01`),+ )}+ onPreviousMonth={header.onPreviousMonth}+ onNextMonth={header.onNextMonth}+ prevMonthButtonDisabled={header.isPreviousMonthDisabled}+ nextMonthButtonDisabled={header.isNextMonthDisabled}/>- <SkeletonLine- width={DATE_PICKER_CONTAINER_WIDTH - 16}- height={SKELETON_HEIGHT_SIZES.l}- borderRadius={2}- />- </StyledDatePickerFallback>+ );}- >- <ReactDatePicker- key={relativeDateRangeKey}- open={true}- disabledKeyboardNavigation- onChange={handleDateChange}- onSelect={handleDateSelect}- openToDate={isRelative ? relativeRangeStartDate : dateForDatePicker}- selectsRange={isRelative ? true : undefined}- startDate={isRelative ? relativeRangeStartDate : undefined}- endDate={isRelative ? relativeRangeEndDate : undefined}- selected={isRelative ? undefined : dateForDatePicker}- calendarStartDay={- calendarStartDay as 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined- }- renderCustomHeader={({- monthDate,- decreaseMonth,- increaseMonth,- prevMonthButtonDisabled,- nextMonthButtonDisabled,- }) =>- isRelative ? (- <RelativeDatePickerHeader- instanceId={instanceId}- direction={relativeDate?.direction ?? 'PAST'}- amount={relativeDate?.amount}- unit={relativeDate?.unit ?? doNotTranslate('DAY')}- onChange={onRelativeDateChange}- calendarMonthDate={monthDate}- onPreviousMonth={decreaseMonth}- onNextMonth={increaseMonth}- prevMonthButtonDisabled={prevMonthButtonDisabled}- nextMonthButtonDisabled={nextMonthButtonDisabled}- />- ) : (- <DatePickerHeader- instanceId={instanceId}- date={plainDate?.toString() ?? null}- onChange={onChange}- onChangeMonth={handleChangeMonth}- onChangeYear={handleChangeYear}- onAddMonth={handleAddMonth}- onSubtractMonth={handleSubtractMonth}- prevMonthButtonDisabled={prevMonthButtonDisabled}- nextMonthButtonDisabled={nextMonthButtonDisabled}- hideInput={hideHeaderInput}- />- )- }- />- </Suspense>- </div>- {clearable && (- <StyledButtonContainer onClick={() => onClear?.()}>- <StyledButtonContent>- <IconCalendarX size={theme.icon.size.md} />- <Text>{t`Clear`}</Text>- </StyledButtonContent>- </StyledButtonContainer>- )}++ return (+ <DatePickerHeader+ instanceId={instanceId}+ date={plainDate.toString()}+ viewedMonth={header.viewedMonth}+ onChange={onChange}+ onChangeMonth={header.onMonthChange}+ onChangeYear={header.onYearChange}+ onAddMonth={header.onNextMonth}+ onSubtractMonth={header.onPreviousMonth}+ prevMonthButtonDisabled={header.isPreviousMonthDisabled}+ nextMonthButtonDisabled={header.isNextMonthDisabled}+ hideInput={hideHeaderInput}+ />+ );+ }}+ />+ {clearable && <DatePickerClearButton onClear={onClear} />}</StyledDatePickerContainer>);};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerCalendar.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerCalendar.tsxnew file mode 100644index 00000000000..829eb43e5b2--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerCalendar.tsx@@ -0,0 +1,80 @@+import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';+import { getDatePickerWeekStartOrThrow } from '@/ui/input/components/internal/date/utils/getDatePickerWeekStartOrThrow';+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';+import { t } from '@lingui/core/macro';+import { useState } from 'react';+import { Temporal } from 'temporal-polyfill';+import { SOURCE_LOCALE } from 'twenty-shared/translations';+import { isDefined } from 'twenty-shared/utils';+import { DatePicker, type DatePickerProps } from 'twenty-ui/components/input';++type DatePickerCalendarProps = {+ value: string | null;+ onChange?: (date: string) => void;+ onSelect?: (date: string) => void;+ highlightedRange?: { start: string; end: string };+ readOnly?: boolean;+ isGridHidden?: boolean;+ today?: string;+ weekStart?: DatePickerProps['weekStart'];+ onViewedMonthChange?: (month: string) => void;+ renderHeader?: DatePickerProps['renderHeader'];+ loadingFallback?: DatePickerProps['loadingFallback'];+};++export const DatePickerCalendar = ({+ value,+ onChange,+ onSelect,+ highlightedRange,+ readOnly,+ isGridHidden,+ today,+ weekStart,+ onViewedMonthChange,+ renderHeader,+ loadingFallback,+}: DatePickerCalendarProps) => {+ const currentWorkspaceMember = useAtomStateValue(currentWorkspaceMemberState);+ const currentToday = today ?? Temporal.Now.plainDateISO().toString();+ const referenceDate = highlightedRange?.start ?? value ?? currentToday;+ const referenceKey = isDefined(highlightedRange)+ ? `${highlightedRange.start}-${highlightedRange.end}`+ : referenceDate;+ const [calendarState, setCalendarState] = useState({+ referenceKey,+ viewedMonth: referenceDate.slice(0, 7),+ });+ if (calendarState.referenceKey !== referenceKey) {+ setCalendarState({ referenceKey, viewedMonth: referenceDate.slice(0, 7) });+ }++ return (+ <DatePicker+ aria-label={t`Choose a date`}+ value={value}+ onValueChange={(date) => onChange?.(date)}+ onValueSelect={onSelect}+ viewedMonth={calendarState.viewedMonth}+ onViewedMonthChange={(month) => {+ setCalendarState({ referenceKey, viewedMonth: month });+ onViewedMonthChange?.(month);+ }}+ weekStart={+ weekStart ??+ getDatePickerWeekStartOrThrow(currentWorkspaceMember?.calendarStartDay)+ }+ locale={SOURCE_LOCALE}+ previousMonthLabel={t`Previous`}+ nextMonthLabel={t`Next`}+ monthLabel={t`Month`}+ yearLabel={t`Year`}+ highlightedRange={highlightedRange}+ readOnly={readOnly}+ isGridHidden={isGridHidden}+ isKeyboardNavigationDisabled+ renderHeader={renderHeader}+ loadingFallback={loadingFallback}+ />+ );+};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerClearButton.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerClearButton.tsxnew file mode 100644index 00000000000..b746df69901--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerClearButton.tsx@@ -0,0 +1,57 @@+import { t } from '@lingui/core/macro';+import { styled } from '@linaria/react';+import { IconCalendarX } from 'twenty-ui/icon';+import { Text } from 'twenty-ui/primitives/typography';+import { useTheme, themeCssVariables } from 'twenty-ui/theme';++const StyledSeparator = styled.div`+ border-bottom: 1px solid ${themeCssVariables.border.color.light};+ width: 100%;+`;++const StyledButtonContainer = styled.div`+ align-items: center;+ border-radius: calc(+ ${themeCssVariables.border.radius.md} - ${themeCssVariables.spacing[1]}+ );+ box-sizing: border-box;+ cursor: pointer;+ display: flex;+ height: ${themeCssVariables.spacing[8]};+ margin: ${themeCssVariables.spacing[1]};+ padding: ${themeCssVariables.spacing[1]};+ width: auto;++ &:hover {+ background: ${themeCssVariables.background.transparent.light};+ }+`;++const StyledButtonContent = styled.div`+ align-items: center;+ display: flex;+ gap: ${themeCssVariables.spacing[2]};+ justify-content: start;+`;++type DatePickerClearButtonProps = {+ onClear?: () => void;+};++export const DatePickerClearButton = ({+ onClear,+}: DatePickerClearButtonProps) => {+ const theme = useTheme();++ return (+ <>+ <StyledSeparator />+ <StyledButtonContainer onClick={() => onClear?.()}>+ <StyledButtonContent>+ <IconCalendarX size={theme.icon.size.md} />+ <Text>{t`Clear`}</Text>+ </StyledButtonContent>+ </StyledButtonContainer>+ </>+ );+};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerHeader.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerHeader.tsxindex 0fc942be63d..03e8c8181cf 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerHeader.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerHeader.tsx@@ -6,6 +6,7 @@ import { Select } from '@/ui/input/components/Select';import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';import { DatePickerInput } from '@/ui/input/components/internal/date/components/DatePickerInput';import { getDatePickerDropdownIds } from '@/ui/input/components/internal/date/utils/getDatePickerDropdownIds';+import { DATE_PICKER_YEAR_SELECT_OPTIONS } from '@/ui/input/components/internal/date/constants/DatePickerYearSelectOptions';import { getMonthSelectOptions } from '@/ui/input/components/internal/date/utils/getMonthSelectOptions';import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';import { Temporal } from 'temporal-polyfill';@@ -15,11 +16,6 @@ import { LightIconButton } from 'twenty-ui/components/input';import { IconChevronLeft, IconChevronRight } from 'twenty-ui/icon';import { themeCssVariables } from 'twenty-ui/theme';-const YEARS_SELECT_OPTIONS = Array.from(- { length: 200 },- (_, i) => new Date().getFullYear() + 50 - i,-).map((year) => ({ label: year.toString(), value: year }));-const StyledCustomDatePickerHeader = styled.div`align-items: center;display: flex;@@ -34,6 +30,7 @@ const StyledCustomDatePickerHeader = styled.div`type DatePickerHeaderProps = {instanceId: string;date: string | null;+ viewedMonth?: string;onChange?: (date: string | null) => void;onChangeMonth: (month: number) => void;onChangeYear: (year: number) => void;@@ -47,6 +44,7 @@ type DatePickerHeaderProps = {export const DatePickerHeader = ({instanceId,date,+ viewedMonth,onChange,onChangeMonth,onChangeYear,@@ -63,6 +61,9 @@ export const DatePickerHeader = ({getDatePickerDropdownIds(instanceId);const dateParsed = isDefined(date) ? Temporal.PlainDate.from(date) : null;+ const displayedMonth = isDefined(viewedMonth)+ ? Temporal.PlainYearMonth.from(viewedMonth)+ : dateParsed;return (<>@@ -72,14 +73,14 @@ export const DatePickerHeader = ({dropdownId={monthSelectDropdownId}options={getMonthSelectOptions(userLocale)}onChange={onChangeMonth}- value={dateParsed?.month}+ value={displayedMonth?.month}fullWidth/><SelectdropdownId={yearSelectDropdownId}onChange={onChangeYear}- value={dateParsed?.year}- options={YEARS_SELECT_OPTIONS}+ value={displayedMonth?.year}+ options={DATE_PICKER_YEAR_SELECT_OPTIONS}fullWidth/><LightIconButtondiff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerLoadingFallback.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerLoadingFallback.tsxnew file mode 100644index 00000000000..037e346adbb--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerLoadingFallback.tsx@@ -0,0 +1,45 @@+import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';+import { DATE_PICKER_CONTAINER_WIDTH } from '@/ui/input/components/internal/date/constants/DatePickerContainerWidth';+import { styled } from '@linaria/react';+import { type ReactNode } from 'react';+import { SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';+import { themeCssVariables } from 'twenty-ui/theme';++const DATE_PICKER_SKELETON_HEIGHT = 300;+const DATE_PICKER_SKELETON_PADDING = 16;+const DATE_PICKER_SKELETON_BORDER_RADIUS = 2;+const DATE_PICKER_SKELETON_ROW_COUNT = 4;++const StyledFallback = styled.div`+ align-items: center;+ background: ${themeCssVariables.background.secondary};+ border-radius: ${themeCssVariables.border.radius.md};+ color: ${themeCssVariables.font.color.tertiary};+ display: flex;+ flex-direction: column;+ gap: ${themeCssVariables.spacing[2]};+ height: ${DATE_PICKER_SKELETON_HEIGHT}px;+ justify-content: center;+ padding: ${themeCssVariables.spacing[4]};+ width: ${DATE_PICKER_CONTAINER_WIDTH}px;+`;++type DatePickerLoadingFallbackProps = {+ children?: ReactNode;+};++export const DatePickerLoadingFallback = ({+ children,+}: DatePickerLoadingFallbackProps) => (+ <StyledFallback>+ {children ??+ Array.from({ length: DATE_PICKER_SKELETON_ROW_COUNT }, (_, index) => (+ <SkeletonLine+ key={index}+ width={DATE_PICKER_CONTAINER_WIDTH - DATE_PICKER_SKELETON_PADDING}+ height={SKELETON_HEIGHT_SIZES.l}+ borderRadius={DATE_PICKER_SKELETON_BORDER_RADIUS}+ />+ ))}+ </StyledFallback>+);diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerWithoutCalendar.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerWithoutCalendar.tsxindex a96bdc03c3d..d1ee13d96a4 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerWithoutCalendar.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DatePickerWithoutCalendar.tsx@@ -1,72 +1,28 @@-import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';-import { styled } from '@linaria/react';-import { Suspense, lazy, type ComponentType } from 'react';-import type { DatePickerProps as ReactDatePickerLibProps } from 'react-datepicker';-import { SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';--import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';-import { CalendarStartDay } from 'twenty-shared/constants';--import { detectCalendarStartDay } from '@/localization/utils/detection/detectCalendarStartDay';+import { DatePickerCalendar } from '@/ui/input/components/internal/date/components/DatePickerCalendar';+import { DatePickerLoadingFallback } from '@/ui/input/components/internal/date/components/DatePickerLoadingFallback';import { DatePickerHeader } from '@/ui/input/components/internal/date/components/DatePickerHeader';-import {- DATE_PICKER_CONTAINER_WIDTH,- StyledDatePickerContainer,-} from '@/ui/input/components/internal/date/components/StyledDatePickerContainer';-import 'react-datepicker/dist/react-datepicker.css';--import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';+import { StyledDatePickerContainer } from '@/ui/input/components/internal/date/components/StyledDatePickerContainer';+import { styled } from '@linaria/react';import { Temporal } from 'temporal-polyfill';import { type Nullable } from 'twenty-shared/types';-import { isDefined, turnJSDateToPlainDate } from 'twenty-shared/utils';+import { isDefined } from 'twenty-shared/utils';import { themeCssVariables } from 'twenty-ui/theme';-const DATE_PICKER_SKELETON_PADDING = 16;-const StyledSpacer = styled.div`height: ${themeCssVariables.spacing[2]};width: auto;`;-const StyledDatePickerFallback = styled.div`- align-items: center;- background: ${themeCssVariables.background.secondary};- border-radius: ${themeCssVariables.border.radius.md};- color: ${themeCssVariables.font.color.tertiary};- display: flex;- flex-direction: column;- gap: ${themeCssVariables.spacing[2]};- height: 300px;- justify-content: center;- padding: ${themeCssVariables.spacing[4]};- width: 280px;-`;-type DatePickerWithoutCalendarProps = {instanceId: string;-date: Nullable<string>;-onClose?: (date: string | null) => void;onChange?: (date: string | null) => void;-onEnter?: (date: string | null) => void;onEscape?: (date: string | null) => void;keyboardEventsDisabled?: boolean;};-type DatePickerPropsType = ReactDatePickerLibProps;--const ReactDatePicker = lazy<ComponentType<DatePickerPropsType>>(() =>- import('react-datepicker').then((mod) => ({- // react-datepicker ships CJS; under vite 8 this dynamic import's `default`- // can be the module namespace ({ default: Component }) rather than the- // component itself, so unwrap a nested default when present.- default: ((mod.default as any)?.default ??- mod.default) as unknown as ComponentType<DatePickerPropsType>,- })),-);-export const DatePickerWithoutCalendar = ({instanceId,date,@@ -74,137 +30,45 @@ export const DatePickerWithoutCalendar = ({onClose,}: DatePickerWithoutCalendarProps) => {const plainDate = isDefined(date) ? Temporal.PlainDate.from(date) : null;-- const currentWorkspaceMember = useAtomStateValue(currentWorkspaceMemberState);-const handleChangeMonth = (month: number) => {- const newDate = plainDate?.with({ month: month });-- onChange?.(newDate?.toString() ?? null);- };-- const handleAddMonth = () => {- const newDate = plainDate?.add({ months: 1 });-- onChange?.(newDate?.toString() ?? null);+ onChange?.(plainDate?.with({ month }).toString() ?? null);};-- const handleSubtractMonth = () => {- const newDate = plainDate?.subtract({ months: 1 });-- onChange?.(newDate?.toString() ?? null);- };-const handleChangeYear = (year: number) => {- const newDate = plainDate?.with({ year: year });-- onChange?.(newDate?.toString() ?? null);+ onChange?.(plainDate?.with({ year }).toString() ?? null);};-- const handleDateChange = (datePicked: Date | null) => {- if (!isDefined(datePicked)) {- return;- }- const plainDatePicked = turnJSDateToPlainDate(datePicked);-- onChange?.(plainDatePicked.toString());+ const handleAddMonth = () => {+ onChange?.(plainDate?.add({ months: 1 }).toString() ?? null);};-- const handleDateSelect = (datePicked: Date | null) => {- if (!isDefined(datePicked)) {- return;- }- const plainDatePicked = turnJSDateToPlainDate(datePicked);-- onClose?.(plainDatePicked.toString());+ const handleSubtractMonth = () => {+ onChange?.(plainDate?.subtract({ months: 1 }).toString() ?? null);};- const calendarStartDay =- currentWorkspaceMember?.calendarStartDay === CalendarStartDay.SYSTEM- ? CalendarStartDay[detectCalendarStartDay()]- : (currentWorkspaceMember?.calendarStartDay ?? undefined);-- const systemTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;-- const dateShiftedToISOString = plainDate- ?.toZonedDateTime(systemTimeZone)- .toInstant()- .toString();-- const dateForDatePicker = isDefined(dateShiftedToISOString)- ? new Date(dateShiftedToISOString)- : null;-return (- <StyledDatePickerContainer hideCalendar={true}>- <div>- <Suspense- fallback={- <StyledDatePickerFallback>- <SkeletonLine- width={- DATE_PICKER_CONTAINER_WIDTH - DATE_PICKER_SKELETON_PADDING- }- height={SKELETON_HEIGHT_SIZES.l}- borderRadius={2}- />- <SkeletonLine- width={- DATE_PICKER_CONTAINER_WIDTH - DATE_PICKER_SKELETON_PADDING- }- height={SKELETON_HEIGHT_SIZES.l}- borderRadius={2}- />- <SkeletonLine- width={- DATE_PICKER_CONTAINER_WIDTH - DATE_PICKER_SKELETON_PADDING- }- height={SKELETON_HEIGHT_SIZES.l}- borderRadius={2}- />- <SkeletonLine- width={- DATE_PICKER_CONTAINER_WIDTH - DATE_PICKER_SKELETON_PADDING- }- height={SKELETON_HEIGHT_SIZES.l}- borderRadius={2}- />- </StyledDatePickerFallback>- }- >- <ReactDatePicker- open={true}- selected={dateForDatePicker}- openToDate={dateForDatePicker ?? undefined}- disabledKeyboardNavigation- onChange={handleDateChange}- calendarStartDay={- calendarStartDay as 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined- }- renderCustomHeader={({- prevMonthButtonDisabled,- nextMonthButtonDisabled,- }) => (- <>- <DatePickerHeader- instanceId={instanceId}- date={plainDate?.toString() ?? null}- onChange={onChange}- onChangeMonth={handleChangeMonth}- onChangeYear={handleChangeYear}- onAddMonth={handleAddMonth}- onSubtractMonth={handleSubtractMonth}- prevMonthButtonDisabled={prevMonthButtonDisabled}- nextMonthButtonDisabled={nextMonthButtonDisabled}- hideInput={true}- />- <StyledSpacer />- </>- )}- onSelect={handleDateSelect}- />- </Suspense>- </div>+ <StyledDatePickerContainer>+ <DatePickerCalendar+ loadingFallback={<DatePickerLoadingFallback />}+ value={plainDate?.toString() ?? null}+ isGridHidden+ onChange={onChange}+ onSelect={onClose}+ renderHeader={(header) => (+ <>+ <DatePickerHeader+ instanceId={instanceId}+ date={plainDate?.toString() ?? null}+ onChange={onChange}+ onChangeMonth={handleChangeMonth}+ onChangeYear={handleChangeYear}+ onAddMonth={handleAddMonth}+ onSubtractMonth={handleSubtractMonth}+ prevMonthButtonDisabled={header.isPreviousMonthDisabled}+ nextMonthButtonDisabled={header.isNextMonthDisabled}+ hideInput+ />+ <StyledSpacer />+ </>+ )}+ /></StyledDatePickerContainer>);};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePicker.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePicker.tsxindex 79975c4a454..bc69f309148 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePicker.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePicker.tsx@@ -1,86 +1,24 @@-import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';+import { doNotTranslate } from 'twenty-shared/i18n';import {convertFirstDayOfTheWeekToCalendarStartDayNumber,isDefined,isSubDayRelativeDateFilterUnit,+ turnJSDateToPlainDate,+ turnPlainDateToShiftedDateInSystemTimeZone,type RelativeDateFilter,} from 'twenty-shared/utils';-import { doNotTranslate } from 'twenty-shared/i18n';+import { Temporal } from 'temporal-polyfill';+import { DatePickerCalendar } from '@/ui/input/components/internal/date/components/DatePickerCalendar';+import { DatePickerClearButton } from '@/ui/input/components/internal/date/components/DatePickerClearButton';import { DateTimePickerHeader } from '@/ui/input/components/internal/date/components/DateTimePickerHeader';+import { DateTimePickerLoadingFallback } from '@/ui/input/components/internal/date/components/DateTimePickerLoadingFallback';+import { useGetShiftedDateToSystemTimeZone } from '@/ui/input/components/internal/date/hooks/useGetShiftedDateToSystemTimeZone';import { RelativeDatePickerHeader } from '@/ui/input/components/internal/date/components/RelativeDatePickerHeader';import { RelativeDateTimeRangeText } from '@/ui/input/components/internal/date/components/RelativeDateTimeRangeText';import { StyledDatePickerContainer } from '@/ui/input/components/internal/date/components/StyledDatePickerContainer';-import { getRelativeDatePickerCalendarRange } from '@/ui/input/components/internal/date/utils/getRelativeDatePickerCalendarRange';-import { styled } from '@linaria/react';-import { t } from '@lingui/core/macro';-import { Suspense, lazy, type ComponentType } from 'react';-import type { DatePickerProps as ReactDatePickerLibProps } from 'react-datepicker';-import { SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';--import 'react-datepicker/dist/react-datepicker.css';--import { IconCalendarX } from 'twenty-ui/icon';-import { Text } from 'twenty-ui/primitives/typography';--import { useGetShiftedDateToSystemTimeZone } from '@/ui/input/components/internal/date/hooks/useGetShiftedDateToSystemTimeZone';import { useUserFirstDayOfTheWeek } from '@/ui/input/components/internal/date/hooks/useUserFirstDayOfTheWeek';import { useUserTimezone } from '@/ui/input/components/internal/date/hooks/useUserTimezone';-import { Temporal } from 'temporal-polyfill';--import { useTheme, themeCssVariables } from 'twenty-ui/theme';--const StyledOuterWrapper = styled.div`- align-items: flex-start;- display: flex;- flex-direction: row;- position: relative;- width: 280px;-`;--const StyledSeparator = styled.div`- border-bottom: 1px solid ${themeCssVariables.border.color.light};- width: 100%;-`;--const StyledButtonContainer = styled.div`- align-items: center;- border-radius: calc(- ${themeCssVariables.border.radius.md} - ${themeCssVariables.spacing[1]}- );- box-sizing: border-box;- cursor: pointer;- display: flex;- height: 32px;- margin: ${themeCssVariables.spacing[1]};- padding: ${themeCssVariables.spacing[1]};- width: auto;-- &:hover {- background: ${themeCssVariables.background.transparent.light};- }-`;--const StyledButtonContent = styled.div`- align-items: center;- display: flex;- gap: ${themeCssVariables.spacing[2]};- justify-content: start;-`;--const StyledDatePickerFallback = styled.div`- align-items: center;- background: ${themeCssVariables.background.secondary};- border-radius: ${themeCssVariables.border.radius.md};- color: ${themeCssVariables.font.color.tertiary};- display: flex;- flex-direction: column;- gap: ${themeCssVariables.spacing[2]};- height: 300px;- justify-content: center;- padding: ${themeCssVariables.spacing[4]};- width: 280px;-`;type DateTimePickerProps = {instanceId: string;@@ -104,28 +42,6 @@ type DateTimePickerProps = {timeZone?: string;};-// react-datepicker v9 types its props as a discriminated union keyed on-// selectsRange/selectsMultiple. We drive selectsRange dynamically (relative-// filters highlight a contiguous range), which TS cannot narrow to a single-// union branch, so collapse the discriminants to plain optionals.-type DatePickerPropsType = Omit<- ReactDatePickerLibProps,- 'selectsRange' | 'selectsMultiple' | 'onChange' | 'formatMultipleDates'-> & {- selectsRange?: boolean;- onChange?: (date: Date | null) => void;-};--const ReactDatePicker = lazy<ComponentType<DatePickerPropsType>>(() =>- import('react-datepicker').then((mod) => ({- // react-datepicker ships CJS; under vite 8 this dynamic import's `default`- // can be the module namespace ({ default: Component }) rather than the- // component itself, so unwrap a nested default when present.- default: ((mod.default as any)?.default ??- mod.default) as unknown as ComponentType<DatePickerPropsType>,- })),-);-export const DateTimePicker = ({instanceId,date,@@ -139,214 +55,127 @@ export const DateTimePicker = ({hideHeaderInput,timeZone,}: DateTimePickerProps) => {- const theme = useTheme();- const { userFirstDayOfTheWeek } = useUserFirstDayOfTheWeek();-const { userTimezone } = useUserTimezone();-- const dateToUse =- date ?? Temporal.Now.zonedDateTimeISO(timeZone ?? userTimezone);-+ const { userFirstDayOfTheWeek } = useUserFirstDayOfTheWeek();+ const resolvedTimeZone = timeZone ?? userTimezone;+ const dateToUse = date ?? Temporal.Now.zonedDateTimeISO(resolvedTimeZone);const { getShiftedDateToSystemTimeZone } =useGetShiftedDateToSystemTimeZone();-- const getZonedDateTimeFromDatePicked = (datePicked: Date) => {- const plainDatePart = Temporal.PlainDate.from({- day: datePicked.getDate(),- month: datePicked.getMonth() + 1,- year: datePicked.getFullYear(),- });-- const zonedDateTime = plainDatePart- .toZonedDateTime(timeZone ?? userTimezone)- .with({- hour: dateToUse?.hour ?? 0,- minute: dateToUse?.minute ?? 0,- });-- return { zonedDateTime };- };-- const handleChangeMonth = (month: number) => {- const newZonedDateTime = dateToUse?.with({ month: month }) ?? null;-- onChange?.(newZonedDateTime);- };-- const handleAddMonth = () => {- const newZonedDateTime = dateToUse?.add({ months: 1 }) ?? null;-- onChange?.(newZonedDateTime);- };-- const handleSubtractMonth = () => {- const newZonedDateTime = dateToUse?.subtract({ months: 1 }) ?? null;-- onChange?.(newZonedDateTime);- };-- const handleChangeYear = (year: number) => {- const newZonedDateTime = dateToUse?.with({ year: year }) ?? null;-- onChange?.(newZonedDateTime);- };-- const handleDateChange = (newDate: Date | null) => {- if (!isDefined(newDate)) {- return;- }- const { zonedDateTime } = getZonedDateTimeFromDatePicked(newDate);-- onChange?.(zonedDateTime);- };-- const handleDateSelect = (newDate: Date | null) => {- if (!isDefined(newDate)) {- return;- }- const { zonedDateTime } = getZonedDateTimeFromDatePicked(newDate);-- onClose?.(zonedDateTime);- };-+ const selectedCalendarDate = getShiftedDateToSystemTimeZone(+ new Date(dateToUse.toInstant().toString()),+ resolvedTimeZone,+ );+ const selectedCalendarValue =+ turnJSDateToPlainDate(selectedCalendarDate).toString();+ const hasSelectedCalendarTime =+ selectedCalendarDate.getHours() !== 0 ||+ selectedCalendarDate.getMinutes() !== 0 ||+ selectedCalendarDate.getSeconds() !== 0 ||+ selectedCalendarDate.getMilliseconds() !== 0;const relativeUnit = relativeDate?.unit ?? doNotTranslate('DAY');const relativeRangeStart = isRelative ? relativeDate?.start : undefined;const relativeRangeEnd = isRelative ? relativeDate?.end : undefined;-+ const relativeRangeStartDate = relativeRangeStart?.toPlainDate().toString();+ const relativeRangeEndDate = relativeRangeEnd+ ?.subtract({ nanoseconds: 1 })+ .toPlainDate()+ .toString();+ const highlightedRange = isDefined(relativeRangeStartDate)+ ? {+ start: relativeRangeStartDate,+ end: relativeRangeEndDate ?? relativeRangeStartDate,+ }+ : undefined;const isSubDayRelativeUnit =isRelative === true && isSubDayRelativeDateFilterUnit(relativeUnit);+ const getZonedDateTimeFromDatePicked = (datePicked: string) =>+ Temporal.PlainDate.from(datePicked)+ .toZonedDateTime(resolvedTimeZone)+ .with({ hour: dateToUse.hour, minute: dateToUse.minute });- const relativeRangeStartPlainDate = isDefined(relativeRangeStart)- ? relativeRangeStart.toPlainDate()- : null;-- const relativeRangeEndPlainDate = isDefined(relativeRangeEnd)- ? relativeRangeEnd.subtract({ nanoseconds: 1 }).toPlainDate()- : null;-- const {- startDate: relativeRangeStartDate,- endDate: relativeRangeEndDate,- rangeKey: relativeDateRangeKey,- } = getRelativeDatePickerCalendarRange(- relativeRangeStartPlainDate,- relativeRangeEndPlainDate,- );-- const nonShiftedDateForReactDatePicker = new Date(- dateToUse.toInstant().toString(),- );+ const handleDateSelect = (datePicked: string) => {+ const selectedDate = getZonedDateTimeFromDatePicked(datePicked);+ const isSameCalendarDay = datePicked === selectedCalendarValue;- const shiftedDateForReactDatePicker = getShiftedDateToSystemTimeZone(- nonShiftedDateForReactDatePicker,- timeZone ?? userTimezone,- );+ if (isSameCalendarDay && hasSelectedCalendarTime) {+ onChange?.(selectedDate);+ }- const calendarStartDayNumber =- convertFirstDayOfTheWeekToCalendarStartDayNumber(userFirstDayOfTheWeek);+ onClose?.(selectedDate);+ };return (- <StyledOuterWrapper>- <StyledDatePickerContainer- calendarDisabled={isRelative && !isSubDayRelativeUnit}- >- {isSubDayRelativeUnit ? (- <>- <RelativeDatePickerHeader- instanceId={instanceId}- direction={relativeDate?.direction ?? 'PAST'}- amount={relativeDate?.amount}- unit={relativeUnit}- onChange={onRelativeDateChange}- allowIntraDayUnits={true}+ <StyledDatePickerContainer>+ {isSubDayRelativeUnit ? (+ <>+ <RelativeDatePickerHeader+ instanceId={instanceId}+ direction={relativeDate?.direction ?? 'PAST'}+ amount={relativeDate?.amount}+ unit={relativeUnit}+ onChange={onRelativeDateChange}+ allowIntraDayUnits+ />+ {isDefined(relativeRangeStart) && isDefined(relativeRangeEnd) && (+ <RelativeDateTimeRangeText+ start={relativeRangeStart}+ end={relativeRangeEnd}/>- {isDefined(relativeRangeStart) && isDefined(relativeRangeEnd) && (- <RelativeDateTimeRangeText- start={relativeRangeStart}- end={relativeRangeEnd}- />- )}- </>- ) : (- <Suspense- fallback={- <StyledDatePickerFallback>- <SkeletonLine width={200} height={SKELETON_HEIGHT_SIZES.m} />- <SkeletonLine width={240} height={SKELETON_HEIGHT_SIZES.l} />- <SkeletonLine width={220} height={SKELETON_HEIGHT_SIZES.m} />- <SkeletonLine width={180} height={SKELETON_HEIGHT_SIZES.s} />- </StyledDatePickerFallback>+ )}+ </>+ ) : (+ <DatePickerCalendar+ loadingFallback={<DateTimePickerLoadingFallback />}+ value={isRelative ? null : selectedCalendarValue}+ onChange={(datePicked) =>+ onChange?.(getZonedDateTimeFromDatePicked(datePicked))+ }+ onSelect={handleDateSelect}+ highlightedRange={highlightedRange}+ readOnly={isRelative}+ weekStart={convertFirstDayOfTheWeekToCalendarStartDayNumber(+ userFirstDayOfTheWeek,+ )}+ renderHeader={(header) => {+ if (isRelative) {+ return (+ <RelativeDatePickerHeader+ instanceId={instanceId}+ direction={relativeDate?.direction ?? 'PAST'}+ amount={relativeDate?.amount}+ unit={relativeUnit}+ onChange={onRelativeDateChange}+ allowIntraDayUnits+ calendarMonthDate={turnPlainDateToShiftedDateInSystemTimeZone(+ Temporal.PlainDate.from(`${header.viewedMonth}-01`),+ )}+ onPreviousMonth={header.onPreviousMonth}+ onNextMonth={header.onNextMonth}+ prevMonthButtonDisabled={header.isPreviousMonthDisabled}+ nextMonthButtonDisabled={header.isNextMonthDisabled}+ />+ );}- >- <ReactDatePicker- key={relativeDateRangeKey}- open={true}- disabledKeyboardNavigation- onChange={handleDateChange}- onSelect={handleDateSelect}- openToDate={- isRelative- ? relativeRangeStartDate- : shiftedDateForReactDatePicker- }- selectsRange={isRelative ? true : undefined}- startDate={isRelative ? relativeRangeStartDate : undefined}- endDate={isRelative ? relativeRangeEndDate : undefined}- selected={isRelative ? undefined : shiftedDateForReactDatePicker}- calendarStartDay={- calendarStartDayNumber as 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined- }- renderCustomHeader={({- monthDate,- decreaseMonth,- increaseMonth,- prevMonthButtonDisabled,- nextMonthButtonDisabled,- }) =>- isRelative ? (- <RelativeDatePickerHeader- instanceId={instanceId}- direction={relativeDate?.direction ?? 'PAST'}- amount={relativeDate?.amount}- unit={relativeUnit}- onChange={onRelativeDateChange}- allowIntraDayUnits={true}- calendarMonthDate={monthDate}- onPreviousMonth={decreaseMonth}- onNextMonth={increaseMonth}- prevMonthButtonDisabled={prevMonthButtonDisabled}- nextMonthButtonDisabled={nextMonthButtonDisabled}- />- ) : (- <DateTimePickerHeader- instanceId={instanceId}- date={dateToUse}- onChange={onChange}- onAddMonth={handleAddMonth}- onSubtractMonth={handleSubtractMonth}- prevMonthButtonDisabled={prevMonthButtonDisabled}- nextMonthButtonDisabled={nextMonthButtonDisabled}- hideInput={hideHeaderInput}- onChangeMonth={handleChangeMonth}- onChangeYear={handleChangeYear}- />- )- }- />- </Suspense>- )}- {clearable && (- <>- <StyledSeparator />- <StyledButtonContainer onClick={() => onClear?.()}>- <StyledButtonContent>- <IconCalendarX size={theme.icon.size.md} />- <Text>{t`Clear`}</Text>- </StyledButtonContent>- </StyledButtonContainer>- </>- )}- </StyledDatePickerContainer>- </StyledOuterWrapper>++ return (+ <DateTimePickerHeader+ instanceId={instanceId}+ date={dateToUse}+ viewedMonth={header.viewedMonth}+ onChange={onChange}+ onAddMonth={header.onNextMonth}+ onSubtractMonth={header.onPreviousMonth}+ prevMonthButtonDisabled={header.isPreviousMonthDisabled}+ nextMonthButtonDisabled={header.isNextMonthDisabled}+ hideInput={hideHeaderInput}+ onChangeMonth={header.onMonthChange}+ onChangeYear={header.onYearChange}+ />+ );+ }}+ />+ )}+ {clearable && <DatePickerClearButton onClear={onClear} />}+ </StyledDatePickerContainer>);};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePickerHeader.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePickerHeader.tsxindex 564f302a595..7ff1a623ad4 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePickerHeader.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePickerHeader.tsx@@ -1,21 +1,22 @@import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';import { styled } from '@linaria/react';-import { useEffect } from 'react';import { useIMask } from 'react-imask';import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';import { useDateTimeFormat } from '@/localization/hooks/useDateTimeFormat';import { Select } from '@/ui/input/components/Select';import { DateTimePickerInput } from '@/ui/input/components/internal/date/components/DateTimePickerInput';+import { DateTimePickerTimeValueEffect } from '@/ui/input/components/internal/date/components/DateTimePickerTimeValueEffect';import { useTimeInput } from '@/ui/input/components/internal/date/hooks/useTimeInput';import { getDatePickerDropdownIds } from '@/ui/input/components/internal/date/utils/getDatePickerDropdownIds';+import { DATE_PICKER_YEAR_SELECT_OPTIONS } from '@/ui/input/components/internal/date/constants/DatePickerYearSelectOptions';import { getMonthSelectOptions } from '@/ui/input/components/internal/date/utils/getMonthSelectOptions';import { getTimeBlocks } from '@/ui/input/components/internal/date/utils/getTimeBlocks';import { getTimeMask } from '@/ui/input/components/internal/date/utils/getTimeMask';import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';import { DropdownRoot } from '@/ui/layout/dropdown/components/DropdownRoot';import { t } from '@lingui/core/macro';-import { type Temporal } from 'temporal-polyfill';+import { Temporal } from 'temporal-polyfill';import { SOURCE_LOCALE } from 'twenty-shared/translations';import { isDefined } from 'twenty-shared/utils';import { doNotTranslate } from 'twenty-shared/i18n';@@ -30,10 +31,7 @@ import {} from 'twenty-ui/icon';import { themeCssVariables } from 'twenty-ui/theme';-const YEARS_SELECT_OPTIONS = Array.from(- { length: 200 },- (_, i) => new Date().getFullYear() + 50 - i,-).map((year) => ({ label: year.toString(), value: year }));+const TIME_INPUT_ICON_SIZE = 16;const StyledTimeRow = styled.div`align-items: center;@@ -78,6 +76,7 @@ const StyledMonthYearSelector = styled.div`type DateTimePickerHeaderProps = {instanceId: string;date: Temporal.ZonedDateTime | null;+ viewedMonth: string;onChange?: (date: Temporal.ZonedDateTime | null) => void;onAddMonth: () => void;onSubtractMonth: () => void;@@ -91,6 +90,7 @@ type DateTimePickerHeaderProps = {export const DateTimePickerHeader = ({instanceId,date,+ viewedMonth,onChange,onAddMonth,onSubtractMonth,@@ -102,6 +102,10 @@ export const DateTimePickerHeader = ({}: DateTimePickerHeaderProps) => {const { timeFormat } = useDateTimeFormat();const { formatTime, parseTime, isHour12 } = useTimeInput(timeFormat);+ const displayedMonth = Temporal.PlainYearMonth.from(viewedMonth);+ const formattedTime = isDefined(date)+ ? formatTime(date.hour, date.minute)+ : undefined;const currentWorkspaceMember = useAtomStateValue(currentWorkspaceMemberState);const userLocale = currentWorkspaceMember?.locale ?? SOURCE_LOCALE;@@ -112,7 +116,7 @@ export const DateTimePickerHeader = ({monthYearPanelDropdownId,} = getDatePickerDropdownIds(instanceId);- const { ref: iMaskRef, setValue } = useIMask(+ const { ref: iMaskRef, setValue } = useIMask<HTMLInputElement>({mask: getTimeMask(timeFormat),blocks: getTimeBlocks(timeFormat),@@ -120,14 +124,14 @@ export const DateTimePickerHeader = ({autofix: true,},{- defaultValue: isDefined(date)- ? formatTime(date.hour, date.minute)- : undefined,+ defaultValue: formattedTime,onComplete: (value) => {- if (!date) return;+ if (!isDefined(date)) {+ return;+ }const parsedTime = parseTime(value);- if (!parsedTime) {+ if (!isDefined(parsedTime)) {return;}@@ -138,16 +142,14 @@ export const DateTimePickerHeader = ({},);- useEffect(() => {- if (isDefined(date)) {- setValue(formatTime(date.hour, date.minute));- }- }, [date, formatTime, setValue]);-- const timeInputRef = iMaskRef as React.Ref<HTMLInputElement>;-return (<>+ {isDefined(formattedTime) && (+ <DateTimePickerTimeValueEffect+ value={formattedTime}+ setValue={setValue}+ />+ )}{!hideInput && (<><DateTimePickerInput date={date} onChange={onChange} />@@ -156,10 +158,10 @@ export const DateTimePickerHeader = ({)}<StyledTimeRow><Field.Root render={<StyledTimeInputWrapper />}>- <InputGroup startElement={<IconClock size={16} />}>+ <InputGroup startElement={<IconClock size={TIME_INPUT_ICON_SIZE} />}><Inputtype="text"- ref={timeInputRef}+ ref={iMaskRef}placeholder={doNotTranslate(isHour12 ? 'HH:mm AA' : 'HH:mm')}aria-label={t`Time`}/>@@ -188,15 +190,15 @@ export const DateTimePickerHeader = ({dropdownId={monthSelectDropdownId}options={getMonthSelectOptions(userLocale)}onChange={onChangeMonth}- value={date?.month}+ value={displayedMonth.month}fullWidth={false}dropdownWidth={160}/><SelectdropdownId={yearSelectDropdownId}onChange={onChangeYear}- value={date?.year}- options={YEARS_SELECT_OPTIONS}+ value={displayedMonth.year}+ options={DATE_PICKER_YEAR_SELECT_OPTIONS}fullWidth={false}dropdownWidth={160}/>diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePickerLoadingFallback.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePickerLoadingFallback.tsxnew file mode 100644index 00000000000..e71103aaa8b--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePickerLoadingFallback.tsx@@ -0,0 +1,18 @@+import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';+import { DatePickerLoadingFallback } from '@/ui/input/components/internal/date/components/DatePickerLoadingFallback';+import { SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';++const DATE_TIME_PICKER_LOADING_ROWS = [+ { width: 200, height: SKELETON_HEIGHT_SIZES.m },+ { width: 240, height: SKELETON_HEIGHT_SIZES.l },+ { width: 220, height: SKELETON_HEIGHT_SIZES.m },+ { width: 180, height: SKELETON_HEIGHT_SIZES.s },+];++export const DateTimePickerLoadingFallback = () => (+ <DatePickerLoadingFallback>+ {DATE_TIME_PICKER_LOADING_ROWS.map(({ width, height }) => (+ <SkeletonLine key={width} width={width} height={height} />+ ))}+ </DatePickerLoadingFallback>+);diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePickerTimeValueEffect.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePickerTimeValueEffect.tsxnew file mode 100644index 00000000000..a72aaa97cdb--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/DateTimePickerTimeValueEffect.tsx@@ -0,0 +1,17 @@+import { useEffect } from 'react';++type DateTimePickerTimeValueEffectProps = {+ value: string;+ setValue: (value: string) => void;+};++export const DateTimePickerTimeValueEffect = ({+ value,+ setValue,+}: DateTimePickerTimeValueEffectProps) => {+ useEffect(() => {+ setValue(value);+ }, [setValue, value]);++ return null;+};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/StyledDatePickerContainer.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/StyledDatePickerContainer.tsxindex 50c2bdd9364..f3f93c2a178 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/StyledDatePickerContainer.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/StyledDatePickerContainer.tsx@@ -1,260 +1,6 @@+import { DATE_PICKER_CONTAINER_WIDTH } from '@/ui/input/components/internal/date/constants/DatePickerContainerWidth';import { styled } from '@linaria/react';-import { themeCssVariables } from 'twenty-ui/theme';-export const DATE_PICKER_CONTAINER_WIDTH = 280;--export const StyledDatePickerContainer = styled.div<{- calendarDisabled?: boolean;- hideCalendar?: boolean;-}>`+export const StyledDatePickerContainer = styled.div`width: ${DATE_PICKER_CONTAINER_WIDTH}px;-- & .react-datepicker {- border-color: ${themeCssVariables.border.color.light};- background: transparent;- font-family: 'Inter';- font-size: ${themeCssVariables.font.size.md};- border: none;- display: block;- font-weight: ${themeCssVariables.font.weight.regular};- }-- & .react-datepicker-popper {- position: relative !important;- inset: auto !important;- transform: none !important;- padding: 0 !important;- }-- & .react-datepicker__triangle {- display: none;- }-- & .react-datepicker__triangle::after {- display: none;- }-- & .react-datepicker__triangle::before {- display: none;- }-- & .react-datepicker-wrapper {- display: none;- }-- & .react-datepicker__header {- background: transparent;- border: none;- padding: 0;- }-- &- .react-datepicker__input-time-container- .react-datepicker-time__input-container- .react-datepicker-time__input {- outline: none;- }-- & .react-datepicker__header__dropdown {- display: flex;- color: ${themeCssVariables.font.color.primary};- margin-left: ${themeCssVariables.spacing[1]};- margin-bottom: ${themeCssVariables.spacing[10]};- }-- & .react-datepicker__month-dropdown-container,- & .react-datepicker__year-dropdown-container {- text-align: left;- border-radius: calc(- ${themeCssVariables.border.radius.md} - ${themeCssVariables.spacing[1]}- );- margin-left: ${themeCssVariables.spacing[1]};- margin-right: 0;- padding: ${themeCssVariables.spacing[2]};- padding-right: ${themeCssVariables.spacing[4]};- background-color: ${themeCssVariables.background.tertiary};- }-- & .react-datepicker__month-read-view--down-arrow,- & .react-datepicker__year-read-view--down-arrow {- height: 5px;- width: 5px;- border-width: 1px 1px 0 0;- border-color: ${themeCssVariables.border.color.light};- top: 3px;- right: -6px;- }-- & .react-datepicker__year-read-view,- & .react-datepicker__month-read-view {- padding-right: ${themeCssVariables.spacing[2]};- }-- & .react-datepicker__month-dropdown-container {- width: 80px;- }-- & .react-datepicker__year-dropdown-container {- width: 50px;- }-- & .react-datepicker__month-dropdown,- & .react-datepicker__year-dropdown {- overflow-y: scroll;- top: ${themeCssVariables.spacing[2]};- }- & .react-datepicker__month-dropdown {- left: ${themeCssVariables.spacing[2]};- height: 260px;- }-- & .react-datepicker__year-dropdown {- left: calc(${themeCssVariables.spacing[9]} + 80px);- width: 100px;- height: 260px;- }-- & .react-datepicker__navigation--years {- display: none;- }-- & .react-datepicker__month-option--selected,- & .react-datepicker__year-option--selected {- display: none;- }-- & .react-datepicker__year-option,- & .react-datepicker__month-option {- text-align: left;- padding: ${themeCssVariables.spacing[2]}- calc(${themeCssVariables.spacing[2]} - 2px);- width: calc(100% - ${themeCssVariables.spacing[4]});- border-radius: ${themeCssVariables.border.radius.xs};- color: ${themeCssVariables.font.color.secondary};- cursor: pointer;- margin: 2px;-- &:hover {- background: ${themeCssVariables.background.transparent.light};- }- }-- & .react-datepicker__year-option {- &:first-of-type,- &:last-of-type {- display: none;- }- }-- & .react-datepicker__current-month {- display: none;- }-- & .react-datepicker__day-name {- color: ${themeCssVariables.font.color.secondary};- width: 34px;- height: 40px;- line-height: 40px;- // Uniform 2px margin keeps the header row aligned with the day grid below;- // react-datepicker's default (0.166rem) leaves the grid tighter on the right.- margin: 2px;- }-- & .react-datepicker__month-container {- float: none;- }-- & .react-datepicker__month {- margin: 0;-- pointer-events: ${({ calendarDisabled }) =>- calendarDisabled ? 'none' : 'auto'};- opacity: ${({ calendarDisabled }) => (calendarDisabled ? '0.5' : '1')};-- display: ${({ hideCalendar }) =>- hideCalendar === true ? 'none' : 'visible'};- }-- & .react-datepicker__day-names {- display: ${({ hideCalendar }) =>- hideCalendar === true ? 'none' : 'visible'};- }-- & .react-datepicker__day {- width: 34px;- height: 34px;- line-height: 34px;- // Matches the day-name margin so each column lines up symmetrically.- margin: 2px;- }-- & .react-datepicker__navigation--previous,- & .react-datepicker__navigation--next {- height: 34px;- border-radius: calc(- ${themeCssVariables.border.radius.md} - ${themeCssVariables.spacing[1]}- );- padding-top: 6px;- &:hover {- background: ${themeCssVariables.background.transparent.light};- }- }- & .react-datepicker__navigation--previous {- right: 38px;- top: 6px;- left: auto;-- & > span {- margin-left: -6px;- }- }-- & .react-datepicker__navigation--next {- right: 6px;- top: 6px;-- & > span {- margin-left: 6px;- }- }-- & .react-datepicker__navigation-icon::before {- height: 7px;- width: 7px;- border-width: 1px 1px 0 0;- border-color: ${themeCssVariables.font.color.tertiary};- }-- & .react-datepicker__day--keyboard-selected {- background-color: inherit;- }-- & .react-datepicker__day,- .react-datepicker__time-name {- color: ${themeCssVariables.font.color.primary};- }-- & .react-datepicker__day--selected,- & .react-datepicker__day--in-range,- & .react-datepicker__day--range-start,- & .react-datepicker__day--range-end {- background-color: ${themeCssVariables.color.blue};- color: ${themeCssVariables.background.primary};-- &.react-datepicker__day:hover {- color: ${themeCssVariables.background.primary};- }- }-- & .react-datepicker__day--outside-month {- color: ${themeCssVariables.font.color.tertiary};- }-- & .react-datepicker__day:hover {- color: ${themeCssVariables.font.color.tertiary};- }-- & .clearable {- border-bottom: 1px solid ${themeCssVariables.border.color.light};- }`;diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DatePicker.stories.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DatePicker.stories.tsxindex 56e1e7f0457..bb2b7fe65d3 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DatePicker.stories.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DatePicker.stories.tsx@@ -1,9 +1,10 @@import { DatePicker } from '@/ui/input/components/internal/date/components/DatePicker';import { type Meta, type StoryObj } from '@storybook/react-vite';import { useState } from 'react';-import { expect, userEvent, waitFor, within } from 'storybook/test';+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';import { type RelativeDateFilter } from 'twenty-shared/utils';import { ComponentDecorator } from 'twenty-ui/testing';+import { Text } from 'twenty-ui/primitives/typography';const INITIAL_PLAIN_DATE = '2023-01-01';@@ -19,24 +20,36 @@ const DatePickerStory = ({instanceId = 'story-date-picker',isRelative,clearable,+ onChange,+ onClose,}: {instanceId?: string;isRelative?: boolean;clearable?: boolean;+ onChange?: (date: string | null) => void;+ onClose?: (date: string | null) => void;}) => {const [plainDateString, setPlainDateString] = useState<string | null>(INITIAL_PLAIN_DATE,);return (- <DatePicker- instanceId={instanceId}- plainDateString={plainDateString}- onChange={setPlainDateString}- clearable={clearable}- isRelative={isRelative}- relativeDate={isRelative ? RELATIVE_DATE : undefined}- />+ <>+ <DatePicker+ instanceId={instanceId}+ plainDateString={plainDateString}+ onChange={(date) => {+ setPlainDateString(date);+ onChange?.(date);+ }}+ onClose={onClose}+ onClear={() => setPlainDateString(null)}+ clearable={clearable}+ isRelative={isRelative}+ relativeDate={isRelative ? RELATIVE_DATE : undefined}+ />+ <Text aria-label="Selected date">{plainDateString ?? 'None'}</Text>+ </>);};@@ -53,8 +66,11 @@ type Story = StoryObj<typeof DatePicker>;export const Default: Story = {play: async ({ canvasElement }) => {const canvas = within(canvasElement);- // Lazy-loaded react-datepicker renders the day grid; wait for a day cell.- await canvas.findByText('15', {}, { timeout: 10000 });+ await canvas.findByRole(+ 'gridcell',+ { name: /^Choose Sunday, January 15/ },+ { timeout: 10000 },+ );},};@@ -62,7 +78,11 @@ export const NotClearable: Story = {render: () => <DatePickerStory clearable={false} />,play: async ({ canvasElement }) => {const canvas = within(canvasElement);- await canvas.findByText('15', {}, { timeout: 10000 });+ await canvas.findByRole(+ 'gridcell',+ { name: /^Choose Sunday, January 15/ },+ { timeout: 10000 },+ );expect(canvas.queryByText('Clear')).not.toBeInTheDocument();},};@@ -71,7 +91,13 @@ export const Relative: Story = {render: () => <DatePickerStory isRelative />,play: async ({ canvasElement }) => {const canvas = within(canvasElement);- await canvas.findByText('15', {}, { timeout: 10000 });+ await expect(+ await canvas.findByRole(+ 'gridcell',+ { name: /^Choose Sunday, December 25/ },+ { timeout: 10000 },+ ),+ ).toHaveAttribute('aria-selected', 'true');},};@@ -126,7 +152,84 @@ export const OpensOnlyItsOwnMonthSelect: Story = {await userEvent.click(firstMonthSelect);await waitFor(() => {- expect(body.getAllByRole('dialog', { name: 'January' })).toHaveLength(1);+ expect(body.getAllByRole('listbox')).toHaveLength(1);+ });+ },+};++export const NavigationDoesNotSelect: Story = {+ args: { onChange: fn(), onClose: fn() },+ render: ({ onChange, onClose }) => (+ <DatePickerStory onChange={onChange} onClose={onClose} />+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ await userEvent.click(await canvas.findByRole('button', { name: 'Next' }));+ const nextDate = await canvas.findByRole('gridcell', {+ name: /^Choose Wednesday, February 15/,+ });+ expect(canvas.getByText('February')).toBeVisible();+ expect(canvas.getByLabelText('Selected date')).toHaveTextContent(+ INITIAL_PLAIN_DATE,+ );+ expect(args.onChange).not.toHaveBeenCalled();+ expect(args.onClose).not.toHaveBeenCalled();+ await userEvent.click(nextDate);+ expect(args.onChange).toHaveBeenCalledWith('2023-02-15');+ expect(args.onClose).toHaveBeenCalledWith('2023-02-15');+ },+};++export const SelectingTheSameDateOnlyCloses: Story = {+ args: { onChange: fn(), onClose: fn() },+ render: ({ onChange, onClose }) => (+ <DatePickerStory onChange={onChange} onClose={onClose} />+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ await userEvent.click(+ await canvas.findByRole('gridcell', {+ name: /^Choose Sunday, January 1st, 2023$/,+ }),+ );+ expect(args.onChange).not.toHaveBeenCalled();+ expect(args.onClose).toHaveBeenCalledOnce();+ expect(args.onClose).toHaveBeenCalledWith(INITIAL_PLAIN_DATE);+ },+};++export const SelectsAnAdjacentMonthDate: Story = {+ args: { onChange: fn(), onClose: fn() },+ render: ({ onChange, onClose }) => (+ <DatePickerStory onChange={onChange} onClose={onClose} />+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ expect(await canvas.findByText('January')).toBeVisible();+ await userEvent.click(+ await canvas.findByRole('gridcell', {+ name: /^Choose Wednesday, February 1st, 2023$/,+ }),+ );+ expect(args.onChange).toHaveBeenCalledOnce();+ expect(args.onChange).toHaveBeenCalledWith('2023-02-01');+ expect(args.onClose).toHaveBeenCalledOnce();+ expect(args.onClose).toHaveBeenCalledWith('2023-02-01');+ expect(canvas.getByLabelText('Selected date')).toHaveTextContent(+ '2023-02-01',+ );+ },+};++export const ClearSelection: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await userEvent.click(await canvas.findByText('Clear'));+ expect(canvas.getByLabelText('Selected date')).toHaveTextContent('None');+ await waitFor(() => {+ const selectedDates = canvas.getAllByRole('gridcell', { selected: true });+ expect(selectedDates).toHaveLength(1);+ expect(selectedDates[0]).toHaveAttribute('aria-current', 'date');});},};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DatePickerWithoutCalendar.stories.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DatePickerWithoutCalendar.stories.tsxindex fa29b252d8e..95de287d44f 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DatePickerWithoutCalendar.stories.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DatePickerWithoutCalendar.stories.tsx@@ -1,7 +1,7 @@import { DatePickerWithoutCalendar } from '@/ui/input/components/internal/date/components/DatePickerWithoutCalendar';import { type Meta, type StoryObj } from '@storybook/react-vite';import { useState } from 'react';-import { expect, userEvent, waitFor, within } from 'storybook/test';+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';import { ComponentDecorator } from 'twenty-ui/testing';const INITIAL_PLAIN_DATE = '2023-01-01';@@ -35,7 +35,6 @@ type Story = StoryObj<typeof DatePickerWithoutCalendar>;export const Default: Story = {play: async ({ canvasElement }) => {const canvas = within(canvasElement);- // Calendar grid is hidden; only the month/year header should be present.const monthSelect = await canvas.findByText('January',{},@@ -64,7 +63,40 @@ export const OpensOnlyItsOwnYearSelect: Story = {await userEvent.click(firstYearSelect);await waitFor(() => {- expect(body.getAllByRole('dialog', { name: '2023' })).toHaveLength(1);+ expect(body.getAllByRole('listbox')).toHaveLength(1);});},};++export const ChangesMonthWithoutShowingDays: Story = {+ args: { date: '2023-01-31', onChange: fn() },+ render: ({ date, onChange }) => (+ <DatePickerWithoutCalendar+ date={date}+ onChange={onChange}+ instanceId="month-only"+ />+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ expect(canvas.queryByRole('gridcell')).not.toBeInTheDocument();+ await userEvent.click(await canvas.findByRole('button', { name: 'Next' }));+ expect(args.onChange).toHaveBeenCalledWith('2023-02-28');+ },+};++export const KeepsEmptySelection: Story = {+ args: { date: null, onChange: fn() },+ render: ({ date, onChange }) => (+ <DatePickerWithoutCalendar+ date={date}+ onChange={onChange}+ instanceId="empty-month-only"+ />+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ await userEvent.click(await canvas.findByRole('button', { name: 'Next' }));+ expect(args.onChange).toHaveBeenCalledWith(null);+ },+};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DateTimePicker.stories.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DateTimePicker.stories.tsxindex 38f1d407f35..14ad292c47d 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DateTimePicker.stories.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/components/__stories__/DateTimePicker.stories.tsx@@ -1,14 +1,23 @@-import { DateTimePicker } from '@/ui/input/components/internal/date/components/DateTimePicker';import { type Meta, type StoryObj } from '@storybook/react-vite';import { useState } from 'react';-import { expect, userEvent, waitFor, within } from 'storybook/test';+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';import { Temporal } from 'temporal-polyfill';import { Field } from 'twenty-ui/primitives/input';+import { Text } from 'twenty-ui/primitives/typography';import { ComponentDecorator } from 'twenty-ui/testing';+import { DateTimePicker } from '@/ui/input/components/internal/date/components/DateTimePicker';+const INITIAL_DATE = Temporal.ZonedDateTime.from('2023-01-01T02:00:00+00:00[UTC]',);+const MIDNIGHT_DATE = Temporal.ZonedDateTime.from(+ '2023-01-01T00:00:00+00:00[UTC]',+);+const ZONED_DATE = Temporal.ZonedDateTime.from(+ '2023-01-01T02:15:30.123456789+00:00[UTC]',+);+const NEXT_YEAR_OPTION_LABEL = /^2024$/;const RELATIVE_CALENDAR_RANGE = {direction: 'PAST' as const,@@ -28,13 +37,35 @@ const RELATIVE_SUB_DAY_RANGE = {const DateTimePickerStory = ({instanceId = 'story-date-time-picker',+ initialDate = INITIAL_DATE,+ timeZone = 'UTC',+ onChange,+ onClose,+ isSelectedDateShown = false,}: {instanceId?: string;+ initialDate?: Temporal.ZonedDateTime;+ timeZone?: string;+ onChange?: (date: Temporal.ZonedDateTime | null) => void;+ onClose?: (date: Temporal.ZonedDateTime | null) => void;+ isSelectedDateShown?: boolean;}) => {- const [date, setDate] = useState<Temporal.ZonedDateTime | null>(INITIAL_DATE);+ const [date, setDate] = useState<Temporal.ZonedDateTime | null>(initialDate);return (- <DateTimePicker instanceId={instanceId} date={date} onChange={setDate} />+ <>+ <DateTimePicker+ instanceId={instanceId}+ date={date}+ timeZone={timeZone}+ onChange={(nextDate) => {+ setDate(nextDate);+ onChange?.(nextDate);+ }}+ onClose={onClose}+ />+ {isSelectedDateShown && <Text role="status">{date?.toString()}</Text>}+ </>);};@@ -42,7 +73,10 @@ const meta: Meta<typeof DateTimePicker> = {title: 'UI/Input/Internal/Date/DateTimePicker',component: DateTimePicker,decorators: [ComponentDecorator],- render: () => <DateTimePickerStory />,+ args: { onChange: fn(), onClose: fn() },+ render: ({ onChange, onClose }) => (+ <DateTimePickerStory onChange={onChange} onClose={onClose} />+ ),};export default meta;@@ -51,77 +85,70 @@ type Story = StoryObj<typeof DateTimePicker>;export const Default: Story = {play: async ({ canvasElement }) => {const canvas = within(canvasElement);- await canvas.findByRole(- 'button',- { name: 'Select month and year' },- { timeout: 10000 },- );++ await expect(+ await canvas.findByRole('gridcell', {+ name: /^Choose Sunday, January 15/,+ }),+ ).toBeVisible();+ await expect(canvas.getByRole('textbox', { name: 'Time' })).toBeVisible();+ await expect(+ canvas.getByRole('button', { name: 'Select month and year' }),+ ).toBeVisible();},};export const WithOpenMonthSelect: Story = {- play: async ({ canvasElement }) => {+ play: async ({ canvasElement, args }) => {const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);- const calendarButton = await canvas.findByRole(- 'button',- { name: 'Select month and year' },- { timeout: 10000 },+ await userEvent.click(+ await canvas.findByRole('button', { name: 'Select month and year' }),);- await userEvent.click(calendarButton);-- const monthSelect = await body.findByText(- 'January',- {},- { timeout: 10000 },+ const panel = within(+ await body.findByRole('dialog', { name: 'Select month and year' }),+ );+ await userEvent.click(panel.getByText('January'));+ const options = await body.findByRole('listbox');+ await userEvent.click(+ within(options).getByRole('option', { name: 'February' }),);- await userEvent.click(monthSelect);-- for (const monthLabel of [- 'February',- 'March',- 'April',- 'May',- 'June',- 'July',- 'August',- 'September',- 'October',- 'November',- 'December',- ]) {- expect(await body.findByText(monthLabel)).toBeInTheDocument();- }-- await userEvent.click(await body.findByText('February'));-- expect(await body.findByText('February')).toBeInTheDocument();++ await expect(+ await canvas.findByRole('gridcell', {+ name: /^Choose Wednesday, February 15/,+ }),+ ).toBeVisible();+ await expect(args.onChange).not.toHaveBeenCalled();+ await expect(args.onClose).not.toHaveBeenCalled();},};export const WithOpenYearSelect: Story = {- play: async ({ canvasElement }) => {+ play: async ({ canvasElement, args }) => {const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);- const calendarButton = await canvas.findByRole(- 'button',- { name: 'Select month and year' },- { timeout: 10000 },+ await userEvent.click(+ await canvas.findByRole('button', { name: 'Select month and year' }),+ );+ const panel = within(+ await body.findByRole('dialog', { name: 'Select month and year' }),+ );+ await userEvent.click(panel.getByText('2023'));+ const options = await body.findByRole('listbox');+ await userEvent.click(+ within(options).getByRole('option', { name: NEXT_YEAR_OPTION_LABEL }),);- await userEvent.click(calendarButton);-- const yearSelect = await body.findByText('2023', {}, { timeout: 10000 });- await userEvent.click(yearSelect);-- for (const yearLabel of ['2024', '2025', '2026']) {- expect(await body.findByText(yearLabel)).toBeInTheDocument();- }-- await userEvent.click(await body.findByText('2024'));- expect(await body.findByText('2024')).toBeInTheDocument();+ await expect(+ await canvas.findByRole('gridcell', {+ name: /^Choose Monday, January 15/,+ }),+ ).toBeVisible();+ await expect(args.onChange).not.toHaveBeenCalled();+ await expect(args.onClose).not.toHaveBeenCalled();},};@@ -133,31 +160,125 @@ export const WithTimeInput: Story = {</Field.Root>),play: async ({ canvasElement }) => {+ await expect(+ await within(canvasElement).findByRole('textbox', { name: 'Time' }),+ ).toBeVisible();+ },+};++export const SelectingTheSameDateWithTime: Story = {+ render: ({ onChange, onClose }) => (+ <DateTimePickerStory+ initialDate={ZONED_DATE}+ onChange={onChange}+ onClose={onClose}+ isSelectedDateShown+ />+ ),+ play: async ({ canvasElement, args }) => {const canvas = within(canvasElement);+ await userEvent.click(+ await canvas.findByRole('gridcell', {+ name: /^Choose Sunday, January 1st, 2023$/,+ }),+ );+ await expect(args.onChange).toHaveBeenCalledOnce();+ await expect(args.onClose).toHaveBeenCalledOnce();+ await expect(canvas.getByRole('status')).toHaveTextContent(+ '2023-01-01T02:15:00+00:00[UTC]',+ );+ },+};- // Increased timeout to account for lazy-loaded react-datepicker on slower CI runners- const timeInput = await canvas.findByPlaceholderText(- /HH:mm/,- {},- { timeout: 10000 },+export const SelectingTheSameDateAtMidnightOnlyCloses: Story = {+ render: ({ onChange, onClose }) => (+ <DateTimePickerStory+ initialDate={MIDNIGHT_DATE}+ onChange={onChange}+ onClose={onClose}+ />+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ await userEvent.click(+ await canvas.findByRole('gridcell', {+ name: /^Choose Sunday, January 1st, 2023$/,+ }),);+ await expect(args.onChange).not.toHaveBeenCalled();+ await expect(args.onClose).toHaveBeenCalledOnce();+ },+};- expect(timeInput).toBeInTheDocument();- expect(canvas.getByRole('textbox', { name: 'Time' })).toBe(timeInput);+export const PreservesTimeInTheSelectedTimezone: Story = {+ render: ({ onChange, onClose }) => (+ <DateTimePickerStory+ initialDate={ZONED_DATE}+ timeZone="America/Los_Angeles"+ onChange={onChange}+ onClose={onClose}+ isSelectedDateShown+ />+ ),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const selectedDate = await canvas.findByRole('gridcell', {+ name: /^Choose Saturday, December 31/,+ });++ await expect(selectedDate).toHaveAttribute('aria-selected', 'true');+ await userEvent.click(+ canvas.getByRole('gridcell', {+ name: /^Choose Friday, December 30/,+ }),+ );+ await waitFor(() =>+ expect(canvas.getByRole('status')).toHaveTextContent(+ '2022-12-30T02:15:00-08:00[America/Los_Angeles]',+ ),+ );+ await expect(args.onClose).toHaveBeenCalledOnce();},};export const RelativeWithCalendarRange: Story = {- render: () => (+ render: ({ onChange }) => (<DateTimePickerinstanceId="story-relative-date-time-picker"date={null}isRelative+ timeZone="UTC"relativeDate={RELATIVE_CALENDAR_RANGE}- onChange={() => {}}+ onChange={onChange}onRelativeDateChange={() => {}}/>),+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const firstDate = await canvas.findByRole('gridcell', {+ name: /^Choose Thursday, December 1st, 2022$/,+ });+ const lastDate = canvas.getByRole('gridcell', {+ name: /^Choose Saturday, December 31/,+ });++ await expect(firstDate).toHaveAttribute('aria-selected', 'true');+ await expect(lastDate).toHaveAttribute('aria-selected', 'true');+ await expect(+ canvas.getByRole('rowgroup', { name: 'Month December, 2022' }),+ ).toHaveStyle({ pointerEvents: 'none', opacity: '0.5' });+ await userEvent.click(canvas.getByRole('button', { name: 'Next' }));+ await expect(+ await canvas.findByText('January 2023', {+ selector: 'span:not([role="alert"])',+ }),+ ).toBeVisible();+ const exclusiveEndDate = canvas.getByRole('gridcell', {+ name: /^Choose Sunday, January 1st, 2023$/,+ });+ await expect(exclusiveEndDate).toHaveAttribute('aria-selected', 'false');+ await expect(args.onChange).not.toHaveBeenCalled();+ },};export const RelativeWithSubDayText: Story = {@@ -166,14 +287,20 @@ export const RelativeWithSubDayText: Story = {instanceId="story-relative-sub-day-picker"date={null}isRelative+ timeZone="UTC"relativeDate={RELATIVE_SUB_DAY_RANGE}onChange={() => {}}onRelativeDateChange={() => {}}/>),+ play: async ({ canvasElement }) => {+ await expect(+ within(canvasElement).queryByRole('gridcell'),+ ).not.toBeInTheDocument();+ },};-export const OpensOnlyItsOwnMonthYearPanel: Story = {+export const OpensOnlyItsOwnMonthSelect: Story = {render: () => (<><DateTimePickerStory instanceId="first-date-time-picker" />@@ -183,18 +310,20 @@ export const OpensOnlyItsOwnMonthYearPanel: Story = {play: async ({ canvasElement }) => {const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);- const [firstCalendarButton] = await canvas.findAllByRole(- 'button',- { name: 'Select month and year' },- { timeout: 10000 },- );+ const [firstCalendarButton, secondCalendarButton] =+ await canvas.findAllByRole('button', { name: 'Select month and year' });await userEvent.click(firstCalendarButton);-- await waitFor(() => {- expect(- body.getAllByRole('dialog', { name: 'Select month and year' }),- ).toHaveLength(1);+ const panels = await body.findAllByRole('dialog', {+ name: 'Select month and year',});+ await expect(panels).toHaveLength(1);+ await expect(firstCalendarButton).toHaveAttribute('aria-expanded', 'true');+ await expect(secondCalendarButton).toHaveAttribute(+ 'aria-expanded',+ 'false',+ );+ await userEvent.click(within(panels[0]).getByText('January'));+ await expect(await body.findAllByRole('listbox')).toHaveLength(1);},};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DatePickerContainerWidth.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DatePickerContainerWidth.tsnew file mode 100644index 00000000000..6102af40e3a--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DatePickerContainerWidth.ts@@ -0,0 +1 @@+export const DATE_PICKER_CONTAINER_WIDTH = 280;diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DatePickerYearSelectOptions.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DatePickerYearSelectOptions.tsnew file mode 100644index 00000000000..3c7f67531f4--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DatePickerYearSelectOptions.ts@@ -0,0 +1,9 @@+import { DATE_PICKER_YEAR_SELECT_OPTIONS_CONFIG } from '@/ui/input/components/internal/date/constants/DatePickerYearSelectOptionsConfig';++export const DATE_PICKER_YEAR_SELECT_OPTIONS = Array.from(+ { length: DATE_PICKER_YEAR_SELECT_OPTIONS_CONFIG.optionCount },+ (_, index) =>+ new Date().getFullYear() ++ DATE_PICKER_YEAR_SELECT_OPTIONS_CONFIG.yearsAfterCurrentYear -+ index,+).map((year) => ({ label: year.toString(), value: year }));diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DatePickerYearSelectOptionsConfig.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DatePickerYearSelectOptionsConfig.tsnew file mode 100644index 00000000000..8b9cc806890--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DatePickerYearSelectOptionsConfig.ts@@ -0,0 +1,4 @@+export const DATE_PICKER_YEAR_SELECT_OPTIONS_CONFIG = {+ optionCount: 200,+ yearsAfterCurrentYear: 50,+};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/exceptions/DatePickerException.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/exceptions/DatePickerException.tsnew file mode 100644index 00000000000..44962d77256--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/exceptions/DatePickerException.ts@@ -0,0 +1,8 @@+import { doNotTranslate } from 'twenty-shared/i18n';++export class DatePickerException extends RangeError {+ constructor({ message }: { message: string }) {+ super(message);+ this.name = doNotTranslate('DatePickerException');+ }+}diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/__tests__/getDatePickerWeekStartOrThrow.test.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/__tests__/getDatePickerWeekStartOrThrow.test.tsnew file mode 100644index 00000000000..3a3c6613298--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/__tests__/getDatePickerWeekStartOrThrow.test.ts@@ -0,0 +1,46 @@+import { CalendarStartDay } from 'twenty-shared/constants';+import { FirstDayOfTheWeek } from 'twenty-shared/types';++import { DatePickerException } from '@/ui/input/components/internal/date/exceptions/DatePickerException';++import { detectCalendarStartDay } from '@/localization/utils/detection/detectCalendarStartDay';++import { getDatePickerWeekStartOrThrow } from '@/ui/input/components/internal/date/utils/getDatePickerWeekStartOrThrow';++jest.mock('@/localization/utils/detection/detectCalendarStartDay');++describe('getDatePickerWeekStartOrThrow', () => {+ it.each([CalendarStartDay.MONDAY, CalendarStartDay.SATURDAY, 2])(+ 'preserves the configured weekday %s',+ (calendarStartDay) => {+ expect(getDatePickerWeekStartOrThrow(calendarStartDay)).toBe(+ calendarStartDay,+ );+ },+ );++ it.each([undefined, null])(+ 'uses Sunday for missing preference %s',+ (calendarStartDay) => {+ expect(getDatePickerWeekStartOrThrow(calendarStartDay)).toBe(+ CalendarStartDay.SUNDAY,+ );+ },+ );++ it.each([-1, 8])('rejects the unsupported weekday %s', (calendarStartDay) => {+ expect(() => getDatePickerWeekStartOrThrow(calendarStartDay)).toThrow(+ DatePickerException,+ );+ });++ it('detects the weekday for the system preference', () => {+ jest+ .mocked(detectCalendarStartDay)+ .mockReturnValue(FirstDayOfTheWeek.MONDAY);++ expect(getDatePickerWeekStartOrThrow(CalendarStartDay.SYSTEM)).toBe(+ CalendarStartDay.MONDAY,+ );+ });+});diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/getDatePickerWeekStartOrThrow.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/getDatePickerWeekStartOrThrow.tsnew file mode 100644index 00000000000..083f6ea0699--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/getDatePickerWeekStartOrThrow.ts@@ -0,0 +1,42 @@+import { detectCalendarStartDay } from '@/localization/utils/detection/detectCalendarStartDay';+import { CalendarStartDay } from 'twenty-shared/constants';+import { doNotTranslate } from 'twenty-shared/i18n';+import {+ convertFirstDayOfTheWeekToCalendarStartDayNumber,+ isDefined,+} from 'twenty-shared/utils';++import { DatePickerException } from '@/ui/input/components/internal/date/exceptions/DatePickerException';+import { type DatePickerProps } from 'twenty-ui/components/input';++const CALENDAR_WEEK_START_DAYS: readonly DatePickerProps['weekStart'][] = [+ 0, 1, 2, 3, 4, 5, 6,+];++export const getDatePickerWeekStartOrThrow = (+ calendarStartDay?: number | null,+): DatePickerProps['weekStart'] => {+ if (!isDefined(calendarStartDay)) {+ return CalendarStartDay.SUNDAY;+ }++ if (calendarStartDay === CalendarStartDay.SYSTEM) {+ return convertFirstDayOfTheWeekToCalendarStartDayNumber(+ detectCalendarStartDay(),+ );+ }++ const weekStart = CALENDAR_WEEK_START_DAYS.find(+ (day) => day === calendarStartDay,+ );++ if (isDefined(weekStart)) {+ return weekStart;+ }++ throw new DatePickerException({+ message: doNotTranslate(+ 'Calendar week starts must be weekdays 0 through 6 or the system preference.',+ ),+ });+};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/getMonthSelectOptions.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/getMonthSelectOptions.tsindex 9c01090ed48..fe6d02910bf 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/getMonthSelectOptions.ts+++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/getMonthSelectOptions.ts@@ -1,24 +1,18 @@-const getMonthName = (index: number, locale?: string): string =>- new Intl.DateTimeFormat(locale || 'en-US', { month: 'long' }).format(- new Date(0, index, 1),- );--const getMonthNames = (- locale?: string,- monthNames: string[] = [],-): string[] => {- if (monthNames.length === 12) return monthNames;+import { isNonEmptyString } from '@sniptt/guards';+import { SOURCE_LOCALE } from 'twenty-shared/translations';- return getMonthNames(locale, [- ...monthNames,- getMonthName(monthNames.length, locale),- ]);-};+const MONTH_COUNT = 12;export const getMonthSelectOptions = (locale?: string,-): { label: string; value: number }[] =>- getMonthNames(locale).map((month, index) => ({- label: month,+): { label: string; value: number }[] => {+ const formatter = new Intl.DateTimeFormat(+ isNonEmptyString(locale) ? locale : SOURCE_LOCALE,+ { month: 'long' },+ );++ return Array.from({ length: MONTH_COUNT }, (_, index) => ({+ label: formatter.format(new Date(0, index, 1)),value: index + 1,}));+};diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/getRelativeDatePickerCalendarRange.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/getRelativeDatePickerCalendarRange.tsdeleted file mode 100644index 1da9be9ca30..00000000000--- a/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/getRelativeDatePickerCalendarRange.ts+++ /dev/null@@ -1,27 +0,0 @@-import { type Temporal } from 'temporal-polyfill';-import {- isDefined,- turnPlainDateToShiftedDateInSystemTimeZone,-} from 'twenty-shared/utils';--type RelativeDatePickerCalendarRange = {- startDate: Date | undefined;- endDate: Date | undefined;- rangeKey: string | undefined;-};--export const getRelativeDatePickerCalendarRange = (- startPlainDate: Temporal.PlainDate | null,- endInclusivePlainDate: Temporal.PlainDate | null,-): RelativeDatePickerCalendarRange => ({- startDate: isDefined(startPlainDate)- ? turnPlainDateToShiftedDateInSystemTimeZone(startPlainDate)- : undefined,- endDate: isDefined(endInclusivePlainDate)- ? turnPlainDateToShiftedDateInSystemTimeZone(endInclusivePlainDate)- : undefined,- rangeKey:- isDefined(startPlainDate) && isDefined(endInclusivePlainDate)- ? `${startPlainDate.toString()}-${endInclusivePlainDate.toString()}`- : undefined,-});diff --git a/packages/twenty-shared/src/utils/filter/dates/utils/convertFirstDayOfTheWeekToCalendarStartDayNumber.ts b/packages/twenty-shared/src/utils/filter/dates/utils/convertFirstDayOfTheWeekToCalendarStartDayNumber.tsindex 2e19fae6559..b9078a3147b 100644--- a/packages/twenty-shared/src/utils/filter/dates/utils/convertFirstDayOfTheWeekToCalendarStartDayNumber.ts+++ b/packages/twenty-shared/src/utils/filter/dates/utils/convertFirstDayOfTheWeekToCalendarStartDayNumber.ts@@ -3,7 +3,7 @@ import { FirstDayOfTheWeek } from '@/types';export const convertFirstDayOfTheWeekToCalendarStartDayNumber = (firstDayOfTheWeek: FirstDayOfTheWeek,-): CalendarStartDay => {+): Exclude<CalendarStartDay, CalendarStartDay.SYSTEM> => {switch (firstDayOfTheWeek) {case FirstDayOfTheWeek.MONDAY:return CalendarStartDay.MONDAY;diff --git a/yarn.lock b/yarn.lockindex ae3ee4d90f6..a9833ce5cc0 100644--- a/yarn.lock+++ b/yarn.lock@@ -50269,7 +50269,6 @@ __metadata:qs: "npm:^6.15.2"react: "npm:^19.2.0"react-data-grid: "npm:7.0.0-beta.59"- react-datepicker: "npm:^9.1.0"react-dom: "npm:^19.2.0"react-dropzone: "npm:^14.2.3"react-error-boundary: "npm:^4.0.11"