UNPKG

carbon-components-angular

Version:
1,205 lines (1,009 loc) 65.6 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"> <style> footer.carbon { position: absolute; bottom: 0; width: 100%; z-index: 9999; } #root > div { /* * Subtracting the height of the footer to prevent * overlaying the footer ontop of content */ height: calc(100vh - 48px); } </style> </head> <body> <script> // Blocking script to avoid flickering dark mode // Dark mode toggle button var useDark = window.matchMedia('(prefers-color-scheme: dark)'); var darkModeState = useDark.matches; var $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input'); var $darkModeToggles = document.querySelectorAll('.dark-mode-switch'); var darkModeStateLocal = localStorage.getItem('compodoc_darkmode-state'); function checkToggle(check) { for (var i = 0; i < $darkModeToggleSwitchers.length; i++) { $darkModeToggleSwitchers[i].checked = check; } } function toggleDarkMode(state) { if (window.localStorage) { localStorage.setItem('compodoc_darkmode-state', state); } checkToggle(state); const hasClass = document.body.classList.contains('dark'); if (state) { for (var i = 0; i < $darkModeToggles.length; i++) { $darkModeToggles[i].classList.add('dark'); } if (!hasClass) { document.body.classList.add('dark'); } } else { for (var i = 0; i < $darkModeToggles.length; i++) { $darkModeToggles[i].classList.remove('dark'); } if (hasClass) { document.body.classList.remove('dark'); } } } useDark.addEventListener('change', function (evt) { toggleDarkMode(evt.matches); }); if (darkModeStateLocal) { darkModeState = darkModeStateLocal === 'true'; } toggleDarkMode(darkModeState); </script> <div class="navbar navbar-default navbar-fixed-top d-md-none p-0"> <div class="d-flex"> <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> <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="d-none d-md-block 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 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 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 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 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> </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 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 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 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 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 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>