UNPKG

@blocktion/json-to-table

Version:

A powerful, modular React component for converting JSON data to navigable tables with advanced features like automatic column detection, theming, and sub-table navigation. Part of the Blocktion SaaS project ecosystem.

33 lines (32 loc) 940 B
export const enhanceColumnsForEditing = (columns, enableEditing = false) => { if (!enableEditing) { return columns.map((col) => ({ ...col, editable: false })); } return columns.map((column) => { // Determine editor type based on column type let editorType = "text"; switch (column.columnType.type) { case "number": editorType = "number"; break; case "boolean": editorType = "boolean"; break; case "date": editorType = "date"; break; case "string": editorType = "text"; break; default: editorType = "text"; } return { ...column, editable: true, deletable: true, editorType, validationRules: [], }; }); };