<commit_before># table-select

Allows you to select table row elements like in your standard finder environment.
Built in support `ctrl`, `shift`, enter and the arrow keys.

Demo

## Quick Start

```html
<script src="table-select.min.js"></script>

<script>
  new TableSelect(document.getElementById('table-id'));
</script>
```

## Browser Support

`table-select` expects `classList` to be supported. For this to work on older versions of
IE, use [a shim](https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills#classlist).

| <img src="http://i.imgur.com/dJC1GUv.png" width="48px" height="48px" alt="Chrome logo"> | <img src="http://i.imgur.com/o1m5RcQ.png" width="48px" height="48px" alt="Firefox logo"> | <img src="http://i.imgur.com/8h3iz5H.png" width="48px" height="48px" alt="Internet Explorer logo"> | <img src="http://i.imgur.com/iQV4nmJ.png" width="48px" height="48px" alt="Opera logo"> | <img src="http://i.imgur.com/j3tgNKJ.png" width="48px" height="48px" alt="Safari logo"> |
|:---:|:---:|:---:|:---:|:---:|
| 8+ ✔ | 3.6+ ✔ | 10+ ✔ | 11.50+ ✔ | 5.1+ ✔ |

## Additional options

You can pass in options as a second parameter. The currently supported options are:

* `className`: The class name of the table. Default: `'selectable'`.
* `tabIndex`: The tab index of the table. Default: `1.
* `selectedClassName`: The class name of a selected row. Default: `'selected'`.
* `shouldSelectRow(row)`: Function that determines whether `row` is selectable. 
Default: All rows can be selected.
* `shouldDeselectRow(row)`: Function that determines whether `row` is deselectable.
Default: All rows can be deselected.

```js
new TableSelect(document.getElementById('table-id'), {
  selectedClassName: 'highlighted',
  shouldSelectRow(row) { return !row.classList.contains('unselectable'); },
});
```

### Events

`table-select` supports five custom events:

* `beforeSelect`
* `afterSelect`
* `beforeDeselect`
* `afterDeselect`
* `action`

Specifc information of the event can be found in `event.detail`, e.g.:
<commit_msg>extended readme<commit_after># table-select

Allows you to select table row elements like in your standard finder environment.
Built in support `ctrl`, `shift`, enter and the arrow keys.

Demo

## Quick Start

```html
<script src="table-select.min.js"></script>

<script>
  new TableSelect(document.getElementById('table-id'));
</script>
```

## Browser Support

`table-select` expects `classList` to be supported. For this to work on older versions of
IE, use [a shim](https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills#classlist).

| <img src="http://i.imgur.com/dJC1GUv.png" width="48px" height="48px" alt="Chrome logo"> | <img src="http://i.imgur.com/o1m5RcQ.png" width="48px" height="48px" alt="Firefox logo"> | <img src="http://i.imgur.com/8h3iz5H.png" width="48px" height="48px" alt="Internet Explorer logo"> | <img src="http://i.imgur.com/iQV4nmJ.png" width="48px" height="48px" alt="Opera logo"> | <img src="http://i.imgur.com/j3tgNKJ.png" width="48px" height="48px" alt="Safari logo"> |
|:---:|:---:|:---:|:---:|:---:|
| 8+ ✔ | 3.6+ ✔ | 10+ ✔ | 11.50+ ✔ | 5.1+ ✔ |

## Additional options

You can pass in options as a second parameter. The currently supported options are:

* `className`: The class name of the table. Default: `'selectable'`.
* `tabIndex`: The tab index of the table. Default: `1.
* `selectedClassName`: The class name of a selected row. Default: `'selected'`.
* `shouldSelectRow(row)`: Function that determines whether `row` is selectable. 
Default: All rows can be selected.
* `shouldDeselectRow(row)`: Function that determines whether `row` is deselectable.
Default: All rows can be deselected.

```js
new TableSelect(document.getElementById('table-id'), {
  selectedClassName: 'highlighted',
  shouldSelectRow(row) { return !row.classList.contains('unselectable'); },
});
```

You can configure the default options by setting them via:

```js
import { setDefaultOptions} from 'table-select';

setDefaultOptions({
  ...
});
```

### Events

`table-select` supports five custom events:

* `beforeSelect`
* `afterSelect`
* `beforeDeselect`
* `afterDeselect`
* `action`

Specifc information of the event can be found in `event.detail`, e.g.:

{'fraction_non_alphanumeric': 0.17182699125502246, 'fraction_numerical': 0.019380761049397306, 'mean_word_length': 4.885952712100139, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4748985', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1429, 'n_words': 413}