GridCell.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { CellIdentifier } from '@/appflowy_app/stores/effects/database/cell/cell_bd_svc';
  2. import { CellCache } from '@/appflowy_app/stores/effects/database/cell/cell_cache';
  3. import { FieldController } from '@/appflowy_app/stores/effects/database/field/field_controller';
  4. import { FieldType } from '@/services/backend';
  5. import GridSingleSelectOptions from './GridSingleSelectOptions';
  6. import GridTextCell from './GridTextCell';
  7. import { GridCheckBox } from './GridCheckBox';
  8. import { GridDate } from './GridDate';
  9. import { GridUrl } from './GridUrl';
  10. import { GridNumberCell } from './GridNumberCell';
  11. export const GridCell = ({
  12. cellIdentifier,
  13. cellCache,
  14. fieldController,
  15. width,
  16. }: {
  17. cellIdentifier: CellIdentifier;
  18. cellCache: CellCache;
  19. fieldController: FieldController;
  20. width?: number;
  21. }) => {
  22. return (
  23. <div style={{ width }}>
  24. {cellIdentifier.fieldType === FieldType.MultiSelect ||
  25. cellIdentifier.fieldType === FieldType.Checklist ||
  26. cellIdentifier.fieldType === FieldType.SingleSelect ? (
  27. <GridSingleSelectOptions
  28. cellIdentifier={cellIdentifier}
  29. cellCache={cellCache}
  30. fieldController={fieldController}
  31. />
  32. ) : cellIdentifier.fieldType === FieldType.Checkbox ? (
  33. <GridCheckBox cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController} />
  34. ) : cellIdentifier.fieldType === FieldType.DateTime ? (
  35. <GridDate cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController}></GridDate>
  36. ) : cellIdentifier.fieldType === FieldType.URL ? (
  37. <GridUrl cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController}></GridUrl>
  38. ) : cellIdentifier.fieldType === FieldType.Number ? (
  39. <GridNumberCell cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController} />
  40. ) : (
  41. <GridTextCell cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController} />
  42. )}
  43. </div>
  44. );
  45. };