npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mat-row-keyboard-selection

v1.3.0

Published

A very simple directive that allows Focus MatRow and toogle SelectionModel using keyboard TAB, arrows Up, Down, Enter and Space.

Downloads

46

Readme

MatRowKeyboardSelectionDirective

GitHub issues GitHub stars GitHub license

Demo

https://douglasgsouza.github.io/mat-row-keyboard-selection/

Table of contents

About

This is a simple directive that allows navigate Angular Material Data Table with keyboard. This allow Focus MatRow and toogle SelectionModel using keyboard TAB, arrows Up, Down, Enter and Space.

Made with :heart: in Brazil.

Getting Started

Installing and Importing

Install the package by command:

    npm install mat-row-keyboard-selection --save

Import the module

import { MatRowKeyboardSelectionModule } from "mat-row-keyboard-selection";

@NgModule({
    imports: [
        ...
        MatRowKeyboardSelectionModule
    ],
    declarations: [...],
    providers: [...]
})
export class AppModule {}

or import only Directive

import { MatRowKeyboardSelectionDirective } from "mat-row-keyboard-selection";

@NgModule({
    declarations: [MatRowKeyboardSelectionDirective],
})
export class YourModule {}

Using

With <table mat-table>

    <table mat-table [dataSource]="dataSource1">
    ....
    <tr mat-row [matRowKeyboardSelection]="selectionModel" [rowModel]="row" *matRowDef="let row; columns: displayedColumns;"></tr>

With <mat-table>

    <table mat-table [dataSource]="dataSource1">
    ....
    <mat-row [matRowKeyboardSelection]="selectionModel" [rowModel]="row" *matRowDef="let row; columns: displayedColumns;"></mat-row>

Keyboard Keys:

  • Tab - Focus a row or next element (follow the native tabindex).
  • Space and Enter - When row focused, toggle row. (Can be disabled with option toggleOnEnter = false)
  • Arrow Down - Move focus to next row.
  • Arrow Up - Move focus to previous row.

Case selectOnFocus is True model is selected when row is focused.

Options

You can set options...

    <tr mat-row [matRowKeyboardSelection]="selectionModel" [rowModel]="row" [selectOnFocus]="true" [deselectOnBlur]="true" *matRowDef="let row; columns: displayedColumns;"></tr>

Available options:

  • selectOnFocus - Automatic select on row focus. (default: false)
    • If you have other row selection behaviors such as select on click or checkbox selection I recommend not enable this option and let your component decide when to make selection.
  • deselectOnBlur - Automatic deselect on row blur. (default: false)
  • toggleOnEnter - Toggle Row on press Enter or Space. (default: true)
  • preventNewSelectionOnTab - Prevent next row Focus on Tab. (default: false)

Dependencies

  • Angular Core
  • Angular Material (MatTable, MatTableDataSource, MatRow)
  • Angular CDK Collections (SelectionModel)

Tested and made with on Angular 7.3.

License

MIT @ Douglas Gomes de Souza