New field type: DATE (#4876)

### Description
New field type: DATE

### Refs
https://github.com/twentyhq/twenty/issues/4377

### Demo

https://jam.dev/c/d0b59883-593c-4ca3-966b-c12d5d2e1c32

Fixes #4377

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
gitstart-app[bot]
2024-04-11 17:29:29 +02:00
committed by GitHub
parent ca9cc86742
commit 7211730570
49 changed files with 354 additions and 62 deletions

View File

@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from 'react';
import { useRef, useState } from 'react';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { flip, offset, useFloating } from '@floating-ui/react';
@ -14,8 +14,6 @@ const StyledCalendarContainer = styled.div`
border-radius: ${({ theme }) => theme.border.radius.md};
box-shadow: ${({ theme }) => theme.boxShadow.strong};
margin-top: 1px;
position: absolute;
z-index: 1;
@ -38,6 +36,7 @@ export type DateInputProps = {
hotkeyScope: string;
clearable?: boolean;
onChange?: (newDate: Nullable<Date>) => void;
isDateTimeInput?: boolean;
};
export const DateInput = ({
@ -48,6 +47,7 @@ export const DateInput = ({
onClickOutside,
clearable,
onChange,
isDateTimeInput,
}: DateInputProps) => {
const theme = useTheme();
@ -60,7 +60,7 @@ export const DateInput = ({
middleware: [
flip(),
offset({
mainAxis: theme.spacingMultiplicator * 2,
mainAxis: theme.spacingMultiplicator * -6,
}),
],
});
@ -70,10 +70,6 @@ export const DateInput = ({
onChange?.(newDate);
};
useEffect(() => {
setInternalValue(value);
}, [value]);
useRegisterInputEvents({
inputRef: wrapperRef,
inputValue: internalValue,
@ -99,6 +95,7 @@ export const DateInput = ({
onEnter(newDate);
}}
clearable={clearable ? clearable : false}
isDateTimeInput={isDateTimeInput}
/>
</StyledCalendarContainer>
</div>