(props: PropsWithDefaults, isLoading: boolean)
| 118 | |
| 119 | export default class Sanitizer { |
| 120 | sanitize(props: PropsWithDefaults, isLoading: boolean): SanitizedProps { |
| 121 | const locale_format = this.applyDefaultToLocale(props.locale_format); |
| 122 | const data = props.data ?? []; |
| 123 | const columns = props.columns |
| 124 | ? this.applyDefaultsToColumns( |
| 125 | locale_format, |
| 126 | props.sort_as_null, |
| 127 | props.columns, |
| 128 | props.editable, |
| 129 | props.filter_options |
| 130 | ) |
| 131 | : this.populateColumnsFrom(data); |
| 132 | const visibleColumns = this.getVisibleColumns( |
| 133 | columns, |
| 134 | props.hidden_columns |
| 135 | ); |
| 136 | |
| 137 | let headerFormat = props.export_headers; |
| 138 | if ( |
| 139 | props.export_format === ExportFormat.Xlsx && |
| 140 | R.isNil(headerFormat) |
| 141 | ) { |
| 142 | headerFormat = ExportHeaders.Names; |
| 143 | } else if ( |
| 144 | props.export_format === ExportFormat.Csv && |
| 145 | R.isNil(headerFormat) |
| 146 | ) { |
| 147 | headerFormat = ExportHeaders.Ids; |
| 148 | } |
| 149 | |
| 150 | const active_cell = props.cell_selectable |
| 151 | ? props.active_cell |
| 152 | : undefined; |
| 153 | |
| 154 | const selected_cells = props.cell_selectable |
| 155 | ? props.selected_cells |
| 156 | : NULL_SELECTED_CELLS; |
| 157 | |
| 158 | return R.mergeRight(props, { |
| 159 | active_cell, |
| 160 | columns, |
| 161 | data, |
| 162 | export_headers: headerFormat, |
| 163 | filter_action: this.getFilterAction(props.filter_action), |
| 164 | fixed_columns: getFixedColumns( |
| 165 | props.fixed_columns, |
| 166 | props.row_deletable, |
| 167 | props.row_selectable |
| 168 | ), |
| 169 | fixed_rows: getFixedRows( |
| 170 | props.fixed_rows, |
| 171 | columns, |
| 172 | props.filter_action |
| 173 | ), |
| 174 | loading_state: isLoading, |
| 175 | locale_format, |
| 176 | selected_cells, |
| 177 | visibleColumns |
no test coverage detected