Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { format, isValid } from "date-fns";
import { dateTimeFormat } from "../CellViews/DateTimeCell";
import clsx from "clsx";
 
export const valueToString = (value) => {
  if (typeof value === "string") return value;
  /* if undefined or null we'll treat it as empty string */
  if (value === undefined || value === null) return "";
  if (value instanceof Date && isValid(value)) return format(value, dateTimeFormat);
 
  try {
    /* JSON.stringify will handle JSON and non-strings, non-null, non-undefined */
    return JSON.stringify(value);
  } catch {
    return "Error: Invalid JSON";
  }
};
 
export const TextDataGroup = ({ value, hasImage }) => {
  const output = valueToString(value);
  const style = {
    height: hasImage ? TextDataGroup.height : "auto",
  };
 
  return (
    <div
      style={style}
      title={output}
      className={clsx("p-tight", {
        "text-wrap leading-normal": !hasImage,
        "text-nowrap": hasImage,
      })}
    >
      {output}
    </div>
  );
};
 
TextDataGroup.height = 32;