Uniformize folder structure (#693)
* Uniformize folder structure * Fix icons * Fix icons * Fix tests * Fix tests
This commit is contained in:
3
front/src/modules/ui/table/states/CellContext.ts
Normal file
3
front/src/modules/ui/table/states/CellContext.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
export const CellContext = createContext<string | null>(null);
|
||||
3
front/src/modules/ui/table/states/RowContext.ts
Normal file
3
front/src/modules/ui/table/states/RowContext.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
export const RowContext = createContext<string | null>(null);
|
||||
3
front/src/modules/ui/table/states/TableContext.ts
Normal file
3
front/src/modules/ui/table/states/TableContext.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
export const TableContext = createContext<string | null>(null);
|
||||
@ -0,0 +1,26 @@
|
||||
import { selector } from 'recoil';
|
||||
|
||||
import { AllRowsSelectedStatus } from '../types/AllRowSelectedStatus';
|
||||
|
||||
import { numberOfTableRowsSelectorState } from './numberOfTableRowsSelectorState';
|
||||
import { selectedRowIdsSelector } from './selectedRowIdsSelector';
|
||||
|
||||
export const allRowsSelectedStatusSelector = selector<AllRowsSelectedStatus>({
|
||||
key: 'allRowsSelectedStatusSelector',
|
||||
get: ({ get }) => {
|
||||
const numberOfRows = get(numberOfTableRowsSelectorState);
|
||||
|
||||
const selectedRowIds = get(selectedRowIdsSelector);
|
||||
|
||||
const numberOfSelectedRows = selectedRowIds.length;
|
||||
|
||||
const allRowsSelectedStatus =
|
||||
numberOfSelectedRows === 0
|
||||
? 'none'
|
||||
: numberOfRows === numberOfSelectedRows
|
||||
? 'all'
|
||||
: 'some';
|
||||
|
||||
return allRowsSelectedStatus;
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { PositionType } from '@/ui/action-bar/types/PositionType';
|
||||
|
||||
export const contextMenuPositionState = atom<PositionType>({
|
||||
key: 'contextMenuPositionState',
|
||||
default: {
|
||||
x: null,
|
||||
y: null,
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { CellPosition } from '../types/CellPosition';
|
||||
|
||||
export const currentCellInEditModePositionState = atom<CellPosition>({
|
||||
key: 'currentCellInEditModePositionState',
|
||||
default: {
|
||||
row: 0,
|
||||
column: 1,
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
export const currentColumnNumberScopedState = atomFamily<number, string>({
|
||||
key: 'currentColumnNumberScopedState',
|
||||
default: 0,
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
export const currentRowEntityIdScopedState = atomFamily<string | null, string>({
|
||||
key: 'currentRowEntityIdScopedState',
|
||||
default: null,
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
export const currentRowNumberScopedState = atomFamily<number, string>({
|
||||
key: 'currentRowNumberScopedState',
|
||||
default: 0,
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { TableDimensions } from '../hooks/useInitializeEntityTable';
|
||||
|
||||
export const entityTableDimensionsState = atom<TableDimensions>({
|
||||
key: 'entityTableDimensionsState',
|
||||
default: {
|
||||
numberOfRows: 0,
|
||||
numberOfColumns: 0,
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { CellPosition } from '../types/CellPosition';
|
||||
|
||||
export const isCellInEditModeFamilyState = atomFamily<boolean, CellPosition>({
|
||||
key: 'isCellInEditModeFamilyState',
|
||||
default: false,
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
export const isFetchingEntityTableDataState = atom<boolean>({
|
||||
key: 'isFetchingEntityTableDataState',
|
||||
default: true,
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
export const isRowSelectedFamilyState = atomFamily<boolean, string>({
|
||||
key: 'isRowSelectedFamilyState',
|
||||
default: false,
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
export const isSoftFocusActiveState = atom<boolean>({
|
||||
key: 'isSoftFocusActiveState',
|
||||
default: false,
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { CellPosition } from '../types/CellPosition';
|
||||
|
||||
export const isSoftFocusOnCellFamilyState = atomFamily<boolean, CellPosition>({
|
||||
key: 'isSoftFocusOnCellFamilyState',
|
||||
default: false,
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
export const isSomeInputInEditModeState = atom<boolean>({
|
||||
key: 'isSomeInputInEditModeState',
|
||||
default: false,
|
||||
});
|
||||
@ -0,0 +1,12 @@
|
||||
import { selector } from 'recoil';
|
||||
|
||||
import { entityTableDimensionsState } from './entityTableDimensionsState';
|
||||
|
||||
export const numberOfTableColumnsSelectorState = selector<number>({
|
||||
key: 'numberOfTableColumnsState',
|
||||
get: ({ get }) => {
|
||||
const { numberOfColumns } = get(entityTableDimensionsState);
|
||||
|
||||
return numberOfColumns;
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,12 @@
|
||||
import { selector } from 'recoil';
|
||||
|
||||
import { entityTableDimensionsState } from './entityTableDimensionsState';
|
||||
|
||||
export const numberOfTableRowsSelectorState = selector<number>({
|
||||
key: 'numberOfTableRowsState',
|
||||
get: ({ get }) => {
|
||||
const { numberOfRows } = get(entityTableDimensionsState);
|
||||
|
||||
return numberOfRows;
|
||||
},
|
||||
});
|
||||
15
front/src/modules/ui/table/states/selectedRowIdsSelector.ts
Normal file
15
front/src/modules/ui/table/states/selectedRowIdsSelector.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { selector } from 'recoil';
|
||||
|
||||
import { isRowSelectedFamilyState } from './isRowSelectedFamilyState';
|
||||
import { tableRowIdsState } from './tableRowIdsState';
|
||||
|
||||
export const selectedRowIdsSelector = selector<string[]>({
|
||||
key: 'selectedRowIdsSelector',
|
||||
get: ({ get }) => {
|
||||
const rowIds = get(tableRowIdsState);
|
||||
|
||||
return rowIds.filter(
|
||||
(rowId) => get(isRowSelectedFamilyState(rowId)) === true,
|
||||
);
|
||||
},
|
||||
});
|
||||
11
front/src/modules/ui/table/states/softFocusPositionState.ts
Normal file
11
front/src/modules/ui/table/states/softFocusPositionState.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { CellPosition } from '../types/CellPosition';
|
||||
|
||||
export const softFocusPositionState = atom<CellPosition>({
|
||||
key: 'softFocusPositionState',
|
||||
default: {
|
||||
row: 0,
|
||||
column: 1,
|
||||
},
|
||||
});
|
||||
6
front/src/modules/ui/table/states/tableRowIdsState.ts
Normal file
6
front/src/modules/ui/table/states/tableRowIdsState.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
export const tableRowIdsState = atom<string[]>({
|
||||
key: 'tableRowIdsState',
|
||||
default: [],
|
||||
});
|
||||
Reference in New Issue
Block a user