FieldDisplay & FieldInput (#1708)
* Removed view field duplicate types * wip * wip 2 * wip 3 * Unified state for fields * Renaming * Wip * Post merge * Post post merge * wip * Delete unused file * Boolean and Probability * Finished InlineCell * Renamed EditableCell to TableCell * Finished double texts * Finished MoneyField * Fixed bug inline cell click outside * Fixed hotkey scope * Final fixes * Phone * Fix url and number input validation * Fix * Fix position * wip refactor activity editor * Fixed activity editor --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { ViewFieldMetadata } from '@/ui/editable-field/types/ViewField';
|
||||
import { FieldMetadata } from '@/ui/field/types/FieldMetadata';
|
||||
|
||||
import { ColumnDefinition } from '../types/ColumnDefinition';
|
||||
|
||||
export const availableTableColumnsScopedState = atomFamily<
|
||||
ColumnDefinition<ViewFieldMetadata>[],
|
||||
ColumnDefinition<FieldMetadata>[],
|
||||
string
|
||||
>({
|
||||
key: 'availableTableColumnsScopedState',
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { CellPosition } from '../types/CellPosition';
|
||||
|
||||
export const currentCellInEditModePositionState = atom<CellPosition>({
|
||||
key: 'currentCellInEditModePositionState',
|
||||
default: {
|
||||
row: 0,
|
||||
column: 1,
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { TableCellPosition } from '../types/TableCellPosition';
|
||||
|
||||
export const currentTableCellInEditModePositionState = atom<TableCellPosition>({
|
||||
key: 'currentTableCellInEditModePositionState',
|
||||
default: {
|
||||
row: 0,
|
||||
column: 1,
|
||||
},
|
||||
});
|
||||
@ -1,8 +0,0 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { CellPosition } from '../types/CellPosition';
|
||||
|
||||
export const isCellInEditModeFamilyState = atomFamily<boolean, CellPosition>({
|
||||
key: 'isCellInEditModeFamilyState',
|
||||
default: false,
|
||||
});
|
||||
@ -1,8 +0,0 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { CellPosition } from '../types/CellPosition';
|
||||
|
||||
export const isSoftFocusOnCellFamilyState = atomFamily<boolean, CellPosition>({
|
||||
key: 'isSoftFocusOnCellFamilyState',
|
||||
default: false,
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { TableCellPosition } from '../types/TableCellPosition';
|
||||
|
||||
export const isSoftFocusOnTableCellFamilyState = atomFamily<
|
||||
boolean,
|
||||
TableCellPosition
|
||||
>({
|
||||
key: 'isSoftFocusOnTableCellFamilyState',
|
||||
default: false,
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { TableCellPosition } from '../types/TableCellPosition';
|
||||
|
||||
export const isTableCellInEditModeFamilyState = atomFamily<
|
||||
boolean,
|
||||
TableCellPosition
|
||||
>({
|
||||
key: 'isTableCellInEditModeFamilyState',
|
||||
default: false,
|
||||
});
|
||||
@ -1,11 +1,11 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { ViewFieldMetadata } from '@/ui/editable-field/types/ViewField';
|
||||
import { FieldMetadata } from '@/ui/field/types/FieldMetadata';
|
||||
|
||||
import { ColumnDefinition } from '../types/ColumnDefinition';
|
||||
|
||||
export const savedTableColumnsFamilyState = atomFamily<
|
||||
ColumnDefinition<ViewFieldMetadata>[],
|
||||
ColumnDefinition<FieldMetadata>[],
|
||||
string | undefined
|
||||
>({
|
||||
key: 'savedTableColumnsFamilyState',
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { selectorFamily } from 'recoil';
|
||||
|
||||
import { ViewFieldMetadata } from '@/ui/editable-field/types/ViewField';
|
||||
import { FieldMetadata } from '@/ui/field/types/FieldMetadata';
|
||||
|
||||
import { ColumnDefinition } from '../../types/ColumnDefinition';
|
||||
import { savedTableColumnsFamilyState } from '../savedTableColumnsFamilyState';
|
||||
@ -11,6 +11,6 @@ export const savedTableColumnsByKeyFamilySelector = selectorFamily({
|
||||
(viewId: string | undefined) =>
|
||||
({ get }) =>
|
||||
get(savedTableColumnsFamilyState(viewId)).reduce<
|
||||
Record<string, ColumnDefinition<ViewFieldMetadata>>
|
||||
Record<string, ColumnDefinition<FieldMetadata>>
|
||||
>((result, column) => ({ ...result, [column.key]: column }), {}),
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { selectorFamily } from 'recoil';
|
||||
|
||||
import { ViewFieldMetadata } from '@/ui/editable-field/types/ViewField';
|
||||
import { FieldMetadata } from '@/ui/field/types/FieldMetadata';
|
||||
|
||||
import { ColumnDefinition } from '../../types/ColumnDefinition';
|
||||
import { tableColumnsScopedState } from '../tableColumnsScopedState';
|
||||
@ -11,6 +11,6 @@ export const tableColumnsByKeyScopedSelector = selectorFamily({
|
||||
(scopeId: string) =>
|
||||
({ get }) =>
|
||||
get(tableColumnsScopedState(scopeId)).reduce<
|
||||
Record<string, ColumnDefinition<ViewFieldMetadata>>
|
||||
Record<string, ColumnDefinition<FieldMetadata>>
|
||||
>((result, column) => ({ ...result, [column.key]: column }), {}),
|
||||
});
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
import { selectorFamily } from 'recoil';
|
||||
|
||||
import { tableEntitiesFamilyState } from '../tableEntitiesFamilyState';
|
||||
|
||||
export const tableEntityFieldFamilySelector = selectorFamily({
|
||||
key: 'tableEntityFieldFamilySelector',
|
||||
get:
|
||||
<T>({ fieldName, entityId }: { fieldName: string; entityId: string }) =>
|
||||
({ get }) =>
|
||||
get(tableEntitiesFamilyState(entityId))?.[fieldName] as T,
|
||||
set:
|
||||
<T>({ fieldName, entityId }: { fieldName: string; entityId: string }) =>
|
||||
({ set }, newValue: T) =>
|
||||
set(tableEntitiesFamilyState(entityId), (prevState) => ({
|
||||
...prevState,
|
||||
[fieldName]: newValue,
|
||||
})),
|
||||
});
|
||||
@ -1,8 +1,8 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { CellPosition } from '../types/CellPosition';
|
||||
import { TableCellPosition } from '../types/TableCellPosition';
|
||||
|
||||
export const softFocusPositionState = atom<CellPosition>({
|
||||
export const softFocusPositionState = atom<TableCellPosition>({
|
||||
key: 'softFocusPositionState',
|
||||
default: {
|
||||
row: 0,
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { ViewFieldMetadata } from '@/ui/editable-field/types/ViewField';
|
||||
import { FieldMetadata } from '@/ui/field/types/FieldMetadata';
|
||||
|
||||
import { ColumnDefinition } from '../types/ColumnDefinition';
|
||||
|
||||
export const tableColumnsScopedState = atomFamily<
|
||||
ColumnDefinition<ViewFieldMetadata>[],
|
||||
ColumnDefinition<FieldMetadata>[],
|
||||
string
|
||||
>({
|
||||
key: 'tableColumnsScopedState',
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
export const tableEntitiesFamilyState = atomFamily<
|
||||
Record<string, unknown> | null,
|
||||
string
|
||||
>({
|
||||
key: 'tableEntitiesFamilyState',
|
||||
default: null,
|
||||
});
|
||||
Reference in New Issue
Block a user