Skip to content

Commit

Permalink
test: update carbon e2e DataTable to use generics
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Apr 20, 2024
1 parent 7519895 commit 5af7bd6
Show file tree
Hide file tree
Showing 4 changed files with 639 additions and 293 deletions.
173 changes: 135 additions & 38 deletions tests/e2e/carbon/COMPONENT_API.json
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@
"name": "headers",
"kind": "let",
"description": "Specify the data table headers",
"type": "DataTableHeader[]",
"type": "ReadonlyArray<DataTableHeader<Row>>",
"value": "[]",
"isFunction": false,
"isFunctionDeclaration": false,
Expand All @@ -1900,19 +1900,19 @@
"name": "rows",
"kind": "let",
"description": "Specify the rows the data table should render\nkeys defined in `headers` are used for the row ids",
"type": "DataTableRow[]",
"type": "ReadonlyArray<Row>",
"value": "[]",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": true
"reactive": false
},
{
"name": "size",
"kind": "let",
"description": "Set the size of the data table",
"type": "\"compact\" | \"short\" | \"tall\"",
"type": "\"compact\" | \"short\" | \"medium\" | \"tall\"",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
Expand Down Expand Up @@ -1967,6 +1967,30 @@
"constant": false,
"reactive": false
},
{
"name": "sortKey",
"kind": "let",
"description": "Specify the header key to sort by",
"type": "DataTableKey",
"value": "null",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": true
},
{
"name": "sortDirection",
"kind": "let",
"description": "Specify the sort direction",
"type": "\"none\" | \"ascending\" | \"descending\"",
"value": "\"none\"",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": true
},
{
"name": "expandable",
"kind": "let",
Expand Down Expand Up @@ -1995,14 +2019,26 @@
"name": "expandedRowIds",
"kind": "let",
"description": "Specify the row ids to be expanded",
"type": "DataTableRowId[]",
"type": "ReadonlyArray<DataTableRowId>",
"value": "[]",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": true
},
{
"name": "nonExpandableRowIds",
"kind": "let",
"description": "Specify the ids for rows that should not be expandable",
"type": "ReadonlyArray<DataTableRowId>",
"value": "[]",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": false
},
{
"name": "radio",
"kind": "let",
Expand Down Expand Up @@ -2043,14 +2079,26 @@
"name": "selectedRowIds",
"kind": "let",
"description": "Specify the row ids to be selected",
"type": "DataTableRowId[]",
"type": "ReadonlyArray<DataTableRowId>",
"value": "[]",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": true
},
{
"name": "nonSelectableRowIds",
"kind": "let",
"description": "Specify the ids of rows that should not be selectable",
"type": "ReadonlyArray<DataTableRowId>",
"value": "[]",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": false
},
{
"name": "stickyHeader",
"kind": "let",
Expand All @@ -2062,6 +2110,42 @@
"isRequired": false,
"constant": false,
"reactive": false
},
{
"name": "useStaticWidth",
"kind": "let",
"description": "Set to `true` to use static width",
"type": "boolean",
"value": "false",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": false
},
{
"name": "pageSize",
"kind": "let",
"description": "Specify the number of items to display in a page",
"type": "number",
"value": "0",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": false
},
{
"name": "page",
"kind": "let",
"description": "Set to `number` to set current page",
"type": "number",
"value": "0",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": false
}
],
"moduleExports": [],
Expand All @@ -2070,27 +2154,38 @@
{
"name": "cell",
"default": false,
"fallback": "{headers[j].display ? headers[j].display(cell.value) : cell.value}",
"slot_props": "{ row: DataTableRow; cell: DataTableCell; }"
"fallback": "{cell.display ? cell.display(cell.value, row) : cell.value}",
"slot_props": "{ row: Row; cell: DataTableCell<Row>; rowIndex: number; cellIndex: number; }"
},
{
"name": "cell-header",
"default": false,
"fallback": "{header.value}",
"slot_props": "{ header: DataTableNonEmptyHeader; }"
},
{
"name": "description",
"default": false,
"fallback": "{description}",
"slot_props": "{}"
},
{
"name": "expanded-row",
"default": false,
"slot_props": "{ row: DataTableRow; }",
"description": "The expanded row"
"slot_props": "{ row: Row; }"
},
{
"name": "title",
"default": false,
"fallback": "{title}",
"slot_props": "{}"
}
],
"events": [
{
"type": "dispatched",
"name": "click",
"detail": "{ header?: DataTableHeader; row?: DataTableRow; cell?: DataTableCell; }"
"detail": "{ header?: DataTableHeader<Row>; row?: Row; cell?: DataTableCell<Row>; }"
},
{
"type": "dispatched",
Expand All @@ -2100,74 +2195,76 @@
{
"type": "dispatched",
"name": "click:header",
"detail": "{ header: DataTableHeader; sortDirection: \"ascending\" | \"descending\" | \"none\" }"
"detail": "{ header: DataTableHeader<Row>; sortDirection?: \"ascending\" | \"descending\" | \"none\" }"
},
{ "type": "dispatched", "name": "click:row", "detail": "DataTableRow" },
{
"type": "dispatched",
"name": "mouseenter:row",
"detail": "DataTableRow"
"name": "click:header--select",
"detail": "{ indeterminate: boolean; selected: boolean; }"
},
{ "type": "dispatched", "name": "click:row", "detail": "Row" },
{ "type": "dispatched", "name": "mouseenter:row", "detail": "Row" },
{ "type": "dispatched", "name": "mouseleave:row", "detail": "Row" },
{
"type": "dispatched",
"name": "mouseleave:row",
"detail": "DataTableRow"
"name": "click:row--expand",
"detail": "{ expanded: boolean; row: Row; }"
},
{
"type": "dispatched",
"name": "click:row--expand",
"detail": "{ expanded: boolean; row: DataTableRow; }"
"name": "click:row--select",
"detail": "{ selected: boolean; row: Row; }"
},
{
"type": "dispatched",
"name": "click:cell",
"detail": "DataTableCell"
"detail": "DataTableCell<Row>"
}
],
"typedefs": [
{
"type": "string",
"name": "DataTableKey",
"ts": "type DataTableKey = string"
"type": "Omit<keyof Row, \"id\">",
"name": "DataTableKey<Row>",
"ts": "type DataTableKey<Row> = Omit<keyof Row, \"id\">"
},
{
"type": "any",
"name": "DataTableValue",
"ts": "type DataTableValue = any"
},
{
"type": "{ key: DataTableKey; empty: boolean; display?: (item: Value) => DataTableValue; sort?: (a: DataTableValue, b: DataTableValue) => (0 | -1 | 1); columnMenu?: boolean; }",
"name": "DataTableEmptyHeader",
"ts": "interface DataTableEmptyHeader { key: DataTableKey; empty: boolean; display?: (item: Value) => DataTableValue; sort?: (a: DataTableValue, b: DataTableValue) => (0 | -1 | 1); columnMenu?: boolean; }"
"type": "{ key: DataTableKey<Row>; empty: boolean; display?: (item: Value, row: Row) => DataTableValue; sort?: false | ((a: DataTableValue, b: DataTableValue) => number); columnMenu?: boolean; width?: string; minWidth?: string; }",
"name": "DataTableEmptyHeader<Row>",
"ts": "interface DataTableEmptyHeader<Row> { key: DataTableKey<Row>; empty: boolean; display?: (item: Value, row: Row) => DataTableValue; sort?: false | ((a: DataTableValue, b: DataTableValue) => number); columnMenu?: boolean; width?: string; minWidth?: string; }"
},
{
"type": "{ key: DataTableKey; value: DataTableValue; display?: (item: Value) => DataTableValue; sort?: (a: DataTableValue, b: DataTableValue) => (0 | -1 | 1); columnMenu?: boolean; }",
"name": "DataTableNonEmptyHeader",
"ts": "interface DataTableNonEmptyHeader { key: DataTableKey; value: DataTableValue; display?: (item: Value) => DataTableValue; sort?: (a: DataTableValue, b: DataTableValue) => (0 | -1 | 1); columnMenu?: boolean; }"
"type": "{ key: DataTableKey<Row>; value: DataTableValue; display?: (item: Value, row: Row) => DataTableValue; sort?: false | ((a: DataTableValue, b: DataTableValue) => number); columnMenu?: boolean; width?: string; minWidth?: string; }",
"name": "DataTableNonEmptyHeader<Row>",
"ts": "interface DataTableNonEmptyHeader<Row> { key: DataTableKey<Row>; value: DataTableValue; display?: (item: Value, row: Row) => DataTableValue; sort?: false | ((a: DataTableValue, b: DataTableValue) => number); columnMenu?: boolean; width?: string; minWidth?: string; }"
},
{
"type": "DataTableNonEmptyHeader | DataTableEmptyHeader",
"name": "DataTableHeader",
"ts": "type DataTableHeader = DataTableNonEmptyHeader | DataTableEmptyHeader"
"type": "DataTableNonEmptyHeader<Row> | DataTableEmptyHeader<Row>",
"name": "DataTableHeader<Row>",
"ts": "type DataTableHeader<Row> = DataTableNonEmptyHeader<Row> | DataTableEmptyHeader<Row>"
},
{
"type": "{ id: any; [key: string]: DataTableValue; }",
"name": "DataTableRow",
"ts": "interface DataTableRow { id: any; [key: string]: DataTableValue; }"
},
{
"type": "string",
"type": "any",
"name": "DataTableRowId",
"ts": "type DataTableRowId = string"
"ts": "type DataTableRowId = any"
},
{
"type": "{ key: DataTableKey; value: DataTableValue; }",
"type": "{ key: DataTableKey<Row>; value: DataTableValue; display?: (item: Value, row: DataTableRow) => DataTableValue; }",
"name": "DataTableCell",
"ts": "interface DataTableCell { key: DataTableKey; value: DataTableValue; }"
"ts": "interface DataTableCell { key: DataTableKey<Row>; value: DataTableValue; display?: (item: Value, row: DataTableRow) => DataTableValue; }"
}
],
"generics": null,
"rest_props": { "type": "InlineComponent", "name": "TableContainer" }
"generics": ["Row", "Row extends DataTableRow = DataTableRow"],
"rest_props": { "type": "Element", "name": "div" }
},
{
"moduleName": "DataTableSkeleton",
Expand Down
Loading

0 comments on commit 5af7bd6

Please sign in to comment.