property-icons.ts1.7 KBView on GitHub
/**
 * The glyph that leads a property row.
 *
 * Keyed off `fieldRenderType`, never off the raw `type` string — so an agent that invented
 * `type: 'sentiment'` gets the text glyph beside a working text row, exactly as it gets the
 * text CONTROL. One fallback, applied in one place, rather than a second list of type names
 * here that would drift the day a column type is added.
 */

import {
  AlignLeft,
  Building2,
  CalendarDays,
  CircleCheck,
  CircleDot,
  DollarSign,
  FileText,
  Hash,
  Link2,
  Mail,
  MessagesSquare,
  Percent,
  SquareCheck,
  Tags,
  Type,
  User,
  type LucideIcon,
} from 'lucide-react';
import { fieldRenderType, type BoardField } from '@zero/server/board';
import { TABLE_COLUMN_TYPE } from '@zero/server/table';

export function propertyIcon(field: Pick<BoardField, 'type'>): LucideIcon {
  switch (fieldRenderType(field)) {
    case TABLE_COLUMN_TYPE.LONG_TEXT:
      return AlignLeft;
    case TABLE_COLUMN_TYPE.NUMBER:
      return Hash;
    case TABLE_COLUMN_TYPE.CURRENCY:
      return DollarSign;
    case TABLE_COLUMN_TYPE.PERCENT:
      return Percent;
    case TABLE_COLUMN_TYPE.DATE:
      return CalendarDays;
    case TABLE_COLUMN_TYPE.CHECKBOX:
      return SquareCheck;
    case TABLE_COLUMN_TYPE.SELECT:
      return CircleDot;
    case TABLE_COLUMN_TYPE.MULTI_SELECT:
      return Tags;
    case TABLE_COLUMN_TYPE.URL:
      return Link2;
    case TABLE_COLUMN_TYPE.EMAIL:
      return Mail;
    case TABLE_COLUMN_TYPE.CONVERSATION:
      return MessagesSquare;
    case TABLE_COLUMN_TYPE.TASK:
      return CircleCheck;
    case TABLE_COLUMN_TYPE.DOC:
      return FileText;
    case TABLE_COLUMN_TYPE.PERSON:
      return User;
    case TABLE_COLUMN_TYPE.COMPANY:
      return Building2;
    default:
      return Type;
  }
}