| 204 | const ROW_START = 65; |
| 205 | // Define the table element |
| 206 | function TableElement({ |
| 207 | columnNames, |
| 208 | rows, |
| 209 | width, |
| 210 | height, |
| 211 | isSelected, |
| 212 | }: ElementWithSelected<TableElement>) { |
| 213 | const cellId = useCellId(); |
| 214 | return ( |
| 215 | <> |
| 216 | <Highlighter.Stroke |
| 217 | padding={25} |
| 218 | rx={5} |
| 219 | ry={5} |
| 220 | strokeWidth={3} |
| 221 | stroke={LIGHT} |
| 222 | isHidden={!isSelected} |
| 223 | > |
| 224 | <foreignObject width={width} height={height} overflow="visible"> |
| 225 | <div |
| 226 | style={{ width, height }} |
| 227 | className="flex flex-col border-1 border-solid border-white/20 text-white rounded-lg p-4 w-full h-full bg-gray-900 shadow-sm" |
| 228 | > |
| 229 | <table className="w-full"> |
| 230 | <thead> |
| 231 | <tr> |
| 232 | {columnNames.map((name) => ( |
| 233 | <th key={name} className="text-left p-2"> |
| 234 | {name} |
| 235 | </th> |
| 236 | ))} |
| 237 | </tr> |
| 238 | </thead> |
| 239 | <tbody> |
| 240 | {rows.map((row, index) => ( |
| 241 | <tr key={index}> |
| 242 | {row.map((cell, cellIndex) => ( |
| 243 | <td |
| 244 | key={cellIndex} |
| 245 | className="p-2 border-t border-white/20 border-dashed" |
| 246 | > |
| 247 | {cell} |
| 248 | </td> |
| 249 | ))} |
| 250 | </tr> |
| 251 | ))} |
| 252 | </tbody> |
| 253 | </table> |
| 254 | </div> |
| 255 | </foreignObject> |
| 256 | </Highlighter.Stroke> |
| 257 | <Port.Group position="right" id="out" dx={-10}> |
| 258 | {rows.map((_, index) => ( |
| 259 | <Port.Item |
| 260 | key={index} |
| 261 | id={`out-${cellId}-${index}`} |
| 262 | y={index * ROW_HEIGHT + ROW_START} |
| 263 | > |