UNPKG

carbon-components-angular

Version:
1,357 lines (1,142 loc) 58.7 kB
<!doctype html> <html class="no-js" lang=""> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>carbon-components-angular documentation</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="../images/favicon.ico"> <link rel="stylesheet" href="../styles/style.css"> <link rel="stylesheet" href="../styles/dark.css"> </head> <body> <div class="navbar navbar-default navbar-fixed-top d-block d-sm-none"> <a href="../" class="navbar-brand">carbon-components-angular documentation</a> <button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button> </div> <div class="xs-menu menu" id="mobile-menu"> <div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu> </div> <div class="container-fluid main"> <div class="row main"> <div class="hidden-xs menu"> <compodoc-menu mode="normal"></compodoc-menu> </div> <!-- START CONTENT --> <div class="content class"> <div class="content-data"> <ol class="breadcrumb"> <li class="breadcrumb-item">Classes</li> <li class="breadcrumb-item" >TableDomAdapter</li> </ol> <ul class="nav nav-tabs" role="tablist"> <li class="nav-item"> <a href="#info" class="nav-link" class="nav-link active" role="tab" id="info-tab" data-bs-toggle="tab" data-link="info">Info</a> </li> <li class="nav-item"> <a href="#source" class="nav-link" role="tab" id="source-tab" data-bs-toggle="tab" data-link="source">Source</a> </li> </ul> <div class="tab-content"> <div class="tab-pane fade active in" id="info"> <p class="comment"> <h3>File</h3> </p> <p class="comment"> <code>src/table/table-adapter.class.ts</code> </p> <p class="comment"> <h3>Description</h3> </p> <p class="comment"> <p>A concrete implementation of <code>TableAdapter</code></p> <p>Provides standard and consistent access to table cells and rows</p> </p> <p class="comment"> <h3>Implements</h3> </p> <p class="comment"> <code><a href="../classes/TableAdapter.html" target="_self" >TableAdapter</a></code> </p> <section data-compodoc="block-index"> <h3 id="index">Index</h3> <table class="table table-sm table-bordered index-table"> <tbody> <tr> <td class="col-md-4"> <h6><b>Properties</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <span class="modifier">Public</span> <a href="#tableElement" >tableElement</a> </li> </ul> </td> </tr> <tr> <td class="col-md-4"> <h6><b>Methods</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <span class="modifier">Protected</span> <a href="#findCell" >findCell</a> </li> <li> <span class="modifier">Protected</span> <a href="#findCellInColumn" >findCellInColumn</a> </li> <li> <span class="modifier">Protected</span> <a href="#findCellInRow" >findCellInRow</a> </li> <li> <a href="#findColumnIndex" >findColumnIndex</a> </li> <li> <a href="#findIndex" >findIndex</a> </li> <li> <a href="#findRowIndex" >findRowIndex</a> </li> <li> <a href="#getCell" >getCell</a> </li> <li> <a href="#getColumn" >getColumn</a> </li> <li> <span class="modifier">Protected</span> <a href="#getRealRowLength" >getRealRowLength</a> </li> <li> <a href="#getRow" >getRow</a> </li> </ul> </td> </tr> <tr> <td class="col-md-4"> <h6><b>Accessors</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <a href="#lastColumnIndex" >lastColumnIndex</a> </li> <li> <a href="#lastRowIndex" >lastRowIndex</a> </li> </ul> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-constructor"> <h3 id="constructor">Constructor</h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <code>constructor(tableElement: HTMLTableElement)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="116" class="link-to-prism">src/table/table-adapter.class.ts:116</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p><code>TableDomAdapter</code> works on a normal HTML table structure. Custom tables that don&#39;t follow the standard structure should use a custom implementation of <code>TableAdapter</code>.</p> <p>The standard structure allows us to directly query rows for cells and indexes - though we do have to handle colspans specially.</p> </div> <div> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>tableElement</td> <td> <code>HTMLTableElement</code> </td> <td> No </td> <td> <p>the root HTML table element.</p> </td> </tr> </tbody> </table> </div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-properties"> <h3 id="inputs"> Properties </h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="tableElement"></a> <span class="name"> <span class="modifier">Public</span> <span ><b>tableElement</b></span> <a href="#tableElement"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code>HTMLTableElement</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="126" class="link-to-prism">src/table/table-adapter.class.ts:126</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description">the root HTML table element.</div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-methods"> <h3 id="methods"> Methods </h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="findCell"></a> <span class="name"> <span class="modifier">Protected</span> <span ><b>findCell</b></span> <a href="#findCell"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <span class="modifier-icon icon ion-ios-reset"></span> <code>findCell(cells: HTMLTableCellElement[], targetIndex: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>, spanDirection: <a href="../undefineds/TableDomSpanDirection.html" target="_self">TableDomSpanDirection</a>)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="295" class="link-to-prism">src/table/table-adapter.class.ts:295</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Finds a cell and it&#39;s real index given an array of cells, a target index, and the spanning direction</p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>cells</td> <td> <code>HTMLTableCellElement[]</code> </td> <td> No </td> <td> <p>An array of cells to search</p> </td> </tr> <tr> <td>targetIndex</td> <td> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </td> <td> No </td> <td> <p>The index we think the cell is located at</p> </td> </tr> <tr> <td>spanDirection</td> <td> <code><a href="../miscellaneous/enumerations.html#TableDomSpanDirection" target="_self" >TableDomSpanDirection</a></code> </td> <td> No </td> <td> <p>The direction of the cell spans. Should be <code>&quot;colSpan&quot;</code> for a row and <code>&quot;rowSpan&quot;</code> for a column</p> </td> </tr> </tbody> </table> </div> <div> </div> <div class="io-description"> <b>Returns : </b> <code>{ cell: any; realIndex: number; }</code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="findCellInColumn"></a> <span class="name"> <span class="modifier">Protected</span> <span ><b>findCellInColumn</b></span> <a href="#findCellInColumn"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <span class="modifier-icon icon ion-ios-reset"></span> <code>findCellInColumn(col: HTMLTableCellElement[], index: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="332" class="link-to-prism">src/table/table-adapter.class.ts:332</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Helper method around <code>findCell</code>, searches based on a column of cells</p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>col</td> <td> <code>HTMLTableCellElement[]</code> </td> <td> No </td> <td> <p>the column of elements to search</p> </td> </tr> <tr> <td>index</td> <td> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </td> <td> No </td> <td> <p>the index of the element</p> </td> </tr> </tbody> </table> </div> <div> </div> <div class="io-description"> <b>Returns : </b> <code>{ cell: any; realIndex: number; }</code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="findCellInRow"></a> <span class="name"> <span class="modifier">Protected</span> <span ><b>findCellInRow</b></span> <a href="#findCellInRow"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <span class="modifier-icon icon ion-ios-reset"></span> <code>findCellInRow(row: HTMLTableCellElement[], index: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="322" class="link-to-prism">src/table/table-adapter.class.ts:322</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Helper method around <code>findCell</code>, searches based on a row of cells</p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>row</td> <td> <code>HTMLTableCellElement[]</code> </td> <td> No </td> <td> <p>the row of elements to search</p> </td> </tr> <tr> <td>index</td> <td> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </td> <td> No </td> <td> <p>the index of the element</p> </td> </tr> </tbody> </table> </div> <div> </div> <div class="io-description"> <b>Returns : </b> <code>{ cell: any; realIndex: number; }</code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="findColumnIndex"></a> <span class="name"> <span ><b>findColumnIndex</b></span> <a href="#findColumnIndex"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>findColumnIndex(cell: HTMLTableCellElement)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="192" class="link-to-prism">src/table/table-adapter.class.ts:192</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Finds the column index of a given cell</p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>cell</td> <td> <code>HTMLTableCellElement</code> </td> <td> No </td> <td> <p>the cell to search for</p> </td> </tr> </tbody> </table> </div> <div> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="findIndex"></a> <span class="name"> <span ><b>findIndex</b></span> <a href="#findIndex"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>findIndex(cell: HTMLTableCellElement)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="271" class="link-to-prism">src/table/table-adapter.class.ts:271</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Finds the row and column index of a given cell</p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>cell</td> <td> <code>HTMLTableCellElement</code> </td> <td> No </td> <td> <p>the cell to search for</p> </td> </tr> </tbody> </table> </div> <div> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="findRowIndex"></a> <span class="name"> <span ><b>findRowIndex</b></span> <a href="#findRowIndex"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>findRowIndex(cell: HTMLTableCellElement)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="257" class="link-to-prism">src/table/table-adapter.class.ts:257</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Finds the row index of a given cell</p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>cell</td> <td> <code>HTMLTableCellElement</code> </td> <td> No </td> <td> <p>the cell to search for</p> </td> </tr> </tbody> </table> </div> <div> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="getCell"></a> <span class="name"> <span ><b>getCell</b></span> <a href="#getCell"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>getCell(row: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>, column: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="134" class="link-to-prism">src/table/table-adapter.class.ts:134</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Returns a cell from the table taking colspans in to account.</p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>row</td> <td> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </td> <td> No </td> <td> <p>index of the row</p> </td> </tr> <tr> <td>column</td> <td> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </td> <td> No </td> <td> <p>index of the column</p> </td> </tr> </tbody> </table> </div> <div> </div> <div class="io-description"> <b>Returns : </b> <code>HTMLTableCellElement</code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="getColumn"></a> <span class="name"> <span ><b>getColumn</b></span> <a href="#getColumn"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>getColumn(column: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="147" class="link-to-prism">src/table/table-adapter.class.ts:147</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Returns a column from the table, using the <code>id</code> and <code>headers</code> attributes</p> <p>See here for more detail these attributes: <a href="https://www.w3.org/TR/WCAG20-TECHS/H43.html">https://www.w3.org/TR/WCAG20-TECHS/H43.html</a></p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>column</td> <td> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </td> <td> No </td> <td> <p>the index of the column</p> </td> </tr> </tbody> </table> </div> <div> </div> <div class="io-description"> <b>Returns : </b> <code>HTMLTableCellElement[]</code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="getRealRowLength"></a> <span class="name"> <span class="modifier">Protected</span> <span ><b>getRealRowLength</b></span> <a href="#getRealRowLength"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <span class="modifier-icon icon ion-ios-reset"></span> <code>getRealRowLength(row: <a href="../classes/TableRow.html" target="_self">HTMLTableRowElement</a>)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="283" class="link-to-prism">src/table/table-adapter.class.ts:283</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Helper function that returns the &quot;real&quot; length of a row. Only accurate with regard to colspans (though that&#39;s sufficient for it&#39;s uses here)</p> <p>TODO: Take rowSpan into account</p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>row</td> <td> <code><a href="../classes/TableRow.html" target="_self" >HTMLTableRowElement</a></code> </td> <td> No </td> <td> <p>the row to get the length of</p> </td> </tr> </tbody> </table> </div> <div> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="getRow"></a> <span class="name"> <span ><b>getRow</b></span> <a href="#getRow"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>getRow(row: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="183" class="link-to-prism">src/table/table-adapter.class.ts:183</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Returns a row from the table</p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td>row</td> <td> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </td> <td> No </td> <td> <p>index of the row</p> </td> </tr> </tbody> </table> </div> <div> </div> <div class="io-description"> <b>Returns : </b> <code><a href="../classes/TableRow.html" target="_self" >HTMLTableRowElement</a></code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-accessors"> <h3 id="accessors"> Accessors </h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="lastColumnIndex"></a> <span class="name"><b>lastColumnIndex</b><a href="#lastColumnIndex"><span class="icon ion-ios-link"></span></a></span> </td> </tr> <tr> <td class="col-md-4"> <span class="accessor"><b>get</b><code>lastColumnIndex()</code></span> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="107" class="link-to-prism">src/table/table-adapter.class.ts:107</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>The last accessible column in the table</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="lastRowIndex"></a> <span class="name"><b>lastRowIndex</b><a href="#lastRowIndex"><span class="icon ion-ios-link"></span></a></span> </td> </tr> <tr> <td class="col-md-4"> <span class="accessor"><b>get</b><code>lastRowIndex()</code></span> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="114" class="link-to-prism">src/table/table-adapter.class.ts:114</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>The last accessible row in the table</p> </div> </td> </tr> </tbody> </table> </section> </div> <div class="tab-pane fade tab-source-code" id="source"> <pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">export abstract class TableCellAdapter { /** * The index of the cell in the table */ cellIndex: number; /** * The number of columns spanned by this cell */ colSpan: number; /** * The number of rows spanned by this cell */ rowSpan: number; } /** * An abstract class that represents a row in a table */ export abstract class TableRowAdapter { /** * The index of the row in the table */ rowIndex: number; /** * An array (or &#x60;HTMLCollection&#x60;) of &#x60;TableCellAdapter&#x60;s */ cells: HTMLCollection | TableCellAdapter[]; } /** * An abstract representation of a table that provides * a standard interface to query 2d tables for cell and row information. */ export abstract class TableAdapter { /** * The last accessible column in the table */ public get lastColumnIndex(): number { return; } /** * The last accessible row in the table */ public get lastRowIndex(): number { return; } /** * Returns a cell from the table * * @param row index of the row * @param column index of the column */ getCell(row: number, column: number): TableCellAdapter { return; } /** * Returns a row from the table * * @param column index of the column */ getColumn(column: number): TableCellAdapter[] { return; } /** * Returns a row from the table * * @param row index of the row */ getRow(row: number): TableRowAdapter { return; } /** * Finds the column index of a given cell * * @param cell the cell to search for */ findColumnIndex(cell: TableCellAdapter): number { return; } /** * Finds the row index of a given cell * * @param cell the cell to search for */ findRowIndex(cell: TableCellAdapter): number { return; } /** * Finds the row and column index of a given cell * * @param cell the cell to search for * @returns a tuple that follows the &#x60;[row, column]&#x60; convention */ findIndex(cell: TableCellAdapter): [number, number] { return; } } enum TableDomSpanDirection { colSpan &#x3D; &quot;colSpan&quot;, rowSpan &#x3D; &quot;rowSpan&quot; } /** * A concrete implementation of &#x60;TableAdapter&#x60; * * Provides standard and consistent access to table cells and rows */ export class TableDomAdapter implements TableAdapter { /** * The last accessible column in the table */ public get lastColumnIndex() { return this.getRealRowLength(this.tableElement.rows[0]); } /** * The last accessible row in the table */ public get lastRowIndex() { return this.tableElement.rows.length - 1; } /** * &#x60;TableDomAdapter&#x60; works on a normal HTML table structure. * Custom tables that don&#x27;t follow the standard structure should use a custom implementation of &#x60;TableAdapter&#x60;. * * The standard structure allows us to directly query rows for cells and indexes - though we do have to handle colspans specially. * * @param tableElement the root HTML table element. */ constructor(public tableElement: HTMLTableElement) { } /** * Returns a cell from the table taking colspans in to account. * * @param row index of the row * @param column index of the column */ getCell(row: number, column: number): HTMLTableCellElement { const col &#x3D; this.getColumn(column); return this.findCellInColumn(col, row).cell; } /** * Returns a column from the table, using the &#x60;id&#x60; and &#x60;headers&#x60; attributes * * See here for more detail these attributes: https://www.w3.org/TR/WCAG20-TECHS/H43.html * * @param column the index of the column */ getColumn(column: number): HTMLTableCellElement[] { const firstHeader &#x3D; Array.from(this.tableElement.rows[0].cells); const { cell: header, realIndex: realColumnIndex } &#x3D; this.findCellInRow(firstHeader, column); const linkedCells: HTMLTableCellElement[] &#x3D; []; for (let i &#x3D; 1; i &lt; this.tableElement.rows.length; i++) { const row &#x3D; this.tableElement.rows[i]; // query for any cells that are linked to the given header id // &#x60;~&#x3D;&#x60; matches values in space separated lists - so &#x60;[headers~&#x3D;&#x27;foo&#x27;]&#x60; would match &#x60;headers&#x3D;&quot;foo bar&quot;&#x60; and &#x60;headers&#x3D;&quot;foo&quot;&#x60; // but not &#x60;heade