Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(table): rename value parser getter #667

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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