Skip to content

Commit

Permalink
refactor(table): rename value parser getter (c4spar#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar authored and annervisser committed Feb 6, 2024
1 parent 01c8dff commit 504ba12
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
17 changes: 7 additions & 10 deletions table/_layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,13 @@ export class TableLayout<
);
}

const cellValueParser =
(cell.getValueParser() ?? row.getCellValueParser() ??
(
isHeaderRow
? column?.getHeaderValueParser()
: column?.getCellValueParser()
) ??
(isHeaderRow
? this.table.getHeaderValueParser()
: this.table.getCellValueParser())) as ValueParser<CellValue>;
const cellValueParser = (cell.getValueParser() ?? row.getValueParser() ??
(
isHeaderRow ? column?.getHeaderValueParser() : column?.getValueParser()
) ??
(isHeaderRow
? this.table.getHeaderValueParser()
: this.table.getValueParser())) as ValueParser<CellValue>;

if (cellValueParser) {
cell.value(cellValueParser);
Expand Down
3 changes: 1 addition & 2 deletions table/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export interface CellOptions<TValue extends CellValue> {
rowSpan?: number;
/** Cell cell alignment direction. */
align?: Direction;
// value?: ValueParser<TValue>;
value?(value: TValue): ValueParserResult;
value?: ValueParser<TValue>;
/**
* Any unterminated ANSI formatting overflowed from previous lines of a
* multi-line cell.
Expand Down
2 changes: 1 addition & 1 deletion table/column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class Column<
}

/** Get value parser. */
getCellValueParser(): ValueParser<TValue> | undefined {
getValueParser(): ValueParser<TValue> | undefined {
return this.opts.value;
}
}
2 changes: 1 addition & 1 deletion table/row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class Row<
}

/** Get value parser. */
public getCellValueParser(): ValueParser<GetCellValue<TCell>> | undefined {
public getValueParser(): ValueParser<GetCellValue<TCell>> | undefined {
return this.options.value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export class Table<
}

/** Get value parser. */
public getCellValueParser():
public getValueParser():
| ValueParser<GetRowInnerValue<TRow>>
| undefined {
return this.options.value;
Expand Down

0 comments on commit 504ba12

Please sign in to comment.