Migrate to twenty-ui - input components (#7914)

### Description

Migrate Input components: 

- CardPicker
- Radio
- RadioGroup
- Checkbox
- Toggle
- IconListViewGrip

### Demo

Radio Component on Storybook


![](https://assets-service.gitstart.com/4814/2d0c7436-9fab-4f3d-a5c4-be874e885789.png)

Checkbox component on Storybook


![](https://assets-service.gitstart.com/4814/07bcc040-cc92-4c7e-9be8-ca1a5f454993.png)

###### Fixes twentyhq/private-issues#92

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
gitstart-app[bot] 2024-10-28 15:36:58 +01:00 committed by GitHub
parent ff388f56ea
commit fc8c9d9167
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 53 additions and 43 deletions

View File

@ -1,11 +1,15 @@
import { useTheme } from '@emotion/react'; import { useTheme } from '@emotion/react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { IconCalendar, OverflowingTextWithTooltip } from 'twenty-ui'; import {
Checkbox,
CheckboxShape,
IconCalendar,
OverflowingTextWithTooltip,
} from 'twenty-ui';
import { useOpenActivityRightDrawer } from '@/activities/hooks/useOpenActivityRightDrawer'; import { useOpenActivityRightDrawer } from '@/activities/hooks/useOpenActivityRightDrawer';
import { ActivityTargetsInlineCell } from '@/activities/inline-cell/components/ActivityTargetsInlineCell'; import { ActivityTargetsInlineCell } from '@/activities/inline-cell/components/ActivityTargetsInlineCell';
import { getActivitySummary } from '@/activities/utils/getActivitySummary'; import { getActivitySummary } from '@/activities/utils/getActivitySummary';
import { Checkbox, CheckboxShape } from '@/ui/input/components/Checkbox';
import { beautifyExactDate, hasDatePassed } from '~/utils/date-utils'; import { beautifyExactDate, hasDatePassed } from '~/utils/date-utils';
import { ActivityRow } from '@/activities/components/ActivityRow'; import { ActivityRow } from '@/activities/components/ActivityRow';

View File

@ -17,7 +17,6 @@ import { InlineCellHotkeyScope } from '@/object-record/record-inline-cell/types/
import { RecordValueSetterEffect } from '@/object-record/record-store/components/RecordValueSetterEffect'; import { RecordValueSetterEffect } from '@/object-record/record-store/components/RecordValueSetterEffect';
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
import { ObjectRecord } from '@/object-record/types/ObjectRecord'; import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { Checkbox, CheckboxVariant } from '@/ui/input/components/Checkbox';
import { TextInput } from '@/ui/input/components/TextInput'; import { TextInput } from '@/ui/input/components/TextInput';
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
import { RecordBoardScrollWrapperContext } from '@/ui/utilities/scroll/contexts/ScrollWrapperContexts'; import { RecordBoardScrollWrapperContext } from '@/ui/utilities/scroll/contexts/ScrollWrapperContexts';
@ -29,6 +28,8 @@ import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { import {
AnimatedEaseInOut, AnimatedEaseInOut,
AvatarChipVariant, AvatarChipVariant,
Checkbox,
CheckboxVariant,
ChipSize, ChipSize,
IconEye, IconEye,
IconEyeOff, IconEyeOff,

View File

@ -4,7 +4,7 @@ import { useCallback, useContext } from 'react';
import { RecordTableRowContext } from '@/object-record/record-table/contexts/RecordTableRowContext'; import { RecordTableRowContext } from '@/object-record/record-table/contexts/RecordTableRowContext';
import { RecordTableTd } from '@/object-record/record-table/record-table-cell/components/RecordTableTd'; import { RecordTableTd } from '@/object-record/record-table/record-table-cell/components/RecordTableTd';
import { useSetCurrentRowSelected } from '@/object-record/record-table/record-table-row/hooks/useSetCurrentRowSelected'; import { useSetCurrentRowSelected } from '@/object-record/record-table/record-table-row/hooks/useSetCurrentRowSelected';
import { Checkbox } from '@/ui/input/components/Checkbox'; import { Checkbox } from 'twenty-ui';
const StyledContainer = styled.div` const StyledContainer = styled.div`
align-items: center; align-items: center;

View File

@ -3,7 +3,7 @@ import { useContext } from 'react';
import { RecordTableRowContext } from '@/object-record/record-table/contexts/RecordTableRowContext'; import { RecordTableRowContext } from '@/object-record/record-table/contexts/RecordTableRowContext';
import { RecordTableTd } from '@/object-record/record-table/record-table-cell/components/RecordTableTd'; import { RecordTableTd } from '@/object-record/record-table/record-table-cell/components/RecordTableTd';
import { IconListViewGrip } from '@/ui/input/components/IconListViewGrip'; import { IconListViewGrip } from 'twenty-ui';
const StyledContainer = styled.div` const StyledContainer = styled.div`
cursor: grab; cursor: grab;

View File

@ -3,7 +3,7 @@ import { useRecoilValue } from 'recoil';
import { useRecordTableStates } from '@/object-record/record-table/hooks/internal/useRecordTableStates'; import { useRecordTableStates } from '@/object-record/record-table/hooks/internal/useRecordTableStates';
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable'; import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';
import { Checkbox } from '@/ui/input/components/Checkbox'; import { Checkbox } from 'twenty-ui';
const StyledContainer = styled.div` const StyledContainer = styled.div`
align-items: center; align-items: center;

View File

@ -1,8 +1,7 @@
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { ReactNode } from 'react'; import { ReactNode } from 'react';
import { Radio } from '@/ui/input/components/Radio'; import { Card, CardContent, Radio } from 'twenty-ui';
import { Card, CardContent } from 'twenty-ui';
type SettingsAccountsRadioSettingsCardProps<Option extends { value: string }> = type SettingsAccountsRadioSettingsCardProps<Option extends { value: string }> =
{ {

View File

@ -1,7 +1,6 @@
import styled from '@emotion/styled';
import { Radio } from '@/ui/input/components/Radio';
import { IconComponent, CardContent } from 'twenty-ui';
import { useTheme } from '@emotion/react'; import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { CardContent, IconComponent, Radio } from 'twenty-ui';
const StyledRadioCardContent = styled(CardContent)` const StyledRadioCardContent = styled(CardContent)`
display: flex; display: flex;

View File

@ -1,9 +1,8 @@
import { useTheme } from '@emotion/react'; import { useTheme } from '@emotion/react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { useIcons } from 'twenty-ui'; import { Checkbox, useIcons } from 'twenty-ui';
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem'; import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { Checkbox } from '@/ui/input/components/Checkbox';
import { TableCell } from '@/ui/layout/table/components/TableCell'; import { TableCell } from '@/ui/layout/table/components/TableCell';
import { TableRow } from '@/ui/layout/table/components/TableRow'; import { TableRow } from '@/ui/layout/table/components/TableRow';

View File

@ -2,7 +2,7 @@
import { Column, FormatterProps, useRowSelection } from 'react-data-grid'; import { Column, FormatterProps, useRowSelection } from 'react-data-grid';
import { ImportedRow } from '@/spreadsheet-import/types'; import { ImportedRow } from '@/spreadsheet-import/types';
import { Radio } from '@/ui/input/components/Radio'; import { Radio } from 'twenty-ui';
const SELECT_COLUMN_KEY = 'select-row'; const SELECT_COLUMN_KEY = 'select-row';

View File

@ -8,8 +8,7 @@ import { SpreadsheetImportStep } from '@/spreadsheet-import/steps/types/Spreadsh
import { SpreadsheetImportStepType } from '@/spreadsheet-import/steps/types/SpreadsheetImportStepType'; import { SpreadsheetImportStepType } from '@/spreadsheet-import/steps/types/SpreadsheetImportStepType';
import { exceedsMaxRecords } from '@/spreadsheet-import/utils/exceedsMaxRecords'; import { exceedsMaxRecords } from '@/spreadsheet-import/utils/exceedsMaxRecords';
import { mapWorkbook } from '@/spreadsheet-import/utils/mapWorkbook'; import { mapWorkbook } from '@/spreadsheet-import/utils/mapWorkbook';
import { Radio } from '@/ui/input/components/Radio'; import { Radio, RadioGroup } from 'twenty-ui';
import { RadioGroup } from '@/ui/input/components/RadioGroup';
import { Modal } from '@/ui/layout/modal/components/Modal'; import { Modal } from '@/ui/layout/modal/components/Modal';
import { WorkBook } from 'xlsx-ugnis'; import { WorkBook } from 'xlsx-ugnis';

View File

@ -2,11 +2,10 @@ import styled from '@emotion/styled';
// @ts-expect-error // Todo: remove usage of react-data-grid // @ts-expect-error // Todo: remove usage of react-data-grid
import { Column, useRowSelection } from 'react-data-grid'; import { Column, useRowSelection } from 'react-data-grid';
import { createPortal } from 'react-dom'; import { createPortal } from 'react-dom';
import { AppTooltip, Toggle } from 'twenty-ui'; import { AppTooltip, Checkbox, CheckboxVariant, Toggle } from 'twenty-ui';
import { MatchColumnSelect } from '@/spreadsheet-import/components/MatchColumnSelect'; import { MatchColumnSelect } from '@/spreadsheet-import/components/MatchColumnSelect';
import { Fields, ImportedStructuredRow } from '@/spreadsheet-import/types'; import { Fields, ImportedStructuredRow } from '@/spreadsheet-import/types';
import { Checkbox, CheckboxVariant } from '@/ui/input/components/Checkbox';
import { TextInput } from '@/ui/input/components/TextInput'; import { TextInput } from '@/ui/input/components/TextInput';
import { isDefined } from '~/utils/isDefined'; import { isDefined } from '~/utils/isDefined';

View File

@ -1,7 +1,6 @@
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { IconComponent, Tag, ThemeColor } from 'twenty-ui'; import { Checkbox, IconComponent, Tag, ThemeColor } from 'twenty-ui';
import { Checkbox } from '@/ui/input/components/Checkbox';
import { MenuItemLeftContent } from '@/ui/navigation/menu-item/internals/components/MenuItemLeftContent'; import { MenuItemLeftContent } from '@/ui/navigation/menu-item/internals/components/MenuItemLeftContent';
import { StyledMenuItemBase } from '../internals/components/StyledMenuItemBase'; import { StyledMenuItemBase } from '../internals/components/StyledMenuItemBase';

View File

@ -1,8 +1,6 @@
import { ReactNode } from 'react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { OverflowingTextWithTooltip } from 'twenty-ui'; import { ReactNode } from 'react';
import { Checkbox, OverflowingTextWithTooltip } from 'twenty-ui';
import { Checkbox } from '@/ui/input/components/Checkbox';
import { import {
StyledMenuItemBase, StyledMenuItemBase,

View File

@ -1,10 +1,10 @@
import { Tag, ThemeColor } from 'twenty-ui';
import { import {
Checkbox, Checkbox,
CheckboxShape, CheckboxShape,
CheckboxSize, CheckboxSize,
} from '@/ui/input/components/Checkbox'; Tag,
ThemeColor,
} from 'twenty-ui';
import { import {
StyledMenuItemBase, StyledMenuItemBase,

View File

@ -7,12 +7,17 @@ import { billingState } from '@/client-config/states/billingState';
import { AppPath } from '@/types/AppPath'; import { AppPath } from '@/types/AppPath';
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar'; import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { CardPicker } from '@/ui/input/components/CardPicker';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { isNonEmptyString, isNumber } from '@sniptt/guards'; import { isNonEmptyString, isNumber } from '@sniptt/guards';
import { useState } from 'react'; import { useState } from 'react';
import { useRecoilValue } from 'recoil'; import { useRecoilValue } from 'recoil';
import { ActionLink, CAL_LINK, Loader, MainButton } from 'twenty-ui'; import {
ActionLink,
CAL_LINK,
CardPicker,
Loader,
MainButton,
} from 'twenty-ui';
import { import {
ProductPriceEntity, ProductPriceEntity,
SubscriptionInterval, SubscriptionInterval,

View File

@ -3,12 +3,9 @@ import { ThemeType } from 'twenty-ui';
export { ThemeProvider } from '@emotion/react'; export { ThemeProvider } from '@emotion/react';
export * from 'twenty-ui'; export * from 'twenty-ui';
export * from './src/modules/ui/input/components/AutosizeTextInput'; export * from './src/modules/ui/input/components/AutosizeTextInput';
export * from './src/modules/ui/input/components/Checkbox';
export * from './src/modules/ui/input/components/EntityTitleDoubleTextInput'; export * from './src/modules/ui/input/components/EntityTitleDoubleTextInput';
export * from './src/modules/ui/input/components/IconPicker'; export * from './src/modules/ui/input/components/IconPicker';
export * from './src/modules/ui/input/components/ImageInput'; export * from './src/modules/ui/input/components/ImageInput';
export * from './src/modules/ui/input/components/Radio';
export * from './src/modules/ui/input/components/RadioGroup';
export * from './src/modules/ui/input/components/Select'; export * from './src/modules/ui/input/components/Select';
export * from './src/modules/ui/input/components/TextArea'; export * from './src/modules/ui/input/components/TextArea';
export * from './src/modules/ui/input/components/TextInput'; export * from './src/modules/ui/input/components/TextInput';

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { Radio } from '@/ui/input/components/Radio'; import { Radio } from './Radio';
const StyledSubscriptionCardContainer = styled.button` const StyledSubscriptionCardContainer = styled.button`
background-color: ${({ theme }) => theme.background.secondary}; background-color: ${({ theme }) => theme.background.secondary};

View File

@ -1,6 +1,6 @@
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import * as React from 'react'; import * as React from 'react';
import { IconCheck, IconMinus } from 'twenty-ui'; import { IconCheck, IconMinus } from '@ui/display/icon/components/TablerIcons';
export enum CheckboxVariant { export enum CheckboxVariant {
Primary = 'primary', Primary = 'primary',

View File

@ -1,4 +1,4 @@
import IconListViewGripRaw from '@/ui/input/components/list-view-grip.svg?react'; import IconListViewGripRaw from '@ui/input/components/list-view-grip.svg?react';
import { IconComponentProps } from '@ui/display/icon/types/IconComponent'; import { IconComponentProps } from '@ui/display/icon/types/IconComponent';
type IconListViewGripProps = Pick<IconComponentProps, 'size' | 'stroke'>; type IconListViewGripProps = Pick<IconComponentProps, 'size' | 'stroke'>;

View File

@ -1,8 +1,7 @@
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
import * as React from 'react'; import * as React from 'react';
import { RGBA } from 'twenty-ui'; import { RGBA } from '@ui/theme';
import { RadioGroup } from './RadioGroup'; import { RadioGroup } from './RadioGroup';
export enum RadioSize { export enum RadioSize {

View File

@ -1,5 +1,9 @@
import { Meta, StoryObj } from '@storybook/react'; import { Meta, StoryObj } from '@storybook/react';
import { CatalogDecorator, CatalogStory, ComponentDecorator } from 'twenty-ui'; import {
CatalogDecorator,
CatalogStory,
ComponentDecorator,
} from '@ui/testing';
import { import {
Checkbox, Checkbox,

View File

@ -1,5 +1,9 @@
import { Meta, StoryObj } from '@storybook/react'; import { Meta, StoryObj } from '@storybook/react';
import { CatalogDecorator, CatalogStory, ComponentDecorator } from 'twenty-ui'; import {
CatalogDecorator,
CatalogStory,
ComponentDecorator,
} from '@ui/testing';
import { LabelPosition, Radio, RadioSize } from '../Radio'; import { LabelPosition, Radio, RadioSize } from '../Radio';

View File

Before

Width:  |  Height:  |  Size: 478 B

After

Width:  |  Height:  |  Size: 478 B

View File

@ -17,5 +17,10 @@ export * from './code-editor/components/CodeEditorHeader';
export * from './code-editor/theme/utils/codeEditorTheme'; export * from './code-editor/theme/utils/codeEditorTheme';
export * from './color-scheme/components/ColorSchemeCard'; export * from './color-scheme/components/ColorSchemeCard';
export * from './color-scheme/components/ColorSchemePicker'; export * from './color-scheme/components/ColorSchemePicker';
export * from './components/CardPicker';
export * from './components/Checkbox';
export * from './components/IconListViewGrip';
export * from './components/Radio';
export * from './components/RadioGroup';
export * from './components/Toggle'; export * from './components/Toggle';
export * from './types/ColorScheme'; export * from './types/ColorScheme';

View File

@ -9,7 +9,7 @@ Used when a user needs to select multiple values from several options.
<ArticleTabs label1="Usage" label2="Props"> <ArticleTabs label1="Usage" label2="Props">
<ArticleTab> <ArticleTab>
<SandpackEditor content={`import { Checkbox } from "@/ui/input/components/Checkbox"; <SandpackEditor content={`import { Checkbox } from "twenty-ui";
export const MyComponent = () => { export const MyComponent = () => {
return ( return (

View File

@ -9,7 +9,7 @@ Used when users may only choose one option from a series of options.
<ArticleTabs label1="Usage" label2="Props"> <ArticleTabs label1="Usage" label2="Props">
<ArticleTab> <ArticleTab>
<SandpackEditor content={`import { Radio } from "@/ui/input/components/Radio"; <SandpackEditor content={`import { Radio } from "twenty-ui";
export const MyComponent = () => { export const MyComponent = () => {
@ -65,8 +65,7 @@ Groups together related radio buttons.
<ArticleTab> <ArticleTab>
<SandpackEditor content={`import React, { useState } from "react"; <SandpackEditor content={`import React, { useState } from "react";
import { Radio } from "@/ui/input/components/Radio"; import { Radio, RadioGroup } from "twenty-ui";
import { RadioGroup } from "@/ui/input/components/RadioGroup";
export const MyComponent = () => { export const MyComponent = () => {