Remove local mdc-datatable (#3840)

With version 3.2.0 of mdc-datatable they removed the ts files from the published package, so we can now use it again.
This commit is contained in:
Bram Kragten 2019-10-01 11:34:25 +02:00 committed by GitHub
parent 313b984a53
commit 3cf4b890b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 1 additions and 2491 deletions

View File

@ -1,32 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.1.1](https://github.com/material-components/material-components-web/compare/v3.1.0...v3.1.1) (2019-08-14)
### Bug Fixes
- **data-table:** Fixed alignment of header cell title for numer… ([#4963](https://github.com/material-components/material-components-web/issues/4963)) ([b6274a7](https://github.com/material-components/material-components-web/commit/b6274a7))
# [4.0.0-alpha.0](https://github.com/material-components/material-components-web/compare/v3.1.0...v4.0.0-alpha.0) (2019-08-07)
**Note:** Version bump only for package @material/data-table
# [3.1.0](https://github.com/material-components/material-components-web/compare/v3.0.0...v3.1.0) (2019-07-22)
### Features
- **data-table:** Added data table component ([#4889](https://github.com/material-components/material-components-web/issues/4889)) ([7d3380a](https://github.com/material-components/material-components-web/commit/7d3380a))
# [3.1.0-alpha.0](https://github.com/material-components/material-components-web/compare/v3.0.0...v3.1.0-alpha.0) (2019-07-16)
### Features
- **data-table:** Added data table component ([#4889](https://github.com/material-components/material-components-web/issues/4889)) ([7d3380a](https://github.com/material-components/material-components-web/commit/7d3380a))
# [3.1.0](https://github.com/material-components/material-components-web/compare/v3.0.0...v3.1.0) (2019-07-16)
### Features
- **data-table:** Added data table component ([#4889](https://github.com/material-components/material-components-web/issues/4889)) ([7d3380a](https://github.com/material-components/material-components-web/commit/7d3380a))

View File

@ -1,21 +0,0 @@
The MIT License
Copyright (c) 2014-2019 Google, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,411 +0,0 @@
<!--docs:
title: "Data Tables"
layout: detail
section: components
excerpt: "Material Design-styled tables."
iconId: data_table
path: /catalog/data-tables/
-->
# Data Table
Data tables display information in a grid-like format of rows and columns. They organize information in a way that's
easy to scan, so that users can look for patterns and insights.
## Design & API Documentation
<ul class="icon-list">
<li class="icon-list-item icon-list-item--spec">
<a href="https://material.io/go/design-data-tables">Material Design guidelines: Data tables</a>
</li>
<li class="icon-list-item icon-list-item--link">
<a href="https://material-components.github.io/material-components-web-catalog/#/component/data-table">Demo</a>
</li>
</ul>
## Installation
```
npm install @material/data-table
```
### Styles
```scss
@import "@material/checkbox/mdc-checkbox"; // Required only for data table with row selection.
@import "@material/data-table/mdc-data-table";
```
> _NOTE_: Styles for any components you intend to include within data-table (e.g. Checkboxes, Buttons etc.) must be
> imported.
### JavaScript Instantiation
```js
import { MDCDataTable } from "@material/data-table";
const dataTable = new MDCDataTable(document.querySelector(".mdc-data-table"));
```
> See [Importing the JS component](../../docs/importing-js.md) for more information on how to import JavaScript.
> Instantiating `MDCDataTable` component is only required to add interactions for example, row selection.
MDC Data Table component auto instantiates `MDCCheckbox` for header row checkbox and all row checkboxes. Make sure to set required class names to instantiate checkbox component. We suggest to use `layout` API when rows are added or removed from data table to register new checkbox components.
## Basic Usage
### HTML Structure
```html
<div class="mdc-data-table">
<table class="mdc-data-table__table" aria-label="Dessert calories">
<thead>
<tr class="mdc-data-table__header-row">
<th class="mdc-data-table__header-cell" role="columnheader" scope="col">
Dessert
</th>
<th
class="mdc-data-table__header-cell mdc-data-table__header-cell--numeric"
role="columnheader"
scope="col"
>
Carbs (g)
</th>
<th
class="mdc-data-table__header-cell mdc-data-table__header-cell--numeric"
role="columnheader"
scope="col"
>
Protein (g)
</th>
<th class="mdc-data-table__header-cell" role="columnheader" scope="col">
Comments
</th>
</tr>
</thead>
<tbody class="mdc-data-table__content">
<tr class="mdc-data-table__row">
<td class="mdc-data-table__cell">Frozen yogurt</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">24</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">4.0</td>
<td class="mdc-data-table__cell">Super tasty</td>
</tr>
<tr class="mdc-data-table__row">
<td class="mdc-data-table__cell">Ice cream sandwich</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">37</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">
4.33333333333
</td>
<td class="mdc-data-table__cell">I like ice cream more</td>
</tr>
<tr class="mdc-data-table__row">
<td class="mdc-data-table__cell">Eclair</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">24</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">6.0</td>
<td class="mdc-data-table__cell">New filing flavor</td>
</tr>
</tbody>
</table>
</div>
```
## Variants
### Data table with row selection
```html
<div class="mdc-data-table">
<table class="mdc-data-table__table" aria-label="Dessert calories">
<thead>
<tr class="mdc-data-table__header-row">
<th
class="mdc-data-table__header-cell mdc-data-table__header-cell--checkbox"
role="columnheader"
scope="col"
>
<div
class="mdc-checkbox mdc-data-table__header-row-checkbox mdc-checkbox--selected"
>
<input
type="checkbox"
class="mdc-checkbox__native-control"
aria-label="Checkbox for header row selection"
/>
<div class="mdc-checkbox__background">
<svg class="mdc-checkbox__checkmark" viewbox="0 0 24 24">
<path
class="mdc-checkbox__checkmark-path"
fill="none"
d="M1.73,12.91 8.1,19.28 22.79,4.59"
/>
</svg>
<div class="mdc-checkbox__mixedmark"></div>
</div>
</div>
</th>
<th class="mdc-data-table__header-cell" role="columnheader" scope="col">
Status
</th>
<th class="mdc-data-table__header-cell" role="columnheader" scope="col">
Signal name
</th>
<th class="mdc-data-table__header-cell" role="columnheader" scope="col">
Severity
</th>
<th class="mdc-data-table__header-cell" role="columnheader" scope="col">
Stage
</th>
<th
class="mdc-data-table__header-cell mdc-data-table__header-cell--numeric"
role="columnheader"
scope="col"
>
Time
</th>
<th class="mdc-data-table__header-cell" role="columnheader" scope="col">
Roles
</th>
</tr>
</thead>
<tbody class="mdc-data-table__content">
<tr data-row-id="u0" class="mdc-data-table__row">
<td class="mdc-data-table__cell mdc-data-table__cell--checkbox">
<div class="mdc-checkbox mdc-data-table__row-checkbox">
<input
type="checkbox"
class="mdc-checkbox__native-control"
aria-labelledby="u0"
/>
<div class="mdc-checkbox__background">
<svg class="mdc-checkbox__checkmark" viewbox="0 0 24 24">
<path
class="mdc-checkbox__checkmark-path"
fill="none"
d="M1.73,12.91 8.1,19.28 22.79,4.59"
/>
</svg>
<div class="mdc-checkbox__mixedmark"></div>
</div>
</div>
</td>
<td class="mdc-data-table__cell">Online</td>
<td class="mdc-data-table__cell" id="u0">Arcus watch slowdown</td>
<td class="mdc-data-table__cell">Medium</td>
<td class="mdc-data-table__cell">Triaged</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">0:33</td>
<td class="mdc-data-table__cell">Allison Brie</td>
</tr>
<tr
data-row-id="u1"
class="mdc-data-table__row mdc-data-table__row--selected"
aria-selected="true"
>
<td class="mdc-data-table__cell mdc-data-table__cell--checkbox">
<div
class="mdc-checkbox mdc-data-table__row-checkbox mdc-checkbox--selected"
>
<input
type="checkbox"
class="mdc-checkbox__native-control"
checked
aria-labelledby="u1"
/>
<div class="mdc-checkbox__background">
<svg class="mdc-checkbox__checkmark" viewbox="0 0 24 24">
<path
class="mdc-checkbox__checkmark-path"
fill="none"
d="M1.73,12.91 8.1,19.28 22.79,4.59"
/>
</svg>
<div class="mdc-checkbox__mixedmark"></div>
</div>
</div>
</td>
<td class="mdc-data-table__cell">Offline</td>
<td class="mdc-data-table__cell" id="u1">
monarch: prod shared ares-managed-features-provider-heavy
</td>
<td class="mdc-data-table__cell">Huge</td>
<td class="mdc-data-table__cell">Triaged</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">0:33</td>
<td class="mdc-data-table__cell">Brie Larson</td>
</tr>
<tr
data-row-id="u2"
class="mdc-data-table__row mdc-data-table__row--selected"
aria-selected="true"
>
<td class="mdc-data-table__cell mdc-data-table__cell--checkbox">
<div
class="mdc-checkbox mdc-data-table__row-checkbox mdc-checkbox--selected"
>
<input
type="checkbox"
class="mdc-checkbox__native-control"
checked
aria-labelledby="u2"
/>
<div class="mdc-checkbox__background">
<svg class="mdc-checkbox__checkmark" viewbox="0 0 24 24">
<path
class="mdc-checkbox__checkmark-path"
fill="none"
d="M1.73,12.91 8.1,19.28 22.79,4.59"
/>
</svg>
<div class="mdc-checkbox__mixedmark"></div>
</div>
</div>
</td>
<td class="mdc-data-table__cell">Online</td>
<td class="mdc-data-table__cell" id="u2">
monarch: prod shared ares-managed-features-provider-heavy
</td>
<td class="mdc-data-table__cell">Minor</td>
<td class="mdc-data-table__cell">Not triaged</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">0:33</td>
<td class="mdc-data-table__cell">Jeremy Lake</td>
</tr>
<tr data-row-id="u3" class="mdc-data-table__row">
<td class="mdc-data-table__cell mdc-data-table__cell--checkbox">
<div class="mdc-checkbox mdc-data-table__row-checkbox">
<input
type="checkbox"
class="mdc-checkbox__native-control"
aria-labelledby="u3"
/>
<div class="mdc-checkbox__background">
<svg class="mdc-checkbox__checkmark" viewbox="0 0 24 24">
<path
class="mdc-checkbox__checkmark-path"
fill="none"
d="M1.73,12.91 8.1,19.28 22.79,4.59"
/>
</svg>
<div class="mdc-checkbox__mixedmark"></div>
</div>
</div>
</td>
<td class="mdc-data-table__cell">Online</td>
<td class="mdc-data-table__cell" id="u3">Arcus watch slowdown</td>
<td class="mdc-data-table__cell">Negligible</td>
<td class="mdc-data-table__cell">Triaged</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">0:33</td>
<td class="mdc-data-table__cell">Angelina Cheng</td>
</tr>
</tbody>
</table>
</div>
```
## Style Customization
### CSS Classes
| CSS Class | Description |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mdc-data-table` | Mandatory. The root DOM element containing `table` and other supporting elements. |
| `mdc-data-table__table` | Mandatory. Table element. Added to `table` HTML tag. |
| `mdc-data-table__header-row` | Mandatory. Table header row element. Added to `thead > tr` HTML tag. |
| `mdc-data-table__header-cell` | Mandatory. Table header cell element. Added to `thead > th > td` HTML tag. |
| `mdc-data-table__header-cell--checkbox` | Optional. Table header cell element that contains `mdc-checkbox`. Added to `thead> th > td:first-child` HTML tag. |
| `mdc-data-table__header-cell--numeric` | Optional. Table header cell element that maps to numeric cells. Added to `thead > th > td` HTML tag. |
| `mdc-data-table__content` | Mandatory. Table body element. Added to `tbody` HTML tag. |
| `mdc-data-table__row` | Mandatory. Table row element. Added to `tbody > tr` HTML tag. |
| `mdc-data-table__cell` | Mandatory. Table cell element. Added to `tbody > tr > td` HTML tag. |
| `mdc-data-table__cell--numeric` | Optional. Table cell element that contains numeric data. Added to `tbody > tr > td` HTML tag. |
| `mdc-data-table__cell--checkbox` | Optional. Table cell element that contains `mdc-checkbox`. Added to `thead> th > td:first-child` HTML tag. |
| `mdc-data-table__header-row-checkbox` | Optional. Checkbox element rendered inside table header row element. Add this class name to `mdc-checkbox` element to override styles required for data-table. |
| `mdc-data-table__row-checkbox` | Optional. Checkbox element rendered inside table row element. Add this class name to `mdc-checkbox` element to override styles required for data-table. |
| `mdc-data-table__row--selected` | Optional. Modifier class added to `mdc-data-table__row` when table row is selected. |
### Sass Mixins
| Mixin | Description |
| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| `mdc-data-table-fill-color($color)` | Sets the background color of data-table surface. |
| `mdc-data-table-row-fill-color($color)` | Sets the background color of table row container. |
| `mdc-data-table-header-row-fill-color($color)` | Sets the background color of table header row container. |
| `mdc-data-table-selected-row-fill-color($color)` | Sets the background color of selected row container. |
| `mdc-data-table-checked-icon-color($color)` | Sets the checked icon color. |
| `mdc-data-table-divider-color($color)` | Sets the table rows divider color. |
| `mdc-data-table-divider-size($size)` | Sets the table rows divider size. |
| `mdc-data-table-row-hover-fill-color($color)` | Sets the background color of table row on hover. |
| `mdc-data-table-header-row-text-color($color)` | Sets the header row text color. |
| `mdc-data-table-row-text-color($color)` | Sets the row text color. |
| `mdc-data-table-shape-radius($radius)` | Sets the rounded shape with given radius size. `$radius` can be single radius or list radius values up to 4 list size. |
| `mdc-data-table-stroke-size($size)` | Sets the border size of data-table. |
| `mdc-data-table-stroke-color($color)` | Sets the border color of data-table. |
| `mdc-data-table-header-row-height($height)` | Sets the header row height. |
| `mdc-data-table-row-height($height)` | Sets row height. |
| `mdc-data-table-cell-padding($leading-padding, $trailing-padding)` | Sets leading & trailing padding for all cells. |
| `mdc-data-table-column-widths($width-list)` | Sets the custom widths for each table column. |
## Accessibility
Please refer [WAI-ARIA Authoring Practices for table](https://www.w3.org/TR/wai-aria-practices-1.1/#table) for ARIA recommended role, states & properties required for table element.
## Events
Please use MDCDataTable's constants file to access these event constants.
```ts
const {events} from '@material/data-table/constants';
// `events.ROW_SELECTION_CHANGED` to access event constant.
```
| Event constant | Event name | Description |
| ----------------------- | ---------------------------- | -------------------------------------------------------- |
| `ROW_SELECTION_CHANGED` | `MDCDataTable:changed` | Event emitted when row checkbox is checked or unchecked. |
| `SELECTED_ALL` | `MDCDataTable:selectedAll` | Event emitted when header row checkbox is checked. |
| `UNSELECTED_ALL` | `MDCDataTable:unselectedAll` | Event emitted when header row checkbox is unchecked. |
## `MDCDataTable` Properties and Methods
| Method Signature | Description |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `layout() => void` | Registers new row checkboxes, header row checkbox and updates the state of header row checkbox. Use this when rows are added / removed from data table. |
| `getRows() => HTMLElement[]` | Returns array of row elements. |
| `getSelectedRowIds() => Array<string \| null>` | Returns array of selected row ids. |
| `setSelectedRowIds(rowIds: string[])` | Sets selected row ids. Overwrites previously selected rows. |
## Usage within Web Frameworks
If you are using a JavaScript framework, such as React or Angular, you can create a Data Table for your framework. Depending on your needs, you can use the _Simple Approach: Wrapping MDC Web Vanilla Components_, or the _Advanced Approach: Using Foundations and Adapters_. Please follow the instructions [here](../../docs/integrating-into-frameworks.md).
### `MDCDataTableAdapter`
| Method Signature | Description |
| ------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `addClassAtRowIndex(rowIndex: number, cssClasses: string) => void` | Adds a class name to row element at given row index excluding header row. |
| `getRowCount() => number` | Returns row count excluding header row. |
| `getRowElements() => HTMLElement[]` | Returns array of row elements excluding header row. |
| `getRowIdAtIndex(rowIndex: number) => string \| null` | Returns row id of row element at given row index based on `data-row-id` attribute on row element `tr`. |
| `getRowIndexByChildElement(el: Element) => number` | Returns index of row element that contains give child element. |
| `getSelectedRowCount() => number` | Returns selected row count. |
| `isCheckboxAtRowIndexChecked(rowIndex: number) => boolean;` | Returns True if row checkbox at given row index is checked. |
| `isHeaderRowCheckboxChecked() => boolean` | Returns true if header row checkbox is checked. |
| `isRowsSelectable() => boolean` | Returns true if table rows are selectable. |
| `notifyRowSelectionChanged(data: MDCDataTableRowSelectionChangedEventDetail) => void` | Notifies when row selection is changed. |
| `notifySelectedAll() => void` | Notifies when header row is checked. |
| `notifyUnselectedAll() => void` | Notifies when header row is unchecked. |
| `registerHeaderRowCheckbox() => Promise<void> \| void` | Initializes header row checkbox. Destroys previous header row checkbox instance if any. Can return Promise only if registering checkbox is asynchronous. |
| `registerRowCheckboxes() => Promise<void> \| void` | Initializes all row checkboxes. Destroys all previous row checkbox instances if any. This is usually called when row checkboxes are added or removed from table. Can return Promise only if registering checkbox is asynchronous. |
| `removeClassAtRowIndex(rowIndex: number, cssClasses: string) => void` | Removes class name from row element at give row index. |
| `setAttributeAtRowIndex(rowIndex: number, attr: string, value: string) => void` | Sets attribute to row element at given row index. |
| `setHeaderRowCheckboxChecked(checked: boolean) => void` | Sets header row checkbox checked or unchecked. |
| `setHeaderRowCheckboxIndeterminate(indeterminate: boolean) => void` | Sets header row checkbox to indeterminate. |
| `setRowCheckboxCheckedAtIndex(rowIndex: number, checked: boolean) => void` | Sets row checkbox to checked or unchecked at given row index. |
### `MDCDataTableFoundation`
| Method Signature | Description |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `layout() => void` | Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table. Use this if registering checkbox is synchronous. |
| `layoutAsync() => Promise<void> \| void` | Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table. Use this only if `registerRowCheckboxes` and `registerHeaderRowCheckboxe` are asynchronous. |
| `getRows() => HTMLElement[]` | Returns array of row elements. |
| `setSelectedRowIds(rowIds: string[]) => void` | Sets selected row ids. Overwrites previously selected rows. |
| `getSelectedRowIds() => Array<string \| null>` | Returns array of selected row ids. |
| `handleHeaderRowCheckboxChange() => void` | Handles header row checkbox change event. |
| `handleRowCheckboxChange(event: Event) => void` | Handles change event originated from row checkboxes. |

View File

@ -1,306 +0,0 @@
//
// Copyright 2019 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
@import "@material/animation/functions";
@import "@material/elevation/mixins";
@import "@material/feature-targeting/functions";
@import "@material/feature-targeting/mixins";
@import "@material/checkbox/mixins";
@import "@material/rtl/mixins";
@import "@material/shape/mixins";
@import "@material/theme/mixins";
@import "@material/theme/variables"; // for mdc-theme-prop-value.
@import "@material/typography/mixins";
@import "./variables";
@mixin mdc-data-table-core-styles($query: mdc-feature-all()) {
$feat-structure: mdc-feature-create-target($query, structure);
$feat-typography: mdc-feature-create-target($query, typography);
// postcss-bem-linter: define data-table
.mdc-data-table__content {
@include mdc-typography(body2, $query: $query);
}
.mdc-data-table {
@include mdc-data-table-fill-color($mdc-data-table-fill-color, $query: $query);
@include mdc-data-table-shape-radius($mdc-data-table-shape-radius, $query: $query);
@include mdc-data-table-stroke-size($mdc-data-table-stroke-size, $query: $query);
@include mdc-data-table-stroke-color($mdc-data-table-stroke-color, $query: $query);
@at-root {
@include mdc-data-table-row-fill-color($mdc-data-table-row-fill-color, $query: $query);
@include mdc-data-table-header-row-fill-color($mdc-data-table-header-row-fill-color, $query: $query);
@include mdc-data-table-selected-row-fill-color($mdc-data-table-selected-row-fill-color, $query: $query);
@include mdc-data-table-divider-color($mdc-data-table-divider-color, $query: $query);
@include mdc-data-table-divider-size($mdc-data-table-divider-size, $query: $query);
@include mdc-data-table-row-hover-fill-color($mdc-data-table-row-hover-fill-color, $query: $query);
@include mdc-data-table-header-row-text-color($mdc-data-table-header-row-text-color, $query: $query);
@include mdc-data-table-row-text-color($mdc-data-table-row-text-color, $query: $query);
@include mdc-data-table-header-row-height($mdc-data-table-header-row-height, $query: $query);
@include mdc-data-table-row-height($mdc-data-table-row-height, $query: $query);
@include mdc-data-table-cell-padding(
$leading-padding: $mdc-data-table-cell-leading-padding,
$trailing-padding: $mdc-data-table-cell-trailing-padding,
$query: $query
);
}
@include mdc-feature-targets($feat-structure) {
display: inline-flex;
flex-direction: column;
box-sizing: border-box;
overflow-x: auto;
}
}
.mdc-data-table__table {
@include mdc-feature-targets($feat-structure) {
width: 100%;
border: 0;
white-space: nowrap;
border-collapse: collapse;
}
}
.mdc-data-table__cell {
@include mdc-typography(body2, $query: $query);
}
.mdc-data-table__cell--numeric {
@include mdc-feature-targets($feat-structure) {
text-align: right;
}
@include mdc-feature-targets($feat-structure) {
@include mdc-rtl {
/* @noflip */
text-align: left;
}
}
}
.mdc-data-table__header-cell {
@include mdc-typography(subtitle2, $query: $query);
@include mdc-feature-targets($feat-structure) {
text-align: left;
}
@include mdc-feature-targets($feat-structure) {
@include mdc-rtl {
/* @noflip */
text-align: right;
}
}
}
.mdc-data-table__header-cell--numeric {
@include mdc-feature-targets($feat-structure) {
text-align: right;
}
@include mdc-feature-targets($feat-structure) {
@include mdc-rtl {
/* @noflip */
text-align: left;
}
}
}
}
@mixin mdc-data-table-fill-color($color, $query: mdc-feature-all()) {
$feat-color: mdc-feature-create-target($query, color);
@include mdc-feature-targets($feat-color) {
@include mdc-theme-prop("background-color", $color);
}
}
@mixin mdc-data-table-header-row-fill-color($color, $query: mdc-feature-all()) {
$feat-color: mdc-feature-create-target($query, color);
.mdc-data-table__header-row {
@include mdc-feature-targets($feat-color) {
@include mdc-theme-prop("background-color", $color);
}
}
}
@mixin mdc-data-table-row-fill-color($color, $query: mdc-feature-all()) {
$feat-color: mdc-feature-create-target($query, color);
.mdc-data-table__row {
@include mdc-feature-targets($feat-color) {
@include mdc-theme-prop("background-color", $color);
}
}
}
@mixin mdc-data-table-selected-row-fill-color($color, $query: mdc-feature-all()) {
$feat-color: mdc-feature-create-target($query, color);
.mdc-data-table__row--selected {
@include mdc-feature-targets($feat-color) {
@include mdc-theme-prop("background-color", $color);
}
}
}
@mixin mdc-data-table-checked-icon-color($color, $query: mdc-feature-all()) {
.mdc-data-table__header-row-checkbox,
.mdc-data-table__row-checkbox {
@include mdc-checkbox-focus-indicator-color($color, $query: $query);
@include mdc-checkbox-container-colors($marked-stroke-color: $color, $marked-fill-color: $color, $query: $query);
}
}
@mixin mdc-data-table-divider-color($color, $query: mdc-feature-all()) {
$feat-color: mdc-feature-create-target($query, color);
.mdc-data-table__row {
@include mdc-feature-targets($feat-color) {
border-top-color: $color;
}
}
}
@mixin mdc-data-table-divider-size($size, $query: mdc-feature-all()) {
$feat-structure: mdc-feature-create-target($query, structure);
.mdc-data-table__row {
@include mdc-feature-targets($feat-structure) {
border-top-width: $size;
border-top-style: solid;
}
}
}
@mixin mdc-data-table-row-hover-fill-color($color, $query: mdc-feature-all()) {
$feat-color: mdc-feature-create-target($query, color);
.mdc-data-table__row:not(.mdc-data-table__row--selected):hover {
@include mdc-feature-targets($feat-color) {
@include mdc-theme-prop("background-color", $color);
}
}
}
@mixin mdc-data-table-header-row-text-color($color, $query: mdc-feature-all()) {
$feat-color: mdc-feature-create-target($query, color);
.mdc-data-table__header-cell {
@include mdc-feature-targets($feat-color) {
@include mdc-theme-prop("color", $color);
}
}
}
@mixin mdc-data-table-row-text-color($color, $query: mdc-feature-all()) {
$feat-color: mdc-feature-create-target($query, color);
.mdc-data-table__cell {
@include mdc-feature-targets($feat-color) {
@include mdc-theme-prop("color", $color);
}
}
}
@mixin mdc-data-table-shape-radius($radius, $rtl-reflexive: false, $query: mdc-feature-all()) {
@include mdc-shape-radius($radius, $rtl-reflexive, $query: $query);
}
@mixin mdc-data-table-stroke-size($size, $query: mdc-feature-all()) {
$feat-structure: mdc-feature-create-target($query, structure);
@include mdc-feature-targets($feat-structure) {
border-width: $size;
border-style: solid;
}
}
@mixin mdc-data-table-stroke-color($color, $query: mdc-feature-all()) {
$feat-color: mdc-feature-create-target($query, color);
@include mdc-feature-targets($feat-color) {
border-color: $color;
}
}
@mixin mdc-data-table-header-row-height($height, $query: mdc-feature-all()) {
$feat-structure: mdc-feature-create-target($query, structure);
.mdc-data-table__header-row {
@include mdc-feature-targets($feat-structure) {
height: $height;
}
}
}
@mixin mdc-data-table-row-height($height, $query: mdc-feature-all()) {
$feat-structure: mdc-feature-create-target($query, structure);
.mdc-data-table__row {
@include mdc-feature-targets($feat-structure) {
height: $height;
}
}
}
@mixin mdc-data-table-cell-padding(
$leading-padding: $mdc-data-table-cell-leading-padding,
$trailing-padding: $mdc-data-table-cell-trailing-padding,
$query: mdc-feature-all()) {
$feat-structure: mdc-feature-create-target($query, structure);
.mdc-data-table__cell,
.mdc-data-table__header-cell {
@include mdc-feature-targets($feat-structure) {
padding-right: $trailing-padding;
padding-left: $leading-padding;
}
}
.mdc-data-table__header-cell--checkbox,
.mdc-data-table__cell--checkbox {
@include mdc-feature-targets($feat-structure) {
@include mdc-rtl-reflexive-property(padding, $leading-padding, 0);
}
}
}
@mixin mdc-data-table-column-widths($width-list, $query: mdc-feature-all()) {
$feat-structure: mdc-feature-create-target($query, structure);
@for $i from 1 through length($width-list) {
.mdc-data-table__row > :nth-child(#{$i}) {
@include mdc-feature-targets($feat-structure) {
width: nth($width-list, $i);
}
}
}
}
@mixin mdc-data-table-theme-baseline($query: mdc-feature-all()) {
@include mdc-data-table-checked-icon-color($mdc-data-table-checked-icon-color, $query: $query);
}

View File

@ -1,46 +0,0 @@
//
// Copyright 2019 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
@import "@material/theme/functions";
$mdc-data-table-fill-color: surface !default;
$mdc-data-table-header-row-fill-color: inherit !default;
$mdc-data-table-row-fill-color: inherit !default;
$mdc-data-table-selected-row-fill-color: rgba(mdc-theme-prop-value(primary), .04) !default;
$mdc-data-table-checked-icon-color: primary !default;
$mdc-data-table-divider-color: rgba(mdc-theme-prop-value(on-surface), .12) !default;
$mdc-data-table-divider-size: 1px !default;
$mdc-data-table-row-hover-fill-color: rgba(mdc-theme-prop-value(on-surface), .04) !default;
$mdc-data-table-checkbox-touch-dimension: 48px !default;
$mdc-data-table-header-row-text-color: rgba(mdc-theme-prop-value(on-surface), .87) !default;
$mdc-data-table-row-text-color: rgba(mdc-theme-prop-value(on-surface), .87) !default;
$mdc-data-table-shape-radius: medium !default;
$mdc-data-table-stroke-size: 1px !default;
$mdc-data-table-stroke-color: rgba(mdc-theme-prop-value(on-surface), .12) !default;
$mdc-data-table-row-height: 52px !default;
$mdc-data-table-header-row-height: $mdc-data-table-row-height + 4px !default;
$mdc-data-table-cell-leading-padding: 16px !default;
$mdc-data-table-cell-trailing-padding: 16px !default;

View File

@ -1,140 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* Defines the shape of the adapter expected by the foundation.
* Implement this adapter for your framework of choice to delegate updates to
* the component in your framework of choice. See architecture documentation
* for more details.
* https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md
*/
import { MDCDataTableRowSelectionChangedEventDetail } from "./types";
export interface MDCDataTableAdapter {
/**
* Adds a class name to row element at given row index excluding header row.
*
* @param rowIndex Index of row element excluding header row.
* @param cssClasses CSS Class string to add.
*/
addClassAtRowIndex(rowIndex: number, cssClasses: string): void;
/**
* @return Row count excluding header row.
*/
getRowCount(): number;
/**
* @return Array of row elements excluding header row.
*/
getRowElements(): Element[];
/**
* Returns row id of row element at given row index based on `data-row-id` attribute on row element `tr`.
*
* @param rowIndex Index of row element.
* @return Row id of row element, returns `null` in absence of `data-row-id` attribute on row element.
*/
getRowIdAtIndex(rowIndex: number): string | null;
/**
* Returns index of row element that contains give child element. Returns -1 if element is not child of any row
* element.
*
* @param el Child element of row element.
* @return Index of row element.
*/
getRowIndexByChildElement(el: Element): number;
/**
* @return Selected row count.
*/
getSelectedRowCount(): number;
/**
* @param rowIndex Index of row element.
* @return True if row checkbox at given row index is checked.
*/
isCheckboxAtRowIndexChecked(rowIndex: number): boolean;
/**
* @return True if header row checkbox is checked.
*/
isHeaderRowCheckboxChecked(): boolean;
/**
* @return True if table rows are selectable.
*/
isRowsSelectable(): boolean;
/**
* Notifies when row selection is changed.
*
* @param data Event detail data for row selection changed event.
*/
notifyRowSelectionChanged(
data: MDCDataTableRowSelectionChangedEventDetail
): void;
/**
* Notifies when header row is checked.
*/
notifySelectedAll(): void;
/**
* Notifies when header row is unchecked.
*/
notifyUnselectedAll(): void;
/**
* Initializes header row checkbox. Destroys previous header row checkbox instance if any.
* @return Can return Promise only if registering checkbox is asynchronous.
*/
registerHeaderRowCheckbox(): Promise<void> | void;
/**
* Initializes all row checkboxes. Destroys previous row checkbox instances if any. This is usually called when row
* checkboxes are added or removed from table.
* @return Can return Promise only if registering checkbox is asynchronous.
*/
registerRowCheckboxes(): Promise<void> | void;
/**
* Removes class name from row element at give row index.
*
* @param rowIndex Index of row element excluding header row element.
* @param cssClasses Class name string.
*/
removeClassAtRowIndex(rowIndex: number, cssClasses: string): void;
/**
* Sets attribute to row element at given row index.
*
* @param rowIndex Index of row element excluding header row element.
* @param attr Name of attribute.
* @param value Value of attribute.
*/
setAttributeAtRowIndex(rowIndex: number, attr: string, value: string): void;
/**
* Sets header row checkbox checked or unchecked.
*
* @param checked True to set header row checkbox checked.
*/
setHeaderRowCheckboxChecked(checked: boolean): void;
/**
* Sets header row checkbox to indeterminate.
*
* @param indeterminate True to set header row checkbox indeterminate.
*/
setHeaderRowCheckboxIndeterminate(indeterminate: boolean): void;
/**
* Sets row checkbox to checked or unchecked at given row index.
*
* @param rowIndex Index of row element excluding header row element.
* @param checked True to set checked.
*/
setRowCheckboxCheckedAtIndex(rowIndex: number, checked: boolean): void;
}

View File

@ -1,23 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
//# sourceMappingURL=adapter.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG"}

View File

@ -1,161 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* Defines the shape of the adapter expected by the foundation.
* Implement this adapter for your framework of choice to delegate updates to
* the component in your framework of choice. See architecture documentation
* for more details.
* https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md
*/
import { MDCDataTableRowSelectionChangedEventDetail } from "./types";
export interface MDCDataTableAdapter {
/**
* Adds a class name to row element at given row index excluding header row.
*
* @param rowIndex Index of row element excluding header row.
* @param cssClasses CSS Class string to add.
*/
addClassAtRowIndex(rowIndex: number, cssClasses: string): void;
/**
* @return Row count excluding header row.
*/
getRowCount(): number;
/**
* @return Array of row elements excluding header row.
*/
getRowElements(): Element[];
/**
* Returns row id of row element at given row index based on `data-row-id` attribute on row element `tr`.
*
* @param rowIndex Index of row element.
* @return Row id of row element, returns `null` in absence of `data-row-id` attribute on row element.
*/
getRowIdAtIndex(rowIndex: number): string | null;
/**
* Returns index of row element that contains give child element. Returns -1 if element is not child of any row
* element.
*
* @param el Child element of row element.
* @return Index of row element.
*/
getRowIndexByChildElement(el: Element): number;
/**
* @return Selected row count.
*/
getSelectedRowCount(): number;
/**
* @param rowIndex Index of row element.
* @return True if row checkbox at given row index is checked.
*/
isCheckboxAtRowIndexChecked(rowIndex: number): boolean;
/**
* @return True if header row checkbox is checked.
*/
isHeaderRowCheckboxChecked(): boolean;
/**
* @return True if table rows are selectable.
*/
isRowsSelectable(): boolean;
/**
* Notifies when row selection is changed.
*
* @param data Event detail data for row selection changed event.
*/
notifyRowSelectionChanged(
data: MDCDataTableRowSelectionChangedEventDetail
): void;
/**
* Notifies when header row is checked.
*/
notifySelectedAll(): void;
/**
* Notifies when header row is unchecked.
*/
notifyUnselectedAll(): void;
/**
* Initializes header row checkbox. Destroys previous header row checkbox instance if any.
* @return Can return Promise only if registering checkbox is asynchronous.
*/
registerHeaderRowCheckbox(): Promise<void> | void;
/**
* Initializes all row checkboxes. Destroys previous row checkbox instances if any. This is usually called when row
* checkboxes are added or removed from table.
* @return Can return Promise only if registering checkbox is asynchronous.
*/
registerRowCheckboxes(): Promise<void> | void;
/**
* Removes class name from row element at give row index.
*
* @param rowIndex Index of row element excluding header row element.
* @param cssClasses Class name string.
*/
removeClassAtRowIndex(rowIndex: number, cssClasses: string): void;
/**
* Sets attribute to row element at given row index.
*
* @param rowIndex Index of row element excluding header row element.
* @param attr Name of attribute.
* @param value Value of attribute.
*/
setAttributeAtRowIndex(rowIndex: number, attr: string, value: string): void;
/**
* Sets header row checkbox checked or unchecked.
*
* @param checked True to set header row checkbox checked.
*/
setHeaderRowCheckboxChecked(checked: boolean): void;
/**
* Sets header row checkbox to indeterminate.
*
* @param indeterminate True to set header row checkbox indeterminate.
*/
setHeaderRowCheckboxIndeterminate(indeterminate: boolean): void;
/**
* Sets row checkbox to checked or unchecked at given row index.
*
* @param rowIndex Index of row element excluding header row element.
* @param checked True to set checked.
*/
setRowCheckboxCheckedAtIndex(rowIndex: number, checked: boolean): void;
}

View File

@ -1,58 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import { MDCComponent } from "@material/base/component";
import { MDCCheckboxFactory } from "@material/checkbox/component";
import { MDCDataTableFoundation } from "./foundation";
export declare class MDCDataTable extends MDCComponent<MDCDataTableFoundation> {
static attachTo(root: Element): MDCDataTable;
private headerRowCheckbox_;
private rowCheckboxList_;
private checkboxFactory_;
private headerRow_;
private content_;
private handleHeaderRowCheckboxChange_;
private handleRowCheckboxChange_;
initialize(checkboxFactory?: MDCCheckboxFactory): void;
initialSyncWithDOM(): void;
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
*/
layout(): void;
/**
* @return Returns array of row elements.
*/
getRows(): Element[];
/**
* @return Returns array of selected row ids.
*/
getSelectedRowIds(): Array<string | null>;
/**
* Sets selected row ids. Overwrites previously selected rows.
* @param rowIds Array of row ids that needs to be selected.
*/
setSelectedRowIds(rowIds: string[]): void;
destroy(): void;
getDefaultFoundation(): MDCDataTableFoundation;
private getRowByIndex_;
private getRowIdByIndex_;
}

View File

@ -1,202 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import * as tslib_1 from "tslib";
import { MDCComponent } from "@material/base/component";
import { MDCCheckbox } from "@material/checkbox/component";
import { closest } from "@material/dom/ponyfill";
import { cssClasses, events, strings } from "./constants";
import { MDCDataTableFoundation } from "./foundation";
var MDCDataTable = /** @class */ (function(_super) {
tslib_1.__extends(MDCDataTable, _super);
function MDCDataTable() {
return (_super !== null && _super.apply(this, arguments)) || this;
}
MDCDataTable.attachTo = function(root) {
return new MDCDataTable(root);
};
MDCDataTable.prototype.initialize = function(checkboxFactory) {
if (checkboxFactory === void 0) {
checkboxFactory = function(el) {
return new MDCCheckbox(el);
};
}
this.checkboxFactory_ = checkboxFactory;
};
MDCDataTable.prototype.initialSyncWithDOM = function() {
var _this = this;
this.headerRow_ = this.root_.querySelector("." + cssClasses.HEADER_ROW);
this.handleHeaderRowCheckboxChange_ = function() {
return _this.foundation_.handleHeaderRowCheckboxChange();
};
this.headerRow_.addEventListener(
"change",
this.handleHeaderRowCheckboxChange_
);
this.content_ = this.root_.querySelector("." + cssClasses.CONTENT);
this.handleRowCheckboxChange_ = function(event) {
return _this.foundation_.handleRowCheckboxChange(event);
};
this.content_.addEventListener("change", this.handleRowCheckboxChange_);
this.layout();
};
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
*/
MDCDataTable.prototype.layout = function() {
this.foundation_.layout();
};
/**
* @return Returns array of row elements.
*/
MDCDataTable.prototype.getRows = function() {
return this.foundation_.getRows();
};
/**
* @return Returns array of selected row ids.
*/
MDCDataTable.prototype.getSelectedRowIds = function() {
return this.foundation_.getSelectedRowIds();
};
/**
* Sets selected row ids. Overwrites previously selected rows.
* @param rowIds Array of row ids that needs to be selected.
*/
MDCDataTable.prototype.setSelectedRowIds = function(rowIds) {
this.foundation_.setSelectedRowIds(rowIds);
};
MDCDataTable.prototype.destroy = function() {
this.headerRow_.removeEventListener(
"change",
this.handleHeaderRowCheckboxChange_
);
this.content_.removeEventListener("change", this.handleRowCheckboxChange_);
this.headerRowCheckbox_.destroy();
this.rowCheckboxList_.forEach(function(checkbox) {
return checkbox.destroy();
});
};
MDCDataTable.prototype.getDefaultFoundation = function() {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
addClassAtRowIndex: function(rowIndex, className) {
return _this.getRows()[rowIndex].classList.add(className);
},
getRowCount: function() {
return _this.getRows().length;
},
getRowElements: function() {
return [].slice.call(
_this.root_.querySelectorAll(strings.ROW_SELECTOR)
);
},
getRowIdAtIndex: function(rowIndex) {
return _this.getRows()[rowIndex].getAttribute(strings.DATA_ROW_ID_ATTR);
},
getRowIndexByChildElement: function(el) {
return _this.getRows().indexOf(closest(el, strings.ROW_SELECTOR));
},
getSelectedRowCount: function() {
return _this.root_.querySelectorAll(strings.ROW_SELECTED_SELECTOR)
.length;
},
isCheckboxAtRowIndexChecked: function(rowIndex) {
return _this.rowCheckboxList_[rowIndex].checked;
},
isHeaderRowCheckboxChecked: function() {
return _this.headerRowCheckbox_.checked;
},
isRowsSelectable: function() {
return !!_this.root_.querySelector(strings.ROW_CHECKBOX_SELECTOR);
},
notifyRowSelectionChanged: function(data) {
_this.emit(
events.ROW_SELECTION_CHANGED,
{
row: _this.getRowByIndex_(data.rowIndex),
rowId: _this.getRowIdByIndex_(data.rowIndex),
rowIndex: data.rowIndex,
selected: data.selected,
},
/** shouldBubble */ true
);
},
notifySelectedAll: function() {
return _this.emit(events.SELECTED_ALL, {}, /** shouldBubble */ true);
},
notifyUnselectedAll: function() {
return _this.emit(events.UNSELECTED_ALL, {}, /** shouldBubble */ true);
},
registerHeaderRowCheckbox: function() {
if (_this.headerRowCheckbox_) {
_this.headerRowCheckbox_.destroy();
}
var checkboxEl = _this.root_.querySelector(
strings.HEADER_ROW_CHECKBOX_SELECTOR
);
_this.headerRowCheckbox_ = _this.checkboxFactory_(checkboxEl);
},
registerRowCheckboxes: function() {
if (_this.rowCheckboxList_) {
_this.rowCheckboxList_.forEach(function(checkbox) {
return checkbox.destroy();
});
}
_this.rowCheckboxList_ = [];
_this.getRows().forEach(function(rowEl) {
var checkbox = _this.checkboxFactory_(
rowEl.querySelector(strings.ROW_CHECKBOX_SELECTOR)
);
_this.rowCheckboxList_.push(checkbox);
});
},
removeClassAtRowIndex: function(rowIndex, className) {
_this.getRows()[rowIndex].classList.remove(className);
},
setAttributeAtRowIndex: function(rowIndex, attr, value) {
_this.getRows()[rowIndex].setAttribute(attr, value);
},
setHeaderRowCheckboxChecked: function(checked) {
_this.headerRowCheckbox_.checked = checked;
},
setHeaderRowCheckboxIndeterminate: function(indeterminate) {
_this.headerRowCheckbox_.indeterminate = indeterminate;
},
setRowCheckboxCheckedAtIndex: function(rowIndex, checked) {
_this.rowCheckboxList_[rowIndex].checked = checked;
},
};
return new MDCDataTableFoundation(adapter);
};
MDCDataTable.prototype.getRowByIndex_ = function(index) {
return this.getRows()[index];
};
MDCDataTable.prototype.getRowIdByIndex_ = function(index) {
return this.getRowByIndex_(index).getAttribute(strings.DATA_ROW_ID_ATTR);
};
return MDCDataTable;
})(MDCComponent);
export { MDCDataTable };
//# sourceMappingURL=component.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,209 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import { MDCComponent } from "@material/base/component";
import { SpecificEventListener } from "@material/base/types";
import { MDCCheckbox, MDCCheckboxFactory } from "@material/checkbox/component";
import { closest } from "@material/dom/ponyfill";
import { MDCDataTableAdapter } from "./adapter";
import { cssClasses, events, strings } from "./constants";
import { MDCDataTableFoundation } from "./foundation";
import { MDCDataTableRowSelectionChangedEventDetail } from "./types";
export class MDCDataTable extends MDCComponent<MDCDataTableFoundation> {
static attachTo(root: Element): MDCDataTable {
return new MDCDataTable(root);
}
private headerRowCheckbox_!: MDCCheckbox;
private rowCheckboxList_!: MDCCheckbox[];
private checkboxFactory_!: MDCCheckboxFactory;
private headerRow_!: HTMLElement;
private content_!: HTMLElement;
private handleHeaderRowCheckboxChange_!: SpecificEventListener<"change">;
private handleRowCheckboxChange_!: SpecificEventListener<"change">;
initialize(
checkboxFactory: MDCCheckboxFactory = (el: Element) => new MDCCheckbox(el)
) {
this.checkboxFactory_ = checkboxFactory;
}
initialSyncWithDOM() {
this.headerRow_ = this.root_.querySelector(
`.${cssClasses.HEADER_ROW}`
) as HTMLElement;
this.handleHeaderRowCheckboxChange_ = () =>
this.foundation_.handleHeaderRowCheckboxChange();
this.headerRow_.addEventListener(
"change",
this.handleHeaderRowCheckboxChange_
);
this.content_ = this.root_.querySelector(
`.${cssClasses.CONTENT}`
) as HTMLElement;
this.handleRowCheckboxChange_ = (event) =>
this.foundation_.handleRowCheckboxChange(event);
this.content_.addEventListener("change", this.handleRowCheckboxChange_);
this.layout();
}
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
*/
layout() {
this.foundation_.layout();
}
/**
* @return Returns array of row elements.
*/
getRows(): Element[] {
return this.foundation_.getRows();
}
/**
* @return Returns array of selected row ids.
*/
getSelectedRowIds(): Array<string | null> {
return this.foundation_.getSelectedRowIds();
}
/**
* Sets selected row ids. Overwrites previously selected rows.
* @param rowIds Array of row ids that needs to be selected.
*/
setSelectedRowIds(rowIds: string[]) {
this.foundation_.setSelectedRowIds(rowIds);
}
destroy() {
this.headerRow_.removeEventListener(
"change",
this.handleHeaderRowCheckboxChange_
);
this.content_.removeEventListener("change", this.handleRowCheckboxChange_);
this.headerRowCheckbox_.destroy();
this.rowCheckboxList_.forEach((checkbox) => checkbox.destroy());
}
getDefaultFoundation() {
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
const adapter: MDCDataTableAdapter = {
addClassAtRowIndex: (rowIndex: number, className: string) =>
this.getRows()[rowIndex].classList.add(className),
getRowCount: () => this.getRows().length,
getRowElements: () =>
[].slice.call(this.root_.querySelectorAll(strings.ROW_SELECTOR)),
getRowIdAtIndex: (rowIndex: number) =>
this.getRows()[rowIndex].getAttribute(strings.DATA_ROW_ID_ATTR),
getRowIndexByChildElement: (el: Element) => {
return this.getRows().indexOf(closest(
el,
strings.ROW_SELECTOR
) as HTMLElement);
},
getSelectedRowCount: () =>
this.root_.querySelectorAll(strings.ROW_SELECTED_SELECTOR).length,
isCheckboxAtRowIndexChecked: (rowIndex: number) =>
this.rowCheckboxList_[rowIndex].checked,
isHeaderRowCheckboxChecked: () => this.headerRowCheckbox_.checked,
isRowsSelectable: () =>
!!this.root_.querySelector(strings.ROW_CHECKBOX_SELECTOR),
notifyRowSelectionChanged: (
data: MDCDataTableRowSelectionChangedEventDetail
) => {
this.emit(
events.ROW_SELECTION_CHANGED,
{
row: this.getRowByIndex_(data.rowIndex),
rowId: this.getRowIdByIndex_(data.rowIndex),
rowIndex: data.rowIndex,
selected: data.selected,
},
/** shouldBubble */ true
);
},
notifySelectedAll: () =>
this.emit(events.SELECTED_ALL, {}, /** shouldBubble */ true),
notifyUnselectedAll: () =>
this.emit(events.UNSELECTED_ALL, {}, /** shouldBubble */ true),
registerHeaderRowCheckbox: () => {
if (this.headerRowCheckbox_) {
this.headerRowCheckbox_.destroy();
}
const checkboxEl = this.root_.querySelector(
strings.HEADER_ROW_CHECKBOX_SELECTOR
) as HTMLElement;
this.headerRowCheckbox_ = this.checkboxFactory_(checkboxEl);
},
registerRowCheckboxes: () => {
if (this.rowCheckboxList_) {
this.rowCheckboxList_.forEach((checkbox) => checkbox.destroy());
}
this.rowCheckboxList_ = [];
this.getRows().forEach((rowEl) => {
const checkbox = this.checkboxFactory_(rowEl.querySelector(
strings.ROW_CHECKBOX_SELECTOR
) as HTMLElement);
this.rowCheckboxList_.push(checkbox);
});
},
removeClassAtRowIndex: (rowIndex: number, className: string) => {
this.getRows()[rowIndex].classList.remove(className);
},
setAttributeAtRowIndex: (
rowIndex: number,
attr: string,
value: string
) => {
this.getRows()[rowIndex].setAttribute(attr, value);
},
setHeaderRowCheckboxChecked: (checked: boolean) => {
this.headerRowCheckbox_.checked = checked;
},
setHeaderRowCheckboxIndeterminate: (indeterminate: boolean) => {
this.headerRowCheckbox_.indeterminate = indeterminate;
},
setRowCheckboxCheckedAtIndex: (rowIndex: number, checked: boolean) => {
this.rowCheckboxList_[rowIndex].checked = checked;
},
};
return new MDCDataTableFoundation(adapter);
}
private getRowByIndex_(index: number): Element {
return this.getRows()[index];
}
private getRowIdByIndex_(index: number): string | null {
return this.getRowByIndex_(index).getAttribute(strings.DATA_ROW_ID_ATTR);
}
}

View File

@ -1,46 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
export declare const cssClasses: {
CELL: string;
CELL_NUMERIC: string;
CONTENT: string;
HEADER_ROW: string;
HEADER_ROW_CHECKBOX: string;
ROOT: string;
ROW: string;
ROW_CHECKBOX: string;
ROW_SELECTED: string;
};
export declare const strings: {
ARIA_SELECTED: string;
DATA_ROW_ID_ATTR: string;
HEADER_ROW_CHECKBOX_SELECTOR: string;
ROW_CHECKBOX_SELECTOR: string;
ROW_SELECTED_SELECTOR: string;
ROW_SELECTOR: string;
};
export declare const events: {
ROW_SELECTION_CHANGED: string;
SELECTED_ALL: string;
UNSELECTED_ALL: string;
};

View File

@ -1,47 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
export var cssClasses = {
CELL: "mdc-data-table__cell",
CELL_NUMERIC: "mdc-data-table__cell--numeric",
CONTENT: "mdc-data-table__content",
HEADER_ROW: "mdc-data-table__header-row",
HEADER_ROW_CHECKBOX: "mdc-data-table__header-row-checkbox",
ROOT: "mdc-data-table",
ROW: "mdc-data-table__row",
ROW_CHECKBOX: "mdc-data-table__row-checkbox",
ROW_SELECTED: "mdc-data-table__row--selected",
};
export var strings = {
ARIA_SELECTED: "aria-selected",
DATA_ROW_ID_ATTR: "data-row-id",
HEADER_ROW_CHECKBOX_SELECTOR: "." + cssClasses.HEADER_ROW_CHECKBOX,
ROW_CHECKBOX_SELECTOR: "." + cssClasses.ROW_CHECKBOX,
ROW_SELECTED_SELECTOR: "." + cssClasses.ROW_SELECTED,
ROW_SELECTOR: "." + cssClasses.ROW,
};
export var events = {
ROW_SELECTION_CHANGED: "MDCDataTable:rowSelectionChanged",
SELECTED_ALL: "MDCDataTable:selectedAll",
UNSELECTED_ALL: "MDCDataTable:unselectedAll",
};
//# sourceMappingURL=constants.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,CAAC,IAAM,UAAU,GAAG;IACxB,IAAI,EAAE,sBAAsB;IAC5B,YAAY,EAAE,+BAA+B;IAC7C,OAAO,EAAE,yBAAyB;IAClC,UAAU,EAAE,4BAA4B;IACxC,mBAAmB,EAAE,qCAAqC;IAC1D,IAAI,EAAE,gBAAgB;IACtB,GAAG,EAAE,qBAAqB;IAC1B,YAAY,EAAE,8BAA8B;IAC5C,YAAY,EAAE,+BAA+B;CAC9C,CAAC;AAEF,MAAM,CAAC,IAAM,OAAO,GAAG;IACrB,aAAa,EAAE,eAAe;IAC9B,gBAAgB,EAAE,aAAa;IAC/B,4BAA4B,EAAE,MAAI,UAAU,CAAC,mBAAqB;IAClE,qBAAqB,EAAE,MAAI,UAAU,CAAC,YAAc;IACpD,qBAAqB,EAAE,MAAI,UAAU,CAAC,YAAc;IACpD,YAAY,EAAE,MAAI,UAAU,CAAC,GAAK;CACnC,CAAC;AAEF,MAAM,CAAC,IAAM,MAAM,GAAG;IACpB,qBAAqB,EAAE,kCAAkC;IACzD,YAAY,EAAE,0BAA0B;IACxC,cAAc,EAAE,4BAA4B;CAC7C,CAAC"}

View File

@ -1,49 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
export const cssClasses = {
CELL: "mdc-data-table__cell",
CELL_NUMERIC: "mdc-data-table__cell--numeric",
CONTENT: "mdc-data-table__content",
HEADER_ROW: "mdc-data-table__header-row",
HEADER_ROW_CHECKBOX: "mdc-data-table__header-row-checkbox",
ROOT: "mdc-data-table",
ROW: "mdc-data-table__row",
ROW_CHECKBOX: "mdc-data-table__row-checkbox",
ROW_SELECTED: "mdc-data-table__row--selected",
};
export const strings = {
ARIA_SELECTED: "aria-selected",
DATA_ROW_ID_ATTR: "data-row-id",
HEADER_ROW_CHECKBOX_SELECTOR: `.${cssClasses.HEADER_ROW_CHECKBOX}`,
ROW_CHECKBOX_SELECTOR: `.${cssClasses.ROW_CHECKBOX}`,
ROW_SELECTED_SELECTOR: `.${cssClasses.ROW_SELECTED}`,
ROW_SELECTOR: `.${cssClasses.ROW}`,
};
export const events = {
ROW_SELECTION_CHANGED: "MDCDataTable:rowSelectionChanged",
SELECTED_ALL: "MDCDataTable:selectedAll",
UNSELECTED_ALL: "MDCDataTable:unselectedAll",
};

View File

@ -1,69 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import { MDCFoundation } from "@material/base/foundation";
import { MDCDataTableAdapter } from "./adapter";
export declare class MDCDataTableFoundation extends MDCFoundation<
MDCDataTableAdapter
> {
static readonly defaultAdapter: MDCDataTableAdapter;
constructor(adapter?: Partial<MDCDataTableAdapter>);
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
* Use this if registering checkbox is synchronous.
*/
layout(): void;
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
* Use this if registering checkbox is asynchronous.
*/
layoutAsync(): Promise<void>;
/**
* @return Returns array of row elements.
*/
getRows(): Element[];
/**
* Sets selected row ids. Overwrites previously selected rows.
* @param rowIds Array of row ids that needs to be selected.
*/
setSelectedRowIds(rowIds: string[]): void;
/**
* @return Returns array of selected row ids.
*/
getSelectedRowIds(): Array<string | null>;
/**
* Handles header row checkbox change event.
*/
handleHeaderRowCheckboxChange(): void;
/**
* Handles change event originated from row checkboxes.
*/
handleRowCheckboxChange(event: Event): void;
/**
* Updates header row checkbox state based on number of rows selected.
*/
private setHeaderRowCheckboxState_;
/**
* Sets the attributes of row element based on selection state.
*/
private selectRowAtIndex_;
}

View File

@ -1,244 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import * as tslib_1 from "tslib";
import { MDCFoundation } from "@material/base/foundation";
import { cssClasses, strings } from "./constants";
var MDCDataTableFoundation = /** @class */ (function(_super) {
tslib_1.__extends(MDCDataTableFoundation, _super);
function MDCDataTableFoundation(adapter) {
return (
_super.call(
this,
tslib_1.__assign({}, MDCDataTableFoundation.defaultAdapter, adapter)
) || this
);
}
Object.defineProperty(MDCDataTableFoundation, "defaultAdapter", {
get: function() {
return {
addClassAtRowIndex: function() {
return undefined;
},
getRowCount: function() {
return 0;
},
getRowElements: function() {
return [];
},
getRowIdAtIndex: function() {
return "";
},
getRowIndexByChildElement: function() {
return 0;
},
getSelectedRowCount: function() {
return 0;
},
isCheckboxAtRowIndexChecked: function() {
return false;
},
isHeaderRowCheckboxChecked: function() {
return false;
},
isRowsSelectable: function() {
return false;
},
notifyRowSelectionChanged: function() {
return undefined;
},
notifySelectedAll: function() {
return undefined;
},
notifyUnselectedAll: function() {
return undefined;
},
registerHeaderRowCheckbox: function() {
return undefined;
},
registerRowCheckboxes: function() {
return undefined;
},
removeClassAtRowIndex: function() {
return undefined;
},
setAttributeAtRowIndex: function() {
return undefined;
},
setHeaderRowCheckboxChecked: function() {
return undefined;
},
setHeaderRowCheckboxIndeterminate: function() {
return undefined;
},
setRowCheckboxCheckedAtIndex: function() {
return undefined;
},
};
},
enumerable: true,
configurable: true,
});
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
* Use this if registering checkbox is synchronous.
*/
MDCDataTableFoundation.prototype.layout = function() {
if (this.adapter_.isRowsSelectable()) {
this.adapter_.registerHeaderRowCheckbox();
this.adapter_.registerRowCheckboxes();
this.setHeaderRowCheckboxState_();
}
};
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
* Use this if registering checkbox is asynchronous.
*/
MDCDataTableFoundation.prototype.layoutAsync = function() {
return tslib_1.__awaiter(this, void 0, void 0, function() {
return tslib_1.__generator(this, function(_a) {
switch (_a.label) {
case 0:
if (!this.adapter_.isRowsSelectable()) return [3 /*break*/, 3];
return [4 /*yield*/, this.adapter_.registerHeaderRowCheckbox()];
case 1:
_a.sent();
return [4 /*yield*/, this.adapter_.registerRowCheckboxes()];
case 2:
_a.sent();
this.setHeaderRowCheckboxState_();
_a.label = 3;
case 3:
return [2 /*return*/];
}
});
});
};
/**
* @return Returns array of row elements.
*/
MDCDataTableFoundation.prototype.getRows = function() {
return this.adapter_.getRowElements();
};
/**
* Sets selected row ids. Overwrites previously selected rows.
* @param rowIds Array of row ids that needs to be selected.
*/
MDCDataTableFoundation.prototype.setSelectedRowIds = function(rowIds) {
for (var rowIndex = 0; rowIndex < this.adapter_.getRowCount(); rowIndex++) {
var rowId = this.adapter_.getRowIdAtIndex(rowIndex);
var isSelected = false;
if (rowId && rowIds.indexOf(rowId) >= 0) {
isSelected = true;
}
this.adapter_.setRowCheckboxCheckedAtIndex(rowIndex, isSelected);
this.selectRowAtIndex_(rowIndex, isSelected);
}
this.setHeaderRowCheckboxState_();
};
/**
* @return Returns array of selected row ids.
*/
MDCDataTableFoundation.prototype.getSelectedRowIds = function() {
var selectedRowIds = [];
for (var rowIndex = 0; rowIndex < this.adapter_.getRowCount(); rowIndex++) {
if (this.adapter_.isCheckboxAtRowIndexChecked(rowIndex)) {
selectedRowIds.push(this.adapter_.getRowIdAtIndex(rowIndex));
}
}
return selectedRowIds;
};
/**
* Handles header row checkbox change event.
*/
MDCDataTableFoundation.prototype.handleHeaderRowCheckboxChange = function() {
var isHeaderChecked = this.adapter_.isHeaderRowCheckboxChecked();
for (var rowIndex = 0; rowIndex < this.adapter_.getRowCount(); rowIndex++) {
this.adapter_.setRowCheckboxCheckedAtIndex(rowIndex, isHeaderChecked);
this.selectRowAtIndex_(rowIndex, isHeaderChecked);
}
if (isHeaderChecked) {
this.adapter_.notifySelectedAll();
} else {
this.adapter_.notifyUnselectedAll();
}
};
/**
* Handles change event originated from row checkboxes.
*/
MDCDataTableFoundation.prototype.handleRowCheckboxChange = function(event) {
var rowIndex = this.adapter_.getRowIndexByChildElement(event.target);
if (rowIndex === -1) {
return;
}
var selected = this.adapter_.isCheckboxAtRowIndexChecked(rowIndex);
this.selectRowAtIndex_(rowIndex, selected);
this.setHeaderRowCheckboxState_();
var rowId = this.adapter_.getRowIdAtIndex(rowIndex);
this.adapter_.notifyRowSelectionChanged({
rowId: rowId,
rowIndex: rowIndex,
selected: selected,
});
};
/**
* Updates header row checkbox state based on number of rows selected.
*/
MDCDataTableFoundation.prototype.setHeaderRowCheckboxState_ = function() {
if (this.adapter_.getSelectedRowCount() === this.adapter_.getRowCount()) {
this.adapter_.setHeaderRowCheckboxChecked(true);
this.adapter_.setHeaderRowCheckboxIndeterminate(false);
} else if (this.adapter_.getSelectedRowCount() === 0) {
this.adapter_.setHeaderRowCheckboxIndeterminate(false);
this.adapter_.setHeaderRowCheckboxChecked(false);
} else {
this.adapter_.setHeaderRowCheckboxIndeterminate(true);
this.adapter_.setHeaderRowCheckboxChecked(false);
}
};
/**
* Sets the attributes of row element based on selection state.
*/
MDCDataTableFoundation.prototype.selectRowAtIndex_ = function(
rowIndex,
selected
) {
if (selected) {
this.adapter_.addClassAtRowIndex(rowIndex, cssClasses.ROW_SELECTED);
this.adapter_.setAttributeAtRowIndex(
rowIndex,
strings.ARIA_SELECTED,
"true"
);
} else {
this.adapter_.removeClassAtRowIndex(rowIndex, cssClasses.ROW_SELECTED);
this.adapter_.setAttributeAtRowIndex(
rowIndex,
strings.ARIA_SELECTED,
"false"
);
}
};
return MDCDataTableFoundation;
})(MDCFoundation);
export { MDCDataTableFoundation };
//# sourceMappingURL=foundation.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"foundation.js","sourceRoot":"","sources":["foundation.ts"],"names":[],"mappings":"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"}

View File

@ -1,199 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import { MDCFoundation } from "@material/base/foundation";
import { MDCDataTableAdapter } from "./adapter";
import { cssClasses, strings } from "./constants";
export class MDCDataTableFoundation extends MDCFoundation<MDCDataTableAdapter> {
static get defaultAdapter(): MDCDataTableAdapter {
return {
addClassAtRowIndex: () => undefined,
getRowCount: () => 0,
getRowElements: () => [],
getRowIdAtIndex: () => "",
getRowIndexByChildElement: () => 0,
getSelectedRowCount: () => 0,
isCheckboxAtRowIndexChecked: () => false,
isHeaderRowCheckboxChecked: () => false,
isRowsSelectable: () => false,
notifyRowSelectionChanged: () => undefined,
notifySelectedAll: () => undefined,
notifyUnselectedAll: () => undefined,
registerHeaderRowCheckbox: () => undefined,
registerRowCheckboxes: () => undefined,
removeClassAtRowIndex: () => undefined,
setAttributeAtRowIndex: () => undefined,
setHeaderRowCheckboxChecked: () => undefined,
setHeaderRowCheckboxIndeterminate: () => undefined,
setRowCheckboxCheckedAtIndex: () => undefined,
};
}
constructor(adapter?: Partial<MDCDataTableAdapter>) {
super({ ...MDCDataTableFoundation.defaultAdapter, ...adapter });
}
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
* Use this if registering checkbox is synchronous.
*/
layout() {
if (this.adapter_.isRowsSelectable()) {
this.adapter_.registerHeaderRowCheckbox();
this.adapter_.registerRowCheckboxes();
this.setHeaderRowCheckboxState_();
}
}
/**
* Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
* Use this if registering checkbox is asynchronous.
*/
async layoutAsync(): Promise<void> {
if (this.adapter_.isRowsSelectable()) {
await this.adapter_.registerHeaderRowCheckbox();
await this.adapter_.registerRowCheckboxes();
this.setHeaderRowCheckboxState_();
}
}
/**
* @return Returns array of row elements.
*/
getRows(): Element[] {
return this.adapter_.getRowElements();
}
/**
* Sets selected row ids. Overwrites previously selected rows.
* @param rowIds Array of row ids that needs to be selected.
*/
setSelectedRowIds(rowIds: string[]) {
for (let rowIndex = 0; rowIndex < this.adapter_.getRowCount(); rowIndex++) {
const rowId = this.adapter_.getRowIdAtIndex(rowIndex);
let isSelected = false;
if (rowId && rowIds.indexOf(rowId) >= 0) {
isSelected = true;
}
this.adapter_.setRowCheckboxCheckedAtIndex(rowIndex, isSelected);
this.selectRowAtIndex_(rowIndex, isSelected);
}
this.setHeaderRowCheckboxState_();
}
/**
* @return Returns array of selected row ids.
*/
getSelectedRowIds(): Array<string | null> {
const selectedRowIds: Array<string | null> = [];
for (let rowIndex = 0; rowIndex < this.adapter_.getRowCount(); rowIndex++) {
if (this.adapter_.isCheckboxAtRowIndexChecked(rowIndex)) {
selectedRowIds.push(this.adapter_.getRowIdAtIndex(rowIndex));
}
}
return selectedRowIds;
}
/**
* Handles header row checkbox change event.
*/
handleHeaderRowCheckboxChange() {
const isHeaderChecked = this.adapter_.isHeaderRowCheckboxChecked();
for (let rowIndex = 0; rowIndex < this.adapter_.getRowCount(); rowIndex++) {
this.adapter_.setRowCheckboxCheckedAtIndex(rowIndex, isHeaderChecked);
this.selectRowAtIndex_(rowIndex, isHeaderChecked);
}
if (isHeaderChecked) {
this.adapter_.notifySelectedAll();
} else {
this.adapter_.notifyUnselectedAll();
}
}
/**
* Handles change event originated from row checkboxes.
*/
handleRowCheckboxChange(event: Event) {
const rowIndex = this.adapter_.getRowIndexByChildElement(
event.target as HTMLInputElement
);
if (rowIndex === -1) {
return;
}
const selected = this.adapter_.isCheckboxAtRowIndexChecked(rowIndex);
this.selectRowAtIndex_(rowIndex, selected);
this.setHeaderRowCheckboxState_();
const rowId = this.adapter_.getRowIdAtIndex(rowIndex);
this.adapter_.notifyRowSelectionChanged({ rowId, rowIndex, selected });
}
/**
* Updates header row checkbox state based on number of rows selected.
*/
private setHeaderRowCheckboxState_() {
if (this.adapter_.getSelectedRowCount() === this.adapter_.getRowCount()) {
this.adapter_.setHeaderRowCheckboxChecked(true);
this.adapter_.setHeaderRowCheckboxIndeterminate(false);
} else if (this.adapter_.getSelectedRowCount() === 0) {
this.adapter_.setHeaderRowCheckboxIndeterminate(false);
this.adapter_.setHeaderRowCheckboxChecked(false);
} else {
this.adapter_.setHeaderRowCheckboxIndeterminate(true);
this.adapter_.setHeaderRowCheckboxChecked(false);
}
}
/**
* Sets the attributes of row element based on selection state.
*/
private selectRowAtIndex_(rowIndex: number, selected: boolean) {
if (selected) {
this.adapter_.addClassAtRowIndex(rowIndex, cssClasses.ROW_SELECTED);
this.adapter_.setAttributeAtRowIndex(
rowIndex,
strings.ARIA_SELECTED,
"true"
);
} else {
this.adapter_.removeClassAtRowIndex(rowIndex, cssClasses.ROW_SELECTED);
this.adapter_.setAttributeAtRowIndex(
rowIndex,
strings.ARIA_SELECTED,
"false"
);
}
}
}

View File

@ -1,27 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
export * from "./adapter";
export * from "./component";
export * from "./foundation";
export * from "./constants";
export * from "./types";

View File

@ -1,26 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
export * from "./component";
export * from "./foundation";
export * from "./constants";
//# sourceMappingURL=index.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}

View File

@ -1,28 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
export * from "./adapter";
export * from "./component";
export * from "./foundation";
export * from "./constants";
export * from "./types";

View File

@ -1,25 +0,0 @@
//
// Copyright 2019 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
@import "./mixins";
@include mdc-data-table-core-styles;
@include mdc-data-table-theme-baseline;

View File

@ -1,37 +0,0 @@
{
"name": "@material/data-table",
"version": "3.1.1",
"description": "The Material Components Web data table component",
"license": "MIT",
"keywords": [
"material components",
"material design",
"data table"
],
"main": "dist/mdc.dataTable.js",
"module": "index.js",
"sideEffects": false,
"types": "dist/mdc.dataTable.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/material-components/material-components-web.git"
},
"dependencies": {
"@material/animation": "^3.1.0",
"@material/base": "^3.1.0",
"@material/checkbox": "^3.1.0",
"@material/dom": "^3.1.0",
"@material/elevation": "^3.1.0",
"@material/feature-targeting": "^3.1.0",
"@material/ripple": "^3.1.0",
"@material/rtl": "^3.1.0",
"@material/shape": "^3.1.0",
"@material/theme": "^3.1.0",
"@material/typography": "^3.1.0",
"tslib": "^1.10.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4a7d0aa41afb294e54c4aeae56558b1793416074"
}

View File

@ -1,27 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
export interface MDCDataTableRowSelectionChangedEventDetail {
rowIndex: number;
rowId: string | null;
selected: boolean;
}

View File

@ -1,23 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
//# sourceMappingURL=types.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG"}

View File

@ -1,28 +0,0 @@
/**
* @license
* Copyright 2019 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
export interface MDCDataTableRowSelectionChangedEventDetail {
rowIndex: number;
rowId: string | null;
selected: boolean;
}

View File

@ -4,7 +4,7 @@ import deepClone from "deep-clone-simple";
import {
MDCDataTableAdapter,
MDCDataTableFoundation,
} from "../../../mdc-data-table/index"; // Because mdc-data-table published ts files, temporary load them from own repo, outside src so our linters won't complain
} from "@material/data-table";
import {
BaseElement,